1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.settings.biometrics2.ui.model 17 18 import android.content.Context 19 import android.content.Intent 20 import android.os.Bundle 21 import com.android.settings.SetupWizardUtils 22 import com.android.settings.biometrics.BiometricEnrollActivity.EXTRA_SKIP_INTRO 23 import com.google.android.setupcompat.util.WizardManagerHelper 24 import com.google.android.setupcompat.util.WizardManagerHelper.EXTRA_IS_SUW_SUGGESTED_ACTION_FLOW 25 26 /** 27 * Biometric enrollment generic intent data, which includes 28 * 1. isSuw 29 * 2. isAfterSuwOrSuwSuggestedAction 30 * 3. theme 31 * 4. isFromSettingsSummery 32 * 5. isSkipIntro 33 * 6. isSkipFindSensor 34 * 7. a helper method, getSetupWizardExtras 35 */ 36 class EnrollmentRequest( 37 intent: Intent, 38 context: Context, 39 isSetupActivity: Boolean 40 ) { 41 val isSuw: Boolean = isSetupActivity && WizardManagerHelper.isAnySetupWizard(intent) 42 43 val isAfterSuwOrSuwSuggestedAction = (isSetupActivity 44 && (WizardManagerHelper.isDeferredSetupWizard(intent) 45 || WizardManagerHelper.isPortalSetupWizard(intent) 46 || intent.getBooleanExtra(EXTRA_IS_SUW_SUGGESTED_ACTION_FLOW, false))) 47 48 private val _suwExtras = getSuwExtras(isSuw, intent) 49 50 val isSkipIntro = intent.getBooleanExtra(EXTRA_SKIP_INTRO, false) 51 52 val isSkipFindSensor = intent.getBooleanExtra(EXTRA_SKIP_FIND_SENSOR, false) 53 54 val theme = SetupWizardUtils.getTheme(context, intent) 55 56 val suwExtras: Bundle 57 get() = Bundle(_suwExtras) 58 59 /** 60 * Returns a string representation of the object 61 */ toStringnull62 override fun toString(): String { 63 return (javaClass.simpleName + ":{isSuw:" + isSuw 64 + ", isAfterSuwOrSuwSuggestedAction:" + isAfterSuwOrSuwSuggestedAction 65 + "}") 66 } 67 68 companion object { 69 const val EXTRA_SKIP_FIND_SENSOR = "skip_find_sensor" getSuwExtrasnull70 private fun getSuwExtras(isSuw: Boolean, intent: Intent): Bundle { 71 val toIntent = Intent() 72 if (isSuw) { 73 SetupWizardUtils.copySetupExtras(intent, toIntent) 74 } 75 return toIntent.extras ?: Bundle() 76 } 77 } 78 } 79