1/n Start adding Face settings (base, intro)
This change refactors common biometric settings code as well to minimize duplicated code in areas such as: Preference Controller EnrollBase EnrollIntro This change also updates ChooseLock to have Face + Pin/Pattern/Pass Bug: 110589286 Test: Fingerprint settings/enrollment still works Test: make -j56 RunSettingsRoboTests Change-Id: Ie35406a01b85617423beece42683ac086e9bc4a7
This commit is contained in:
132
src/com/android/settings/biometrics/BiometricEnrollBase.java
Normal file
132
src/com/android/settings/biometrics/BiometricEnrollBase.java
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.biometrics;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SetupWizardUtils;
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintEnrollEnrolling;
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintSettings;
|
||||
import com.android.settings.core.InstrumentedActivity;
|
||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||
import com.android.setupwizardlib.GlifLayout;
|
||||
|
||||
/**
|
||||
* Base activity for all fingerprint enrollment steps.
|
||||
*/
|
||||
public abstract class BiometricEnrollBase extends InstrumentedActivity
|
||||
implements View.OnClickListener {
|
||||
public static final int RESULT_FINISHED = BiometricSettings.RESULT_FINISHED;
|
||||
public static final int RESULT_SKIP = BiometricSettings.RESULT_SKIP;
|
||||
public static final int RESULT_TIMEOUT = BiometricSettings.RESULT_TIMEOUT;
|
||||
|
||||
protected byte[] mToken;
|
||||
protected int mUserId;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mToken = getIntent().getByteArrayExtra(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
|
||||
if (savedInstanceState != null && mToken == null) {
|
||||
mToken = savedInstanceState.getByteArray(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
|
||||
}
|
||||
mUserId = getIntent().getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
|
||||
resid = SetupWizardUtils.getTheme(getIntent());
|
||||
super.onApplyThemeResource(theme, resid, first);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
initViews();
|
||||
}
|
||||
|
||||
protected void initViews() {
|
||||
getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||
Button nextButton = getNextButton();
|
||||
if (nextButton != null) {
|
||||
nextButton.setOnClickListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected GlifLayout getLayout() {
|
||||
return (GlifLayout) findViewById(R.id.setup_wizard_layout);
|
||||
}
|
||||
|
||||
protected void setHeaderText(int resId, boolean force) {
|
||||
TextView layoutTitle = getLayout().getHeaderTextView();
|
||||
CharSequence previousTitle = layoutTitle.getText();
|
||||
CharSequence title = getText(resId);
|
||||
if (previousTitle != title || force) {
|
||||
if (!TextUtils.isEmpty(previousTitle)) {
|
||||
layoutTitle.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_POLITE);
|
||||
}
|
||||
getLayout().setHeaderText(title);
|
||||
setTitle(title);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setHeaderText(int resId) {
|
||||
setHeaderText(resId, false /* force */);
|
||||
}
|
||||
|
||||
protected Button getNextButton() {
|
||||
return (Button) findViewById(R.id.next_button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == getNextButton()) {
|
||||
onNextButtonClick();
|
||||
}
|
||||
}
|
||||
|
||||
protected void onNextButtonClick() {
|
||||
}
|
||||
|
||||
protected Intent getFingerprintEnrollingIntent() {
|
||||
Intent intent = new Intent();
|
||||
intent.setClassName("com.android.settings", FingerprintEnrollEnrolling.class.getName());
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
|
||||
if (mUserId != UserHandle.USER_NULL) {
|
||||
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
|
||||
}
|
||||
return intent;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user