Bluetooth reconnection method and device of equipment, electronic equipment and storage medium
By monitoring the bright-screen broadcast to determine the device mode and optimizing the Bluetooth connection process, the problem of slow and unstable Bluetooth connection speed during the hibernation wake-up process is solved, and more efficient and stable Bluetooth connection management is achieved.
Patent Information
- Application Number
- CN202510647050.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-19
- Publication Date
- 2025-07-11
AI Technical Summary
During the device's sleep and wake-up process, the Bluetooth connection speed is slow and unstable, and the driver restarts frequently, resulting in excessive system resource usage and stability problems.
By monitoring the bright-screen broadcast, determine the device mode, identify the Bluetooth device to be connected to, and keep the connection in the specified mode, avoid hardware errors triggering Bluetooth restart, optimize the driver reporting mechanism, and set the connection priority to connect.
It improves the efficiency and stability of Bluetooth connection, reduces driver restart, optimizes system resource utilization, and improves user experience and device battery life.
Smart Images

Figure CN120302269A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of Bluetooth technology, and in particular, to a Bluetooth reconnection method, apparatus, electronic device, and computer-readable storage medium for a device. Background Art
[0002] In the current implementation solution of the Bluetooth reconnection operation in the sleep wake-up scenario, a specific process is relied on to trigger the Bluetooth restart and reconnection. The specific process is as follows: When the device is awakened from the sleep state, first, the driver reaches the USB wake-up stage. After that, the driver reports hardware error information to the Bluetooth protocol stack. After receiving the hardware error information, the Bluetooth protocol stack triggers the restart operation of Bluetooth. When Bluetooth enters the enabling stage, it then performs the action of reconnecting to the relevant Bluetooth device, thereby implementing the Bluetooth reconnection function in the sleep standby scenario.
[0003] However, in the above process of waking up the device from sleep, due to the reporting of hardware error information, the Bluetooth process is restarted, which in turn causes the restart of the driver. As a result, many programs need to execute the wake-up action, and these programs have occupied a large amount of system resources, leading to slow Bluetooth reconnection speed and unstable reconnection time. Summary of the Invention
[0004] Embodiments of the present disclosure provide a Bluetooth reconnection method, apparatus, electronic device, and computer-readable storage medium for a device, aiming to at least solve one of the technical problems in the related art to a certain extent.
[0005] In a first aspect, embodiments of the present disclosure provide a Bluetooth reconnection method for a device, the method including:
[0006] In response to monitoring a screen-on broadcast, determining whether the device is currently in a specified mode;
[0007] If the device is not currently in the specified mode, identifying the Bluetooth device to be reconnected currently;
[0008] Performing a Bluetooth reconnection operation to establish a Bluetooth connection with the Bluetooth device to be reconnected,
[0009] wherein when the device is in the specified mode, it maintains a connection with the Bluetooth device in the sleep state.
[0010] In a second aspect, embodiments of the present disclosure further provide a Bluetooth reconnection apparatus for a device, the apparatus including:
[0011] In a third aspect, embodiments of the present disclosure further provide a Bluetooth reconnection apparatus for a device, the apparatus including:
[0012] A first determination module, configured to determine whether the device is currently in a specified mode in response to monitoring a screen-on broadcast;
[0013] An identification module, configured to identify a Bluetooth device to be reconnected currently if the device is not currently in the specified mode;
[0014] A connection module, configured to perform a Bluetooth reconnection operation to establish a Bluetooth connection with the Bluetooth device to be reconnected,
[0015] wherein, when the device is in the specified mode, the connection with the Bluetooth device is maintained.
[0016] In a fourth aspect, an embodiment of the present disclosure further provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the steps in the Bluetooth reconnection method of the above-mentioned device are implemented.
[0017] In a fifth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the Bluetooth reconnection method of the above-mentioned device are implemented.
[0018] In a sixth aspect, an embodiment of the present disclosure further provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the methods provided in various alternative implementations of the embodiments of the present disclosure.
[0019] In the embodiments of the present disclosure, first, in response to monitoring a screen-on broadcast, it is determined whether the device is currently in the specified mode. Then, if the device is not currently in the specified mode, the Bluetooth device to be reconnected currently is identified. Then, a Bluetooth reconnection operation is performed to establish a Bluetooth connection with the Bluetooth device to be reconnected. Among them, when the device is in the specified mode, the connection with the Bluetooth device is maintained in the sleep state. Thus, it is not necessary to trigger Bluetooth reconnection by reporting a hardware error, avoiding unnecessary restart of the driver, occupying relatively very little resources, being able to perform Bluetooth reconnection in time after monitoring the screen-on broadcast, and maintaining the connection with the Bluetooth device in the sleep state when the device is in the specified mode. This can very effectively improve the efficiency and speed of Bluetooth reconnection and improve the stability of Bluetooth reconnection.
[0020] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] To more clearly illustrate the technical solutions in the present disclosure, the following will briefly introduce the drawings required for description in the embodiments. Obviously, the following drawings are only some embodiments of the present invention. For those skilled in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0022] Figure 1 It is a schematic flowchart of the Bluetooth reconnection method of the device provided in the first embodiment of the present disclosure;
[0023] Figure 2 It is a flowchart of a device connection state control;
[0024] Figure 3 It is a flowchart of device reconnection priority setting and connection strategy;
[0025] Figure 4 It is a schematic structural diagram of a Bluetooth reconnection device of a device provided in the embodiment of the present disclosure;
[0026] Figure 5 It is a schematic structural diagram of an electronic device provided in the embodiment of the present disclosure. Detailed Embodiments
[0027] Here, some embodiments of the present disclosure will be described in detail, and the examples are shown in the drawings. When the following description involves the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. Various changes, modifications, and equivalents of the methods, devices, and / or systems described herein will become apparent after understanding the present disclosure. For example, the order of the operations described herein is only an example and is not limited to those described herein. Instead, it can be changed as will be apparent after understanding the present disclosure, except for operations that must be performed in a specific order. In addition, for the sake of clarity and conciseness, the description of features known in the art may be omitted.
[0028] It should be noted that when the device is in the sleep standby state, the disconnection method of its Bluetooth connection is as follows: It depends on the driver to enter the sleep state (SUSPEND). At this time, the chip will perform a radio frequency off operation, causing the connected peer device to disconnect due to timeout. In the entire sleep scenario, the USB connection state of the driver actually remains unchanged all the time, without involving USB disconnection and reconnection actions, only the driver itself enters the sleep state.
[0029] In the related art, there are at least the following problems:
[0030] (1) Bluetooth reconnection speed and stability problems
[0031] Since the speed of Bluetooth restarting until it starts reconnecting is severely restricted by the CPU scheduling resources. During the device's sleep and wake-up process, numerous programs (such as the UI, etc.) need to perform wake-up actions, and these programs have already occupied a large amount of system resources. The Bluetooth process runs in a 100% cold start manner and, as a background service process, has a relatively low priority level. This results in the Bluetooth process usually being able to use only 0 to 3 CPUs when running, making the time consumed for the entire Bluetooth restart process extremely unstable. The resulting consequence is that the method of triggering reconnection by restarting the Bluetooth process is prone to problems such as slow reconnection speed and unstable reconnection time, affecting the user experience.
[0032] (2) The disconnection time of the peer device is uncertain
[0033] When the device is in sleep standby, the disconnection of the peer device depends on the chip's radio frequency shutdown operation after the driver enters the sleep state (SUSPEND) to cause the peer device to time out and disconnect. However, due to possible blocking effects from other processes, the driver often takes a long time to enter the sleep state after the screen goes off. This makes the user feel that the Bluetooth is still connected to the relevant peripherals for a long time after the device goes into sleep shutdown, causing unnecessary trouble and not meeting the expected low-power state during device sleep.
[0034] (3) Unnecessary restart of the driver
[0035] Throughout the sleep scenario, the USB connection of the driver actually remains intact all the time, without involving USB disconnection and reconnection actions. It is only the driver entering the sleep state, and there should be no reporting of hardware error information. But in the current solution, due to the reporting of hardware error information, it causes the Bluetooth process to restart, which in turn triggers the restart of the hardware interface, and finally leads to the restart of the driver. This unnecessary driver restart can be optimized because it not only increases the burden on the system but also may bring some potential problems.
[0036] (4) Stability risks
[0037] The current sleep and wake-up mechanism causes both the Bluetooth process and the driver to restart. During the entire process of Bluetooth turning off, turning on, and the driver turning off and turning on, there are many risks of timing confusion. For example, when the time interval between two sleep and wake-up operations is short, the previous Bluetooth or driver turn-on process has not been completely finished when the turn-off action is performed, which may cause the system to access some resources that have already been cleared. And such problems are usually very difficult to locate and solve, seriously affecting the stability and reliability of the system.
[0038] Therefore, the embodiments of the present disclosure propose a Bluetooth reconnection method for a device to solve at least one of the above-mentioned multiple problems.
[0039] The embodiments described in some embodiments of the present disclosure below do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0040] It should be noted that the execution subject of the Bluetooth reconnection method of the device in this embodiment can be the Bluetooth reconnection device of the device, and this device can be configured in any type of electronic device, such as a tablet computer, a television, a mobile phone, a watch, a computer, etc., which is not limited herein.
[0041] It should be noted that the description order of the following embodiments does not limit the priority order of the embodiments.
[0042] Figure 1 It is a schematic flowchart of the Bluetooth reconnection method of the device provided in the first embodiment of the present disclosure.
[0043] As Figure 1 shown, this method is executed by the data sender, and this method includes:
[0044] Step 101, in response to monitoring the screen-on broadcast, determine whether the device is currently in a specified mode.
[0045] Among them, the screen-on broadcast refers to a broadcast signal sent when an electronic device switches from the off state (or standby state) to the on state (screen-on state). At this time, the device is awakened from the STR (Short-Term Retention) state. This signal is used to notify the system and application programs that the device has been turned on, thereby triggering possible operations or updates. For example, in a smart phone, when the user clicks the power button to turn on the screen, the system will send a screen-on broadcast. This broadcast can be listened to by application programs so that specific operations can be executed when the screen is turned on, such as updating notifications or interface states.
[0046] Among them, the screen-on broadcast refers to a broadcast signal sent by the system when the device screen is turned on. Taking the Android system as an example, its action name is ACTION_SCREEN_ON. Correspondingly, when the screen is turned off, the system will send the ACTION_SCREEN_OFF broadcast.
[0047] For example, in the Android system, a class inherited from BroadcastReceiver can be created to receive the screen-on broadcast. In this class, implement the onReceive() method to process the received broadcast.
[0048] As a possible implementation, a broadcast receiver can be registered to listen for the system's screen-on broadcast event. When the device receives the screen-on broadcast, it can obtain various status information of the current device, such as sensor data, current mode, screen status, etc., which are not limited here.
[0049] Among them, the specified mode can be a specific working state or interface mode that the device or system enters according to user settings or specific conditions. This mode can provide users with different functions and experiences, such as energy-saving mode, focus mode, or an optimized mode for a specific application.
[0050] Optionally, the specified mode can also include multiple sub-modes, and the behavior and performance parameters of the device (such as screen brightness, audio settings, etc.) will be different under each mode.
[0051] In the embodiments of the present disclosure, the specified mode can be the speaker mode, which is not limited here.
[0052] It should be noted that the user can enable the speaker mode through the system settings or the Bluetooth application.
[0053] As an example, when the system screen is on, the Bluetooth module listens for the screen-on broadcast and makes a judgment. If the device is currently in the speaker mode, repeated connection is avoided.
[0054] As a possible implementation, in response to listening to the screen-off broadcast, it can be determined whether the device is currently in the speaker mode. If the device is in the speaker mode, the Bluetooth disconnection operation is not performed. If the device is not in the speaker mode, the Bluetooth disconnection operation is performed. Thus, when the device screen is turned off, the Bluetooth connection status can be intelligently processed according to whether the device is in the speaker mode, so as to achieve the purpose of both ensuring the continuity of music playback and saving system resources when not needed.
[0055] Specifically, the device system can send a specific broadcast signal when the screen is turned off, telling the application that "the screen has been closed". The application listens for this broadcast through a specific mechanism and triggers a series of subsequent operations after listening.
[0056] Optionally, after the system receives the screen-off broadcast, the Bluetooth module can determine whether the device is in the speaker mode. The speaker mode usually means that the device is being used as a Bluetooth speaker and is playing music or other audio content. There may be multiple ways to judge, such as checking whether there is currently an audio stream transmitted to the speaker device through Bluetooth, or checking whether the option related to the speaker mode is enabled in the system settings, etc., which are not limited here.
[0057] It is understandable that if the Bluetooth module determines that the current device is in the speaker mode, in order to ensure that music playback will not be interrupted, the Bluetooth module will maintain the current connection status and will not perform the operation of disconnecting the Bluetooth connection. In this way, even after the screen is turned off, the user can still continue to enjoy a smooth music playback experience. If the judgment result shows that the device is not in the speaker mode, it means that there is no need to maintain the Bluetooth connection at present. At this time, the system will perform the Bluetooth disconnection operation according to the normal process. Disconnecting the Bluetooth connection can reduce the resource consumption of the system, such as reducing power usage and reducing the burden on the processor, thereby improving the overall performance and battery life of the device. Thus, while meeting the user's needs, the reasonable utilization of system resources is also taken into account. For users who like to listen to music in the screen-off state, not disconnecting the Bluetooth connection in the speaker mode ensures the continuity of music playback; while disconnecting it in time when Bluetooth connection is not needed helps to extend the battery life of the device and improve the operating efficiency of the device.
[0058] Step 102, if the device is not currently in the specified mode, identify the Bluetooth device to be reconnected.
[0059] It should be noted that when the device is in the specified mode, it maintains the connection with the Bluetooth device in the sleep state. If the device is not currently in the specified mode, it means that it has not maintained the connection with the Bluetooth device.
[0060] As a possible implementation, the operating system or related software of the device can provide a function interface for obtaining the list of paired Bluetooth devices. Taking a common operating system as an example, when the Bluetooth function of the device is turned on, the system can maintain a record set of paired devices. By calling the corresponding system functions or interfaces, this list of paired devices can be obtained. For example, in the Bluetooth settings interface of a computer, the relevant information of all the Bluetooth devices that have been paired can be seen.
[0061] After obtaining the list of paired devices, it is necessary to determine the criteria for identifying the Bluetooth device to be reconnected. For example, there can be the following several:
[0062] Device name: Each Bluetooth device has its specific name. The user can search for the corresponding device in the list of paired devices according to the name of the device to be reconnected. For example, if the name of the Bluetooth speaker to be reconnected is "XX brand smart speaker", then the device with a matching name can be searched for in the list.
[0063] Device address: The Bluetooth device has a unique physical address. If the accurate address of the device to be reconnected is known, the device can be identified by comparing the addresses in the list.
[0064] Device Type: Different types of Bluetooth devices have their unique classification identifiers. For example, Bluetooth headsets, Bluetooth keyboards, Bluetooth mice, etc. all belong to different device types. Users can filter out devices that match the type in the list of paired devices according to the type of the device to be reconnected, and then further confirm.
[0065] As a possible implementation, the system can also identify the Bluetooth device to be reconnected by scanning the list of paired devices.
[0066] Step 103, perform a Bluetooth reconnection operation to establish a Bluetooth connection with the Bluetooth device to be reconnected.
[0067] Optionally, the reconnection priority of the Bluetooth device to be reconnected can be determined first based on the connection metric data of each Bluetooth device to be reconnected, and then a Bluetooth connection can be established with the Bluetooth device to be reconnected in turn based on the reconnection priority.
[0068] It can be understood that the reconnection priority of each Bluetooth device to be reconnected can be comprehensively evaluated and accurately determined first based on the connection metric data corresponding to each Bluetooth device to be reconnected.
[0069] Among them, the connection metric data can cover key information in many aspects such as signal strength, connection stability, historical connection success rate, etc. For example, it can include the number of connection times, usage frequency, historical disconnection information, and user-defined tags corresponding to the Bluetooth device, which are not limited here.
[0070] Among them, the number of connection times can be the number of connection times within a specified time, such as the number of connection times in the last 3 days or the last week, which is not limited here.
[0071] Among them, the number of connection times can be the total number of times the device successfully establishes a Bluetooth connection with the current device within a specified time. This data can reflect the frequency of the device being used and connected in the past.
[0072] Among them, the usage frequency can be measured by recording the usage duration or the number of usage times of the device within a certain time range (such as a week or a month). A high usage frequency means that the device is more important to the user.
[0073] Among them, the historical disconnection information can record the number of disconnections, disconnection times, and disconnection reasons that occurred during the past connection process of the device. More specifically, the historical disconnection information can be the time of the last disconnection of the Bluetooth device, which is not limited here.
[0074] Among them, the user can add specific tags to the Bluetooth device according to their own needs, such as "frequently used device", "important device", "backup device", etc. These tags reflect the user's subjective degree of importance to the device.
[0075] After that, reliable Bluetooth connections can be attempted one by one in descending order according to the determined reconnection priority sequence for each Bluetooth device to be reconnected, so as to ensure that connections can be preferentially completed with devices having better performance and more stable connections, improving the overall connection efficiency and user experience.
[0076] Optionally, the weight corresponding to the Bluetooth device to be reconnected can be determined first based on the connection times, usage frequency, historical disconnection information, and user-defined tags of the Bluetooth device to be reconnected. Then, according to the weights corresponding to each Bluetooth device to be reconnected, the reconnection priority of each Bluetooth device to be reconnected can be determined.
[0077] For example, a weight coefficient can be assigned to the connection times, usage frequency, historical disconnection information, and user-defined tags respectively, and the sum of these coefficients should be 1. The assignment of the weight coefficients needs to be determined according to the actual situation and experience. The following is an example:
[0078] Connection times: 0.2
[0079] Usage frequency: 0.3
[0080] Historical disconnection information: 0.3
[0081] User-defined tags: 0.2
[0082] After that, for each Bluetooth device to be reconnected, the corresponding weight score can be calculated based on the collected data and the assigned weight coefficients:
[0083] Connection times score: The score can be calculated by the proportion of the connection times of a device to the total connection times of all devices to be reconnected. For example, if the connection times of device A is 50 times and the total connection times of all devices to be reconnected is 200 times, then the connection times score of device A is 50÷200 = 0.25. Multiply this score by the weight coefficient 0.2 of the connection times to get the weight contribution corresponding to the connection times as 0.25×0.2 = 0.05.
[0084] Usage frequency score: Devices can be ranked according to the usage frequency, and then corresponding scores can be assigned according to the ranking. For example, the device with the highest usage frequency is rated 1 point, the lowest is rated 0 point, and other devices are scored by linear interpolation according to the ranking. Assume that the usage frequency ranking of device A is medium and the score is 0.5. Multiply this score by the weight coefficient 0.3 of the usage frequency to get the weight contribution corresponding to the usage frequency as 0.5×0.3 = 0.15.
[0085] Historical disconnection information score: It can be comprehensively evaluated according to factors such as the number of disconnections and the disconnection time. The fewer the number of disconnections and the shorter the disconnection time, the higher the score. For example, the disconnection situation of device A is better, with a score of 0.8. Multiply this score by the weight coefficient of historical disconnection information, which is 0.3, to obtain the weight contribution corresponding to historical disconnection information as 0.8×0.3 = 0.24.
[0086] User preset label score: It is assigned according to the user-preset labels. For example, "frequently used device" is assigned 1, "important device" is assigned 0.8, and "spare device" is assigned 0.2. Assume that device A is marked by the user as "frequently used device" with a score of 1. Multiply this score by the weight coefficient of user preset labels, which is 0.2, to obtain the weight contribution corresponding to user preset labels as 1×0.2 = 0.2.
[0087] Add up the above-mentioned weight contributions to obtain the final weight score of device A: 0.05 + 0.15 + 0.24 + 0.2 = 0.64. Calculate the weight scores of other devices to be reconnected in the same way.
[0088] After that, the weight scores of each device to be reconnected via Bluetooth can be sorted from high to low. The higher the weight score of a device, the higher its reconnection priority. For example, the weight score of device A is 0.64, the weight score of device B is 0.5, and the weight score of device C is 0.3. Then the reconnection priority order is: device A > device B > device C. When performing the Bluetooth device reconnection operation, attempt to establish a connection with the devices in this priority order.
[0089] It should be noted that the above example is only an illustrative description and does not limit the present disclosure.
[0090] As a possible implementation, if the historical disconnection information is the last disconnection time, and the last disconnection time of a certain Bluetooth device X to be reconnected is the closest to the current time, then the priority of Bluetooth device X can be set as the highest priority.
[0091] Specifically, after determining the reconnection priorities of the Bluetooth devices to be reconnected, establish Bluetooth connections with these devices in order from the highest to the lowest priority. The specific steps are as follows: Select the Bluetooth device to be reconnected with the highest priority from the priority list. Then, use the Bluetooth function of the device to initiate a connection request to the selected device. When initiating the request, ensure that the Bluetooth function of the device is turned on and the device is in a discoverable state. Wait for the response to the connection request. If the connection is successful, continue to process the device with the next priority; if the connection fails, record the reason for the failure (such as the device is not turned on, out of the connection range, etc.), and then skip this device and continue to attempt to establish a connection with the device with the next priority. After that, continuously repeat the above steps until all the devices to be reconnected have been attempted to be connected or the preset connection attempt limit is reached.
[0092] Optionally, it can first be determined whether the driver has entered the USB disconnection state. If the driver has entered the USB disconnection state, report the hardware error information; if the driver has not entered the USB disconnection state, do not report the hardware error information.
[0093] It should be noted that during the driver loading completion stage, the system can determine whether the driver has entered the USB disconnection state. The driver loading completion stage is suitable for determining the state of the driver during the previous operation process. If the driver has ever entered the USB disconnection state, it indicates that there may be hardware problems or abnormal situations. At this time, the system will report the hardware error information so that relevant components such as the upper-layer Bluetooth protocol stack can be aware of it and take corresponding handling measures.
[0094] When it is determined that the driver has not entered the USB disconnection state, the system does not report the hardware error information. This is because without the occurrence of USB disconnection, it means that the driver is relatively stable during the current operation process and there are no abnormalities caused by USB connection problems, so there is no need to report error information to cause the driver to restart. The purpose of doing this is to ensure that the driver can maintain a stable connection state throughout the sleep scenario and avoid system instability factors brought by unnecessary restart operations, such as avoiding problems such as timing disorder and resource access exceptions that may occur during the driver restart process, thereby improving the overall stability and reliability of the system.
[0095] Figure 2 It is a flowchart for controlling the device connection state, mainly based on the screen-on, screen-off broadcasts and speaker mode judgment to determine the device connection operation: When the device receives the screen-on broadcast, it will perform the speaker mode judgment. If it is currently in the speaker mode, the device will maintain the connection state; if it is not in the speaker mode, it will perform the reconnection operation and attempt to re-establish the connection. When receiving the screen-off broadcast, it also performs the speaker mode judgment. If it is in the speaker mode, the device maintains the connection; if it is not in the speaker mode, it will perform the disconnection operation.
[0096] Figure 3 It is a flowchart for setting the priority of device reconnection and connection strategy: First, the system scans the device list to obtain information such as the connection times, usage frequency, importance setting, and the situation of disconnection during the last screen-off of each device. These data are the basis for subsequent evaluation. According to the above information collected, a weight evaluation is performed on each device, and various factors are comprehensively considered to determine the reconnection priority of the device. The device that was disconnected last time is set to the highest priority and will immediately attempt to connect; the devices evaluated as high-priority will also immediately attempt to connect; the low-priority devices will connect in sequence.
[0097] In the embodiments of the present disclosure, first, in response to the monitored screen-on broadcast, it is determined whether the device is currently in a specified mode. Then, if the device is not currently in the specified mode, the Bluetooth device to be reconnected currently is identified, and then a Bluetooth reconnection operation is performed to establish a Bluetooth connection with the Bluetooth device to be reconnected. Among them, when the device is in the specified mode, it maintains the connection with the Bluetooth device in the sleep state. Thus, it is not necessary to trigger Bluetooth reconnection by reporting a hardware error, avoiding unnecessary restart of the driver, occupying relatively little resources, being able to perform Bluetooth reconnection in a timely manner after the screen-on broadcast is monitored, and maintaining the connection with the Bluetooth device in the sleep state when the device is in the specified mode. This can effectively improve the efficiency and speed of Bluetooth reconnection and enhance the stability of Bluetooth reconnection.
[0098] Furthermore, in the embodiments of the present disclosure, a speaker mode selection is introduced, allowing the user to continue to maintain the Bluetooth speaker connection after the screen is off to continuously play music. By monitoring the system screen-on and screen-off broadcasts, it replaces the traditional Bluetooth restart reconnection mechanism, improving the reconnection efficiency and stability. A multi-device recognition and management mechanism is added, and the reconnection priority is set according to the importance and usage frequency of the device, improving the reconnection speed of key devices. The driver reporting hardware error mechanism is optimized to avoid unnecessary driver restarts and enhance the overall stability and reliability of the system. It can solve the problems of slow and unstable Bluetooth disconnection and reconnection speed and system stability problems caused by frequent restarts in the existing technology in the sleep-on startup scenario, improve the Bluetooth reconnection speed in the sleep-on startup scenario, and ensure the user experience. Reduce the number of Bluetooth restarts, reduce resource occupancy, and improve the system resource utilization rate. Optimize the Bluetooth connection management during sleep standby and wake-up, reduce unnecessary Bluetooth connections and driver restarts, and improve the system stability and reliability.
[0099] To facilitate better implementation of the Bluetooth reconnection method of the device of the present disclosure, the present disclosure also provides a Bluetooth reconnection device for the device based on the above Bluetooth reconnection method of the device. The meanings of the nouns are the same as those in the above Bluetooth reconnection method of the device, and the specific implementation details can refer to the description in the method embodiments.
[0100] Please refer toFigure 4 , Figure 4 is a schematic structural diagram of a Bluetooth reconnection device of the device provided in an embodiment of the present disclosure. The Bluetooth reconnection device 400 of the device includes:
[0101] A first judgment module 410, configured to judge whether the device is currently in a specified mode in response to monitoring a screen-on broadcast;
[0102] An identification module 420, configured to identify a currently to-be-reconnected Bluetooth device if the device is not currently in the specified mode;
[0103] A connection module 430, configured to perform a Bluetooth reconnection operation to establish a Bluetooth connection with the to-be-reconnected Bluetooth device, wherein when the device is in the specified mode, the connection with the Bluetooth device is maintained.
[0104] Optionally, the specified mode is a speaker mode, and the device further includes:
[0105] A second judgment module, configured to judge whether the device is currently in the speaker mode in response to monitoring a screen-off broadcast;
[0106] A first execution module, configured to not perform a Bluetooth disconnection operation if the device is in the speaker mode;
[0107] A second execution module, configured to perform a Bluetooth disconnection operation if the device is not in the speaker mode.
[0108] Optionally, the connection module includes:
[0109] A determination unit, configured to determine the reconnection priority of the to-be-reconnected Bluetooth device based on the connection index data of each to-be-reconnected Bluetooth device;
[0110] A connection unit, configured to establish a Bluetooth connection with the to-be-reconnected Bluetooth device in sequence based on the reconnection priority.
[0111] Optionally, the determination unit is specifically configured to:
[0112] Determine the weight corresponding to the to-be-reconnected Bluetooth device based on the connection times, usage frequency, historical disconnection information, and user preset tags corresponding to the to-be-reconnected Bluetooth device;
[0113] Determine the reconnection priority of each to-be-reconnected Bluetooth device according to the weights corresponding to each to-be-reconnected Bluetooth device.
[0114] Optionally, the device further includes:
[0115] A judgment module, configured to judge whether the driver has entered the USB disconnection state;
[0116] The first reporting unit is configured to report hardware error information if the driver has entered the USB disconnection state.
[0117] The second reporting unit is configured not to report the hardware error information if the driver has not entered the USB disconnection state.
[0118] In the embodiments of the present disclosure, first, in response to detecting a screen-on broadcast, it is determined whether the device is currently in a specified mode. Then, if the device is not currently in the specified mode, the currently to-be-reconnected Bluetooth device is identified, and then a Bluetooth reconnection operation is performed to establish a Bluetooth connection with the to-be-reconnected Bluetooth device. Among them, when the device is in the specified mode, the connection with the Bluetooth device is maintained in the sleep state. Thus, it is not necessary to trigger Bluetooth reconnection by reporting a hardware error, avoiding unnecessary restart of the driver, consuming relatively little resources, being able to perform Bluetooth reconnection in a timely manner after detecting the screen-on broadcast, and maintaining the connection with the Bluetooth device in the sleep state when the device is in the specified mode. This can effectively improve the efficiency and speed of Bluetooth reconnection and enhance the stability of Bluetooth reconnection.
[0119] In addition, the present disclosure also provides an electronic device, as Figure 5 shown, which shows a schematic structural diagram of the electronic device involved in the present disclosure. Specifically:
[0120] The electronic device may include a processor 501 with one or more processing cores, a memory 502 with one or more computer-readable storage media, a power supply 503, an input unit 504, and other components. Those skilled in the art can understand that Figure 5 the structural diagram of the electronic device shown in
[0121] does not constitute a limitation on the electronic device, and it may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements. Among them:
[0122] The memory 502 can be used to store software programs and modules. The processor 501 executes various functional applications and data processing by running the software programs and modules stored in the memory 502. The memory 502 mainly includes a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function (such as a sound playback function, an image playback function, etc.); the data storage area can store data created according to the use of the electronic device. In addition, the memory 502 can include high-speed random access memory and can also include non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state storage devices. Correspondingly, the memory 502 can also include a memory controller to provide the processor 501 with access to the memory 502.
[0123] The electronic device further includes a power supply 503 for powering each component. Preferably, the power supply 503 can be logically connected to the processor 501 through a power management system, so as to implement functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 503 can also include any components such as one or more DC or AC power supplies, a recharge system, a power device debugging circuit, a power converter or inverter, and a power status indicator.
[0124] The electronic device may further include an input unit 504, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.
[0125] Although not shown, the electronic device may further include a display unit, etc., which will not be elaborated here. Specifically, in this embodiment, the processor 501 in the electronic device can load the executable files corresponding to the processes of one or more application programs into the memory 502 according to the following instructions, and the processor 501 runs the application programs stored in the memory 502, so as to implement the steps in any one of the Bluetooth reconnection methods for devices provided by the embodiments of the present disclosure.
[0126] For the specific implementation of each of the above operations, reference can be made to the previous embodiments, which will not be elaborated here.
[0127] In an embodiment of the present disclosure, first, in response to detecting a screen-on broadcast, it is determined whether the device is currently in a specified mode. Then, if the device is not currently in the specified mode, the Bluetooth device to be reconnected is identified, and then a Bluetooth reconnection operation is performed to establish a Bluetooth connection with the Bluetooth device to be reconnected. Among them, when the device is in the specified mode, it maintains a connection with the Bluetooth device in the sleep state. Thus, it is not necessary to trigger Bluetooth reconnection by reporting a hardware error, avoiding unnecessary restart of the driver, occupying relatively little resources, being able to perform Bluetooth reconnection in a timely manner after detecting the screen-on broadcast, and maintaining a connection with the Bluetooth device in the sleep state when the device is in the specified mode. This can effectively improve the efficiency and speed of Bluetooth reconnection and enhance the stability of Bluetooth reconnection.
[0128] Those of ordinary skill in the art can understand that all or part of the steps in the above-described methods of the embodiments can be completed by instructions or by controlling related hardware through instructions. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0129] Therefore, the present disclosure provides a computer-readable storage medium on which a computer program is stored. The computer program can be loaded by a processor to execute the steps in the Bluetooth reconnection method of any device provided by the present disclosure.
[0130] For the specific implementation of each of the above operations, reference can be made to the previous embodiments, which will not be elaborated here.
[0131] Among them, the computer-readable storage medium may include: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), a magnetic disk or an optical disc, etc.
[0132] Since the instructions stored in the computer-readable storage medium can execute the steps in the Bluetooth reconnection method of any device provided by the present disclosure, the beneficial effects achievable by the Bluetooth reconnection method of any device provided by the present disclosure can be realized. For details, refer to the previous embodiments, which will not be elaborated here.
[0133] The above has introduced in detail a Bluetooth reconnection method, device, electronic device, and computer-readable storage medium provided by the present disclosure. Specific examples are used herein to elaborate on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention; at the same time, for those skilled in the art, according to the idea of the present invention, there can be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present invention.
Claims
1. A Bluetooth reconnection method for a device, characterized in that, Including: In response to monitoring the screen - on broadcast, determine whether the device is currently in a specified mode; If the device is not currently in the specified mode, identify the Bluetooth device to be re - connected currently; Execute a Bluetooth re - connection operation to establish a Bluetooth connection with the Bluetooth device to be re - connected, wherein, when the device is in the specified mode, it maintains a connection with the Bluetooth device in the sleep state.
2. The method according to claim 1, wherein The specified mode is the speaker mode, and the method further includes: In response to monitoring the screen - off broadcast, determine whether the device is currently in the speaker mode; If the device is in the speaker mode, do not execute the Bluetooth disconnection operation; If the device is not in the speaker mode, execute the Bluetooth disconnection operation.
3. The method according to claim 1, characterized in that The executing the Bluetooth re - connection operation to establish a Bluetooth connection with the Bluetooth device to be re - connected includes: Based on the connection index data of each of the Bluetooth devices to be re - connected, determine the re - connection priority of the Bluetooth devices to be re - connected; Based on the re - connection priority, sequentially establish Bluetooth connections with the Bluetooth devices to be re - connected.
4. The method according to claim 3, characterized in that, The based on the connection index data of each of the Bluetooth devices to be re - connected, determining the re - connection priority of the Bluetooth devices to be re - connected includes: Based on the connection times, usage frequency, historical disconnection information, and user - preset tags corresponding to the Bluetooth devices to be re - connected, determine the weights corresponding to the Bluetooth devices to be re - connected; According to the weights corresponding to each of the Bluetooth devices to be re - connected, determine the re - connection priorities of each of the Bluetooth devices to be re - connected.
5. The method according to claim 1, wherein Also including: Judge whether the driver has entered the USB disconnection state; If the driver has entered the USB disconnection state, report hardware error information; If the driver has not entered the USB disconnection state, do not report the hardware error information.
6. A Bluetooth reconnection device for a device, characterized in that, Including: A first judgment module, configured to, in response to monitoring the screen - on broadcast, determine whether the device is currently in a specified mode; An identification module, configured to, if the device is not currently in the specified mode, identify the Bluetooth device to be re - connected currently; A connection module, configured to execute a Bluetooth re - connection operation to establish a Bluetooth connection with the Bluetooth device to be re - connected, wherein, when the device is in the specified mode, it maintains a connection with the Bluetooth device.
7. The device according to claim 6, characterized in that, The specified mode is the speaker mode, and the device further includes: A second judgment module, configured to, in response to monitoring the screen - off broadcast, determine whether the device is currently in the speaker mode; A first execution module, configured to, if the device is in the speaker mode, do not execute the Bluetooth disconnection operation; A second execution module, configured to, if the device is not in the speaker mode, execute the Bluetooth disconnection operation.
8. The device according to claim 6, characterized in that The connection module, specifically: Based on the connection index data of each of the Bluetooth devices to be re - connected, determine the re - connection priority of the Bluetooth devices to be re - connected; Based on the re - connection priority, sequentially establish Bluetooth connections with the Bluetooth devices to be re - connected.
9. An electronic device, characterized in that, Including a processor and a memory, the memory stores multiple instructions; the processor loads instructions from the memory to execute the steps in the method according to any one of claims 1 - 5.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores multiple instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the method according to any one of claims 1-5.
Citation Information
Cited By
Method and system for optimizing slow Bluetooth reconnection problem of Android system
CN121240054A