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

Commit 1e9bd27e authored by Eran Messeri's avatar Eran Messeri
Browse files

Further Credentials-related clean-up

Additional clean-up work related to removal of screenlock dependency
from the credentials installation flow:
* Move the CredentialStorage class to security/ so that Enterprise team
  owners could review changes to it.
* Remove the ConfigureKeyGuardDialog class as it is no longer used.
* Remove attempt to unlock KeyStore from VPN settings.
* Remove intents that will no longer be sent from the manifest.

Bug: 120901345
Test: m -j RunSettingsRoboTests
Test: Manual with CtsVerifier
Change-Id: Ia708ede3366892d74c148f3712a63858d5ab53b7
parent bcb64928
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -1249,12 +1249,11 @@
                  android:label="@string/local_backup_password_title"
                  android:exported="false" />

        <activity android:name="CredentialStorage"
        <activity android:name=".security.CredentialStorage"
                android:theme="@style/Transparent"
                android:launchMode="singleTop"
                android:configChanges="orientation|keyboardHidden|screenSize">
            <intent-filter android:priority="1">
                <action android:name="com.android.credentials.UNLOCK" />
                <action android:name="com.android.credentials.INSTALL" />
                <action android:name="com.android.credentials.RESET" />
                <category android:name="android.intent.category.DEFAULT" />
+0 −4
Original line number Diff line number Diff line
@@ -5731,10 +5731,6 @@
    <string name="credentials_erased">Credential storage is erased.</string>
    <!-- Toast message [CHAR LIMIT=30] when credential storage containing private keys and certificates could not be erased (opposite of string credentials_erased) -->
    <string name="credentials_not_erased">Credential storage couldn\u2019t be erased.</string>
    <!-- This string is in a dialog, and the dialog shows up on a device that's managed by a user's company. It lets the user know that they need to have a secure lock screen (PIN, password, or pattern) before they can use credential storage [CHAR LIMIT=NONE] -->
    <string name="credentials_configure_lock_screen_hint">Before you can use credential storage, your device need to have a secure lock screen</string>
    <!-- This string is for the content of the button that leads user to lock screen settings  [CHAR LIMIT=20] -->
    <string name="credentials_configure_lock_screen_button">SET LOCK</string>
    <!-- Title of Usage Access preference item [CHAR LIMIT=30] -->
    <string name="usage_access_title">Apps with usage access</string>
+0 −86
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.app.Activity;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.app.settings.SettingsEnums;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;

import com.android.settings.CredentialStorage;
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.password.ChooseLockGeneric;

/**
 * Prompt for key guard configuration confirmation.
 */
public class ConfigureKeyGuardDialog extends InstrumentedDialogFragment
        implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener {

    public static final String TAG = "ConfigureKeyGuardDialog";

    private boolean mConfigureConfirmed;

    @Override
    public int getMetricsCategory() {
        return SettingsEnums.CONFIGURE_KEYGUARD_DIALOG;
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        return new AlertDialog.Builder(getActivity())
                .setTitle(android.R.string.dialog_alert_title)
                .setMessage(R.string.credentials_configure_lock_screen_hint)
                .setPositiveButton(R.string.credentials_configure_lock_screen_button, this)
                .setNegativeButton(android.R.string.cancel, this)
                .create();
    }

    @Override
    public void onClick(DialogInterface dialog, int button) {
        mConfigureConfirmed = (button == DialogInterface.BUTTON_POSITIVE);
    }

    @Override
    public void onDismiss(DialogInterface dialog) {
        if (mConfigureConfirmed) {
            mConfigureConfirmed = false;
            startPasswordSetup();
            return;
        } else {
            final Activity activity = getActivity();
            if (activity != null) {
                activity.finish();
            }
        }
    }

    @VisibleForTesting
    void startPasswordSetup() {
        Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
        intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY,
                CredentialStorage.MIN_PASSWORD_QUALITY);
        startActivity(intent);
    }
}
+2 −3
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.settings;
package com.android.settings.security;

import android.app.Activity;
import android.app.admin.DevicePolicyManager;
@@ -44,8 +44,8 @@ import androidx.fragment.app.FragmentActivity;
import com.android.internal.widget.LockPatternUtils;
import com.android.org.bouncycastle.asn1.ASN1InputStream;
import com.android.org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
import com.android.settings.R;
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settings.security.ConfigureKeyGuardDialog;
import com.android.settings.vpn2.VpnUtils;

import java.io.ByteArrayInputStream;
@@ -61,7 +61,6 @@ public final class CredentialStorage extends FragmentActivity {

    private static final String TAG = "CredentialStorage";

    public static final String ACTION_UNLOCK = "com.android.credentials.UNLOCK";
    public static final String ACTION_INSTALL = "com.android.credentials.INSTALL";
    public static final String ACTION_RESET = "com.android.credentials.RESET";

+0 −23
Original line number Diff line number Diff line
@@ -56,8 +56,6 @@ public class ConfigDialogFragment extends InstrumentedDialogFragment implements
            ServiceManager.getService(Context.CONNECTIVITY_SERVICE));
    private Context mContext;

    private boolean mUnlocking = false;


    @Override
    public int getMetricsCategory() {
@@ -84,27 +82,6 @@ public class ConfigDialogFragment extends InstrumentedDialogFragment implements
        mContext = context;
    }

    @Override
    public void onResume() {
        super.onResume();

        // Check KeyStore here, so others do not need to deal with it.
        if (!KeyStore.getInstance().isUnlocked()) {
            if (!mUnlocking) {
                // Let us unlock KeyStore. See you later!
                Credentials.getInstance().unlock(mContext);
            } else {
                // We already tried, but it is still not working!
                dismiss();
            }
            mUnlocking = !mUnlocking;
            return;
        }

        // Now KeyStore is always unlocked. Reset the flag.
        mUnlocking = false;
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        Bundle args = getArguments();
Loading