A resource cleaning method and an electronic device

By registering a cleanup service in cross-device service calls and using IBinder objects and Binder IDs, the problem of untimely client resource cleanup after the server exits is solved, achieving timely resource cleanup and ease of operation.

CN118945210BActive Publication Date: 2026-03-20HONOR DEVICE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-12
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

During cross-device service calls, the client cannot clean up resources in a timely manner after the server exits, resulting in resource redundancy.

Method used

By registering a cleanup service between the first and second electronic devices, cross-device resource cleanup is performed using IBinder objects and Binder IDs, ensuring timely resource cleanup when the service exits.

Benefits of technology

It enables cross-device resource cleanup, avoids resource redundancy, and improves the ease and efficiency of user operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118945210B_ABST
    Figure CN118945210B_ABST
Patent Text Reader

Abstract

The application provides a resource cleaning method and an electronic device, relates to the field of electronic devices, and is applied to a first electronic device. The method comprises the following steps: the first electronic device registers a cleaning service for a target service of a second electronic device; wherein the cleaning service is used for triggering the first electronic device to clean up the calling resources of the target service and the cleaning service; the calling resources comprise resources used by the first electronic device when calling the corresponding service; the first electronic device sends a registration indication of the cleaning service to the second electronic device based on a first IBinder object of the cleaning service; wherein the registration indication is used for instructing the second electronic device to register the cleaning service of the target service; and the first electronic device executes the cleaning service based on the first IBinder object in response to receiving a first cleaning calling request from the second electronic device; wherein the first cleaning request is sent by the second electronic device in response to the exit of the target service. The method can clean up the resources of the two devices in time, and avoids resource redundancy.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of electronic devices, and in particular to a resource cleaning method and an electronic device. BACKGROUND

[0002] Currently, in the process of cross-device service calling, such as in the process of calling a service of a server by a client, the application of the server may exit.

[0003] If the client cannot learn about the situation in time after the service of the server exits, the resources for service calling of the client cannot be cleaned in time, resulting in resource redundancy. SUMMARY

[0004] Embodiments of the present application provide a resource cleaning method and an electronic device, which can clean resources of both ends in time in the process of cross-device service calling when the called service exits, so as to avoid resource redundancy.

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

[0006] In a first aspect, a resource cleaning method is provided, which can be applied to a first electronic device. The method comprises: the first electronic device registers a cleaning service for a target service of a second electronic device; wherein the cleaning service is used to trigger the first electronic device to clean calling resources of the target service and the cleaning service; the calling resources include resources used by the first electronic device when calling the corresponding service; the first electronic device sends a registration indication of the cleaning service to the second electronic device based on a first IBinder object of the cleaning service; wherein the registration indication is used to instruct the second electronic device to register the cleaning service of the target service; and the first electronic device executes the cleaning service based on the first IBinder object in response to receiving a first cleaning calling request from the second electronic device; wherein the first cleaning request is sent by the second electronic device in response to the exit of the target service.

[0007] Through the scheme, the first electronic device can receive the message of service exit of the second electronic device in time, and can clean the stored resources in time, so as to avoid resource redundancy in the first electronic device.

[0008] In a possible implementation, before the first electronic device registers the cleaning service for the target service of the second electronic device, the method further includes: displaying, by the first electronic device, a display interface of a first application, the display interface of the first application including a plurality of device controls, each device control corresponding to a device that has established a preset wireless connection with the first electronic device, and each device control including one or more services provided by the corresponding device; and receiving, by the first electronic device, a first touch operation of a user on a target device control in the plurality of device controls, the first touch operation corresponding to the target service of the second electronic device.

[0009] In response to the first touch operation, the first electronic device obtains a first Binder ID corresponding to the target service from the second electronic device, and creates a second IBinder object based on the first Binder ID; wherein the first Binder ID is determined by the second electronic device when registering the target service according to a third IBinder object of the target service, and the second IBinder object and the third IBinder object are used to call the target service.

[0010] In a possible implementation, the first electronic device sends a registration indication of the cleaning service to the second electronic device based on the first IBinder object of the cleaning service, including: obtaining, by the first electronic device, the first IBinder object of the cleaning service based on the second IBinder object; creating, by the first electronic device, a corresponding second Binder ID based on the first IBinder object, and sending the second Binder ID to the second electronic device; wherein the registration indication of the first cleaning service includes the second Binder ID.

[0011] In a possible implementation, in response to receiving the first cleaning call request from the second electronic device, the first electronic device executes the cleaning service based on the first IBinder object, including: in response to receiving the first cleaning call request, the first electronic device finds the corresponding first IBinder object according to the second Binder ID contained in the first cleaning call request; and the first electronic device executes the cleaning service based on the first IBinder object.

[0012] In a possible implementation, before the first electronic device responds to the first cleaning request from the second electronic device, the method further includes: receiving, by the first electronic device, a registration message from the second electronic device; wherein the registration message is used to indicate that the second electronic device has completed the registration of the cleaning service.

[0013] In a possible implementation, the calling resource includes a service name of the target service, the second IBinder object, the first Binder ID, and the first IBinder object of the cleaning service and the second Binder ID.

[0014] In a possible implementation, the first electronic device obtains the first IBinder object of the cleaning service based on the second IBinder object, including that the first application of the first electronic device obtains the first IBinder object of the cleaning service based on the second IBinder object.

[0015] In a possible implementation, the first electronic device creates the corresponding second Binder ID based on the first IBinder object, and sends the second Binder ID to the second electronic device, including that the first application sends the first IBinder object to the distributed Binder management module of the first electronic device; the distributed Binder management module creates the corresponding second Binder ID based on the first IBinder object, and sends the second Binder ID to the second electronic device through the communication module of the first electronic device.

[0016] In a possible implementation, the first electronic device finds the corresponding first IBinder object according to the second Binder ID contained in the first cleaning call request in response to receiving the first cleaning call request, including that the distributed Binder management module of the first electronic device receives the first cleaning call request through the communication module of the first electronic device, and finds the corresponding first IBinder object according to the second Binder ID contained in the first cleaning call request.

[0017] In a possible implementation, the first electronic device executes the cleaning service based on the first IBinder object, including that the distributed Binder management module invokes the cleaning service based on the first IBinder object, and cleans the calling resources of the target service stored in the distributed Binder management module; the distributed Binder management module sends a cleaning notification to the first application; and the first application cleans the calling resources of the target service and the cleaning service stored in the first application in response to the cleaning notification.

[0018] In a second aspect, a resource cleaning method is provided, applied to a second electronic device, including:

[0019] The second electronic device receives a registration indication from the first electronic device; the registration indication is used to indicate that the second electronic device registers a cleaning service of a target service; the cleaning service is used to trigger the second electronic device to clean calling resources of the target service and the cleaning service; the calling resources include resources used when the first electronic device calls the corresponding service; the second electronic device obtains a fourth IBinder object of the cleaning service; and the second electronic device executes the cleaning service based on the fourth IBinder object in response to an exit of the target service.

[0020] In a possible implementation, the method further includes: in response to the exit of the target service, the second electronic device sends a first clean-up call request to the first electronic device based on the fourth IBinder object; and the first clean-up call request is used to instruct the first electronic device to clean up the calling resource of the target service and the clean-up service.

[0021] In a possible implementation, before the second electronic device receives the registration indication from the first electronic device, the method further includes: the second electronic device receives an acquisition instruction from the first electronic device, and finds the first Binder ID of the target service based on the acquisition instruction; the first Binder ID is determined by the second electronic device when registering the target service according to a third IBinder object of the target service, and the third IBinder object is used to call the target service; and the second electronic device sends the first Binder ID to the first electronic device.

[0022] In a possible implementation, the second electronic device acquires the fourth IBinder object of the clean-up service, including: the second electronic device receives the second Binder ID from the first electronic device, and creates the fourth IBinder object based on the second Binder ID; the second Binder ID is created by the first electronic device based on a first IBinder object of the clean-up service, and the first IBinder object is used to call the clean-up service.

[0023] In a possible implementation, after the second electronic device acquires the fourth IBinder object of the clean-up service, the method further includes: the second electronic device sends a registration message to the first electronic device; and the registration message is used to indicate that the second electronic device has completed the registration of the clean-up service.

[0024] In a possible implementation, in response to the exit of the target service, the second electronic device sends a first clean-up call request to the first electronic device based on the fourth IBinder object, including: in response to the exit of the target service, the second electronic device sends a first clean-up call request to the first electronic device based on the fourth IBinder object; and the second Binder ID is contained in the first clean-up call request.

[0025] In a possible implementation, the second electronic device receives the second Binder ID from the first electronic device, and creates the fourth IBinder object based on the second Binder ID, including: a distributed Binder management module of the second electronic device receives the second Binder ID from the first electronic device through a communication module of the second electronic device, and creates the fourth IBinder object based on the second Binder ID.

[0026] In a possible implementation, the second electronic device sends a first cleanup call request to the first electronic device in response to the exit of the target service and based on the fourth IBinder object, including: the distributed Binder management module of the electronic device sends a first cleanup call request to the first electronic device through the communication module of the second electronic device in response to the exit of the target service and based on the fourth IBinder object; and the first cleanup call request contains the second Binder ID.

[0027] In a possible implementation, the second electronic device executes a cleanup service in response to the exit of the target service and based on the fourth IBinder object, including: the distributed Binder management module of the second electronic device calls the cleanup service in response to the exit of the target service and based on the fourth IBinder object, to clean up the calling resources of the target service stored in the distributed Binder management module.

[0028] It can be understood that the second electronic device can clean up the calling resources of the cleanup service after cleaning up the calling resources of the target service. In summary, the first electronic device and the second electronic device can clean up the locally stored resources to avoid resource redundancy.

[0029] Optionally, a cross-device service calling method can also be provided, which can be applied to the first electronic device. The method includes: the first electronic device displays a display interface of a first application, the display interface of the first application including a plurality of device controls, each device control corresponding to a device that establishes a preset wireless connection with the first electronic device, and each device control including one or more services provided by the corresponding device; the first electronic device receives a first touch operation of a user on a target device control in the plurality of device controls, the first touch operation corresponding to a distributed application management service of a second electronic device; the first electronic device obtains a first Binder identification ID corresponding to the distributed application management service from the second electronic device, and creates a second IBinder object based on the first Binder ID; the first Binder ID is determined by the second electronic device when registering the distributed application management service according to a first IBinder object of the distributed application management service, and the first IBinder object and the second IBinder object are used to call the distributed application management service.

[0030] The first electronic device, in response to receiving the first request from the second electronic device, finds the corresponding second IBinder object according to the first Binder ID contained in the first request, and indicates the first file providing object of the first application to the second electronic device based on the second IBinder object; wherein the first request is used to request to obtain the first file providing object, the first request is sent by the second electronic device in response to a second touch operation of a second application by a user, the second touch operation is used to confirm a result of the second electronic device executing the distributed application management service on the second application, and the first file providing object is used to support the second electronic device returning the result of executing the distributed application management service to the first electronic device;

[0031] The first electronic device, in response to receiving the second request from the second electronic device, indicates the first file handle object to the second electronic device based on the first file providing object; wherein the second request is generated by the second electronic device based on the first file providing object, and is used to request to obtain the first file handle object for calling the preset cache file of the first application; and the first electronic device receives the result of executing the distributed application management service returned by the second electronic device based on the first file handle object.

[0032] By adopting the technical scheme, the user can realize sending a shooting instruction to the second electronic device using the first electronic device, the second electronic device calls up the camera to execute the shooting or scanning task after receiving the shooting instruction, and then returns the shooting result or the scanned text to the first electronic device. The step of uploading the shooting result or the scanned text to the second electronic device, then downloading and saving it to the second electronic device, and then uploading it to the corresponding position of the second electronic device can be saved, the operation is more convenient, and the working efficiency of the user is improved.

[0033] Optionally, a cross-device service calling method can also be provided, and the method is applied to a second electronic device and includes: the second electronic device, in response to a second touch operation of a user on a second application of the second electronic device, sends a first request to a first electronic device based on a first Binder ID of a distributed application management service; the first request is used to request a first file providing object of a first application of the first electronic device, and the first Binder ID is determined by the second electronic device according to a first IBinder object of the distributed application management service when the second electronic device registers the distributed application management service, the first IBinder object is used to call the distributed application management service, the second touch operation is used to confirm a result of the second electronic device executing the distributed application management service on the second application, and the first file providing object is used to support the second electronic device returning the result of executing the distributed application management service to the first electronic device; the second electronic device receives the first file providing object indicated by the first electronic device, and sends a second request to the first electronic device based on the first file providing object; the second request is used to request a first file handle object used to call a preset cache file of the first application; the second electronic device receives the first file handle object indicated by the first electronic device, and returns the result of executing the distributed application management service to the first electronic device based on the first file handle object.

[0034] By adopting the technical scheme, the user can use the first electronic device to send a shooting instruction to the second electronic device, the second electronic device calls up the camera to execute the shooting or scanning task after receiving the shooting instruction, and then returns the shooting result or the scanned text to the first electronic device directly. The user can save the step of uploading the shooting result or the scanned text to the second electronic device, then downloading and saving the shooting result or the scanned text to the second electronic device, and then uploading the shooting result or the scanned text to the corresponding position of the second electronic device, and the operation is more convenient, and the working efficiency of the user is improved.

[0035] In a possible implementation, the first electronic device, in response to receiving the first request from the second electronic device, finds a corresponding second IBinder object according to the first Binder ID contained in the first request, and indicates the first file providing object of the first application to the second electronic device based on the second IBinder object, including: the first electronic device, in response to receiving the first request from the second electronic device, finds a corresponding second IBinder object according to the first Binder ID contained in the first request; the first electronic device obtains the first file providing object of the first application based on the second IBinder object, and creates a corresponding second Binder ID based on the first file providing object; and the first electronic device sends the second Binder ID to the second electronic device.

[0036] In a possible implementation, the first electronic device indicates the first file handle object to the second electronic device based on the first file providing object in response to receiving the second request from the second electronic device, including: the first electronic device looks up the corresponding first file providing object according to the second Binder ID contained in the second request in response to receiving the second request from the second electronic device; the first electronic device acquires the first file handle object based on the first file providing object, and creates the first distributed file based on the first file handle; and the first electronic device sends the name of the first distributed file to the second electronic device.

[0037] In a possible implementation, the first electronic device acquires the first Binder ID corresponding to the distributed application management service from the second electronic device, and creates the second IBinder object based on the first Binder ID, including: the first application acquires the service name of the distributed application management service, and sends an acquisition instruction to the distributed service management module of the first electronic device; the acquisition instruction includes the service name, and is used to acquire the first Binder ID corresponding to the distributed application management service; the distributed service management module sends the acquisition instruction to the second electronic device through the preset wireless connection by using the communication module of the first electronic device in response to the acquisition instruction; the communication module receives the first Binder ID from the second electronic device through the preset wireless connection, and sends the first Binder ID to the distributed service management module; the distributed service management module sends the first Binder ID to the distributed Binder management module of the first electronic device; and the distributed Binder management module creates the second IBinder object based on the first Binder ID.

[0038] Optionally, a cross-device service calling method can also be provided, and the method is applied to a first electronic device and includes: the first electronic device displays a display interface of a first application, the display interface of the first application includes a plurality of device controls, each device control corresponds to a device that establishes a preset wireless connection with the first electronic device, and each device control includes one or more services provided by the corresponding device; the first electronic device receives a first touch operation of a user on a target device control in the plurality of device controls, the first touch operation corresponds to a target service of a second electronic device; the first electronic device obtains a first Binder identifier ID corresponding to the target service from the second electronic device, and creates a second IBinder object based on the first Binder identifier ID; the first Binder identifier ID is determined by the second electronic device when registering the target service according to a first IBinder object of the target service, and the first IBinder object and the second IBinder object are used to call the target service; the first electronic device sends a calling request to the second electronic device based on the second IBinder object; the calling request includes the first Binder identifier ID of the second IBinder object, and the calling request is used to request to call the target service of a second application in the second electronic device; and the first electronic device receives a calling response from the second electronic device, and the calling response includes a result of calling the target service by the first electronic device.

[0039] By using the technical solution, after the first electronic device receives the BinderId of the IBinder object corresponding to the service of the second electronic device, the first electronic device can create the local IBinder object corresponding to the BinderId, and then call the service of the second electronic device through the local IBinder object, thereby realizing cross-device service calling.

[0040] Optionally, another cross-device service calling method can also be provided, and the method is applied to a second electronic device and includes: the second electronic device receives a calling request from a first electronic device; the calling request includes a first Binder identifier ID of a second IBinder object, and the calling request is used to request to call a target service of a second application in the second electronic device; the second electronic device responds to the calling request, and finds a first IBinder object created for the target service when the second electronic device registers the target service according to the first Binder ID of the second IBinder object; the second electronic device calls the target service based on the first IBinder object, and feeds back a calling response to the first electronic device, and the calling response includes a result of calling the target service.

[0041] In the above cross-device service calling process, cross-device data transmission is also involved.

[0042] Optionally, a cross-device data processing method can also be provided, which can be applied to the first electronic device. The method comprises: the first electronic device acquires a first IBinder object, and creates a corresponding Binder identifier ID based on the first IBinder object; wherein the first IBinder object is used to call a target service of the first electronic device; the first electronic device sends the Binder ID to the second electronic device, so that the second electronic device creates a corresponding second IBinder object based on the Binder ID, and the second IBinder object is used for the second electronic device to call the target service.

[0043] Through the scheme, when the parcel package contains a complex object such as a Binder object, the Binder object in the parcel package is replaced and then serialized, so that the two devices can access each other.

[0044] Optionally, another cross-device data processing method can also be provided, which is applied to the second electronic device, and the method comprises: the second electronic device receives the Binder identifier ID sent by the first electronic device; wherein the Binder ID is created by the first electronic device based on the first IBinder object, the first IBinder object is acquired by the first electronic device, and is used to call the target service of the first electronic device; the second electronic device creates a corresponding second IBinder object based on the Binder ID; wherein the second IBinder object is used to call the target service.

[0045] In summary, in the scenario of cross-device transmission of the Parcel package, if the Parcel package contains a Binder object, the Binder object is replaced by a corresponding BinderId, and then serialized and transmitted. That is, the local resource (Binder object) is replaced by the cross-device resource (BinderId) for serialization and transmission. After receiving the serialized parcel package at the other end, the BinderId is obtained by deserialization, and the BinderId is replaced by the locally created Binder object, so that the cross-device transmission of the Parcel package containing the Binder object can be realized.

[0046] For example, in the process of the camera application of the second electronic device obtaining the FileProvider object of the note application of the first electronic device, the first electronic device allocates a corresponding BinderId for the File Provider object (IFile Pc object). Before serialization, the first electronic device can replace the IFile Pc object in the data packet 1 (parcel packet) with the corresponding BinderId to obtain the data packet 2. Then, the data packet 2 is subjected to serialization processing to obtain serialized data (parcel byte stream), which is then transmitted to the second electronic device through the network.

[0047] After receiving the serialized data (parcel byte stream), the second electronic device deserializes the serialized data to obtain the data packet 2. The second electronic device parses the data packet 2 to obtain the BinderId. Then, the second electronic device creates a reference object IFile Ps object corresponding to the BinderId locally, and writes the IFile Ps object into the data packet 2 to obtain the data packet 3. In this way, the cross-device transmission of the Parcel packet containing the Binder object (File Provider object) is realized.

[0048] Optionally, another cross-device data processing method can also be provided, which can be applied to the first electronic device. The method comprises: the first electronic device calling a target service of the second electronic device; the first electronic device obtaining a first file handle object of a preset file, and creating a first distributed file based on the first file handle object; wherein the preset file is used to save preset data, and the preset data is a result of the second electronic device executing the target service; the first distributed file and a second distributed file in the second electronic device are used to support data access between the first electronic device and the second electronic device, and the first file handle object is used for the first electronic device to return the preset data in the first distributed file to the preset file;

[0049] The first electronic device sends a file name of the first distributed file to the second electronic device, so that the second electronic device opens a corresponding second distributed file based on the file name, and the second distributed file is used to obtain the preset data; the first distributed file of the first electronic device receives the preset data transmitted by the second distributed file of the second electronic device; and the first electronic device returns the preset data in the first distributed file to the preset file through the first file handle object.

[0050] Through the scheme, when transmitting complex objects such as file handle objects, the file handle object can be replaced and then transmitted, so that the two devices can access each other.

[0051] Thus, in the scenario of cross-device transmission of a Parcel package (transmission data package), if the Parcel package contains a file handle object, the file handle object is replaced by the name of the corresponding distributed file, and then serialization processing and transmission are performed. That is, the local resource (file handle object) is replaced by the cross-device resource (name of the distributed file) for serialization processing and transmission. After receiving the serialized Parcel package at the other end, deserialization processing is performed to obtain the name of the distributed file. Then, the corresponding distributed file is opened according to the name of the distributed file to obtain the file handle object of the locally created distributed file. Thus, cross-device transmission of a Parcel package containing a file handle object can be achieved.

[0052] For example, in the process of obtaining the file handle of the photo cache file of the note application of the first electronic device by the camera application of the second electronic device, the first electronic device creates a corresponding first distributed file for the file handle object. Before serialization, the first electronic device can replace the file handle object in the data packet 1 (Parcel package) with the name of the corresponding first distributed file to obtain a data packet 2. Then, the data packet 2 is subjected to serialization processing to obtain serialized data (Parcel byte stream), which is then transmitted to the second electronic device through the network.

[0053] After receiving the serialized data (Parcel byte stream), the second electronic device performs deserialization to obtain the data packet 2. The second electronic device parses the data packet 2 to obtain the name of the distributed file. Then, the second electronic device opens the corresponding second distributed file according to the name of the distributed file to obtain the file handle object of the second distributed file. The photo data obtained by the camera application is written to the second distributed file through the file handle object, and the second distributed file transmits the photo data to the first distributed file. The first distributed file returns the photo data to the photo cache file. Thus, cross-device transmission of a Parcel package containing a file handle is achieved, and the result of cross-device backhaul execution service is achieved.

[0054] In a third aspect, the present application provides an electronic device, comprising: a communication module, a display screen, a memory and one or more processors; the communication module, the display screen, the memory and the processor are coupled; the memory is used to store computer program code, the computer program code comprises computer instructions, when the computer instructions are executed by the electronic device, the electronic device executes the method of the first aspect to the second aspect.

[0055] In a fourth aspect, the present application provides a computer readable storage medium, having stored therein instructions which, when executed on a computer, cause the computer to perform the method of any one of the first aspect to the second aspect.

[0056] In a fifth aspect, the present application provides a computer program product having instructions which, when executed on a computer, cause the computer to perform the method of any one of the first aspect to the second aspect.

[0057] In a sixth aspect, the present application provides a computer program product having instructions which, when executed on a computer, cause the computer to perform the method of any one of the first aspect to the second aspect.

[0058] It can be understood that the electronic device of the third aspect, the computer readable storage medium of the fourth aspect, the computer program product of the fifth aspect and the chip of the sixth aspect are all used to perform the corresponding method provided above, and thus the beneficial effects achieved thereby can refer to the beneficial effects of the corresponding method provided above, which will not be described here again. BRIEF DESCRIPTION OF DRAWINGS

[0059] Figure 1 A scene schematic diagram of inserting board content of offline classroom for an embodiment of the present application;

[0060] Figure 2 A hardware structure schematic diagram of an electronic device for an embodiment of the present application;

[0061] Figure 3 A software structure schematic diagram of an electronic device for an embodiment of the present application;

[0062] Figure 4 A timing diagram of registering a service and obtaining a service for an embodiment of the present application;

[0063] Figure 5 An interface display schematic diagram of a note application for an embodiment of the present application;

[0064] Figure 6 An interface display schematic diagram of another note application for an embodiment of the present application;

[0065] Figure 7 An interface display schematic diagram of another note application for an embodiment of the present application;

[0066] Figure 8 A timing diagram of calling a service interface for an embodiment of the present application;

[0067] Figure 9A schematic diagram of a cross-device service calling method provided for an embodiment of the present application;

[0068] Figure 10 A timing diagram of registering a distributed application management service and obtaining a service provided for an embodiment of the present application;

[0069] Figure 11 A schematic diagram of a first electronic device starting a camera of a second electronic device provided for an embodiment of the present application;

[0070] Figure 12 A timing diagram of obtaining a File Provider object of a note provided for an embodiment of the present application;

[0071] Figure 13 A timing diagram of obtaining a file handle of a note provided for an embodiment of the present application;

[0072] Figure 14 A schematic diagram of a cross-device calling scenario provided for an embodiment of the present application;

[0073] Figure 15 A data structure schematic diagram of a parcel provided for an embodiment of the present application;

[0074] Figure 16 A schematic diagram of a cross-device data transmission method provided for an embodiment of the present application;

[0075] Figure 17 A schematic diagram of another cross-device data transmission method provided for an embodiment of the present application;

[0076] Figure 18 A schematic diagram of another cross-device data transmission method provided for an embodiment of the present application;

[0077] Figure 19 A schematic diagram of another cross-device data transmission method provided for an embodiment of the present application;

[0078] Figure 20 A flowchart of another cross-device data transmission method provided for an embodiment of the present application;

[0079] Figure 21 A flowchart of a cross-device resource cleaning method provided for an embodiment of the present application;

[0080] Figure 22 A timing diagram of a cross-device service calling resource cleaning method provided for an embodiment of the present application;

[0081] Figure 23 A structural schematic diagram of a chip system provided for an embodiment of the present application. DETAILED DESCRIPTION

[0082] The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0083] The terms "first", "second", and the like are used only for the purpose of description, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined with "first", "second", and the like can explicitly or implicitly include one or more of the features. In the description of the embodiments, unless otherwise specified, the meaning of "a plurality of" is two or more. In the present application, the character " / " generally represents an "or" relationship between the front and rear associated objects. For example, A / B can be understood as A or B.

[0084] In addition, the terms "include" and "have" and any variations thereof mentioned in the description of the present application are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or modules is not limited to the listed steps or modules, but can optionally include other steps or modules not listed, or can optionally include other steps or modules inherent to the process, method, product or device.

[0085] In addition, in the embodiments of the present application, the words "exemplary" or "for example" are used to mean serving as an example, instance, or illustration. Any embodiment or design solution described as "exemplary" or "for example" in the present application should not be interpreted as being more preferred or advantageous than other embodiments or design solutions. Rather, the use of "exemplary" or "for example" is intended to present concepts in a concrete manner.

[0086] For ease of understanding, the terms related to the embodiments of the present application are introduced here:

[0087] (1) Binder: from Android TM Binder is a medium for communication between a client and a server in the application layer. The server returns a Binder object containing a service call of the server. Through the Binder object, the client can obtain the services or data provided by the server.

[0088] The Binder mechanism supports both in-process and inter-process calls. Android remote calls (i.e., cross-process calls) can be implemented through IBinder. IBinder is a basic interface used for remote calls. The main API of IBinder is transact(), and the corresponding method is Binder.onTransact(). The first method enables the local end to send a call to the remote IBinder object, and the second method enables the remote object of the local end to respond to the received call.

[0089] (2) Parcel: Parcel is a container for messages, and is used for data transmission through the Binder mechanism. It can carry serialized data through IPC transmission and then deserialize it at the destination. Parcel can also pass IBinder objects, and the destination will accept the transmitted IBinder object proxy.

[0090] Currently, for the sake of learning convenience, users usually use a tablet (Pad) or a personal computer (PC) to record and organize notes. Therefore, the user needs to obtain the content of the blackboard in the offline classroom and insert it into the notes of the tablet or personal computer. Alternatively, when the user organizes the ideas of a thesis on a tablet or a personal computer, he or she often needs to obtain the content of the textbook and insert it into the tablet or personal computer.

[0091] However, since there is no rear camera on the personal computer, the user usually takes pictures or scans the content of the blackboard in the offline classroom or the content of the textbook through the mobile phone, uploads them to the personal computer, then downloads and saves them to the personal computer, and finally uploads them to the corresponding position of the notes. The user's operation is relatively complex, and the user needs to switch between multiple devices and perform data transmission.

[0092] Alternatively, the user can take pictures of the blackboard content through the tablet, but the tablet is relatively bulky. At the same time, due to the limitations of device parameters, students in the back row (too far away) and students in the front row (too close to the blackboard, and need to use a wide-angle function to take pictures of the overall appearance of the blackboard content) may not be able to take pictures of the blackboard that meet the user's needs.

[0093] Therefore, the present application provides a cross-device service calling method, which enables the user to use a first electronic device (such as a tablet or a personal computer) to send a shooting instruction to a second electronic device (such as a mobile phone). The mobile phone receives the shooting instruction and invokes the camera to perform the shooting or scanning task, and then returns the shooting result or the scanned text to the tablet or the personal computer.

[0094] As Figure 1As shown, the master device can include a tablet and a personal computer, and the auxiliary device can include a mobile phone. The note application of the master device sends a shooting instruction or a scanning instruction to the auxiliary device in response to the operation of the user. After receiving the shooting instruction or the scanning instruction, the auxiliary device invokes the camera to perform a shooting task or a scanning task. After the shooting or scanning is completed, the auxiliary device returns the shooting result (a photo) or the scanning result (extracted text) to the note application of the master device.

[0095] Compared with the existing method, the remote call between the devices is used to realize different functions on the multiple devices, so as to reduce the switching between the multiple devices when the multiple functions are implemented. For example, the step of uploading the shooting result or the scanned text to the personal computer, then downloading and saving the shooting result or the scanned text to the personal computer, and then uploading the shooting result or the scanned text to the corresponding position of the personal computer can be saved, the operation is more convenient, and the work efficiency of the user is improved. Moreover, the shooting operation is performed by using the mobile phone, and a photo of the board content that meets the demand of the user can be shot.

[0096] For example, the electronic device in the embodiment of the present application can be a tablet computer, a mobile phone, a desktop computer, a laptop computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) \ virtual reality (VR) device, a vehicle-mounted device, and the like. The specific form of the electronic device is not specially limited in the embodiment of the present application.

[0097] In the embodiment of the present application, the electronic device can be divided into a private device and a public device. It can be understood that the private device is used to indicate a device that can be used only by the owner (i.e., the owner of the device). For example, the private device can be a mobile phone, a smart watch, smart glasses, a headset, and the like. The public device is used to indicate a device that can be used by any user. That is, there can be multiple accounts logged in the public device, and the multiple different accounts are associated with each other. For example, the public device can be a television, a sound box, a tablet computer, and the like.

