Calling method, device and equipment of SDK and computer readable storage medium

CN115543645BActive Publication Date: 2026-10-30TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110728862.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-29
Publication Date
2026-10-30
Estimated Expiration
2041-06-29

AI Technical Summary

Technical Problem

[0003]本申请针对现有的方式的缺点,提出一种SDK的调用方法、装置、设备及计算机可读存储介质,用以解决如何实现对SDK的私有接口和/或SDK的私有属性的调用进行合理保护,并降低调用耗时的问题

Benefits of technology

[0033]响应于针对SDK调用请求,调用方生成SDK的第一对象对应的代理对象,并将包含代理对象的标识的通知消息发送至SDK,以用于指示SDK确定所述代理对象的属性;基于接收到的来自SDK的代理对象的属性,调用方确定代理对象的属性对应的配置;如此,基于属性的类型和配置,调用方通过代理对象,以反射方式实现了对SDK的私有接口、SDK的私有属性中的至少一项的调用进行合理保护,当调用方未设置代理对象,则调用方不能对SDK的私有接口、SDK的私有属性中的至少一项进行调用;同时代理对象仅需调用方在发生调用行为时进行设置,功能执行完毕后代理对象销毁,这样可以保证数据的完整性,并且不会产生脏数据,降低了调用方的调用分析成本,从而降低了调用方的调用耗时。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115543645B_ABST
    Figure CN115543645B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a software development kit (SDK) calling method and device, equipment and a storage medium, comprising: in response to an SDK calling request, a calling party generates a proxy object corresponding to a first object of the SDK, and sends a notification message containing an identifier of the proxy object to the SDK to instruct the SDK to determine the attributes of the proxy object; based on the received attributes of the proxy object from the SDK, the calling party determines the configuration corresponding to the attributes of the proxy object; based on the type and configuration of the attributes, the calling party calls at least one of the private interface of the SDK and the private attribute of the SDK through the proxy object in a reflective manner. The method realizes reasonable protection of the calling of the private interface of the SDK and / or the private attribute of the SDK in a reflective manner through the proxy object, while reducing the calling analysis cost of the calling party.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and more specifically, to an SDK invocation method, apparatus, device, and computer-readable storage medium. Background Technology

[0002] An SDK (Software Development Kit) is generally a collection of development tools used by users to build application software for specific software packages, software frameworks, hardware platforms, operating systems, etc. One existing approach involves using compiler warnings to prevent calls to unmaintained or prohibited SDK interfaces. This is achieved through compiler plugins that add warning messages during the compilation phase. However, this approach is not very user-friendly and incurs significant time and effort on the caller's end. Another approach involves sending the caller's parameters to a server, which first processes and analyzes their validity before performing logical and arithmetic operations within the interface to generate the result. However, this approach is time-consuming due to the server's analysis and processing of SDK interface calls, thus reducing the efficiency of the SDK's internal computations. Summary of the Invention

[0003] This application addresses the shortcomings of existing methods by proposing an SDK invocation method, apparatus, device, and computer-readable storage medium to solve the problem of how to reasonably protect the invocation of SDK private interfaces and / or SDK private attributes, and reduce invocation time.

[0004] Firstly, this application provides a method for calling a Software Development Kit (SDK), including:

[0005] In response to an SDK call request, a proxy object corresponding to the first object of the SDK is generated, and a notification message containing the identifier of the proxy object is sent to the SDK to instruct the SDK to determine the properties of the proxy object;

[0006] Based on the attributes of the proxy object received from the SDK, determine the configuration corresponding to the attributes of the proxy object;

[0007] Based on the type and configuration of the attribute, at least one of the SDK's private interfaces and private attributes can be invoked via a proxy object using reflection.

[0008] In one embodiment, based on the type and configuration of the attribute, at least one of the SDK's private interfaces and private attributes is invoked via a proxy object using reflection, including:

[0009] When the type of the attribute is not an empty object and the configuration meets the preset requirements, the proxy object is used to call at least one of the SDK's private interface and SDK's private attribute in a reflection manner, and the data for at least one of the SDK's private interface and SDK's private attribute returned by the SDK through the first function of the proxy object is received.

[0010] The first object is either a class object or an instance object.

[0011] In one embodiment, when the type of the attribute is an empty object, or the configuration does not meet the preset requirements, the first call exception data returned by the SDK through the first function of the proxy object is received.

[0012] Secondly, this application provides a method for invoking an SDK, including:

[0013] In response to an SDK call request, a protocol method is generated, and the protocol information corresponding to the protocol method is sent to the SDK to instruct the SDK to match the protocol information with the protocol information in the SDK's protocol list;

[0014] When the protocol information corresponding to the protocol method matches the protocol information in the protocol list, at least one of the SDK's public interfaces and public properties corresponding to the protocol information in the protocol list is called through the second object of the SDK.

[0015] In one embodiment, when the protocol information corresponding to a protocol method matches the protocol information in the protocol list, at least one of the SDK's public interfaces and public properties is invoked through the SDK's second object, including:

[0016] When the protocol information corresponding to the protocol method includes the protocol name, interface name, interface function description, and first interface parameter, which respectively match the protocol information in the protocol list, then at least one of the SDK's public interface and SDK's public attributes is called through the SDK's second object, and the data for at least one of the SDK's public interface and SDK's public attributes is received by the SDK through the preset second function.

[0017] The second object is a class object or an instance object.

[0018] In one embodiment, when at least one of the protocol name, interface name, interface function description, and first interface parameter included in the protocol information corresponding to the protocol method is different from the protocol information in the protocol list, the second interface parameter is determined according to the first interface parameter included in the protocol information corresponding to the protocol method and the preset parameter, so as to instruct the SDK to set the value of the second interface parameter to any one of the following: default value, empty string, first number, and empty object, according to the type of the second interface parameter.

[0019] Receive the second call exception data returned by the SDK through the preset second function. The second call exception data includes the value of the second interface parameter.

