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

Commit c3838f85 authored by Elliott Hughes's avatar Elliott Hughes Committed by Gerrit Code Review
Browse files

Merge "Remove OEM_UNLOCK_PROP usage" into main

parents 204576da bab174bf
Loading
Loading
Loading
Loading
+0 −15
Original line number Diff line number Diff line
@@ -170,7 +170,6 @@ public class PersistentDataBlockService extends SystemService {
    static final int MAX_DATA_BLOCK_SIZE = 1024 * 100;

    public static final int DIGEST_SIZE_BYTES = 32;
    private static final String OEM_UNLOCK_PROP = "sys.oem_unlock_allowed";
    private static final String FLASH_LOCK_PROP = "ro.boot.flash.locked";
    private static final String FLASH_LOCK_LOCKED = "1";
    private static final String FLASH_LOCK_UNLOCKED = "0";
@@ -274,7 +273,6 @@ public class PersistentDataBlockService extends SystemService {
            enforceChecksumValidity();
            if (mFrpEnforced) {
                automaticallyDeactivateFrpIfPossible();
                setOemUnlockEnabledProperty(doGetOemUnlockEnabled());
                setOldSettingForBackworkCompatibility(mFrpActive);
            } else {
                formatIfOemUnlockEnabled();
@@ -302,10 +300,6 @@ public class PersistentDataBlockService extends SystemService {
        }
    }

    private void setOemUnlockEnabledProperty(boolean oemUnlockEnabled) {
        setProperty(OEM_UNLOCK_PROP, oemUnlockEnabled ? "1" : "0");
    }

    @Override
    public void onBootPhase(int phase) {
        // Wait for initialization in onStart to finish
@@ -341,7 +335,6 @@ public class PersistentDataBlockService extends SystemService {
                formatPartitionLocked(true);
            }
        }
        setOemUnlockEnabledProperty(enabled);
    }

    private void enforceOemUnlockReadPermission() {
@@ -808,17 +801,9 @@ public class PersistentDataBlockService extends SystemService {
            channel.force(true);
        } catch (IOException e) {
            Slog.e(TAG, "unable to access persistent partition", e);
            return;
        } finally {
            setOemUnlockEnabledProperty(enabled);
        }
    }

    @VisibleForTesting
    void setProperty(String name, String value) {
        SystemProperties.set(name, value);
    }

    private boolean doGetOemUnlockEnabled() {
        DataInputStream inputStream;
        try {
+0 −11
Original line number Diff line number Diff line
@@ -86,7 +86,6 @@ public class PersistentDataBlockServiceTest {
    private File mDataBlockFile;
    private File mFrpSecretFile;
    private File mFrpSecretTmpFile;
    private String mOemUnlockPropertyValue;
    private boolean mIsUpgradingFromPreV = false;

    @Mock private UserManager mUserManager;
@@ -104,13 +103,6 @@ public class PersistentDataBlockServiceTest {
            signalInitDone();
        }

        @Override
        void setProperty(String key, String value) {
            // Override to capture the value instead of actually setting the property.
            assertThat(key).isEqualTo("sys.oem_unlock_allowed");
            mOemUnlockPropertyValue = value;
        }

        @Override
        boolean isUpgradingFromPreVRelease() {
            return mIsUpgradingFromPreV;
@@ -598,7 +590,6 @@ public class PersistentDataBlockServiceTest {

        mInterface.setOemUnlockEnabled(true);
        assertThat(mInterface.getOemUnlockEnabled()).isTrue();
        assertThat(mOemUnlockPropertyValue).isEqualTo("1");
    }

    @Test
@@ -635,7 +626,6 @@ public class PersistentDataBlockServiceTest {
        // The current implementation does not check digest before set or get the oem unlock bit.
        tamperWithDigest();
        mInterface.setOemUnlockEnabled(true);
        assertThat(mOemUnlockPropertyValue).isEqualTo("1");
        tamperWithDigest();
        assertThat(mInterface.getOemUnlockEnabled()).isTrue();
    }
@@ -676,7 +666,6 @@ public class PersistentDataBlockServiceTest {

        mInternalInterface.forceOemUnlockEnabled(true);

        assertThat(mOemUnlockPropertyValue).isEqualTo("1");
        assertThat(readBackingFile(mPdbService.getOemUnlockDataOffset(), 1).array())
                .isEqualTo(new byte[] { 1 });
    }