CN117827487A - Android application cross-process communication method and device, android device and storage medium - Google Patents

Android application cross-process communication method and device, android device and storage medium Download PDF

Info

Publication number
CN117827487A
CN117827487A CN202311766062.9A CN202311766062A CN117827487A CN 117827487 A CN117827487 A CN 117827487A CN 202311766062 A CN202311766062 A CN 202311766062A CN 117827487 A CN117827487 A CN 117827487A
Authority
CN
China
Prior art keywords
service
interface
information
request
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311766062.9A
Other languages
Chinese (zh)
Inventor
李尚云
张诗豪
陈秋香
罗富贵
李晓亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Maojia Technology Guangdong Co ltd
Original Assignee
Maojia Technology Guangdong Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Maojia Technology Guangdong Co ltd filed Critical Maojia Technology Guangdong Co ltd
Priority to CN202311766062.9A priority Critical patent/CN117827487A/en
Publication of CN117827487A publication Critical patent/CN117827487A/en
Pending legal-status Critical Current

Links

Landscapes

  • Telephonic Communication Services (AREA)

Abstract

The invention relates to the technical field of android application, and discloses a cross-process communication method and device for android Zhuo Ying, android equipment and a storage medium, wherein the method comprises the following steps: when a service call request exists in the current application, acquiring a request service identifier according to the service call request; the system service management is carried out through the interface management component, whether target service information corresponding to the request service identifier exists in the interface management component is judged, and a service information judgment result is obtained; when the service information judging result is yes, service interface information corresponding to the target service and interface proxy object information of the service interface information are obtained; and determining the target service according to the interface proxy object information. Because the invention realizes the management of the service interface through the interface management component, the application can directly inquire and acquire the service, and compared with the existing mode of repeatedly writing AIDL, the invention is beneficial to reducing the cost of system development and maintenance.

Description

Android application cross-process communication method and device, android device and storage medium
Technical Field
The invention relates to the technical field of android applications, in particular to a cross-process communication method and device for android Zhuo Ying, android equipment and a storage medium.
Background
In the android system, different applications are in different processes, and data among the processes are not communicated, so that when the applications need to communicate, data interaction needs to be realized in a cross-process mode.
Conventional android cross-process communications require the creation of a large number of interface definition language (Android Interface Definition Language, AIDL) files. The use of AIDL requires a great deal of work by the developer, including defining interfaces, implementing services, etc., and because the code fault tolerance of the AIDL file is low and the writing fineness requirement is high, these operations are manually written by the developer, so that the problems of high learning cost and large workload are existed in the practical use.
The foregoing is provided merely for the purpose of facilitating understanding of the technical scheme of the present invention and is not intended to represent an admission that the foregoing is related art.
Disclosure of Invention
The invention mainly aims to provide a cross-process communication method and device for security Zhuo Ying, android equipment and a storage medium, and aims to solve the technical problem that a developer needs to expend a great deal of time to write files in the traditional mode of realizing cross-process communication of AIDL files.
To achieve the above object, the present invention provides a method for cross-process communication for security Zhuo Ying, the method comprising the steps of:
When a service call request exists in the current application, acquiring a request service identifier according to the service call request;
performing system service management through an interface management component, and judging whether target service information corresponding to the request service identifier exists in the interface management component or not to obtain a service information judgment result;
when the service information judging result is yes, acquiring service interface information corresponding to the target service and interface proxy object information of the service interface information;
and determining the target service information according to the interface proxy object information.
Optionally, the system service management is performed by the interface management component, and whether the target service information corresponding to the request service identifier exists in the interface management component is judged, so as to obtain a service information judgment result, including:
acquiring all shared class applications in a system, and analyzing the list file information of each shared class application;
extracting shared service interface information of each shared class application according to the list file information;
carrying out interface management on each shared service interface information through the interface management component to obtain management interface information;
And judging whether target service information corresponding to the request service identifier exists in the management interface information according to the request service identifier, and obtaining a service information judgment result.
Optionally, the determining, according to the request service identifier, whether the target service information corresponding to the request service identifier exists in the management interface information, to obtain a service information determination result includes:
acquiring each service item in a cache pool of the interface management component, wherein each service item corresponds to a service identification name;
comparing the request service identifier with each service identifier name, and judging whether target service information corresponding to the request service identifier exists in the management interface information according to a comparison result to obtain a service information judgment result;
and when the service information judging result is yes, acquiring service interface information corresponding to the target service and interface proxy object information of the service interface information, including:
when the target service information corresponding to the request service identifier exists in the management interface information, acquiring a process connection relation of the target service in a cross-process connection pool;
And acquiring service interface information corresponding to the target service and interface proxy object information of the service interface information based on the process connection relation.
Optionally, the comparing the request service identifier with each service identifier name, and judging whether the target service information corresponding to the request service identifier exists in the management interface information according to a comparison result, so as to obtain a service information judgment result, further including:
when the target service information corresponding to the request service identifier does not exist in the management interface information, determining a sharing application corresponding to the request service identifier;
and adding the shared service interface information of the corresponding shared application to the management interface information, and caching the service item provided by the corresponding shared service interface as the target service information into a cache pool of the interface management component.
Optionally, the acquiring service interface information corresponding to the target service and interface proxy object information of the service interface information based on the process connection relationship includes:
determining a service interface of the target service based on the process connection relationship;
creating a dynamic proxy object corresponding to the service interface, and determining an implementation logic mode of the service interface according to the target service information;
And establishing a mapping relation between the implementation logic mode and the dynamic proxy object, and defining a service function of the dynamic proxy object according to the mapping relation to obtain interface proxy object information of the service interface.
Optionally, the determining the target service information according to the interface proxy object information includes:
when a service interface of the target service is called, forwarding a call request to the dynamic proxy object according to the interface proxy object information;
and calling a service mode in the dynamic proxy object to obtain the target service information.
Optionally, the calling the service mode in the dynamic proxy object to obtain the target service information includes:
acquiring an implementation logic mode of a service interface corresponding to the dynamic proxy object;
acquiring a preset processing mode in a transaction processor, and packaging the implementation logic mode according to the preset processing mode to acquire a target calling mode, wherein the transaction processor is obtained by creating the dynamic proxy object in advance;
and obtaining the service item in the target calling mode, and obtaining the target service information by executing the service item.
In addition, to achieve the above object, the present invention also provides a cross-process communication device for android Zhuo Ying, the cross-process communication device for android application includes:
the identification service module is used for acquiring a request service identification according to a service call request when the service call request exists in the current application;
the service judging module is used for carrying out system service management through the interface management component and judging whether target service information corresponding to the request service identifier exists in the interface management component or not to obtain a service information judging result;
the interface acquisition module is used for acquiring service interface information corresponding to the target service and interface proxy object information of the service interface information when the service information judging result is yes;
and the service calling module is used for determining the target service information according to the interface proxy object information.
In addition, in order to achieve the above objective, the present invention also proposes an android device, which includes a memory, a processor, and an android application cross-process communication program stored on the memory and executable on the processor, the android application cross-process communication program being configured to implement the android application cross-process communication method as described above.
In addition, in order to achieve the above object, the present invention also proposes a storage medium having stored thereon an android application cross-process communication program that, when executed by a processor, implements an android application cross-process communication method as described above.
When a service call request exists in the current application, acquiring a request service identifier according to the service call request; performing system service management through an interface management component, and judging whether target service information corresponding to the request service identifier exists in the interface management component or not to obtain a service information judgment result; when the service information judging result is yes, acquiring service interface information corresponding to the target service and interface proxy object information of the service interface information; and determining the target service according to the interface proxy object information. The invention judges whether the corresponding target service information exists in the interface management component according to the request service identification, and realizes the management of the service interface through the interface management component, so that the application can directly inquire and acquire when the service call request exists.
Drawings
Fig. 1 is a schematic diagram of an android device structure of a hardware running environment according to an embodiment of the present invention;
FIG. 2 is a flowchart of a first embodiment of a method for cross-process communication of android applications according to the present invention;
FIG. 3 is a flowchart of a second embodiment of the android application cross-process communication method of the present invention;
FIG. 4 is a system architecture diagram of an android application cross-process communication method implementation of the present invention;
FIG. 5 is a flowchart of a third embodiment of the android application cross-process communication method of the present invention;
FIG. 6 is a schematic diagram of a dynamic proxy for implementing a service interface using an InvolutionHandler in a third embodiment of an android application cross-process communication method of the present invention;
FIG. 7 is a flowchart of an application calling interface in a third embodiment of the android application cross-process communication method of the present invention;
fig. 8 is a block diagram of a first embodiment of an android application cross-process communication device.
The achievement of the objects, functional features and advantages of the present invention will be further described with reference to the accompanying drawings, in conjunction with the embodiments.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
Referring to fig. 1, fig. 1 is a schematic diagram of an android device structure of a hardware running environment according to an embodiment of the present invention.
As shown in fig. 1, the android device may include: a processor 1001, such as a central processing unit (Central Processing Unit, CPU), a communication bus 1002, a user interface 1003, a network interface 1004, a memory 1005. Wherein the communication bus 1002 is used to enable connected communication between these components. The user interface 1003 may include a Display, an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may further include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a Wireless interface (e.g., a Wireless-Fidelity (WI-FI) interface). The Memory 1005 may be a high-speed random access Memory (Random Access Memory, RAM) or a stable nonvolatile Memory (NVM), such as a disk Memory. The memory 1005 may also optionally be a storage device separate from the processor 1001 described above.
Those skilled in the art will appreciate that the structure shown in fig. 1 is not limiting of the android device and may include more or fewer components than shown, or may combine certain components, or a different arrangement of components.
As shown in fig. 1, an operating system, a network communication module, a user interface module, and an android application cross-process communication program may be included in the memory 1005 as one type of storage medium.
In the android device shown in fig. 1, the network interface 1004 is mainly used for data communication with a network server; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 in the android device can be arranged in the android device, and the android device calls the android application cross-process communication program stored in the memory 1005 through the processor 1001 and executes the android application cross-process communication method provided by the embodiment of the invention.
The embodiment of the invention provides a cross-process communication method for android Zhuo Ying, and referring to fig. 2, fig. 2 is a flow chart of a first embodiment of the cross-process communication method for android applications.
In this embodiment, the android application cross-process communication method includes the following steps:
step S10: and when a service call request exists in the current application, acquiring a request service identifier according to the service call request.
It should be understood that, the method of the embodiment may be applied to a scenario where different applications in the android system need to perform inter-process communication, or may be applied to a scenario where the same application where multiple processes exist in the android system needs to perform inter-process communication in the application. The execution subject of the method of the embodiment may be an android system-based computing electronic device with service call, data processing, network communication, program running, for example: cell phones, tablets, etc., and other electronic devices capable of performing the same or similar functions. The following description will be made of this embodiment and the following embodiments by taking the android device as an example.
It should be appreciated that the current application may be any application in the current system that requires data interaction or service invocation with other process applications in the system. The service call request may include a service name that the current application needs to obtain, where the service name may be a request service identifier.
When there is a service call request in the current application, the current application may be regarded as a client application, and the service identifier of the request may identify a service identifier provided by a server application opposite to the current application.
Step S20: and carrying out system service management through an interface management component, and judging whether target service information corresponding to the request service identifier exists in the interface management component or not to obtain a service information judging result.
It should be understood that the interface management component may be a native component ContentProvider of the android system, and the interface management component may perform unified management on service interfaces that are externally published by all applications in the android device system.
It should be appreciated that the request service identification may be a URI identification identifying the service name issued by the ContentProvider. The application in the current system can register and access through the URI identifier, and can call all service interfaces in the issued service after the registration is successful.
Further, since all applications can be loaded into the memory when the system is started, the service interface of each application issued to the outside is obtained, and step S20 includes:
step S21: and acquiring all the shared class applications in the system, and analyzing the list file information of each shared class application.
It should be noted that the shared application may be an application program located in the same android system as the current application, and the shared application may include a service that may be invoked by other applications in the same system.
It should be understood that the manifest file may be an android application manifest file (xml), which is located under the root directory of the application, and the manifest file information may include components, rights, configuration, and other metadata describing the application.
Step S22: and extracting the shared service interface information of each shared class application according to the list file information.
It should be understood that the shared service interface may be a custom interface predefined and implemented by an application developer and required to be issued to other applications for calling, through which it may be determined that each shared application class provides service items for other applications to obtain, that is, the custom interface is a service interface corresponding to each service item. Compared with the existing mode of repeatedly writing AIDL files to realize application cross-process, the embodiment self-defines a set of cross-process frames, has a simpler framework, and is simpler to develop and maintain the system. And the method does not need to write a large amount of AIDL files, only needs a developer to define and realize the interface, and further reduces the development and maintenance cost.
In a specific implementation, when the system is started, all the shared applications can be loaded into the memory in advance, and the custom interfaces externally provided by the shared applications are obtained according to the component data provided in the manifest file information.
Step S23: and carrying out interface management on each piece of shared service interface information through the interface management component to obtain management interface information.
It should be noted that, the ContentProvider is one of four large components of the android system, which can implement cross-process communication and unify data access modes, and compared with the existing method of implementing data sharing by using ContentProvider, in this embodiment, contentProvider is used as an interface management component, which can implement convergence management on all interfaces issued externally in the current system, and provide interfaces for application call.
It should be understood that, in this embodiment, the convergence management of the ContentProvider as the interface is based on the Binder mechanism to manage each service interface, where the management interface information includes interface information of each service interface managed by the ContentProvider. The release of service items in ContentProvider is based on the underlying Binder architecture.
It should be noted that, the Binder may provide an efficient mechanism to allow communication between different processes, and may be used as a bottom layer mechanism by a current application end and a service interface customized by a developer, so as to implement an android. Os. Binder interface in an android system, and implement the method of the onTransact method AIDL manually, without repeatedly writing an AIDL file, and may uniformly walk the customized Binder. When the current application calls the service interface, the Binder is uniformly adopted for cross-process communication.
It should be understood that when the system is started, a total ContentProvider may be published, so that an application in the system may acquire a service item published by the ContentProvider through a URI identifier, and call a corresponding service interface based on the underlying Binder architecture.
Step S24: and judging whether target service information corresponding to the request service identifier exists in the management interface information according to the request service identifier, and obtaining a service information judgment result.
In a specific implementation, after the URI identifier is obtained, it may be determined, based on the management interface information, whether a target service corresponding to the URI exists in the services issued by the ContentProvider according to the URI identifier.
Step S30: and when the service information judging result is yes, acquiring service interface information corresponding to the target service and interface proxy object information of the service interface information.
It should be appreciated that since inter-application communication is performed, an interface proxy object may be set for the service interface that the current application needs to invoke. By adopting the interface proxy object as the proxy class of the service interface to carry out interface call, the communication details of the bottom layer can be encapsulated, so that the current application can call the remote service in a local call mode without concerning the implementation details of the cross-process communication.
It should be understood that after determining the service interfaces of each application, a class for implementing the service interfaces, that is, an implementation class, may be created first, where the implementation class is responsible for actual service logic implementation, then an interface proxy object for the service interfaces may be created based on the implementation class, and then the interface proxy object may make a call for the service interfaces.
Step S40: and determining the target service information according to the interface proxy object information.
In a specific implementation, after the current application establishes connection with the target service based on a Binder mechanism of a preset interface management component, the call of a service item corresponding to a service interface can be realized through the interface proxy object, so that the target service is obtained, and the call mode of the service item is cross-process access based on the Binder mechanism.
In the embodiment, when a service call request exists in the current application, a request service identifier is acquired according to the service call request; performing system service management through an interface management component, and judging whether target service information corresponding to the request service identifier exists in the interface management component or not to obtain a service information judgment result; when the service information judging result is yes, acquiring service interface information corresponding to the target service and interface proxy object information of the service interface information; and determining the target service according to the interface proxy object information. In this embodiment, whether corresponding target service information exists in the interface management component is firstly determined according to the request service identifier, and management of the service interface is achieved through the interface management component, so that the application can directly perform query and acquisition when a service call request exists.
Referring to fig. 3, fig. 3 is a flowchart of a second embodiment of the android application cross-process communication method according to the present invention.
Based on the above embodiment, in order to increase the speed of service call, step S24 includes:
step S241: and acquiring each service item in the cache pool of the interface management component, wherein each service item corresponds to a service identification name.
It should be appreciated that when the current application needs to make a call to a target service, it may be first determined in the cache pool whether the target service exists. The created service item can be placed in the cache pool of the interface management component in advance, and the service item is uniquely corresponding to the service identification name, so that the service in the cache pool can be directly used and reused when the subsequent application calls the service of the same application, the system overhead can be reduced, and the service call rate is improved.
Step S242: and comparing the request service identifier with each service identifier name, and judging whether target service information corresponding to the request service identifier exists in the management interface information according to a comparison result to obtain a service information judgment result.
It should be understood that, because the service items respectively correspond to the service identifier names, the name comparison can be performed, and it is determined whether the service identifier consistent with the requested service identifier exists in the service identifier names corresponding to the service items, if so, it can be determined that the service item with the consistent service identifier is the target service in the management information of the ContentProvider of the service interface of the target service.
Further, in order to further reduce the loss of system resources, step S30 includes:
step S301: and when the target service information corresponding to the request service identifier exists in the management interface information, acquiring the process connection relation of the target service in the cross-process connection pool.
It should be understood that, in the cross-network communication of this embodiment, the interface is invoked based on the Binder mechanism in the ContentProvider, so that the ContentProvider may include a cross-process connection pool, i.e., a Binder connection pool, so that efficiency and performance of the Binder communication can be improved. The Binder connection pool may pre-create a number of process connection relationships, i.e., binder connections, and cache them in system memory, which may be shared by applications in the system. When an application needs to communicate with other processes, an available Binder connection can be obtained from the pool of Binder connections without being recreated. The cost of creating and destroying the Binder connection in the system can be effectively reduced.
In a specific implementation, when the target service information exists in the management interface information, the Binder connection with the corresponding target service can be obtained in the Binder connection pool based on the Binder architecture of the ContentProvider bottom layer.
Step S302: and acquiring service interface information corresponding to the target service and interface proxy object information of the service interface information based on the process connection relation.
It should be understood that after establishing a process connection relationship with the target service, the current application can realize remote call of the service interface of the target service based on the corresponding interface proxy object, thereby obtaining the target service and meeting the cross-process communication requirement of the current application.
Further, when the target service corresponding to the request service identifier does not exist in the cache pool, a new service can be created and stored in the cache pool, so that the current application can directly use the service item in the cache through the ContentProvider. Thus, after step S242, it includes:
step S2001: and when the management interface information does not have the target service information corresponding to the request service identifier, determining the sharing application corresponding to the request service identifier.
Step S2002: and adding the shared service interface information of the corresponding shared application to the management interface information, and caching the service item provided by the corresponding shared service interface as the target service information into a cache pool of the interface management component.
It should be appreciated that when there is no corresponding target service in the management interface information, then the target service is not invoked by the application initialization. The service item corresponding to the request service identifier of the current application and the shared service interface for providing the service item can be determined first, the shared service item interface is added to an interface management component ContentProvider for carrying out aggregation management on the service interface, and the service item is saved in a cache pool of the system so as to facilitate the subsequent application to call the corresponding target service.
Reference is made herein to fig. 4, which is a system architecture diagram of an android application cross-process communication method implementation of the present invention.
In fig. 4, when there is a service CALL request, the application first determines the URI of the service CALL request, then requests connection to the target service based on the URI CALL according to the URI identification to the service name issued by the interface management component ContentProvider as the middleware. Judging whether the target service is in a service cache pool which is a cache pool of the interface management component, if so, directly taking out the service from the service cache pool and returning the service to the application; if not, a new service can be created based on the service name of the URI identifier of the service request and stored in the service cache pool, so that the service in the service cache pool can be used first when the application calls the service next time.
In this embodiment, each service item in the cache pool of the interface management component is obtained, where each service item corresponds to a service identifier name; and comparing the request service identifier with each service identifier name, and judging whether target service information corresponding to the request service identifier exists in the management interface information according to a comparison result to obtain a service information judgment result. When the target service information corresponding to the request service identifier exists in the management interface information, acquiring a process connection relation of the target service in a cross-process connection pool; and acquiring service interface information corresponding to the target service and interface proxy object information of the service interface information based on the process connection relation. When the target service information corresponding to the request service identifier does not exist in the management interface information, determining a sharing application corresponding to the request service identifier; and adding the shared service interface information of the corresponding shared application to the management interface information, and caching the service item provided by the corresponding shared service interface as the target service information into a cache pool of the interface management component. Because the ContentProvider bottom layer in the embodiment adopts a Binder architecture, the communication among applications of multiple processes can be realized, the robustness of the program is improved, and the applications can repeatedly and efficiently use the connection through the Binder connection pool, so that the system resources are saved. In addition, the application can automatically buffer the service after initializing and calling the service, and the service in the service buffer pool can be preferentially used when the service is called again next time, so that the speed of the application cross-process service calling in the system is further improved.
Referring to fig. 5, fig. 5 is a flowchart of a third embodiment of a method for cross-process communication of android applications according to the present embodiment.
Based on the above embodiment, further, considering that the system may adopt a remote call mode when making the cross-procedure call, step S302 includes:
step S3021: and determining a service interface of the target service based on the process connection relation.
It should be appreciated that after the current application establishes a connection with the published target service based on the implementation of the ContentProvider underlying Binder, when the service interface of the target service is invoked, the invocation of the interface is also implemented based on the Binder connection.
It should be noted that, because the current application needs to perform cross-process communication, the current application may implement data exchange between different processes based on a remote procedure call (Remote Procedure Call, RPC) mechanism.
Step S3022: and creating a dynamic proxy object corresponding to the service interface, and determining an implementation logic mode of the service interface according to the target service information.
It should be understood that in the process of implementing RPC, a dynamic proxy object may be constructed based on the Java reflection interface, and the call to the service interface is implemented through the dynamic proxy mode.
It should be noted that, the implementation logic manner may be a specific implementation logic operation of a service item serving as a target service, that is, a specific execution item, and through the specific execution item, a task requirement of a current cross-process task may be met.
Step S3023: and establishing a mapping relation between the implementation logic mode and the dynamic proxy object, and defining a service function of the dynamic proxy object according to the mapping relation to obtain interface proxy object information of the service interface.
It should be appreciated that after determining the specific execution terms of the target service, service function definition may be performed on the dynamic proxy object, instantiation of the dynamic proxy object may be completed, and interface proxy object information for the dynamic proxy object may be obtained.
It should be noted that, the transaction processor that constructs the dynamic proxy object may be designated as InvocationHandler, invocationHandler as a centralized control point for service call, and when the service interface is called by the dynamic proxy object, the call to the service interface is forwarded to the preset handling mode (Invoke) of the transaction processor.
It should be understood that the preset processing manner may include the implementation logic manner, and by establishing a mapping relationship between the implementation logic manner and the dynamic proxy object, it may be determined that the service function of the dynamic proxy object is a specific execution item of the implementation logic manner, so as to determine an interface proxy object of the service interface, and achieve unification of service functions of the interface proxy object and the target service.
Reference is made herein to fig. 6, which is a schematic diagram of a dynamic proxy for implementing a service interface using an invite handler in this embodiment.
In fig. 6, firstly, a service interface Subject to be called is determined, a code class file for realizing a service function in the service interface is defined as a real object RealSubject to be proxied, a ProxyHandler equivalent to an interceptor is set in front of the RealSubject, and encapsulation of the real object is realized by inheriting an Invoke interface and rewriting an Invoke mode. A dynamic Proxy object ProxySubject is then defined as Proxy class Proxy for the encapsulated real object.
In fig. 6, when a specific execution item of a target service in the Subject service interface needs to be called, the Invoke mode in ProxySubject is called, and thus, in this mode, the specific execution item of the target service that needs to be called can be implemented.
The Invoke method in the Invoke handler may be predetermined according to a call method of the service interface, that is, a specific execution item of the target service, and the Invoke method may include serialization and anti-serialization of data, callback of the interface, and the like. After the Invoke mode is determined, a designated invite handler can be generated, then the dynamic proxy object is created according to the mapping relation between the implementation logic mode and the dynamic proxy object through a reflection mechanism, and the instantiation of the dynamic proxy object is completed, so that the interface proxy object is obtained.
It should be appreciated that, since the dynamic proxy object may map the target service of the service interface to be invoked to the specified Invoke handler, it is achieved that all calls to the service interface by the dynamic proxy object will be converted to Invoke methods to Invoke. Thus, step S40 includes:
step S401: and when the service interface of the target service is called, forwarding a calling request to the interface proxy object according to the interface proxy object information.
It should be understood that the calling manner of the service interface may be a code class file for implementing the service function in the service interface, that is, a specific execution item of the target service. The specific execution item can be called through the connection with the service interface, so that the task of completing the target service is achieved.
Step S402: and calling a service mode in the dynamic proxy object to obtain the target service information.
It should be understood that firstly, the implementation logic mode of the service interface corresponding to the dynamic proxy object can be obtained; then, a preset processing mode in a transaction processor is obtained, the implementation logic mode is packaged according to the preset processing mode, and a target calling mode is obtained, wherein the transaction processor is obtained by creating the dynamic proxy object in advance; and finally, obtaining the service item in the target calling mode, and obtaining the target service information by executing the service item.
It should be noted that, the implementation logic manner is a specific execution item of the target service, the transaction processor is an Invoke manner, the preset processing manner is an Invoke manner which is set in a personalized manner, the specific execution item of the target service is packaged by the Invoke manner, so that a service execution item (service item) can be obtained, the service execution item is included in the target calling manner, and the acquisition of the target service information can be realized by executing the service execution item.
In a specific implementation, after a connection relationship is established between a current application and a published target service based on a Binder, an Invoke mode in the Invoke handler needs to be called, so that a service execution item under a service interface corresponding to the target service is called, and target service information is obtained.
Here, reference is made to fig. 7, and fig. 7 is a flowchart of an application call interface in this embodiment.
In fig. 7, after the current application establishes a connection relationship with the target Service, programming is performed towards a corresponding interface to call an abstract interface Service of the Service interface, where the abstract interface may be an implementation interface including a dynamic Proxy object in Invoke mode, i.e. a Proxy class Proxy. The proxy class holds the entire contents of the proxy implementation class (servicell) object, i.e., the proxy class may contain predefined code class files for implementing the service functions in the service interface.
The embodiment determines a service interface of the target service based on the process connection relation; creating a dynamic proxy object corresponding to the service interface, and determining an implementation logic mode of the service interface according to the target service information; and establishing a mapping relation between the implementation logic mode and the dynamic proxy object, and defining a service function of the dynamic proxy object according to the mapping relation to obtain interface proxy object information of the service interface. Because the RPC is combined with the dynamic proxy, the calling details can be shielded, further, the remote calling is realized in the application cross-process calling as simple as the local calling, the quality problem of the project can be greatly reduced, the problem can be rapidly positioned, the simplicity of the system architecture is ensured, and the subsequent development and maintenance of the system are facilitated.
In addition, the embodiment of the invention also provides a storage medium, wherein the storage medium is stored with an android application cross-process communication program, and the android application cross-process communication method is realized when the android application cross-process communication program is executed by a processor.
Furthermore, referring to fig. 8, fig. 8 is a block diagram of a first embodiment of the android application cross-process communication device according to the present invention; the invention also provides a cross-process communication device for the android Zhuo Ying, which comprises the following components:
An identification service module 801, configured to obtain, when a service call request exists in a current application, a request service identification according to the service call request;
the service judging module 802 is configured to perform system service management through an interface management component, and judge whether target service information corresponding to the requested service identifier exists in the interface management component, so as to obtain a service information judging result;
an interface obtaining module 803, configured to obtain service interface information corresponding to a target service and interface proxy object information of the service interface information when the service information determination result is yes;
and a service calling module 804, configured to determine the target service information according to the interface proxy object information.
Further, the service determining module 802 is further configured to obtain all the shared applications in the system, and parse manifest file information of each shared application; extracting shared service interface information of each shared class application according to the list file information; carrying out interface management on each shared service interface information through the interface management component to obtain management interface information; and judging whether target service information corresponding to the request service identifier exists in the management interface information according to the request service identifier, and obtaining a service information judgment result.
When a service call request exists in the current application, the embodiment acquires a request service identifier according to the service call request; performing system service management through an interface management component, and judging whether target service information corresponding to the request service identifier exists in the interface management component or not to obtain a service information judgment result; when the service information judging result is yes, acquiring service interface information corresponding to the target service and interface proxy object information of the service interface information; and determining the target service according to the interface proxy object information. In this embodiment, whether corresponding target service information exists in the interface management component is firstly determined according to the request service identifier, and management of the service interface is achieved through the interface management component, so that the application can directly perform query and acquisition when a service call request exists.
Based on the first embodiment of the android application cross-process communication device, a second embodiment of the android application cross-process communication device is provided.
In this embodiment, a service determining module 802 is configured to obtain each service item in a cache pool of the interface management component, where each service item corresponds to a service identifier name; comparing the request service identifier with each service identifier name, and judging whether target service information corresponding to the request service identifier exists in the management interface information according to a comparison result to obtain a service information judgment result;
an interface obtaining module 803, configured to obtain, when the management interface information includes target service information corresponding to the request service identifier, a process connection relationship of the target service in a cross-process connection pool; and acquiring service interface information corresponding to the target service and interface proxy object information of the service interface information based on the process connection relation.
Further, the service determining module 802 is further configured to determine, when the target service information corresponding to the requested service identifier does not exist in the management interface information, a sharing application corresponding to the requested service identifier; and adding the shared service interface information of the corresponding shared application to the management interface information, and caching the service item provided by the corresponding shared service interface as the target service information into a cache pool of the interface management component.
Further, the interface obtaining module 803 is further configured to determine a service interface of the target service based on the process connection relationship; creating a dynamic proxy object corresponding to the service interface, and determining an implementation logic mode of the service interface according to the target service information; and establishing a mapping relation between the implementation logic mode and the dynamic proxy object, and defining a service function of the dynamic proxy object according to the mapping relation to obtain interface proxy object information of the service interface.
A service calling module 804, configured to forward a call request to the dynamic proxy object according to the interface proxy object information when a service interface of the target service is called; and calling a service mode in the dynamic proxy object to obtain the target service information.
Further, the service calling module 804 is further configured to obtain an implementation logic manner of a service interface corresponding to the dynamic proxy object; acquiring a preset processing mode in a transaction processor, and packaging the implementation logic mode according to the preset processing mode to acquire a target calling mode, wherein the transaction processor is obtained by creating the dynamic proxy object in advance; and obtaining the service item in the target calling mode, and obtaining the target service information by executing the service item.
Other embodiments or specific implementations of the android application cross-process communication device according to the present invention may refer to the above method embodiments, and are not described herein.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. read only memory mirror (Read Only Memory image, ROM)/random access memory (Random Access Memory, RAM), magnetic disk, optical disk), comprising instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the method according to the embodiments of the present invention.
The foregoing description is only of the preferred embodiments of the present invention, and is not intended to limit the scope of the invention, but rather is intended to cover any equivalents of the structures or equivalent processes disclosed herein or in the alternative, which may be employed directly or indirectly in other related arts.

