Do not toggle OEM unlock if bootloader unlocked am: c48b20f8f1

am: 83583bd596

Change-Id: Ib8293a02ca13587154133a939c4515de1a114bd9
This commit is contained in:
Esteban Talavera
2016-08-11 19:00:37 +00:00
committed by android-build-merger
3 changed files with 13 additions and 10 deletions

View File

@@ -614,7 +614,8 @@ public class UserManager {
/** /**
* Specifies if a user is not allowed to enable the oem unlock setting. The default value is * Specifies if a user is not allowed to enable the oem unlock setting. The default value is
* <code>false</code>. * <code>false</code>. Setting this restriction has no effect if the bootloader is already
* unlocked.
* *
* @see DevicePolicyManager#addUserRestriction(ComponentName, String) * @see DevicePolicyManager#addUserRestriction(ComponentName, String)
* @see DevicePolicyManager#clearUserRestriction(ComponentName, String) * @see DevicePolicyManager#clearUserRestriction(ComponentName, String)

View File

@@ -163,10 +163,9 @@ public class PersistentDataBlockManager {
/** /**
* Retrieves available information about this device's flash lock state. * Retrieves available information about this device's flash lock state.
* *
* @return FLASH_LOCK_STATE_LOCKED if device bootloader is locked, * @return {@link #FLASH_LOCK_LOCKED} if device bootloader is locked,
* FLASH_LOCK_STATE_UNLOCKED if device bootloader is unlocked, * {@link #FLASH_LOCK_UNLOCKED} if device bootloader is unlocked, or {@link #FLASH_LOCK_UNKNOWN}
* or FLASH_LOCK_STATE unknown if this information cannot be ascertained * if this information cannot be ascertained on this device.
* on this device.
*/ */
@FlashLockState @FlashLockState
public int getFlashLockState() { public int getFlashLockState() {

View File

@@ -26,11 +26,9 @@ import android.app.ActivityManager;
import android.app.ActivityManagerNative; import android.app.ActivityManagerNative;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.net.Uri;
import android.os.Binder; import android.os.Binder;
import android.os.Bundle; import android.os.Bundle;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.UserManager; import android.os.UserManager;
import android.service.persistentdata.PersistentDataBlockManager; import android.service.persistentdata.PersistentDataBlockManager;
@@ -188,8 +186,7 @@ public class UserRestrictionsUtils {
serializer.endTag(null, tag); serializer.endTag(null, tag);
} }
public static void readRestrictions(XmlPullParser parser, Bundle restrictions) public static void readRestrictions(XmlPullParser parser, Bundle restrictions) {
throws IOException {
for (String key : USER_RESTRICTIONS) { for (String key : USER_RESTRICTIONS) {
final String value = parser.getAttributeValue(null, key); final String value = parser.getAttributeValue(null, key);
if (value != null) { if (value != null) {
@@ -437,7 +434,13 @@ public class UserRestrictionsUtils {
if (newValue) { if (newValue) {
PersistentDataBlockManager manager = (PersistentDataBlockManager) context PersistentDataBlockManager manager = (PersistentDataBlockManager) context
.getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE); .getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
if (manager != null && manager.getOemUnlockEnabled()) { if (manager != null
&& manager.getOemUnlockEnabled()
&& manager.getFlashLockState()
!= PersistentDataBlockManager.FLASH_LOCK_UNLOCKED) {
// Only disable OEM unlock if the bootloader is locked. If it's already
// unlocked, setting the OEM unlock enabled flag to false has no effect
// (the bootloader would remain unlocked).
manager.setOemUnlockEnabled(false); manager.setOemUnlockEnabled(false);
} }
} }