From 20c5812a65f16b43f8eba2471493b8f9e4f95d1e Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Tue, 21 Feb 2017 17:49:12 -0800 Subject: [PATCH] Add logging to trace when force stop button is clicked Bug: 35633637 Test: manual Change-Id: If7bcf7a3265d1eb75b7f58337f4757dfcbb0ba2f --- .../settings/applications/InstalledAppDetails.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java index 441a02ea216..0be4d9e8614 100755 --- a/src/com/android/settings/applications/InstalledAppDetails.java +++ b/src/com/android/settings/applications/InstalledAppDetails.java @@ -760,6 +760,7 @@ public class InstalledAppDetails extends AppInfoBase MetricsEvent.ACTION_APP_FORCE_STOP, pkgName); ActivityManager am = (ActivityManager) getActivity().getSystemService( Context.ACTIVITY_SERVICE); + Log.d(LOG_TAG, "Stopping package " + pkgName); am.forceStopPackage(pkgName); int userId = UserHandle.getUserId(mAppEntry.info.uid); mState.invalidatePackage(pkgName, userId); @@ -782,10 +783,12 @@ public class InstalledAppDetails extends AppInfoBase private void checkForceStop() { if (mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) { // User can't force stop device admin. + Log.w(LOG_TAG, "User can't force stop device admin"); updateForceStopButton(false); - } else if ((mAppEntry.info.flags&ApplicationInfo.FLAG_STOPPED) == 0) { + } else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_STOPPED) == 0) { // If the app isn't explicitly stopped, then always show the // force stop button. + Log.w(LOG_TAG, "App is not explicitly stopped"); updateForceStopButton(true); } else { Intent intent = new Intent(Intent.ACTION_QUERY_PACKAGE_RESTART, @@ -793,6 +796,8 @@ public class InstalledAppDetails extends AppInfoBase intent.putExtra(Intent.EXTRA_PACKAGES, new String[] { mAppEntry.info.packageName }); intent.putExtra(Intent.EXTRA_UID, mAppEntry.info.uid); intent.putExtra(Intent.EXTRA_USER_HANDLE, UserHandle.getUserId(mAppEntry.info.uid)); + Log.d(LOG_TAG, "Sending broadcast to query restart status for " + + mAppEntry.info.packageName); getActivity().sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, null, mCheckKillProcessesReceiver, null, Activity.RESULT_CANCELED, null, null); } @@ -1302,7 +1307,10 @@ public class InstalledAppDetails extends AppInfoBase private final BroadcastReceiver mCheckKillProcessesReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - updateForceStopButton(getResultCode() != Activity.RESULT_CANCELED); + final boolean enabled = getResultCode() != Activity.RESULT_CANCELED; + Log.d(LOG_TAG, "Got broadcast response: Restart status for " + + mAppEntry.info.packageName + " " + enabled); + updateForceStopButton(enabled); } };