From 43ed2d7bcdae9976ae45ce07e6680b71cb2643bb Mon Sep 17 00:00:00 2001 From: Sarbyn Date: Mon, 14 Oct 2013 14:08:27 +0200 Subject: [PATCH 1/8] Create README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000000000..d7627c7c0bc69 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +android_frameworks_base +======================= + +Android base frameworks (cyanogenmod) by Sarbyn From 9efe7211245cb92b592696fa97d06f33824f025c Mon Sep 17 00:00:00 2001 From: sarbyn Date: Wed, 16 Oct 2013 16:33:49 +0200 Subject: [PATCH 2/8] first commit Change-Id: If6db94ee4b14ce71df2e627edd533a0b92c7a2ea --- packages/SystemUI/res/menu/notification_popup_menu.xml | 9 ++++++++- .../com/android/systemui/statusbar/BaseStatusBar.java | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/res/menu/notification_popup_menu.xml b/packages/SystemUI/res/menu/notification_popup_menu.xml index 8923fb67ff0e2..6b837aa1aaee5 100644 --- a/packages/SystemUI/res/menu/notification_popup_menu.xml +++ b/packages/SystemUI/res/menu/notification_popup_menu.xml @@ -18,5 +18,12 @@ */ --> - + + + + diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 84b2322d6f112..6dec4ab346ff7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -331,8 +331,10 @@ public boolean onMenuItemClick(MenuItem item) { if (item.getItemId() == R.id.notification_inspect_item) { startApplicationDetailsActivity(packageNameF); animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE); + } else if (item.getItemId() == R.id.notification_inspect_item_kill_app){ + } else if (item.getItemId() == R.id.notification_inspect_item_wipe_app){ } else { - return false; + return false; } return true; } From a5db8e27f7a1d17bdc7afd7ad700b4569827b453 Mon Sep 17 00:00:00 2001 From: sarbyn Date: Mon, 21 Oct 2013 16:56:49 +0200 Subject: [PATCH 3/8] First working prototype Change-Id: Ic94b863951a387a64b741fea26630199647cdc8d --- packages/SystemUI/AndroidManifest.xml | 4 +++ .../res/menu/notification_popup_menu.xml | 2 -- .../systemui/statusbar/BaseStatusBar.java | 25 ++++++++++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index 2d6e1d6c81f5d..3587f48d429b5 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -59,6 +59,10 @@ + + + + - Date: Mon, 28 Oct 2013 23:44:37 +0100 Subject: [PATCH 4/8] add new menu to recent panel view Change-Id: Ie80c434945c8f2fb0878b4921d19fb0dd6473556 --- .../SystemUI/res/menu/recent_popup_menu.xml | 4 +++ .../systemui/recent/RecentsPanelView.java | 35 +++++++++++++++++++ .../systemui/statusbar/BaseStatusBar.java | 3 -- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/res/menu/recent_popup_menu.xml b/packages/SystemUI/res/menu/recent_popup_menu.xml index eecfb9ab7fbe9..7c0617b2a4be0 100644 --- a/packages/SystemUI/res/menu/recent_popup_menu.xml +++ b/packages/SystemUI/res/menu/recent_popup_menu.xml @@ -20,4 +20,8 @@ + + diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java index 5cbb75d19c477..345e44d6afcee 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java @@ -21,8 +21,10 @@ import android.app.ActivityManager; import android.app.ActivityManagerNative; import android.app.ActivityOptions; +import android.content.ContentResolver; import android.content.Context; import android.content.Intent; +import android.content.pm.IPackageDataObserver; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; @@ -882,6 +884,14 @@ public void handleLongPress( new PopupMenu(mContext, anchorView == null ? selectedView : anchorView); mPopup = popup; popup.getMenuInflater().inflate(R.menu.recent_popup_menu, popup.getMenu()); + + final ContentResolver cr = mContext.getContentResolver(); + if(Settings.Secure.getInt(cr, + Settings.Secure.DEVELOPMENT_SETTINGS_ENABLED, 0) == 0) { + popup.getMenu().findItem(R.id.recent_kill_app).setVisible(false); + popup.getMenu().findItem(R.id.recent_wipe_app).setVisible(false); + } + popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { if (item.getItemId() == R.id.recent_remove_item) { @@ -895,6 +905,26 @@ public boolean onMenuItemClick(MenuItem item) { } else { throw new IllegalStateException("Oops, no tag on view " + selectedView); } + } else if (item.getItemId() == R.id.recent_kill_app){ + ViewHolder viewHolder = (ViewHolder) selectedView.getTag(); + if (viewHolder != null) { + final TaskDescription ad = viewHolder.taskDescription; + ActivityManager am = (ActivityManager)mContext.getSystemService( + Context.ACTIVITY_SERVICE); + am.forceStopPackage(ad.packageName); + } else { + throw new IllegalStateException("Oops, no tag on view " + selectedView); + } + } else if (item.getItemId() == R.id.recent_wipe_app){ + ViewHolder viewHolder = (ViewHolder) selectedView.getTag(); + if (viewHolder != null) { + final TaskDescription ad = viewHolder.taskDescription; + ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); + am.clearApplicationUserData(ad.packageName, new FakeClearUserDataObserver()); + } else { + throw new IllegalStateException("Oops, no tag on view " + selectedView); + } + } else { return false; } @@ -909,4 +939,9 @@ public void onDismiss(PopupMenu menu) { }); popup.show(); } + + class FakeClearUserDataObserver extends IPackageDataObserver.Stub { + public void onRemoveCompleted(final String packageName, final boolean succeeded) { + } + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index e409473b7a188..f87537d4dbbde 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -363,9 +363,6 @@ public boolean onMenuItemClick(MenuItem item) { class FakeClearUserDataObserver extends IPackageDataObserver.Stub { public void onRemoveCompleted(final String packageName, final boolean succeeded) { -// final Message msg = mHandler.obtainMessage(CLEAR_USER_DATA); -// msg.arg1 = succeeded?OP_SUCCESSFUL:OP_FAILED; -// mHandler.sendMessage(msg); } } From ceeedf34455ccea324f58ed55e05fae6a37eab38 Mon Sep 17 00:00:00 2001 From: sarbyn Date: Tue, 29 Oct 2013 08:19:50 +0100 Subject: [PATCH 5/8] fix i18n strings and code formatting Change-Id: Ic09a222b4083dcc7a898dbb58e8412a6176ce391 --- .../res/menu/notification_popup_menu.xml | 5 +- .../SystemUI/res/menu/recent_popup_menu.xml | 7 +- .../SystemUI/res/values-en-rGB/strings.xml | 2 + packages/SystemUI/res/values-it/strings.xml | 2 + .../systemui/recent/RecentsPanelView.java | 2 +- .../systemui/statusbar/BaseStatusBar.java | 366 ++++++++++-------- 6 files changed, 220 insertions(+), 164 deletions(-) diff --git a/packages/SystemUI/res/menu/notification_popup_menu.xml b/packages/SystemUI/res/menu/notification_popup_menu.xml index 66f0547daf8b8..6b7100d446a0e 100644 --- a/packages/SystemUI/res/menu/notification_popup_menu.xml +++ b/packages/SystemUI/res/menu/notification_popup_menu.xml @@ -21,7 +21,8 @@ + android:title="@string/advanced_dev_option_force_stop" /> + android:title="@string/advanced_dev_option_wipe_app" /> + diff --git a/packages/SystemUI/res/menu/recent_popup_menu.xml b/packages/SystemUI/res/menu/recent_popup_menu.xml index 7c0617b2a4be0..57cc5bb444842 100644 --- a/packages/SystemUI/res/menu/recent_popup_menu.xml +++ b/packages/SystemUI/res/menu/recent_popup_menu.xml @@ -20,8 +20,7 @@ - - + + + diff --git a/packages/SystemUI/res/values-en-rGB/strings.xml b/packages/SystemUI/res/values-en-rGB/strings.xml index f02d09ca23a4a..53e7b3063fa61 100644 --- a/packages/SystemUI/res/values-en-rGB/strings.xml +++ b/packages/SystemUI/res/values-en-rGB/strings.xml @@ -140,6 +140,8 @@ "Clear all notifications." "Activate screen saver" "App info" + "Wipe app data" + "Force stop" "Notifications off" "Tap here to turn notifications back on." "Screen will rotate automatically." diff --git a/packages/SystemUI/res/values-it/strings.xml b/packages/SystemUI/res/values-it/strings.xml index 8cf53a8660b58..7e7ffc2e090ae 100644 --- a/packages/SystemUI/res/values-it/strings.xml +++ b/packages/SystemUI/res/values-it/strings.xml @@ -146,6 +146,8 @@ "Cancella tutte le notifiche." "Attiva screensaver" "Informazioni applicazione" + "Cancella dati applicazioni" + "Arresto forzato" "Notifiche disattivate" "Tocca qui per riattivare le notifiche." "Lo schermo ruoterà automaticamente." diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java index 345e44d6afcee..2587e8f8e7a93 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java @@ -889,7 +889,7 @@ public void handleLongPress( if(Settings.Secure.getInt(cr, Settings.Secure.DEVELOPMENT_SETTINGS_ENABLED, 0) == 0) { popup.getMenu().findItem(R.id.recent_kill_app).setVisible(false); - popup.getMenu().findItem(R.id.recent_wipe_app).setVisible(false); + popup.getMenu().findItem(R.id.recent_wipe_app).setVisible(false); } popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index f87537d4dbbde..c61a6ac07b2a3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -75,7 +75,7 @@ import com.android.systemui.R; public abstract class BaseStatusBar extends SystemUI implements - CommandQueue.Callbacks, RecentsPanelView.OnRecentsPanelVisibilityChangedListener { + CommandQueue.Callbacks, RecentsPanelView.OnRecentsPanelVisibilityChangedListener { static final String TAG = "StatusBar"; private static final boolean DEBUG = false; @@ -123,8 +123,8 @@ public abstract class BaseStatusBar extends SystemUI implements // UI-specific methods /** - * Create all windows necessary for the status bar (including navigation, overlay panels, etc) - * and add them to the window manager. + * Create all windows necessary for the status bar (including navigation, + * overlay panels, etc) and add them to the window manager. */ protected abstract void createAndAddWindows(); @@ -167,9 +167,12 @@ public boolean onClickHandler(View view, PendingIntent pendingIntent, Intent fil if (isActivity) { try { // The intent we are sending is for the application, which - // won't have permission to immediately start an activity after - // the user switches to home. We know it is safe to do at this - // point, so make sure new activity switches are now allowed. + // won't have permission to immediately start an activity + // after + // the user switches to home. We know it is safe to do at + // this + // point, so make sure new activity switches are now + // allowed. ActivityManagerNative.getDefault().resumeAppSwitches(); // Also, notifications can be launched from the lock screen, // so dismiss the lock screen when the activity starts. @@ -192,7 +195,7 @@ public boolean onClickHandler(View view, PendingIntent pendingIntent, Intent fil private boolean mShowNotificationCounts; public void start() { - mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)) + mDisplay = ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay(); mProvisioningObserver.onChange(false); // set up @@ -231,14 +234,15 @@ public void start() { disable(switches[0]); setSystemUiVisibility(switches[1], 0xffffffff); topAppWindowChanged(switches[2] != 0); - // StatusBarManagerService has a back up of IME token and it's restored here. + // StatusBarManagerService has a back up of IME token and it's restored + // here. setImeWindowStatus(binders.get(0), switches[3], switches[4]); setHardKeyboardStatus(switches[5] != 0, switches[6] != 0); // Set up the initial icon state int N = iconList.size(); int viewIndex = 0; - for (int i=0; i " + notification + ")"); + if (DEBUG) + Slog.d(TAG, "updateNotification(" + key + " -> " + notification + ")"); final NotificationData.Entry oldEntry = mNotificationData.findByKey(key); if (oldEntry == null) { @@ -856,7 +889,8 @@ public void updateNotification(IBinder key, StatusBarNotification notification) final StatusBarNotification oldNotification = oldEntry.notification; - // XXX: modify when we do something more intelligent with the two content views + // XXX: modify when we do something more intelligent with the two + // content views final RemoteViews oldContentView = oldNotification.notification.contentView; final RemoteViews contentView = notification.notification.contentView; final RemoteViews oldBigContentView = oldNotification.notification.bigContentView; @@ -875,7 +909,8 @@ public void updateNotification(IBinder key, StatusBarNotification notification) + " bigContentView=" + bigContentView); } - // Can we just reapply the RemoteViews in place? If when didn't change, the order + // Can we just reapply the RemoteViews in place? If when didn't change, + // the order // didn't change. // 1U is never null @@ -887,22 +922,24 @@ public void updateNotification(IBinder key, StatusBarNotification notification) // large view may be null boolean bigContentsUnchanged = (oldEntry.getLargeView() == null && bigContentView == null) - || ((oldEntry.getLargeView() != null && bigContentView != null) - && bigContentView.getPackage() != null - && oldBigContentView.getPackage() != null - && oldBigContentView.getPackage().equals(bigContentView.getPackage()) - && oldBigContentView.getLayoutId() == bigContentView.getLayoutId()); + || ((oldEntry.getLargeView() != null && bigContentView != null) + && bigContentView.getPackage() != null + && oldBigContentView.getPackage() != null + && oldBigContentView.getPackage().equals( + bigContentView.getPackage()) + && oldBigContentView.getLayoutId() == bigContentView.getLayoutId()); ViewGroup rowParent = (ViewGroup) oldEntry.row.getParent(); - boolean orderUnchanged = notification.notification.when==oldNotification.notification.when + boolean orderUnchanged = notification.notification.when == oldNotification.notification.when && notification.score == oldNotification.score; - // score now encompasses/supersedes isOngoing() + // score now encompasses/supersedes isOngoing() boolean updateTicker = notification.notification.tickerText != null && !TextUtils.equals(notification.notification.tickerText, oldEntry.notification.notification.tickerText); boolean isTopAnyway = isTopNotification(rowParent, oldEntry); if (contentsUnchanged && bigContentsUnchanged && (orderUnchanged || isTopAnyway)) { - if (DEBUG) Slog.d(TAG, "reusing notification for key: " + key); + if (DEBUG) + Slog.d(TAG, "reusing notification for key: " + key); oldEntry.notification = notification; try { // Reapply the RemoteViews @@ -929,18 +966,22 @@ public void updateNotification(IBinder key, StatusBarNotification notification) return; } updateExpansionStates(); - } - catch (RuntimeException e) { - // It failed to add cleanly. Log, and remove the view from the panel. + } catch (RuntimeException e) { + // It failed to add cleanly. Log, and remove the view from the + // panel. Slog.w(TAG, "Couldn't reapply views for package " + contentView.getPackage(), e); removeNotificationViews(key); addNotificationViews(key, notification); } } else { - if (DEBUG) Slog.d(TAG, "not reusing notification for key: " + key); - if (DEBUG) Slog.d(TAG, "contents was " + (contentsUnchanged ? "unchanged" : "changed")); - if (DEBUG) Slog.d(TAG, "order was " + (orderUnchanged ? "unchanged" : "changed")); - if (DEBUG) Slog.d(TAG, "notification is " + (isTopAnyway ? "top" : "not top")); + if (DEBUG) + Slog.d(TAG, "not reusing notification for key: " + key); + if (DEBUG) + Slog.d(TAG, "contents was " + (contentsUnchanged ? "unchanged" : "changed")); + if (DEBUG) + Slog.d(TAG, "order was " + (orderUnchanged ? "unchanged" : "changed")); + if (DEBUG) + Slog.d(TAG, "notification is " + (isTopAnyway ? "top" : "not top")); final boolean wasExpanded = oldEntry.userExpanded(); removeNotificationViews(key); addNotificationViews(key, notification); @@ -951,7 +992,8 @@ public void updateNotification(IBinder key, StatusBarNotification notification) } } - // Update the veto button accordingly (and as a result, whether this row is + // Update the veto button accordingly (and as a result, whether this row + // is // swipe-dismissable) updateNotificationVetoButton(oldEntry.row, notification); @@ -967,27 +1009,37 @@ public void updateNotification(IBinder key, StatusBarNotification notification) // See if we need to update the intruder. if (ENABLE_INTRUDERS && oldNotification == mCurrentlyIntrudingNotification) { - if (DEBUG) Slog.d(TAG, "updating the current intruder:" + notification); - // XXX: this is a hack for Alarms. The real implementation will need to *update* + if (DEBUG) + Slog.d(TAG, "updating the current intruder:" + notification); + // XXX: this is a hack for Alarms. The real implementation will need + // to *update* // the intruder. - if (notification.notification.fullScreenIntent == null) { // TODO(dsandler): consistent logic with add() - if (DEBUG) Slog.d(TAG, "no longer intrudes!"); + if (notification.notification.fullScreenIntent == null) { // TODO(dsandler): + // consistent + // logic + // with + // add() + if (DEBUG) + Slog.d(TAG, "no longer intrudes!"); mHandler.sendEmptyMessage(MSG_HIDE_INTRUDER); } } } // Q: What kinds of notifications should show during setup? - // A: Almost none! Only things coming from the system (package is "android") that also + // A: Almost none! Only things coming from the system (package is "android") + // that also // have special "kind" tags marking them as relevant for setup (see below). protected boolean showNotificationEvenIfUnprovisioned(StatusBarNotification sbn) { if ("android".equals(sbn.pkg)) { if (sbn.notification.kind != null) { for (String aKind : sbn.notification.kind) { // IME switcher, created by InputMethodManagerService - if ("android.system.imeswitcher".equals(aKind)) return true; + if ("android.system.imeswitcher".equals(aKind)) + return true; // OTA availability & errors, created by SystemUpdateService - if ("android.system.update".equals(aKind)) return true; + if ("android.system.update".equals(aKind)) + return true; } } } From 735709ef23f44e57fd9d11bf2f499ea116192189 Mon Sep 17 00:00:00 2001 From: sarbyn Date: Tue, 29 Oct 2013 13:33:31 +0100 Subject: [PATCH 6/8] fix wrong commit Change-Id: I315a93320fb1c5e0e3c6a831bd070a611109523b --- packages/SystemUI/res/menu/notification_popup_menu.xml | 2 +- packages/SystemUI/res/menu/recent_popup_menu.xml | 4 ++-- packages/SystemUI/res/values-en-rGB/strings.xml | 2 -- packages/SystemUI/res/values-it/strings.xml | 4 ++-- packages/SystemUI/res/values/strings.xml | 3 +++ .../src/com/android/systemui/recent/RecentsPanelView.java | 4 ++-- .../src/com/android/systemui/statusbar/BaseStatusBar.java | 4 ++-- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/SystemUI/res/menu/notification_popup_menu.xml b/packages/SystemUI/res/menu/notification_popup_menu.xml index 6b7100d446a0e..50c257c0e7907 100644 --- a/packages/SystemUI/res/menu/notification_popup_menu.xml +++ b/packages/SystemUI/res/menu/notification_popup_menu.xml @@ -20,7 +20,7 @@ - diff --git a/packages/SystemUI/res/menu/recent_popup_menu.xml b/packages/SystemUI/res/menu/recent_popup_menu.xml index 57cc5bb444842..c1a8ae4753c72 100644 --- a/packages/SystemUI/res/menu/recent_popup_menu.xml +++ b/packages/SystemUI/res/menu/recent_popup_menu.xml @@ -20,7 +20,7 @@ - - + + diff --git a/packages/SystemUI/res/values-en-rGB/strings.xml b/packages/SystemUI/res/values-en-rGB/strings.xml index 53e7b3063fa61..f02d09ca23a4a 100644 --- a/packages/SystemUI/res/values-en-rGB/strings.xml +++ b/packages/SystemUI/res/values-en-rGB/strings.xml @@ -140,8 +140,6 @@ "Clear all notifications." "Activate screen saver" "App info" - "Wipe app data" - "Force stop" "Notifications off" "Tap here to turn notifications back on." "Screen will rotate automatically." diff --git a/packages/SystemUI/res/values-it/strings.xml b/packages/SystemUI/res/values-it/strings.xml index 7e7ffc2e090ae..767d5ad24ac43 100644 --- a/packages/SystemUI/res/values-it/strings.xml +++ b/packages/SystemUI/res/values-it/strings.xml @@ -146,8 +146,6 @@ "Cancella tutte le notifiche." "Attiva screensaver" "Informazioni applicazione" - "Cancella dati applicazioni" - "Arresto forzato" "Notifiche disattivate" "Tocca qui per riattivare le notifiche." "Lo schermo ruoterà automaticamente." @@ -163,4 +161,6 @@ Tasto menu (nascondi autom.) Tasto menu (mostra sempre) Tasto menu + "Cancella dati applicazioni" + "Arresto forzato" diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index b4ef23f55cf8a..61416d3d23223 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -425,4 +425,7 @@ Menu (autoHide) button Menu (alwaysShow) button Menu button + + "Wipe app data" + "Force stop" diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java index 2587e8f8e7a93..b7ddf87000f4e 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java @@ -888,7 +888,7 @@ public void handleLongPress( final ContentResolver cr = mContext.getContentResolver(); if(Settings.Secure.getInt(cr, Settings.Secure.DEVELOPMENT_SETTINGS_ENABLED, 0) == 0) { - popup.getMenu().findItem(R.id.recent_kill_app).setVisible(false); + popup.getMenu().findItem(R.id.recent_force_stop).setVisible(false); popup.getMenu().findItem(R.id.recent_wipe_app).setVisible(false); } @@ -905,7 +905,7 @@ public boolean onMenuItemClick(MenuItem item) { } else { throw new IllegalStateException("Oops, no tag on view " + selectedView); } - } else if (item.getItemId() == R.id.recent_kill_app){ + } else if (item.getItemId() == R.id.recent_force_stop){ ViewHolder viewHolder = (ViewHolder) selectedView.getTag(); if (viewHolder != null) { final TaskDescription ad = viewHolder.taskDescription; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index c61a6ac07b2a3..a56421699af99 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -337,7 +337,7 @@ public boolean onLongClick(View v) { if (Settings.Secure.getInt(cr, Settings.Secure.DEVELOPMENT_SETTINGS_ENABLED, 0) == 0) { mNotificationBlamePopup.getMenu() - .findItem(R.id.notification_inspect_item_kill_app).setVisible(false); + .findItem(R.id.notification_inspect_item_force_stop).setVisible(false); mNotificationBlamePopup.getMenu() .findItem(R.id.notification_inspect_item_wipe_app).setVisible(false); } @@ -348,7 +348,7 @@ public boolean onMenuItemClick(MenuItem item) { if (item.getItemId() == R.id.notification_inspect_item) { startApplicationDetailsActivity(packageNameF); animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE); - } else if (item.getItemId() == R.id.notification_inspect_item_kill_app) { + } else if (item.getItemId() == R.id.notification_inspect_item_force_stop) { ActivityManager am = (ActivityManager) mContext .getSystemService( Context.ACTIVITY_SERVICE); From e003fa28448fbc16b2ea9b3878475665a666b2fa Mon Sep 17 00:00:00 2001 From: sarbyn Date: Tue, 29 Oct 2013 16:18:02 +0100 Subject: [PATCH 7/8] final commit - it works Change-Id: Icbe9d9be569ca3f79fe285a13191f41b971b00f2 --- .../src/com/android/systemui/recent/RecentsPanelView.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java index b7ddf87000f4e..5a1c1ea773fd8 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java @@ -912,6 +912,7 @@ public boolean onMenuItemClick(MenuItem item) { ActivityManager am = (ActivityManager)mContext.getSystemService( Context.ACTIVITY_SERVICE); am.forceStopPackage(ad.packageName); + mRecentsContainer.removeViewInLayout(selectedView); } else { throw new IllegalStateException("Oops, no tag on view " + selectedView); } @@ -921,6 +922,7 @@ public boolean onMenuItemClick(MenuItem item) { final TaskDescription ad = viewHolder.taskDescription; ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); am.clearApplicationUserData(ad.packageName, new FakeClearUserDataObserver()); + mRecentsContainer.removeViewInLayout(selectedView); } else { throw new IllegalStateException("Oops, no tag on view " + selectedView); } From 2e07b70ded65c1fb1b18e2546832839ff4bb37bc Mon Sep 17 00:00:00 2001 From: sarbyn Date: Sat, 2 Nov 2013 13:39:10 +0100 Subject: [PATCH 8/8] Disable the 'wipe data' option if the application has FLAG_SYSTEM Change-Id: I667580ee7deab689e4c4f05c1bad77a1b2ab00fb --- .../systemui/recent/RecentsPanelView.java | 29 +++++++++++++++- .../systemui/statusbar/BaseStatusBar.java | 34 ++++++++++++++----- 2 files changed, 53 insertions(+), 10 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java index 5a1c1ea773fd8..06a78ad2e5b4f 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java @@ -21,10 +21,14 @@ import android.app.ActivityManager; import android.app.ActivityManagerNative; import android.app.ActivityOptions; +import android.app.admin.DevicePolicyManager; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; +import android.content.pm.ApplicationInfo; import android.content.pm.IPackageDataObserver; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; @@ -40,6 +44,7 @@ import android.provider.Settings; import android.util.AttributeSet; import android.util.Log; +import android.util.Slog; import android.view.Display; import android.view.KeyEvent; import android.view.IWindowManager; @@ -890,7 +895,29 @@ public void handleLongPress( Settings.Secure.DEVELOPMENT_SETTINGS_ENABLED, 0) == 0) { popup.getMenu().findItem(R.id.recent_force_stop).setVisible(false); popup.getMenu().findItem(R.id.recent_wipe_app).setVisible(false); - } + } else { + ViewHolder viewHolder = (ViewHolder) selectedView.getTag(); + if (viewHolder != null) { + final TaskDescription ad = viewHolder.taskDescription; + try { + PackageManager pm = (PackageManager) mContext.getPackageManager(); + ApplicationInfo mAppInfo = pm.getApplicationInfo(ad.packageName, 0); + DevicePolicyManager mDpm = (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE); + + if ((mAppInfo.flags&(ApplicationInfo.FLAG_SYSTEM + | ApplicationInfo.FLAG_ALLOW_CLEAR_USER_DATA)) + == ApplicationInfo.FLAG_SYSTEM + || mDpm.packageHasActiveAdmins(ad.packageName)) + popup.getMenu() + .findItem(R.id.notification_inspect_item_wipe_app).setEnabled(false); + else + Slog.d(TAG, "Not a 'special' application"); + } catch (NameNotFoundException ex) { + Slog.e(TAG, "Failed looking up ApplicationInfo for " + ad.packageName, ex); + } + } + } + popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index a56421699af99..b17a3537a8e76 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -16,18 +16,17 @@ package com.android.systemui.statusbar; -import java.util.ArrayList; - import android.app.ActivityManager; import android.app.ActivityManagerNative; import android.app.KeyguardManager; -import android.app.Notification; import android.app.PendingIntent; +import android.app.admin.DevicePolicyManager; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.IPackageDataObserver; +import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.database.ContentObserver; import android.graphics.Rect; @@ -55,24 +54,25 @@ import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.RemoteViews; import android.widget.PopupMenu; +import android.widget.RemoteViews; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.statusbar.StatusBarIcon; import com.android.internal.statusbar.StatusBarIconList; import com.android.internal.statusbar.StatusBarNotification; import com.android.internal.widget.SizeAdaptiveLayout; +import com.android.settings.applications.ApplicationsState; +import com.android.systemui.R; import com.android.systemui.SearchPanelView; import com.android.systemui.SystemUI; -import com.android.systemui.recent.RecentsPanelView; import com.android.systemui.recent.RecentTasksLoader; +import com.android.systemui.recent.RecentsPanelView; import com.android.systemui.recent.TaskDescription; -import com.android.systemui.statusbar.CommandQueue; -import com.android.systemui.statusbar.NotificationData.Entry; import com.android.systemui.statusbar.policy.NotificationRowLayout; import com.android.systemui.statusbar.tablet.StatusBarPanel; -import com.android.systemui.R; + +import java.util.ArrayList; public abstract class BaseStatusBar extends SystemUI implements CommandQueue.Callbacks, RecentsPanelView.OnRecentsPanelVisibilityChangedListener { @@ -340,8 +340,24 @@ public boolean onLongClick(View v) { .findItem(R.id.notification_inspect_item_force_stop).setVisible(false); mNotificationBlamePopup.getMenu() .findItem(R.id.notification_inspect_item_wipe_app).setVisible(false); + } else { + try { + PackageManager pm = (PackageManager) mContext.getPackageManager(); + ApplicationInfo mAppInfo = pm.getApplicationInfo(packageNameF, 0); + DevicePolicyManager mDpm = (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE); + + if ((mAppInfo.flags&(ApplicationInfo.FLAG_SYSTEM + | ApplicationInfo.FLAG_ALLOW_CLEAR_USER_DATA)) + == ApplicationInfo.FLAG_SYSTEM + || mDpm.packageHasActiveAdmins(packageNameF)) + mNotificationBlamePopup.getMenu() + .findItem(R.id.notification_inspect_item_wipe_app).setEnabled(false); + + } catch (NameNotFoundException ex) { + Slog.e(TAG, "Failed looking up ApplicationInfo for " + packageNameF, ex); + } } - + mNotificationBlamePopup .setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) {