Merge "[Fingerprint] Add fingerprint enroll in setup wizard" into mnc-dev

This commit is contained in:
Maurice Lam
2015-07-15 19:28:05 +00:00
committed by Android (Google) Code Review
22 changed files with 436 additions and 34 deletions

View File

@@ -1434,9 +1434,16 @@
<activity android:name=".fingerprint.FingerprintEnrollFindSensor" android:exported="false"/>
<activity android:name=".fingerprint.FingerprintEnrollEnrolling" android:exported="false"/>
<activity android:name=".fingerprint.FingerprintEnrollFinish" android:exported="false"/>
<activity android:name=".fingerprint.FingerprintEnrollIntroduction"
<activity android:name=".fingerprint.FingerprintEnrollIntroduction" android:exported="false" />
<activity android:name=".fingerprint.SetupFingerprintEnrollOnboard" android:exported="false"/>
<activity android:name=".fingerprint.SetupFingerprintEnrollFindSensor" android:exported="false"/>
<activity android:name=".fingerprint.SetupFingerprintEnrollEnrolling" android:exported="false"/>
<activity android:name=".fingerprint.SetupFingerprintEnrollFinish" android:exported="false"/>
<activity android:name=".fingerprint.SetupFingerprintEnrollIntroduction"
android:exported="true"
android:permission="android.permission.MANAGE_FINGERPRINT">
android:permission="android.permission.MANAGE_FINGERPRINT"
android:theme="@style/SetupWizardDisableAppStartingTheme">
<intent-filter>
<action android:name="android.settings.FINGERPRINT_SETUP" />
<category android:name="android.intent.category.DEFAULT" />

View File

@@ -20,7 +20,7 @@
android:id="@+id/setup_wizard_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/SetupWizardFingerprintStyle">
style="?attr/fingerprint_layout_theme">
<LinearLayout
style="@style/SuwContentFrame"

View File

@@ -20,7 +20,7 @@
android:id="@+id/setup_wizard_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/SetupWizardFingerprintStyle">
style="?attr/fingerprint_layout_theme">
<LinearLayout
style="@style/SuwContentFrame"

View File

@@ -20,7 +20,7 @@
android:id="@+id/setup_wizard_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/SetupWizardFingerprintStyle">
style="?attr/fingerprint_layout_theme">
<LinearLayout
style="@style/SuwContentFrame"

View File

@@ -20,7 +20,7 @@
android:id="@+id/setup_wizard_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/SetupWizardFingerprintStyle">
style="?attr/fingerprint_layout_theme">
<LinearLayout
style="@style/SuwContentFrame"

View File

@@ -20,7 +20,7 @@
android:id="@+id/setup_wizard_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/SetupWizardFingerprintStyle">
style="?attr/fingerprint_layout_theme">
<LinearLayout
style="@style/SuwContentFrame"

View File

@@ -20,7 +20,7 @@
android:id="@+id/setup_wizard_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/SetupWizardFingerprintStyle">
style="?attr/fingerprint_layout_theme">
<LinearLayout
style="@style/SuwContentFrame"

View File

@@ -20,7 +20,7 @@
android:id="@+id/setup_wizard_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/SetupWizardFingerprintStyle">
style="?attr/fingerprint_layout_theme">
<LinearLayout
style="@style/SuwContentFrame"
@@ -58,6 +58,7 @@
android:layout_weight="1"/>
<LinearLayout
android:id="@+id/button_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="-12dp"

View File

@@ -19,7 +19,7 @@
android:id="@+id/setup_wizard_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/SetupWizardFingerprintStyle">
style="?attr/fingerprint_layout_theme">
<LinearLayout
style="@style/SuwContentFrame"

View File

@@ -327,12 +327,18 @@
<item name="android:textColor">@color/warning</item>
</style>
<style name="SetupWizardFingerprintStyle">
<style name="FingerprintLayoutTheme">
<item name="suwBackground">@drawable/fp_enrollment_header</item>
<item name="suwIllustrationAspectRatio">@dimen/fingerprint_illustration_aspect_ratio</item>
<item name="suwDecorPaddingTop">@dimen/fingerprint_decor_padding_top</item>
</style>
<style name="SetupWizardFingerprintLayoutTheme">
<item name="suwBackgroundTile">@drawable/setup_illustration_tile</item>
<item name="suwIllustration">@drawable/setup_illustration_lock_screen</item>
<item name="suwIllustrationHorizontalTile">@drawable/setup_illustration_horizontal_tile</item>
</style>
<style name="TextAppearance.ConfirmDeviceCredentialsErrorText"
parent="android:TextAppearance.Material.Body1">
<item name="android:textColor">@color/warning</item>

