Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd97e7bc authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Do not toggle OEM unlock if bootloader unlocked" into nyc-mr1-dev

parents f6793294 c48b20f8
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -614,7 +614,8 @@ public class UserManager {

    /**
     * Specifies if a user is not allowed to enable the oem unlock setting. The default value is
     * <code>false</code>.
     * <code>false</code>. Setting this restriction has no effect if the bootloader is already
     * unlocked.
     *
     * @see DevicePolicyManager#addUserRestriction(ComponentName, String)
     * @see DevicePolicyManager#clearUserRestriction(ComponentName, String)
+3 −4
Original line number Diff line number Diff line
@@ -163,10 +163,9 @@ public class PersistentDataBlockManager {
    /**
     * Retrieves available information about this device's flash lock state.
     *
     * @return FLASH_LOCK_STATE_LOCKED if device bootloader is locked,
     * FLASH_LOCK_STATE_UNLOCKED if device bootloader is unlocked,
     * or FLASH_LOCK_STATE unknown if this information cannot be ascertained
     * on this device.
     * @return {@link #FLASH_LOCK_LOCKED} if device bootloader is locked,
     * {@link #FLASH_LOCK_UNLOCKED} if device bootloader is unlocked, or {@link #FLASH_LOCK_UNKNOWN}
     * if this information cannot be ascertained on this device.
     */
    @FlashLockState
    public int getFlashLockState() {
+8 −5
Original line number Diff line number Diff line
@@ -26,11 +26,9 @@ import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.content.ContentResolver;
import android.content.Context;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.service.persistentdata.PersistentDataBlockManager;
@@ -188,8 +186,7 @@ public class UserRestrictionsUtils {
        serializer.endTag(null, tag);
    }

    public static void readRestrictions(XmlPullParser parser, Bundle restrictions)
            throws IOException {
    public static void readRestrictions(XmlPullParser parser, Bundle restrictions) {
        for (String key : USER_RESTRICTIONS) {
            final String value = parser.getAttributeValue(null, key);
            if (value != null) {
@@ -437,7 +434,13 @@ public class UserRestrictionsUtils {
                    if (newValue) {
                        PersistentDataBlockManager manager = (PersistentDataBlockManager) context
                                .getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
                        if (manager != null && manager.getOemUnlockEnabled()) {
                        if (manager != null
                                && manager.getOemUnlockEnabled()
                                && manager.getFlashLockState()
                                        != PersistentDataBlockManager.FLASH_LOCK_UNLOCKED) {
                            // Only disable OEM unlock if the bootloader is locked. If it's already
                            // unlocked, setting the OEM unlock enabled flag to false has no effect
                            // (the bootloader would remain unlocked).
                            manager.setOemUnlockEnabled(false);
                        }
                    }