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

Commit f48206e3 authored by Maggie Benthall's avatar Maggie Benthall
Browse files

Fix NPE in SecuritySettings.onResume()

when DISALLOW_CONFIG_CREDENTIALS is true.

Bug: 10405192
Change-Id: Id364ba3cd86151b504158bc253559d0da5e26273
parent dbd2f759
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ public class SecuritySettings extends RestrictedSettingsFragment
    private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive";

    private PackageManager mPM;
    DevicePolicyManager mDPM;
    private DevicePolicyManager mDPM;

    private ChooseLockSettingsHelper mChooseLockSettingsHelper;
    private LockPatternUtils mLockPatternUtils;
@@ -165,9 +165,6 @@ public class SecuritySettings extends RestrictedSettingsFragment


        // Add options for device encryption
        DevicePolicyManager dpm =
                (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);

        mIsPrimary = UserHandle.myUserId() == UserHandle.USER_OWNER;

        if (!mIsPrimary) {
@@ -183,7 +180,7 @@ public class SecuritySettings extends RestrictedSettingsFragment
        }

        if (mIsPrimary) {
            switch (dpm.getStorageEncryptionStatus()) {
            switch (mDPM.getStorageEncryptionStatus()) {
            case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE:
                // The device is currently encrypted.
                addPreferencesFromResource(R.xml.security_settings_encrypted);
@@ -247,8 +244,8 @@ public class SecuritySettings extends RestrictedSettingsFragment

        // Credential storage
        final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
        mKeyStore = KeyStore.getInstance(); // needs to be initialized for onResume()
        if (!um.hasUserRestriction(UserManager.DISALLOW_CONFIG_CREDENTIALS)) {
            mKeyStore = KeyStore.getInstance();
            Preference credentialStorageType = root.findPreference(KEY_CREDENTIAL_STORAGE_TYPE);

            final int storageSummaryRes =