Event processing method, electronic equipment and storage medium

By merging or filtering data file changes during data synchronization, the file synchronization error problem caused by frequent IO operations is solved, and the accuracy and user experience of data synchronization are improved.

CN120407523AActive Publication Date: 2025-08-01HONOR DEVICE CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411550584.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-31
Publication Date
2025-08-01
Estimated Expiration
2044-10-31

AI Technical Summary

Technical Problem

When the existing data synchronization method performs continuous operations on the data file, it leads to frequent IO operations and parallel thread resource preemption, resulting in errors in the final state processing of the data file by the file synchronization service.

Method used

By listening to the change events of the data file, preset filtering rules are used to merge or filter multiple change events to reduce the number of events processed synchronously and avoid errors.

Benefits of technology

Effectively reduces errors in the final state processing of data files by the file synchronization service and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120407523A_ABST
    Figure CN120407523A_ABST
Patent Text Reader

Abstract

The invention provides an event processing method, electronic equipment and a storage medium, relates to the field of data processing, and can avoid the defect that processing of a final state of a data file by a file synchronization service generates an error due to a plurality of continuous change events within a short time. The method comprises the following steps: under the condition that a first change event of a first data file is monitored, 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 so as 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 which is monitored and is not subjected to synchronization processing, and the second data file is a data file associated with the first data file; and under the condition that the change event of the first data file or the second data file is not received within the first preset duration, performing synchronous processing on the change event 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 technical field of terminals, and in particular to an event processing method, an electronic device, and a storage medium. Background Art

[0002] With the rapid development of information technology and intelligent terminals, users use various electronic devices such as mobile phones, portable android devices (PADs), and personal computers (PCs) more and more frequently. Due to the differences in the functions and applicable scenarios of various electronic devices, in different usage scenarios, the electronic devices used by users may be different. In order to facilitate users to process data files in other electronic devices when using a certain electronic device, the data synchronization method can be used to automatically synchronize the data files on electronic device A to electronic device B or the network-side device. After that, when the user uses electronic device B, the user can directly process the data files of electronic device A existing in electronic device B, or download the data files of electronic device A from the network-side device to electronic device B and then process them.

[0003] However, when implementing the current data synchronization, in order to ensure that the data files are synchronized in time, a monitoring tool is used to monitor the change events of the data files in real time and report them to the file synchronization service, so that the file synchronization service can perform corresponding processing (such as writing change events in the storage area and reading change records from the storage area) to complete the synchronization. However, if the user's operations on the data files generate multiple consecutive change events, and the monitoring tool directly reports to the file synchronization service for processing each time a change event is monitored, it will cause the file synchronization service to perform frequent IO operations and frequently process the intermediate state of the data files (the data files when the user has not completed the modification of the data files). Further, since current electronic devices usually complete computing or processing tasks through multiple parallel processes or threads to improve the processing speed, the above-mentioned frequent IO operations and frequent processing of the intermediate state of the data files may cause errors in the processing of the final state of the data files (the final state that needs to be synchronized after the data file transformation is completed) by the file synchronization service due to resource preemption or data competition and conflicts among parallel threads. Summary of the Invention

[0004] The embodiments of the present application provide an event processing method, an electronic device, and a storage medium, which can reduce the change events that need to be processed by the file synchronization service and avoid the defect that the file synchronization service processes the final state of the data file incorrectly due to multiple consecutive change events in a short period of time.

[0005] In order to achieve the above objectives, the embodiments of the present application adopt the following technical solutions:

[0006] In a first aspect, an embodiment of the present application provides an event processing method, which is applied to an electronic device. The method includes: in the presence of a file synchronization task, monitoring the change event of the data file in the target path indicated by the file synchronization task; in the case of monitoring the first change event of the first data file, if there is a first change event set, 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 monitored and not synchronized, and the second data file is a data file associated with the first data file; in the case that no change event of the first data file or the second data file is received within a first preset time period, synchronizing the change event in the first change event set.

[0007] Based on the technical solution provided by the embodiment of the present application, since the time interval between the change events generated during a certain adjustment of a data file by a user is very short, multiple change events generated continuously in a short period of time for a certain file can be considered to be generated by a single adjustment operation by the user. Based on this, in the technical solution provided by the present application, when the electronic device performs a file synchronization task, it can merge and process multiple change events generated continuously in a short period of time for the same data file (two associated files are also considered to be the same file), thereby reducing the number of change events that need to be synchronized for the data file (for example, the first data file), thereby avoiding as much as possible the defect that the file synchronization service processes the final state of the data file incorrectly due to too many change events generated by a certain adjustment operation of the user on the data file.

[0008] In a possible implementation of the first aspect, the first change event and at least one second change event included in the first change event set are filtered according to preset filtering rules to update the first change event set, including: when the first change event is a deletion event or a removal event, if there is a creation event or a move-in event in at least one second change event, then the first change event set is controlled to be empty; when the first change event is a deletion event or a removal event, if there is no creation event or move-in event in at least one second change event, then the updated first change event set is controlled to include only the deletion event.

[0009] If the current first change event is a delete event or a move-out event, if at least one second change event contains a create event or a move-in event, this indicates that the electronic device, in response to a user operation, first created or moved the first data file (or second data file) into a specific path, and then deleted or moved it out of the specific path within a short period of time. It can then be considered that the first data file has not substantially changed. Therefore, at this point, it can be considered that the first data file has no change events, i.e., the update to the first change event set can be to set the first change event set to empty. If the current first change event is a delete event or a move-out event, if at least one second change event contains no create event or move-in event, this indicates that the electronic device, in response to a user operation, has currently deleted the first data file (or second data file). Regardless of whether there were other events in the first change event set other than the move-in event or the create event, this deletion will invalidate these events. Therefore, at this point, it can be considered that the first data file only contains the deletion time, i.e., the update to the first change event set can be to update the first change event set to a change event set that only includes the delete event.

[0010] In summary, based on the technical solution corresponding to the above-mentioned implementation method, when the current first change event is a deletion event or a removal event, appropriate filtering means 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, thereby avoiding as much as possible the defect of the file synchronization service processing the final state of the data file incorrectly due to too many change events generated by a user's adjustment operation on the data file.

[0011] In a possible implementation of the first aspect, the first change event and at least one second change event included in the first change event set are filtered according to preset filtering rules to update the first change event set, and also includes: when the first change event is a creation event or a move-in event, controlling the updated first change event set to only include new events or the first change event.

[0012] If the current first change event is a create event or a move event, it indicates that the first data file has just been created or moved to a specific path. The first change event set may only contain move-out events or delete events for the first data file. The previous move-out event or delete event does not have any change significance for the newly created first data file. When the creation event is subsequently synchronized, the creation event is generally regarded as a new event. Therefore, the updated first change event set can include only the first change event, or, to facilitate subsequent processing, the updated first change event set can include only the new event.

[0013] In summary, based on the technical solution corresponding to the above-mentioned implementation method, when the current first change event is a creation event or a move-in event, appropriate filtering means 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, thereby avoiding as much as possible the defect of the file synchronization service processing the final state of the data file incorrectly due to too many change events generated by a user's adjustment operation on the data file.

[0014] In a possible implementation of the first aspect, the first change event and at least one second change event included in the first change event set are filtered according to preset filtering rules to update the first change event set, and also include: when the first change event is not a deletion event or a move-in event or a creation event or a move-in event, if there is a change event of the same type as the first change event in at least one second change event, then the first change event set is controlled not to change; when the first change event is not a deletion event or a move-in event or a creation event or a move-in event, if there is no change event of the same type as the first change event in at least one second change event, then the first change event is added to the first change event set to update the first change event set.

[0015] In the case where a change event of the same type already exists in the first change event set for the current first change event, it can be considered that a duplicate event has occurred for the first data file. For a certain data file, a change event of a certain type is sufficient to reflect that the data file has generated a change indicated by a change event of that type. The subsequent synchronous processing of a change event of that type is also sufficient to complete the synchronization of the changes of the data file with the change event of that type. Therefore, at this time, the first change event can be left unchanged. In the case where a change event of the same type does not exist in the first change event set for the current first change event, it can be considered that a non-duplicate event has occurred for the first data file, and the first change event is meaningful for the modification synchronization of the data file. Therefore, adding the first change event to the first change event set at this time can better complete the synchronization of the first data file when the first change event set is subsequently synchronized.

[0016] In summary, based on the technical solution corresponding to the above-mentioned implementation method, when the current first change event is a repeated event or a non-repeated event, appropriate filtering means 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, thereby avoiding as much as possible the defect of the file synchronization service processing the final state of the data file incorrectly due to too many change events generated by a user's adjustment operation on the data file.

[0017] In a possible implementation of the first aspect, when the event identifier carried by each monitored change event is binary data with only one bit being 1 and the position of 1 in the event identifiers corresponding to different types of change events is different, the method further includes: performing an 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 incoming event, an outgoing event, a create event, or a deleted 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.

[0018] Based on the technical solution corresponding to the above-mentioned 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 according to the preset filtering rules can be quickly completed through operations, so that the electronic device can quickly complete the filtering processing 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, thereby reducing the number of change events, thereby avoiding as much as possible the defect of the file synchronization service processing the final state of the data file incorrectly due to too many change events generated by a user's adjustment operation on the data file.

[0019] In a possible implementation of the first aspect, the method further includes: performing an 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 AND operation result; if the second AND operation result contains 1, it is determined that a change event of the same type as the first change event exists in the first change event set; if the second AND operation result does not contain 1, it is determined that a change event of the same type as the first change event exists in the first change event set.

[0020] Based on the technical solution corresponding to the above-mentioned implementation method, the electronic device can successfully complete the judgment of 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, and then reducing the number of change events, thereby avoiding as much as possible the defect of the file synchronization service processing the final state of the data file incorrectly due to too many change events generated by a user's adjustment operation on the data file.

[0021] In a 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 identifier 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 in the future, relevant processing can be performed based on the latest event identifier and completion, so that the electronic device can smoothly reduce the number of subsequent change events, thereby avoiding as much as possible the defect of the file synchronization service processing the final state of the data file incorrectly due to too many change events generated by a user's adjustment operation on the data file.

[0023] In a 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 are not preset values; the file identification information is used to represent the data file corresponding to the change event, and the association identification information is used to represent the association relationship between the change event and other change events.

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

[0025] In a second aspect, embodiments of the present application further provide an event processing device that can be applied to an electronic device. The functions of the device can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions, such as a monitoring module, a filtering module, and a processing module.

[0026] Among them, a monitoring module is used to monitor change events of data files in a target path indicated by a file synchronization task when there is a file synchronization task. A filtering module is used to, when the monitoring module monitors a first change event of a first data file, if there is a first change event set, filter and process 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 and not synchronized, and the second data file is a data file associated with the first data file. A processing module is used to synchronize the change events in the first change event set when the monitoring module does not monitor a change event of the first data file or the second data file within a first preset time period.

[0027] In a third aspect, the present application provides an electronic device, which includes a memory and one or more processors; the memory is coupled to the processor; wherein, computer program code is stored in the memory, and the computer program code includes computer instructions, when the computer instructions are executed by the processor, the electronic device is caused to execute the event processing method provided in the first aspect and any one of its possible design manners.

[0028] In a fourth aspect, the present application provides a computer-readable storage medium, which includes computer instructions, when the computer instructions run on an electronic device, the electronic device is caused to execute the event processing method provided in the first aspect and any one of its possible design manners.

[0029] In a fifth aspect, the present application provides a computer program product, when the computer program product runs on an electronic device, the electronic device is caused to execute the event processing method provided in the first aspect and any one of its possible design manners.

[0030] It can be understood that for the beneficial effects that can be achieved by the technical solutions provided in the second aspect to the fifth aspect above, reference can be made to the beneficial effects in the first aspect and any one of its possible design manners, which will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 It is a schematic diagram of a file synchronization scenario provided by an embodiment of the present application;

[0032] Figure 2 It is a schematic flowchart of a file synchronization provided by an embodiment of the present application;

[0033] Figure 3 It is a schematic diagram of the principle of an event processing method provided by an embodiment of the present application;

[0034] Figure 4Schematic diagram of the hardware architecture of an electronic device provided by an embodiment of the present application;

[0035] Figure 5 Schematic diagram of the software architecture of an electronic device provided by an embodiment of the present application;

[0036] Figure 6 Schematic flow chart of an event processing method provided by an embodiment of the present application Figure 1 ;

[0037] Figure 7 Schematic flow chart of an event processing method provided by an embodiment of the present application Figure 2 ;

[0038] Figure 8 Schematic flow chart of an event processing method provided by an embodiment of the present application Figure 3 ;

[0039] Figure 9 Schematic diagram of the structure of an event processing device provided by an embodiment of the present application. Detailed implementation manners

[0040] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in the specification and appended claims of the present application, the singular forms "a", "an", "the", "above-mentioned", "said", and "this" are intended to include the plural forms as well, unless the context clearly dictates otherwise. It should also be understood that " / " means "or", for example, A / B can mean A or B; "and / or" in the text is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone.

[0041] Referring to "embodiment" in the present application means that a specific feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the present application. The phrase appears in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art explicitly and implicitly understand that the embodiments described in the present application can be combined with other embodiments.

[0042] The terms "first" and "second" in the following embodiments of the present application are only for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of the embodiments of the present application, unless otherwise stated, the meaning of "a plurality" is two or more.

[0043] First, the nouns involved in the embodiments of the present application are described as follows:

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

[0045] (2) Non-access stratum: non-access stratum, abbreviated as NAS. After layering the current communication system (such as Universal Mobile Telecommunications System (UMTS)) from the perspective of the protocol stack, the NAS layer is the highest layer in the control plane. As a functional layer between the core network and the user terminal, the non-access stratum supports signaling and event processing between the two.

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

[0047] (3) Write / Read (Input / Output, I / O) operation: The I / O operation refers to the process of data exchange between a computer and the external world. These operations include reading data (input operation) from external devices (such as keyboards, mice, displays, disk drives, network devices, etc.) and writing data (output operation) to external devices.

[0048] (4) Event: In computer science and software engineering, an "event" generally refers to a meaningful state change or a specific behavior that occurs in a system. Events can be triggered by user operations, such as clicking a button, keyboard input, etc.; they can also be triggered by activities within the system, such as a timer expiring, a change in a data file, a change in the network connection status, etc. In the embodiments of the present application, an event refers to a situation where the status of a data file or a related directory of a data file changes. These changes may include, but are not limited to: creation / adding, deletion, modification, moving (moving in and out), renaming, etc. In addition, to facilitate the distinction of different events, different types of change events of a data file can correspond to different identifiers, such as a mask value.

[0049] When using a monitoring tool to monitor the changes in the file system, the monitoring tool will monitor / capture the changes in the data files in the file system and generate corresponding change events (or change event objects). The change event can include all relevant information. For example, the specific type of change that occurred can be characterized by a mask, the file path / directory of the data file corresponding to the change event can be characterized by a watch descriptor (WD), the moment when the change event occurred can be characterized by a timestamp, and the association between the change event and other change events can be characterized by cookies (specifically, the corresponding data file association or being substantially the same (i.e., having exactly the same content)). When the cookies are 0 (or a preset value), it indicates that the change event to which it belongs has no association with other change events. When the cookies are not 0, it indicates that the change event to which it belongs has an association with other change events; specifically, if the cookies of two change events are not 0 and are equal, it is considered that the two change events are associated, that is, the data files corresponding to the two change events are two associated data files (or two substantially the same data files).

[0050] In the related art, to facilitate a user to process data files in other electronic devices while using a certain electronic device, data synchronization can be used to automatically synchronize the data files on Electronic Device A to Electronic Device B or a network-side device.

[0051] Taking Electronic Device A including a tablet computer and a mobile phone as an example, in a possible implementation scenario, referring to Figure 1 as shown in (a), for User A's multiple electronic devices, User A can, through the settings of the trust ring application on each electronic device, enable the data files of the tablet computer and mobile phone he owns to be automatically backed up to the personal computer he owns in a data synchronization manner. In another possible implementation scenario, referring to Figure 1As shown in Figure (b), for multiple electronic devices of User A, User A can also set the trust ring application on each electronic device and set the trust ring application on the network-side device in a specific manner (such as instructing the electronic device manufacturer or the trust ring application manufacturer), so that the data files of the tablet computer and mobile phone owned by User A can be automatically backed up (or can be called file automatic backup) to the personal computer owned by User A in a data synchronization manner.

[0052] Of course, in practice, the scenario of file synchronization can also be any other possible scenario, and this application does not make specific restrictions on this.

[0053] After that, when the user uses Electronic Device B, the user can directly process the data files of Electronic Device A existing in Electronic Device B, or download the data files in Electronic Device A from the network-side device to Electronic Device B and then process them.

[0054] In a possible implementation manner, the process of synchronizing the data files in Electronic Device A to Electronic Device B through the trust ring application and the corresponding file synchronization service between Electronic Device A and Electronic Device B that have established a trust ring can be as Figure 2 shown:

[0055] First, the user operates the trust ring application in Electronic Device A, so that the trust ring application on Electronic Device A calls the software development kit (SDK) interface of the file synchronization software to complete the creation of synchronization configuration information in the file synchronization service, namely 1.1 and 1.2. Among them, the synchronization configuration information may include configuration information such as the file path / directory of the data file to be synchronized, the file metadata of the data file, and the synchronization identifier. In some embodiments, the synchronization configuration information may be referred to as repo, and the synchronization identifier may be referred to as repo identifier (ID, identity document). The file metadata of the data file may include file name, modification time (the time of the last modification), creation time, size, hash value, etc.

[0056] Similarly, the user will also operate the trust ring application in Electronic Device B, so that the trust ring application on Electronic Device B also completes the creation of repo in the file synchronization service based on the file synchronization SDK interface. The path / directory of the files to be synchronized included in the repo created in Electronic Device B may be different.

[0057] After the repo is created in the A electronic device and the B electronic device in the file synchronization service, in order to facilitate the data file synchronization from the A electronic device to the B electronic device, it is necessary to first perform repo sharing (i.e., 2.1), so that the B electronic device can determine whether to accept the synchronization data from the A electronic device based on the repo created by itself and the repo created in the A electronic device, such as subsequent file metadata and file synchronization content, etc. In the embodiment of the present application, the repo sharing can specifically be that after the file synchronization service in the A electronic device stores the repo in a specific database (data base, DB) and completes the 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 the B electronic device, that is, execute 3.1. After the file synchronization service of the B electronic device receives the repo metadata from the file synchronization service of the A electronic device, it can determine whether to receive the synchronization data from the A electronic device 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 from the file synchronization service of the A electronic device is the same as the repo ID included in the repo in the A electronic device, the file synchronization service of the B electronic device can receive the synchronization data from the A electronic device. Of course, the file synchronization service of the B electronic device will also send the judgment result to the file synchronization service of the A electronic device, so that the A electronic device can clearly know that the B electronic device has created the repo and can receive the synchronization data, and then can further send the synchronization data to the file synchronization service of the B electronic device subsequently.

[0058] After the repo is created in the A electronic device, the file synchronization service in the A electronic device can determine that there is a data synchronization requirement or a data synchronization task. Then, the file synchronization service in the A electronic device can use a monitoring tool to monitor the file path indicated by the repo in the file system, that is, execute 4.1.

[0059] When an application in the A electronic device creates or modifies (including moving, deleting, renaming, etc.) a file (i.e., 4.2) in the file path indicated by the repo in the file system, the monitoring tool can monitor this situation, generate a 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] After the file synchronization service in the A electronic device receives the reported change event, it can first persist the change event, that is, execute 4.4. In a possible implementation, the file synchronization service can generate a flag bit that can indicate the change event based on the change event and store it in the file metadata of the data file corresponding to the change event in the database. The file metadata can be obtained when the A electronic device creates a repo and stored in the database together when the repo is persisted, or it can be obtained from the storage area storing the data file when the change event of a certain data file is received for the first time and then stored in the database. Each time the file synchronization service persists the change of a certain change event, it will cause a change in the database (or it can be said that the storage water level of the database changes), and generate 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] In addition, the file synchronization service in the A electronic device can read the change records of the database in real time or periodically based on a short time period (such as 5 ms), that is, execute 5.1. When it is determined that there is new data in the database, the file synchronization service can send the file metadata corresponding to the new data to the file synchronization service of the B electronic device, that is, execute 5.2.

[0062] After the file synchronization service of the B electronic device receives the file metadata from the A electronic device, it can compare the file metadata with the file metadata of the corresponding file in its own database, that is, execute 5.3. Among them, the file paths of the files to which the two file metadata participating in the comparison belong are the same. If the file metadata from the A electronic device is different from the file metadata of the corresponding file stored in the database of the B electronic device, and the modification time of the file metadata from the A electronic device is newer, the file synchronization service of the B electronic device requests the file content of the data file corresponding to the file metadata from the file synchronization service of the A electronic device. The request can be a file content request, and the file content request can carry a file identifier (such as name, path, etc.). If the file metadata from the A electronic device is the same as the file metadata of the corresponding file stored in the database of the B electronic device, the file synchronization service of the B electronic device will not perform subsequent actions.

[0063] After the file synchronization service of the A electronic device receives the file content request from the file synchronization service of the B electronic device, it can read the file content of the corresponding data file from the storage area storing the data file, that is, execute 6.1. After that, the file synchronization service of the A electronic device can send the file content of the data file to the file synchronization service of the B electronic device (that is, execute 6.2) for it to update the data file.

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

[0065] So far, a file synchronization process is completed.

[0066] It can be seen that when implementing the current data synchronization, in order to ensure that the data file is synchronized in a timely manner, a monitoring tool is used to monitor the change events of the data file in real time and report them to the file synchronization service, so that the file synchronization service can perform corresponding processing (such as writing change events in the storage area and reading change records from the storage area) to complete the synchronization.

[0067] However, if the user's operations on the data file (such as copying and pasting a certain data file) generate multiple consecutive change events, and the monitoring tool directly reports to the file synchronization service for processing each time a change event is monitored, it will cause the file synchronization service to perform frequent IO operations (i.e., performing change persistence and reading change records), and frequently process the intermediate state of the data file (the data file when the user has not completed the modification of the data file) (i.e., reading the file content and sending it to the file synchronization service of another electronic device). Further, since current electronic devices usually complete computing or processing tasks through multiple parallel processes or threads to improve processing speed, the above-mentioned frequent IO operations and frequent processing of the intermediate state of the data file may cause errors in the processing of the final state of the data file (the state that finally needs to be synchronized after the data file transformation) due to resource preemption, data competition, and conflicts among parallel threads. As a result, the user experience is poor.

[0068] To solve the above technical problems, an embodiment of the present application provides an event processing method, which is applied to an electronic device. In this technical solution, as shown in Figure 3 When there is a file synchronization task (performing file synchronization) in the electronic device, monitor the change events of the data file in the target path indicated by the file synchronization task.

[0069] In the case where a first change event corresponding to a first data file is obtained through monitoring, if it is determined that a first change event set exists, the first change event is added to the first change event set, and the first change event and at least one second change event included in the first change event set are filtered (or called merged) according to a preset filtering rule 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 change events and second change events. The first change event set includes at least one second change event, and the second change event is a change event of the first data file or the second data file that has been monitored and not synchronized. The first data file and the second data file are the same or associated. The second data file is a data file after the first data file is renamed or a data file after the file path of the first data file is changed. If the 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] Afterwards, if no change event of the first data file or the second data file is monitored within the first preset time period, the first change event set or the second change event set may be synchronized to complete the synchronization of the first data file. After the synchronization, the first change event set or the second change event set may be deleted.

[0071] Based on the technical solution provided by the present 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 continuously in a short period of time for a file can be considered to be generated by a single adjustment operation by the user. Based on this, the technical solution provided by the present application can merge and process multiple change events generated continuously in a short period of time for the same data file (two associated files are also considered to be the same file) when performing a file synchronization task, thereby reducing the number of change events that need to be synchronized for the data file (for example, the first data file), thereby avoiding as much as possible the defect of the file synchronization service processing the final state of the data file incorrectly due to too many change events generated by a user's adjustment operation on the data file.

[0072] The technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0073] The technical solution provided by this application can be applied to an electronic device with a trust ring application or a file synchronization function provided by a trust ring application. In some embodiments, the electronic device may be a mobile phone, a tablet computer, a handheld computer, a personal computer (PC), an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a wearable device, a vehicle-mounted device, a smart home device, and / or a smart city device, etc. The specific type of the electronic device is not particularly limited in the embodiments of this application.

[0074] Exemplarily, taking the electronic device as a mobile phone as an example, Figure 4 The structural schematic diagram of an electronic device provided by the embodiments of this application is shown.

[0075] Referring to 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, an antenna 1, an 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 interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a display screen 193, a subscriber identification module (SIM) card interface 194, and a camera 195, etc. Among them, the sensor module 180 may include a pressure sensor, a gyroscope sensor, a barometric pressure sensor, a magnetic sensor, an acceleration sensor, a gravity sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, etc.

[0076] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors.

[0077] The controller may be the nerve center and command center of the electronic device. The controller may generate operation control signals according to the command operation code and timing signal to complete the control of fetching and executing commands.

[0078] A memory may also be provided in the processor 110 for storing commands and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory may save the commands or data that the processor 110 has just used or recycled. If the processor 110 needs to use the command or data again, it can be directly called 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. The 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 a wireless power supply device (such as a charger, laptop power supply, etc.). Among them, the charger can be a wireless charger or a wired charger. In some embodiments of wired charging, the charging management module 140 can receive the charging input of the wired charger through the USB interface 130. In some embodiments of wireless charging, the charging management module 140 can receive the wireless charging input through the receiving coil in the wireless charging chip of the electronic device. Or, the charging management module 140 includes a wireless charging chip, and thus can receive the wireless charging input through the receiving coil in the wireless charging chip. Of course, in some embodiments, the receiving coil can also be separately provided relative to the charging management module 140. At this time, the charging management module can use the receiving coil to receive the wireless charging input through the wireless charging chip. In addition, in some other embodiments, the charging management module 140 can also wirelessly charge other electronic devices through 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. Among them, the battery 142 can specifically be composed of multiple batteries connected in series. The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. In some other embodiments, the charging management module 140 can also be provided in the processor 110.

[0082] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives the input from the battery 142 and / or the charging management module 140 and supplies power to the processor 110, the internal memory 121, the display screen 193, the camera 195, the wireless communication module 160, etc. The power management module 141 can also be used to monitor parameters such as the voltage, current, battery cycle count, and battery health status (leakage, impedance) of the battery. In some other embodiments, the power management module 141 can also be provided in the processor 110. In some embodiments, the charging management module 140 and the power management module 141 can be provided in the same device.

[0083] The external memory interface 120 can be used to connect to an external non-volatile memory to expand the storage capacity of the electronic device. The external non-volatile memory communicates with the processor 110 through the external memory interface 120 to implement the data storage function. For example, files such as music and videos are saved in the external non-volatile memory.

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

[0085] The touch sensor, also known as a "touch control device". The touch sensor can be disposed on the display screen 193, and the touch sensor and the display screen 193 form a touch screen, also known as a "touch control screen". The touch sensor is used to monitor touch operations acting on or near it. The touch sensor can transmit the monitored 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 some other embodiments, the touch sensor can also be disposed on the surface of the electronic device, at a different position from the display screen 193.

[0086] The ambient light sensor is used to sense the ambient light brightness. The pressure sensor is used to sense pressure signals and can convert the pressure signals into electrical signals. In some embodiments, the pressure sensor can be disposed on the display screen 193. There are many types of pressure sensors, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc.

[0087] The accelerometer (G-sensor), also called a gravity sensor, is actually a device that can sense acceleration in any direction. The triaxial accelerometer works based on the basic principle of acceleration. Acceleration is a spatial vector. On the one hand, to accurately understand the motion state of an object, the components on its three coordinate axes must be measured; on the other hand, in the case where the motion direction of the object is not known in advance, only the triaxial acceleration sensor can be used to detect the acceleration signal.

[0088] A gyroscope sensor, also known as a ground sensor, traditionally has a gyroscope inside. A three-axis gyroscope can simultaneously measure the positions, movement trajectories, and accelerations in six directions. A single-axis gyroscope can only measure quantities in two directions, meaning a system requires three gyroscopes, while a 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 gyro rotor in a three-dimensional coordinate system and the device, calculate the angular velocity, and use the angle and angular velocity to determine the motion state of the object in three-dimensional space. A three-axis gyroscope can simultaneously measure six directions such as up, down, left, right, front, and back (the combined direction can also be decomposed into three-axis coordinates), and ultimately determine the movement trajectory and acceleration of the device. That is to say, a three-axis gyroscope determines the current motion state of the device by measuring its own rotation state, such as whether it is moving forward, backward, upward, downward, left, or right; whether it is accelerating (angular velocity) or decelerating (angular velocity), etc.

[0089] The combination of an acceleration sensor and a gyroscope sensor can form an A+G module. Through the A module (acceleration sensor) in the A+G module, the electronic device can know "how many meters it has moved forward", and through the G module (gyroscope sensor) in the A+G module, the electronic device can know "it has turned around". Therefore, through the A+G module, the electronic device can determine whether it is moving. Of course, in order for the electronic device to successfully detect whether it is moving, the electronic device can also include any other possible sensors.

[0090] In some embodiments, the electronic device may include one or N cameras 195, where N is a positive integer greater than 1. In the embodiments of this application, the types of the cameras 195 can be distinguished according to the hardware configuration and physical location. For example, the camera set on the side of the display screen 193 of the electronic device can be called a front camera, and the camera set on the back cover of the electronic device can be called a rear camera; for another example, a camera with a short focal length and a large viewing angle can be called a wide-angle camera, and a camera with a long focal length and a small viewing angle can be called a normal camera. Among them, the length of the focal length and the size of the viewing angle are relative concepts and there are no specific parameter limitations. Therefore, the wide-angle camera and the normal camera are also relative concepts and can be specifically distinguished according to physical parameters such as the focal length and the viewing angle.

[0091] The electronic device realizes the display function through the GPU, the display screen 193, and the application processor, etc. The GPU is a microprocessor for image editing, connecting 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 change display information.

[0092] The electronic device can implement the shooting function through the ISP, camera 195, video codec, GPU, display screen 193, application processor, etc. 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 change display information.

[0093] The ISP is used to process the data fed back by the camera 195. For example, when taking a photo, the shutter is opened, and the light passes through the lens and is transmitted to the camera sensor. The light signal is converted into an electrical signal, and the camera sensor transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. The ISP can also optimize the noise and brightness of the image through algorithms. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 195. The camera 195 is used to capture static images or videos.

[0094] The digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy, etc.

[0095] The video codec is used to compress or decompress digital videos. The electronic device can support one or more video codecs. In this way, the electronic device can play or record videos in multiple coding formats, such as: Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0096] The display screen 193 is used to display images, videos, etc. The display screen 193 includes a display panel. The display panel can adopt 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 Miniled, a MicroLed, a Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device may include 1 or N display screens 193, where N is a positive integer greater than 1.

[0097] In the embodiments of the present application, the display screen 193 can be used to display the pages required by the electronic device (for example, the display page of the captured image, etc.), and display the images captured by any one or more cameras 195 in this interface.

[0098] The wireless communication function of the electronic device can be implemented by antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem, baseband processor, etc.

[0099] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device can be used to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization rate of the antennas.

[0100] The mobile communication module 150 can provide solutions for wireless communications such as 2G / 3G / 4G / 5G applied to the electronic device. The mobile communication module 150 can receive electromagnetic waves through antenna 1, filter, amplify, etc. the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor and convert it into electromagnetic waves through antenna 1 for radiation. In some embodiments, at least some functional modules of the mobile communication module 150 can be disposed 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 disposed in the same device.

[0101] The modulation and demodulation processor can include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. Subsequently, the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs a sound signal through an audio device (not limited to speaker 170A, receiver 170B, etc.), or displays an image or video through the display screen 193. In some embodiments, the modulation and demodulation processor can be an independent device. In other embodiments, the modulation and demodulation processor can be independent of the processor 110 and disposed in the same device as the mobile communication module 150 or other functional modules.

[0102] The wireless communication module 160 may provide solutions for wireless communications applied to an electronic device, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite systems (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), and the like. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, performs frequency modulation and filtering processing on the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 may also receive signals to be sent from the processor 110, perform frequency modulation and amplification on them, and convert them into electromagnetic waves through the antenna 2 for radiation.

[0103] In some embodiments, antenna 1 of the electronic device is coupled to the mobile communication module 150, and antenna 2 is coupled to the wireless communication module 160, enabling the electronic device to communicate with the network and other devices through wireless communication technologies. The wireless communication technologies 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 Global Positioning System (GPS), Global Navigation Satellite System (GLONASS), Beidou Navigation Satellite System (BDS), Quasi-Zenith Satellite System (QZSS), and / or Satellite Based Augmentation Systems (SBAS).

[0104] The SIM card interface 194 is used to connect to the SIM card. The SIM card can be in contact with and separated from the electronic device by being inserted into or removed from the SIM card interface 194. The electronic device may support one or more SIM card interfaces. The SIM card interface 194 may support Nano SIM cards, Micro SIM cards, SIM cards, etc. Multiple cards can be inserted into the same SIM card interface 194 simultaneously. The SIM card interface 194 may also be compatible with external memory cards. The electronic device interacts with the network through the SIM card to implement functions such as calls and data communication. One SIM card corresponds to one user number.

[0105] It can be understood that the interface connection relationships among the modules illustrated in the embodiments of the present invention are only illustrative and do not constitute a structural limitation on the electronic device. In other embodiments of the present application, the electronic device may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0106] Of course, it can be understood that the above Figure 4 is only an exemplary illustration when the form of the electronic device is a mobile phone. When the electronic device is in other device forms such as a tablet computer, a handheld computer, a PC, a PDA, a wearable device (such as a smart watch, a smart bracelet), etc., the structure of the electronic device may include fewer structures than those Figure 4 shown in Figure 4 or may include more structures than those

[0107] shown in, which is not limited herein.

[0107] It can be understood that generally speaking, in addition to the support of hardware, the realization of the functions of the electronic device also requires the cooperation of software. The software system of the electronic device may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservices architecture, or a cloud architecture. In the embodiments of the present application, taking the system of the layered architecture as an example, the software structure of the electronic device is illustratively described.

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

[0109] In some examples, as shown in Figure 5 in the embodiments of the present application, the software system set on the application processor (AP) in the system-on-chip (SOC) of the electronic device is divided into five layers, from top to bottom are the application layer, the framework layer (or called the application framework layer), the system libraries and Android Runtime, the HAL layer (hardware abstraction layer), and the kernel layer (or called the driver layer). Among them, the system libraries and Android Runtime can also be called the native framework layer or the native layer.

[0110] Among them, the application layer may include a series of applications. As Figure 5 shown, the application layer may include applications (APPs) such as a camera, a gallery, a calendar, a map, WLAN, Bluetooth, news, music, video, short message, call, navigation, instant messaging, etc.

[0111] In the embodiments of the present application, the application layer may further include a trust ring application. The trust ring application can be used for functions such as account creation and trust ring management. Among them, 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, creating a repo, and so on.

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

[0113] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.

[0114] The content provider is used to store and obtain data, and make this data accessible to applications. This data may include videos, images, audio, incoming and outgoing calls, browsing history and bookmarks, phone books, etc.

[0115] The view system includes visible controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface including a text message notification icon may include a view for displaying text and a view for displaying pictures.

[0116] The phone manager is used to provide the communication function of the electronic device. For example, the phone manager can manage the call status of the call application (including initiation, connection, hanging up, etc.).

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

[0118] The resource manager provides various resources for applications, such as localized strings, icons, pictures, layout files, video files, and so on.

[0119] The notification manager enables an application to display notification information in the status bar. It can be used to convey informative messages, which can automatically disappear after a short stay without user interaction. For example, the notification manager is used to inform that a download is completed, a message is reminded, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or a scrolling text, such as a notification of a background-running application, or a notification that appears on the screen in the form of a dialogue window. For example, it can prompt text information in the status bar, emit a prompt tone, vibrate the electronic device, blink the indicator light, etc.

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

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

[0122] Of course, in practice, the technical solution provided by the present application can also be any possible module in the application processor. The above is only an example and does not constitute a specific limitation to the actual situation.

[0123] The system library may include multiple functional modules. For example: surface manager, Media Libraries, open graphics library embedded systems (OpenGL ES), SGL, etc. The surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications. The Media Libraries support the playback and recording of multiple common audio and video formats, as well as static image files, etc. The Media Libraries can support multiple audio and video coding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc. OpenGL ES is used to implement three-dimensional graphic drawing, image rendering, synthesis, and layer processing, etc. SGL is a drawing engine for 2D drawing.

[0124] In the embodiment of the present application, the system library may further include a file synchronization service. The file synchronization service is specifically used to execute a file synchronization task after the trust ring application creates a repo, and implement the file synchronization function of the trust ring application. The specific implementation can refer to the relevant descriptions for Figure 2 the above.

[0125] In addition, the file synchronization service is specifically used to execute the technical solution provided by this application during the execution of the file synchronization task. Specifically, it can be achieved by the event reporting layer and the EventsFilter module in the file synchronization service in cooperation with each other to implement the technical solution provided by this application.

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

[0127] Android runtime includes the core library and the ART virtual machine. Android runtime is responsible for the scheduling and management of the Android system. The core library consists of two parts: one part is the functional functions that need to be called by the Java language, and the other part is the core library of Android. The application layer and the application framework layer run in the ART virtual machine. The ART virtual machine executes the Java files of the application layer and the application framework layer into binary files. The ART virtual machine is used to execute functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0128] The HAL layer is the interface layer between the operating system kernel and the hardware circuit, and its purpose is to abstract the hardware. It hides the hardware interface details of a specific platform and provides a virtual hardware platform for the operating system, making it hardware-independent and portable on multiple platforms. The HAL layer provides a standard interface to display the device hardware functions to a higher-level Java API framework (i.e., the framework layer). The HAL layer contains multiple library modules, and each module implements an interface for a specific type of hardware component. For example: the audio HAL audio module, the bluetooth HAL bluetooth module, the camera HAL camera module (which can also be called the camera HAL or the camera hardware abstraction module), the sensors HAL sensor module (or called the Isensor service, the sensor service), the display HAL (display module), etc.

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

[0130] It should be noted that although this application embodiment is described by taking the Android system as an example, its basic principle also applies to electronic devices based on operating systems such as iOS and Windows.

[0131] The technical solutions provided in the embodiments of the present application can all be implemented in an electronic device with the above-mentioned hardware architecture and software architecture.

[0132] Based on the above Figure 5 shown software architecture, the following will introduce the process of the event processing method provided in the embodiments of the present application in combination with Figure 6 , and introduce the process of the event processing method provided in the embodiments of the present application. Figure 6 It is a schematic flow chart of an event processing method provided in an embodiment of the present application. Refer to Figure 6 shown. Taking an electronic device as a mobile phone with a file synchronization function, and the file synchronization service that realizes the file synchronization function in the mobile phone includes an event reporting layer and an event filter as an example, the event processing method may include S601-S610:

[0133] S601. When there is a file synchronization task, the event reporting layer monitors the change events of the data files in the target path indicated by the file synchronization task.

[0134] In the embodiments of the present application, when the user creates a repo by operating the trust ring application in the electronic device, it can be considered that there is a file synchronization task currently. When there is a file synchronization task, the event reporting layer in the file synchronization service can use the listening tool predefined by the operating system to monitor the change events of the data files under the target path indicated by the file synchronization task. The specific implementation of creating a repo can refer to the relevant descriptions in the foregoing embodiments for Figure 2 , and will not be elaborated here.

[0135] In the embodiments of the present application, the types of change events may specifically include, but are not limited to, the following: modify event (modify), delete event (delete), rename event (rename), move event (move), create event (create), etc. Among them, the modify event refers to the modification of the content in the data file; the delete event refers to the overall deletion of the data file; the rename event refers to the modification of the file name of the data file; the create event refers to the creation of a new data file, and the new event refers to the addition of a new data file. The move event may include a move-from event (move from) and a move-to event (moveto). The move-from event refers to moving the data file out of a path, and the move-to event refers to moving the data file into a certain path. In the embodiments of the present application, the rename event monitored by the listening tool can actually be composed of adjacent move-from event and move-to event. The move-to event corresponding to the rename event may carry an old name identifier indicating the old file name used when the data file corresponding to the rename event modifies the file name; ultimately, the rename event reported by the event reporting layer to the event filter is essentially the corresponding move-from event and the move-to event with the old name identifier.

[0136] In addition, in the embodiments of the present application, except that the moving event corresponding to the rename event carries the old name identifier, all change events can specifically carry the file name, WD, cookies, and event identifier of their corresponding files. Among them, the event identifier can specifically be a mask.

[0137] Exemplarily, the monitoring tool can be inotify for the linux platform or ReadDirectoryChangesExW for the windows platform according to different operating systems, or it can also be any other possible monitoring tool, and the present application does not make specific limitations thereto. In practice, inotify or ReadDirectoryChangesExW can specifically be application programming interfaces (APIs) that can implement the monitoring function, and the event reporting layer can implement the monitoring of change events of data files under the target path by calling these interfaces.

[0138] After the event reporting layer monitors a change event, in order to avoid the problem that the synchronous processing of consecutive change events causes frequent IO operations of the file synchronization service and frequent processing of the intermediate state of the data file, resulting in an error in the processing of the final state of the data file by the file synchronization service, the change event can first be handed over to the event filter in the file synchronization service for processing to minimize the change events that ultimately need to be synchronously processed. Based on this, S602 is executed after S601.

[0139] S602: When the event reporting layer monitors the first change event of the first data file through the monitoring tool, the event reporting layer sends the first change event to the event filter.

[0140] In the embodiments of the present application, after the event reporting layer monitors the first change event through the monitoring tool, the event reporting layer can send the first change event to the event filter through a specific interface. Exemplarily, the specific interface can be PutEvents.

[0141] Since in practice, the change events continuously generated by the same data file in a short period of time are largely related, and the relationship between these change events may result in some change events being redundant or filterable (or mergable) among these change events. Therefore, after the event filter receives the first change event, in order to reduce the change events, it is necessary to first determine whether there are change events of the first data file that have been monitored and not yet synchronously processed. In the case where it is determined that there are change events of the first data file that have not been synchronously processed, all the unsynchronized change events of the first data file can be filtered according to a specific rule (such as a preset filtering rule).

[0142] Furthermore, for a certain change event, the corresponding data file is characterized by the file name and WD carried by this change event. If the WDs and file names carried by two change events are both the same, it indicates that the data files corresponding to these two change events are the same. In the embodiments of the present application, the combination of the file name and WD can be referred to as file identification information.

[0143] In practice, for a certain data file, the file names carried by the two change events of moving out and moving in generated after it is moved are the same, but the WDs are different; similarly, the WDs carried by the moving out event and the moving out time generated by renaming are the same, and the file names are the same. Therefore, it is determined according to the WD and file name that the data files corresponding to these two change events are different. However, substantially, the contents of the data files corresponding to these two change events are exactly the same, and these two change events can be considered as change events of the same data file. Therefore, when it is determined according to the WD and file name that the data files corresponding to two transformation events are different, it is also necessary to combine cookies to determine whether the data files corresponding to these two change events are associated files. If it is determined based on cookies that the data files corresponding to two change events are associated files, it indicates that the data files corresponding to these two events are substantially the same. In the embodiments of the present application, cookies can be referred to as association identification information.

[0144] Based on the above statements, after the event filter receives the first change event, in order to reduce change events, it is necessary to first determine whether there is a change event of a second data file that has been monitored and not synchronized. Among them, the second data file is the same as or associated with the first data file. That is, after S602, S603 and S604 are executed.

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

[0146] S604. The event filter determines whether there is a first change event set.

[0147] Among them, the second change event is a change event of the first data file or the second data file that has been monitored and not synchronized, and the second data file is a data file associated with the first data file.

[0148] In some embodiments, if the association identification information of two change events is not the preset value and is the same, the data files corresponding to these two change events are mutually associated data files. Exemplarily, the association identification information can be cookies, and the preset value can be 0. If the file identification information of two change events is the same, the data files corresponding to these two change events are the same. Exemplarily, the file identification information includes the file name and WD.

[0149] That is to say, 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 associated identification information carried by the first change event is equal to the associated identification information carried by the second change event of the second data file and neither is a preset value. Exemplarily, the preset value can be 0.

[0150] In some embodiments, when the event filter obtains the first change event, it first determines whether there is a corresponding data file in the previously obtained change events that have not been synchronously processed and that is the same as or associated with the data file corresponding to the new change event. If there is at least one second change event, then the combination of these second change events can be regarded as the first change event set. If there is no second change event, it can be considered that there is no first change event set.

[0151] In the case where it is determined that there is a first change event set, it can be considered that there are multiple consecutive change events that have not been synchronously processed for the first data file currently, that is, there are multiple change events that can be filtered (or called merged). At this time, the multiple change events that have not been synchronously processed for this data file can be filtered to reduce the number of change events that the file synchronization service needs to synchronously process subsequently. That is, execute S605.

[0152] In the case where it is determined that there is no first change event set, it can be considered that there is only one change event for the first data file currently, and there are no multiple change events that can be filtered (or called merged). At this time, the first change event can be retained first (or called waiting to process the first change event), and filtered when other change events of the first data file or the second data file appear subsequently. That is, execute S606.

[0153] S605. The event filter performs a filtering process 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.

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

[0155] Specifically, when executing S605, the event filter can first add the first change event into the first change event set, and then perform a filtering process on all the change events in the first change event set according to a preset filtering rule, so as to realize the update of the first change event set.

[0156] In some embodiments, for the convenience of processing, the event filter may set the same set identifier (or sequence number num) for the unsynchronized change events belonging to the same data file (or two related data files). The unsynchronized change events of different data files (or data files that are not related to each other) correspond to different set identifiers. The unsynchronized change events with the same set identifier can be combined into a change event set, such as the first change event set. When the data file corresponding to the new change event received by the event filter is the same as or related to the data file corresponding 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 the preset filtering rules to update the change event set.

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

[0158] In some embodiments, in combination with Figure 6 , with reference to Figure 7 as shown, the specific content of the event filter in S605 filtering the first change event and at least one second change event included in the first change event set according to the preset filtering rules may include the following:

[0159] (1) When the first change event is a deletion event or a removal event, if there is a creation event or an addition event among at least one second change event, the event filter sets the first change event set to be empty. Setting the first change event set to be empty is the update of the first change event. Setting the first change event set to be empty means that there are no change events in the first change event set.

[0160] Specifically, when the current first change event is a deletion event or a removal event, if there is a creation event or an addition event among at least one second change event, it indicates that for the first data file (or the second data file), the electronic device first performs a creation or addition to a specific path in response to a user operation, and then performs a deletion or removal from the specific path in a short time. Then it can be considered that the first data file has not actually changed. Therefore, at this time, it can be considered that the first data file has no change events, that is, the update of the first change event set can be to set the first change event set to be empty.

[0161] After the first change event set is emptied, it can be considered that there are no change events in the first data file. Subsequently, if no change events of the first data file or the second data file are received within the first preset duration, the event filter will not report any change events of the first data file or the second data file to the event reporting layer.

[0162] Of course, if after the first change event set is emptied, change events of the first data file or the second data file are received within the first preset duration, the logic of S603 - S606 can be processed again.

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

[0164] Specifically, in the case where the current first change event is a deletion event or a removal event, if there is no creation event or addition event in at least one second change event, it indicates that for the first data file (or the second data file), the electronic device has currently performed a deletion in response to a user operation. Then regardless of whether there are other events other than addition events or creation events in the first change event set before, this deletion will render these events invalid. So at this time, it can be considered that the first data file only has a deletion event, that is, the update of the first change event set can be to update the first change event set to a change event set that only includes the deletion event.

[0165] (3) In the case where the first change event is a creation event or an addition 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 overwrite other change events in the first change event set; or, the event filter can be to use the first change event to overwrite 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, in the case where the current first change event is a creation event or an addition event, it indicates that the first data file has just been created or just been moved into a specific path. Only removal events or deletion events for the first data file may exist in the first change event set. And the previous removal events or deletion events have no change significance for the newly created first data file at this time. When synchronously processing the creation event subsequently, the creation event is generally regarded as a new event. So at this time, the updated first change event set can be made to include only the first change event, or to include only the new event in the updated first change event set for the convenience of subsequent processing.

[0167] In addition, in some embodiments, when the first change event is a moving-in event carrying an old name identifier, it can be considered that the moving-in event is the moving-in event corresponding to the renaming event. At this time, it indicates that the first data file has been renamed. Only a moving-out event for the first data file may exist in the first change event set, and for the newly moved-in first data file at this time, the previous moving-out event has no change significance. Therefore, at this time, the updated first change event set can be made to only include this first change event. However, since the moving-in event corresponding to the renaming event cannot be recognized as a new event, in this case, the updated first change event set cannot be made to only include new events. When the subsequent event reporting layer receives the report of the event filter on this first change event (or the report of the first change event set including this first change event), it can adjust the event identifier of this first change event to the event identifier corresponding to the renaming event and then perform synchronization processing.

[0168] (4) When the first change event is not a deletion event, a moving-in event, a creation event, or a moving-in event, if there is a change event of the same type as the first change event among at least one second change event, the event filter makes the first change event set unchanged. The change events of the same type refer to being the same creation event, moving event, deletion event, or modification event.

[0169] Specifically, when the current first change event already exists in the first change event set as a change event of the same type, it can be considered that a duplicate event has occurred for the first data file. For a certain data file, one change event of a certain type is sufficient to reflect the change indicated by the change event of that type for the data file. Subsequent synchronization processing of one change event of that type is also sufficient to complete the synchronization of the change of the change event of that type for the data file. Therefore, at this time, the first change event can be left unchanged.

[0170] (5) When the first change event is not a deletion event, a moving-in event, a creation event, or a moving-in event, if there is no change event of the same type as the first change event among at least one second change event, the event filter adds the first change event to the first change event set. That is to say, compared with the first change event set before update, the updated first change event set has added the first change event.

[0171] Specifically, in the case where the current first change event does not have the same type of change event in the first change event set, it can be considered that a non-repetitive event has occurred for the first data file, and this first change event is meaningful for the modification synchronization of the data file. Therefore, adding this first change event to the first change event set at this time can enable better synchronization of the first data file when the event filter sends this first change event set to the event reporting layer for synchronization processing later.

[0172] Of course, the above (1)-(5) are only examples of the specific implementation of S605. In practice, the event filter can also use any other possible method 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 complete the update of the first change event set.

[0173] In a possible implementation manner, if the monitoring tool for monitoring change events is inotify on the linux platform, the event identifiers (such as mask) carried (or corresponding) by all change events monitored by the event reporting layer through the monitoring tool are binary data with a specific number of bits and only one bit being "1", and the positions of "1" in the event identifiers corresponding to different types of change events are different. The value of the specific number of bits can be the same as the number of types of change events.

[0174] Exemplarily, taking all types of change events including modification events, deletion events, move-in events, move-out events, and creation events as an example, 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, a quick judgment of the above (1)-(5) can be completed based on this event identifier. Specifically, an event identifier and masksum can be preset 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 a modification event and a creation event, and the event identifiers corresponding to the modification event and the creation event are 10000 and 00001 respectively, then the event identifier sum of the first change event set is 10001.

[0176] On this basis, if it is necessary to determine whether there is a move event or a create event in the first change event set, the event identifier corresponding to the move event or the create event can be used to perform a logical AND (&) operation 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 there is a move event or a create event in the first change event set; otherwise, it indicates that there is no move event or create event. Exemplarily, taking the sum of the event identifiers of the first change event set as 10001, the event identifier carried by the move event as 00100, and the event identifier carried by the create event as 00001 as an example, the result of the AND operation between 00001 and 10001 is 00001. Since there is a 1 in this result, it indicates that there is a create event in the first change event set; the result of the AND operation between 00100 and 10001 is 00000. Since there is no 1 in this result, it indicates that there is no create event in the first change event set.

[0177] Alternatively, the sum of the event identifiers corresponding to the move event or the create event can also be used to perform a logical AND (&) operation 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 there is a move event or a create event in the first change event set; otherwise, it indicates that there is no move event or create event. Exemplarily, taking the sum of the event identifiers of the first change event set as 10001, the event identifier carried by the move event as 00100, and the event identifier carried by the create event as 00001 as an example, the sum of 00100 and 00001 is 00101. The result of the AND operation between 00101 and 10001 is 00001. Since there is a 1 in this result, it indicates that there is a move event or a create event in the first change event set.

[0178] If it is necessary to determine whether there is a change event in the first change event set that has the same type as the first change event, the event identifier corresponding to the first change event can be used to perform a logical AND (&) operation 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 there is a change event in the first change event set that has the same type as the first change event; otherwise, it indicates that there is no change event in the first change event set that has the same type as the first change event. Exemplarily, taking the sum of the event identifiers of the first change event set as 10001 and the event identifier carried by the first change event as 00100 as an example, the result of the AND operation between 00100 and 10001 is 00000. Since there is no 1 in this result, it indicates that there is no change event in the first change event set that has the same type as the first change event.

[0179] Based on the above description, the following judgment logic can be obtained: perform an AND operation on the event identifier corresponding to the target event and the sum of the event identifiers in the first change event set to obtain a first AND operation result; the sum of the event identifiers is the sum of the event identifiers carried by all the second change events in the first change event set, and the target event is a move-in event, a move-out event, a create event, or a delete event; if the first AND operation result contains 1, it is determined that there is a target event in the first change event set; if the first AND operation result does not contain 1, it is determined that there is no target event in the first change event set.

[0180] In this way, the above judgments in (1)-(5) can be quickly completed through the AND operation, enabling the event filter 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, and then complete the update of the first change event set.

[0181] In addition, after a first change event is added to the first change event set, the sum of the old event identifiers of the first change event set before the update needs to be updated to the sum of the old event identifier and the event identifier carried by the first change event. This can facilitate subsequent processing when the event filter receives change events of the first data file or the second data file again.

[0182] In addition, if the monitoring tool for monitoring change events is not inotify on the linux platform, the event identifiers carried by all types of monitored change events can be converted into the corresponding event identifiers obtained when inotify monitors change events according to specific rules. Then, refer to the foregoing embodiments to provide relevant processing methods to complete the above judgments in (1)-(5).

[0183] In another possible implementation, the event filter can also complete the judgment of whether there is a move-in event or a create event in the first change event set based on the one-to-one comparison between the event identifier corresponding to the move-in event or the create event and the event identifier carried by each second change event in the first change event set. Similarly, based on the one-to-one comparison between the event identifier carried by the first change event and the event identifier carried by each second change event in the first change event set, the judgment of whether there is a change event of the same type as the first change event in the first change event set can be completed.

[0184] Of course, in practice, other arbitrary possible implementation methods can also be used to complete the above judgments in (1)-(5), 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. The present application does not make specific restrictions on this.

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

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

[0187] Due to the operations of a user on a certain data file in the file system, multiple change events will be continuously generated within a short period of time. That is to say, the interval between the generation times of adjacent change events generated by a certain operation is relatively short. If the event interval between the next change event of a certain data file and the current change event of this data file is relatively long, it can be considered that the next change event is generated by the user's next operation. In order to synchronize the data file in a timely manner after each user operation and not confuse the adjustments to the data file by two different user operations, it is necessary to synchronize the change events of an operation in a timely manner, that is, the change events cannot be left unsynchronized for a long time.

[0188] Based on this, after generating the second change event set or updating the first change event set, if the event filter does not receive a change event of the first data file or the second data file within the first preset duration, it can timely send the change events in the second change event set or the first change event set to the event reporting layer, so that the event reporting layer performs 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: In the case that the event filter does not receive a change event of the first data file or the second data file from the event reporting layer within the first preset duration, send the first change event set to the event reporting layer.

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

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

[0192] Among them, the synchronization processing of the change events in the first change event set by the event reporting layer can specifically 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 synchronizes the first data file based on the change records in this database. The specific implementation can refer to the relevant descriptions in 4.4, 5.1, 5.2, 5.3, 6.1, 6.2, and 6.3 in the foregoing embodiments, which will not be elaborated here.

[0193] Based on S607 and S608, in the case that no change events of the first data file or the second data file are monitored within a short period of time, it can be considered that the user's current operation on the first data file has probably ended. At this time, the file synchronization service in the mobile phone can promptly synchronize the filtered change events of the first data file, minimizing the change events as much as possible and promptly completing the synchronization of the first data file.

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

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

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

[0197] For the specific implementation of S610, reference can be made to the relevant description of S609 in the foregoing embodiments, and details are not elaborated here.

[0198] Based on the technical solutions corresponding to S609 and S610, in the case that no change events of the first data file or the second data file are monitored within a short period of time, it can be considered that the user's current operation on the first data file has probably ended. At this time, the file synchronization service in the mobile phone can promptly synchronize the filtered change events of the first data file, minimizing the change events as much as possible and promptly completing the synchronization of the first data file or the second data file.

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

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

[0201] In the embodiments of the present application, in order to facilitate the timing of the first preset duration, a unified timer is set for the change event set (such as the first change event set) composed of the change events that have not been synchronized for the same data file (or two related data files); or a unified timer is set for the change events corresponding to the same set identifier.

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

[0203] At this time, if the timing of the original timer continues according to the original progress, it may cause the new change events generated by the user's current operation on the first data file later to not be filtered according to the preset filtering rules, resulting in the failure to better reduce the number of change events. Therefore, in order to minimize the change events generated by the current operation on the first data file as much as possible, after each update of the first change event set, the timer corresponding to the first change event set needs to be restarted to re - perform the timing of the first preset duration. Of course, if the first change event set is empty after a certain update of the first change event set, the first change event set can be directly deleted and the corresponding timer can be cancelled.

[0204] After that, if the event filter does not receive the change event of the first data file or the second data file after the timing of the timer is completed once, the first change event set will be sent to the event reporting layer for processing, and then the first change event set stored in the cache of the event filter will be deleted, and at the same time, the timer corresponding to the first change event set will be cancelled.

[0205] The above creation of the timer can be considered as creating a delay task with a delay time of the first preset duration, restarting the timer to re - time can be considered as refreshing the delay task with a delay time of the first preset duration. Cancelling the timer can be considered as deleting the delay task.

[0206] Based on the technical solution provided by the embodiment of the present application, since the time interval between the change events generated during a certain adjustment of a data file by a user is very short, multiple change events generated continuously in a short period of time for a certain file can be considered to be generated by a single adjustment operation by the user. Based on this, in the technical solution provided by the present application, when the electronic device performs a file synchronization task, it can merge and process multiple change events generated continuously in a short period of time for the same data file (two associated files are also considered to be the same file), thereby reducing the number of change events that need to be synchronized for the data file (for example, the first data file), thereby avoiding as much as possible the defect that the file synchronization service processes the final state of the data file incorrectly due to too many change events generated by a certain adjustment operation of the user on the data file.

[0207] In some embodiments, when the event reporting layer receives the change events reported by the event filter, there are preset reporting rules, such as not receiving certain specific change events, not receiving change events of certain specific files, or directly receiving all change events. Figure 6 , refer to Figure 7 As shown, before S607 and S609, the method further includes S600:

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

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

[0210] The purpose of S600 may be that the event reporting layer sends preset reporting rules to the event filter.

[0211] In some embodiments, when the event reporting layer initially uses a monitoring tool to monitor change events in response to a file synchronization task, a time processor can be registered in the event filter. Figure 7 As shown, when there is a file synchronization task, S600 may be executed first and then S601.

[0212] On this basis, combined with Figure 6 , refer to Figure 7 As shown, S607 may specifically be S607A, and S609 may be S609A:

[0213] S607A. When the event filter does not receive a change event of the first data file or the second data file from the event reporting layer within the first preset duration, it calls the event processor to update 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.

[0214] In some embodiments, if the event reporting layer registers an event processor with the event filter by sending a preset reporting rule to the event filter, S608A may also be that when the event filter does not receive a change event of the first data file or the second data file from the event reporting layer within the first preset duration, 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. When the event filter does not receive a change event of the first data file or the second data file from the event reporting layer within the first preset duration, it calls the event processor to update 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.

[0216] In some embodiments, if the event reporting layer registers an event processor with the event filter by sending a preset reporting rule to the event filter, S608A may also be that when the event filter does not receive a change event of the first data file or the second data file from the event reporting layer within the first preset duration, 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 the filtered change events to the event reporting layer according to the preset reporting rule specified by the event reporting layer, so that the event reporting layer can receive the change events that meet the rules, and then can smoothly perform synchronous processing on the received change events, so as to complete the synchronization of the first data file on the basis of minimizing the change events as much as possible, and avoid the defect that the file synchronization service makes an error in processing the final state of the data file due to too many change events generated by a certain adjustment operation of the user on the data file.

[0218] For ease of understanding, the following assigns the same set identifier to change events corresponding to the same data file or two interrelated data files. A timer is used to time the first preset duration, and the monitoring tool is inotify on the linux platform. All change events carry (or correspond to) an event identifier (such as mask), which is binary data with a specific number of digits and only one bit being "1". Moreover, the position of the "1" in the event identifier corresponding to different types of change events is different. Taking the sum of event identifiers of change events corresponding to the same set identifier (or a set of change events composed of change events corresponding to the same set identifier) as an example, in combination with the expressions in the foregoing embodiments, refer to Figure 8 as shown, a specific implementation process of the event processing method provided in the embodiments of the present application will be introduced. Refer to Figure 8 as shown, the event processing method may specifically include the following processes:

[0219] 1. The event reporting layer monitors change events through the monitoring tool. When a current change event is monitored, the monitored event is reported to the event filter.

[0220] Among them, the current change event may be the first change event mentioned in the foregoing embodiments. The specific implementation of this step may refer to the relevant expressions of S601 - S602 in the foregoing embodiments, and the present application will not elaborate specifically on this.

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

[0222] Among them, the container may refer to the cache of the event filter, and multiple change events corresponding to data files that have not been synchronized may be stored in this cache. Change events corresponding to the same data file or two interrelated data files will be set with the same sequence number num. This sequence number num is the set identifier in the foregoing embodiments. A combination of change events corresponding to the same data file or two interrelated data files can be regarded as a set of change events, such as the first set of change events.

[0223] When step 2 is executed, when there is a target change event in the container, the sequence number num of the target event is assigned to the current change event. The target change event corresponds to the same data file or interrelated data files as the current change event. After the sequence number num of the target change event is assigned to the current change event, it can be considered that all events corresponding to this sequence number num can be merged / filtered, or it is considered that there are merge / filter events that need to be merged / filtered, and then step 4 is executed.

[0224] If the target change event doesn't exist in the container, it's assumed that the container can't obtain the sequence number num that can be assigned to the current change event. In this case, a new sequence number num is assigned to the current change event, stored in the cache, and a delayed task is created for the current change event. The delayed task can be set to 500ms. This means executing step 3. Specifically, this 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 above event filter receives the current change event reported by the event reporting layer and determines whether the target change event exists to assign a sequence number num. This can be understood as the event filter determining whether the first change event set exists after receiving the first change event. For specific implementation, please refer to the relevant descriptions of S603 and S604 in the above embodiment.

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

[0227] In some embodiments, step 3 can specifically be referred to as event reporting and waiting for processing. After executing step 3, a change event set consisting solely of the current change event is generated. Furthermore, the delay 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 corresponding to multiple change events will correspond to a delay task.

[0228] If no change event is received within 500ms for the same data file or a corresponding data file associated with the current change event, the current change event may be reported to the event reporting layer. For specific implementation, please refer to the relevant descriptions of S609 and S610 in the aforementioned embodiment. If a change event is received within 500ms for the same data file or a corresponding data file associated with the current change event, step 2 is restarted.

[0229] 4. The event filter filters / merges the change events corresponding to the same sequence number num according to the event identifier and the preset filtering rules.

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

[0231] If the current change event is a delete event or a move-out event, and there is a create event or move-in event in the change event corresponding to the same sequence number num as the current change event, the event filter will set the first change event set to empty and delete the corresponding delayed task. In other words, since there is no corresponding change event for sequence number num, the event filter will not report any change events to the event reporting layer.

[0232] In the case where the current change event is a deletion event or a removal event, if there is no creation event or addition event among the change events with the same sequence number num corresponding to the current change event, the event filter refreshes the delayed task corresponding to the sequence number num, and overwrites all the change events (or change event sets) corresponding to the sequence number num with the current change event or a deletion event.

[0233] In the case where the current change event is an addition event or a creation event, the delayed task corresponding to the sequence number num is refreshed, and all the change events (or change event sets) corresponding to the sequence number are overwritten with the current change event or a new event.

[0234] In the case where the current change event is not an addition event or a creation event or a removal event or a deletion event, if there is a change event with the same type as the current change event among the other change events with the same sequence number num corresponding to the current change event, the current change event is deleted, and the delayed task corresponding to the sequence number num is refreshed.

[0235] In the case where the current change event is not an addition event or a creation event or a removal event or a deletion event, if there is no change event with the same type as the current change event among the other change events with the same sequence number num corresponding to the current change event, the current change event is added to all the change events corresponding to the sequence number num, and the delayed task corresponding to the sequence number num is refreshed.

[0236] In a possible implementation, if the monitoring tool for monitoring change events is inotify on the linux platform, the event identifiers (such as mask) carried (or corresponding) by all the change events monitored by the monitoring tool through the event reporting layer are binary data with a specific number of bits and only one bit being "1", and the positions of "1" in the event identifiers corresponding to different types of change events are different. Among them, the value of the specific number of bits can be the same as the number of types of change events. In this case, the various types of change events in the above filtering rules can be completed based on the event identifier and masksum corresponding to the same sequence number num and the event identifiers of the various types of change events. Among them, masksum corresponds one-to-one with the sequence number num (or the change event set corresponding to the sequence number num). After performing an operation on the event identifier of a certain type of change event and the masksum corresponding to a certain sequence number num, if the result does not contain 1, it indicates that there is no change event of this type among the change events other than the current change event corresponding to the sequence number num; if the result contains 1, it indicates that there is a change event of this type among the change events other than the current change event corresponding to the sequence number num.

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

[0238] For the specific meaning of the above filtering rules, reference can be made to the relevant descriptions in (1)-(5) after S605 in the foregoing embodiments, which will not be elaborated here. For the relevant definitions and examples of the above masksum, and the specific implementation of judging the content in the above preset filtering rules based on the masksum, reference can be made to the relevant descriptions after S605 in the foregoing embodiments, which will not be elaborated here.

[0239] After steps 3 and 4, if the event filter does not receive a change event of the first data file or the second data file within the first preset time period, the current change event or all change events corresponding to the serial number num of the current change event can be reported to the event reporting layer in a timely manner.

[0240] For the relevant implementation and beneficial effects of the technical solutions provided in the above embodiments, reference can be made to the relevant content of the event processing method provided in the foregoing embodiments, which will not be elaborated here.

[0241] It can be understood that, in order to implement the above functions, the above electronic device includes corresponding hardware structures and / or software modules for executing each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed in this article, the embodiments of the present invention can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the embodiments of this application.

[0242] The embodiments of the present application can divide the above electronic device into functional modules according to the above method examples. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware or in the form of a software functional module. It should be noted that the division of modules in the embodiments of the present invention is illustrative, only a logical function division, and there may be other division methods in actual implementation.

[0243] In the case of dividing each functional module corresponding to each function, the embodiments of the present application also provide an event processing device, which can be applied to an electronic device. The device can include a monitoring module 901, a filtering module 902, and a processing module 903.

[0244] Among them, the monitoring module 901 is used to monitor the change events of data files in the target path indicated by the file synchronization task when there is a file synchronization task. The filtering module 902 is used to, when the monitoring module 901 monitors the first change event of the first data file, if there is a first change event set, filter and process 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 the change event of the first data file or the second data file that has been monitored and 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 when the monitoring module 901 does not monitor the change events of the first data file or the second data file within a first preset time period.

[0245] In addition, the cooperation of the monitoring module 901, the filtering module 902, and the processing module 903 can implement any step of the event processing method provided in the foregoing embodiments, which will not be elaborated here. Regarding the electronic device in the foregoing embodiments, the specific manners in which each module performs operations have been described in detail in the embodiments of the event processing method in the foregoing embodiments, and will not be specifically elaborated here. Its related beneficial effects can also refer to the related beneficial effects of the foregoing event processing method, which will not be elaborated here.

[0246] Regarding the event processing device in the foregoing embodiments, the specific manners in which each module performs operations have been described in detail in the embodiments of the event processing method in the foregoing embodiments, and will not be specifically elaborated here. Its related beneficial effects can also refer to the related beneficial effects of the foregoing event processing method, which will not be elaborated here.

[0247] An embodiment of the present application further provides an electronic device, which includes: a memory and one or more processors; the memory is coupled to the processor; among them, computer program code is stored in the memory, and the computer program code includes computer instructions. When the computer instructions are executed by the processor, the electronic device is caused to execute the dropped frame fault determination method provided in the foregoing embodiments. The specific structure of the electronic device can be referred to Figure 4 the structure of the electronic device shown in.

[0248] An embodiment of the present application further provides a computer-readable storage medium, which includes computer instructions. When the computer instructions run on an electronic device, the electronic device is caused to execute the event processing method provided in the foregoing embodiments.

[0249] The embodiments of the present application also provide a computer program product, which includes executable instructions. When the computer program product runs on an electronic device, the electronic device is caused to execute the event processing method provided in the foregoing embodiments.

[0250] Through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and conciseness of description, only the division of the above functional modules is used as an example. In actual applications, the above functions can be allocated to different functional modules according to needs, 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 several embodiments provided by the present application, it should be understood that the disclosed device / equipment and method can be implemented in other ways. For example, the device / equipment embodiments described above are merely illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some interfaces. The indirect coupling or communication connection of the device or unit can be in electrical, mechanical or other forms.

[0252] The unit described as a separate component may or may not be physically separated. The component displayed as a unit may be a physical unit or multiple physical units, that is, it may be located in one place, or may be distributed to multiple different places. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0253] In addition, in each embodiment of the present application, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.

[0254] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on such an understanding, the technical solution of the embodiments of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The software product is stored in a storage medium and includes several instructions for causing a device (which can be a single-chip microcomputer, a chip, etc.) or a processor to execute all or part of the steps of the methods described in the embodiments of the present application. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks, or optical discs that can store program codes.

[0255] The above content is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. An event handling method, characterized in that, Applied to an electronic device, the method includes: When there is a file synchronization task, listen for change events of data files in the target path indicated by the file synchronization task; When a first change event of a first data file is detected, if there is a first change event set, filter 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 a second data file that has been detected and not synchronized, and the second data file is a data file associated with the first data file; When no change event of the first data file or the second data file is detected within a first preset time period, synchronize the change events in the first change event set.

2. The method according to claim 1, wherein The 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 includes: When the first change event is a deletion event or a removal event, if there is a creation event or an addition event among the at least one second change event, control the first change event set to be emptied; When the first change event is a deletion event or a removal event, if there is no creation event or an addition event among the at least one second change event, control the updated first change event set to only include deletion events.

3. The method according to claim 2, wherein The 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: When the first change event is a creation event or an addition event, control the updated first change event set to only include new events or the first change event.

4. The method according to claim 2, characterized in that, The 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: When the first change event is not a deletion event or an addition event or a creation event or an addition event, if there is a change event of the same type as the first change event among the at least one second change event, control the first change event set not to change; When the first change event is not a deletion event or an addition event or a creation event or an addition event, if there is no change event of the same type as the first change event among the at least one second change event, add the first change event to the first change event set to update the first change event set.

5. The method according to claim 4, wherein When the event identifier carried by each detected change event is binary data with a specific number of digits and only one bit is 1, and the positions of 1 in the event identifiers corresponding to different types of change events are different, the method further includes: Perform an AND operation on the event identifier corresponding to the target event and the sum of the event identifiers in the first change event set. The sum of the event identifiers is the sum of the event identifiers carried by all second change events in the first change event set. The target event is a move-in event, a move-out event, a create event, or a delete 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.

6. The method according to claim 5, wherein The method further includes: Perform an AND operation on the event identifier carried by the first change event and the sum of the event identifiers in the first change event set to obtain a second AND operation result. If the second AND operation result contains 1, 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 AND operation result does not contain 1, it is determined 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 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 identifier sum of the first change event set before update and the event identifier carried by the first change event as the event identifier sum of the updated first change event set.

8. The method according to any one of claims 1 to 7, 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 is equal to the associated identifier information carried by the second change event of the second data file and is not the preset value. The file identifier information is used to represent the data file corresponding to the change event to which it belongs, and the associated identifier information is used to represent the association relationship between the change event to which it belongs and other change events.

9. The method according to claim 8, wherein The file identifier information includes a file name and a monitoring descriptor WD. The associated identifier information includes cookies, and the preset value is 0.

10. An electronic device, characterized in that, Includes: A memory and one or more processors; the memory is coupled to the processor. Among them, computer program code is stored in the memory, and the computer program code includes computer instructions. When the computer instructions are executed by the processor, the electronic device is caused to execute the event processing method according to any one of claims 1-8.

11. A computer-readable storage medium, characterized in that, Includes computer instructions. When the computer instructions run on an electronic device, the electronic device is caused to execute the event processing method according to any one of claims 1-8.

Citation Information

Patent Citations

  • File synchronization method and device

    CN101763421A

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

    CN109992087A

  • Service collaboration method, electronic equipment, readable storage medium and chip system

    CN116528337A

  • Condition triggering task configuration method and device

    CN117648043A

  • Cross-platform game data synchronization system

    CN118041933A