@@ -122,7 +122,7 @@ class AuthenticatorActivity : AppCompatActivity(), TransportHandlerCallback {
122122 }
123123
124124 @RequiresApi(24 )
125- suspend fun handleRequest (options : RequestOptions ) {
125+ suspend fun handleRequest (options : RequestOptions , allowInstant : Boolean = true ) {
126126 try {
127127 val facetId = getFacetId(this , options, callerPackage)
128128 options.checkIsValid(this , facetId, callerPackage)
@@ -135,10 +135,10 @@ class AuthenticatorActivity : AppCompatActivity(), TransportHandlerCallback {
135135 Log .d(TAG , " facetId=$facetId , appName=$appName " )
136136
137137 // Check if we can directly open screen lock handling
138- if (! requiresPrivilege) {
138+ if (! requiresPrivilege && allowInstant ) {
139139 val instantTransport = transportHandlers.firstOrNull { it.isSupported && it.shouldBeUsedInstantly(options) }
140140 if (instantTransport != null && instantTransport.transport in INSTANT_SUPPORTED_TRANSPORTS ) {
141- startTransportHandling(instantTransport.transport)
141+ startTransportHandling(instantTransport.transport, true )
142142 return
143143 }
144144 }
@@ -250,10 +250,18 @@ class AuthenticatorActivity : AppCompatActivity(), TransportHandlerCallback {
250250 return shouldStartTransportInstantly(SCREEN_LOCK )
251251 }
252252
253- fun startTransportHandling (transport : Transport ): Job = lifecycleScope.launchWhenResumed {
253+ @RequiresApi(24 )
254+ fun startTransportHandling (transport : Transport , instant : Boolean = false): Job = lifecycleScope.launchWhenResumed {
254255 val options = options ? : return @launchWhenResumed
255256 try {
256257 finishWithSuccessResponse(getTransportHandler(transport)!! .start(options, callerPackage), transport)
258+ } catch (e: SecurityException ) {
259+ Log .w(TAG , e)
260+ if (instant) {
261+ handleRequest(options, false )
262+ } else {
263+ finishWithError(SECURITY_ERR , e.message ? : e.javaClass.simpleName)
264+ }
257265 } catch (e: CancellationException ) {
258266 Log .w(TAG , e)
259267 // Ignoring cancellation here
0 commit comments