A SIM card hot plug dynamic detection method and a communication terminal

CN117014820BActive Publication Date: 2026-09-15SHANGHAI CHANGLIAN ZHIRONG COMM TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310941938.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-28
Publication Date
2026-09-15
Estimated Expiration
2043-07-28

AI Technical Summary

Benefits of technology

[0038] The SIM card hot-swapping dynamic detection method and communication terminal provided by this invention cleverly determine the SIM card insertion/removal status by detecting the main battery insertion/removal status, and execute the SIM card power-on/off procedure. Thus, it can support specific device terminals to obtain SIM card hot-swapping function without occupying the device's detect GPIO resources, and without restarting the device system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117014820B_ABST
    Figure CN117014820B_ABST
Patent Text Reader

Abstract

The application provides a SIM card hot plug dynamic detection method and a communication terminal, and the steps include: when a main battery is detected to be inserted or unplugged, a hot plug irq interrupt interface is triggered, and a hot plug system attribute is updated; a power management service is registered on a system side to send a first broadcast message when a change in the hot plug system attribute is monitored; a battery hot plug service is established and started to create a QcRilHook connection, monitor the first broadcast message, obtain hot plug state information, send a RIL message to a QCRIL module through the IQcRilHook, and carry the hot plug state information; the QCRIL module issues a newly added QMI message through an associated function to carry the hot plug state information; a Modem end defines a QMI message callback function to obtain the hot plug state information carried by the QMI message, so that the Modem end can call a SIM card power-on / power-off process and execute it. Therefore, the SIM card hot plug can be supported without occupying a GPIO interface resource.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to communication technology, and more particularly to a method for dynamic detection of SIM card hot-plugging and a communication terminal. Background Technology

[0002] Currently, existing terminals that support SIM card hot-swapping typically require a hot-swapping card slot in their hardware design. This means that each SIM card needs a dedicated detect GPIO interface. If a dual-SIM dual-standby communication terminal is used, it will occupy two GPIO interfaces. The purpose of this GPIO interface is to support the detection of interrupt signals for SIM card insertion / removal.

[0003] For example, the default design of Qualcomm platform SIM cards requires one detect GPIO pin per card. When this GPIO pin is high, it indicates that the SIM card is removed, triggering the SIM card power-down process; when the GPIO pin goes low, it indicates that the SIM card is inserted, triggering the SIM card power-on process. The hot-swapping function of the SIM card is implemented through the changes in the GPIO pin level.

[0004] Other terminals that do not support SIM card hot-swapping do not need this detect GPIO interface, but they need to restart the device after inserting the SIM card in order to load the SIM power-on process.

[0005] Given the above issues and considering the limited GPIO interface resources, if we want to reserve the detect GPIO port for other modules to use, but do not want to have to restart the device every time a SIM card is inserted for it to be recognized properly, there is currently no solution in the existing technology. Summary of the Invention

[0006] Therefore, the main objective of this invention is to provide a dynamic detection method and communication terminal for hot-swapping of SIM cards, so as to support hot-swapping of SIM cards without occupying GPIO interface resources.

[0007] To achieve the above objectives, according to a first aspect of the present invention, a dynamic detection method for hot-swapping of a SIM card is provided for an Android system, the steps of which include:

[0008] Step S100: Based on LinuxPowerSupply, when the device's main battery is plugged in / out, the hotswap irq interrupt interface is triggered, and the hotswap sys property is updated.

[0009] Step S200: The system side registers a power management service to send a first broadcast message carrying the hot-swap status information of the main battery when it detects a change in the hotswap sys property.

[0010] Step S300 establishes and starts the battery hot-swap service to create a QcRilHook connection, while listening for the first broadcast message to obtain the main battery hot-swap status information, so as to send a RIL message through IQcRilHook and carry the main battery hot-swap status information to the QCRIL module.

[0011] In step S400, the QCRIL module sends a newly added QMI message through the association function to carry the hot-swap status information of the main battery.

