CN113378166A - Method and device for calling Application Program Interface (API) of operating system - Google Patents

Method and device for calling Application Program Interface (API) of operating system Download PDF

Info

Publication number
CN113378166A
CN113378166A CN202110716554.1A CN202110716554A CN113378166A CN 113378166 A CN113378166 A CN 113378166A CN 202110716554 A CN202110716554 A CN 202110716554A CN 113378166 A CN113378166 A CN 113378166A
Authority
CN
China
Prior art keywords
thread
local service
layer
target api
name
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.)
Granted
Application number
CN202110716554.1A
Other languages
Chinese (zh)
Other versions
CN113378166B (en
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.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology 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 Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202110716554.1A priority Critical patent/CN113378166B/en
Publication of CN113378166A publication Critical patent/CN113378166A/en
Application granted granted Critical
Publication of CN113378166B publication Critical patent/CN113378166B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/55Detecting local intrusion or implementing counter-measures
    • G06F21/56Computer malware detection or handling, e.g. anti-virus arrangements
    • G06F21/566Dynamic detection, i.e. detection performed at run-time, e.g. emulation, suspicious activities
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/604Tools and structures for managing or administering access control systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2221/00Indexing scheme relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/21Indexing scheme relating to G06F21/00 and subgroups addressing additional information or applications relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/2141Access rights, e.g. capability lists, access control lists, access tables, access matrices

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Software Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • General Physics & Mathematics (AREA)
  • Bioethics (AREA)
  • Automation & Control Theory (AREA)
  • Virology (AREA)
  • Stored Programmes (AREA)

Abstract

The disclosure provides a method and a device for calling an Application Program Interface (API) of an operating system, and relates to the technical field of computers, in particular to the technical field of clients. The specific implementation scheme is as follows: transmitting the class name and method name corresponding to the target API from the framework layer to the local service layer; searching a method reference corresponding to the target API according to the class name and the method name corresponding to the target API by using a local service thread established in the local service layer, and transmitting the searched method reference back to the framework layer from the local service layer; and calling the target API according to the method reference at the framework layer.

Description

Method and device for calling Application Program Interface (API) of operating system
Technical Field
The present disclosure relates to the field of computer technology, and more particularly, to the field of client technology.
Background
An operating system with an API access blacklist mechanism can restrict system APIs and prohibit non-system processes from accessing the system APIs. For example, when detecting an illegal access to a system API, the operating system of the Android R or above may detect not only a class loader of a caller but also a call stack of the caller, and if it is found that non-system code information of the system API (application programming interface) is intentionally accessed in the call stack, the operating system may recognize that the access of the non-system code information to the access system API is illegal, and prohibit the access.
Disclosure of Invention
The present disclosure provides a method, apparatus, device, and storage medium for calling an Application Program Interface (API) of an operating system.
According to an aspect of the present disclosure, there is provided a method of calling an application program interface API of an operating system, wherein the operating system includes a framework layer and a local service layer, the method including: transmitting the class name and method name corresponding to the target API from the framework layer to the local service layer; searching a method reference corresponding to the target API according to the class name and the method name corresponding to the target API by using a local service thread established in the local service layer, and transmitting the searched method reference back to the framework layer from the local service layer; and calling the target API according to the method reference at the framework layer.
According to another aspect of the present disclosure, there is provided an apparatus for calling an application program interface API of an operating system, wherein the operating system includes a framework layer and a local service layer, the apparatus including: a transfer module for transferring a class name and a method name corresponding to the target API from the framework layer to the local service layer; the searching module is used for searching a method reference corresponding to the target API according to the class name and the method name corresponding to the target API by using a local service thread established in the local service layer; a back transmission module for transmitting the searched method quotation from the local service layer back to the framework layer; and the calling module is used for calling the target API according to the method reference in the framework layer.
Another aspect of the disclosure provides a computing device comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of the embodiments of the present disclosure.
According to another aspect of the disclosed embodiments, there is provided a non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the method shown in the disclosed embodiments.
According to another aspect of the embodiments of the present disclosure, there is provided a computer program product, a computer program, which when executed by a processor implements the method shown in the embodiments of the present disclosure.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present disclosure, nor do they limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description.
Drawings
The drawings are included to provide a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
FIG. 1 schematically illustrates an operating system diagram of methods and apparatus in which an application program interface API of an operating system may be invoked by an application, according to an embodiment of the present disclosure;
FIG. 2 schematically illustrates a flow diagram of a method of calling an Application Program Interface (API) of an operating system, in accordance with an embodiment of the present disclosure;
FIG. 3 schematically illustrates a flow diagram of a method of calling an Application Program Interface (API) of an operating system according to another embodiment of the present disclosure;
FIG. 4 schematically illustrates a diagram of an application program interface API to invoke an operating system according to another embodiment of the present disclosure;
FIG. 5 schematically illustrates a block diagram of an apparatus for calling an Application Program Interface (API) of an operating system, in accordance with an embodiment of the present disclosure; and
FIG. 6 illustrates a schematic block diagram of an example electronic device that can be used to implement embodiments of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, in which various details of the embodiments of the disclosure are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
An operating system of the method and apparatus for calling an application program interface API of the operating system by an application provided by the present disclosure will be described with reference to fig. 1.
Fig. 1 schematically illustrates an operating system diagram of a method and apparatus in which an application program interface API of an operating system may be invoked by an application according to an embodiment of the present disclosure.
As shown in fig. 1, the operating system 10 may be an operating system installed in various smart devices, such as an android operating system. The Android operating system is a Linux-based operating system. Development of upper-layer applications in the Android operating system is generally completed based on Java.
The operating system 10 may include a framework layer 11 and a local service layer 12. The framework layer 11 may include various system services, and the like, among others. Illustratively, the framework layer 11 may be, for example, a Java layer of an Android operating system. The local services layer 12 may include various local services and link libraries, among others. Illustratively, the local service layer may be, for example, a Native layer of an Android operating system. The framework layer 11 and the local service layer 12 can implement mutual calling through an interlayer interface between the framework layer and the local service layer. The inter-layer Interface may be, for example, a JNI (Java Native Interface), which is an integrated programming Interface of Java and other programming languages. The JNI may allow Java programs running on the virtual machine to call programs and libraries written in other languages (e.g., C, C + + and assembly languages, etc.), and may also enable Java virtual machines to be embedded directly into native applications, allow native methods to create, inspect and update Java objects, call Java methods, reference Java classes, capture and throw exceptions, etc.
It should be noted that, in addition to the framework layer 11 and the local service layer 12, the operating system 10 may also include other hierarchical structures, which are not specifically limited in this application.
The method for calling the application program interface API of the operating system will be described in detail below with reference to fig. 2.
FIG. 2 schematically shows a flow diagram of a method of calling an Application Program Interface (API) of an operating system according to an embodiment of the present disclosure. The operating system may include, among other things, a framework layer and a local services layer. The operating system may be, for example, the operating system shown above. The framework layer and the local service layer may be, for example, the framework layer and the local service layer shown above.
As shown in FIG. 2, the method 200 of calling an application program interface API of an operating system includes operations S210-S240.
Wherein the class name and the method name corresponding to the target API are transferred from the framework layer to the local service layer in operation S210.
According to embodiments of the present disclosure, the target API may be, for example, various application program interfaces. For example, in this embodiment, the target API may be an API limited by a system blacklist mechanism, and the API is only accessible to the process of the operating system, and cannot be directly accessed by other processes.
According to an embodiment of the present disclosure, the class name and the method name corresponding to the target API may be transferred from the framework layer to the native service layer, for example, through an inter-layer interface (e.g., a JNI interface) between the framework layer and the native service layer.
Then, in operation S220, a Method (Method) reference corresponding to the target API is found according to the class name and the Method name corresponding to the target API using the local service thread created in the local service layer.
According to embodiments of the present disclosure, a method reference may be used to point to the address of the target API in memory.
According to the embodiment of the disclosure, an independent thread can be newly created at the local service layer for executing the search work of the method reference of the target API. For example, the class name and method name may be passed to the newly created independent thread. And then searching the method reference corresponding to the target API by using the independent thread according to the class name and the method name, and transmitting the searched method reference back to the framework layer from the local service layer.
In operation S230, the found method reference is transmitted from the local service layer back to the framework layer.
According to an embodiment of the present disclosure, the found method reference may be transferred from the local service layer back to the framework layer, for example, through an inter-layer interface between the framework layer and the local service layer.
In operation S240, a target API is called according to the method reference at the framework layer.
According to an embodiment of the present disclosure, a method object may be obtained by a method reference, through which a target API is called.
For operating systems with API access blacklist mechanisms, such as Android R, when detecting illegal access to a target API, these operating systems will detect not only the class loader of the caller, but also the call stack of the caller.
According to the embodiment of the disclosure, a thread is newly built on a framework layer, and a code quoted by a method for searching a target API is run in the newly built thread, so that the thread newly built on a local service layer is not related to the framework layer, namely, a service stack does not exist, at this time, the detection of a calling stack by an operating system is invalid, and the target API is accessed by bypassing the limitation of the operating system.
In addition, the method for calling the API of the operating system according to the embodiment of the disclosure has a simple flow, and the size of the corresponding program file is small. On the other hand, the method has better compatibility. By taking the Android system as an example, the problem of compatibility caused by the change of the Art virtual machine of the Android new version can be avoided.
FIG. 3 schematically illustrates a flow diagram of a method of calling an Application Program Interface (API) of an operating system according to another embodiment of the present disclosure.
As shown in FIG. 3, the method 300 of calling an application program interface API of an operating system includes operations S310 to S370.
Wherein, in operation S310, the class name and the method name corresponding to the target API are transferred to the local service layer through an inter-layer interface between the framework layer and the local service layer using the first thread of the framework layer.
According to the embodiment of the disclosure, a reflection call entry may be set in the framework layer according to the inter-layer interface, for connecting the framework layer and the local service layer. For example, in this embodiment, the inter-layer interface may be a JNI interface, for example. The reflection call entry may for example comprise getdecleardmethod. Based on the method, the first thread can be used for introducing the class name and the method name corresponding to the target API into the reflection call entry, so that the class name and the method name are transmitted to the local service layer in a framework layer.
In operation S320, a new thread is created as a local service thread using a second thread of the local service layer.
According to an embodiment of the present disclosure, a local service thread may be created at a local service layer using a pthread _ create method, for example. The local service thread is created by the pthread _ create method, and the thread in stl is not adopted, so that the corresponding code complexity can be reduced, and the file size of a program file (such as a so file) obtained after the code is compiled can be further reduced.
In operation S330, the class name and the method name are transmitted to the local service thread using the second thread.
According to the embodiment of the disclosure, the second thread can be utilized to acquire the class name and the method name through the interlayer interface, and then the second process establishes communication with the local service process and transmits the class name and the method name to the local service thread. Exemplarily, in this embodiment, the second process may establish communication with the local service process through an attach method.
In operation S340, a method reference corresponding to the target API is searched for according to the class name and the method name using the local service thread.
According to embodiments of the present disclosure, a reflection mechanism may be utilized to find a method reference corresponding to a target API. The reflection mechanism refers to that in the running state of a program, an object of any one class can be constructed, a class to which any one object belongs can be obtained, member variables and methods of any one class can be obtained, and attributes and methods of any one object can be called. This function of dynamically acquiring program information and dynamically calling objects is called a reflection mechanism.
In operation S350, the second thread merges the local service threads to obtain the method reference found by the local service threads.
According to the embodiment of the present disclosure, for example, the local service thread may be merged into the second thread by using a pthread _ join method, so that the second thread may obtain a method reference found by the local service thread.
As an alternative embodiment, in the case where the second thread is referred to by the method, a thread detach operation may be performed for the local service thread to release the resources occupied by the local service thread. For example, in this embodiment, the thread separation operation may be performed on the local service thread by the detach method.
In operation S360, the method reference is transferred back to the framework layer through the inter-layer interface using the second thread.
According to an embodiment of the disclosure, the method reference may be transferred back to the framework layer through the JNI interface using the second thread.
In operation S370, a target API is called according to the method reference using the first thread.
For example, in this embodiment, at the framework layer, a method object may be obtained according to a method reference, and the method object is taken as a parameter to execute an invoke method to call the target API.
According to the method for calling the application program interface API of the operating system, the detection of the operating system on the service stack can be avoided, and the limitation of a system blacklist mechanism is further avoided. In addition, the method has simpler flow, so the size of the corresponding program file is smaller. On the other hand, the method has better compatibility. By taking the Android system as an example, the problem of compatibility caused by the change of the Art virtual machine of the Android new version can be avoided.
The method for invoking the application program interface API of the operating system described above is further described with reference to FIG. 4 in conjunction with certain embodiments. Those skilled in the art will appreciate that the following example embodiments are only for the understanding of the present disclosure, and the present disclosure is not limited thereto.
For example, in this embodiment, the operating system is an Android operating system, and a version of the Android operating system is an R version or a version greater than the R version. The framework layer is a Java layer of an Android operating system, the local service layer is a Native layer of the Android operating system, the target API is an API limited by a system blacklist mechanism, only the process of the operating system has access right, and other processes cannot directly access.
FIG. 4 schematically shows a diagram of an application program interface API for calling an operating system according to another embodiment of the present disclosure.
As shown in fig. 4, at the Java layer, the upper layer service code initiates an operation of calling a target API at operation S410. In response to the call operation, the first thread of the Java layer obtains the class name and method name of the class in which the target API is located. And then transmitting the class name and the method name corresponding to the target API to a Native layer through a JNI interface.
In operation S420, a Native method is performed at a Native layer.
In operation S430, the second thread of the Native layer creates a new thread, i.e., a Native thread, at the Native layer by using pthread _ create method.
Then, in operation S440, the class name and the method name obtained from the JNI interface are transferred to the Native thread through the attach method.
In operation S450, the Native thread finds a method reference of the target API according to the class name and the method name.
In operation S460, Native threads are separated by the detach method.
In operation S470, the execution result is returned.
In operation S480, when the Method reference of the Native thread to the target API is found to be completed, the second thread obtains the Method reference found by the Native thread through the pthread _ join Method. And then returning the search result to the Java layer through the JNI interface.
Returning to operation S410, the first thread of the Java layer acquires a method reference from the JNI interface, then acquires a method object according to the method reference, and calls the target API through the method object and the invoke method.
Based on the above method for calling the application program interface API of the operating system, the present disclosure also provides an apparatus for calling the application program interface API of the operating system, which will be described in detail below with reference to fig. 5.
FIG. 5 schematically illustrates a block diagram of an apparatus for calling an Application Program Interface (API) of an operating system, according to an embodiment of the present disclosure. The operating system may include, among other things, a framework layer and a local services layer.
As shown in fig. 5, the apparatus 500 for calling an application program interface API of an operating system includes a transmitting module 510, a searching module 520, a returning module 530, and a calling module 540.
The transfer module 510 may be configured to transfer a class name and a method name corresponding to the target API from the framework layer to the local service layer.
The searching module 520 may search, by using the local service thread created in the local service layer, the method reference corresponding to the target API according to the class name and the method name corresponding to the target API.
The pass-back module 530 may pass the found method reference back from the local service layer to the framework layer.
The calling module 540 may call the target API according to the method reference at the framework layer.
According to an embodiment of the present disclosure, the transmitting module may include a transmitting submodule, which may be configured to transmit, by using a first thread of the framework layer, the class name and the method name corresponding to the target API to the local service layer through an inter-layer interface.
According to an embodiment of the present disclosure, the apparatus may further include a creating module, which may create a new thread as the local service thread by using a second thread of the local service layer.
According to an embodiment of the present disclosure, the search module may include a parameter passing sub-module, a search sub-module, and a merge sub-module. The parameter passing module may be configured to transmit the class name and the method name to the local service thread using the second thread. And the searching submodule can search the method reference corresponding to the target API according to the class name and the method name by using the local service thread. And the merging submodule can be used for merging the local service thread by the second thread to obtain the method reference searched by the local service thread.
According to an embodiment of the present disclosure, the apparatus may further include a splitting module, configured to perform a thread splitting operation for the local service thread if the second thread is referred to by the method.
According to an embodiment of the present disclosure, the backhaul module may include a backhaul sub-module for transmitting the method reference back to the framework layer through the inter-layer interface using the second thread.
It should be noted that, in the technical solution of the present disclosure, the acquisition, storage, application, and the like of the personal information of the related user all conform to the regulations of the relevant laws and regulations, and do not violate the common customs of the public order.
The present disclosure also provides an electronic device, a readable storage medium, and a computer program product according to embodiments of the present disclosure.
FIG. 6 illustrates a schematic block diagram of an example electronic device 600 that can be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 6, the apparatus 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM)602 or a computer program loaded from a storage unit 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the device 600 can also be stored. The calculation unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
A number of components in the device 600 are connected to the I/O interface 605, including: an input unit 606 such as a keyboard, a mouse, or the like; an output unit 607 such as various types of displays, speakers, and the like; a storage unit 608, such as a magnetic disk, optical disk, or the like; and a communication unit 609 such as a network card, modem, wireless communication transceiver, etc. The communication unit 609 allows the device 600 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
The computing unit 601 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various dedicated Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, and so forth. The computing unit 601 performs the various methods and processes described above, such as a method of calling an application program interface API of an operating system. For example, in some embodiments, the method of calling an Application Program Interface (API) of an operating system may be implemented as a computer software program tangibly embodied in a machine-readable medium, such as storage unit 608. In some embodiments, part or all of the computer program may be loaded and/or installed onto the device 600 via the ROM 602 and/or the communication unit 609. When the computer program is loaded into RAM 603 and executed by the computing unit 601, one or more steps of the above-described method of calling an application program interface, API, of an operating system may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured by any other suitable means (e.g., by means of firmware) to perform a method of calling an application program interface, API, of an operating system.
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program codes, when executed by the processor or controller, cause the functions/operations specified in the flowchart and/or block diagram to be performed. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), Wide Area Networks (WANs), and the Internet.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present disclosure may be executed in parallel, sequentially, or in different orders, as long as the desired results of the technical solutions disclosed in the present disclosure can be achieved, and the present disclosure is not limited herein.
The above detailed description should not be construed as limiting the scope of the disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present disclosure should be included in the scope of protection of the present disclosure.

