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

Commit 43ee1029 authored by joffenberg's avatar joffenberg
Browse files

Remove "storage type" preference from Settings

Since storage type is mandated as hardware-backed, this preference is no longer meaningful.

Bug: 160225361
Test: atest SettingsRoboTests
Change-Id: I9b6c1d6afdd3563201b1e85673acf4d8cb81c0a1
parent 01ec6774
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -5907,12 +5907,6 @@
    <string name="user_credentials_summary">View and modify stored credentials</string>
    <!-- Title of preference group for advance security settings [CHAR LIMIT=30] -->
    <string name="advanced_security_title">Advanced</string>
    <!-- Title of preference of what type of credential storage this device has: hardware or software [CHAR LIMIT=30] -->
    <string name="credential_storage_type">Storage type</string>
    <!-- Summary text for preference showing what type of credential storage this device has when it is stored in a hardware-backed storage (as opposed to "software only") [CHAR LIMIT=NONE] -->
    <string name="credential_storage_type_hardware">Hardware-backed</string>
    <!-- Summary text for preference showing what type of credential storage this device has when it is stored in software only (as opposed to "hardware-backed") [CHAR LIMIT=NONE] -->
    <string name="credential_storage_type_software">Software only</string>
    <!-- Error message for users that aren't allowed to see or modify credentials [CHAR LIMIT=none] -->
    <string name="credentials_settings_not_available">Credentials are not available for this user</string>
    <!-- Sub-heading for a user credential installed to be used by apps and as part of VPN configurations. [CHAR LIMIT=NONE] -->
+0 −6
Original line number Diff line number Diff line
@@ -38,12 +38,6 @@
        android:persistent="false"
        android:order="100">

        <com.android.settingslib.RestrictedPreference
            android:key="credential_storage_type"
            android:title="@string/credential_storage_type"
            android:summary="@string/summary_placeholder"
            settings:userRestriction="no_config_credentials" />

        <Preference
            android:key="trusted_credentials"
            android:title="@string/trusted_credentials"
+0 −49
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.security;

import android.content.Context;
import android.os.UserManager;
import android.security.KeyStore;

import androidx.preference.Preference;

import com.android.settings.R;

public class CredentialStoragePreferenceController extends
        RestrictedEncryptionPreferenceController {

    private static final String KEY_CREDENTIAL_STORAGE_TYPE = "credential_storage_type";
    private final KeyStore mKeyStore;

    public CredentialStoragePreferenceController(Context context) {
        super(context, UserManager.DISALLOW_CONFIG_CREDENTIALS);
        mKeyStore = KeyStore.getInstance();
    }

    @Override
    public String getPreferenceKey() {
        return KEY_CREDENTIAL_STORAGE_TYPE;
    }

    @Override
    public void updateState(Preference preference) {
        preference.setSummary(mKeyStore.isHardwareBacked()
                ? R.string.credential_storage_type_hardware
                : R.string.credential_storage_type_software);
    }
}
+0 −1
Original line number Diff line number Diff line
@@ -73,7 +73,6 @@ public class EncryptionAndCredential extends DashboardFragment {
        controllers.add(new PreferenceCategoryController(context,
                "encryption_and_credentials_status_category").setChildren(
                Arrays.asList(encryptStatusController)));
        controllers.add(new CredentialStoragePreferenceController(context));
        controllers.add(new UserCredentialsPreferenceController(context));
        controllers.add(new ResetCredentialsPreferenceController(context, lifecycle));
        controllers.add(new InstallCertificatePreferenceController(context));
+0 −69
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.security;

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

import android.content.Context;

import androidx.preference.Preference;

import com.android.settings.R;
import com.android.settings.testutils.shadow.ShadowKeyStore;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowKeyStore.class)
public class CredentialStoragePreferenceControllerTest {

    private Context mContext;
    private CredentialStoragePreferenceController mController;
    private Preference mPreference;

    @Before
    public void setUp() {
        mContext = RuntimeEnvironment.application;
        mController = new CredentialStoragePreferenceController(mContext);
        mPreference = new Preference(mContext);
    }

    @Test
    public void updateState_hardwareBacked_showHardwareSummary() {
        ShadowKeyStore.setHardwareBacked(true);

        mController.updateState(mPreference);

        assertThat(mPreference.getSummary())
                .isEqualTo(mContext.getText(R.string.credential_storage_type_hardware));
    }

    @Test
    public void updateState_hardwareBacked_showSoftwareSummary() {
        ShadowKeyStore.setHardwareBacked(false);

        mController.updateState(mPreference);

        assertThat(mPreference.getSummary())
                .isEqualTo(mContext.getText(R.string.credential_storage_type_software));
    }
}
Loading