callkeep icon indicating copy to clipboard operation
callkeep copied to clipboard

doesn't work on android 12 devices

Open humbledroid opened this issue 4 years ago • 3 comments

The example app works fine on pre android 12 devices, and it also works on android 12 device, if the target sdk and compile sdk is kept at 30.

It throws this error and doesn't ask for any permissions

java.lang.SecurityException: Neither user 10353 nor current process has android.permission.READ_PHONE_NUMBERS.
	at android.os.Parcel.createExceptionOrNull(Parcel.java:2437)
	at android.os.Parcel.createException(Parcel.java:2421)
	at android.os.Parcel.readException(Parcel.java:2404)
	at android.os.Parcel.readException(Parcel.java:2346)
	at com.android.internal.telecom.ITelecomService$Stub$Proxy.getPhoneAccount(ITelecomService.java:1926)
	at android.telecom.TelecomManager.getPhoneAccount(TelecomManager.java:1483)
	at io.wazo.callkeep.CallKeepModule.hasPhoneAccount(CallKeepModule.java:636)
	at io.wazo.callkeep.CallKeepModule.hasPhoneAccount(CallKeepModule.java:490)
	at io.wazo.callkeep.CallKeepModule.handleMethodCall(CallKeepModule.java:177)
	at com.github.cloudwebrtc.flutter_callkeep.FlutterCallkeepPlugin.onMethodCall(FlutterCallkeepPlugin.java:69)
	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:296)
	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:320)
	at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$AIEPqY6mWzaNK15HekX9bftoAXs.run(Unknown Source:12)
	at android.os.Handler.handleCallback(Handler.java:938)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loopOnce(Looper.java:226)
	at android.os.Looper.loop(Looper.java:313)
	at android.app.ActivityThread.main(ActivityThread.java:8633)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1133)
Caused by: android.os.RemoteException: Remote stack trace:
	at android.app.ContextImpl.enforce(ContextImpl.java:2273)
	at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:2301)
	at android.content.ContextWrapper.enforceCallingOrSelfPermission(ContextWrapper.java:922)
	at com.android.server.telecom.TelecomServiceImpl.canGetPhoneAccount(TelecomServiceImpl.java:2580)
	at com.android.server.telecom.TelecomServiceImpl.access$1100(TelecomServiceImpl.java:95)

humbledroid avatar Apr 08 '22 19:04 humbledroid

@carotkut94 did you figure out this error?

cmarshallls avatar Nov 10 '22 22:11 cmarshallls

@carotkut94 I also would be interested in a solution.

janhelwich avatar Nov 30 '22 13:11 janhelwich

@carotkut94 we fixed this issue by asking for permissions to the phone before checking if they have a phone account. We used the permission_handler package and added this line before we checked for phone accounts.

await Permission.phone.request();
bool hasPhoneAccount = await _callKeep.hasPhoneAccount();

also we had to add READ_PHONE_NUMBERS to our android manifest permissions.

<uses-permission android:name="android.permission.BIND_TELECOM_CONNECTION_SERVICE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />

cmarshallls avatar Dec 06 '22 14:12 cmarshallls