How long does a Subscription ID stick around in Android?

2.2k views Asked by At

Starting on API Level 22, there is native support in Android for Dual-SIM devices. At the center of the APIs, there is SubscriptionInfo.getSubscriptionId().

Using these IDs, you can retrieve SmsManagers for each respective SIM card to send SMS and MMS. You can also identify through which SIM card an SMS was received on the SMS_RECEIVED_ACTION, and so on.

However, what is the lifetime of a Subscription ID? Can I store a Subscription ID in a local database and count on it to still be valid and pointing to the same SIM card later? By later, I mean after rebooting the device, removing its SIM card and popping it back in, or even after factory resetting the device.

2

There are 2 answers

2
AudioBubble On BEST ANSWER

I tested the resilience of SubscriptionId myself, using two SIM cards, though on a Single-SIM device, since that is what I had available at the time.

First, I noted the SubscriptionId the system was giving me when SIM Card A was inserted. The SubscriptionId I was getting had a value of 2.

Next, I restarted the device. The SubscriptionId after restart was still 2.

Then, I turned off the device, removed SIM Card A and put in SIM Card B. After turning the device back on, the SubscriptionId changed to 4.

Lastly, I turned the device back off, removed SIM Card B and put SIM Card A back in. After turning the device back on, the SubscriptionId changed back to 2.

In conclusion, it looks like Android assigns a SubscriptionId unique to each SIM Card. The SubscriptionId seems to survive system reboots, and SIM Card removal and reinsertion. I did not test factory resets, but my gut feeling is that it probably will not survive those, since the system would not have any history of interaction with a SIM Card after a factory reset.

0
atrocia6 On

From the Android documentation

The Subscription ID provides an index value (starting at 1) for uniquely identifying installed SIMs (including physical and electronic) used on the device. Through this ID, your app can associate its functionality with various subscription information for a given SIM. This value is stable for a given SIM unless the device is factory reset. However, there may be cases where the same SIM has a different Subscription ID on different devices or different SIMs have the same ID on different devices.