Merge "Further Credentials-related clean-up"
This commit is contained in:
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
@@ -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";
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user