Disallow downgrade of bundled home apps
Bug 14162565 Change-Id: I754721178722edbf0765039bc9669ed24b92633c
This commit is contained in:
@@ -347,11 +347,12 @@ public class InstalledAppDetails extends Fragment
|
|||||||
|
|
||||||
private void initUninstallButtons() {
|
private void initUninstallButtons() {
|
||||||
mUpdatedSysApp = (mAppEntry.info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
|
mUpdatedSysApp = (mAppEntry.info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
|
||||||
|
final boolean isBundled = (mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
|
||||||
boolean enabled = true;
|
boolean enabled = true;
|
||||||
if (mUpdatedSysApp) {
|
if (mUpdatedSysApp) {
|
||||||
mUninstallButton.setText(R.string.app_factory_reset);
|
mUninstallButton.setText(R.string.app_factory_reset);
|
||||||
boolean showSpecialDisable = false;
|
boolean showSpecialDisable = false;
|
||||||
if ((mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
|
if (isBundled) {
|
||||||
showSpecialDisable = handleDisableable(mSpecialDisableButton);
|
showSpecialDisable = handleDisableable(mSpecialDisableButton);
|
||||||
mSpecialDisableButton.setOnClickListener(this);
|
mSpecialDisableButton.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
@@ -361,7 +362,7 @@ public class InstalledAppDetails extends Fragment
|
|||||||
mMoreControlButtons.setVisibility(showSpecialDisable ? View.VISIBLE : View.GONE);
|
mMoreControlButtons.setVisibility(showSpecialDisable ? View.VISIBLE : View.GONE);
|
||||||
} else {
|
} else {
|
||||||
mMoreControlButtons.setVisibility(View.GONE);
|
mMoreControlButtons.setVisibility(View.GONE);
|
||||||
if ((mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
|
if (isBundled) {
|
||||||
enabled = handleDisableable(mUninstallButton);
|
enabled = handleDisableable(mUninstallButton);
|
||||||
} else if ((mPackageInfo.applicationInfo.flags
|
} else if ((mPackageInfo.applicationInfo.flags
|
||||||
& ApplicationInfo.FLAG_INSTALLED) == 0
|
& ApplicationInfo.FLAG_INSTALLED) == 0
|
||||||
@@ -380,19 +381,27 @@ public class InstalledAppDetails extends Fragment
|
|||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is the default (or only) home app, suppress uninstall (even if
|
// Home apps need special handling. Bundled ones we don't risk downgrading
|
||||||
// we still think it should be allowed for other reasons)
|
// because that can interfere with home-key resolution. Furthermore, we
|
||||||
|
// can't allow uninstallation of the only home app, and we don't want to
|
||||||
|
// allow uninstallation of an explicitly preferred one -- the user can go
|
||||||
|
// to Home settings and pick a different one, after which we'll permit
|
||||||
|
// uninstallation of the now-not-default one.
|
||||||
if (enabled && mHomePackages.contains(mPackageInfo.packageName)) {
|
if (enabled && mHomePackages.contains(mPackageInfo.packageName)) {
|
||||||
ArrayList<ResolveInfo> homeActivities = new ArrayList<ResolveInfo>();
|
if (isBundled) {
|
||||||
ComponentName currentDefaultHome = mPm.getHomeActivities(homeActivities);
|
enabled = false;
|
||||||
if (currentDefaultHome == null) {
|
|
||||||
// No preferred default, so permit uninstall only when
|
|
||||||
// there is more than one candidate
|
|
||||||
enabled = (mHomePackages.size() > 1);
|
|
||||||
} else {
|
} else {
|
||||||
// There is an explicit default home app -- forbid uninstall of
|
ArrayList<ResolveInfo> homeActivities = new ArrayList<ResolveInfo>();
|
||||||
// that one, but permit it for installed-but-inactive ones.
|
ComponentName currentDefaultHome = mPm.getHomeActivities(homeActivities);
|
||||||
enabled = !mPackageInfo.packageName.equals(currentDefaultHome.getPackageName());
|
if (currentDefaultHome == null) {
|
||||||
|
// No preferred default, so permit uninstall only when
|
||||||
|
// there is more than one candidate
|
||||||
|
enabled = (mHomePackages.size() > 1);
|
||||||
|
} else {
|
||||||
|
// There is an explicit default home app -- forbid uninstall of
|
||||||
|
// that one, but permit it for installed-but-inactive ones.
|
||||||
|
enabled = !mPackageInfo.packageName.equals(currentDefaultHome.getPackageName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user