[0012] Step S500: The Modem defines a QMI message callback function to obtain the main battery hot-swap status information carried in the QMI message, so that the Modem can call and execute the SIM card power-on / power-off process accordingly.

[0013] In a possible preferred embodiment, step S300, which involves establishing and initiating a battery hot-swap service to create a QcRilHook connection, includes:

[0014] Step S310: Create a battery hot-swap service class that inherits from the Android service and start it to implement the QcRilHookCallback callback function. QcRilHookCallback.onQcRilHookReady() is used for callback after QcRilHook connection is successfully created, and QcRilHookCallback.onQcRilHookDisconnected() is used for callback after QcRilHook connection is disconnected. Initialize the QcRilHook interface and pass QcRilHookCallback as a parameter to the interface to create a QcRilHook connection.

[0015] Step S320: Create a BootReceiver class that inherits from the Android BroadcastReceiver class to implement the broadcast mechanism. When the system finishes booting up and the boot broadcast message is received, start the battery hot-swap service.

[0016] In a possible preferred embodiment, step S300, which involves listening to the first broadcast message via the battery hot-swap service to obtain the main battery hot-swap status information, includes:

[0017] In step S330, a new subclass of battery hot-swap receiver is created in the battery hot-swap service class. This subclass inherits from the AndroidBroadcastReceiver class to implement broadcast functionality. The broadcast service is registered with the system using registerReceiver(), and the first broadcast message is listened to using IntentFilter.addAction() to obtain the main battery hot-swap status information.

[0018] In a possible preferred embodiment, step S300, which involves sending a RIL message via IQcRilHook and carrying the main battery hot-swap status information to the QCRIL module, includes:

[0019] Step S340: Add a first RIL message to the IQCRilHook class, implement a battery hot-plug status sending function in the QcRilHook class, and send the first RIL message and a ByteBuffer byte array used to store the main battery hot-plug status information parameters to the QCRIL module through the message sending function.

[0020] In a possible preferred embodiment, step S400, in which the QCRIL module sends a newly added QMI message through an association function to carry the main battery hot-plug status information, includes:

[0021] Step S410 Define a second RIL message in the QCRIL module and associate the first and second RIL messages in the qcril_qmi_oem_hook_map() interface;

[0022] Step S420: Add a main battery hot-plug status request function to qcril_qmi_nas2.cpp in the QCRIL module, and associate the second RIL message and the main battery hot-plug status request function in qcril_qmi_oem_eventlist.h; when the QCRIL module sends the second RIL message, call the main battery hot-plug status request function to send the QMI message.

[0023] In step S430, in the network access service of the QCRIL module, a new QMI message is added and its ID is defined. A new structure for storing the hot-swappable status information of the main battery is added. An array variable for the hot-swappable status information of the main battery and its ID are added to store the structure and the QMI message ID.

[0024] Step S440 associates the QMI message with the main battery hot-swap status information array variable through the nas_message_table_v01() and nas_service_command_messages_v01() interfaces provided by Qualcomm.

[0025] In a possible preferred embodiment, step S500, where the Modem defines a QMI message callback function to obtain the main battery hot-plug status information carried in the QMI message, includes:

[0026] In step S510, the same QMI message, structure, and message array variables are defined in the network access service on the Modem side, just like in steps S430-S440.

[0027] In step S520, the first authentication message and the QMI message ID are defined in qmi_nas.c on the Modem side, and a first hot-plug status request interface is added. The callback function of the first authentication message is bound to the first hot-plug status request interface in the qmi_nasi_cmd_callbacks() interface.

[0028] In step S530, a first request message is added to qmi_nas_msg.h on the Modem side, and its ID is set to be equal to the ID of the main battery hot-swap status information array variable; the main battery hot-swap status request interface is implemented in qmi_nas_msg.c to obtain the main battery hot-swap status parameters carried in the main battery hot-swap status information message array variable according to the defined message ID.

[0029] In a possible preferred embodiment, step S500, the steps performed by the Modem to invoke the SIM card power-on / power-off procedure include:

[0030] Step S540: Add a hot-swap status setting request function to uimdrv.c of the SIM module, and use the main battery hot-swap status parameter as the parameter of the function. The qmi_nas.c obtains the main battery hot-swap status parameter by calling the hot-swap status setting request function, and transmits it to the SIM module.

[0031] In step S550, the SIM module calls the uim_power_up and uim_power_down functions in uimdrv.c respectively to implement the SIM card power-on / power-off process based on the hot-swap status parameters of the main battery.

[0032] To achieve the above objectives, according to a second aspect of the present invention, a communication terminal is also provided for performing the steps of the SIM card hot-plug dynamic detection method as described above, comprising: a SIM card slot unit, a power module, a motherboard, and a communication unit, wherein the power module includes a main battery, an auxiliary battery, and a power management unit, the main battery covering the SIM card slot unit to restrict the insertion / removal of the SIM card in the SIM card slot unit from requiring the main battery to be removed, and the power management unit controlling the auxiliary battery to supply power to maintain the operation of the terminal system when the main battery is removed;

[0033] The motherboard, based on the BSP driver, monitors the main battery insertion / removal status, triggers the hotswap irq interrupt interface, and updates the hotswap sys property.

[0034] The Android system, based on the power management service, sends a first broadcast message carrying the main battery hot-swap status information when it detects a change in the hotswap sys property. It also creates a QcRilHook connection based on the battery hot-swap service, listens for the first broadcast message, obtains the main battery hot-swap status information, and sends a RIL message via IQcRilHook, carrying the main battery hot-swap status information to the QCRIL module. The QCRIL module then sends a newly added QMI message through an associated function, carrying the main battery hot-swap status information.

[0035] The communication unit is used to define QMI message callback functions on the modem side, obtain the main battery hot-swap status information carried in the QMI message, so that the modem side can call and execute the SIM card power-on / power-off process accordingly.

[0036] In a possible preferred embodiment, the communication terminal is a mobile phone.

[0037] In a possible preferred embodiment, the communication terminal is a computer terminal with a network card.

[0038] The SIM card hot-swapping dynamic detection method and communication terminal provided by this invention cleverly determine the SIM card insertion / removal status by detecting the main battery insertion / removal status, and execute the SIM card power-on / off procedure. Thus, it can support specific device terminals to obtain SIM card hot-swapping function without occupying the device's detect GPIO resources, and without restarting the device system. Attached Figure Description

[0039] The accompanying drawings, which form part of this application, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an undue limitation of the invention. In the drawings:

[0040] Figure 1 This is a schematic diagram illustrating the steps of a dynamic detection method for hot-plugging of a SIM card according to the present invention;

[0041] Figure 2 This is a flowchart illustrating the dynamic detection method for hot-plugging of a SIM card according to the present invention.

[0042] Figure 3 This is a schematic diagram of the structure of a communication terminal according to the present invention. Detailed Implementation

[0043] To enable those skilled in the art to better understand the technical solutions of the present invention, the specific technical solutions of the present invention will be clearly and completely described below in conjunction with embodiments, so as to help those skilled in the art further understand the present invention. Obviously, the embodiments described in this application are merely some embodiments of the present invention, and not all embodiments. It should be noted that, for those skilled in the art, the embodiments and features in the embodiments of this application can be combined with each other without departing from the concept of the present invention and without conflict. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the disclosure and protection scope of the present invention.

[0044] Furthermore, the terms "first," "second," "S100," "S200," etc., used in the specification, claims, and drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented in orders other than those described herein. At the same time, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. Unless otherwise expressly specified and limited, the terms "set," "arranged," "installed," "connected," and "linked" should be interpreted broadly, for example, as a fixed connection, a detachable connection, or an integral connection; a mechanical connection or an electrical connection; a direct connection or an indirect connection through an intermediate medium; or a connection within two elements. Those skilled in the art can understand the specific meaning of the above terms in this case according to the specific circumstances and in conjunction with existing technology.

