if (ActivityManager.isUserAMonkey()) {
return;
}
- enforceOemUnlockPermission();
+
+ enforceOemUnlockWritePermission();
enforceIsAdmin();
+ // Do not allow oem unlock modification if it has been disallowed.
+ if (Settings.Global.getInt(getContext().getContentResolver(),
+ Settings.Global.OEM_UNLOCK_DISALLOWED, 0) == 1) {
+ throw new SecurityException("OEM unlock has been disallowed.");
+ }
+ if (enabled) {
+ enforceFactoryResetAllowed();
+ }
synchronized (mLock) {
doSetOemUnlockEnabledLocked(enabled);
computeAndWriteDigestLocked();