A method and apparatus for managing a connection state

By detecting the synchronization service status and disconnecting when idle, the problem of excessive connection load on NAS devices was solved, resulting in reduced load pressure and improved user experience.

CN123185247APending Publication Date: 2026-11-27HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510695254.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-27
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Due to the performance limitations of NAS devices, maintaining too many devices in a long-term connection with the NAS device can lead to excessive connection load, affecting the normal operation of both the devices and the NAS device.

Method used

By monitoring the status of the synchronization service, the device disconnects from the NAS device when the synchronization service is idle, thereby reducing connection load.

Benefits of technology

It effectively reduces the connection load on NAS devices while ensuring the normal operation of the devices and NAS, thus improving the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123185247A_ABST
    Figure CN123185247A_ABST
Patent Text Reader

Abstract

The application provides a method and device for managing a connection state, the method comprising: detecting a state of a synchronization service of a device, the state of the synchronization service comprising a working state and an idle state; and disconnecting a connection between the device and a NAS device in a case where the device and the NAS device are in a connection state and the synchronization service is detected to be in the idle state. In the embodiment of the application, the device can detect the state of the synchronization service, and when the synchronization service is in the idle state and the device and the NAS device are in the connection state, the device can disconnect the connection between the device and the NAS device, which not only reduces the connection load pressure of the NAS device, but also does not affect the normal operation of the device and the NAS device, and helps to improve the experience of a user.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of devices, and more specifically, to a method and device for managing connection states. Background Technology

[0002] With technological advancements and the increasing prevalence of various types of devices, users' personal data is also growing, leading to a surge in demand for storage devices. Storage devices include network attached storage (NAS), which communicates with NAS devices via peer-to-peer network connections. To ensure real-time synchronization with the NAS device, the peer-to-peer network connection needs to maintain a persistent connection through heartbeat requests. However, due to performance limitations of NAS devices, the number of simultaneously online devices is typically limited. Maintaining a large number of persistent connections with the NAS device can result in a significant connection load. Summary of the Invention

[0003] This application provides a method and device for managing connection status. The device can detect the status of the synchronization service. When the synchronization service is in an idle state and the device is connected to the NAS device, the device can disconnect the connection between the device and the NAS device. This reduces the connection load pressure on the NAS device without affecting the normal operation of the device and the NAS device, thus helping to improve the user experience.

[0004] In a first aspect, a method for managing connection states is provided, the method being applied to a device, the method comprising: detecting the state of a synchronization service of the device, the state of the synchronization service including an active state and an idle state; and disconnecting the device from the NAS device when the device is in a connected state with a network accessory device (NAS) and the synchronization service is detected to be in the idle state.

[0005] In this application, the device can detect the status of the synchronization service. When the synchronization service is idle and the device is connected to the NAS device, the device can disconnect the connection between the device and the NAS device. This reduces the connection load pressure on the NAS device without affecting the normal operation of the device and the NAS device, thus improving the user experience.

[0006] In conjunction with the first aspect, in some implementations of the first aspect, detecting the state of the synchronization service includes: detecting a first set associated with the synchronization service, the first set being used to store thread identifiers and / or file identifiers associated with the synchronization service, wherein, if the first set is empty, the synchronization service is in the idle state.

[0007] In conjunction with the first aspect, in some implementations of the first aspect, before disconnecting the device from the NAS device, the method further includes: determining that the duration for which the synchronization service is idle is greater than or equal to a first threshold.

[0008] In this application, before disconnecting the device from the NAS device, the device can also detect the duration of the synchronization service being in an idle state, so that the device can disconnect from the NAS device when the synchronization service is in an idle state for a long time, which can effectively prevent the device from accidentally disconnecting from the NAS.

[0009] In conjunction with the first aspect, in some implementations of the first aspect, before disconnecting the device from the NAS device, the method further includes: determining that the number of devices connected to the NAS device is greater than or equal to a second threshold.

[0010] In this application, before disconnecting the device from the NAS device, the device can also detect the number of devices currently connected to the NAS device. This allows the device to disconnect from the NAS device when its synchronization service is idle and it is determined that the NAS device has a large number of connected devices, thus improving management flexibility.

[0011] In conjunction with the first aspect, in some implementations of the first aspect, when the device displays a first interface, the first set includes a thread identifier of a first thread, and the method further includes: when the display of the first interface is changed to the closing of the first interface, deleting the thread identifier of the first thread from the first set, the first interface being a first directory interface of the storage partition of the NAS device, and the first thread being a thread used to open the directory of the storage partition of the NAS device.

[0012] In conjunction with the first aspect, in some implementations of the first aspect, when the device opens the first file, the first set includes a first file identifier of the first file, and the method further includes: deleting the first file identifier from the first set when the first file is changed from being opened to being closed.

[0013] In conjunction with the first aspect, in some implementations of the first aspect, when the NAS device synchronizes a second file to the device, the first set includes a second file identifier of the second file, and the method further includes: when the NAS device completes the synchronization of the second file, the device deletes the second file identifier from the first set.

[0014] In a second aspect, an apparatus is provided, the apparatus comprising one or more processors; one or more memories; the one or more memories storing one or more programs that, when executed by the one or more processors, cause the foregoing aspects or any possible implementation thereof to be performed.

[0015] Thirdly, a readable storage medium is provided, the readable storage medium including a program or instructions that, when executed on a device, cause the foregoing aspects or any possible implementation thereof to be performed.

[0016] Fourthly, a program product is provided, comprising a program or instructions that, when executed on a device, cause the foregoing aspects or any possible implementation thereof to be performed.

[0017] Fifthly, a program is provided that, when run on a device, causes the foregoing aspects or any possible implementation thereof to be executed.

[0018] Sixthly, an apparatus is provided, comprising modules / units for performing the above aspects or any possible design of the above aspects; these modules / units may be implemented in hardware or by hardware executing corresponding software.

[0019] In a seventh aspect, a chip is provided, the chip including a processor and a communication interface for receiving a signal and transmitting the signal to the processor, the processor processing the signal such that the foregoing aspects or any possible implementation thereof are executed.

[0020] It should be understood that the beneficial effects that can be achieved by the second to seventh aspects provided above can be referred to the beneficial effects of the first aspect and any of its possible design methods, and will not be repeated here. Attached Figure Description

[0021] Figure 1 This is a schematic diagram of the device provided in the embodiments of this application.

[0022] Figure 2 This is a schematic flowchart of a method for managing connection status provided in an embodiment of this application.

[0023] Figure 3 This is a set of GUIs provided in the embodiments of this application.

[0024] Figure 4 This is a schematic diagram of a management of a first set provided in an embodiment of this application.

[0025] Figure 5This is a schematic diagram of another method for managing the first set provided in an embodiment of this application.

[0026] Figure 6 This is a schematic diagram of another method for managing the first set provided in the embodiments of this application.

[0027] Figure 7 This is a schematic flowchart illustrating another method for managing connection status provided in an embodiment of this application.

[0028] Figure 8 This is a schematic diagram of the device composition provided in the application embodiment. Detailed Implementation

[0029] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.

[0030] The terminology used in the following embodiments is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification and appended claims of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to also include expressions such as “one or more,” unless the context clearly indicates otherwise. It should also be understood that in the following embodiments of this application, “at least one” and “one or more” refer to one, two, or more than two. The term “and / or” is used to describe the relationship between related objects, indicating that three relationships may exist; for example, A and / or B can indicate: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character “ / ” generally indicates that the preceding and following related objects are in an “or” relationship.

[0031] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0032] The following describes a device, a user interface for such a device, and embodiments for using such a device. In some embodiments, the device includes, but is not limited to, a mobile phone, tablet computer, smart screen, wearable device, laptop computer, etc. It should also be understood that in some other embodiments, the device also includes a desktop computer.

[0033] For example, Figure 1 A schematic diagram of the structure of device 100 is shown. Device 100 may include a processor 110, an external memory interface 120, an internal memory 121, an antenna 1, a wireless communication module 130, a display screen 140, etc.

[0034] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on device 100. In other embodiments of this application, 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.

[0035] 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.

[0036] The controller can serve as the central nervous system and command center of the device 100. The controller can generate operation control signals based on instruction opcodes and timing signals to control the fetching and execution of instructions.

[0037] 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.

[0038] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0039] The wireless communication function of device 100 can be implemented through antenna 1, wireless communication module 130, modem processor and baseband processor, etc.

[0040] Antenna 1 is used to transmit and receive electromagnetic wave signals. Each antenna in 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 antenna can be used in conjunction with a tuning switch.

