Merge "Schematize Crypto system properties"
This commit is contained in:
@@ -19,8 +19,8 @@ package com.android.settings.development;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.SystemProperties;
|
|
||||||
import android.os.storage.IStorageManager;
|
import android.os.storage.IStorageManager;
|
||||||
|
import android.sysprop.CryptoProperties;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -35,9 +35,6 @@ public class FileEncryptionPreferenceController extends DeveloperOptionsPreferen
|
|||||||
private static final String KEY_CONVERT_FBE = "convert_to_file_encryption";
|
private static final String KEY_CONVERT_FBE = "convert_to_file_encryption";
|
||||||
private static final String KEY_STORAGE_MANAGER = "mount";
|
private static final String KEY_STORAGE_MANAGER = "mount";
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
static final String FILE_ENCRYPTION_PROPERTY_KEY = "ro.crypto.type";
|
|
||||||
|
|
||||||
private final IStorageManager mStorageManager;
|
private final IStorageManager mStorageManager;
|
||||||
|
|
||||||
public FileEncryptionPreferenceController(Context context) {
|
public FileEncryptionPreferenceController(Context context) {
|
||||||
@@ -66,8 +63,7 @@ public class FileEncryptionPreferenceController extends DeveloperOptionsPreferen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
if (!TextUtils.equals("file",
|
if (!TextUtils.equals("file", CryptoProperties.type().orElse("none"))) {
|
||||||
SystemProperties.get(FILE_ENCRYPTION_PROPERTY_KEY, "none" /* default */))) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.development;
|
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 com.google.common.truth.Truth.assertThat;
|
||||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
@@ -26,8 +25,8 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.SystemProperties;
|
|
||||||
import android.os.storage.IStorageManager;
|
import android.os.storage.IStorageManager;
|
||||||
|
import android.sysprop.CryptoProperties;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
@@ -92,7 +91,7 @@ public class FileEncryptionPreferenceControllerTest {
|
|||||||
ReflectionHelpers.setField(mController, "mStorageManager", mStorageManager);
|
ReflectionHelpers.setField(mController, "mStorageManager", mStorageManager);
|
||||||
when(mStorageManager.isConvertibleToFBE()).thenReturn(true);
|
when(mStorageManager.isConvertibleToFBE()).thenReturn(true);
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
SystemProperties.set(FILE_ENCRYPTION_PROPERTY_KEY, "foobar");
|
CryptoProperties.type("foobar");
|
||||||
|
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
@@ -106,7 +105,7 @@ public class FileEncryptionPreferenceControllerTest {
|
|||||||
ReflectionHelpers.setField(mController, "mStorageManager", mStorageManager);
|
ReflectionHelpers.setField(mController, "mStorageManager", mStorageManager);
|
||||||
when(mStorageManager.isConvertibleToFBE()).thenReturn(true);
|
when(mStorageManager.isConvertibleToFBE()).thenReturn(true);
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
SystemProperties.set(FILE_ENCRYPTION_PROPERTY_KEY, "file");
|
CryptoProperties.type("file");
|
||||||
|
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user