Allow system apps to be disabled
If it is a single-user device, keep earlier behavior of disabling and offering to downgrade the system app. If there are other users, then only disable the app. Bug: 26694521 Change-Id: I4e62fec6bb186afa5d4c3f29f5524783494dfb06
This commit is contained in:
@@ -485,17 +485,9 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
if (requestCode == REQUEST_UNINSTALL) {
|
if (requestCode == REQUEST_UNINSTALL) {
|
||||||
if (mDisableAfterUninstall) {
|
if (mDisableAfterUninstall) {
|
||||||
mDisableAfterUninstall = false;
|
mDisableAfterUninstall = false;
|
||||||
try {
|
new DisableChanger(this, mAppEntry.info,
|
||||||
ApplicationInfo ainfo = getActivity().getPackageManager().getApplicationInfo(
|
PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER)
|
||||||
mAppEntry.info.packageName, PackageManager.GET_UNINSTALLED_PACKAGES
|
.execute((Object)null);
|
||||||
| PackageManager.GET_DISABLED_COMPONENTS);
|
|
||||||
if ((ainfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) == 0) {
|
|
||||||
new DisableChanger(this, mAppEntry.info,
|
|
||||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER)
|
|
||||||
.execute((Object)null);
|
|
||||||
}
|
|
||||||
} catch (NameNotFoundException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!refreshUi()) {
|
if (!refreshUi()) {
|
||||||
setIntentAndFinish(true, true);
|
setIntentAndFinish(true, true);
|
||||||
@@ -656,11 +648,11 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
.create();
|
.create();
|
||||||
case DLG_SPECIAL_DISABLE:
|
case DLG_SPECIAL_DISABLE:
|
||||||
return new AlertDialog.Builder(getActivity())
|
return new AlertDialog.Builder(getActivity())
|
||||||
.setMessage(getActivity().getText(R.string.app_special_disable_dlg_text))
|
.setMessage(getActivity().getText(R.string.app_disable_dlg_text))
|
||||||
.setPositiveButton(R.string.app_disable_dlg_positive,
|
.setPositiveButton(R.string.app_disable_dlg_positive,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
// Clear user data here
|
// Disable the app and ask for uninstall
|
||||||
uninstallPkg(mAppEntry.info.packageName,
|
uninstallPkg(mAppEntry.info.packageName,
|
||||||
false, true);
|
false, true);
|
||||||
}
|
}
|
||||||
@@ -706,7 +698,7 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void forceStopPackage(String pkgName) {
|
private void forceStopPackage(String pkgName) {
|
||||||
ActivityManager am = (ActivityManager)getActivity().getSystemService(
|
ActivityManager am = (ActivityManager) getActivity().getSystemService(
|
||||||
Context.ACTIVITY_SERVICE);
|
Context.ACTIVITY_SERVICE);
|
||||||
am.forceStopPackage(pkgName);
|
am.forceStopPackage(pkgName);
|
||||||
int userId = UserHandle.getUserId(mAppEntry.info.uid);
|
int userId = UserHandle.getUserId(mAppEntry.info.uid);
|
||||||
@@ -779,7 +771,7 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String packageName = mAppEntry.info.packageName;
|
String packageName = mAppEntry.info.packageName;
|
||||||
if(v == mUninstallButton) {
|
if (v == mUninstallButton) {
|
||||||
if (mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) {
|
if (mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
Intent uninstallDAIntent = new Intent(activity, DeviceAdminAdd.class);
|
Intent uninstallDAIntent = new Intent(activity, DeviceAdminAdd.class);
|
||||||
@@ -796,7 +788,10 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(), admin);
|
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(), admin);
|
||||||
} else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
|
} else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
|
||||||
if (mAppEntry.info.enabled && !isDisabledUntilUsed()) {
|
if (mAppEntry.info.enabled && !isDisabledUntilUsed()) {
|
||||||
if (mUpdatedSysApp) {
|
// 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(DLG_SPECIAL_DISABLE, 0);
|
showDialogInner(DLG_SPECIAL_DISABLE, 0);
|
||||||
} else {
|
} else {
|
||||||
showDialogInner(DLG_DISABLE, 0);
|
showDialogInner(DLG_DISABLE, 0);
|
||||||
@@ -822,6 +817,13 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 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
|
||||||
|
|| (mUserManager.isSplitSystemUser() && userCount == 2);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
if (preference == mStoragePreference) {
|
if (preference == mStoragePreference) {
|
||||||
|
Reference in New Issue
Block a user