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 17 package com.android.systemui.biometrics; 18 19 import android.content.BroadcastReceiver; 20 import android.content.Context; 21 import android.content.Intent; 22 import android.hardware.biometrics.BiometricSourceType; 23 24 import com.android.systemui.dagger.SysUISingleton; 25 26 import javax.inject.Inject; 27 28 /** 29 * Receives broadcasts sent by {@link BiometricNotificationService} and takes 30 * the appropriate action. 31 */ 32 @SysUISingleton 33 public class BiometricNotificationBroadcastReceiver extends BroadcastReceiver { 34 static final String ACTION_SHOW_FACE_REENROLL_DIALOG = "face_action_show_reenroll_dialog"; 35 static final String ACTION_SHOW_FINGERPRINT_REENROLL_DIALOG = 36 "fingerprint_action_show_reenroll_dialog"; 37 38 static final String EXTRA_IS_REENROLL_FORCED = "is_reenroll_forced"; 39 40 private static final String TAG = "BiometricNotificationBroadcastReceiver"; 41 42 private final Context mContext; 43 private final BiometricNotificationDialogFactory mNotificationDialogFactory; 44 @Inject BiometricNotificationBroadcastReceiver( Context context, BiometricNotificationDialogFactory notificationDialogFactory)45 BiometricNotificationBroadcastReceiver( 46 Context context, 47 BiometricNotificationDialogFactory notificationDialogFactory) { 48 mContext = context; 49 mNotificationDialogFactory = notificationDialogFactory; 50 } 51 52 @Override onReceive(Context context, Intent intent)53 public void onReceive(Context context, Intent intent) { 54 final String action = intent.getAction(); 55 56 switch (action) { 57 case ACTION_SHOW_FACE_REENROLL_DIALOG: 58 mNotificationDialogFactory.createReenrollDialog( 59 mContext.getUserId(), 60 mContext::startActivity, 61 BiometricSourceType.FACE, 62 false) 63 .show(); 64 break; 65 case ACTION_SHOW_FINGERPRINT_REENROLL_DIALOG: 66 mNotificationDialogFactory.createReenrollDialog( 67 mContext.getUserId(), 68 mContext::startActivity, 69 BiometricSourceType.FINGERPRINT, 70 intent.getBooleanExtra(EXTRA_IS_REENROLL_FORCED, false)) 71 .show(); 72 break; 73 default: 74 break; 75 } 76 } 77 } 78