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

Commit e798c078 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Schematize Crypto system properties"

parents 3826f5ec 3737da3a
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -19,10 +19,9 @@ package com.android.settings.development;
import android.content.Context;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.os.storage.IStorageManager;
import android.text.TextUtils;

import android.sysprop.CryptoProperties;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;

@@ -36,9 +35,6 @@ public class FileEncryptionPreferenceController extends DeveloperOptionsPreferen
    private static final String KEY_CONVERT_FBE = "convert_to_file_encryption";
    private static final String KEY_STORAGE_MANAGER = "mount";

    @VisibleForTesting
    static final String FILE_ENCRYPTION_PROPERTY_KEY = "ro.crypto.type";

    private final IStorageManager mStorageManager;

    public FileEncryptionPreferenceController(Context context) {
@@ -67,8 +63,7 @@ public class FileEncryptionPreferenceController extends DeveloperOptionsPreferen

    @Override
    public void updateState(Preference preference) {
        if (!TextUtils.equals("file",
                SystemProperties.get(FILE_ENCRYPTION_PROPERTY_KEY, "none" /* default */))) {
        if (!TextUtils.equals("file", CryptoProperties.type().orElse("none"))) {
            return;
        }

+3 −7
Original line number Diff line number Diff line
@@ -16,9 +16,6 @@

package com.android.settings.development;

import static com.android.settings.development.FileEncryptionPreferenceController
        .FILE_ENCRYPTION_PROPERTY_KEY;

import static com.google.common.truth.Truth.assertThat;

import static org.mockito.ArgumentMatchers.anyBoolean;
@@ -29,9 +26,8 @@ import static org.mockito.Mockito.when;

import android.content.Context;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.storage.IStorageManager;

import android.sysprop.CryptoProperties;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;

@@ -96,7 +92,7 @@ public class FileEncryptionPreferenceControllerTest {
        ReflectionHelpers.setField(mController, "mStorageManager", mStorageManager);
        when(mStorageManager.isConvertibleToFBE()).thenReturn(true);
        mController.displayPreference(mPreferenceScreen);
        SystemProperties.set(FILE_ENCRYPTION_PROPERTY_KEY, "foobar");
        CryptoProperties.type("foobar");

        mController.updateState(mPreference);

@@ -110,7 +106,7 @@ public class FileEncryptionPreferenceControllerTest {
        ReflectionHelpers.setField(mController, "mStorageManager", mStorageManager);
        when(mStorageManager.isConvertibleToFBE()).thenReturn(true);
        mController.displayPreference(mPreferenceScreen);
        SystemProperties.set(FILE_ENCRYPTION_PROPERTY_KEY, "file");
        CryptoProperties.type("file");

        mController.updateState(mPreference);