Fix app uninstalling/stopping possible in screen pinning mode
Bug: 135604684 Test: maunal & robotest Change-Id: I96eddb11ff32c6c46915682eb58857be7d24ed99
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.settings.applications.appinfo;
|
||||
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.BroadcastReceiver;
|
||||
@@ -182,6 +183,10 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
super.onCreate(icicle);
|
||||
mFinishing = false;
|
||||
final Activity activity = getActivity();
|
||||
if (isLockTaskModePinned(activity)) {
|
||||
finishActivity(activity);
|
||||
return;
|
||||
}
|
||||
mDpm = (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||
mUserManager = (UserManager) activity.getSystemService(Context.USER_SERVICE);
|
||||
mPm = activity.getPackageManager();
|
||||
@@ -192,7 +197,6 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
return;
|
||||
}
|
||||
startListeningToPackageRemove();
|
||||
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@@ -314,9 +318,8 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
@VisibleForTesting
|
||||
boolean ensurePackageInfoAvailable(Activity activity) {
|
||||
if (mPackageInfo == null) {
|
||||
mFinishing = true;
|
||||
Log.w(TAG, "Package info not available. Is this package already uninstalled?");
|
||||
activity.finishAndRemoveTask();
|
||||
finishActivity(activity);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -331,14 +334,28 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
@VisibleForTesting
|
||||
boolean ensureDisplayableModule(Activity activity) {
|
||||
if (AppUtils.isHiddenSystemModule(activity.getApplicationContext(), mPackageName)) {
|
||||
mFinishing = true;
|
||||
Log.w(TAG, "Package is hidden module, exiting: " + mPackageName);
|
||||
activity.finishAndRemoveTask();
|
||||
finishActivity(activity);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the state of device lock task mode.
|
||||
*
|
||||
* @return true if the device lock task mode pinned.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
boolean isLockTaskModePinned(Activity activity) {
|
||||
ActivityManager activityManager = activity.getSystemService(ActivityManager.class);
|
||||
if (activityManager.getLockTaskModeState() == ActivityManager.LOCK_TASK_MODE_PINNED) {
|
||||
Log.w(TAG, "Device lock task mode pinned.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
@@ -637,6 +654,11 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
getContext().unregisterReceiver(mPackageRemovedReceiver);
|
||||
}
|
||||
|
||||
private void finishActivity(Activity activity) {
|
||||
mFinishing = true;
|
||||
activity.finishAndRemoveTask();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
final BroadcastReceiver mPackageRemovedReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user