[0041] A modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor.

[0042] The wireless communication module 130 can provide a solution for at least one of the following wireless communication technologies applied to the device 100: wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR). The wireless communication module 130 can be one or more devices integrating at least one communication processing module. The wireless communication module 130 receives electromagnetic waves via antenna 1, performs frequency modulation and filtering of the electromagnetic wave signal, and sends the processed signal to processor 110. The wireless communication module 130 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 1.

[0043] Device 100 implements display functions through a GPU, display screen 140, and application processor. The GPU is a microprocessor for image processing, connected to the display screen 140 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.

[0044] The display screen 140 is used to display images, videos, etc. The display screen 140 includes a display panel. In some embodiments, the device 100 may include one or N display screens 140, where N is a positive integer greater than 1.

[0045] Internal memory 121 can be used to store program code, which includes instructions. Processor 110 executes various functional applications and data processing of 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, at least one application program required for a function (such as image playback function), etc. The data storage area may store data created during the use of device 100 (such as audio data), etc. In addition, 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, etc.

[0046] With technological advancements and the increasing prevalence of various types of devices, users' personal data is also growing, leading to a surge in demand for storage devices. Common storage devices include NAS devices, which are devices that provide data storage and allow other devices to access them via a network. NAS devices consist of storage devices (e.g., disk arrays, tape drives, or removable storage media) and embedded system software. NAS devices can be applied in various scenarios, such as home and industrial environments. In this embodiment, a NAS device used in a home environment can be referred to as a home storage device.

[0047] Devices can communicate with NAS devices via peer-to-peer network connections. To ensure real-time synchronization with the NAS device, the peer-to-peer network connection needs to maintain a persistent connection through heartbeat requests. However, due to the performance limitations of NAS devices, the number of devices online simultaneously is generally limited. If too many devices maintain persistent connections with the NAS device without any data exchange, it actually wastes the NAS device's connection resources and increases its connection load. Therefore, managing the connection status between devices and NAS devices has become a pressing technical problem to be solved.

[0048] This application provides a method for managing connection status, which can detect the status of the device's synchronization service and dynamically adjust the connection status between the device and the NAS device based on the status of the synchronization service. This reduces the connection load of the NAS device while ensuring the normal operation of the synchronization service.

[0049] Figure 2 This illustration shows a schematic flowchart of a method for managing connection status provided in an embodiment of this application. This method can be executed by a device, or by a component of the device (e.g., a processor, chip system, etc.). The following description uses a device as the executing entity. Figure 2 As shown, the method 200 includes:

[0050] S201, Detect the status of the synchronization service of the device, which includes working status and idle status.

[0051] The synchronization service in this embodiment refers to the synchronization service between the device and the NAS device. The synchronization service provides functions such as file synchronization and file management between the device and the NAS device. To use the NAS device, the device can install the corresponding application (or operating system) for the NAS device. After installing the application, the device can interact with the NAS device. The synchronization service has two states: active and idle.

[0052] For example, a device can transfer its own files to a NAS device through a synchronization service.

[0053] For example, devices can view and retrieve files stored on the NAS device through the synchronization service.

[0054] For example, the NAS device is connected to Device 1 and Device 2. Device 2 synchronizes file 1 from its own storage device to the NAS device, and the NAS device can then synchronize file 1 back to Device 1.

[0055] In some possible embodiments, after successfully installing the application corresponding to the NAS device, the device may display one or more storage partitions, in which the files are stored on the NAS device.

[0056] Figure 3 A set of graphical user interfaces (GUIs) provided in embodiments of this application are shown.

[0057] like Figure 3 As shown in (a), the device displays an interface 301, which includes multiple storage partitions, such as storage partition 302, storage partition 303, storage partition 304, and storage partition 305. Storage partitions 303, 304, and 305 can be storage partitions of the device's own storage device, while storage partition 305 can be a storage partition corresponding to the NAS device. This storage partition 305 can also be called a sync disk, and the name of this sync disk can be named "Home Storage".

[0058] It should be noted that, Figure 3 The GUI shown in (a) only illustrates the display of a storage partition of a NAS device, but this embodiment does not limit it to this specific case. For example, the device can also display storage partitions of more NAS devices on interface 301. When the device detects a user clicking on storage partition 305, it can display as follows: Figure 3 The GUI shown in (b) is shown in the image.

