From 48b0b241aa30c5b4c97b74e62bbd806e88fd28a0 Mon Sep 17 00:00:00 2001 From: Andres Morales Date: Tue, 4 Nov 2014 10:58:19 -0800 Subject: [PATCH] Confirm enabling OEM unlock with warning dialog Bug: 18227644 Change-Id: I326a4cf215ef0e30fd8a054964e0efeb3f627d89 --- res/values/strings.xml | 4 +++ .../android/settings/DevelopmentSettings.java | 30 +++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 2329a9ef2cc..d163ecc1bb4 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -3396,6 +3396,10 @@ Enter your PIN Enter your device PIN to enable OEM unlock + + Warning + + Enabling OEM unlock disables theft protection features on this device and may void your warranty. Continue? diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java index 97a3b68dd88..4af2baf47d2 100644 --- a/src/com/android/settings/DevelopmentSettings.java +++ b/src/com/android/settings/DevelopmentSettings.java @@ -1279,6 +1279,24 @@ public class DevelopmentSettings extends SettingsPreferenceFragment getActivity().getContentResolver(), Settings.Secure.ANR_SHOW_BACKGROUND, 0) != 0); } + private void confirmEnableOemUnlock() { + DialogInterface.OnClickListener onConfirmListener = new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + Utils.setOemUnlockEnabled(getActivity(), true); + updateAllOptions(); + } + }; + + new AlertDialog.Builder(getActivity()) + .setTitle(R.string.confirm_enable_oem_unlock_title) + .setMessage(R.string.confirm_enable_oem_unlock_text) + .setPositiveButton(R.string.yes, onConfirmListener) + .setNegativeButton(android.R.string.cancel, null) + .create() + .show(); + } + @Override public void onSwitchChanged(Switch switchView, boolean isChecked) { if (switchView != mSwitchBar.getSwitch()) { @@ -1316,7 +1334,11 @@ public class DevelopmentSettings extends SettingsPreferenceFragment } } else if (requestCode == REQUEST_CODE_ENABLE_OEM_UNLOCK) { if (resultCode == Activity.RESULT_OK) { - Utils.setOemUnlockEnabled(getActivity(), mEnableOemUnlock.isChecked()); + if (mEnableOemUnlock.isChecked()) { + confirmEnableOemUnlock(); + } else { + Utils.setOemUnlockEnabled(getActivity(), false); + } } } else { super.onActivityResult(requestCode, resultCode, data); @@ -1372,7 +1394,11 @@ public class DevelopmentSettings extends SettingsPreferenceFragment writeBtHciSnoopLogOptions(); } else if (preference == mEnableOemUnlock) { if (!showKeyguardConfirmation(getResources(), REQUEST_CODE_ENABLE_OEM_UNLOCK)) { - Utils.setOemUnlockEnabled(getActivity(), mEnableOemUnlock.isChecked()); + if (mEnableOemUnlock.isChecked()) { + confirmEnableOemUnlock(); + } else { + Utils.setOemUnlockEnabled(getActivity(), false); + } } } else if (preference == mAllowMockLocation) { Settings.Secure.putInt(getActivity().getContentResolver(),