diff --git a/src/com/android/settings/applications/appinfo/AppButtonsPreferenceController.java b/src/com/android/settings/applications/appinfo/AppButtonsPreferenceController.java index 4387f83a136..ff191ab4476 100644 --- a/src/com/android/settings/applications/appinfo/AppButtonsPreferenceController.java +++ b/src/com/android/settings/applications/appinfo/AppButtonsPreferenceController.java @@ -102,8 +102,6 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp @VisibleForTesting String mPackageName; @VisibleForTesting - boolean mDisableAfterUninstall = false; - @VisibleForTesting ActionButtonsPreference mButtonsPref; private final int mUserId; @@ -124,7 +122,6 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp private PreferenceScreen mScreen; private long mSessionId; - private boolean mUpdatedSysApp = false; private boolean mListeningToPackageRemove = false; private boolean mFinishing = false; private boolean mAppsControlDisallowedBySystem; @@ -197,7 +194,7 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp mActivity, UserManager.DISALLOW_APPS_CONTROL, mUserId); if (!refreshUi()) { - setIntentAndFinish(true, false); + setIntentAndFinish(false); } } } @@ -241,14 +238,7 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp RestrictedLockUtils.sendShowAdminSupportDetailsIntent(mActivity, admin); } else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { if (mAppEntry.info.enabled && !isDisabledUntilUsed()) { - // If the system app has an update and this is the only user on the device, - // then offer to downgrade the app, otherwise only offer to disable the - // app for this user. - if (mUpdatedSysApp && isSingleUser()) { - showDialogInner(ButtonActionDialogFragment.DialogType.SPECIAL_DISABLE); - } else { - showDialogInner(ButtonActionDialogFragment.DialogType.DISABLE); - } + showDialogInner(ButtonActionDialogFragment.DialogType.DISABLE); } else { mMetricsFeatureProvider.action( mActivity, @@ -260,9 +250,9 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp PackageManager.COMPONENT_ENABLED_STATE_DEFAULT)); } } else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_INSTALLED) == 0) { - uninstallPkg(packageName, true, false); + uninstallPkg(packageName, true); } else { - uninstallPkg(packageName, false, false); + uninstallPkg(packageName, false); } } } @@ -292,11 +282,6 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp public void handleActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == mRequestUninstall) { - if (mDisableAfterUninstall) { - mDisableAfterUninstall = false; - AsyncTask.execute(new DisableChangerRunnable(mPm, mAppEntry.info.packageName, - PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER)); - } refreshAndFinishIfPossible(true); } else if (requestCode == mRequestRemoveDeviceAdmin) { refreshAndFinishIfPossible(false); @@ -311,11 +296,6 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp AsyncTask.execute(new DisableChangerRunnable(mPm, mAppEntry.info.packageName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER)); break; - case ButtonActionDialogFragment.DialogType.SPECIAL_DISABLE: - mMetricsFeatureProvider.action(mActivity, - SettingsEnums.ACTION_SETTINGS_DISABLE_APP); - uninstallPkg(mAppEntry.info.packageName, false, true); - break; case ButtonActionDialogFragment.DialogType.FORCE_STOP: forceStopPackage(mAppEntry.info.packageName); break; @@ -493,12 +473,9 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp /** * Finish this fragment and return data if possible */ - private void setIntentAndFinish(boolean appChanged, boolean removeTaskWhenFinishing) { - if (LOCAL_LOGV) { - Log.i(TAG, "appChanged=" + appChanged); - } + private void setIntentAndFinish(boolean removeTaskWhenFinishing) { Intent intent = new Intent(); - intent.putExtra(APP_CHG, appChanged); + intent.putExtra(APP_CHG, true); intent.putExtra(KEY_REMOVE_TASK_WHEN_FINISHING, removeTaskWhenFinishing); mActivity.finishPreferencePanel(Activity.RESULT_OK, intent); mFinishing = true; @@ -506,7 +483,7 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp private void refreshAndFinishIfPossible(boolean removeTaskWhenFinishing) { if (!refreshUi()) { - setIntentAndFinish(true, removeTaskWhenFinishing); + setIntentAndFinish(removeTaskWhenFinishing); } else { startListeningToPackageRemove(); } @@ -547,17 +524,15 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp } @VisibleForTesting - void uninstallPkg(String packageName, boolean allUsers, boolean andDisable) { + void uninstallPkg(String packageName, boolean allUsers) { stopListeningToPackageRemove(); // Create new intent to launch Uninstaller activity Uri packageUri = Uri.parse("package:" + packageName); Intent uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageUri); uninstallIntent.putExtra(Intent.EXTRA_UNINSTALL_ALL_USERS, allUsers); - mMetricsFeatureProvider.action( - mActivity, SettingsEnums.ACTION_SETTINGS_UNINSTALL_APP); + mMetricsFeatureProvider.action(mActivity, SettingsEnums.ACTION_SETTINGS_UNINSTALL_APP); mFragment.startActivityForResult(uninstallIntent, mRequestUninstall); - mDisableAfterUninstall = andDisable; } @VisibleForTesting @@ -622,12 +597,6 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp newFragment.show(mActivity.getSupportFragmentManager(), "dialog " + id); } - /** Returns whether there is only one user on this device, not including the system-only user */ - private boolean isSingleUser() { - final int userCount = mUserManager.getUserCount(); - return userCount == 1; - } - private final BroadcastReceiver mCheckKillProcessesReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { @@ -666,8 +635,7 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp List homeActivities = new ArrayList<>(); mPm.getHomeActivities(homeActivities); mHomePackages.clear(); - for (int i = 0, size = homeActivities.size(); i < size; i++) { - ResolveInfo ri = homeActivities.get(i); + for (ResolveInfo ri : homeActivities) { final String activityPkg = ri.activityInfo.packageName; mHomePackages.add(activityPkg); @@ -694,8 +662,7 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp } private void initButtonPreference() { - mButtonsPref = ((ActionButtonsPreference) mScreen.findPreference( - KEY_ACTION_BUTTONS)) + mButtonsPref = ((ActionButtonsPreference) mScreen.findPreference(KEY_ACTION_BUTTONS)) .setButton1Text(R.string.launch_instant_app) .setButton1Icon(R.drawable.ic_settings_open) .setButton1OnClickListener(v -> launchApplication()) diff --git a/src/com/android/settings/applications/appinfo/ButtonActionDialogFragment.java b/src/com/android/settings/applications/appinfo/ButtonActionDialogFragment.java index 7b7e3e944ea..5a466f5021a 100644 --- a/src/com/android/settings/applications/appinfo/ButtonActionDialogFragment.java +++ b/src/com/android/settings/applications/appinfo/ButtonActionDialogFragment.java @@ -48,12 +48,10 @@ public class ButtonActionDialogFragment extends InstrumentedDialogFragment imple @Retention(RetentionPolicy.SOURCE) @IntDef({ DialogType.DISABLE, - DialogType.SPECIAL_DISABLE, DialogType.FORCE_STOP }) public @interface DialogType { int DISABLE = 0; - int SPECIAL_DISABLE = 1; int FORCE_STOP = 2; } @@ -105,7 +103,6 @@ public class ButtonActionDialogFragment extends InstrumentedDialogFragment imple final Context context = getContext(); switch (id) { case DialogType.DISABLE: - case DialogType.SPECIAL_DISABLE: return new AlertDialog.Builder(context) .setMessage(R.string.app_disable_dlg_text) .setPositiveButton(R.string.app_disable_dlg_positive, this) diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java index 9a65dc8829c..54c2d6ea8f0 100644 --- a/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppButtonsPreferenceControllerTest.java @@ -85,10 +85,8 @@ import java.util.Set; public class AppButtonsPreferenceControllerTest { private static final String PACKAGE_NAME = "com.android.settings"; - private static final String RRO_PACKAGE_NAME = "com.android.settings.overlay"; private static final String RESOURCE_STRING = "string"; private static final boolean ALL_USERS = false; - private static final boolean DISABLE_AFTER_INSTALL = true; private static final int REQUEST_UNINSTALL = 0; private static final int REQUEST_REMOVE_DEVICE_ADMIN = 1; private static final OverlayInfo OVERLAY_DISABLED = createFakeOverlay("overlay", false, 1); @@ -401,14 +399,13 @@ public class AppButtonsPreferenceControllerTest { @Test public void uninstallPkg_intentSent() { - mController.uninstallPkg(PACKAGE_NAME, ALL_USERS, DISABLE_AFTER_INSTALL); + mController.uninstallPkg(PACKAGE_NAME, ALL_USERS); verify(mFragment).startActivityForResult(any(), eq(REQUEST_UNINSTALL)); assertThat( mUninstallIntent.getBooleanExtra(Intent.EXTRA_UNINSTALL_ALL_USERS, true)) .isEqualTo(ALL_USERS); assertThat(mUninstallIntent.getAction()).isEqualTo(Intent.ACTION_UNINSTALL_PACKAGE); - assertThat(mController.mDisableAfterUninstall).isEqualTo(DISABLE_AFTER_INSTALL); } @Test diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/ButtonActionDialogFragmentTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/ButtonActionDialogFragmentTest.java index 432104d27cc..c5820799557 100644 --- a/tests/robotests/src/com/android/settings/applications/appinfo/ButtonActionDialogFragmentTest.java +++ b/tests/robotests/src/com/android/settings/applications/appinfo/ButtonActionDialogFragmentTest.java @@ -50,8 +50,6 @@ public class ButtonActionDialogFragmentTest { private static final int FORCE_STOP_ID = ButtonActionDialogFragment.DialogType.FORCE_STOP; private static final int DISABLE_ID = ButtonActionDialogFragment.DialogType.DISABLE; - private static final int SPECIAL_DISABLE_ID = - ButtonActionDialogFragment.DialogType.SPECIAL_DISABLE; @Mock private TestFragment mTargetFragment; private ButtonActionDialogFragment mFragment; @@ -129,26 +127,6 @@ public class ButtonActionDialogFragmentTest { mShadowContext.getString(R.string.dlg_cancel)); } - @Test - public void testOnCreateDialog_specialDisableDialog() { - ButtonActionDialogFragment fragment = - ButtonActionDialogFragment.newInstance(SPECIAL_DISABLE_ID); - FragmentController.setupFragment(fragment, FragmentActivity.class, 0 /* containerViewId */, - null /* bundle */); - final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog(); - - assertThat(dialog).isNotNull(); - - ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog); - - assertThat(shadowDialog.getMessage()).isEqualTo( - mShadowContext.getString(R.string.app_disable_dlg_text)); - assertThat(dialog.getButton(DialogInterface.BUTTON_POSITIVE).getText()).isEqualTo( - mShadowContext.getString(R.string.app_disable_dlg_positive)); - assertThat(dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getText()).isEqualTo( - mShadowContext.getString(R.string.dlg_cancel)); - } - /** * Test fragment that used as the target fragment, it must implement the * {@link ButtonActionDialogFragment.AppButtonsDialogListener}