[0059] like Figure 3 As shown in (b), in response to a user's click on storage partition 305, the device can display interface 306 (or enter the directory of storage partition 305). Interface 306 is the directory interface of storage partition 305, and can also be referred to as the main directory interface of storage partition 305. The device can display files and folders stored in storage partition 305 on interface 306, such as folder 307 and file 308. When interface 306 is displayed, it can be understood that the device is running a synchronization service, i.e., the synchronization service is in working condition. When the device detects a user's click on folder 307, in response to this operation, it can display... Figure 3 The GUI shown in (c) is as follows. When the device detects that the user clicks on file 308, in response to the operation, it can display something like... Figure 3 The GUI shown in (d) is shown in the image.

[0060] like Figure 3 As shown in (c), in response to a user clicking on folder 307, the device can display interface 309. This interface 309 is the interface corresponding to folder 307, and can also be referred to as the next-level directory interface after interface 306, i.e., the subdirectory interface of storage partition 305. The device can display the files, folders, etc. included in folder 307 on interface 309. When interface 309 is displayed, it can also be understood that the device is running a synchronization service, i.e., the synchronization service is in a working state.

[0061] like Figure 3 As shown in (d), in response to the user's click on file 308, the device can display interface 310, which is the interface corresponding to file 308. When interface 310 is displayed, it can also be understood that the device is running a synchronization service, that is, the synchronization service is in a working state.

[0062] It should be noted that for some files, the device may not display the corresponding interface when opening the file, but this can still be understood as the device running a synchronization service.

[0063] If the device responds to the user's action and closes the interface (306), it can be understood that the device is no longer running the synchronization service, meaning the synchronization service is idle.

[0064] If the device responds to the user's operation, it returns from interface 306 to interface 301, and the synchronization service is in an idle state.

[0065] If the device responds to the user's action, closes the interface (309), and the synchronization service is in an idle state.

[0066] If the device responds to the user's operation, closes the interface 310, which means closes the file 308, and the synchronization service is in an idle state.

[0067] The device can copy files from its own storage device to storage partition 305, meaning it synchronizes files from its own storage device to the NAS device. The device can also copy files from storage partition 305 to other storage partitions, meaning it synchronizes files from the NAS device to its own storage device. When the device copies files from its own storage device to storage partition 305, and from storage partition 305 to other storage partitions, it can be understood that the device is running a synchronization service, meaning the synchronization service is active.

[0068] It is understandable that when the device's synchronization service is active, there is data interaction between the device and the NAS device, such as displaying the interface associated with the NAS device (e.g., ...). Figure 3 As shown in interfaces 306, 309, and 310, when the device sends files to the NAS device and retrieves files from the NAS device, the device and the NAS device are in a connected state. When the device's synchronization service is in an idle state, there is no data interaction between the device and the NAS device. Even if the device and the NAS device are disconnected, it will not affect the normal operation of the device and the NAS device. Therefore, in this embodiment, the device can determine whether it needs to disconnect the device from the NAS device by judging the status of the synchronization service.

[0069] In some possible embodiments, the device may configure a first set for storing thread identifiers (IDs) and / or file identifiers associated with the synchronization service. The device can use this first set to determine whether the synchronization service is in a working or idle state. When the first set is empty, the device can determine that the synchronization service is idle; when the first set is not empty, the device can determine that the synchronization service is working. The following describes how information is added to this first set. The name of this first set is merely illustrative and should not be construed as a specific limitation corresponding to the embodiments of this application. For example, the first set may also be called an event set, and the first set may be stored in the form of a list, document, database, array, etc.

[0070] The device can register a detection service in the file explorer. This service can detect events such as opening files, opening storage partitions, opening folders, and closing windows, and determine the corresponding thread IDs for these events. When the device detects a user opening a storage partition on the NAS device through this detection service, it can add the corresponding thread ID to a first set.

[0071] Figure 4 This illustration shows a schematic diagram of managing a first set according to an embodiment of this application. Figure 4 The example shows the device performing four operations: 1. The device opens the storage partition directory of the NAS device; 2. The device opens a folder in the storage partition directory of the NAS device; 3. The device switches from the storage partition directory of the NAS device to the storage partition directory of its own storage device; 4. The device closes the storage partition directory of the NAS device.

