WO2019071927A1 - Authorization information obtaining method and apparatus, electronic device, and readable storage medium - Google Patents

Authorization information obtaining method and apparatus, electronic device, and readable storage medium Download PDF

Info

Publication number
WO2019071927A1
WO2019071927A1 PCT/CN2018/081384 CN2018081384W WO2019071927A1 WO 2019071927 A1 WO2019071927 A1 WO 2019071927A1 CN 2018081384 W CN2018081384 W CN 2018081384W WO 2019071927 A1 WO2019071927 A1 WO 2019071927A1
Authority
WO
WIPO (PCT)
Prior art keywords
application
authorization
feedback data
code
protocol
Prior art date
Application number
PCT/CN2018/081384
Other languages
French (fr)
Chinese (zh)
Inventor
张磊
张文明
陈少杰
Original Assignee
武汉斗鱼网络科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 武汉斗鱼网络科技有限公司 filed Critical 武汉斗鱼网络科技有限公司
Publication of WO2019071927A1 publication Critical patent/WO2019071927A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/10Protecting distributed programs or content, e.g. vending or licensing of copyrighted material ; Digital rights management [DRM]
    • G06F21/12Protecting executable software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/52Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow

Definitions

  • a filter intent-filter may be added in the description file, and then a filtering method Action class is added in the filter, where the Action class is a bridge between the user request and the business logic.
  • Each Action acts as a business agent for the customer.
  • the Activity is an application component, which is used to provide a screen, which can be used to interact to complete a certain task, that is, when the system corresponding Action event corresponding to the application appears. At that time, you can start the application's startup page.
  • the implicit start method is combined with the startActivityforResult function to overcome the startActivityforResult function is limited to the same application.
  • the startActivityforResult function is a system-level function, and AIDL is only a service. Therefore, the startActivityforResult function has higher security performance than AIDL.
  • Step S104 When the second application acquires the unauthorized information before the second application is closed, generating authorization failure feedback data.
  • the generating module 203 is further configured to generate authorization failure feedback data when the second application does not obtain the authorization information before the second application is closed;
  • the generating module 203 is further configured to:
  • the setResult(RESULT_OK, intent) function is called to return the authorization feedback data, wherein RESULT_OK is an integer used to indicate that the result is successfully obtained.
  • the feedback data is the feedback data of the authorization success, and the RESULT_OK corresponds to a preset integer (such as 1); when the feedback data is the feedback data of the authorization failure, the RESULT_OK corresponds to a non-preset integer (such as 0); the intent represents an intent object.
  • the intent object includes a bundle object, and the bundle object is used to store the authorization code; wherein the authorization code is by calling putString(AUTH_CODE, code) in the bundler object Stored, where AUTH_CODE represents the key name of the authorization code, and code represents the value of the authorization code.
  • the parsing module 205 is configured to parse the authorization success feedback data to obtain the authorization code when the first application determines that the received authorization feedback data is authorization success feedback data.
  • the parsing module is specifically configured to:
  • the second obtaining module 206 is configured to obtain the description information corresponding to each of the applications, where the description information includes an application package name.
  • step S201 may be performed by the second obtaining module 206.
  • step S202 may be performed by the adding module 207.
  • each block of the block diagrams and/or flowcharts, and combinations of blocks in the block diagrams and/or flowcharts can be implemented in a dedicated hardware-based system that performs the specified function or action. Or it can be implemented by a combination of dedicated hardware and computer instructions.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Technology Law (AREA)
  • Stored Programmes (AREA)

Abstract

An authorization information obtaining method and apparatus, an electronic device, and a readable storage medium provided in the present application. The method comprises: a first application invokes, according to description information, a first protocol preset in the electronic device to implicitly open a start page predefined in a second application; when the second application obtains an authorization code before being closed, generate authorization feedback data according to the authorization code; and after the second application is closed, feed the authorization feedback data back to the first application by means of a second protocol, thereby enabling the first application to obtain authorization information of the second application. The function of allowing the second application to send the feedback data to the first application after the second application is started by the first protocol is skillfully applied, so that a coupling relationship between the applications is reduced, and the efficiency of communication between the applications is effectively improved. Furthermore, the first protocol is a system-level protocol with higher security.

Description

授权信息获取方法、装置、电子设备及可读存储介质Authorization information acquisition method, device, electronic device and readable storage medium
本申请要求于2017年10月09日提交中国专利局的申请号为201710928685.X名称为“授权信息获取方法、装置及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese Patent Application No. 201710928685.X entitled "Authorization Information Acquisition Method, Apparatus and Electronic Device" filed on October 09, 2017, the entire contents of which are incorporated herein by reference. In the application.
技术领域Technical field
本申请涉及计算机技术领域,具体而言,涉及一种授权信息获取方法、装置、电子设备及可读存储介质。The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, an electronic device, and a readable storage medium for obtaining authorization information.
背景技术Background technique
在实现不同应用程序之间进行交互之前,通常需要进行不同应用程序的授权登录。而授权登录本质上是在两个应用程序之间进行数据通信。现有技术中,两个应用程序之间进行通信的方式通常是通过采用安卓接口语言定义(Android Interface Definition Language,AIDL)的方式来实现。Authorized logins for different applications are usually required before interacting between different applications. Authorized login is essentially a data communication between two applications. In the prior art, the way to communicate between two applications is usually implemented by adopting the Android Interface Definition Language (AIDL).
但是,通过AIDL的方式进行进程间通信的方法存在如下缺陷:当AIDL发生变化时,两个应用程序均需要同时进行变更和升级AIDL文件,这样才能进行进程间通信。这导致两个应用程序之间的耦合关系过于紧密。一旦出现一方应用程序升级AIDL文件而另一方应用程序没有升级AIDL文件就会导致两个应用程序之间出现通信失败等异常情况。However, the method of inter-process communication by means of AIDL has the following drawbacks: When AIDL changes, both applications need to change and upgrade the AIDL file at the same time, so that inter-process communication can be performed. This causes the coupling relationship between the two applications to be too tight. Once a party application upgrades the AIDL file and the other application does not upgrade the AIDL file, it will cause an abnormal situation such as communication failure between the two applications.
发明内容Summary of the invention
本申请的目的在于提供一种授权信息获取方法、装置、电子设备及可读存储介质,用以改善上述问题。The purpose of the present application is to provide a method, an apparatus, an electronic device, and a readable storage medium for obtaining authorization information to improve the above problem.
为了实现上述目的,本申请实施例采用的技术方案如下:In order to achieve the above object, the technical solution adopted by the embodiment of the present application is as follows:
第一方面,本申请实施例提供了一种授权信息获取方法,应用于电子设备,所述电子设备内存储多个应用程序,所述方法包括:第一应用程序响应用户操作获取第二应用程序对应的描述信息;所述第一应用程序根据所述描述信息,调用所述电子设备内预先设置的第一协议,隐式打开所述第二应用程序中预先定义的启动页面,其中,所述第一协议用于实现启动与所述描述信息对应的应用程序进程并允许所述应用程序进程关闭后将反馈数据至所述第一应用程序,其中,所述反馈数据是所述第二应用程序启动页面启动之后生成的数据;当所述第二应用程序在所述第二应用程序关闭之前获取授权码时,根据所述授权码生成授权反馈数据,其中,所述反馈数据包括授权反馈数据;所述第二应用程序关闭后,通过预设置的第二协议将所述授权反馈数据反馈至所述第一应用程序,以使所述第一应用程 序获取第二应用程序的授权信息,其中,第二协议用于实现所述第二应用程序关闭后将所述反馈数据传递至允许接收所述反馈数据的应用程序。In a first aspect, the embodiment of the present application provides a method for acquiring authorization information, which is applied to an electronic device, where the plurality of applications are stored in the electronic device, where the method includes: the first application obtains the second application in response to the user operation. Corresponding description information; the first application invokes a first protocol preset in the electronic device according to the description information, and implicitly opens a predefined startup page in the second application, where the The first protocol is configured to implement an application process corresponding to the description information and allow the application process to be closed to feed back data to the first application, where the feedback data is the second application Generating data generated after the page is started; when the second application acquires the authorization code before the second application is closed, generating authorization feedback data according to the authorization code, wherein the feedback data includes authorization feedback data; After the second application is closed, the authorization feedback data is fed back to the device through a preset second protocol. a first application, so that the first application acquires authorization information of the second application, where the second protocol is used to implement the feedback of the feedback data after the second application is closed to allow the feedback to be received Data application.
第二方面,本申请实施例还提供了一种授权信息获取装置,应用于电子设备,所述电子设备内存储多个应用程序,所述装置包括:第一获取模块、启动模块、生成模块及反馈模块。其中,第一获取模块,用于第一应用程序响应用户操作获取第二应用程序对应的描述信息;启动模块,用于所述第一应用程序根据所述描述信息,调用所述电子设备内预先设置的第一协议,隐式打开所述第二应用程序中预先定义的启动页面,其中,所述第一协议用于实现启动与所述描述信息对应的应用程序进程并允许所述应用程序进程关闭后将反馈数据至所述第一应用程序,其中,所述反馈数据是所述第二应用程序启动页面启动之后生成的数据;生成模块,用于当所述第二应用程序在所述第二应用程序关闭之前获取授权码时,根据所述授权码生成授权反馈数据,其中,所述反馈数据包括授权反馈数据;反馈模块,用于所述第二应用程序关闭后,通过预设置的第二协议将所述授权反馈数据反馈至所述第一应用程序,以使所述第一应用程序获取第二应用程序的授权信息,其中,第二协议用于实现所述第二应用程序关闭后将所述反馈数据传递至允许接收所述反馈数据的应用程序。In a second aspect, the embodiment of the present application further provides an authorization information acquiring apparatus, which is applied to an electronic device, where the electronic device stores a plurality of application programs, where the device includes: a first acquiring module, a starting module, a generating module, and Feedback module. The first obtaining module is configured to: obtain, by the first application, the description information corresponding to the second application in response to the user operation; the startup module, configured to invoke, in the electronic device, the electronic device according to the description information Setting a first protocol, implicitly opening a predefined startup page in the second application, wherein the first protocol is used to implement launching an application process corresponding to the description information and allowing the application process After the closing, the data is fed back to the first application, wherein the feedback data is data generated after the second application launch page is started; and the generating module is configured to: when the second application is in the When the authorization code is obtained before the application is closed, the authorization feedback data is generated according to the authorization code, where the feedback data includes authorization feedback data, and the feedback module is configured to: after the second application is closed, pass the preset The second protocol feeds back the authorization feedback data to the first application, so that the first application acquires the second application Program authorization information, wherein the second protocol for implementing closed after the second application to the feedback data is transmitted to allow the feedback received application data.
第三方面,本申请实施例还提供了一种电子设备,所述电子设备包括:存储器;处理器;以及授权信息获取装置,所述授权信息获取装置存储于所述存储器中并包括一个或多个由所述处理器执行的软件功能模组,其包括:第一获取模块,用于第一应用程序响应用户操作获取第二应用程序对应的描述信息;启动模块,用于所述第一应用程序根据所述描述信息,调用所述电子设备内预先设置的第一协议,隐式打开所述第二应用程序中预先定义的启动页面,其中,所述第一协议用于实现启动与所述描述信息对应的应用程序进程并允许所述应用程序进程关闭后将反馈数据至所述第一应用程序,其中,所述反馈数据是所述第二应用程序启动页面启动之后生成的数据;生成模块,用于当所述第二应用程序在所述第二应用程序关闭之前获取授权码时,根据所述授权码生成授权反馈数据,其中,所述反馈数据包括授权反馈数据;反馈模块,用于所述第二应用程序关闭后,通过预设置的第二协议将所述授权反馈数据反馈至所述第一应用程序,以使所述第一应用程序获取第二应用程序的授权信息,其中,第二协议用于实现所述第二应用程序关闭后将所述反馈数据传递至允许接收所述反馈数据的 应用程序。In a third aspect, an embodiment of the present application further provides an electronic device, where the electronic device includes: a memory; a processor; and an authorization information acquiring device, where the authorization information acquiring device is stored in the memory and includes one or more a software function module executed by the processor, comprising: a first acquiring module, configured to acquire, by the first application, the description information corresponding to the second application in response to the user operation; and the startup module is configured to be used by the first application The program, according to the description information, invokes a first protocol preset in the electronic device, and implicitly opens a predefined startup page in the second application, where the first protocol is used to implement startup and the Describe the application process corresponding to the information and allow the application process to be closed to feed back data to the first application, wherein the feedback data is data generated after the second application launch page is started; generating module And when the second application acquires an authorization code before the second application is closed, according to the granting Code generation authorization feedback data, wherein the feedback data includes authorization feedback data; and a feedback module, after the second application is closed, feeding back the authorization feedback data to the first through a preset second protocol An application, so that the first application acquires authorization information of the second application, where the second protocol is configured to implement, after the second application is closed, the feedback data is delivered to the data that is allowed to receive the feedback data. application.
第四方面,本申请实施例还提供了一种可读存储介质,所述可读存储介质包括计算机程序,所述计算机程序运行时控制所述可读存储介质所在电子设备执行第一方面所述的授权信息获取方法。In a fourth aspect, the embodiment of the present application further provides a readable storage medium, where the readable storage medium includes a computer program, where the computer program controls the electronic device where the readable storage medium is located to perform the first aspect. The method of obtaining authorization information.
与现有技术相比,本申请提供的一种授权信息获取方法、装置、电子设备及可读存储介质。所述第一应用程序通过根据描述信息及第一协议,以隐式启动的方式打开第二应用程序。巧妙的应用了第一协议启动第二应用程序后,允许第二应用程序将反馈数据发送至第一应用程序的功能替代了现有技术中使用AIDL服务进行数据通信,进而降低了应用程序之间的耦合关系。有效的提升应用程序间通信的效率。同时,第一协议属于系统级别的协议,安全性更高、更可靠。Compared with the prior art, the present application provides an authorization information acquisition method, apparatus, electronic device, and readable storage medium. The first application opens the second application in an implicitly initiated manner according to the description information and the first protocol. After clever application of the first protocol to start the second application, the function of allowing the second application to send feedback data to the first application replaces the prior art using AIDL service for data communication, thereby reducing the application between Coupling relationship. Effectively improve the efficiency of communication between applications. At the same time, the first protocol is a system-level protocol, which is more secure and more reliable.
为使本申请的上述目的、特征和优点能更明显易懂,下文特举较佳实施例,并配合所附附图,作详细说明如下。The above described objects, features, and advantages of the present invention will become more apparent from the following description.
附图说明DRAWINGS
为了更清楚地说明本申请实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,应当理解,以下附图仅示出了本申请的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings to be used in the embodiments will be briefly described below. It should be understood that the following drawings show only certain embodiments of the present application, and therefore It should be seen as a limitation on the scope, and those skilled in the art can obtain other related drawings according to these drawings without any creative work.
图1示出了本申请实施例提供的电子设备的方框示意图。FIG. 1 is a block schematic diagram of an electronic device provided by an embodiment of the present application.
图2示出了本申请较佳实施例提供的授权信息获取方法的步骤流程图的一部分。FIG. 2 is a part of a flow chart showing the steps of the method for acquiring authorization information provided by the preferred embodiment of the present application.
图3示出了本申请较佳实施例提供的授权信息获取方法的步骤流程图的另一部分。FIG. 3 shows another part of the flow chart of the steps of the method for acquiring authorization information provided by the preferred embodiment of the present application.
图4示出了本申请较佳实施例提供的授权信息获取装置的示意图。FIG. 4 is a schematic diagram of an authorization information acquiring apparatus provided by a preferred embodiment of the present application.
图标:100-电子设备;101-存储器;102-存储控制器;103-处理器;200-授权信息获取装置;201-第一获取模块;202-启动模块;203-生成模块;204-反馈模块;205-解析模块;206-第二获取模块;207-添加模块。Icon: 100-electronic device; 101-memory; 102-storage controller; 103-processor; 200-authorization information acquisition device; 201-first acquisition module; 202-activation module; 203-generation module; 204-feedback module ; 205 - parsing module; 206 - second acquiring module; 207 - adding module.
具体实施方式Detailed ways
下面将结合本申请实施例中附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本申请实施例的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本 申请的实施例的详细描述并非旨在限制要求保护的本申请的范围,而是仅仅表示本申请的选定实施例。基于本申请的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application are clearly and completely described in the following with reference to the drawings in the embodiments of the present application. It is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. The components of the embodiments of the present application, which are generally described and illustrated in the figures herein, may be arranged and designed in various different configurations. The detailed description of the embodiments of the present application, which is set forth in the accompanying drawings, is not intended to limit the scope of the claims All other embodiments obtained by a person skilled in the art based on the embodiments of the present application without creative efforts are within the scope of the present application.
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。同时,在本申请的描述中,术语“第一”、“第二”等仅用于区分描述,而不能理解为指示或暗示相对重要性。It should be noted that similar reference numerals and letters indicate similar items in the following figures. Therefore, once an item is defined in one figure, it is not necessary to further define and explain it in the subsequent figures. Also, in the description of the present application, the terms "first", "second", and the like are used merely to distinguish a description, and are not to be construed as indicating or implying a relative importance.
请参照图1,图1示出了本申请实施例提供的电子设备100的方框示意图。电子设备100可以是,但不限于智能手机、平板电脑、膝上型便携计算机、车载电脑、个人数字助理(personal digital assistant,PDA)、穿戴式移动终端等等。所述电子设备100安装有iOS系统,其包括授权信息获取装置200、存储器101、存储控制器102及处理器103。Please refer to FIG. 1 , which is a block diagram of an electronic device 100 according to an embodiment of the present application. The electronic device 100 can be, but is not limited to, a smart phone, a tablet computer, a laptop portable computer, a car computer, a personal digital assistant (PDA), a wearable mobile terminal, and the like. The electronic device 100 is installed with an iOS system including an authorization information acquisition device 200, a memory 101, a storage controller 102, and a processor 103.
所述存储器101、存储控制器102及处理器103各元件相互之间直接或间接地电性连接,以实现数据的传输或交互。例如,这些元件相互之间可通过一条或多条通讯总线或信号线实现电性连接。所述授权信息获取装置200包括至少一个可以软件或固件(firmware)的形式存储于所述存储器101中或固化在所述电子设备100的操作系统(operating system,OS)中的软件功能模块或安装于电子设备100中的应用程序。所述处理器103用于执行存储器101中存储的可执行模块,例如所述授权信息获取装置200包括的软件功能模块或计算机程序。The components of the memory 101, the memory controller 102, and the processor 103 are electrically connected directly or indirectly to each other to implement data transmission or interaction. For example, the components can be electrically connected to one another via one or more communication buses or signal lines. The authorization information obtaining apparatus 200 includes at least one software function module or installation that can be stored in the memory 101 or is solidified in an operating system (OS) of the electronic device 100 in the form of software or firmware. An application in the electronic device 100. The processor 103 is configured to execute an executable module stored in the memory 101, such as a software function module or a computer program included in the authorization information acquiring device 200.
其中,存储器101可以是,但不限于,随机存取存储器(Random Access Memory,RAM),只读存储器(Read Only Memory,ROM),可编程只读存储器(Programmable Read-Only Memory,PROM),可擦除只读存储器(Erasable Programmable Read-Only Memory,EPROM),电可擦除只读存储器(Electric Erasable Programmable Read-Only Memory,EEPROM)等。其中,存储器101用于存储程序,所述处理器103在接收到执行指令后,执行所述程序,本申请任一实施例揭示的流程定义的服务器所执行的方法可以应用于处理器103中,或者由处理器103实现。The memory 101 may be, but not limited to, a random access memory (RAM), a read only memory (ROM), and a programmable read-only memory (PROM). Erasable Programmable Read-Only Memory (EPROM), Electric Erasable Programmable Read-Only Memory (EEPROM), and the like. The memory 101 is used to store a program, and the processor 103 executes the program after receiving the execution instruction. The method executed by the server defined by the process disclosed in any embodiment of the present application may be applied to the processor 103. Or implemented by the processor 103.
处理器103可以是一种集成电路芯片,具有信号处理能力。上述的处理器103可以是通用处理器,包括中央处理器(Central Processing Unit,CPU)、网络处理器(Network Processor,NP)、语音处理器以及视频处 理器等;还可以是数字信号处理器、专用集成电路、现场可编程门阵列或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器103也可以是任何常规的处理器103等。The processor 103 can be an integrated circuit chip with signal processing capabilities. The processor 103 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), a voice processor, a video processor, etc., and may also be a digital signal processor. ASIC, field programmable gate array or other programmable logic device, discrete gate or transistor logic device, discrete hardware component. The methods, steps, and logical block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general purpose processor may be a microprocessor or the processor 103 may be any conventional processor 103 or the like.
第一实施例First embodiment
请参考图2,图2示出了本申请较佳实施例提供的授权信息获取方法的流程图。所述授权信息获取方法应用于图1中的电子设备100,所述电子设备100中存储有多个应用程序,授权信息获取方法包括以下步骤:Please refer to FIG. 2. FIG. 2 is a flowchart of a method for acquiring authorization information provided by a preferred embodiment of the present application. The authorization information acquisition method is applied to the electronic device 100 in FIG. 1 . The electronic device 100 stores a plurality of applications, and the authorization information acquisition method includes the following steps:
步骤S201,获取每个所述应用程序对应的描述信息。Step S201: Obtain description information corresponding to each of the applications.
在本实施例中,所述描述信息与应用程序对应,以方便通过描述信息查找对应的应用程序。描述信息可以是对应用程序的功能进行描述的信息,例如,将检索作为浏览应用程序的描述信息;当然描述信息也可以是应用程序包名。本实施例中,以每个应用程序包名作为对应的应用程序的描述信息,其中,每个应用程序的包名在电子设备100中都是唯一的。In this embodiment, the description information corresponds to an application to facilitate searching for a corresponding application by using the description information. The description information may be information describing the function of the application, for example, the retrieval is used as the description information of the browsing application; of course, the description information may also be the application package name. In this embodiment, each application package name is used as the description information of the corresponding application, wherein the package name of each application is unique in the electronic device 100.
步骤S202,将所述描述信息添加入对应的所述应用程序的描述文件中。Step S202, adding the description information to a description file of the corresponding application.
在本实施例中,在每个应用程序中创建一个用于启动授权的启动页面。启动页面包括描述文件。将描述信息添加入对应的描述文件中。需要说明的是,描述文件可以是一个设置文件,实质是一个XML文件。In this embodiment, a launch page for launching an authorization is created in each application. The startup page includes a description file. Add the description information to the corresponding description file. It should be noted that the description file can be a setting file, which is essentially an XML file.
作为本实施例的一种实施方式,可以通过在描述文件中添加一个过滤器intent-filter,然后在该过滤器中添加过滤方法Action类,其中,Action类是用户请求和业务逻辑之间的桥梁,每个Action充当客户的一项业务代理。Action事件可以是<action android:name="com.xxx.xxx.getuserinfo">,其中com.xxx.xxx.getuserinfo为描述信息。当与该应用程序对应的过滤方法Action对应的Activity出现,其中,Activity是一个应用程序组件,用于提供一个屏幕,可以用来交互以完成某项任务,即当系统出现应用程序对应的Action事件的时候,就可以将该应用程序的启动页面进行启动。As an implementation manner of this embodiment, a filter intent-filter may be added in the description file, and then a filtering method Action class is added in the filter, where the Action class is a bridge between the user request and the business logic. Each Action acts as a business agent for the customer. The Action event can be <action android:name="com.xxx.xxx.getuserinfo">, where com.xxx.xxx.getuserinfo is the descriptive information. When the activity corresponding to the filtering method Action corresponding to the application appears, the Activity is an application component, which is used to provide a screen, which can be used to interact to complete a certain task, that is, when the system corresponding Action event corresponding to the application appears. At that time, you can start the application's startup page.
如图3所示,本实施例提供的授权信息获取方法还包括以下步骤:As shown in FIG. 3, the method for acquiring authorization information provided in this embodiment further includes the following steps:
步骤S101,第一应用程序响应用户操作获取第二应用程序对应的描述信息。Step S101: The first application acquires the description information corresponding to the second application in response to the user operation.
电子设备100中安装了多个应用程序,在第一应用程序运行过程中,响应用户操作获取第二应用程序的描述信息。在本实施例中,响应用户操 作获取第二应用程序的描述信息可以是的第二应用程序的包名。A plurality of applications are installed in the electronic device 100, and the description information of the second application is acquired in response to the user operation during the running of the first application. In this embodiment, the description of the second application may be the package name of the second application in response to the user operation.
步骤S102,所述第一应用程序根据所述描述信息,调用所述电子设备100内预先设置的第一协议,隐式打开所述第二应用程序中预先定义的启动页面。Step S102: The first application invokes a first protocol preset in the electronic device 100 according to the description information, and implicitly opens a preset startup page in the second application.
在本实施例中,所述第一协议用于实现启动与所述描述信息对应的应用程序进程并允许在所述应用程序进程关闭后将数据反馈至所述第一应用程序,其中,反馈的数据是所述第二应用程序的启动页面在启动之后生成的数据。可选地,所述第一协议可以包括startActivityforResult函数。在startActivityforResult函数中,以隐式启动的方式打开所述描述信息对应的第二应用程序的启动页面。In this embodiment, the first protocol is used to implement an application process corresponding to the description information and allow data to be fed back to the first application after the application process is closed, wherein the feedback is The data is data generated by the startup page of the second application after startup. Optionally, the first protocol may include a startActivityforResult function. In the startActivityforResult function, the startup page of the second application corresponding to the description information is opened in an implicitly started manner.
在本实施例中,为了使第二应用程序能够通过隐式启动的方式被启动,需要在第二应用程序中定义一个页面并在该页面的描述文件(比如,AndroidManifest.xml文件)中对需要隐式启动的页面定义一个隐式入口。具体地,通过添加一个过滤器intent-filter然后在该过滤器中添加过滤方法Action,其中,Action的具体内容可以是<action android:name="com.xxx.xxx.getuserinfo"/>,这样第二应用程序中的Activity就会过滤出自定义的这个action对象,当系统有该自定义的action对象的时候就可以对该页面进行启动。其中com.xxx.xxx.getuserinfo为应用的包名,因同一个系统中不可能存在包名相同的两个应用,这样就可以确保com.xxx.xxx.getuserinfo的唯一性。In this embodiment, in order to enable the second application to be launched by means of implicit startup, it is necessary to define a page in the second application and in the description file of the page (for example, AndroidManifest.xml file) An implicitly launched page defines an implicit entry. Specifically, by adding a filter intent-filter and then adding a filtering method Action in the filter, wherein the specific content of the Action can be <action android:name="com.xxx.xxx.getuserinfo"/>, such that The Activity in the application will filter out the custom action object. When the system has the custom action object, the page can be started. Where com.xxx.xxx.getuserinfo is the package name of the application. Since there are no two applications with the same package name in the same system, the uniqueness of com.xxx.xxx.getuserinfo can be ensured.
在本实施例中,intent类用于使两个Activity之间产生联系,具体地,intent类可以用于在一个Activity当中启动另外一个Activity;或使用intent在Activity之间的数据传输。In this embodiment, the intent class is used to make a relationship between the two activities. Specifically, the intent class can be used to start another Activity in an Activity; or use an intent to transfer data between activities.
作为本实施例的一种实施方式,在第一应用程序运行时,通过在Intent类中构造方法来得到Intent对象的实例,然后通过调用intent中的addAction(“com.xxx.xxx.getuserinfo”)方法给该Intent对象添加一个action事件,再通过调用intent.addAction("android.intent.action.VIEW"),添加Intent对象的动作描述,在本实施例中,动作描述为取得授权。通过上述两个步骤,实现打开action类为android.intent.getuserinfo的启动页面。然后在第一应用程序通过调用startActivityforResult(intent)方法来打开启动页面。需要说明的是,startActivityforResult函数通常只能应用于同一应用程序中各个进程之间的启动,在本实施例中,巧妙的利用隐式启动的方法结合 startActivityforResult函数,克服了startActivityforResult函数仅限于同一应用程序中的使用的局限性,同时,由于startActivityforResult函数可以使启动页面关闭后允许反馈数据进而实现了不借助AIDL依然能实现不同应用程序之间数据交互。且startActivityforResult函数属于系统级别的函数,而AIDL仅为服务,因此,startActivityforResult函数相较于AIDL而言安全性能更高。As an implementation manner of this embodiment, when the first application is running, an instance of the Intent object is obtained by constructing a method in the Intent class, and then by calling addAction ("com.xxx.xxx.getuserinfo") in the intent. The method adds an action event to the Intent object, and then adds an action description of the Intent object by calling intent.addAction("android.intent.action.VIEW"). In this embodiment, the action is described as obtaining authorization. Through the above two steps, the startup page of the action class android.intent.getuserinfo is opened. The startup page is then opened in the first application by calling the startActivityforResult(intent) method. It should be noted that the startActivityforResult function can only be applied to the startup between processes in the same application. In this embodiment, the implicit start method is combined with the startActivityforResult function to overcome the startActivityforResult function is limited to the same application. The limitation of the use in the middle, at the same time, because the startActivityforResult function can enable the feedback data after the startup page is closed, and thus realize the data interaction between different applications without using AIDL. And the startActivityforResult function is a system-level function, and AIDL is only a service. Therefore, the startActivityforResult function has higher security performance than AIDL.
步骤S103,当所述第二应用程序在所述第二应用程序关闭之前获取授权码时,根据所述授权码生成授权反馈数据,其中,所述反馈数据包括授权反馈数据。Step S103: When the second application acquires an authorization code before the second application is closed, generating authorization feedback data according to the authorization code, where the feedback data includes authorization feedback data.
在本实施例中,在第二应用程序的启动页面中响应用户的点击操作获取授权码。例如,用户点击第二应用程序的启动页面中的授权按钮,生成授权码。在所述第二应用程序的启动页面关闭之前,根据获取的授权码生成授权反馈数据。可选地,当所述第二应用程序在预定时间内获取到所述授权码时,根据所述授权码生成授权成功的反馈数据;当所述第二应用程序未在预定时间内获取到所述授权码时,根据所述授权码生成授权失败的反馈数据。In this embodiment, the authorization code is obtained in response to the user's click operation in the startup page of the second application. For example, the user clicks the authorization button in the launch page of the second application to generate an authorization code. Authorization feedback data is generated according to the obtained authorization code before the startup page of the second application is closed. Optionally, when the second application acquires the authorization code within a predetermined time, generating feedback data of authorization success according to the authorization code; when the second application does not acquire the location within a predetermined time When the authorization code is described, the feedback data of the authorization failure is generated according to the authorization code.
步骤S104,当所述第二应用程序在所述第二应用程序关闭之前获取到不授权信息时,生成授权失败反馈数据。Step S104: When the second application acquires the unauthorized information before the second application is closed, generating authorization failure feedback data.
在本实施例中,生成授权失败反馈数据且所述第二应用程序关闭后,通过预设置的第二协议将所述授权失败的反馈数据反馈至所述第一应用程序。需要说明的是,不授权信息可以是有用户在第二应用程序的启动页面中点击拒绝授权而生成的信息。In this embodiment, after the authorization failure feedback data is generated and the second application is closed, the feedback data of the authorization failure is fed back to the first application through a preset second protocol. It should be noted that the unauthorized information may be information generated by the user clicking the rejection authorization in the startup page of the second application.
步骤S105,所述第二应用程序关闭后,通过预设置的第二协议将所述授权反馈数据反馈至所述第一应用程序,以使所述第一应用程序获取第二应用程序的授权信息。Step S105, after the second application is closed, feeding back the authorization feedback data to the first application by using a preset second protocol, so that the first application acquires authorization information of the second application. .
在本实施例中,第二协议用于在所述第二应用程序关闭后将所述反馈数据传递至允许接收所述反馈数据的应用程序。可选地,第二协议可以采用setResult方法实现。In this embodiment, the second protocol is for transmitting the feedback data to an application that allows the feedback data to be received after the second application is closed. Alternatively, the second protocol can be implemented using the setResult method.
作为一种实施方式,调用setResult(RESULT_OK,intent)方法来将反馈数据进行返回。其中RESULT_OK是一个整数用于表示结果获取成功,当所述反馈数据为授权成功的反馈数据,则RESULT_OK为正常值;当反馈数据为授权失败的反馈数据,则RESULT_OK为异常。intent表示一个意图 对象,在该意图对象中封装需要回传的授权码。该意图对象中包含了一个bundle对象,bundle对象用于存储授权码。具体地,其中授权码是通过调用bundler中的putString(AUTH_CODE,code)方式进行存储的,其中AUTH_CODE表示的是授权码的键名称,code表示的是授权码的值。这样通过setResult方法设置后在该页面返回的时候系统会将该intent消息返回到第一应用程序中,从而就完成了第一应用程序和第二应用程序间的消息的传输。As an implementation, the setResult(RESULT_OK, intent) method is called to return the feedback data. RESULT_OK is an integer used to indicate that the result is successfully obtained. When the feedback data is feedback data of authorization success, RESULT_OK is a normal value; when the feedback data is feedback data of authorization failure, RESULT_OK is abnormal. The intent represents an intent object in which the authorization code that needs to be returned is encapsulated. The intent object contains a bundle object, and the bundle object is used to store the authorization code. Specifically, the authorization code is stored by calling putString(AUTH_CODE, code) in the bundler, where AUTH_CODE represents the key name of the authorization code, and code represents the value of the authorization code. After the setResult method is set, the system will return the intent message to the first application when the page returns, thereby completing the transmission of the message between the first application and the second application.
步骤S106,当所述第一应用程序判断接收到的授权反馈数据为授权成功的反馈数据时,对所述授权成功的反馈数据进行解析,以获取所述授权码。Step S106: When the first application determines that the received authorization feedback data is the feedback data of the authorization success, the feedback data of the authorization success is parsed to obtain the authorization code.
作为一种实施方式,可以在先检验第二应用程序通过setResult方法传递过来的信息中,RESULT_OK是否异常。当所述RESULT_OK异常时,判定本次授权失败,第一应用程序未获取第二应用程序的授权。当所述RESULT_OK正常时,第一应用程序对传递过来的intent对象进行解析,以获得授权码的内容。具体的解析过程是通过调用intent中的getBundle首先获取到bundle对象,然后在调用bundler对象中的getString(AUTH_CODE)方法来获取到授权码的内容,如此就可以完成授权码信息的获取。As an implementation manner, whether the RESULT_OK is abnormal in the information transmitted by the second application through the setResult method may be checked first. When the RESULT_OK is abnormal, it is determined that the current authorization fails, and the first application does not acquire the authorization of the second application. When the RESULT_OK is normal, the first application parses the passed intent object to obtain the content of the authorization code. The specific parsing process is to obtain the bundle object by calling the getBundle in the intent, and then get the content of the authorization code by calling the getString(AUTH_CODE) method in the bundler object, so that the authorization code information can be obtained.
第二实施例Second embodiment
请参考图4,图4为本申请较佳实施例提供的授权信息获取装置200的示意图。授权信息获取装置200包括第一获取模块201、启动模块202、生成模块203、反馈模块204、解析模块205、第二获取模块206及添加模块207。Please refer to FIG. 4. FIG. 4 is a schematic diagram of an authorization information acquiring apparatus 200 according to a preferred embodiment of the present application. The authorization information obtaining apparatus 200 includes a first obtaining module 201, a starting module 202, a generating module 203, a feedback module 204, a parsing module 205, a second obtaining module 206, and an adding module 207.
第一获取模块201,用于第一应用程序响应用户操作获取第二应用程序对应的描述信息。The first obtaining module 201 is configured to obtain, by the first application, the description information corresponding to the second application in response to the user operation.
在本申请实施例中,步骤S101可以由第一获取模块201执行。In the embodiment of the present application, step S101 may be performed by the first obtaining module 201.
启动模块202,用于所述第一应用程序根据所述描述信息,调用所述电子设备100内预先设置的第一协议,隐式打开所述第二应用程序中预先定义的启动页面,其中,所述第一协议用于实现启动与所述描述信息对应的应用程序进程并允许所述应用程序进程关闭后将反馈数据至所述第一应用程序,所述反馈数据是所述第二应用程序启动页面启动之后生成的数据。The startup module 202 is configured to invoke the first protocol preset in the electronic device 100 according to the description information, and implicitly open a preset startup page in the second application, where The first protocol is configured to implement an application process corresponding to the description information and allow the application process to be closed to feed back data to the first application, where the feedback data is the second application Starts the data generated after the page is started.
在本申请实施例中,步骤S102可以由启动模块202执行。In the embodiment of the present application, step S102 may be performed by the startup module 202.
生成模块203,用于当所述第二应用程序在所述第二应用程序关闭之 前获取授权码时,根据所述授权码生成授权反馈数据,其中,所述反馈数据包括授权反馈数据。及还用于当所述第二应用程序在所述第二应用程序关闭之前获取到不授权信息时,生成授权失败反馈数据。The generating module 203 is configured to generate authorization feedback data according to the authorization code when the second application acquires an authorization code before the second application is closed, wherein the feedback data includes authorization feedback data. And being further configured to generate authorization failure feedback data when the second application acquires the unauthorized information before the second application is closed.
在本实施例中,所述生成模块具体用于:In this embodiment, the generating module is specifically configured to:
当所述第二应用程序在预定时间内获取到所述授权码时,根据所述授权码生成授权成功的反馈数据;When the second application acquires the authorization code within a predetermined time, generating feedback data of authorization success according to the authorization code;
当所述第二应用程序未在预定时间内获取到所述授权码时,根据所述授权码生成授权失败的反馈数据。When the second application does not acquire the authorization code within a predetermined time, the feedback data of the authorization failure is generated according to the authorization code.
反馈模块204,用于所述第二应用程序关闭后,通过预设置的第二协议将所述授权反馈数据反馈至所述第一应用程序,以使所述第一应用程序获取第二应用程序的授权信息,其中,第二协议用于实现所述第二应用程序关闭后将所述反馈数据传递至允许接收所述反馈数据的应用程序。a feedback module 204, after the second application is closed, feeding back the authorization feedback data to the first application by using a preset second protocol, so that the first application acquires the second application The authorization information, wherein the second protocol is used to implement the feedback of the feedback data to the application that allows the feedback data to be received after the second application is closed.
在本实施例中,所述生成模块203,还用于在所述第二应用程序在所述第二应用程序关闭之前获取不到授权信息时,生成授权失败反馈数据;In this embodiment, the generating module 203 is further configured to generate authorization failure feedback data when the second application does not obtain the authorization information before the second application is closed;
所述反馈模块204,还用于在所述第二应用程序关闭后,通过预设置的第二协议将所述授权失败的反馈数据反馈至所述第一应用程序。The feedback module 204 is further configured to feed back the feedback data of the authorization failure to the first application by using a preset second protocol after the second application is closed.
所述生成模块203进一步用于:The generating module 203 is further configured to:
在所述第二应用程序在所述第二应用程序关闭之前获取授权码时,调用setResult(RESULT_OK,intent)函数将授权反馈数据进行返回,其中,RESULT_OK是一个整数用于表示结果获取成功,当所述反馈数据为授权成功的反馈数据,则RESULT_OK对应一预设整数(比如1);当反馈数据为授权失败的反馈数据,则RESULT_OK对应非预设整数(比如0);intent表示一个意图对象,在该意图对象中封装需要回传的授权码;该意图对象中包含了一个bundle对象,bundle对象用于存储授权码;其中,授权码是通过调用bundler对象中的putString(AUTH_CODE,code)方式进行存储的,其中AUTH_CODE表示的是授权码的键名称,code表示的是授权码的值。When the second application acquires the authorization code before the second application is closed, the setResult(RESULT_OK, intent) function is called to return the authorization feedback data, wherein RESULT_OK is an integer used to indicate that the result is successfully obtained. The feedback data is the feedback data of the authorization success, and the RESULT_OK corresponds to a preset integer (such as 1); when the feedback data is the feedback data of the authorization failure, the RESULT_OK corresponds to a non-preset integer (such as 0); the intent represents an intent object. Encapsulating an authorization code that needs to be returned in the intent object; the intent object includes a bundle object, and the bundle object is used to store the authorization code; wherein the authorization code is by calling putString(AUTH_CODE, code) in the bundler object Stored, where AUTH_CODE represents the key name of the authorization code, and code represents the value of the authorization code.
在本申请实施例中,步骤S103及步骤S104均可以由生成模块203执行,步骤S105可以由反馈模块204执行。In the embodiment of the present application, both step S103 and step S104 may be performed by the generating module 203, and the step S105 may be performed by the feedback module 204.
解析模块205,用于当所述第一应用程序判断接收到的授权反馈数据为授权成功反馈数据时,对所述授权成功反馈数据进行解析,以获取所述授权码。The parsing module 205 is configured to parse the authorization success feedback data to obtain the authorization code when the first application determines that the received authorization feedback data is authorization success feedback data.
所述解析模块具体用于:The parsing module is specifically configured to:
调用intent对象中的getBundle函数,获得Bundle对象;Call the getBundle function in the intent object to get the Bundle object.
调用Bundle对象中的getString(AUTH_CODE)函数获得所述授权码。The authorization code is obtained by calling the getString(AUTH_CODE) function in the Bundle object.
在本申请实施例中,步骤S106可以由解析模块205执行。In the embodiment of the present application, step S106 may be performed by the parsing module 205.
第二获取模块206,用于获取每个所述应用程序对应的所述描述信息,其中,所述描述信息包括应用程序包名。The second obtaining module 206 is configured to obtain the description information corresponding to each of the applications, where the description information includes an application package name.
在本申请实施例中,步骤S201可以由第二获取模块206执行。In the embodiment of the present application, step S201 may be performed by the second obtaining module 206.
添加模块207,用于将所述描述信息添加入对应的所述应用程序的描述文件中。The adding module 207 is configured to add the description information into a description file of the corresponding application.
在本申请实施例中,步骤S202可以由添加模块207执行。In the embodiment of the present application, step S202 may be performed by the adding module 207.
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,也可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,附图中的流程图和框图显示了根据本申请的多个实施例的装置、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或代码的一部分,所述模块、程序段或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现方式中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may also be implemented in other manners. The apparatus embodiments described above are merely illustrative, for example, the flowcharts and block diagrams in the figures illustrate the architecture, functionality, and functionality of possible implementations of apparatus, methods, and computer program products according to various embodiments of the present application. operating. In this regard, each block of the flowchart or block diagram can represent a module, a program segment, or a portion of code that includes one or more of the Executable instructions. It should also be noted that, in some alternative implementations, the functions noted in the blocks may also occur in a different order than those illustrated in the drawings. For example, two consecutive blocks may be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending upon the functionality involved. It is also noted that each block of the block diagrams and/or flowcharts, and combinations of blocks in the block diagrams and/or flowcharts, can be implemented in a dedicated hardware-based system that performs the specified function or action. Or it can be implemented by a combination of dedicated hardware and computer instructions.
另外,在本申请各个实施例中的各功能模块可以集成在一起形成一个独立的部分,也可以是各个模块单独存在,也可以两个或两个以上模块集成形成一个独立的部分。In addition, each functional module in each embodiment of the present application may be integrated to form a separate part, or each module may exist separately, or two or more modules may be integrated to form a separate part.
所述功能如果以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或 者光盘等各种可以存储程序代码的介质。The functions, if implemented in the form of software functional modules and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application, which is essential or contributes to the prior art, or a part of the technical solution, may be embodied in the form of a software product, which is stored in a storage medium, including The instructions are used to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like. .
需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that, in this context, relational terms such as first and second are used merely to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply these entities or operations. There is any such actual relationship or order between them. Furthermore, the term "comprises" or "comprises" or "comprises" or any other variations thereof is intended to encompass a non-exclusive inclusion, such that a process, method, article, or device that comprises a plurality of elements includes not only those elements but also Other elements, or elements that are inherent to such a process, method, item, or device. An element that is defined by the phrase "comprising a ..." does not exclude the presence of additional equivalent elements in the process, method, item, or device that comprises the element.
以上所述仅为本申请的优选实施例而已,并不用于限制本申请,对于本领域的技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。The above description is only the preferred embodiment of the present application, and is not intended to limit the present application, and various changes and modifications may be made to the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this application are intended to be included within the scope of the present application. It should be noted that similar reference numerals and letters indicate similar items in the following figures. Therefore, once an item is defined in one figure, it is not necessary to further define and explain it in the subsequent figures.
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应所述以权利要求的保护范围为准。The foregoing is only a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto, and any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present application. It should be covered by the scope of protection of this application. Therefore, the scope of protection of the present application should be determined by the scope of the claims.
工业实用性Industrial applicability
本申请提供的一种授权信息获取方法、装置、电子设备及可读存储介质,巧妙的应用了第一协议启动第二应用程序后,允许第二应用程序将反馈数据发送至第一应用程序的功能替代了现有技术中使用AIDL服务进行数据通信,进而降低了应用程序之间的耦合关系。有效的提升应用程序间通信的效率。同时,第一协议属于系统级别的协议,安全性更高、更可靠。The method for acquiring authorization information, the electronic device, and the readable storage medium provided by the application, after the first protocol is started, the second application is allowed to send the feedback data to the first application. The function replaces the prior art using AIDL services for data communication, thereby reducing the coupling relationship between applications. Effectively improve the efficiency of communication between applications. At the same time, the first protocol is a system-level protocol, which is more secure and more reliable.

