OSDN Git Service

Merge "Revert "Add an entry in developer options for location tools."" into nyc-dev...
[android-x86/packages-apps-Settings.git] / src / com / android / settings / DevelopmentSettings.java
index 4daa881..ee6a7e9 100644 (file)
@@ -237,7 +237,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
     private SwitchPreference mBugreportInPower;
     private RestrictedSwitchPreference mKeepScreenOn;
     private SwitchPreference mBtHciSnoopLog;
-    private SwitchPreference mEnableOemUnlock;
+    private RestrictedSwitchPreference mEnableOemUnlock;
     private SwitchPreference mDebugViewAttributes;
     private SwitchPreference mForceAllowOnExternal;
 
@@ -369,7 +369,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
         mBugreportInPower = findAndInitSwitchPref(BUGREPORT_IN_POWER_KEY);
         mKeepScreenOn = (RestrictedSwitchPreference) findAndInitSwitchPref(KEEP_SCREEN_ON);
         mBtHciSnoopLog = findAndInitSwitchPref(BT_HCI_SNOOP_LOG);
-        mEnableOemUnlock = findAndInitSwitchPref(ENABLE_OEM_UNLOCK);
+        mEnableOemUnlock = (RestrictedSwitchPreference) findAndInitSwitchPref(ENABLE_OEM_UNLOCK);
         if (!showEnableOemUnlockPreference()) {
             removePreference(mEnableOemUnlock);
             mEnableOemUnlock = null;
@@ -1008,12 +1008,28 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
             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() {
         if (mEnableOemUnlock != null) {
+            // Showing mEnableOemUnlock preference as device has persistent data block.
+            mEnableOemUnlock.setDisabledByAdmin(null);
             mEnableOemUnlock.setEnabled(enableOemUnlockPreference());
+            if (mEnableOemUnlock.isEnabled()) {
+                // mEnableOemUnlock is enabled as device's flash lock is unlocked.
+                if (RestrictedLockUtils.hasBaseUserRestriction(getActivity(),
+                        UserManager.DISALLOW_FACTORY_RESET, UserHandle.myUserId())) {
+                    // Set mEnableOemUnlock to disabled as restriction is set, but not by admin.
+                    mEnableOemUnlock.setEnabled(false);
+                } else {
+                    // Check restriction, disable mEnableOemUnlock and apply policy transparency.
+                    mEnableOemUnlock
+                            .checkRestrictionAndSetDisabled(UserManager.DISALLOW_FACTORY_RESET);
+                }
+            }
         }
     }