SecurityException: not allowed to perform OP_READ_

2020-06-07 07:32发布

问题:

User is reporting my app crashes with this error trace

java.lang.SecurityException: com.android.phone from uid 10134 not allowed to perform OP_READ_PHONE_STATE
at android.os.Parcel.readException(Parcel.java:1620)
at android.os.Parcel.readException(Parcel.java:1573)
at com.android.internal.telephony.IPhoneSubInfo$Stub$Proxy.getVoiceMailNumberForSubscriber(IPhoneSubInfo.java:858)
at android.telephony.TelephonyManager.getVoiceMailNumber(TelephonyManager.java:2383)
at android.telephony.TelephonyManager.getVoiceMailNumber(TelephonyManager.java:2366)

So far only one user has reported this problem. Several thousand other users are running this version of the app with no apparent problems.

The exception is thrown when we call TelephonyManager.getVoiceMailNumber(). This operation is documented as required the READ_PHONE_STATE permission, which has absolutely, positively been granted.

I tracked down the OP_READ_PHONE_STATE permission to the android.apps.AppOpsManager class but can not figure out exactly what it is unhappy about.

Can anyone explain just what is happening and what needs to be done to fix things.

Thanks, -Ken