Claims (18)

  1. 一种授权信息获取方法,其特征在于,应用于电子设备,所述电子设备内存储多个应用程序,所述方法包括:A method for acquiring authorization information, which is characterized in that it is applied to an electronic device, and the electronic device stores a plurality of applications, and the method includes:
    第一应用程序响应用户操作获取第二应用程序对应的描述信息;The first application obtains the description information corresponding to the second application in response to the user operation;
    所述第一应用程序根据所述描述信息,调用所述电子设备内预先设置的第一协议,隐式打开所述第二应用程序中预先定义的启动页面,其中,所述第一协议用于实现启动与所述描述信息对应的应用程序进程并允许所述应用程序进程关闭后将反馈数据至所述第一应用程序,所述反馈数据是所述第二应用程序启动页面启动之后生成的数据;The first application, according to the description information, invokes a first protocol preset in the electronic device, and implicitly opens a predefined startup page in the second application, where the first protocol is used for Implementing an application process corresponding to the description information and allowing the application process to close, and then feeding back data to the first application, the feedback data being data generated after the second application startup page is started ;
    当所述第二应用程序在所述第二应用程序关闭之前获取授权码时,根据所述授权码生成授权反馈数据,其中,所述反馈数据包括授权反馈数据;And when the second application acquires the authorization code before the second application is closed, generating authorization feedback data according to the authorization code, where the feedback data includes authorization feedback data;
    所述第二应用程序关闭后,通过预设置的第二协议将所述授权反馈数据反馈至所述第一应用程序,以使所述第一应用程序获取第二应用程序的授权信息,其中,第二协议用于在所述第二应用程序关闭后将所述反馈数据传递至允许接收所述反馈数据的应用程序。After the second application is closed, the authorization feedback data is fed back to the first application by using a preset second protocol, so that the first application acquires authorization information of the second application, where The second protocol is for transmitting the feedback data to an application that allows the feedback data to be received after the second application is closed.
  2. 如权利要求1所述的方法,其特征在于,所述启动页面包括描述文件,所述方法还包括:The method of claim 1, wherein the startup page comprises a description file, the method further comprising:
    获取每个所述应用程序对应的所述描述信息,其中,所述描述信息包括应用程序包名;Obtaining the description information corresponding to each of the applications, where the description information includes an application package name;
    将所述描述信息添加入对应的所述应用程序的描述文件中。The description information is added to the corresponding description file of the application.
  3. 如权利要求1所述的方法,其特征在于,当所述第二应用程序在所述第二应用程序关闭之前获取授权码时,根据所述授权码生成授权反馈数据的步骤包括:The method according to claim 1, wherein when the second application acquires an authorization code before the second application is closed, the step of generating authorization feedback data according to the authorization code comprises:
    当所述第二应用程序在预定时间内获取到所述授权码时,根据所述授权码生成授权成功的反馈数据;When the second application acquires the authorization code within a predetermined time, generating feedback data of authorization success according to the authorization code;
    当所述第二应用程序未在预定时间内获取到所述授权码时,根据所述授权码生成授权失败的反馈数据。When the second application does not acquire the authorization code within a predetermined time, the feedback data of the authorization failure is generated according to the authorization code.
  4. 如权利要求3所述的方法,其特征在于,所述方法还包括:The method of claim 3, wherein the method further comprises:
    在所述第二应用程序在所述第二应用程序关闭之前获取不到授权信息时,生成授权失败反馈数据;Generating authorization failure feedback data when the second application fails to obtain authorization information before the second application is closed;
    在所述第二应用程序关闭后,通过预设置的第二协议将所述授权失败的反馈数据反馈至所述第一应用程序。After the second application is closed, the feedback data of the authorization failure is fed back to the first application through a preset second protocol.
  5. 如权利要求3所述的方法,其特征在于,当所述第二应用程序在所述第二应用程序关闭之前获取授权码时,根据所述授权码生成授权反馈数据的步骤包括:The method according to claim 3, wherein when the second application acquires an authorization code before the second application is closed, the step of generating authorization feedback data according to the authorization code comprises:
    所述第二应用程序在所述第二应用程序关闭之前获取授权码时,调用setResult(RESULT_OK,intent)函数将授权反馈数据进行返回,其中,RESULT_OK是一个整数用于表示结果获取成功,当所述反馈数据为授权成功的反馈数据,则RESULT_OK对应一预设整数;当反馈数据为授权失败的反馈数据,则RESULT_OK对应非预设整数;intent表示一个意图对象,在该意图对象中封装需要回传的授权码;该意图对象中包含了一个bundle对象,bundle对象用于存储授权码;其中,授权码是通过调用bundler对象中的putString(AUTH_CODE,code)方式进行存储的,其中AUTH_CODE表示的是授权码的键名称,code表示的是授权码的值。The second application calls the setResult(RESULT_OK, intent) function to return the authorization feedback data when the authorization code is obtained before the second application is closed, wherein RESULT_OK is an integer used to indicate that the result is successfully obtained. The feedback data is the feedback data of the authorization success, and the RESULT_OK corresponds to a preset integer; when the feedback data is the feedback data of the authorization failure, the RESULT_OK corresponds to the non-preset integer; the intent represents an intent object, and the encapsulation needs to be returned in the intent object. The authorization code passed; the intent object contains a bundle object, and the bundle object is used to store the authorization code; wherein the authorization code is stored by calling putString(AUTH_CODE, code) in the bundler object, where AUTH_CODE indicates The key name of the authorization code, code indicates the value of the authorization code.
  6. 如权利要求5所述的方法,其特征在于,所述方法还包括:The method of claim 5, wherein the method further comprises:
    当所述第一应用程序判断接收到的授权反馈数据为授权成功反馈数据时,对所述授权成功反馈数据进行解析,以获取所述授权码。And when the first application determines that the received authorization feedback data is the authorization success feedback data, parsing the authorization success feedback data to obtain the authorization code.
  7. 如权利要求6所述的方法,其特征在于,所述对所述授权成功反馈数据进行解析,以获取所述授权码的步骤包括:The method of claim 6, wherein the step of parsing the authorization success feedback data to obtain the authorization code comprises:
    调用intent对象中的getBundle函数,获得Bundle对象;Call the getBundle function in the intent object to get the Bundle object.
    调用Bundle对象中的getString(AUTH_CODE)函数获得所述授权码。The authorization code is obtained by calling the getString(AUTH_CODE) function in the Bundle object.
  8. 如权利要求1-7任一项所述的方法,其特征在于,所述第一协议包括startActivityforResult函数。The method of any of claims 1-7, wherein the first protocol comprises a startActivityforResult function.
  9. 如权利要求1-7任一项所述的方法,其特征在于,所述第二协议包括setResult函数。The method of any of claims 1-7, wherein the second protocol comprises a setResult function.
  10. 一种授权信息获取装置,其特征在于,应用于电子设备,所述电子设备内存储多个应用程序,所述装置包括:An authorization information acquisition device is characterized in that it is applied to an electronic device, and the electronic device stores a plurality of application programs, and the device includes:
    第一获取模块,配置成第一应用程序响应用户操作获取第二应用程序对应的描述信息;a first acquiring module, configured to: the first application, in response to the user operation, obtain description information corresponding to the second application;
    启动模块,配置成所述第一应用程序根据所述描述信息,调用所述电子设备内预先设置的第一协议,隐式打开所述第二应用程序中预先定义的启动页面,其中,所述第一协议用于实现启动与所述描述信息对应的应用程序进程并允许所述应用程序进程关闭后将反馈数据至所述第一应用程序,所述反馈数据是所述第二应用程序启动页面启动之后生成的数据;a startup module, configured to: the first application invokes a first protocol preset in the electronic device according to the description information, and implicitly opens a predefined startup page in the second application, where The first protocol is configured to implement an application process corresponding to the description information and allow the application process to be closed to feed back data to the first application, the feedback data being the second application startup page Data generated after startup;
    生成模块,配置成当所述第二应用程序在所述第二应用程序关闭之前获取授权码时,根据所述授权码生成授权反馈数据,其中,所述反馈数据包括授权反馈数据;a generating module, configured to generate authorization feedback data according to the authorization code when the second application acquires an authorization code before the second application is closed, where the feedback data includes authorization feedback data;
    反馈模块,配置成所述第二应用程序关闭后,通过预设置的第二协议将所述授权反馈数据反馈至所述第一应用程序,以使所述第一应用程序获取第二应用程序的授权信息,其中,第二协议用于在所述第二应用程序关闭后将所述反馈数据传递至允许接收所述反馈数据的应用程序。a feedback module, configured to: after the second application is closed, feed back the authorization feedback data to the first application by using a preset second protocol, so that the first application acquires the second application Authorization information, wherein the second protocol is for transmitting the feedback data to an application that allows the feedback data to be received after the second application is closed.
  11. 如权利要求10所述的装置,其特征在于,所述启动页面包括描述文件,所述装置还包括:The device of claim 10, wherein the activation page comprises a description file, the device further comprising:
    第二获取模块,配置成获取每个所述应用程序对应的所述描述信息,其中,所述描述信息包括应用程序包名;a second obtaining module, configured to obtain the description information corresponding to each of the applications, where the description information includes an application package name;
    添加模块,配置成将所述描述信息添加入对应的所述应用程序的描述文件中。And adding a module configured to add the description information to a description file of the corresponding application.
  12. 如权利要求10所述的装置,其特征在于,所述生成模块具体被配置成:The device according to claim 10, wherein the generating module is specifically configured to:
    当所述第二应用程序在预定时间内获取到所述授权码时,根据所述授权码生成授权成功的反馈数据;When the second application acquires the authorization code within a predetermined time, generating feedback data of authorization success according to the authorization code;
    当所述第二应用程序未在预定时间内获取到所述授权码时,根据所述授权码生成授权失败的反馈数据。When the second application does not acquire the authorization code within a predetermined time, the feedback data of the authorization failure is generated according to the authorization code.
  13. 如权利要求12所述的装置,其特征在于:The device of claim 12 wherein:
    所述生成模块,还配置成在所述第二应用程序在所述第二应用程序关闭之前获取不到授权信息时,生成授权失败反馈数据;The generating module is further configured to generate authorization failure feedback data when the second application fails to obtain authorization information before the second application is closed;
    所述反馈模块,还配置成在所述第二应用程序关闭后,通过预设置的第二协议将所述授权失败的反馈数据反馈至所述第一应用程序。The feedback module is further configured to feed back the feedback data of the authorization failure to the first application by using a preset second protocol after the second application is closed.
  14. 如权利要求12所述的装置,其特征在于,所述生成模块进一步配置成:The apparatus of claim 12 wherein said generating module is further configured to:
    所述第二应用程序在所述第二应用程序关闭之前获取授权码时,调用setResult(RESULT_OK,intent)函数将授权反馈数据进行返回,其中,RESULT_OK是一个整数用于表示结果获取成功,当所述反馈数据为授权成功的反馈数据,则RESULT_OK对应一预设整数;当反馈数据为授权失败的反馈数据,则RESULT_OK对应非预设整数;intent表示一个意图对象,在该意图对象中封装需要回传的授权码;该意图对象中包含了一个bundle 对象,bundle对象用于存储授权码;其中,授权码是通过调用bundler对象中的putString(AUTH_CODE,code)方式进行存储的,其中AUTH_CODE表示的是授权码的键名称,code表示的是授权码的值。The second application calls the setResult(RESULT_OK, intent) function to return the authorization feedback data when the authorization code is obtained before the second application is closed, wherein RESULT_OK is an integer used to indicate that the result is successfully obtained. The feedback data is the feedback data of the authorization success, and the RESULT_OK corresponds to a preset integer; when the feedback data is the feedback data of the authorization failure, the RESULT_OK corresponds to the non-preset integer; the intent represents an intent object, and the encapsulation needs to be returned in the intent object. The authorization code passed; the intent object contains a bundle object, and the bundle object is used to store the authorization code; wherein the authorization code is stored by calling putString(AUTH_CODE, code) in the bundler object, where AUTH_CODE indicates The key name of the authorization code, code indicates the value of the authorization code.
  15. 如权利要求14所述的装置,其特征在于,所述装置还包括:The device of claim 14 wherein said device further comprises:
    解析模块,配置成当所述第一应用程序判断接收到的授权反馈数据为授权成功反馈数据时,对所述授权成功反馈数据进行解析,以获取所述授权码。The parsing module is configured to parse the authorization success feedback data to obtain the authorization code when the first application determines that the received authorization feedback data is the authorization success feedback data.
  16. 如权利要求15所述的装置,其特征在于,所述解析模块具体配置成:The apparatus according to claim 15, wherein the parsing module is specifically configured to:
    调用intent对象中的getBundle函数,获得Bundle对象;Call the getBundle function in the intent object to get the Bundle object.
    调用Bundle对象中的getString(AUTH_CODE)函数获得所述授权码。The authorization code is obtained by calling the getString(AUTH_CODE) function in the Bundle object.
  17. 一种电子设备,其特征在于,所述电子设备包括:An electronic device, comprising:
    存储器;Memory
    处理器;以及Processor;
    授权信息获取装置,所述授权信息获取装置存储于所述存储器中并包括一个或多个由所述处理器执行的软件功能模组,其包括:An authorization information acquisition device, the authorization information acquisition device being stored in the memory and comprising one or more software function modules executed by the processor, comprising:
    第一获取模块,配置成第一应用程序响应用户操作获取第二应用程序对应的描述信息;a first acquiring module, configured to: the first application, in response to the user operation, obtain description information corresponding to the second application;
    启动模块,配置成所述第一应用程序根据所述描述信息,调用所述电子设备内预先设置的第一协议,隐式打开所述第二应用程序中预先定义的启动页面,其中,所述第一协议用于实现启动与所述描述信息对应的应用程序进程并允许所述应用程序进程关闭后将反馈数据至所述第一应用程序,其中,所述反馈数据是所述第二应用程序启动页面启动之后生成的数据;a startup module, configured to: the first application invokes a first protocol preset in the electronic device according to the description information, and implicitly opens a predefined startup page in the second application, where The first protocol is configured to implement an application process corresponding to the description information and allow the application process to be closed to feed back data to the first application, where the feedback data is the second application The data generated after the startup page is started;
    生成模块,配置成当所述第二应用程序在所述第二应用程序关闭之前获取授权码时,根据所述授权码生成授权反馈数据,其中,所述反馈数据包括授权反馈数据;a generating module, configured to generate authorization feedback data according to the authorization code when the second application acquires an authorization code before the second application is closed, where the feedback data includes authorization feedback data;
    反馈模块,配置成所述第二应用程序关闭后,通过预设置的第二协议将所述授权反馈数据反馈至所述第一应用程序,以使所述第一应用程序获取第二应用程序的授权信息,其中,第二协议用于在所述第二应用程序关闭后将所述反馈数据传递至允许接收所述反馈数据的应用程序。a feedback module, configured to: after the second application is closed, feed back the authorization feedback data to the first application by using a preset second protocol, so that the first application acquires the second application Authorization information, wherein the second protocol is for transmitting the feedback data to an application that allows the feedback data to be received after the second application is closed.
  18. 一种可读存储介质,所述可读存储介质包括计算机程序,其特征在 于:A readable storage medium, the readable storage medium comprising a computer program, characterized by:
    所述计算机程序运行时控制所述可读存储介质所在电子设备执行权利要求1-8中任意一项所述的授权信息获取方法。The electronic device in which the readable storage medium is located is controlled to execute the authorization information acquiring method according to any one of claims 1-8.
