An event handling method, an electronic device, and a storage medium

By monitoring data file change events in electronic devices and using preset filtering rules to merge or filter continuous change events, the error problem caused by frequent I/O operations in data synchronization is solved, improving the accuracy of file synchronization and user experience.

CN120407523BActive Publication Date: 2026-03-13HONOR DEVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-31
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

Existing data synchronization methods lead to frequent I/O operations and concurrent thread resource contention when users perform continuous operations on data files, causing errors in the file synchronization service's handling of the final state of the data files.

Method used

By monitoring data file change events in electronic devices, and using preset filtering rules to merge or filter consecutive change events, the number of events processed synchronously can be reduced, thus avoiding errors.

Benefits of technology

This effectively reduces errors in the final state processing of data files by the file synchronization service, thus improving the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120407523B_ABST
    Figure CN120407523B_ABST
Patent Text Reader

Abstract

This application provides an event processing method, electronic device, and storage medium, relating to the field of data processing, which can avoid the defect of file synchronization service processing the final state of data files incorrectly due to multiple consecutive change events in a short period of time. The method includes: upon detecting a first change event of a first data file, if a first change event set exists, filtering the first change event and at least one second change event included in the first change event set according to a preset filtering rule to update the first change event set; the second change event is a change event of the first data file or the second data file that has been detected but not yet synchronized, and the second data file is a data file associated with the first data file; if no change event of the first data file or the second data file is received within a first preset time period, synchronizing the change events in the first change event set.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The application relates to the field of terminal technology, and in particular to an event processing method, electronic device, and storage medium. Background Technology

[0002] With the rapid development of information technology and smart terminals, users are increasingly using various electronic devices such as mobile phones, tablets (portable Android devices, PADs), and personal computers (PCs). Due to the differences in the functions and suitable application scenarios of these electronic devices, users may use different devices in different situations. To facilitate users processing data files on other electronic devices while using one, a data synchronization method can be used to automatically synchronize data files from device A to device B or a network-side device. Then, when using device B, the user can directly process the data files from device A stored on device B, or download data files from device A from the network-side device to device B for processing.

[0003] However, current data synchronization implementations, to ensure timely synchronization of data files, use monitoring tools to listen for changes in data files in real time and report these changes to the file synchronization service. The file synchronization service then processes these changes accordingly (e.g., writing changes to the storage area and reading changes from the storage area) to complete the synchronization. However, if user operations on data files generate multiple consecutive change events, and the monitoring tool reports each change event directly to the file synchronization service, the service will frequently perform I / O operations and process the intermediate state of the data files (the data files before the user has completed modifications). Furthermore, because current electronic devices typically use multiple parallel processes or threads to complete computations or processing tasks to improve processing speed, these frequent I / O operations and processing of intermediate states can lead to errors in the file synchronization service's handling of the final state of the data files (the state that needs to be synchronized after the data files have been modified) due to resource contention, data races, and conflicts between parallel threads. Summary of the Invention

[0004] This application provides an event processing method, an electronic device, and a storage medium that can reduce the number of change events that a file synchronization service needs to process, and avoid the defects caused by multiple consecutive change events in a short period of time leading to errors in the final state of data files in the file synchronization service.

[0005] To achieve the above objectives, the embodiments of this application adopt the following technical solutions:

[0006] In a first aspect, embodiments of this application provide an event processing method applied to an electronic device. The method includes: when a file synchronization task exists, monitoring change events of data files in a target path indicated by the file synchronization task; if a first change event of a first data file is detected, and if a first change event set exists, filtering the first change event and at least one second change event included in the first change event set according to a preset filtering rule to update the first change event set; the second change event is a change event of a first data file or a second data file that has been monitored but not synchronized, and the second data file is a data file associated with the first data file; if no change event of the first data file or the second data file is received within a first preset time period, synchronizing the change events in the first change event set.

[0007] Based on the technical solution provided in this application, since the time interval between change events generated during a user's adjustment of a data file is very short, multiple change events generated consecutively in a short period of time for a file can be considered as generated by a single user adjustment operation. Therefore, in the technical solution provided in this application, when an electronic device performs a file synchronization task, it can merge multiple change events generated consecutively in a short period of time for the same data file (two associated files are also considered the same file). This reduces the number of change events that need to be synchronized for the data file (e.g., the first data file), thereby minimizing the possibility of errors in the file synchronization service's handling of the final state of the data file due to too many change events generated by a user's adjustment operation.

[0008] In one possible implementation of the first aspect, filtering is performed on the first change event and at least one second change event included in the first change event set according to a preset filtering rule to update the first change event set, including: if the first change event is a deletion event or a removal event, and if there is a creation event or a removal event among the at least one second change event, then the first change event set is set to empty; if the first change event is a deletion event or a removal event, and there is no creation event or removal event among the at least one second change event, then the updated first change event set is controlled to include only deletion events.

[0009] If the first change event is a deletion or removal event, and at least one of the second change events contains a creation or removal event, it indicates that for the first data file (or the second data file), the electronic device, in response to a user operation, first created or removed the file to a specific path, and then deleted or removed it from the specific path shortly afterward. Therefore, it can be considered that the first data file has not undergone any substantial change. Thus, in this case, it can be assumed that the first data file has no change events, and updating the first change event set can be done by setting the first change event set to empty. If the first change event is a deletion or removal event, and at least one of the second change events does not contain a creation or removal event, it indicates that for the first data file (or the second data file), the electronic device, in response to a user operation, has currently deleted the file. Therefore, regardless of whether there were other events besides initial removal or creation events in the first change event set, this deletion will invalidate those events. Thus, in this case, it can be assumed that the first data file only has a deletion event, and updating the first change event set can be done by updating the first change event set to include only deletion events.

[0010] In summary, based on the technical solutions corresponding to the above implementation methods, when the current first change event is a deletion event or a removal event, appropriate filtering methods can be used to filter the first change event and at least one second change event included in the first change event set, thereby reducing the number of change events. This minimizes the possibility of errors in the file synchronization service's handling of the final state of the data file caused by too many change events generated by a user's adjustment operation on the data file.

[0011] In one possible implementation of the first aspect, filtering the first change event and at least one second change event included in the first change event set according to a preset filtering rule to update the first change event set, further includes: if the first change event is a creation event or a move-in event, controlling the updated first change event set to include only the newly added event or the first change event.

[0012] If the current first change event is a creation event or a move-in event, it indicates that the first data file has just been created or moved to a specific path. The first change event set can only contain move-out or delete events for the first data file. Previous move-out or delete events have no significance for the newly created first data file. When synchronizing creation events later, they are generally treated as new events. Therefore, the updated first change event set can be configured to include only the first change event, or for ease of subsequent processing, the updated first change event set can be configured to include only new events.

[0013] In summary, based on the technical solutions corresponding to the above implementation methods, when the current first change event is a creation event or a move-in event, appropriate filtering methods can be used to filter the first change event and at least one second change event included in the first change event set, thereby reducing the number of change events. This minimizes the possibility of errors in the file synchronization service's handling of the final state of the data file caused by too many change events generated by a user's adjustment operation on the data file.

[0014] In one possible implementation of the first aspect, filtering the first change event and at least one second change event included in the first change event set according to a preset filtering rule to update the first change event set further includes: if the first change event is not a deletion event, a move-in event, a creation event, or a move-in event, and if at least one second change event contains a change event of the same type as the first change event, then controlling the first change event set not to change; if the first change event is not a deletion event, a move-in event, a creation event, or a move-in event, and if at least one second change event does not contain a change event of the same type as the first change event, then adding the first change event to the first change event set to update the first change event set.

[0015] If a first change event of the same type already exists in the first change event set, it can be considered a duplicate event for the first data file. For a given data file, one change event of a certain type is sufficient to reflect the change indicated by that type of change event. Subsequent synchronization processing of that type of change event is also sufficient to synchronize the changes of that type of change event to the data file. Therefore, in this case, the first change event does not need to be changed. If a first change event of the same type does not exist in the first change event set, it can be considered a non-duplicate event for the first data file. This first change event is meaningful for synchronizing modifications to the data file. Therefore, adding this first change event to the first change event set in this case allows for better synchronization of the first data file when synchronizing the first change event set subsequently.

[0016] In summary, based on the technical solutions corresponding to the above implementation methods, when the current first change event is a duplicate event or a non-duplicate event, appropriate filtering methods can be used to filter the first change event and at least one second change event included in the first change event set, thereby reducing the number of change events. This helps to avoid the defect that the file synchronization service might err in processing the final state of the data file due to too many change events generated by a user's adjustment operation on the data file.

[0017] In one possible implementation of the first aspect, where each monitored change event carries an event identifier of a specific number of bits, with only one bit set to 1, and the order of the 1 bits in the event identifiers corresponding to different types of change events is different, the method further includes: performing a bitwise AND operation on the event identifier corresponding to the target event and the event identifier sum of the first change event set to obtain a first AND operation result; the event identifier sum is the sum of the event identifiers carried by all second change events in the first change event set, and the target event is an insert event, an remove event, a creation event, or a deletion event; if the first AND operation result contains 1, then it is determined that the target event exists in the first change event set; if the first AND operation result does not contain 1, then it is determined that the target event does not exist in the first change event set.

[0018] Based on the technical solution corresponding to the above implementation method, the relevant judgments required for filtering the first change event and at least one second change event included in the first change event set can be quickly completed by AND operation according to preset filtering rules. This allows the electronic device to quickly complete the filtering process of the first change event and at least one second change event included in the first change event set, thereby completing the update of the first change event set. This reduces the number of change events and avoids as much as possible the defect of the file synchronization service making errors in the final state of the data file due to too many change events generated by a user's adjustment operation on the data file.

[0019] In one possible implementation of the first aspect, the method further includes: performing a bitwise AND operation between the event identifier carried by the first change event and the event identifier of the first change event set to obtain a second bitwise AND result; if the second bitwise AND result contains 1, then it is determined that there is a change event of the same type as the first change event in the first change event set; if the second bitwise AND result does not contain 1, then it is determined that there is no change event of the same type as the first change event in the first change event set.

[0020] Based on the technical solution corresponding to the above implementation method, the electronic device can successfully determine whether there is a change event of the same type as the first change event in the first change event set, thereby improving the efficiency of filtering the first change event and at least one second change event included in the first change event set, thereby reducing the number of change events, and thus avoiding as much as possible the defect that the file synchronization service will make mistakes in the final state of the data file due to too many change events generated by a user's adjustment operation on the data file.

[0021] In one possible implementation of the first aspect, after adding the first change event to the first change event set to update the first change event set, the method further includes: determining the sum of the event identifiers of the first change event set before the update and the event identifiers carried by the first change event as the sum of the event identifiers of the first change event set after the update.

[0022] Based on the technical solution corresponding to the above implementation method, when a change event of the first data file or the second data file is received again, it is convenient to perform relevant processing based on the latest event identifier and completion. This allows the electronic device to smoothly reduce the number of subsequent change events, thereby avoiding the defect of the file synchronization service making errors in the final state of the data file due to too many change events generated by a user's adjustment operation on the data file.

[0023] In one possible implementation of the first aspect, the file identification information carried by the first change event is the same as the file identification information carried by the second change event of the first data file; the file identification information carried by the first change event and the association identification information carried by the second change event of the second data file are equal and not preset values; the file identification information is used to characterize the data file corresponding to the change event, and the association identification information is used to characterize the association relationship between the change event and other change events.

[0024] In one possible implementation of the first aspect, the file identification information includes the file name and the monitoring descriptor WD, and the associated identification information includes cookies, with a default value of 0.

[0025] Secondly, embodiments of this application also provide an event processing device, which can be applied to an electronic device. The functions of this device can be implemented in hardware or by executing corresponding software. The hardware or software includes one or more modules corresponding to the aforementioned functions, such as a listening module, a filtering module, and a processing module.

[0026] The system includes the following modules: a monitoring module for monitoring changes in data files in the target path indicated by a file synchronization task; a filtering module for updating the first change event set by filtering the first change event and at least one second change event included in the first change event set according to preset filtering rules when the monitoring module detects a first change event in the first data file; and a processing module for synchronizing the change events in the first change event set when the monitoring module does not detect any change events in the first or second data file within a first preset time period.

[0027] Thirdly, this application provides an electronic device including a memory and one or more processors; the memory is coupled to the processors; wherein the memory stores computer program code, the computer program code including computer instructions, which, when executed by the processor, cause the electronic device to perform an event handling method as provided in the first aspect and any of its possible design embodiments.

[0028] Fourthly, this application provides a computer-readable storage medium including computer instructions that, when executed on an electronic device, cause the electronic device to perform an event processing method as provided in the first aspect and any possible design of the present application.

[0029] Fifthly, this application provides a computer program product that, when run on an electronic device, causes the electronic device to execute the event processing method provided by the first aspect and any possible design of the first aspect.

[0030] Understandably, the beneficial effects that the technical solutions provided in the second to fifth aspects described above can be achieved can be referred to the beneficial effects in the first aspect and any of its possible design methods, which will not be repeated here. Attached Figure Description

[0031] Figure 1 This application provides a schematic diagram of a file synchronization scenario.

[0032] Figure 2 A schematic diagram of a file synchronization process is provided for embodiments of this application;

[0033] Figure 3 A schematic diagram illustrating the principle of an event handling method provided in an embodiment of this application;

[0034] Figure 4A schematic diagram of the hardware architecture of an electronic device provided in an embodiment of this application;

[0035] Figure 5 A schematic diagram of the software architecture of an electronic device provided in an embodiment of this application;

[0036] Figure 6 A flowchart illustrating an event handling method provided in this application embodiment. Figure 1 ;

[0037] Figure 7 A flowchart illustrating an event handling method provided in this application embodiment. Figure 2 ;

[0038] Figure 8 A flowchart illustrating an event handling method provided in this application embodiment. Figure 3 ;

[0039] Figure 9 This is a schematic diagram of the structure of an event processing device provided in an embodiment of this application. Detailed Implementation

[0040] The terminology used in the following embodiments of this application 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 include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that “ / ” means “or,” for example, A / B can mean A or B; “and / or” in the text is merely a description of the relationship between related objects, indicating that three relationships can exist, for example, A and / or B can mean: A alone, A and B simultaneously, and B alone.

[0041] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application can be combined with other embodiments.

[0042] The terms "first" and "second" in the following embodiments of this application are for descriptive purposes only and should not be construed as implying relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.

[0043] First, the terms used in the embodiments of this application are explained as follows:

[0044] (1) Trust Ring: The same user account can log in on different electronic devices. When two or more electronic devices under the same user account trust each other, then the two or more electronic devices constitute a trust ring. For an electronic device in the trust ring (such as electronic device 1), the other electronic devices in the trust ring (such as electronic device 2) can all be understood as trusted devices of electronic device 1. The application used to build the trust ring in the electronic device can be called a trust ring application.

[0045] (2) Non-access stratum: NAS. In a protocol stack-based classification of existing communication systems (e.g., Universal Mobile Telecommunications System (UMTS)), the NAS layer is the highest layer in the control plane. As a functional layer between the core network and user terminals, the NAS supports signaling and event processing between the two.

[0046] In this embodiment, the network-side device (or NAS device) existing in the non-access stratum can serve as one end of data synchronization. When a user needs to use a data file on the network-side device, the data file can be downloaded from the network-side device to the currently used electronic device for use. Of course, before downloading, the user needs to establish a trust loop between the currently used electronic device and the network-side device. For example, by logging into the user account corresponding to the network-side device in the trust loop application on the currently used electronic device, a trust loop between the currently used electronic device and the network-side device can be constructed.

[0047] (3) Input / Output (I / O) Operations: I / O operations refer to the process of exchanging data between a computer and the outside world. These operations include reading data from external devices (such as keyboard, mouse, monitor, disk drive, network devices, etc.) (input operations) and writing data to external devices (output operations).

[0048] (4) Event: In computer science and software engineering, an "event" typically refers to a meaningful state change or specific behavior that occurs within a system. Events can be triggered by user actions, such as clicking a button or typing on a keyboard; they can also be triggered by internal system activities, such as timer expiration, changes to data files, or changes in network connection status. In this embodiment, an event refers to a change in the state of a data file or its related directory. These changes may include, but are not limited to, creation / addition, deletion, modification, movement (moving in and out), and renaming. Furthermore, to facilitate the differentiation of different events, different types of data file change events can correspond to different identifiers, such as mask values.

[0049] When a monitoring tool listens for changes in the file system, it detects / captures changes to data files within the file system and generates corresponding change events (or change event objects). These change events can include all relevant information, such as a mask indicating the specific type of change, a watch descriptor (WD) indicating the file path / directory of the data file corresponding to the change event, a timestamp indicating the time the change event occurred, and cookies indicating the association between this change event and other change events (specifically, whether the corresponding data files are related or substantially identical (i.e., the content is completely the same)). When cookies are 0 (or the default value), it indicates that the change event is not associated with any other change event. When cookies are not 0, it indicates that the change event is associated with other change events; specifically, if the cookies of two change events are not 0 and are equal, then the two change events are considered associated, meaning the data files corresponding to these two change events are related (or substantially identical).

[0050] In related technologies, in order to enable users to process data files on other electronic devices while using one electronic device, a data synchronization method can be used to automatically synchronize data files on electronic device A to electronic device B or network-side devices.

[0051] Taking electronic device A, which includes tablets and mobile phones, as an example, in one possible implementation scenario, refer to... Figure 1 As shown in (a), for user A's multiple electronic devices, user A can configure the trust loop application on each electronic device to automatically back up the data files of their tablet and mobile phone to their personal computer via data synchronization. In another possible implementation scenario, refer to... Figure 1As shown in (b), for multiple electronic devices of user A, user A can also configure the trust ring application on the network side device by setting the trust ring application on each electronic device and by using specific methods (such as instructing the electronic device manufacturer or the trust ring application manufacturer) to enable the data files of his / her tablet computer and mobile phone to be automatically backed up to his / her personal computer in the form of data synchronization (or can be called automatic file backup).

[0052] Of course, in practice, file synchronization can take many other possible scenarios, and this application does not impose any specific restrictions on them.

[0053] After that, when using electronic device B, the user can directly process the data files of electronic device A that are present in electronic device B, or download the data files of electronic device A from the network side device to electronic device B for processing.

[0054] In one possible implementation, electronic devices A and B, which have established a trust loop, synchronize data files from electronic device A to electronic device B through the trust loop application and corresponding file synchronization services. The process can be as follows: Figure 2 As shown:

[0055] First, the user operates the trust ring application on electronic device A, causing the trust ring application on electronic device A to call the file synchronization software development kit (SDK) interface to complete the creation of synchronization configuration information in the file synchronization service, i.e., 1.1 and 1.2. The synchronization configuration information may include the file path / directory of the data files to be synchronized, the file metadata of the data files, synchronization identifiers, and other configuration information. In some embodiments, the synchronization configuration information may be called a repository, and the synchronization identifier may be called a repository identifier (ID, identity document). The file metadata of the data files may include the file name, modification time (latest modification event), creation time, size, hash value, etc.

[0056] Similarly, users can also manipulate the trust ring application on device B, causing the trust ring application on device B to create a repository in the file synchronization service based on the file synchronization SDK interface. The paths / directories of the files to be synchronized in the repository created on device B can be different.

[0057] After electronic devices A and B create repos in the file synchronization service, to facilitate data file synchronization between electronic device A and electronic device B, repo sharing (i.e., 2.1) is required. This allows electronic device B to determine whether to accept synchronization data from electronic device A, such as subsequent file metadata and file synchronization content, based on its own repo and the repo created in electronic device A. In this embodiment, repo sharing specifically involves the file synchronization service in electronic device A storing the repo in a specific database (DB). After completing repo persistence (i.e., 1.3), the file synchronization service can send the relevant data of the repo (i.e., repo metadata) to the file synchronization service of electronic device B, i.e., executing 3.1. After receiving the repo metadata from the file synchronization service of electronic device A, the file synchronization service of electronic device B can decide whether to accept synchronization data from electronic device A based on the repo ID in the repo metadata and the repo ID in its own repo. Specifically, if the repo ID in the repo metadata of the file synchronization service from electronic device A is the same as the repo ID included in the repo in electronic device A, then the file synchronization service of electronic device B can accept the synchronization data from electronic device A. Of course, the file synchronization service of electronic device B will also send the judgment result to the file synchronization service of electronic device A, so that electronic device A knows that electronic device B has created a repository and can receive synchronization data, and can then send synchronization data to the file synchronization service of electronic device B.

[0058] After the repository is created on electronic device A, the file synchronization service on electronic device A can determine whether there is a data synchronization need or a data synchronization task. Then, the file synchronization service on electronic device A can use a listening tool to monitor the file paths indicated by the repository in the file system, i.e., execute step 4.1.

[0059] When an application in electronic device A creates or modifies (including moving, deleting, renaming, etc.) a file in the file path indicated by the repo in the file system (i.e., 4.2), the monitoring tool can detect this situation, generate the corresponding change event, and report it to the file synchronization service to complete the change notification to the file synchronization service (i.e., 4.3).

[0060] Upon receiving a reported change event, the file synchronization service in electronic device A first persists the change event, i.e., proceeds to step 4.4. In one possible implementation, the file synchronization service can generate a flag indicating the change event based on it and store it in the file metadata of the data file corresponding to the change event in the database. This file metadata can be obtained when electronic device A creates a repository and stored in the database along with the repository during persistence, or it can be obtained from the storage area where the data file is stored and stored in the database when a change event is first received. Each time the file synchronization service persists a change event, it causes a change in the database (or a change in the database's storage level) and generates a corresponding change record. Of course, in practice, the file synchronization service can also store the change event in the database and establish a correspondence between the change event and the corresponding file metadata.

[0061] Furthermore, the file synchronization service in electronic device A can read changes from the database in real time or periodically at shorter intervals (e.g., 5ms), i.e., execute 5.1. If it is determined that new data exists in the database, the file synchronization service can send the file metadata corresponding to the new data to the file synchronization service in electronic device B, i.e., execute 5.2.

[0062] After receiving file metadata from electronic device A, the file synchronization service of device B can compare this file metadata with the corresponding file metadata in its own database, i.e., proceed to step 5.3. The files to which the two file metadata entries belong must have the same file path. If the file metadata from device A differs from the corresponding file metadata stored in device B's database, and the modification time of the file metadata from device A is updated, then the file synchronization service of device B requests the file content of the data file corresponding to that file metadata from the file synchronization service of device A. This request can be a file content request, which may include a file identifier (e.g., name, path). If the file metadata from device A is identical to the corresponding file metadata stored in device B's database, then the file synchronization service of device B will not perform any further actions.

[0063] After receiving a file content request from the file synchronization service of electronic device B, the file synchronization service of electronic device A can read the file content of the corresponding data file from the storage area where the data file is stored, i.e., execute 6.1. Then, the file synchronization service of electronic device A can send the file content of the data file to the file synchronization service of electronic device B (i.e., execute 6.2) for it to update the data file.

[0064] After obtaining the file content of the data file, electronic device B can use the file content of the data file to update the data file in the corresponding storage area, thus completing the file writing to disk (i.e., 6.3).

[0065] This completes one file synchronization process.

[0066] As can be seen, current data synchronization methods employ a monitoring tool to listen for changes in data files in real time and report these changes to the file synchronization service in order to ensure timely synchronization of the required data files. This allows the file synchronization service to process the changes accordingly (e.g., writing change events to the storage area and reading change records from the storage area) to complete the synchronization.

[0067] However, if user operations on data files (such as copying and pasting a data file) generate multiple consecutive change events, and the monitoring tool immediately reports each change event to the file synchronization service, the file synchronization service will frequently perform I / O operations (i.e., persisting changes and reading change records) and frequently process the intermediate state of the data file (the data file before the user has finished modifying it) (i.e., reading file content and sending it to the file synchronization service of another electronic device). Furthermore, because current electronic devices typically use multiple parallel processes or threads to complete computation or processing tasks to improve processing speed, the aforementioned frequent I / O operations and frequent processing of the intermediate state of the data file may lead to errors in the file synchronization service's handling of the final state of the data file (the state that needs to be synchronized after the data file has been transformed) due to issues such as resource contention or data races and conflicts between parallel threads. This results in a poor user experience.

[0068] To address the aforementioned technical problems, this application provides an event handling method applied in an electronic device. In this technical solution, reference is made to... Figure 3 As shown, when a file synchronization task exists in the electronic device (performing file synchronization), the system monitors for changes in data files under the target path indicated by the file synchronization task.

[0069] If a first change event corresponding to a first data file is detected, and a first change event set is determined to exist, the first change event is added to the first change event set. Then, the first change event and at least one second change event included in the first change event set are filtered (or merged) according to preset filtering rules to update the first change event set. The updated first change event set includes at least one third change event, the number of which is less than or equal to the sum of the number of first and second change events. The first change event set includes at least one second change event, which is a change event of a first or second data file that has been detected but not yet synchronized. The first and second data files are identical or related. The second data file is either a renamed version of the first data file or a data file whose file path has been changed. If a first change event set does not exist, a second change event set corresponding to the first data file is generated based on the first change event.

[0070] Subsequently, if no change event is detected in the first or second data file within the first preset time period, the first or second change event set can be synchronized to complete the synchronization of the first data file. After synchronization, the first or second change event set is deleted.

[0071] Based on the technical solution provided in this application, since the time interval between change events generated during a user's adjustment of a data file is very short, multiple change events generated consecutively in a short period of time for a file can be considered as generated by a single user adjustment operation. Therefore, when performing file synchronization tasks, the technical solution provided in this application can merge multiple change events generated consecutively in a short period of time for the same data file (two associated files are also considered the same file), thereby reducing the number of change events that need to be synchronized for that data file (e.g., the first data file). This minimizes the possibility of errors in the file synchronization service's handling of the final state of the data file due to too many change events generated by a user's adjustment operation.

[0072] The technical solutions provided in the embodiments of this application will be described in detail below with reference to the accompanying drawings.

[0073] The technical solutions provided in this application can be applied to electronic devices that have a trust ring application or file synchronization functionality provided by a trust ring application. In some embodiments, the electronic device may be a mobile phone, tablet computer, handheld computer, personal computer (PC), ultra-mobile personal computer (UMPC), netbook, as well as cellular phone, personal digital assistant (PDA), augmented reality (AR) device, virtual reality (VR) device, artificial intelligence (AI) device, wearable device, in-vehicle device, smart home device and / or smart city device, etc. The embodiments of this application do not impose any special limitations on the specific type of electronic device.

[0074] For example, taking a mobile phone as an electronic device, Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of this application is shown.

[0075] Reference Figure 4 As shown, the electronic device 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 speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a display screen 193, a subscriber identification module (SIM) card interface 194, and a camera 195, etc. The sensor module 180 may include pressure sensors, gyroscope sensors, barometric pressure sensors, magnetic sensors, accelerometers, gravity sensors, distance sensors, proximity sensors, fingerprint sensors, temperature sensors, touch sensors, ambient light sensors, bone conduction sensors, etc.

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

[0077] A controller can be the nerve center and command center of an electronic device. Based on command opcodes and timing signals, the controller generates operation control signals to control the fetching and execution of commands.

[0078] The processor 110 may also include a memory for storing commands and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store commands or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the command 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.

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

[0080] The charging management module 140 is used to receive charging input from wireless power supply devices (such as chargers, laptop batteries, etc.). 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. In some wireless charging embodiments, the charging management module 140 can receive wireless charging input via the receiving coil in the wireless charging chip of the electronic device. Alternatively, the charging management module 140 includes a wireless charging chip, and can then receive wireless charging input via the receiving coil in the wireless charging chip. Of course, in some embodiments, the receiving coil can be set separately from the charging management module 140, in which case the charging management module can use the receiving coil to receive wireless charging input via the wireless charging chip. Furthermore, in other embodiments, the charging management module 140 can also wirelessly charge other electronic devices via the receiving coil.

[0081] While charging the battery 142, the charging management module 140 can also supply power to the electronic device through the power management module 141. Specifically, the battery 142 can be composed of multiple batteries connected in series. The power management module 141 connects the battery 142, the charging management module 140, and the processor 110. In some other embodiments, the charging management module 140 may also be located within the processor 110.

[0082] The power management module 141 connects 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, providing power to the processor 110, internal memory 121, display screen 193, camera 195, and wireless communication module 160, etc. The power management module 141 can also monitor parameters such as battery voltage, current, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 141 may also be located within the processor 110. In some embodiments, the charging management module 140 and the power management module 141 may be located in the same device.

[0083] The external memory interface 120 can be used to connect to external non-volatile memory, thereby expanding the storage capacity of the electronic device. The external non-volatile memory communicates with the processor 110 through the external memory interface 120 to perform data storage functions. For example, music, video, and other files can be stored in the external non-volatile memory.

[0084] Internal memory 121 may include one or more random access memory (RAM) and one or more non-volatile memory (NVM). The RAM can be directly read and written by the processor 110 and can be used to store executable programs (e.g., machine commands) of the operating system or other running programs, as well as user and application data. The NVM can also store executable programs and user and application data, and can be pre-loaded into the RAM for direct read and write operations by the processor 110.

[0085] A touch sensor, also known as a "touch device," can be located on the display screen 193. The touch sensor and the display screen 193 together form a touchscreen, also called a "touchscreen." The touch sensor detects 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 the display screen 193. In other embodiments, the touch sensor may also be located on the surface of the electronic device, in a different position than the display screen 193.

[0086] An ambient light sensor is used to detect ambient light intensity. A pressure sensor is used to sense pressure signals and can convert these signals into electrical signals. In some embodiments, the pressure sensor may be located on the display screen 193. There are many types of pressure sensors, such as resistive pressure sensors, inductive pressure sensors, and capacitive pressure sensors.

[0087] An accelerometer (G-sensor), also called a gravity sensor, is a device that can sense acceleration in any direction. A triaxial accelerometer works based on the fundamental principle of acceleration. Acceleration is a spatial vector; on the one hand, to accurately understand the motion of an object, its components on its three coordinate axes must be measured; on the other hand, in situations where the direction of the object's motion is unknown beforehand, only a triaxial accelerometer can detect the acceleration signal.

[0088] A gyroscope (GYRO-sensor), also known as a ground sensor, traditionally contains an internal gyroscope. A three-axis gyroscope can simultaneously measure position, trajectory, and acceleration in six directions. A single-axis gyroscope can only measure quantities in two directions, meaning a system typically requires three gyroscopes. A single three-axis gyroscope can replace three single-axis gyroscopes. The working principle of a three-axis gyroscope is to measure the angle between the vertical axis of the gyroscope rotor and the device in a three-dimensional coordinate system, and calculate the angular velocity. The angle and angular velocity are used to determine the object's motion state in three-dimensional space. A three-axis gyroscope can simultaneously measure six directions: up, down, left, right, forward, and backward (the composite direction can also be decomposed into three-axis coordinates), ultimately determining the device's trajectory and acceleration. In other words, by measuring its own rotation, the three-axis gyroscope determines the device's current motion state, such as forward, backward, up, down, left, or right; and whether it is accelerating (angular velocity) or decelerating (angular velocity).

[0089] A combination of an accelerometer and a gyroscope can be called an A+G module. The A module (accelerometer) within the A+G module allows the electronic device to determine "how many meters it has moved forward," while the G module (gyroscope) indicates "it has turned around." Therefore, the A+G module enables the electronic device to determine whether it has moved. Of course, to ensure the electronic device can effectively detect its own movement, it can include any other possible sensors.

[0090] In some embodiments, an electronic device may include one or N cameras 195, where N is a positive integer greater than 1. In this application embodiment, the type of camera 195 can be distinguished based on hardware configuration and physical location. For example, a camera located on the side of the electronic device's display screen 193 can be called a front-facing camera, and a camera located on the side of the electronic device's back cover can be called a rear-facing camera; another example is that a camera with a short focal length and a wide field of view can be called a wide-angle camera, while a camera with a long focal length and a narrow field of view can be called a regular camera. Here, focal length and field of view are relative concepts and are not specifically limited by parameters. Therefore, wide-angle cameras and regular cameras are also relative concepts, and can be specifically distinguished based on physical parameters such as focal length and field of view.

[0091] The electronic device implements display functions through a GPU, a display screen 193, and an application processor. The GPU is a microprocessor for image editing, connected to the display screen 193 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute program commands to generate or modify display information.

[0092] Electronic devices can achieve shooting functions through ISP, camera 195, video codec, GPU, display 193, and 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 commands to generate or modify display information.

[0093] The Information Service Provider (ISP) is used to process data fed back from the camera 195. For example, when taking a picture, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, and the camera's photosensitive element transmits the electrical signal to the ISP for processing, transforming it into an image visible to the naked eye. The ISP can also perform algorithmic optimization on image noise and brightness. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be integrated into the camera 195. The camera 195 is used to capture still images or videos.

[0094] Digital signal processors (DSPs) are used to process digital signals. Besides digital image signals, they can also process other digital signals. For example, when an electronic device is selecting a frequency, a DSP can perform a Fourier transform on the frequency energy.

[0095] Video codecs are used to compress or decompress digital video. Electronic devices can support one or more video codecs. This allows the electronic device to play or record video in various encoded formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0096] Display screen 193 is used to display images, videos, etc. Display screen 193 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Mini LED, a MicroLED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device may include one or N displays 193, where N is a positive integer greater than 1.

[0097] In this embodiment of the application, the display screen 193 can be used to display pages required by the electronic device (e.g., a page displaying captured images, etc.), and to display images captured by any one or more cameras 195 in the interface.

[0098] The wireless communication function of electronic devices can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem, and baseband processor.

[0099] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in an electronic device can be used to cover one or more communication frequency bands. Different antennas can also be reused to improve antenna utilization.

[0100] The mobile communication module 150 can provide wireless communication solutions, including 2G / 3G / 4G / 5G, for use in electronic devices. 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. In some embodiments, at least some functional modules of the mobile communication module 150 can be housed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 can be housed in the same device.

[0101] The 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. The application processor outputs sound signals through audio devices (not limited to speaker 170A, receiver 170B, etc.) or displays images or videos through the display screen 193. In some embodiments, the modem processor may be a separate device. In other embodiments, the modem processor may be independent of the processor 110 and may be housed in the same device as the mobile communication module 150 or other functional modules.

[0102] The wireless communication module 160 can provide solutions for wireless communication applications in electronic devices, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. 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 signals, 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.

[0103] In some embodiments, antenna 1 of the electronic device is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, enabling the electronic device to communicate with networks and other devices via wireless communication technology. The wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time-Division Code Division Multiple Access (TDSCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technologies, etc. The GNSS may include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the BeiDou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS), and / or satellite-based augmentation systems (SBAS).

[0104] 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 make contact with and detach from the electronic device. The electronic device can support one or more SIM card interfaces. The SIM card interface 194 supports Nano SIM cards, Micro SIM cards, and other SIM cards. Multiple cards can be inserted into the same SIM card interface 194 simultaneously. The SIM card interface 194 is also compatible with external memory cards. The electronic device interacts with the network through the SIM card to achieve functions such as calls and data communication. One SIM card corresponds to one user number.

[0105] It is understood that the interface connection relationships between the modules illustrated in the embodiments of the present invention are merely illustrative and do not constitute a limitation on the structure of the electronic device. In other embodiments of this application, the electronic device may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.

[0106] Of course, it is understandable that the above... Figure 4 The illustration shown is merely an example when the electronic device is in the form of a mobile phone. If the electronic device is in the form of a tablet, handheld computer, PC, PDA, wearable device (such as a smartwatch, smart bracelet), or other similar device, the structure of the electronic device may include more advanced features. Figure 4 The fewer structures shown can also include more than Figure 4 The structures shown are not limited here.

[0107] It is understandable that, generally speaking, the implementation of electronic device functions requires not only hardware support but also software cooperation. The software system of electronic devices can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application's embodiment uses a layered architecture... Taking the system as an example, the software structure of the electronic device is illustrated.

[0108] Figure 5 This is a schematic diagram of the layered architecture of the software system of the electronic device provided in the embodiments of this application. The layered architecture divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces (e.g., APIs).

[0109] In some examples, refer to Figure 5 As shown in this embodiment, the software system located on the application processor (AP) in the system-on-a-chip (SOC) of the electronic device is divided into five layers, from top to bottom: application layer, framework layer (or application framework layer), system library and Android runtime, HAL layer (hardware abstraction layer), and kernel layer (or driver layer). The system library and Android runtime can also be referred to as the native framework layer or native layer.

[0110] The application layer can include a series of applications. For example... Figure 5 As shown, the application layer can include applications (APPs) such as camera, gallery, calendar, map, WLAN, Bluetooth, news, music, video, SMS, call, navigation, and instant messaging.

[0111] In this embodiment, the application layer may further include a trust ring application. This trust ring application can be used for functions such as account creation and trust ring management. Trust ring management may include, but is not limited to, adding devices to the trust ring, deleting devices from the trust ring, deleting the trust ring, freezing the trust ring, and creating a repository.

[0112] The framework layer provides application programming interfaces (APIs) and programming frameworks for applications in the application layer. The application framework layer includes predefined functions or services. For example, the application framework layer may include an activity manager, window manager, content provider, audio service, view system, phone manager, resource manager, notification manager, package manager, etc., but this embodiment does not impose any limitations on these.

[0113] The window manager is used to manage windowed applications. It can retrieve screen size, determine the presence of a status bar, lock the screen, and capture screenshots, among other things.

[0114] Content providers store and retrieve data, making that data accessible to applications. This data can include videos, images, audio, phone calls made and received, browsing history and bookmarks, phone books, etc.

[0115] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon could include views for displaying text and views for displaying images.

[0116] A phone manager is used to provide communication functionality for electronic devices. For example, a phone manager can manage the call status of a calling application (including initiation, connection, and termination).

[0117] The main function of the camera service is to provide a unified interface and functionality for applications to access and operate camera devices.

[0118] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.

[0119] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager can be used to notify users of completed downloads or message alerts. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting sounds, vibrating electronic devices, and flashing indicator lights.

[0120] Package manager in The package manager is used to manage application packages. It allows applications to obtain detailed information about installed applications and their services, permissions, etc. The package manager is also used to manage events such as application installation, uninstallation, and upgrades.

[0121] In this embodiment, the framework layer may further include a file synchronization SDK interface, which can specifically be a service interface for trust ring applications. Trust ring applications can create a repository in the file synchronization service of the system library by calling this file synchronization SDK interface.

[0122] Of course, in practice, the technical solution provided in this application can be implemented by any possible module in the application processor. The above is only an example and is not intended to impose specific limitations on the actual implementation.

[0123] The system library can include multiple functional modules. For example: a surface manager, media libraries, open graphics library embedded systems (OpenGL ES), and SGL. The surface manager manages the display subsystem and provides fusion of 2D and 3D layers for multiple applications. The media libraries support playback and recording of various common audio and video formats, as well as still image files. The media libraries support various audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG. OpenGL ES is used for 3D graphics drawing, image rendering, compositing, and layer processing. SGL is a 2D graphics engine.

[0124] In this embodiment, the system library may further include a file synchronization service. Specifically, the file synchronization service is used to execute file synchronization tasks after the trust ring application creates a repository, thereby implementing the file synchronization function of the trust ring application. For specific implementation details, please refer to the foregoing embodiments regarding... Figure 2 The relevant statements.

[0125] Furthermore, the file synchronization service is also specifically used to execute the technical solution provided in this application during the execution of file synchronization tasks. Specifically, the technical solution provided in this application can be implemented through the cooperation of the event reporting layer and the EventsFilter module in the file synchronization service.

[0126] Currently, in practice, the file synchronization service or module that implements the technical solution provided in this application is also set in other layers besides the system library, and this application does not impose specific restrictions on this.

[0127] The Android runtime consists of the core libraries and the ART virtual machine. The Android runtime is responsible for scheduling and managing the Android system. The core libraries comprise two parts: one part contains the functionalities that Java code needs to call, and the other part consists of the Android core libraries. The application layer and application framework layer run in the ART virtual machine. The ART virtual machine executes the Java files of the application layer and application framework layer into binary files. The ART virtual machine is used for managing object lifecycles, stack management, thread management, security and exception management, and garbage collection.

[0128] The Hardware Abstraction Layer (HAL) is the interface layer between the operating system kernel and the hardware circuitry, designed to abstract the hardware. It hides the platform-specific hardware interface details, providing the operating system with a virtual hardware platform that is hardware-independent and portable across multiple platforms. The HAL provides a standard interface that exposes device hardware functionality to the higher-level Java API framework (i.e., the framework layer). The HAL contains multiple library modules, each implementing an interface for a specific type of hardware component, such as: audio HAL, Bluetooth HAL, camera HAL (also known as camera HAL or camera hardware abstraction module), sensors HAL (or i-sensor service), and display HAL (display module), etc.

[0129] The kernel layer is the layer between hardware and software. The kernel layer contains at least various types of drivers. These drivers can include display drivers, camera drivers, audio drivers, sensor drivers, wireless charging drivers, etc., but this application does not limit the scope.

[0130] It should be noted that although the embodiments in this application use the Android system as an example for illustration, the basic principles are equally applicable to systems based on... Electronic devices using operating systems such as iOS and Windows.

[0131] The technical solutions provided in the embodiments of this application can all be implemented in electronic devices with the above-described hardware and software architectures.

[0132] Based on the above Figure 5 The software architecture shown below, combined with Figure 6 The flow of the event handling method provided in the embodiments of this application will be described. Figure 6 This is a flowchart illustrating an event handling method provided in an embodiment of this application. (Refer to...) Figure 6 As shown, taking a mobile phone with file synchronization function as an example, the file synchronization service in the mobile phone includes an event reporting layer and an event filter. The event handling method can include S601-S610:

[0133] S601. When a file synchronization task exists, the event reporting layer listens for changes in data files in the target path indicated by the file synchronization task.

[0134] In this embodiment, if a user creates a repository by operating a trust ring application on an electronic device, a file synchronization task can be considered to exist. When a file synchronization task exists, the event reporting layer in the file synchronization service can utilize predefined listening tools from the operating system to monitor change events of data files under the target path indicated by the file synchronization task. The specific implementation of creating a repository can refer to the previous embodiments for... Figure 2 The relevant statements will not be repeated here.

[0135] In this embodiment, the types of change events may include, but are not limited to, the following: modify events, delete events, rename events, move events, and create events. A modify event refers to modifying the content of a data file; a delete event refers to deleting the entire data file; a rename event refers to modifying the filename of a data file; a create event refers to creating a new data file; and a add event refers to adding a new data file. Move events may include move-out events and move-in events. A move-out event refers to removing a data file from a path, while a move-in event refers to moving a data file into a path. In this embodiment, the rename event detected by the monitoring tool can actually consist of adjacent move-out and move-in events. The move-in event corresponding to the rename event may carry an old name identifier indicating the old filename used between the modified filenames of the data file corresponding to the rename event. Finally, the rename event reported by the event reporting layer to the event filter is essentially the corresponding move-out event and the move-in event carrying the old name identifier.

[0136] Furthermore, in this embodiment, apart from the move-in event corresponding to the rename event carrying the old name identifier, all change events can specifically carry the file name, WD, cookies, and event identifier of their corresponding file. The event identifier can specifically be a mask.

[0137] For example, the monitoring tool can be inotify on Linux or ReadDirectoryChangesExW on Windows, depending on the operating system, or any other possible monitoring tool; this application does not impose any specific limitations on this. In practice, inotify or ReadDirectoryChangesExW can specifically be application programming interfaces (APIs) capable of implementing monitoring functions. The event reporting layer can monitor changes to data files under the target path by calling these interfaces.

[0138] After the event reporting layer detects a change event, to avoid frequent I / O operations and frequent processing of intermediate states of data files caused by the synchronization of continuous change events, which could lead to errors in the final state of the data files, the change event can first be handled by the event filter in the file synchronization service. This minimizes the number of change events that ultimately need to be synchronized. Based on this, S602 is executed after S601.

[0139] S602. When the event reporting layer detects the first change event of the first data file through the listening tool, it sends the first change event to the event filter.

[0140] In this embodiment of the application, after the event reporting layer detects a first change event through a listening tool, it can send the first change event to the event filter through a specific interface. For example, this specific interface may be PutEvents.

[0141] In practice, changes occurring consecutively within the same data file over a short period are often correlated. These correlations may lead to some changes being redundant or potentially filterable (or merged). Therefore, after receiving the first change event, the event filter needs to first determine if any changes in the first data file have been detected but not yet synchronized. If such unsynchronized changes are identified, they can be filtered according to specific rules (e.g., preset filtering rules).

[0142] Furthermore, for a given change event, its corresponding data file is characterized by the filename and WD carried by that change event. If two change events carry the same WD and filename, it indicates that the two change events correspond to the same data file. In this embodiment, the combination of filename and WD can be referred to as file identification information.

[0143] In practice, for a given data file, the two change events generated after a move—move-out and move-in—carry the same filename but different readability (WD). Similarly, the move-out event generated by renaming carries the same WD and filename as the move-out time. Therefore, based on the WD and filename, it can be determined that the data files corresponding to these two change events are different. However, in reality, the content of the data files corresponding to these two change events is completely identical, and these two change events can be considered as change events for the same data file. Therefore, when determining that the data files corresponding to two change events are different based on the WD and filename, it is also necessary to combine cookies to determine whether the data files corresponding to these two change events are related files. If it is determined based on cookies that the data files corresponding to the two change events are related files, it indicates that the data files corresponding to these two events are substantially the same. In this embodiment, cookies can be referred to as association identification information.

[0144] Based on the above description, after the event filter receives the first change event, in order to reduce the number of change events, it is necessary to first determine whether there is a change event in a second data file that has been detected but not synchronized. The second data file is the same as or related to the first data file. That is, S603 and S604 are executed after S602.

[0145] S603, The event filter receives the first change event from the event reporting layer.

[0146] S604. The event filter determines whether the first change event set exists.

[0147] The second change event is a change event of the first or second data file that has been detected but not yet synchronized, and the second data file is a data file associated with the first data file.

[0148] In some embodiments, if the association identifier information of two change events is not a preset value and is the same, then the data files corresponding to the two change events are related data files. For example, the association identifier information can be cookies, and the preset value can be 0. If the file identifier information of two change events is the same, then the data files corresponding to the two change events are the same. For example, the file identifier information includes the file name and WD.

[0149] In other words, the file identification information carried by the first change event is the same as the file identification information carried by the second change event of the first data file; the association identification information carried by the first change event and the association identification information carried by the second change event of the second data file are equal and neither is a preset value. For example, the preset value can be 0.

[0150] In some embodiments, when the event filter receives a first change event, it first determines whether there exists a second change event among the previously received, unsynchronized change events, whose corresponding data file is the same as or associated with the data file corresponding to the new change event. If at least one second change event exists, the combination of these second change events can be considered as the first change event set. If no second change event exists, it can be considered that the first change event set does not exist.

[0151] If a first set of change events is determined to exist, it can be assumed that there are multiple consecutive unsynchronized change events for the first data file, meaning there are multiple change events that can be filtered (or merged). At this point, these unsynchronized changes to the data file can be filtered to reduce the number of change events that the file synchronization service needs to process subsequently. This is where S605 is executed.

[0152] If it is determined that there is no first set of change events, then it can be assumed that there is only one change event in the current first data file, and there are no multiple change events that can be filtered (or merged). In this case, the first change event can be retained (or the first change event can be put on hold for later processing), and then filtered when other change events occur in the first or second data file. That is, execute S606.

[0153] S605. The event filter performs filtering processing on the first change event and at least one second change event included in the first change event set according to preset filtering rules, so as to update the first change event set.

[0154] In this embodiment of the application, the updated first change event set includes at least one third change event, the number of which is less than or equal to the sum of the number of the first change event and the number of the second change event.

[0155] Specifically, when executing S605, the event filter can first add the first change event to the first change event set, and then filter all change events in the first change event set according to the preset filtering rules, thereby realizing the update of the first change event set.

[0156] In some embodiments, for ease of processing, the event filter can assign the same set identifier (or sequence number num) to unsynchronized change events belonging to the same data file (or two related data files). Unsynchronized change events from different data files (or unrelated data files) correspond to different set identifiers. Unsynchronized change events with the same set identifier can be grouped into a change event set, such as a first change event set. When the data file corresponding to a new change event received by the event filter is the same as or related to the data file corresponding to a change event belonging to a certain set identifier, the set identifier can be assigned to the new change event, and the new change event can be added to the change event set to which the set identifier belongs. Then, the change events in the change event set can be filtered according to preset filtering rules to update the change event set.

[0157] In this case, S605 can specifically be an event filter that filters the first change event and all unsynchronized second change events with the same set identifier as the first change event according to a preset filtering rule, so as to obtain at least one third change event with the set identifier corresponding to the first change event after filtering.

[0158] In some embodiments, combined with Figure 6 , refer to Figure 7 As shown, the event filter in S605 performs filtering processing on the first change event and at least one second change event included in the first change event set according to preset filtering rules, which may specifically include the following:

[0159] (1) If the first change event is a deletion event or a removal event, and at least one of the second change events contains a creation event or a removal event, then the event filter sets the first change event set to empty. Setting the first change event set to empty is equivalent to updating the first change event set. Setting the first change event set to empty means that there are no change events in the first change event set.

[0160] Specifically, if the first change event is a deletion or removal event, and at least one of the second change events contains a creation or removal event, it indicates that for the first data file (or the second data file), the electronic device first created or moved the file to a specific path in response to a user operation, and then deleted or moved the file out of the specific path shortly afterward. Therefore, it can be considered that the first data file has not undergone any substantial change. Thus, it can be assumed that the first data file has no change events, meaning that updating the first change event set can be done by setting the first change event set to empty.

[0161] After setting the first change event set to empty, it can be assumed that the first data file has no change events. If no change events for the first data file or the second data file are received within the first preset time period, the event filter will not report any change events for the first data file or the second data file to the event reporting layer.

[0162] Of course, if the first change event set is set to empty, and a change event of the first data file or the second data file is received within the first preset time period, then the logic of S603-S606 can be reprocessed.

[0163] (2) If the first change event is a deletion event or a removal event, and if there is no creation event or removal event in at least one of the second change events, the event filter makes the updated set of the first change events include only deletion events.

