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

Commit ade05380 authored by Wei Wang's avatar Wei Wang
Browse files

Always synchronize the OemUnlockAllowed bit to the FRP partition

ag/3023334 tried to synchronize the OemUnlockAllowed bit to the FRP
partition when deice is being unlocked.
However it missed a case when device was unlocked before ag/3023334
landed.
This CL will sync synchronize the OemUnlockAllowed bit on
isOemUnlockAllowed(), and it avoids redundant write by checking if
the bit is already synced.

Bug: 67043266
Bug: 68245782
Test: do factory reset on a device unlocked before ag/3023334 and FRP is
      not enforced
Change-Id: If209757cfbb202e180a5b2c1b5259af6d00aa599
parent 1d47305b
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -178,14 +178,21 @@ public class OemLockService extends SystemService {
            }
        }

        /** Currently MasterClearConfirm will call isOemUnlockAllowed()
         * to sync PersistentDataBlockOemUnlockAllowedBit which
         * is needed before factory reset
         * TODO: Figure out better place to run sync e.g. adding new API
         */
        @Override
        public boolean isOemUnlockAllowed() {
            enforceOemUnlockReadPermission();

            final long token = Binder.clearCallingIdentity();
            try {
                return mOemLock.isOemUnlockAllowedByCarrier() &&
                        mOemLock.isOemUnlockAllowedByDevice();
                boolean allowed = mOemLock.isOemUnlockAllowedByCarrier()
                        && mOemLock.isOemUnlockAllowedByDevice();
                setPersistentDataBlockOemUnlockAllowedBit(allowed);
                return allowed;
            } finally {
                Binder.restoreCallingIdentity(token);
            }
@@ -213,7 +220,8 @@ public class OemLockService extends SystemService {
        final PersistentDataBlockManager pdbm = (PersistentDataBlockManager)
                mContext.getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
        // if mOemLock is PersistentDataBlockLock, then the bit should have already been set
        if (pdbm != null && !(mOemLock instanceof PersistentDataBlockLock)) {
        if (pdbm != null && !(mOemLock instanceof PersistentDataBlockLock)
                && pdbm.getOemUnlockEnabled() != allowed) {
            Slog.i(TAG, "Update OEM Unlock bit in pst partition to " + allowed);
            pdbm.setOemUnlockEnabled(allowed);
        }