Skip to content

Commit

Permalink
Fix binding to external authenticator app on Android 14+
Browse files Browse the repository at this point in the history
External authenticator apps may need to start background
activities (for example, to allow users enter a pin code), but
starting from Android 14, if the app bound to the service is
targeting Android 14 or higher, it no longer allows the app that
has the service to start a background activity by default. We
need to add flag BIND_ALLOW_ACTIVITY_STARTS to allow the
external authenticator app to start background activities.
  • Loading branch information
lisa-bella97 authored and schwabe committed Apr 22, 2024
1 parent 4ef3bb1 commit 4473ad1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main/src/main/java/de/blinkt/openvpn/core/ExtAuthHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,9 @@ public void onServiceDisconnected(ComponentName name) {
Intent intent = new Intent(ACTION_CERT_PROVIDER);
intent.setPackage(packagename);

if (!context.bindService(intent, extAuthServiceConnection, Context.BIND_AUTO_CREATE)) {
throw new KeyChainException("could not bind to external authticator app: " + packagename);
if (!context.bindService(intent, extAuthServiceConnection,
Context.BIND_AUTO_CREATE | Context.BIND_ALLOW_ACTIVITY_STARTS)) {
throw new KeyChainException("could not bind to external authenticator app: " + packagename);
}
return new ExternalAuthProviderConnection(context, extAuthServiceConnection, q.take());
}
Expand Down

0 comments on commit 4473ad1

Please sign in to comment.