summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/Utils.java
diff options
context:
space:
mode:
authorAndres Morales <anmorales@google.com>2014-07-07 16:58:16 -0700
committerAndres Morales <anmorales@google.com>2014-07-09 18:16:04 -0700
commitce249fe38ddf8da562a0e92c58a7bb216a23c0bb (patch)
treeaf71d3ec0139c45ea9a39d8ef0f571157fd661cc /src/com/android/settings/Utils.java
parente2403822ec3ba058950280209b1bd106b9d45b82 (diff)
downloadpackages_apps_Settings-ce249fe38ddf8da562a0e92c58a7bb216a23c0bb.zip
packages_apps_Settings-ce249fe38ddf8da562a0e92c58a7bb216a23c0bb.tar.gz
packages_apps_Settings-ce249fe38ddf8da562a0e92c58a7bb216a23c0bb.tar.bz2
Enable OEM unlock checkbox in Developer Settings
For Volantis+ devices, we will give users the ability to enable OEM unlock through Developer Settings. To do so, we must write the value to the last byte of a special partition that does not get erased even after factory reset. This feature will only be available on devices with the persistent data partition, thus the checkbox is only visible for devices that meet this requirement. This depends on https://googleplex-android-review.git.corp.google.com/#/c/495350/ DD: go/factory-reset Bug: 14288780 Change-Id: I8f80b950bc101a1067912faf221391bf0dd826b7
Diffstat (limited to 'src/com/android/settings/Utils.java')
-rw-r--r--src/com/android/settings/Utils.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 692d8f3..8211816 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -18,14 +18,12 @@ package com.android.settings;
import android.app.ActivityManager;
import android.app.AlertDialog;
-import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.app.Fragment;
import android.app.IActivityManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
-import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@@ -55,6 +53,7 @@ import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.Profile;
import android.provider.ContactsContract.RawContacts;
+import android.service.persistentdata.PersistentDataBlockManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
@@ -62,8 +61,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TabWidget;
-
-import com.android.settings.R.string;
import com.android.settings.dashboard.DashboardCategory;
import com.android.settings.dashboard.DashboardTile;
@@ -670,4 +667,23 @@ public final class Utils {
.create();
return dlg;
}
+
+ /**
+ * Returns whether or not this device is able to be OEM unlocked.
+ */
+ static boolean isOemUnlockEnabled(Context context) {
+ PersistentDataBlockManager manager =(PersistentDataBlockManager)
+ context.getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
+ return manager.getOemUnlockEnabled();
+ }
+
+ /**
+ * Allows enabling or disabling OEM unlock on this device. OEM unlocked
+ * devices allow users to flash other OSes to them.
+ */
+ static void setOemUnlockEnabled(Context context, boolean enabled) {
+ PersistentDataBlockManager manager =(PersistentDataBlockManager)
+ context.getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
+ manager.setOemUnlockEnabled(enabled);
+ }
}