[0164] Specifically, if the current first change event is a deletion event or a move-out event, and at least one of the second change events does not contain a creation event or a move-in event, it indicates that the electronic device has deleted the first data file (or the second data file) in response to a user operation. Therefore, regardless of whether there were other events besides initial move-in or creation events in the previous first change event set, this deletion will invalidate those events. Thus, in this case, it can be considered that the first data file only has a deletion time; that is, updating the first change event set can be done by updating the first change event set to include only deletion events.

[0165] (3) If the first change event is a creation event or a move-in event, the event filter makes the updated first change event set include only the new event or the first change event; or, the event filter can be to use the first change event to cover other change events in the first change event set; or, the event filter can be to use the first change event to cover other change events in the first change event set and adjust the event identifier carried by the first change event to an event identifier indicating a new event.

[0166] Specifically, if the current first change event is a creation event or a move-in event, it indicates that the first data file has just been created or moved to a specific path. The first change event set can only contain move-out or delete events related to the first data file. Previous move-out or delete events have no significance for the newly created first data file. When synchronizing creation events later, they are generally treated as new events. Therefore, the updated first change event set can either include only the first change event or, for ease of subsequent processing, only include new events.

[0167] Furthermore, in some embodiments, if the first change event is an inbound event carrying the old name identifier, it can be considered that the inbound event corresponds to the rename event. This indicates that the first data file has been renamed, and the first change event set can only contain outbound events for the first data file. The previous outbound events have no significance for the newly inbound first data file. Therefore, the updated first change event set can include only this first change event. However, since the inbound event corresponding to the rename event cannot be considered a new event, the updated first change event set cannot include only new events in this case. When the subsequent event reporting layer receives the event filter's report of the first change event (or the report of the first change event set including the first change event), it can adjust the event identifier of the first change event to the event identifier of the corresponding rename event before performing synchronization processing.

[0168] (4) If the first change event is not a delete event, move event, create event, or move-in event, and at least one of the second change events contains a change event of the same type as the first change event, then the event filter prevents the first change event set from changing. Here, change events of the same type refer to events that are all creation events, move events, delete events, or modify events.

[0169] Specifically, if a change event of the same type already exists in the first change event set, it can be considered a duplicate event for the first data file. For a given data file, one change event of a certain type is sufficient to reflect that the data file has undergone a change indicated by that type of change event. Subsequent synchronization processing of one change event of that type is also sufficient to synchronize the changes of that type of change event to the data file. Therefore, in this case, the first change event does not need to be modified.

[0170] (5) If the first change event is not a delete event, move-in event, create event, or move-in event, and if at least one of the second change events does not contain a change event of the same type as the first change event, then the event filter adds the first change event to the first change event set. That is, the updated first change event set has an additional first change event compared to the original first change event set.

[0171] Specifically, if no other change event of the same type exists in the first change event set, it can be considered that a non-duplicate event has occurred for the first data file, and this first change event is significant for the synchronization of modifications to the data file. Therefore, adding this first change event to the first change event set at this time can better synchronize the first data file when the event filter sends this first change event set to the event reporting layer for synchronization processing.

[0172] Of course, the above (1)-(5) are only examples of specific implementations of S605. In practice, the event filter can also use any other possible methods to complete the filtering process of the first change event and at least one second change event included in the first change event set, thereby completing the update of the first change event set.

[0173] In one possible implementation, if the monitoring tool for change events is inotify on a Linux platform, then all change events monitored by the event reporting layer through the monitoring tool carry (or correspond to) event identifiers (e.g., masks) that are binary data of a specific number of bits, with only one bit set to "1". Furthermore, the order of the "1" bits in the event identifier differs for different types of change events. The number of bits can be the same as the number of change event types.

[0174] For example, taking all types of change events, including modification events, deletion events, move-in events, move-out events, and creation events, the event identifier carried by the modification event can be 10000, the event identifier carried by the deletion event can be 01000, the event identifier carried by the move-in event can be 00100, the event identifier carried by the move-out event can be 00010, and the event identifier carried by the creation event can be 00001.

[0175] In this case, the above (1)-(5) can be quickly judged based on the event identifier. Specifically, an event identifier and masksum can be pre-set for the first change event set. The event identifier sum is the sum of the event identifiers carried by all change events in the first change event set. For example, if the first change event set includes modification events and creation events, and the event identifiers corresponding to the modification events and creation events are 10000 and 00001 respectively, then the event identifier sum of the first change event set is 10001.

[0176] Based on this, if it is necessary to determine whether a move-in event or a creation event exists in the first set of change events, the event identifier corresponding to the move-in event or creation event can be ANDed (&) with the event identifier of the first set of change events. If the result of the AND operation contains "1", it indicates that a move-in event or a creation event exists in the first set of change events; otherwise, it indicates that no move-in event or creation event exists. For example, if the sum of the event identifiers of the first set of change events is 10001, the event identifier carried by the move-in event is 00100, and the event identifier carried by the creation event is 00001, the result of the AND operation between 00001 and 10001 is 00001. Since this result contains 1, it indicates that a creation event exists in the first set of change events. The result of the AND operation between 00100 and 10001 is 00000. Since this result does not contain 1, it indicates that no creation event exists in the first set of change events.

[0177] Alternatively, the sum of the event identifiers corresponding to the move-in event or the creation event can be ANDed (&) with the sum of the event identifiers of the first change event set. If the result of the AND operation contains "1", it indicates that a move-in event or a creation event exists in the first change event set; otherwise, it indicates that no move-in event or creation event exists. For example, if the sum of the event identifiers of the first change event set is 10001, the event identifier carried by the move-in event is 00100, and the event identifier carried by the creation event is 00001, the sum of 00100 and 00001 is 00101. The result of the AND operation between 00101 and 10001 is 00001. Since this result contains 1, it indicates that a move-in event or a creation event exists in the first change event set.

[0178] To determine whether a change event of the same type as the first change event exists in the first change event set, an AND (&) operation can be performed between the event identifier corresponding to the first change event and the event identifier sum of the first change event set. If the result of the AND operation contains "1", it indicates that a change event of the same type as the first change event exists in the first change event set; otherwise, it indicates that no change event of the same type as the first change event exists. For example, if the event identifier sum of the first change event set is 10001 and the event identifier carried by the first change event is 00100, the result of the AND operation between 00100 and 10001 is 00000. Since there is no "1" in this result, it indicates that no change event of the same type as the first change event exists in the first change event set.

[0179] Based on the above description, the following judgment logic can be obtained: Perform a bitwise AND operation between the event identifier corresponding to the target event and the event identifier sum of the first change event set to obtain the first AND operation result; the event identifier sum is the sum of the event identifiers carried by all second change events in the first change event set, and the target event is an in event, an out event, a creation event, or a deletion event; if the first AND operation result contains 1, it is determined that the target event exists in the first change event set; if the first AND operation result does not contain 1, it is determined that the target event does not exist in the first change event set.

[0180] In this way, the relevant judgments of (1)-(5) above can be quickly completed through the operation, so that the event filter can quickly complete the filtering process of the first change event and at least one second change event included in the first change event set, and then complete the update of the first change event set.

[0181] Furthermore, after adding a new change event to the first change event set, it is necessary to sum the old event identifier of the first change event set before the update with the old event identifier and the event identifier carried by the first change event. This facilitates the subsequent processing when the event filter receives change events from the first or second data file again.

[0182] Additionally, if the monitoring tool for change events is not inotify on the Linux platform, the event identifiers carried by all types of change events can be converted into the corresponding event identifiers obtained by inotify when monitoring change events according to specific rules. Then, the relevant processing methods provided in the aforementioned embodiments are used to complete the relevant judgments in (1)-(5) above.

[0183] In another possible implementation, the event filter can also determine whether a move-in event or creation event exists in the first change event set by comparing the event identifier corresponding to the move-in event or creation event with the event identifier carried by each second change event in the first change event set. Similarly, it can determine whether a change event of the same type as the first change event exists in the first change event set by comparing the event identifier carried by the first change event with the event identifier carried by each second change event in the first change event set.

[0184] Of course, in practice, any other possible implementation can be used to complete the relevant judgments in (1)-(5) above, to complete the filtering process of the first change event and at least one second change event included in the first change event set, and then to complete the update of the first change event set. This application does not impose any specific restrictions on this.

[0185] S606. The event filter generates a second set of change events based on the first change event.

[0186] The second set of change events includes only the first change event. Specifically, the event filter can store the second set of change events in a separate cache.

[0187] Because user operations on a data file in the file system generate multiple change events in a short period of time, meaning the interval between adjacent change events from a single operation is relatively short, if the interval between the next change event and the current change event of a data file is long, then the next change event can be considered to have been generated by the user's next operation. To ensure timely synchronization of the data file after each user operation and to avoid confusion between adjustments made by different user operations, it is necessary to synchronize change events for each operation promptly; therefore, it is unacceptable to leave change events unsynchronized for extended periods.

[0188] Based on this, after generating the second set of change events or updating the first set of change events, if the event filter does not receive any change events in the first or second data file within a first preset time period, it can promptly send the change events in the second or first set of change events to the event reporting layer, so that the event reporting layer can perform corresponding synchronization processing to complete the synchronization of the first data file. That is, S607 and S608 are executed after S605, and S609 and S610 are executed after S606.

[0189] S607. If the event filter does not receive any change events from the first data file or the second data file of the event reporting layer within a first preset time period, it sends the first change event set to the event reporting layer.

[0190] For example, the first preset duration can be 500ms.

[0191] S608. The event reporting layer receives the first set of change events from the event filter and performs synchronization processing on the change events in the first set of change events to complete the synchronization of the first data file.

[0192] Specifically, the synchronization processing of change events in the first change event set by the event reporting layer can refer to storing the change events in the first change event set into the database corresponding to the file synchronization service, so that the file synchronization service can synchronize the first data file based on the change records in the database. For specific implementation details, please refer to the relevant descriptions in sections 4.4, 5.1, 5.2, 5.3, 6.1, 6.2, and 6.3 of the aforementioned embodiments, which will not be repeated here.

[0193] Based on S607 and S608, if no change events are detected in the first or second data file within a short period of time, it can be assumed that the user's operation on the first data file has most likely ended. At this time, the file synchronization service in the phone can promptly process the filtered change events of the first data file, thereby completing the synchronization of the first data file in a timely manner while minimizing the number of change events.

[0194] S609. If the event filter does not receive any change events from the first data file or the second data file of the event reporting layer within the first preset time period, it sends a second set of change events to the event reporting layer.

[0195] For example, the first preset duration can be 500ms.

[0196] S610, The event reporting layer receives the second set of change events from the event filter and performs synchronization processing on the change events in the second set of change events to complete the synchronization of the first data file.

[0197] The specific implementation of S610 can be referred to the relevant description of S609 in the aforementioned embodiments, and will not be repeated here.

[0198] Based on the technical solutions corresponding to S609 and S610, if no change event is detected in the first or second data file within a short period of time, it can be assumed that the user's operation on the first data file has most likely ended. At this time, the file synchronization service in the phone can promptly process the filtered change event of the first data file, thereby completing the synchronization of the first or second data file in a timely manner while minimizing the number of change events.

[0199] Of course, after S605, if the event filter receives a fourth change event from the first or second data file of the event reporting layer again within the first preset time period, it indicates that not all change events generated by the user's current operation on the first data file have been generated. In this case, processing can continue according to the logic of S603-S606 in the aforementioned embodiment. That is, the fourth change event and at least one third change event in the updated first change event set can be filtered according to the preset filtering rules to update the first change event set again.

[0200] Similarly, after S606, if the event filter receives a fifth change event from the first or second data file of the event reporting layer again within the first preset time period, it indicates that not all change events generated by the user's current operation on the first data file have been generated. In this case, processing can continue according to the logic of S603-S606 in the aforementioned embodiment. That is, the fifth change event and the first change event in the second change event set can be filtered according to the preset filtering rules to update the second change event set.

[0201] In this embodiment of the application, in order to facilitate timing of the first preset duration, a unified timer is set for a set of change events (e.g., the first set of change events) that are not synchronized and belong to the same data file (or two related data files); or a unified timer is set for change events corresponding to the same set identifier.

[0202] The timer's duration is a first preset duration. Taking the first change event set as an example, each time the event filter updates the first change event set, it means that a change event (e.g., the first change event) of the first data file or the second data file has been received within the first preset duration after the last update of the first change event set. This indicates that the change events generated by the user's current operation in the first data file may not have been fully generated yet.

[0203] If the timer continues to run at the original pace, subsequent changes to the first data file caused by the user's current operation may not be filtered according to the preset filtering rules, thus failing to effectively reduce the number of change events. Therefore, to minimize the number of change events to the first data file caused by this operation, the timer corresponding to the first change event set needs to be restarted after each update to begin timing for the preset duration. Of course, if the first change event set is empty after an update, it can be deleted and the corresponding timer canceled.

[0204] Subsequently, if the event filter does not receive any change events for the first or second data file after a timer completes its countdown, it will send the first change event set to the event reporting layer for processing, delete the first change event set stored in the event filter's cache, and cancel the timer corresponding to the first change event set.

[0205] The above-mentioned creation of a timer can be considered as creating a delayed task with a delay time of the first preset duration. Restarting the timer to reset the timing can be considered as refreshing the delayed task with the first preset delay time. Cancelling the timer can be considered as deleting the delayed task.

[0206] Based on the technical solution provided in this application, since the time interval between change events generated during a user's adjustment of a data file is very short, multiple change events generated consecutively in a short period of time for a file can be considered as generated by a single user adjustment operation. Therefore, in the technical solution provided in this application, when an electronic device performs a file synchronization task, it can merge multiple change events generated consecutively in a short period of time for the same data file (two associated files are also considered the same file). This reduces the number of change events that need to be synchronized for the data file (e.g., the first data file), thereby minimizing the possibility of errors in the file synchronization service's handling of the final state of the data file due to too many change events generated by a user's adjustment operation.

[0207] In some embodiments, when the event reporting layer receives change events reported by the event filter, there are preset reporting rules. For example, it may not receive certain specific change events, or it may not receive change events for certain specific files, or it may directly receive all change events. Based on this, combined with Figure 6 , refer to Figure 7 As shown, prior to S607 and S609, the method further includes S600:

[0208] S600: When a file synchronization task exists, the event reporting layer registers an event handler (listenerProcessor) in the event filter.

[0209] The event handler is used to process change events that the event filter needs to send to the event reporting layer according to preset reporting rules, or the event handler carries preset reporting rules.

[0210] The purpose of S600 is to allow the event reporting layer to send preset reporting rules to the event filter.

[0211] In some embodiments, when the event reporting layer initially listens for change events using a listening tool in response to a file synchronization task, a time handler can be registered in the event filter. That is, as follows: Figure 7 As shown, when a file synchronization task exists, S600 can be executed first, followed by S601.

[0212] Based on this, combined Figure 6 , refer to Figure 7 As shown, S607 can specifically be S607A, and S609 can be S609A:

[0213] S607A. If the event filter does not receive any change events from the first data file or the second data file of the event reporting layer within the first preset time period, it calls the event processor to update the first change event set according to the preset reporting rules, and then sends the updated first change event set to the event reporting layer.

[0214] In some embodiments, if the event reporting layer registers an event handler with the event filter by sending a preset reporting rule to the event filter, then S608A may also be that if the event filter does not receive a change event from the first data file or the second data file of the event reporting layer within a first preset time period, it updates the first change event set according to the preset reporting rule and then sends the updated first change event set to the event reporting layer.

[0215] S609A. If the event filter does not receive any change events from the first data file or the second data file of the event reporting layer within the first preset time period, it calls the event processor to update the second change event set according to the preset reporting rules, and then sends the updated second change event set to the event reporting layer.

[0216] In some embodiments, if the event reporting layer registers an event handler with the event filter by sending a preset reporting rule to the event filter, then S608A may also be that if the event filter does not receive a change event from the first data file or the second data file of the event reporting layer within a first preset time period, it updates the second change event set according to the preset reporting rule and then sends the updated second change event set to the event reporting layer.

[0217] Based on the above technical solution, the event filter can report filtered change events to the event reporting layer according to the preset reporting rules specified by the event reporting layer. This allows the event reporting layer to receive change events that conform to the rules and then smoothly process the received change events for synchronization. This achieves the synchronization of the first data file while minimizing the number of change events, avoiding the defect that the file synchronization service might err in processing the final state of the data file due to too many change events generated by a user's adjustment operation on the data file.

[0218] For ease of understanding, the following describes how change events corresponding to the same data file or two related data files are assigned the same set identifier. A timer is used to time a first preset duration, and the monitoring tool is inotify on the Linux platform. All change events carry (or correspond to) event identifiers (e.g., masks) that are binary data of a specific number of bits, with only one bit being "1". Different types of change events have different positions of the "1" bit in their event identifiers. For example, change events corresponding to the same set identifier (or change event sets consisting of change events corresponding to the same set identifier) ​​have event identifiers and... Referring to the descriptions in the preceding embodiments... Figure 8 As shown, a specific implementation process of the event handling method provided in this application embodiment is described. (Refer to...) Figure 8 As shown, the event handling method can specifically include the following process:

[0219] 1. The event reporting layer listens for change events through listening tools. When a change event is detected, the listening event is reported to the event filter.

[0220] The current change event can be the first change event mentioned in the previous embodiments. The specific implementation of this step can refer to the relevant descriptions of S601-S602 in the previous embodiments, and this application will not elaborate on it in detail.

[0221] 2. After receiving the current change event reported by the event reporting layer, the event filter can attempt to assign the current change event a sequence number num from the container.

[0222] Here, the container can refer to the cache of the event filter, which can store unsynchronized change events corresponding to multiple data files. Change events corresponding to the same data file or two related data files are assigned the same sequence number num. This sequence number num is the set identifier in the aforementioned embodiment. A combination of change events corresponding to the same data file or two related data files can be identified as a change event set, such as the first change event set.

[0223] During step 2, if a target change event exists in the container, a sequence number `num` is assigned to the current change event. This target change event corresponds to the same data file or is associated with a related data file as the current change event. After assigning the target change event sequence number `num` to the current change event, it can be assumed that all events corresponding to that sequence number `num` can be merged / filtered, or that there are events that need to be merged / filtered, thus proceeding to step 4.

[0224] If the target change event does not exist in the container, it can be assumed that a sequence number `num` cannot be obtained from the container to assign to the current change event. In this case, a new sequence number `num` can be assigned to the current change event, and the current change event can be stored in the cache. At the same time, a delayed task corresponding to the current change event can be created, with a delay time of 500ms. That is, three steps are executed. Specifically, the delayed task can be created by creating a timer with a duration of 500ms.

[0225] Taking the current change event as the first change as an example, the event filter receives the current change event reported by the event reporting layer and determines whether a target change event exists to assign a sequence number num. This can be understood as the event filter receiving the first change event and determining whether a first change event set exists. For specific implementation details, please refer to the relevant descriptions in S603 and S604 of the aforementioned embodiments.

[0226] 3. The event filter stores the current change event in the cache and sets a delay time of 500m for the task.

[0227] In some embodiments, step 3 can specifically be called event reporting waiting processing. After these three steps are executed, a set of change events containing only the current change event is generated. Furthermore, the delayed task will always accompany the change event set to which the current change event belongs. Based on the logic of steps 2 and 3, it can be seen that each sequence number num corresponds to multiple change events, and each will correspond to a delayed task.

[0228] If no change event is received within 500ms for the same data file or related data files corresponding to the current change event, then the current change event can be reported to the event reporting layer. For specific implementation details, refer to the relevant descriptions of S609 and S610 in the aforementioned embodiments. If a change event is received within 500ms for the same data file or related data files corresponding to the current change event, then the execution restarts from step 2.

[0229] 4. Event Filter: For change events corresponding to the same sequence number num, the event filter filters / merges these change events according to the event identifier and preset filtering rules.

[0230] Specifically, preset filtering rules can include the following:

[0231] If the current change event is a delete or remove event, and a create or remove event exists among the change events with the same sequence number num, the event filter will set the first change event set to empty and delete the corresponding delayed task. In other words, for that sequence number num, since no corresponding change event exists, the event filter will not report any further change events to the event reporting layer.

[0232] If the current change event is a delete event or a move-out event, and there is no create event or move-in event among the change events with the same sequence number num as the current change event, then the event filter refreshes the delayed task corresponding to sequence number num and overwrites all change events (or change event sets) corresponding to sequence number num with the current change event or a delete event.

[0233] If the current change event is a move-in event or a creation event, refresh the delayed task corresponding to the sequence number num, and overwrite all change events (or change event sets) corresponding to that sequence number with the current change event or the newly added event.

[0234] If the current change event is not an in, creation, removal, or deletion event, and there is another change event of the same type as the current change event with the same sequence number num, then delete the current change event and refresh the delayed task corresponding to sequence number num.

[0235] If the current change event is not an in, creation, removal, or deletion event, and there is no other change event of the same type as the current change event among the other change events with the same sequence number num, then the current change event will be added to all change events corresponding to that sequence number num, and the delayed task corresponding to that sequence number num will be refreshed.

[0236] In one possible implementation, if the monitoring tool for change events is inotify on a Linux platform, then all change events monitored by the event reporting layer carry (or correspond to) event identifiers (e.g., masks) of a specific number of bits, with only one bit set to "1". The order of the "1" bits differs depending on the type of change event. The specific number of bits can be the same as the number of change event types. In this case, the filtering rules for each type of change event can be based on the event identifiers corresponding to the same sequence number `num` and the `masksum` corresponding to the event identifiers of each type of change event. The `masksum` corresponds one-to-one with the sequence number `num` (or the set of change events corresponding to `num`). After calculating the event identifier of a certain type of change event with the `masksum` corresponding to a certain sequence number `num`, if the result does not contain 1, it indicates that there are no change events of that type other than the current change event corresponding to that sequence number `num`; if the result contains 1, it indicates that there are change events of that type other than the current change event corresponding to that sequence number `num`.

[0237] In addition, if a new change event needs to be added to the change event corresponding to a certain sequence number num, the event identifier of the new change event needs to be added to the corresponding masksum to update the masksum.

[0238] The specific meaning of the above filtering rules can be found in the relevant descriptions after S605 (1)-(5) in the aforementioned embodiments, and will not be repeated here. The relevant definitions and examples of the above masksum, as well as the specific implementation of judging the judgment content in the above preset filtering rules based on masksum, can be found in the relevant descriptions after S605 in the aforementioned embodiments, and will not be repeated here.

[0239] After steps 3 and 4, if the event filter does not receive any change events for the first or second data file within the first preset time period, it can promptly report the current change event or all change events corresponding to the sequence number num of the current change event to the event reporting layer.

[0240] The implementation and beneficial effects of the technical solutions provided in the above embodiments can be referred to the relevant content of the event handling methods provided in the foregoing embodiments, and will not be repeated here.

[0241] It is understood that, in order to achieve the aforementioned functions, the electronic device includes corresponding hardware structures and / or software modules for performing each function. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein, the embodiments of the present invention can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in a hardware-driven or software-driven manner 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 implementations should not be considered beyond the scope of the embodiments of this application.

[0242] This application embodiment can divide the above-described electronic device into functional modules based on the method example described above. For example, each function can be divided into its own functional modules, or two or more functions can be integrated into one processing module. The integrated modules can be implemented in hardware or as software functional modules. It should be noted that the module division in this embodiment is illustrative and only represents one logical functional division; in actual implementation, there may be other division methods.

[0243] In the case of dividing each function into corresponding modules, embodiments of this application also provide an event processing device that can be applied to electronic devices. This device may include a listening module 901, a filtering module 902, and a processing module 903.

[0244] The monitoring module 901 is used to monitor change events of data files in the target path indicated by the file synchronization task when a file synchronization task exists. The filtering module 902 is used to, when the monitoring module 901 detects a first change event of a first data file, filter the first change event and at least one second change event included in the first change event set according to preset filtering rules, thereby updating the first change event set; the second change event is a change event of a first or second data file that has been monitored but not yet synchronized, and the second data file is a data file associated with the first data file. The processing module 903 is used to synchronize the change events in the first change event set if the monitoring module 901 does not detect a change event of the first or second data file within a first preset time period.

[0245] Furthermore, the cooperation of the monitoring module 901, the filtering module 902, and the processing module 903 can implement any step of the event handling method provided in the foregoing embodiments, which will not be elaborated here. Regarding the electronic device in the above embodiments, the specific methods by which each module performs its operations have been described in detail in the embodiments of the event handling method in the foregoing embodiments, and will not be elaborated here. The related beneficial effects can also be referred to the related beneficial effects of the foregoing event handling method, which will not be elaborated here.

[0246] Regarding the event handling apparatus in the above embodiments, the specific methods by which each module performs its operations have been described in detail in the embodiments of the event handling method described above, and will not be elaborated here. The related beneficial effects can also be referred to the related beneficial effects of the aforementioned event handling method, and will not be repeated here.

[0247] This application also provides an electronic device, which includes a memory and one or more processors; the memory is coupled to the processors; wherein the memory stores computer program code, which includes computer instructions, and when the computer instructions are executed by the processor, the electronic device performs the frame loss fault determination method provided in the foregoing embodiments. The specific structure of this electronic device can be referred to... Figure 4 The structure of the electronic device shown is illustrated.

[0248] This application also provides a computer-readable storage medium including computer instructions that, when executed on an electronic device, cause the electronic device to perform the event handling method provided in the foregoing embodiments.

[0249] This application also provides a computer program product containing executable instructions that, when run on an electronic device, cause the electronic device to perform the event handling method provided in the foregoing embodiments.

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

[0251] In the several embodiments provided in this application, it should be understood that the disclosed apparatus / device and method can be implemented in other ways. For example, the apparatus / device 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 device, 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 devices or units may be electrical, mechanical, or other forms.

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

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

[0254] 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, essentially or in other words, 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 described in 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.

[0255] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations 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. An event handling method, characterized in that, Applied to electronic devices, the software architecture of which includes multi-device collaborative applications and file synchronization services, the file synchronization service including an event reporting layer and an event filter, the method including: When the multi-device collaborative application determines that a file synchronization task exists, the event reporting layer listens for change events of data files in the target path indicated by the file synchronization task. When the event reporting layer detects a first change event in the first data file, it sends the first change event to the event filter. If the event filter has a first set of change events, it filters the first change event and at least one second change event included in the first set of change events according to a preset filtering rule to update the first set of change events. The second change event is a change event in the first data file or the second data file that has been detected but not synchronized. The second data file is a data file associated with the first data file. If the event filter does not receive any change events from the first data file or the second data file of the event reporting layer within a first preset time period, it sends a first set of change events to the event reporting layer. The event reporting layer performs synchronous processing on the change events in the first set of change events.

2. The method according to claim 1, characterized in that, If the event filter contains a first set of changed events, then filtering is performed on the first changed events and at least one second changed event included in the first set of changed events according to a preset filtering rule to update the first set of changed events, including: If the first change event is a deletion event or a removal event, and if a creation event or a removal event exists in at least one of the second change events, then the event filter controls the first change event set to empty; In the case that the first change event is a deletion event or a removal event, if there is no creation event or removal event in at least one of the second change events, then the event filter controls the updated set of the first change events to include only deletion events.

3. The method according to claim 2, characterized in that, If the event filter contains a first set of changed events, then filtering is performed on the first changed events and at least one second changed event included in the first set of changed events according to a preset filtering rule to update the first set of changed events. This further includes: If the first change event is a creation event or a move-in event, the updated set of the first change events is controlled to include only the addition event or the first change event.

4. The method according to claim 2, characterized in that, If the event filter contains a first set of changed events, then filtering is performed on the first changed events and at least one second changed event included in the first set of changed events according to a preset filtering rule to update the first set of changed events. This further includes: If the first change event is not a deletion event, a move-in event, a creation event, or a move-in event, and if at least one of the second change events contains a change event of the same type as the first change event, then the event filter controls the first change event set to remain unchanged. If the first change event is not a deletion event, a move-in event, a creation event, or a move-in event, and if there is no change event of the same type as the first change event among the at least one second change event, then the event filter adds the first change event to the first change event set to update the first change event set.

5. The method according to claim 4, characterized in that, When each change event detected by the event reporting layer carries an event identifier that is a binary data of a specific number of bits, with only one bit set to 1, and the order of the 1 bits in the event identifier differs for different types of change events, the method further includes: The event filter performs a bitwise AND operation between the event identifier corresponding to the target event and the event identifier sum of the first change event set to obtain the first AND operation result; the event identifier sum is the sum of the event identifiers carried by all second change events in the first change event set, and the target event is an in event, an out event, a creation event, or a deletion event; If the result of the first AND operation contains 1, the event filter determines that the target event exists in the first set of changed events; if the result of the first AND operation does not contain 1, the event filter determines that the target event does not exist in the first set of changed events.

6. The method according to claim 5, characterized in that, The method further includes: The event filter performs a bitwise AND operation on the event identifier carried by the first change event and the event identifier of the first change event set to obtain a second bitwise AND result; If the result of the second AND operation contains 1, the event filter determines that there is a change event of the same type as the first change event in the first change event set; if the result of the second AND operation does not contain 1, the event filter determines that there is no change event of the same type as the first change event in the first change event set.

7. The method according to claim 5 or 6, characterized in that, After the event filter adds the first change event to the first change event set to update the first change event set, the method further includes: the event filter determines the sum of the event identifier of the first change event set before the update and the event identifier carried by the first change event as the event identifier of the first change event set after the update.

8. The method according to any one of claims 1-6, characterized in that, The file identifier information carried by the first change event is the same as the file identifier information carried by the second change event of the first data file; the file identifier information carried by the first change event and the association identifier information carried by the second change event of the second data file are equal and not preset values; The file identification information is used to characterize the data file corresponding to the change event, and the association identification information is used to characterize the association relationship between the change event and other change events.

9. The method according to claim 8, characterized in that, The file identification information includes the file name and the monitoring descriptor WD, the associated identification information includes cookies, and the preset value is 0.

10. An electronic device, characterized in that, include: A memory and one or more processors; the memory is coupled to the processors; wherein the memory stores computer program code, the computer program code including computer instructions, which, when executed by the processor, cause the electronic device to perform the event handling method as described in any one of claims 1-9.

11. A computer-readable storage medium, characterized in that, Includes computer instructions that, when executed on an electronic device, cause the electronic device to perform the event handling method as described in any one of claims 1-9.

Citation Information

Patent Citations

  • File synchronization method and device

    CN101763421A

  • Optimization method for data display of wearable device, wearable device and storage medium

    CN109992087A