[0045] The inventors noted that the power supply of some existing communication terminals consists of a main battery and an auxiliary battery, and the main battery can be removed and replaced. At the same time, when the main battery is replaced, the auxiliary battery can maintain the terminal's low power consumption operation without system restart. In addition, the SIM card slot unit is located under the main battery board, and the main battery board needs to be removed before the SIM card can be inserted / removed each time the SIM card is replaced.

[0046] Given the structure of the existing communication terminal, in order to realize the hot-swap function of the SIM card without occupying the SIM card detect GPIO resources, the inventors considered monitoring the insertion / removal events of the main battery and using the BSP driver to communicate with the SIM module to control its power-on / power-off process.

[0047] However, the problem is that the SIM module on the Qualcomm platform runs by default in the Modem subsystem, and the BSP driver of this platform cannot communicate directly with the SIM module. Therefore, as... Figures 1 to 2As shown, this invention proposes a dynamic detection method for hot-swapping of SIM cards, the steps of which include:

[0048] Step S100: Based on LinuxPowerSupply, when the device's main battery is plugged in / out, the hotswap irq interrupt interface is triggered, and the hotswap sys property is updated.

[0049] Specifically, the Android platform uses the LinuxPowerSupply open-source battery management project. Therefore, inserting / removing the main battery will trigger the hotswap irq interrupt interface. When the main battery is removed, the interrupt is triggered, and the battery will enter the lowbattery working mode and update the hotswap property parameters. At this time, the Android system can be notified through the uevent mechanism. Similarly, when the battery is inserted, the hotswap sys property parameters will be updated, and the Android system will also be notified through the uevent mechanism.

[0050] Step S200: The system registers a power management service to send a first broadcast message carrying the hot-swap status information of the main battery when a change in the hotswap sys property is detected.

[0051] Specifically, in order to monitor the hotswap sys property, the Android system can register a PowerManagerService at boot to listen for changes in the hotswap sys property. Once the property parameter changes, it will receive a notifier notification, such as sending an "intent.action.ACTION_INHOTSWAP" Broadcast first broadcast message, carrying the status of Battery Hotswap (insertion / removal status).

[0052] Step S300 establishes and starts the battery hot-swap service to create a QcRilHook connection, while listening for the first broadcast message to obtain the main battery hot-swap status information, so as to send a RIL message through IQcRilHook and carry the main battery hot-swap status information to the QCRIL module.

[0053] Specifically, since the Qualcomm platform SIM module runs in the Modem subsystem by default, the BSP driver cannot communicate directly with the SIM module. Therefore, this invention aims to add a Service on the system side to communicate with the SIM module, and to power on or power down the SIM card based on the received "intent.action.ACTION_INHOTSWAP" first broadcast message and the status of Battery Hotswap carried.

[0054] Specifically, the steps in step S300 to establish and start the battery hot-swap service to create a QcRilHook connection include:

[0055] Step S310: Create a `BatteryHotswapService` service class that inherits from `Android Service`. After starting the service using `startService`, implement the `QcRilHookCallback` callback function. `QcRilHookCallback.onQcRilHookReady()` is used for callbacks after a successful QcRilHook connection creation, and `QcRilHookCallback.onQcRilHookDisconnected()` is used for callbacks after a QcRilHook connection is disconnected. Initialize the `QcRilHook` interface and pass `QcRilHookCallback` as a parameter to the interface to create a QcRilHook connection. The result of the connection creation is returned through `QcRilHookCallback`.

[0056] Step S320: Create a BootReceiver class that inherits from the Android BroadcastReceiver class to implement the broadcast mechanism. By listening for the "Intent.ACTION_BOOT_COMPLETED" boot broadcast message, the BatteryHotswapService (battery hot-swap service) will be started when the system finishes booting.

[0057] The step S300, which involves listening to the first broadcast message through the battery hot-swap service to obtain the main battery hot-swap status information, includes:

[0058] In step S330, a new subclass `BatteryHotswapReceiver` is created within the `BatteryHotswapService` service class. The `BatteryHotswapReceiver` class inherits from the `Android BroadcastReceiver` class to implement broadcast functionality. It uses `IntentFilter.addAction()` to listen for the first broadcast message "intent.action.ACTION_INHOTSWAP", and registers the broadcast service with the system using `registerReceiver()`. When the first broadcast message is sent in step S200, `BatteryHotswapReceiver` can receive it. This broadcast functionality allows for timely acquisition of the status of the main battery insertion / removal events.

[0059] Furthermore, the step of sending a RIL message via IQcRilHook and carrying the main battery hot-plug status information to the QCRIL module in step S300 includes:

[0060] In step S340, a new first RIL message (QCRIL_EVT_HOOK_BATTERY_HOTSWAP_STATE=2200) is defined in the Qualcomm IQCRilHook class. In the QcRilHook class, the sendBatteryHotswapState() function is implemented to send the RIL message and the ByteBuffer byte array used to store the status parameters of the main battery insertion / removal event to the QCRIL module through the sendRilOemHookMsg() function.

[0061] In step S400, the QCRIL module sends a newly added QMI message through the association function to carry the hot-swap status information of the main battery.

[0062] Specifically, in the S400, the QCRIL module sends a new QMI message through an association function to carry the main battery hot-swap status information, including the following steps:

[0063] Step S410 defines a second RIL message (QCRIL_REQ_HOOK_BATTERY_HOTSWAP_STATE=2200) in the QCRIL module and associates the first RIL message QCRIL_EVT_HOOK_BATTERY_HOTSWAP_STATE and the second RIL message QCRIL_REQ_HOOK_BATTERY_HOTSWAP_STATE with the qcril_qmi_oem_hook_map() interface.

[0064] In step S420, the `qcril_qmi_nas_request_set_battery_hotswap_state()` function is added to `qcril_qmi_nas2.cpp` in the QCRIL module. The `qcril_qmi_oem_eventlist.h` file associates the second RIL message `QCRIL_REQ_HOOK_BATTERY_HOTSWAP_STATE` with the `qcril_qmi_nas_request_set_battery_hotswap_state()` function. Thus, sending the second RIL message `QCRIL_REQ_HOOK_BATTERY_HOTSWAP_STATE` will invoke the `qcril_qmi_nas_request_set_battery_hotswap_state()` function, which is responsible for sending the QMI message added in subsequent step S430.

[0065] Step S430 adds a QMI message and defines its ID (QMI_BATTERY_HOTSWAP_SET_STATE_REQ_MSG_V01=0x6001) in network_access_service_v01.c of the QMI module, and adds a hotswap_state_set_state_req_msg_v01 structure for storing battery hotswap state. It also adds a hotswap_state_set_state_req_msg_data_v01 information array variable to store the hotswap_state_set_state_req_msg_v01 structure and the message ID.

[0066] Step S440 uses the nas_message_table_v01() and nas_service_command_messages_v01() interfaces provided by Qualcomm to associate the QMI_BATTERY_HOTSWAP_SET_STATE_REQ_MSG_V01 QMI message with the hotswap_state_set_state_req_msg_data_v01 information array variable.

[0067] In this way, the message ID can be used to determine the array variable containing the main battery insertion / removal status information, and then the status information stored in it can be obtained.

[0068] Step S500: The Modem defines a QMI message callback function to obtain the main battery hot-swap status information carried in the QMI message, so that the Modem can call and execute the SIM card power-on / power-off process accordingly.

[0069] The specific steps include:

[0070] Step S510: Since the Modem side also has network_access_service_v01.c, the Modem side needs to define QMI messages, structures, and array variables similar to those in steps S430-S440. Because this part is shared between the AP side and the Modem side, the newly added content is consistent.

