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

Commit a0c71092 authored by Victor Hsieh's avatar Victor Hsieh Committed by Android (Google) Code Review
Browse files

Merge "Set SECURE_FRP_MODE for backward compatibility on deactivation" into main

parents 7979379f 29846f67
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -275,10 +275,7 @@ public class PersistentDataBlockService extends SystemService {
            if (mFrpEnforced) {
                automaticallyDeactivateFrpIfPossible();
                setOemUnlockEnabledProperty(doGetOemUnlockEnabled());
                // Set the SECURE_FRP_MODE flag, for backward compatibility with clients who use it.
                // They should switch to calling #isFrpActive().
                Settings.Global.putInt(mContext.getContentResolver(),
                        Settings.Global.SECURE_FRP_MODE, mFrpActive ? 1 : 0);
                setOldSettingForBackworkCompatibility(mFrpActive);
            } else {
                formatIfOemUnlockEnabled();
            }
@@ -292,6 +289,13 @@ public class PersistentDataBlockService extends SystemService {
        mInitDoneSignal.countDown();
    }

    private void setOldSettingForBackworkCompatibility(boolean isActive) {
        // Set the SECURE_FRP_MODE flag, for backward compatibility with clients who use it.
        // They should switch to calling #isFrpActive().
        Settings.Global.putInt(mContext.getContentResolver(),
                Settings.Global.SECURE_FRP_MODE, isActive ? 1 : 0);
    }

    private void setOemUnlockEnabledProperty(boolean oemUnlockEnabled) {
        setProperty(OEM_UNLOCK_PROP, oemUnlockEnabled ? "1" : "0");
    }
@@ -628,6 +632,7 @@ public class PersistentDataBlockService extends SystemService {
                Slog.w(TAG, "Upgrading from Android 14 or lower, defaulting FRP secret");
                writeFrpMagicAndDefaultSecret();
                mFrpActive = false;
                setOldSettingForBackworkCompatibility(mFrpActive);
                return true;
            }

@@ -699,6 +704,7 @@ public class PersistentDataBlockService extends SystemService {
    void activateFrp() {
        synchronized (mLock) {
            mFrpActive = true;
            setOldSettingForBackworkCompatibility(mFrpActive);
        }
    }

@@ -740,6 +746,7 @@ public class PersistentDataBlockService extends SystemService {
        if (MessageDigest.isEqual(secret, partitionSecret)) {
            mFrpActive = false;
            Slog.i(TAG, "FRP secret matched, FRP deactivated.");
            setOldSettingForBackworkCompatibility(mFrpActive);
            return true;
        } else {
            Slog.e(TAG,
@@ -1315,6 +1322,7 @@ public class PersistentDataBlockService extends SystemService {
        public boolean deactivateFactoryResetProtectionWithoutSecret() {
            synchronized (mLock) {
                mFrpActive = false;
                setOldSettingForBackworkCompatibility(/* isActive */ mFrpActive);
            }
            return true;
        }