Merge "Add logging to trace when force stop button is clicked"

This commit is contained in:
TreeHugger Robot
2017-02-22 03:59:34 +00:00
committed by Android (Google) Code Review

View File

@@ -760,6 +760,7 @@ public class InstalledAppDetails extends AppInfoBase
MetricsEvent.ACTION_APP_FORCE_STOP, pkgName); MetricsEvent.ACTION_APP_FORCE_STOP, pkgName);
ActivityManager am = (ActivityManager) getActivity().getSystemService( ActivityManager am = (ActivityManager) getActivity().getSystemService(
Context.ACTIVITY_SERVICE); Context.ACTIVITY_SERVICE);
Log.d(LOG_TAG, "Stopping package " + pkgName);
am.forceStopPackage(pkgName); am.forceStopPackage(pkgName);
int userId = UserHandle.getUserId(mAppEntry.info.uid); int userId = UserHandle.getUserId(mAppEntry.info.uid);
mState.invalidatePackage(pkgName, userId); mState.invalidatePackage(pkgName, userId);
@@ -782,10 +783,12 @@ public class InstalledAppDetails extends AppInfoBase
private void checkForceStop() { private void checkForceStop() {
if (mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) { if (mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) {
// User can't force stop device admin. // User can't force stop device admin.
Log.w(LOG_TAG, "User can't force stop device admin");
updateForceStopButton(false); 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 // If the app isn't explicitly stopped, then always show the
// force stop button. // force stop button.
Log.w(LOG_TAG, "App is not explicitly stopped");
updateForceStopButton(true); updateForceStopButton(true);
} else { } else {
Intent intent = new Intent(Intent.ACTION_QUERY_PACKAGE_RESTART, 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_PACKAGES, new String[] { mAppEntry.info.packageName });
intent.putExtra(Intent.EXTRA_UID, mAppEntry.info.uid); intent.putExtra(Intent.EXTRA_UID, mAppEntry.info.uid);
intent.putExtra(Intent.EXTRA_USER_HANDLE, UserHandle.getUserId(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, getActivity().sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, null,
mCheckKillProcessesReceiver, null, Activity.RESULT_CANCELED, null, null); mCheckKillProcessesReceiver, null, Activity.RESULT_CANCELED, null, null);
} }
@@ -1302,7 +1307,10 @@ public class InstalledAppDetails extends AppInfoBase
private final BroadcastReceiver mCheckKillProcessesReceiver = new BroadcastReceiver() { private final BroadcastReceiver mCheckKillProcessesReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { 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);
} }
}; };