Track ro.flash.locked bit to enable/disable OEM unlocking pref
if the device is OEM unlocked already, disable the OEM
unlocking pref. If it's locked, enable.
Bug: 26039090
Change-Id: I915f3cf57deef8f5775d466dec59c891c1546b1b
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index a1d9750..b0a685c 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -203,6 +203,7 @@
private static final int RESULT_MOCK_LOCATION_APP = 1001;
private static final String PERSISTENT_DATA_BLOCK_PROP = "ro.frp.pst";
+ private static final String FLASH_LOCKED_PROP = "ro.boot.flash.locked";
private static final int REQUEST_CODE_ENABLE_OEM_UNLOCK = 0;
@@ -703,6 +704,7 @@
updateForceResizableOptions();
updateEnableFreeformWindowsSupportOptions();
updateWebViewProviderOptions();
+ updateOemUnlockOptions();
if (mColorTemperaturePreference != null) {
updateColorTemperature();
}
@@ -967,6 +969,17 @@
return !SystemProperties.get(PERSISTENT_DATA_BLOCK_PROP).equals("");
}
+ private static boolean enableOemUnlockPreference() {
+ String flashLocked = SystemProperties.get(FLASH_LOCKED_PROP);
+ return !"0".equals(flashLocked);
+ }
+
+ private void updateOemUnlockOptions() {
+ if (mEnableOemUnlock != null) {
+ mEnableOemUnlock.setEnabled(enableOemUnlockPreference());
+ }
+ }
+
private void updateBugreportOptions() {
mBugreport.setEnabled(true);
mBugreportInPower.setEnabled(true);