Skip to content

java.lang.SecurityException: getSubscriberIdForSubscriber #1

@grant-h

Description

@grant-h

Trying to get the SIM server running, but it is unable to get the IMSI due to permissions issues it seems.
I tried adding permissions to the manifest, but the required ones as stated in https://developer.android.com/reference/android/telephony/TelephonyManager#getSubscriberId() cannot be granted to normal apps.
Any suggestions to fix this? I could also just get the IMSI through dialer commands, but it would be nice to be able to swap SIMs.

Strangely, getIccAuthentication still works, even though it still has the same requirements as getSubscriberId, as I see RILD messages and no exceptions on that API call.

OS Version: Android 12
API version: same as build.gradle
Device: Pixel 6

Build using command line gradle, installed debug APK, and ran shell script provided.

Exception:

05-25 14:32:23.822  2666  2666 E AndroidRuntime: FATAL EXCEPTION: main
05-25 14:32:23.822  2666  2666 E AndroidRuntime: PID: 2666
05-25 14:32:23.822  2666  2666 E AndroidRuntime: java.lang.SecurityException: getSubscriberIdForSubscriber: Package android does not belong to 2000
05-25 14:32:23.822  2666  2666 E AndroidRuntime: 	at android.os.Parcel.createExceptionOrNull(Parcel.java:2425)
05-25 14:32:23.822  2666  2666 E AndroidRuntime: 	at android.os.Parcel.createException(Parcel.java:2409)
05-25 14:32:23.822  2666  2666 E AndroidRuntime: 	at android.os.Parcel.readException(Parcel.java:2392)
05-25 14:32:23.822  2666  2666 E AndroidRuntime: 	at android.os.Parcel.readException(Parcel.java:2334)
05-25 14:32:23.822  2666  2666 E AndroidRuntime: 	at com.android.internal.telephony.IPhoneSubInfo$Stub$Proxy.getSubscriberIdForSubscriber(IPhoneSubInfo.java:1161)
05-25 14:32:23.822  2666  2666 E AndroidRuntime: 	at android.telephony.TelephonyManager.getSubscriberId(TelephonyManager.java:4106)
05-25 14:32:23.822  2666  2666 E AndroidRuntime: 	at android.telephony.TelephonyManager.getSubscriberId(TelephonyManager.java:4085)
05-25 14:32:23.822  2666  2666 E AndroidRuntime: 	at com.worthdoingbadly.simserver.SimServerMain.main(SimServerMain.java:40)
05-25 14:32:23.822  2666  2666 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
05-25 14:32:23.822  2666  2666 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)
05-25 14:32:23.822  2666  2666 E AndroidRuntime: Error reporting crash

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions