1 /* 2 * Copyright (C) 2024 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.plugins 18 19 import android.os.IBinder 20 import android.view.View 21 import com.android.systemui.plugins.annotations.ProvidesInterface 22 23 /** 24 * Plugin for experimental "Contextual Auth" features. 25 * 26 * These plugins will get raw access to low-level events about the user's environment, such as 27 * moving in/out of trusted locations, connection status of trusted devices, auth attempts, etc. 28 * They will also receive callbacks related to system events & transitions to enable prototypes on 29 * sensitive surfaces like lock screen and BiometricPrompt. 30 * 31 * Note to rebuild the plugin jar run: m PluginDummyLib 32 */ 33 @ProvidesInterface(action = AuthContextPlugin.ACTION, version = AuthContextPlugin.VERSION) 34 interface AuthContextPlugin : Plugin { 35 36 /** 37 * Called in the background when the plugin is enabled. 38 * 39 * This is a good time to ask your friendly [saucier] to cook up something special. The 40 * [Plugin.onCreate] can also be used for initialization. 41 */ activatednull42 fun activated(saucier: Saucier) 43 44 /** 45 * Called when a [SensitiveSurface] is first shown. 46 * 47 * This may be called repeatedly if the state of the surface changes after it is shown. For 48 * example, [SensitiveSurface.BiometricPrompt.isCredential] will change if the user falls back 49 * to a credential-based auth method. 50 */ 51 fun onShowingSensitiveSurface(surface: SensitiveSurface) 52 53 /** 54 * Called when a [SensitiveSurface] sensitive surface is hidden. 55 * 56 * This method may still be called without [onShowingSensitiveSurface] in cases of rapid 57 * dismissal and plugins implementations should typically be idempotent. 58 */ 59 fun onHidingSensitiveSurface(surface: SensitiveSurface) 60 61 companion object { 62 /** Plugin action. */ 63 const val ACTION = "com.android.systemui.action.PLUGIN_AUTH_CONTEXT" 64 /** Plugin version. */ 65 const val VERSION = 1 66 } 67 68 /** Information about a sensitive surface in the framework, which the Plugin may augment. */ 69 sealed interface SensitiveSurface { 70 71 /** Information about the BiometricPrompt that is being shown to the user. */ 72 data class BiometricPrompt(val view: View? = null, val isCredential: Boolean = false) : 73 SensitiveSurface 74 75 /** Information about bouncer. */ 76 data class LockscreenBouncer(val view: View? = null) : SensitiveSurface 77 } 78 79 /** Ask for the special. */ 80 interface Saucier { 81 82 /** What [flavor] would you like? */ getSaucenull83 fun getSauce(flavor: String): IBinder? 84 } 85 } 86