[0072] like Figure 4 As shown, the device responds to the user's operation of opening the storage partition directory of the NAS device (such as...). Figure 3As shown in the example, when a user clicks on storage partition 305, the associated thread 1 can be identified, and the thread ID of thread 1 can be added to the first set. At this time, the information stored in the first set includes the thread ID of thread 1.

[0073] Continue to refer to Figure 4 When a user opens a folder in the storage partition directory of the NAS device, the device can identify the associated thread 1 and add the thread ID of thread 1 to the first set. Since the device has already added the thread ID of thread 1 to the first set when opening the storage partition directory of the NAS device, the information stored in the first set at this time is still the thread ID of thread 1.

[0074] Continue to refer to Figure 4 When the device displays the storage partition directory of the NAS device, in response to the user switching from the storage partition directory of the NAS device to the directory of a storage partition of a non-NAS device, it can delete the thread ID of thread 1 in the first set. At this time, the first set is an empty set.

[0075] Continue to refer to Figure 4 When the device displays the NAS device's storage partition directory, in response to the user's action of closing the NAS device's storage partition directory, it can delete the thread ID of thread 1 in the first set. At this time, the first set is an empty set.

[0076] In summary, in some possible embodiments, when the device displays the first interface, the first set includes the thread ID of the first thread. When the device changes from displaying the first interface to closing it, the device can delete the thread ID of the first thread from the first set. The first interface is the directory interface of the NAS device's storage partition, which can be a main directory interface or a subdirectory interface. The first thread is the thread used to open the directory of the NAS device's storage partition. Closing the first interface can be done by the device directly closing the first interface or by changing from displaying the first interface to displaying a second interface. This second interface is not the main directory interface or subdirectory interface of the NAS device's storage partition, nor is it the interface of a file within the main directory interface or subdirectory interface of the NAS device's storage partition. This file includes, but is not limited to, documents, spreadsheets, web pages, audio files, video files, images, etc.

[0077] For example, with Figure 3 Taking the GUI shown as an example, the first interface can be interface 306 or interface 309, and the second interface can be interface 301 or the directory interface corresponding to storage partition 302, storage partition 303, and storage partition 304.

[0078] Figure 5This illustration shows another schematic diagram of managing the first set provided by an embodiment of this application. Figure 5 The example shows the device performing two operations: 1. The device opens a file stored on the NAS device, and 2. The device closes the already opened file, which is stored on the NAS device. The device can open the file stored on the NAS device through a third-party application.

[0079] like Figure 5 As shown, when a device opens a file stored on a NAS device, it can be understood as running a synchronization service. Therefore, when a device opens a file stored on a NAS device, it can add the file identifier to a first set. At this time, the first set includes the file identifier of the opened file.

[0080] Continue to refer to Figure 5 When the device closes an open file, it can delete the file identifier from the first set, which contains files stored on the NAS device. At this point, the first set is empty.

[0081] In this embodiment of the application, the type of file identifier is not specifically limited. For example, the file identifier can be a file handle, a file descriptor, etc.

[0082] In summary, in some possible embodiments, when the device displays the first file, the first set includes the first file identifier of the first file; when the device changes from opening the first file to closing the first file, the device can delete the first file identifier from the first set, wherein the first file is a file stored by the NAS device.

[0083] For example, with Figure 3 Taking the GUI shown as an example, the first file can be file 308.

[0084] Figure 6 A schematic diagram of another method for managing the first set provided in this application is shown.

[0085] like Figure 6 As shown, when a device sends a file to a NAS device or receives a file from a NAS device, the device can add a corresponding file identifier in the first set.

[0086] Continue to refer to Figure 6 When the device completes file synchronization with the NAS device, the device can delete the file identifier in the first set.

[0087] For example, when a device synchronizes file 1 to a NAS device, the device can add the file identifier of file 1 to a first set, and delete the file identifier of file 1 from the first set after the transfer of file 1 is complete.

[0088] For example, when a NAS device synchronizes file 2 to a device, the device can add the file identifier of file 2 to a first set, and delete the file identifier of file 2 from the first set after the transfer of file 2 is completed.

[0089] S202, disconnect the device from the network accessory device when the device is connected to the network accessory device and the synchronization service is detected to be idle.