Claims (10)

1. A method of cross-process communication for an apparatus Zhuo Ying, the method comprising:
when a service call request exists in the current application, acquiring a request service identifier according to the service call request;
performing system service management through an interface management component, and judging whether target service information corresponding to the request service identifier exists in the interface management component or not to obtain a service information judgment result;
when the service information judging result is yes, acquiring service interface information corresponding to the target service and interface proxy object information of the service interface information;
and determining the target service information according to the interface proxy object information.
2. The android application cross-process communication method of claim 1, wherein said performing system service management by an interface management component and determining whether there is target service information corresponding to the request service identifier in the interface management component, obtaining a service information determination result, includes:
Acquiring all shared class applications in a system, and analyzing the list file information of each shared class application;
extracting shared service interface information of each shared class application according to the list file information;
carrying out interface management on each shared service interface information through the interface management component to obtain management interface information;
and judging whether target service information corresponding to the request service identifier exists in the management interface information according to the request service identifier, and obtaining a service information judgment result.
3. The android application cross-process communication method of claim 2, wherein said determining, according to said request service identifier, whether there is target service information corresponding to said request service identifier in said management interface information, to obtain a service information determination result includes:
acquiring each service item in a cache pool of the interface management component, wherein each service item corresponds to a service identification name;
comparing the request service identifier with each service identifier name, and judging whether target service information corresponding to the request service identifier exists in the management interface information according to a comparison result to obtain a service information judgment result;
And when the service information judging result is yes, acquiring service interface information corresponding to the target service and interface proxy object information of the service interface information, including:
when the target service information corresponding to the request service identifier exists in the management interface information, acquiring a process connection relation of the target service in a cross-process connection pool;
and acquiring service interface information corresponding to the target service and interface proxy object information of the service interface information based on the process connection relation.
4. The android application cross-process communication method of claim 3, wherein said comparing said request service identifier with each said service identifier name, judging whether there is target service information corresponding to said request service identifier in said management interface information according to a comparison result, and after obtaining a service information judgment result, further comprising:
when the target service information corresponding to the request service identifier does not exist in the management interface information, determining a sharing application corresponding to the request service identifier;
and adding the shared service interface information of the corresponding shared application to the management interface information, and caching the service item provided by the corresponding shared service interface as the target service information into a cache pool of the interface management component.
5. The android application cross-process communication method of claim 3, wherein said obtaining service interface information corresponding to a target service and interface proxy object information of said service interface information based on said process connection relationship comprises:
determining a service interface of the target service based on the process connection relationship;
creating a dynamic proxy object corresponding to the service interface, and determining an implementation logic mode of the service interface according to the target service information;
and establishing a mapping relation between the implementation logic mode and the dynamic proxy object, and defining a service function of the dynamic proxy object according to the mapping relation to obtain interface proxy object information of the service interface.
6. The android application cross-process communication method of claim 5, wherein said determining said target service information from said interface proxy object information comprises:
when a service interface of the target service is called, forwarding a call request to the dynamic proxy object according to the interface proxy object information;
and calling a service mode in the dynamic proxy object to obtain the target service information.
7. The android application cross-process communication method of claim 6, wherein said invoking a service manner in said dynamic proxy object to obtain said target service information comprises:
acquiring an implementation logic mode of a service interface corresponding to the dynamic proxy object;
acquiring a preset processing mode in a transaction processor, and packaging the implementation logic mode according to the preset processing mode to acquire a target calling mode, wherein the transaction processor is obtained by creating the dynamic proxy object in advance;
and obtaining the service item in the target calling mode, and obtaining the target service information by executing the service item.
8. A cross-process communication device for android Zhuo Ying, the cross-process communication device comprising:
the identification service module is used for acquiring a request service identification according to a service call request when the service call request exists in the current application;
the service judging module is used for carrying out system service management through the interface management component and judging whether target service information corresponding to the request service identifier exists in the interface management component or not to obtain a service information judging result;
The interface acquisition module is used for acquiring service interface information corresponding to the target service and interface proxy object information of the service interface information when the service information judging result is yes;
and the service calling module is used for determining the target service information according to the interface proxy object information.
9. An android device, characterized in that the android device comprises: memory, a processor and an android application cross-process communication program stored on the memory and executable on the processor, which when executed by the processor, implements the steps of the android application cross-process communication processing method according to any one of claims 1 to 7.
10. A storage medium, wherein the storage medium has stored thereon an android application cross-process communication program, which when executed by a processor, implements the steps of the android application cross-process communication processing method according to any one of claims 1 to 7.
CN202311766062.9A 2023-12-20 2023-12-20 Android application cross-process communication method and device, android device and storage medium Pending CN117827487A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311766062.9A CN117827487A (en) 2023-12-20 2023-12-20 Android application cross-process communication method and device, android device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311766062.9A CN117827487A (en) 2023-12-20 2023-12-20 Android application cross-process communication method and device, android device and storage medium

