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
This commit is contained in:
Andres Morales
2016-01-13 15:28:54 -08:00
parent 34de9f6bf8
commit e32497c6de

View File

@@ -203,6 +203,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
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 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
updateForceResizableOptions();
updateEnableFreeformWindowsSupportOptions();
updateWebViewProviderOptions();
updateOemUnlockOptions();
if (mColorTemperaturePreference != null) {
updateColorTemperature();
}
@@ -967,6 +969,17 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
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);