Merge "Disallow OEM unlock when DISALLOW_FACTORY_RESET applies" into nyc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
dd86aa141e
@@ -146,6 +146,15 @@ public class PersistentDataBlockService extends SystemService {
|
||||
"Only the Admin user is allowed to change OEM unlock state");
|
||||
}
|
||||
}
|
||||
|
||||
private void enforceFactoryResetAllowed() {
|
||||
final boolean isOemUnlockRestricted = UserManager.get(mContext)
|
||||
.hasUserRestriction(UserManager.DISALLOW_FACTORY_RESET);
|
||||
if (isOemUnlockRestricted) {
|
||||
throw new SecurityException("OEM unlock is disallowed by DISALLOW_FACTORY_RESET");
|
||||
}
|
||||
}
|
||||
|
||||
private int getTotalDataSizeLocked(DataInputStream inputStream) throws IOException {
|
||||
// skip over checksum
|
||||
inputStream.skipBytes(DIGEST_SIZE_BYTES);
|
||||
@@ -452,7 +461,9 @@ public class PersistentDataBlockService extends SystemService {
|
||||
Settings.Global.OEM_UNLOCK_DISALLOWED, 0) == 1) {
|
||||
throw new SecurityException("OEM unlock has been disallowed.");
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
enforceFactoryResetAllowed();
|
||||
}
|
||||
synchronized (mLock) {
|
||||
doSetOemUnlockEnabledLocked(enabled);
|
||||
computeAndWriteDigestLocked();
|
||||
|
||||
@@ -33,6 +33,7 @@ import android.os.RemoteException;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.service.persistentdata.PersistentDataBlockManager;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.util.Log;
|
||||
@@ -424,6 +425,14 @@ public class UserRestrictionsUtils {
|
||||
android.provider.Settings.Global.SAFE_BOOT_DISALLOWED,
|
||||
newValue ? 1 : 0);
|
||||
break;
|
||||
case UserManager.DISALLOW_FACTORY_RESET:
|
||||
if (newValue) {
|
||||
PersistentDataBlockManager manager = (PersistentDataBlockManager) context
|
||||
.getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
|
||||
if (manager != null) {
|
||||
manager.setOemUnlockEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(id);
|
||||
|
||||
Reference in New Issue
Block a user