Merge "Show uninstall for all users option menu in app info."

This commit is contained in:
TreeHugger Robot
2017-03-03 04:19:06 +00:00
committed by Android (Google) Code Review
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);
@@ -572,6 +556,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) {