View File

@@ -15,6 +15,7 @@
-->
<resources>
<attr name="fingerprint_layout_theme" format="reference" />
<attr name="ic_menu_add" format="reference" />
<attr name="ic_menu_moreoverflow" format="reference" />
<attr name="ic_wps" format="reference" />
@@ -36,6 +37,7 @@
<item name="android:listPreferredItemPaddingStart">@dimen/suw_layout_margin_sides</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
<item name="@*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
<item name="fingerprint_layout_theme">@style/SetupWizardFingerprintLayoutTheme</item>
<item name="ic_menu_add">@drawable/ic_menu_add_dark</item>
<item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
<item name="ic_wps">@drawable/ic_wps_dark</item>
@@ -58,6 +60,7 @@
<item name="android:listPreferredItemPaddingStart">@dimen/suw_layout_margin_sides</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
<item name="@*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
<item name="fingerprint_layout_theme">@style/SetupWizardFingerprintLayoutTheme</item>
<item name="ic_menu_add">@drawable/ic_menu_add_light</item>
<item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
<item name="ic_wps">@drawable/ic_wps_light</item>
@@ -90,6 +93,7 @@
<item name="apnPreferenceStyle">@style/ApnPreference</item>
<item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
<item name="ic_menu_add">@drawable/ic_menu_add_dark</item>
<item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_holo_dark</item>
<item name="ic_wps">@drawable/ic_wps_light</item>

View File

