Cross-device data processing method and electronic device
Through cross-device service calls and data processing methods, the serialized transmission of distributed files and Binder objects is solved, and the problem of cumbersome operations between multiple devices is realized, direct data transmission and service calls are improved, and user work efficiency is improved.
Patent Information
- Application Number
- CN202310541285.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-12
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2043-05-12
AI Technical Summary
In the prior art, users need to switch back and forth between multiple devices and data transmission, and the operation is cumbersome, and direct data processing and service calls across devices cannot be realized, especially when the computer does not have a rear camera, it is impossible to conveniently shoot and organize. Blackboard content.
By implementing service calls and data processing methods across devices between electronic devices, using serialized transmission of distributed files and Binder objects, the first electronic device is allowed to call the services of the second electronic device and directly pass the shooting or scanning results. Simplify the operation process.
Realize direct data transmission and service calls across devices, reduce the complexity of user operations and improve work efficiency. Especially when shooting content on the blackboard, it can directly return the results to the computer, avoiding the steps of multiple uploads and downloads. .
Smart Images

Figure CN118945179A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of electronic devices, and in particular to a cross-device data processing method and electronic device. Background Art
[0002] Currently, since different types of electronic devices have different functions, users will use more convenient electronic devices according to different scenarios. For example, since the screen of a computer is larger than that of a mobile phone, users usually use a computer to organize notes for study, while in offline classes, they need to take pictures of the blackboard content and insert them into the computer notes.
[0003] Since there is no rear camera on the computer, the existing solution is to use the mobile phone to shoot the blackboard content, then upload the captured content to the computer, then download and save it to the computer, and finally upload it to the computer's notes. However, in this method, switching back and forth between multiple devices and transmitting data is relatively cumbersome. Summary of the invention
[0004] The embodiments of the present application provide a cross-device data processing method and an electronic device, which can realize cross-device calling of services, reduce the complexity of operations, and improve user work efficiency.
[0005] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:
[0006] The embodiments of the present application provide a cross-device data processing method and an electronic device, which can implement cross-device calling of services, reduce the complexity of operations, and improve user work efficiency.
[0007] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:
[0008] In a first aspect, a cross-device data processing method is provided, which can be applied to a first electronic device. The method includes: the first electronic device calls a target service of a second electronic device; the first electronic device obtains a first file handle object of a preset file, and creates 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 the result of the second electronic device executing the target service; the first distributed file and the 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 by the first electronic device to return the preset data in the first distributed file to the preset file.
[0009] The first electronic device sends the file name of the first distributed file to the second electronic device, so that the second electronic device opens the corresponding second distributed file based on the file name, and the second distributed file is used to obtain 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; the first electronic device returns the preset data in the first distributed file to the preset file through the first file handle object.
[0010] Through this solution, when transmitting complex objects such as file handle objects, the file handle objects can be replaced before transmission, so that devices at both ends can access each other.
[0011] In one possible implementation, the first electronic device obtains the first file handle object of a preset file, including: the first electronic device receives a first request from a second electronic device to obtain the first file handle object of the preset file; wherein the first request is used for the second electronic device to request the first electronic device to obtain the first file handle object.
[0012] In a possible implementation, before the first electronic device sends the file name of the first distributed file to the second electronic device, the method further includes: the first electronic device generates a first transmission data packet based on the first file handle object; wherein the first transmission data packet includes the first file handle object; the first electronic device replaces the first file handle object in the first transmission data packet with the file name of the first distributed file to obtain a second transmission data packet;
[0013] In a possible implementation manner, the first electronic device sends the file name of the first distributed file to the second electronic device, including: the first electronic device sends a second transmission data packet to the second electronic device.
[0014] In a possible implementation, before the first electronic device sends the file name of the first distributed file to the second electronic device, the method further includes: the first electronic device generates a first transmission data packet based on the first file handle object; wherein the first transmission data includes the first file handle object; the first electronic device replaces the first file handle object in the first transmission data packet with the file name of the first distributed file and a preset placeholder to obtain a second transmission data packet; wherein the first file handle object is stored in the first byte of the first transmission data packet, the file name and the preset placeholder are stored in the second byte of the second transmission data packet, the first byte and the second byte are the same in size, and the position of the first byte in the first transmission data packet corresponds to the position of the second byte in the second transmission data packet;
[0015] In a possible implementation manner, the first electronic device sends the file name of the first distributed file to the second electronic device, including: the first electronic device sends a second transmission data packet to the second electronic device.
[0016] In a possible implementation, a first electronic device sends a second transmission data packet to a second electronic device, including: the first electronic device serializes the second transmission data packet to obtain corresponding first serialized data; and the first electronic device sends the first serialized data to the second electronic device.
[0017] In a possible implementation, the first electronic device generates a first transmission data packet based on the first file handle object, including: a first application of the first electronic device generates the first transmission data packet based on the first file handle object.
[0018] In a possible implementation, after the first electronic device generates the first transmission data packet based on the first file handle object, the method further includes: the first application sends the first transmission data packet to the distributed Binder management module of the first electronic device; the distributed Binder management module receives the first transmission data packet, and sends a creation instruction for the first distributed file to the distributed file module of the first electronic device based on the first file handle object in the first transmission data packet; the distributed file module creates the first distributed file based on the creation instruction, and sends a creation success instruction to the distributed Binder management module;
[0019] In one possible implementation, the first electronic device replaces the first file handle object in the first transmission data packet with the file name of the first distributed file to obtain a second transmission data packet, including: the distributed Binder management module replaces the first file handle object in the first transmission data packet with the file name of the first distributed file in response to a creation success instruction to obtain a second transmission data packet.
[0020] In a possible implementation, the first electronic device serializes the second transmission data packet to obtain corresponding first serialized data, including: a distributed Binder management module of the first electronic device serializes the second transmission data packet to obtain the first serialized data;
[0021] In a possible implementation, the first electronic device sends the first serialized data to the second electronic device, including: the distributed Binder management module sends the first serialized data to the second electronic device through the communication module of the first electronic device.
[0022] In a second aspect, a cross-device data processing method is provided, which is applied to a second electronic device, and the method includes: the second electronic device receives the file name of a first distributed file from the first electronic device; wherein the first distributed file is created by the first electronic device based on a first file handle object of a preset file, and is used with a second distributed file in the second electronic device to support data access between the first electronic device and the second electronic device, the preset file is used to save preset data, and the preset data is the result of the second electronic device executing a target service, and the first file handle object is used by the first electronic device to return the preset data in the first distributed file to the preset file; the second electronic device opens the corresponding second distributed file based on the file name, and obtains the second file handle object of the second distributed file; wherein the second file handle object is used by the second distributed file to obtain the preset data; the second distributed file of the second electronic device obtains the preset data through the second file handle object, and transmits the preset data to the first distributed file of the first electronic device, so that the first electronic device returns the preset data in the first distributed file to the preset file through the first file handle object.
[0023] In a possible implementation, before the first electronic device obtains the first file handle object of the preset file, the method further includes: the second electronic device sends a first request to the first electronic device; wherein the first request is used for the second electronic device to request the first electronic device to obtain the first file handle object of the preset file.
[0024] In one possible implementation, a second electronic device receives a file name of a first distributed file from a first electronic device, including: the second electronic device receives a second transmission data packet sent by the first electronic device; wherein the second transmission data packet is obtained by the first electronic device replacing a first file handle object in the first transmission data packet with the file name, and the first transmission data packet is generated by the first electronic device based on the first file handle object.
[0025] In one possible implementation, a second electronic device receives a second transmission data packet sent by a first electronic device, including: the second electronic device receives first serialized data sent by the first electronic device, and deserializes the first serialized data to obtain a corresponding second transmission data packet; wherein the first serialized data is obtained by the first electronic device serializing the second transmission data packet.
[0026] In one possible implementation, the second electronic device opens the corresponding second distributed file based on the file name and obtains the second file handle object of the second distributed file, including: the second electronic device opens the corresponding second distributed file based on the file name in the second transmission data packet and obtains the second file handle object of the second distributed file.
[0027] In one possible implementation, after the second electronic device opens the corresponding second distributed file based on the file name and obtains the second file handle object of the second distributed file, the method also includes: the second electronic device replaces the file name in the second transmission data packet with the second file handle object to obtain a third transmission data packet.
[0028] In one possible implementation, a second electronic device receives first serialized data sent by a first electronic device, and deserializes the first serialized data to obtain a corresponding second transmission data packet, including: a distributed Binder management module of the second electronic device receives the first serialized data sent by the first electronic device through a communication module of the second electronic device; the distributed Binder management module deserializes the first serialized data to obtain a corresponding second transmission data packet.
[0029] In one possible implementation, the second electronic device opens the corresponding second distributed file based on the file name in the second transmission data packet and obtains the second file handle object of the second distributed file, including: the distributed Binder management module of the second electronic device sends an open instruction to the distributed file module of the second electronic device based on the file name; wherein the open instruction includes the file name; the distributed file module responds to the open instruction, opens the second distributed file corresponding to the file name, and sends the second file handle object of the second distributed file to the distributed Binder management module.
[0030] In one possible implementation, the second electronic device replaces the file name in the second transmission data packet with the second file handle object to obtain a third transmission data packet, including: the distributed Binder management module of the second electronic device replaces the file name in the second transmission data packet with the second file handle object to obtain the third transmission data packet.
[0031] In a possible implementation, after the second electronic device replaces the file name in the second transmission data packet with the second file handle object to obtain the third transmission data packet, the method further includes: the distributed Binder management module sends the third transmission data packet to the second application of the second electronic device.
[0032] In one possible implementation, the second distributed file of the second electronic device obtains preset data through the second file handle object, and transmits the preset data to the first distributed file of the first electronic device, including: the second application returns the obtained preset data to the second distributed file through the second file handle object in the third transmission data packet; the second distributed file transmits the preset data to the first distributed file of the first electronic device.
[0033] In summary, this solution can be used in the scenario where the Parcel package (transmission data package) is transmitted across devices. If the Parcel package contains a file handle object, the file handle object is replaced with the name of the corresponding distributed file, and then serialized and transmitted. That is, the local resource (file handle object) is replaced with the cross-device resource (the name of the distributed file) and then serialized and transmitted. After receiving the serialized parcel package at the other end, deserialization is performed first to obtain the name of the distributed file. Then, the corresponding distributed file is opened according to the name of the distributed file, and the file handle object corresponding to the locally created distributed file is obtained. In this way, cross-device transmission of the Parcel package containing the file handle object can be realized.
[0034] For example, in the process of the camera application of the second electronic device obtaining the file handle of the photo cache file of the note application of the first 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 data packet 2. Then, the data packet 2 is serialized to obtain serialized data (parcel byte stream), which is then transmitted to the second electronic device through the network.
[0035] After receiving the serialized data (parcel byte stream), the second electronic device deserializes it to obtain data packet 2. The second electronic device parses 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 and obtains the file handle object of the second distributed file. The photo data obtained by the camera application is written into the second distributed file through the file handle object, and the second distributed file transfers the photo data to the first distributed file. The first distributed file then returns the photo data to the photo cache file. In this way, the cross-device transmission of the Parcel package containing the file handle is realized, and the result of the cross-device return execution service is achieved.
[0036] The above cross-device service transmission method can be applied to a cross-device service calling method.
[0037] Optionally, a cross-device service calling method can also be provided, which can be applied to a 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 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 of a user on a target device control among multiple device controls, and the first touch operation corresponds 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; wherein the first Binder ID is determined according to the first IBinder object of the distributed application management service when the second electronic device registers the distributed application management service, and the first IBinder object and the second IBinder object are used to call the distributed application management service.
[0038] The first electronic device, in response to receiving the first request from the second electronic device, searches for the corresponding second IBinder object according to the first Binder ID included 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 the second touch operation of the user on the second application, the second touch operation is used to confirm the 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 to return the result of executing the distributed application management service to the first electronic device;
[0039] In response to receiving a second request from a second electronic device, the first electronic device indicates a 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 a preset cache file for calling the first application; 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.
[0040] By adopting this technical solution, the user can use the first electronic device to send a shooting instruction to the second electronic device. After receiving the shooting instruction, the second electronic device will call up the camera to perform the shooting or scanning task, and after completion, the shooting result or the scanned text will be directly sent back to the first electronic device. This can save the user the steps 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. The operation is simpler and the user's work efficiency is improved.
[0041] Optionally, a cross-device service calling method can also be provided, which is applied to a second electronic device, the method comprising: the second electronic device sends a first request to the first electronic device based on the first Binder ID of the distributed application management service in response to the second touch operation of the user on the second application of the second electronic device; wherein the first request is used to request to obtain the first file providing object of the first application of the first electronic device, the first Binder ID is determined according to the 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 the 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 to return 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; wherein the second request is used to request to obtain the first file handle object of the preset cache file used to call 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.
[0042] Optionally, a cross-device service calling method can also be provided, which is applied to a first electronic device, and the method includes: the first electronic device displays a display interface of a first application, the display interface of the first application 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 of a user on a target device control among the multiple device controls, and the first touch operation corresponds to a target service of the second electronic device; the first electronic device obtains a first Binder identification ID corresponding to the target service from the second electronic device, and creates a second IBinder object based on the first Binder identification ID; wherein the first Binder identification ID is determined according to the first IBinder object of the target service when the second electronic device registers 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 call request to the second electronic device based on the second IBinder object; wherein the call request includes the first Binder identification ID of the second IBinder object, and the call request is used to request to call the target service of the second application in the second electronic device; the first electronic device receives a call response from the second electronic device, and the call response includes the result of the first electronic device calling the target service.
[0043] By adopting this technical solution, after the first electronic device receives the BinderId of the IBinder object corresponding to the service of the second electronic device, it can create an IBinder object on the local side corresponding to the BinderId, and then call the service of the second electronic device through the IBinder object on the local side, thereby realizing cross-device service calling.
[0044] Optionally, another cross-device service calling method can also be provided, which is applied to a second electronic device, and the method includes: the second electronic device receives a calling request from a first electronic device; wherein the calling request includes a first Binder identification 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 searches for 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 the result of calling the target service.
[0045] Optionally, a cross-device data processing method can also be provided, which can be applied to a first electronic device. The method includes: the first electronic device obtains a first IBinder object, and creates a corresponding Binder identification 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 a Binder ID to a 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 by the second electronic device to call the target service.
[0046] Through this solution, when a parcel package contains complex objects such as a Binder object, the Binder object in the parcel package can be replaced and then serialized so that the devices at both ends can access each other.
[0047] In the above cross-device service calling method, another cross-device data transmission including a binder object is also involved.
[0048] Optionally, another cross-device data processing method can be provided and applied to a second electronic device, the method comprising: the second electronic device receives a Binder identification ID sent by a first electronic device; wherein the Binder ID is created by the first electronic device based on a first IBinder object, and the first IBinder object is acquired by the first electronic device and is used to call a 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.
[0049] In summary, in the scenario where the Parcel package is transmitted across devices, if the Parcel package contains a Binder object, the Binder object can be replaced with the corresponding BinderId before serialization and transmission. That is, the local resource (Binder object) is replaced with the cross-device resource (BinderId) and then serialized and transmitted. After receiving the serialized parcel package at the other end, it is first deserialized to obtain the BinderId, and then the BinderId is replaced with the locally created Binder object, so that the Parcel package containing the Binder object can be transmitted across devices.
[0050] 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 assigns a corresponding BinderId to the File Provider object (IFile Pc object). Before serialization, the first electronic device can replace the IFilePc object in data packet 1 (parcel package) with the corresponding BinderId to obtain data packet 2. Then, the data packet 2 is serialized to obtain serialized data (parcel byte stream), which is then transmitted to the second electronic device via the network.
[0051] After receiving the serialized data (parcel byte stream), the second electronic device deserializes it to obtain data packet 2. The second electronic device parses data packet 2 to obtain BinderId. Then, the reference object IFile Ps object corresponding to BinderId is created locally on the second electronic device, and the IFile Ps object is written into data packet 2 to obtain data packet 3. Thus, the cross-device transmission of the Parcel package containing the Binder object (File Provider object) is realized.
[0052] In the process of the client (first electronic device) calling a service of the server (second electronic device), the server application may exit. For example, an abnormality occurs in the server application, causing the application to exit, or the application exits normally in response to a user operation. The above situations can all be considered as abnormalities in the server application. At this time, both the client application and the server application need to clean up the locally stored resources to avoid resource redundancy.
[0053] Optionally, a resource cleaning method can also be provided, which can be applied to a first electronic device. The method includes: 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 up the target service and the calling resources of the cleaning 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 indication of the cleaning service to the second electronic device based on the 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; the first electronic device executes the cleaning service based on the first IBinder object in response to receiving a first cleaning call 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.
[0054] Through this solution, the first electronic device can promptly receive the service exit message of the second electronic device, and can clean up the stored resources in time to avoid resource redundancy in the first electronic device.
[0055] In a possible implementation, before the first electronic device registers a cleanup service for a target service of the second electronic device, the method further 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 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 of a user on a target device control among the plurality of device controls, the first touch operation corresponds to the target service of the second electronic device;
[0056] In response to the first touch operation, the first electronic device obtains the first Binder identification 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 according to the third IBinder object of the target service when the second electronic device registers the target service, and the second IBinder object and the third IBinder object are used to call the target service.
[0057] In one possible implementation, the first electronic device sends a registration indication of a 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 cleanup 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; wherein the registration indication of the first cleanup service includes the second Binder ID.
[0058] In one possible implementation, the first electronic device performs a cleanup service based on the first IBinder object in response to receiving a first cleanup call request from the second electronic device, including: the first electronic device searches for the corresponding first IBinder object according to the second Binder ID included in the first cleanup call request in response to receiving the first cleanup call request; the first electronic device performs a cleanup service based on the first IBinder object.
[0059] In a possible implementation, before the first electronic device responds to receiving the first cleaning 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 registration for the cleaning service.
[0060] In a possible implementation, the calling resource includes 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.
[0061] In a possible implementation, the first electronic device acquires the first IBinder object of the cleaning service based on the second IBinder object, including: a first application of the first electronic device acquires the first IBinder object of the cleaning service based on the second IBinder object;
[0062] In one possible implementation, 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.
[0063] In a possible implementation, the first electronic device searches for the corresponding first IBinder object according to the second Binder ID included in the first cleanup call request in response to receiving the first cleanup call request, including: a distributed Binder management module of the first electronic device receives the first cleanup call request through a communication module of the first electronic device, and searches for the corresponding first IBinder object according to the second Binder ID included in the first cleanup call request;
[0064] In one possible implementation, the first electronic device performs a 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 calling 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; the first application responds to the cleanup notification to clean up the target service stored in the first application and the calling resources of the cleanup service.
[0065] Optionally, another resource cleanup method can be provided and applied to a second electronic device, the method comprising: the second electronic device receives a registration indication from a first electronic device; wherein the registration indication is used to instruct the second electronic device to register a cleanup service for a target service; the cleanup service is used to trigger the second electronic device to clean up the target service and call resources for the cleanup service; the calling resources include resources used by the first electronic device when calling the corresponding service; the second electronic device obtains a fourth IBinder object for the cleanup service; and the second electronic device executes the cleanup service based on the fourth IBinder object in response to the exit of the target service.
[0066] In a possible implementation, the method further includes: the second electronic device responds to the exit of the target service and 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 calling resources of the cleanup service.
[0067] It is understandable that after cleaning up the calling resources of the target service, the second electronic device can clean up the calling resources of the cleaning service. In summary, the first electronic device and the second electronic device can clean up the locally stored resources to avoid resource redundancy.
[0068] 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, and the computer program code includes computer instructions, and when the computer instructions are executed by the electronic device, the electronic device executes the methods described in the first aspect to the second aspect above.
[0069] In a fourth aspect, the present application provides a computer-readable storage medium, which stores instructions. When the computer-readable storage medium is executed on a computer, the computer can execute any one of the methods described in the first to second aspects above.
[0070] In a fifth aspect, the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any one of the methods described in the first to second aspects above.
[0071] In a sixth aspect, the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method described in any one of the first to second aspects above.
[0072] It can be understood that the electronic device described in the third aspect provided above, the computer-readable storage medium described in the fourth aspect, the computer program product described in the fifth aspect, and the chip described in the sixth aspect are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] Figure 1 A schematic diagram of a scenario for inserting blackboard content into an offline classroom provided in an embodiment of the present application;
[0074] Figure 2 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0075] Figure 3 A schematic diagram of the software structure of an electronic device provided in an embodiment of the present application;
[0076] Figure 4 A timing diagram of a registration service and a service acquisition service provided in an embodiment of the present application;
[0077] Figure 5 A schematic diagram of an interface display of a note-taking application provided in an embodiment of the present application;
[0078] Figure 6A schematic diagram of another interface display of a note-taking application provided in an embodiment of the present application;
[0079] Figure 7 A schematic diagram of another interface display of a note-taking application provided in an embodiment of the present application;
[0080] Figure 8 A timing diagram for calling a service interface provided in an embodiment of the present application;
[0081] Fig. 9 A schematic diagram of a cross-device service calling method provided in an embodiment of the present application;
[0082] Fig.10 A timing diagram of registering a distributed application management service and obtaining a service provided in an embodiment of the present application;
[0083] Fig.11 A schematic diagram of a first electronic device turning on a camera of a second electronic device provided in an embodiment of the present application;
[0084] Fig.12 A timing diagram of a File Provider object for obtaining notes provided in an embodiment of the present application;
[0085] Fig.13 A timing diagram of obtaining a file handle of a note provided in an embodiment of the present application;
[0086] Fig.14 A schematic diagram of a cross-device call scenario provided in an embodiment of the present application;
[0087] Fig.15 A schematic diagram of the data structure of a parcel provided in an embodiment of the present application;
[0088] Fig.16 A schematic diagram of a cross-device data transmission method provided in an embodiment of the present application;
[0089] Fig.17 A schematic diagram of another cross-device data transmission method provided in an embodiment of the present application;
[0090] Fig.18 A schematic diagram of another cross-device data transmission method provided in an embodiment of the present application;
[0091] Fig.19 A schematic diagram of another cross-device data transmission method provided in an embodiment of the present application;
[0092] Fig. 20 A flowchart of another cross-device data transmission method provided in an embodiment of the present application;
[0093] Fig.21 A schematic diagram of a process flow of a cross-device resource cleaning method provided in an embodiment of the present application;
[0094] Fig. 22 A timing diagram of a cross-device service call resource cleanup method provided in an embodiment of the present application;
[0095] Fig.23 A schematic diagram of the structure of a chip system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0096] The following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0097] The following terms "first", "second", etc. are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, features defined as "first", "second", etc. may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "multiple" means two or more. In this application, the character " / " generally indicates that the objects associated with each other are in an "or" relationship. For example, A / B can be understood as A or B.
[0098] In addition, the terms "including" and "having" and any variations thereof mentioned in the description of this application are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or modules is not limited to the listed steps or modules, but may optionally include other steps or modules that are not listed, or may optionally include other steps or modules that are inherent to these processes, methods, products or devices.
[0099] In addition, in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present concepts in a specific way.
[0100] For ease of understanding, the following terms are introduced in this application:
[0101] (1) Binder: From Android TMAt the application layer, Binder is the medium for communication between the client and the server. The server will return a Binder object containing the server's business call. Through this Binder object, the client can obtain the services or data provided by the server.
[0102] Among them, the Binder mechanism supports both intra-process calls and inter-process calls. Android's remote calls (i.e. cross-process calls) can be implemented through IBinder. IBinder is a basic interface 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 calls to the remote IBinder object, and the second method enables the local remote object to respond to the received calls.
[0103] (2) Parcel: Parcel is a container for messages, and uses the Binder mechanism to transmit data. It can carry serialized data and transmit it through IPC, and then deserialize it at the destination. Parcel can also pass IBinder objects, and the destination will receive the proxy of the transmitted IBinder object.
[0104] Currently, in order to make learning more convenient, users usually use tablets (Pads) or personal computers (PCs) to record and organize notes. Then users need to obtain the blackboard content in offline classes and insert it into the notes on the tablet or personal computer. Or, when users organize their thesis ideas on a tablet or personal computer, they often need to use the obtained textbook content to insert references into the tablet or personal computer.
[0105] However, since there is no rear camera on personal computers, users usually use their mobile phones to take pictures or scan the contents of the blackboard or textbooks in offline classes, upload them to their personal computers, download and save them to their personal computers, and finally upload them to the corresponding location of their notes. The number of user operations is relatively high, and switching back and forth between multiple devices and transferring data is relatively cumbersome.
[0106] Alternatively, you can take a photo of the blackboard content with a tablet, but the tablet is 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 capture the full view of the blackboard content) may not be able to take photos of the blackboard that meet user needs.
[0107] Therefore, this application provides a cross-device service calling method, whereby a user can use a first electronic device (such as a tablet or a personal computer) to send a shooting command to a second electronic device (such as a mobile phone). After receiving the shooting command, the mobile phone activates the camera to perform a shooting or scanning task, and after completion, directly transmits the shooting result or the scanned text back to the tablet or the personal computer.
[0108] like Figure 1 As shown, the main device may include a tablet and a personal computer, and the auxiliary device may include a mobile phone. The note application of the main device responds to the user's operation and sends a shooting instruction or a scanning instruction to the auxiliary device. After receiving the shooting instruction or the scanning instruction, the auxiliary device calls up the camera to perform the shooting task or the scanning task. After the shooting or scanning is completed, the auxiliary device returns the shooting result (photo) or the scanning result (extracted text) to the note application of the main device.
[0109] Compared with the existing methods, different functions can be realized on the above multiple devices respectively through remote calls between the above devices, so as to reduce the manual switching between multiple devices when realizing the above multiple functions. For example, it can save the user the steps of uploading the shooting results or the scanned extracted text to the personal computer, then downloading and saving it to the personal computer, and then uploading it to the corresponding location of the personal computer. The operation is simpler and the user's work efficiency is improved. In addition, by using a mobile phone to perform shooting operations, photos of the blackboard content that can meet the user's needs can be taken.
[0110] Exemplarily, the electronic device in the embodiments of the present application may be a tablet computer, a mobile phone, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, a vehicle-mounted device, or the like. The embodiments of the present application do not impose any special restrictions on the specific form of the electronic device.
[0111] In the embodiments of the present application, electronic devices can be divided into private devices and public devices. It is understandable that private devices are used to indicate devices that can only be used by the owner (i.e., the owner of the device). For example, private devices can be mobile phones, smart watches, smart glasses, headphones and other devices. Public devices are used to indicate devices that can be used by any user. In other words, there may be multiple accounts logged in to a public device, and there may be associations between multiple different accounts. For example, a public device can be a TV, a stereo, a tablet computer, etc.
[0112] The execution subject of the cross-device service calling method provided in the present application can be a device for cross-device service calling, and the execution device can be Figure 2 The electronic device shown. At the same time, the execution device can also be a central processing unit (CPU) of the electronic device, or a control module for cross-device service invocation in the electronic device. In the embodiment of the present application, the cross-device service invocation method provided by the embodiment of the present application is explained by taking the electronic device executing the cross-device service invocation method as an example.
[0113] The following will describe the implementation of the embodiment of the present application in detail with reference to the accompanying drawings. Taking the above-mentioned electronic device as a mobile phone as an example, the hardware structure of the electronic device (such as the electronic device 300) is introduced. Figure 2 The electronic device 300 shown is merely one example of an electronic device, and the electronic device 300 may have more or fewer components than shown in the figure, may combine two or more components, or may have a different configuration of components. Figure 2 The various components shown in the EMBODIMENTS 2000 may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application specific integrated circuits.
[0114] See also Figure 2 , Figure 2 A schematic diagram of the structure of an electronic device is shown. Figure 2 As shown, the electronic device 300 may include: a processor 310, an external memory interface 320, an internal memory 321, a USB interface 330, a charging 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, an earphone interface, a sensor module 380, a button 390, a motor 391, an indicator 392, a camera 393, a display screen 394, and a subscriber identification module (SIM) card interface 395, etc.
[0115] Among them, the above-mentioned sensor module 380 may include sensors such as pressure sensor, gyroscope sensor, air pressure sensor, magnetic sensor, acceleration sensor, distance sensor, proximity light sensor, fingerprint sensor, temperature sensor, touch sensor, ambient light sensor and bone conduction sensor.
[0116] It is to be understood that the structure illustrated in this embodiment does not constitute a specific limitation on the electronic device 300. In other embodiments, the electronic device 300 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0117] The processor 310 may include one or more processing units, for example, the processor 310 may include an application processor (AP), a modem processor, a graphics processor (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 may be independent devices or integrated into one or more processors.
[0118] The controller may be the nerve center and command center of the electronic device 300. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0119] The processor 310 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 310 is a cache memory. The memory may store instructions or data that the processor 310 has just used or cyclically used. If the processor 310 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 310, and thus improves the efficiency of the system.
[0120] In some embodiments, the processor 310 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0121] It is understandable that the interface connection relationship between the modules shown in this embodiment is only a schematic illustration and does not constitute a structural limitation on the electronic device 300. In other embodiments, the electronic device 300 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0122] The charging management module 340 is used to receive charging input from a charger. In the embodiment of the present application, the charger may be a wired charger, and the charging management module 340 may receive charging input from the wired charger through the USB interface 330 (i.e., the above-mentioned charging interface). While the charging management module 340 is charging the battery 342, it may also power the electronic device through the power management module 341.
[0123] The power management module 341 is used to connect the battery 342, the charging management module 340 and the processor 310. The power management module 341 receives input from the battery 342 and / or the charging management module 340, and supplies 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. The power management module 341 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 341 can also be set in the processor 310. In other embodiments, the power management module 341 and the charging management module 340 can also be set in the same device.
[0124] The wireless communication function of the electronic device 300 can be implemented through the antenna 1, the antenna 2, the mobile communication module 350, the wireless communication module 360, the modem processor and the baseband processor.
[0125] Antenna 1 and antenna 2 are used 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 reused to improve the utilization of the antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0126] The mobile communication module 350 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 300. The mobile communication module 350 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 350 can receive electromagnetic waves from the antenna 1, and filter, amplify, etc. the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation.
[0127] The mobile communication module 350 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some functional modules of the mobile communication module 350 can be set in the processor 310. In some embodiments, at least some functional modules of the mobile communication module 350 can be set in the same device as at least some modules of the processor 310.
[0128] The wireless communication module 360 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 300. For example, in the embodiment of the present application, the electronic device 300 can access the Wi-Fi network through the wireless communication module 360.
[0129] The wireless communication module 360 may be one or more devices integrating at least one communication processing module. The wireless communication module 360 receives electromagnetic waves via the antenna 2, modulates the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 310. The wireless communication module 360 may also receive a signal to be sent from the processor 310, modulate the signal, amplify the signal, and convert it into an electromagnetic wave for radiation via the antenna 2.
[0130] In some embodiments, the antenna 1 of the electronic device 300 is coupled to the mobile communication module 350, and the antenna 2 is coupled to the wireless communication module 360, so that the electronic device 300 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).
[0131] The electronic device 300 implements the display function through a GPU, a display screen 394, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 394 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 310 may include one or more GPUs, which execute program instructions to generate or change display information.
[0132] The display screen 394 is used 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 or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc.
[0133] The electronic device 300 can realize the shooting function through ISP, camera 393, video codec, GPU, display screen 394 and application processor. ISP is used to process the data fed back by camera 393. Camera 393 is used to capture static images or videos. In some embodiments, the electronic device 300 may include 1 or N cameras 393, where N is a positive integer greater than 1. The digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 300 is in frequency selection, the digital signal processor is used to perform Fourier transform on the frequency energy. The video codec is used to compress or decompress digital video. NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of the electronic device 100 can be realized, such as image recognition, face recognition, speech recognition, text understanding, etc.
[0134] The external memory interface 320 can be used 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, such as storing music, video and other files in the external memory card.
[0135] The internal memory 321 may be used to store computer executable program codes, which include instructions. The processor 310 executes various functional applications and data processing of the electronic device 300 by running the instructions stored in the internal memory 321. For example, in an embodiment of the present application, the processor 310 may execute the instructions stored in the internal memory 321, and the internal memory 321 may include a program storage area and a data storage area.
[0136] The program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 300 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 321 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0137] The electronic device 300 can implement audio functions such as music playing and recording through the audio module 370, the speaker 370A, the receiver 370B, the microphone, the headphone interface, and the application processor.
[0138] The audio module 370 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 370 can also be used to encode and decode audio signals. In some embodiments, the audio module 370 can be arranged in the processor 310, or some functional modules of the audio module 370 can be arranged in the processor 310. The speaker 370A, also known as the "speaker", is used to convert audio electrical signals into sound signals. The receiver 370B, also known as the "earpiece", is used to convert audio electrical signals into sound signals. The microphone, also known as the "microphone" or "microphone", is used to convert sound signals into electrical signals.
[0139] The headphone jack is used to connect a wired headphone, and the headphone jack may be a USB interface 330, or a 3.5 mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0140] The button 390 includes a power button, a volume button, etc. The button 390 can be a mechanical button. It can also be a touch button. The motor 391 can generate a vibration prompt. The motor 391 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. The indicator 392 can be an indicator light, which can be used to indicate the charging status, power changes, messages, missed calls, notifications, etc. The SIM card interface 395 is used to connect the SIM card. The SIM card can be inserted into the SIM card interface 395, or pulled out from the SIM card interface 395 to achieve contact and separation with the electronic device 300. The electronic device 300 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 395 can support Nano SIM cards, Micro SIM cards, SIM cards, etc.
[0141] although Figure 2 Not shown, the electronic device 300 may also include a flash, a micro-projection device, a near field communication (NFC) device, etc., which will not be described in detail here.
[0142] After introducing the hardware structure of the electronic device, the system architecture of the electronic device provided by the present application is introduced. The system architecture of the electronic device can adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present invention takes a system with a layered architecture as an example to exemplify the software structure of the electronic device.
[0143] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the system is divided into five layers, from top to bottom: application layer, system application framework layer, collaborative service and scheduling layer, communication module and device profile layer, and kernel layer.
[0144] The application layer may include a series of application packages. Figure 3 As shown, the application package may include: notes, camera, mail, schedule. The application package may also include gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications.
[0145] like Figure 3As shown, the system application framework layer may include an activity management service (ActivityManagerService, AMS), a distributed activity management service (DistributedActivityManagerService, DAMS), a package management service (PackageManagerService, PMS), a distributed package management service (DistributedPackageManagerService, DPMS), a service management module (Service Manager, SM), a distributed service management module (Service Manager, DSM), and a system Binder framework. Among them, AMS, PMS and SM are existing system services in the Android system, and the related functions are not specifically introduced here. Among them, DAMS, DPMS and DSM are system functions newly added in the distributed system of the embodiment of the present application, and together they are a distributed application framework for processing service calls between distributed applications in the present application.
[0146] The distributed application framework may provide a distributed application management service for registering in the distributed service management module to implement service calls and management between distributed applications.
[0147] like Figure 3 As shown, the collaborative service and scheduling layer is used to provide remote service management capabilities, 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 resource references between devices. Among them, the collaborative 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.
[0148] The distributed service management module includes a service registration module, a service management module, a service acquisition module and a service life cycle module. The service management module is used to manage multiple remote devices when there are multiple remote devices.
[0149] The service registration module is used for, before device 1 calls the target service of device 2, the service registration module of device 2 registers the target service.
[0150] The service acquisition module is used to, in the scenario where device 1 calls the target service of device 2, after the target service of device 2 is fully registered, the service acquisition module of device 1 acquires the target service of device 2.
[0151] The service lifecycle module is used to call the services provided by device A and device B if device 1 can call the services provided by device A and device B. There may be two services on device A and two services on device B. When a service on device A or device B becomes abnormal or disappears, that is, after the service exits, the service lifecycle module of device 1 needs to process the service that has exited. The lifecycle can be understood as a process of creation and closing.
[0152] Among them, the services listed in the distributed service management module are all known services, all system services, that is, all real-name services, and the corresponding Binder objects are all real-name Binders. When the server registers the service provided, it will register the service in the distributed service management module.
[0153] The distributed Binder management module includes a Binder management mapping module, a Binder access authentication module, and a Binder life cycle module.
[0154] The binders in the distributed binder management module, except for the real-name binders, are all anonymous binders, so their scope is wider than that of the binders in the distributed service management module. Among them, anonymous binders refer to binders that are not registered in the distributed service management module and are binders created by the application itself.
[0155] The Binder management mapping module is used to manage Binder objects, which involves the mapping between the local Binder and the remote Binder.
[0156] The Binder access authentication module is used to manage the distributed Binder access authentication capabilities in cross-device or distributed scenarios.
[0157] The distributed file management module is responsible for reading and writing files across devices. The distributed file management module manages distributed files, mainly operations such as creating files and opening files, which also involves the transmission of messages between devices, and will perform serialization and deserialization.
[0158] The distributed file management module mainly refers to the scenario of taking photos. For example, the PC needs to call the camera function of the mobile phone. In fact, the photo cache file is created by the PC. Then, after taking the photo, the mobile phone needs to obtain the file handle of the photo cache file on the PC side. After obtaining the file handle, write operations need to be performed on this photo cache file. This is where cross-device reading and writing are involved. The distributed file management module can provide access to files across devices.
[0159] Among them, the file handle is a relatively complex object, similar to the Binder object.
[0160] The transmission management module refers to the channel (session) created between devices, through which messages are transmitted.
[0161] The device management module refers to the connected devices. The devices may be online or offline. Offline means that the device has been connected and then offline, that is, it is no longer connected. Then all resources related to the device need to be cleaned up or other operations. Among them, one or more devices may be connected.
[0162] like Figure 3 As shown, the communication module and device Profile (Device Profile) layer includes a communication module, a device Profile module and a distributed file module.
[0163] The communication module is responsible for transmission, including device discovery and connection services and data transmission services, providing a cross-device transmission interface, supporting automatic networking within a trust ring, one-to-many connections, and awakening dormant devices. In the cross-device call scenario, information is transmitted between devices through the communication module.
[0164] The device Profile module is used to provide device information, service registration interfaces supported by the device, and interfaces for other device query services.
[0165] The distributed file module, namely the distributed file management mentioned above, is responsible for reading and writing files across devices.
[0166] The kernel layer includes the Binder driver module, which is mainly used for cross-device communication.
[0167] The methods in the following embodiments can all be implemented in an electronic device having the above hardware structure and the above system architecture.
[0168] In the embodiment of the present application, the first electronic device is taken as the client (main device) and the second electronic device is taken as the server (auxiliary device) as an example. The first electronic device can call the service 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 refers to the end that provides the service, and the client refers to the end that uses the service provided by the server.
[0169] In the scenario where the first electronic device calls the target service of the second electronic device, the second electronic device first registers the target service in the device itself, and then the first electronic device obtains the target service registered by the second electronic device. After the first electronic device successfully obtains the target service of the second electronic device, the first electronic device can call the service interface of the second electronic device.
[0170] Therefore, in the embodiment of the present application, the overall process of the cross-device service calling method is mainly divided into three parts: service registration of the second electronic device, the first electronic device obtaining the service of the second electronic device, and the first electronic device calling the service interface of the second electronic device.
[0171] First, the service registration process of the second electronic device is introduced.
[0172] Take the case where the target service registered by the second electronic device is a distributed application management service, where the distributed application management service (target service) is in the system application framework. When the electronic device is turned on, the system application framework will be started, that is, the distributed application management service will be started. After the electronic device is turned on, the communication module is started. After the communication module is started, the service collaboration module is started. Therefore, after the service collaboration module is started, the second electronic device can register the distributed application management service in the service collaboration module.
[0173] 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 BinderId is assigned to the IBinder object.
[0174] Among them, the service name and IBinder are parameters, and an IBinder object can call a target service. After the first electronic device obtains the IBinder object of the target service of the second electronic device, it can use the IBinder object to call the interface of the corresponding target service, that is, to call the capabilities that the target service can provide.
[0175] Each service is set with a corresponding service name (ServiceName), such as AMS service, camera service, audio service, etc. Among them, the service name will be registered in the service management module of the system. If it is a distributed service scenario, the service name can be registered in the distributed service management module.
[0176] For example, the camera service is a system service, and the service name can be camera, or camera1, camera2. As a service provider, the camera service has a corresponding IBinder object. Among them, the camera service may provide multiple interfaces, and different capabilities correspond to different interfaces. For example, the interfaces provided by the camera service may include opening the camera, taking pictures, and recording videos. Then, the above interfaces can be directly called through the corresponding IBinder object.
[0177] In the embodiment of the present application, a unique identifier (BinderId) can be assigned to the IBinder object, each Binder object has a BinderID, and the BinderId can establish a mapping relationship with the IBinder object. In other words, there is a BinderId for the service on the server side, and when the client obtains the corresponding service, the BinderId can identify the relationship between the two. Among them, the mapping relationship can be understood as a key-value pair.
[0178] The BinderId may be allocated according to the device. For example, when multiple second electronic devices are connected, the second electronic device first sets the device identifier (DeviceId), and then allocates the BinderId to the service on each second electronic device. The device identifier may be pre-set.
[0179] Specifically, BinderId can be assigned in a certain order. For example, the second electronic device A can provide service a (IBinder a) and service b (IBinder b), and 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, text, etc. When using numbers as BinderId, it does not necessarily start from 1, but can also start from a specific number and increase sequentially.
[0180] In the embodiment of the present application, the second electronic device stores the service name and iBinder object of the target service, and the second electronic device assigns a BinderId to the iBinder object. Then, in the following steps, the target service can be obtained by the service name. The specific acquisition process is to determine the IBinder object by 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 corresponding.
[0181] It is understandable that for real-name services, what is stored on the server side is the service name, IBinder object and BinderId. The above relationship is stored in the distributed service management module on the server side. Among them, the system service will have a corresponding service name, and the service name will be registered in the distributed service management module. Therefore, the system services are all real-name services.
[0182] The storage method may be a list method, as shown in Table 1:
[0183] Service Name IBinder Object BinderId Service S1 IBinder S1 BinderId S1 Service S2 IBinder S2 BinderId S2
[0184] Table 1
[0185] It can also be stored in two lists, that is, the service name and IBinder object can be stored in one list, and the IBinder object and BinderId can be stored in another list. There is a one-to-one correspondence between the three. As shown in Table 2a and Table 2b:
[0186] Service Name IBinder Object Service S1 IBinder S1 Service S2 IBinder S2
[0187] Table 2a
[0188] IBinder Object BinderId IBinder S1 BinderId S1 IBinder S2 BinderId S2
[0189] Table 2b
[0190] In the embodiment of the present application, after the distributed Binder management module of the second electronic device assigns a BinderId to the IBinder object and establishes a mapping relationship, it indicates that the target service of the second electronic device has been successfully registered. The distributed Binder management module of the second electronic device can send a notification message of 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.
[0191] Secondly, the process of the first electronic device acquiring the target service registered by the second electronic device is introduced. Among them, after the target service of the second electronic device is successfully registered, the first electronic device can acquire the target service registered by the second electronic device. It is understandable that before acquiring 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 and calls up the device list and capability list. In other words, when the first electronic device receives the user's operation, it can be considered that the user has the intention of cross-device call, and therefore needs to acquire the target service.
[0192] Among them, 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 the device has a collaborative service and scheduling module. If a device does not have a collaborative service and scheduling module, the device does not have the ability to call across devices, and an empty message is sent to the application of the first electronic device. Then the application interface of the first electronic device will not display the device name of the device, or it will display the device name of the device, but distinguish it from other devices with cross-device calling capabilities through specific identifiers.
[0193] In the embodiment of the present application, a calling entry is provided in the application of the first electronic device. For example, the note application calls the camera application. Figure 5 As shown, an insert button 502 is provided on the display interface 501 of the note application of the computer. After the computer responds to the user's touch operation on the insert button, the display interface displays the server device that can provide services and the capability list corresponding to the device. The displayed devices may be a mobile phone 1 and a tablet 1. The capability list includes the services that the server device can provide, such as Figure 5 Among them, mobile phone 1 corresponds to taking pictures, scanning, etc., and tablet 1 corresponds to taking pictures, scanning, etc.
[0194] In some embodiments of the present application, the display interface of the note application can display all devices with cross-device calling capabilities within a set range. For example, if all devices with cross-device calling capabilities within the set range are mobile phone 1 and tablet 1. Figure 5 As shown, the displayed devices are a mobile phone 1 and a tablet 1, and the mobile phone 1 and the tablet 1 can provide photo taking, scanning, etc. respectively.
[0195] In some embodiments of the present application, the display interface of the note application can also display all devices within a set range, and distinguish whether the device has the cross-device call capability through a set identifier. For example, devices that do not have the cross-device call capability can be displayed in gray, and other devices that have the cross-device call capability can be displayed normally. Figure 6 As shown, if all devices within the set range are mobile phone 1, mobile phone 2, tablet 1 and tablet 2. The oblique dotted line indicates gray display, mobile phone 1 and tablet 1 are displayed normally and are devices with cross-device calling capabilities, while mobile phone 2 and tablet 2 are devices without cross-device calling capabilities.
[0196] In some embodiments of the present application, the capability list corresponding to the device may also display all possible services, distinguish whether the service is provided by the device through the set identification information, or only display the services that the device can provide.
[0197] In some embodiments of the present application, the display interface of the note application may 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. Figure 7 As shown, the displayed device list includes mobile phone 1, mobile phone 2, tablet 1 and tablet 2. In response to the touch operation on mobile phone 1, the capability list corresponding to mobile phone 1 is displayed.
[0198] In the embodiment of the present application, in response to an opening operation of an application on the first electronic device, the application interface is displayed, and then in response to a touch operation on a target button (such as Figure 5 ), then the application interface of the first electronic device will display a device list and a corresponding capability list.
[0199] In some other embodiments of the present application, in response to an opening operation of an application on the first electronic device, an application interface is displayed, and the application interface directly displays a device list and a corresponding capability list.
[0200] That is, before obtaining the service, the device list and capability list are displayed, and then in response to the user's touch operation on a certain item in the list, for example, after the first electronic device responds to the user's touch operation on the camera service option of mobile phone 1 in a list of a certain application, 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 obtain the distributed application management service of mobile phone 1.
[0201] like Figure 4 As shown, the process of the first electronic device acquiring the target service includes: 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 carries the device identifier (DeviceId) and the service name (ServiceName) when it is initiated.
[0202] In some embodiments of the present application, the first electronic device may establish a connection with the second electronic device according to the device identification 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.
[0203] In some embodiments of the present application, the first electronic device may call the same service multiple times. Then, after the first electronic device obtains the service for the first time, the obtained information of the service can be cached locally. The next time the application of the first electronic device calls the service, the service name can be directly searched from the local cache. For example, application 1 of computer 1 has called the scanning service of mobile phone 1 once, so the next time application 1 of computer 1 calls the scanning service, it can directly search the name of mobile phone 1 and the name of the distributed application management service from the local cache of computer 1.
[0204] 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 stored in the local cache, then the first electronic device may search for the corresponding target service in the second electronic device.
[0205] The specific step of searching the second electronic device for the corresponding target service includes: creating a session between the first electronic device and the second electronic device. After the session is successfully created, the first electronic device searches the second electronic device for the corresponding target service according to the service name.
[0206] The specific steps of creating a channel include: after the communication module of the first electronic device and the communication module of the second electronic device successfully create a channel, the communication module of the second electronic device sends a channel 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 channel creation success instruction to the distributed binder management module of the first electronic device. The distributed binder management module here is used to manage Binder objects.
[0207] Among them, the specific steps of the first electronic device searching for the corresponding service from the second electronic device according to the service name include: the first electronic device sends the service name to be obtained to the target device through a message. After the second electronic device receives the message, it parses the service name according to the message content. Then search 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.
[0208] If the corresponding target service is found, the IBinder object corresponding to the target service is determined, and then the IBinder object is returned to the first electronic device.
[0209] Among them, the communication module is a message receiving module with the function of receiving messages. After the communication module of the second electronic device receives the message, the message can be parsed. If the message contains a service name, then the message can be considered to be a query-type instruction message. Then, based on the service name in the message, the corresponding target service can be queried in the distributed service management module. If the distributed service management module stores a service name that is the same as the service name in the message, it means 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.
[0210] It is understandable 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. Figure 4 The communication module of the second electronic device performs a query in the distributed service management module according to the mapping relationship.
[0211] Among them, after the second electronic device finds the corresponding IBinder object according to the service name in the distributed service management module, it 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 based on the established mapping relationship between the Iinder object and the BinderId. Then, the determined BinderID is sent to the communication module of the second electronic device.
[0212] That is to say, when the two devices actually interact, the communication module of the second electronic device sends the BinderID to the communication module of the first electronic device.
[0213] It should be noted that the IBinder object of the target service generated by the second electronic device is not actually sent to the client. This is because the IBinder object has a system boundary and is only meaningful on the second electronic device. The IBinder object can be understood as a pointer or address. There is no practical meaning in sending the IBinder object to the first electronic device. Therefore, the second electronic device sends the BinderID to the first electronic device.
[0214] Specifically, after receiving the BinderID of the target service, the communication module of the second electronic device assembles the message and sends the message to the communication module of the first electronic device. In other words, the message carries the BinderID of the target service.
[0215] 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 will create a local IBinder object according to the BinderId. Among them, the distributed Binder management module of the first electronic device creates a local IBinder object according to the BinderId.
[0216] Then, the newly created IBinder object is returned to the application 1 of the first electronic device. Specifically, the newly created IBinder object is sequentially returned to the distributed service management module of the first electronic device, the system application framework, and finally to the application 1 of the first electronic device.
[0217] It is understandable that the newly created IBinder object of the first electronic device is created based on the BinderID carried in the received message, that is, the BinderId transmitted from the second electronic device to the first electronic device. Among them, the BinderId is unchanged. Then, the first electronic device creates a corresponding IBinder object based on the BinderId. In other words, in the first electronic device, a mapping relationship is also established between the BinderId and the new IBinder object.
[0218] That is to say, 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.
[0219] It should be noted that a service has a corresponding IBinder object, which includes several forms, one is the service itself, and the other is a reference to a Binder object. Generally speaking, the client obtains a reference to the Binder object (i.e., Binder proxy). In other words, the server sends an object of this type, Binder proxy, to the client's system application framework, which means that a proxy object is created on the client.
[0220] Finally, after the first electronic device acquires the target service, the first electronic device can call the service interface of the second electronic device. That is, after the first electronic device acquires the service provided by the application of the second electronic device, it calls the interface of the service through the IBinder object.
[0221] When the client calls the service interface of the server, it sends a service call request to the server; after receiving the request, the server calls the corresponding service interface and then returns a reply containing the call result to the client.
[0222] The request may contain an anonymous IBinder object or may not contain an anonymous IBinder object. An anonymous IBinder object is an IBinder object that has not been submitted to the distributed service management module for registration. An anonymous IBinder object can call an anonymous service. When the client calls a service registered by the server, if a simple instruction is transmitted during the request, there is no instruction that needs to be further called (equivalent to the request not containing an anonymous IBinder object). If the returned result can be used directly, there is no instruction that needs to be further called (equivalent to the reply not containing an anonymous I Binder object). If the returned result cannot be used directly, the returned result must be used for further access or call (equivalent to the reply containing an anonymous Binder object).
[0223] For example, if the service provided by the second electronic device is a computing service, such as a simple adder (a+b). For the application of the first electronic device, the input parameters are two numbers a and b. By calling the interface of the service, the result c can be directly obtained. The result c is a number and does not contain anything else. The above situation is equivalent to the request not containing the IBinder object, and the reply (reply) does not contain the IBinder object.
[0224] For another example, if the service provided by the second electronic device is the camera's photo service. For the application of the second electronic device (i.e., the camera), after taking a photo, when the photo data needs to be transmitted back to the application of the first electronic device (such as the note application), it is necessary to first obtain the file handle of the photo cache file of the note, and then write the photo data back to the photo cache file of the application of the first electronic device. Since the handle is a local resource of the first electronic device, it cannot be directly obtained. Therefore, the handle is hosted in a certain service (such as the Provider service), and the second electronic device obtains the FileProvider object of the note, and then obtains the file handle through the object. The above situation is equivalent to the request not containing an anonymous I Binder object, and the reply containing an anonymous Binder object. It can be understood that in the process of the camera obtaining the FileProvider object of the note, it is equivalent to the camera obtaining the service of the note. Therefore, in the process of the camera obtaining the FileProvider object of the note, the camera acts as the client at this time, and the note acts as the server at this time. The camera sends a request to the note (i.e., obtains the FileProvider object of the note), and the camera receives the reply returned by the client (i.e., the FileProvider object of the note). Among them, the note obtains its own FileProvider object, which is not registered in the distributed application management service module, which is equivalent to an anonymous IBinder object.
[0225] For another example, if the request sent by the client to the server contains an anonymous Binder object, then after the server obtains the IBinder object, it can call the interface provided by the IBinder object in the client.
[0226] like Figure 8 The steps are as follows. It is assumed that the request does not contain an IBinder object, but the reply contains an IBinder object. The method can be applied to a scenario 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 can also be further called by the first electronic device.
[0227] like Figure 8 As shown, when the application 1 of the first electronic device uses the Binder reference object to call the interface corresponding to the remote service, it enters the distributed Binder management module of the service collaboration, and the input parameters in the interface call can be encapsulated in a Parcel package (ie, Request Parcel).
[0228] The service collaboration module parses the received Request Parcel package (set as Parcel1) to determine whether it contains an IBinder object. If it does not contain an IBinder object, the Parcel package can be serialized directly. If it contains an IBinder object, the IBinder object is mapped and replaced before serializing the Parcel package. Assuming that the request does not contain an IBinder object, that is, after parsing Parcel1, it is determined that there is no IBinder object in Parcel1, the received Parcel1 can be serialized directly.
[0229] After Parcel1 is serialized, the first electronic device can send the request (i.e., Binder call request) to the second electronic device. It can be understood that serializing the Parcel package means serializing the state of the object into a byte stream, which can be transmitted across devices. Therefore, Parcel1 can be transmitted across devices, i.e., from the first electronic device to the second electronic device.
[0230] Specifically, the communication module of the first electronic device can assemble a message (set as message 1), and the message 1 carries a Binder call request (i.e., Parcel1 byte stream), and the communication module of the first electronic device sends the message 1 to the communication module of the second electronic device. Among them, the message 1 can include identification information for identifying that what is carried in the message 1 is a Binder call from 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 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. Among them, the correspondence between the identification information and the request type can be preset.
[0231] The message 1 also includes the BinderId of the target service received when the first electronic device acquires the target service.
[0232] The communication module of the second electronic device receives the message 1 and parses it, 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 transact 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 Parcel1 byte stream. First, since the previously assumed request does not contain an IBinder object, the Parcel1 byte stream can be directly deserialized. Then check again whether it contains an IBinder object. Among them, since it does not contain an anonymous IBinder object, the second electronic device can find the corresponding IBinder object according to the incoming BinderId (according to the mapping relationship stored in the second electronic device), and then directly call the transact interface to make an actual service call. That is, the second electronic device finds the corresponding target service according to the received BinderId and calls the interface of the application where the target service is located.
[0233] After the service interface call of the second electronic device is completed, which is equivalent to the actual method execution, a result will be generated, which is also returned to the caller (i.e., the first electronic device) through a Parcel package (i.e., Reply Parcel). In the remote call scenario, the Reply Parcel (set to Parcel2) needs to be returned to the first electronic device through the network.
[0234] When the second electronic device processes (parses) Parcel2, it can be determined that Parcel2 contains an IBinder object. The distributed Binder management module of the second electronic device assigns a BinderId to 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 Parcel2. Before serialization, the Binder object in Parcel2 is replaced with the BinderId, and the other space belonging to the Binder object is filled with the placeholder.
[0235] The serialized data (Parcel2 byte stream) is then 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 the 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 then sends the message 2 to the communication module of the first electronic device.
[0236] After receiving the message 2, the communication module of the first electronic device parses the message 2 to obtain 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.
[0237] After the first electronic device receives the Parcel2 byte stream (i.e., the reply parcel byte stream called by the above-mentioned Binder), it processes the Parcel2 byte stream. That is, the distributed Binder management module of the first electronic device processes the Parcel2 byte stream. Specifically, the Parcel2 byte stream is first deserialized to obtain the Parcel2 object. Then, since the first electronic device can determine that Parcel2 contains an IBinder object, that is, by parsing Parcel2, it can be determined that the corresponding BinderId is written in Parcel2. Therefore, 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 a mapping relationship is established between the BinderId and the local Binder reference object. Then, the distributed Binder management module of the first electronic device writes the created Binder reference object into a new reply package and returns it to application 1 of the first electronic device.
[0238] To summarize, an embodiment of the present application provides a cross-device service calling method. After a first electronic device receives the BinderId of an IBinder object corresponding to a service of a second electronic device, it can create an IBinder object on the local side corresponding to the BinderId, and then call the service of the second electronic device through the IBinder object on the local side, thereby realizing cross-device service calling.
[0239] In the embodiment of the present application, the above cross-device service calling method can be applied to a scenario where a first electronic device calls a second electronic device's photo taking service. 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.
[0240] If the first electronic device is a personal computer, the above cross-device service calling method is introduced by taking an application (such as a note) of the first electronic device calling a photo taking service of an application (such as a camera) of the second electronic device as an example.
[0241] In the scenario where the note application of the first electronic device calls the photo service of the camera application of the second electronic device, the second electronic device must first register the distributed application management service in the device itself, and then the first electronic device obtains the distributed application management service registered by the second electronic device. After the first electronic device successfully obtains the distributed application management service of the second electronic device, the note application of the first electronic device pulls up the camera application of the second electronic device, and after the camera application takes a photo of the specified content, the second electronic device obtains the photo data and transmits it to the note application of the first electronic device.
[0242] Therefore, the overall process of the above cross-device service calling method may include the service registration of the second electronic device, the acquisition of the service by the first electronic device, and the transmission of the service data (photographing data) of the second electronic device back to the first electronic device. The service registered by the second electronic device at this time is the distributed application management service. Fig. 9 As shown, Fig. 9 A flowchart of a cross-device service calling method provided in an embodiment of the present application.
[0243] like Fig. 9 In the process shown, the first electronic device displays the display interface of the first application, receives the user's first touch operation on the target device control of multiple device controls, and sends an acquisition instruction to the second electronic device, that is, to obtain the distributed application management service registered by the second electronic device. The second electronic device receives the acquisition instruction from the first electronic device, searches for the BinderID of the distributed application management service based on the acquisition instruction, and sends the BinderID to the first electronic device. The first electronic device obtains the BinderID of the distributed application management service and creates an IBinder object based on the BinderID (refer to Fig. 9 Steps S101-S103). That is, the specific process of the second electronic device registering the service and the first electronic device obtaining the service, which is described in detail below.
[0244] See also Fig.10 , Fig.10 Sequence diagram of service registration of the second electronic device and acquisition of service by the first electronic device. First, the service registration process of the second electronic device is introduced.
[0245] Among them, the distributed application management service is in the system application framework. When the electronic device is turned on, the system application framework will be started, that is, the distributed application management service will be started. After the electronic device is turned on, the communication module is started. After the communication module is started, the service collaboration module is started. Therefore, after the service collaboration module is started, the second electronic device can register the distributed application management service in the service collaboration module.
[0246] The service registration process of the second electronic device is also the registration process of the distributed application management service of the second electronic device, which specifically includes: the distributed application management service of the second electronic device is registered in the distributed service management module (Distributed Service Manager) (refer to Fig.10 Step 1) wherein the distributed application management service is in the system application framework, and after the second electronic device is turned on, the distributed application management service is started.
[0247] The service name (e.g., "DisApp") and the IBinder object (e.g., "IBinder S1") of the distributed application management service are stored in the distributed service management module. Then, the service name and the IBinder object are sent to the distributed Binder management module. The distributed Binder management module caches the IBinder object (the above-mentioned IBinder S1) and assigns a BinderId (e.g., "Binder S1") to the IBinder object. That is, a mapping relationship is established between IBinder S1 and Binder S1 (refer to Fig.10 Then, the distributed Binder management module returns the registration result to the system application framework (refer to Fig.10 Step 1.2).
[0248] In the embodiment of the present application, after the distributed Binder management module of the second electronic device assigns a BinderId to the IBinder object and establishes a mapping relationship, it indicates that the distributed application management service of the second electronic device has been successfully registered. The distributed Binder management module of the second electronic device can send a notification message of 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.
[0249] The application (e.g., camera application) is an interface provided by the distributed application framework, which is in the system application framework. After the first electronic device obtains the distributed application management service registered by the second electronic device, it can call the camera application of the second electronic device through the distributed application framework to obtain the service provided by the camera application.
[0250] Next, the process of the first electronic device acquiring a service is introduced, wherein after the second electronic device successfully registers the distributed application management service, the first electronic device can acquire the distributed application management service registered by the second electronic device.
[0251] It is understandable that before acquiring the photo service, the first electronic device has already opened the note application, and the first electronic device calls out the device list and capability list in response to the user's touch operation on the call entry of the note application interface. In other words, when the first electronic device receives the user's operation, it can be considered that the user has the intention of cross-device call, and therefore needs to acquire the distributed application management service provided by the second electronic device.
[0252] Among them, a calling entry is provided in the note application of the first electronic device. Figure 5 As shown, an insert button is provided on the display interface of the note application of the computer. After the computer responds to the user's touch operation on the insert button, the second electronic device that can provide services and the capability list corresponding to the device are displayed on the display interface. The displayed devices may be mobile phone 1 and tablet 1. The capability list includes the services that the second electronic device can provide, such as Figure 5 Among them, mobile phone 1 corresponds to taking pictures, scanning, etc., and tablet 1 corresponds to taking pictures, scanning, etc.
[0253] In some embodiments of the present application, the first electronic device may call the camera service of the second electronic device for the first time, or there may be multiple calls. Then, after the first electronic device obtains the camera service of the camera for the first time, the obtained call information of the camera service can be cached locally. Therefore, the first electronic device can first search for the second electronic device and the distributed application management service from the local cache, and if it is found, it will be directly returned to the note application. If it is not found, it can be searched from the second electronic device.
[0254] The embodiment of the present application describes in detail the process of obtaining the distributed application management service when the first electronic device calls the camera service of the camera of the second electronic device for the first time.
[0255] 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 user's touch operation on the call entry of the note application interface, the note application of the first electronic device can obtain the distributed context of the second electronic device, that is, obtain the "DisApp" service of the second electronic device (refer to Fig.10 Step 2.1). Specifically, the system application framework of the first electronic device sends a request to obtain 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 to obtain the "DisApp" service to the message center (Message Center)-communication module of the first electronic device (refer to Fig.10 Step 2.2).
[0256] After receiving the request for obtaining the "DisApp" service, the communication module of the first electronic device creates a channel (session) with the first electronic device (refer to Fig.10 After the channel is successfully created, the distributed service management module of the first electronic device sends an instruction to obtain the "DisApp" service to the communication module of the first electronic device (refer to Fig.10 Step 2.2.2). The communication module of the first electronic device receives the instruction to obtain the "DisApp" service, composes a message, and sends it to the communication module of the second electronic device through the message.
[0257] After receiving the message, the communication module of the second electronic device parses the message and obtains an instruction for obtaining the "DisApp" service (refer to Fig.10 The communication module of the second electronic device sends the instruction to the distributed Binder management module of the second electronic device (refer to Fig.10 (as in step 2.1.4).
[0258] 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. Among them, it can be seen from step 1.1 that the distributed service management module stores the service name and the corresponding IBinder object. Therefore, the distributed Binder management module can search whether the service is stored in the distributed service management module according to the service name ("DisApp") in the above instruction. If the service ("DisApp" service) is found, the corresponding IBinder object (IBinder S1) is determined.
[0259] 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) according to the established mapping relationship between the IBinder object and the BinderId (refer to Fig.10 Then, the BinderId (BinderId S1) is sent to the communication module of the second electronic device (refer to Fig.10 Step 2.2.5).
[0260] After receiving the BinderId (BinderId S1) of the "DisApp" service, the communication module of the second electronic device assembles it into a message (the message carries BinderId S1) and sends the message to the communication module of the first electronic device.
[0261] The communication module of the first electronic device receives the message, parses the information content, and obtains the BinderId (BinderId S1) of the "DisApp" service (refer to Fig.10 Step 2.2.6). 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 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 (refer to Fig.10 (Step 2.2.7).
[0262] 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, and the system application framework (refer to Fig.10 Step 2.2.8), and finally returns to the note application of the first electronic device (refer to Fig.10 Step 2.3).
[0263] In the embodiment of the present 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.
[0264] The specific process of the note application of the first electronic device opening the camera application of the second electronic device is as follows:
[0265] like Fig.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 the locally created IBinder C1, and the input parameters (uri and device information) in the message are encapsulated in parcel A. The system application framework sends parcelA 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 can determine that there is no IBinder object in parcel A. Parcel A can be serialized directly to obtain the byte stream of parcel A.
[0266] The service collaboration module of the first electronic device then 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 then 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.
[0267] 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 returned by the camera application (camera on) 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 can determine that there is no IBinder object in parcel A'. Parcel A' can be directly serialized to obtain a parcel A' byte stream.
[0268] The service collaboration module of the second electronic device sends the parcel A' byte stream to the service collaboration 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 then forwards the parcel A' byte stream to the distributed Binder management module in the service collaboration module of the first electronic device. The distributed Binder management module deserializes the parcel A' byte stream to obtain parcel A'.
[0269] The distributed Binder management module of the first electronic device sends parcel A' to the system application framework of the first electronic device. At this point, the camera is turned on successfully.
[0270] 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 photo of the information that needs to be sent back to the notes, and the camera application responds to the user's operation and sends the acquired photo data back to the notes. For example, insert the blackboard content of an offline class into the note application, then after the camera application is opened, the user uses the camera to take a photo of the blackboard content, and the camera responds to the user's click on the photo button to obtain a blackboard photo (photographed data of the blackboard content). Then, the camera sends the blackboard photo back to the notes.
[0271] The camera obtains the photo in response to the user's click operation on the photo button, and then can confirm whether the photo meets the user's requirements. The camera obtains the confirmed photo in response to the user's click operation on the confirmation button, that is, after confirming that the photo meets the user's requirements. The camera returns the confirmed photo to the note. That is, after the camera responds to the user's click operation on the confirmation button, the camera returns the photo data to the note of the first electronic device.
[0272] Among them, for the camera, after taking a photo, when the photo data needs to be transmitted back to the note application, it is necessary to first obtain the file handle of the photo cache file of the note, and then write the photo data back to the photo 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 Provider object (file provider object) of the note, and then obtains the file handle through the object. It can be understood that what the camera application sends to the note application is a simple acquisition instruction (request), and the result (reply) returned by the note application to the camera application is an object that needs to be further called. The above situation is equivalent to the request not containing an anonymous IBinder object, and the reply containing an anonymous IBinder object.
[0273] Therefore, the specific steps of transmitting the service data (photographing data) of the second electronic device back to the first electronic device include: the camera application obtains the IContent Provider object (i.e., the File Provider object) of the note application, the camera application obtains the file handle of the photo cache file of the note application, and the camera application writes the photographing data back to the first electronic device. The photographing data refers to the result of the second electronic device executing the distributed application management service.
[0274] The note 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), and the note application registers the File Provider with the system application framework. The note application can create a photo cache file in response to a user's touch operation on a camera option, or it can create a photo cache file at any time before obtaining the file handle of the photo cache file.
[0275] See also Fig.12 , Fig.12 This is a sequence diagram of the File Provider object for obtaining notes provided in the embodiment of the present application. Fig.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, and the input parameters in the interface call (by calling the transact method) can be encapsulated in the Parcel package (that is, the request parcel).
[0276] The distributed Binder management module of the service collaboration module processes the request parcel (set to reqA) (refer to Fig.12 Step 1.3). Specifically, first determine whether reqA contains an anonymous IBinder object. By parsing reqA, it can be determined that reqA does not contain an anonymous IBinder object. It can be understood that since reqA is only used to obtain the File Provider object of the note and does not need to be further called, reqA does not contain an anonymous IBinder object. Then, the distributed Binder management module can directly serialize reqA.
[0277] After the distributed Binder management module serializes reqA, it forwards the call request (reqA byte stream) to the communication module of the second electronic device. The communication module of the second electronic device sends the reqA byte stream to the communication module of the first electronic device by assembling a message, and the message contains the BinderId S1 of the "DisApp" service.
[0278] The communication module of the first electronic device receives and parses the message, determines that the message carries a Binder call request, and then sends the message to the distributed Binder management module of the first electronic device. The distributed Binder management module of the first electronic device parses the message to obtain the reqA byte stream (i.e., serialized reqA), deserializes the reqA byte stream to obtain reqA. The distributed Binder management module of the first electronic device finds the corresponding local IBinder object (IBinder C1) based on the received BinderId S1. Then call transact to make the actual service call (that is, to obtain the File Provider object of the note).
[0279] The system application framework of the first electronic device writes the File Provider object of the note application into the Parcel package, namely the Reply Parcel (set as repB), and then returns repB to the camera application of the second electronic device. Specifically, the system application framework calls on transact (refer to Fig.12 Step 1.6). The distributed Binder management module of the first electronic device processes repB. Specifically, check that repB contains IFile Pc (equivalent to the IBinder object), and then assign BinderId2 to the IFile Pc object (that is, establish a mapping relationship between the IFile Pc object and BinderId2). Then, the distributed Binder management module serializes repB. Before serialization, replace the IFile Pc object in repB with BinderId2, set the generated new Reply Parcel to repB1, and fill the other spaces belonging to the IFile Pc object with placeholders (refer to Fig.12 as in step 1.6.1).
[0280] Then, the first electronic device sends the serialized repB1 (i.e., the repB1 byte stream) to the second electronic device. Specifically, the distributed Binder management module of the first electronic device constructs a message that carries 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.
[0281] After receiving 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.
[0282] 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 repB1 contains an IBinder object, that is, by parsing repB1, it can be determined that the corresponding BinderId2 is written in repB1. Therefore, the second electronic device can obtain the BinderId2 of the first electronic device, and then create an Ibinder object of the second electronic device (set to IFilePs), wherein a mapping relationship is established between BinderId2 and the IFilePs object of the second electronic device. Then, the distributed Binder management module of the second electronic device writes the created IFilePs object into the reply package (set to repB2) and returns it to the camera application (refer to Fig.12 as in step 1.8).
[0283] 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.
[0284] See also Fig.13 , Fig.13 The timing diagram of obtaining the file handle of the photo cache file of the note provided in the embodiment of the present application. Fig.13 As shown, when the camera application uses the IFilePs object to call the corresponding interface of the note application, it enters the distributed Binder management module of the service collaboration module, and the input parameters in the interface call (by calling the transact method) can be encapsulated in the Parcel package (that is, the request parcel).
[0285] The distributed Binder management module of the service collaboration module processes the request parcel (set to reqD) reqD (refer to Fig.13 Step 1.3). Specifically, first determine whether reqD contains an anonymous IBinder object. By parsing reqD, it can be determined that reqD does not contain an anonymous IBinder object. It can be understood that since reqD is only used to obtain the file handle of the note, no further call is required, and it can be determined that reqD does not contain an anonymous Ibinder object. Then, the distributed Binder management module can directly serialize reqD.
[0286] After the distributed Binder management module serializes reqD, it forwards the call request (reqD byte stream) 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, and the message contains BinderId2.
[0287] The communication module of the first electronic device receives and parses the message, determines that the message carries a Binder call 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 reqD. The distributed Binder management module of the first electronic device finds the corresponding local IBinder object (IFilePc) based on the received BinderId2. Then call transact to make the actual service call (i.e., obtain the file handle of the note).
[0288] The note application of the first electronic device writes the file descriptor object Fdc into the Parcel package, namely the Reply Parcel (set as repE), and then returns repE to the camera application of the second electronic device. Specifically, the note application calls on Transact (refer to Fig.13 Step 1.6). The distributed Binder management module of the first electronic device processes repE. Specifically, it is checked that repE contains Fdc (equivalent to the Binder object), and then an instruction to create a distributed file is sent to the distributed file module of the first electronic device (refer to Fig.13Step 1.6.2). Assume that the name of the created distributed file is "DisPicture". It is understandable that files can be accessed through file handles, such as opening files, closing files, reading and writing files, etc. Therefore, after the camera obtains the file handle, the photo data can be written to the actual file. Since the actual file is on the device side where the note application is located, and the camera application performs cross-device reading and writing, a distributed file can be created (the distributed file module can provide cross-device file access) to ensure that the data is written across devices on the camera side to the file on the device side where the note is located.
[0289] 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 of the original Fdc in repE and occupies it, generating repE1 (refer to Fig.13 Then, the distributed Binder management module serializes repE1.
[0290] 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, which carries 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.
[0291] After receiving the message, the communication module of the second electronic device parses the message to obtain a 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.
[0292] 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 name of the distributed file is contained in repE1, that is, repE1 contains relevant information of the corresponding file handle. The second electronic device can read the name of the distributed file in repE1 ("DisPicture") and open the corresponding distributed file (refer to Fig.13 as in step 1.7.2).
[0293] 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 the reply packet (set as repE2) and returns it to the camera application (refer to Fig.13 as in step 1.8).
[0294] At this time, the second electronic device obtains the file handle VFd of the note application. Then, the camera application can write the photo data back to the first electronic device, that is, the camera application writes the photo data to the distributed file of the second electronic device through the file handle, and then transfers it to the distributed file of the first electronic device, and finally returns it to the note application of the first electronic device.
[0295] That is to say, a channel can be created between the distributed file module of the first electronic device and the second electronic device. After the camera application calls the data writing interface of the distributed file of the second electronic device through the file handle, it writes the photo data, transfers it to the distributed file of the first electronic device through the channel created above, and then returns it to the note.
[0296] The above-mentioned step of transmitting the photographed data back to the first electronic device, that is, Fig. 9 Steps S104-S110 in the above description. Specifically, the second electronic device responds to the user's second touch operation on the second application, and sends a request to the first electronic device based on the first BinderID of the distributed application management service. The first electronic device responds to the request received from the second electronic device and searches for the corresponding IBinder object according to the BinderID contained in the request. The first electronic device then indicates the first file providing object to the second electronic device according to the IBinder object, that is, the BinderID corresponding to the first file providing object is sent to the second electronic device as mentioned above. The second electronic device creates a local corresponding second file providing object according to the BinderID corresponding to the received first file providing object. The second electronic device initiates a request to the first electronic device again according to the second file providing object to obtain a file handle object. The first electronic device responds to the received request and indicates the first file handle object to the second electronic device, that is, 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, that is, receives the name of the corresponding distributed file, and opens the corresponding distributed file. The second electronic device returns the result of executing the service to the distributed file, and then returns the result to the first electronic device.
[0297] In summary, in the above-mentioned cross-device service calling method, the user can use the first electronic device to send a shooting instruction to the second electronic device. After receiving the shooting instruction, the second electronic device activates the camera to perform a shooting or scanning task, and after completion, directly transmits the shooting result or the scanned extracted text back to the first electronic device. This can save the user the steps of uploading the shooting result or the scanned extracted text to the first electronic device, then downloading and saving it to the first electronic device, and then uploading it to the corresponding location of the first electronic device. The operation is simpler and the user's work efficiency is improved.
[0298] See also Fig.14 , Fig.14 A schematic diagram of a cross-device call scenario is provided, such as Fig.14 As shown, an insert button is provided on the display interface of the note application of the computer. After the computer responds to the user's touch operation on the insert button, the display interface displays the server device that can provide services and the capability list corresponding to the device. Among them, the displayed devices can be mobile phone 1 and tablet 1. The capability list includes the services that the server device can provide, such as Fig.14 In the computer, the corresponding functions of mobile phone 1 are photography, scanning, etc., and the corresponding functions of tablet 1 are photography, scanning, etc. In response to the user clicking the photography option in mobile phone 1, the computer sends a command to mobile phone 1 to open the camera application. Mobile phone 1 opens the camera application, takes a photo of the specified content, and obtains the photo of the specified content in response to the user clicking the photography button. Then, mobile phone 1 responds to the user clicking the confirmation button, that is, after confirming that the photo meets the user's needs, it obtains the confirmed photo. Mobile phone 1 sends the confirmed photo back to the specified location in the note application of the computer.
[0299] Therefore, through the above cross-device service calling method, users can send shooting instructions from the computer to the mobile phone. After receiving the shooting instructions, the mobile phone calls up the camera to perform the shooting or scanning task, and then directly transmits the shooting results or scanned text back to the computer. This can save users the steps of uploading the shooting results or scanned text to the computer, then downloading and saving them to the computer, and then uploading them to the corresponding location. The operation is simpler and the user's work efficiency is improved.
[0300] In an embodiment of the present application, in the above-mentioned cross-device service call method, the serialization and deserialization of parcel packages are involved. For example, in the process of the above-mentioned camera application obtaining the File Provider object of the note application, reqA (request parcel A) needs to be serialized and deserialized, and repB (reply parcel B) needs to be serialized and deserialized. In the process of the above-mentioned camera application obtaining the file handle of the photo cache file of the note application, reqD (request parcel D) needs to be serialized and deserialized, and repE (reply parcel E) needs to be serialized and deserialized. Among them, reqA and reqD do not contain anonymous binder objects, while repB contains File Pc objects (that is, repB contains anonymous Binder objects), and repE contains Fdc objects (that is, repE contains file handles).
[0301] The existing serialization and deserialization methods only support serialization and deserialization of parcel packages that do not contain anonymous Binder objects or file handles, that is, when the parcel package only contains objects of basic types (such as int, string objects), the above existing methods are applicable. However, the existing methods do not support serialization and deserialization of parcel packages containing complex objects such as anonymous binder objects or file handles.
[0302] In an embodiment of the present application, a cross-device data processing method is provided. When a parcel package contains complex objects such as Binder objects or file handles, the Binder objects or file handles in the parcel package can be replaced and then serialized so that devices at both ends can access each other.
[0303] like Fig.15 As shown, a data structure diagram of a parcel package is provided in an embodiment of the present application. Fig.15 In the , InterfaceToken is located at the beginning of mData, and the package name is usually filled in. An application has one package name. Fig.15 There is also an int type of data and a string type of data in it. Here, only two common data types are used as examples, and other types of data can also be used.
[0304] The parcel package also contains the starting positions of binder1 and binder2, that is, the DataPos of binder1 and binder2, that is, the bytes starting from which byte is the binder1 object, and the bytes starting from which byte is the binder2 object. In other words, the data structure contains bytes that can identify the position 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.
[0305] It should be noted that Fig.15 The parcel data structure in the figure is only an example. In actual scenarios, a parcel package generally contains only one Binder object, not two Binder objects.
[0306] See also Fig.16 , Fig.16 A cross-device data processing method is provided in an embodiment of the present application, wherein a Parcel package includes a Binder object. Fig.16 As shown, the left side can be set as electronic device 1 and the right side as electronic device 2, and the local resources of electronic device 1 can be sent to electronic device 2. Among them, S in Parcel A is a Binder object, and its corresponding BinderId is S1. Before serialization, electronic device 1 can replace the Binder object S with the corresponding BinderId (S1) to obtain Parcel A'. Then, Parcel A' is serialized to obtain the serialized Parcel A', that is, the byte stream of Parcel A', and then transmitted to the client through the network. It can be understood that S in ParcelA, as a Binder object, can call the corresponding target service in electronic device 1, such as service 1.
[0307] After receiving the byte stream of Parcel A', electronic device 2 deserializes it to obtain Parcel A'. Electronic device 2 parses Parcel A' to obtain BinderId (S1), then creates a Binder reference object Q corresponding to BinderId (S1) locally on electronic device 2, writes Q into Parcel A', and obtains Parcel B. That is, electronic device 2 can subsequently use Binder reference object Q to call service 1 of electronic device 1.
[0308] Among them, the length of bytes occupied by the Binder object in the Parcel package is fixed, for example, it occupies 28 bytes. Before serialization, a corresponding Binder Id is assigned to the Binder object, where BinderId can be defined as an integer type, occupying 4 bytes. Then, in Parcel A', after replacing the Binder object with BinderId, the bytes of the Binder object other than BinderId must be filled with placeholders. Therefore, when replacing the Binder object in the Parcel package, other data remains unchanged and will not affect the original structure of the Parcel package. Among them, when filling the placeholders as mentioned above, as long as the preset placeholders can occupy the corresponding positions, the form of the preset placeholders is not limited in this application, and can be filled with blanks or filled with 0s.
[0309] Fig.16 In the example, the Binder object can be S, and the assigned BinderId is S2. Before serialization, electronic device 1 can replace the Binder object S with the corresponding BinderId (S2) to obtain Parcel A'. Then, Parcel A' is serialized to obtain serialized Parcel A', that is, the byte stream of Parcel A', and then transmitted to electronic device 2 through the network. After receiving the byte stream of Parcel A', electronic device 2 deserializes it to obtain Parcel A'. Electronic device 2 parses Parcel A' to obtain BinderId (S2), and then creates a binder reference object Q1 corresponding to BinderId (S2) locally on electronic device 2, writes Q1 into Parcel A', and obtains Parcel B.
[0310] In the embodiment of the present application, in the process of the camera application obtaining the File Provider object of the note application, 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 (ie, repB). Fig.17 A serialization method for repB is provided.
[0311] Fig.17In the embodiment of the present invention, the local Binder1 in repB can represent the above-mentioned File Provider object (IFile Pc object). The first electronic device allocates the 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, repB1 is serialized to obtain the serialized repB1, that is, the byte stream of repB1, which is then transmitted to the second electronic device via the network.
[0312] After receiving the repB1 byte stream, the second electronic device deserializes it to obtain repB1. The second electronic device parses repB1 to obtain BinderId 2, and then creates a reference object IFile Ps object (i.e., Fig.17 The remote Binder 10 in the process writes the IFile Ps object into repB1 to obtain repB2.
[0313] In summary, a Parcel package serialization method provided in an embodiment of the present application can be used in a scenario where the Parcel package is transmitted across devices. If the Parcel package contains a Binder object, the Binder object is replaced with the corresponding BinderId before serialization and transmission. That is, the local resource (Binder object) is replaced with the cross-device resource (BinderId) and then serialization and transmission are performed. After receiving the serialized parcel package at the other end, deserialization is first performed to obtain the BinderId, and then the BinderId is replaced with the locally created Binder object. Therefore, the cross-device transmission of the Parcel package containing the Binder object can be realized through the above-mentioned Parcel package serialization method.
[0314] In the embodiment of the present application, in the cross-device service call scenario, cross-device transmission of a Parcel package containing a file handle is also involved. The serialization method of the Parcel package is introduced below.
[0315] See also Fig.18 , Fig.18 A cross-device data transmission method is provided in an embodiment of the present application, wherein the Parcel package contains a file handle. Fig.18As shown, the left side can be set as electronic device 3 and the right side as electronic device 4, and the local resources in electronic device 3 can be sent to electronic device 4. Among them, T in Parcel D is a file handle object, and its 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, Parcel D' is serialized to obtain the serialized Parcel D', that is, the byte stream of Parcel D', and then transmitted to electronic device 4 through the network.
[0316] After receiving the byte stream of Parcel D', electronic device 4 deserializes it 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 on electronic device 4, writes K into Parcel D', and obtains Parcel E.
[0317] In the embodiment of the present application, in the process of the camera application obtaining the file handle of the photo cache file of the note 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 (ie, repE). Fig.19 A serialization method for this repE is provided.
[0318] Fig.19 In the example, the first electronic device creates a distributed file for the file descriptor Fdc object, and the name of the distributed file is set to the above-mentioned "DisPicture". Before serialization, the first electronic device can replace the Fdc object with "DisPicture" to obtain repE1. Then, repE1 is serialized to obtain serialized repE1, that is, the byte stream of repE1, which is then transmitted to the client through the network.
[0319] After receiving the repE1 byte stream, the second electronic device deserializes it to obtain repE1. The second electronic device parses repE1 to obtain the name of the distributed file. 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, returns the handle VFd of the distributed file, and writes the handle VFd object of the distributed file into repE1 to obtain repE2.
[0320] In summary, a Parcel package serialization method provided in an embodiment of the present application can be used in a scenario where the Parcel package is transmitted across devices. If the Parcel package contains a file handle object, the file handle object is replaced with 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 with the cross-device resource (the name of the distributed file) and then serialization processing and transmission are performed. After receiving the serialized parcel package at the other end, deserialization processing is first performed to obtain the name of the distributed file. Then, the corresponding distributed file is opened according to the name of the distributed file, and the file handle object corresponding to the locally created distributed file is obtained. Therefore, the cross-device transmission of the Parcel package containing the file handle object can be realized through the above-mentioned Parcel package serialization method.
[0321] See also Fig. 20 ,like Fig. 20 In the process of the cross-device data transmission method shown (refer to steps S201-S209), after the first electronic device calls the target service of the second electronic device, that is, the distributed application management service, the second electronic device, after obtaining the execution result, refers to the specific steps of the camera application returning the photographed data to the note. That is, first obtain the File Provider object of the note, and then use the object to obtain the file handle. The second electronic device sends a request to the first electronic device, requesting 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 through the received file name and obtains the corresponding second file handle object. Then the second electronic device writes the obtained photographed data into the first distributed file. The photographed data in the second distributed file is then transmitted to the first distributed file of the first electronic device, and then written into the preset file of the first electronic device.
[0322] Therefore, through the above-mentioned cross-device data transmission method, the cross-device transmission of the Parcel package containing the file handle object can be realized, the photo data can be returned to the calling application of the first electronic device, and the complete process of cross-device calling can be realized.
[0323] In the embodiment of the present application, during the process of the client calling a service on the server, the application on the server may exit. For example, an abnormality occurs in the application on the server, causing the application to exit, or the application exits normally in response to a certain operation of the user. The above situations can all be considered as abnormalities in the application on the server. At this time, both the client application and the server application need to clean up the locally stored resources to avoid resource redundancy.
[0324] Therefore, an embodiment of the present application provides a cross-device service call resource cleaning method, which can clean up the resources stored by the client application and the server application when the server application exits.
[0325] In the embodiment of the present application, the above cross-device service call resource cleaning method can be applied to the scenario where a first electronic device (client) calls a service of a second electronic device (server). 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.
[0326] If the first electronic device is a personal computer, taking the case where application 1 of the first electronic device calls service S1 of application 2 of the second electronic device as an example, the above cross-device service call resource cleaning method is introduced.
[0327] See also Fig.21 ,like Fig.21 In the process of the resource cleanup method 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 indication of 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 indication from the first electronic device and acquires 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 call the first electronic device. In response to receiving the first cleanup call request from the second electronic device, the second electronic device executes the cleanup service based on the first IBinder object. Among them, the registration of the cleanup service here means the registration of the death notification. Among them, the cleaned resources mainly include the calling resources of the target service and the cleanup service, and the calling resources include the resources used when the electronic device calls the corresponding service. The above steps are described in detail below.
[0328] Among them, the overall process of the above-mentioned cross-device service call resource cleaning method can be mainly divided into four parts: service registration of the first electronic device, acquisition of service by the second electronic device, service registration death notification of the first electronic device, and service exit of the second electronic device. Among them, the service registered and acquired by the electronic device can be any service, such as distributed application management service, audio service, etc. Among them, the registration death notification is used to receive a notification when the client accidentally hangs up due to internal errors or other circumstances after the Binder communication is established.
[0329] See also Fig. 22 , Fig. 22 A timing diagram of a cross-device service call resource cleanup method provided in an embodiment of the present application. Fig. 22 As shown, assume that the service name registered by application 2 is "ServiceS1", and the process of application 2 registering the service is consistent with the process of registering the service in the above-mentioned cross-device service call method. Specifically, the "ServiceS1" service of application 2 is registered in the distributed service management module of the service collaboration module, and the service name ("ServiceS1") and IBinder object (IBinder S1) of the "ServiceS1" service are stored in the distributed service management module. And the corresponding BinderId (BinderId S1) is assigned to the "ServiceS1" service through the distributed Binder management module.
[0330] After the second electronic device stores the service name, 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 request to the second electronic device to obtain the service, and the request carries the device identifier (DeviceId) and the service name ("ServiceS1") when it is initiated. Among them, 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.
[0331] The first electronic device may establish a connection with the second electronic device according to the device identifier in the request.
[0332] The distributed Binder management module of the second electronic device searches for the corresponding service in the distributed service management module according to the service name carried in the message. The correspondence between the service name and the IBinder object is stored in the distributed service management module. After finding the corresponding service, the IBinder object corresponding to the service is determined, and then the IBinder object is returned to the distributed Binder management module of the second electronic device to determine the BinderId S1 corresponding to the IBinder object.
[0333] Then, the distributed Binder management module of the second electronic device can assemble a message (carrying BinderIdS1) 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.
[0334] After receiving the message, the distributed Binder management module of the first electronic device parses and obtains BinderId S1, and creates a local IBinder object (IBinder C1) according to BinderId S1. A mapping relationship is established between IBinder C1 and BinderId S1.
[0335] 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 sequence.
[0336] 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 may register a death notification for the IBinder C1.
[0337] Specifically, application 1 of the first electronic device sends a request (i.e., request parcel, set as req1) to the distributed Binder management module of the first electronic device, wherein req1 contains recipient C1. The distributed Binder management module of the first electronic device allocates a corresponding BinderId (BinderId C1) to recipient C1. A mapping relationship is established between recipient C1 and BinderId C1.
[0338] It can be understood that RecipientC1 is an anonymous binder object created by application 1 itself.
[0339] The distributed Binder management module of the first electronic device replaces the 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.
[0340] 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 and obtains the BinderId C1 in req1.
[0341] 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 the death notification to application 2, that is, the distributed Binder management module of the second electronic device sends an instruction to register the death notification for IBinder S1 (ServiceS1) to application 2.
[0342] After the second electronic device successfully registers the death notification, the registration result is returned to the first electronic device.
[0343] At this time, both the first electronic device and the second electronic device have completed the registration of the death notification. When the service of the second electronic device is exited, the first electronic device and the second electronic device can clean up the resources related to the service according to the death notification mechanism.
[0344] In the embodiment of the present application, after the 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 cleans up the local ServiceS1 related resources in the binderDied function, including the mapping relationship between ServiceS1 and its ServiceName, BinderId, etc.
[0345] After the second electronic device completes the cleaning, it sends a message to notify the first electronic device to clean up the service associated with Service S1, thereby triggering resource cleaning and application notification of the first electronic device.
[0346] After receiving the message, the first electronic device finds the recipientC1 of the service ServiceC1 associated with ServiceS1, and uses the recipientC1 to call back the binderDied function of the death notification interface. After receiving the callback, the application cleans up the resources related to ServiceC1 by itself.
[0347] After the first electronic device completes the callback of recipientC1, it first cleans up the local resources related to ServiceC1, such as the mapping relationship between ServiceC1 and its ServiceName, BinderId, etc.; secondly, it cleans up the mapping relationship between recipientC1 and its BinderId, etc.
[0348] In the embodiment of the present application, the second electronic device may first clean up local resources, and then send a message to notify the first electronic device to clean up resources (eg Fig. 22 Alternatively, a message may be sent to notify the first electronic device to clean up resources first, and then local resources may be cleaned up. Alternatively, parallel processing may be performed: while the second electronic device is cleaning up local resources, a message may be sent to notify the first electronic device to clean up resources. After the second electronic device sends a message to notify the first electronic device to clean up resources, and after cleaning up local resources, the calling resources corresponding to the death notification, such as the mapping relationship between recipientC1 and its BinderId, may also be cleaned up.
[0349] It is understandable that when registering the death notification, the service call is normal. That is, after the first electronic device obtains the service registered by the second electronic device, it must register the death notification. If the death notification is registered when the service is exited, it is meaningless, and it is impossible to notify both ends in time to clean up their respective service call resources.
[0350] After the first electronic device and the second electronic device complete resource cleanup, the first electronic device needs to re-acquire the service of the second electronic device and re-register the death notification when calling the first electronic device next time.
[0351] In summary, the application 1 of the first electronic device can promptly receive the service exit message of the second electronic device, and can promptly clean up the stored resources to avoid causing resource redundancy in the first electronic device. In addition, after the first electronic device promptly cleans up the relevant resources called by the service, there is no longer any information related to the service in the first electronic device (for example, the calling interface of application 1 no longer displays the corresponding second electronic device and service), and there will be no problem of calling the service again and failing to call (for example, the user's click operation on the second electronic device and service in the calling interface is invalid), which can also improve the user's operating experience.
[0352] The present application also provides a chip system, such as Fig.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 can be interconnected via lines. For example, the interface circuit 902 can be used to receive signals from other devices (such as a memory of an electronic device). For another example, the interface circuit 902 can be used to send signals to other devices (such as the processor 901). Exemplarily, the interface circuit 902 can read instructions stored in the memory and send the instructions to the processor 901. When the instructions are executed by the processor 901, the electronic device can execute the various steps in the above embodiments. Of course, the chip system may also include other discrete devices, which are not specifically limited in the embodiments of the present application.
[0353] An embodiment of the present application also provides a computer storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned electronic device, the electronic device executes each function or step executed by the mobile phone in the above-mentioned method embodiment.
[0354] The embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute each function or step executed by the mobile phone in the above method embodiment.
[0355] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned 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.
[0356] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0357] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0358] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0359] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0360] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A cross-device data processing method, applied to a first electronic device, characterized in that: The method comprises: The first electronic device calls a target service of the second electronic device; The first electronic device obtains a first file handle object of a preset file, and creates a first distributed file based on the first file handle object; wherein the preset file is used to store preset data, and the preset data is a result of the second electronic device executing the target service; the first distributed file and the 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 by the first electronic device to return the preset data in the first distributed file to the preset file; The first electronic device sends the file name of the first distributed file to the second electronic device, so that the second electronic device opens the 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; The first electronic device returns the preset data in the first distributed file to the preset file through the first file handle object.
2. The cross-device data processing method according to claim 1, characterized in that: The first electronic device obtains a first file handle object of a preset file, including: The first electronic device receives a first request from a second electronic device to obtain the first file handle object of the preset file; wherein the first request is used by the second electronic device to request the first electronic device to obtain the first file handle object.
3. The cross-device data processing method according to claim 1 or 2, characterized in that: Before the first electronic device sends the file name of the first distributed file to the second electronic device, the method further includes: The first electronic device generates a first transmission data packet based on the first file handle object; wherein the first transmission data packet includes the first file handle object; The first electronic device replaces the first file handle object in the first transmission data packet with the file name of the first distributed file to obtain a second transmission data packet; The first electronic device sending the file name of the first distributed file to the second electronic device includes: The first electronic device sends the second transmission data packet to the second electronic device.
4. The cross-device data processing method according to claim 1 or 2, characterized in that: Before the first electronic device sends the file name of the first distributed file to the second electronic device, the method further includes: The first electronic device generates a first transmission data packet based on the first file handle object; wherein the first transmission data packet includes the first file handle object; The first electronic device replaces the first file handle object in the first transmission data packet with the file name and a preset placeholder of the first distributed file to obtain a second transmission data packet; wherein the first file handle object is stored in a first byte of the first transmission data packet, the file name and the preset placeholder are stored in a second byte of the second transmission data packet, the first byte and the second byte have the same size, and a position of the first byte in the first transmission data packet corresponds to a position of the second byte in the second transmission data packet; The first electronic device sending the file name of the first distributed file to the second electronic device includes: The first electronic device sends the second transmission data packet to the second electronic device.
5. The cross-device data processing method according to claim 3 or 4, characterized in that: The first electronic device sending the second transmission data packet to the second electronic device includes: The first electronic device performs serialization processing on the second transmission data packet to obtain corresponding first serialization data; The first electronic device sends the first serialized data to the second electronic device.
6. The cross-device data processing method according to any one of claims 3 to 5, characterized in that: The first electronic device generates a first transmission data packet based on the first file handle object, including: The first application of the first electronic device generates a first transmission data packet based on the first file handle object; After the first electronic device generates a first transmission data packet based on the first file handle object, the method further includes: The first application sends the first transmission data packet to the distributed Binder management module of the first electronic device; The distributed Binder management module receives the first transmission data packet, and sends a creation instruction for the first distributed file to the distributed file module of the first electronic device based on the first file handle object in the first transmission data packet; The distributed file module creates the first distributed file based on the creation instruction, and sends a creation success instruction to the distributed Binder management module; The first electronic device replaces the first file handle object in the first transmission data packet with the file name of the first distributed file to obtain a second transmission data packet, including: In response to the creation success instruction, the distributed Binder management module replaces the first file handle object in the first transmission data packet with the file name of the first distributed file to obtain a second transmission data packet.
7. The cross-device data processing method according to claim 5 or 6, characterized in that: The first electronic device performs serialization processing on the second transmission data packet to obtain corresponding first serialization data, including: The distributed Binder management module of the first electronic device performs serialization processing on the second transmission data packet to obtain the first serialized data; The first electronic device sending the first serialized data to the second electronic device includes: The distributed Binder management module sends the first serialized data to the second electronic device through the communication module of the first electronic device.
8. A cross-device data processing method, applied to a second electronic device, characterized in that: The method comprises: The second electronic device receives a file name of a first distributed file from the first electronic device; wherein the first distributed file is created by the first electronic device based on a first file handle object of a preset file, and is used together with a second distributed file in the second electronic device to support data access between the first electronic device and the second electronic device, the preset file is used to store preset data, the preset data is a result of the second electronic device executing the target service, and the first file handle object is used by the first electronic device to return the preset data in the first distributed file to the preset file; The second electronic device opens the corresponding second distributed file based on the file name, and obtains a second file handle object of the second distributed file; wherein the second file handle object is used for the second distributed file to obtain the preset data; The second distributed file of the second electronic device obtains the preset data through the second file handle object, and transmits the preset data to the first distributed file of the first electronic device, so that the first electronic device returns the preset data in the first distributed file to the preset file through the first file handle object.
9. The cross-device data processing method according to claim 8, characterized in that: Before the first electronic device obtains the first file handle object of the preset file, the method further includes: The second electronic device sends a first request to the first electronic device; wherein the first request is used by the second electronic device to request the first electronic device to obtain a first file handle object of the preset file.
10. The cross-device data processing method according to claim 8 or 9, characterized in that: The second electronic device receives the file name of the first distributed file from the first electronic device, including: The second electronic device receives a second transmission data packet sent by the first electronic device; wherein the second transmission data packet is obtained by the first electronic device replacing the first file handle object in the first transmission data packet with the file name, and the first transmission data packet is generated by the first electronic device based on the first file handle object.
11. The cross-device data processing method according to claim 10, characterized in that: The second electronic device receives a second transmission data packet sent by the first electronic device, including: The second electronic device receives the first serialized data sent by the first electronic device, and deserializes the first serialized data to obtain a corresponding second transmission data packet; wherein the first serialized data is obtained by the first electronic device serializing the second transmission data packet.
12. The cross-device data processing method according to claim 11, characterized in that: The second electronic device opens the corresponding second distributed file based on the file name, and obtains a second file handle object of the second distributed file, including: The second electronic device opens the corresponding second distributed file based on the file name in the second transmission data packet, and obtains a second file handle object of the second distributed file; Wherein, after the second electronic device opens the corresponding second distributed file based on the file name and obtains the second file handle object of the second distributed file, the method further includes: The second electronic device replaces the file name in the second transmission data packet with the second file handle object to obtain a third transmission data packet.
13. The cross-device data processing method according to claim 11 or 12, characterized in that: The second electronic device receives the first serialized data sent by the first electronic device, and performs deserialization processing on the first serialized data to obtain a corresponding second transmission data packet, including: The distributed Binder management module of the second electronic device receives the first serialized data sent by the first electronic device through the communication module of the second electronic device; The distributed Binder management module deserializes the first serialized data to obtain a corresponding second transmission data packet.
14. The cross-device data processing method according to claim 12 or 13, characterized in that: The second electronic device opens the corresponding second distributed file based on the file name in the second transmission data packet, and obtains a second file handle object of the second distributed file, including: The distributed Binder management module of the second electronic device sends an opening instruction to the distributed file module of the second electronic device based on the file name; wherein the opening instruction includes the file name; The distributed file module opens the second distributed file corresponding to the file name in response to the open instruction, and sends a second file handle object of the second distributed file to the distributed Binder management module; The second electronic device replaces the file name in the second transmission data packet with the second file handle object to obtain a third transmission data packet, including: The distributed Binder management module of the second electronic device replaces the file name in the second transmission data packet with the second file handle object to obtain a third transmission data packet; After the second electronic device replaces the file name in the second transmission data packet with the second file handle object to obtain a third transmission data packet, the method further includes: The distributed Binder management module sends the third transmission data packet to the second application of the second electronic device.
15. The cross-device data processing method according to claim 14, characterized in that: The second distributed file of the second electronic device obtains the preset data through the second file handle object, and transmits the preset data to the first distributed file of the first electronic device, including: The second application returns the acquired preset data to the second distributed file through the second file handle object in the third transmission data packet; The second distributed file transmits the preset data to the first distributed file of the first electronic device.
16. An electronic device, characterized in that: The electronic device comprises: 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, and the computer program code comprises computer instructions, and when the computer instructions are executed by the electronic device, the electronic device executes 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, and when the instructions are executed in an electronic device, the electronic device executes the method according to any one of claims 1 to 15.
Citation Information
Patent Citations
File sharing method and terminal device
CN113672576A
Data synchronization method and device, terminal and storage medium
CN114138908A
File sharing method and electronic equipment
CN114328423A
Data processing system, method and equipment and storage medium
CN114328434A
