A connection method and an electronic device
By receiving and comparing status information, the consistency of device status is ensured, which solves the problem of business data failure caused by the failure to detect device disconnection in a timely manner, and realizes the accuracy and reliability of connection management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2026-04-03
AI Technical Summary
The failure to detect the problem of business data transmission failure after the device connection was lost in a timely manner.
By receiving and comparing status information, we ensure the consistency of device status, delete session information in a timely manner, and avoid business data failures caused by inconsistent status.
This effectively avoids business data transmission failures caused by inconsistent device status, ensuring the accuracy and reliability of connection management.
Smart Images

Figure CN120475550B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to a connection method and an electronic device. Background Technology
[0002] When using personal computers (PCs), mobile phones, and tablets, users can achieve data transfer between multiple devices through networking, such as transferring data for services like super keyboard and mouse, screen sharing, and super notifications.
[0003] Networking multiple devices is typically achieved through methods such as Wi-Fi (wireless fidelity) and / or Bluetooth. When establishing a connection using a single method, if the connection is lost, it may take some time for the devices to detect it. However, during this time, sending service data from one device to another will fail. Summary of the Invention
[0004] This application provides a connection method and an electronic device to avoid the problem of service data transmission failure due to the device not sensing the disconnection between devices.
[0005] To achieve the above objectives, the embodiments of this application adopt the following technical solutions:
[0006] In a first aspect, a connection method is provided for use in a first electronic device, the method comprising:
[0007] After establishing a connection with the second electronic device, the first electronic device receives first status information from the second electronic device; this first status information indicates whether the first electronic device is online on the second electronic device. The first electronic device then obtains second status information, which indicates whether the second electronic device is online on the first electronic device. By comparing the first and second status information, it can be determined whether the statuses of the first and second electronic devices on the peer device are consistent. If they are inconsistent—specifically, the first electronic device is offline on the second electronic device while the second electronic device is online on the first electronic device—it indicates that the status of the second electronic device on the first electronic device is inaccurate. In this case, the first electronic device deletes the established session information between the first and second electronic devices. This avoids the problem of the first electronic device failing to send service data to the second electronic device due to the second electronic device being online on the first electronic device.
[0008] With the above solution, in a scenario where, after the first electronic device establishes a connection with the second electronic device, the second electronic device detects the connection loss first, but the first electronic device does not detect the connection loss, and then the second electronic device reconnects and restores the connection with the first electronic device, the first electronic device can delete the established session information based on the first and second state information. This avoids the problem of the first electronic device failing to send service data to the second electronic device due to residual session information from an undetected connection loss. In this solution, even if the first and second electronic devices establish a connection using only one method, such as Bluetooth or Wi-Fi, it can ensure that both devices maintain a consistent state on the other end.
[0009] In another possible implementation of the first aspect, after a connection is established between the first electronic device and the second electronic device, the first electronic device sends a heartbeat broadcast to the second electronic device, and the second electronic device sends a heartbeat broadcast to the first electronic device. The heartbeat broadcast is a broadcast sent at preset intervals.
[0010] In another possible implementation of the first aspect, the first electronic device senses a disconnection, specifically by the first electronic device not receiving a heartbeat broadcast from the second electronic device for a timeout. Alternatively, the first electronic device may sense a disconnection by receiving an operation from the user to disable the connection function on the first electronic device; for example, if the first electronic device and the second electronic device establish a connection via Bluetooth, the operation to disable the connection function could specifically correspond to disabling the Bluetooth function; or if the first electronic device and the second electronic device establish a connection via Wi-Fi, the operation to disable the connection function could specifically correspond to disabling the Wi-Fi function.
[0011] In another possible implementation of the first aspect, the established session between the first electronic device and the second electronic device is used for sending service data between them. That is, when the first electronic device deletes the session information of the established session between the first electronic device and the second electronic device, it means that the first electronic device can no longer send service data to the second electronic device.
[0012] In another possible implementation of the first aspect, the first electronic device may send service data to the second electronic device before deleting the session information of the established session between the first and second electronic devices. Specifically, when the first electronic device sends service data to the second electronic device, it does so by: the first electronic device sending service data to the second electronic device based on the session information of the established session between the two devices.
[0013] In another possible implementation of the first aspect, the session information includes a session identifier.
[0014] In another possible implementation of the first aspect, when the first electronic device establishes a connection with the second electronic device, after detecting the connection establishment and verifying the authentication data from the second electronic device, the first electronic device updates the status of the second electronic device to online on its own device. Furthermore, after updating the status of the second electronic device to online on its own device, the first electronic device also updates the status of the second electronic device's identifier to online on its connection management page.
[0015] Furthermore, the first electronic device maintains the status of the second electronic device based on the heartbeat broadcast sent by the second electronic device. Specifically, if a heartbeat broadcast from the second electronic device is received within the timeout period, the first electronic device keeps the second electronic device's status as online. Additionally, the first electronic device maintains the online status of the second electronic device's identifier on its connection management page.
[0016] Conversely, if the first electronic device does not receive a heartbeat broadcast from the second electronic device within a timeout period, it updates the status of the second electronic device to offline. Additionally, the status of the second electronic device's identifier in the first electronic device's connection management page is updated to offline.
[0017] In another possible implementation of the first aspect, when the first electronic device detects that the user has disabled the connection function on the first electronic device, it can also update the status of the second electronic device to offline. Additionally, the status of the second electronic device's identifier on the first electronic device's connection management page is updated to offline.
[0018] In another possible implementation of the first aspect, the method further includes: if the first electronic device is offline on the second electronic device and the second electronic device is online on the first electronic device, then on the connection management page of the first electronic device, the status of the second electronic device's identifier is updated from online to offline. This ensures that the status of the first and second electronic devices on the peer device is consistent. Furthermore, the first electronic device notifies the user on its connection management page that the second electronic device is currently offline, preventing the user from failing to initiate a service request to the second electronic device from the first electronic device. Afterwards, once the first electronic device has successfully authenticated the second electronic device based on the authentication data from the second electronic device, it can update the second electronic device's identifier from offline to online again on its connection management page.
[0019] In another possible implementation of the first aspect, receiving the first status information from the second electronic device may specifically include: the first electronic device receiving authentication data sent by the second electronic device; wherein the authentication data carries the first status information. That is, in the embodiments of this application, status information is added to the authentication data sent between electronic devices so that the peer device can synchronize its status information based on the status information, thereby ensuring that the status information of both parties is consistent with that of the peer device.
[0020] In another possible implementation of the first aspect, the method may further include: if the first electronic device is offline on the second electronic device, and the second electronic device is offline on the first electronic device, it indicates that the states of both devices on the other end are consistent. In this case, it means that the two devices have not established a connection recently. Therefore, when the first electronic device authenticates the second electronic device based on the authentication data from the second electronic device, the first electronic device can directly update the status of the second electronic device's identifier from offline to online on the connection management page of the first electronic device.
[0021] In another possible implementation of the first aspect, the method may further include: after establishing a connection with the second electronic device, sending second status information to the second electronic device. In this way, the second electronic device can also ensure that its status is consistent with that of the first electronic device based on the second status information sent by the first electronic device.
[0022] Upon receiving the second status information, if the second electronic device is offline on the first electronic device and the first electronic device is online on the second electronic device, then the established session information between the two electronic devices is deleted. Additionally, on the connection management page of the second electronic device, the status of the first electronic device's identifier is updated from online to offline. When the second electronic device successfully authenticates the first electronic device based on the authentication data from the first electronic device, the second electronic device can also update the first electronic device's identifier from offline to online on its connection management page.
[0023] In another possible implementation of the first aspect, updating the status of the second electronic device's identifier from online to offline on the connection management page of the first electronic device can specifically include: de-displaying the identifier of the second electronic device on the connection management page of the first electronic device. Wherein, displaying the identifier of the second electronic device on the connection management page of the first electronic device indicates that the identifier of the second electronic device is online on the connection management page of the first electronic device. Conversely, not displaying the identifier of the second electronic device on the connection management page of the first electronic device indicates that the identifier of the second electronic device is offline on the connection management page of the first electronic device.
[0024] In another possible implementation of the first aspect, updating the status of the second electronic device's identifier from online to offline on the connection management page of the first electronic device can specifically include: updating the second electronic device's identifier from a lit state to a grayed-out state on the connection management page of the first electronic device. Here, a lit-out identifier indicates that the second electronic device is online on the connection management page of the first electronic device. A grayed-out identifier indicates that the second electronic device is offline on the connection management page of the first electronic device.
[0025] The above provides two ways to update the status of electronic device identifiers on the connection management page. Both methods can indicate the online status of devices on the trust ring to the user.
[0026] In another possible implementation of the first aspect, the first electronic device includes a communication module, a device management module, and a control center. After establishing a connection with the second electronic device, receiving first status information from the second electronic device includes: the communication module of the first electronic device receiving the first status information sent by the communication module of the second electronic device after establishing a connection. Obtaining second status information includes: the communication module of the first electronic device obtaining the second status information. Deleting the established session information between the first and second electronic devices includes: the communication module of the first electronic device sending a notification message to the control center through the device management module to trigger the control center to delete the established session information between the first and second electronic devices.
[0027] In one possible implementation of the first aspect, the connection established between the first electronic device and the second electronic device includes a Bluetooth connection or a Wi-Fi connection, etc.
[0028] Secondly, this application also provides an electronic device. The electronic device may include a processor and a memory. The memory stores computer-executable instructions, and when the electronic device is running, the processor executes the computer-executable instructions stored in the memory to cause the electronic device to perform the connection method as described in any of the first aspects above.
[0029] Thirdly, this application provides a computer-readable storage medium storing instructions that, when executed on a computer, enable the computer to perform the connection method described in any of the first aspects above.
[0030] Fourthly, a computer program product containing instructions is provided, which, when run on an electronic device, enables the electronic device to execute any of the connection methods described in the first aspect above.
[0031] Fifthly, an apparatus (e.g., a system-on-a-chip) is provided, comprising a processor for supporting an electronic device in performing the functions described in the first aspect above. In one possible design, the apparatus further comprises a memory for storing program instructions and data necessary for the electronic device. When the apparatus is a system-on-a-chip, it may be composed of chips or may include chips and other discrete devices.
[0032] The technical effects of any of the design methods in aspects two through five can be found in the technical effects of different design methods in aspect one, and will not be repeated here. Attached Figure Description
[0033] Figure 1 This application provides a schematic diagram of the structure of a communication system according to an embodiment of the present application.
[0034] Figure 2 This is a flowchart illustrating a connection method in related technologies;
[0035] Figure 3 A schematic diagram illustrating user operations provided in an embodiment of this application;
[0036] Figure 4 This is a flowchart illustrating a connection method in related technologies;
[0037] Figure 5A A flowchart illustrating a connection method provided in an embodiment of this application;
[0038] Figure 5B A flowchart illustrating a connection method provided in an embodiment of this application;
[0039] Figure 6 A flowchart illustrating a specific implementation of a connection method provided in an embodiment of this application;
[0040] Figure 7 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application;
[0041] Figure 8 This is a framework diagram of a chip system provided in an embodiment of this application. Detailed Implementation
[0042] In related technologies, some electronic devices support interconnection with multiple electronic devices used by the user to realize shared services in interconnected scenarios. For example, shared services in interconnected scenarios may include: screen sharing, keyboard and mouse sharing, remote control, file access, cross-platform invocation (e.g., cross-platform invocation of photo taking, scanning, etc.), and network sharing.
[0043] For example, multiple electronic devices can establish an interconnected relationship based on the same logged-in user account. Figure 1 As shown, mobile phone 1, mobile phone 2, tablet computer 3, and laptop computer 4 are logged into the same user account. These four devices can establish connections with each other. Based on these connections, the four devices can share services.
[0044] In some examples, the ability for multiple devices logged into the same user account to establish connections and share services can be termed ad hoc networks, smart interconnections, or trust rings. Multiple devices logged into the same user account can be represented as devices on the same trust ring.
[0045] Typically, if two devices are logged into the same user account, both have Bluetooth (and / or Wi-Fi) enabled, and are within a certain distance, they can mutually enable each other's online status. Specifically, for device A, after establishing a connection with device B, they exchange authentication data through this connection. Device A can confirm device B's online status after successfully authenticating it based on the authentication data. The same applies to device B enabling device A's online status. Furthermore, after devices A and B are online on the other end, they need to continuously send heartbeat broadcasts. For device A, receiving a heartbeat broadcast from device B within a timeout period is sufficient to keep device B online. Further, when the other device's status is updated to online on the local end, the local end can perform an online operation on the other device's identifier on the trust ring management page, updating the other device's identifier to online to notify the user that the other device is currently online. As an example, the identifier of device A (e.g., device A) comes online on the trust ring management page of the peer device (e.g., device B). Specifically, this means that the identifier of device A is displayed on the trust ring management page of device B. If a mobile phone and a PC are logged into the same user account and both have Bluetooth enabled, a Bluetooth connection is established between the mobile phone and the PC when the distance between them is within a certain range (e.g., the Bluetooth signal range). After the Bluetooth connection is successfully established, the devices authenticate each other by exchanging authentication data. The mobile phone can then display the PC's identifier on its trust ring management page; the PC can display the mobile phone's identifier on its trust ring management page. It should be noted that in other embodiments, device A comes online on the trust ring management page of device B. Specifically, this means that the identifier of device A is changed from a grayed-out state to an illuminated state (or a colored state) on the trust ring management page of device B. It is understood that the trust ring management page can be called by other names, such as the connection management page, interconnection management page, etc.
[0046] After the trust ring management pages of mobile phones and PCs are online, users can initiate services between the two devices by performing operations on the trust ring management pages of their mobile phones or PCs. Taking triggering a keyboard and mouse sharing service from the PC to the mobile phone as an example, the PC will send a session request to the mobile phone in response to the user's trigger operation. The mobile phone will then establish a session with the PC. Afterwards, the PC and mobile phone can transfer relevant service data through this established session to realize the keyboard and mouse sharing service between the PC and the mobile phone.
[0047] A device may support multiple services (i.e., shared services). Different devices may support the same services or different services. Two devices need to have a shared supported service before they can establish a relevant session to transmit service data for that service, thereby enabling shared services.
[0048] Connections between devices can be established via Wi-Fi and / or Bluetooth. When devices establish a connection using only a single communication method (i.e., a single-connection network), communication will cease once the connection is broken. If one device (e.g., device A) goes offline by disabling its connection, another device (e.g., device B) can only detect the other device's offline status after a timeout period without receiving a heartbeat broadcast. There is a certain delay in device B detecting device A's offline status. If the distance between devices A and B exceeds the specified range, causing the connection to break, both devices A and B can only determine the other device's offline status by not receiving a heartbeat broadcast from it after a timeout. However, in this case, it's possible that device A detects the connection break first, followed by device B, meaning there's a certain delay in device B detecting device A's offline status. In the above example, during the time period when device B delays detecting device A's offline status, any service initiated by device B to device A will fail.
[0049] Figure 2 Taking a PC and a mobile phone establishing a connection solely via Bluetooth as an example, this document describes the process of establishing a connection and session between the two devices. In this embodiment, the PC includes a control center, a device management module, and a communication module, and the mobile phone also includes a control center, a device management module, and a communication module. The control center displays the trust ring's management page, which shows the identifiers of each device in the trust ring, indicating their online status and the business flow between them. The device management module manages the online devices in the trust ring. The communication module communicates with other devices.
[0050] The PC interacts with the mobile phone's communication module via its communication module to establish a Bluetooth connection. Based on this Bluetooth connection, the PC's and mobile phone's communication modules exchange authentication data. After successful authentication, both the PC and mobile phone can update the other device's status to online. Furthermore, based on the other device's online status update, both the PC and mobile phone can perform an online operation on the other device's identifier on their respective trust ring management pages. Specifically: After successful authentication, the PC's communication module updates the mobile phone's status to online. Additionally, the PC's communication module sends a mobile phone online message to the control center through the device management module. The control center then performs an online operation on the mobile phone's identifier on the trust ring management page. After online, the mobile phone's identifier indicates that the mobile phone is online in the trust ring. Similarly, after successful authentication, the mobile phone's communication module updates the PC's status to online. Additionally, the mobile phone's communication module sends a PC online message to the control center through the device management module. The control center then performs an online operation on the PC's identifier on the trust ring management page. After online, the PC's identifier indicates that the PC is online in the trust ring. Subsequently, the PC and mobile phone can maintain online status on the other device by sending Bluetooth broadcasts as heartbeats. For example, if the PC receives a heartbeat broadcast from the mobile phone at preset intervals, it can keep the mobile phone's status online and keep the mobile phone's identifier displayed on the trust ring management page; if the mobile phone receives a heartbeat broadcast from the PC at preset intervals, it can keep the PC's status online and keep the PC's identifier displayed on the trust ring management page.
[0051] After a connection is established between a PC and a mobile phone, services can be initiated between them. Taking a user initiating a service on a PC as an example, in response to the service initiation operation, the PC's control center instructs the communication module to initiate the service. The PC's communication module interacts with the mobile phone's communication module to establish a session, denoted as session A. Subsequently, the PC and mobile phone can transmit relevant service data based on session A. In some examples, after session A is established between the PC and the mobile phone, the PC's communication module notifies the PC's control center that session A has been established, and the PC's control center can store the session information of session A. Similarly, the mobile phone's communication module notifies the mobile phone's control center that session A has been established, and the mobile phone's control center stores the session information of session A. In some embodiments, the session information may specifically include a session identifier.
[0052] Taking PCs as an example of electronic devices, combined with Figure 3 This section provides a brief explanation of the Trust Ring management interface and the user's operations within it. For example... Figure 3 As shown, the PC can display the trust ring management page 101.
[0053] On the management page 101, the PC can display the identifiers of devices within the same trust ring as the PC. In some embodiments, the PC may only display the identifiers of currently online devices within the same trust ring as the PC on the management page 101. In other embodiments, the device identifiers displayed on the management page 101 may also include the identifiers of all devices on the trust ring, including online and offline devices. In this embodiment, the PC can distinguish between online and offline devices through different display states. For example, the PC can display the identifiers of online devices in a colored state (or an illuminated state), while displaying the identifiers of offline devices in a grayed-out state. Specifically, "online" on the PC's trust ring management page refers to a device that is powered on, logged into the user account corresponding to the trust ring, and within a certain range of the PC, having established a connection with the PC.
[0054] Specifically, taking devices in the trust ring, including PCs, mobile phones, and tablets, as an example, these devices are represented by icons on the management page 101, using the aforementioned device identifiers as icons. Figure 3 As shown, the management page 101 includes an icon 102 for the local machine (i.e., PC), an icon 103 for the mobile phone, and an icon 104 for the tablet computer. In some examples, the icon representing the device can be named a device ball. The management page 101 can also display the prompt message: "Click the device ball to select the required service to complete the transfer." This prompt message can be used to guide the user to complete the service transfer between devices. It should be noted that the process of transferring service 1 between device A and device B corresponds to the process of device A initiating service 1 to device B.
[0055] On the management page 101, users can select any device icon (i.e., a device sphere) to view the expanded icon of that device. The expanded icon of a device can be used to display the identifier of the services supported by that device as the initiator. Users can choose to view the expanded icon of their own device or other devices on the management page 101. For example, in response to a user's trigger operation on the device's icon 102, the PC can display the expanded icon of the device itself, i.e., the device's service list 105. The trigger operation can be a click, double-click, or long-press operation, etc. Figure 3 The following explanation uses a click operation as an example.
[0056] When the corresponding device's expanded icon is displayed, the PC can also display a prompt message: "Click / drag to complete the service flow." This prompt message is used to remind the user to select the service control for the service to be initiated, as well as the service receiving end.
[0057] In the embodiments of this application, the service list 105 can be used to display controls for services supported by the PC as the initiator. The controls can include icons and names. For example, if the services supported by the PC as the initiator include screen sharing service and keyboard and mouse sharing service, then the service list 105 includes controls for screen sharing service and controls for keyboard and mouse sharing service.
[0058] Taking drag-and-drop as an example, a user can select a service control in service list 105 and drag it to the icon of another device before releasing it. For instance, if a user selects a keyboard and mouse sharing service control in service list 105, drags it to the phone's icon, and then releases it, the PC responds to the dragging operation of the keyboard and mouse sharing service control and the subsequent release operation, triggering the PC to establish a session with the phone based on the keyboard and mouse sharing service. After the session is established, the PC and phone can transfer service data based on the session to realize the keyboard and mouse sharing service.
[0059] Taking a click-based approach as an example, a user can select a service from service list 105 and perform a click operation. For instance, if a user selects the keyboard and mouse sharing service from service list 105 and clicks on the keyboard and mouse sharing service control, the PC will respond to this click operation and display a prompt message. This prompt message guides the user to select the PC as the receiving end based on the keyboard and mouse sharing service. After selecting the keyboard and mouse sharing service, the user selects the receiving end of the service by clicking. For example, if the user selects a mobile phone as the receiving end of the PC's keyboard and mouse sharing service, the PC will respond to the user's click on the mobile phone icon, triggering a session between the PC and the mobile phone based on the keyboard and mouse sharing service to realize the keyboard and mouse sharing service.
[0060] The drag-and-drop or click method described above triggers the process of establishing a session between the PC and the mobile phone based on the keyboard and mouse sharing service. Figure 2 The example shown illustrates the process by which a PC, in response to a user's request to initiate a service, establishes a session with a mobile phone via its communication module.
[0061] After a connection and session are established, if the Bluetooth on the PC or mobile phone is turned off, or if the distance between the PC and mobile phone exceeds a certain range, the Bluetooth connection between the PC and mobile phone will be disconnected. Once the PC detects the Bluetooth connection disconnection, its communication module can notify the PC's control center, which can then delete the session information for Session A. The process of the mobile phone clearing the session information for Session A when it detects the Bluetooth connection disconnection is similar to that of the PC.
[0062] Taking turning off Bluetooth on a PC as an example, the PC immediately disconnects from the phone in response to the Bluetooth shutdown operation. After the Bluetooth connection between the PC and the phone is disconnected, the PC's communication module stops Bluetooth broadcasting and scanning, and updates the phone's status to offline. Then, the PC's communication module sends a notification message to the control center via the device management module, indicating that the phone is offline. In response to this notification message, the control center performs a shutdown operation on the phone's identifier in the trust ring management page. That is, the PC can update the phone's status to offline within a short time. However, the phone needs to rely on heartbeat broadcasts to determine if the PC is online. When the PC turns off Bluetooth, it will no longer broadcast Bluetooth, meaning it cannot send heartbeat broadcasts. The phone can only determine that the PC is offline after a timeout period if it does not receive a heartbeat broadcast from the PC. Compared to the PC immediately updating the phone's status to offline when Bluetooth is turned off, the phone needs to wait a period of time to detect the PC's offline status before updating its status to online. In this scenario, there is a delay in the phone's perception of the PC's offline status.
[0063] From the moment the PC turns off Bluetooth until the phone times out and does not receive a heartbeat broadcast, the PC remains online on the phone. Understandably, while the PC is online on the phone, the phone retains the session information for session A established between the PC and the phone. During this period, if the phone tries to send service data to the PC using this session A information, the data transmission will fail because the PC has Bluetooth turned off.
[0064] Among them, combined Figure 2 There exists a scenario, such as Figure 4 As shown: If the PC re-enables Bluetooth before the phone detects that the PC has gone offline, the PC can re-establish a Bluetooth connection with the phone. After the Bluetooth connection is established, the PC can continue to send heartbeat broadcasts to the phone. Therefore, in this scenario, the phone will not be aware that the PC was briefly offline; thus, on the phone, the PC's status remains online, and the phone retains the session information of the previously established session A. When the user initiates a service request from the phone to the PC, the phone will send the service data to the PC based on the retained session information of session A. However, since the PC has cleared the session information of session A when it turned off Bluetooth, the phone's attempt to send service data to the PC based on session A will fail.
[0065] Based on this, this application proposes a connection method to address the problem in a network scenario where a first electronic device establishes a connection with a second electronic device, but the connection is broken without the first electronic device being aware of the break, leading to the failure of the first electronic device to send service data to the second electronic device and affecting service usage. The method is applied to the first electronic device and includes: after establishing a connection with the second electronic device, the first electronic device receives first status information from the second electronic device. The first status information indicates whether the first electronic device is online on the second electronic device. Then, the first electronic device obtains second status information. The second status information indicates whether the second electronic device is online on the first electronic device. If the first electronic device is offline on the second electronic device and the second electronic device is online on the first electronic device, then the session information of the established session between the first and second electronic devices is deleted. This avoids the problem of the first electronic device failing to send service data to the second electronic device because the second electronic device is online on the first electronic device.
[0066] In the embodiments of this application, the first electronic device and the second electronic device can be of the same type or different types. For example, the first electronic device and the second electronic device can be mobile phones, tablets, personal computers, smart screens, desktop computers, laptops, handheld computers, notebook computers, ultra-mobile personal computers (UMPCs), netbooks, smartwatches and other wearable devices, artificial intelligence (AI) speakers, and in-vehicle devices. They can also be various teaching aids (such as learning machines, early education machines), smart toys, portable robots, personal digital assistants (PDAs), augmented reality (AR) / virtual reality (VR) devices, media players, etc. They can also be devices with mobile office functions, smart home functions, audio-visual entertainment functions, devices supporting smart travel, etc. The embodiments of this application do not impose special limitations on the specific form of the electronic device.
[0067] The connection method proposed in the embodiments of this application will be described in detail below with reference to the accompanying drawings. In the following embodiments, the first electronic device is a mobile phone and the second electronic device is a PC, as an example. Figure 5A The following are some embodiments illustrating the specific implementation process of establishing a connection between a mobile phone and a PC.
[0068] S301. PC establishes connection with mobile phone.
[0069] In some embodiments, the PC and the mobile phone can establish a connection via Bluetooth or Wi-Fi. The communication method for establishing the connection between the PC and the mobile phone is not limited to Bluetooth or Wi-Fi; other communication methods can also be used, and this application embodiment does not impose specific limitations.
[0070] S302. PC and mobile phone interaction authentication data.
[0071] The authentication data is used for authentication between the PC and the mobile phone. Only after the PC successfully authenticates the mobile phone based on the authentication data can the PC update the mobile phone's status to online. Similarly, only after the mobile phone successfully authenticates the PC based on the authentication data can the mobile phone update the PC's status to online.
[0072] In the embodiments of this application, to avoid the problem of inaccurate PC status on the mobile phone leading to failure of the mobile phone to send business data to the PC, status information can be sent to the peer device during authentication data exchange. For example, when the PC sends authentication data to the mobile phone, the authentication data may include first status information, which indicates whether the mobile phone's identifier is online on the PC's trust ring management page. When the mobile phone sends authentication data to the PC, the authentication data may include second status information, which indicates whether the PC's identifier is online on the mobile phone's trust ring management page.
[0073] S303. The mobile phone obtains the second status information S2 and the first status information S1 from the authentication data from the PC.
[0074] The first state information is used to characterize whether the mobile phone is online on the PC. In the embodiments of this application, the mobile phone being online on the PC specifically means that the PC perceives that the mobile phone is currently online in the trust ring. The mobile phone being offline on the PC, i.e., offline, specifically means that the PC perceives that the mobile phone is currently offline in the trust ring. The second state information specifically indicates whether the PC is online on the mobile phone.
[0075] In some embodiments, the PC can store the phone's status parameters to represent the phone's status on the PC. Similarly, the phone can store the PC's status parameters to represent the PC's status on the phone. For example, the phone's status parameters stored on the phone can represent two situations: the PC is online on the phone, and the PC is offline on the phone. For instance, a status parameter of 0 indicates the device is online, and a status parameter of 1 indicates the device is offline. In some embodiments, after the phone successfully authenticates the PC based on authentication data, the phone can update the PC's status parameters to online. Afterward, if the phone receives a heartbeat broadcast from the PC without timeout, it can continue to keep the PC's status parameters online. In this embodiment, the phone obtaining the second status information S2 can specifically include: the phone reading the PC's status parameters to determine the PC's status on the phone.
[0076] The first status information is sent from the PC to the mobile phone. In some embodiments, the first status information is included in the authentication data sent from the PC to the mobile phone. That is, in the technical solution proposed in this application embodiment, by adding status information to the authentication data, the peer device can synchronize its status information according to the status information, so as to ensure that the status information of both parties on the peer device is consistent.
[0077] In some embodiments, the first state information can be specifically represented by oldDiscoveryType. The value of oldDiscoveryType can be 0 or 1. For example, when the value of oldDiscoveryType is 0, it means that the mobile phone is offline on the PC, and when the value of oldDiscoveryType is 1, it means that the mobile phone is online on the PC.
[0078] S304. The mobile phone determines whether S1 indicates that the local device is offline on the PC, and whether S2 indicates that the PC is online on the local device.
[0079] In S304, the local end is the mobile phone. If the judgment result of S304 is yes, it means that the states of the two sides on the other end device are inconsistent. At this time, it is necessary to take the PC offline on the local end, that is, update the status of the PC to offline on the mobile phone, so that the states of the two sides on the other end device are consistent, as shown in S305.
[0080] If the result of S304 is negative, then after the authentication is confirmed to be successful based on the authentication data, the PC status can be directly updated to online on the mobile phone, as in S306.
[0081] S305. The phone updates the PC's status to offline.
[0082] In some embodiments, S305 may specifically include: the mobile phone updating the PC's status parameter from 1 to 0, indicating that the PC's status on the mobile phone is updated from online to offline.
[0083] In other embodiments, S305 may specifically include: the mobile phone performing an offline operation on the PC's identifier on the trust ring management page, that is, updating the PC's identifier to offline on the trust ring management page.
[0084] In other embodiments, if a service has been initiated between the mobile phone and the PC after the connection is established, an established session exists between the mobile phone and the PC, and the session information of that session is stored in the mobile phone. Specifically, S305 may include: the mobile phone deleting the session information of the established session between the mobile phone and the PC.
[0085] In some embodiments, updating the PC's identifier to offline on the trust ring management page of the mobile phone can specifically include: deselecting the PC's identifier from the PC's trust ring management page. Wherein, displaying the PC's identifier on the mobile phone's trust ring management page indicates that the PC is online on the mobile phone's trust ring management page. Conversely, not displaying the PC's identifier on the mobile phone's trust ring management page indicates that the PC is offline on the mobile phone's trust ring management page.
[0086] In another possible implementation of the first aspect, updating the PC's identifier status from online to offline on the phone's trust ring management page can specifically include: updating the PC's identifier from an illuminated state to a grayed-out state on the phone's trust ring management page. An illuminated PC identifier indicates that the PC is online on the phone's trust ring management page. A grayed-out PC identifier indicates that the PC is offline on the phone's trust ring management page.
[0087] In other embodiments, S305 may specifically include: the mobile phone updating the PC's status parameters from online to offline, the mobile phone updating the PC's identifier to offline on the trust ring management page, and the mobile phone deleting the session information of the established session between the mobile phone and the PC.
[0088] After S305, both parties are offline on the other end's device, maintaining consistency. At this point, S306 can be executed.
[0089] S306. After the mobile phone successfully authenticates the PC based on the authentication data, it updates the PC's status to online.
[0090] In some embodiments, S306 may specifically include: the mobile phone updating the PC's status parameter from 0 to 1, indicating that the PC's status on the mobile phone has been updated from offline to online.
[0091] In other embodiments, S306 may specifically include: the mobile phone performing an online operation on the PC's identifier on the trust ring management page, that is, updating the PC's identifier to online on the trust ring management page.
[0092] In other embodiments, S306 may specifically include: the mobile phone updating the PC's status parameters from offline to online, and the mobile phone updating the PC's identifier to online on the trust ring management page.
[0093] S307.PC obtains the first status information S1 and the second status information S2 from the authentication data from the mobile phone.
[0094] S308.PC determines whether S2 indicates that the local device is offline on the mobile phone, and whether S1 indicates that the mobile phone is online on the local device.
[0095] In S308, the local end is the PC. If the judgment result of S308 is yes, then the local end needs to trigger the mobile phone to go offline, even if the status of the mobile phone is updated to offline on the PC, so that the status of both parties on the other end device is consistent, as in S309.
[0096] If the S308's judgment result is negative, then after confirming that the authentication is successful based on the authentication data, the phone's status can be directly updated to online on the PC, as in the S310.
[0097] S309.PC updates the phone's status to offline.
[0098] In some embodiments, S309 may specifically include: the PC updating the phone's status parameter from 0 to 1, indicating that the phone's status on the PC has been updated from offline to online.
[0099] In other embodiments, S309 may specifically include: the PC performing an online operation on the mobile phone's identifier on the trust ring management page, that is, updating the mobile phone's identifier to online on the trust ring management page.
[0100] In other embodiments, if a service has been initiated between the mobile phone and the PC after the connection is established, an established session exists between the mobile phone and the PC, and the session information of that session is stored in the PC. Specifically, S309 may include: the PC deleting the session information of the established session between the mobile phone and the PC.
[0101] In other embodiments, S309 may specifically include: the PC updating the status parameters of the mobile phone from offline to online, the PC updating the mobile phone's identifier to online on the trust ring management page, and deleting the session information of the established session between the mobile phone and the PC.
[0102] After the PC updates its status to offline, both devices will then maintain an offline status on the other end, ensuring consistency. Afterwards, S310 can be executed.
[0103] After S310.PC successfully authenticates the phone based on the authentication data, it updates the phone's status to online.
[0104] In some embodiments, S310 may specifically include: the PC updating the status parameter of the mobile phone from 0 to 1, indicating that the status of the mobile phone on the PC has been updated from offline to online.
[0105] In other embodiments, S310 may specifically include: the PC performing an online operation on the mobile phone's identifier on the trust ring management page, that is, updating the mobile phone's identifier to online on the trust ring management page.
[0106] In other embodiments, S310 may specifically include: the PC updating the status parameters of the mobile phone from offline to online, and the PC updating the mobile phone's identifier to online on the trust ring management page.
[0107] In the technical solution provided in the embodiments of this application, when two devices exchange authentication data after establishing a connection, they send status information to the peer device to inform the local device of the peer device's status. Furthermore, upon receiving the status information sent by the peer device, the local device determines, based on the peer device's status on its own end, whether it is necessary to update the peer device's status on its own end first. Specifically, if the local end is offline on the peer device while the peer device is online on the local end, the local end first updates the peer device's status to offline to ensure consistency between the statuses of both devices. This avoids the problem of service initiation failure due to inconsistencies in the statuses of both devices on the peer device.
[0108] With the above solution, in a scenario where, after the first electronic device establishes a connection with the second electronic device, the second electronic device detects the connection loss first, but the first electronic device does not detect the connection loss, and then the second electronic device reconnects and restores the connection with the first electronic device, the first electronic device can delete the established session information based on the first and second state information. This avoids the problem of the first electronic device failing to send service data to the second electronic device due to residual session information from an undetected connection loss. In this solution, even if the first and second electronic devices establish a connection using only one method, such as Bluetooth or Wi-Fi, it can ensure that both devices maintain a consistent state on the other end.
[0109] like Figure 5B As shown, the connection method proposed in this application embodiment will be described in detail with reference to a specific scenario. The method includes S401-S418.
[0110] S401. PC establishes a connection with mobile phone.
[0111] As can be seen from the above description, in some embodiments, after the PC and the mobile phone establish a connection, the PC continuously sends heartbeat broadcasts to maintain the connection with the mobile phone; the mobile phone continuously sends heartbeat broadcasts to maintain the connection with the PC.
[0112] S402. PC and mobile phone interaction authentication data.
[0113] S403. The mobile phone obtains the second status information S2 and the first status information S1 from the authentication data from the PC.
[0114] exist Figure 5B In the example shown, since the mobile phone and PC have not established a connection before S403, the first state information in S403 indicates that the mobile phone is offline on the PC. Furthermore, the second state information indicates that the PC is offline on the mobile phone.
[0115] S404. The mobile phone determines whether S1 indicates that the local device is offline on the PC, and whether S2 indicates that the PC is online on the local device.
[0116] In S404, "local end" refers to the mobile phone. As explained above, prior to S404, both the first and second status information indicate offline status; therefore, the judgment result of S404 is negative. That is, the status of the peer device is consistent on both the mobile phone and the PC. Furthermore, after confirming successful authentication based on the authentication data, the PC can be directly brought online from the mobile phone, i.e., the PC's status is updated to online on the mobile phone, as shown in S407.
[0117] S405.PC obtains the first status information S1 and the second status information S2 from the authentication data from the mobile phone.
[0118] S406.PC determines whether S2 indicates that the local device is offline on the mobile phone, and whether S1 indicates that the mobile phone is online on the local device.
[0119] In S406, "local end" refers to the PC. As explained above, prior to S406, both the first and second status information indicated offline status; therefore, the judgment result of S406 is negative. That is, the status of the peer device is consistent on both the mobile phone and the PC. Furthermore, after confirming successful authentication based on the authentication data, the mobile phone can be directly brought online on the PC, i.e., the mobile phone's status is updated to online on the PC, as shown in S408.
[0120] S407. After the mobile phone successfully authenticates the PC based on the authentication data, it updates the PC's status to online.
[0121] After S408.PC successfully authenticates the phone based on the authentication data, it updates the phone's status to online.
[0122] For the specific implementation of S401-S408 above, please refer to the specific description of some steps in S301-S310.
[0123] S409.PC detects the connection loss and updates the phone's status to offline on the PC.
[0124] In the embodiments of this application, while the PC senses the connection being disconnected, the mobile phone does not sense the connection being disconnected, so the PC remains online on the mobile phone.
[0125] Taking the connection between a mobile phone and a PC as a Bluetooth connection as an example, in some cases, the PC detects that the connection has been lost, specifically, the PC detects the operation of turning off Bluetooth.
[0126] Taking the connection between a mobile phone and a PC established via Wi-Fi as an example, in some cases, the PC detects that the connection has been lost, specifically, the PC detects the operation of turning off Wi-Fi.
[0127] Furthermore, regardless of the method used to establish a connection between a mobile phone and a PC, the distance between the two devices must remain within a certain range to maintain the connection. When the distance exceeds the preset range, the connection will be lost; simultaneously, heartbeat broadcasts from both the mobile phone and the PC will not be received by the other device. Therefore, in some examples, the PC may perceive a connection loss specifically because it has not received a heartbeat broadcast from the mobile phone for a timeout. The PC can reset the timer after each heartbeat broadcast from the mobile phone; if it still hasn't received a heartbeat broadcast from the mobile phone after the preset timeout, it indicates that the PC has timed out.
[0128] If the PC times out and does not receive a heartbeat broadcast from the phone, the PC can determine that the connection between the PC and the phone has been lost. In this case, the PC can update the phone's status to offline. Similarly, if the phone times out and does not receive a heartbeat broadcast from the PC, the phone can determine that the connection between the phone and the PC has been lost. In this case, the phone can update the PC's status to offline.
[0129] S410.PC restores the connection between the PC and the mobile phone.
[0130] As can be seen from the above embodiments, when the PC senses a disconnection, it can be in response to the PC receiving an operation to turn off Bluetooth (or Wi-Fi); correspondingly, the PC and the mobile phone can reconnect, specifically by the PC receiving an operation to turn on Bluetooth (or Wi-Fi) and then re-establishing a connection with the mobile phone.
[0131] In other examples, the PC may detect a disconnection due to a timeout in receiving a heartbeat broadcast from the phone. In this embodiment, the PC and phone reconnect, specifically after the distance between the PC and the phone returns to a certain range, the PC detects the phone, and re-establishes a connection with the phone after receiving a Bluetooth broadcast (or Wi-Fi broadcast) from the phone.
[0132] In some embodiments, the time interval between S409 and S410 is less than a preset time. For example, this preset time may specifically be the maximum time threshold during which the mobile phone detects the PC going offline because it has not received a heartbeat broadcast from the PC for an extended period.
[0133] S411. PC and mobile phone interaction authentication data.
[0134] S412. The mobile phone obtains the second status information S2 and the first status information S1 from the authentication data from the PC.
[0135] S413. The mobile phone determines whether S1 indicates that the local device is offline on the PC, and whether S2 indicates that the PC is online on the local device.
[0136] exist Figure 5B In the example shown, since the phone does not perceive the connection loss during and after S409, the second state information indicates that the PC is online on the phone. However, after S409, the PC has updated the phone's status to offline, so the first state information indicates that the phone is offline on the PC. Therefore, the judgment result of S413 is yes. At this time, the status of the peer device identifier on the trust ring management page of the phone and PC is inconsistent. To make them consistent, the PC can be taken offline on the phone, that is, the PC's status can be updated to offline on the phone, i.e., S414.
[0137] S414. The phone updates the PC's status to offline.
[0138] After a connection is established between a mobile phone and a PC, both devices can go online on the other end. Since the connection is reciprocal, normally, while the connection is maintained, both the mobile phone and the PC are online on the mobile phone. When the connection is broken, both the mobile phone and the PC are offline on the mobile phone. That is, under normal circumstances, the state of the mobile phone on the PC should be consistent with the state of the PC on the mobile phone. Therefore, when the mobile phone detects a discrepancy between its state on the PC and the PC's state on the mobile phone, it indicates that one device is delayed in going offline. In this situation, the device that delayed in detecting the other device's offline status may experience transmission failures when sending service data to the other device. In the embodiments of this application, to avoid this situation, when it is determined that the state of the mobile phone on the PC is inconsistent with the state of the PC on the mobile phone, the mobile phone performs an offline operation on the PC to compensate for the offline status, updating the PC's state on the mobile phone to offline. This ensures that the state of the mobile phone on the PC is consistent with the state of the PC on the mobile phone.
[0139] After the mobile phone performs the offline operation for the PC compensation, the PC re-establishes a connection with the mobile phone. Therefore, after the authentication is successful based on the authentication data, the mobile phone can update the PC's status back to online, i.e., S417.
[0140] S415.PC obtains the first status information S1 and the second status information S2 from the authentication data from the mobile phone.
[0141] S416.PC determines whether S2 indicates that the local device is offline on the mobile phone, and whether S1 indicates that the mobile phone is online on the local device.
[0142] As explained above, in S416, the second state information indicates that the local terminal (i.e., the PC) is online on the mobile phone, and the first state information indicates that the mobile phone is offline on the local terminal. That is, the judgment result of S416 is negative. At this time, after the PC determines that the authentication is successful based on the authentication data, it can directly perform the online operation on the mobile phone on the PC, that is, update the status of the mobile phone to online on the PC, as in S418.
[0143] S417. After the mobile phone successfully authenticates the PC based on the authentication data, it updates the PC's status to online.
[0144] After S418.PC successfully authenticates the phone based on the authentication data, it updates the phone's status to online.
[0145] In the technical solution proposed in this application, during the period when the PC first detects the connection loss and takes the phone's identifier offline on the trust ring management page, and the phone does not yet detect the connection loss, if the PC and phone reconnect within a short time, the phone can combine the first status information sent by the PC with the phone's second status information to perform an offline operation on the phone, thereby updating the PC's status to offline on the phone. This ensures that the states of the phone and PC on the other end device remain consistent, avoiding the problem of inaccurate PC status on the phone leading to failures in sending service data from the phone to the PC.
[0146] As explained above, the specific reason why the mobile phone fails to send service data to the PC during the period when the PC detects the connection loss but the mobile phone does not is that the mobile phone retains the session information of the session established when the connection was not broken (denoted as session A). The mobile phone sends service data to the PC through this session A. However, after the PC detects the connection loss, it updates the mobile phone's status to offline and clears the session information of session A between the PC and the mobile phone. Therefore, the mobile phone cannot successfully send service data to the PC based on session A. To avoid this problem, in the embodiments of this application, when the PC and the mobile phone establish a connection, the current status of the mobile phone on the PC is synchronized with the mobile phone. In this way, the mobile phone can trigger the mobile phone to go offline to the PC when the status of the two devices is inconsistent, that is, update the PC's status to offline and clear the session information of session A stored in the mobile phone. Figure 6 The specific implementation process of the connection method proposed in this application is shown.
[0147] like Figure 6 As shown, the connection method includes:
[0148] The S501.PC's communication module establishes a Bluetooth connection with the mobile phone's communication module.
[0149] In different electronic devices, different communication modules may be named differently. In some embodiments, the communication module of a PC may be named the Softbus module. In some embodiments, the communication module of a mobile phone may be named the Nearby module.
[0150] The S502.PC's communication module exchanges authentication data with the mobile phone's communication module.
[0151] S503. The mobile phone's communication module obtains the second status information S2 and the first status information S1 from the authentication data from the PC.
[0152] S504. The mobile phone determines whether S1 indicates offline and whether S2 indicates online.
[0153] Combination Figure 4 As can be seen from the examples, if the judgment result of S504 is negative, S507a-S507c can be executed.
[0154] The S505.PC obtains the first status information S1 and the second status information S2 from the authentication data from the mobile phone.
[0155] S506.PC determines whether S2 represents offline and whether S1 represents online.
[0156] Combination Figure 4 As can be seen from the examples, if the judgment result of S506 is negative, S508a-S508c can be executed.
[0157] S507a. The mobile phone successfully authenticates the PC based on the authentication data, and the mobile phone's communication module notifies the device management module that the PC is online.
[0158] In some embodiments, the method further includes: the mobile phone successfully authenticating the PC based on the authentication data, and the mobile phone's communication module updating the PC's status parameters to online. The PC's status parameters are stored in the mobile phone's communication module.
[0159] S507b. The device management module of the mobile phone notifies the control center that the PC is online.
[0160] The S507c phone's control center performs an online operation on the PC's identifier on the trust ring display page.
[0161] S508a.PC authenticates the mobile phone based on the authentication data, and the PC's communication module notifies the device management module that the mobile phone is online.
[0162] In some embodiments, the method further includes: the PC authenticating the mobile phone based on the authentication data, and the PC's communication module updating the mobile phone's status parameters to online. The mobile phone's status parameters are stored in the PC's communication module.
[0163] The S508b.PC's device management module notifies the control center that the mobile phone is online.
[0164] The S508c.PC's control center performs an online operation on the phone's identifier on the trust ring display page.
[0165] It should be noted that S507a-S507c can be executed first, followed by S508a-S508c; or S508a-S508c can be executed first, followed by S507a-S507c; or S507a-S507c and S508a-S508c can be executed simultaneously. In the embodiments of this application, the execution order of S507a-S507c and S508a-S508c is not limited.
[0166] S509. Mobile phones and PCs stay online by sending heartbeat broadcasts.
[0167] In response to the request to initiate a service, the S510.PC notifies the communication module to initiate the service.
[0168] The S511.PC's communication module establishes session A with the mobile phone's communication module.
[0169] In some embodiments, after session A is established, the PC's communication module can also notify the PC's control center that session A has been established by calling a callback function. Subsequently, when the PC's control center sends service data to the mobile phone in response to user operations, it can do so through the established session A. Similarly, the mobile phone's communication module can also notify the mobile phone's control center that session A has been established by calling a callback function. Subsequently, when the mobile phone's control center sends service data to the PC in response to user operations, it can do so through the established session A. For example, the callback function can specifically be represented as sessionopened.
[0170] As an example, after the PC's communication module notifies the PC's control center that session A has been established by calling a callback function, the PC's communication module can store the session information of session A. This session information is used to send service data to the peer device when initiating a service.
[0171] S512. The mobile phone's communication module notifies the control center that session A has been established.
[0172] S513. The phone's control center stores session information for session A.
[0173] The S514.PC's communication module notifies the control center that session A has been established.
[0174] The S515.PC's control center stores session information for session A.
[0175] S516. Transmit service data based on session A.
[0176] The S517.PC's communication module received an order to turn off Bluetooth.
[0177] The S518.PC's communication module stops Bluetooth broadcasting and scanning.
[0178] In some embodiments, the method further includes: after the PC's communication module stops Bluetooth broadcasting and scanning, the PC's communication module updates the mobile phone's status parameters to offline.
[0179] The S519a.PC's communication module notifies the device management module that the mobile phone is offline.
[0180] The S519b.PC's device management module notifies the control center that the mobile phone is offline.
[0181] In some embodiments, the communication module notifies the device management module that the mobile phone is offline, and the device management module notifies the control center that the mobile phone is offline. This can be achieved by calling an interface. For example, the interface can be represented as onlinkDownsession.
[0182] The S519c.PC's control center performs a deactivation operation on the phone's identifier on the trust ring management page.
[0183] The S520 PC's control center clears session information for session A.
[0184] The S521.PC's communication module receives the command to enable Bluetooth.
[0185] The S522 PC's communication module establishes a Bluetooth connection with the mobile phone's communication module.
[0186] The S523 PC's communication module exchanges authentication data with the mobile phone's communication module.
[0187] S524. The mobile phone's communication module obtains the second status information S2 and the first status information S1 from the authentication data from the PC.
[0188] S525. Does S1 of the mobile phone represent offline, and does S2 represent online?
[0189] Combination Figure 4 As can be seen from the example, if the judgment result of S525 is yes, then S526a-S526c can be executed.
[0190] S526a. The mobile phone's communication module notifies the device management module that the PC is offline.
[0191] S526b. The device management module of the mobile phone notifies the control center that the PC is offline.
[0192] In some embodiments, the above method further includes: if the determination result of S525 is yes, the communication module of the mobile phone updates the status parameters of the PC to offline.
[0193] In some embodiments, the mobile phone's communication module notifies the device management module that the PC is offline, and the device management module notifies the control center that the PC is offline, which can be specifically addressed by calling onlinkDownsession once.
[0194] The S526c phone's control center performs a deactivation operation on the PC's identifier on the trust ring management page.
[0195] In addition, if the judgment result of S525 is yes, the mobile phone can also execute S527 to avoid the problem that residual session A will cause the mobile phone to fail to initiate business to the PC later.
[0196] S527. Clear session information for session A from the phone's control center.
[0197] After that, the phone can execute S530a-S530c.
[0198] S528.PC obtains the first status information S1 and the second status information S2 from the authentication data from the mobile phone.
[0199] S529.PC determines whether S2 represents offline and whether S1 represents online.
[0200] As can be seen from the above explanation, in S529, S2 represents online and S represents offline. The judgment result of S529 is negative, and S531a-S531c can be executed.
[0201] S530a. The mobile phone authenticates the PC based on the authentication data and the mobile phone's communication module notifies the device management module that the PC is online.
[0202] The S530b mobile phone's device management module notifies the control center that the PC is online.
[0203] The S530c phone's control center performs an online operation on the PC's identifier on the Trust Ring display page.
[0204] S531a.PC authenticates the mobile phone based on the authentication data, and the PC's communication module notifies the device management module that the mobile phone is online.
[0205] The S531b.PC's device management module notifies the control center that the mobile phone is online.
[0206] The S531c.PC's control center performs an online operation on the phone's identifier on the trust ring display page.
[0207] It should be noted that S530a-S530c can be executed first, followed by S531a-S531c; or S531a-S531c can be executed first, followed by S530a-S530c; or S530a-S530c and S531a-S531c can be executed simultaneously. In the embodiments of this application, the execution order of S530a-S530c and S531a-S531c is not limited.
[0208] S532. The mobile phone responds to the request to initiate a service and notifies the communication module to initiate the service.
[0209] S533. The mobile phone's communication module communicates with the PC's communication module to establish session B.
[0210] It should be noted that Session B and Session A are only used to distinguish between sessions established at different times.
[0211] S534. The mobile phone's communication module notifies the control center that session B has been established.
[0212] S535. The phone's control center stores session information for session B.
[0213] The S536.PC's communication module notifies the control center that session B has been established.
[0214] The S537.PC's control center stores session information for session B.
[0215] S538. Transmit service data based on session B.
[0216] Since both the PC and the mobile phone are aware of the newly established session B, this session B exists in the control centers of both the mobile phone and the PC. Therefore, whether a service is initiated from the PC to the mobile phone or vice versa, the service data can be transmitted through this session B.
[0217] In the technical solution proposed in this application, during the period when the PC first detects the connection loss and goes offline in the trust ring, but the mobile phone does not yet detect the PC's offline status, if the PC reconnects within a short time and the PC and mobile phone reconnect, the mobile phone can perform a compensatory offline operation on the PC based on the status of the mobile phone on the PC sent by the PC. This ensures that the status of the mobile phone and PC on the peer device remains consistent, avoiding the problem of inaccurate PC status on the mobile phone, specifically the issue of delayed PC offline on the mobile phone causing the mobile phone to fail to send service data to the PC.
[0218] The above embodiments have provided a detailed description of the connection method. Next, we will describe the electronic device that implements the connection method.
[0219] like Figure 7The diagram shown is a structural schematic of an electronic device 100 provided in an embodiment of this application. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, antenna 1, antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a sensor module 180, buttons 190, a motor 191, a camera 192, a display screen 193, and a subscriber identification module (SIM) card interface 194, etc. The sensor module 180 may include a pressure sensor 180A, a touch sensor 180B, etc.
[0220] For example, the electronic device 100 may be the first electronic device described above, or it may be the second electronic device.
[0221] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0222] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0223] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to the instruction opcode and timing signals to complete the control of fetching and executing instructions.
[0224] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0225] USB interface 130 is an interface that conforms to the USB standard specification, specifically it can be a Mini USB interface, Micro USB interface, USB Type C interface, etc. USB interface 130 can be used to connect a charger to charge electronic device 100, and it can also be used for data transfer between electronic device 100 and peripheral devices.
[0226] The external storage interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.
[0227] Internal memory 121 can be used to store executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a given function (such as sound playback, image playback, etc.).
[0228] In addition, the internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0229] The charging management module 140 is used to receive charging input from the charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 can receive charging input from the wired charger via the USB interface 130.
[0230] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, internal memory 121, external memory, display 193, camera 192, and wireless communication module 160, etc.
[0231] In some other embodiments, the power management module 141 may also be located within the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may also be located in the same device.
[0232] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.
[0233] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with tuning switches.
[0234] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1.
[0235] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLAN) (such as Wi-Fi), Bluetooth, Global Navigation Satellite System (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR). The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signal, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.
[0236] The wireless communication module 160 can specifically correspond to the communication module in the above embodiments. In some embodiments of this application, the electronic device 100 can establish a connection with other devices based on Wi-Fi or Bluetooth provided by the wireless communication module 160, and maintain online status with the other device by sending heartbeat broadcasts after the connection is established.
[0237] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, so that electronic device 100 can communicate with networks and other devices through wireless communication technology.
[0238] Electronic device 100 can implement audio functions through audio module 170 and application processor, such as music playback and recording.
[0239] The audio module 170 is used to convert digital audio signals into analog audio signals for output, and also to convert analog audio inputs into digital audio signals. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 may be located in the processor 110.
[0240] Pressure sensor 180A is used to sense pressure signals and convert them into electrical signals. In some embodiments, pressure sensor 180A may be disposed on display screen 193. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, and capacitive pressure sensors. A capacitive pressure sensor may include at least two parallel plates with conductive material. When a force is applied to pressure sensor 180A, the capacitance between the electrodes changes. Electronic device 100 determines the pressure intensity based on the change in capacitance. When a touch operation is applied to display screen 193, electronic device 100 detects the touch operation intensity based on pressure sensor 180A. Electronic device 100 can also calculate the touch position based on the detection signal from pressure sensor 180A.
[0241] Touch sensor 180B, also known as a "touch panel," can be located on display screen 193. The touch sensor 180B and display screen 193 together form a touchscreen, also known as a "touch screen." Touch sensor 180B is used to detect touch operations applied to or near it. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through display screen 193. In other embodiments, touch sensor 180B may also be located on the surface of electronic device 100, in a different position than display screen 193.
[0242] Buttons 190 include a power button, volume buttons, etc. Buttons 190 can be mechanical buttons or touch-sensitive buttons. Electronic device 100 can receive button input and generate key signal inputs related to user settings and function control of electronic device 100.
[0243] Motor 191 can generate vibration alerts. Motor 191 can be used for incoming call vibration alerts or for touch vibration feedback.
[0244] Camera 192 is used to capture still images or videos. In some embodiments, electronic device 100 may include one or N cameras 192, where N is a positive integer greater than 1.
[0245] Electronic device 100 implements display functions through a GPU, a display screen 193, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 193 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0246] The display screen 193 is used to display images, videos, etc. In some embodiments, the electronic device 100 may include one or N display screens 193, where N is a positive integer greater than 1.
[0247] The SIM card interface 194 is used to connect a SIM card. The SIM card can be inserted into or removed from the SIM card interface 194 to achieve contact and separation with the electronic device 100. The electronic device 100 can support one or N SIM card interfaces, where N is a positive integer greater than 1.
[0248] The connection methods described in the above embodiments can all be implemented in the electronic device 100 with the above hardware structure.
[0249] Other embodiments of this application provide an electronic device (such as a PC or mobile phone). The electronic device may include a memory and one or more processors. The memory is coupled to the processors. The memory is also used to store computer program code, which includes computer instructions. When the processor executes the computer instructions, the electronic device can perform various functions or steps performed by the mobile phone or PC in the above method embodiments. The structure of the electronic device can be referred to... Figure 7 The structure of the electronic device 100 shown.
[0250] This application also provides a chip system, such as... Figure 8As shown, the chip system 800 includes at least one processor 801 and at least one interface circuit 802. The processor 801 and the interface circuit 802 are interconnected via lines. For example, the interface circuit 802 can be used to receive signals from other devices (e.g., a computer's memory). As another example, the interface circuit 802 can be used to send signals to other devices (e.g., the processor 801). Exemplarily, the interface circuit 802 can read instructions stored in memory and send those instructions to the processor 801. When the instructions are executed by the processor 801, the computer can perform the steps in the above embodiments. Of course, the chip system may also include other discrete devices, which are not specifically limited in this application embodiment.
[0251] This application also provides a computer-readable storage medium including computer instructions that, when executed on the aforementioned electronic device (such as a mobile phone or PC), cause the electronic device to perform various functions or steps performed by the mobile phone or PC in the above method embodiments.
[0252] This application also provides a computer program product that, when run on a computer, causes the computer to perform the various functions or steps performed by the mobile phone or PC in the above method embodiments. The computer can be an electronic device, such as a mobile phone or PC.
[0253] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0254] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0255] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0256] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0257] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0258] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A connection method, characterized in that, Applied to a first electronic device, the method includes: After establishing a connection with the second electronic device, first status information is received from the second electronic device; the first status information is used to characterize whether the first electronic device is online on the second electronic device; Obtain second status information; the second status information is used to characterize whether the second electronic device is online on the first electronic device; If the first electronic device is offline on the second electronic device and the second electronic device is online on the first electronic device, then delete the session information that has been established between the first electronic device and the second electronic device.
2. The method according to claim 1, characterized in that, The method further includes: If the first electronic device is offline on the second electronic device and the second electronic device is online on the first electronic device, then on the connection management page of the first electronic device, the status of the identifier of the second electronic device will be updated from online to offline, and then from offline to online.
3. The method according to claim 1 or 2, characterized in that, The receiving of first status information from the second electronic device includes: The system receives authentication data sent by the second electronic device; the authentication data carries the first status information.
4. The method according to any one of claims 1-3, characterized in that, The method further includes: If the first electronic device is offline on the second electronic device, and the second electronic device is offline on the first electronic device, then on the connection management page of the first electronic device, the status of the second electronic device's identifier will be updated from offline to online.
5. The method according to any one of claims 1-4, characterized in that, The method further includes: After establishing a connection with the second electronic device, the second status information is sent to the second electronic device.
6. The method according to claim 2, characterized in that, The step of updating the status of the second electronic device's identifier from online to offline on the connection management page of the first electronic device includes: On the connection management page of the first electronic device, the identifier of the second electronic device is not displayed; when the connection management page of the first electronic device displays the identifier of the second electronic device, it indicates that the identifier of the second electronic device is online on the connection management page of the first electronic device; when the connection management page of the first electronic device does not display the identifier of the second electronic device, it indicates that the identifier of the second electronic device is offline on the connection management page of the first electronic device. or, On the connection management page of the first electronic device, the identifier of the second electronic device is updated from lit to grayed out; when the identifier of the second electronic device is lit, it indicates that the identifier of the second electronic device is online on the connection management page of the first electronic device; when the identifier of the second electronic device is grayed out, it indicates that the identifier of the second electronic device is offline on the connection management page of the first electronic device.
7. The method according to any one of claims 1-6, characterized in that, The first electronic device includes a communication module, a device management module, and a control center; The step of receiving first status information from the second electronic device after establishing a connection with the second electronic device includes: after the communication module of the first electronic device establishes a connection with the communication module of the second electronic device, receiving the first status information sent by the communication module of the second electronic device; The step of obtaining the second status information includes: the communication module of the first electronic device obtaining the second status information; The deletion of the session information between the first electronic device and the second electronic device includes: the communication module of the first electronic device sending a notification message to the control center through the device management module to trigger the control center to delete the session information between the first electronic device and the second electronic device.
8. An electronic device, characterized in that, The electronic device includes: a processor, a memory, and a computer program stored in the memory; the memory is coupled to the processor. When the electronic device is running, the processor executes the computer program to implement the method as described in any one of claims 1-7.
9. A computer-readable storage medium, characterized in that, The device contains a computer program that, when executed by a processor of an electronic device, implements the method as described in any one of claims 1-7.
10. A computer program product, characterized in that, It includes a computer program, which, when executed by a processor, implements the method as described in any one of claims 1-7.
Citation Information
Patent Citations
Bluetooth Mesh device state updating method and display device
CN111405331A
Online state detection method and device of equipment
CN115801645A