microsoftconnect / ms-intune-app-sdk-android

Intune App SDK for Android enables data protection features and mobile app management via Microsoft Intune
45 stars 18 forks source link

App crashes with INTUNE SDK integrated throws java.lang.SecurityException: getCallState: Neither user 10325 nor current process has android.permission.READ_PHONE_STATE. #77

Closed pa-chihaya-katagi closed 3 years ago

pa-chihaya-katagi commented 3 years ago

Describe the bug: When I do a fresh install of the app and launch the app, it crashes.

Exception is thrown because phone permissions are not allowed. If I allow phone permissions before launching the app, it will not crash.

To Reproduce

Steps to reproduce the behavior:

  1. Install a new app.
  2. Launch the app.
  3. App crashes.

Expected behavior: App should not crash.

Screenshots and logs:

--------- beginning of crash 10-08 09:06:05.634 E/AndroidRuntime(30048): FATAL EXCEPTION: main 10-08 09:06:05.634 E/AndroidRuntime(30048): Process: net.phoneappli.people.dev, PID: 30048 10-08 09:06:05.634 E/AndroidRuntime(30048): java.lang.RuntimeException: Unable to resume activity {net.phoneappli.people.dev/com.microsoft.intune.mam.client.app.startup.MAMStartupActivity}: java.lang.SecurityException: getCallState: Neither user 10325 nor current process has android.permission.READ_PHONE_STATE. 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4761) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4794) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:54) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2214) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.os.Handler.dispatchMessage(Handler.java:106) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.os.Looper.loopOnce(Looper.java:201) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.os.Looper.loop(Looper.java:288) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.app.ActivityThread.main(ActivityThread.java:7842) 10-08 09:06:05.634 E/AndroidRuntime(30048): at java.lang.reflect.Method.invoke(Native Method) 10-08 09:06:05.634 E/AndroidRuntime(30048): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 10-08 09:06:05.634 E/AndroidRuntime(30048): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) 10-08 09:06:05.634 E/AndroidRuntime(30048): Caused by: java.lang.SecurityException: getCallState: Neither user 10325 nor current process has android.permission.READ_PHONE_STATE. 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.os.Parcel.createExceptionOrNull(Parcel.java:2425) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.os.Parcel.createException(Parcel.java:2409) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.os.Parcel.readException(Parcel.java:2392) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.os.Parcel.readException(Parcel.java:2334) 10-08 09:06:05.634 E/AndroidRuntime(30048): at com.android.internal.telecom.ITelecomService$Stub$Proxy.getCallStateUsingPackage(ITelecomService.java:2578) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.telecom.TelecomManager.getCallState(TelecomManager.java:1803) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.telephony.TelephonyManager.getCallState(TelephonyManager.java:5707) 10-08 09:06:05.634 E/AndroidRuntime(30048): at com.phoneappli.pacd.Manager.LifecycleHandler.onActivityResumed(LifecycleHandler.java:70) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.app.Application.dispatchActivityResumed(Application.java:416) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.app.Activity.dispatchActivityResumed(Activity.java:1397) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.app.Activity.onResume(Activity.java:1950) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1476) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.app.Activity.performResume(Activity.java:8191) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4751) 10-08 09:06:05.634 E/AndroidRuntime(30048): ... 13 more 10-08 09:06:05.634 E/AndroidRuntime(30048): Caused by: android.os.RemoteException: Remote stack trace: 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.app.ContextImpl.enforce(ContextImpl.java:2178) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:2206) 10-08 09:06:05.634 E/AndroidRuntime(30048): at android.content.ContextWrapper.enforceCallingOrSelfPermission(ContextWrapper.java:905) 10-08 09:06:05.634 E/AndroidRuntime(30048): at com.android.server.telecom.TelecomServiceImpl.canReadPhoneState(TelecomServiceImpl.java:2323) 10-08 09:06:05.634 E/AndroidRuntime(30048): at com.android.server.telecom.TelecomServiceImpl.access$300(TelecomServiceImpl.java:78) 10-08 09:06:05.634 E/AndroidRuntime(30048): 10-08 09:06:05.634 E/ApplicationManager(30048): Uncaught exception. thread=main 10-08 09:06:05.634 E/ApplicationManager(30048): java.lang.RuntimeException: Unable to resume activity {net.phoneappli.people.dev/com.microsoft.intune.mam.client.app.startup.MAMStartupActivity}: java.lang.SecurityException: getCallState: Neither user 10325 nor current process has android.permission.READ_PHONE_STATE. 10-08 09:06:05.634 E/ApplicationManager(30048): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4761) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4794) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:54) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2214) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.os.Handler.dispatchMessage(Handler.java:106) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.os.Looper.loopOnce(Looper.java:201) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.os.Looper.loop(Looper.java:288) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.app.ActivityThread.main(ActivityThread.java:7842) 10-08 09:06:05.634 E/ApplicationManager(30048): at java.lang.reflect.Method.invoke(Native Method) 10-08 09:06:05.634 E/ApplicationManager(30048): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 10-08 09:06:05.634 E/ApplicationManager(30048): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) 10-08 09:06:05.634 E/ApplicationManager(30048): Caused by: java.lang.SecurityException: getCallState: Neither user 10325 nor current process has android.permission.READ_PHONE_STATE. 10-08 09:06:05.634 E/ApplicationManager(30048): at android.os.Parcel.createExceptionOrNull(Parcel.java:2425) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.os.Parcel.createException(Parcel.java:2409) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.os.Parcel.readException(Parcel.java:2392) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.os.Parcel.readException(Parcel.java:2334) 10-08 09:06:05.634 E/ApplicationManager(30048): at com.android.internal.telecom.ITelecomService$Stub$Proxy.getCallStateUsingPackage(ITelecomService.java:2578) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.telecom.TelecomManager.getCallState(TelecomManager.java:1803) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.telephony.TelephonyManager.getCallState(TelephonyManager.java:5707) 10-08 09:06:05.634 E/ApplicationManager(30048): at com.phoneappli.pacd.Manager.LifecycleHandler.onActivityResumed(LifecycleHandler.java:70) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.app.Application.dispatchActivityResumed(Application.java:416) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.app.Activity.dispatchActivityResumed(Activity.java:1397) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.app.Activity.onResume(Activity.java:1950) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1476) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.app.Activity.performResume(Activity.java:8191) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4751) 10-08 09:06:05.634 E/ApplicationManager(30048): ... 13 more 10-08 09:06:05.634 E/ApplicationManager(30048): Caused by: android.os.RemoteException: Remote stack trace: 10-08 09:06:05.634 E/ApplicationManager(30048): at android.app.ContextImpl.enforce(ContextImpl.java:2178) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:2206) 10-08 09:06:05.634 E/ApplicationManager(30048): at android.content.ContextWrapper.enforceCallingOrSelfPermission(ContextWrapper.java:905) 10-08 09:06:05.634 E/ApplicationManager(30048): at com.android.server.telecom.TelecomServiceImpl.canReadPhoneState(TelecomServiceImpl.java:2323) 10-08 09:06:05.634 E/ApplicationManager(30048): at com.android.server.telecom.TelecomServiceImpl.access$300(TelecomServiceImpl.java:78) 10-08 09:06:05.634 E/ApplicationManager(30048):

Smartphone (please complete the following information):

Intune App SDK for Android (please complete the following information):

codylund commented 3 years ago

Hi @pa-chihaya-katagi, thanks for your report! Currently, the MAM SDK does not require android.permission.READ_PHONE_STATE or invoke TelephonyManager.getCallState() and should not impact usages of it. It appears that your app or another non-MAM dependency invokes this method.

Based on the [Android docs for TelephonyManager.getCallState()](https://developer.android.com/reference/android/telephony/TelephonyManager#getCallState()), your observation is the expected behavior. The READ_PHONE_STATE permission is now required for applications targeting API level 31+.

pa-chihaya-katagi commented 3 years ago

@codylund Thank you! I understand now. I did not do enough research. I'm sorry. I will check the product code again.

codylund commented 3 years ago

Thanks for confirming, @pa-chihaya-katagi! Closing this issue, because we believe the behavior is expected. Feel free to reopen if you discover otherwise.