[0071] In step S520, a first authentication message NASI_CMD_VAL_SET_MAX_POWER is defined in qmi_nas.c of the Modem. Its message ID is 0x6100, which is equal to the QMI message ID of QMI_BATTERY_HOTSWAP_SET_STATE_REQ_MSG_V01. A first hot-swap state request interface qmi_nasi_hotswap_state_set_req() is added. In the qmi_nasi_cmd_callbacks() interface, the callback function of the first authentication message (NASI_CMD_VAL_SET_MAX_POWER) is bound to the first hot-swap state request interface qmi_nasi_hotswap_state_set_req().

[0072] In step S530, add a first request message MAX_POWER_SET_STATE_VAL_REQ_T01 message ID to the Modem's qmi_nas_msg.h file, matching the message ID defined in hotswap_state_set_state_req_msg_data_v01. Implement the qmi_hotswap_state_set_state_val_req() interface in qmi_nas_msg.c to retrieve the batteryhotswap state parameter carried in hotswap_state_set_state_req_msg_data_v01 based on the message ID defined above.

[0073] Step S540 adds the hotswap_state_set_req() function to the SIM module uimdrv.c, and allows the battery hotswap state parameter to be used as the parameter of this function; when the QMI message value is 0x6100 and is sent to the Modem, the qmi_nasi_hotswap_state_set_req() interface will be called, which calls the qmi_hotswap_state_set_state_val_req() function implemented in step S530 to obtain the battery hotswap state parameter.

[0074] The qmi_nas.c file then calls the hotswap_state_set_req() function to obtain the batteryhotswap state parameter, which is then passed to the SIM module.

[0075] In step S550, the SIM module calls the `uim_power_up` and `uim_power_down` functions provided by Qualcomm in `uimdrv.c` based on the obtained state of the main battery insertion / removal event to implement the SIM card power-on / power-off process. For example, when the main battery is removed, it is determined that the SIM card is removed, and the SIM card power-off procedure is executed. When the main battery is inserted, it is determined that the SIM card is inserted, and the SIM card power-on procedure is executed. This enables the SIM card hot-swapping function without system restart and without occupying GPIO resources.

[0076] On the other hand, corresponding to the above methods, such as Figure 3 As shown, the present invention also provides a communication terminal for performing the steps of the SIM card hot-plugging dynamic detection method as described above, comprising: a SIM card slot unit, a power module, a motherboard, and a communication unit, wherein the power module includes a main battery, an auxiliary battery, and a power management unit, the main battery being covered on the SIM card slot unit to restrict the insertion / removal of the SIM card in the SIM card slot unit from requiring the main battery to be removed, and the power management unit being used to control the auxiliary battery to supply power to maintain the operation of the terminal system when the main battery is removed;

[0077] The motherboard, based on the BSP driver, monitors the main battery insertion / removal status, triggers the hotswap irq interrupt interface, and updates the hotswap sys property to notify the Android system through the uevent mechanism.

[0078] The Android system, based on the power management service, sends a first broadcast message carrying the main battery hot-swap status information when it detects a change in the hotswap sys property. It also creates a QcRilHook connection based on the battery hot-swap service, listens for the first broadcast message, obtains the main battery hot-swap status information, and sends a RIL message via IQcRilHook, carrying the main battery hot-swap status information to the QCRIL module. The QCRIL module then sends a newly added QMI message through an associated function, carrying the main battery hot-swap status information.

[0079] The communication unit is used to define QMI message callback functions on the modem side, obtain the main battery hot-swap status information carried in the QMI message, so that the modem side can call and execute the SIM card power-on / power-off process accordingly.

[0080] In a preferred example, the communication terminal is a mobile phone or a computer terminal with a network card.

[0081] In summary, the SIM card hot-swapping dynamic detection method and communication terminal provided by this invention cleverly determine the SIM card insertion / removal status by detecting the main battery insertion / removal status, thereby executing the SIM card power-on / off procedure. This allows specific device terminals to obtain SIM card hot-swapping functionality without occupying the device's detect GPIO resources, and without needing to restart the device system.

[0082] The preferred embodiments of the present invention disclosed above are merely illustrative of the invention. These preferred embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this specification. This specification selects and specifically describes these embodiments to better explain the principles and practical applications of the invention, thereby enabling those skilled in the art to better understand and utilize the invention. The present invention is limited only by the claims and their full scope and equivalents. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the invention should be included within the protection scope of the invention.

[0083] Those skilled in the art will understand that, besides implementing the system, apparatus, and their modules provided by this invention in purely computer-readable program code, the same program can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, the system, apparatus, and their modules provided by this invention can be considered a hardware component, and the modules included therein for implementing various programs can also be considered structures within the hardware component; alternatively, modules for implementing various functions can be considered both software programs implementing the method and structures within the hardware component.

[0084] Furthermore, all or part of the steps in the methods of the above embodiments can be implemented by a program instructing related hardware. This program is stored in a storage medium and includes several instructions to cause a microcontroller, chip, or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0085] Furthermore, various different implementations of the present invention can be combined arbitrarily, as long as they do not violate the spirit of the present invention, they should also be regarded as the content disclosed in the present invention.

Claims

1. A dynamic detection method for hot-swapping of SIM cards, used in an Android system, comprising the following steps: Step S100: Based on LinuxPowerSupply, when the device's main battery is plugged in / out, the hotswap irq interrupt interface is triggered, and the hotswap sys property is updated. Step S200: The system side registers a power management service to send a first broadcast message carrying the hot-swap status information of the main battery when it detects a change in the hotswap sys property. Step S300 establishes and starts the battery hot-swap service to create a QcRilHook connection, while listening for the first broadcast message to obtain the main battery hot-swap status information, so as to send a RIL message through IQcRilHook and carry the main battery hot-swap status information to the QCRIL module. In step S400, the QCRIL module sends a newly added QMI message through the association function to carry the hot-swap status information of the main battery. Step S500: The Modem defines a QMI message callback function to obtain the main battery hot-swap status information carried in the QMI message, so that the Modem can call and execute the SIM card power-on / power-off process accordingly.

2. The SIM card hot-swap dynamic detection method according to claim 1, wherein step S300, establishing and starting the battery hot-swap service to create a QcRilHook connection, includes: Step S310: Create a battery hot-swap service class that inherits from the Android service and start it to implement the QcRilHookCallback callback function. QcRilHookCallback.onQcRilHookReady() is used for callback after QcRilHook connection is successfully created, and QcRilHookCallback.onQcRilHookDisconnected() is used for callback after QcRilHook connection is disconnected. Initialize the QcRilHook interface and pass QcRilHookCallback as a parameter to the interface to create a QcRilHook connection; Step S320: Create a BootReceiver class that inherits from the Android BroadcastReceiver class to implement the broadcast mechanism. When the system finishes booting up and the boot broadcast message is received, start the battery hot-swap service.

3. The SIM card hot-swap dynamic detection method according to claim 1, wherein step S300, which involves listening to the first broadcast message through the battery hot-swap service to obtain the main battery hot-swap status information, includes: In step S330, a new subclass of battery hot-swap receiver is created in the battery hot-swap service class. This subclass inherits from the AndroidBroadcastReceiver class to implement broadcast functionality. The broadcast service is registered with the system using registerReceiver(), and the first broadcast message is listened to using IntentFilter.addAction() to obtain the main battery hot-swap status information.

4. The SIM card hot-plug dynamic detection method according to claim 1, wherein step S300, which involves sending a RIL message via IQcRilHook and carrying the main battery hot-plug status information to the QCRIL module, includes: Step S340: Add a first RIL message to the IQCRilHook class, implement a battery hot-plug status sending function in the QcRilHook class, and send the first RIL message and a ByteBuffer byte array used to store the main battery hot-plug status information parameters to the QCRIL module through the message sending function.