@@ -28,11 +28,9 @@ import android.content.res.Resources;
import android.os.Bundle;
import android.os.UserHandle;
import android.preference.PreferenceFragment;
import android.hardware.fingerprint.FingerprintManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
/**
* Setup Wizard's version of ChooseLockGeneric screen. It inherits the logic and basic structure
@@ -70,14 +68,6 @@ public class SetupChooseLockGeneric extends ChooseLockGeneric {
final SetupWizardListLayout layout = (SetupWizardListLayout) inflater.inflate(
R.layout.setup_choose_lock_generic, container, false);
layout.setHeaderText(getActivity().getTitle());
ListView list = layout.getListView();
final FingerprintManager fpm = (FingerprintManager)
getActivity().getSystemService(Context.FINGERPRINT_SERVICE);
if (fpm != null && fpm.isHardwareDetected()) {
final View footer = inflater.inflate(
R.layout.setup_screen_lock_fingerprint_details, list, false);
list.addFooterView(footer, null, false);
}
final NavigationBar navigationBar = layout.getNavigationBar();
navigationBar.getNextButton().setEnabled(false);

View File

@@ -20,7 +20,6 @@ import android.annotation.Nullable;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
@@ -72,6 +71,10 @@ public class FingerprintEnrollBase extends Activity implements View.OnClickListe
@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
initViews();
}
protected void initViews() {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS |
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);

View File

@@ -213,14 +213,17 @@ public class FingerprintEnrollEnrolling extends FingerprintEnrollBase
}
private void launchFinish(byte[] token) {
Intent intent = new Intent();
intent.setClassName("com.android.settings", FingerprintEnrollFinish.class.getName());
Intent intent = getFinishIntent();
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
startActivity(intent);
setResult(RESULT_FINISHED);
finish();
}
protected Intent getFinishIntent() {
return new Intent(this, FingerprintEnrollFinish.class);
}
private void updateDescription() {
if (mSidecar.getEnrollmentSteps() == -1) {
setHeaderText(R.string.security_settings_fingerprint_enroll_start_title);

View File

@@ -61,8 +61,8 @@ public class FingerprintEnrollFinish extends FingerprintEnrollBase {
@Override
public void onClick(View v) {
if (v.getId() == R.id.add_another_button) {
finish();
startActivity(getEnrollingIntent());
finish();
}
super.onClick(v);
}

View File

@@ -47,22 +47,29 @@ public class FingerprintEnrollIntroduction extends FingerprintEnrollBase {
@Override
protected void onNextButtonClick() {
Intent intent = new Intent();
final String clazz;
Intent intent;
if (!mHasPassword) {
// No fingerprints registered, launch into enrollment wizard.
clazz = FingerprintEnrollOnboard.class.getName();
intent = getOnboardIntent();
} else {
// Lock thingy is already set up, launch directly into find sensor step from wizard.
clazz = FingerprintEnrollFindSensor.class.getName();
intent = getFindSensorIntent();
}
intent.setClassName("com.android.settings", clazz);
startActivityForResult(intent, 0);
}
protected Intent getOnboardIntent() {
return new Intent(this, FingerprintEnrollOnboard.class);
}
protected Intent getFindSensorIntent() {
return new Intent(this, FingerprintEnrollFindSensor.class);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_FINISHED) {
setResult(RESULT_OK);
finish();
} else {
super.onActivityResult(requestCode, resultCode, data);

View File

@@ -57,9 +57,8 @@ public class FingerprintEnrollOnboard extends FingerprintEnrollBase {
}
private void launchChooseLock() {
Intent intent = new Intent();
Intent intent = getChooseLockIntent();
long challenge = getSystemService(FingerprintManager.class).preEnroll();
intent.setClassName("com.android.settings", ChooseLockGeneric.class.getName());
intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY,
DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_DISABLED_PREFS, true);
@@ -68,11 +67,18 @@ public class FingerprintEnrollOnboard extends FingerprintEnrollBase {
startActivityForResult(intent, CHOOSE_LOCK_GENERIC_REQUEST);
}
protected Intent getChooseLockIntent() {
return new Intent(this, ChooseLockGeneric.class);
}
private void launchFindSensor(byte[] token) {
Intent intent = new Intent();
intent.setClassName("com.android.settings", FingerprintEnrollFindSensor.class.getName());
Intent intent = getFindSensorIntent();
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
startActivity(intent);
finish();
}
protected Intent getFindSensorIntent() {
return new Intent(this, FingerprintEnrollFindSensor.class);
}
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (C) 2015 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.fingerprint;
import android.content.Intent;
import android.content.res.Resources;
import android.view.View;
import android.widget.Button;
import com.android.settings.R;
import com.android.settings.SetupWizardUtils;
import com.android.setupwizardlib.view.NavigationBar;
public class SetupFingerprintEnrollEnrolling extends FingerprintEnrollEnrolling
implements NavigationBar.NavigationBarListener {
@Override
protected Intent getFinishIntent() {
final Intent intent = new Intent(this, SetupFingerprintEnrollFinish.class);
SetupWizardUtils.copySetupExtras(getIntent(), intent);
return intent;
}
@Override
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
resid = SetupWizardUtils.getTheme(getIntent());
super.onApplyThemeResource(theme, resid, first);
}
@Override
protected void initViews() {
SetupWizardUtils.setImmersiveMode(this);
final View buttonBar = findViewById(R.id.button_bar);
if (buttonBar != null) {
buttonBar.setVisibility(View.GONE);
}
final NavigationBar navigationBar = getNavigationBar();
navigationBar.setNavigationBarListener(this);
// Enrolling screen auto-advances once the fingerprint is added
navigationBar.getNextButton().setEnabled(false);
}
@Override
protected Button getNextButton() {
return getNavigationBar().getNextButton();
}
@Override
public void onNavigateBack() {
onBackPressed();
}
@Override
public void onNavigateNext() {
onNextButtonClick();
}
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (C) 2015 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.fingerprint;
import android.content.Intent;
import android.content.res.Resources;
import android.view.View;
import android.widget.Button;
import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.R;
import com.android.settings.SetupWizardUtils;
import com.android.setupwizardlib.view.NavigationBar;
public class SetupFingerprintEnrollFindSensor extends FingerprintEnrollFindSensor
implements NavigationBar.NavigationBarListener {
@Override
protected Intent getEnrollingIntent() {
Intent intent = new Intent(this, SetupFingerprintEnrollEnrolling.class);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
SetupWizardUtils.copySetupExtras(getIntent(), intent);
return intent;
}
@Override
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
resid = SetupWizardUtils.getTheme(getIntent());
super.onApplyThemeResource(theme, resid, first);
}
@Override
protected void initViews() {
SetupWizardUtils.setImmersiveMode(this);
final View nextButton = findViewById(R.id.next_button);
if (nextButton != null) {
nextButton.setVisibility(View.GONE);
}
getNavigationBar().setNavigationBarListener(this);
getNavigationBar().getBackButton().setVisibility(View.GONE);
}
@Override
protected Button getNextButton() {
return getNavigationBar().getNextButton();
}
@Override
public void onNavigateBack() {
onBackPressed();
}
@Override
public void onNavigateNext() {
onNextButtonClick();
}
}

View File

@@ -0,0 +1,74 @@
/*
* Copyright (C) 2015 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.fingerprint;
import android.content.Intent;
import android.content.res.Resources;
import android.view.View;
import android.widget.Button;
import com.android.settings.ChooseLockSettingsHelper;
import com.android.settings.R;
import com.android.settings.SetupWizardUtils;
import com.android.setupwizardlib.view.NavigationBar;
public class SetupFingerprintEnrollFinish extends FingerprintEnrollFinish
implements NavigationBar.NavigationBarListener {
@Override
protected Intent getEnrollingIntent() {
Intent intent = new Intent(this, SetupFingerprintEnrollEnrolling.class);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
SetupWizardUtils.copySetupExtras(getIntent(), intent);
return intent;
}
@Override
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
resid = SetupWizardUtils.getTheme(getIntent());
super.onApplyThemeResource(theme, resid, first);
}
@Override
protected void initViews() {
SetupWizardUtils.setImmersiveMode(this);
final View nextButton = findViewById(R.id.next_button);
if (nextButton != null) {
nextButton.setVisibility(View.GONE);
}
final NavigationBar navigationBar = getNavigationBar();
navigationBar.setNavigationBarListener(this);
navigationBar.getBackButton().setVisibility(View.GONE);
}
@Override
protected Button getNextButton() {
return getNavigationBar().getNextButton();
}
@Override
public void onNavigateBack() {
onBackPressed();
}
@Override
public void onNavigateNext() {
onNextButtonClick();
}
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright (C) 2015 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.fingerprint;
import android.content.Intent;
import android.content.res.Resources;
import android.view.View;
import android.widget.Button;
import com.android.settings.R;
import com.android.settings.SetupWizardUtils;
import com.android.setupwizardlib.view.NavigationBar;
public class SetupFingerprintEnrollIntroduction extends FingerprintEnrollIntroduction
implements NavigationBar.NavigationBarListener {
@Override
protected Intent getOnboardIntent() {
final Intent intent = new Intent(this, SetupFingerprintEnrollOnboard.class);
SetupWizardUtils.copySetupExtras(getIntent(), intent);
return intent;
}
@Override
protected Intent getFindSensorIntent() {
final Intent intent = new Intent(this, SetupFingerprintEnrollFindSensor.class);
SetupWizardUtils.copySetupExtras(getIntent(), intent);
return intent;
}
@Override
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
resid = SetupWizardUtils.getTheme(getIntent());
super.onApplyThemeResource(theme, resid, first);
}
@Override
protected void initViews() {
SetupWizardUtils.setImmersiveMode(this);
final View buttonBar = findViewById(R.id.button_bar);
if (buttonBar != null) {
buttonBar.setVisibility(View.GONE);
}
getNavigationBar().setNavigationBarListener(this);
}
@Override
protected Button getNextButton() {
return getNavigationBar().getNextButton();
}
@Override
public void onNavigateBack() {
onBackPressed();
}
@Override
public void onNavigateNext() {
onNextButtonClick();
}
}

View File

@@ -0,0 +1,78 @@
/*
* Copyright (C) 2015 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.fingerprint;
import android.content.Intent;
import android.content.res.Resources;
import android.view.View;
import android.widget.Button;
import com.android.settings.R;
import com.android.settings.SetupChooseLockGeneric;
import com.android.settings.SetupWizardUtils;
import com.android.setupwizardlib.view.NavigationBar;
public class SetupFingerprintEnrollOnboard extends FingerprintEnrollOnboard
implements NavigationBar.NavigationBarListener {
@Override
protected Intent getChooseLockIntent() {
Intent intent = new Intent(this, SetupChooseLockGeneric.class);
SetupWizardUtils.copySetupExtras(getIntent(), intent);
return intent;
}
@Override
protected Intent getFindSensorIntent() {
final Intent intent = new Intent(this, SetupFingerprintEnrollFindSensor.class);
SetupWizardUtils.copySetupExtras(getIntent(), intent);
return intent;
}
@Override
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
resid = SetupWizardUtils.getTheme(getIntent());
super.onApplyThemeResource(theme, resid, first);
}
@Override
protected void initViews() {
SetupWizardUtils.setImmersiveMode(this);
final View nextButton = findViewById(R.id.next_button);
if (nextButton != null) {
nextButton.setVisibility(View.GONE);
}
getNavigationBar().setNavigationBarListener(this);
}
@Override
protected Button getNextButton() {
return getNavigationBar().getNextButton();
}
@Override
public void onNavigateBack() {
onBackPressed();
}
@Override
public void onNavigateNext() {
onNextButtonClick();
}
}