Show uninstall for all users option menu in app info.

- when there is only 1 user installed the app, also check if it is
installed by the current user or by other user to determine whether or
not to show the uninstall for all button.

Change-Id: I1eecb13a7748c92159cb0626e2b6fe1ed6987d15
Fix: 34760157
Test: make RunSettingsRoboTests
This commit is contained in:
Doris Ling
2017-03-02 11:39:51 -08:00
parent 05c3333cbd
commit 2508ed56ca
2 changed files with 80 additions and 17 deletions

View File

@@ -490,23 +490,7 @@ public class InstalledAppDetails extends AppInfoBase
if (mFinishing) {
return;
}
boolean showIt = true;
if (mUpdatedSysApp) {
showIt = false;
} else if (mAppEntry == null) {
showIt = false;
} else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
showIt = false;
} else if (mPackageInfo == null || mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) {
showIt = false;
} else if (UserHandle.myUserId() != 0) {
showIt = false;
} else if (mUserManager.getUsers().size() < 2) {
showIt = false;
} else if (PackageUtil.countPackageInUsers(mPm, mUserManager, mPackageName) < 2) {
showIt = false;
}
menu.findItem(UNINSTALL_ALL_USERS_MENU).setVisible(showIt);
menu.findItem(UNINSTALL_ALL_USERS_MENU).setVisible(shouldShowUninstallForAll(mAppEntry));
mUpdatedSysApp = (mAppEntry.info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
MenuItem uninstallUpdatesItem = menu.findItem(UNINSTALL_UPDATES);
uninstallUpdatesItem.setVisible(mUpdatedSysApp && !mAppsControlDisallowedBySystem);
@@ -571,6 +555,28 @@ public class InstalledAppDetails extends AppInfoBase
}
}
@VisibleForTesting
boolean shouldShowUninstallForAll(ApplicationsState.AppEntry appEntry) {
boolean showIt = true;
if (mUpdatedSysApp) {
showIt = false;
} else if (appEntry == null) {
showIt = false;
} else if ((appEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
showIt = false;
} else if (mPackageInfo == null || mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) {
showIt = false;
} else if (UserHandle.myUserId() != 0) {
showIt = false;
} else if (mUserManager.getUsers().size() < 2) {
showIt = false;
} else if (PackageUtil.countPackageInUsers(mPm, mUserManager, mPackageName) < 2
&& (appEntry.info.flags & ApplicationInfo.FLAG_INSTALLED) != 0) {
showIt = false;
}
return showIt;
}
@VisibleForTesting
int getInstallationStatus(ApplicationInfo info) {
if ((info.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {