Hot plug stability guarantee method of Android system and hot plug system

By adopting hot-swap detection algorithm and anti-shake algorithm in the Android system, combined with dynamic adjustment strategies of the driver management module and resource management module, the delay problem of Android system when detecting hot-swap events is solved, and the system's response speed and user experience are improved.

CN119987877APending Publication Date: 2025-05-13镁佳(北京)科技有限公司
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202510085098.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-20
Publication Date
2025-05-13

Smart Images

  • Figure CN119987877A_ABST
    Figure CN119987877A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of hot plug, and discloses a hot plug stability guarantee method of an Android system and a hot plug system.The method comprises the steps that when the Android system is started, a drive management module optimizes a hot plug drive program based on a preset compatibility framework and determines operation modes corresponding to all SD card types; the event detection module is used for detecting whether a hot plug event exists in the Android system or not in real time by adopting a hot plug detection algorithm and an anti-jitter algorithm; the drive management module is used for adjusting the operation mode of a hot plug drive program according to the SD card type of the hot plug event; and the resource management module is used for dynamically adjusting a memory allocation strategy based on the operation mode and responding to the hot plug event by adopting a preset reserved memory. According to the method provided by the embodiment of the invention, the hot plug detection algorithm and the anti-jitter algorithm are adopted, the hot plug event is monitored in real time, and the delay of the Android system during detection of the hot plug event is reduced, so that the use experience of a user is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of hot-plugging technology, and in particular to a hot-plugging stability assurance method and a hot-plugging system for an Android system. Background Art

[0002] As one of the most popular mobile operating systems in the world, Android system provides users with a wealth of extended functions due to its openness and customizability. Among them, hot-swap technology is a function that users use frequently.

[0003] In the related art, there is often a certain delay when the Android system detects hot plug events, which causes the system to be unable to respond to the plug action in time, thereby affecting the user's experience. Therefore, how to reduce the delay when the Android system detects hot plug events, thereby improving the user's experience, has become a problem that needs to be solved. Summary of the invention

[0004] In view of this, the present disclosure provides a hot-plug stability assurance method and a hot-plug system for an Android system to solve the problem of how to reduce the delay of the Android system when detecting hot-plug events and improve the user experience.

[0005] On the one hand, the present disclosure provides a hot-swap stability assurance method for an Android system, which is applied to a hot-swap system. The hot-swap system includes: a driver management module, an event detection module and a resource management module. The method includes: the driver management module, when the Android system is started, optimizes the hot-swap driver program based on a preset compatibility framework, and determines the operation mode corresponding to each SD card type; the event detection module, using a hot-swap detection algorithm and an anti-jitter algorithm, detects in real time whether there is a hot-swap event in the Android system, and when there is a hot-swap event, sends the hot-swap event to the driver management module and the resource management module; the driver management module adjusts the operation mode of the hot-swap driver program according to the SD card type of the hot-swap event; the resource management module, based on the operation mode, dynamically adjusts the memory allocation strategy, and uses a preset reserved memory to respond to the hot-swap event.

[0006] On the other hand, the present disclosure also provides a hot-swap system, which includes a driver management module, an event detection module and a resource management module, wherein: the driver management module is used to optimize the hot-swap driver program based on a preset compatibility framework when the Android system is started, and determine the operation mode corresponding to each SD card type; the event detection module is used to use a hot-swap detection algorithm and an anti-jitter algorithm to detect in real time whether there is a hot-swap event in the Android system, and when a hot-swap event occurs, send the hot-swap event to the driver management module and the resource management module; the driver management module is used to adjust the operation mode of the hot-swap driver program according to the SD card type of the hot-swap event; the resource management module is used to dynamically adjust the memory allocation strategy based on the operation mode, and use the preset reserved memory to respond to the hot-swap event.

[0007] On the other hand, the present disclosure further provides a computer-readable storage medium, on which computer instructions are stored, and the computer instructions are used to enable a computer to implement the above-mentioned hot-swap stability assurance method for the Android system.

[0008] On the other hand, the present disclosure further provides a computer program product, including computer instructions, which are used to enable a computer to execute the above-mentioned hot-swap stability assurance method for the Android system.

[0009] Through the hot-swap stability assurance method and hot-swap system of the Android system of the above-mentioned embodiment of the present disclosure, the event detection module adopts a hot-swap detection algorithm and an anti-jitter algorithm to monitor hot-swap events in real time. When the SD card is inserted or removed, the system can quickly capture the signal and reduce the probability of false detection. The anti-jitter algorithm ensures that there will be no misjudgment when the signal changes are received, thereby reducing the misoperation or system response delay caused by instantaneous level changes. Therefore, the response speed and accuracy of the system can be improved, the lag caused by the plug-in operation can be reduced, and the user experience can be improved.

[0010] In addition, during the system startup phase, the driver management module optimizes the hot-swappable driver based on the preset compatibility framework to ensure that different types of SD cards can adapt to the corresponding operating modes, improves the compatibility of different types of SD cards and the response speed of the driver, and reduces stability issues caused by driver incompatibility. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0012] Figure 1a An exemplary schematic diagram showing the architecture of a hot-swap system applied to a hot-swap stability assurance method for an Android system according to an embodiment of the present disclosure;

[0013] Figure 1b It is a flow chart of a method for ensuring hot-swap stability of an Android system provided by an embodiment of the present disclosure;

[0014] Figure 2 An exemplary schematic diagram showing the architecture of another hot-swap system applied to a hot-swap stability assurance method for an Android system according to an embodiment of the present disclosure;

[0015] Figure 3 is a structural schematic diagram of another hot-swap system provided by an embodiment of the present disclosure;

[0016] Figure 4 It is a structural schematic diagram of another hot-swap system provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0017] With the popularity of smart devices, especially the widespread use of mobile phones, tablets and other portable devices, users' demands for device functions are constantly increasing, especially in data storage and transmission. As an important function, hot-swap technology enables users to insert or remove external storage devices (such as SD cards, USB storage devices, etc.) at any time without turning off the power of the device. This feature allows users to easily exchange data between multiple devices or quickly increase storage space. As one of the most widely used operating systems in the world, the Android system has become an operating platform that widely supports hot-swap functions due to its openness and customizability.

[0018] Although hot-swap technology has brought great convenience to the Android system, there are still some problems that affect system stability and user experience in actual use, which are mainly reflected in the following aspects:

[0019] 1. In the related art, the detection of hot-plug events usually relies on the hardware detection of external devices and the interrupt processing of the system kernel. However, the existing detection mechanism often has a certain delay, resulting in a poor user experience.

[0020] 2. During the hot-swap operation, the management and allocation of system resources (such as memory, CPU, etc.) may not be reasonable, resulting in resource preemption, further affecting system stability.

[0021] To solve the above problems, various embodiments of the present invention provide a hot-swap stability assurance method for an Android system, which is applied to a hot-swap system. The hot-swap system includes: a driver management module, an event detection module and a resource management module. The method includes: the driver management module, when the Android system is started, optimizes the hot-swap driver program based on a preset compatibility framework, and determines the operation mode corresponding to each SD card type; the event detection module, using a hot-swap detection algorithm and an anti-jitter algorithm, detects in real time whether there is a hot-swap event in the Android system, and when there is a hot-swap event, sends the hot-swap event to the driver management module and the resource management module; the driver management module adjusts the operation mode of the hot-swap driver program according to the SD card type of the hot-swap event; the resource management module, based on the operation mode, dynamically adjusts the memory allocation strategy, and uses a preset reserved memory to respond to the hot-swap event.

[0022] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.

[0023] Please refer to Figure 1a , Figure 1a An exemplary schematic diagram of the architecture of a hot-swap system used in a hot-swap stability assurance method for an Android system according to an embodiment of the present disclosure is shown. Figure 1a As shown, the hot-swap system includes: a drive management module, an event detection module and a resource management module.

[0024] like Figure 1a As shown, the hot-plug system can be a modular architecture in the Android system specifically used to handle hot-plug operations.

[0025] Among them, the driver management module in the hot plug system can be used to adjust the driver operation mode in the operating system according to the type of hot plug event, and ensure that the driver can correctly handle the read and write operations of the external storage device. Here, the type of hot plug event can include: insertion and removal. The event detection module can be used to detect hot plug events in real time. The resource management module can be used to dynamically adjust the allocation of system resources when a hot plug event occurs.

[0026] Furthermore, the hot-swap system can be deployed in environments that need to support dynamic plugging and unplugging of external devices, such as mobile devices and vehicle-mounted systems.

[0027] Further references Figure 1b , Figure 1bis a flow chart of a method for ensuring hot-swap stability of an Android system provided by an embodiment of the present disclosure, which is applied to the above Figure 1a The hot-swap system shown in the figure may include the following steps:

[0028] Step S101, the driver management module optimizes the hot-swap driver based on a preset compatibility framework when the Android system is started, and determines the operation mode corresponding to each SD card type.

[0029] In this embodiment, when the Android system is started, the hot-swap driver of the SD card slot is initialized; the driver management module loads a preset compatibility framework during the initialization of the hot-swap driver of the SD card slot. The preset compatibility framework can be used to enable the Android system to identify various SD card types and configure a corresponding operation mode for each type. The preset compatibility framework can include compatibility settings and optimization rules for at least one type of SD card.

[0030] In a possible implementation, the driving management module determines the type of the SD card, which may include:

[0031] The driver management module obtains the response information of the SD card based on the hardware interface and determines the type of the SD card according to the response information; or the driver management module determines the type of the SD card according to the representation information of the SD card.

[0032] Furthermore, optimizing the hot-swap driver based on the preset compatibility framework may include:

[0033] The driver management module adjusts the working mode of the hot-swappable driver according to the resource conditions of the Android system during the optimization process.

[0034] For example, when system resources are sufficient, a higher transmission rate may be allowed, while when resources are tight, the driver may choose a lower rate to ensure system stability.

[0035] Furthermore, the operation mode may include but is not limited to: data transmission rate, interface protocol, and voltage level.

[0036] Step S102, the event detection module uses a hot plug detection algorithm and an anti-shake algorithm to detect in real time whether there is a hot plug event in the Android system. When a hot plug event occurs, the hot plug event is sent to the driver management module and the resource management module.

[0037] In this embodiment, the hot plug detection algorithm can be an algorithm for real-time monitoring of hardware plug events to ensure that the Android system can respond to the insertion or removal of external devices in a timely manner. The external device is not limited to the SD card and can be specifically set according to actual needs.

[0038] The anti-jitter algorithm can be an algorithm used to eliminate short-term level fluctuations (noise) in the signal caused by mechanical or other external interference, so as to ensure that the system responds only to valid level changes and avoid misjudgment caused by level jumps.

[0039] In a possible implementation, the event detection module uses a hot plug detection algorithm and an anti-shake algorithm to detect in real time whether there is a hot plug event in the Android system. When a hot plug event occurs, the hot plug event is sent to the driver management module and the resource management module, which may include:

[0040] The event detection module uses a hot-plug detection algorithm to detect in real time whether there is a hot-plug event in the Android system. When a hot-plug event occurs, an anti-jitter algorithm is used to detect whether the hot-plug event is valid. When the hot-plug event is determined to be valid, the hot-plug event is sent to the driver management module and the resource management module.

[0041] Step S103: the driver management module adjusts the operation mode of the hot-plug driver according to the SD card type of the hot-plug event.

[0042] In this embodiment, the driver management module identifies the type of the inserted or removed SD card according to the SD card type information transmitted by the event detection module.

[0043] The driver management module will adjust the operation mode of the SD card based on the preset compatibility framework according to the identified SD card type, ensuring that the system can be optimally configured according to different SD card characteristics.

[0044] As an example, if it is detected that the inserted card is a standard SD card, the driver management module operation mode is configured as standard mode, which does not support higher read and write speeds; if it is detected that the inserted card is an SDHC card, the driver program switches the operation mode to a mode that supports the SDHC format and can support higher storage capacity.

[0045] Step S104: The resource management module dynamically adjusts the memory allocation strategy based on the operation mode and uses the preset reserved memory to respond to the hot plug event.

[0046] In this embodiment, when the Android system is started, the resource management module reserves a preset size of memory as dedicated memory for hot-plugging operations based on a preset configuration to ensure that the system has enough memory to load the SD card driver and cache data during the hot-plugging process.

[0047] Furthermore, the resource management module evaluates the system resources required in the operation mode according to the operation mode adjusted by the driver management module, dynamically adjusts the memory allocation strategy, and allocates memory for the SD card.

[0048] In the hot-swap stability assurance method and hot-swap system of the Android system of the above-mentioned embodiment of the present disclosure, the event detection module adopts a hot-swap detection algorithm and an anti-jitter algorithm to monitor hot-swap events in real time. When the SD card is inserted or removed, the system can quickly capture the signal and reduce the probability of false detection. The anti-jitter algorithm ensures that there will be no misjudgment when the signal change is received, thereby reducing the misoperation or system response delay caused by instantaneous level changes, thereby improving the response speed and accuracy of the system, reducing the lag caused by plug-in operations, and improving the user experience. In the system startup phase, the driver management module optimizes the hot-swap driver based on the preset compatibility framework to ensure that different types of SD cards can adapt to the corresponding operating modes, improve the compatibility of different types of SD cards and the response speed of the driver, and reduce the stability problems caused by driver incompatibility.

[0049] In a possible implementation of the above embodiment, the driver management module, when the Android system is started, optimizes the hot-swap driver based on a preset compatibility framework and determines the operation modes corresponding to each SD card type, including:

[0050] The driver management module defines a preset standard interface for the hot-plug driver during the initialization phase of the hot-plug driver, wherein the preset standard interface includes at least one of the following: initialization, reading and writing, and erasing;

[0051] The driver management module determines the type of the SD card installed on the device where the Android system is located based on the compatibility detection, sets the corresponding adapter for the SD card in the hot-swap driver, and configures the compatibility parameters for the SD card; wherein the adapter is used to implement a preset standard interface for the SD card;

[0052] The driver management module configures error handling logic and log records for the hot-plug driver during the initialization phase of the hot-plug driver.

[0053] In this embodiment, the preset standard interface can be used to uniformly process the operation of the SD card. Among them, the initialization interface in the preset standard interface can be used to initialize the SD card and configure the necessary parameters for the SD card; the read and write interface can be used to perform data read and write operations and provide access to the SD card file system; the erase interface can be used to erase the data on the SD card.

[0054] The driver management module determines the type of the SD card installed on the device where the Android system is located based on the compatibility detection, and may include: the driver management module integrates the compatibility detection logic in the initialization phase to determine the type of the SD card and the adapter type corresponding to the SD card type. Among them, the adapter can be a design pattern, the purpose of which is to provide a unified interface between different systems or modules so that these systems or modules can be compatible with each other.

[0055] Furthermore, the driver management module, after determining the type of the SD card, configures a corresponding adapter for the SD card, the adapter being used to implement the above-mentioned preset standard interface and map the call of the interface to a specific hardware operation.

[0056] In a possible implementation, the driver management module configures compatibility parameters for the SD card, which may include:

[0057] The driver management module loads the compatibility parameters from a preset configuration file; or the driver management module dynamically adjusts the compatibility parameters according to actual hardware characteristics of the SD card.

[0058] Here, the purpose of configuring the compatibility parameters may be to ensure seamless cooperation between the SD card and the system.

[0059] In a possible implementation, the driver management module configures error handling logic and log records for the hot-plug driver during the initialization phase of the hot-plug driver, which may include:

[0060] The driver management module implements error handling logic and records detailed log information during the initialization phase of the hot-swap driver.

[0061] Here, the driver management module can track and debug problems by configuring error handling logic and logging.

[0062] In the hot-swap stability assurance method and hot-swap system of the Android system of the above-mentioned embodiment of the present disclosure, by configuring a corresponding adapter for each SD card type in the driver management module and implementing a preset standard interface for it, it is possible to ensure that the hot-swap operations of different types of SD cards in the system have high compatibility and stability. By defining a standard initialization interface, the driver can automatically perform initialization configuration according to the SD card type at startup, reducing the probability of manual intervention and configuration errors. By allocating a corresponding adapter for each SD card type, the compatibility between the driver and the specific hardware can be ensured, preventing system crashes or data loss caused by driver-hardware mismatches. By configuring error handling logic and logging functions in the initialization phase of the hot-swap driver, problems can be quickly located and fixed.

[0063] In a possible implementation of the above embodiment, the method further includes: a driver management module, in the initialization phase of the hot-plug driver, configuring a try block and at least one catch block corresponding to the try block in a target code segment of the hot-plug driver based on preset configuration information, wherein the catch block includes at least one exception handling logic; wherein the target code segment is used to represent a code segment with a possibility of an exception;

[0064] The driver management module, during the initialization phase of the hot-swap driver, when an exception is captured, determines the exception handling logic that has a mapping relationship with the exception in the preset API document, and uses the exception handling logic to handle the exception.

[0065] In this embodiment, the driver management module analyzes the code of the driver program during the initialization phase of the hot-plug driver program, and identifies the code segment where an exception may occur as the target code segment.

[0066] For example, the target code segment may include, but is not limited to, code for processing hardware interactions and code for reading configuration files.

[0067] Furthermore, after identifying the target code segment, the driver management module configures a try block and a catch block corresponding to the try block in the target code segment to capture and process possible exceptions.

[0068] Here, the try block can refer to a code area used to catch possible exceptions. The code written in the try block will be executed, and if an exception occurs during the execution, the program will jump to the corresponding catch block for processing. The catch block is paired with the try block and can be used to catch exceptions thrown in the try block, handle the exceptions, convert the exceptions into more specific exceptions and re-throw them.

[0069] Configuring a try block may refer to placing the code that may throw an exception into the try block to ensure that once an exception occurs, the program can be transferred to the corresponding catch block for processing. Configuring a catch block may refer to writing processing logic for different exception types in each catch block. For example, the processing logic may include: logging, error prompts, and resource release.

[0070] Furthermore, the driver management module configures a cleanup code in a finally block during the initialization phase of the hot-plug driver program to ensure that resources are released.

[0071] Furthermore, the driver management module records all possible exception types that may be thrown in the preset API document according to the exception type in the try-catch block, and records the corresponding processing strategy for each exception in the preset API document;

[0072] Driver management module verifies the effectiveness of exception handling strategy through unit testing and integration testing.

[0073] In the hot-swap stability assurance method and hot-swap system of the Android system in the above-mentioned embodiment of the present disclosure, a robust exception handling mechanism is constructed to improve the stability of the system and the user experience. By defining the exception handling mapping relationship in the API document in advance, developers and system maintenance personnel can more clearly understand the processing scheme and priority of each exception type. This clear and standardized processing method improves the maintainability and predictability of the system. By appropriately adding try-catch processing, exceptions can be effectively captured and recovery operations can be performed, which can reduce system crashes and instability factors.

[0074] In a possible implementation of the above step S102, the event detection module uses a hot plug detection algorithm and an anti-shake algorithm to detect in real time whether there is a hot plug event in the Android system, including:

[0075] The event detection module configures the GPIO port of the microcontroller to an input mode, and based on the input mode, receives a level change signal when the SD card is inserted or removed through the GPIO port;

[0076] Event detection module, when the GPIO port changes from low level to high level, it is determined that an SD card is inserted into the Android system, triggering the first interrupt and calling the preset interrupt service routine; when the GPIO port changes from high level to low level, it is determined that the SD card is removed from the Android system, triggering the second interrupt and calling the preset interrupt service routine;

[0077] The event detection module, in a preset interrupt service routine, uses an anti-jitter algorithm to determine whether a hot plug event is valid. When the hot plug event is valid, it is determined that a hot plug event exists in the Android system.

[0078] In this embodiment, the event detection module ensures that the SD card slot is connected to a general-purpose input / output (GPIO) port of the microcontroller.

[0079] Here, the microcontroller can be the core computing unit that performs hot plug event detection, processes SD card plug and unplug signals, and interacts with other system modules. The GPIO port can include an input mode and an output module, the input module can be used to receive external signals, and the output mode can be used to output signals to the outside world.

[0080] The event detection module configures the GPIO port of the microcontroller to an input mode, and sets a pull-up resistor or a pull-down resistor for the GPIO port.

[0081] Here, the pull-up resistor can be used to ensure that the input port is at a high level when there is no input signal, and the pull-down resistor can be used to determine that the input port is at a low level when there is no input signal. Setting a pull-up resistor or a pull-down resistor for the GPIO port can be used to ensure that the level of the input port is in a stable known state and prevent the signal from floating (i.e., an undefined state) to ensure that the system can correctly identify level changes.

[0082] Furthermore, the event detection module sets external interrupt and edge trigger modes for the GPIO port of the microcontroller.

[0083] Here, external interrupt can refer to an interrupt triggered by hardware or an external pin of a microcontroller, and causes an interrupt service routine to be executed under certain conditions (such as when a level changes). Edge-triggered mode can refer to an interrupt being triggered by the "edge" of a level change of an input signal, rather than by a stable state of the level.

[0084] For example, the edge trigger mode may include rising edge triggering and falling edge triggering; wherein, rising edge triggering may mean that an interrupt is triggered when the signal changes from a low level (logic 0) to a high level (logic 1), and falling edge triggering may mean that an interrupt is triggered when the signal changes from a high level (logic 1) to a low level (logic 0).

[0085] Therefore, when the SD card is inserted, the level of the GPIO port changes from low level to high level. When the event detection module detects that the level of the GPIO port changes from low level to high level, it will identify it as an SD card insertion event, trigger the first interrupt, and call the preset interrupt service routine to handle the subsequent logic of the SD card insertion.

[0086] When the SD card is pulled out, the level of the GPIO port changes from high to low. When the event detection module detects that the level of the GPIO port changes from high to low, it will identify it as an SD card removal event, trigger the second interrupt, and call the preset interrupt service routine to handle the subsequent logic of the SD card removal.

[0087] Here, the preset interrupt service routine (ISR) may refer to a piece of code that has been defined and configured in advance to respond to a specific interrupt event. For example, when an SD card is inserted, the ISR will perform operations such as initializing the SD card driver and mounting the file system. When the SD card is removed, the ISR will perform operations such as unmounting the file system and releasing SD card resources.

[0088] In the hot-swap stability assurance method and hot-swap system of the Android system of the above-mentioned embodiment of the present disclosure, by monitoring the level change when the SD card is inserted or removed through the GPIO port, the plug-in event can be obtained in real time and accurately, the response speed of the system is improved, and the hot-swap event caused by the detection delay cannot be identified and processed in time, and the real-time and sensitivity of the system to user operations are enhanced. In the preset interrupt service routine, the anti-jitter algorithm is used to eliminate false triggers caused by factors such as electrical interference or poor contact. The anti-jitter algorithm can effectively verify when the event occurs to ensure the reliability of the plug-in event.

[0089] In a possible implementation of the above embodiment, the event detection module, in a preset interrupt service routine, uses an anti-jitter algorithm to determine whether a hot plug event is valid, and when the hot plug event is valid, determines that there is a hot plug event in the Android system, including:

[0090] An event detection module, in a preset interrupt service routine, when the first interrupt or the second interrupt is triggered, records a timestamp of the triggering moment;

[0091] The event detection module re-reads the latest level signal of the GPIO port after a preset delay, and if the latest level signal is consistent with the level change signal, determines that the hot plug event corresponding to the first interrupt or the second interrupt is initially valid;

[0092] The event detection module determines that the hot plug event is finally valid when the results of the preset number of validity checks on the GPIO port are consistent, determines that the hot plug event exists in the Android system, executes the operation corresponding to the hot plug event, and updates the timestamp.

[0093] In this embodiment, the event detection module records the current timestamp when detecting a level change; in the preset interrupt service routine, the plug-in event is not processed immediately, and a preset delay time is set to wait for the jitter to stabilize;

[0094] The event detection module reads the level state of the GPIO port again after a preset delay based on the preset delay time. If the level state is consistent with the state after the initial change, it is considered to be a preliminary valid plug-in and pull-out event;

[0095] The event detection module, after determining a preliminary valid plug-in and pull-out event, repeats the test for a preset number of times. If the results of the preset number of repeated tests are all consistently valid, it is determined that the hot plug-in event is ultimately valid.

[0096] In one example, the steps of the anti-shake algorithm may be as follows:

[0097] 1. During the initialization process:

[0098] 1. Set the debounce delay threshold DEBOUNCE_DELAY, which can be used to ensure that events are not triggered frequently and avoid false triggering due to electrical noise or poor contact;

[0099] 2. Initialize the interrupt timestamp last_interrupt_time to record the time of the last valid interruption so as to calculate the time difference Δt later;

[0100] 2. When an interruption occurs:

[0101] 1. Anti-jitter check: Calculate the time difference Δt between the timestamp t of the current interrupt and the timestamp last_interrupt_time of the last valid interrupt, and use the anti-jitter check function to determine whether Δt is less than the set anti-jitter delay threshold DEBOUNCE_DELAY;

[0102] 2. SD card status detection: If Δt is greater than or equal to the anti-shake delay threshold, call the SDStatusCheck() function to determine the current SD card status (determine whether it is inserted);

[0103] 3. Execute interrupt service behavior: If SDInserted() returns True (SD card is inserted), call SDInsertionHandler() to perform the insertion operation; if SDInserted() returns False (SD card is removed), call SDRemovalHandler() to perform the removal operation;

[0104] 4. After completing the corresponding operation, update last_interrupt_time to the current timestamp t.

[0105] In the hot-swap stability guarantee method and hot-swap system of the Android system of the above-mentioned embodiment of the present disclosure, anti-jitter is judged by time difference, unnecessary event triggering is reduced, and the accuracy of detection is improved. Anti-jitter and interrupt timestamp update ensure that the system remains stable under high-frequency plug-in operations to avoid false triggering and system crashes. After the interrupt is triggered, the preset interrupt service routine is quickly executed without polling or waiting, thereby improving the system response speed.

[0106] In a possible implementation of the above embodiment, the resource management module dynamically adjusts the memory allocation strategy based on the operation mode and uses the preset reserved memory to respond to the hot plug event, which is implemented based on the following steps:

[0107] The resource management module reserves a preset memory in the memory for the hot plug event when the Android system is started, and marks the preset memory as a reserved state;

[0108] The resource management module attempts to allocate preset memory for the hot plug event when there is a hot plug event, and allocates system memory for the hot plug event when the preset memory is insufficient;

[0109] The resource management module, when there is a hot plug event, preempts the preset resources based on the preset preemption mechanism; when the hot plug event is completed, releases the preset resources based on the preset release mechanism.

[0110] In this embodiment, the resource management module, when the Android system is started, uses a memory reservation algorithm to reserve a preset memory in the memory for the hot plug event.

[0111] As an example, the memory reservation algorithm may be as follows:

[0112] F=mark_memory_as_reservedoallocate_memoryoget_reserved_memory_size

[0113] Among them, o can represent a combination operation of functions, that is, the output of one function is used as the input of another function. The formula can represent a continuous process from obtaining the reserved memory size to marking the memory as reserved.

[0114] Furthermore, when a hot plug event occurs, the resource management module uses a dynamic memory management function to allocate a preset memory for the hot plug event.

[0115] As an example, a dynamic memory management function could look like this:

[0116]

[0117] Among them, "allocate_from_reserved_memory(size)" can indicate an attempt to allocate memory of a specified size from the reserved memory;

[0118] If "allocate_from_reserved_memory(size)" returns a non-null pointer (i.e., memory allocation is successful), then the pointer is returned, i.e., reserved memory is allocated for the hot plug event;

[0119] If "allocate_from_reserved_memory(size)" returns a null pointer (that is, the reserved memory is insufficient), "allocate_from_system_memory(size)" is executed to allocate system memory for the hot plug event.

[0120] In a possible implementation, the expression formula of the preset preemption mechanism can be as follows:

[0121] F preempt =R CPU +R IO +R other

[0122] Among them, F preempt Represents the function of grabbing resources; R CPU Indicates the operation of preempting CPU resources;

[0123] R IO Indicates the operation of seizing I / O resources; R other Represents an operation that preempts other necessary resources.

[0124] Similarly, the expression formula of the preset release mechanism can be as follows:

[0125] F (H) =R CPU +R IO +R other

[0126] Among them, F (H) Represents a function that releases resources after hot plugging; R CPU Indicates the operation of releasing CPU resources; R IO Indicates the operation of releasing I / O resources; R other Represents an operation to release other resources.

[0127] In the hot-plug stability assurance method and hot-plug system of the Android system of the above-mentioned embodiment of the present disclosure, by reserving memory when the Android system is started, the delay of dynamically allocating memory when a hot-plug event occurs is avoided. This enables the system to respond quickly when faced with a hot-plug operation, improving the user experience. During a hot-plug event, it is ensured that the preset memory is allocated first, avoiding the problems of memory allocation competition and resource preemption. Through the preemption mechanism and the release mechanism, the priority processing of hot-plug events is guaranteed, reducing the possibility of system load and conflict.

[0128] In a possible implementation of the above embodiment, the hot-swap system may further include a test module, wherein:

[0129] The test module performs functional testing on the hot-swap function, wherein the functional test scenarios may include: continuous plugging and unplugging and quick plugging and unplugging.

[0130] In this embodiment, the continuous plugging and unplugging test may be to plug and unplug the SD card multiple times, with a fixed interval between each plugging and unplugging, so as to simulate the frequent plugging and unplugging operations that the user may perform during actual use.

[0131] Test the module to observe whether the system can normally detect each plug-in and unplug event and load / unload the driver to ensure that the device status can be correctly updated after each plug-in and unplug; verify whether the resource management module can allocate and release the preset memory in time after each plug-in and unplug to ensure that system resources are effectively utilized.

[0132] The fast plug and unplug test can be to quickly plug and unplug the SD card in a very short time (for example, multiple plugs and unplugs within 0.1 seconds) to simulate extreme scenarios.

[0133] Test the module and observe the response time of the event detection module to ensure that the system can accurately respond to each plug-in and plug-out operation under high-frequency plug-in and plug-out conditions; ensure that the anti-jitter algorithm can effectively filter out false triggering events to avoid system instability caused by too frequent plug-in and plug-out operations.

[0134] Furthermore, the test module records the performance of each test scenario in detail, analyzes the response time of plug-in and unplug-out events, driver loading time, memory allocation and release; evaluates whether the functionality meets expectations, records any non-compliance, and makes corresponding optimization suggestions.

[0135] In the hot-plug stability assurance method and hot-plug system of the Android system of the above-mentioned embodiment of the present disclosure, functional testing can ensure that plug-in events can be detected and responded to in a timely manner, driver loading and unloading are carried out smoothly, and memory resources are effectively managed. Through the test of continuous plug-in and rapid plug-in, it is verified that the system can remain stable in the face of frequent and rapid plug-in events, and the anti-jitter algorithm effectively filters out mis-plug-in events, avoiding system crashes or deadlocks.

[0136] In one embodiment, Figure 2 An exemplary schematic diagram of the architecture of another hot-swap system applied to a hot-swap stability assurance method for an Android system according to an embodiment of the present disclosure is shown, Figure 2 As shown:

[0137] The hot-swap system may include: a drive management module 201 , an event detection module 202 , a resource management module 203 and a test module 204 .

[0138] In one embodiment, a hot-swap system 300 is provided, and the hot-swap system 300 corresponds to the hot-swap stability guarantee method of the Android system in the above embodiment. Figure 3 As shown, the hot-swap system 300 includes a driver management module 301, an event detection module 302 and a resource management module 303, wherein each functional module is described in detail as follows:

[0139] The driver management module 301 is used to optimize the hot-swap driver based on a preset compatibility framework when the Android system is started, and determine the operation mode corresponding to each SD card type;

[0140] The event detection module 302 is used to use a hot plug detection algorithm and an anti-shake algorithm to detect in real time whether there is a hot plug event in the Android system. When a hot plug event occurs, the hot plug event is sent to the driver management module 301 and the resource management module 303;

[0141] The driver management module 301 is used to adjust the operation mode of the hot-plug driver according to the SD card type of the hot-plug event;

[0142] The resource management module 303 is used to dynamically adjust the memory allocation strategy based on the operation mode and use the preset reserved memory to respond to the hot plug event.

[0143] In one embodiment, the driver management module 301 is used to define a preset standard interface for the hot-plug driver during the initialization phase of the hot-plug driver, and the preset standard interface includes at least one of the following: initialization, reading and writing, and erasing;

[0144] The driver management module 301 is used to determine the type of SD card installed on the device where the Android system is located based on compatibility detection, set a corresponding adapter for the SD card in the hot-swap driver, and configure compatibility parameters for the SD card; wherein the adapter is used to implement a preset standard interface for the SD card;

[0145] The driver management module 301 is used to configure error handling logic and log records for the hot-plug driver during the initialization phase of the hot-plug driver.

[0146] In one embodiment, the driver management module 301 is further used to configure a try block and at least one catch block corresponding to the try block in a target code segment of the hot-plug driver based on preset configuration information during the initialization phase of the hot-plug driver, wherein the catch block includes at least one exception handling logic; wherein the target code segment is used to represent a code segment with a possibility of an exception;

[0147] The driver management module 301 is also used to determine the exception handling logic that has a mapping relationship with the exception in the preset API document when an exception is captured during the initialization phase of the hot-plug driver, and use the exception handling logic to handle the exception.

[0148] In one embodiment, the event detection module 302 is used to configure the GPIO port of the microcontroller to an input mode, and based on the input mode, receive a level change signal when the SD card is inserted or removed through the GPIO port;

[0149] The event detection module 302 is used to determine that an SD card is inserted into the Android system when the GPIO port changes from a low level to a high level, trigger a first interrupt, and call a preset interrupt service routine; when the GPIO port changes from a high level to a low level, determine that an SD card is removed from the Android system, trigger a second interrupt, and call a preset interrupt service routine;

[0150] The event detection module 302 is used to use an anti-jitter algorithm in a preset interrupt service routine to determine whether a hot plug event is valid, and when the hot plug event is valid, determine that a hot plug event exists in the Android system.

[0151] In one embodiment, the event detection module 302 is used to record a timestamp of a triggering moment when the first interrupt or the second interrupt is triggered in a preset interrupt service routine;

[0152] An event detection module 302 is used to re-read the latest level signal of the GPIO port after a preset delay, and if the latest level signal is consistent with the level change signal, determine that the hot plug event corresponding to the first interrupt or the second interrupt is initially valid;

[0153] The event detection module 302 is used to determine that the hot plug event is finally valid when the results of the preset number of validity checks on the GPIO port are consistent, determine that the hot plug event exists in the Android system, perform the operation corresponding to the hot plug event, and update the timestamp.

[0154] In one embodiment, the resource management module 303 is used to reserve a preset memory in the memory for the hot plug event when the Android system is started, and mark the preset memory as a reserved state;

[0155] The resource management module 303 is used for trying to allocate a preset memory for the hot plug event when there is a hot plug event, and when the preset memory is insufficient, allocating system memory for the hot plug event;

[0156] The resource management module 303 is used to seize preset resources based on a preset preemption mechanism when a hot plug event occurs; and to release preset resources based on a preset release mechanism after the hot plug event is completed.

[0157] It should be noted that: the hot-swap system provided in the above embodiment is only illustrated by the division of the above program modules when implementing the hot-swap stability guarantee method of the corresponding Android system. In actual application, the above processing can be assigned to different program modules as needed, that is, the internal structure of the above system can be divided into different program modules to complete all or part of the above-described processing. Figure 1b The embodiments of the method shown belong to the same concept, and the specific implementation process is detailed in the method embodiments, which will not be repeated here.

[0158] The present disclosure also provides a computer device having the above Figure 3 Hot-swap system shown.

[0159] See also Figure 4 , Figure 4 is a structural diagram of another hot-swap system provided by an embodiment of the present disclosure, such as Figure 4 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 4 A processor 10 is taken as an example.

[0160] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0161] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.

[0162] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0163] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.

[0164] The computer device also includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Figure 4 The example of connecting through bus is taken in the following.

[0165] The input device 30 can receive input digital or character information, and generate key signal input related to the user settings and function control of the computer device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device can be a touch screen.

[0166] The computer device also includes a communication interface, which is used for the computer device to communicate with other devices or a communication network.

[0167] The embodiments of the present disclosure also provide a computer-readable storage medium. The above-mentioned method according to the embodiments of the present disclosure can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium and downloaded through a network, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.

[0168] A part of the present disclosure may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present disclosure through the operation of the computer. Those skilled in the art should understand that the existence of computer program instructions in computer-readable media includes, but is not limited to, source files, executable files, installation package files, etc., and accordingly, the way in which computer program instructions are executed by a computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer.

[0169] Although the embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A hot-swap stability guarantee method for an Android system, characterized in that: Applied to a hot-swap system, the hot-swap system includes: a drive management module, an event detection module and a resource management module, and the method includes: The driver management module optimizes the hot-swap driver based on the preset compatibility framework when the Android system is started, and determines the operation mode corresponding to each SD card type; An event detection module, which uses a hot-plug detection algorithm and an anti-shake algorithm to detect in real time whether there is a hot-plug event in the Android system, and when the hot-plug event exists, sends the hot-plug event to the drive management module and the resource management module; The driver management module adjusts the operation mode of the hot-plug driver according to the SD card type of the hot-plug event; The resource management module dynamically adjusts the memory allocation strategy based on the operation mode and uses a preset reserved memory to respond to the hot plug event.

2. The method according to claim 1, characterized in that The driver management module, when the Android system is started, optimizes the hot-swap driver based on a preset compatibility framework and determines the operation mode corresponding to each SD card type, including: The driver management module defines a preset standard interface for the hot-plug driver during the initialization phase of the hot-plug driver, wherein the preset standard interface includes at least one of the following: initialization, reading and writing, and erasing; The driver management module determines the type of SD card installed on the device where the Android system is located based on compatibility detection, sets a corresponding adapter for the SD card in the hot-swap driver, and configures compatibility parameters for the SD card; wherein the adapter is used to implement the preset standard interface for the SD card; The driver management module configures error handling logic and log records for the hot-plug driver during the initialization phase of the hot-plug driver.

3. The method according to claim 2, characterized in that The method further comprises: A driver management module, in the initialization phase of the hot-plug driver, configures a try block and at least one catch block corresponding to the try block in a target code segment of the hot-plug driver based on preset configuration information, wherein the catch block includes at least one exception handling logic; wherein the target code segment is used to represent a code segment with a possibility of an exception; The driver management module, during the initialization phase of the hot-plug driver, when an exception is captured, determines an exception handling logic that has a mapping relationship with the exception in a preset API document, and uses the exception handling logic to handle the exception.

4. The method according to claim 1, characterized in that: The event detection module uses a hot plug detection algorithm and an anti-shake algorithm to detect in real time whether there is a hot plug event in the Android system, including: An event detection module configures the GPIO port of the microcontroller to an input mode, and based on the input mode, receives a level change signal when the SD card is inserted or removed through the GPIO port; The event detection module determines that an SD card is inserted into the Android system when the GPIO port changes from a low level to a high level, triggers a first interrupt, and calls a preset interrupt service routine; when the GPIO port changes from a high level to a low level, it determines that an SD card is removed from the Android system, triggers a second interrupt, and calls the preset interrupt service routine; The event detection module, in the preset interrupt service routine, uses an anti-jitter algorithm to determine whether a hot plug event is valid, and when the hot plug event is valid, determines that the hot plug event exists in the Android system.

5. The method according to claim 4, characterized in that The event detection module, in the preset interrupt service routine, uses an anti-jitter algorithm to determine whether a hot plug event is valid, and when the hot plug event is valid, determines that the hot plug event exists in the Android system, including: An event detection module, in a preset interrupt service routine, when the first interrupt or the second interrupt is triggered, records a timestamp of the triggering moment; The event detection module re-reads the latest level signal of the GPIO port after a preset delay, and if the latest level signal is consistent with the level change signal, determines that the hot plug event corresponding to the first interrupt or the second interrupt is preliminarily valid; The event detection module determines that the hot plug event is finally valid when the results of the preset number of validity detections performed on the GPIO port are consistent, determines that the hot plug event exists in the Android system, executes the operation corresponding to the hot plug event, and updates the timestamp.

6. The method according to claim 5, characterized in that The resource management module dynamically adjusts the memory allocation strategy based on the operation mode and uses the preset reserved memory to respond to the hot plug event, which is implemented based on the following steps: The resource management module reserves a preset memory in the memory for the hot plug event when the Android system is started, and marks the preset memory as a reserved state; The resource management module attempts to allocate the preset memory for the hot plug event when the hot plug event occurs, and allocates system memory for the hot plug event when the preset memory is insufficient; The resource management module, when the hot plug event occurs, preempts the preset resources based on a preset preemption mechanism; When the hot plug event is completed, the preset resource is released based on a preset release mechanism.

7. A hot-swap system, characterized in that: The hot-swap system includes a drive management module, an event detection module and a resource management module, wherein: The driver management module is used to optimize the hot-swap driver based on a preset compatibility framework when the Android system is started, and determine the operation mode corresponding to each SD card type; An event detection module, used to use a hot plug detection algorithm and an anti-shake algorithm to detect in real time whether there is a hot plug event in the Android system, and when the hot plug event exists, send the hot plug event to the drive management module and the resource management module; The driver management module is used to adjust the operation mode of the hot-plug driver according to the SD card type of the hot-plug event; The resource management module is used to dynamically adjust the memory allocation strategy based on the operation mode and use the preset reserved memory to respond to the hot plug event.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the hot-swap stability assurance method for an Android system according to any one of claims 1 to 6.

9. A computer program product, characterized in that It includes computer instructions, and the computer instructions are used to enable a computer to execute the hot-swap stability assurance method for an Android system according to any one of claims 1 to 6.

Citation Information

Cited By

  • Hot plug expansion system and method of non-hot plug display interface

    CN120705100A

  • A hot-plug expansion system and method of a non-hot-plug display interface

    CN120705100B

  • Module identification method and device based on hybrid detection mechanism and storage medium

    CN121387676A