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
This commit is contained in:
Andres Morales
2014-07-07 16:58:16 -07:00
parent e2403822ec
commit ce249fe38d
6 changed files with 82 additions and 16 deletions

View File

@@ -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);
}
}