[0098] The execution subject of the cross-device service calling method provided in the present application can be a cross-device service calling device, and the execution device can be Figure 2The electronic device shown. Meanwhile, the execution device can also be a central processing unit (CPU) of the electronic device, or a control module in the electronic device for cross-device service calling. In the embodiment of the application, the cross-device service calling method executed by the electronic device is taken as an example to illustrate the cross-device service calling method provided by the embodiment of the application.

[0099] The implementation of the embodiment of the application will be described in detail below with reference to the drawings. The above electronic device is taken as a mobile phone as an example to introduce the hardware structure of the electronic device (such as the electronic device 300). Among them, Figure 2 The electronic device 300 shown is only an example of the electronic device, and the electronic device 300 can have more or fewer components than those shown in the figure, can combine two or more components, or can have a different component configuration. Figure 2 The various components shown in the figure can be implemented in hardware, software, or a combination of hardware and software including one or more signal processing and / or application specific integrated circuits.

[0100] Please refer to Figure 2 , Figure 2 The structure of the electronic device is shown in the schematic diagram, such as Figure 2 As shown in the figure, the electronic device 300 can include a processor 310, an external memory interface 320, an internal memory 321, a USB interface 330, a charge management module 340, a power management module 341, a battery 342, an antenna 1, an antenna 2, a mobile communication module 350, a wireless communication module 360, an audio module 370, a speaker 370A, a receiver 370B, a microphone, a headset interface, a sensor module 380, a key 390, a motor 391, an indicator 392, a camera 393, a display screen 394, and a subscriber identification module (SIM) card interface 395, etc.

[0101] Among them, the above-mentioned sensor module 380 can include pressure sensor, gyroscope sensor, barometric pressure sensor, magnetic sensor, acceleration sensor, distance sensor, proximity light sensor, fingerprint sensor, temperature sensor, touch sensor, ambient light sensor and bone conduction sensor, etc.

[0102] It can be understood that the structure shown in the embodiment does not constitute a specific limitation on the electronic device 300. In other embodiments, the electronic device 300 can include more or fewer components than the figure, or combine certain components, or split certain components, or different component arrangement. The components shown can be implemented in hardware, software or a combination of software and hardware.

[0103] The processor 310 can include one or more processing units, for example: the processor 310 can 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. Different processing units can be independent devices or integrated in one or more processors.

[0104] The controller can be the nerve center and command center of the electronic device 300. The controller can generate operation control signals according to instruction operation codes and timing signals, and complete the control of fetching and executing instructions.

[0105] The memory can also be provided in the processor 310, for storing instructions and data. In some embodiments, the memory in the processor 310 is a cache memory. The memory can save instructions or data that have just been used or are frequently used by the processor 310. If the processor 310 needs to use the instructions or data again, it can directly call from the memory. This avoids repeated access and reduces the waiting time of the processor 310, thereby improving the efficiency of the system.

[0106] In some embodiments, the processor 310 can include one or more interfaces. The interfaces can 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.

[0107] It can be understood that the interface connection relationship between the modules shown in the embodiments is only illustrative and does not constitute a limitation on the structure of the electronic device 300. In other embodiments, the electronic device 300 can also use different interface connection modes or combinations of multiple interface connection modes.

[0108] The charging management module 340 is configured to receive charging input from a charger. In the embodiments of the present application, the charger is a wired charger, and the charging management module 340 can receive the charging input of the wired charger through the USB interface 330 (i.e., the charging interface described above). The charging management module 340 can charge the battery 342 and also supply power to the electronic device through the power management module 341.

[0109] The power management module 341 is configured to connect the battery 342 and the charging management module 340 to the processor 310. The power management module 341 receives input from the battery 342 and / or the charging management module 340 to supply power to the processor 310, the internal memory 321, the external memory, the display screen 394, the camera 393, and the wireless communication module 360, etc. The power management module 341 can also be configured to monitor parameters such as battery capacity, battery cycle count, battery health status (leakage, impedance), etc. In other embodiments, the power management module 341 can also be arranged in the processor 310. In other embodiments, the power management module 341 and the charging management module 340 can also be arranged in the same device.

[0110] The wireless communication function of the electronic device 300 can be realized through the antenna 1, the antenna 2, the mobile communication module 350, the wireless communication module 360, the modem processor, and the baseband processor, etc.

[0111] The antenna 1 and the antenna 2 are configured to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 300 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. For example, the antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In other embodiments, the antenna can be used in combination with a tuning switch.

[0112] The mobile communication module 350 can provide a solution for wireless communication including 2G / 3G / 4G / 5G, etc. applied to the electronic device 300. The mobile communication module 350 can include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 350 can receive electromagnetic waves from the antenna 1 and perform filtering, amplification, etc. on the received electromagnetic waves and transmit them to the modem processor for demodulation.

[0113] The mobile communication module 350 can also amplify the signal modulated by the modem processor and convert it into electromagnetic wave radiation through the antenna 1. In some embodiments, at least part of the functions of the mobile communication module 350 can be arranged in the processor 310. In some embodiments, at least part of the functions of the mobile communication module 350 can be arranged in the same device as at least part of the modules of the processor 310.

[0114] The wireless communication module 360 can provide a wireless communication solution applied to the electronic device 300, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) network), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (IR), etc. For example, in the embodiments of the present application, the electronic device 300 can access the Wi-Fi network through the wireless communication module 360.

[0115] The wireless communication module 360 can be one or more devices integrating at least one communication processing module. The wireless communication module 360 receives electromagnetic waves via the antenna 2, performs frequency modulation and filtering processing on the electromagnetic wave signal, and sends the processed signal to the processor 310. The wireless communication module 360 can also receive signals to be sent from the processor 310, perform frequency modulation and amplification, and convert them into electromagnetic wave radiation through the antenna 2.

[0116] In some embodiments, the antenna 1 and the mobile communication module 350 of the electronic device 300 are coupled, and the antenna 2 and the wireless communication module 360 are coupled, so that the electronic device 300 can communicate with a network and other devices through wireless communication technology. The wireless communication technology can 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 (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. The GNSS can include a global positioning system (GPS), a global navigation satellite system (GLONASS), a beidu navigation satellite system (BDS), a quasi-zenith satellite system (QZSS), and / or a satellite based augmentation systems (SBAS).

[0117] The electronic device 300 implements a display function through a GPU, a display screen 394, and an application processor, etc. The GPU is a microprocessor for image processing, which is connected to the display screen 394 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 310 can include one or more GPUs, which execute program instructions to generate or change display information.

[0118] The display screen 394 is configured to display images, videos, etc. The display screen 394 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flex light-emitting diode (FLED), a Miniled, a Micro Led, a Micro-oLed, a quantum dot light emitting diode (QLED), etc.

[0119] The electronic device 300 can implement a photographing function through an ISP, a camera 393, a video codec, a GPU, a display screen 394, and an application processor, etc. The ISP is configured to process data fed back by the camera 393. The camera 393 is configured to capture a still image or a video. In some embodiments, the electronic device 300 can include one or N cameras 393, where N is a positive integer greater than 1. The digital signal processor is configured to process digital signals, which can be digital image signals, and can also be other digital signals. For example, when the electronic device 300 selects a frequency point, the digital signal processor is configured to perform Fourier transform on the frequency point energy, etc. The video codec is configured to compress or decompress a digital video. The NPU is a neural-network (NN) calculation processor, which is inspired by the structure of a biological neural network, for example, by the transmission mode between human brain neurons, to quickly process input information, and can also constantly self-learn. Through the NPU, the electronic device 100 can implement intelligent cognition applications, such as image recognition, face recognition, voice recognition, text understanding, etc.

[0120] The external memory interface 320 can be configured to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 300. The external memory card communicates with the processor 310 through the external memory interface 320 to implement a data storage function. For example, music, video, etc. files are saved in the external memory card.

[0121] The internal memory 321 can be used to store computer executable program codes, which include instructions. The processor 310 performs various functional applications and data processing of the electronic device 300 by running the instructions stored in the internal memory 321. For example, in the embodiments of the present application, the processor 310 can perform the instructions stored in the internal memory 321, and the internal memory 321 can include a storage program area and a storage data area.

[0122] The storage program area can store an operating system, at least one application program required by a function (such as a sound playing function, an image playing function, etc.), and the like. The storage data area can store data (such as audio data, a phone book, etc.) created during the use of the electronic device 300, and the like. In addition, the internal memory 321 can include a high-speed random access memory, and can further include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), and the like.

[0123] The electronic device 300 can realize an audio function through an audio module 370, a speaker 370A, a receiver 370B, a microphone, a headset interface, and an application processor, and the like. For example, music playing, recording, and the like.

[0124] The audio module 370 is used to convert digital audio information into an analog audio signal output, and is also used to convert an analog audio input into a digital audio signal. The audio module 370 can also be used to encode and decode an audio signal. In some embodiments, the audio module 370 can be disposed in the processor 310, or part of the functions of the audio module 370 can be disposed in the processor 310. The speaker 370A, also known as a “loudspeaker”, is used to convert an audio electrical signal into a sound signal. The receiver 370B, also known as a “earpiece”, is used to convert an audio electrical signal into a sound signal. The microphone, also known as a “microphone”, “sound receiver”, is used to convert a sound signal into an electrical signal.

[0125] The headset interface is used to connect a wired headset. The headset interface can be a USB interface 330, or a 3.5mm open mobile terminal platform (OMTP) standard interface, a cellular telecommunications industry association of the USA (CTIA) standard interface.

[0126] The keys 390 include a power key, a volume key, and the like. The keys 390 can be mechanical keys. The keys 390 can also be touch keys. The motor 391 can generate a vibration prompt. The motor 391 can be used for incoming call vibration prompt, and can also be used for touch vibration feedback. The indicator 392 can be an indicator light, and can be used for indicating a charging state, a power change, and can also be used for indicating a message, a missed call, a notification, and the like. The SIM card interface 395 is used for connecting a SIM card. The SIM card can be inserted into or pulled out of the SIM card interface 395 to realize contact and separation with the electronic device 300. The electronic device 300 can support one or N SIM card interfaces, and N is a positive integer greater than 1. The SIM card interface 395 can support a Nano SIM card, a Micro SIM card, a SIM card, and the like.

[0127] Although Figure 2 Not shown, the electronic device 300 can also have a flash, a micro projection device, a near field communication (NFC) device, and the like, which will not be described here.

[0128] After introducing the hardware structure of the electronic device, the system architecture of the electronic device provided in the present application is introduced. The system architecture of the electronic device can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. The embodiment of the present application takes a layered architecture system as an example to exemplarily illustrate the software structure of the electronic device.

[0129] 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 a software interface. In some embodiments, the system is divided into five layers, and from top to bottom, the application layer, the system application framework layer, the collaborative service and scheduling layer, the communication module and device Profile layer, and the kernel layer.

[0130] Among them, the application program layer can include a series of application program packages. As Figure 3 shown, the application program package can include: notes, cameras, mail, schedules. The application program package can also include gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, and the like.

[0131] As Figure 3As shown, the system application framework layer can include an Activity Manager Service (AMS), a Distributed Activity Manager Service (DAMS), a Package Manager Service (PMS), a Distributed Package Manager Service (DPMS), a Service Manager (SM), a Distributed Service Manager (DSM), and a system Binder framework. Among them, the AMS, PMS and SM are system services in the Android system, and the related functions are not specifically introduced here. Among them, the DAMS, DPMS and DSM are system functions newly added by the embodiments of the present application in the distributed system, and together they are a distributed application framework, used to process service calls between distributed applications in the present application.

[0132] Among them, the distributed application framework can provide a distributed application management service, used to register in the distributed service management module, to realize service calls and management between distributed applications.

[0133] As shown in Figure 3 The collaboration service and scheduling layer is used to provide management capabilities of remote services, including remote service registration and remote service acquisition. It is responsible for forwarding service calls between devices, and converting local resource references (anonymous Binder objects, file descriptors, etc.) into inter-device resource references. Among them, the collaboration service and scheduling layer can include a distributed service management module, a distributed Binder management module, a distributed file management module, a transmission management module and a device management module.

[0134] Among them, the distributed service management module includes a service registration module, a service management module, a service acquisition module and a service lifecycle module. The service management module is used to manage multiple remote devices in the case where multiple remote devices exist.

[0135] The service registration module is used to register the target service by the service registration module of device 2 before device 1 calls the target service of device 2.

[0136] The service acquisition module is used to acquire the target service of device 2 by the service acquisition module of device 1 after the target service of device 2 is registered completely in the scenario where device 1 calls the target service of device 2.

[0137] The service lifecycle module is used to handle situations where device 1 can call services provided by devices A and B. Device A may have two services, and device B may also have two services. When a service on either device A or B becomes abnormal or is terminated (i.e., the service exits), the service lifecycle module on device 1 needs to perform certain actions on the exited service. The lifecycle can be understood as a process of creation and closure.

[0138] The distributed service management module lists only services with known names; these are all system services, meaning they are all named services, and their corresponding Binder objects are all named Binders. When a server registers its services, it registers the services with the distributed service management module.

[0139] The distributed Binder management module includes a Binder management mapping module, a Binder access authentication module, and a Binder lifecycle module.

[0140] In the distributed Binder management module, all Binders except for those with real names are anonymous Binders. Therefore, the scope is broader than that of the Binders in the distributed service management module. Anonymous Binders refer to Binders that are not registered in the distributed service management module and are created by the application itself.

[0141] The Binder management mapping module is used to manage Binder objects, involving the mapping between local Binders and remote Binders.

[0142] The Binder access authentication module is used to manage distributed Binder access authentication capabilities in cross-device or distributed scenarios.

[0143] The distributed file management module is responsible for reading and writing files across devices. It manages distributed files, primarily creating and opening files, which involves message transmission between devices, including serialization and deserialization.

[0144] The distributed file management module primarily refers to scenarios like taking photos. For example, when a PC needs to access a phone's camera, the actual photo cache file is created by the PC. Then, after taking a photo, the phone needs to obtain the file handle of the photo cache file from the PC. After obtaining the file handle, it needs to perform write operations on this photo cache file. This involves cross-device read and write operations. The distributed file management module can provide cross-device file access.

[0145] Among them, the file handle is a relatively complex object, similar to the Binder object.

[0146] The transmission management module refers to a session created between devices, and messages are transmitted through the session.

[0147] The device management module refers to the accessed device, and the device can have operations such as online or offline. Offline means that the device has been accessed and then offline, that is, no longer accessed, and all resources related to the device need to be cleaned up or other operations. Among them, one or more devices can be accessed.

[0148] As shown in Figure 3 The communication module and the device Profile (Device Profile) layer include a communication module, a device Profile module, and a distributed file module.

[0149] Among them, the communication module is responsible for transmission, including device discovery connection services and data transmission services, providing cross-device transmission interfaces, supporting automatic networking within the trust ring, one-to-many connection, and hibernating device wake-up. In the cross-device calling scenario, information is transmitted between devices through the communication module.

[0150] The device Profile module is used to provide device information, provide service registration interfaces supported by the device, and other device query service interfaces.

[0151] The distributed file module, that is, the distributed file management mentioned above, is responsible for cross-device file reading and writing.

[0152] The kernel layer includes a Binder driver module, mainly used for cross-device communication.

[0153] The methods in the following embodiments can be implemented in an electronic device with the hardware structure and the system architecture described above.

[0154] In the embodiments of the present application, the first electronic device is taken as an example of a client (main device), and the second electronic device is taken as an example of a server (auxiliary device). The first electronic device can call the services of the second electronic device, wherein the first electronic device can be a personal computer, a tablet, a mobile phone, etc., and the second electronic device can be a tablet, a mobile phone, etc. Among them, the server (sever) refers to the side that provides services, and the client (client) refers to the side that wants to use the services provided by the server.

[0155] In a scenario where the first electronic device invokes a target service from the second electronic device, the second electronic device first registers the target service within its own device, and then the first electronic device retrieves the registered target service. After successfully retrieving the target service from the second electronic device, the first electronic device can then invoke the service interface of the second electronic device.

[0156] Therefore, in this embodiment of the application, the overall process of the cross-device service invocation method is mainly divided into three parts: service registration of the second electronic device, obtaining the service of the second electronic device from the first electronic device, and invoking the service interface of the second electronic device from the first electronic device.

[0157] First, the service registration process for the second electronic device will be introduced.

[0158] Taking a distributed application management service as an example, where the target service registered by the second electronic device is a distributed application management service, this service (target service) is within the system application framework. When the electronic device powers on, the system application framework starts, which in turn starts the distributed application management service. After the electronic device powers on, the communication module starts. Following the communication module, the service collaboration module starts. Therefore, after the service collaboration module starts, the second electronic device can register the distributed application management service with the service collaboration module.

[0159] like Figure 4 As shown, the service registration process of the second electronic device includes: the target service of the second electronic device is registered to the distributed service management module (DistributedServiceManager) of the service collaboration module of the second electronic device; the service name (ServiceName) and IBinder object of the target service are stored in the distributed service management module; and a BinderId is assigned to the IBinder object.

[0160] The service name and IBinder are parameters; an IBinder object can invoke a target service. After the first electronic device obtains the IBinder object of the target service from the second electronic device, it can use the IBinder object to invoke the corresponding target service's interface, that is, to invoke the capabilities provided by the target service.

[0161] Each service has a corresponding service name, such as AMS service, camera service, audio service, etc. The service name is registered with the system's service management module. In a distributed service scenario, the service name can also be registered with the distributed service management module.

[0162] For example, the camera service is a system service, and the service name can be camera, or camera1, camera2. The camera service serves as a provider of a service, and has a corresponding IBinder object. The camera service can provide multiple interfaces, and different capabilities correspond to different interfaces. For example, the interfaces provided by the camera service can include opening the camera, taking a photo, and recording a video. Then, the above interfaces can be directly called through the corresponding IBinder object.

[0163] In the embodiments of the present application, a unique identifier (BinderId) can be allocated to the IBinder object, each Binder object has a BinderID, and the BinderId can establish a mapping relationship with the IBinder object. That is, the service of the server has a BinderId, and when the corresponding service is obtained at the client side, the BinderId can identify the relationship between the two. The mapping relationship can be understood as a key-value pair.

[0164] The BinderId can be allocated according to the device, for example, in the case of accessing multiple second electronic devices, the second electronic devices first set a device identifier (DeviceId), and then allocate BinderId to the services on each second electronic device. The device identifier can be pre-set.

[0165] Specifically, the BinderId can be allocated in a certain order. For example, the second electronic device A can provide services a (IBinder a), service b (IBinder b), the second electronic device B can provide service c (IBinder c), then the BinderId corresponding to IBinder a can be Binder1, the BinderId corresponding to IBinder b can be Binder2, and the BinderId corresponding to IBinder c can be Binder3. The form of BinderId is not limited to numbers, but can also be letters, characters, etc. When using numbers as BinderId, it is not necessarily from 1, but can also start from a specific number and increase sequentially.

[0166] In the embodiments of the present application, the second electronic device stores the service name and the IBinder object of the target service, and the second electronic device allocates BinderId to the IBinder object. Then, in the following steps, the target service can be obtained through the service name. The specific obtaining process is to determine the IBinder object through the service name, and after determining the IBinder object, the corresponding BinderId can be determined. The IBinder object and the BinderId are one-to-one correspondence.

[0167] It can be understood that the real-name service is to store the service name, IBinder object and BinderId in the service end. The above relationship is stored in the distributed service management module in the service end. The system service has a corresponding service name, and the service name is registered in the distributed service management module. Therefore, the system service is a real-name service.

[0168] The storage mode can be a list mode, as shown in Table 1.

[0169] Service Name IBinder Object BinderId Service S1 IBinder S1 BinderId S1 Service S2 IBinder S2 BinderId S2

[0170] Table 1

[0171] The service name and IBinder object can be stored in one list, and the IBinder object and BinderId can be stored in another list. The three are one-to-one corresponding. As shown in Table 2a and Table 2b:

[0172] Service Name IBinder Object Service S1 IBinder S1 Service S2 IBinder S2

[0173] Table 2a

[0174] IBinder Object BinderId IBinder S1 BinderId S1 IBinder S2 BinderId S2

[0175] Table 2b

[0176] In the embodiment of the application, after the distributed Binder management module of the second electronic device allocates BinderId for the IBinder object and establishes the mapping relationship, it means that the target service of the second electronic device is registered successfully. The distributed Binder management module of the second electronic device can send the notification information of the successful registration to the system application framework of the second electronic device. At this time, the first electronic device can obtain the target service registered by the second electronic device.

[0177] Secondly, the process that the first electronic device obtains the target service registered by the second electronic device is introduced. After the target service of the second electronic device is registered successfully, the first electronic device can obtain the target service registered by the second electronic device. It can be understood that before obtaining the target service, the first electronic device has opened the application, and the first electronic device responds to a certain operation of the user on the application interface to call the device list and the capability list. That is to say, when the first electronic device receives the operation of the user, it can be considered that the user has the intention of cross-device calling, and therefore the target service needs to be obtained.

[0178] The application of the first electronic device can obtain a list of devices within a set range through interactions between devices. The distributed application framework of each device can determine whether a device has a collaborative service and scheduling module. If a device does not have a collaborative service and scheduling module, it does not have cross-device call capabilities and sends an empty message to the application of the first electronic device. In this case, the application interface of the first electronic device will not display the device name, or it will display the device name but distinguish it from other devices with cross-device call capabilities through a specific identifier.

[0179] In this embodiment, a call entry point is provided within the application of the first electronic device. For example, consider a note-taking application calling a camera application. Figure 5 As shown, the computer's note-taking application display interface 501 includes an insert button 502. After the user touches the insert button, the computer displays a list of server devices that can provide services and their corresponding capabilities on the display interface. The displayed devices can be a mobile phone 1 or a tablet 1. The capability list includes the services that the server device can provide, such as... Figure 5 Mobile phone 1 has functions for taking photos and scanning, while tablet 1 has functions for taking photos and scanning.

[0180] In some embodiments of this application, the display interface of the note-taking application can show all devices with cross-device calling capabilities within a set range. For example, if the set range of devices with cross-device calling capabilities includes mobile phone 1 and tablet 1. Figure 5 As shown, the devices displayed are mobile phone 1 and tablet 1, and the functions that mobile phone 1 and tablet 1 can provide, such as taking pictures and scanning.

[0181] In some embodiments of this application, the display interface of the note-taking application can also display all devices within a set range, and distinguish whether a device has cross-device calling capabilities through a set identifier. For example, devices without cross-device calling capabilities can be displayed in gray, while other devices with cross-device calling capabilities are displayed normally. Figure 6 As shown, if all devices within the set range are phone 1, phone 2, tablet 1, and tablet 2, they are represented by diagonal dashed lines and displayed in gray. Phone 1 and tablet 1 are displayed normally, indicating devices with cross-device calling capabilities, while phone 2 and tablet 2 are devices without cross-device calling capabilities.

[0182] In some embodiments of this application, the capability list corresponding to the device can also display all possible services, and distinguish whether a service is provided by the device by setting identification information, or only display the services that the device can provide.

[0183] In some embodiments of the present application, the display interface of the note application can first display a device list, and then in response to a touch operation on a device in the device list, display a capability list corresponding to the device. For example, as shown in Figure 7 the displayed device list includes mobile phone 1, mobile phone 2, tablet 1 and tablet 2. In response to a touch operation on mobile phone 1, a capability list corresponding to mobile phone 1 is displayed.

[0184] In embodiments of the present application, in response to an opening operation on an application of a first electronic device, an application interface is displayed, and then in response to a touch operation on a target button (such as the "insert" button in Figure 5 , the application interface of the first electronic device displays a device list and a corresponding capability list.

[0185] In some other embodiments of the present application, in response to an opening operation on an application of a first electronic device, an application interface is displayed, and the application interface directly displays a device list and a corresponding capability list.

[0186] That is, the device list and the capability list are displayed before the service is acquired, and then in response to a touch operation of a user on an item in the list, such as a touch operation of the first electronic device on a camera service option of mobile phone 1 in the list of a certain application of the user, it can be determined that the corresponding second electronic device is mobile phone 1 and the target service is the distributed application management service. At this time, the first electronic device can start to acquire the distributed application management service of mobile phone 1.

[0187] As shown in Figure 4 , the process of the first electronic device acquiring the target service includes that the system application framework of the first electronic device initiates a request for acquiring the service to the distributed service management module of the first electronic device, and the request is initiated with a device identifier (DeviceId) and a service name (ServiceName).

[0188] In some embodiments of the present application, the first electronic device can establish a connection with the second electronic device according to the device identifier in the request. After the connection is established, the corresponding target service is searched from the second electronic device according to the service name in the request.

[0189] In some embodiments of the present application, the first electronic device can call the same service multiple times. Then, after the first electronic device acquires the service for the first time, the information of the acquired service can be cached locally. When the application of the first electronic device calls the service next time, the service name can be directly searched from the local cache. For example, the application 1 of the computer 1 calls the scanning service of the mobile phone 1 once. Then, when the application 1 of the computer 1 calls the scanning service next time, the name of the mobile phone 1 and the name of the distributed application management service can be directly searched from the local cache of the computer 1.

[0190] In some embodiments of the present application, if the target service is not found in the local cache, that is, the device name and the corresponding service name are not saved in the local cache. Then, the first electronic device can search for the corresponding target service in the second electronic device.

[0191] The specific steps of searching for the corresponding target service in the second electronic device include: creating a session between the first electronic device and the second electronic device. After the session is successfully created, the first electronic device searches for the corresponding target service from the second electronic device according to the service name.

[0192] The specific steps of creating the session include: after the session between the communication module of the first electronic device and the communication module of the second electronic device is successfully created, the communication module of the second electronic device sends a session creation success instruction to the distributed binder management module of the second electronic device, and the communication module of the first electronic device sends a session creation success instruction to the distributed binder management module of the first electronic device. The distributed binder management module is used to manage Binder objects.

[0193] The specific steps of searching for the corresponding service in the second electronic device according to the service name by the first electronic device include: the first electronic device sends the service name to be acquired to the target device through a message. After receiving the message, the second electronic device parses the service name according to the content of the message. Then, the second electronic device searches for the target service corresponding to the service name from the distributed service management module. The distributed service management module stores the correspondence between the service name and the IBinder object.

[0194] If the corresponding target service is found, the IBinder object corresponding to the target service is determined, and the IBinder object is returned to the first electronic device.

[0195] The communication module is a message receiving module and has a message receiving function. After the communication module of the second electronic device receives the message, the message can be parsed. If the message contains a service name, the message can be considered as a query type instruction message. Then, the service name in the message can be used to query the corresponding target service in the distributed service management module. If the distributed service management module stores a service name same as the service name in the message, it indicates that the corresponding target service is found. The second electronic device returns the IBinder object corresponding to the target service to the communication module of the second electronic device.

[0196] It can be understood that the distributed Binder management module of the second electronic device establishes a mapping relationship between the IBinder object and the BinderId. After the mapping relationship is successfully established, the distributed Binder management module of the second electronic device sends the mapping relationship to the distributed service management module, and the distributed service management module saves the mapping relationship. For details, refer to the arrow indication of Figure 4

[0197] The second electronic device finds the corresponding IBinder object in the distributed service management module according to the service name, and then sends the IBinder object back to the distributed Binder management module of the second electronic device. The distributed Binder management module of the second electronic device determines the BinderId corresponding to the IBinder object according to the established mapping relationship between the IBinder object and the BinderId. Then, the determined BinderId is sent to the communication module of the second electronic device.

[0198] That is, when the two devices really interact, the communication module of the second electronic device sends the BinderId to the communication module of the first electronic device.

[0199] It should be noted that the IBinder object of the target service generated by the second electronic device is actually not really sent to the client. Because the IBinder object has a system boundary, it only has a specific meaning on the second electronic device. The IBinder object can be understood as a pointer or address, and sending the IBinder object to the first electronic device has no actual meaning. Therefore, the second electronic device sends the BinderId to the first electronic device.

[0200] ​Specifically, the communication module of the second electronic device assembles a message after receiving the BinderID of the target service, and sends the message to the communication module of the first electronic device. That is, the message carries the BinderID of the target service.

[0201] The communication module of the first electronic device receives the message, that is, receives the BinderID of the target service carried in the message. The first electronic device creates a local IBinder object according to the BinderId. The distributed Binder management module of the first electronic device creates the local IBinder object according to the BinderId.

[0202] Then, the newly created IBinder object is returned to the application 1 of the first electronic device. Specifically, the newly created IBinder object is returned to the distributed service management module of the first electronic device, the system application framework, and finally returned to the application 1 of the first electronic device.

[0203] It can be understood that the newly created IBinder object of the first electronic device is created according to the BinderID carried in the received message, that is, the BinderId transmitted from the second electronic device to the first electronic device. The BinderId is constant. Then, the first electronic device newly creates a corresponding IBinder object according to the BinderId. That is, in the first electronic device, the BinderId and the new IBinder object also have a mapping relationship.

[0204] That is, in the embodiment of the present application, in order to enable the first electronic device to call the second electronic device, a virtual IBinder object is created for the first electronic device, and then corresponds to the received BinderId.

[0205] It should be noted that one service has a corresponding IBinder object, including several forms, one of which is the service itself, and the other is a reference to a Binder object provided. Generally, the client obtains only the reference of the Binder object (i.e., Binder proxy). That is, the server sends to the system application framework of the client is an object of the Binder proxy type, that is, a proxy object is created in the client.

[0206] Finally, after the first electronic device obtains the target service, the first electronic device can call the service interface of the second electronic device. That is, after the first electronic device obtains the service provided by the application of the second electronic device, the interface of the service is called through the IBinder object.

[0207] Wherein, when the client calls the service interface of the server, a request of service call is sent to the server; after the server receives the request, the corresponding service interface is called, and then a reply containing the call result is returned to the client.

[0208] Wherein, the request may contain an anonymous IBinder object or not contain an anonymous IBinder object. The anonymous IBinder object is an IBinder object that is not submitted to the distributed service management module for registration, and the anonymous IBinder object can call an anonymous service. When the client calls the service registered by the server, if a simple instruction is transmitted in the request, there is no further instruction (equivalent to that the request does not contain an anonymous IBinder object). If the returned result can be directly used, there is no further instruction (equivalent to that the reply does not contain an anonymous IBinder object), and if the returned result cannot be directly used, the returned result is further accessed or called (equivalent to that the reply contains an anonymous IBinder object).

[0209] For example, if the service provided by the second electronic device is a calculation service, taking a simple adder (a+b) as an example. For the application of the first electronic device, the input parameters are two numbers a and b, the interface of the service is called, and the result c can be directly obtained; wherein, the result c is a number and does not contain anything else. The above case is equivalent to that the request does not contain an IBinder object, and the reply (reply) does not contain an IBinder object.

[0210] For example, if the second electronic device provides a camera photo-taking service, when the application of the second electronic device (i.e., the camera) needs to send the photo data back to the application of the first electronic device (such as a notes application) after taking a photo, it first needs to obtain the file handle of the notes' photo cache file, and then write the photo data back to the photo cache file of the first electronic device's application. Since the handle is a local resource of the first electronic device, it cannot be obtained directly. Therefore, the handle is hosted in a service (such as a Provider service). The second electronic device obtains the notes' FileProvider object, and then obtains the file handle through that object. The above situation is equivalent to the request not containing an anonymous IBinder object, while the response contains an anonymous IBinder object. It can be understood that in the process of the camera obtaining the notes' FileProvider object, it is equivalent to the camera obtaining the notes' service. Therefore, in the process of the camera obtaining the notes' FileProvider object, the camera acts as the client at this time, and the notes act as the server at this time. The camera sends a request to the notes (i.e., obtains the notes' FileProvider object), and the camera receives the response returned by the client (i.e., the notes' FileProvider object). In this case, the note obtains its own FileProvider object, which is not registered in the distributed application management service module, and is equivalent to an anonymous IBinder object.

[0211] For example, if the client sends a request to the server that includes an anonymous IBinder object, the server can obtain this IBinder object and then call the interface provided by this IBinder object in the client.

[0212] like Figure 8 The steps are as follows. It is assumed that the request does not contain an IBinder object, but the response does. This can be applied to scenarios where a first electronic device calls a service of a second electronic device, and the service returned by the second electronic device to the first electronic device allows the first electronic device to make further calls.

[0213] like Figure 8 As shown, when the application 1 of the first electronic device uses a Binder reference object to call the interface corresponding to the remote service, it enters the distributed Binder management module for service collaboration. The input parameters in the interface call can be encapsulated in a Parcel package (i.e., Request Parcel).

[0214] The service coordination module parses the received Request Parcel package (set as Parcel 1) to determine whether it contains an IBinder object. If it does not contain an IBinder object, the Parcel package can be directly serialized. If it contains an IBinder object, the IBinder object is mapped and replaced, and then the Parcel package is serialized. Since it is assumed that the request does not contain an IBinder object, that is, after the Parcel 1 is parsed, it is determined that the Parcel 1 does not contain an IBinder object, the received Parcel 1 can be directly serialized.

[0215] After the Parcel 1 is serialized, the first electronic device can send the request (that is, the Binder call request) to the second electronic device. It can be understood that the Parcel package is serialized, that is, the state of the object is serialized into a byte stream, and the byte stream can be transmitted across devices. Therefore, the Parcel 1 can be transmitted across devices, that is, from the first electronic device to the second electronic device.

[0216] Specifically, the communication module of the first electronic device can assemble a message (set as message 1), which carries the Binder call request (that is, the Parcel 1 byte stream), and the communication module of the first electronic device sends the message 1 to the communication module of the second electronic device. The message 1 can include identification information, which is used to identify that the message 1 carries a Binder call of the first electronic device to the second electronic device. For example, some bytes in the byte stream can be used to represent the above identification information. The second electronic device can determine the type of the request carried in the message 1 through the identification information, for example, determine that the above request is a function call type through the identification information. The correspondence between the identification information and the request type can be preset.

[0217] The message 1 further includes the BinderId of the target service received by the first electronic device when obtaining the target service.

[0218] The communication module of the second electronic device receives and parses the message 1, and determines that the message 1 carries a Binder call request. That is, the second electronic device receives the request, deserializes the request, and calls the transact interface to execute the interface call of the service of the second electronic device. Specifically, the distributed Binder management module of the second electronic device processes the Parcel 1 byte stream. First, since the request previously assumed does not contain an IBinder object, the Parcel 1 byte stream can be directly deserialized. Then, it is detected again whether the IBinder object is contained. Since the anonymous IBinder object is not contained, the second electronic device can find the corresponding IBinder object according to the BinderId transmitted (according to the mapping relationship stored in the second electronic device), and then directly call the transact interface to perform the actual service call. That is, the second electronic device finds the target service according to the received BinderId, and calls the interface of the application where the target service is located.

[0219] After the interface call of the service of the second electronic device is completed, it is equivalent to that the actual method execution is completed, and a result is generated. The result is returned to the calling party (that is, the first electronic device) through a Parcel package (that is, a Reply Parcel). In the remote call scenario, the Reply Parcel (set as Parcel 2) needs to be returned to the first electronic device through the network.

[0220] When the second electronic device processes (parses) the Parcel 2, it can be determined that the Parcel 2 contains an IBinder object. The distributed Binder management module of the second electronic device allocates a BinderId for the IBinder object (that is, establishes a mapping relationship between the IBinder object and the BinderId), and caches it in the Binder list. Then, the distributed Binder management module of the second electronic device serializes the Parcel 2. Before serialization, the Binder object in the Parcel 2 is replaced with a BinderId, and other space padding placeholders belonging to the Binder object are filled.

[0221] Then, the serialized data (Parcel 2 byte stream) is sent to the first electronic device. Specifically, the distributed Binder management module of the second electronic device constructs a message (set as message 2), which carries a reply to the Binder call. The distributed Binder management module of the second electronic device sends the constructed message 2 to the communication module of the second electronic device, and the communication module of the second electronic device sends the message 2 to the communication module of the first electronic device.

[0222] The communication module of the first electronic device receives the message 2, parses the message 2, and obtains a message corresponding to the reply of the Binder call. Then, the communication module of the first electronic device sends the parsed message to the distributed Binder management module of the first electronic device for processing.

[0223] After the first electronic device receives the Parcel2 byte stream (i.e., the reply parcel byte stream of the Binder call), the first electronic device processes the Parcel2 byte stream. That is, the distributed Binder management module of the first electronic device processes the Parcel2 byte stream. Specifically, the first electronic device deserializes the Parcel2 byte stream to obtain a Parcel2 object. Then, since the first electronic device can determine that the Parcel2 contains an IBinder object, i.e., the corresponding BinderId is written in the Parcel2 by parsing the Parcel2, the first electronic device can obtain the BinderId of the second electronic device, and then create a local Binder reference object of the first electronic device, wherein the BinderId and the local Binder reference object establish a mapping relationship. Then, the distributed Binder management module of the first electronic device writes the created Binder reference object into a new reply parcel and returns the new reply parcel to the application 1 of the first electronic device.

[0224] In summary, the embodiment of the present application provides a cross-device service calling method. After the first electronic device receives the BinderId of the IBinder object corresponding to the service of the second electronic device, the first electronic device creates an IBinder object of the local end corresponding to the BinderId, and then calls the service of the second electronic device through the IBinder object of the local end, thereby realizing cross-device service calling.

[0225] In the embodiment of the present application, the above-mentioned cross-device service calling method can be applied to the scenario that the first electronic device calls the photographing service of the second electronic device. The first electronic device can be a personal computer, a tablet, a mobile phone, etc., and the second electronic device can be a tablet, a mobile phone, etc.

[0226] If the first electronic device is a personal computer, taking the scenario that the application (e.g., a note) of the first electronic device calls the photographing service of the application (e.g., a camera) of the second electronic device as an example, the above-mentioned cross-device service calling method is introduced.

[0227] In a scenario where the note-taking application of the first electronic device invokes the camera application's photo-taking service of the second electronic device, the second electronic device first registers with the distributed application management service within its own device. Then, the first electronic device obtains the registered distributed application management service from the second electronic device. After the first electronic device successfully obtains the second electronic device's distributed application management service, its note-taking application launches the second electronic device's camera application. The camera application takes a picture of the specified content, and the second electronic device then transmits the captured data to the first electronic device's note-taking application.

[0228] Therefore, the overall process of the aforementioned cross-device service invocation method can include three parts: service registration by the second electronic device, service acquisition by the first electronic device, and service data (photograph data) being sent back from the second electronic device to the first electronic device. The service registered by the second electronic device at this point is a distributed application management service. For example... Figure 9 As shown, Figure 9 This is a flowchart illustrating a cross-device service invocation method provided in an embodiment of this application.

[0229] like Figure 9 In the illustrated process, the first electronic device displays the interface of the first application, receives first touch operations from the user on multiple target device controls, and sends an acquisition command to the second electronic device, which is to acquire the distributed application management service registered by the second electronic device. The second electronic device receives the acquisition command from the first electronic device, looks up the BinderID of the distributed application management service based on the command, and sends the BinderID to the first electronic device. The first electronic device acquires the BinderID of the distributed application management service and creates an IBinder object based on that BinderID (see reference). Figure 9 (Steps S101-S103). That is, the specific process of the second electronic device registering for service and the first electronic device obtaining service, which will be described in detail below.

[0230] Please see Figure 10 , Figure 10 This is a sequence diagram showing the service registration process for the second electronic device and the service acquisition process for the first electronic device. First, the service registration process for the second electronic device is introduced.

[0231] The distributed application management service is located within the system application framework. When the electronic device powers on, the system application framework, including the distributed application management service, is started. After the electronic device powers on, the communication module starts. Following the communication module, the service collaboration module starts. Therefore, after the service collaboration module starts, the second electronic device can register the distributed application management service with the service collaboration module.

[0232] The service registration procedure of the second electronic device, i.e., the registration procedure of the distributed application management service of the second electronic device, specifically includes: the distributed application management service of the second electronic device is registered in a distributed service manager (see step 1 in Figure 10 ). The distributed application management service is started in the system application framework after the second electronic device is powered on.

[0233] The service name (for example, “DisApp”) and the IBinder object (for example, “IBinder S1”) of the distributed application management service are stored in the distributed service manager. Then, the service name and the IBinder object are sent to a distributed Binder management module. The distributed Binder management module caches the IBinder object (IBinder S1) and allocates a BinderId (for example, “Binder S1”) for the IBinder object. That is, the IBinder S1 and the Binder S1 establish a mapping relationship (see step 1.1.1 in Figure 10 ). Then, the distributed Binder management module returns the registration result to the system application framework (see step 1.2 in Figure 10 ).

[0234] In the embodiment of the present application, after the distributed Binder management module of the second electronic device allocates the BinderId for the IBinder object and establishes the mapping relationship, it indicates that the registration of the distributed application management service of the second electronic device is successful. The distributed Binder management module of the second electronic device can send the notification information of the successful registration to the system application framework of the second electronic device. At this time, the first electronic device can obtain the distributed application management service registered by the second electronic device.

[0235] The application (for example, the camera application) is an interface provided by the distributed application framework in the system application framework. After the first electronic device obtains the distributed application management service registered by the second electronic device, the first electronic device can call the camera application of the second electronic device through the distributed application framework and can obtain the service provided by the camera application.

[0236] Secondly, the procedure of the first electronic device obtaining the service is introduced. After the registration of the distributed application management service of the second electronic device is successful, the first electronic device can obtain the distributed application management service registered by the second electronic device.

[0237] It can be understood that before the photographing service is acquired, the first electronic device has opened the note application, and the first electronic device invokes the device list and the capability list in response to the touch operation of the user on the invoking entry of the note application interface. That is, when the first electronic device receives the operation of the user, it can be considered that the user has the intention of cross-device invocation, and therefore the distributed application management service provided by the second electronic device needs to be acquired.

[0238] As shown in FIG. 1, the invoking entry is provided in the note application of the first electronic device. As shown in FIG. 2, the insertion button is provided in the display interface of the note application of the computer, and the computer displays the second electronic device that can provide the service and the capability list corresponding to the device in the display interface in response to the touch operation of the user on the insertion button. The displayed device can be the mobile phone 1 and the tablet 1. The capability list includes the services that can be provided by the second electronic device, such as the photographing, scanning, and the like corresponding to the mobile phone 1, and the photographing, scanning, and the like corresponding to the tablet 1. Figure 5 Figure 5

[0239] In some embodiments of the present application, the first electronic device can be the first time to invoke the photographing service of the camera of the second electronic device, or there can be multiple invocations. After the first electronic device acquires the photographing service of the camera for the first time, the invoking information of the acquired photographing service can be cached in the local. Therefore, the first electronic device can first search the second electronic device and the distributed application management service from the local cache, and if found, directly return to the note application, and if not found, search from the second electronic device.

[0240] The following describes in detail the process of acquiring the distributed application management service when the first electronic device invokes the photographing service of the camera of the second electronic device for the first time according to an embodiment of the present application.

[0241] In the embodiment of the present application, after the distributed application management service of the second electronic device is successfully registered, and in response to the touch operation of the user on the invoking entry of the note application interface, the note application of the first electronic device can acquire the distributed context of the second electronic device, that is, acquire the “DisApp” service of the second electronic device (refer to step 2.1 of FIG. 2). Specifically, the system application framework of the first electronic device sends a request for acquiring the “DisApp” service to the distributed service management module of the first electronic device. Then, the distributed service management module of the first electronic device sends a request for acquiring the “DisApp” service to the message center (Message Center) - communication module of the first electronic device (refer to step 2.2 of FIG. 2). Figure 10 Figure 10

[0242] ​​​​After receiving a request to obtain the "DisApp" service, the communication module of the first electronic device creates a session with the first electronic device (see [reference]). Figure 10 Step 2.2.1). After the channel is successfully created, the distributed service management module of the first electronic device sends an instruction to the communication module of the first electronic device to obtain the "DisApp" service (refer to...). Figure 10 Step 2.2.2). The communication module of the first electronic device receives the instruction to obtain the "DisApp" service, assembles a message, and sends the message to the communication module of the second electronic device.

[0243] After receiving the message, the communication module of the second electronic device parses the message and obtains the instruction to obtain the "DisApp" service (see reference). Figure 10 Step 2.2.3). The communication module of the second electronic device sends this instruction to the distributed Binder management module of the second electronic device (refer to...). Figure 10 Step 2.2.4).

[0244] After receiving the instruction, the distributed Binder management module of the second electronic device searches for the "DisApp" service in the distributed service management module. As mentioned in step 1.1, the distributed service management module stores service names and corresponding IBinder objects. Therefore, the distributed Binder management module can search its database to see if the service ("DisApp") is stored based on the service name in the instruction. If the service ("DisApp") is found, the corresponding IBinder object (IBinder S1) is determined.

[0245] Then, the distributed service management module of the second electronic device returns the IBinder object (IBinder S1) to the distributed Binder management module of the second electronic device. The distributed Binder management module of the second electronic device determines the BinderId (BinderId S1) corresponding to the IBinder object (IBinder S1) based on the established mapping relationship between IBinder objects and BinderIds (see reference). Figure 10 Step 2.2.4). Then, the BinderId (BinderId S1) is sent to the communication module of the second electronic device (see step 2.2.4). Figure 10 Step 2.2.5).

[0246] The communication module of the second electronic device, after receiving the BinderId (BinderId S1) of the "DisApp" service, assembles a message (the message carries BinderId S1) and sends the message to the communication module of the first electronic device.

[0247] The communication module of the first electronic device receives the message and parses the information content to obtain the BinderId (BinderId S1) of the "DisApp" service (see step 2.2.6 of Figure 10 ). The communication module of the first electronic device sends the BinderId (BinderId S1) of the "DisApp" service to the distributed service management module of the first electronic device. The distributed service management module of the first electronic device sends the BinderId (BinderId S1) of the "DisApp" service to the distributed Binder management module of the first electronic device. Then, the distributed Binder management module newly creates a corresponding local IBinder object (IBinder C1) according to BinderId S1, that is, the distributed Binder management module creates a mapping relationship between BinderId S1 and IBinder C1 and stores the mapping relationship (see step 2.2.7 of Figure 10 ).

[0248] Then, the distributed Binder management module of the first electronic device returns the service name ("DisApp") and the corresponding IBinder object (IBinder C1) to the communication module of the first electronic device, the system application framework (see step 2.2.8 of Figure 10 ), and finally returns to the note application of the first electronic device (see step 2.3 of Figure 10 ).

[0249] In the embodiment of the application, after the first electronic device obtains the "DisApp" service registered by the second electronic device, the first electronic device opens the camera application of the second electronic device.

[0250] The specific process in which the note application of the first electronic device opens the camera application of the second electronic device is as follows:

[0251] As shown in Figure 11As shown, the note application sends a start activity for result (intent) message to the system application framework of the first electronic device, and the Intent contains the uri and device information. The note application calls through the locally created IBinder C1, and the input parameters (uri and device information) in the message are encapsulated in parcel A, and the system application framework sends parcel A to the distributed Binder management module in the service collaboration module of the first electronic device. The distributed Binder management module parses parcel A, and it can be determined that there is no IBinder object in parcel A, and parcel A can be directly serialized to obtain a parcel A byte stream.

[0252] The service collaboration module of the first electronic device sends the parcel A byte stream (request) to the service collaboration module of the second electronic device. Specifically, the communication module of the first electronic device sends the parcel A byte stream to the communication module of the second electronic device. The communication module of the second electronic device forwards the parcel A byte stream to the distributed Binder management module in the service collaboration module of the second electronic device. The distributed Binder management module deserializes the parcel A byte stream to obtain parcel A.

[0253] The distributed Binder management module of the second electronic device sends parcel A (request) to the system application framework of the second electronic device. The system application framework of the second electronic device sends a start activity message to the camera application, and calls the start activity method through the locally created IBinder S1 to start the camera. Then, the system application framework encapsulates the result data (camera opening) returned by the camera application in parcel A' (reply), and sends it to the distributed Binder management module in the service collaboration module of the second electronic device. The distributed Binder management module parses parcel A', and it can be determined that there is no IBinder object in parcel A', and parcel A' can be directly serialized to obtain a parcel A' byte stream.

[0254] The service coordination module of the second electronic device sends the parcel A' byte stream to the service coordination module of the first electronic device. Specifically, the communication module of the second electronic device sends the parcel A' byte stream to the communication module of the first electronic device. The communication module of the first electronic device forwards the parcel A' byte stream to the distributed Binder management module in the service coordination module of the first electronic device. The distributed Binder management module deserializes the parcel A' byte stream to obtain the parcel A'.

[0255] The distributed Binder management module of the first electronic device sends the parcel A' to the system application framework of the first electronic device. At this time, the camera is successfully turned on.

[0256] After the first electronic device obtains the "DisApp" service registered by the second electronic device and the camera application of the second electronic device is opened, the user uses the camera application to take a picture of information that needs to be returned to the note. The camera application returns the obtained picture data to the note in response to the user's operation. For example, the board content of the offline class is inserted in the note application. After the camera application is opened, the user uses the camera to take a picture of the board content. The camera obtains the board picture (picture data of the board content) in response to the user's click operation on the shooting button. Then, the camera returns the board picture to the note.

[0257] The camera obtains the picture in response to the user's click operation on the shooting button, and then can confirm whether the picture meets the user's demand. The camera obtains the confirmed picture in response to the user's click operation on the confirmation button, that is, after confirming that the picture meets the user's demand. The camera returns the confirmed picture to the note. That is, after the camera responds to the user's click operation on the confirmation button, the camera returns the picture data to the note of the first electronic device.

[0258] For the camera, when the picture data needs to be returned to the note application after shooting, the file handle of the picture cache file of the note needs to be obtained first, and then the picture data is written back to the picture cache file of the client application. Since the handle is a local resource of the first electronic device, it cannot be directly obtained. Therefore, the file handle can be hosted in a certain service (such as a Provider service), and the camera obtains the file handle through the File Provider object (file providing object) of the note. It can be understood that the camera application sends a simple request to the note application, and the result returned by the note application to the camera application is an object that needs to be further called. The above case is equivalent to that the request does not contain an anonymous IBinder object, and the reply contains an anonymous IBinder object.

[0259] Therefore, the specific steps for the second electronic device to send service data (photo data) back to the first electronic device include: the camera application obtaining the IContent Provider object (i.e., File Provider object) of the note-taking application; the camera application obtaining the file handle of the photo cache file of the note-taking application; and the camera application writing the photo data back to the first electronic device. Here, the photo data refers to the result of the second electronic device executing the distributed application management service.

[0260] The note-taking application of the first electronic device can create a photo cache file (File Provider) with a Uniform Resource Identifier (URI). Specifically, the photo cache file has a File Provider (equivalent to a binder object), which the note-taking application registers with the system application framework. The note-taking application can create the photo cache file in response to a user's touch operation on the camera options, or it can create the photo cache file at any time before obtaining its file handle.

[0261] Please see Figure 12 , Figure 12 A timing diagram of a File Provider object for obtaining notes, provided in an embodiment of this application. For example... Figure 12 As shown, when the camera application uses IBinder S1 to call the corresponding interface of the note application, it enters the distributed Binder management module of the service collaboration module. The input parameters in the interface call (by calling the transact method) can be encapsulated in the Parcel package (i.e., the request parcel).

[0262] The distributed Binder management module of the service collaboration module processes the request parcel (denoted as reqA) (see reference). Figure 12 Step 1.3). Specifically, first, it is determined whether reqA contains an anonymous IBinder object. By parsing reqA, it can be determined that reqA does not contain an anonymous IBinder object. This is understandable, since reqA is only used to retrieve the File Provider object for notes and does not require further calls, reqA does not contain an anonymous IBinder object. Then, the distributed Binder management module can directly serialize reqA.

[0263] The distributed Binder management module of the second electronic device receives the message and parses it. It is determined that the message carries a Binder call request. The message is then sent to the distributed Binder management module of the second electronic device. The distributed Binder management module of the second electronic device parses the message and obtains the reqA byte stream (i.e. the serialized reqA). The distributed Binder management module of the second electronic device deserializes the reqA byte stream and obtains reqA. The distributed Binder management module of the second electronic device finds the corresponding local IBinder object (IBinder C2) according to the received BinderId S1. The transact is then called to perform an actual service call (i.e. to obtain the File Provider object of the camera application).

[0264] The distributed Binder management module of the second electronic device receives the message and parses it. It is determined that the message carries a Binder call request. The message is then sent to the distributed Binder management module of the second electronic device. The distributed Binder management module of the second electronic device parses the message and obtains the reqA byte stream (i.e. the serialized reqA). The distributed Binder management module of the second electronic device deserializes the reqA byte stream and obtains reqA. The distributed Binder management module of the second electronic device finds the corresponding local IBinder object (IBinder C2) according to the received BinderId S1. The transact is then called to perform an actual service call (i.e. to obtain the File Provider object of the camera application).

[0265] The distributed Binder management module of the second electronic device receives the message and parses it. It is determined that the message carries a Binder call request. The message is then sent to the distributed Binder management module of the second electronic device. The distributed Binder management module of the second electronic device parses the message and obtains the reqA byte stream (i.e. the serialized reqA). The distributed Binder management module of the second electronic device deserializes the reqA byte stream and obtains reqA. The distributed Binder management module of the second electronic device finds the corresponding local IBinder object (IBinder C2) according to the received BinderId S1. The transact is then called to perform an actual service call (i.e. to obtain the File Provider object of the camera application). Figure 12 Figure 12

[0266] ​​Then, the first electronic device sends the serialized repB1 (i.e., repB1 byte stream) to the second electronic device. Specifically, the distributed Binder management module of the first electronic device constructs a message carrying the repB1 byte stream. The distributed Binder management module of the first electronic device sends the constructed message to the communication module of the first electronic device, and then the communication module of the first electronic device sends the message to the communication module of the second electronic device.

[0267] After the communication module of the second electronic device receives the message, the communication module of the second electronic device parses the message to obtain a message corresponding to repB1. Then, the communication module of the second electronic device sends the parsed message to the distributed Binder management module of the second electronic device for processing.

[0268] That is, the distributed Binder management module of the second electronic device processes the repB1 byte stream. Specifically, the repB1 byte stream is first deserialized to obtain the repB1 object. Then, since the second electronic device can determine that the repB1 contains the IBinder object, i.e., the corresponding BinderId2 is written in the repB1 by parsing the repB1, the second electronic device can obtain the BinderId2 of the first electronic device, and then create an Ibinder object (denoted as IFilePs) of the second electronic device, wherein the BinderId2 and the IFilePs object of the second electronic device establish a mapping relationship. Then, the distributed Binder management module of the second electronic device writes the created IFilePs object into a reply packet (denoted as repB2) and returns the camera application (see step 1.8 of Figure 12 ).

[0269] At this time, the second electronic device obtains the File Provider object of the note application. Then, the second electronic device can obtain the file handle of the photo cache file of the note through the File Provider object.

[0270] Please refer to Figure 13 , Figure 13 the timing diagram provided by the embodiments of the present application for obtaining the file handle of the photo cache file of the note. As shown in Figure 13 , when the camera application uses the IFilePs object to call the interface corresponding to the note application, the distributed Binder management module of the service coordination module is entered, and the input parameters in the interface call (by calling the transact method) can be encapsulated in a Parcel packet (i.e., a request parcel).

[0271] The distributed Binder management module of the service coordination module processes the request parcel (denoted as reqD) reqD (refer to step 1.3 of FIG. 1). Specifically, it is first determined whether the reqD contains an anonymous IBinder object. By parsing the reqD, it is determined that the reqD does not contain an anonymous IBinder object. It can be understood that since the reqD is only used to obtain the file handle of the note, further calling is not needed, and it is determined that the reqD does not contain an anonymous IBinder object. Then, the distributed Binder management module can directly serialize the reqD. Figure 13

[0272] After the distributed Binder management module serializes the reqD, the calling request (reqD byte stream) is forwarded to the communication module of the second electronic device. The communication module of the second electronic device sends the reqD byte stream to the communication module of the first electronic device by assembling a message containing BinderId2.

[0273] The communication module of the first electronic device receives and parses the message, determines that the message carries a Binder calling request, and then sends the message to the Binder management module of the first electronic device. The Binder management module of the first electronic device parses the message to obtain the serialized reqD (reqD byte stream), deserializes the reqD byte stream to obtain the reqD, and finds the corresponding local IBinder object (IFilePc) according to the received BinderId2. Then, the transact is called to perform actual service calling (i.e., obtaining the file handle of the note).

[0274] The note application of the first electronic device writes the file descriptor (File Descriptor) object Fdc into the Parcel package, i.e., the Reply Parcel (denoted as repE), and returns the repE to the camera application of the second electronic device. Specifically, the note application calls on Transact (refer to step 1.6 of FIG. 1). The distributed Binder management module of the first electronic device processes the repE. Specifically, it checks that the repE contains the Fdc (equivalent to the Binder object), and then sends an instruction to create a distributed file to the distributed file module of the first electronic device (refer to step 1.7 of FIG. 1). Figure 13 Figure 13 ​​Step 1.6.2 of FIG. 1.6.1). It is understood that the file can be accessed by a file handle, such as opening the file, closing the file, reading and writing the file, etc., so after the camera application obtains the file handle, the photographing data can be written into the actual file. Since the actual file is on the device side where the note application is located, the camera application is for cross-device reading and writing, so a distributed file (the distributed file module can provide cross-device file access) can be created to ensure that the data is written into the file on the device side where the note is located.

[0275] After the distributed file is successfully created, the distributed Binder management module of the first electronic device writes the name of the distributed file into the location where the original Fdc is located in repE and occupies the location, to generate repE1 (refer to Figure 13 Step 1.6.4 of FIG. 1.6.1). Then, the distributed Binder management module serializes repE1.

[0276] Then, the first electronic device sends the serialized repE1 (i.e., repE1 byte stream) to the second electronic device. Specifically, the distributed Binder management module of the first electronic device constructs a message carrying repE1. The distributed Binder management module of the first electronic device sends the constructed message to the communication module of the first electronic device, and then the communication module of the first electronic device sends the message to the communication module of the second electronic device.

[0277] After the communication module of the second electronic device receives the message, the communication module of the second electronic device parses the message to obtain the message corresponding to repE1. Then, the communication module of the second electronic device sends the parsed message to the distributed Binder management module of the second electronic device for processing.

[0278] That is, the distributed Binder management module of the second electronic device processes the repE1 byte stream. Specifically, the distributed Binder management module of the second electronic device deserializes the repE1 byte stream to obtain the repE1 object. Then, the distributed Binder management module can detect that the repE1 contains the name of the distributed file, that is, the repE1 contains the information corresponding to the file handle. The second electronic device can read the name of the distributed file (DisPicture) in repE1 and open the corresponding distributed file (refer to Figure 13 Step 1.7.2 of FIG. 1.7.1).

[0279] Then, the distributed file module of the second electronic device returns the file handle VFd of the distributed file to the distributed Binder management module of the second electronic device. The distributed Binder management module writes the file handle VFd into a reply packet (set as repE2) and returns it to the camera application (refer to step 1.8 of Figure 13 ).

[0280] At this time, the second electronic device has obtained the file handle VFd of the note application. Then, the camera application can write the photograph data back to the first electronic device, i.e., the camera application writes the photograph data into the distributed file of the second electronic device through the file handle, and then into the distributed file of the first electronic device, and finally returns to the note application of the first electronic device.

[0281] That is, a channel can be created between the distributed file modules of the first electronic device and the second electronic device. After the camera application calls the write data interface of the distributed file of the second electronic device through the file handle, the photograph data is written, transmitted to the distributed file of the first electronic device through the channel created above, and then returned to the note.

[0282] The above step of returning the photograph data to the first electronic device is also Figure 9 S104-S110. Specifically, the second electronic device sends a request to the first electronic device based on the first BinderID of the distributed application management service in response to the second touch operation of the user on the second application, the first electronic device finds the corresponding IBinder object according to the BinderID contained in the request in response to receiving the request from the second electronic device. The first electronic device indicates the first file providing object to the second electronic device according to the IBinder object, i.e., sends the BinderID corresponding to the first file providing object to the second electronic device. The second electronic device creates a local corresponding second file providing object according to the BinderID corresponding to the first file providing object received. The second electronic device initiates a request to the first electronic device according to the second file providing object, and obtains a file handle object. The first electronic device indicates the first file handle object to the second electronic device in response to receiving the request, i.e., sends the name of the distributed file corresponding to the first file handle object to the second electronic device. The second electronic device receives the indicated first file handle object, i.e., receives the name of the corresponding distributed file, opens the corresponding distributed file. The second electronic device returns the result of the execution service to the distributed file, and then returns the result to the first electronic device.

[0283] In summary, in the cross-device service calling method described above, the user can use the first electronic device to send a shooting instruction to the second electronic device, the second electronic device receives the shooting instruction and calls the camera to perform the shooting or scanning task, and then returns the shooting result or the scanned text to the first electronic device. The user can save the step of uploading the shooting result or the scanned text to the first electronic device, then downloading and saving it to the first electronic device, and then uploading it to the corresponding position of the first electronic device. The operation is more convenient, and the user's work efficiency is improved.

[0284] Please refer to Figure 14 , Figure 14 A cross-device calling scenario is provided, as shown in Figure 14 , the display interface of the notebook application of the computer is provided with an insert button. The computer displays the server device that can provide services and the corresponding capability list of the device after responding to the touch operation of the user on the insert button. The displayed device can be a mobile phone 1 and a tablet 1. The capability list includes the services that the server device can provide, such as Figure 14 the photographing, scanning, etc. corresponding to the mobile phone 1, and the photographing, scanning, etc. corresponding to the tablet 1. The computer sends an instruction to open the camera application to the mobile phone 1 in response to the click operation of the user on the photographing option in the mobile phone 1. The mobile phone 1 opens the camera application and takes a photo of the specified content in response to the click operation of the user on the photographing button. Then, the mobile phone 1 acquires the confirmed photo in response to the click operation of the user on the confirmation button, that is, the confirmation that the photo meets the user's demand. The mobile phone 1 returns the confirmed photo to the specified position in the notebook application of the computer.

[0285] Therefore, through the cross-device service calling method described above, the user can send a shooting instruction from the computer to the mobile phone, the mobile phone receives the shooting instruction and calls the camera to perform the shooting or scanning task, and then returns the shooting result or the scanned text to the computer. The user can save the step of uploading the shooting result or the scanned text to the computer, then downloading and saving it to the computer, and then uploading it to the corresponding position. The operation is more convenient, and the user's work efficiency is improved.

[0286] In the cross-device service calling method, serialization and deserialization of the parcel package are involved. For example, in the process of the camera application obtaining the File Provider object of the note application, serialization and deserialization of reqA (request parcel A) and serialization and deserialization of repB (reply parcel B) are required. In the process of the camera application obtaining the file handle of the photo cache file of the note application, serialization and deserialization of reqD (request parcel D) and serialization and deserialization of repE (reply parcel E) are required. The reqA and the reqD do not contain an anonymous binder object, the repB contains a File Pc object (that is, the repB contains an anonymous Binder object), and the repE contains an Fdc object (that is, the repE contains a file handle).

[0287] The existing serialization and deserialization method only supports serialization and deserialization of a parcel package that does not contain an anonymous Binder object or a file handle, that is, the existing method is applicable only when the parcel package contains only basic type objects (for example, int and string objects). The existing method does not support serialization and deserialization of a parcel package that contains a complex object such as an anonymous binder object or a file handle.

[0288] In the embodiment of the present application, a cross-device data processing method is provided, which can replace the Binder object or the file handle in the parcel package when the parcel package contains a complex object such as the Binder object or the file handle, and then perform serialization, so that the two devices can access each other.

[0289] As shown in FIG. 1, a data structure diagram of a parcel package is provided in the embodiment of the present application. Figure 15 In the embodiment, InterfaceToken is located at the beginning of mData, and a package name is generally filled in InterfaceToken. An application has one package name. Figure 15 In the embodiment, an int type data and a string type data are further included. Here, writing of two common data types is taken as an example, and other types of data can also be used. Figure 15

[0290] ​In the parcel package, the start positions of binder1 and binder2 are also included, that is, the DataPos of binder1 and binder2, that is, the byte position from which the binder1 object starts and the byte position from which the binder2 object starts. That is, the data structure includes the bytes that can identify the positions of the binder object or the file handle object. The specific position of the binder object can be obtained through the above bytes in the parcel.

[0291] It should be noted that, Figure 15 The parcel data structure in the above is only an example. In actual scenarios, the parcel package generally only includes one Binder object, and does not include two Binder objects.

[0292] Referring to Figure 16 , Figure 16 A cross-device data processing method provided by an embodiment of the present application, wherein the parcel package includes a Binder object. As shown in Figure 16 , the left side can be an electronic device 1, and the right side can be an electronic device 2. The local resource of the electronic device 1 is sent to the electronic device 2. S in the parcel A is a Binder object, and the corresponding BinderId is S1. Before serialization, the electronic device 1 can replace the Binder object S with the corresponding BinderId (S1) to obtain the parcel A'. Then, the parcel A' is subjected to serialization processing to obtain the serialized parcel A', that is, the byte stream of the parcel A', and then transmitted to the client through the network. It can be understood that S in the parcel A is a Binder object, and the corresponding target service, for example, service 1, in the electronic device 1 can be called.

[0293] After the electronic device 2 receives the byte stream of the parcel A', the byte stream is subjected to deserialization to obtain the parcel A'. The electronic device 2 analyzes the parcel A' to obtain the BinderId (S1), and then creates the Binder reference object Q corresponding to the BinderId (S1) in the electronic device 2, and writes Q into the parcel A' to obtain the parcel B. That is, the electronic device 2 can subsequently call the service 1 of the electronic device 1 through the Binder reference object Q.

[0294] Binder object occupies a fixed length of bytes in the Parcel package, such as 28 bytes. Before serialization, the Binder object is assigned a corresponding Binder Id, where Binder Id can be defined as an integer type, occupying 4 bytes. Then, in Parcel A', after replacing the Binder object with Binder Id, the position of the bytes of the Binder object other than Binder Id is filled with a placeholder. Thus, when replacing the Binder object in the Parcel package with Binder Id, other data remains unchanged and does not affect the original structure of the Parcel package. In the above filling of the placeholder, as long as the preset placeholder can occupy the corresponding position, the form of the preset placeholder is not limited in the present application, which can be a blank or 0.

[0295] Figure 16 Binder object can be S, and the assigned Binder Id is S2. Before serialization, the electronic device 1 can replace the Binder object S with the corresponding Binder Id (S2) to obtain Parcel A'. Then, the electronic device 1 serializes Parcel A' to obtain the serialized Parcel A', i.e., the byte stream of Parcel A', and then transmits it to the electronic device 2 through the network. After receiving the byte stream of Parcel A', the electronic device 2 deserializes it to obtain Parcel A'. The electronic device 2 analyzes Parcel A' to obtain Binder Id (S2), and then creates a binder reference object Q1 corresponding to Binder Id (S2) in the local of the electronic device 2, and writes Q1 into Parcel A' to obtain Parcel B.

[0296] In the process of obtaining the File Provider object of the note application by the camera application in the present embodiment, after the first electronic device receives the request reqA for obtaining the File Provider object, the first electronic device writes the File Provider object of the note application into the Parcel package (i.e., repB), Figure 17 A serialization method of the repB is provided.

[0297] Figure 17In the repB, the local Binder1 in the repB can represent the File Provider object (IFile Pc object) described above. The first electronic device assigns a corresponding BinderId (BinderId2) to the IFile Pc object. Before serialization, the first electronic device can replace the IFile Pc object with the corresponding BinderId (BinderId2) to obtain repB1. Then, the repB1 is subjected to serialization processing to obtain the serialized repB1, that is, the byte stream of repB1, and then transmitted to the second electronic device through the network.

[0298] After receiving the repB1 byte stream, the second electronic device deserializes it to obtain repB1. The second electronic device analyzes repB1 to obtain BinderId 2, and then creates a reference object IFile Ps object (that is, the remote Binder10 in the repB) corresponding to BinderId 2 locally in the second electronic device, and writes the IFile Ps object into repB1 to obtain repB2. Figure 17

[0299] In summary, the serialization method of the Parcel package provided in the embodiments of the present application can be used in the scenario of cross-device transmission of the Parcel package. If the Parcel package contains a Binder object, the Binder object is replaced with a corresponding BinderId before serialization processing and transmission. That is, the local resource (Binder object) is replaced with a cross-device resource (BinderId) before serialization processing and transmission. After receiving the serialized parcel package at the other end, the BinderId is obtained by deserialization processing, and then the BinderId is replaced with a locally created Binder object. Thus, the serialization method of the Parcel package can realize cross-device transmission of the Parcel package containing a Binder object.

[0300] In the service calling scenario across devices in the embodiments of the present application, cross-device transmission of a Parcel package containing a file handle is also involved. The serialization method of the Parcel package is introduced as follows.

[0301] Please refer to Figure 18 , Figure 18 The cross-device data transmission method provided in the embodiments of the present application contains a file handle in the Parcel package. For example, Figure 18 ​As shown, the left side can be electronic device 3 and the right side can be electronic device 4, and the local resource in electronic device 3 is sent to electronic device 4. In Parcel D, T is a file handle object, and the corresponding name is T1. Before serialization, electronic device 3 can replace the file handle object T with the corresponding name T1 to obtain Parcel D'. Then, the serialization processing is performed on Parcel D' to obtain the serialized Parcel D', that is, the byte stream of Parcel D', and then transmitted to electronic device 4 through the network.

[0302] After receiving the byte stream of Parcel D', electronic device 4 performs deserialization to obtain Parcel D'. Electronic device 4 parses Parcel D' to obtain the name T1 corresponding to the file handle object T, and then creates a file handle object K corresponding to the name T1 locally in electronic device 4, and writes K into Parcel D' to obtain Parcel E.

[0303] In the embodiment of the application, in the process of obtaining the file handle of the photo cache file of the note application by the camera application, after the first electronic device receives the request reqD for obtaining the file handle object, the first electronic device writes the file descriptor Fdc of the note application into the Parcel package (that is, repE), Figure 19 A serialization method for the repE is provided.

[0304] Figure 19 In the embodiment of the application, in the process of obtaining the file handle of the photo cache file of the note application by the camera application, after the first electronic device receives the request reqD for obtaining the file handle object, the first electronic device writes the file descriptor Fdc of the note application into the Parcel package (that is, repE),

[0305] After receiving the byte stream of repE1, the second electronic device performs deserialization to obtain repE1. The second electronic device parses repE1 to obtain the name of the distributed file. In this embodiment, the second electronic device can read the name of the distributed file according to the type and offset position in the message header of repE1. Then, the second electronic device opens the corresponding distributed file according to the name, and returns the handle VFd of the distributed file, and writes the handle VFd object of the distributed file into repE1 to obtain repE2.

[0306] In summary, the Parcel packet serialization method provided in this application embodiment can, in scenarios where Parcel packets are transmitted across devices, replace the file handle object with the name of the corresponding distributed file before serialization and transmission if the Parcel packet contains a file handle object. That is, the local resource (file handle object) is replaced with the cross-device resource (name of the distributed file) before serialization and transmission. Upon receiving the serialized Parcel packet at the other end, deserialization is performed to obtain the name of the distributed file. Then, the corresponding distributed file is opened based on the name, and the file handle object corresponding to the locally created distributed file is obtained. Therefore, the above Parcel packet serialization method can achieve cross-device transmission of Parcel packets containing file handle objects.

[0307] Please see Figure 20 ,like Figure 20 In the cross-device data transmission method flowchart shown (refer to steps S201-S209), after the first electronic device calls the target service of the second electronic device, namely the distributed application management service, the second electronic device, after obtaining the execution result, follows the specific steps of the camera application sending the captured data back to the note. Specifically, it first obtains the note's File Provider object, and then uses that object to obtain the file handle. The second electronic device sends a request to the first electronic device to obtain the first file handle object. After obtaining the first file handle object of the preset file, the first electronic device creates a corresponding first distributed file based on the first file handle object, and then sends the file name of the first distributed file to the second electronic device. The second electronic device opens the corresponding second distributed file using the received file name and obtains the corresponding second file handle object. Then, the second electronic device writes the acquired captured data into the first distributed file. The captured data in the second distributed file is then transmitted to the first distributed file of the first electronic device, and then further written into the preset file of the first electronic device.

[0308] Therefore, through the above-mentioned cross-device data transmission method, the cross-device transmission of Parcel packages containing file handle objects can be realized, enabling the return of photographed data to the calling application of the first electronic device, thus realizing the complete process of cross-device calling.

[0309] In this embodiment of the application, during the process of a client calling a service on the server, the server application may exit. For example, the server application may exit due to some kind of exception, or the application may exit normally in response to a user's operation. Both of these situations can be considered as an exception occurring in the server application. In this case, both the client application and the server application need to clean up the locally stored resources to avoid resource redundancy.

[0310] Therefore, this application provides a cross-device service call resource cleanup method, which can clean up the resources stored in the client application and the server application when the server application exits.

[0311] In this embodiment, the cross-device service call resource cleanup method described above can be applied to scenarios where a first electronic device (client) calls a service from a second electronic device (server). The first electronic device can be a personal computer, tablet, mobile phone, etc., and the second electronic device can be a tablet, mobile phone, etc.

[0312] If the first electronic device is a personal computer, the above-mentioned cross-device service call resource cleanup method is introduced by taking the application 1 of the first electronic device calling the service S1 of the application 2 of the second electronic device as an example.

[0313] Please see Figure 21 ,like Figure 21 In the resource cleanup method flowchart shown (refer to steps S301-S307), after the first electronic device calls the target service of the second electronic device, it registers a cleanup service for the acquired target service and sends a registration instruction for the cleanup service to the second electronic device based on the first IBinder object of the cleanup service. The second electronic device receives the registration instruction from the first electronic device and obtains the fourth IBinder object of the cleanup service. In response to the exit of the target service, the second electronic device executes the cleanup service based on the fourth IBinder object and sends a request to the first electronic device to invoke the service. In response to receiving the first cleanup invocation request from the second electronic device, the second electronic device executes the cleanup service based on the first IBinder object. Here, registering the cleanup service means registering a death notification. The cleanup resources mainly include the target service and the invocation resources of the cleanup service, and the invocation resources include the resources used by the electronic device when invoking the corresponding service. The above steps are described in detail below.

[0314] The overall flow of the cross-device service call resource cleaning method can mainly include four parts: service registration of the first electronic device, service obtaining of the second electronic device, service registration death notification of the first electronic device, and service exit of the second electronic device. The registered and obtained services of the electronic device can be any service, such as a distributed application management service, an audio service, and the like. The registration death notification is used to notify the client of the service end due to internal errors or other conditions after the Binder communication is established.

[0315] Referring to Figure 22 , Figure 22 A timing diagram of a cross-device service call resource cleaning method provided by an embodiment of the present application is shown in FIG. 2. As shown in FIG. 2, the service name registered by the application 2 is "ServiceS1", and the service registration process of the application 2 is the same as the service registration process in the cross-device service call method. Specifically, the "ServiceS1" service of the application 2 is registered in the distributed service management module of the service coordination module, and the service name ("ServiceS1") and the IBinder object (IBinder S1) of the "ServiceS1" service are stored in the distributed service management module. The distributed Binder management module allocates a corresponding BinderId (BinderId S1) for the "ServiceS1" service. Figure 22

[0316] After the second electronic device stores the service name, the IBinder object, and the corresponding BinderId, the service registration of the first electronic device is successful. The first electronic device can obtain the "ServiceS1" service registered in the second electronic device. Specifically, the first electronic device initiates a service obtaining request to the second electronic device, and the request carries the device identifier (DeviceId) and the service name ("ServiceS1") when the request is initiated. The distributed Binder management module of the first electronic device can assemble a message (carrying the service name) and send the message to the distributed Binder management module of the second electronic device through the channel established between the communication module of the first electronic device and the communication module of the second electronic device.

[0317] The first electronic device can establish a connection with the second electronic device according to the device identifier in the request.

[0318] ​The distributed Binder management module of the second electronic device finds the corresponding service according to the service name carried in the message in the distributed service management module. The distributed service management module stores the correspondence between the service name and the IBinder object. After the corresponding service is found, the IBinder object corresponding to the service is determined, and the IBinder object is returned to the distributed Binder management module of the second electronic device, and the BinderId S1 corresponding to the IBinder object is determined.

[0319] Then, the distributed Binder management module of the second electronic device can assemble a message (carrying BinderId S1) and send the message to the distributed Binder management module of the first electronic device through the channel established between the communication module of the first electronic device and the communication module of the second electronic device.

[0320] After the distributed Binder management module of the first electronic device receives the message, BinderId S1 is obtained by parsing, and a local IBinder object (IBinder C1) is created according to BinderId S1. Wherein, IBinder C1 and BinderId S1 establish a mapping relationship.

[0321] Then, the newly created Ibinder object is returned to the distributed service management module of the first electronic device and the application 1 of the first electronic device in turn.

[0322] After the first electronic device obtains the service S1, that is, the first electronic device obtains the IBinder reference object (IBinder C1) of the service S1, the first electronic device can register the death notification for IBinder C1.

[0323] Specifically, the application 1 of the first electronic device sends a request (that is, a request parcel, set as req1) to the distributed Binder management module of the first electronic device, wherein the req1 contains recipient C1. The distributed Binder management module of the first electronic device allocates a corresponding BinderId (BinderId C1) for recipient C1. Wherein, the mapping relationship between recipient C1 and BinderId C1 is established.

[0324] It can be understood that RecipientC1 is an anonymous binder object created by application 1 itself.

[0325] The distributed Binder management module of the first electronic device replaces recipient C1 in req1 with BinderId C1 and serializes the req1. Then, the distributed Binder management module of the first electronic device can assemble a message (carrying the serialized req1) and send the message to the distributed Binder management module of the second electronic device through the channel established between the communication module of the first electronic device and the communication module of the second electronic device.

[0326] The distributed Binder management module of the second electronic device parses the received message to obtain the serialized req1 (req1 byte stream). The distributed Binder management module of the second electronic device deserializes the req1 byte stream to obtain req1 and parses BinderId C1 in req1.

[0327] The distributed Binder management module of the second electronic device creates recipient S1 and associates it with BinderId C1. The distributed Binder management module of the second electronic device sends an instruction to register a death notification to application 2, that is, the distributed Binder management module of the second electronic device sends an instruction to register a death notification for IBinder S1 (Service S1) to application 2.

[0328] After the second electronic device successfully registers the death notification, a registration result is returned to the first electronic device.

[0329] At this time, the first electronic device and the second electronic device have both completed the registration of the death notification. When the service of the second electronic device exits, the first electronic device and the second electronic device can clean up service-related resources according to the death notification mechanism.

[0330] In the embodiment of the application, after application 2 of the second electronic device exits, the driver of the second electronic device triggers the recipient S1 death notification callback binderDied function, and the local Service S1 related resources are cleaned up in the binderDied function, including the mapping relationship of Service S1 and its ServiceName and BinderId.

[0331] After the second electronic device is cleaned up, a message is sent to the first electronic device to clean up the service associated with Service S1, triggering the resource cleaning and application notification of the first electronic device.

[0332] The first electronic device receives the message and finds the recipientC1 of the service ServiceC1 associated with the ServiceS1, and calls the binderDied function of the death notification interface with the recipientC1. After the application receives the callback, it cleans up the resources related to the ServiceC1 by itself.

[0333] After the recipientC1 callback of the first electronic device is completed, first, the resources related to the ServiceC1 in the first electronic device are cleaned up, such as the mapping relationship of the ServiceC1 and the ServiceName and the BinderId thereof; second, the mapping relationship of the recipientC1 and the BinderId thereof is cleaned up.

[0334] In the embodiment of the application, the second electronic device can first clean up the local resources, and then send a message to the first electronic device to clean up the resources (such as the steps of the first electronic device). Figure 22 Alternatively, the second electronic device can first send a message to the first electronic device to clean up the resources, and then clean up the local resources. Alternatively, the second electronic device can process in parallel: while cleaning up the local resources, the second electronic device sends a message to the first electronic device to clean up the resources. After the second electronic device sends a message to the first electronic device to clean up the resources, and after cleaning up the local resources, the mapping relationship of the recipientC1 and the BinderId thereof and the corresponding calling resources of the death notification can be cleaned up.

[0335] It can be understood that the service call is normal when the death notification is registered. That is, after the first electronic device obtains the service registered by the second electronic device, the death notification needs to be registered. If the death notification is registered when the service exits, it is meaningless, and the two ends cannot be notified in time to clean up the service calling resources.

[0336] After the first electronic device and the second electronic device complete the resource cleaning, the first electronic device needs to obtain the service of the second electronic device again and re-register the death notification when the first electronic device calls next time.

[0337] In summary, the application 1 of the first electronic device can receive the service exit message of the second electronic device in time, can clean up the stored resources in time, and can avoid causing resource redundancy in the first electronic device. After the first electronic device cleans up the related resources of the service call in time, the first electronic device no longer has information related to the service (such as the calling interface of the application 1 no longer displays the corresponding second electronic device and service), and the problem of calling failure of the service again (such as the user's click operation on the second electronic device and the service in the calling interface is invalid) does not occur, and the user's operation experience can be improved.

[0338] This application also provides a chip system, such as... Figure 23 As shown, the chip system 90 includes at least one processor 901 and at least one interface circuit 902. The processor 901 and the interface circuit 902 are interconnected via lines. For example, the interface circuit 902 can be used to receive signals from other devices (e.g., the memory of an electronic device). As another example, the interface circuit 902 can be used to send signals to other devices (e.g., the processor 901). Exemplarily, the interface circuit 902 can read instructions stored in the memory and send those instructions to the processor 901. When the instructions are executed by the processor 901, the electronic device can perform the steps in the above embodiments. Of course, the chip system may also include other discrete devices, and this application embodiment does not specifically limit this.

[0339] This application also provides a computer storage medium that includes computer instructions. When the computer instructions are executed on the electronic device, the electronic device causes the electronic device to perform various functions or steps performed by the mobile phone in the above method embodiment.

[0340] This application also provides a computer program product that, when run on a computer, causes the computer to perform the various functions or steps performed by the mobile phone in the above method embodiments.

[0341] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0342] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0343] The units described as separate components may or may not be physically separate, and the components displayed as units may be a physical unit or multiple physical units, that is, may be located in one place, or also can be distributed to multiple different places. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.

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

[0345] The integrated unit, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in a readable storage medium. Based on such understanding, the technical scheme of the embodiments of the present application essentially or the part that contributes to the prior art or the whole or part of the technical scheme can be embodied in the form of a software product, which is stored in a storage medium and includes a plurality of instructions for causing an apparatus (which can be a single-chip microcomputer, a chip, etc.) or a processor to execute all or part of the steps of the method described in the embodiments of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various program code storage media.

[0346] The above is only a specific embodiment of the present application, but the protection scope of the present application is not limited thereto, any change or replacement within the technical scope disclosed in the present application should be covered in 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. A resource cleanup method, applied to a first electronic device, characterized in that, The method includes: The first electronic device registers a cleanup service for the target service of the second electronic device; wherein, the cleanup service is used to trigger the first electronic device to clean up the target service and the calling resources of the cleanup service; the calling resources include the resources used by the first electronic device when calling the corresponding service; The first electronic device sends a registration instruction for the cleanup service to the second electronic device based on a first IBinder object of the cleanup service; wherein, the registration instruction is used to instruct the second electronic device to register for the cleanup service of the target service; the registration instruction for the cleanup service includes a second Binder ID; In response to receiving a first cleanup call request from the second electronic device, the first electronic device performs the cleanup service based on the first IBinder object; wherein the first cleanup call request is sent by the second electronic device in response to the exit of the target service, and the first cleanup call request contains the second Binder ID of the cleanup service.

2. The resource cleanup method according to claim 1, characterized in that, Before the first electronic device registers a cleanup service for the target service of the second electronic device, the method further includes: The first electronic device displays the display interface of the first application, which includes multiple device controls. Each device control corresponds to a device that has established a preset wireless connection with the first electronic device, and each device control includes one or more services provided by the corresponding device. The first electronic device receives a first touch operation from a user on a target device control among the plurality of device controls, and the first touch operation corresponds to a target service of the second electronic device; In response to the first touch operation, the first electronic device obtains the first Binder ID corresponding to the target service from the second electronic device, and creates a second IBinder object based on the first Binder ID; wherein, the first Binder ID is determined by the second electronic device based on the third IBinder object of the target service when registering the target service, and the second IBinder object and the third IBinder object are used to invoke the target service.

3. The resource cleanup method according to claim 2, characterized in that, The first electronic device sends a registration instruction for the cleanup service to the second electronic device based on the first IBinder object of the cleanup service, including: The first electronic device obtains the first IBinder object of the cleaning service based on the second IBinder object; The first electronic device creates a corresponding second Binder ID based on the first IBinder object and sends the second Binder ID to the second electronic device.

4. The resource cleanup method according to claim 3, characterized in that, In response to receiving a first cleanup invocation request from the second electronic device, the first electronic device performs the cleanup service based on the first IBinder object, including: In response to receiving the first cleanup call request, the first electronic device searches for the corresponding first IBinder object based on the second Binder ID contained in the first cleanup call request; The first electronic device performs the cleanup service based on the first IBinder object.

5. The resource cleanup method according to any one of claims 1-4, characterized in that, Before the first electronic device responds to receiving a first cleanup call request from the second electronic device, the method further includes: The first electronic device receives a registration message from the second electronic device; wherein the registration message is used to instruct the second electronic device to complete the registration for the cleanup service.

6. The resource cleanup method according to any one of claims 2-4, characterized in that, The invoked resources include the service name of the target service, the second IBinder object, the first Binder ID, and the first IBinder object and the second Binder ID of the cleanup service.

7. The resource cleanup method according to claim 3 or 4, characterized in that, The first electronic device obtains the first IBinder object of the cleaning service based on the second IBinder object, including: The first application of the first electronic device obtains the first IBinder object of the cleaning service based on the second IBinder object; Wherein, the first electronic device creates a corresponding second Binder ID based on the first IBinder object, and sends the second Binder ID to the second electronic device, including: The first application sends the first IBinder object to the distributed Binder management module of the first electronic device; The distributed Binder management module creates a corresponding second Binder ID based on the first IBinder object, and sends the second Binder ID to the second electronic device through the communication module of the first electronic device.

8. The resource cleanup method according to claim 7, characterized in that, In response to receiving the first cleanup call request, the first electronic device locates the corresponding first IBinder object based on the second Binder ID contained in the first cleanup call request, including: The distributed Binder management module of the first electronic device receives the first cleanup call request through the communication module of the first electronic device, and searches for the corresponding first IBinder object based on the second Binder ID contained in the first cleanup call request; The first electronic device performs the cleanup service based on the first IBinder object, including: The distributed Binder management module calls the cleanup service based on the first IBinder object to clean up the call resources of the target service stored in the distributed Binder management module; The distributed Binder management module sends a cleanup notification to the first application; In response to the cleanup notification, the first application cleans up the target service and the call resources of the cleanup service stored in the first application.

9. A resource cleanup method, applied to a second electronic device, characterized in that, The method includes: The second electronic device receives a registration instruction from the first electronic device; wherein the registration instruction is used to instruct the second electronic device to register a cleanup service for the target service; the cleanup service is used to trigger the second electronic device to clean up the target service and the invocation resources of the cleanup service; the invocation resources include the resources used by the first electronic device when invoking the corresponding service; The second electronic device acquires the fourth IBinder object of the cleaning service; In response to the exit of the target service, the second electronic device performs the cleanup service based on the fourth IBinder object and instructs the first electronic device to perform the cleanup service; The instruction to the first electronic device to perform the cleaning service includes: In response to the exit of the target service, the second electronic device sends a first cleanup call request to the first electronic device based on the fourth IBinder object; wherein, the first cleanup call request is used to instruct the first electronic device to clean up the target service and the call resources of the cleanup service.

10. The resource cleanup method according to claim 9, characterized in that, Before the second electronic device receives a registration instruction from the first electronic device, the method further includes: The second electronic device receives an acquisition instruction from the first electronic device and searches for the first Binder ID of the target service based on the acquisition instruction; wherein, the first Binder ID is determined by the second electronic device when registering the target service based on the third IBinder object of the target service, and the third IBinder object is used to invoke the target service; The second electronic device sends the first Binder ID to the first electronic device.

11. The resource cleanup method according to claim 9, characterized in that, The second electronic device acquires the fourth IBinder object of the cleaning service, including: The second electronic device receives a second Binder ID from the first electronic device and creates a fourth IBinder object based on the second Binder ID; wherein the second Binder ID is created by the first electronic device based on a first IBinder object of the cleanup service, and the first IBinder object is used to invoke the cleanup service; The process further includes, after the second electronic device acquires the fourth IBinder object of the cleaning service: The second electronic device sends a registration message to the first electronic device; wherein the registration message is used to instruct the second electronic device to complete the registration for the cleanup service.

12. The resource cleanup method according to claim 11, characterized in that, In response to the exit of the target service, the second electronic device sends a first cleanup call request to the first electronic device based on the fourth IBinder object, including: In response to the exit of the target service, the second electronic device sends a first cleanup call request to the first electronic device based on the fourth IBinder object; wherein the first cleanup call request includes the second BinderID.

13. The resource cleanup method according to claim 11, characterized in that, The second electronic device receives a second Binder ID from the first electronic device and creates a fourth IBinder object based on the second Binder ID, including: The distributed Binder management module of the second electronic device receives the second Binder ID from the first electronic device through the communication module of the second electronic device, and creates a fourth Binder object based on the second Binder ID.

14. The resource cleanup method according to claim 12 or 13, characterized in that, In response to the exit of the target service, the second electronic device sends a first cleanup call request to the first electronic device based on the fourth IBinder object, including: In response to the exit of the target service, the distributed Binder management module of the electronic device sends a first cleanup call request to the first electronic device through the communication module of the second electronic device based on the fourth IBinder object; wherein the first cleanup call request contains the second Binder ID.

15. The resource cleanup method according to claim 9, characterized in that, In response to the exit of the target service, the second electronic device performs the cleanup service based on the fourth IBinder object, including: In response to the exit of the target service, the distributed Binder management module of the second electronic device calls the cleanup service based on the fourth IBinder object to clean up the call resources of the target service stored in the distributed Binder management module.

16. An electronic device, characterized in that, The electronic device includes: a communication module, a display screen, a memory, and one or more processors; the communication module, the display screen, the memory, and the processors are coupled; the memory is used to store computer program code, the computer program code including computer instructions, which, when executed by the electronic device, cause the electronic device to perform the method as described in any one of claims 1-15.

17. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed in an electronic device, cause the electronic device to perform the method as described in any one of claims 1 to 15.

Citation Information

Patent Citations

  • Micro-service instance exit method and device, equipment and storage medium

    CN112799786A