A method and device for network access by application in intelligent terminal device
Through system services and network drivers, the routing rule table is configured in the intelligent terminal device according to the network connection mode setting type of the application, which solves the problem of being unable to automatically specify the network connection mode in the existing technology and realizes the function of safe access of the application under the designated network. , avoiding the risk of data leakage.
Patent Information
- Application Number
- CN202411112922.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-08-14
AI Technical Summary
Existing smart terminal devices cannot specify a specific application to use a specific network connection method during the network connection process, resulting in unsafe network access, and merchants need to manually switch the connection method, making it impossible to automatically achieve secure network access.
Use system services and network drivers to set the type according to the application's network connection method, determine and configure the routing rule table, and ensure that the application is accessed under the specified network connection method, including obtaining application configuration information and saving network connection configuration information to custom routing settings. table and apply it to the routing rule table through configuration directives.
It enables secure access of applications under designated network connection methods, avoids the risk of data leakage caused by network security issues, and ensures safe operation and processing of applications.
Smart Images

Figure CN118646605B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent terminal security, and in particular to a method and device for performing network access by an application in an intelligent terminal device. Background Art
[0002] Smart terminals are a type of embedded computer system equipment. With the rapid development of information technology, smart terminal products have also emerged in the payment field, such as smart POS machines and other devices. Smart POS machines are a type of smart terminal equipment that integrates payment, settlement, identification, printing and other functions. Smart POS machines provide more efficient and convenient services by integrating various advanced technologies and software, bringing a new experience to merchants and consumers.
[0003] At present, with the popularization of network connection methods, existing smart terminals can also provide a variety of network connection methods to meet the diverse needs of merchants. Merchants can freely choose network connection methods and data paths, such as Ethernet, mobile data, Wi-Fi, etc. However, in the existing mobile terminal network connection process, network connection has priority, and it is impossible to specify a specific application to use a specific network connection method, resulting in insecurity issues in the process of specific applications accessing background services. If merchants need to use a specific network connection method for a specific application to access the background service, merchants often need to manually switch the connection. Therefore, how to solve the problem of smart terminal device applications accessing the network according to the specified network connection method has become a technical problem that needs to be solved urgently. Summary of the invention
[0004] In order to solve the above technical problems, the present invention provides a method and device for an application in a smart terminal device to access a network. The technical solution is as follows:
[0005] According to a first aspect of the present invention, the present invention provides a method for an application in an intelligent terminal device to access a network, the method comprising:
[0006] Step S1, the system service determines the application network connection mode setting type according to the called interface type, and if the application network connection mode setting type is the first type, execute step S2;
[0007] Step S2, the system service obtains the application configuration information passed in through the called first preset interface, and determines whether there is user authority information according to the application configuration information, and if yes, executes step S3, otherwise ends;
[0008] Step S3, the system service obtains a custom routing setting table, saves the network connection configuration information in the application configuration information into the custom routing setting table, and transmits the network connection configuration information to the network driver, wherein the network connection configuration information includes IP information and a network connection mode corresponding to the IP information;
[0009] Step S4, the network driver configures the network connection configuration information into the routing rule table through the configuration instruction, and ends;
[0010] The method further comprises:
[0011] Step F1: When the system service receives a network connection request initiated by an application in the intelligent terminal device, the system service sends the network connection request to the network driver;
[0012] Step F2, the network driver obtains the IP information in the network connection request, and determines whether there is network connection configuration information identical to the IP information in the routing rule table, if yes, execute step F3, otherwise execute step F4;
[0013] Step F3, the network driver determines the network connection mode corresponding to the IP information through the routing rule table, sends a network request data packet to the IP information according to the network connection mode, and executes step F5;
[0014] Step F4, the network driver sends a network request data packet to the IP information according to the default network connection mode, and executes step F5;
[0015] Step F5, the network driver receives the network response data packet and returns the network response data packet to the system service;
[0016] Step F6: The system service returns the network response data packet to the application.
[0017] According to a second aspect of the present invention, an embodiment of the present invention provides a device for setting application access network in an intelligent terminal device, characterized in that the device includes a system service and a network driver, and the system service includes:
[0018] A first determination module, configured to determine the application network connection mode setting type according to the called interface type, and trigger a first acquisition judgment module if the application network connection mode setting type is the first type;
[0019] The first acquisition and judgment module is used to obtain application configuration information passed in through the called interface, and judge whether there is user permission information according to the application configuration information;
[0020] an acquisition and saving module, configured to acquire a custom routing setting table when the first acquisition and judgment module determines that user authority information exists, save the network connection configuration information in the application configuration information into the custom routing setting table, and transfer the network connection configuration information to the network driver;
[0021] The network driver includes:
[0022] A configuration module, used to configure the network connection configuration information into a routing rule table through configuration instructions;
[0023] The system services also include:
[0024] A receiving module, used to receive a network connection request initiated by an application in the smart terminal device, and also used to receive a network response data packet;
[0025] A sending module, used to send the network connection request received by the receiving module to the network driver, and also used to return the network response data packet to the application;
[0026] The network driver also includes:
[0027] A first determination module, used to receive and obtain IP information in the network connection request;
[0028] A second judgment module is used to judge whether there is network connection configuration information identical to the IP information in the routing rule table, and if so, trigger the first processing module, otherwise, trigger the second processing module;
[0029] The first processing module is used to determine the network connection mode corresponding to the IP information through the routing rule table, send a network request data packet to the IP information according to the network connection mode, and receive a network response data packet and return the network response data packet to the system service;
[0030] The second processing module is used to send a network request data packet to the IP information according to a default network connection mode, and is also used to receive a network response data packet and return the network response data packet to the system service.
[0031] According to a third aspect of the present invention, an embodiment of the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement a method for network access by an application in a smart terminal device as described in the first aspect above.
[0032] According to a fourth aspect of the present invention, an embodiment of the present invention provides a computer-readable storage medium having a computer program / instruction stored thereon, which, when executed by a processor, implements a method for an application in an intelligent terminal device to access a network as described in the first aspect above.
[0033] According to a fifth aspect of the present invention, an embodiment of the present invention provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements a method for network access by an application in a smart terminal device as described in the first aspect above.
[0034] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:
[0035] The present invention provides a method and apparatus for network access by applications in intelligent terminal devices. The scheme sets the network connection mode specified by the application according to the determined application network connection mode setting type through system services and network drivers, thereby solving the network access security problem caused by the inability to set the network connection mode due to the lack of permission of the application in the prior art, and realizing the function that the application can perform secure access and secure operation processing under the specified network connection mode, thereby avoiding the risks of data leakage and the like caused by network security problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0037] Figure 1 It is a flowchart of network settings in a method for performing network access by an application in an intelligent terminal device provided in the first embodiment of the present invention;
[0038] Figure 2 This is a flowchart of a method for an application in a smart terminal device to access a network provided in a first embodiment of the present invention;
[0039] Figure 3 A schematic diagram of a flow chart of application installation package generation in a method for performing network access by an application in an intelligent terminal device provided in a second embodiment of the present invention;
[0040] Figure 4 A flowchart of a method for an application in a smart terminal device to access a network when the application is first installed, provided in a second embodiment of the present invention;
[0041] Figure 5A flowchart of a method for performing network access by an application in a smart terminal device implemented during application upgrade installation provided by a second embodiment of the present invention;
[0042] Figure 6 A flowchart of a method for an application in a smart terminal device to access a network when a third-party application calls the method provided in Embodiment 3 of the present invention;
[0043] Figure 7 A fourth embodiment of the present invention provides a flowchart of a method for an application in a smart terminal device to access a network. DETAILED DESCRIPTION
[0044] In order to make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
[0045] When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are only examples of devices and methods consistent with some aspects of the present invention as detailed in the attached claims.
[0046] To make the purpose, technical solution and advantages of the present invention more clear, a method for an application in a smart terminal device to access a network provided by an embodiment of the present invention will be described in detail below with reference to the accompanying drawings.
[0047] Embodiment 1
[0048] Embodiment 1 of the present invention provides a method for an application in an intelligent terminal device to access a network, such as Figure 1 and Figure 2 As shown, the intelligent terminal device includes a system service and a network driver, and the method includes:
[0049] Step 101, the system service determines the application network connection mode setting type according to the called interface type, and if the application network connection mode setting type is the first type, step 102 is executed;
[0050] Step 102: The system service obtains the application configuration information passed in through the called interface, and determines whether there is user authority information according to the application configuration information. If yes, execute step 103; otherwise, terminate;
[0051] Step 103: The system service obtains a custom routing setting table, saves the network connection configuration information in the application configuration information into the custom routing setting table, and transmits the network connection configuration information to the network driver;
[0052] Step 104: The network driver configures the network connection configuration information into the routing rule table through the configuration instruction, and ends;
[0053] The method further includes:
[0054] Step 201: When the system service receives a network connection request initiated by an application in the intelligent terminal device, the system service sends the network connection request to the network driver;
[0055] Step 202: The network driver obtains the IP information in the network connection request, and determines whether there is network connection configuration information matching the IP information in the routing rule table. If yes, execute step 203; otherwise, execute step 204.
[0056] Step 203: The network driver determines the network connection mode corresponding to the IP information through the routing rule table, and sends the network request data packet to the server corresponding to the IP information according to the determined network connection mode, and executes step 205;
[0057] Step 204: The network driver sends a network request data packet to the server corresponding to the IP information according to the default network connection mode, and then executes step 205;
[0058] Step 205: The network driver receives the network response data packet and returns the network response data packet to the system service;
[0059] Step 206: The system service returns a network response data packet to the application.
[0060] In an practicable manner, the method further includes, when the system service determines that the application network connection mode setting type is the second type according to the called interface type, executing the following steps:
[0061] Step 105: The system service obtains the application configuration information transmitted through the called second preset interface, and determines whether there is user authority information according to the application configuration information. If yes, execute step 106, otherwise, terminate;
[0062] Step 106, the system service obtains the custom routing setting table, determines whether there is network connection configuration information in the custom routing setting table, if yes, transfers the network connection configuration information to the network driver, deletes the network connection configuration information in the custom routing setting table, and executes step 107, otherwise, the process ends;
[0063] Step 107: The network driver deletes the network connection configuration information from the routing rule table through a deletion instruction, and the process ends.
[0064] In one implementable method, a system service determines the application network connection mode setting type according to the type of interface being called: when the first preset interface of the system service is called, the system service determines the application network connection mode setting type as the first type; when the second preset interface of the system service is called, the system service determines the application network connection mode setting type as the second type.
[0065] In one practicable manner, the system service includes a package management service, and before step 101, the following is further included:
[0066] Step 1101: The package management service obtains the APK file of the application to be installed;
[0067] Step 1102: The package management service calls an API interface to parse the manifest file in the APK file of the application to be installed, and obtains configuration startup item information;
[0068] Step 1103: The package management service determines the network connection configuration type according to the configuration startup item information, and calls the system service interface according to the network connection configuration type.
[0069] Specifically, in one implementable method, in step 1103, the interface for calling the system service is as follows: the package management service obtains the user permission information and network connection configuration information in the manifest file, organizes the network connection configuration information and the user permission information to obtain the application configuration information, and calls the preset interface of the system service to pass in the application configuration information as a parameter.
[0070] Specifically, in an implementable manner, the method further includes generating an APK file of the application to be installed; generating the APK file of the application to be installed specifically comprises:
[0071] Step D1, determining the network connection configuration type;
[0072] Step D2: Write the configuration startup item information, network connection configuration information and user permission information corresponding to the network connection configuration type into the manifest file according to a predetermined format to obtain the APK file to be installed for the application.
[0073] Specifically, in one practicable manner, in step 103, before the network connection configuration information in the application configuration information is saved in the custom routing setting table, the following steps are further included:
[0074] Step M21, the system service determines whether there is network connection configuration information in the custom routing setting table, if yes, executes step M22, otherwise saves the network connection configuration information in the application configuration information into the custom IP information list;
[0075] Step M22, the system service obtains the network connection configuration information in the application configuration information, and determines whether the network connection configuration information in the custom routing setting table is the same as the network connection configuration information in the application configuration information. If so, the process ends; otherwise, the process proceeds to step M23;
[0076] Step M23, the system service transfers the network connection configuration information in the custom routing setting table to the network driver, deletes the network connection configuration information in the custom routing setting table from the custom routing setting table, saves the network connection configuration information in the application configuration information to the custom routing setting table, and executes step M24;
[0077] Step M24: The network driver deletes the network connection configuration information in the custom routing setting table from the routing rule table through a deletion instruction.
[0078] In one practicable manner, the intelligent terminal device includes a POS management service;
[0079] The process before step 101 also includes: the POS management service determines the interface type for calling the system service according to the interface type called by the third-party application, and calls the interface of the system service according to the determined interface type.
[0080] Specifically, an implementable method is to call the interface of the system service according to the determined interface type: the POS management service obtains the application package name, organizes the network connection configuration information and the application package name to obtain the application configuration information, and calls the preset interface of the system service to pass in the application configuration information as a parameter.
[0081] Furthermore, an implementable method for determining whether user permission information exists based on application configuration information is as follows: the system service determines whether user permission information exists for a third-party application corresponding to the application package name based on the application package name in the application configuration information.
[0082] In an practicable manner, when it is determined that there is user authority information according to the application configuration information, the system service obtains the verification data in the application configuration information to perform code verification, and if the verification is passed, the network configuration authority is obtained, and step 103 is executed; if the verification fails, the process ends;
[0083] Specifically, the signature verification data includes specified parameters, verification key and signature data.
[0084] In an practicable manner, the method further includes: when the intelligent terminal device is turned off, the network driver deletes all network connection configuration information in the routing rule table through a deletion instruction.
[0085] In an practicable manner, the method further includes: when the smart terminal device is powered on and restarted, the system service obtains the saved custom routing setting table, traverses the custom routing setting table, sequentially obtains the network connection configuration information in the custom routing setting table and transmits the network connection configuration information to the network driver, and executes step 104.
[0086] In one practicable manner, in step 102, when it is determined that there is user permission information according to the application configuration information, the method further includes: the system service sets permission group information corresponding to the application according to the user permission information in the application configuration information;
[0087] Before the network driver obtains the IP information in the network request, the process also includes: the network driver determines whether the application initiating the network connection request has permission information, and if so, executes step 202, otherwise, executes step 204.
[0088] The present invention provides a method and apparatus for network access by applications in an intelligent terminal device. The system service determines the application network connection mode setting type according to the type of interface being called, and verifies the application's authority according to the parameters passed by the application. If the verification is passed, the network connection mode setting authority is obtained, and the network connection mode specified by the application is set according to the determined application network connection mode setting type through a network driver. The network access security problem caused by the inability to set the connection mode due to the lack of authority of the application in the prior art is solved, and the function of the application being able to securely access and securely operate under the specified network type is realized, thereby avoiding the risk of data leakage caused by network security issues.
[0089] Embodiment 2
[0090] Embodiment 2 of the present invention provides a method for an application in a smart terminal device to access a network, wherein the present embodiment is that a third-party application sets up a network by installing an application installation package, such as Figure 3 As shown, the method flow of generating an APK file to be installed in the method of network access by an application specifically includes:
[0091] Step 301: Determine the network connection configuration type;
[0092] In this embodiment, the network connection configuration types include configuration and cancellation;
[0093] Specifically, the network connection configuration type is defined as a preset value of the configuration startup item information, the first preset value is true, indicating that the network connection configuration type is configuration, and the second preset value is false, indicating that the network connection configuration type is cancellation of configuration;
[0094] For example, the value corresponding to the configuration startup item coexist is true / false, the value corresponding to the IP information is 192.168.8.102; the user permission information is defined as android.permission.CONTROL_FIREWALL_RULED.
[0095] Step 302: Write the configuration startup item information, network connection configuration information and user permission information corresponding to the network connection configuration type into the manifest file according to a predetermined format to obtain an APK file of the application to be installed.
[0096] Specifically, APK (Android application package) refers to the Android application package, which is a file format in the Android system. The APK file contains all the files of the application, including static resource files (assets), library files (lib), signature files (META-INF), compiled resource files (res), manifest files (AndroidManifest.xml), core code files (classes. Dex) and resource mapping files (resources.arsc) and other information. For example, the manifest file is:
[0097] <manifest xmlns:android="http: / / schemas.android.com / apk / res / android"
[0098] xmlns:tools="http: / / schemas.android.com / tools"
[0099] package="com.ft.myapplication">
[0100] <users-permission android:name="android.permission.INTERNET" / >
[0101] <uses-permission android:name=" CONTROL_IP_ROUTE" / >
[0102] <meta-data android: name="coexist" value="true" / >
[0103] <meta-data android: name="mobile" value="192.168.9.11" / >
[0104] <meta-data android: name="Wi-Fi" value="https: / / rc-odhenpos.teknisa.cloud" / > .
[0105] <meta-data android: name="ethernet" value="https: / / www.ftsafe.com.cn" / >
[0106] Specifically, the manifest file (AndroidManifest.xml) is a compiled file that describes the manifest information of the application, including: package name, application name, permissions, four major components of Android, version and other important information. When packaging the application, the AndroidManifest.xml file is automatically generated and packaged into the APK file. When installing the application, the Android system will read this file to determine the basic information and permission requirements of the application.
[0107] In one practicable manner, the predetermined format in step 302 is specifically a key-value pair format;
[0108] For example, the network connection configuration information is:
[0109] name: coexist value: true / false
[0110] name: mobile value: 192.168.8.102
[0111] name: Wi-Fi value: 192.168.7.12
[0112] name:ethernet value:192.168.333.5;
[0113] In an implementable manner, the manifest file also includes verification parameters, keys, and signature data;
[0114] The verification parameter may be a random number, and the signature data is specifically obtained by performing MD5 calculation on the verification parameter using a key.
[0115] Furthermore, an embodiment of the present invention provides a method for an application in a smart terminal device to access a network, such as Figure 4 , Figure 5 As shown, the method includes a process of installing the application through an installation package, and before executing the installation process of the application in the method, it also includes writing and updating the first preset interface, the second preset interface and each preset method into the Android system. Specifically, the Android system includes system services and network drivers. Further, the system services include a package management service (PackageManagerService, referred to as PKMS) and a first connection service;
[0116] One possible way is to Figure 4 As shown, in this implementation, accessing the network setting is performed during the first installation of the application, and the method specifically includes:
[0117] Step 401: The package management service obtains the APK file of the application to be installed;
[0118] In the Android system, when the system starts, the system server starts the package management service (PackageManagerService, referred to as PKMS), which executes the application installation process;
[0119] Specifically, the system starts the package management service by calling a preset method, the preset method is PackageManagerService.installPackage;
[0120] An implementable method is to install the application through adb install.
[0121] Step 402: The package management service calls the first API interface to parse the manifest file in the APK file of the application to be installed, and obtains configuration startup item information;
[0122] Specifically, the first API interface is install Package();
[0123] In an practicable manner, calling the first API interface to parse the manifest file in the APK file to be installed of the application is specifically as follows: parsing the manifest file in the APK file to be installed of the application through a function object, and obtaining configuration startup item information in the manifest file;
[0124] Specifically, the function object is Package Parser;
[0125] An implementable method, step 402 also includes a package management service to determine whether there is user permission information in the manifest file, is to be installed APK file corresponding to the application is added to the preset permission group, step 403, otherwise step 403;
[0126] Specifically, adding the application corresponding to the APK file to be installed to the preset permission group is as follows: adding AID_CONTROL_FIREWALL 1098 in UIDMap and Android_filesystem_config.h.
[0127] Step 403: The package management service determines the network connection configuration type according to the configuration startup item information. If the network connection configuration type is configuration, step 404 is executed.
[0128] In an implementable manner, the startup item is configured as coexist, and the first preset value is true;
[0129] Specifically, if the value corresponding to the configuration startup item is the first preset value, it means that the network accessed by the application in the terminal device is configured. After the configuration is completed, the IP / domain name specified in the network connection configuration information is only allowed to be accessed with the specified network connection method, and other unspecified network connection methods are not accessible.
[0130] Step 404: The package management service obtains the user authority information and the network connection configuration information in the manifest file, organizes the network connection configuration information and the user authority information to obtain the application configuration information, and calls the first preset interface to pass the application configuration information as a parameter to the first connection service;
[0131] In an practicable manner, step 404 is specifically as follows: the package management service obtains the user authority information, the network connection configuration information and the signature verification data in the manifest file, organizes the network connection configuration information, the user authority information and the signature verification data to obtain the application configuration information, and calls the first preset interface to pass the application configuration information as a parameter to the first connection service;
[0132] Specifically, the first preset interface is CS.addRoute.
[0133] Step 405: The first connection service determines that the application network connection mode setting type is the first type according to the called interface type, obtains application configuration information, and determines whether there is user authority information according to the application configuration information. If yes, execute step 406, otherwise terminate;
[0134] In one practicable manner, the first connection service includes a network connection service (Connectivity Service, CS for short) and a network management service (Network Management Service, NMS for short). In step 404, the package management service calls the first preset interface to pass the application configuration information as a parameter to the first connection service. Specifically, the package management service calls the first preset interface to pass the application configuration information as a parameter to the network connection service.
[0135] Specifically, step 405 is as follows: the network connection service determines that the application network connection mode setting type is the first type according to the called interface type, obtains the application configuration information, and determines whether there is user authority information according to the application configuration information. If yes, step 406 is executed, otherwise, the process ends;
[0136] Further, judging whether there is user permission information according to the application configuration information is specifically as follows: judging whether there is a corresponding value of android.permission.CONTROL_FIREWALL_RULED in the application configuration information, if so, it indicates that there is user permission information, otherwise, there is no user permission information;
[0137] In an practicable manner, when it is determined that there is user permission information according to the application configuration information, the system service further includes: obtaining the verification data in the application configuration information to perform code verification, if the verification passes, obtaining the network configuration permission, and executing step 406; if the verification fails, the process ends, and the verification data includes the specified parameters, the verification key, and the signature data;
[0138] Specifically, the system service obtains the verification data in the application configuration information to perform code verification as follows: the system service obtains the specified parameters, the verification key and the signature data, calculates the specified parameters through the verification key to obtain the first data, and determines whether the first data is consistent with the signature data. If so, the verification passes, otherwise the verification fails.
[0139] Step 406: The first connection service obtains a custom routing setting table, saves the network connection configuration information in the application configuration information into the custom routing setting table, and transmits the network connection configuration information to the network driver;
[0140] Specifically, step 406 is as follows: the network connection service obtains the custom routing setting table, saves the network connection configuration information in the application configuration information into the custom routing setting table, calls the first preset method to pass the network connection configuration information as a parameter to the network management service, and the network management service calls the second preset method to pass the network connection configuration information as a parameter to the network driver;
[0141] Specifically, the first preset method is NMS.enableRoute, and the second preset method is INetd.enableRoute.
[0142] Step 407: The network driver configures the network connection configuration information into the routing rule table through the configuration instruction, and the process ends.
[0143] In one practicable manner, step 407 is specifically that the network driver sends a configuration instruction to the routing tool, and after receiving the instruction, the routing tool configures the incoming network connection configuration information into the routing rule table;
[0144] Specifically, the network driver includes the Netd local service and the routing controller;
[0145] Furthermore, the network management service calls the second preset method to pass the network connection configuration information as a parameter to the network driver specifically: the network management service calls the second preset method to pass the network connection configuration information as a parameter to the Netd local service;
[0146] Further, step 407 is specifically as follows: the Netd local service passes the network connection configuration information as a parameter to the routing controller by calling the third preset method, the routing controller sends a configuration instruction to the routing tool, and the routing tool configures the incoming IP information and network connection mode into the routing rule table after receiving the configuration instruction;
[0147] Specifically, the Netd local service is NetdNativeService (NNS for short), the third preset method is RC.enableRoute; the route controller is Route Controller (RC for short); and the configuration instruction is specifically to add the incoming network connection configuration information to the route rule table.
[0148] In one practicable manner, the routing tool executes configuration instructions specifically using the Linux network driver technology, specifically: executing the IP rule instruction can add the network connection method specified by the IP information to the routing rule table;
[0149] For example, the routing controller sends the ip rule command:
[0150] Usage: ip rule [ list | add | del ] SELECTOR ACTION (add: add, del: delete, list: list) command. The routing tool adds the network connection method specified by the IP information to the routing rule table according to the command.
[0151] In this embodiment, an practicable method is as follows: Figure 5 As shown, another method for an application in a smart terminal device to access a network is provided. Specifically, in this embodiment, the network access setting is performed during the upgrade process after the application is installed. The method specifically includes:
[0152] Step 501: The package management service obtains the APK file of the application to be installed;
[0153] In the Android system, the system starts the package management service (PackageManagerService, referred to as PKMS), and executes the application upgrade and installation process through the package management service;
[0154] An implementable method is to install or upgrade an application by remotely pushing an APK file.
[0155] Step 502: The package management service calls the second API interface to parse the manifest file in the APK file of the application to be installed, and obtains configuration startup item information;
[0156] Specifically, the second API interface is updatePackage();
[0157] In an practicable manner, calling the second API interface to parse the manifest file in the APK file to be installed of the application is specifically as follows: parsing the manifest file in the APK file to be installed of the application through a function object, and obtaining configuration startup item information in the manifest file;
[0158] Specifically, the function object is Package Parser;
[0159] In an implementable manner, step 502 further includes a package management service determining whether the manifest file contains user permission information, if so, adding the application corresponding to the APK file to be installed to the preset permission group, and executing step 503, if otherwise, executing step 503;
[0160] Specifically, adding the application corresponding to the APK file to be installed to the preset permission group is as follows: adding AID_CONTROL_FIREWALL 1098 in UIDMap and Android_filesystem_config.h.
[0161] Step 503, the package management service determines the network connection configuration type according to the configuration startup item information, and if the network connection configuration type is configuration, execute step 504; if the network connection configuration type is cancellation of configuration, execute step 512;
[0162] In an implementable manner, the first preset value is true;
[0163] Specifically, if the value corresponding to the configuration startup item is the first preset value, it means that the network accessed by the application in the terminal device is configured, and after the configuration is completed, the IP / domain name specified in the network connection configuration information is only allowed to be accessed by the specified network connection method, and other unspecified network connection methods are not accessible;
[0164] In an practicable manner, the value corresponding to the configuration startup item may also be specifically a second preset value; wherein the second preset value is false;
[0165] Specifically, if the value corresponding to the configuration startup item is the second preset value, it means that the network connection method for accessing the application in the terminal device does not need to be configured.
[0166] Step 504: The package management service obtains the user authority information and the network connection configuration information in the manifest file, organizes the network connection configuration information and the user authority information to obtain the application configuration information, and calls the first preset interface to pass the application configuration information as a parameter to the first connection service;
[0167] Specifically, the first preset interface is CS.addRoute.
[0168] Step 505: The first connection service determines that the application network connection mode setting type is the first type according to the called interface type, obtains application configuration information, and determines whether there is user authority information according to the application configuration information. If yes, execute step 506, otherwise end;
[0169] In this embodiment, the first connection service includes: a network connection service and a network management service;
[0170] Specifically, step 505 is as follows: the network connection service determines that the application network setting type is the first type according to the called interface type, obtains the application configuration information, and determines whether there is user authority information according to the application configuration information. If yes, step 506 is executed, otherwise, the process ends;
[0171] Step 506: The first connection service obtains a custom routing setting table and determines whether there is network connection configuration information in the custom routing setting table. If yes, execute step 507; otherwise, execute step 510.
[0172] Specifically, step 506 is as follows: the network connection service obtains the custom routing setting table, and determines whether there is network connection configuration information in the custom routing setting table. If yes, step 507 is executed, otherwise, step 510 is executed;
[0173] Step 507: The first connection service obtains the network connection configuration information in the application configuration information, and determines whether the network connection configuration information in the custom routing setting table is the same as the network connection configuration information in the application configuration information. If yes, the process ends; otherwise, the process proceeds to step 508.
[0174] Specifically, step 507 is as follows: the network connection service obtains the network connection configuration information in the application configuration information, and determines whether the network connection configuration information in the custom routing setting table is the same as the network connection configuration information in the application configuration information, and if so, ends; otherwise, executes step 508;
[0175] Step 508: The first connection service transfers the network connection configuration information in the custom routing setting table to the network driver, deletes the network connection configuration information in the custom routing setting table from the custom routing setting table, and executes step 509;
[0176] Specifically, step 508 is as follows: the network connection service deletes the network connection configuration information in the custom route setting table from the custom route setting table, calls the fourth preset method to pass the network connection configuration information in the custom route setting table as a parameter to the network management service, and the network management service calls the fifth preset method to pass the network connection configuration information as a parameter to the network driver;
[0177] Specifically, the fourth preset method is NMS.disableRoute, and the fifth preset method is INetd.disableRoute.
[0178] Step 509: The network driver deletes the network connection configuration information in the custom routing setting table from the routing rule table through a deletion instruction, and then executes step 510;
[0179] In one practicable manner, step 509 is specifically that the network driver sends a deletion instruction to the routing tool, and the routing tool deletes the incoming network connection configuration information from the routing rule table after receiving the instruction;
[0180] Specifically, the network driver includes the Netd local service and the routing controller;
[0181] Further, the network management service calls the fifth preset method to pass the network connection configuration information as a parameter to the network driver specifically: the network management service calls the fifth preset method to pass the network connection configuration information as a parameter to the Netd local service;
[0182] Further, step 509 is specifically as follows: the Netd local service passes the network connection configuration information as a parameter to the routing controller by calling the sixth preset method, the routing controller sends a deletion instruction to the routing tool, and the routing tool deletes the passed-in IP information from the routing rule table after receiving the instruction;
[0183] Specifically, the sixth preset method is RC. disableRoute.
[0184] Step 510: The first connection service saves the network connection configuration information in the application configuration information into the custom routing setting table, transfers the network connection configuration information in the application configuration information to the network driver, and executes step 511;
[0185] Specifically, step 510 is as follows: the network connection service saves the network connection configuration information in the application configuration information into the custom routing setting table, calls the first preset method to pass the network connection configuration information in the application configuration information as a parameter to the network management service, and the network management service calls the second preset method to pass the network connection configuration information as a parameter to the network driver;
[0186] Among them, the first preset method is NMS.enableRoute, and the second preset method is INetd.enableRoute.
[0187] Step 511: The network driver configures the network connection configuration information in the application configuration information into the routing rule table through the configuration instruction, and ends;
[0188] In one practicable manner, step 511 is specifically that the network driver sends a configuration instruction to the routing tool, and after receiving the instruction, the routing tool configures the incoming network connection configuration information into the routing rule table;
[0189] Specifically, the network driver includes the Netd local service and the routing controller;
[0190] Furthermore, the network management service calls the second preset method to pass the network connection configuration information as a parameter to the network driver specifically: the network management service calls the second preset method to pass the network connection configuration information as a parameter to the Netd local service;
[0191] Further, step 511 is specifically as follows: the Netd local service passes the network connection configuration information as a parameter to the routing controller by calling the third preset method, the routing controller sends a configuration instruction to the routing tool, and the routing tool configures the passed-in IP information into the routing rule table after receiving the instruction;
[0192] Specifically, the Netd local service is NetdNativeService (NNS for short), the third preset method is RC.enableRoute; the route controller is Route Controller (RC for short); and the configuration instruction is specifically to add the incoming network connection configuration information to the route rule table.
[0193] Step 512: The package management service obtains the user authority information and the network connection configuration information in the manifest file, organizes the network connection configuration information and the user authority information to obtain the application configuration information, and calls the second preset interface to pass the application configuration information as a parameter to the first connection service;
[0194] Specifically, the second preset interface is CS.RemoveRoute.
[0195] Step 513: The first connection service determines that the application network connection mode setting type is the second type according to the called interface type, obtains application configuration information, and determines whether there is user authority information according to the application configuration information. If yes, execute step 514, otherwise terminate.
[0196] In one practicable manner, the first connection service includes a network connection service and a network management service, and in step 512, the package management service calls the second preset interface to pass the application configuration information as a parameter to the first connection service, specifically: the package management service calls the second preset interface to pass the application configuration information as a parameter to the network connection service;
[0197] Specifically, step 513 is as follows: the network connection service determines that the application network connection mode setting type is the second type according to the called interface type, obtains the application configuration information, and determines whether there is user authority information according to the application configuration information. If yes, step 514 is executed, otherwise, the process ends;
[0198] Further, judging whether there is user permission information according to the application configuration information is specifically as follows: judging whether there is a corresponding value of android.permission.CONTROL_FIREWALL_RULED in the application configuration information, if so, it indicates that there is user permission information, otherwise, there is no user permission information;
[0199] Step 514: The first connection service obtains a custom routing setting table, transfers the network connection configuration information in the custom routing setting table to the network driver, deletes the network connection configuration information in the custom routing setting table, and executes step 515;
[0200] In an practicable manner, step 514 specifically includes: the first connection service obtains the network connection configuration information in the application configuration information, obtains the custom route setting table, determines whether the network connection configuration information exists in the custom route setting table, and if so, transmits the network connection configuration information to the network driver, deletes the network connection configuration information from the custom route setting table, and executes step 515, otherwise, the process ends;
[0201] Specifically, step 514 is as follows: the network connection service obtains the custom routing setting table, calls the fourth preset method to pass the network connection configuration information in the custom routing setting table as a parameter to the network management service, deletes the network connection configuration information in the custom routing setting table, and the network management service calls the fifth preset method to pass the network connection configuration information as a parameter to the network driver;
[0202] Specifically, the fourth preset method is NMS.disableRoute, and the fifth preset method is INetd.disableRoute.
[0203] Step 515: The network driver deletes the network connection configuration information from the routing rule table through a deletion instruction, and the process ends.
[0204] In one practicable manner, step 515 is specifically that the network driver sends a configuration instruction to the routing tool, and the routing tool deletes the incoming network connection configuration information from the routing rule table after receiving the instruction;
[0205] Specifically, the network driver includes the Netd local service and the routing controller;
[0206] Further, the network management service calls the sixth preset method to pass the network connection configuration information as a parameter to the network driver specifically: the network management service calls the sixth preset method to pass the network connection configuration information as a parameter to the Netd local service;
[0207] Further, step 515 is specifically as follows: the Netd local service passes the network connection configuration information as a parameter to the routing controller by calling the sixth preset method, the routing controller sends a deletion instruction to the routing tool, and the routing tool deletes the passed-in network connection configuration information from the routing rule table after receiving the instruction.
[0208] An implementable method is that when there are multiple network connection configuration information in the custom routing setting table, the network connection configuration information is transmitted to the network driver in step 514 as follows: traverse and obtain the network connection configuration information, transmit the network connection configuration information to the network driver in turn, and execute step 515 in turn until the list is empty.
[0209] In an implementable manner, the application configuration information also includes verification data. When the system service determines that there is user permission information based on the application configuration information, it also includes: the system service obtains the verification data in the application configuration information to perform code verification, the verification data includes specified parameters, verification key and signature data, and if the verification passes, the network configuration permission is obtained; if the verification fails, an error is reported and the process ends.
[0210] In this embodiment, in one practicable manner, when the intelligent terminal device is turned off, the network driver deletes all the network connection configuration information configured in the routing rule table through the routing tool;
[0211] In this embodiment, an implementable method is that when the smart terminal device is powered on and restarted, the system service obtains the saved custom routing setting table by calling the CS.systemReady() method, traverses the custom routing setting table, sequentially obtains the network connection configuration information in the list and executes steps 510 to 511.
[0212] The embodiment of the present invention provides a method for an application in a smart terminal device to access a network, which is applicable to a smart terminal device installed with an Android system. In this embodiment, the smart terminal device includes an application, and the application in the smart terminal device connects to the network through a specified network connection method to complete a specific user operation. This solution sets the network connection method accessed by the application according to the network connection configuration information during the installation of the application installation package or the upgrade package, thereby realizing the function that the application can perform secure operation processing under the specified network connection method, thereby avoiding the risk of data leakage caused by network security issues.
[0213] Embodiment 3
[0214] Embodiment 3 of the present invention provides a method for an application in a smart terminal device to access a network, wherein the present embodiment is set by a third-party application through an interface function. The embodiment of the present invention provides a method for an application in a smart terminal device to access a network, which includes providing an interface function SDK for a third-party application to call before executing the method, and writing and updating a preset interface into an Android system of the smart terminal device. Specifically, the smart terminal device includes a system service and a network driver, and the smart terminal device also includes a POS management service (application process). Further, the system service includes a connectivity service (CS) and a network management service (NMS). Further, an ICM interface is pre-defined in the POS management service, and the ICM interface includes a first ICM interface and a second ICM interface, wherein the first ICM interface indicates configuring a network access type, and the second ICM interface indicates clearing a configured network access type.
[0215] like Figure 6 As shown, a method for an application in a smart terminal device to access a network provided by an embodiment of the present invention specifically includes:
[0216] When the POS management service is called by the third-party application through the first ICM interface, step 601 is executed; when the POS management service is called by the third-party application through the second ICM interface, step 605 is executed;
[0217] In this embodiment, the method further includes: generating an interface function SDK, the third-party application binds the POS management service through the AIDL method, establishing a connection and initialization operation, and calling the POS management service through the interface in the SDK, and passing the network connection configuration information and application information to be configured as parameters; for example, the parameters passed in when calling the first ICM interface are: enableRoute(String IP, String packageName), and the parameters passed in when calling the second ICM interface are: disableRoute(String IP, String packageName);
[0218] Specifically, the first ICM interface is: enable.RouteFromCustomer; the second ICM interface is: disable.RouteFromCustomer.
[0219] Step 601: The POS management service calls the first preset interface, and transmits the network connection configuration information and application information transmitted by the third-party application to the system service as application configuration information;
[0220] In this embodiment, the application information is specifically an application package name, such as String packageName;
[0221] Step 602: The system service determines that the application network connection mode setting type is the first type according to the called interface type, and executes step 603;
[0222] In one practicable manner, the system service includes a network connection service and a network management service, and step 601 specifically includes: the POS management service calls the first interface, and transmits the network connection configuration information and application information transmitted by the third-party application as application configuration information to the network connection service;
[0223] Specifically, step 602 is specifically as follows: the network connection service determines that the application network connection mode setting type is the first type according to the called interface type;
[0224] The first default interface is CS.addRoute.
[0225] Step 603: The system service determines whether the application has user permission information according to the application configuration information. If yes, the system service obtains the custom routing setting table, saves the network connection configuration information in the application configuration information into the custom routing setting table, transfers the network connection configuration information to the network driver, and executes step 604; otherwise, the system service ends.
[0226] In one practicable manner, the system service determines whether the application has user permission information according to the application configuration information: the system service determines whether the third-party application corresponding to the application package name has user permission information according to the application package name in the application configuration information;
[0227] Specifically, step 603 is as follows: the network connection service determines whether the application has user permission information according to the application configuration information, and if so, obtains the custom routing setting table, saves the network connection configuration information in the application configuration information into the custom routing setting table, calls the first preset method to pass the network connection configuration information as a parameter to the network management service, and the network management service calls the second preset method to pass the network connection configuration information as a parameter to the network driver;
[0228] Specifically, the first preset method is NMS.enableRoute, and the second preset method is INetd.enableRoute.
[0229] Step 604: The network driver configures the incoming network connection configuration information into the routing rule table through the configuration instruction, and ends;
[0230] In one practicable manner, step 604 is specifically as follows: the network driver sends a configuration instruction to the routing tool, and after receiving the instruction, the routing tool configures the incoming network connection configuration information into the routing rule table;
[0231] Specifically, the network driver includes a Netd local service and a routing controller. Further, the network management service calls the second preset method to pass the network connection configuration information as a parameter to the network driver. Specifically, the network management service calls the second preset method to pass the network connection configuration information as a parameter to the Netd local service.
[0232] Further, step 604 is specifically as follows: the Netd local service passes the network connection configuration information as a parameter to the routing controller by calling the third preset method, the routing controller sends a configuration instruction to the routing tool, and the routing tool configures the passed-in network connection configuration information into the routing rule table after receiving the instruction;
[0233] Specifically, the Netd local service is NetdNativeService (NNS for short), the third preset method is RC.enableRoute; the route controller is Route Controller (RC for short); and the configuration instruction is specifically to add the incoming network connection configuration information to the route rule table.
[0234] Step 605: The POS management service calls the second preset interface and transmits the application information transmitted by the third-party application to the system service as application configuration information;
[0235] In one practicable manner, step 605 is specifically as follows: the POS management service obtains the application package name, organizes the application package name to obtain application configuration information, and calls the second preset interface of the system service to pass the application configuration information as a parameter to the system service;
[0236] Optionally, step 605 is specifically as follows: the POS management service obtains the application package name and the network connection configuration information, organizes the application package name and the network connection configuration information to obtain the application configuration information, and calls the second interface of the system service to pass the application configuration information as a parameter to the system service.
[0237] Step 606: The system service determines that the application network connection mode setting type is the second type according to the called interface type, and executes step 607;
[0238] In one practicable manner, the system service includes a network connection service and a network management service, and step 605 is specifically as follows: the POS management service calls the second interface to pass the application information passed in by the third-party application as application configuration information to the network connection service;
[0239] Specifically, step 606 is as follows: the network connection service determines that the application network connection mode setting type is the second type according to the called interface type;
[0240] The second default interface is CS.RemoveRoute.
[0241] Step 607: The system service determines whether the application has user permission information according to the application configuration information. If yes, execute step 608; otherwise, end;
[0242] In one practicable manner, the system service determines whether the application has user permission information according to the application configuration information: the system service determines whether the third-party application corresponding to the application package name has corresponding user permission information according to the application package name in the application configuration information;
[0243] Specifically, step 607 is as follows: the network connection service determines whether the application has user permission information according to the application configuration information, and if so, executes step 608, and if not, ends.
[0244] Step 608: The system service obtains the custom routing setting table and determines whether there is network connection configuration information in the custom routing setting table. If yes, execute step 609; otherwise, end;
[0245] In one practicable manner, determining whether there is network connection configuration information in the custom route setting table is specifically as follows: the system service determines whether there is network connection configuration information in the application configuration information in the custom route setting table, and if so, executes step 609, otherwise ends;
[0246] Specifically, step 608 is as follows: the network connection service obtains the custom routing setting table, and determines whether there is IP information in the custom routing setting table. If yes, step 609 is executed, otherwise, the process ends.
[0247] Step 609: The system service transfers the network connection configuration information to the network driver, deletes the network connection configuration information in the custom routing setting table, and executes step 610;
[0248] Specifically, step 609 is as follows: the network connection service deletes the network connection configuration information in the custom routing setting table, calls the fourth preset method to pass the network connection configuration information as a parameter to the network management service, and the network management service calls the fifth preset method to pass the network connection configuration information as a parameter to the network driver;
[0249] Step 610: The network driver deletes the network connection configuration information from the routing rule table through a deletion instruction, and the process ends.
[0250] In this embodiment, in an implementable manner, step 610 is specifically as follows: the network driver sends a deletion instruction to the routing tool, and the routing tool deletes the incoming network connection configuration information from the routing rule table after receiving the instruction;
[0251] Specifically, the network driver includes a Netd local service and a routing controller, and the network management service calls the fifth preset method to pass the network connection configuration information as a parameter to the network driver. Specifically: the network management service calls the fifth preset method to pass the network connection configuration information as a parameter to the Netd local service;
[0252] Further, step 610 is specifically as follows: the Netd local service passes the network connection configuration information as a parameter to the routing controller by calling the sixth preset method; the routing controller sends a deletion instruction to the routing tool, and the routing tool deletes the passed-in network connection configuration information from the routing rule table after receiving the instruction;
[0253] Specifically, the Netd local service is NetdNativeService; the sixth preset method is RC.disableRoute; and the route controller is Route Controller.
[0254] In an implementable manner, the application configuration information also includes verification data. When the system service determines that there is user permission information based on the application configuration information, it also includes: the system service obtains the verification data in the application configuration information to perform code verification, the verification data includes specified parameters, verification key and signature data, and if the verification passes, the network configuration permission is obtained; if the verification fails, an error is reported and the process ends.
[0255] A method for network access by an application in a smart terminal device provided by an embodiment of the present invention is applicable to a smart terminal device installed with an Android system. In this embodiment, the smart terminal device includes a third-party application. The third-party application in the smart terminal device calls a POS management service in the smart terminal device through an interface function SDK to complete the application network connection mode setting operation. The network type specified by the application is set according to the determined application network connection mode setting type through system services and network drivers, thereby solving the problem in the prior art that the application cannot set secure network access due to lack of permission, realizing the function that the application can perform secure operation processing under the specified network type, and avoiding the risks of data leakage caused by network security problems.
[0256] Embodiment 4
[0257] Embodiment 4 of the present invention provides a method for an application in an intelligent terminal device to access a network based on Embodiment 1, such as Figure 7As shown, Embodiment 4 of the present invention provides a method for an application in a smart terminal device to access a network, the method comprising:
[0258] Step 701: The application initiates a network connection request;
[0259] Specifically, the application uses WebView or Chrome browser to type a domain name to access the Internet, or directly initiates an http request.
[0260] Step 702: When the system service receives the network connection request, it sends the network request to the network driver;
[0261] Step 703: The network driver obtains the IP information in the network connection request and determines whether there is network connection configuration information matching the IP information in the routing rule table. If yes, execute step 704; otherwise, execute step 706.
[0262] Step 704: The network driver determines the network connection mode corresponding to the IP information through the routing rule table, and sends the network request data packet to the server corresponding to the IP information according to the determined network connection mode, and executes step 705;
[0263] Step 705, the network driver determines whether a network response data packet returned by the server corresponding to the IP information is received, if yes, it returns the network response data packet to the system service, and executes step 709, if no, it returns an error message to the system service, and executes step 710;
[0264] Step 706: The network driver sends a network request data packet to the server corresponding to the IP information according to the default network connection mode, and then executes step 707;
[0265] Step 707, the network driver determines whether a network response data packet returned by the server is received, if yes, the network response data packet is returned to the system service, and step 709 is executed, otherwise, step 708 is executed;
[0266] Step 708, the network driver determines whether there is a switchable network connection mode, if yes, switches the network connection mode and sends a network request data packet to the server corresponding to the IP information, and executes step 707, otherwise returns an error message to the system service, and executes step 710;
[0267] Step 709: The system service returns a network response data packet to the application, and the process ends.
[0268] Step 710: The system service returns error information to the application and ends.
[0269] In the prior art, if the IP in the network connection request cannot request access using the default network connection mode, when sending and receiving data packets, the network driver will switch with the default network connection mode priority. In this solution, when the IP in the network connection request specifies the network connection mode, the specified network connection mode must be used to send and receive data packets, and other connection modes cannot access or send and receive data packets. By adopting this method, it is ensured that the private network is dedicated and cannot be switched at will, thereby ensuring data security during the access process.
[0270] Specifically, the network driver listens to network requests through the routing tool. The main function of the routing tool Android iprule is to determine which routing table sends the request data packet based on the destination IP in the network request; the iprule routing tool maintains the routing rule table.
[0271] In an practicable manner, step 102 of the first embodiment further includes: the system service sets a permission group corresponding to the application according to the user permission information in the application configuration information;
[0272] Specifically, in this embodiment, before executing step 704, the network driver also includes determining whether the permission information applied in the network response data packet is the same as the permission group information in the routing rule table, and if so, executing step 704, otherwise executing step 705.
[0273] Specifically, in one implementable manner, if the application does not receive a response within a preset time period, an error message is displayed and the application ends.
[0274] In this embodiment, in one practicable manner, icons corresponding to all network connection modes are displayed on the display interface of the smart terminal device, and when any network connection mode is used, the icon corresponding to the connected network connection mode also includes a connection flashing icon;
[0275] Specifically, when the network driver determines that there is a switchable network connection mode, the network connection mode is switched. After the network connection mode is switched, a flashing icon of the network connection mode will also be displayed on the display interface of the smart terminal device.
[0276] The present invention provides a method for an application in an intelligent terminal device to access the network. The solution sets the network access setting information specified by the application according to a determined application network connection mode setting type through system services and network drivers, thereby solving the problem in the prior art that the application cannot set secure network access due to lack of permission, and realizes the function that the application can access securely and operate securely in a specified network environment, thereby avoiding the risk of data leakage caused by network security issues.
[0277] The following are embodiments of the apparatus of the present invention, which can be used to implement the embodiments of the method of the present invention. For details not disclosed in the embodiments of the apparatus of the present invention, reference can be made to the embodiments of the method of the present invention.
[0278] An exemplary embodiment of the present invention provides a device for setting application access network in an intelligent terminal device, the device comprising: the device comprises a system service and a network driver;
[0279] Among them, system services include:
[0280] A first determination module, configured to determine the application network connection mode setting type according to the called interface type, and trigger a first acquisition judgment module if the application network connection mode setting type is determined to be the first type;
[0281] A first acquisition and judgment module is used to obtain application configuration information passed in through the called interface, and judge whether there is user authority information according to the application configuration information;
[0282] an acquisition and saving module, used for acquiring a custom routing setting table, saving the network connection configuration information in the application configuration information into the custom routing setting table, and transferring the network connection configuration information to the network driver when the first acquisition and judgment module determines that the user authority information exists;
[0283] The network driver includes: a configuration module, which is used to configure the network connection configuration information into the routing rule table through configuration instructions;
[0284] The system service also includes: a receiving module for receiving a network connection request initiated by an application in the intelligent terminal device;
[0285] The sending module is used to send the network request to the network driver when receiving the network connection request, and is also used to return the network response data packet to the application;
[0286] The network driver also includes: a first judgment module, which is used to obtain the IP information in the network request, and judge whether there is network connection configuration information that is the same as the IP information in the routing rule table, and if so, trigger the first processing module, otherwise, trigger the second processing module;
[0287] A first processing module, used to determine the network connection mode corresponding to the IP information through the routing rule table, send a network request data packet to the IP information according to the network connection mode, and also used to receive a network response data packet and return the network response data packet to the system service;
[0288] The second processing module is used to send a network request data packet to the IP information according to the default network connection mode, and is also used to receive a network response data packet and return the network response data packet to the system service.
[0289] Optionally, the system service further includes a second acquisition judgment module and an acquisition deletion module;
[0290] The first determination module determines that the application network connection mode setting type is the second type, then triggers the second acquisition and judgment module, the second acquisition and judgment module is used to obtain the application configuration information passed in through the called interface, and determine whether there is user permission information according to the application configuration information;
[0291] an acquisition and deletion module, which is used to acquire the custom routing setting table when the second acquisition and judgment module determines that the user authority information exists, and to determine whether the network connection configuration information exists in the custom routing setting table. If yes, the network connection configuration information is transferred to the network driver, and the network connection configuration information is deleted from the custom routing setting table;
[0292] The network driver also includes a first deletion module, which is used to delete the network connection configuration information from the routing rule table through a configuration instruction. Optionally, the first determination module is specifically used to determine that the application network connection mode setting type is the first type when the first preset interface is called, and to determine that the application network connection mode setting type is the second type when the second preset interface is called.
[0293] Optionally, the system service further includes a package management service, which includes a first acquisition module and a first calling module, wherein the first acquisition module is used to acquire an APK file of the application to be installed, call an API interface to parse a manifest file in the APK file of the application to be installed, and acquire configuration startup item information;
[0294] The first calling module is used to determine the network connection configuration type according to the configuration startup item information, and call the interface of the system service according to the network connection configuration type.
[0295] Further optionally, the first calling module is specifically used to obtain user permission information and network connection configuration information in the manifest file, organize the network connection configuration information and user permission information to obtain application configuration information, and call the interface of the system service to pass in the application configuration information as a parameter.
[0296] Further optionally, the system service also includes a generation module for generating an APK file to be installed for the application; the generation module is specifically used to determine the network connection configuration type, and write the configuration startup item information, network connection configuration information and user authority information corresponding to the network connection configuration type into the manifest file according to a predetermined format to obtain the APK file to be installed for the application.
[0297] Optionally, the acquisition and storage module further includes a first judgment unit and a second judgment unit;
[0298] The first judgment unit is used to judge whether there is network connection configuration information in the custom routing setting table, and if so, trigger the second judgment unit, otherwise, save the network connection configuration information in the application configuration information into the custom IP information list;
[0299] The second judgment unit is used to obtain the network connection configuration information in the application configuration information, and judge whether the network connection configuration information in the custom routing setting table is the same as the network connection configuration information in the application configuration information, and if so, the process ends, otherwise, the first processing unit is triggered;
[0300] The first processing unit is used to transfer the network connection configuration information in the custom routing setting table to the network driver, delete the network connection configuration information from the custom routing setting table, save the network connection configuration information in the application configuration information to the custom routing setting table, and trigger the first deletion module.
[0301] Optionally, the device includes a POS management service; the POS management service includes a second calling module, which is used to determine the interface type for calling the system service according to the interface type called by the third-party application, and call the interface of the system service according to the determined interface type.
[0302] Further optionally, the second calling module is specifically used to obtain the application package name, organize the network connection configuration information and the application package name to obtain the application configuration information, and call the interface of the system service to pass in the application configuration information as a parameter.
[0303] Furthermore, the first acquisition and judgment module or the second acquisition and judgment module is used to judge whether there is user permission information according to the application configuration information, and specifically to judge whether there is user permission information for the third-party application corresponding to the application package name according to the application package name in the application configuration information.
[0304] Optionally, the system service also includes a signature verification module, which is used to obtain the signature verification data in the application configuration information for code verification. If the signature verification passes, the network configuration permission is obtained, triggering the acquisition and saving module; if the signature verification fails, the process ends.
[0305] Optionally, the first deleting module is also used for the network driver to delete all network connection configuration information in the routing rule table through a deletion instruction when the intelligent terminal device is shut down.
[0306] Optionally, the system service also includes an acquisition processing module, which is used to obtain the saved custom routing setting table when the smart terminal device is powered on and restarted, traverse the custom routing setting table, sequentially obtain the network connection configuration information in the custom routing setting table and pass the network connection configuration information to the network driver.
[0307] Optionally, the acquisition and saving module is used to set permission group information corresponding to the application according to the user permission information in the application configuration information when the first acquisition and judgment module determines that the user permission information exists;
[0308] The network driver further includes a second judgment module for judging whether the application initiating the network connection request has permission information, and if so, triggering the first judgment module, otherwise, triggering the second processing module.
[0309] It should be noted that the apparatus for performing network access by an application in a smart terminal device provided in the above embodiment only uses the division of the above functional modules as an example when executing the method for performing network access by an application. In actual applications, the above functions can be allocated and completed by different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus for performing network access by an application in a smart terminal device provided in the above embodiment and the method for performing network access by an application in a smart terminal device belong to the same concept, and the implementation process thereof is detailed in the method embodiment, which will not be repeated here.
[0310] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0311] The present invention provides a method and device for network access by applications in an intelligent terminal device, which sets the network access setting information specified by the application according to a determined application network connection mode setting type through system services and network drivers, thereby solving the problem in the prior art that secure network access cannot be set due to the application having no authority, and realizing the function that the application can securely access and operate securely in a specified network environment, thereby avoiding the risks of data leakage caused by network security issues.
[0312] An embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the method for network access by an application in an intelligent terminal device disclosed in any of the aforementioned embodiments.
[0313] The embodiment of the present invention also provides a computer-readable storage medium, on which a computer program / instruction is stored, and when the program / instruction is executed by a processor, the method for network access by an application in an intelligent terminal device disclosed in any of the above embodiments is implemented. The computer-readable storage medium may include, but is not limited to, any type of disk, including a floppy disk, an optical disk, a DVD, a CD-ROM, a micro drive, and a magneto-optical disk, a ROM, a RAM, an EPROM, an EEPROM, a DRAM, a VRAM, a flash memory device, a magnetic card or an optical card, a nanosystem (including a molecular memory IC), or any type of medium or device suitable for storing instructions and / or data.
[0314] An embodiment of the present invention provides a computer program product, including a computer program / instruction, wherein the computer program / instruction, when executed by a processor, implements the method for network access by an application in an intelligent terminal device disclosed in any of the aforementioned embodiments.
[0315] In the present invention, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or order; the term "plurality" refers to two or more, unless otherwise clearly defined. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: the existence of A alone, the existence of A and B at the same time, and the existence of B alone. The character " / " generally indicates that the objects associated with each other are in an "or" relationship. Terms such as "install", "connect", "connect", and "fix" should be understood in a broad sense. For example, "connection" can be a fixed connection, a detachable connection, or an integral connection; "connection" can be a direct connection or an indirect connection through an intermediate medium. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0316] In the description of the present invention, it is necessary to understand that the directions or positional relationships indicated by the terms "upper" and "lower" etc. are based on the directions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or unit referred to must have a specific direction, be constructed and operated in a specific orientation. Therefore, it cannot be understood as a limitation on the present invention.
[0317] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope covered by the present invention.
Claims
1. A method for network access by an application in an intelligent terminal device, wherein the intelligent terminal device includes a system service and a network driver, characterized in that: The method comprises: Step S1, the system service determines the application network connection mode setting type according to the called interface type, and if the application network connection mode setting type is the first type, execute step S2; Step S2, the system service obtains the application configuration information passed in through the called first preset interface, and determines whether there is user authority information according to the application configuration information, and if yes, executes step S3, otherwise ends; Step S3, the system service obtains a custom routing setting table, saves the network connection configuration information in the application configuration information into the custom routing setting table, and transmits the network connection configuration information to the network driver, wherein the network connection configuration information includes IP information and a network connection mode corresponding to the IP information; Step S4, the network driver configures the network connection configuration information into the routing rule table through the configuration instruction, and ends; The method further comprises: Step F1: When the system service receives a network connection request initiated by an application in the intelligent terminal device, the system service sends the network connection request to the network driver; Step F2, the network driver obtains the IP information in the network connection request, and determines whether there is network connection configuration information matching the IP information in the routing rule table, if yes, executes step F3, otherwise executes step F4; Step F3, the network driver determines the network connection mode corresponding to the IP information through the routing rule table, sends the network request data packet to the server corresponding to the IP information according to the network connection mode, and executes step F5; Step F4, the network driver sends the network request data packet to the server corresponding to the IP information according to the default network connection mode, and executes step F5; Step F5, the network driver receives a network response data packet returned by the server corresponding to the IP information, and returns the network response data packet to the system service; Step F6: the system service returns the network response data packet to the application; In the step S3, before the network connection configuration information in the application configuration information is saved in the custom routing setting table, the step further includes: Step M21, the system service determines whether there is network connection configuration information in the custom routing setting table, and if yes, executes step M22, otherwise, saves the network connection configuration information in the application configuration information into the custom routing setting table; Step M22, the system service obtains the network connection configuration information in the application configuration information, and determines whether the network connection configuration information in the custom routing setting table is the same as the network connection configuration information in the application configuration information, and if so, ends; otherwise, executes step M23; Step M23, the system service transfers the network connection configuration information in the custom routing setting table to the network driver, and deletes the network connection configuration information in the custom routing setting table; Step M24, the network driver deletes the network connection configuration information in the custom routing setting table from the routing rule table through a deletion instruction; In the step S2, when it is determined according to the application configuration information that there is user permission information, the system service further includes: setting permission group information corresponding to the application according to the user permission information; Before the network driver obtains the IP information in the network connection request, the method further includes: the network driver determines whether the application initiating the network connection request has permission information, and if so, executes step F2, otherwise, executes step F4.
2. The method according to claim 1, characterized in that: The method further includes the following steps when the system service determines that the application network connection mode setting type is the second type according to the called interface type: Step S5, the system service obtains the application configuration information transmitted through the called second preset interface, and determines whether there is user authority information according to the application configuration information, and if yes, executes step S6, otherwise ends; Step S6, the system service obtains a custom routing setting table, determines whether there is network connection configuration information in the custom routing setting table, if yes, deletes the network connection configuration information in the custom routing setting table, transfers the network connection configuration information to the network driver, and executes step S7, otherwise, ends; Step S7: The network driver deletes the network connection configuration information from the routing rule table through a deletion instruction, and the process ends.
3. The method according to claim 2, characterized in that The system service determines the application network connection mode setting type according to the type of the called interface: when the first preset interface of the system service is called, the system service determines the application network connection mode setting type as the first type; when the second preset interface of the system service is called, the system service determines the application network connection mode setting type as the second type.
4. The method according to claim 1, characterized in that: The system service includes a package management service, and before step S1, the following steps are also included: Step P1, the package management service obtains the APK file of the application to be installed; Step P2: The package management service calls an API interface to parse the manifest file in the APK file to be installed, and obtains configuration startup item information; Step P3: The package management service determines the network connection configuration type according to the configuration startup item information, and calls the interface of the system service according to the network connection configuration type.
5. The method according to claim 4, characterized in that In the step P3, the interface of calling the system service according to the network connection configuration type is specifically as follows: the package management service obtains the user permission information and the network connection configuration information in the manifest file, organizes the network connection configuration information and the user permission information to obtain the application configuration information, and calls the interface of the system service to pass in the application configuration information as a parameter.
6. The method according to claim 4, characterized in that The method further comprises generating an APK file to be installed for the application; The specific steps of generating the APK file to be installed are as follows: Step D1, determining the network connection configuration type; Step D2: Write the configuration startup item information, network connection configuration information and user authority information corresponding to the network connection configuration type into the manifest file according to a predetermined format to obtain the APK file to be installed for the application.
7. The method according to claim 2, characterized in that The intelligent terminal device includes POS management services; The step before step S1 also includes: the POS management service determines the interface type for calling the system service according to the interface type called by the third-party application, and calls the interface of the system service according to the determined interface type.
8. The method according to claim 7, characterized in that The interface for calling the system service according to the determined interface type is specifically as follows: the POS management service obtains network connection configuration information and application package name, organizes the network connection configuration information and the application package name to obtain application configuration information, and calls the interface of the system service to pass in the application configuration information as a parameter.
9. The method according to claim 8, characterized in that The determining whether there is user permission information according to the application configuration information is specifically: The system service determines, according to the application package name in the application configuration information, whether there is user permission information for the third-party application corresponding to the application package name.
10. The method according to claim 1, characterized in that When it is determined according to the application configuration information that user permission information exists, before executing step S3, the method further includes: The system service obtains the verification data in the application configuration information to perform code verification. If the verification passes, the network configuration authority is obtained and step S3 is executed. If the verification fails, the process ends.
11. The method according to claim 1, characterized in that: The method further includes: when the intelligent terminal device is turned off, the network driver deletes all the network connection configuration information in the routing rule table through a deletion instruction.
12. The method according to claim 1, characterized in that The method also includes: when the smart terminal device is powered on and restarted, the system service obtains the saved custom routing setting table, traverses the custom routing setting table, sequentially obtains the network connection configuration information in the custom routing setting table and transfers the network connection configuration information to the network driver, and executes step S4.
13. A device for an application in an intelligent terminal device to access a network, characterized in that: The device is implemented by using the method for network access by application in a smart terminal device according to any one of claims 1 to 12, and the device includes a system service and a network driver, and the system service specifically includes: A first determination module, configured to determine the application network connection mode setting type according to the called interface type, and trigger a first acquisition judgment module if the application network connection mode setting type is the first type; The first acquisition and judgment module is used to obtain application configuration information passed in through the called interface, and judge whether there is user permission information according to the application configuration information; an acquisition and saving module, configured to acquire a custom routing setting table when the first acquisition and judgment module determines that user authority information exists, save the network connection configuration information in the application configuration information into the custom routing setting table, and transfer the network connection configuration information to the network driver; The network driver includes: A configuration module, used to configure the network connection configuration information into a routing rule table through configuration instructions; The system services also include: A receiving module, used to receive a network connection request initiated by an application in the smart terminal device, and also used to receive a network response data packet; A sending module, used to send the network request received by the receiving module to the network driver, and also used to return the network response data packet to the application; The network driver also includes: A first determination module, used to receive and obtain IP information in the network connection request; A second judgment module is used to judge whether there is network connection configuration information identical to the IP information in the routing rule table, and if so, trigger the first processing module, otherwise, trigger the second processing module; The first processing module is used to determine the network connection mode corresponding to the IP information through the routing rule table, send a network request data packet to the IP information according to the network connection mode, and receive a network response data packet and return the network response data packet to the system service; The second processing module is used to send a network request data packet to the IP information according to a default network connection mode, and is also used to receive a network response data packet and return the network response data packet to the system service.
14. A computer device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the method according to any one of claims 1 to 12.
15. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instructions are executed by a processor, the method according to any one of claims 1 to 12 is implemented.
16. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the method according to any one of claims 1 to 12 is implemented.