Publications (1)

Publication Number Publication Date
CN117827487A true CN117827487A (en) 2024-04-05

Family

ID=90507085

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311766062.9A Pending CN117827487A (en) 2023-12-20 2023-12-20 Android application cross-process communication method and device, android device and storage medium

Country Status (1)

Country Link
CN (1) CN117827487A (en)

Similar Documents

Publication Publication Date Title
US10776171B2 (en) Endpoint management system and virtual compute system
US7673029B2 (en) Grid automation bus to integrate management frameworks for dynamic grid management
EP2153344B1 (en) Dynamically loading scripts
US8978023B2 (en) Canonical mechanism for securely assembling features into a mobile application
US8103713B2 (en) System and method for managing service interactions
US5926636A (en) Remote procedural call component management method for a heterogeneous computer network
US8505029B1 (en) Virtual machine communication
US8091097B2 (en) Distributed virtual machine architecture
EP0817445A2 (en) Apparatus and method for indentifying server computer aggregation topologies
US20060248140A1 (en) Compatibility framework using versioning class loaders
US20040068553A1 (en) Dynamically selecting a Web service container for hosting remotely instantiated Web services
US11595299B2 (en) System and method of suppressing inbound payload to an integration flow of an orchestration based application integration
US20080288622A1 (en) Managing Server Farms
US10977007B2 (en) Apparatus and method for executing function
US10244068B2 (en) System and method for providing distributed caching in a transactional processing environment
US8495664B2 (en) System, method and program product for invoking a remote method
US9128886B2 (en) Computer implemented method, computer system, electronic interface, mobile computing device and computer readable medium
US10963538B2 (en) Client application for web application execution
US20080066060A1 (en) Redirection interface system and method for CIM object manager provider
CN113179269B (en) Protocol data analysis method, system and medium based on Internet of things
US20100153565A1 (en) Connection management in line-of-business
US7353521B1 (en) Object oriented distributed software system with methodology for piggybacked reflective callbacks
CN117827487A (en) Android application cross-process communication method and device, android device and storage medium
CN115633073A (en) Micro-service calling method, electronic device, system and readable storage medium
US8549537B2 (en) Middleware bridge system and method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication