From 4473ad1f1bc49c166fb8ab92ee7a7b91c608135e Mon Sep 17 00:00:00 2001 From: Elizaveta Date: Mon, 22 Apr 2024 16:50:45 +0300 Subject: [PATCH] Fix binding to external authenticator app on Android 14+ 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. --- main/src/main/java/de/blinkt/openvpn/core/ExtAuthHelper.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main/src/main/java/de/blinkt/openvpn/core/ExtAuthHelper.java b/main/src/main/java/de/blinkt/openvpn/core/ExtAuthHelper.java index 391516465..0da8abbbe 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/ExtAuthHelper.java +++ b/main/src/main/java/de/blinkt/openvpn/core/ExtAuthHelper.java @@ -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()); }