Skip to content

Commit f0be7d0

Browse files
blongSteve Kondik
authored andcommitted
Filter internal account when set device owner
Change-Id: I1bf3fe42e7e3d27e8cf443c9386edb178384a402
1 parent b0cc052 commit f0be7d0

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java

100644100755
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import static android.content.pm.PackageManager.GET_UNINSTALLED_PACKAGES;
2323

2424
import android.accessibilityservice.AccessibilityServiceInfo;
25+
import android.accounts.Account;
2526
import android.accounts.AccountManager;
2627
import android.app.Activity;
2728
import android.app.ActivityManagerNative;
@@ -4094,7 +4095,20 @@ public String getProfileOwnerName(int userHandle) {
40944095
private boolean allowedToSetDeviceOwnerOnDevice() {
40954096
int callingId = Binder.getCallingUid();
40964097
if (callingId == Process.SHELL_UID || callingId == Process.ROOT_UID) {
4097-
return AccountManager.get(mContext).getAccounts().length == 0;
4098+
Account[] mAccounts = AccountManager.get(mContext).getAccounts();
4099+
if(mAccounts.length == 0) {
4100+
return true;
4101+
} else {
4102+
int i = mAccounts.length;
4103+
for (Account account : mAccounts) {
4104+
if (account.type
4105+
.equals("com.qualcomm.qti.calendarlocalaccount")
4106+
|| account.type.equals("com.android.localphone")
4107+
|| account.type.equals("com.android.sim"))
4108+
i--;
4109+
}
4110+
return i == 0;
4111+
}
40984112
} else {
40994113
return !hasUserSetupCompleted(UserHandle.USER_OWNER);
41004114
}

0 commit comments

Comments
 (0)