[0020] Thirdly, this application provides an SDK invocation device, including:

[0021] The first processing module is used to respond to the SDK call request, generate a proxy object corresponding to the first object of the SDK, and send a notification message containing the identifier of the proxy object to the SDK to instruct the SDK to determine the properties of the proxy object;

[0022] The second processing module is used to determine the configuration corresponding to the attributes of the proxy object based on the attributes received from the SDK.

[0023] The third processing module is used to invoke at least one of the SDK's private interfaces and private properties via a proxy object using reflection, based on the type and configuration of the property.

[0024] Fourthly, this application provides an SDK invocation device, comprising:

[0025] The fourth processing module is used to respond to SDK call requests, generate protocol methods, and send the protocol information corresponding to the protocol methods to the SDK, so as to instruct the SDK to match the protocol information with the protocol information in the SDK's protocol list;

[0026] The fifth processing module is used to call at least one of the SDK's public interfaces and public properties corresponding to the protocol information in the protocol list when the protocol information corresponding to the protocol method matches each other.

[0027] Fifthly, this application provides an electronic device, including: a processor, a memory, and a bus;

[0028] A bus is used to connect the processor and memory;

[0029] Memory, used to store operation instructions;

[0030] A processor is configured to execute the calling methods of the SDKs of the first and second aspects of this application by invoking operation instructions.

[0031] Sixthly, this application provides a computer-readable storage medium storing a computer program that is used to execute the calling methods of the SDKs of the first and second aspects of this application.

[0032] The technical solution provided in this application has at least the following beneficial effects:

[0033] In response to an SDK call request, the caller generates a proxy object corresponding to the first object of the SDK and sends a notification message containing the identifier of the proxy object to the SDK to instruct the SDK to determine the attributes of the proxy object. Based on the attributes of the proxy object received from the SDK, the caller determines the configuration corresponding to the attributes of the proxy object. Thus, based on the type and configuration of the attributes, the caller, through the proxy object, uses reflection to reasonably protect calls to at least one of the SDK's private interfaces and private attributes. If the caller does not set a proxy object, the caller cannot call at least one of the SDK's private interfaces and private attributes. At the same time, the proxy object only needs to be set by the caller when the call occurs, and the proxy object is destroyed after the function is executed. This ensures data integrity and does not generate dirty data, reducing the caller's call analysis cost and thus reducing the caller's call time. Attached Figure Description

[0034] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below.

[0035] Figure 1 A schematic diagram of the system architecture provided for embodiments of this application;

[0036] Figure 2 A flowchart illustrating an SDK invocation method provided in this application embodiment;

[0037] Figure 3 A flowchart illustrating another SDK invocation method provided in this application embodiment;

[0038] Figure 4 A flowchart illustrating another SDK invocation method provided in this application embodiment;

[0039] Figure 5 A flowchart illustrating another SDK invocation method provided in this application embodiment;

[0040] Figure 6A schematic diagram of the structure of an SDK invocation device provided in an embodiment of this application;

[0041] Figure 7 A schematic diagram of the structure of another SDK calling device provided in an embodiment of this application;

[0042] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0043] To make the inventive objectives, features, and advantages of this application more apparent and understandable, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0044] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.

[0045] Those skilled in the art will understand that, unless explicitly stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in the specification of this application means the presence of features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we say an element is “connected” or “coupled” to another element, it can be directly connected or coupled to the other element, or there may be intermediate elements. Furthermore, “connected” or “coupled” as used herein can include wireless connections or wireless coupling. The term “and / or” as used herein includes all or any units and all combinations of one or more associated listed items.

[0046] This application provides an SDK invocation method for mobile services in the field of cloud technology. This SDK invocation method involves multiple areas of cloud technology, such as cloud computing and cloud services.

[0047] Cloud computing is a computing model that distributes computing tasks across a large pool of computers, enabling various application systems to access computing power, storage space, and information services as needed. The network providing these resources is called the "cloud." From the user's perspective, resources in the "cloud" appear infinitely scalable, readily available, on-demand, and expandable, with payment based on usage.

[0048] As a provider of fundamental cloud computing capabilities, a cloud resource pool (referred to as a cloud platform, generally called an IaaS (Infrastructure as a Service) platform) is established. Various types of virtual resources are deployed in the resource pool for external customers to choose from. The cloud resource pool mainly includes: computing devices (virtualized machines containing operating systems), storage devices, and network devices.

[0049] Based on logical function, a PaaS (Platform as a Service) layer can be deployed on top of the IaaS (Infrastructure as a Service) layer, and a SaaS (Software as a Service) layer can be deployed on top of the PaaS layer. Alternatively, SaaS can be deployed directly on top of IaaS. PaaS is a platform for running software, such as databases and web containers. SaaS refers to various types of business software, such as web portals and bulk SMS senders. Generally speaking, SaaS and PaaS are upper layers compared to IaaS.

[0050] Artificial intelligence cloud services are generally also known as AIaaS (AI as a Service). This is currently a mainstream service model for artificial intelligence platforms. Specifically, AIaaS platforms break down several common AI services and provide them as independent or packaged services in the cloud. This service model is similar to opening an AI-themed marketplace: all developers can access and use one or more AI services provided by the platform through API interfaces. Some experienced developers can also use the AI ​​framework and AI infrastructure provided by the platform to deploy and maintain their own dedicated cloud AI services.

[0051] Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.

[0052] Artificial intelligence (AI) is a comprehensive discipline encompassing a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies primarily include computer vision, speech processing, natural language processing, as well as machine learning / deep learning, autonomous driving, and intelligent transportation.

[0053] To better understand and explain the solutions of the embodiments of this application, some technical terms involved in the embodiments of this application will be briefly explained below.

[0054] Reflection: Reflection refers to the ability of an app's code to obtain all the properties and methods of any class at runtime, and to call and modify all the properties and methods of any class or instance.

