Kernel data transmission method and device based on TCP loopback, equipment and medium

By using the TCP loopback kernel data transmission method, the problem of adaptation complexity when multiple applications call kernel data in the Android system is solved, which simplifies the development process and reduces costs.

CN116126565BActive Publication Date: 2026-05-12SHENZHEN KTC COMMERCIAL DISPLAY TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHENZHEN KTC COMMERCIAL DISPLAY TECHNOLOGY CO LTD
Filing Date
2023-03-06
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

When multiple applications in the Android system call kernel data, the HAL layer and Frameworks layer need to be adapted for each application, which makes the development and adaptation process complex and costly.

Method used

By using a kernel data transmission method based on TCP loopback, a communication connection is established between the target Android upper layer and the target user layer based on the TCP loopback address and port number. The target user layer obtains data reading parameters and transmits them to the target kernel. After processing, the target kernel sends the data to the target Android upper layer, thus avoiding the need for pre-configuration of the HAL layer and Frameworks layer.

Benefits of technology

It simplifies the development and adaptation process, improves development efficiency and scalability, and reduces development costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116126565B_ABST
    Figure CN116126565B_ABST
Patent Text Reader

Abstract

The application provides a kernel data transmission method and device based on a TCP loopback, equipment and a medium. After a target Android upper layer and a target user layer establish a connection based on a corresponding TCP loopback address, a communication link between the target Android upper layer and a target kernel is constructed. Then, the target user layer obtains target data reading parameters corresponding to a kernel data acquisition instruction and sends the target data reading parameters to the target kernel. The target kernel obtains target kernel data based on the target data reading parameters and sends the target kernel data to the target user layer. The target user layer sends the target kernel data to the target Android upper layer. The application realizes that a HAL layer and a Frameworks layer corresponding to an application program do not need to be pre-configured in a smart terminal, but a fixed TCP loopback address and different port numbers corresponding to each application program are configured, so that the whole development and adaptation process is simplified, the development efficiency and scalability are improved, and the development cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of kernel data transmission technology, and in particular to a kernel data transmission method, apparatus, device and medium based on TCP loopback. Background Technology

[0002] Currently, the main operating systems installed on smart terminals (such as smartphones and tablets) are Android, HarmonyOS, and iOS (the operating system developed by Apple). Taking Android as an example, when upper-layer applications need to obtain kernel data, they need to adapt the HAL (Hardware Abstraction Layer) and Frameworks (located in the communication link between the kernel and Android applications) to the Android applications. Furthermore, corresponding interfaces for the Android applications need to be added to the Frameworks. If multiple applications are installed on a smart terminal with Android, and each application needs to access kernel data, then the corresponding HAL and Frameworks layers must be adapted for each application, making the entire development and adaptation process complex and increasing development costs. Summary of the Invention

[0003] This application provides a kernel data transmission method, apparatus, device, and medium based on TCP loopback, aiming to solve the problem in the prior art where multiple applications in the Android system have the need to call kernel data, requiring adaptation of their respective HAL and Framework layers for each application, which makes the entire development and adaptation process complex and increases development costs.

[0004] In a first aspect, embodiments of this application provide a kernel data transmission method based on TCP loopback, which includes:

[0005] In response to a kernel data acquisition command, the target Android upper layer corresponding to the kernel data acquisition command is acquired;

[0006] Obtain the target kernel corresponding to the target Android upper layer, and the target user layer corresponding to the target kernel;

[0007] The target Android upper layer establishes a communication connection with the target user layer based on the corresponding TCP loopback address and target port number;

[0008] The target user layer obtains the target data reading parameters corresponding to the kernel data acquisition instruction and sends them to the target kernel;

[0009] The target kernel obtains target kernel data based on the target data reading parameters, and sends the target kernel data to the target user layer according to a preset data stream sending strategy;

[0010] The target user layer sends the target kernel data to the target Android upper layer.

[0011] Secondly, embodiments of this application provide a kernel data transmission device based on TCP loopback, comprising:

[0012] The target Android upper layer determination unit is used to obtain the target Android upper layer corresponding to the kernel data acquisition instruction in response to the kernel data acquisition instruction.

[0013] The target underlying acquisition unit is used to acquire the target kernel corresponding to the target Android upper layer and the target user layer corresponding to the target kernel;

[0014] A communication establishment unit is used to establish a communication connection between the target Android upper layer and the target user layer based on the corresponding TCP loopback address and target port number.

[0015] A parameter acquisition unit is used to acquire target data reading parameters corresponding to the kernel data acquisition instruction in the target user layer and send them to the target kernel;

[0016] The kernel data first sending unit is used to obtain target kernel data based on the target data reading parameters, and send the target kernel data to the target user layer according to a preset data stream sending strategy.

[0017] The kernel data second sending unit is used for the target user layer to send the target kernel data to the target Android upper layer.

[0018] Thirdly, embodiments of this application provide a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the kernel data transmission method based on TCP loopback described in the first aspect.

[0019] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, causes the processor to perform the TCP loopback-based kernel data transmission method described in the first aspect.

[0020] This application provides a kernel data transmission method, apparatus, device, and medium based on TCP loopback. After establishing a connection between the target Android upper layer and the target user layer based on corresponding TCP loopback addresses, a communication link between the target Android upper layer and the target kernel is constructed. Then, the target user layer obtains target data reading parameters corresponding to the kernel data acquisition command and sends them to the target kernel; the target kernel obtains target kernel data based on the target data reading parameters and sends it to the target user layer; the target user layer then sends the target kernel data to the target Android upper layer. This eliminates the need for pre-configuration of the HAL layer and Frameworks layer corresponding to each application in the smart terminal. Instead, it configures a fixed TCP loopback address and different port numbers for each application, simplifying the entire development and adaptation process, improving development efficiency and scalability, and reducing development costs. Attached Figure Description

[0021] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0022] Figure 1 A schematic diagram illustrating an application scenario of the kernel data transmission method based on TCP loopback provided in this application embodiment;

[0023] Figure 2 A flowchart illustrating the kernel data transmission method based on TCP loopback provided in this application embodiment;

[0024] Figure 3 A schematic block diagram of a kernel data transmission device based on TCP loopback provided in an embodiment of this application;

[0025] Figure 4 A schematic block diagram of a computer device provided in an embodiment of this application. Detailed Implementation

[0026] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0027] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.

[0028] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.

[0029] It should also be further understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0030] Please see Figure 1 and Figure 2 , Figure 1 A schematic diagram illustrating an application scenario of the kernel data transmission method based on TCP loopback provided in this application embodiment; Figure 2 This is a flowchart illustrating a kernel data transmission method based on TCP loopback provided in an embodiment of this application. This kernel data transmission method based on TCP loopback is applied to a smart terminal.

[0031] like Figure 2 As shown, the method includes steps S101 to S106.

[0032] S101. In response to the kernel data acquisition instruction, acquire the target Android upper layer corresponding to the kernel data acquisition instruction.

[0033] In this embodiment, when a user operates a smart terminal running the Android system and uses an application installed on it, a kernel data retrieval instruction will be triggered if the application needs to access kernel data. When the smart terminal receives the generated kernel data retrieval instruction, it can first obtain the target Android upper layer corresponding to the kernel data retrieval instruction to determine the specific target application that triggered the kernel data retrieval instruction and its corresponding target Android upper layer.

[0034] The target Android upper layer can be understood as the user interface of the target application. When the user clicks on the interface elements of the user interface (such as virtual buttons, or more specifically, audio data playback buttons), a kernel data acquisition instruction is generated. At this time, the smart terminal can obtain the target application that triggered the kernel data acquisition instruction and its corresponding target Android upper layer.

[0035] In one embodiment, the method further includes the following steps before step S101:

[0036] A mapping relationship between the Android upper layer and the kernel is pre-set; wherein the mapping relationship includes multiple kernels and several Android upper layers corresponding to each kernel;

[0037] The TCP loopback address and port number corresponding to each Android upper layer included in the mapping relationship are pre-set; wherein, the TCP loopback address corresponding to the Android upper layer is used to establish a communication connection between the Android upper layer and the corresponding user layer based on the TCP communication protocol.

[0038] In this embodiment, if multiple applications are installed on a smart terminal, the application developers need to know the terminal model of the smart terminal in advance, as well as the specific kernel information of the smart terminal model (such as the total number of kernels and the application types that each kernel corresponds to). Then, the developers can pre-configure the mapping relationship between the Android upper layers and the kernels for their developed applications, so that the application can call the corresponding kernel when running on the smart terminal. Each kernel corresponds to several Android upper layers (i.e., each kernel corresponds to at least one Android upper layer). For example, the mapping relationship configures eight kernels, labeled kernel 1 to kernel 8. Kernel 1 is mapped to applications 1 to 4, kernel 2 to applications 5 to 8, kernel 3 to applications 9 to 12, kernel 4 to applications 13 to 16, kernel 5 to applications 17 to 20, kernel 6 to applications 21 to 24, kernel 7 to applications 25 to 28, and kernel 8 to applications 29 to 32.

[0039] Simultaneously, the smart terminal needs to pre-configure the TCP loopback address (TCP stands for Transmission Control Protocol) and port number corresponding to each Android upper layer included in the mapping relationship. This ensures that when each application starts, its Android upper layer can establish a communication connection with the corresponding user layer based on the corresponding TCP loopback address and port number using the TCP communication protocol. Furthermore, this user layer is the user layer communicating with the target kernel corresponding to the application's Android upper layer. Referring to the example above, the Android upper layers corresponding to applications 1-32 each have pre-configured TCP loopback addresses (such as 127.0.0.1). After completing these pre-configurations, it can be ensured that when an application starts subsequently, its Android upper layer can establish a communication connection with the corresponding target user layer based on the preset TCP loopback address and corresponding port number, and obtain kernel data using the target user layer as an intermediate carrier. Specifically, the connection between the Android upper layer of different applications and the target user layer is based on a fixed TCP loopback address and a unique port number; that is, the connection relationship between the application's Android upper layer and the user layer is distinguished by the port number.

[0040] S102. Obtain the target kernel corresponding to the target Android upper layer and the target user layer corresponding to the target kernel.

[0041] In this embodiment, after the smart terminal obtains the target Android upper layer of the launched application, it can also determine the target kernel corresponding to the target Android upper layer based on the preset mapping relationship between the Android upper layer and the kernel, and it can also determine the target user layer corresponding to the target kernel. After the above determination of the target kernel and target user layer is completed, it is convenient to establish a communication link between the target Android upper layer, the target user layer and the target kernel, thereby enabling rapid transmission of kernel data.

[0042] S103, The target Android upper layer establishes a communication connection with the target user layer based on the corresponding TCP loopback address and target port number.

[0043] In this embodiment, after the smart terminal obtains the target Android upper layer, target user layer, and target kernel of the launched application, it can also obtain the TCP loopback address for establishing a TCP loopback connection between the target Android upper layer and the target user layer. Then, the target Android upper layer establishes a communication connection with the target user layer based on this TCP loopback address, thereby completing the establishment of the communication link between the target Android upper layer, the target user layer, and the target kernel, ensuring that kernel data can be transmitted from the target kernel to the target Android upper layer.

[0044] In one embodiment, step S103 includes:

[0045] The target user layer creates a Socket server;

[0046] The target Android upper layer creates a Socket client and obtains the port number corresponding to the Socket client;

[0047] The Socket server establishes a communication connection with the Socket client based on the port number corresponding to the Socket client and the TCP loopback address.

[0048] In this embodiment, when establishing a communication connection between the target Android upper layer and the target user layer based on the TCP loopback address, a Socket server is first created in the target user layer. The Socket server needs to obtain the port number and TCP loopback address of the target Android upper layer to establish a connection. Afterwards, a Socket client needs to be created in the target Android upper layer to complete the Android client registration for the smart terminal. The specific creation of the Socket server and Socket client is as follows:

[0049] fd = socket(AF_INET,SOCK_STREAM,0);

[0050] struct sockaddr_in client;

[0051] client.sin_family = AF_INET;

[0052] client.sin_port = htons(2735);

[0053] client.sin_addr.s_addr = inet_addr("127.0.0.1");

[0054] connect(fd,(struct sockaddr *)&client,sizeof(client))

[0055] Given client.sin_addr.s_addr (i.e., the TCP loopback address) and client.sin_port (i.e., the port number corresponding to the Socket client), a communication connection between the Socket server and the Socket client can be established based on the connect instruction (i.e., the connection instruction). This will ultimately establish a communication link between the target Android upper layer, the target user layer, and the target kernel, ensuring that kernel data can be transmitted from the target kernel to the target Android upper layer.

[0056] S104. The target user layer obtains the target data reading parameters corresponding to the kernel data acquisition instruction and sends them to the target kernel.

[0057] In this embodiment, after establishing the communication link between the target Android upper layer, the target user layer, and the target kernel of the application, the corresponding target data reading parameters can be obtained based on the kernel data acquisition instruction. These parameters include specific parameters such as the reading method (e.g., resampling), the amount of data read each time, and the reading cycle. Once the target user layer knows the target data reading parameters, it can obtain kernel data from the target kernel accordingly.

[0058] In one embodiment, step S104 includes:

[0059] The target user layer obtains data reading parameters based on the input / output interface, uses the data reading parameters as target data reading parameters corresponding to the kernel data acquisition instruction, and sends the target data reading parameters to the target kernel.

[0060] In this embodiment, the target user layer can obtain the corresponding data reading parameters in the kernel data acquisition instruction based on the input / output interface (i.e., ioctl), and use these data reading parameters as the target data reading parameters to send to the target kernel. The target kernel can read the target data from the storage space based on the target data reading parameters and pre-store it in the target kernel. Then, the target kernel sends the target data to the target user layer as a data stream, and the target user layer, acting as a relay station, continues to send the target data to the target Android upper layer, thereby enabling the target Android upper layer to obtain kernel data. Since there is no need to pre-configure the HAL layer and Frameworks layer corresponding to the application in the smart terminal, but instead configures a fixed TCP loopback address and different port numbers for each application, the entire development and adaptation process is simplified, development efficiency and scalability are improved, and development costs are reduced.

[0061] S105. The target kernel obtains target kernel data based on the target data reading parameters, and sends the target kernel data to the target user layer according to a preset data stream sending strategy.

[0062] In this embodiment, once the target kernel obtains the target data reading parameters, it can read the corresponding target data from the storage space of the smart terminal based on specific parameters such as the parameter reading method, the amount of data read each time, and the parameter reading cycle, and process it into corresponding target kernel data. The target kernel then sends the target kernel data to the target user layer according to the data stream sending strategy. Therefore, the target kernel can obtain the target data according to the target data reading parameters, process it into target kernel data, and then send it to the target user layer; the target kernel performs data preprocessing.

[0063] In one embodiment, the method further includes the following steps before step S105:

[0064] The target kernel creates a singly linked circular list based on the target data reading parameters; wherein, the singly linked circular list is used to store kernel data with a preset data size obtained by the target kernel;

[0065] The target kernel obtains the data storage space address corresponding to the target data reading parameters.

[0066] In this embodiment, due to the limited storage space in the kernel, several singly linked circular lists need to be created in the kernel. The data obtained by the kernel is stored in one of the corresponding singly linked circular lists to control the amount of kernel data transmitted by each user member corresponding to each singly linked circular list. Moreover, after the target kernel and the target user layer maintain a communication link and the target data reading parameters are known, the data storage space address included therein needs to be obtained to retrieve data from the storage space corresponding to the smart terminal (generally in the memory of the smart terminal) and store it in the corresponding single-page singly linked circular list, thus saving the data in linked list form.

[0067] In one embodiment, the data stream sending strategy is used for the target kernel to send target kernel data to the target user layer based on a preset data sending period. Step S105 includes:

[0068] The target kernel acquires target kernel data based on the target data reading parameters, and sends the target kernel data to the target user layer according to a preset data stream sending strategy, including:

[0069] The target kernel obtains target kernel data from the data storage space address based on the target data reading parameters and stores it in the unidirectional circular linked list;

[0070] The target kernel preprocesses the target kernel data stored in the unidirectional circular linked list based on a preset data preprocessing strategy in order to update the target kernel data stored in the unidirectional circular linked list;

[0071] The target kernel sends the target kernel data to the target user layer according to the data stream sending strategy.

[0072] In this embodiment, after the target kernel obtains the target kernel data corresponding to the target data read parameters from the storage area corresponding to the data storage space address, it needs to be stored in the form of a linked list, that is, the target kernel data is first stored in a singly linked circular list. Since the input / output interface (i.e., ioctl) of the target user layer can also set the corresponding data preprocessing strategy (such as data deduplication, data sorting, etc.) in the target kernel and send it to the target kernel, the target kernel data can also be preprocessed in the target kernel based on the data preprocessing strategy to update the target kernel data stored in the singly linked circular list. After the target kernel data preprocessing is completed in the target kernel, the target kernel data can be sent to the target user layer according to the data stream sending strategy. The data transmission period set in the data stream transmission strategy can be configured such that after the preprocessing of the target kernel data is completed, the target kernel data is sent to the target user layer according to the data transmission period (e.g., 1ms, 10ms, 0.1s, 0.5s, etc., but the specific implementation is not limited to the example duration, and the data transmission period can be customized according to the kernel's input and output performance).

[0073] In one embodiment, after the step of the target kernel sending the target kernel data to the target user layer according to the data stream sending strategy, the method further includes:

[0074] The target kernel data stored in the singly linked circular list is deleted to clear the singly linked circular list.

[0075] In this embodiment, after the target kernel data in a singly linked circular list has been sent to the target user layer in the target kernel, the target kernel data stored in the singly linked circular list can be deleted to clear the list. Alternatively, when kernel data is received again in the singly linked circular list, the target kernel data can be directly overwritten to update the data in the list by overwriting the old data. Therefore, regardless of the method used to reuse the singly linked circular list, the target kernel can send kernel data to the target user layer, which acts as a relay station, in the form of a data stream.

[0076] S106, The target user layer sends the target kernel data to the target Android upper layer.

[0077] In this embodiment, when the target user layer obtains the target kernel data, it sends it to the corresponding target Android upper layer, thereby enabling the application's Android upper layer to call kernel data more quickly and conveniently.

[0078] As can be seen, the embodiments of this method do not require pre-configuration of the HAL layer and Frameworks layer corresponding to the application in the smart terminal. Instead, they configure a fixed TCP loopback address and a different port number for each application, thereby simplifying the entire development and adaptation process, improving development efficiency and scalability, and reducing development costs.

[0079] This application also provides a kernel data transmission apparatus based on TCP loopback, which is used to execute any of the aforementioned embodiments of the kernel data transmission method based on TCP loopback. Specifically, please refer to... Figure 3 , Figure 3 This is a schematic block diagram of a kernel data transmission device 100 based on TCP loopback provided in an embodiment of this application.

[0080] like Figure 3 As shown, the kernel data transmission device 100 based on TCP loopback includes a target Android upper layer determination unit 101, a target lower layer acquisition unit 102, a communication establishment unit 103, a parameter reading acquisition unit 104, a kernel data first sending unit 105, and a kernel data second sending unit 106.

[0081] The target Android upper layer determination unit 101 is used to obtain the target Android upper layer corresponding to the kernel data acquisition instruction in response to the kernel data acquisition instruction.

[0082] In this embodiment, when a user operates a smart terminal running the Android system and uses an application installed on it, a kernel data retrieval instruction will be triggered if the application needs to access kernel data. When the smart terminal receives the generated kernel data retrieval instruction, it can first obtain the target Android upper layer corresponding to the kernel data retrieval instruction to determine the specific target application that triggered the kernel data retrieval instruction and its corresponding target Android upper layer.

[0083] The target Android upper layer can be understood as the user interface of the target application. When the user clicks on the interface elements of the user interface (such as virtual buttons, or more specifically, audio data playback buttons), a kernel data acquisition instruction is generated. At this time, the smart terminal can obtain the target application that triggered the kernel data acquisition instruction and its corresponding target Android upper layer.

[0084] In one embodiment, the TCP loopback-based kernel data transmission device 100 further includes:

[0085] A mapping relationship setting unit is used to pre-set the mapping relationship between the Android upper layer and the kernel; wherein, the mapping relationship includes multiple kernels and several Android upper layers corresponding to each kernel;

[0086] The TCP loopback address setting unit is used to pre-set the TCP loopback address and port number corresponding to each Android upper layer included in the mapping relationship; wherein, the TCP loopback address corresponding to the Android upper layer is used to establish a communication connection between the Android upper layer and the corresponding user layer based on the TCP communication protocol.

[0087] In this embodiment, if multiple applications are installed on a smart terminal, the application developers need to know the terminal model of the smart terminal in advance, as well as the specific kernel information of the smart terminal model (such as the total number of kernels and the application types that each kernel corresponds to). Then, the developers can pre-configure the mapping relationship between the Android upper layers and the kernels for their developed applications, so that the application can call the corresponding kernel when running on the smart terminal. Each kernel corresponds to several Android upper layers (i.e., each kernel corresponds to at least one Android upper layer). For example, the mapping relationship configures eight kernels, labeled kernel 1 to kernel 8. Kernel 1 is mapped to applications 1 to 4, kernel 2 to applications 5 to 8, kernel 3 to applications 9 to 12, kernel 4 to applications 13 to 16, kernel 5 to applications 17 to 20, kernel 6 to applications 21 to 24, kernel 7 to applications 25 to 28, and kernel 8 to applications 29 to 32.

[0088] Simultaneously, the smart terminal needs to pre-configure the TCP loopback address and port number (TCP stands for Transmission Control Protocol) corresponding to each Android upper layer included in the mapping relationship. This ensures that when each application starts, its Android upper layer can establish a communication connection with the corresponding user layer based on the corresponding TCP loopback address and the TCP communication protocol. Furthermore, this user layer is the user layer communicating with the target kernel corresponding to the application's Android upper layer. Referring to the example above, the Android upper layers corresponding to applications 1-32 each have pre-configured TCP loopback addresses (such as 127.0.0.1, 127.0.0.2, etc.). After completing these pre-configurations, it can be ensured that when an application starts subsequently, its Android upper layer can establish a communication connection with the corresponding target user layer based on the preset TCP loopback address, and obtain kernel data using the target user layer as an intermediate carrier. The connection between the Android upper layer and the target user layer of different applications is based on a fixed TCP loopback address and a unique port number; that is, the connection relationship between the application's Android upper layer and the user layer is distinguished by the port number.

[0089] The target underlying acquisition unit 102 is used to acquire the target kernel corresponding to the target Android upper layer and the target user layer corresponding to the target kernel.

[0090] In this embodiment, after the smart terminal obtains the target Android upper layer of the launched application, it can also determine the target kernel corresponding to the target Android upper layer based on the preset mapping relationship between the Android upper layer and the kernel, and it can also determine the target user layer corresponding to the target kernel. After the above determination of the target kernel and target user layer is completed, it is convenient to establish a communication link between the target Android upper layer, the target user layer and the target kernel, thereby enabling rapid transmission of kernel data.

[0091] The communication establishment unit 103 is used to establish a communication connection between the target Android upper layer and the target user layer based on the corresponding TCP loopback address and target port number.

[0092] In this embodiment, after the smart terminal obtains the target Android upper layer, target user layer, and target kernel of the launched application, it can also obtain the TCP loopback address for establishing a TCP loopback connection between the target Android upper layer and the target user layer. Then, the target Android upper layer establishes a communication connection with the target user layer based on this TCP loopback address, thereby completing the establishment of the communication link between the target Android upper layer, the target user layer, and the target kernel, ensuring that kernel data can be transmitted from the target kernel to the target Android upper layer.

[0093] In one embodiment, the communication establishment unit 103 is used for:

[0094] The target user layer creates a Socket server;

[0095] The target Android upper layer creates a Socket client and obtains the port number corresponding to the Socket client;

[0096] The Socket server establishes a communication connection with the Socket client based on the port number corresponding to the Socket client and the TCP loopback address.

[0097] In this embodiment, when establishing a communication connection between the target Android upper layer and the target user layer based on the TCP loopback address, a Socket server is first created in the target user layer. The Socket server needs to obtain the port number and TCP loopback address of the target Android upper layer to establish a connection. Afterwards, a Socket client needs to be created in the target Android upper layer to complete the Android client registration for the smart terminal. The specific creation of the Socket server and Socket client is as follows:

[0098] fd = socket(AF_INET,SOCK_STREAM,0);

[0099] struct sockaddr_in client;

[0100] client.sin_family = AF_INET;

[0101] client.sin_port = htons(2735);

[0102] client.sin_addr.s_addr = inet_addr("127.0.0.1");

[0103] connect(fd,(struct sockaddr *)&client,sizeof(client))

[0104] Given client.sin_addr.s_addr (i.e., the TCP loopback address) and client.sin_port (i.e., the port number corresponding to the Socket client), a communication connection between the Socket server and the Socket client can be established based on the connect instruction (i.e., the connection instruction). This will ultimately establish a communication link between the target Android upper layer, the target user layer, and the target kernel, ensuring that kernel data can be transmitted from the target kernel to the target Android upper layer.

[0105] The parameter acquisition unit 104 is used to acquire the target data reading parameters corresponding to the kernel data acquisition instruction in the target user layer and send them to the target kernel.

[0106] In this embodiment, after establishing the communication link between the target Android upper layer, the target user layer, and the target kernel of the application, the corresponding target data reading parameters can be obtained based on the kernel data acquisition instruction. These parameters include specific parameters such as the reading method (e.g., resampling), the amount of data read each time, and the reading cycle. Once the target user layer knows the target data reading parameters, it can obtain kernel data from the target kernel accordingly.

[0107] In one embodiment, the parameter acquisition unit 104 is used for:

[0108] The target user layer obtains data reading parameters based on the input / output interface, uses the data reading parameters as target data reading parameters corresponding to the kernel data acquisition instruction, and sends the target data reading parameters to the target kernel.

[0109] In this embodiment, the target user layer can obtain the corresponding data reading parameters in the kernel data acquisition instruction based on the input / output interface (i.e., ioctl), and use these data reading parameters as the target data reading parameters to send to the target kernel. The target kernel can read the target data from the storage space based on the target data reading parameters and pre-store it in the target kernel. Then, the target kernel sends the target data to the target user layer as a data stream, and the target user layer, acting as a relay station, continues to send the target data to the target Android upper layer, thereby enabling the target Android upper layer to obtain kernel data. Since there is no need to pre-configure the HAL layer and Frameworks layer corresponding to the application in the smart terminal, but instead configures a fixed TCP loopback address and different port numbers for each application, the entire development and adaptation process is simplified, development efficiency and scalability are improved, and development costs are reduced.

[0110] The kernel data first sending unit 105 is used for the target kernel to obtain target kernel data based on the target data reading parameters, and to send the target kernel data to the target user layer according to a preset data stream sending strategy.

[0111] In this embodiment, once the target kernel obtains the target data reading parameters, it can read the corresponding target data from the storage space of the smart terminal based on specific parameters such as the parameter reading method, the amount of data read each time, and the parameter reading cycle, and process it into corresponding target kernel data. The target kernel then sends the target kernel data to the target user layer according to the data stream sending strategy. Therefore, the target kernel can obtain the target data according to the target data reading parameters, process it into target kernel data, and then send it to the target user layer; the target kernel performs data preprocessing.

[0112] In one embodiment, the TCP loopback-based kernel data transmission device 100 further includes:

[0113] A singly linked circular list creation unit is used to create a singly linked circular list based on the target data reading parameters of the target kernel; wherein, the singly linked circular list is used to store kernel data with a preset data size obtained by the target kernel;

[0114] A storage space acquisition unit is used for the target kernel to acquire the data storage space address corresponding to the target data reading parameters.

[0115] In this embodiment, due to the limited storage space in the kernel, several singly linked circular lists need to be created in the kernel. The data obtained by the kernel is stored in one of the corresponding singly linked circular lists to control the amount of kernel data transmitted by each user member corresponding to each singly linked circular list. Moreover, after the target kernel and the target user layer maintain a communication link and the target data reading parameters are known, the data storage space address included therein needs to be obtained to retrieve data from the storage space corresponding to the smart terminal (generally in the memory of the smart terminal) and store it in the corresponding single-page singly linked circular list, thus saving the data in linked list form.

[0116] In one embodiment, the data stream sending strategy is used for the target kernel to send target kernel data to the target user layer based on a preset data sending period, and the kernel data first sending unit 105 is used for:

[0117] The target kernel acquires target kernel data based on the target data reading parameters, and sends the target kernel data to the target user layer according to a preset data stream sending strategy, including:

[0118] The target kernel obtains target kernel data from the data storage space address based on the target data reading parameters and stores it in the unidirectional circular linked list;

[0119] The target kernel preprocesses the target kernel data stored in the unidirectional circular linked list based on a preset data preprocessing strategy in order to update the target kernel data stored in the unidirectional circular linked list;

[0120] The target kernel sends the target kernel data to the target user layer according to the data stream sending strategy.

[0121] In this embodiment, after the target kernel obtains the target kernel data corresponding to the target data read parameters from the storage area corresponding to the data storage space address, it needs to be stored in the form of a linked list, that is, the target kernel data is first stored in a singly linked circular list. Since the input / output interface (i.e., ioctl) of the target user layer can also set the corresponding data preprocessing strategy (such as data deduplication, data sorting, etc.) in the target kernel and send it to the target kernel, the target kernel data can also be preprocessed in the target kernel based on the data preprocessing strategy to update the target kernel data stored in the singly linked circular list. After the target kernel data preprocessing is completed in the target kernel, the target kernel data can be sent to the target user layer according to the data stream sending strategy. The data transmission period set in the data stream transmission strategy can be configured such that after the preprocessing of the target kernel data is completed, the target kernel data is sent to the target user layer according to the data transmission period (e.g., 1ms, 10ms, 0.1s, 0.5s, etc., but the specific implementation is not limited to the example duration, and the data transmission period can be customized according to the kernel's input and output performance).

[0122] In one embodiment, the TCP loopback-based kernel data transmission device 100 further includes:

[0123] The linked list clearing unit is used to delete the target kernel data stored in the singly linked circular list to clear the singly linked circular list.

[0124] In this embodiment, after the target kernel data in a singly linked circular list has been sent to the target user layer in the target kernel, the target kernel data stored in the singly linked circular list can be deleted to clear the list. Alternatively, when kernel data is received again in the singly linked circular list, the target kernel data can be directly overwritten to update the data in the list by overwriting the old data. Therefore, regardless of the method used to reuse the singly linked circular list, the target kernel can send kernel data to the target user layer, which acts as a relay station, in the form of a data stream.

[0125] The kernel data second sending unit 106 is used for the target user layer to send the target kernel data to the target Android upper layer.

[0126] In this embodiment, when the target user layer obtains the target kernel data, it sends it to the corresponding target Android upper layer, thereby enabling the application's Android upper layer to call the kernel data more quickly and conveniently.

[0127] As can be seen, the embodiments of this device do not require pre-configuration of the HAL layer and Frameworks layer corresponding to the application in the smart terminal. Instead, they configure a fixed TCP loopback address and a different port number for each application, thereby simplifying the entire development and adaptation process, improving development efficiency and scalability, and reducing development costs.

[0128] The aforementioned kernel data transmission device based on TCP loopback can be implemented as a computer program, which can be used in, for example... Figure 4 It runs on the computer device shown.

[0129] Please see Figure 4 , Figure 4 This is a schematic block diagram of a computer device provided in an embodiment of this application. The computer device 500 is a smart terminal, such as a smartphone, tablet computer, or other smart device.

[0130] See Figure 4 The computer device 500 includes a processor 502, a memory, and a network interface 505 connected via a device bus 501, wherein the memory may include a storage medium 503 and internal memory 504.

[0131] The storage medium 503 can store the operating system 5031 and the computer program 5032. When the computer program 5032 is executed, it enables the processor 502 to execute a kernel data transfer method based on TCP loopback.

[0132] The processor 502 provides computing and control capabilities to support the operation of the entire computer device 500.

[0133] The internal memory 504 provides an environment for the computer program 5032 in the storage medium 503 to run. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a kernel data transmission method based on TCP loopback.

[0134] This network interface 505 is used for network communication, such as providing data transmission. Those skilled in the art will understand that... Figure 4The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device 500 to which the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0135] The processor 502 is used to run a computer program 5032 stored in the memory to implement the kernel data transmission method based on TCP loopback disclosed in the embodiments of this application.

[0136] Those skilled in the art will understand that Figure 4 The embodiments of the computer device shown do not constitute a limitation on the specific configuration of the computer device. In other embodiments, the computer device may include more or fewer components than illustrated, or combine certain components, or have different component arrangements. For example, in some embodiments, the computer device may include only memory and a processor. In such embodiments, the structure and function of the memory and processor are different from those shown. Figure 4 The embodiments shown are consistent and will not be described again here.

[0137] It should be understood that in the embodiments of this application, the processor 502 may be a central processing unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.

[0138] In another embodiment of this application, a computer-readable storage medium is provided. This computer-readable storage medium may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. The computer-readable storage medium stores a computer program, wherein when executed by a processor, the computer program implements the TCP loopback-based kernel data transmission method disclosed in the embodiments of this application.

[0139] Those skilled in the art will readily understand that, for the sake of convenience and brevity, the specific working processes of the devices, apparatuses, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0140] In the several embodiments provided in this application, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Units with the same function may be grouped into one unit. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or units, or it may be an electrical, mechanical, or other form of connection.

[0141] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of the embodiments of this application, depending on actual needs.

[0142] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0143] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a backend server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), magnetic disks, or optical disks.

[0144] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A kernel data transmission method based on TCP loopback, characterized in that, include: In response to a kernel data acquisition command, the target Android upper layer corresponding to the kernel data acquisition command is acquired; The target Android upper layer is the user interface of the target application, and a kernel data acquisition instruction is generated when the interface elements of the user interface are clicked. Obtain the target kernel corresponding to the target Android upper layer and the target user layer corresponding to the target kernel; wherein, the target kernel corresponding to the target Android upper layer and the target user layer corresponding to the target kernel are determined based on a preset mapping relationship between Android upper layers and kernels; the mapping relationship includes multiple kernels and several Android upper layers corresponding to each kernel; the TCP loopback address and port number corresponding to each Android upper layer included in the mapping relationship are preset, and the TCP loopback address corresponding to the Android upper layer is used to establish a communication connection between the Android upper layer and the corresponding user layer based on the TCP communication protocol; The target Android upper layer establishes a communication connection with the target user layer based on the corresponding TCP loopback address and target port number; The target user layer obtains the target data read parameters corresponding to the kernel data acquisition instruction and sends them to the target kernel; The target kernel obtains target kernel data based on the target data reading parameters, and sends the target kernel data to the target user layer according to a preset data stream sending strategy; The target user layer sends the target kernel data to the target Android upper layer.

2. The method according to claim 1, characterized in that, Before the step of retrieving the target Android upper layer corresponding to the kernel data retrieval instruction in response to the kernel data retrieval instruction, the method further includes: The mapping relationship between the Android upper layer and the kernel is pre-configured.

3. The method according to claim 1, characterized in that, The target Android upper layer establishes a communication connection with the target user layer based on the corresponding TCP loopback address and target port number, including: The target user layer creates a Socket server; The target Android upper layer creates a Socket client and obtains the port number corresponding to the Socket client; The Socket server establishes a communication connection with the Socket client based on the port number corresponding to the Socket client and the TCP loopback address.

4. The method according to claim 1, characterized in that, The target user layer acquires the target data read parameters corresponding to the kernel data acquisition instruction and sends them to the target kernel, including: The target user layer obtains data reading parameters based on the input / output interface, uses the data reading parameters as target data reading parameters corresponding to the kernel data acquisition instruction, and sends the target data reading parameters to the target kernel.

5. The method according to claim 1, characterized in that, Before the step of the target kernel acquiring target kernel data based on the target data reading parameters and sending the target kernel data to the target user layer according to a preset data stream sending strategy, the method further includes: The target kernel creates a singly linked circular list based on the target data reading parameters; wherein, the singly linked circular list is used to store kernel data with a preset data size obtained by the target kernel; The target kernel obtains the data storage space address corresponding to the target data reading parameters.

6. The method according to claim 5, characterized in that, The data stream sending strategy is used by the target kernel to send target kernel data to the target user layer based on a preset data sending period; The target kernel acquires target kernel data based on the target data reading parameters, and sends the target kernel data to the target user layer according to a preset data stream sending strategy, including: The target kernel obtains target kernel data from the data storage space address based on the target data reading parameters and stores it in the unidirectional circular linked list; The target kernel preprocesses the target kernel data stored in the unidirectional circular linked list based on a preset data preprocessing strategy in order to update the target kernel data stored in the unidirectional circular linked list; The target kernel sends the target kernel data to the target user layer according to the data stream sending strategy.

7. The method according to claim 6, characterized in that, After the step of sending the target kernel data to the target user layer according to the data stream sending strategy, the method further includes: The target kernel data stored in the singly linked circular list is deleted to clear the singly linked circular list.

8. A kernel data transmission device based on TCP loopback, characterized in that, include: The target Android upper layer determination unit is used to obtain the target Android upper layer corresponding to the kernel data acquisition instruction in response to the kernel data acquisition instruction. The target Android upper layer is the user interface of the target application, and a kernel data acquisition instruction is generated when the interface elements of the user interface are clicked. The target lower-level acquisition unit is used to acquire the target kernel corresponding to the target Android upper layer and the target user layer corresponding to the target kernel. The target kernel corresponding to the target Android upper layer and the target user layer corresponding to the target kernel are determined based on a preset mapping relationship between Android upper layers and kernels. The mapping relationship includes multiple kernels and several Android upper layers corresponding to each kernel. A TCP loopback address and port number corresponding to each Android upper layer included in the mapping relationship are preset. The TCP loopback address corresponding to the Android upper layer is used to establish a communication connection between the Android upper layer and the corresponding user layer based on the TCP communication protocol. A communication establishment unit is used to establish a communication connection between the target Android upper layer and the target user layer based on the corresponding TCP loopback address and target port number. A parameter acquisition unit is used to acquire target data reading parameters corresponding to the kernel data acquisition instruction in the target user layer and send them to the target kernel; The kernel data first sending unit is used to obtain target kernel data based on the target data reading parameters, and send the target kernel data to the target user layer according to a preset data stream sending strategy. The kernel data second sending unit is used for the target user layer to send the target kernel data to the target Android upper layer.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the kernel data transmission method based on TCP loopback as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, causes the processor to perform the kernel data transmission method based on TCP loopback as described in any one of claims 1-7.