Mobile terminal-based unified communication method, electronic device, and medium
By triggering the dynamic proxy mechanism on the mobile terminal and selecting appropriate communication solutions, it solves the problem of application architecture complexity in different communication scenarios, realizes unified communication solutions, reduces maintenance difficulty and improves user experience.
Patent Information
- Application Number
- PCT/CN2024/075975
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-09
- Filing Date
- 2024-02-05
- Publication Date
- 2024-09-12
AI Technical Summary
The existing technology lacks a unified communication solution, which leads to increased application architecture complexity and maintenance difficulty in different communication scenarios, and high learning and use costs.
By triggering the dynamic proxy mechanism on the mobile terminal, it obtains services and selects the appropriate communication solution (same-process, cross-process, remote network or near-field communication), and performs corresponding communication operations based on the channel layer to dynamically switch communication scenarios.
It realizes a unified solution for various communication scenarios, reduces the complexity of application architecture and maintenance difficulty, and improves user experience and development efficiency.
Smart Images

Figure CN2024075975_12092024_PF_FP_ABST
Abstract
Description
Unified communication method, electronic device and medium based on mobile terminal
[0001] This application claims priority to Chinese patent application No. 202310227035.8, filed on March 9, 2023, with the invention name “Unified communication method, electronic device and medium based on mobile terminal”. The entire contents of the above Chinese patent application are incorporated into this application by reference. Technical Field
[0002] The present invention relates to the field of multi-scenario communication technology, and specifically provides a unified communication method, electronic equipment, and medium based on a mobile terminal. Background Art
[0003] With the rapid development of mobile applications, communication has become an indispensable part. Some businesses hope to achieve communication between modules in the same process, while others hope to achieve cross-process communication. Network communication is also essential for mobile Internet services. With the development of the Internet of Things (IoT) and vehicle-mounted systems, many businesses also need to achieve cross-device communication.
[0004] For inter-module communication, there's EventBus and ARouter; for inter-process communication, there's Google's AIDL; for network communication, there's Retrofit and Okhttp; and for communication between in-vehicle computers and IoT devices, there's Huawei's distributed soft bus. However, the underlying implementations of these communications vary significantly, and businesses typically need to choose solutions tailored to specific communication scenarios. While targeted communication solutions exist for each scenario, the industry lacks a proven, unified solution, resulting in extremely high learning and usage costs, significantly increasing the complexity and maintenance difficulty of application architectures.
[0005] Accordingly, the art needs a new unified communication method based on mobile terminals to solve the above problems.
[0006] Summary of the Invention
[0007] The present invention aims to solve the above technical problem, that is, to solve the problem that the prior art lacks a unified solution for various communication scenarios, thereby increasing the complexity of the application architecture and the difficulty of maintenance.
[0008] To achieve the above objectives, in a first aspect, the present invention provides a unified communication method based on a mobile terminal, the method comprising the following steps:
[0009] When the first system calls the service of the second system, the dynamic proxy mechanism is triggered;
[0010] Based on the dynamic proxy mechanism, obtaining the service called by the first system;
[0011] Selecting a corresponding scenario communication solution based on the obtained service, wherein the corresponding scenario communication solution is at least one of a same-process inter-module communication solution, a cross-process inter-module communication solution, a remote network communication solution, and a near-field communication solution;
[0012] Based on the corresponding scenario communication scheme, control the mobile terminal to perform corresponding communication operations.
[0013] In the optional technical solution of the unified communication method based on the mobile terminal, the service includes at least the method of the second system, and the step of "selecting a corresponding scenario communication solution based on the service" includes:
[0014] The corresponding scenario communication solution is selected based on the annotations on the method of the second system.
[0015] In the optional technical solution of the unified communication method based on a mobile terminal, the service includes at least a method of the second system. Before controlling the mobile terminal to perform a corresponding communication operation based on the corresponding scenario communication solution, the method further includes:
[0016] Encapsulate the relevant parameters of the method of the second system into a request object;
[0017] The step of “controlling the mobile terminal to perform a corresponding communication operation based on the corresponding scenario communication scheme” includes:
[0018] Based on the corresponding channel layer, sending the request object from the first system to the second system;
[0019] After the sending of the request object is completed, a return value is returned to the framework layer based on the corresponding channel layer, wherein the return value is a return result of the second system based on the request object;
[0020] Based on the dynamic proxy mechanism, the return value is sent to the first system.
[0021] In the optional technical solution of the above-mentioned unified communication method based on a mobile terminal, the step of “sending the request object from the first system to the second system based on the corresponding channel layer” includes:
[0022] When the corresponding scenario communication scheme is a same-process inter-module communication scheme, the request object is sent to a response processor of the second system based on the same process.
[0023] In the optional technical solution of the above-mentioned unified communication method based on a mobile terminal, the step of “sending the request object from the first system to the second system based on the corresponding channel layer” includes:
[0024] When the corresponding scenario communication solution is a cross-process communication solution, hijack the first Provider and the second Provider, where the first Provider is the Provider of the first system and the second Provider is the Provider of the second system;
[0025] The Binder driver sends the request object from the first system to the second system based on the IBinder interface in the first Provider and the IBinder interface in the second Provider.
[0026] In the optional technical solution of the above-mentioned unified communication method based on a mobile terminal, the step of “sending the request object from the first system to the second system based on the corresponding channel layer” includes:
[0027] When the corresponding scenario communication solution is a near field communication solution, authenticating the second system based on a wireless network;
[0028] When the authentication is passed, a Socket channel is established based on the wireless network;
[0029] Based on the Socket channel, the request object is sent from the first system to the second system.
[0030] In the optional technical solution of the above-mentioned unified communication method based on a mobile terminal, before sending the request object from the first system to the second system, the method further includes:
[0031] When the corresponding scenario communication scheme is a remote network communication scheme, converting the request object into a remote network request object;
[0032] The step of “sending the request object from the first system to the second system based on the corresponding channel layer” includes:
[0033] When the corresponding scenario communication solution is a remote network communication solution, the remote network request object is sent from the first system to the second system based on the Socket channel and the remote network communication protocol.
[0034] In the optional technical solution of the above-mentioned unified communication method based on a mobile terminal, when the corresponding scenario communication solution is at least one of a same-process inter-module communication solution, a cross-process inter-communication solution, and a near-field communication solution, before returning the return value to the framework layer based on the corresponding channel layer, the method further includes:
[0035] a method for determining the second system based on the request object;
[0036] A method for triggering the second system based on reflection.
[0037] In a second aspect, the present invention also provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the unified communication method based on a mobile terminal as described above is implemented.
[0038] In a third aspect, the present invention further provides a readable storage medium storing a plurality of program codes, wherein the program codes are suitable for being loaded and run by a processor to execute any one of the above-mentioned unified communication methods based on mobile terminals.
[0039] Those skilled in the art will understand that, in the technical solution of the present invention, a dynamic proxy mechanism is triggered when a first system calls a service from a second system; based on the dynamic proxy mechanism, the service called by the first system is obtained; based on the obtained service, a corresponding scenario communication scheme is selected, wherein the corresponding scenario communication scheme is at least one of a same-process inter-module communication scheme, a cross-process inter-communication scheme, a remote network communication scheme, and a near-field communication scheme; and based on the corresponding scenario communication scheme, the mobile terminal is controlled to perform the corresponding communication operation. This setting can establish a unified solution for multiple communication scenarios, thereby reducing the complexity and maintenance difficulty of the application architecture and improving the user experience.
[0040] Furthermore, the service includes at least a method of the second system, and the step of "selecting a corresponding scenario communication solution based on the service" includes selecting a corresponding scenario communication solution based on the annotation of the method of the second system. This setting enables the selection of the corresponding scenario communication solution during communication, thereby dynamically switching the communication scenarios between the first and second systems, improving the efficiency of systematic development. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The disclosure of the present invention will be more easily understood with reference to the accompanying drawings. Those skilled in the art will readily appreciate that these drawings are for illustrative purposes only and are not intended to limit the scope of protection of the present invention. Furthermore, similar numbers in the drawings represent similar components, wherein:
[0042] 1 is a schematic flow chart of main steps of a unified communication method based on a mobile terminal according to an embodiment of the present invention;
[0043] FIG2 is a schematic flow chart of main steps for controlling a mobile terminal to perform corresponding communication operations based on a corresponding scenario communication solution according to an embodiment of the present invention;
[0044] FIG3 is a schematic flow chart of main steps when the corresponding scenario communication solution is a cross-process communication solution according to an embodiment of the present invention;
[0045] FIG4 is a schematic diagram of a flow chart of main steps when the corresponding scenario communication solution is a near field communication solution according to an embodiment of the present invention;
[0046] 5 is a schematic diagram of a detailed flow chart of a unified communication method based on a mobile terminal applied to a communication scenario between modules in the same process according to an embodiment of the present invention;
[0047] 6 is a schematic diagram of a detailed flow chart of a unified communication method based on a mobile terminal applied to a cross-process communication scenario according to an embodiment of the present invention;
[0048] 7 is a schematic diagram of a detailed flow chart of a unified communication method based on a mobile terminal applied to a remote network communication scenario according to an embodiment of the present invention;
[0049] FIG8 is a schematic diagram of a detailed flow chart of a unified communication method based on a mobile terminal applied to a near field communication scenario according to an embodiment of the present invention;
[0050] FIG9 is a schematic diagram of a main structural block diagram of an electronic device for executing the mobile terminal-based unified communication method of the present invention. DETAILED DESCRIPTION
[0051] Some embodiments of the present invention are described below with reference to the accompanying drawings. Those skilled in the art should understand that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the scope of protection of the present invention.
[0052] In the description of the present invention, "module" and "processor" may include hardware, software, or a combination of the two. A module may include hardware circuits, various suitable sensors, communication ports, and memory. It may also include software components, such as program code, or a combination of software and hardware. The processor may be a central processing unit, a microprocessor, an image processor, a digital signal processor, or any other suitable processor. The processor has data and / or signal processing functions. The processor may be implemented in software, hardware, or a combination of the two. Non-transitory computer-readable storage media include any suitable medium that can store program code, such as a magnetic disk, hard disk, optical disk, flash memory, read-only memory, random access memory, etc. The terms "at least one of A or B" or "at least one of A and B" have similar meanings to "A and / or B" and may include only A, only B, or A and B. The singular forms "one" and "the" may also include plural forms.
[0053] As described in the background technology section, in order to solve the problem that the prior art lacks a unified solution for various communication scenarios, thereby increasing the complexity and maintenance difficulty of the application architecture, the present invention provides a unified communication method based on a mobile terminal.
[0054] Referring to FIG. 1 , FIG. 1 is a flow chart illustrating the main steps of a unified communication method based on a mobile terminal according to an embodiment of the present invention. The mobile terminal includes, but is not limited to, a smartphone, a tablet computer, and a wearable device. As shown in FIG. 1 , the unified communication method based on a mobile terminal of the present invention includes the following steps:
[0055] Step S101: When the first system calls the service of the second system, the dynamic proxy mechanism is triggered.
[0056] Specifically, the proxy class is responsible for pre-processing messages, filtering messages, and forwarding messages for the delegate class. Through the proxy class, direct access to the delegate class objects can be effectively controlled, and the delegate class objects can be well hidden and protected. Depending on the generation time of the proxy class, the proxy can be divided into static proxy and dynamic proxy. The relationship between the proxy class and the delegate class of the dynamic proxy is determined when the program is executed, that is, its source code is dynamically generated by the JVM (Java Virtual Machine) according to the reflection mechanism during execution. When the first system needs to call the external Java interface of the second system, the framework layer takes over all methods of the second system's external Java interface and returns a dynamic proxy; when the first system calls any method in the second system's external Java interface, the dynamic proxy mechanism will be triggered.
[0057] Step S102: Based on the dynamic proxy mechanism, obtain the service called by the first system.
[0058] Specifically, the framework layer obtains the service of the first system call through a dynamic proxy.
[0059] Step S103: Select a corresponding scenario communication solution based on the obtained service, wherein the corresponding scenario communication solution is at least one of a same-process inter-module communication solution, a cross-process inter-communication solution, a remote network communication solution, and a near-field communication solution.
[0060] Specifically, a process is an operation of a program in a computer on a certain data set, that is, when a program is run, a process is started.
[0061] In some embodiments, the service includes at least a method of the second system, and selecting a corresponding scenario communication scheme based on the service includes: selecting a corresponding scenario communication scheme based on annotations on the method of the second system. Specifically, there is a certain difference between annotations and comments. Annotations can be understood as special tags in the code, which can be read during compilation, class loading, and runtime, and corresponding processing can be performed. The method of the second system is a method of the second system's external Java interface. Selecting a corresponding scenario communication scheme based on the annotations on the method of the second system, that is, the framework layer selects a corresponding scenario communication scheme based on the annotations on the method of the second system's external Java interface.
[0062] Step S104: Based on the corresponding scenario communication solution, control the mobile terminal to perform corresponding communication operations.
[0063] Based on the above steps S101 to S104, the present invention triggers a dynamic proxy mechanism when the first system calls a service of the second system; based on the dynamic proxy mechanism, obtains the service called by the first system; selects a corresponding scenario communication scheme based on the obtained service, wherein the corresponding scenario communication scheme is at least one of a same-process inter-module communication scheme, a cross-process inter-communication scheme, a remote network communication scheme, and a near-field communication scheme; and controls the mobile terminal to perform corresponding communication operations based on the corresponding scenario communication scheme. This setting can establish a unified solution for multiple communication scenarios, thereby reducing the complexity and maintenance difficulty of the application architecture and improving the user experience.
[0064] Step S104 is further described below.
[0065] In some embodiments, the service includes at least a method of the second system. Before controlling the mobile terminal to perform a corresponding communication operation based on a corresponding scenario communication scheme, the method further includes: encapsulating relevant parameters of the method of the second system into a request object.
[0066] Specifically, the method of the second system is the method of the second system's external Java interface, and the relevant parameters include the method name, parameter list and return value. Therefore, the framework layer encapsulates the relevant parameters of the second system's method into a request object, that is, the framework layer encapsulates the method name, parameter list and return value of the second system's external Java interface method into a request object within the framework.
[0067] Referring to FIG. 2 , FIG. 2 is a flow chart illustrating the main steps of controlling a mobile terminal to perform a corresponding communication operation based on a corresponding scenario communication scheme according to an embodiment of the present invention. As shown in FIG. 2 , in some embodiments, controlling a mobile terminal to perform a corresponding communication operation based on a corresponding scenario communication scheme includes the following steps:
[0068] Step S201: Based on the corresponding channel layer, the request object is sent from the first system to the second system.
[0069] Step S202: After the request object is sent, a return value is returned to the framework layer based on the corresponding channel layer, wherein the return value is a return result of the second system based on the request object.
[0070] Step S203: Based on the dynamic proxy mechanism, the return value is sent to the first system.
[0071] Specifically, after the request object is sent, the return value is assembled into a response object inside the framework layer, and the response object is returned to the framework layer based on the corresponding channel layer; the framework layer obtains the return value from the response object, and sends the return value to the first system based on the dynamic proxy mechanism.
[0072] In some embodiments, when the corresponding scenario communication scheme is a same-process module communication scheme, sending the request object from the first system to the second system based on the corresponding channel layer includes: sending the request object to the response processor of the second system based on the same process.
[0073] Refer to Figure 3, which is a flowchart illustrating the main steps when the corresponding scenario communication scheme is an inter-process communication scheme according to an embodiment of the present invention. As shown in Figure 3, when the corresponding scenario communication scheme is an inter-process communication scheme, sending the request object from the first system to the second system based on the corresponding channel layer includes the following steps:
[0074] Step S301: hijacking a first Provider and a second Provider, wherein the first Provider is a Provider of a first system, and the second Provider is a Provider of a second system.
[0075] Step S302: The Binder driver sends the request object from the first system to the second system based on the IBinder interface in the first Provider and the IBinder interface in the second Provider.
[0076] Specifically, a provider is one of the four major components of an Android application. It serves as the sole means of sharing data between applications (across applications). Its primary function is to store and retrieve data and provide an interface for other applications to access that data. The IBinder interface is the fundamental interface for remote objects, defining the core components for high-performance, lightweight remote calls across processes. The IBinder interface's primary API (inter-process communication) is transact(), and its corresponding method is Binder.onTransact(). transact() initiates a call to the remote IBinder object, while onTransact() allows the remote object to respond to the incoming call. The IBinder interface's APIs execute synchronously; for example, transact() does not return until the other party's Binder.onTransact() method completes. Each process that needs to provide services (API calls) to other processes must register with the Binder driver so that the other process can determine where its data should be sent. The Binder driver is not coupled to the business operations within the application process and is solely responsible for implementing inter-process data communication.
[0077] Referring to FIG. 4 , FIG. 4 is a flow chart illustrating the main steps when the corresponding scenario communication solution is a near field communication solution according to an embodiment of the present invention. As shown in FIG. 4 , in some embodiments, when the corresponding scenario communication solution is a near field communication solution, sending the request object from the first system to the second system based on the corresponding channel layer includes the following steps:
[0078] Step S401: authenticating the second system based on the wireless network.
[0079] Step S402: After the authentication is passed, a Socket channel is established based on the wireless network.
[0080] Step S403: Based on the Socket channel, the request object is sent from the first system to the second system.
[0081] Specifically, based on Bluetooth or Wifip2p, the first system and the second system implement the interaction of key information to authenticate the second system. The key information includes the hotspot name, SSID, password, and service list, among which SSID (Service Set Identifier) is the service set identifier. When the authentication is passed, the network is established based on the Wifi hotspot, so that the request object is sent based on the Socket channel within the local area network. Socket is used to describe the IP address and port. It is the handle of the communication chain. It is the basic operation unit of network communication that supports the TCP / IP protocol. It is an abstract representation of the endpoint in the network communication process. Through the socket convention, a computer can receive data from other computers and send data to other computers. The Socket() function returns an integer Socket descriptor. Subsequent operations such as connection establishment and data transmission are all implemented through the Socket.
[0082] In some embodiments, when the corresponding scenario communication scheme is a remote network communication scheme, before sending the request object from the first system to the second system, the method also includes: converting the request object into a remote network request object; based on the corresponding channel layer, sending the request object from the first system to the second system includes: based on the Socket channel and the remote network communication protocol, sending the remote network request object from the first system to the second system.
[0083] Specifically, the framework layer implements a unified network request adaptation layer based on common network libraries. The network request adaptation layer converts the request objects in the framework layer into remote network request objects. The network request adaptation layer is the underlying interaction layer between the user and the network. This layer provides the communication protocol between the user and the network, and encapsulates and hides the interface details.
[0084] For computers and network devices to communicate with each other, both parties must use the same methods. For example, rules such as how to detect the communication target, which side initiates communication first, which language to use for communication, and how to end communication all need to be determined in advance. These rules are called protocols. Remote network communication protocols are TCP / UDP. TCP (Transmission Control Protocol) provides a connection-oriented, reliable byte stream service. It defines the format of data and confirmation information exchanged for reliable transmission between computers and networks, as well as the measures taken to ensure the correct arrival of data. UDP (User Datagram Protocol) is a simple datagram-oriented transport layer protocol that provides non-connection-oriented, unreliable data stream transmission. It only needs to obtain the server's IP and port for transmission. There is no security mechanism during transmission. During transmission, the data stream is sent as is, neither split nor merged.
[0085] For example, a common network library could be OkHttp, a dependency library for processing HTTP network requests. Designed, developed, and open-sourced by Square, OkHttp is currently available in Java and Kotlin. Its main advantages include sharing sockets, reducing the number of network requests, and reducing request latency through connection pooling. Alternatively, a common network library could be SkyNet, an open-source server-side concurrency framework based on C and Lua. This framework is a single-process, multi-threaded model that uses a Skynet node. The master node recognizes all other Skynet nodes in the network, and they establish one-way communication channels with each other. The above-mentioned common network library settings are for illustrative purposes only. In actual applications, you can choose the one based on your actual needs.
[0086] In some embodiments, when the corresponding scenario communication scheme is at least one of a same-process module communication scheme, a cross-process communication scheme, and a near-field communication scheme, before returning the return value to the framework layer based on the corresponding channel layer, the method also includes: a method for determining the second system based on the request object; and a method for triggering the second system based on reflection.
[0087] Specifically, after receiving the request object, the response handler determines the method of the second system based on the method name, parameter list, and return value encapsulated in the request object. The framework layer triggers the method of the second system through reflection. Reflection allows you to obtain all properties and methods of any class and call any method and property of any object at runtime. This dynamic acquisition of information and the ability to call objects is called the reflection mechanism.
[0088] In some embodiments, the framework layer does not require any initialization in any communication scenario and has an automatic garbage collection mechanism. Garbage collection (GC) is a fundamental component of JavaScript's memory management system, designed to prevent memory leaks on both ends of the communication.
[0089] Referring to FIG. 5 , FIG. 5 is a flowchart illustrating detailed steps of a unified communication method based on a mobile terminal for use in a same-process inter-module communication scenario according to an embodiment of the present invention. As shown in FIG. 5 , the unified communication method based on a mobile terminal for use in a same-process inter-module communication scenario includes the following steps:
[0090] Step S501: When a first module calls a service of a second module, a dynamic proxy mechanism is triggered, wherein the first module and the second module belong to the same process.
[0091] Step S502: The service includes a method of the second module, obtains the method of the second module called by the first module based on the dynamic proxy, and selects a communication scheme between modules in the same process based on the annotation on the method of the second module.
[0092] Step S503: The method name, parameter list, and return value of the method of the second module are uniformly encapsulated into a request object within the framework layer.
[0093] Step S504: Perform tracking and monitoring in the basic channel.
[0094] Specifically, through the decoupling of design patterns, the underlying core data channels are abstracted. The sending and receiving interfaces of the corresponding channels in the communication scenarios between modules in the same process will go to the bottom-level basic channel (base channel). Therefore, tracking and monitoring can be performed in the basic channel to monitor and report performance data such as the communication success rate and duration.
[0095] Step S505: Identify that the request object is a request object between modules in the same process, and transmit the request object to the response processor of the framework layer.
[0096] Specifically, the framework layer recognizes that the request object is a request object between modules in the same process, and directly sends the request object to the response processor inside the framework layer.
[0097] Step S506: After receiving the request object, the response processor determines the method of the second module based on the method name, parameter list, and return value encapsulated in the request object.
[0098] Step S507: Actively trigger the method of the second module based on reflection and obtain a return value, where the return value is the return result of the method of the second module.
[0099] Step S508: Assemble the return value into a response object within the framework layer, and return the response object from the second module to the first module based on the channel for sending the request object.
[0100] Step S509: Acquire the return value based on the response object, and transmit the return value to the first module based on the dynamic proxy.
[0101] Referring to FIG. 6 , FIG. 6 is a flowchart illustrating detailed steps of a unified communication method based on a mobile terminal for use in a cross-process communication scenario according to an embodiment of the present invention. As shown in FIG. 6 , the unified communication method based on a mobile terminal for use in a cross-process communication scenario of the present invention includes the following steps:
[0102] Step S601: When the first process calls the service of the second process, the dynamic proxy mechanism is triggered.
[0103] Step S602: The service includes a method of the second process, the method of the second process called by the first process is obtained based on the dynamic proxy, and a cross-process communication scheme is selected based on the annotation on the method of the second process.
[0104] Step S603: The method name, parameter list, and return value of the method of the second process are uniformly encapsulated into a request object within the framework layer.
[0105] Step S604: Perform tracking and monitoring in the basic channel.
[0106] Specifically, through the decoupling of design patterns, the underlying core data channels are abstracted. The sending and receiving interfaces of the corresponding channels in cross-process communication scenarios will all go to the bottom-level basic channel (base channel). Therefore, tracking and monitoring can be performed in the basic channel to monitor and report performance data such as the communication success rate and duration.
[0107] Step S605: Identify the request object as an inter-process request object, and select an inter-process request processor to send the request object.
[0108] Step S606: hijacking the Provider of the first process and the Provider of the second process based on the cross-process request processor, so that the Provider of the first process and the Provider of the second process proxy the cross-process request processor to perform cross-process communication.
[0109] Step S607: Serialize the request object based on the IBinder interface in the Provider of the first process; the Binder driver sends the serialized request object from the first process to the second process based on the IBinder interface in the Provider of the first process and the IBinder interface in the Provider of the second process.
[0110] Specifically, serialization is the process of converting the state information of a request object into a form that can be stored or transmitted. During serialization, the request object writes its current state to a temporary or persistent storage area, preventing it from being stored in memory and consuming memory resources. Serialization also facilitates the transmission of the request object.
[0111] In some embodiments, after obtaining the fd through ashmem, the serialized request object is transmitted based on the Binder driver.
[0112] Specifically, the Binder memory size requested during the initialization of the first process is 1MB-8KB. However, the first process can have multiple Binder threads, and these Binder threads will share this space simultaneously, that is, they all use this space to transfer data with the Binder driver. As a result, the data that a single Binder thread can transfer will not exceed 1MB-8KB. Ashmem (Android Shared Memory) is a memory sharing mechanism provided by Android. fd is the handle of shared memory. It writes large data based on Parcel's WiteBlob; internally, fd is obtained through ashmem and then transmitted based on the Binder driver, thus solving the size limit of Binder transmission.
[0113] Step S608: Based on the Provider of the second process, the serialized request object is deserialized and sent to the response processor.
[0114] Step S609: After receiving the request object, the response processor determines the method of the second process based on the method name, parameter list, and return value encapsulated in the request object.
[0115] Step S610: Actively triggering the method of the second process in a reflection-based manner and obtaining a return value, where the return value is the return result of the method of the second process.
[0116] Step S611: Assemble the return value into a response object within the framework layer, and return the response object from the second process to the first process based on the channel that sent the request object.
[0117] In some embodiments, a callback mechanism is supported for inter-process communication scenarios. Specifically, a callback is a callback, which is equivalent to a reverse call. In inter-process communication scenarios, the callback is cached by the callee and passed to the binder on the service side. The service side maps it based on a unique timestamp. That is, the callback object received by the service on the service side is actually a dynamic proxy object wrapped with a binder and a timestamp, thus achieving a one-to-one mapping between the callback object and the callee.
[0118] Step S612: Acquire the return value based on the response object, and transmit the return value to the first process based on the dynamic proxy.
[0119] Referring to FIG. 7 , FIG. 7 is a flowchart illustrating detailed steps of a unified communication method based on a mobile terminal applied to a remote network communication scenario according to an embodiment of the present invention. As shown in FIG. 7 , the unified communication method based on a mobile terminal applied to a remote network communication scenario of the present invention includes the following steps:
[0120] Step S701: When the business end calls the service of the network end, the dynamic proxy mechanism is triggered.
[0121] Step S702: The service includes a network-side method, obtains the network-side method called by the service end based on the dynamic proxy, and selects a remote network communication solution based on the annotation on the network-side method.
[0122] Step S703: The method name, parameter list, and return value of the network-side method are uniformly encapsulated into a request object within the framework layer.
[0123] Step S704: Perform tracking and monitoring in the basic channel.
[0124] Specifically, through the decoupling of design patterns, the underlying core data channels are abstracted. The sending and receiving interfaces of the corresponding channels in remote network communication scenarios will all go to the bottom-level basic channel (base channel). Therefore, tracking and monitoring can be performed in the basic channel to monitor and report performance data such as the communication success rate and duration.
[0125] Step S705: Identify the request object as a remote network request object, and select a remote network request processor to send the request object.
[0126] Step S706: establishing a network request adaptation layer based on the remote network request processor, and converting the request object into a remote network request object based on the network request adaptation layer.
[0127] Step S707: Based on the Socket channel and TCP / UDP protocol, the remote network request object is sent from the service end to the network end.
[0128] Step S708: Based on the remote network request object, determine the return value corresponding to the network end, wherein the return value is the return result of the method on the network end.
[0129] Step S709: Based on the network request adaptation layer, the return value is converted into a response object within the framework layer and the response object is returned from the network end to the service end based on the channel for sending the remote network request object.
[0130] In some embodiments, a callback mechanism for remote network communication is supported. Specifically, in remote network communication scenarios, the underlying communication channel is a bidirectional channel, and the server receives a dynamic proxy object containing a timestamp, eliminating the need to notify the caller in reverse. This means a one-to-one mapping between the callback object and the caller is achieved based on a unique timestamp.
[0131] Step S710: Obtain the return value based on the response object, and transmit the return value to the service end based on the dynamic proxy.
[0132] Referring to FIG8 , FIG8 is a flowchart illustrating detailed steps of a unified communication method based on a mobile terminal for a near field communication scenario according to an embodiment of the present invention. As shown in FIG8 , the unified communication method based on a mobile terminal for a near field communication scenario of the present invention includes the following steps:
[0133] Step S801: When the service end calls the service of the device end, the dynamic proxy mechanism is triggered.
[0134] Specifically, the number of devices on the device side can be set to 1 or more. In actual applications, the number of device sides can be set according to actual needs.
[0135] Step S802: The service includes a device-side method, obtains the device-side method called by the service end based on the dynamic proxy, and selects a near field communication solution based on the annotation on the device-side method.
[0136] Step S803: The method name, parameter list, and return value of the device-side method are uniformly encapsulated into a request object within the framework layer.
[0137] Step S804: Perform tracking and monitoring in the basic channel.
[0138] Specifically, through the decoupling of design patterns, the underlying core data channels are abstracted. The sending and receiving interfaces of the corresponding channels in the near-field communication scenario will all go to the bottom-level basic channel (base channel). Therefore, tracking and monitoring can be performed in the basic channel to monitor and report performance data such as the communication success rate and duration.
[0139] Step S805: Identify the request object as a near-field request object, and select a near-field request processor to send the request object.
[0140] Step S806: Based on the near field request processor, the device end is authenticated through the wireless network; when the authentication is passed, a Socket channel is established based on the wireless network.
[0141] Step S807: Serialize the request object based on the near field request processor.
[0142] Step S808: A Socket channel is established based on the wireless network to send the serialized request object from the service end to the device end.
[0143] Step S809: The framework layer on the device side receives the serialized request object, deserializes the serialized request object, and sends the deserialized request object to the response processor.
[0144] Step S810: After receiving the request object, the response processor determines the device-side method based on the method name, parameter list, and return value encapsulated in the deserialized request object.
[0145] Step S811: Actively trigger the method on the device side in a reflection-based manner and obtain a return value, where the return value is the return result of the method on the device side.
[0146] Step S812: Assemble the return value into a response object within the framework layer, and return the response object from the device end to the service end based on the channel through which the request object was sent.
[0147] In some embodiments, a callback mechanism for near-field communication is supported. Specifically, in near-field communication scenarios, the underlying communication channel is a bidirectional channel, and the server receives a dynamic proxy object containing a timestamp, eliminating the need to notify the caller in reverse. This means a one-to-one mapping between the callback object and the caller is achieved based on a unique timestamp.
[0148] Step S812: Obtain the return value based on the response object, and transmit the return value to the service end based on the dynamic proxy.
[0149] It should be pointed out that although the various steps in the above embodiments are described in a specific order, those skilled in the art will understand that in order to achieve the effects of the present invention, different steps do not have to be performed in such an order. They can be performed simultaneously (in parallel) or in other orders. These changes are within the scope of protection of the present invention.
[0150] Furthermore, the present invention also provides an electronic device.
[0151] See Figure 9, which is a schematic block diagram of the main structure of an electronic device for executing the mobile terminal-based unified communication method of the present invention. As shown in Figure 9, the present invention also provides an electronic device for executing the mobile terminal-based unified communication method of the present invention. The electronic device includes: a processor 11, a memory 12, and a computer program 13 stored in the memory 12 and executable on the processor 11. When the processor 11 executes the computer program 13, the steps of the above-mentioned method embodiments are implemented. Alternatively, when the processor 11 executes the computer program 13, the functions of the modules / units in the above-mentioned embodiments are implemented.
[0152] Illustratively, the processor 11 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.
[0153] Exemplarily, the memory 12 can be an internal storage unit of the electronic device, such as a hard disk or memory of the electronic device. The memory 12 can also be an external storage device of the electronic device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash memory card, etc. equipped on the electronic device. Furthermore, the memory 12 can also include both an internal storage unit of the electronic device and an external storage device. The memory 12 is used to store computer programs and other programs and data required by the electronic device. The memory 12 can also be used to temporarily store data that has been output or is about to be output.
[0154] In some possible implementations, the electronic device may include multiple processors 11 and memories 12. The program for executing the unified communication method based on mobile terminals of the above-mentioned method embodiment may be divided into multiple subprograms, and each subprogram may be loaded and run by the processor 11 to execute different steps of the unified communication method based on mobile terminals of the above-mentioned method embodiment. Specifically, each subprogram may be stored in a different memory 12, and each processor 11 may be configured to execute the program in one or more memories 12 to jointly implement the unified communication method based on mobile terminals of the above-mentioned method embodiment, that is, each processor 11 executes different steps of the unified communication method based on mobile terminals of the above-mentioned method embodiment to jointly implement the unified communication method based on mobile terminals of the above-mentioned method embodiment.
[0155] The multiple processors 11 may be processors deployed on the same device. For example, the electronic device may be a high-performance device composed of multiple processors, and the multiple processors 11 may be processors configured on the high-performance device. Furthermore, the multiple processors 11 may be processors deployed on different devices. For example, the electronic device may be a server cluster, and the multiple processors 11 may be processors on different servers in the server cluster.
[0156] Furthermore, the present invention also provides a computer-readable storage medium. In a computer-readable storage medium embodiment according to the present invention, the computer-readable storage medium can be configured to store a program for executing the mobile terminal-based unified communication method of the above-mentioned method embodiment, and the program can be loaded and run by the processor to implement the above-mentioned mobile terminal-based unified communication method. For ease of explanation, only the parts related to the embodiment of the present invention are shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present invention. The computer-readable storage medium can be a storage device formed by various electronic devices. Optionally, the computer-readable storage medium in the embodiment of the present invention is a non-temporary computer-readable storage medium.
[0157] Furthermore, it should be understood that since the configuration of each module is merely for the purpose of illustrating the functional units of the apparatus of the present invention, the physical devices corresponding to these modules may be the processor itself, or a portion of the software in the processor, a portion of the hardware, or a combination of software and hardware. Therefore, the number of modules in the figure is merely illustrative.
[0158] Those skilled in the art will appreciate that the various modules in the device can be adaptively split or merged. Such splitting or merging of specific modules does not cause the technical solution to deviate from the principles of the present invention. Therefore, the technical solutions after splitting or merging will fall within the scope of protection of the present invention.
[0159] Thus far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it will be readily understood by those skilled in the art that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art may make equivalent changes or substitutions to the relevant technical features, and the technical solutions after such changes or substitutions will fall within the scope of protection of the present invention.
Claims
1. A unified communication method based on a mobile terminal, characterized in that: The method comprises the following steps: When the first system calls the service of the second system, the dynamic proxy mechanism is triggered; Based on the dynamic proxy mechanism, obtaining the service called by the first system; Selecting a corresponding scenario communication solution based on the obtained service, wherein the corresponding scenario communication solution is at least one of a same-process module communication solution, a cross-process communication solution, a remote network communication solution, and a near-field communication solution; Based on the corresponding scenario communication scheme, control the mobile terminal to perform corresponding communication operations.
2. The unified communication method based on mobile terminal according to claim 1, characterized in that: The service at least includes a method of the second system, and the step of "selecting a corresponding scenario communication scheme based on the service" includes: The corresponding scenario communication scheme is selected based on the annotation on the method of the second system.
3. The unified communication method based on mobile terminal according to claim 1 or 2, characterized in that: The service at least includes a method of the second system, and before controlling the mobile terminal to perform a corresponding communication operation based on the corresponding scene communication scheme, the method further includes: Encapsulating relevant parameters of the method of the second system into a request object; The step of "controlling the mobile terminal to perform a corresponding communication operation based on the corresponding scene communication scheme" includes: Based on the corresponding channel layer, sending the request object from the first system to the second system; After the sending of the request object is completed, a return value is returned to the framework layer based on the corresponding channel layer, wherein the return value is a return result of the second system based on the request object; Based on the dynamic proxy mechanism, the return value is sent to the first system.
4. The unified communication method based on mobile terminal according to claim 3, characterized in that: The step of “sending the request object from the first system to the second system based on the corresponding channel layer” includes: When the corresponding scenario communication scheme is a same-process inter-module communication scheme, the request object is sent to a response processor of the second system based on the same process.
5. The unified communication method based on mobile terminal according to claim 3, characterized in that: The step of “sending the request object from the first system to the second system based on the corresponding channel layer” includes: When the corresponding scenario communication scheme is a cross-process communication scheme, hijack the first Provider and the second Provider, wherein the first Provider is the Provider of the first system, and the second Provider is the Provider of the second system; The Binder driver sends the request object from the first system to the second system based on the IBinder interface in the first Provider and the IBinder interface in the second Provider.
6. The unified communication method based on mobile terminal according to claim 3, characterized in that: The step of “sending the request object from the first system to the second system based on the corresponding channel layer” includes: When the corresponding scene communication scheme is a near field communication scheme, authenticating the second system based on a wireless network; When the authentication is passed, a Socket channel is established based on the wireless network; Based on the Socket channel, the request object is sent from the first system to the second system.
7. The unified communication method based on mobile terminal according to claim 3, characterized in that: Before sending the request object from the first system to the second system, the method further includes: When the corresponding scenario communication scheme is a remote network communication scheme, converting the request object into a remote network request object; The step of “sending the request object from the first system to the second system based on the corresponding channel layer” includes: When the corresponding scenario communication scheme is a remote network communication scheme, the remote network request object is sent from the first system to the second system based on the Socket channel and the remote network communication protocol.
8. The unified communication method based on a mobile terminal according to any one of claims 3 to 7, characterized in that: When the corresponding scenario communication scheme is at least one of a same-process module communication scheme, a cross-process communication scheme, and a near-field communication scheme, before returning the return value to the framework layer based on the corresponding channel layer, the method further includes: A method for determining the second system based on the request object; A method for triggering the second system in a reflection-based manner.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the unified communication method based on the mobile terminal according to any one of claims 1 to 8 is implemented.
10. A readable storage medium storing a plurality of program codes, characterized in that: The program code is suitable for being loaded and run by a processor to execute the unified communication method based on a mobile terminal according to any one of claims 1 to 8.
Citation Information
Patent Citations
Remote calling method and device for different deployment scenes, equipment and storage medium
CN114020498A
Agile development method for realizing partner business rapid landing based on java dynamic proxy and medium
CN114327400A
Class implementation method and device based on section-oriented programming, equipment and medium
CN115658187A
Data translation using a proxy service
US20170187818A1
