Android: what vendor-specific methods are known for dual-SIM phones to detect a SIM used for SMS?

995 views Asked by At

It is known that Android's SMS is stored as:

CREATE TABLE sms (_id INTEGER PRIMARY KEY,
   thread_id INTEGER,
   address TEXT,
   person INTEGER,
   date INTEGER,
   date_sent INTEGER DEFAULT 0,
   protocol INTEGER,
   read INTEGER DEFAULT 0,
   status INTEGER DEFAULT -1,
   type INTEGER,
   reply_path_present INTEGER,
   subject TEXT,
   body TEXT,
   service_center TEXT,
   locked INTEGER DEFAULT 0,
   error_code INTEGER DEFAULT 0,
   seen INTEGER DEFAULT 0
)

In a situation with dual-SIM phone, can it be expected that some of the parameters can be used to identify which SIM was used to send/receive SMS?

Its known that person == NULL for outgoing SMS in normal case; it doesn't seems that my dual-sim MTK phone has any tendency to remember from which SIM a message was sent in conversation (that's how I replyleaked my work number to friends once...).

Also, I guess there's still only one SMS content folder (or else a severe compatibility problems will come), and ContentValues seemingly can't store much data too.

But, I still want to support both HTC's and MTK's dual sim solutions; what are most known ways to associate incoming/outgoing SMS with a SIM #? How to get sender # for outgoing SMS and get receive path number for incoming?


P.S. "Service center #" is known but rejected solution - I do own two SIMs from one operator in one phone..

1

There are 1 answers

0
Maher Abuthraa On

I would suggest:

1 - build a message app that supports dual sim device. its important to let user make this app as default . because from Android 19 ( Kitkat ) only default message app can access db.

2 - use this way to manage which SIM to use for sending message. https://stackoverflow.com/a/30677542/2267723

3 - implicitly that means your app is for storing data to database for incoming/outgoing/sent messages (SMS/MMS). so of you know which sim is used by#2, then store sim_ID in DB. later you can use it to know which sim managed that message.

enter image description here

A hint: It'd be better to store the ID of SIM ( IMSI / subscriberID) or you can use serialNumer of SIM card to identify SIM, in app if that ID belongs to inserted SIM, then you can refer to message as SIM1 or SIM2 message. otherwise keep message independently from SIM slots ... its not recommended to store message with values 0/1 or 1/2 as identifiers for used sim. because if user changes SIMs or switches them .. there will be a conflict. and you can see its a broken design.

Good luck,