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

Commit 94add587 authored by Joe Bolinger's avatar Joe Bolinger Committed by Automerger Merge Worker
Browse files

Add handoff activity to parental consent flow. am: fb515ed6

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/15029584

Change-Id: Ia81d929181c4820ef55b4663f9807597e05ae040
parents 5ae80144 fb515ed6
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1823,6 +1823,10 @@
            android:exported="false"
            android:screenOrientation="portrait"/>

        <activity android:name=".biometrics.BiometricHandoffActivity"
                  android:exported="false"
                  android:screenOrientation="portrait"/>

        <!-- Must not be exported -->
        <activity android:name=".biometrics.BiometricEnrollActivity$InternalActivity"
            android:exported="false"
+24 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2021 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.
  -->

<com.google.android.setupdesign.GlifLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    style="?attr/face_layout_theme"
    android:id="@+id/setup_wizard_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
</com.google.android.setupdesign.GlifLayout>
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
@@ -1008,6 +1008,10 @@
    <string name="biometric_settings_use_biometric_unlock_phone">Unlocking your phone</string>
    <!-- Text shown on a toggle which allows or disallows the device to use biometric for authentication. [CHAR LIMIT=50] -->
    <string name="biometric_settings_use_biometric_for_apps">Authentication in apps</string>
    <!-- Message shown during enrollment to prompt a child to give the device to a parent or guardian. [CHAR LIMIT=NONE]-->
    <string name="biometric_settings_hand_back_to_guardian">Hand the phone back to your parent</string>
    <!-- Button text shown during enrollment to proceed after a child user has handed the device to a parent or guardian. [CHAR LIMIT=22] -->
    <string name="biometric_settings_hand_back_to_guardian_ok">OK</string>
    <!-- Title of dialog shown when the user tries to skip setting up a screen lock, warning them of potential consequences of not doing so [CHAR LIMIT=30]-->
    <string name="lock_screen_intro_skip_title">Skip screen lock?</string>
+21 −5
Original line number Diff line number Diff line
@@ -69,6 +69,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
    private static final int REQUEST_CONFIRM_LOCK = 2;
    // prompt for parental consent options
    private static final int REQUEST_CHOOSE_OPTIONS = 3;
    // prompt hand phone back to parent after enrollment
    private static final int REQUEST_HANDOFF_PARENT = 4;

    public static final int RESULT_SKIP = BiometricEnrollBase.RESULT_SKIP;

@@ -303,14 +305,23 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
                    final boolean isStillPrompting = mParentalConsentHelper.launchNext(
                            this, REQUEST_CHOOSE_OPTIONS, resultCode, data);
                    if (!isStillPrompting) {
                        Log.d(TAG, "Enrollment options set, starting enrollment now");

                        Log.d(TAG, "Enrollment options set, requesting handoff");
                        launchHandoffToParent();
                    }
                } else {
                    Log.d(TAG, "Unknown or cancelled parental consent");
                    setResult(RESULT_CANCELED);
                    finish();
                }
                break;
            case REQUEST_HANDOFF_PARENT:
                if (resultCode == RESULT_OK) {
                    Log.d(TAG, "Enrollment options set, starting enrollment");
                    mParentalOptions = mParentalConsentHelper.getConsentResult();
                    mParentalConsentHelper = null;
                    startEnroll();
                    }
                } else {
                    Log.d(TAG, "Unknown or cancelled parental consent");
                    Log.d(TAG, "Unknown or cancelled handoff");
                    setResult(RESULT_CANCELED);
                    finish();
                }
@@ -492,6 +503,11 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
        mMultiBiometricEnrollHelper.startNextStep();
    }

    private void launchHandoffToParent() {
        final Intent intent = BiometricUtils.getHandoffToParentIntent(this, getIntent());
        startActivityForResult(intent, REQUEST_HANDOFF_PARENT);
    }

    @Override
    public int getMetricsCategory() {
        return SettingsEnums.BIOMETRIC_ENROLL_ACTIVITY;
+76 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.app.settings.SettingsEnums;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.settings.R;

import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupdesign.GlifLayout;

/**
 * Prompts the user to hand the device to their parent or guardian.
 */
public class BiometricHandoffActivity extends BiometricEnrollBase {

    @Nullable
    private FooterButton mPrimaryFooterButton;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.biometric_handoff);

        setHeaderText(R.string.biometric_settings_hand_back_to_guardian);

        final GlifLayout layout = getLayout();
        mFooterBarMixin = layout.getMixin(FooterBarMixin.class);
        mFooterBarMixin.setPrimaryButton(getPrimaryFooterButton());
    }

    @NonNull
    protected FooterButton getPrimaryFooterButton() {
        if (mPrimaryFooterButton == null) {
            mPrimaryFooterButton = new FooterButton.Builder(this)
                    .setText(R.string.biometric_settings_hand_back_to_guardian_ok)
                    .setButtonType(FooterButton.ButtonType.NEXT)
                    .setListener(this::onNextButtonClick)
                    .setTheme(R.style.SudGlifButton_Primary)
                    .build();
        }
        return mPrimaryFooterButton;
    }

    @Override
    protected void onNextButtonClick(View view) {
        setResult(RESULT_OK);
        finish();
    }

    @Override
    public int getMetricsCategory() {
        // TODO (b/188847063): add new category
        return SettingsEnums.BIOMETRIC_ENROLL_ACTIVITY;
    }
}
Loading