Service access methods, devices and storage media
By initializing the first service of the application layer in the Android system and utilizing Binder proxy objects and broadcast functionality, the problem of the application layer being unable to access native layer services is solved, enabling reliable communication between the application layer and the native layer even when framework layer APIs are missing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-21
- Publication Date
- 2026-03-13
AI Technical Summary
In Android systems, the application layer cannot effectively access services in the native layer, especially when relevant APIs in the framework layer are missing, leading to difficulties in interaction.
The first service is initialized when the terminal powers on and starts up. This service is configured in the application layer to enable access to the second service in the native layer and to exchange data through the Binder proxy object and broadcast function, thus ensuring communication between the application layer and the native layer.
Reliable interaction between the application layer and the native layer is achieved without the involvement of the framework layer, ensuring the application's access to native layer services.
Smart Images

Figure CN119668706B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to a service access method, apparatus and storage medium. Background Technology
[0002] The Android Open Source Project (AOSP) is a completely open-source project that is secure and stable, allowing developers to customize an operating system to meet their needs and goals. However, in cases where Android's framework layer APIs are missing or not used, the application layer cannot effectively access services in the native layer. Summary of the Invention
[0003] To overcome the problems existing in related technologies, this disclosure provides a service access method, apparatus and storage medium.
[0004] According to a first aspect of the present disclosure, a service access method is provided, including:
[0005] Upon power-on startup, the terminal initializes a first service, which is configured in the application layer of the terminal. The first service is used to enable access to the second service in the native layer of the terminal.
[0006] The application in the application layer accesses the second service through the first service, wherein the second service is used to implement the hardware driver interaction of the terminal's underlying layer.
[0007] Optionally, initializing the first service includes:
[0008] The first service registers a first interface with the application layer, and the first interface is used for data interaction between the application layer and the first service.
[0009] Optionally, initializing the first service further includes:
[0010] The first service obtains a Binder proxy object, which is used for data interaction between the first service and the second service.
[0011] The application layer application accesses the native layer's second service through the first service, including:
[0012] The application sends an access command to the first service through the first interface;
[0013] The first service responds to the access command, parses the access command and accesses the second service through the Binder proxy object to obtain the target data corresponding to the second service;
[0014] The first service sends the target data to the application through the first interface.
[0015] Optionally, the Binder proxy object is obtained based on a target cpp file, which is obtained by converting a target aidl file using aidl commands. The target aidl file is the aidl file in the native layer related to the second service.
[0016] Optionally, initializing the first service further includes:
[0017] The first service registers with a broadcast function encapsulated in the native layer, which is used by the first service to receive data broadcast by the second service.
[0018] The application layer application accesses the native layer's second service through the first service, including:
[0019] The second service, in response to a state change, sends the target data to the broadcast function;
[0020] The broadcast function sends the target data to the first service via a callback function;
[0021] The first service sends the target data to the application through the first interface.
[0022] Optionally, the broadcast function is obtained by encapsulating the intent and broadcast classes in C or C++, and the broadcast function has the ability to use reflection properties in C or C++.
[0023] Optionally, the second service may be one or more of the following: Bluetooth service, WIFI service, sensor service, audio service, and USB service.
[0024] According to a second aspect of the present disclosure, a service access apparatus is provided, comprising:
[0025] An initialization module is configured to initialize a first service module in response to power-on startup. The first service module is configured in the application layer of the terminal, wherein the first service is used to enable access to the second service of the terminal's native layer.
[0026] An application module is configured to access a second service module of the terminal's native layer through the first service module, wherein the second service module is used to implement the hardware driver interaction of the terminal's underlying layer.
[0027] Optionally, the first service module is configured to register a first interface with the application layer, the first interface being used for data interaction between the application layer and the first service module.
[0028] Optionally, the first service module is configured to obtain a Binder proxy object, which is used for data interaction between the first service module and the second service module;
[0029] The application module is also configured to send an access command to the first service module through the first interface;
[0030] The first service module is configured to respond to the access command, parse the access command and access the second service module through the Binder proxy object to obtain the target data corresponding to the second service module;
[0031] The first service module is configured to send the target data to the application module through the first interface.
[0032] Optionally, the Binder proxy object is obtained based on a target cpp file, which is obtained by converting a target aidl file using aidl commands. The target aidl file is the aidl file in the native layer that is related to the second service module.
[0033] Optionally, the first service module is configured to register with a broadcast function module encapsulated in the native layer, the broadcast function module being used by the first service module to receive data broadcast by the second service module;
[0034] The second service module is configured to send target data to the broadcast function in response to a state change;
[0035] The broadcast function module is configured to send the target data to the first service module via a callback function;
[0036] The first service module sends the target data to the application module through the first interface.
[0037] Optionally, the broadcast function module is obtained by encapsulating the intent class and broadcast class based on C language or C++, and the broadcast function module has the ability to use C language or C++ to perform reflection attributes.
[0038] Optionally, the second service module may be any one or more of the following: Bluetooth service module, WIFI service module, sensor service module, audio service module, and USB service module.
[0039] According to a third aspect of the present disclosure, a service access apparatus is provided, comprising:
[0040] processor;
[0041] Memory used to store processor-executable instructions;
[0042] The processor is configured as follows:
[0043] In response to power-on startup, a first service is initialized. The first service is configured in the application layer of the terminal, wherein the first service is used to enable access to the second service in the native layer of the terminal.
[0044] The application in the application layer accesses the second service through the first service, wherein the second service is used to implement the hardware driver interaction of the terminal's underlying layer.
[0045] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided that stores computer program instructions thereon, which, when executed by a processor, implement the steps of the method described in any of the first aspects of the present disclosure.
[0046] The technical solutions provided by the embodiments of this disclosure may include the following beneficial effects: by configuring the first service and initializing the first service when the terminal is powered on, the application layer application can access the second service of the native layer through the first service without the participation of the framework layer, which can effectively ensure the interaction between the application layer and the native layer in the case of missing related APIs of the framework layer.
[0047] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0048] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0049] Figure 1 This is a flowchart illustrating a service access method according to an exemplary embodiment.
[0050] Figure 2 This is a system architecture diagram illustrating a service access method according to an exemplary embodiment.
[0051] Figure 3 This is a flowchart illustrating another service access method according to an exemplary embodiment.
[0052] Figure 4 This is a block diagram illustrating a service access device according to an exemplary embodiment.
[0053] Figure 5 This is a block diagram illustrating another service access device according to an exemplary embodiment.
[0054] Figure 6 This is a block diagram illustrating yet another service access device according to an exemplary embodiment. Detailed Implementation
[0055] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0056] It should be noted that all actions involving the acquisition of signals, information, or data in this disclosure are carried out in compliance with the relevant data protection laws and policies of the country where the location is situated, and with authorization from the owner of the relevant device.
[0057] Figure 1 This is a flowchart illustrating a service access method according to an exemplary embodiment. The method can be applied to a terminal, which can be an electronic device running an Android operating system, such as a mobile phone or tablet. The Android operating system can encompass Android OS, AOPS, and various derivative systems based on AOSP, such as MIUI. This disclosure does not limit the scope of the method. The terminal includes an application layer and a native layer, such as... Figure 1 As shown, the method includes the following steps.
[0058] S101. The terminal responds to power-on startup and initializes the first service.
[0059] In some embodiments, the first service is configured at the application layer. Optionally, the first service may be implemented in C or C++. It is understood that initializing the first service may include starting the process corresponding to the first service, that is, executing the code corresponding to the first service, so that the terminal can implement the functions provided by the first service after successful power-on.
[0060] In some embodiments, the first service is used to enable access to a second service of the terminal's native layer. For example, the first service can be used by an application to access the second service of the native layer. For instance, the second service can be any one or more of the following: Bluetooth service, Wi-Fi service, sensor service, audio service, USB service. The sensor service may include, for example, a gravity sensor, an orientation sensor, an infrared sensor, a temperature sensor, etc., and this disclosure does not limit the scope of the service.
[0061] In one example, the first service may be, for example, a Bluetooth ADL service for accessing Bluetooth services or a WIFI ADL service for accessing WIFI services, etc. It may be a process configured at the application layer. The name of the first service is not limited in this embodiment of the disclosure.
[0062] S102. Applications in the application layer access the second service in the native layer through the first service.
[0063] Optionally, the second service is used to implement low-level hardware driver interaction on the terminal. It's worth noting that the application layer is above the Java framework layer, and the native layer is below the Java framework layer. The native layer can be developed using C or C++ programming languages and can be used to implement low-level hardware driver interaction, for example, by providing the aforementioned second service.
[0064] In some embodiments, an application accessing a second service may include the application obtaining data corresponding to the second service. Optionally, an application accessing a second service may further include the application sending data to the second service. Optionally, an application accessing a second service may further include the application modifying the configuration corresponding to the second service, etc., which are not limited in this disclosure.
[0065] For example, taking Bluetooth as the second service, an application can access the second service to use Bluetooth functionality. The application could be, for example, a Bluetooth device and configuration options program in the Android operating system, such as the Bluetooth function item in the settings menu, or an app that can use Bluetooth functionality, such as a music player that can implement Bluetooth headset functionality.
[0066] In this embodiment of the disclosure, by configuring the first service and initializing the first service when the terminal is powered on, the application layer application can access the second service of the native layer through the first service without the participation of the framework layer. This can effectively ensure the interaction between the application layer and the native layer in the event that the relevant APIs of the framework layer are missing.
[0067] In some embodiments, initializing the first service includes:
[0068] The first service registers a first interface with the application layer, and the first interface is used for data interaction between the application layer and the first service.
[0069] The first interface can be, for example, a topic / RESTful application layer interface, or any interface capable of enabling cross-process communication at the application layer; this embodiment does not limit the specific interface. Taking the first service as an example of the Bluetooth AIDL service, the first interface can be, for example, a topic / RESTful application layer Bluetooth service-related interface.
[0070] By adopting the above scheme, the first service can register a first interface with the application layer during the initialization of the first service. This allows the application layer application and the first service to interact with each other through the first interface, ensuring the reliability of the application's access to the second service.
[0071] In some embodiments, initializing the first service further includes:
[0072] The first service obtains a Binder proxy object, which is used for data interaction between the first service and the second service.
[0073] Understandably, after the first service and the second service interact with each other, the first service can send the interaction data to the application through the first interface. In other words, the application can access native layer services based on the Binder communication method.
[0074] It's worth noting that Binder IPC (Inter-Process Communication) is a high-efficiency inter-process communication technology in the Android system. It achieves inter-process communication through the underlying mechanism provided by the Binder driver. The Binder driver is the core of Binder IPC communication technology; it's a module located in kernel space responsible for handling inter-process communication requests. The Binder driver provides a set of system call interfaces for creating, registering, finding, and destroying Binder proxy objects, as well as handling inter-process communication requests. For example, the first service can obtain a Binder proxy object through the Binder driver.
[0075] In Binder IPC communication technology, the communication process can be simply described as follows: (1) The server (e.g., the native layer process or service) creates a Binder proxy object and registers it in the Binder driver. (2) The client (e.g., the first service) finds the server's Binder proxy object through the Binder reference. (3) The client calls the corresponding service through the server's Binder proxy object. (4) The server receives the client's call request and processes it. (5) The server returns the processing result to the client.
[0076] In some possible implementations, the Binder proxy object is obtained based on a target cpp file, which is obtained by converting a target aidl file using aidl (Android Interface Definition Language) commands. The target aidl file is the aidl file in the native layer related to the second service.
[0077] Among them, the aidl file is a file used to describe the communication interface between components of an Android application, the cpp file is a C++ source code file, and the aidl command is a compilation command that can generate a cpp base file. Then, development can be carried out based on the generated cpp base file, and the corresponding Binder proxy object can be obtained to realize the data interaction between the first service and the second service of Binder communication.
[0078] Understandably, without a Java-implemented framework layer, the existing interfaces between the native layer and the framework layer cannot be used directly. The above solution uses AIDL commands to effectively convert the existing interfaces into C or C++ implementations, ensuring the reliability of data interaction between the first and second services.
[0079] In some embodiments, the application layer application accesses a second service of the native layer through the first service, including:
[0080] The application sends an access command to the first service through the first interface;
[0081] The first service responds to the access command, parses the access command and accesses the second service through the Binder proxy object to obtain the target data corresponding to the second service;
[0082] The first service sends the target data to the application through the first interface.
[0083] The access command can be used to invoke the capabilities corresponding to the second service. Taking the second service as Bluetooth service as an example, the access command can be used to obtain data transmitted via Bluetooth, or to instruct the search for nearby Bluetooth devices, etc. Correspondingly, the target data may include data received by the Bluetooth module, device information data, etc., which are not limited in this embodiment.
[0084] Furthermore, the calling parameters corresponding to the first interface and the calling parameters of the Binder proxy object can obviously be different. For example, the first service can parse the access command, i.e., the calling parameters corresponding to the first interface, into the corresponding calling parameters of the Binder proxy object. Moreover, before sending the target data to the target application, the first service can also parse the target data, thereby ensuring that the target data can be sent to the application through the first interface.
[0085] Using the above scheme, the application can send an access command to the first service through the first interface, and the first service can parse the access command to call the corresponding capabilities of the second service, and the application can obtain the corresponding feedback data. The application can access the second service through the Binder communication method, which ensures the reliability of the interaction between the application layer and the native layer when the framework layer is not used or the framework layer related APIs are missing.
[0086] In some embodiments, initializing the first service further includes:
[0087] The first service registers with the broadcast function encapsulated in the native layer, which is used by the first service to receive data broadcast by the second service.
[0088] Registering with the broadcast function can include registering the broadcast and callback functions corresponding to the second service. After the first service completes its registration, it can interact with the broadcast data from the second service through the callback functions.
[0089] In some embodiments, the broadcast functionality is derived from the encapsulation of the intent and broadcast classes in C or C++. Optionally, the broadcast functionality has the ability to implement reflection properties using C or C++.
[0090] Understandably, when using a framework layer, the intent and broadcast classes are encapsulated in the native layer using Java to enable communication between the framework layer and the native layer. However, in this embodiment, the first service is implemented in C or C++. Therefore, the two classes can be re-encapsulated in C or C++ to ensure reliable communication between the native layer and the first service. Furthermore, this embodiment can also implement Java's unique reflection capabilities in C or C++, further ensuring the reliability of broadcasting using the C or C++ encapsulated intent and broadcast classes.
[0091] In some embodiments, the application layer application accesses a second service of the native layer through the first service, including:
[0092] In response to a state change, the second service sends the target data to the broadcast function encapsulated in the native layer;
[0093] The broadcast function sends the target data to the first service via a callback function;
[0094] The first service sends the target data to the application through the first interface.
[0095] Taking Bluetooth service as an example, the state change of the second service may include the Bluetooth module detecting a new Bluetooth device or receiving data transmitted by a nearby Bluetooth device. Correspondingly, the target data may include data received by the Bluetooth module, device information data, etc. This disclosure does not limit this aspect.
[0096] Using the above scheme, the second service can send the target data to the first service via broadcast when it determines that the sending status has changed. The first service then sends the target data to the application. The application can access the second service through broadcast communication, ensuring the reliability of the interaction between the application layer and the native layer when the framework layer is not used or when the framework layer-related APIs are missing.
[0097] To enable those skilled in the art to better understand the overall solution provided by the embodiments of this disclosure, the embodiments of this disclosure also provide, for example... Figure 2 The diagram shown illustrates a system architecture diagram of a service access method according to an exemplary embodiment, and... Figure 3 The flowchart shown illustrates a service access method according to an exemplary embodiment.
[0098] like Figure 2As shown, the system includes an application, a first service, AOSP, and a Binder proxy object and broadcast functionality provided by AOSP. AOSP belongs to the native layer in the above embodiments and can be any derivative system developed based on AOSP.
[0099] Reference Figure 2 The application and the first service can interact with each other through the application layer interface based on topic / restful. The first service and AOSP can interact with each other through the Binder proxy object or through the broadcast function. In this way, the application can access the native layer service through the Binder communication method or the broadcast communication method.
[0100] further, Figure 3 This is a flowchart illustrating a service access method according to an exemplary embodiment, such as... Figure 3 As shown, the method includes the following steps:
[0101] S301. Use the aidl command to convert aidl-related files into cpp files to provide the application with a Binder proxy object, thereby providing basic Bluetooth service capabilities.
[0102] S302. Implement Java's reflection properties using C++.
[0103] This facilitates the encapsulation of intent and broadcast in step S303 below.
[0104] S303. In the native layer, the intent and broadcast classes are re-encapsulated in C++ to provide broadcast capabilities.
[0105] S304. During the system power-on initialization process, start the Bluetooth ADL service process.
[0106] In the S305 Bluetooth ADL service, first register the relevant application-layer Bluetooth service interfaces based on topic / RESTful.
[0107] S306. Initialize the Bluetooth ADL service, initialize relevant parameters, and obtain the corresponding AOSP Bluetooth-related services and Binder proxy object.
[0108] S307. In the initialization of the Bluetooth AIL service, register the corresponding Bluetooth service's broadcast and callback functions.
[0109] S308. The application layer interacts with the Bluetooth Aidl service through topic / RESTful. Commands issued by the application are parsed by the Bluetooth Aidl service and then invoke the corresponding capabilities provided by AOSP through the Binder proxy object.
[0110] S309. In response to the state changes of the AOSP Bluetooth service, the broadcast function encapsulated in the native layer of the broadcast notification is used to interact with the AOSP notification data through the callback function registered in the Bluetooth ADL service.
[0111] In this embodiment, the first service is the Bluetooth ADL service, and the second service is the AOSP Bluetooth service. Using this approach, a Bluetooth service interface can be provided to the application layer even when the Bluetooth API at the framework layer is missing, enabling access to the AOSP Bluetooth service. Furthermore, the intent encapsulation at the native layer and the reflection properties of the Java language are implemented in C++, allowing the native layer to obtain application services and the application's broadcast mechanism from AMS (Activity Manager Service).
[0112] In this embodiment, by configuring the first service and initializing it when the terminal powers on, the application layer application can access the second service of the native layer through the first service without the involvement of the framework layer. This effectively ensures the interaction between the application layer and the native layer when the framework layer is not used or when the framework layer-related APIs are missing.
[0113] This disclosure also provides a computer-readable storage medium having stored thereon computer program instructions that, when executed by a processor, implement the steps of the service access method provided in this disclosure.
[0114] Figure 4 This is a block diagram illustrating a service access device 400 according to an exemplary embodiment. For example, device 400 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness device, personal digital assistant, etc.
[0115] Reference Figure 4 The device 400 may include one or more of the following components: processing component 402, memory 404, power supply component 406, multimedia component 408, audio component 410, input / output interface 412, sensor component 414, and communication component 416.
[0116] Processing component 402 typically controls the overall operation of device 400, such as operations associated with display, telephone calls, data communication, camera operation, and recording. Processing component 402 may include one or more processors 420 to execute instructions to perform all or part of the steps of the methods described above. Furthermore, processing component 402 may include one or more modules to facilitate interaction between processing component 402 and other components. For example, processing component 402 may include a multimedia module to facilitate interaction between multimedia component 408 and processing component 402.
[0117] Memory 404 is configured to store various types of data to support the operation of device 400. Examples of such data include instructions for any application or method operating on device 400, contact data, phonebook data, messages, pictures, videos, etc. Memory 404 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0118] Power supply component 406 provides power to various components of device 400. Power supply component 406 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to device 400.
[0119] Multimedia component 408 includes a screen that provides an output interface between the device 400 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 408 includes a front-facing camera and / or a rear-facing camera. When the device 400 is in an operating mode, such as a shooting mode or a video mode, the front-facing camera and / or the rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0120] Audio component 410 is configured to output and / or input audio signals. For example, audio component 410 includes a microphone (MIC) configured to receive external audio signals when device 400 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 404 or transmitted via communication component 416. In some embodiments, audio component 410 also includes a speaker for outputting audio signals.
[0121] Input / output interface 412 provides an interface between processing component 402 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, start buttons, and lock buttons.
[0122] Sensor assembly 414 includes one or more sensors for providing status assessments of various aspects of device 400. For example, sensor assembly 414 may detect the on / off state of device 400, the relative positioning of components such as the display and keypad of device 400, changes in the position of device 400 or a component of device 400, the presence or absence of user contact with device 400, the orientation or acceleration / deceleration of device 400, and temperature changes of device 400. Sensor assembly 414 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 414 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 414 may also include an accelerometer, a gyroscope, a magnetometer, a pressure sensor, or a temperature sensor.
[0123] Communication component 416 is configured to facilitate wired or wireless communication between device 400 and other devices. Device 400 can access wireless networks based on communication standards, such as WiFi, 2G, or 3G, or combinations thereof. In one exemplary embodiment, communication component 416 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 416 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0124] In an exemplary embodiment, the apparatus 400 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the methods described above.
[0125] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 404 including instructions, which can be executed by a processor 420 of the device 400 to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0126] The aforementioned device can be a standalone electronic device or a part of a standalone electronic device. For example, in one embodiment, the device can be an integrated circuit (IC) or a chip, wherein the integrated circuit can be a single IC or a collection of multiple ICs. The chip can include, but is not limited to, the following types: GPU (Graphics Processing Unit), CPU (Central Processing Unit), FPGA (Field Programmable Gate Array), DSP (Digital Signal Processor), ASIC (Application Specific Integrated Circuit), and SoC (System on Chip). The aforementioned integrated circuit or chip can be used to execute executable instructions (or code) to implement the aforementioned service access method. The executable instructions can be stored in the integrated circuit or chip or obtained from other devices or equipment. For example, the integrated circuit or chip includes a processor, memory, and an interface for communicating with other devices. The executable instruction can be stored in the memory, and when the executable instruction is executed by the processor, it implements the above-described service access method; or, the integrated circuit or chip can receive the executable instruction through the interface and transmit it to the processor for execution to implement the above-described service access method.
[0127] In another exemplary embodiment, a computer program product is also provided, the computer program product comprising a computer program executable by a programmable device, the computer program having a code portion for performing the above-described service access method when executed by the programmable device.
[0128] Figure 5 This is a block diagram illustrating a service access device 500 according to an exemplary embodiment. For example, device 500 may be provided as a server. (Refer to...) Figure 5 The apparatus 500 includes a processing component 522, which further includes one or more processors, and memory resources represented by memory 532 for storing instructions, such as application programs, that can be executed by the processing component 522. The application programs stored in memory 532 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 522 is configured to execute instructions to perform the aforementioned service access methods.
[0129] Device 500 may also include a power supply component 526 configured to perform power management of device 500, a wired or wireless network interface 550 configured to connect device 500 to a network, and an input / output interface 558. Device 500 can operate on an operating system, such as Windows Server, stored in memory 532. TM Mac OS X TM Unix TM Linux TM FreeBSD TM Or similar.
[0130] Figure 6 This is a block diagram illustrating a service access apparatus according to an exemplary embodiment, such as... Figure 6 As shown, the service access device 60 includes:
[0131] Initialization module 61 is configured to initialize the first service module in response to power-on startup, and the first service module is configured in the application layer of the terminal;
[0132] Application module 62 is configured to access a second service module of the terminal's native layer through the first service module, wherein the second service module is used to implement hardware driver interaction at the terminal's underlying layer.
[0133] Optionally, the first service module is configured to register a first interface with the application layer, the first interface being used for data interaction between the application layer and the first service module.
[0134] Optionally, the first service module is configured to obtain a Binder proxy object, which is used for data interaction between the first service module and the second service module;
[0135] The application module 62 is also configured to send an access command to the first service module through the first interface;
[0136] The first service module is configured to respond to the access command, parse the access command and access the second service module through the Binder proxy object to obtain the target data corresponding to the second service module;
[0137] The first service module is configured to send the target data to the application module through the first interface.
[0138] Optionally, the Binder proxy object is obtained based on a target cpp file, which is obtained by converting a target aidl file using aidl commands. The target aidl file is the aidl file in the native layer that is related to the second service module.
[0139] Optionally, the first service module is configured to register with a broadcast function module encapsulated in the native layer, the broadcast function module being used by the first service module to receive data broadcast by the second service module;
[0140] The second service module is configured to send target data to the broadcast function in response to a state change;
[0141] The broadcast function module is configured to send the target data to the first service module via a callback function;
[0142] The first service module sends the target data to the application module through the first interface.
[0143] Optionally, the broadcast function module is obtained by encapsulating the intent class and broadcast class in C or C++.
[0144] Optionally, the broadcast function module has the ability to implement reflection properties using C or C++.
[0145] Optionally, the second service module may be any one or more of the following: Bluetooth service module, WIFI service module, sensor service module, audio service module, and USB service module.
[0146] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of this disclosure. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0147] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A service access method characterized by, The application comprises the following steps: A terminal is powered on and a first service is initialized, wherein the first service is configured in an application layer of the terminal, and the first service is used to realize access of a second service in a native layer of the terminal; An application program in the application layer accesses the second service through the first service, wherein the second service is used to realize hardware driver interaction in the bottom layer of the terminal; The first service interacts with the second service through a Binder proxy object-based communication mode or a broadcast function encapsulated in the native layer-based communication mode; the Binder proxy object is used for data interaction between the first service and the second service, and the broadcast function is used for the first service to receive data broadcasted by the second service.
2. The method of claim 1, wherein, The first service is initialized, comprising the following steps: The first service registers a first interface in the application layer, and the first interface is used for data interaction between the application layer and the first service.
3. The method of claim 2, wherein, The first service is initialized, further comprising the following steps: The first service obtains a Binder proxy object; The application program in the application layer accesses the second service in the native layer through the first service, comprising the following steps: The application program sends an access command to the first service through the first interface; The first service responds to the access command, parses the access command and accesses the second service through the Binder proxy object to obtain target data corresponding to the second service; The first service sends the target data to the application program through the first interface.
4. The method of claim 3, wherein, The Binder proxy object is obtained based on a target cpp file, the target cpp file is obtained by converting a target aidl file through an aidl command, and the target aidl file is an aidl file related to the second service in the native layer.
5. The method of claim 2, wherein, The first service is initialized, further comprising the following steps: The first service is registered to a broadcast function encapsulated in the native layer; The application program in the application layer accesses the second service in the native layer through the first service, comprising the following steps: The second service sends target data to the broadcast function in response to a state change; The broadcast function sends the target data to the first service through a callback function; The first service sends the target data to the application program through the first interface.
6. The method of claim 5, wherein, The broadcast function is obtained by encapsulating an intent class and a broadcast class based on C language or C++, and the broadcast function has the ability to reflect properties using C language or C++.
7. The method according to any one of claims 1 to 6, characterized in that, The second service is any one or more of the following: a Bluetooth service, a WIFI service, a sensor service, an audio service and a USB service.
8. A service access device, characterized by The application comprises the following steps: A first service module is initialized in response to power-on, wherein the first service module is configured in an application layer of a terminal, and the first service is used to realize access of a second service in a native layer of the terminal; An application program module is configured to access a second service module of a native layer of the terminal through the first service module, wherein the second service module is configured to implement hardware driver interaction of the terminal bottom layer; The first service module is configured to interact with the second service module through a Binder proxy object-based communication mode or through a broadcast function encapsulated in the native layer-based communication mode; the Binder proxy object is configured to enable the first service module to interact with the second service module; and the broadcast function is configured to enable the first service module to receive data broadcasted by the second service module.
9. A service access device, characterized by The application comprises: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to: initialize a first service in response to power-on start, the first service being configured in an application layer of the terminal, wherein the first service is configured to enable access to a second service of a native layer of the terminal; an application program of the application layer accesses the second service through the first service, wherein the second service is configured to implement hardware driver interaction of the terminal bottom layer; The first service module is configured to interact with the second service module through a Binder proxy object-based communication mode or through a broadcast function encapsulated in the native layer-based communication mode; the Binder proxy object is configured to enable the first service module to interact with the second service module; and the broadcast function is configured to enable the first service module to receive data broadcasted by the second service module.
10. A computer-readable storage medium having stored thereon computer program instructions, wherein, The program instructions, when executed by the processor, implement the steps of the method of any one of claims 1-7.
Citation Information
Patent Citations
Android terminal and method for realizing TR069 network management agent
CN104184618A
Security system and method for operating systems
CN104885092A