[0090] The device can disconnect from the NAS device when it is connected to the NAS device and the synchronization service is detected to be idle.

[0091] In this embodiment, the device can detect the status of the synchronization service. When the synchronization service is idle and the device is connected to the NAS device, the device can disconnect the connection between the device and the NAS device. This reduces the connection load pressure on the NAS device without affecting the normal operation of the device and the NAS device, thus improving the user experience.

[0092] In some possible embodiments, the method 200 further includes: before disconnecting the device from the NAS device, the device may determine the duration of the synchronization service being in an idle state; if the duration of the synchronization service being in an idle state is greater than a first threshold, the device may disconnect the device from the NAS device.

[0093] For example, taking a first threshold of 10 minutes as an example, the device can detect the status of the synchronization service in real time. When the device detects that the synchronization service has switched from working state to idle state for more than 10 minutes and the device is connected to the NAS device, the device can disconnect the device from the NAS device.

[0094] In this embodiment, before disconnecting the device from the NAS device, the device can also detect the duration of the synchronization service being in an idle state, so that the device can disconnect from the NAS device when the synchronization service is in an idle state for a long time, which can effectively prevent the device from accidentally disconnecting the device from the NAS.

[0095] In some possible embodiments, the device may also disconnect from the NAS device if the duration of the synchronization service being idle is equal to a first threshold.

[0096] In some possible embodiments, the method 200 further includes: before disconnecting the device from the NAS device, the device may determine the number of devices connected to the NAS device; if the number of devices connected to the NAS device is greater than a second threshold, the device may disconnect the device from the NAS device.

[0097] For example, with the second threshold equal to 10, the device can detect the status of the synchronization service in real time. When the device detects that the synchronization service has switched from the working state to the idle state and the number of devices currently connected to the NAS device is 12, the device can disconnect the device from the NAS device.

[0098] In this embodiment, before disconnecting the device from the NAS device, the device can also detect the number of devices currently connected to the NAS device. This allows the device to disconnect from the NAS device when its synchronization service is idle and it is determined that the NAS device has already connected to a large number of devices, thus improving management flexibility.

[0099] In some possible embodiments, if the number of devices connected to the NAS device is equal to a second threshold, the device may also disconnect from the NAS device.

[0100] Figure 7 This illustration shows a schematic flowchart of another method for managing connection state provided in an embodiment of this application. This method can be executed by a device, or by a component of the device (e.g., a processor, chip system, etc.). The following description uses a device as the executing entity. Figure 7 As shown, the method 700 includes:

[0101] S701 uses the current moment as the detection moment.

[0102] The device can assign the value of the current moment to the detection moment, that is, use the value of the current moment as the timestamp of the detection moment.

[0103] For example, if the current time is 15:03, then the detection time is also 15:03.

[0104] S702, preset delay duration.

[0105] After determining the current time as the detection time, the device can delay it for a preset duration. It should be noted that the detection time remains unchanged after the device delays for the preset duration.

[0106] For example, if the preset duration is 1 minute, after the device determines the detection time as 15:03 at 15:03, it can delay for 1 minute. At this time, the current time becomes 15:04, but the detection time remains 15:03.

[0107] S703, determine whether the first set is an empty set.

[0108] If the device determines that the first set is an empty set, the device can execute S704. If the device determines that the first set is a non-empty set, the device can execute S705.

[0109] For example, taking a preset duration of 1 minute as an example, after the device determines the detection time as 15:03 at 15:03, it can delay for 1 minute, and then execute S703 at 15:04. If the device determines that the first set is an empty set, the device can execute S704. If the device determines that the first set is a non-empty set, the device can execute S705.

[0110] In some possible embodiments, since the execution time of S703 is very short, which can be on the order of milliseconds or microseconds, the execution time of S703 can be ignored.

[0111] S704, determine whether the difference between the current time and the detection time is greater than the first threshold.

[0112] When the device determines that the difference between the current time and the detection time is greater than the first threshold, the device may execute S706. When the device determines that the difference between the current time and the detection time of the first set is less than or equal to the first threshold, the device may execute S702.

[0113] In some possible embodiments, since the execution time of S704 is very short, which can be on the order of milliseconds or microseconds, the execution time of S704 can be ignored.

[0114] In some other possible embodiments, the device may also determine whether the difference between the current time and the detection time is greater than or equal to a first threshold. When the device determines that the difference between the current time and the detection time is greater than or equal to the first threshold, the device may execute S706. When the device determines that the difference between the current time and the detection time of the first set is less than the first threshold, the device may execute S702.

[0115] For example, taking a first threshold of 10 minutes and a first set being empty, when the device executes S701, the determined detection time is 15:03. When the device executes S704, the current time changes from 15:03 to 15:04 after executing S702 and S703. Since the difference between the current time and the detection time is 1 minute, the device can continue executing S702-S704, and so on in a loop. During the loop execution of S702-S704, the detection time remains unchanged, while the current time changes over time. After the current time becomes 15:14, since the difference between the current time and the detection time is 11 minutes, which is greater than the first threshold, the device can execute S706. During the above loop execution, the device can ignore the execution time of S703 and S704. It can be understood that during the loop execution of S702-S704, if the first set changes from an empty set to a non-empty set, the device can execute S705.

[0116] S705 determines whether the device is disconnected from the NAS device.

[0117] If the device determines that the first set is not empty and the peer-to-peer network connection between the device and the NAS device is disconnected, the device can execute S707. If the device determines that the first set is not empty and the peer-to-peer network connection between the device and the NAS device is connected, the device can execute S701 again to start a new loop. When the device executes S701 again, since the current time has changed, the device can update the timestamp of the detection time.

[0118] In some possible embodiments, since the execution time of S705 is very short, which can be on the order of milliseconds or microseconds, the execution time of S705 can be ignored.

[0119] For example, after the device determines the detection time to be 15:03, it can delay for one minute, changing the current time to 15:04. If the device determines that the first set is not empty and the peer-to-peer network connection between the device and the NAS device is active, the device can execute S701 again. When the device executes S701 again, the detection time changes from 15:03 to 15:04 to begin a new cycle. During the execution of this cycle, the device can ignore the execution time of S703 and S705.

[0120] S706, disconnect the device from the NAS device.

[0121] For example, with a first threshold of 10 minutes, the device can disconnect from the NAS device if it determines that the first set is in an empty set state for more than 10 minutes.

[0122] In some possible embodiments, since the execution time of S706 is very short, which can be on the order of milliseconds or microseconds, the execution time of S706 can be ignored.

[0123] While executing S706, the device can also execute S701 again to start a new cycle.

[0124] For example, assuming a first threshold of 10 minutes and an empty first set, after the device determines the detection time as 15:03, it can repeatedly execute S702-S704 until the current time becomes 15:14. Since the difference between the current time and the detection time is 11 minutes, which is greater than the first threshold, the device can disconnect from the NAS device. The device can then execute S701 again. When the device executes S701 again, the detection time changes from 15:03 to 15:14 to start a new cycle. During the execution of the above cycle, the device can ignore the execution time of S703, S704, and S706.

[0125] S707 establishes a connection with NAS devices.

[0126] The device can establish a connection with the NAS device even when the first set is not empty and the device is disconnected from the NAS device.

[0127] In some possible embodiments, since the execution time of S707 is very short, which can be on the order of milliseconds or microseconds, the execution time of S707 can be ignored.

[0128] While executing S707, the device can also execute S701 again to start a new cycle.

[0129] For example, after the device determines the detection time to be 15:03, it can delay for one minute, changing the current time to 15:04. If the device determines that the first set is not empty and the peer-to-peer network connection between the device and the NAS device is disconnected, the device can establish a connection with the NAS device. The device can also execute S701 again. When the device executes S701 again, the detection time changes from 15:03 to 15:04 to begin a new cycle. During the execution of the above cycle, the device can ignore the execution time of S703, S705, and S707.

[0130] In this embodiment, the device can detect the state of the first set. When the first set is empty and the device is connected to the NAS device, the device can disconnect the connection between the device and the NAS device. This reduces the connection load pressure on the NAS device without affecting the normal operation of the device and the NAS device, thus improving the user experience.

[0131] The method for managing connection status provided by the embodiments of this application has been described in detail above. In the various embodiments of this application, unless otherwise specified or in case of logical conflict, the terminology and / or descriptions between the various embodiments are consistent and can be referenced by each other. Technical features in different embodiments can be combined to form new embodiments according to their inherent logical relationships.

[0132] The foregoing primarily describes a method for managing connection states provided in this application from the perspective of the device. It is understood that, in order to achieve the above functions, the device includes corresponding hardware structures and / or software modules for executing each function. Those skilled in the art should readily recognize that, based on the algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and software. Whether a function is executed in hardware or software-driven hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0133] When each function is divided into different modules (or units) to correspond to its specific function, Figure 8 This application provides a schematic diagram illustrating the composition of a device 800 according to an embodiment. Figure 8 As shown, device 800 includes: application module 810, control module 820, and connection module 830.

[0134] The application module 810 may include multiple applications, such as one or more third-party applications, file explorers, etc.

[0135] Application module 810 is used to open or close the directory of storage partitions on the NAS device.

[0136] Application module 810 is also used to open or close files stored in the NAS device.

[0137] Application module 810 is also used to add thread identifiers and / or file identifiers to the first set when the directory of the storage partition of the NAS device is opened and the files stored in the NAS device are opened.

[0138] The control module 820 includes a synchronization module for synchronizing files from the NAS device.

[0139] The control module 820 is also used to detect whether the first set is an empty set.

[0140] The connection module 830 is used to disconnect the device from the NAS device when the first set is empty and the device remains connected to the NAS device.

[0141] This application provides a program product (also referred to as a computer program product) that, when run on a device, causes the device to execute the technical solutions described above. Its implementation principle and technical effects are similar to those of the related embodiments described above, and will not be repeated here.

[0142] This application provides a readable storage medium (also known as a computer-readable storage medium) containing instructions that, when executed by a device, cause the device to perform the technical solution described in the above embodiments. Its implementation principle and technical effects are similar and will not be repeated here.

[0143] This application provides a chip for executing instructions. When the chip is running, it executes the technical solutions described in the above embodiments. Its implementation principle and technical effects are similar and will not be repeated here.

[0144] The above description is merely a specific implementation of the embodiments of this application, but the protection scope of the embodiments of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the embodiments of this application should be included within the protection scope of the embodiments of this application. Therefore, the protection scope of the embodiments of this application should be determined by the protection scope of the claims.

Claims

1. A method for managing connection state, characterized in that, The method is applied to a device, and the method includes: Detect the status of the synchronization service of the device, the status of the synchronization service includes working status and idle status; If the device and the NAS device are in a connected state and the synchronization service is detected to be in the idle state, disconnect the device from the NAS device.

2. The method according to claim 1, characterized in that, The status of the detection synchronization service includes: The first set associated with the synchronization service is detected. The first set is used to store thread identifiers and / or file identifiers associated with the synchronization service. When the first set is empty, the synchronization service is in the idle state.

3. The method according to claim 1 or 2, characterized in that, Before disconnecting the device from the NAS device, the method further includes: The duration during which the synchronization service is in an idle state is determined to be greater than or equal to a first threshold.

4. The method according to any one of claims 1 to 3, characterized in that, Before disconnecting the device from the NAS device, the method further includes: The number of devices connected to the NAS device is determined to be greater than or equal to a second threshold.

5. The method according to claim 2, characterized in that, When the device displays a first interface, the first set includes a thread identifier for a first thread, and the method further includes: When the first interface is changed from being displayed to being closed, the thread identifier of the first thread in the first set is deleted. The first interface is the first directory interface of the storage partition of the NAS device, and the first thread is a thread used to open the directory of the storage partition of the NAS device.

6. The method according to claim 2, characterized in that, When the device opens the first file, the first set includes a first file identifier of the first file, and the method further includes: When the device changes from opening the first file to closing the first file, the device deletes the first file identifier from the first set.

7. The method according to claim 2, characterized in that, When the NAS device synchronizes a second file with the device, the first set includes a second file identifier of the second file, and the method further includes: Upon completing the synchronization of the second file, the NAS device deletes the identifier of the second file from the first set.

8. A device, characterized in that, It includes one or more processors; one or more memories; said one or more memories storing one or more programs, which, when executed by said one or more processors, cause the method as described in any one of claims 1 to 7 to be performed.

9. A readable storage medium, characterized in that, The readable storage medium stores a program that, when run on the device, causes the method as described in any one of claims 1 to 7 to be executed.

10. A program product, characterized in that, When the program product is run on the device, the device performs the method as described in any one of claims 1 to 7.