Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Tencent excellent testing and sharing practical information selection | Android dual card dual standby adaptation-Hidden

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Tencent Youtest is a professional app automated testing platform, which not only provides multi-dimensional testing services such as compatibility testing, remote real machine rental, but also you share-Tencent's internal mobile R & D and testing materials.

Many APP want to get contacts in the user's address book and use the address book relationship chain information to enrich the product functionality. When reading the ContentProvider of the system's contact database, for dual-card dual-standby phones, both phone and SMS data need to identify which card they come from.

Android 5.0began to join the Dual Sim support. The official scheme of Android is very similar to that of mtk. Interested partners can directly move to the implementation of mtk scheme.

Dual-card database adaptation process

Do adaptive development according to the ContentProvider data content of the system, and find the corresponding value of the identification field and the field that distinguishes the two cards. In order to clarify the content of the following, it is agreed here: primary card-0 card, secondary card-1 card.

There are two main database tables: SMS, MMS and phone.

1. Empty the database

If the phone is equipped with security software, it is possible to "contaminate" the database data, emptying the data in the database can ensure the accuracy of the following operations.

two。 Use the system short message program and dialing program to send text messages and make phone calls using 1 card and 2 cards respectively.

Make sure that the system SMS and dialer are used, and the third-party APP will take over the system program, and you need to uninstall the third-party APP before starting the operation.

3. Read the database value and find the value that distinguishes the card slot

For phones that can root, you can directly find the corresponding database file, and use the SQLite viewer to query the values in the database after export.

Location of SMS and MMS database:

/ data/data/com.android.providers.telephony/mmssms.db

Phone database location:

Data/data/data/com.android.providers.contacts/contacts2.db

Note: the corresponding .db-wal and .db-shm files also need to be exported. SQLite introduces log pre-write mode (WAL). If these two files are not exported, the data will not be updated in time.

What are the common types of dual-card database adaptation?

1. New identity field

Common in: Samsung, moto, etc.

For example: SMS database of mobile phone

From the figure above, we can see that in the SMS database table:

The name of the field that identifies the dual card is sim_id, and the value of the field is card 0Mui 0 | | Card 1m Mel 1

This situation is relatively simple. You only need to do APP related to SMS and phone calls:

(1) determine the corresponding card slot

(2) when database operations are needed, add a list of operations for double-card identification fields.

New siminfo tables for 2.mtk series chips

Mobile phones commonly used in mtk series chips

Phenomenon:

The field and value of the card slot are found according to the method in 1, and it is found that when the user changes the card, the corresponding value of the identification field will change, and the corresponding simID value will be + 1 for each new card.

The cause of the problem:

As shown in the figure below, this type of phone creates a new table to record the information of the SIM card. The corresponding uri is: Uri uri = Uri.parse ("content://telephony/siminfo")

Explanation:

Slot field value is 0: primary card

Slot field value is 1: secondary card

Slot field value is-1: this card is not installed in the card slot

As shown in the following figure, the mapping between the sms table and the siminfo table. The simId field in the sms table stores the identification of the card slot in the corresponding _ id,siminfo in the siminfo table.

Note: the siminfo table is maintained by the system, and the third-party APP only needs to read and does not need to "write".

Solution:

(1) establish the mapping relationship.

At a certain trigger time (application startup, monitoring the change of iteminfo database information), trigger the query of the iteminfo table and establish a mapping relationship between the query results.

0Murray 4

1Murray 3

(2) when you need to operate, obtain the mapping value according to the card slot and write it to db.

The accumulation of mtk in dual-card and dual-standby is very profound for a long time, and it has been widely used in the functional machine era. So why bother to create a new table to do this mapping? Why not use the simple treatment of option 1?

Scene:

Using the method of adding fields to the database in 1, for the WCDMA Unicom customized machine (at the same time G card system), what will happen if the user swaps the two cards?

In scenario 1, all the information is directly bound to the double-card identification field in the sms table. If you change the card, you will not be able to tell which SIM card the information comes from. When the above scenario occurs, all the information of the user and the SIM card will be confused.

In scheme 2, because there is a mapping relationship between sms and siminfo, the icc_id in the siminfo table can uniquely identify a SIM card without the possible information confusion caused by changing cards in scheme 1.

Thinking summary:

The existence of option 2 is reasonable because option 1 is also flawed.

3. Add iteminfo table to coolpad series mobile phones

Common in: Coolpad series of mobile phones

Special point: root did not succeed, unable to view the contents of the data/data directory

Phone database adaptation:

Use the tools to query the database

Operation after emptying db: use 0 card and 1 card to call 5520 and 0 card to 10010 respectively. According to the query result of the record, the phone ID field is moduletype, and the corresponding value of the field is 0MMI 1 | | 1Mel 2

SMS database adaptation:

Send 4 SMS messages to 5520 after emptying db, as shown below:

When you use the query tool to query the results, the following figure occurs, where sim_id is usually used as a dual-card identification field in scenario 1, but the value is-1 on this phone. (1, 2, 3, 4 accumulated when you notice the values in the iteminfo field)

Query the result of the iteminfo database table: Uri.parse ("content://mms-sms/itemInfo")

Database table association relationship:

Adaptation method:

(1) each time a piece of data is inserted into the sms table, the iteminfo will add a corresponding record, which is automatically completed by the system provider.

(2) the network_type field value in the data in iteminfo needs to be updated to identify the card slot.

Summary:

Not only do system contacts need database adaptation, but similar adaptation problems may be encountered when system databases are used in the APP development process. At this point, you can handle it in a similar way.

Wen / Tencent excellent Test Li Yanchao

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report