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

Commit 9745ea35 authored by Lenka Trochtova's avatar Lenka Trochtova Committed by Android (Google) Code Review
Browse files

Merge "Put disallow-safe-boot restriction to system settings to make it...

Merge "Put disallow-safe-boot restriction to system settings to make it accessible during boot." into nyc-dev
parents f1f270a0 6474f0e0
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -8305,6 +8305,16 @@ public final class Settings {
         */
        public static final String BOOT_COUNT = "boot_count";

        /**
         * Whether the safe boot is disallowed.
         *
         * <p>This setting should have the identical value as the corresponding user restriction.
         * The purpose of the setting is to make the restriction available in early boot stages
         * before the user restrictions are loaded.
         * @hide
         */
        public static final String SAFE_BOOT_DISALLOWED = "safe_boot_disallowed";

        /**
         * Settings to backup. This is here so that it's in the same place as the settings
         * keys and easy to update.
+12 −0
Original line number Diff line number Diff line
@@ -425,6 +425,18 @@ public class UserRestrictionsUtils {
                            }
                        }
                    }
                    break;
                case UserManager.DISALLOW_SAFE_BOOT:
                    // Unlike with the other restrictions, we want to propagate the new value to
                    // the system settings even if it is false. The other restrictions modify
                    // settings which could be manually changed by the user from the Settings app
                    // after the policies enforcing these restrictions have been revoked, so we
                    // leave re-setting of those settings to the user.
                    android.provider.Settings.Global.putInt(
                            context.getContentResolver(),
                            android.provider.Settings.Global.SAFE_BOOT_DISALLOWED,
                            newValue ? 1 : 0);
                    break;
            }
        } finally {
            Binder.restoreCallingIdentity(id);
+5 −0
Original line number Diff line number Diff line
@@ -7615,6 +7615,11 @@ public class WindowManagerService extends IWindowManager.Stub
                   + " milliseconds before attempting to detect safe mode.");
        }

        if (Settings.Global.getInt(
                mContext.getContentResolver(), Settings.Global.SAFE_BOOT_DISALLOWED, 0) != 0) {
            return false;
        }

        int menuState = mInputManager.getKeyCodeState(-1, InputDevice.SOURCE_ANY,
                KeyEvent.KEYCODE_MENU);
        int sState = mInputManager.getKeyCodeState(-1, InputDevice.SOURCE_ANY, KeyEvent.KEYCODE_S);