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

Commit 335e4bdf authored by Steven Ng's avatar Steven Ng Committed by android-build-merger
Browse files

Merge "Add a Global setting for disabling OEM unlocking setting" into nyc-mr1-dev am: e333b2eb

am: a62fc512

* commit 'a62fc512':
  Add a Global setting for disabling OEM unlocking setting

Change-Id: I8e0f6f00599923be663c9808ffa187bbe014121c
parents dcc70eeb a62fc512
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -8893,6 +8893,15 @@ public final class Settings {
         * @hide
         */
        public static final String ENABLE_CELLULAR_ON_BOOT = "enable_cellular_on_boot";

        /**
         * Whether toggling OEM unlock is disallowed. If disallowed, it is not possible to enable or
         * disable OEM unlock.
         * <p>
         * Type: int (0: allow OEM unlock setting. 1: disallow OEM unlock)
         * @hide
         */
        public static final String OEM_UNLOCK_DISALLOWED = "oem_unlock_disallowed";
    }

    /**
+3 −0
Original line number Diff line number Diff line
@@ -216,4 +216,7 @@

    <!-- Default setting for ability to add users from the lock screen -->
    <bool name="def_add_users_from_lockscreen">false</bool>

    <!-- Default setting for disallow oem unlock. -->
    <bool name="def_oem_unlock_disallow">false</bool>
</resources>
+13 −1
Original line number Diff line number Diff line
@@ -2078,7 +2078,7 @@ public class SettingsProvider extends ContentProvider {
        }

        private final class UpgradeController {
            private static final int SETTINGS_VERSION = 127;
            private static final int SETTINGS_VERSION = 128;

            private final int mUserId;

@@ -2333,6 +2333,18 @@ public class SettingsProvider extends ContentProvider {
                    currentVersion = 127;
                }

                if (currentVersion == 127) {
                    // Version 127: Disable OEM unlock setting by default on some devices.
                    final SettingsState globalSettings = getGlobalSettingsLocked();
                    String defaultOemUnlockDisabled = (getContext().getResources()
                            .getBoolean(R.bool.def_oem_unlock_disallow) ? "1" : "0");
                    globalSettings.insertSettingLocked(
                            Settings.Global.OEM_UNLOCK_DISALLOWED,
                            defaultOemUnlockDisabled,
                            SettingsState.SYSTEM_PACKAGE_NAME);
                    currentVersion = 128;
                }

                // vXXX: Add new settings above this point.

                // Return the current version.
+7 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.service.persistentdata.IPersistentDataBlockService;
import android.service.persistentdata.PersistentDataBlockManager;
import android.util.Slog;
@@ -437,11 +438,16 @@ public class PersistentDataBlockService extends SystemService {
        }

        @Override
        public void setOemUnlockEnabled(boolean enabled) {
        public void setOemUnlockEnabled(boolean enabled) throws SecurityException {
            // do not allow monkey to flip the flag
            if (ActivityManager.isUserAMonkey()) {
                return;
            }
            // Do not allow oem unlock modification if it has been disallowed.
            if (Settings.Global.getInt(getContext().getContentResolver(),
                    Settings.Global.OEM_UNLOCK_DISALLOWED, 0) == 1) {
                throw new SecurityException("OEM unlock has been disallowed.");
            }
            enforceOemUnlockPermission();
            enforceIsAdmin();