[0055] SDK: Generally, in software development, when a common function is involved, it is abstracted into an SDK. Examples include WeChat sharing, QQ / WeChat login, and WeChat Pay. After the SDK's functionality is expanded, new interfaces or properties will be generated. In some cases, these new interfaces and properties can be protected in the .m file, creating private interfaces or properties that cannot be directly called externally. If adding a new interface causes some older interfaces to no longer be maintained, the `@available` keyword is used to indicate their expiration.

[0056] Proxy: This refers to the proxy design pattern, in which one class represents the functionality of another class. This type of design pattern belongs to the structural pattern category. In the proxy pattern, a proxy object with an existing target object is created to provide a functional interface to the outside world. Problems arise when directly accessing the target object, such as when the target object is on a remote machine. In object-oriented systems, some target objects, for various reasons such as high object creation overhead, security controls required for certain operations, or out-of-process access, can cause many problems for users or the system architecture if accessed directly. Therefore, an access layer can be added when accessing this target object.

[0057] Feed Channel: Sellers can publish videos, images, etc., through the feed channel. Buyers who follow the store can then see this content in the feed channel, and the feed content will also be displayed on the store's homepage. The feed channel is displayed at the bottom of the app (application), in a very prominent position, making it a very important source of traffic.

[0058] The solutions provided in this application relate to cloud technology. The technical solutions of this application and how they solve the aforementioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.

[0059] The solution provided in this application can be applied to any application scenario in the cloud technology field that requires SDK calls. This solution provides reasonable protection for calls to at least one of the SDK's private interfaces and private attributes, or for calls to at least one of the SDK's public interfaces and public attributes, while reducing the call analysis cost for the caller. To better understand the solution provided in this application, a specific application scenario will be used to illustrate the solution below.

[0060] In one embodiment, Figure 1 The diagram shows a structural schematic of an SDK invocation system applicable to embodiments of this application. It is understood that the SDK invocation method provided in these embodiments can be applied to, but is not limited to, applications such as... Figure 1 In the application scenarios shown.

[0061] In this example, as Figure 1As shown, the SDK invocation system in this example may include, but is not limited to, SDK110, caller 120, and server 130. Server 130 can communicate with SDK110 and caller 120 via the network. When caller 120 initializes SDK110, it sends a request to server 130. Based on the request sent by caller 120, server 130 sends a protocol list to SDK110, which then receives the protocol list. In response to the call request to SDK110, caller 120 generates a protocol method and sends the protocol information corresponding to the protocol method to SDK110, instructing SDK110 to match the protocol information corresponding to the protocol method with the protocol information in the protocol list obtained by SDK110. When the protocol information corresponding to the protocol method matches the protocol list...

[0062] If the protocol information in the SDK matches each other, then the caller 120 can use the class object or instance of SDK 110.

[0063] An object that calls at least one of the SDK's public interfaces or public properties corresponding to the protocol information in the protocol list.

[0064] It is understood that the above is only one example, and this embodiment is not limited here.

[0065] Among them, SDK110 and caller 120 can be applications on the terminal, which can be smartphones (such as Android phones, iOS phones, etc.), tablets, laptops, digital broadcast receivers, MIDs (Mobile Internet Devices), PDAs (Personal Digital Assistants), desktop computers, in-vehicle terminals (such as in-vehicle navigation terminals), smart speakers, smartwatches, etc. Server 130 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server or server cluster that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The above-mentioned networks can include, but are not limited to, wired networks and wireless networks. The wired network includes local area networks (LANs), metropolitan area networks (MANs), and wide area networks (WANs), and the wireless network includes Bluetooth, Wi-Fi, and other networks that enable wireless communication. The specific details can also be determined based on the actual application scenario requirements and are not limited here.

[0066] See Figure 2 , Figure 2This illustration shows a flowchart of an SDK invocation method provided in an embodiment of this application. This method can be executed by any electronic device, such as a caller (i.e., a business entity). As an optional implementation, the method can be executed by the caller. For ease of description, in the following descriptions of some optional embodiments, the caller will be used as the subject executing the method. Figure 2 As shown, the SDK calling method provided in this application embodiment includes the following steps:

[0067] S101, in response to the SDK call request, generate a proxy object corresponding to the first object of the SDK, and send a notification message containing the identifier of the proxy object to the SDK to instruct the SDK to determine the attributes of the proxy object.

[0068] In one embodiment, the SDK is a basic capability built into a client application. For example, both video and WeChat applications have a "scan" function, which can be considered an SDK.

[0069] In one embodiment, the caller refers to the business entity that directly calls the SDK. For example, if the "scan" function is launched on the search page, the caller is the search function, and the "scan" function is the SDK. If the "scan" function is launched on the homepage, the caller is the homepage, and the "scan" function is the SDK. The caller can be a relatively independent function or the entire application.

[0070] In one embodiment, in response to an SDK call request, a proxy object corresponding to the first object of the SDK is generated, including:

[0071] When a caller makes a call to an interface of this SDK, the caller triggers the call request according to its own internal logic, and the caller responds to the call request, generating a proxy object corresponding to the first object of the SDK.

[0072] In one embodiment, the first object can be a television channel, and the attribute of the proxy object can be the feed channel.

[0073] In one embodiment, before generating a proxy object corresponding to the first object of the SDK in response to an SDK call request and sending a notification message containing the identifier of the proxy object to the SDK, the method further includes:

[0074] The caller initializes the first object of the SDK, which is either a class object or an instance object.

[0075] In one embodiment, the caller's initialization of the first SDK object will create the caller's current context.

[0076] S102, Based on the attributes of the proxy object received from the SDK, determine the configuration corresponding to the attributes of the proxy object.

[0077] In one embodiment, the attribute of the proxy object can be a feed channel, and correspondingly, the configuration of the attribute of the proxy object can be the specific content of the feed channel, such as long videos or short videos.

[0078] S103, based on the type and configuration of the attribute, invokes at least one of the SDK's private interfaces and private attributes via a proxy object using reflection.

[0079] In one embodiment, a private interface is an interface that cannot be directly accessed from the outside. SDK attributes can be divided into object attributes and class attributes. Object attributes describe the characteristic information of an object; for example, the characteristic information in a player module includes playback progress, status, buffering, and streaming media encoding format. The encoding format can be a private attribute of the SDK, while the others are public attributes. The SDK's private attributes reside in the .m file and cannot be directly accessed or modified externally; for example, when playing a streaming media file, the encoding format cannot be obtained or modified externally. Other public attributes of the SDK, such as playback progress, download data, and playback status (paused, resumed, stopped), can be obtained externally and accessed through API calls.

[0080] In one embodiment, based on the type and configuration of the attribute, at least one of the SDK's private interfaces and private attributes is invoked via a proxy object using reflection, including:

[0081] When the type of the attribute is not an empty object and the configuration meets the preset requirements, the proxy object is used to call at least one of the SDK's private interface and SDK's private attribute in a reflection manner, and the data for at least one of the SDK's private interface and SDK's private attribute returned by the SDK through the first function of the proxy object is received.

[0082] The first object is either a class object or an instance object.

[0083] In one embodiment, the caller generates a proxy object and notifies the SDK of the proxy object. The SDK determines the proxy object's attributes based on the target object corresponding to the proxy object, i.e., the SDK's class object or instance object. The caller then determines the configuration corresponding to the proxy object's attributes based on these attributes. Based on the type of the proxy object's attributes and the corresponding configuration, it is determined whether the call to at least one of the SDK's private interfaces or private attributes was successful. For example, if the type of the proxy object's attribute is not an empty object, and the configuration corresponding to the proxy object's attribute conforms to preset rules, then the call to at least one of the SDK's private interfaces or private attributes is successful.

[0084] In one embodiment, when the type of the attribute is an empty object, or the configuration does not meet the preset requirements, the first call exception data returned by the SDK through the first function of the proxy object is received.

[0085] In one embodiment, if the type of a proxy object's attribute is not an empty object, and the configuration corresponding to the proxy object's attribute does not conform to the preset rules, then calling at least one of the SDK's private interface or SDK's private attribute will fail. For example, the preset rule is that the configured parameter can only be 1, 2, or 3, but the caller, due to a logical error, sets the configuration corresponding to the proxy object's attribute to 4, indicating that the configuration corresponding to the proxy object's attribute does not conform to the preset rules. Similarly, if the type of a proxy object's attribute is an empty object, then calling at least one of the SDK's private interface or SDK's private attribute will fail.

[0086] In one embodiment, the first call exception data may be a call exception warning, logs including information about unsuccessful calls to the SDK's private interfaces or private properties. The first function may be a receiving function.

[0087] In one embodiment, the type of the proxy object's attribute is volume, and the corresponding configuration of the proxy object's attribute is length, width, and height. When the length, width, and height are not all empty objects, the SDK will not return a warning of call exception to the caller; when the volume is an empty object, the SDK returns a warning of call exception to the caller. The warning of call exception is used to indicate that the caller failed to call at least one of the SDK's private interface or SDK's private attribute.

[0088] In this embodiment, based on the type and configuration of the attribute, the caller uses a proxy object to implement reasonable protection for calls to at least one of the SDK's private interfaces and private attributes via reflection, while reducing the caller's call analysis cost.

[0089] See Figure 3 , Figure 3This illustration shows a flowchart of another SDK invocation method provided in an embodiment of this application. This method can be executed by any electronic device, such as the caller (i.e., the business entity). As an optional implementation, the method can be executed by the caller. For ease of description, in the following descriptions of some optional embodiments, the caller will be used as the execution subject of the method. Figure 3 As shown, the SDK calling method provided in this application embodiment includes the following steps:

[0090] S201, in response to an SDK call request, generates a protocol method and sends the protocol information corresponding to the protocol method to the SDK, instructing the SDK to match the protocol information with the protocol information in the SDK's protocol list.

[0091] In one embodiment, the protocol information in the SDK's protocol list includes the protocol name, interface name, interface function description, and first interface parameters. The protocol list is shown in Table 1.

[0092] Table 1 Protocol List

[0093]

[0094] As shown in Table 1, tel: / / \v1 is the protocol name, and the corresponding interface name is Phone, with the function of making a phone call. The first interface parameter is an int number. File: / / \v1\v2 is the protocol name, and the corresponding interface name is openFile, with the function of opening a file. The first interface parameters are String path and String name. Location: / / \v1\v2 is the protocol name, and the corresponding interface name is getLocation, with the function of obtaining location information, such as map location. The first interface parameters are doublelatitude and double longitude. scanCode: / / is the protocol name, and the corresponding interface name is scanQRCode, with the function of scanning a QR code. The first interface parameter is void.

[0095] In one embodiment, in response to an SDK call request, a protocol method is generated, including:

[0096] When a caller makes a call to an interface of this SDK, the caller triggers the call request according to its own internal logic, and the caller responds to the call request by generating a protocol method.

[0097] In one embodiment, before generating a protocol method in response to an SDK call request and sending the protocol information corresponding to the protocol method to the SDK, the method further includes:

[0098] The caller initializes a second object of the SDK, which is either a class object or an instance object.

[0099] S202, when the protocol information corresponding to the protocol method matches the protocol information in the protocol list, then at least one of the SDK's public interface and SDK's public properties corresponding to the protocol information in the protocol list is called through the second object of the SDK.

[0100] In one embodiment, the SDK has a built-in verification module. When the SDK determines through the verification module that the protocol information corresponding to the protocol method matches the protocol information in the protocol list, the caller can then use the second object of the SDK to call at least one of the SDK's public interfaces and public properties corresponding to the protocol information in the protocol list.

[0101] In one embodiment, when the protocol information corresponding to a protocol method matches the protocol information in the protocol list, at least one of the SDK's public interfaces and public properties is invoked through the SDK's second object, including:

[0102] When the protocol information corresponding to the protocol method includes the protocol name, interface name, interface function description, and first interface parameter, which respectively match the protocol information in the protocol list, then at least one of the SDK's public interfaces and public attributes is called through the SDK's second object, and the data for at least one of the SDK's public interfaces and public attributes is received from the SDK through the preset second function.

[0103] For example, as shown in Table 1, tel: / / \v1 is the protocol name, the corresponding interface name is Phone, the interface function description is making a phone call, and the first interface parameter is an int number. When the protocol information corresponding to the protocol method includes the protocol name, interface name, interface function description, and first interface parameter tel: / / \v1, Phone, making a phone call, and int number respectively, and the protocol information in the protocol list includes the protocol name, interface name, interface function description, and first interface parameter tel: / / \v1, Phone, making a phone call, and int number respectively, then the protocol information corresponding to the protocol method matches successfully with the protocol information in the protocol list. The caller, through the SDK's second object, invokes at least one of the SDK's public interfaces and public attributes, and receives data from the SDK returned by a preset second function for at least one of the SDK's public interfaces and public attributes. The second function can be an anonymous function.

[0104] In one embodiment, when the protocol information corresponding to the protocol method matches the protocol information in the protocol list, that is, when the protocol information corresponding to the protocol method matches the protocol information in the protocol list, the effective time of the interface call is set to the lifecycle of the calling object; wherein, the effective time of the interface call includes the time interval from the caller initiating the call to the calling object being destroyed, the calling object is the second object, and the interface call is the public interface call of the SDK.

[0105] In one embodiment, when at least one of the protocol name, interface name, interface function description, and first interface parameter included in the protocol information corresponding to the protocol method is different from the protocol information in the protocol list, the second interface parameter is determined according to the first interface parameter included in the protocol information corresponding to the protocol method and the preset parameter, so as to instruct the SDK to set the value of the second interface parameter to any one of the following: default value, empty string, first number, and empty object, according to the type of the second interface parameter.

[0106] Receive the second call exception data returned by the SDK through the preset second function. The second call exception data includes the value of the second interface parameter.

[0107] For example, as shown in Table 1, if the protocol name included in the protocol information corresponding to the protocol method is tel: / / , and the protocol names included in the protocol list are tel: / / \v1, File: / / \v1\v2, Location: / / \v1\v2, and scanCode: / / , respectively, and the protocol name included in the protocol information corresponding to the protocol method is different from the protocol name included in any of the protocol information in the protocol list, then the protocol information corresponding to the protocol method and the protocol information in the protocol list will not be matched.

[0108] In one embodiment, the second interface parameters are determined based on the first interface parameters included in the protocol information corresponding to the protocol method, and preset parameters, including:

[0109] The product of the first interface parameter and the preset parameter is used as the second interface parameter.

[0110] In one embodiment, the SDK sets the value of the second interface parameter to any one of the following based on the type of the second interface parameter: a default value, an empty string, a first numeric value, or an empty object, including:

[0111] If the type of the second interface parameter is an enumeration type, then the value of the second interface parameter will be set to the default value;

[0112] If the type of the second interface parameter is string, then the value of the second interface parameter will be set to an empty string;

[0113] If the type of the second interface parameter is numeric, then the value of the second interface parameter is set to the first numeric value, where the first numeric value can be 0;

[0114] If the type of the second interface parameter is an object, then the value of the second interface parameter is set to an empty object.

[0115] In this embodiment, in response to an SDK call request, the caller generates a protocol method and sends the protocol information corresponding to the protocol method to the SDK, instructing the SDK to match the protocol information with the protocol information in the SDK's protocol list. Thus, when the protocol information corresponding to the protocol method matches the protocol information in the protocol list, the caller, through the SDK's second object, calls at least one of the SDK's public interfaces and public attributes corresponding to the protocol information in the protocol list. This achieves reasonable protection for calls to at least one of the SDK's public interfaces and public attributes, while reducing the caller's call analysis cost.

[0116] To better understand the methods provided in the embodiments of this application, the solutions of the embodiments of this application will be further explained below with reference to specific application scenarios.

[0117] The SDK calling method provided in this application embodiment is applied to the mobile business field in cloud technology.

[0118] In one embodiment, when certain public SDKs are expanded, some interfaces are added. These interfaces are only allowed to be called by certain business units (schedulers). An enumeration value is added to the interface parameters for loading / refreshing the feed stream page. However, this enumeration value is only allowed when switching between multiple feed channel pages. Business units with only one feed channel are not allowed to call it. For example, the enumeration parameter named TMFFeedStreamRefreshingReason, when its value is ReasonChannelChanged, must be passed under specific conditions. Some newly added interfaces can be warned to business units by setting compiler properties to throw warnings. For example, the colorWithHexString function is deprecated and should be called using init:init(hexStr hex:String).

[0119] In one embodiment, the image download SDK adds a caching method parameter to the download interface. This parameter is an enumeration type, and the caching methods include disk caching, memory caching, archive caching, and database caching. The newly added caching parameter is database caching, but we do not want other departments to call the newly added caching parameter. Therefore, it is necessary to restrict or protect the newly added caching parameter.

[0120] In this embodiment, when the SDK interface undergoes parameter or functional expansion, it is determined whether the current interface modification can be protected by private attributes. For private interfaces or attributes, the caller needs to initialize the SDK's class object or instance object through reflection before making the call. If callback information exists, it is returned via a proxy. For public interfaces or attributes, a private protocol is defined with the caller. The server issues a list of private protocols during SDK initialization, and the caller passes parameters after detecting the protocol name. This achieves the protection of the underlying SDK's call security, preventing problems caused by calls from other business parties; and reduces the maintenance cost of the SDK interface through a unified calling mechanism.

[0121] See Figure 4 , Figure 4 This illustration shows a flowchart of another SDK invocation method provided in this application embodiment. This method can be executed by any electronic device, such as a caller (i.e., a business entity). As an optional implementation, the method can be executed by the caller. For ease of description, in the following descriptions of some optional embodiments, the caller will be used as the execution subject of the method. Figure 4As shown, the SDK calling method provided in this application embodiment includes the following steps:

[0122] S301, the caller initializes the SDK class object or instance object.

[0123] S302, the SDK provides properties for proxy objects.

[0124] In one embodiment, the caller generates a proxy object and notifies the SDK of the proxy object; the SDK determines the attributes of the proxy object based on the target object corresponding to the proxy object, i.e., the class object or instance object of the SDK; the caller then determines the configuration corresponding to the attributes of the proxy object based on the attributes of the proxy object.

[0125] S303, the caller accesses the SDK's private interfaces or private properties through reflection based on the proxy object.

[0126] S304, the SDK determines whether the type of the proxy object's attribute is an empty object; if the type of the proxy object's attribute is not an empty object, proceed to step S305; if the type of the proxy object's attribute is an empty object, proceed to step S306.

[0127] In one embodiment, based on the type of the proxy object's attribute and the configuration corresponding to the proxy object's attribute, the SDK determines whether the caller successfully calls at least one of the SDK's private interface and the SDK's private attribute. If it is determined that the caller successfully calls at least one of the SDK's private interface and the SDK's private attribute, the process proceeds to step S305. If it is determined that the caller unsuccessfully calls at least one of the SDK's private interface and the SDK's private attribute, the process proceeds to step S306.

[0128] In one embodiment, the SDK determines whether the type of the proxy object's attribute is an empty object. If it is an empty object, the SDK returns a warning of a call exception to the caller.

[0129] In one embodiment, a method for privately returning data is determined based on the proxy object's attributes and corresponding configurations. This method can be for verifying and returning data from a private interface or private attribute called by the caller. After the SDK completes its internal calculations, the data is returned to the caller via a private proxy method called through the proxy object. For example, if the login module calls OCR (Optical Character Recognition) to recognize a face, it needs to pass the user information (name, age) from the recognition result to the login module; the online account opening module needs to return the success or failure of the recognition result. When the proxy object's attribute type is an empty object, the SDK's calculation result will not be returned.

[0130] S305, the SDK executes internal functions to perform algorithmic and logical operations and generate results.

[0131] In one embodiment, the SDK's execution of internal functions for algorithmic and logical operations is a processing of the caller's access to private interfaces or properties. The result could be a carousel.

[0132] S306 logs the call stack and events to the SDK.

[0133] In one embodiment, the log includes information such as the caller's failure to call the SDK's private interface and at least one of the SDK's private properties.

[0134] S307, the SDK executes a private data return method, which uses reflection to call the receiving function of the proxy object, and then returns the generated result to the caller through the receiving function of the proxy object.

[0135] In this embodiment, the caller uses a proxy object to implement reasonable protection for calls to at least one of the SDK's private interfaces and private attributes via reflection, while reducing the caller's call analysis cost.

[0136] See Figure 5 , Figure 5 This illustration shows a flowchart of another SDK invocation method provided in this application embodiment. This method can be executed by any electronic device, such as a caller (i.e., a business entity). As an optional implementation, the method can be executed by the caller. For ease of description, in the following descriptions of some optional embodiments, the caller will be used as the execution subject of the method. Figure 5 As shown, the SDK calling method provided in this application embodiment includes the following steps:

[0137] S401, the caller initializes the SDK class object or instance object.

[0138] S402, the SDK obtains the list of protocols sent by the server.

[0139] In one embodiment, when the caller initializes the SDK, it sends a request to the server. Based on the request sent by the caller, the server sends a list of protocols to the SDK, and the SDK receives the list of protocols.

[0140] S403, the caller accesses the SDK's public interfaces or public properties through class objects or instance objects.

[0141] S404, the SDK detects whether the caller has implemented the protocol methods.

[0142] S405, the SDK obtains the protocol name corresponding to the protocol method and matches the protocol information corresponding to the protocol method with the protocol information in the SDK's protocol list; if the protocol information corresponding to the protocol method matches successfully with the protocol information in the protocol list, the effective time of the interface call is set to the lifecycle of the calling object, and step S406 is executed; if the protocol information corresponding to the protocol method does not match successfully with the protocol information in the protocol list, step S407 is executed.

[0143] In one embodiment, the protocol information corresponding to the protocol method includes the protocol name, interface name, interface function description, and first interface parameters. The effective time of the interface call includes the time interval from when the caller initiates the call to when the called object is destroyed. The called object is the second object, and the interface call is a public interface call of the SDK.

[0144] S406, the SDK executes internal functions to perform algorithmic and logical operations, then proceeds to step S408 for further processing.

[0145] In one embodiment, when the public interface or public property of the SDK is accessed, the current environment of the caller does not need to be considered. When the caller calls the protected public interface, accesses or reads / writes the protected public property, the SDK normally executes its internal functions to perform algorithmic and logical operations.

[0146] S407: When the parameters or properties passed to the SDK's calling interface are protected values, set the parameters or properties to their default values.

[0147] In one embodiment, if the caller fails to call the parameters of the public interface, the SDK sets the parameters of the public interface to their default values.

[0148] S408: When step S406 is executed, the result is generated after the internal logic of the SDK is completed; when step S407 is executed, the caller's behavior is written to the log.

[0149] In one embodiment, the generated result may be a preset TV series.

[0150] S409: When the caller requires the execution result, it is returned to the caller through an anonymous function. After the calling object is destroyed, the protocol's effective time is reset, and the protocol name is updated.

[0151] In one embodiment, the result could be playing a TV series.

[0152] In this embodiment of the application, when the protocol information corresponding to the protocol method matches the protocol information in the protocol list, the caller can call at least one of the public interfaces and public attributes of the SDK corresponding to the protocol information in the protocol list through the class object or instance object of the SDK. This achieves reasonable protection for the call to at least one of the public interfaces and public attributes of the SDK, while reducing the call analysis cost for the caller.

