DPC can be uninstalled in personal profile in New COPE
* For an organization-owned device, the DPC should be able to be uninstalled in the personal profile. Previously, the observed behaviour was that the uninstall button in the App Info Screen was being greyed out. * This was because the previous logic did not allow for uninstalling any app which has a profile owner or device owner on *any* user. * This CL updates this logic, such that, for non-system apps uninstalling is blocked only if the app has a profile owner or device owner for the current calling user. Bug: 149381804 Test: Manual testing atest com.android.settings.applications.appinfo.AppButtonsPreferenceControllerTest Change-Id: Ifaf03daa41724dbbd869c7e1371a77cc39d15ac7
This commit is contained in:
@@ -25,8 +25,8 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.om.OverlayManager;
|
||||
import android.content.om.OverlayInfo;
|
||||
import android.content.om.OverlayManager;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -393,11 +393,19 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
// We don't allow uninstalling DO/PO on *any* users, because if it's a system app,
|
||||
// We don't allow uninstalling DO/PO on *any* users if it's a system app, because
|
||||
// "uninstall" is actually "downgrade to the system version + disable", and "downgrade"
|
||||
// will clear data on all users.
|
||||
if (Utils.isProfileOrDeviceOwner(mUserManager, mDpm, mPackageInfo.packageName)) {
|
||||
enabled = false;
|
||||
if (Utils.isSystemPackage(mActivity.getResources(), mPm, mPackageInfo)) {
|
||||
if (Utils.isProfileOrDeviceOwner(mUserManager, mDpm, mPackageInfo.packageName)) {
|
||||
enabled = false;
|
||||
}
|
||||
// We allow uninstalling if the calling user is not a DO/PO and if it's not a system app,
|
||||
// because this will not have device-wide consequences.
|
||||
} else {
|
||||
if (Utils.isProfileOrDeviceOwner(mDpm, mPackageInfo.packageName, mUserId)) {
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Don't allow uninstalling the device provisioning package.
|
||||
|
Reference in New Issue
Block a user