Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6634c159 authored by joshmccloskey's avatar joshmccloskey
Browse files

Adding slice for Face Enrollment

Fixes: 134965754
Test: Verified slice appears when not enrolled.
Test: Verified slice does not appear when enrolled.
Test: Verified slice disappears after clicking on icon and going back
to settings page.
Change-Id: Id1c4458742ab622df8d5881e926fe54684b36843
parent 24ebff2f
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
<?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="#000000"
        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>
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -974,7 +974,8 @@
    <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] -->
    <string name="security_settings_face_settings_remove_dialog_details">The images and biometric data used by face unlock will be permanently and securely deleted. After removal, you will need your PIN, pattern, or password to unlock your phone, sign in to apps, and confirm payments.</string>
    <!-- Subtitle shown for contextual setting face enrollment [CHAR LIMIT=NONE] -->
    <string name="security_settings_face_settings_context_subtitle">Use face unlock to unlock your phone</string>
    <!-- Fingerprint enrollment and settings --><skip />
    <!-- Title shown for menu item that launches fingerprint settings or enrollment [CHAR LIMIT=22] -->
+5 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.settings.biometrics.BiometricEnrollBase;
import com.android.settings.biometrics.BiometricEnrollSidecar;
import com.android.settings.biometrics.BiometricErrorDialog;
import com.android.settings.biometrics.BiometricsEnrollEnrolling;
import com.android.settings.slices.CustomSliceRegistry;

import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
@@ -184,6 +185,10 @@ public class FaceEnrollEnrolling extends BiometricsEnrollEnrolling {

        // TODO: Have this match any animations that UX comes up with
        if (remaining == 0) {
            // Force the reload of the FaceEnroll slice in case a user has enrolled,
            // this will cause the slice to no longer appear.
            getApplicationContext().getContentResolver().notifyChange(
                    CustomSliceRegistry.FACE_ENROLL_SLICE_URI, null);
            launchFinish(mToken);
        }
    }
+7 −0
Original line number Diff line number Diff line
@@ -72,6 +72,12 @@ public class SettingsContextualCardProvider extends ContextualCardProvider {
                        .setCardName(contextualAdaptiveSleepSliceUri)
                        .setCardCategory(ContextualCard.Category.DEFAULT)
                        .build();
        final ContextualCard contextualFaceSettingsCard =
                ContextualCard.newBuilder()
                        .setSliceUri(CustomSliceRegistry.FACE_ENROLL_SLICE_URI.toString())
                        .setCardName(CustomSliceRegistry.FACE_ENROLL_SLICE_URI.toString())
                        .setCardCategory(ContextualCard.Category.DEFAULT)
                        .build();
        final ContextualCardList cards = ContextualCardList.newBuilder()
                .addCard(wifiCard)
                .addCard(connectedDeviceCard)
@@ -79,6 +85,7 @@ public class SettingsContextualCardProvider extends ContextualCardProvider {
                .addCard(batteryFixCard)
                .addCard(notificationChannelCard)
                .addCard(contextualAdaptiveSleepCard)
                .addCard(contextualFaceSettingsCard)
                .build();

        return cards;
+104 −0
Original line number Diff line number Diff line
/*
 * 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.homepage.contextualcards.slices;


import static android.hardware.biometrics.BiometricConstants.BIOMETRIC_SUCCESS;

import android.app.PendingIntent;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.hardware.biometrics.BiometricManager;
import android.net.Uri;

import androidx.core.graphics.drawable.IconCompat;
import androidx.slice.Slice;
import androidx.slice.builders.ListBuilder;
import androidx.slice.builders.ListBuilder.RowBuilder;
import androidx.slice.builders.SliceAction;

import com.android.settings.R;
import com.android.settings.SubSettings;
import com.android.settings.Utils;
import com.android.settings.biometrics.face.FaceProfileStatusPreferenceController;
import com.android.settings.security.SecuritySettings;
import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.CustomSliceable;
import com.android.settings.slices.SliceBuilderUtils;

public class FaceSetupSlice implements CustomSliceable {

    private final Context mContext;

    public FaceSetupSlice(Context context) {
        mContext = context;
    }

    @Override
    public Slice getSlice() {
        final BiometricManager biometricManager = mContext.getSystemService(BiometricManager.class);
        final PackageManager packageManager = mContext.getPackageManager();
        if (!packageManager.hasSystemFeature(PackageManager.FEATURE_FACE)) {
            // no face hardware
            return null;
        } else if (biometricManager.canAuthenticate() == BIOMETRIC_SUCCESS) {
            // face hardware, and already enrolled
            return null;
        }

        final CharSequence title = mContext.getText(
                R.string.security_settings_face_settings_enroll);
        final ListBuilder listBuilder = new ListBuilder(mContext,
                CustomSliceRegistry.FACE_ENROLL_SLICE_URI, ListBuilder.INFINITY)
                .setAccentColor(Utils.getColorAccentDefaultColor(mContext));
        final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_face_24dp);
        return listBuilder
                .addRow(buildRowBuilder(title,
                        mContext.getText(R.string.security_settings_face_settings_context_subtitle),
                        icon, mContext, getIntent()))
                .build();
    }

    @Override
    public Uri getUri() {
        return CustomSliceRegistry.FACE_ENROLL_SLICE_URI;
    }

    @Override
    public Intent getIntent() {
        return SliceBuilderUtils.buildSearchResultPageIntent(mContext,
                SecuritySettings.class.getName(),
                FaceProfileStatusPreferenceController.KEY_FACE_SETTINGS,
                mContext.getText(R.string.security_settings_face_settings_enroll).toString(),
                SettingsEnums.SLICE)
                .setClassName(mContext.getPackageName(), SubSettings.class.getName());
    }

    private static RowBuilder buildRowBuilder(CharSequence title, CharSequence subTitle,
            IconCompat icon, Context context, Intent intent) {
        final SliceAction primarySliceAction = SliceAction.createDeeplink(
                PendingIntent.getActivity(context, 0, intent, 0), icon, ListBuilder.ICON_IMAGE,
                title);
        return new RowBuilder()
                .setTitleItem(icon, ListBuilder.ICON_IMAGE)
                .setTitle(title)
                .setSubtitle(subTitle)
                .setPrimaryAction(primarySliceAction);
    }
}
 No newline at end of file
Loading