PCT/CN2018/081384 2017-10-09 2018-03-30 Authorization information obtaining method and apparatus, electronic device, and readable storage medium WO2019071927A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710928685.XA CN107679373B (en) 2017-10-09 2017-10-09 Method for acquiring authorized information, device and electronic equipment
CN201710928685.X 2017-10-09

Publications (1)

Publication Number Publication Date
WO2019071927A1 true WO2019071927A1 (en) 2019-04-18

Family

ID=61137933

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/081384 WO2019071927A1 (en) 2017-10-09 2018-03-30 Authorization information obtaining method and apparatus, electronic device, and readable storage medium

Country Status (2)

Country Link
CN (1) CN107679373B (en)
WO (1) WO2019071927A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107679373B (en) * 2017-10-09 2019-09-10 武汉斗鱼网络科技有限公司 Method for acquiring authorized information, device and electronic equipment
CN110069919B (en) * 2019-04-25 2021-08-24 上海连尚网络科技有限公司 Information acquisition method and device
CN115080928A (en) * 2022-06-30 2022-09-20 北京亚控科技发展有限公司 Application authorization management method and related equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014014793A1 (en) * 2012-07-17 2014-01-23 CallSign, Inc. Anti-cloning system and method
CN104102537A (en) * 2013-04-07 2014-10-15 华为技术有限公司 Application calling method and user terminal
CN104462980A (en) * 2014-12-30 2015-03-25 北京奇虎科技有限公司 Authority management method, device and system of application programs and mobile terminal
CN107679373A (en) * 2017-10-09 2018-02-09 武汉斗鱼网络科技有限公司 Method for acquiring authorized information, device and electronic equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014014793A1 (en) * 2012-07-17 2014-01-23 CallSign, Inc. Anti-cloning system and method
CN104102537A (en) * 2013-04-07 2014-10-15 华为技术有限公司 Application calling method and user terminal
CN104462980A (en) * 2014-12-30 2015-03-25 北京奇虎科技有限公司 Authority management method, device and system of application programs and mobile terminal
CN107679373A (en) * 2017-10-09 2018-02-09 武汉斗鱼网络科技有限公司 Method for acquiring authorized information, device and electronic equipment

Also Published As

Publication number Publication date
CN107679373B (en) 2019-09-10
CN107679373A (en) 2018-02-09

Similar Documents

Publication Publication Date Title
US9954855B2 (en) Login method and apparatus, and open platform system
JP5534520B2 (en) System and method for browser-based access to smart cards
US10320940B1 (en) Managing generic data
CN108681662B (en) Method and device for installing program
US10104063B2 (en) Android-based mobile equipment security protection method, and device
WO2017071207A1 (en) Application installation method, corresponding apparatus, and application installation system
CN115021991A (en) Single sign-on for unmanaged mobile devices
WO2020134838A1 (en) Authority verification method and related device
CN112039826B (en) Login method and device applied to applet end, electronic equipment and readable medium
WO2013182006A1 (en) Method and device for use in intercepting call for service by application
WO2016069595A1 (en) Method and system for exchanging content between applications
WO2019071927A1 (en) Authorization information obtaining method and apparatus, electronic device, and readable storage medium
US9614824B2 (en) Handling open authentication of an invoked web service in a process
WO2014166227A1 (en) Method, apparatus, and device for adding plug-in in address book
US9628939B2 (en) Data calling method and device
WO2016154783A1 (en) Control method and terminal for short message reading
TW202036338A (en) Service triggering method and device
JP2019518285A (en) Method and terminal for enhancing information security
US9942267B1 (en) Endpoint segregation to prevent scripting attacks
CN115086394A (en) Service information processing method and device and electronic equipment
CN108509228B (en) Page loading method, terminal equipment and computer readable storage medium
CN108494749B (en) Method, device and equipment for disabling IP address and computer readable storage medium
US9819725B1 (en) System, method, and computer program for remotely controlling mobile web applications installed on a mobile device
US10044728B1 (en) Endpoint segregation to prevent scripting attacks
WO2017113584A1 (en) Security control method and system for container of terminal

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18865766

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18865766

Country of ref document: EP

Kind code of ref document: A1