Switch fingerprint setup to biometric setup instead
* Generic, handles both face and fingerprint * Works the same as before for fingerprint * Works the same as fingerprint for face * What else could one ask for? Change-Id: I9ddd7b46548c8107239fdec457bbaae6b12876e6
This commit is contained in:
committed by
Alessandro Astone
parent
799d3cb3b3
commit
103ac80d23
@@ -234,7 +234,7 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".FingerprintActivity"
|
||||
<activity android:name=".BiometricActivity"
|
||||
android:label="@string/activity_label_empty"
|
||||
android:excludeFromRecents="true"
|
||||
android:configChanges="mcc|mnc"
|
||||
@@ -242,7 +242,7 @@
|
||||
android:exported="false"
|
||||
android:windowSoftInputMode="stateAlwaysHidden">
|
||||
<intent-filter>
|
||||
<action android:name="org.lineageos.setupwizard.LINEAGE_FINGERPRINT_SETTINGS" />
|
||||
<action android:name="org.lineageos.setupwizard.LINEAGE_BIOMETRIC_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
29
res/drawable/ic_face.xml
Normal file
29
res/drawable/ic_face.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2019 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
|
||||
-->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/black"
|
||||
android:pathData="M10.25,13c0,0.69-0.56,1.25-1.25,1.25S7.75,13.69,7.75,13S8.31,11.75,9,11.75S10.25,12.31,10.25,13z M15,11.75 c-0.69,0-1.25,0.56-1.25,1.25s0.56,1.25,1.25,1.25s1.25-0.56,1.25-1.25S15.69,11.75,15,11.75z M22,12c0,5.52-4.48,10-10,10 S2,17.52,2,12S6.48,2,12,2S22,6.48,22,12z M20,12c0-0.78-0.12-1.53-0.33-2.24C18.97,9.91,18.25,10,17.5,10 c-3.13,0-5.92-1.44-7.76-3.69c-1.05,2.56-3.14,4.57-5.74,5.55C4.01,11.9,4,11.95,4,12c0,4.41,3.59,8,8,8S20,16.41,20,12z" />
|
||||
<path
|
||||
android:pathData="M0,0h24v24H0V0z" />
|
||||
</vector>
|
@@ -39,14 +39,14 @@
|
||||
style="@style/PageContent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/setup_biometric_summary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/PageSummaryText"
|
||||
android:textSize="16sp"
|
||||
android:paddingLeft="@dimen/content_margin_left"
|
||||
android:layout_marginBottom="@dimen/summary_margin_bottom"
|
||||
android:paddingRight="@dimen/location_text_margin_right"
|
||||
android:text="@string/fingerprint_setup_summary" />
|
||||
android:paddingRight="@dimen/location_text_margin_right"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
@@ -59,9 +59,10 @@
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/fingerprint_setup_backup_lock_method"/>
|
||||
android:text="@string/biometric_setup_backup_lock_method"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/setup_add_biometric"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="24dp"
|
||||
@@ -71,11 +72,10 @@
|
||||
android:drawablePadding="24dp"
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/fingerprint_setup_add_fingerprint"/>
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/setup_fingerprint"
|
||||
android:id="@+id/setup_biometric"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/content_margin_left"
|
||||
@@ -83,8 +83,8 @@
|
||||
android:gravity="center_vertical"
|
||||
android:textSize="16sp"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="@color/fingerprint_setup_text_color"
|
||||
android:text="@string/fingerprint_setup_screen_lock_setup"/>
|
||||
android:textColor="@color/biometric_setup_text_color"
|
||||
android:text="@string/biometric_setup_screen_lock_setup"/>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
@@ -58,10 +58,10 @@
|
||||
</WizardAction>
|
||||
|
||||
<WizardAction wizard:uri="intent:#Intent;action=org.lineageos.setupwizard.LINEAGE_SETTINGS;end" id="lineage_settings">
|
||||
<result wizard:action="fingerprint_settings" />
|
||||
<result wizard:action="biometric_settings" />
|
||||
</WizardAction>
|
||||
|
||||
<WizardAction wizard:uri="intent:#Intent;action=org.lineageos.setupwizard.LINEAGE_FINGERPRINT_SETTINGS;end" id="fingerprint_settings">
|
||||
<WizardAction wizard:uri="intent:#Intent;action=org.lineageos.setupwizard.LINEAGE_BIOMETRIC_SETTINGS;end" id="biometric_settings">
|
||||
<result wizard:action="lockscreen_settings" />
|
||||
</WizardAction>
|
||||
|
||||
|
@@ -31,5 +31,5 @@
|
||||
<color name="header_bg">@color/primary</color>
|
||||
<color name="header_condensed_bg">@color/primary</color>
|
||||
<color name="button_bar_background">@color/primary</color>
|
||||
<color name="fingerprint_setup_text_color">#167C80</color>
|
||||
<color name="biometric_setup_text_color">#167C80</color>
|
||||
</resources>
|
||||
|
@@ -80,14 +80,17 @@
|
||||
<string name="setup_require_cyanogen_label"><b>Require your account password</b> in order to use your device even after a factory reset.</string>
|
||||
<string name="setup_device_locked_instructions"><i>To turn this feature off/on, please go to Settings > Security</i></string>
|
||||
|
||||
<!-- Fingerprint setup -->
|
||||
<string name="settings_fingerprint_setup_title">Select backup screen lock type</string>
|
||||
<string name="settings_fingerprint_setup_details">How would you like to lock your screen?</string>
|
||||
<!-- Biometric setup -->
|
||||
<string name="settings_biometric_setup_title">Select backup screen lock type</string>
|
||||
<string name="settings_biometric_setup_details">How would you like to lock your screen?</string>
|
||||
<string name="fingerprint_setup_title">Fingerprint setup</string>
|
||||
<string name="fingerprint_setup_summary">To use your fingerprint sensor to unlock your screen, you\'ll need to:</string>
|
||||
<string name="fingerprint_setup_backup_lock_method">Setup a secondary unlock method</string>
|
||||
<string name="fingerprint_setup_add_fingerprint">Add your fingerprint</string>
|
||||
<string name="fingerprint_setup_screen_lock_setup">Setup screen lock</string>
|
||||
<string name="face_setup_title">Face setup</string>
|
||||
<string name="face_setup_summary">To use your face to unlock your screen, you\'ll need to:</string>
|
||||
<string name="face_setup_add_face">Add your face</string>
|
||||
<string name="biometric_setup_backup_lock_method">Setup a secondary unlock method</string>
|
||||
<string name="biometric_setup_screen_lock_setup">Setup screen lock</string>
|
||||
<string name="sim_locale_changed">%1$s SIM detected</string>
|
||||
|
||||
<!-- secure lock screen -->
|
||||
|
@@ -80,7 +80,7 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
|
||||
protected static final int EMERGENCY_DIAL_ACTIVITY_REQUEST = 10038;
|
||||
protected static final int WIFI_ACTIVITY_REQUEST = 10004;
|
||||
protected static final int BLUETOOTH_ACTIVITY_REQUEST = 10100;
|
||||
protected static final int FINGERPRINT_ACTIVITY_REQUEST = 10101;
|
||||
protected static final int BIOMETRIC_ACTIVITY_REQUEST = 10101;
|
||||
protected static final int SCREENLOCK_ACTIVITY_REQUEST = 10102;
|
||||
|
||||
private static final int IMMERSIVE_FLAGS =
|
||||
@@ -610,8 +610,8 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
|
||||
case BLUETOOTH_ACTIVITY_REQUEST:
|
||||
sb.append("BLUETOOTH_ACTIVITY_REQUEST");
|
||||
break;
|
||||
case FINGERPRINT_ACTIVITY_REQUEST:
|
||||
sb.append("FINGERPRINT_ACTIVITY_REQUEST");
|
||||
case BIOMETRIC_ACTIVITY_REQUEST:
|
||||
sb.append("BIOMETRIC_ACTIVITY_REQUEST");
|
||||
break;
|
||||
case SCREENLOCK_ACTIVITY_REQUEST:
|
||||
sb.append("SCREENLOCK_ACTIVITY_REQUEST");
|
||||
@@ -652,7 +652,7 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
|
||||
default:
|
||||
break;
|
||||
}
|
||||
case FINGERPRINT_ACTIVITY_REQUEST:
|
||||
case BIOMETRIC_ACTIVITY_REQUEST:
|
||||
switch (resultCode) {
|
||||
case RESULT_OK:
|
||||
sb.append("RESULT_OK");
|
||||
@@ -661,7 +661,7 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
|
||||
sb.append("RESULT_CANCELED");
|
||||
break;
|
||||
case RESULT_SKIP:
|
||||
sb.append("RESULT_FINGERPRINT_SKIP");
|
||||
sb.append("RESULT_BIOMETRIC_SKIP");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
package org.lineageos.setupwizard;
|
||||
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.ACTION_SETUP_FINGERPRINT;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.ACTION_SETUP_BIOMETRIC;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_ALLOW_SKIP;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_AUTO_FINISH;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_DETAILS;
|
||||
@@ -26,48 +26,75 @@ import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_MATERIAL_LIGHT;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_THEME;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_TITLE;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_USE_IMMERSIVE;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.REQUEST_CODE_SETUP_FINGERPRINT;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.REQUEST_CODE_SETUP_BIOMETRIC;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class FingerprintActivity extends SubBaseActivity {
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
|
||||
public static final String TAG = FingerprintActivity.class.getSimpleName();
|
||||
import org.lineageos.setupwizard.util.SetupWizardUtils;
|
||||
|
||||
public class BiometricActivity extends SubBaseActivity {
|
||||
|
||||
public static final String TAG = BiometricActivity.class.getSimpleName();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
final TextView setupBiometricSummary = (TextView) findViewById(R.id.setup_biometric_summary);
|
||||
final TextView setupAddBiometric = (TextView) findViewById(R.id.setup_add_biometric);
|
||||
if (SetupWizardUtils.hasFace(this)) {
|
||||
setupBiometricSummary.setText(getString(R.string.face_setup_summary));
|
||||
setupAddBiometric.setText(R.string.face_setup_add_face);
|
||||
} else {
|
||||
setupBiometricSummary.setText(getString(R.string.fingerprint_setup_summary));
|
||||
setupAddBiometric.setText(R.string.fingerprint_setup_add_fingerprint);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStartSubactivity() {
|
||||
setNextAllowed(true);
|
||||
findViewById(R.id.setup_fingerprint).setOnClickListener(view -> launchFingerprintSetup());
|
||||
findViewById(R.id.setup_biometric).setOnClickListener(view -> launchBiometricSetup());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.setup_fingerprint;
|
||||
return R.layout.setup_biometric;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getTitleResId() {
|
||||
if (SetupWizardUtils.hasFace(this)) {
|
||||
return R.string.face_setup_title;
|
||||
}
|
||||
return R.string.fingerprint_setup_title;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getIconResId() {
|
||||
if (SetupWizardUtils.hasFace(this)) {
|
||||
return R.drawable.ic_face;
|
||||
}
|
||||
return R.drawable.ic_fingerprint;
|
||||
}
|
||||
|
||||
private void launchFingerprintSetup() {
|
||||
Intent intent = new Intent(ACTION_SETUP_FINGERPRINT);
|
||||
private void launchBiometricSetup() {
|
||||
Intent intent = new Intent(ACTION_SETUP_BIOMETRIC);
|
||||
intent.putExtra(EXTRA_FIRST_RUN, true);
|
||||
intent.putExtra(EXTRA_ALLOW_SKIP, true);
|
||||
intent.putExtra(EXTRA_USE_IMMERSIVE, true);
|
||||
intent.putExtra(EXTRA_THEME, EXTRA_MATERIAL_LIGHT);
|
||||
intent.putExtra(EXTRA_AUTO_FINISH, false);
|
||||
/*intent.putExtra(LockPatternUtils.LOCKSCREEN_FINGERPRINT_FALLBACK, true);*/
|
||||
/*intent.putExtra(LockPatternUtils.LOCKSCREEN_BIOMETRIC_FALLBACK, true);*/
|
||||
intent.putExtra(EXTRA_TITLE,
|
||||
getString(R.string.settings_fingerprint_setup_title));
|
||||
getString(getTitleResId()));
|
||||
intent.putExtra(EXTRA_DETAILS,
|
||||
getString(R.string.settings_fingerprint_setup_details));
|
||||
startSubactivity(intent, REQUEST_CODE_SETUP_FINGERPRINT);
|
||||
getString(R.string.settings_biometric_setup_details));
|
||||
intent.putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true);
|
||||
startSubactivity(intent, REQUEST_CODE_SETUP_BIOMETRIC);
|
||||
}
|
||||
}
|
@@ -38,7 +38,7 @@ public class SetupWizardApp extends Application {
|
||||
public static final String ACTION_SETUP_COMPLETE = "org.lineageos.setupwizard.LINEAGE_SETUP_COMPLETE";
|
||||
public static final String ACTION_FINISHED = "org.lineageos.setupwizard.SETUP_FINISHED";
|
||||
public static final String ACTION_SETUP_WIFI = "android.net.wifi.PICK_WIFI_NETWORK";
|
||||
public static final String ACTION_SETUP_FINGERPRINT = "android.settings.FINGERPRINT_SETUP";
|
||||
public static final String ACTION_SETUP_BIOMETRIC = "android.settings.BIOMETRIC_ENROLL";
|
||||
public static final String ACTION_SETUP_LOCKSCREEN = "com.android.settings.SETUP_LOCK_SCREEN";
|
||||
public static final String ACTION_RESTORE_FROM_BACKUP = "com.stevesoltys.seedvault.RESTORE_BACKUP";
|
||||
public static final String ACTION_EMERGENCY_DIAL = "com.android.phone.EmergencyDialer.DIAL";
|
||||
@@ -60,6 +60,7 @@ public class SetupWizardApp extends Application {
|
||||
public static final String EXTRA_RESULT_CODE = "com.android.setupwizard.ResultCode";
|
||||
public static final String EXTRA_PREFS_SHOW_BUTTON_BAR = "extra_prefs_show_button_bar";
|
||||
public static final String EXTRA_PREFS_SET_BACK_TEXT = "extra_prefs_set_back_text";
|
||||
public static final String EXTRA_IS_SETUP_FLOW = "isSetupFlow";
|
||||
|
||||
public static final String KEY_DETECT_CAPTIVE_PORTAL = "captive_portal_detection_enabled";
|
||||
public static final String KEY_SEND_METRICS = "send_metrics";
|
||||
@@ -69,7 +70,7 @@ public class SetupWizardApp extends Application {
|
||||
public static final int REQUEST_CODE_SETUP_WIFI = 0;
|
||||
public static final int REQUEST_CODE_SETUP_CAPTIVE_PORTAL= 4;
|
||||
public static final int REQUEST_CODE_SETUP_BLUETOOTH= 5;
|
||||
public static final int REQUEST_CODE_SETUP_FINGERPRINT = 7;
|
||||
public static final int REQUEST_CODE_SETUP_BIOMETRIC = 7;
|
||||
public static final int REQUEST_CODE_SETUP_LOCKSCREEN = 9;
|
||||
public static final int REQUEST_CODE_RESTORE = 10;
|
||||
|
||||
|
@@ -42,6 +42,7 @@ import android.content.pm.ComponentInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.Binder;
|
||||
import android.os.SystemProperties;
|
||||
@@ -55,7 +56,7 @@ import android.util.Log;
|
||||
|
||||
import org.lineageos.setupwizard.BluetoothSetupActivity;
|
||||
import org.lineageos.setupwizard.ChooseDataSimActivity;
|
||||
import org.lineageos.setupwizard.FingerprintActivity;
|
||||
import org.lineageos.setupwizard.BiometricActivity;
|
||||
import org.lineageos.setupwizard.MobileDataActivity;
|
||||
import org.lineageos.setupwizard.SetupWizardApp;
|
||||
import org.lineageos.setupwizard.SimMissingActivity;
|
||||
@@ -227,6 +228,10 @@ public class SetupWizardUtils {
|
||||
return packageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK);
|
||||
}
|
||||
|
||||
public static boolean hasBiometric(Context context) {
|
||||
return hasFingerprint(context) || hasFace(context);
|
||||
}
|
||||
|
||||
public static boolean hasFingerprint(Context context) {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
if (packageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
|
||||
@@ -238,6 +243,17 @@ public class SetupWizardUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasFace(Context context) {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
if (packageManager.hasSystemFeature(PackageManager.FEATURE_FACE)) {
|
||||
FaceManager faceManager = (FaceManager)
|
||||
context.getSystemService(Context.FACE_SERVICE);
|
||||
return faceManager.isHardwareDetected();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean simMissing() {
|
||||
return PhoneMonitor.getInstance().simMissing();
|
||||
}
|
||||
@@ -246,8 +262,8 @@ public class SetupWizardUtils {
|
||||
if (!hasLeanback(context)) {
|
||||
disableComponent(context, BluetoothSetupActivity.class);
|
||||
}
|
||||
if (!hasFingerprint(context)) {
|
||||
disableComponent(context, FingerprintActivity.class);
|
||||
if (!hasBiometric(context)) {
|
||||
disableComponent(context, BiometricActivity.class);
|
||||
}
|
||||
if (!hasTelephony(context)) {
|
||||
disableComponent(context, MobileDataActivity.class);
|
||||
|
Reference in New Issue
Block a user