Merge "Add a Global setting for disabling OEM unlocking setting" into nyc-mr1-dev

This commit is contained in:
Steven Ng
2016-05-16 09:20:42 +00:00
committed by Android (Google) Code Review
2 changed files with 10 additions and 4 deletions

View File

@@ -1014,7 +1014,9 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
flashLockState = mOemUnlockManager.getFlashLockState(); flashLockState = mOemUnlockManager.getFlashLockState();
} }
return flashLockState != PersistentDataBlockManager.FLASH_LOCK_UNLOCKED; return flashLockState != PersistentDataBlockManager.FLASH_LOCK_UNLOCKED
&& Settings.Global.getInt(getActivity().getContentResolver(),
Settings.Global.OEM_UNLOCK_DISALLOWED, 0) == 0;
} }
private void updateOemUnlockOptions() { private void updateOemUnlockOptions() {

View File

@@ -759,9 +759,13 @@ public final class Utils extends com.android.settingslib.Utils {
* devices allow users to flash other OSes to them. * devices allow users to flash other OSes to them.
*/ */
static void setOemUnlockEnabled(Context context, boolean enabled) { static void setOemUnlockEnabled(Context context, boolean enabled) {
PersistentDataBlockManager manager =(PersistentDataBlockManager) try {
context.getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE); PersistentDataBlockManager manager = (PersistentDataBlockManager)
manager.setOemUnlockEnabled(enabled); context.getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
manager.setOemUnlockEnabled(enabled);
} catch (SecurityException e) {
Log.e(TAG, "Fail to set oem unlock.", e);
}
} }
/** /**