Introduce config_disable_uninstall_update flag.

This adds the following flag:
config_disable_uninstall_update

Which by default is false. When set to true, it will hide the "Uninstall
updates" menu item for all cases.

This is useful for cases where the device OEMs want to allow users to
install apps, but do not want the ability to roll back updates on system
applications.

Bug: 62379281
Test: make RunSettingsRoboTests ROBOTEST_FILTER=AppInfoDashboardFragmentTest
Change-Id: I55fe92467ca95c05f6682174c117031d8295790e
This commit is contained in:
Ben Lin
2018-02-08 15:53:16 -08:00
parent 2f6f8c7360
commit bba02d88a4
4 changed files with 53 additions and 3 deletions

View File

@@ -82,8 +82,8 @@ public class AppInfoDashboardFragment extends DashboardFragment
private static final String TAG = "AppInfoDashboard";
// Menu identifiers
private static final int UNINSTALL_ALL_USERS_MENU = 1;
private static final int UNINSTALL_UPDATES = 2;
@VisibleForTesting static final int UNINSTALL_ALL_USERS_MENU = 1;
@VisibleForTesting static final int UNINSTALL_UPDATES = 2;
static final int FORCE_STOP_MENU = 3;
// Result code identifiers
@@ -330,7 +330,10 @@ public class AppInfoDashboardFragment extends DashboardFragment
menu.findItem(UNINSTALL_ALL_USERS_MENU).setVisible(shouldShowUninstallForAll(mAppEntry));
mUpdatedSysApp = (mAppEntry.info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
final MenuItem uninstallUpdatesItem = menu.findItem(UNINSTALL_UPDATES);
uninstallUpdatesItem.setVisible(mUpdatedSysApp && !mAppsControlDisallowedBySystem);
final boolean uninstallUpdateDisabled = getContext().getResources().getBoolean(
R.bool.config_disable_uninstall_update);
uninstallUpdatesItem.setVisible(
mUpdatedSysApp && !mAppsControlDisallowedBySystem && !uninstallUpdateDisabled);
if (uninstallUpdatesItem.isVisible()) {
RestrictedLockUtils.setMenuItemAsDisabledByAdmin(getActivity(),
uninstallUpdatesItem, mAppsControlDisallowedAdmin);