5. The SIM card hot-plugging dynamic detection method according to claim 4, wherein step S400, in which the QCRIL module sends a newly added QMI message through an association function to carry the main battery hot-plugging status information, includes: Step S410 Define a second RIL message in the QCRIL module and associate the first and second RIL messages in the qcril_qmi_oem_hook_map() interface; Step S420: Add a main battery hot-plug status request function to qcril_qmi_nas2.cpp in the QCRIL module, and associate the second RIL message and the main battery hot-plug status request function in qcril_qmi_oem_eventlist.h; when the QCRIL module sends the second RIL message, call the main battery hot-plug status request function to send the QMI message. In step S430, in the network access service of the QCRIL module, a new QMI message is added and its ID is defined. A new structure for storing the hot-swappable status information of the main battery is added. An array variable for the hot-swappable status information of the main battery and its ID are added to store the structure and the QMI message ID. Step S440 associates the QMI message with the main battery hot-swap status information array variable through the nas_message_table_v01() and nas_service_command_messages_v01() interfaces provided by Qualcomm.

6. The SIM card hot-plug dynamic detection method according to claim 5, wherein step S500, in which the Modem defines a QMI message callback function to obtain the main battery hot-plug status information carried in the QMI message, includes: In step S510, the same QMI message, structure, and message array variables are defined in the network access service on the Modem side, just like in steps S430-S440. In step S520, the first authentication message and the QMI message ID are defined in qmi_nas.c on the Modem side, and a first hot-plug status request interface is added. The callback function of the first authentication message is bound to the first hot-plug status request interface in the qmi_nasi_cmd_callbacks() interface. In step S530, a first request message is added to qmi_nas_msg.h on the Modem side, and its ID is set to be equal to the ID of the main battery hot-swap status information array variable; the main battery hot-swap status request interface is implemented in qmi_nas_msg.c to obtain the main battery hot-swap status parameters carried in the main battery hot-swap status information message array variable according to the defined message ID.

7. The SIM card hot-plugging dynamic detection method according to claim 6, wherein step S500, the step of calling and executing the SIM card power-on / power-off procedure on the Modem side, includes: Step S540: Add a hot-swap status setting request function to uimdrv.c of the SIM module, and use the main battery hot-swap status parameter as the parameter of the function. The qmi_nas.c obtains the main battery hot-swap status parameter by calling the hot-swap status setting request function, and transmits it to the SIM module. In step S550, the SIM module calls the uim_power_up and uim_power_down functions in uimdrv.c respectively to implement the SIM card power-on / power-off process based on the hot-swap status parameters of the main battery.

8. A communication terminal for performing the steps of the SIM card hot-plug dynamic detection method as described in any one of claims 1 to 7, comprising: a SIM card The system includes a SIM card slot unit, a power module, a motherboard, and a communication unit. The power module includes a main battery, an auxiliary battery, and a power management unit. The main battery covers the SIM card slot unit to restrict the insertion / removal of the SIM card from the SIM card slot unit by removing the main battery. The power management unit controls the auxiliary battery to supply power to maintain the operation of the terminal system when the main battery is removed. The motherboard, based on the BSP driver, monitors the main battery insertion / removal status, triggers the hotswap irq interrupt interface, and updates the hotswap sys property. The Android system, based on the power management service, sends a first broadcast message carrying the hot-swap status information of the main battery when it detects a change in the hotswap sys property. Based on the battery hot-swap service, a QcRilHook connection is created, and the first broadcast message is listened to to obtain the main battery hot-swap status information. The RIL message is then sent through IQcRilHook, carrying the main battery hot-swap status information to the QCRIL module. The QCRIL module sends out new QMI messages through the associated function to carry the hot-swap status information of the main battery; The communication unit is used to define QMI message callback functions on the modem side, obtain the main battery hot-swap status information carried in the QMI message, so that the modem side can call and execute the SIM card power-on / power-off process accordingly.

9. The communication terminal according to claim 8, wherein the communication terminal is a mobile phone.

10. The communication terminal according to claim 8, wherein the communication terminal is a computer terminal with a network card.

Citation Information

Patent Citations

  • Device and method for processing hot plug of SIM (Subscriber Identity Module) card and mobile terminal

    CN102761346A

  • Method and device for supplying power to mobile terminal

    CN103369129A