Data processing methods, terminals and media for Android native and H5
By replacing H5 data access requests with Android native framework requests under the mixed development framework of Android native and H5, and encrypting and decrypting the data, the data security issues caused by H5 are solved and the unification and security of data processing are achieved. promote.
Patent Information
- Application Number
- CN202010731628.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-27
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2040-07-27
AI Technical Summary
Under the framework of Android native and H5 hybrid development, data security issues caused by H5's direct request and processing of data increase the difficulty of formulating code specifications and standards, and poses data security risks.
By replacing the H5 -related data access request to the Android native framework request, using the Android native framework to request data from the server, and encrypt the data to ensure the security of the data in the transmission and storage procedure.
Effectively avoid security problems during the data transmission process, unify data processing methods, transmission formats, and data analysis standards, improve the application process control ability and response management capabilities, reduce code redundancy, and support functional iteration without frequent upgrading upgrades without frequent upgrading. Android application.
Smart Images

Figure CN111857891B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing methods under hybrid development, and in particular to a data processing method, terminal and medium under Android native and H5. Background Art
[0002] In Android application development, using WebView under the Android framework as a carrier can realize hybrid development of Android and H5 to achieve specific functions. Developers can implement the interaction of Android and H5 data and related operations according to functional requirements. The existing technology generally adopts H5 to independently obtain data and process related logic. Android is responsible for providing WebView as a carrier and processing simple interaction logic, but H5 directly requests and processes data. All data requests and processing are under HTML standards and corresponding scripts. Users can directly view related code logic, which will cause data security problems. At the same time, under the Android native and H5 hybrid development framework, it is necessary to provide two data receiving and processing solutions for Android native and H5, which increases the difficulty of formulating code specifications and related standards. There are data security risks in some fields with data security requirements.
[0003] Based on the above analysis, how to solve the data security issues that may arise due to H5 in the hybrid development framework of Android native and H5 is a technical problem that needs to be solved. Summary of the invention
[0004] The technical task of the present invention is to address the above shortcomings and provide a data processing method, terminal and medium under Android native and H5 to solve the problem of data security that may arise due to H5 under the Android native and H5 hybrid development framework.
[0005] In a first aspect, the present invention provides a data processing method under Android native and H5 hybrid development, which replaces H5-related data access requests with Android native framework requests, requests data from a server through the Android native framework, and encrypts and decrypts the data through the Android native framework, including:
[0006] Decrypt the data received from the server through the Android native framework, encapsulate the decrypted data based on the data transmission standard, and pass the encapsulated data to H5;
[0007] After receiving the data uploaded by the user, H5 encapsulates the data based on the data transmission standard and transmits it to the Android native framework. The Android native framework encrypts the encapsulated data and uploads it to the server.
[0008] The data transmission standard is a customized data transmission standard between Android native and H5.
[0009] Preferably, the Android native framework requests data from the server by accessing the server port.
[0010] As a preferred method, the Android native framework decrypts the data received from the server through the encryption protocol and the private key;
[0011] The encryption protocol and private key are the encryption protocol and private key configured between the Android native framework and the server.
[0012] As a preferred method, the Android native framework encapsulates the decrypted data into JSON format based on the data transmission standard and then transmits it to H5;
[0013] After receiving the data uploaded by the user, H5 encapsulates the data into JSON format based on the data transmission standard and then passes it to the Android native framework.
[0014] Preferably, the Android native framework encapsulates the decrypted data into json format, and then calls a Javascript method to transfer the encapsulated data to H5;
[0015] After H5 receives the data uploaded by the user, it calls the Javascript method to encapsulate the data into JSON format and then passes it to the Android native framework.
[0016] Preferably, after the encapsulated data is transferred to H5 through the Android native framework, H5 reads the encapsulated data based on the data transmission standard to perform analysis, obtains the target data, and displays the target data on the H5 interface.
[0017] Preferably, the content form of the target data includes but is not limited to HTML fragments, text content, picture content, and multimedia content.
[0018] In a second aspect, the present invention provides an apparatus, comprising: at least one memory and at least one processor;
[0019] The at least one memory is used to store a machine-readable program;
[0020] The at least one processor is used to call the machine-readable program to execute any method described in the first aspect.
[0021] In a third aspect, the present invention provides a computer-readable medium having computer instructions stored thereon, wherein when the computer instructions are executed by a processor, the processor executes any of the methods described in the first aspect.
[0022] The Android native and H5 data processing method, terminal and medium of the present invention have the following advantages:
[0023] 1. When the H5 interface must be used to complete some functions in Android application development, compared with conventional implementation methods, this technical solution can effectively avoid security issues in the data transmission process through unified data processing. At the same time, because the Android application and the server have established a unified security mechanism, the data processing method, transmission format and data parsing standard can be effectively unified;
[0024] 2. H5 no longer performs data upload and download, which ensures that all requests are initiated and managed uniformly by Android, improving the process control and response management capabilities of the entire application and effectively avoiding code redundancy problems;
[0025] 3. The flexibility of the H5 interface is not destroyed, and the iterative function version can be modified at any time without frequently upgrading the Android application. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, 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.
[0027] The present invention is further described below in conjunction with the accompanying drawings.
[0028] Figure 1 This is a flowchart of the data processing method under Android native and H5 in Example 1. DETAILED DESCRIPTION
[0029] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it. However, the embodiments are not intended to limit the present invention. In the absence of conflict, the embodiments of the present invention and the technical features in the embodiments may be combined with each other.
[0030] The embodiment of the present invention provides an Android native and H5 data processing method, terminal and medium, which are used to solve the technical problem of how to solve the data security that may occur due to H5 in the Android native and H5 hybrid development framework.
[0031] Embodiment 1:
[0032] The present invention provides a data processing method under Android native and H5 hybrid development, which replaces H5-related data access requests with Android native framework requests, requests data from the server through the Android native framework, and encrypts and decrypts the data through the Android native framework. It includes:
[0033] Decrypt the data received from the server through the Android native framework, encapsulate the decrypted data based on the data transmission standard, and pass the encapsulated data to H5;
[0034] After receiving the data uploaded by the user, H5 encapsulates the data based on the data transmission standard and transmits it to the Android native framework. The Android native framework encrypts the encapsulated data and uploads it to the server.
[0035] The above data transmission standards are customized data transmission standards between Android native and H5.
[0036] When developing based on the Android native framework and H5, use the WebView control as the container of the H5 interface. By configuring relevant parameters and calling the loadUrl(String url) method to load the H5 interface, you can complete a simple Android application to load the H5 interface. On this basis, we use the Android native framework and the relevant methods provided by Javascript to complete data interaction:
[0037] (1) The Android native framework calls the H5 Javascript method through the loadUrl(String url) method and passes data, for example:
[0038] public void loadJavascriptMathed(){
[0039] webView.loadUrl("javascript:androidCallJavaScriptMethod()");
[0040] }
[0041] (2) The Android native framework receives H5 data by implementing methods annotated with @JavascriptInterface, for example:
[0042] @JavascriptInterface
[0043] public void onJavascriptClick(String data){
[0044] / / Process data}
[0045] (3) Javascript implements receiving methods and calling methods, for example:
[0046] <script type=”text javascript”language=”javascript”>
[0047] function callJavaScriptMethod(){
[0048] window.mainActivity.onJavascriptClick("data”);
[0049] }
[0050] function androidCallJavaScriptptMethod(){
[0051] }
[0052] <script>
[0053] 与传统的混合开发方案不同,本申请中H5不再参与访问服务器数据,所有数据均由Android原生框架请求并处理后传入Javascript,同时H5提交的数据也通过统一处理后由Android原生框架提交到服务器,H5不参与任何数据的下载和同步。
[0054] 为实现本方案并且不破坏H5的灵活性和可扩展性,需要提供Android原生框架和H5的数据交互标准,该标准需要满足整体要求,即数据通过统一的自定义标准封装成数据包进行传递(如通过json格式封装数据),同时封装标准的制定不涉及内部业务数据的修改,内部业务数据根据功能需求由服务器端程序和H5界面同步制定,并可在服务器端程序和H5同步更新、修改,从而完成功能的迭代升级和相关扩展;Android应用涉及到的数据安全处理和封装,在不涉及到整体安全解决方案和整体业务流程修改的情况下,不需要修改代码逻辑和进行应用版本升级,功能迭代的需求可交由后台服务端和H5界面的更新迭代来完成。
[0055] 数据加密、解密及相关处理由Android原生框架与服务器端程序配合完成,相关加密方案根据系统方案统一制定,由服务器端程序和Android原生框架联合控制,H5不参与任何加密解密处理,只进行必要的数据格式的处理。
[0056] 本实施例中,该方法的步骤为:
[0057] S100、Android原生框架通过访问服务端接口请求数据,此时获取到的数据处于加密状态,Android原生框架通过加密协议、秘钥等解密并处理加密数据,同时根据制定好的Android原生框架与H5数据传递标准完成数据格式的封装,本实施例中将数据封装为json格式;
[0058] S200、Android原生框架调用Javascript方法将封装后的数据传入目标H5界面;
[0059] S300、H5通过数据传递标准解析数据,获取目标数据内容并展示在界面上,因为此节点是作为具体业务功能的展示,所以目标数据内容存在多种形式,包括HTML片段、文字内容、图片内容、多媒体内容等;
[0060] S400、当用户通过与H5界面交互发起数据处理上传的请求时,H5首先收集待上传数据,并通过Javascript将数据处理封装成标准格式(本实施例为json格式),然后调用Android对应方法传入Android原生框架;
[0061] S500、Android原生框架接收Javascript传入的数据,通过统一加密、处理,调用服务器相关接口并传入加密后的数据完成最终请求;
[0062] S600、Android原生框架接收服务器返回的处理结果,重复流程S100的相关步骤,将服务器处理结果反馈给H5,完成本流程的最终结果反馈。
[0063] 实施例2:
[0064] 本发明实施例还提供了一种:装置,包括:至少一个存储器和至少一个处理器;上述至少一个存储器,用于存储机器可读程序;上述至少一个处理器,用于调用所述机器可读程序,执行本发明任一实施例中的Android原生和H5下数据处理方法。
[0065] 实施例3:
[0066] 本发明:提供了一种计算机可读介质,该计算机可读介质上存储有计算机指令,该计算机指令在被处理器执行时,使所述处理器执行本发明任一实施例中的Android原生和H5下数据处理方法。具体地,可以提供配有存储介质的系统或者装置,在该存储介质上存储着实现上述实施例中任一实施例的功能的软件程序代码,且使该系统或者装置的计算机(或CPU或MPU)读出并执行存储在存储介质中的程序代码。
[0067] 在这种情况下,从存储介质读取的程序代码本身可实现上述实施例中任何一项实施例的功能,因此程序代码和存储程序代码的存储介质构成了本发明的一部分。
[0068] 用于提供程序代码的存储介质实施例包括软盘、硬盘、磁光盘、光盘(如CD-ROM、CD-R、CD-RW、DVD-ROM、DVD-RAM、DVD-RW、DVD+RW)、磁带、非易失性存储卡和ROM。可选择地,可以由通信网络从服务器计算机上下载程序代码。
[0069] 此外,应该清楚的是,不仅可以通过执行计算机所读出的程序代码,而且可以通过基于程序代码的指令使计算机上操作的操作系统等来完成部分或者全部的实际操作,从而实现上述实施例中任意一项实施例的功能。
[0070] 此外,可以理解的是,将由存储介质读出的程序代码写到插入计算机内的扩展板中所设置的存储器中或者写到与计算机相连接的扩展单元中设置的存储器中,随后基于程序代码的指令使安装在扩展板或者扩展单元上的CPU等来执行部分和全部实际操作,从而实现上述实施例中任一实施例的功能。
[0071] 需要说明的是,上述各流程不是所有的步骤都是必须的,可以根据实际的需要忽略某些步骤。各步骤的执行顺序不是固定的,可以根据需要进行调整。上述各实施例中描述的系统结构可以是物理结构,也可以是逻辑结构,即,有些模块可能由同一物理实体实现,或者,有些模块可能分由多个物理实体实现,或者,可以由多个独立设备中的某些部件共同实现。
[0072] 以上各实施例中,硬件单元可以通过机械方式或电气方式实现。例如,一个硬件单元可以包括永久性专用的电路或逻辑(如专门的处理器,FPGA或ASIC)来完成相应操作。硬件单元还可以包括可编程逻辑或电路(如通用处理器或其它可编程处理器),可以由软件进行临时的设置以完成相应操作。具体的实现方式(机械方式、或专用的永久性电路、或者临时设置的电路)可以基于成本和时间上的考虑来确定。
[0073] 上文通过附图和优选实施例对本发明进行了详细展示和说明,然而本发明不限于这些已揭示的实施例,基与上述多个实施例本领域技术人员可以知晓,可以组合上述不同实施例中的代码审核手段得到本发明更多的实施例,这些实施例也在本发明的保护范围之内。< / script>
Claims
1. Android native and H5 data processing method, characterized by Replace H5-related data access requests with Android native framework requests, request data from the server by accessing the server port through the Android native framework, and encrypt and decrypt the data through the Android native framework, including: The Android native framework decrypts the data received from the server through the encryption protocol and private key, encapsulates the decrypted data into json format based on the data transmission standard, and calls the Javascript method to pass the encapsulated data to H5. The encryption protocol and private key are the encryption protocol and private key configured between the Android native framework and the server. After receiving the data uploaded by the user, H5 encapsulates the data into json format based on the data transmission standard and then calls the Javascript method to pass it to the Android native framework. The Android native framework encrypts the encapsulated data and then uploads it to the server. H5 reads the encapsulated data based on the data transmission standard and parses it to obtain the target data, and displays the target data on the H5 interface. The content of the target data includes but is not limited to HTML fragments, text content, picture content, and multimedia content. The data transmission standard is a customized data transmission standard between Android native and H5.
2. The device, characterized in that include: at least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is configured to call the machine-readable program to execute the method of claim 1.
3. A medium, which is a computer-readable medium, characterized in that: The computer readable medium stores computer instructions, which, when executed by a processor, cause the processor to perform the method of claim 1 .
Citation Information
Patent Citations
Cross-platform calling method and system for application programs
CN107870821A
Method for safety communication of h5 and server in mixed mode APP
CN109362074A
Front-end information encryption method and device
CN111159748A