[0153] Based on the same inventive concept, this application also provides an SDK invocation device, the structural schematic diagram of which is shown below. Figure 6 As shown, the SDK calling device 40 includes a first processing module 401, a second processing module 402, and a third processing module 403.

[0154] The first processing module 401 is used to respond to the SDK call request, generate a proxy object corresponding to the first object of the SDK, and send a notification message containing the identifier of the proxy object to the SDK to instruct the SDK to determine the attributes of the proxy object.

[0155] The second processing module 402 is used to determine the configuration corresponding to the attributes of the proxy object based on the attributes received from the proxy object of the SDK;

[0156] The third processing module 403 is used to invoke at least one of the SDK's private interfaces and private properties via a proxy object using reflection, based on the type and configuration of the property.

[0157] In one embodiment, the third processing module 403 is specifically used for:

[0158] When the type of the attribute is not an empty object and the configuration meets the preset requirements, the proxy object is used to call at least one of the SDK's private interface and SDK's private attribute in a reflection manner, and the data for at least one of the SDK's private interface and SDK's private attribute returned by the SDK through the first function of the proxy object is received.

[0159] The first object is either a class object or an instance object.

[0160] In one embodiment, the third processing module 403 is further configured to:

[0161] If the type of the attribute is an empty object, or the configuration does not meet the preset requirements, the first call exception data returned by the SDK through the first function of the proxy object will be received.

[0162] Applying the embodiments of this application has at least the following beneficial effects:

[0163] In response to an SDK call request, the caller generates a proxy object corresponding to the first object of the SDK and sends a notification message containing the identifier of the proxy object to the SDK to instruct the SDK to determine the attributes of the proxy object. Based on the attributes of the proxy object received from the SDK, the caller determines the configuration corresponding to the attributes of the proxy object. In this way, based on the type and configuration of the attributes, the caller, through the proxy object, uses reflection to reasonably protect calls to at least one of the SDK's private interfaces and private attributes, while reducing the caller's call analysis cost.

[0164] Based on the same inventive concept, this application also provides another SDK invocation device, the structural schematic diagram of which is shown below. Figure 7 As shown, the SDK calling device 50 includes a fourth processing module 501 and a fifth processing module 502.

[0165] The fourth processing module 501 is used to generate a protocol method in response to an SDK call request, and send the protocol information corresponding to the protocol method to the SDK, so as to instruct the SDK to match the protocol information with the protocol information in the SDK's protocol list;

[0166] The fifth processing module 502 is used to call at least one of the public interfaces and public properties of the SDK corresponding to the protocol information in the protocol list when the protocol information corresponding to the protocol method matches each other.

[0167] In one embodiment, the fifth processing module 502 is specifically used for:

[0168] When the protocol information corresponding to the protocol method includes the protocol name, interface name, interface function description, and first interface parameter, which respectively match the protocol information in the protocol list, then at least one of the SDK's public interface and SDK's public attributes is called through the SDK's second object, and the data for at least one of the SDK's public interface and SDK's public attributes is received by the SDK through the preset second function.

[0169] The second object is a class object or an instance object.

[0170] In one embodiment, the fifth processing module 502 is further configured to:

[0171] If at least one of the protocol information, including the protocol name, interface name, interface function description, and first interface parameter, is different from the protocol information in the protocol list, then the second interface parameter is determined based on the first interface parameter and the preset parameter in the protocol information corresponding to the protocol method, so as to instruct the SDK to set the value of the second interface parameter to any one of the following: default value, empty string, first number, and empty object, according to the type of the second interface parameter.

[0172] Receive the second call exception data returned by the SDK through the preset second function. The second call exception data includes the value of the second interface parameter.

[0173] Applying the embodiments of this application has at least the following beneficial effects:

[0174] In response to an SDK call request, the caller generates a protocol method and sends the corresponding protocol information to the SDK, instructing the SDK to match the protocol information with the protocol information in the SDK's protocol list. Thus, when the protocol information corresponding to the protocol method matches the protocol information in the protocol list, the caller, through the SDK's second object, calls at least one of the SDK's public interfaces and public properties corresponding to the protocol information in the protocol list. This achieves reasonable protection for calls to at least one of the SDK's public interfaces and public properties, while reducing the caller's call analysis cost.

[0175] Based on the same inventive concept, this application also provides an electronic device, the structural schematic diagram of which is shown below. Figure 8 As shown, the electronic device 9000 includes at least one processor 9001, a memory 9002, and a bus 9003. The at least one processor 9001 is electrically connected to the memory 9002. The memory 9002 is configured to store at least one computer-executable instruction, and the processor 9001 is configured to execute the at least one computer-executable instruction to perform the steps of any SDK invocation method provided in any embodiment or optional implementation of this application.

[0176] Furthermore, the processor 9001 can be an FPGA (Field-Programmable Gate Array) or other devices with logic processing capabilities, such as an MCU (Microcontroller Unit) or a CPU (Central Processing Unit).

[0177] Applying the embodiments of this application has at least the following beneficial effects:

[0178] It achieves reasonable protection for calls to at least one of the SDK's private interfaces and private properties, or it achieves reasonable protection for calls to at least one of the SDK's public interfaces and public properties, while reducing the call analysis cost for the caller.

[0179] Based on the same inventive concept, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of calling any SDK provided in any embodiment or optional implementation of this application.

[0180] The computer-readable storage media provided in this application include, but are not limited to, any type of disk (including floppy disk, hard disk, optical disk, CD-ROM, and magneto-optical disk), ROM (Read-Only Memory), RAM (Random Access Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory, magnetic cards, or optical cards. In other words, readable storage media include any medium by which a device (e.g., a computer) stores or transmits information in a readable form.

[0181] Applying the embodiments of this application has at least the following beneficial effects:

[0182] It achieves reasonable protection for calls to at least one of the SDK's private interfaces and private properties, or it achieves reasonable protection for calls to at least one of the SDK's public interfaces and public properties, while reducing the call analysis cost for the caller.

[0183] This application also provides a computer program product containing instructions that, when run on a computer device, cause the computer device to execute the SDK invocation method provided in the above-described method embodiments.

[0184] Those skilled in the art will understand that each block in these structural diagrams and / or block diagrams and / or flow diagrams, as well as combinations of blocks in these structural diagrams and / or block diagrams and / or flow diagrams, can be implemented using computer programs. Those skilled in the art will also understand that these computer program products can be provided to a processor of a general-purpose computer, a professional-purpose computer, or other programmable data processing method for implementation, thereby executing the schemes specified in the blocks or plurality of blocks of the structural diagrams and / or block diagrams and / or flow diagrams disclosed in this application by the processor of the computer or other programmable data processing method.

[0185] Those skilled in the art will understand that the steps, measures, and solutions in the various operations, methods, and processes discussed in this application can be alternated, modified, combined, or deleted. Furthermore, other steps, measures, and solutions in the various operations, methods, and processes discussed in this application can also be alternated, modified, rearranged, decomposed, combined, or deleted. Furthermore, steps, measures, and solutions in the prior art that are similar to those disclosed in this application can also be alternated, modified, rearranged, decomposed, combined, or deleted.

[0186] The above description is only a partial embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A method for invoking a Software Development Kit (SDK), executed by a client on a terminal, characterized in that, include: In response to an SDK call request, a proxy object corresponding to the first object of the SDK is generated, and a notification message containing the identifier of the proxy object is sent to the SDK to instruct the SDK to determine the attributes of the proxy object. The SDK is built into the client, and the first object is a class object or an instance object. Based on the attributes of the proxy object received from the SDK, determine the configuration corresponding to the attributes of the proxy object; Based on the type of the attribute and the configuration, at least one of the SDK's private interfaces and private attributes is invoked via the proxy object using reflection.

2. The method according to claim 1, characterized in that, Based on the type of the attribute and the configuration, the method of invoking at least one of the SDK's private interfaces and private attributes via the proxy object using reflection includes: When the type of the attribute is not an empty object and the configuration conforms to the preset rules, the proxy object is used to call at least one of the SDK's private interface and the SDK's private attribute in a reflection manner, and the data of at least one of the SDK's private interface and the SDK's private attribute returned by the SDK through the first function of the proxy object is received.

3. The method according to claim 1 or 2, characterized in that, Also includes: If the type of the attribute is an empty object, or the configuration does not conform to the preset requirements, the first call exception data returned by the SDK through the first function of the proxy object is received.

4. An SDK invocation method, executed by a client on a terminal, characterized in that, include: In response to an SDK call request, a protocol method is generated, and the protocol information corresponding to the protocol method is sent to the SDK to instruct the SDK to match the protocol information with the protocol information in the SDK's protocol list. The SDK is built into the client. When the protocol information corresponding to the protocol method matches the protocol information in the protocol list, at least one of the public interfaces of the SDK and the public attributes of the SDK corresponding to the protocol information in the protocol list is called through the second object of the SDK. The second object is a class object or an instance object.

5. The method according to claim 4, characterized in that, When the protocol information corresponding to the protocol method matches the protocol information in the protocol list, at least one of the SDK's public interfaces and public attributes is invoked through the second object of the SDK, including: When the protocol information corresponding to the protocol method includes a protocol name, interface name, interface function description, and first interface parameter that match the protocol information in the protocol list one by one, then at least one of the SDK's public interface and public attributes is invoked through the second object of the SDK, and data for at least one of the SDK's public interface and public attributes is received from the SDK through a preset second function.

6. The method according to claim 4 or 5, characterized in that, Also includes: If at least one of the protocol name, interface name, interface function description, and first interface parameter included in the protocol information corresponding to the protocol method is different from the protocol information in the protocol list, then the second interface parameter is determined according to the first interface parameter included in the protocol information corresponding to the protocol method and the preset parameter, so as to instruct the SDK to set the value of the second interface parameter to any one of the following: default value, empty string, first number, and empty object, according to the type of the second interface parameter. The SDK receives second call exception data returned by a preset second function, and the second call exception data includes the value of the second interface parameter.

7. An SDK invocation device, applied to a client on a terminal, characterized in that, include: The first processing module is configured to respond to an SDK call request, generate a proxy object corresponding to a first object of the SDK, and send a notification message containing the identifier of the proxy object to the SDK to instruct the SDK to determine the attributes of the proxy object. The SDK is built into the client, and the first object is a class object or an instance object. The second processing module is used to determine the configuration corresponding to the attributes of the proxy object based on the attributes received from the proxy object of the SDK; The third processing module is used to invoke at least one of the SDK's private interfaces and the SDK's private attributes via the proxy object using reflection, based on the type of the attribute and the configuration.

8. An SDK invocation device, applied to a client on a terminal, characterized in that, include: The fourth processing module is used to generate a protocol method in response to an SDK call request, and send the protocol information corresponding to the protocol method to the SDK, so as to instruct the SDK to match the protocol information with the protocol information in the SDK's protocol list. The SDK is built into the client. The fifth processing module is used to call at least one of the public interfaces of the SDK and the public attributes of the SDK corresponding to the protocol information in the protocol list when the protocol information corresponding to the protocol method matches each other. The second object is a class object or an instance object.

9. An electronic device, characterized in that, include: Processor, memory; The memory is used to store computer programs; The processor is configured to execute the SDK invocation method as described in any one of claims 1-6 by invoking the computer program.

10. A computer-readable storage medium, characterized in that, The system stores a computer program that, when executed by a processor, implements the calling method of the SDK as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Remote procedure call processing method and device

    CN110399233A

  • Interface control method and device, readable medium and electronic equipment

    CN111400068A