Merge "Add feature provider for face unlock" into qt-qpr1-dev
This commit is contained in:
@@ -124,9 +124,9 @@
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="wrap_content"/>
|
||||
<TextView
|
||||
android:id="@+id/face_enroll_introduction_footer_part_2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/security_settings_face_enroll_introduction_footer_part_2"/>
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@@ -990,6 +990,8 @@
|
||||
<string name="security_settings_face_settings_enroll">Set up face unlock</string>
|
||||
<!-- Text shown in face settings explaining what your face can be used for. [CHAR LIMIT=NONE] -->
|
||||
<string name="security_settings_face_settings_footer">Use face unlock to unlock your device, sign in to apps, and confirm payments.\n\nKeep in mind:\nLooking at the phone can unlock it when you don\u2019t intend to.\n\nYour phone can be unlocked by someone else if it\u2019s held up to your face while your eyes are open.\n\nYour phone can be unlocked by someone who looks a lot like you, say, an identical sibling.</string>
|
||||
<!-- Text shown in face settings explaining what your face can be used for. Used when attention checking is not supported. [CHAR LIMIT=NONE] -->
|
||||
<string name="security_settings_face_settings_footer_attention_not_supported">Use face unlock to unlock your device, sign in to apps, and confirm payments.\n\nKeep in mind:\nLooking at the phone can unlock it when you don\u2019t intend to.\n\nYour phone can be unlocked by someone else if it\u2019s held up to your face, even if your eyes are closed.\n\nYour phone can be unlocked by someone who looks a lot like you, say, an identical sibling.</string>
|
||||
<!-- Dialog title shown when the user removes an enrollment [CHAR LIMIT=35] -->
|
||||
<string name="security_settings_face_settings_remove_dialog_title">Delete face data?</string>
|
||||
<!-- Dialog contents shown when the user removes an enrollment [CHAR LIMIT=NONE] -->
|
||||
|
@@ -26,6 +26,7 @@ import android.widget.TextView;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.biometrics.BiometricEnrollIntroduction;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
|
||||
@@ -40,12 +41,15 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
|
||||
private static final String TAG = "FaceIntro";
|
||||
|
||||
private FaceManager mFaceManager;
|
||||
private FaceFeatureProvider mFaceFeatureProvider;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mFaceManager = Utils.getFaceManagerOrNull(this);
|
||||
mFaceFeatureProvider = FeatureFactory.getFactory(getApplicationContext())
|
||||
.getFaceFeatureProvider();
|
||||
|
||||
mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
|
||||
if (WizardManagerHelper.isAnySetupWizard(getIntent())) {
|
||||
@@ -87,6 +91,12 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
|
||||
});
|
||||
}
|
||||
|
||||
final TextView footer2 = findViewById(R.id.face_enroll_introduction_footer_part_2);
|
||||
final int footer2TextResource =
|
||||
mFaceFeatureProvider.isAttentionSupported(getApplicationContext())
|
||||
? R.string.security_settings_face_enroll_introduction_footer_part_2
|
||||
: R.string.security_settings_face_settings_footer_attention_not_supported;
|
||||
footer2.setText(footer2TextResource);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
package com.android.settings.biometrics.face;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/** Feature provider for face unlock */
|
||||
public interface FaceFeatureProvider {
|
||||
/** Returns true if attention checking is supported. */
|
||||
boolean isAttentionSupported(Context context);
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
package com.android.settings.biometrics.face;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
public class FaceFeatureProviderImpl implements FaceFeatureProvider {
|
||||
|
||||
@Override
|
||||
public boolean isAttentionSupported(Context context) {
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -37,6 +37,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
@@ -69,6 +70,7 @@ public class FaceSettings extends DashboardFragment {
|
||||
private List<Preference> mTogglePreferences;
|
||||
private Preference mRemoveButton;
|
||||
private Preference mEnrollButton;
|
||||
private FaceFeatureProvider mFaceFeatureProvider;
|
||||
|
||||
private boolean mConfirmingPassword;
|
||||
|
||||
@@ -119,6 +121,7 @@ public class FaceSettings extends DashboardFragment {
|
||||
mFaceManager = getPrefContext().getSystemService(FaceManager.class);
|
||||
mUserId = getActivity().getIntent().getIntExtra(
|
||||
Intent.EXTRA_USER_ID, UserHandle.myUserId());
|
||||
mFaceFeatureProvider = FeatureFactory.getFactory(getContext()).getFaceFeatureProvider();
|
||||
|
||||
if (mUserManager.getUserInfo(mUserId).isManagedProfile()) {
|
||||
getActivity().setTitle(getActivity().getResources().getString(
|
||||
@@ -192,6 +195,10 @@ public class FaceSettings extends DashboardFragment {
|
||||
final boolean hasEnrolled = mFaceManager.hasEnrolledTemplates(mUserId);
|
||||
mEnrollButton.setVisible(!hasEnrolled);
|
||||
mRemoveButton.setVisible(hasEnrolled);
|
||||
|
||||
if (!mFaceFeatureProvider.isAttentionSupported(getContext())) {
|
||||
removePreference(FaceSettingsAttentionPreferenceController.KEY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -23,6 +23,7 @@ import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.utils.AnnotationSpan;
|
||||
import com.android.settingslib.HelpUtils;
|
||||
import com.android.settingslib.widget.FooterPreference;
|
||||
@@ -34,8 +35,11 @@ public class FaceSettingsFooterPreferenceController extends BasePreferenceContro
|
||||
|
||||
private static final String ANNOTATION_URL = "url";
|
||||
|
||||
private FaceFeatureProvider mProvider;
|
||||
|
||||
public FaceSettingsFooterPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mProvider = FeatureFactory.getFactory(context).getFaceFeatureProvider();
|
||||
}
|
||||
|
||||
public FaceSettingsFooterPreferenceController(Context context) {
|
||||
@@ -55,7 +59,12 @@ public class FaceSettingsFooterPreferenceController extends BasePreferenceContro
|
||||
mContext, mContext.getString(R.string.help_url_face), getClass().getName());
|
||||
final AnnotationSpan.LinkInfo linkInfo =
|
||||
new AnnotationSpan.LinkInfo(mContext, ANNOTATION_URL, helpIntent);
|
||||
|
||||
final int footerRes = mProvider.isAttentionSupported(mContext)
|
||||
? R.string.security_settings_face_settings_footer
|
||||
: R.string.security_settings_face_settings_footer_attention_not_supported;
|
||||
|
||||
preference.setTitle(AnnotationSpan.linkify(
|
||||
mContext.getText(R.string.security_settings_face_settings_footer), linkInfo));
|
||||
mContext.getText(footerRes), linkInfo));
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.accounts.AccountFeatureProvider;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.aware.AwareFeatureProvider;
|
||||
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProvider;
|
||||
import com.android.settings.dashboard.DashboardFeatureProvider;
|
||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
||||
@@ -133,6 +134,8 @@ public abstract class FeatureFactory {
|
||||
|
||||
public abstract AwareFeatureProvider getAwareFeatureProvider();
|
||||
|
||||
public abstract FaceFeatureProvider getFaceFeatureProvider();
|
||||
|
||||
public static final class FactoryNotFoundException extends RuntimeException {
|
||||
public FactoryNotFoundException(Throwable throwable) {
|
||||
super("Unable to create factory. Did you misconfigure Proguard?", throwable);
|
||||
|
@@ -30,6 +30,8 @@ import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.applications.ApplicationFeatureProviderImpl;
|
||||
import com.android.settings.aware.AwareFeatureProvider;
|
||||
import com.android.settings.aware.AwareFeatureProviderImpl;
|
||||
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
||||
import com.android.settings.biometrics.face.FaceFeatureProviderImpl;
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProvider;
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProviderImpl;
|
||||
import com.android.settings.connecteddevice.dock.DockUpdaterFeatureProviderImpl;
|
||||
@@ -84,6 +86,7 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
private ContextualCardFeatureProvider mContextualCardFeatureProvider;
|
||||
private BluetoothFeatureProvider mBluetoothFeatureProvider;
|
||||
private AwareFeatureProvider mAwareFeatureProvider;
|
||||
private FaceFeatureProvider mFaceFeatureProvider;
|
||||
|
||||
@Override
|
||||
public SupportFeatureProvider getSupportFeatureProvider(Context context) {
|
||||
@@ -255,4 +258,12 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
}
|
||||
return mAwareFeatureProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaceFeatureProvider getFaceFeatureProvider() {
|
||||
if (mFaceFeatureProvider == null) {
|
||||
mFaceFeatureProvider = new FaceFeatureProviderImpl();
|
||||
}
|
||||
return mFaceFeatureProvider;
|
||||
}
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ import android.content.Context;
|
||||
import com.android.settings.accounts.AccountFeatureProvider;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.aware.AwareFeatureProvider;
|
||||
import com.android.settings.biometrics.face.FaceFeatureProvider;
|
||||
import com.android.settings.bluetooth.BluetoothFeatureProvider;
|
||||
import com.android.settings.dashboard.DashboardFeatureProvider;
|
||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
||||
@@ -68,6 +69,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
public final ContextualCardFeatureProvider mContextualCardFeatureProvider;
|
||||
public final BluetoothFeatureProvider mBluetoothFeatureProvider;
|
||||
public final AwareFeatureProvider mAwareFeatureProvider;
|
||||
public final FaceFeatureProvider mFaceFeatureProvider;
|
||||
|
||||
public PanelFeatureProvider panelFeatureProvider;
|
||||
public SlicesFeatureProvider slicesFeatureProvider;
|
||||
@@ -114,6 +116,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
panelFeatureProvider = mock(PanelFeatureProvider.class);
|
||||
mBluetoothFeatureProvider = mock(BluetoothFeatureProvider.class);
|
||||
mAwareFeatureProvider = mock(AwareFeatureProvider.class);
|
||||
mFaceFeatureProvider = mock(FaceFeatureProvider.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -215,4 +218,9 @@ public class FakeFeatureFactory extends FeatureFactory {
|
||||
public AwareFeatureProvider getAwareFeatureProvider() {
|
||||
return mAwareFeatureProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaceFeatureProvider getFaceFeatureProvider() {
|
||||
return mFaceFeatureProvider;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user