Claims (15)

1. A method of calling an application program interface, API, of an operating system, wherein the operating system includes a framework layer and a local services layer, the method comprising:
transmitting the class name and method name corresponding to the target API from the framework layer to the local service layer;
searching a method reference corresponding to the target API according to the class name and the method name corresponding to the target API by using a local service thread established in the local service layer, and transmitting the searched method reference back to the framework layer from the local service layer; and
and calling the target API according to the method reference at the framework layer.
2. The method of claim 1, wherein said communicating, by a framework layer, a class name and a method name corresponding to the target API to a local service layer comprises:
and transmitting the class name and the method name corresponding to the target API to a local service layer through an interlayer interface between the framework layer and the local service layer by utilizing a first thread of the framework layer.
3. The method of claim 2, further comprising creating the local service process at the local service layer, comprising:
and creating a new thread by using a second thread of the local service layer as the local service thread.
4. The method of claim 3, wherein the finding, using the local service thread created in the local service layer, a method reference corresponding to a target API from a class name and a method name corresponding to the target API comprises:
communicating, with the second thread, the class name and the method name to the local service thread;
searching a method reference corresponding to a target API by using the local service thread according to the class name and the method name; and
and the second thread merges the local service thread to obtain the method reference searched by the local service thread.
5. The method of claim 4, further comprising:
performing a thread detach operation for the local service thread if the second thread gets the method reference.
6. The method of claim 4, wherein the transferring the located method reference from the local service layer back to the framework layer comprises:
communicating the method reference back to a framework layer through the inter-layer interface using the second thread.
7. An apparatus for calling an Application Program Interface (API) of an operating system, wherein the operating system includes a framework layer and a local service layer, the apparatus comprising:
a transfer module for transferring a class name and a method name corresponding to the target API from the framework layer to the local service layer;
the searching module is used for searching a method reference corresponding to the target API according to the class name and the method name corresponding to the target API by using a local service thread established in the local service layer;
a back transmission module for transmitting the searched method quotation from the local service layer back to the framework layer; and
and the calling module is used for calling the target API according to the method reference in the framework layer.
8. The apparatus of claim 7, wherein the transmitting module comprises:
and the transmission submodule is used for transmitting the class name and the method name corresponding to the target API to a local service layer through an interlayer interface between the framework layer and the local service layer by utilizing the first thread of the framework layer.
9. The apparatus of claim 8, further comprising a creation module to create a new thread with a second thread of the native service layer as the native service thread.
10. The apparatus of claim 9, wherein the lookup module comprises:
a parameter passing module, configured to transmit the class name and the method name to the local service thread using the second thread;
the searching submodule is used for searching a method reference corresponding to the target API by using the local service thread according to the class name and the method name; and
and the merging submodule is used for merging the local service thread by the second thread to obtain the method reference searched by the local service thread.
11. The apparatus of claim 10, further comprising a detach module to perform a thread detach operation for the native service thread if the second thread gets the method reference.
12. The apparatus of claim 10, wherein the backhaul module comprises:
a pass-back submodule, configured to transmit the method reference back to the framework layer through the inter-layer interface using the second thread.
13. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-6.
14. A non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the method of any one of claims 1-6.
15. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1-6.
CN202110716554.1A 2021-06-25 2021-06-25 Method and device for calling application program interface API of operating system Active CN113378166B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110716554.1A CN113378166B (en) 2021-06-25 2021-06-25 Method and device for calling application program interface API of operating system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110716554.1A CN113378166B (en) 2021-06-25 2021-06-25 Method and device for calling application program interface API of operating system

Publications (2)

Publication Number Publication Date
CN113378166A true CN113378166A (en) 2021-09-10
CN113378166B CN113378166B (en) 2024-05-31

Family

ID=77579393

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110716554.1A Active CN113378166B (en) 2021-06-25 2021-06-25 Method and device for calling application program interface API of operating system

Country Status (1)

Country Link
CN (1) CN113378166B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2015135221A1 (en) * 2014-03-12 2015-09-17 深圳创维-Rgb电子有限公司 Inter-process communication method based on application layer of android and basic application communication system
CN106502668A (en) * 2016-10-20 2017-03-15 武汉斗鱼网络科技有限公司 A kind of interface package method for realizing Android JNI reflections and system
CN108132816A (en) * 2016-12-01 2018-06-08 腾讯科技(深圳)有限公司 The method and apparatus that local ccf layer calls are realized in
CN108897533A (en) * 2018-06-06 2018-11-27 北京奇虎科技有限公司 A kind of method, apparatus and terminal of function call
CN110300056A (en) * 2019-06-28 2019-10-01 四川长虹电器股份有限公司 A kind of real-time response formula API gateway and its request processing method
CN111414265A (en) * 2020-03-23 2020-07-14 海信电子科技(深圳)有限公司 Service framework and method for calling system resources
CN112437006A (en) * 2020-11-20 2021-03-02 北京百度网讯科技有限公司 Request control method and device based on API gateway, electronic equipment and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2015135221A1 (en) * 2014-03-12 2015-09-17 深圳创维-Rgb电子有限公司 Inter-process communication method based on application layer of android and basic application communication system
CN106502668A (en) * 2016-10-20 2017-03-15 武汉斗鱼网络科技有限公司 A kind of interface package method for realizing Android JNI reflections and system
CN108132816A (en) * 2016-12-01 2018-06-08 腾讯科技(深圳)有限公司 The method and apparatus that local ccf layer calls are realized in
CN108897533A (en) * 2018-06-06 2018-11-27 北京奇虎科技有限公司 A kind of method, apparatus and terminal of function call
CN110300056A (en) * 2019-06-28 2019-10-01 四川长虹电器股份有限公司 A kind of real-time response formula API gateway and its request processing method
CN111414265A (en) * 2020-03-23 2020-07-14 海信电子科技(深圳)有限公司 Service framework and method for calling system resources
CN112437006A (en) * 2020-11-20 2021-03-02 北京百度网讯科技有限公司 Request control method and device based on API gateway, electronic equipment and storage medium

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
JAEMIN JUNG等: "Android Malware Detection Based on Useful API Calls and Machine Learning", IEEE XPLORE, 8 November 2018 (2018-11-08) *
于浩: "Android平台JNI代码单元测试方法研究", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *
代蕊蕊;王雅哲;: "完整的安卓***框架层调用图生成方法", 智能计算机与应用, no. 03, 26 June 2018 (2018-06-26) *
汪维富;黄海于;汪维华;: "基于黑名单的Parlay安全框架模型研究", 计算机工程与设计, no. 16, 28 August 2008 (2008-08-28) *

Also Published As

Publication number Publication date
CN113378166B (en) 2024-05-31

Similar Documents

Publication Publication Date Title
US20210208951A1 (en) Method and apparatus for sharing gpu, electronic device and readable storage medium
CN112988499B (en) Data processing method and device, electronic equipment and storage medium
JP5936157B2 (en) Systems, methods, and computer programs for hidden automated data mirroring for native interfaces in distributed virtual machines (hidden automated data mirroring for native interfaces in distributed virtual machines )
CN111367635B (en) Application interface implementation method, device, equipment and medium in host platform layer
CN111767090A (en) Method and device for starting small program, electronic equipment and storage medium
CN111400000A (en) Network request processing method, device, equipment and storage medium
CN114077367A (en) Method and device for realizing shortcut of android application in Linux system
CN112835615B (en) Plug-in processing method and device for software development kit and electronic equipment
US11379201B2 (en) Wrapping method, registration method, device, and rendering apparatus
CN113378166B (en) Method and device for calling application program interface API of operating system
CN113612643B (en) Network configuration method, device and equipment of cloud mobile phone and storage medium
CN112905270B (en) Workflow realization method, device, platform, electronic equipment and storage medium
CN114510334A (en) Class instance calling method and device, electronic equipment and automatic driving vehicle
CN111292223B (en) Graph calculation processing method and device, electronic equipment and storage medium
CN113867920A (en) Task processing method and device, electronic equipment and medium
CN113760262A (en) Task processing method, device, computer system and computer readable storage medium
CN113407259A (en) Scene loading method, device, equipment and storage medium
CN114428646B (en) Data processing method and device, electronic equipment and storage medium
US20230359440A1 (en) Externally-initiated runtime type extension
CN116048519A (en) Front-end business embedding method and device, electronic equipment and storage medium
CN116186450A (en) Micro front-end application system, application rendering method, device and storage medium
CN115061664A (en) Object conversion method and device, electronic equipment and storage medium
CN117520195A (en) Method, apparatus, device, storage medium and program product for testing interface
CN116341663A (en) Extension method, device, equipment and medium of deep learning reasoning framework
CN117609065A (en) Code submitting method and device based on version control tool and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant