Add device/profile app check in background check
If app is device or profile app, we disable the background check toggle. This cl also create an util method for this check and remove duplicate code Bug: 64665807 Test: RunSettingsRoboTests Change-Id: Id8336eadaac8832327bc3653aaa7dfbacde352ac
This commit is contained in:
@@ -274,7 +274,7 @@ public class InstalledAppDetails extends AppInfoBase
|
||||
// We don't allow uninstalling DO/PO on *any* users, because if it's a system app,
|
||||
// "uninstall" is actually "downgrade to the system version + disable", and "downgrade"
|
||||
// will clear data on all users.
|
||||
if (isProfileOrDeviceOwner(mPackageInfo.packageName)) {
|
||||
if (Utils.isProfileOrDeviceOwner(mUserManager, mDpm, mPackageInfo.packageName)) {
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
@@ -349,23 +349,6 @@ public class InstalledAppDetails extends AppInfoBase
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/** Returns if the supplied package is device owner or profile owner of at least one user */
|
||||
private boolean isProfileOrDeviceOwner(String packageName) {
|
||||
List<UserInfo> userInfos = mUserManager.getUsers();
|
||||
DevicePolicyManager dpm = (DevicePolicyManager)
|
||||
getContext().getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||
if (dpm.isDeviceOwnerAppOnAnyUser(packageName)) {
|
||||
return true;
|
||||
}
|
||||
for (UserInfo userInfo : userInfos) {
|
||||
ComponentName cn = dpm.getProfileOwnerAsUser(userInfo.id);
|
||||
if (cn != null && cn.getPackageName().equals(packageName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
|
||||
Reference in New Issue
Block a user