WO2014040437A1 - 一种基于Android系统的框架集成方法及系统 - Google Patents

一种基于Android系统的框架集成方法及系统 Download PDF

Info

Publication number
WO2014040437A1
WO2014040437A1 PCT/CN2013/077266 CN2013077266W WO2014040437A1 WO 2014040437 A1 WO2014040437 A1 WO 2014040437A1 CN 2013077266 W CN2013077266 W CN 2013077266W WO 2014040437 A1 WO2014040437 A1 WO 2014040437A1
Authority
WO
WIPO (PCT)
Prior art keywords
adhesive
framework
android
code
party code
Prior art date
Legal status (The legal status 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 status listed.)
Ceased
Application number
PCT/CN2013/077266
Other languages
English (en)
French (fr)
Inventor
史豪君
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huizhou TCL Mobile Communication Co Ltd
Original Assignee
Huizhou TCL Mobile Communication Co Ltd
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 Huizhou TCL Mobile Communication Co Ltd filed Critical Huizhou TCL Mobile Communication Co Ltd
Publication of WO2014040437A1 publication Critical patent/WO2014040437A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs

Definitions

  • the invention belongs to the technical field of Android development, and particularly relates to a framework integration method and system based on an Android system.
  • Android is a smart mobile terminal operating system launched by Google.
  • new features, proprietary development libraries, and common API packages are often added. Every time you add a new feature, you need to turn the Android framework over, find the right place to put the corresponding code, and finally change the Android source code to break, as shown in Figure 1, in the Android Framework (ie Android framework) , with Android code 1, Android code 2 and Android code 3 (ie Android source code), need to find a suitable place to place the corresponding third-party code when adding third-party code to the Android Framework, for example, a third party
  • the code snippet is placed in a different location in Android code 3, and the source code of Android is changed.
  • an object of the present invention is to provide a framework integration method and system based on an Android system to solve the problem of high integration degree between the third-party code and the Android framework in the prior art.
  • one technical solution adopted by the present invention is to provide a framework integration method based on an Android system, which is used for integrating third-party code into an Android framework, wherein the framework integration method includes the following steps: Adding a layer of adhesive between the Android framework and the third-party code, each third-party code that needs to be glued corresponds to an adhesive, defines an adhesive interface for each adhesive, and bonds the bond The third-party code corresponding to the agent notifies the Android framework; wherein, the structure of the adhesive interface includes: an external expansion module, which is used to convert a part of the code of the Android framework when the code of the Android framework uses the adhesive; Forward accessor, for Android frame bonding third Square code; a reverse accessor for third-party code binding to the Android framework; B.
  • Implementing a specific bonding behavior of the adhesive including the Android framework's positive access to third-party code and third parties
  • the reverse access of the code to the Android framework comprises: an adhesive constructor for manufacturing the adhesive; and for bonding with a third party code
  • the Android framework uses the adhesive to glue the corresponding third party code.
  • the methods and attributes defined in the external extension module are converted into a part of the public domain of the code of the Android framework.
  • the step C specifically includes: Cl, the Android framework obtains the adhesive according to the definition of the adhesive interface; C2, the Android framework finds a place in the adhesive that needs to be glued with the third-party code, and invokes The adhesive forward accesses the method in the interface to complete the bond.
  • the step C2 further comprises: creating an adhesive factory having the capability of producing an adhesive according to the requirements of the framework, the requirements include: a name of the adhesive, a forward access interface name of the adhesive, and a paste The reverse access interface name of the mixture and the implementation of the adhesive reverse access interface.
  • another technical solution adopted by the present invention is to provide a framework integration method based on an Android system, which is used for integrating third-party code into an Android framework, wherein the framework integration method includes the following steps: A. Add a layer of adhesive between the Android framework and the third-party code. Each third-party code that needs to be bonded corresponds to an adhesive, defines an adhesive interface for each adhesive, and binds the adhesive. The third-party code corresponding to the mixture notifies the Android framework; B. Implementing a specific bonding behavior of the adhesive, the specific bonding behavior including the Android framework's positive access to the third-party code and the third-party code to the Android framework Reverse access; C. The Android framework uses the adhesive to glue the corresponding third party code.
  • the structure of the adhesive interface defined in the step A includes: an external expansion module, which is used to convert a part of the code of the Android framework when the code of the Android framework uses the adhesive; a forward accessor, for Android The framework glues third-party code; the reverse accessor is used to glue the Android framework to third-party code.
  • the methods and attributes defined in the external extension module are converted into a part of the public domain of the code of the Android framework.
  • the structure for achieving forward access of the adhesive in the step B comprises: an adhesive constructor for manufacturing the adhesive; and for bonding with a third-party code and passing the third-party code The entity that directly calls the binder.
  • the step C specifically includes: Cl, the Android framework obtains the adhesive according to the definition of the adhesive interface; C2, the Android framework finds a place in the adhesive that needs to be glued with the third-party code, and invokes The adhesive forward accesses the method in the interface to complete the bond.
  • the step C2 further comprises: creating an adhesive factory having the capability of producing an adhesive according to the requirements of the framework, the requirements include: a name of the adhesive, a forward access interface name of the adhesive, and a paste
  • the reverse access interface name of the mixture and the implementation of the adhesive reverse access interface are 4 parts.
  • another technical solution adopted by the present invention is to provide a framework integration system based on an Android system, which is used for integrating third party code into an Android framework, wherein the system includes: an adhesive interface a definition module for adding a layer of adhesive between the Android framework and third-party code, each third-party code that needs to be glued corresponds to an adhesive, defines an adhesive interface for each adhesive, and The third-party code corresponding to the adhesive notifies the Android framework; the adhesive behavior implementation module is configured to implement a specific bonding behavior of the adhesive, and the specific bonding behavior includes the positiveness of the Android framework to the third-party code. Reverse access to the Android framework to access and third party code; a building block for the Android framework to glue the corresponding third party code using the adhesive.
  • the structure defining the glue interface includes: an external extension module, which is used to convert a part of the code of the Android framework when the code of the Android framework uses the glue;
  • the structure of the adhesive behavior implementing module to achieve positive access of the adhesive comprises: an adhesive constructor for manufacturing the adhesive; and for bonding with a third party code and The entity of the adhesive is called directly by the third party code.
  • the building module specifically includes: a first building module, configured by the Android framework to obtain the adhesive according to a definition of an adhesive interface; and a second building module for the Android framework to find a need in the adhesive Where the third-party code is glued, the glue is called to access the method in the interface to complete the bond.
  • the Android system-based framework integration method and system of the present invention separates the code of the Android framework from the third-party code through the adhesive, and achieves the purpose of integrating the weak coupling of the Android framework, which can make the Android framework obtain the appropriate Adhesives can glue the required third-party code, and the advantages of strong scalability and weak coupling in Android framework integration are obvious.
  • FIG. 1 is a schematic structural diagram of framework integration of a prior art Android system.
  • FIG. 2 is a schematic structural diagram of framework integration based on Android system of the present invention.
  • FIG. 3 is a flowchart of a framework integration method based on an Android system of the present invention.
  • Figure 4 is a schematic illustration of the structure of an adhesive interface in an embodiment of the framework integration of the Android system of the present invention.
  • FIG. 5 is a structural block diagram of a framework integration system based on the Android system of the present invention.
  • the present invention mainly provides a framework integration method and system based on the Android system.
  • the present invention will be further described in detail below with reference to the accompanying drawings. It is understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
  • the Android system based framework integration method of the invention is used for integrating third party code into
  • the framework integration method is to make third-party code be placed separately without being mixed with the code of the Android framework by adding a glue between the Android framework and the third-party code.
  • the Android Framework ie, the Android framework
  • Android code 1 is provided with Android code 1, Android code 2, and Android code 3, wherein the Android code 3 further includes three code fragments:
  • This application is different, as shown in Figure 2, which provides a glue (Glue) that is placed between the Android framework and third-party code to allow third-party code to be placed separately without being confused with the Android framework code:
  • Third-party code snippets (including third-party code snippet 1 and third-party code snippet 2) are placed in any directory. As a result, the degree of coupling between the third-party code and the Android framework is reduced, which makes the maintenance of the code simpler and the platform upgrades faster.
  • FIG. 3 is a flowchart of a framework integration method based on the Android system of the present invention. As shown, the method includes the following steps:
  • the Android framework uses the adhesive to bond the corresponding third party code.
  • Each third-party code that needs to be glued corresponds to an adhesive, defines an adhesive interface for each adhesive, and bonds the bond.
  • the third-party code corresponding to the agent informs the Android framework: Responsible for telling the Android framework which code the adhesive can glue, that is, defining the bonding ability of the adhesive.
  • the definition of the adhesive interface must have a certain format and a similar structure.
  • the structure of the adhesive interface includes: an external expansion module, a forward accessor, and a reverse accessor, and the external expansion module is used to bind the code of the Android framework.
  • the external extension module is responsible for the external visible portion Gl of the adhesive (ie, Glue), and if the framework code uses the adhesive, then the adhesive.
  • the external extension module is also part of the Framework code, and this part is externally visible (the original Framework has two interfaces visible to F1 and F2. When this glue is used, the code of the new Framework is visible to the outside.
  • the format defined by the adhesive interface includes the following:
  • the specific bonding behavior of the adhesive is achieved.
  • the specific bonding behavior is It is in the implementation of the adhesive.
  • the implementation of the adhesive is subdivided into two parts, namely the forward and reverse access of the adhesive.
  • the implementation of the forward-access adhesive requires completion of all methods in the IGlue interface defined in the adhesive interface, and must have a certain format, and a similar structure.
  • the structure of the forward-access adhesive implementation includes:
  • Adhesive Constructor This constructor is responsible for the manufacture of this adhesive, and the Framework can only truly bond to third-party code if it has acquired the adhesive.
  • the interface of the adhesive is simply an expression of the adhesive's ability and does not really bond.
  • the format of the implementation of the forward-access adhesive includes:
  • the implementation of the reverse-access adhesive is much simpler than the implementation of the forward-access adhesive. There is no fixed format and structure. There is only one requirement, that is, the IAccesser defined in the adhesive interface needs to be completed. All methods in the interface. There is a limit to the placement of the implementation of the reverse-access adhesive, which must be placed in the code that needs to be glued in the Framework. Since the implementation of the reverse-access adhesive is similar to the implementation of the forward-access adhesive, the implementation details for this section are not repeated.
  • the Android framework uses the adhesive to bond the third-party code corresponding to the adhesive.
  • M1 and M2 the following two steps are specifically included:
  • the implementation of the adhesive factory is accomplished by the following method:
  • the adhesive factory has the ability to produce adhesives according to the requirements of the Framework.
  • the requirements here include: the name of the adhesive, the forward access interface name of the adhesive
  • the four parts of the reverse access interface name of the adhesive and the reverse access interface of the adhesive are actually the ability to describe the adhesive that needs to be produced.
  • the factory is implemented using Java's reflection mechanism. The user does not need to modify the code of the factory.
  • the Java implementation is as follows: public final class GlueFactory ⁇
  • the Android framework finds in the adhesive where it needs to be glued to the third-party code, and then completes the bonding. In this embodiment, it is implemented using a forward accessor in the calling adhesive.
  • the invention also provides a framework integration system based on the Android system, which is used for integrating third party code into the Android framework.
  • the system comprises: an adhesive interface definition module 100, an adhesive behavior The module 200 and the building module 300 are implemented, wherein the adhesive interface definition module 100 is configured to add a layer of adhesive between the Android framework and the third-party code, and each of the third-party codes that need to be bonded corresponds to one bonding.
  • An adhesive interface is defined for each adhesive, and the third-party code corresponding to the adhesive is notified to the Android framework; the adhesive behavior realization module 200 is used to achieve a specific adhesive of the adhesive In conjunction with the behavior, the specific bonding behavior includes forward access by the Android framework to third party code and reverse access by third party code to the Android framework; the building block 300 is used to cause the Android framework to adhere using the adhesive Corresponding third party code.
  • the structure of the adhesive interface defined in the adhesive interface definition module comprises: an external expansion module, a forward accessor and a reverse accessor, wherein the external expansion module is used when the code of the Android framework is glued When converted, it is converted to part of the code of the Android framework; the forward accessor is used to glue third-party code to the Android framework; and the reverse accessor is used to glue the Android framework with third-party code.
  • the structure of the adhesive behavior implementing module in the frame integration system for realizing the positive access of the adhesive comprises: an adhesive constructor for manufacturing the adhesive, and An entity that binds to third-party code and can be invoked directly by third-party code.
  • the building module specifically includes: a first building module and a second building module, where the first building module is used by the Android framework to obtain the adhesive according to a definition of an adhesive interface; the second building module For the Android framework to find where the glue needs to be glued to the third-party code, call the glue forward access interface to complete the glue.
  • the Android system-based framework integration method and system of the present invention is used to integrate third-party code into the Android framework.
  • a layer of adhesive is added between the Android framework and the third-party code, and each The third-party code that needs to be bonded corresponds to an adhesive, defines an adhesive interface for each adhesive, and notifies the Android framework of the third-party code corresponding to the adhesive;
  • Specific bonding behavior the specific bonding behavior includes forward access of the Android framework to third-party code and reverse access of the third-party code to the Android framework;
  • the Android framework uses the adhesive to bond the corresponding third party Code. So that the third-party code is placed separately and not mixed with the code of the Android framework, so that the Android framework integrates weak coupling, so that
  • the Android framework can glue the required third-party code as long as it has the right glue.
  • the advantages of strong scalability and weak coupling in Android framework integration are obvious.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Telephone Function (AREA)
  • Telephonic Communication Services (AREA)

Description

一种基于 Android系统的框架集成方法及系统
【技术领域】
本发明属于 Android开发技术领域,具体的涉及一种基于 Android系统的框 架集成方法及系统。
【背景技术】
Android是谷歌推出的一种智能的移动终端操作系统。 在 Android实际开 发过程中, 往往都会添加一些新特性、 专有的开发库、 常用 API的封装等。 每 添加一个新的功能就需要把 Android框架翻个遍,寻找合适的地方放置相应的代 码, 到最后把 Android 的源码改得支离破碎, 如图 1 所示, 在所述 Android Framework (即 Android框架) 中, 设置有 Android代码 1、 Android代码 2和 Android代码 3 (即 Android的源码), 需要在所述 Android Framework增加第三 方代码时, 需要寻找合适的地方放置相应的第三方代码, 例如, 将第三方代码 片段放入 Android代码 3的不同位置中,把 Android的源码改得支离破碎。 当遇 到频繁的 Android版本更新,就要把之前辛苦添加到框架中的代码找出来, 重新 添加到新的版本中去, 这种高耦合度的框架集成方式既费时又费力, 如何把这 些代码集成到 Android框架中成为了开发者最为头痛的事。有鉴于此,如何提供 一种高效的集成 Andro id框架的方法显的尤为重要。
【发明内容】
鉴于上述现有技术的不足之处, 本发明的目的在于提供一种基于 Android 系统的框架集成方法及系统,以解决现有技术中第三方代码与 Android框架之间 的集成高耦合度的问题。
为解决上述技术问题, 本发明釆用的一个技术方案是提供一种基于 Android 系统的框架集成方法, 用于将第三方代码集成到 Android框架中, 其中, 所述框 架集成方法包括以下步骤: A、 在 Android框架和第三方代码之间增加一层粘合 剂, 每一个需要粘合的第三方代码对应一个粘合剂, 为每一粘合剂定义粘合剂 接口, 并将所述粘合剂对应的第三方代码通知所述 Android框架; 其中, 所述粘 合剂接口的结构包括:外部扩展模块,用于当 Android框架的代码使用粘合剂时, 转化为 Android框架的代码的一部分; 正向访问器, 用于 Android框架粘合第三 方代码; 反向访问器, 用于第三方代码粘合 Android框架; B、 实现粘合剂的具 体粘合行为,所述具体粘合行为包括 Android框架对第三方代码的正向访问和第 三方代码对 Android框架的反向访问; 其中, 所述实现粘合剂的正向访问的结构 包括: 用于负责制造所述粘合剂的粘合剂构造器; 以及用于与第三方代码粘合 并可通过第三方代码的直接调用的粘合剂的实体; C、 Android框架使用所述粘 合剂粘合对应的第三方代码。
其中 ,所述在外部扩展模块中定义的方法和属性转化为 Android框架的代码 的 public域的一部分。
其中, 所述步骤 C具体包括: Cl、 Android框架根据粘合剂接口的定义获取 所述粘合剂; C2、 Android框架在所述粘合剂中找到需要与第三方代码粘合的地 方, 调用粘合剂正向访问接口中的方法, 完成粘合。
其中, 所述步骤 C2还包括: 创建一具备根据 Framework的要求生产粘合剂 的能力的粘合剂工厂, 所述要求包括: 粘合剂的名称, 粘合剂的正向访问接口 名, 粘合剂的反向访问接口名和粘合剂反向访问接口的实现。
为解决上述技术问题, 本发明釆用的另一个技术方案是提供一种基于 Android系统的框架集成方法,用于将第三方代码集成到 Android框架中,其中, 所述框架集成方法包括以下步骤: A、 在 Android框架和第三方代码之间增加一 层粘合剂, 每一个需要粘合的第三方代码对应一个粘合剂, 为每一粘合剂定义 粘合剂接口, 并将所述粘合剂对应的第三方代码通知所述 Android框架; B、 实 现粘合剂的具体粘合行为,所述具体粘合行为包括 Android框架对第三方代码的 正向访问和第三方代码对 Android框架的反向访问; C、 Android框架使用所述 粘合剂粘合对应的第三方代码。
其中, 所述步骤 A中定义粘合剂接口的结构包括: 外部扩展模块, 用于当 Android框架的代码使用粘合剂时, 转化为 Android框架的代码的一部分; 正向 访问器, 用于 Android框架粘合第三方代码; 反向访问器, 用于第三方代码粘合 Android框架。
其中 ,所述在外部扩展模块中定义的方法和属性转化为 Android框架的代码 的 public域的一部分。
其中, 所述步骤 B中实现粘合剂的正向访问的结构包括: 用于负责制造所 述粘合剂的粘合剂构造器; 以及用于与第三方代码粘合并可通过第三方代码的 直接调用的粘合剂的实体。 其中, 所述步骤 C具体包括: Cl、 Android框架根据粘合剂接口的定义获取 所述粘合剂; C2、 Android框架在所述粘合剂中找到需要与第三方代码粘合的地 方, 调用粘合剂正向访问接口中的方法, 完成粘合。
其中, 所述步骤 C2还包括: 创建一具备根据 Framework的要求生产粘合剂 的能力的粘合剂工厂, 所述要求包括: 粘合剂的名称, 粘合剂的正向访问接口 名, 粘合剂的反向访问接口名和粘合剂反向访问接口的实现 4部分。
为解决上述技术问题, 本发明釆用的再一个技术方案是提供一种基于 Android系统的框架集成系统,用于将第三方代码集成到 Android框架中,其中, 所述系统包括: 粘合剂接口定义模块,用于在 Android框架和第三方代码之间增 加一层粘合剂, 每一个需要粘合的第三方代码对应一个粘合剂, 为每一粘合剂 定义粘合剂接口, 并将所述粘合剂对应的第三方代码通知所述 Android框架; 粘 合剂行为实现模块, 用于实现粘合剂的具体粘合行为, 所述具体粘合行为包括 Android框架对第三方代码的正向访问和第三方代码对 Android框架的反向访 问; 构建模块, 用于令 Android框架使用所述粘合剂粘合对应的第三方代码。
其中, 定义粘合剂接口的结构包括: 外部扩展模块, 用于当 Android框架的 代码使用粘合剂时, 转化为 Android框架的代码的一部分;
正向访问器, 用于 Android框架粘合第三方代码; 反向访问器, 用于第三方代码 粘合 Android框架。
其中, 所述粘合剂行为实现模块中实现粘合剂的正向访问的结构包括: 用 于负责制造所述粘合剂的粘合剂构造器; 以及用于与第三方代码粘合并可通过 第三方代码的直接调用的粘合剂的实体。
其中, 所述构建模块具体包括: 第一构建模块, 用于 Android框架根据粘合 剂接口的定义获取所述粘合剂; 第二构建模块,用于 Android框架在所述粘合剂 中找到需要与第三方代码粘合的地方, 调用粘合剂正向访问接口中的方法, 完 成粘合。
有益效果:本发明的基于 Android系统的框架集成方法及系统, 通过粘合剂 把 Android框架的代码和第三方代码分离,达到 Android框架集成弱耦合的目的, 其可以令 Android框架只要获取到合适的粘合剂就可以粘合所需的第三方代码 , 其具有的强扩展性和弱耦合度在 Android框架集成中的优势也是显而易见的。 【附图说明】
图 1为现有技术的 Android系统的框架集成的结构示意图。
图 2为本发明的基于 Android系统的框架集成的结构示意图。
图 3为本发明的基于 Android系统的框架集成方法的流程图。
图 4为本发明的 Android系统的框架集成的实施例中粘合剂接口的结构的示 意图。
图 5是本发明的基于 Android系统的框架集成系统的结构框图。
【具体实施方式】
本发明主要提供了一种基于 Android系统的框架集成方法及系统,为使本发 明的目的、 技术方案及效果更加清楚、 明确, 以下参照附图并举实例对本发明 进一步详细说明。 应当理解, 此处所描述的具体实施例仅用以解释本发明, 并 不用于限定本发明。
本发明的基于 Android系统的框架集成方法, 用于将第三方代码集成到
Android框架中, 其中, 所述框架集成方法是通过在 Android框架和第三方代码 之间增加一粘合剂, 使第三方代码单独放置而不与 Android框架的代码混在一 起。 请一并参阅图 1和图 2, 所述 Android Framework (即 Android框架 ) 中, 设置有 Android代码 1、 Android代码 2和 Android代码 3 ,其中, 所述 Android 代码 3进一步包括三个代码片段: 原有代码片段 1、原有代码片段 2和原有代码 片段 3 , 配图 1所示, 现有技术将第三方代码片段(包括第三方代码片段 1和第 三方代码片段 2 )放入 Android代码 3的不同位置中,令 Android代码 3改得支 离破碎。而本申请则不同,配图 2所示,其提供一粘合剂 ( Glue ),设置在 Android 框架和第三方代码之间,使第三方代码单独放置而不与 Android框架的代码混在 在一起: 第三方代码片段(包括第三方代码片段 1和第三方代码片段 2 )放置在 任意目录里。 如此一来, 降低了第三方代码与 Android框架之间的耦合度, 使得 代码的维护更加简单, 平台升级更加快速。
由上述描述可知, 粘合剂的设计和实现是本发明的关键: 必须要为每一个 需要粘合的代码(在 Android Framework中, 以单独的一个 java文件为单位 )创 建一个粘合剂,这样 Android框架(其本质为 Android框架中的 Framework代码 ) 就可以使用粘合剂去粘合他想要的代码了。 请参阅图 3 , 其为本发明的基于 Android系统的框架集成方法的流程图。 如 图所示, 所述方法包括以下步骤:
51、在 Android框架和第三方代码之间增加一层粘合剂,每一个需要粘合的 第三方代码对应一个粘合剂, 为每一粘合剂定义粘合剂接口, 并将所述粘合剂 对应的第三方代码通知所述 Android框架;
52、 实现粘合剂的具体粘合行为,所述具体粘合行为包括 Android框架对第 三方代码的正向访问和第三方代码对 Android框架的反向访问;
S3、 Android框架使用所述粘合剂粘合对应的第三方代码。
下面分别针对上述步骤进行详细介绍:
首先在 Android框架和第三方代码之间增加一层粘合剂,每一个需要粘合的 第三方代码对应一个粘合剂, 为每一粘合剂定义粘合剂接口, 并将所述粘合剂 对应的第三方代码通知所述 Android框架: 负责告诉 Android框架这个粘合剂能 粘合哪些代码, 即定义粘合剂的粘合能力。 粘合剂接口的定义必须有一定的格 式, 且有相似的结构。
配图 4所示, 本实施例中, 所述粘合剂接口的结构包括: 外部扩展模块、 正向访问器和反向访问器,所述外部扩展模块用于当 Android框架的代码使用粘 合剂时, 转化为 Android框架的代码的一部分, 具体来说, 所述外部扩展模块负 责这个粘合剂(即 Glue )的外部可见部分 Gl , 如果有 Framework代码使用此粘 合剂, 那么粘合剂中的外部扩展模块也成为 Framework代码的一部分, 且这部 分是被外部可见的 (原本的 Framework对外有 2个接口可见 F1和 F2 , 当使用 此粘合剂后,新的 Framework的代码对外可见部分变成了 Fl , F2和 G1 )„用 Java 技术描述这种情况就是在此模块中定义的方法 /属性将会成为 Framework代码的 public域的一部分。 所述正向访问器是供 Framework代码使用, 可以通过 G2访 问到第三方的代码片段, 即此正向访问器用于 Framework粘合第三方代码。 所 述反向访问器是供第三方代码使用,可以通过 G3访问到 Framework的代码片段, 即此反向访问器用于第三方代码粘合 Framework。
在本实施例中, 粘合剂接口定义的格式包括以下:
( 1 ) 定义一个名为 IGlueXXX的接口, XXX为 Framework代码的名称。 在此接口中定义的所有方法就是类似图 4中描述的外部扩展模块 G1 ;
( 2 )在 IGlueXXX中定义一个名为 IAccesser的接口,在此接口中定义的所 有的方法就是类似图 4中描述的反向访问器的 G3 ; ( 3 )在 IGlueXXX中定义一个名为 IGlue的接口, 并且此接口必须继承 IGlueXXX接口;
( 4 )在 IGlue接口中定义的所有方法就是类似图 4中正向访问器中的 G2; 粘合剂接口定义的格式结合图 3给出 Java的伪代码如下所示: public interface IGlueXXX {
定义接口 G1
interface IAccesser {
定义接口 G3
}
interface IGlue extends IGlueXXX {
定义接口 G2
}
然后是实现粘合剂的具体粘合行为, 完成了第一部分中定义的粘合剂的接 口后, 由于粘合剂接口中只是定义了粘合剂的粘合能力, 而具体的粘合行为则 是在粘合剂实现中。 粘合剂的实现细分成 2个部分, 即实现粘合剂的正向访问 和反向访问。
正向访问的粘合剂的实现需要完成粘合剂接口中定义的 IGlue接口中的所 有方法, 且必须有一定的格式, 和相似的结构。
以正向访问为例, 正向访问的粘合剂实现的结构包括有:
( 1 ) 粘合剂构造器: 此构造器负责制造此粘合剂, Framework只有获取到 粘合剂之后才能真正的与第三方代码粘合。 粘合剂的接口只是该粘合剂能力的 表达, 并不能真正粘合。
( 2 )粘合剂的实体: 真正与第三方代码粘合的动作是在此部分完成的, 他 是整个粘合剂的核心部分。 用 Java技术表达就是, 在此部分中才会有对第三方 代码的直接调用。
正向访问的粘合剂的实现的格式包括:
( 1 )定义一个名为 GlueXXX的类, XXX为 Framework代码的名称, 和 IGlueXXX中的相同。
( 2 )定义一个带有 IGlueXXX.IAccesser参数的 GlueXXX的构造器。 构造 ( 3 )类 GlueXXX必须实现 IGlueXXX.IGlue中定义的所有的方法。 在每个 方法的实现过程中, 可以直接调用第三方的代码以完成粘合动作。 如果第三方 代码需要反向访问 Framework的代码, 则可以通过 IAccesser完成 ( IAccesser 已经在粘合剂创建的同时被保存在粘合剂内部了)。 正向访问的粘合剂的实现结 合给出的 Java伪代码如下:
public class GlueXXX implements IGlueXXX.IGlue {
GlueXXX(IGlueXXX.IAcesser accesser) {
保存 accesser
}
实现 Gl方法 {
直接调用第三方代码
}
实现 G2方法 {
直接调用第三方代码
}
}
而反向访问的粘合剂的实现与正向访问的粘合剂的实现相比起来要简单的 多, 没有固定的格式和结构, 只有一个要求, 就是需要完成粘合剂接口中定义 的 IAccesser接口中的所有方法。 对于反向访问的粘合剂的实现的放置位置有一 个限制, 就是必须放置在 Framework中需要粘合的代码中。 由于反向访问的粘 合剂的实现与正向访问的粘合剂的实现类似, 所以关于此部分的实现细节就不 再赘述了。
最后是 Android框架使用所述粘合剂粘合所述粘合剂对应的第三方代码。在 本实施例中 , 具体包括以下 Ml、 M2两步:
Ml、 Android框架根据粘合剂接口的定义获取所述粘合剂; 即 Framework 代码中创建出合适的粘合剂, 所谓合适的粘合剂指的是该粘合剂具备粘合此 Framework代码中想要粘合的第三方代码的能力,其实,这样的粘合剂已经粘合 剂接口中定义了。 因此, 本步骤需要做的就是找到这样的粘合剂接口定义, 然 后再根据粘合剂接口定义获取到粘合剂的实现, 在粘合剂实现中, 对于每一个 粘合剂的实现必须要有一个粘合剂构造器的规定, 这样, 就可以使用粘合剂的 构造器制造出该粘合剂供 Framework代码使用。 显然, 这样创建合适的粘合剂 有点复杂, 在具体的实现过程中, 有一个粘合剂工厂存在, 此工厂负责生成各 式各样的粘合剂。 在 Framework代码中只需要通过粘合剂工厂创建出合适的粘 合剂正向访问接口即可。
所述实现粘合剂工厂的实现釆用如下方法:粘合剂工厂具备根据 Framework 的要求生产粘合剂的能力, 这里的要求包括: 粘合剂的名称、 粘合剂的正向访 问接口名、 粘合剂的反向访问接口名和粘合剂反向访问接口的实现这 4部分, 其实这 4部分正是在描述需要生产出来的粘合剂所具备的能力。该工厂使用 Java 的反射机制实现, 用户不需要修改该工厂的代码, 其 Java的实现方式如下: public final class GlueFactory{
public final static <T,E> T buildGule(String moduleName,Class<T>glue,
Class<E>iaccesser, E accesser) {
String glueName="com.xxx.glue.Glue"+moduleName;
try{
return glue.cast(Class.forName(glueName)
. getDeclaredConstructor(new Class[] {iaccesser})
.newlnstance(iaccesser.cast(accesser)));
} catch (Exception e) { 〃捕获异常
}
return null; II返回值无效
}
}
M2、 Android框架在所述粘合剂中找到需要与第三方代码粘合之处, 然后 完成粘合。 在本实施例中, 其釆用调用粘合剂中的正向访问器来实现。
本发明还提供了一种基于 Android系统的框架集成系统,用于将第三方代码 集成到 Android框架中,如图 5所示,所述系统包括: 粘合剂接口定义模块 100、 粘合剂行为实现模块 200和构建模块 300, 其中, 所述粘合剂接口定义模块 100 用于在 Android框架和第三方代码之间增加一层粘合剂 ,每一个需要粘合的第三 方代码对应一个粘合剂, 为每一粘合剂定义粘合剂接口, 并将所述粘合剂对应 的第三方代码通知所述 Android框架;所述粘合剂行为实现模块 200用于实现粘 合剂的具体粘合行为,所述具体粘合行为包括 Android框架对第三方代码的正向 访问和第三方代码对 Android框架的反向访问;所述构建模块 300用于令 Android 框架使用所述粘合剂粘合对应的第三方代码。 优选地, 所述粘合剂接口定义模块中定义粘合剂接口的结构包括: 外部扩 展模块、正向访问器和反向访问器, 所述外部扩展模块用于当 Android框架的代 码使用粘合剂时, 转化为 Android框架的代码的一部分; 所述正向访问器用于 Android框架粘合第三方代码; 所述反向访问器用于第三方代码粘合 Android框 架。
优选地, 所述的框架集成系统中所述粘合剂行为实现模块中实现粘合剂的 正向访问的结构包括: 用于负责制造所述粘合剂的粘合剂构造器, 以及用于与 第三方代码粘合并可通过第三方代码的直接调用的粘合剂的实体。
优选地, 所述构建模块具体包括: 第一构建模块和第二构建模块, 所述第 一构建模块用于 Android框架根据粘合剂接口的定义获取所述粘合剂;所述第二 构建模块用于 Android框架在所述粘合剂中找到需要与第三方代码粘合的地方, 调用粘合剂正向访问接口中的方法, 完成粘合。
关于其具体实现细节,都已经在上述基于 Android系统的框架集成方法中进 行了详细描述, 这里就不再赘述了。
综上所述,本发明的基于 Android系统的框架集成方法及系统,用于将第三 方代码集成到 Android框架中, 首先, 在 Android框架和第三方代码之间增加一 层粘合剂, 每一个需要粘合的第三方代码对应一个粘合剂, 为每一粘合剂定义 粘合剂接口, 并将所述粘合剂对应的第三方代码通知所述 Android框架; 然后, 实现粘合剂的具体粘合行为,所述具体粘合行为包括 Android框架对第三方代码 的正向访问和第三方代码对 Android框架的反向访问; 最后, Android框架使用 所述粘合剂粘合对应的第三方代码。从而使第三方代码单独放置而不与 Android 框架的代码混在在一起, 达到 Android框架集成弱耦合的目的, 从而可以令
Android框架只要获取到合适的粘合剂就可以粘合所需的第三方代码, 其具有的 强扩展性和弱耦合度在 Android框架集成中的优势是显而易见的。
应当理解的是, 本发明的应用不限于上述的举例, 对本领域普通技术人员 来说, 可以根据上述说明加以改进或变换, 所有这些改进和变换都应属于本发 明所附权利要求的保护范围。

Claims

权利 要求
1. 一种基于 Android系统的框架集成方法, 用于将第三方代码集成到 Android框架中, 其特征在于, 所述框架集成方法包括以下步骤:
A、 在 Android框架和第三方代码之间增加一层粘合剂, 每一个需要粘合的 第三方代码对应一个粘合剂, 为每一粘合剂定义粘合剂接口, 并将所述粘合剂 对应的第三方代码通知所述 Android框架; 其中, 所述粘合剂接口的结构包括: 外部扩展模块, 用于当 Android框架的代码使用粘合剂时, 转化为 Android 才 II架的代码的一部分;
正向访问器, 用于 Android框架粘合第三方代码;
反向访问器, 用于第三方代码粘合 Android框架;
B、 实现粘合剂的具体粘合行为, 所述具体粘合行为包括 Android框架对第 三方代码的正向访问和第三方代码对 Android框架的反向访问; 其中, 所述实现 粘合剂的正向访问的结构包括:
用于负责制造所述粘合剂的粘合剂构造器;
以及用于与第三方代码粘合并可通过第三方代码的直接调用的粘合剂的实 体;
C、 Android框架使用所述粘合剂粘合对应的第三方代码。
2. 根据权利要求 1所述的基于 Android系统的框架集成方法,其特征在于, 所述在外部扩展模块中定义的方法和属性转化为 Android框架的代码的 public 域的一部分。
3. 根据权利要求 1所述的基于 Android系统的框架集成方法,其特征在于, 所述步骤 C具体包括:
Cl、 Android框架根据粘合剂接口的定义获取所述粘合剂;
C2、 Android框架在所述粘合剂中找到需要与第三方代码粘合的地方, 调用 粘合剂正向访问接口中的方法, 完成粘合。
4. 根据权利要求 3所述的基于 Android系统的框架集成方法,其特征在于, 所述步骤 C2还包括:创建一具备根据 Framework的要求生产粘合剂的能力的粘 合剂工厂, 所述要求包括: 粘合剂的名称, 粘合剂的正向访问接口名, 粘合剂 的反向访问接口名和粘合剂反向访问接口的实现。
5. 一种基于 Android系统的框架集成方法, 用于将第三方代码集成到 Android框架中, 其特征在于, 所述框架集成方法包括以下步骤:
A、 在 Android框架和第三方代码之间增加一层粘合剂, 每一个需要粘合的 第三方代码对应一个粘合剂, 为每一粘合剂定义粘合剂接口, 并将所述粘合剂 对应的第三方代码通知所述 Android框架;
B、 实现粘合剂的具体粘合行为, 所述具体粘合行为包括 Android框架对第 三方代码的正向访问和第三方代码对 Android框架的反向访问;
C、 Android框架使用所述粘合剂粘合对应的第三方代码。
6. 根据权利要求 5所述的基于 Android系统的框架集成方法,其特征在于, 所述步骤 A中定义粘合剂接口的结构包括:
外部扩展模块, 用于当 Android框架的代码使用粘合剂时, 转化为 Android 才 II架的代码的一部分;
正向访问器, 用于 Android框架粘合第三方代码;
反向访问器, 用于第三方代码粘合 Android框架。
7. 根据权利要求 6所述的基于 Android系统的框架集成方法,其特征在于, 所述在外部扩展模块中定义的方法和属性转化为 Android框架的代码的 public 域的一部分。
8. 根据权利要求 5所述的基于 Android系统的框架集成方法,其特征在于, 所述步骤 B中实现粘合剂的正向访问的结构包括:
用于负责制造所述粘合剂的粘合剂构造器;
以及用于与第三方代码粘合并可通过第三方代码的直接调用的粘合剂的实 体。
9. 根据权利要求 5所述的基于 Android系统的框架集成方法,其特征在于, 所述步骤 C具体包括:
Cl、 Android框架根据粘合剂接口的定义获取所述粘合剂;
C2、 Android框架在所述粘合剂中找到需要与第三方代码粘合的地方, 调用 粘合剂正向访问接口中的方法, 完成粘合。
10.根据权利要求 9所述的基于 Android系统的框架集成方法,其特征在于, 所述步骤 C2还包括:创建一具备根据 Framework的要求生产粘合剂的能力的粘 合剂工厂, 所述要求包括: 粘合剂的名称, 粘合剂的正向访问接口名, 粘合剂 的反向访问接口名和粘合剂反向访问接口的实现。
11. 一种基于 Android系统的框架集成系统, 用于将第三方代码集成到 Android框架中, 其特征在于, 所述框架集成系统包括:
粘合剂接口定义模块,用于在 Android框架和第三方代码之间增加一层粘合 剂, 每一个需要粘合的第三方代码对应一个粘合剂, 为每一粘合剂定义粘合剂 接口, 并将所述粘合剂对应的第三方代码通知所述 Android框架;
粘合剂行为实现模块, 用于实现粘合剂的具体粘合行为, 所述具体粘合行 为包括 Android框架对第三方代码的正向访问和第三方代码对 Android框架的反 向访问;
构建模块, 用于令 Android框架使用所述粘合剂粘合对应的第三方代码。
12. 根据权利要求 11所述的框架集成系统, 其特征在于, 定义粘合剂接口 的结构包括:
外部扩展模块, 用于当 Android框架的代码使用粘合剂时, 转化为 Android 才 II架的代码的一部分;
正向访问器, 用于 Android框架粘合第三方代码;
反向访问器, 用于第三方代码粘合 Android框架。
13. 根据权利要求 11所述的框架集成系统, 其特征在于, 所述粘合剂行为 实现模块中实现粘合剂的正向访问的结构包括:
用于负责制造所述粘合剂的粘合剂构造器;
以及用于与第三方代码粘合并可通过第三方代码的直接调用的粘合剂的实 体。
14. 根据权利要求 11所述的框架集成系统, 其特征在于, 所述构建模块具 体包括:
第一构建模块, 用于 Android框架根据粘合剂接口的定义获取所述粘合剂; 第二构建模块,用于 Android框架在所述粘合剂中找到需要与第三方代码粘 合的地方, 调用粘合剂正向访问接口中的方法, 完成粘合。
PCT/CN2013/077266 2012-09-12 2013-06-14 一种基于Android系统的框架集成方法及系统 Ceased WO2014040437A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201210336000.XA CN102866891B (zh) 2012-09-12 2012-09-12 一种基于Android系统的框架集成方法及系统
CN201210336000.X 2012-09-12

Publications (1)

Publication Number Publication Date
WO2014040437A1 true WO2014040437A1 (zh) 2014-03-20

Family

ID=47445773

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2013/077266 Ceased WO2014040437A1 (zh) 2012-09-12 2013-06-14 一种基于Android系统的框架集成方法及系统

Country Status (2)

Country Link
CN (1) CN102866891B (zh)
WO (1) WO2014040437A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102866891B (zh) * 2012-09-12 2016-09-14 惠州Tcl移动通信有限公司 一种基于Android系统的框架集成方法及系统
CN103645926B (zh) * 2013-11-14 2017-01-25 乐视致新电子科技(天津)有限公司 一种调用关联模块的方法和装置
CN110413259B (zh) * 2018-04-28 2022-07-29 中兴通讯股份有限公司 Android服务框架、实现扩展服务的方法及装置

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1722088A (zh) * 2004-12-30 2006-01-18 杭州华为三康技术有限公司 软件安装与集成的方法
CN101751256A (zh) * 2009-12-31 2010-06-23 金蝶软件(中国)有限公司 与第三方系统交换数据的方法和系统
CN102209111A (zh) * 2011-05-20 2011-10-05 重庆广典传媒有限公司 云计算移动网络终端设备开放性跨平台系统
CN102866891A (zh) * 2012-09-12 2013-01-09 惠州Tcl移动通信有限公司 一种基于Android系统的框架集成方法及系统

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101482817B (zh) * 2008-12-18 2012-01-11 浙江大学 基于黑盒的大粒度Java构件组装方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1722088A (zh) * 2004-12-30 2006-01-18 杭州华为三康技术有限公司 软件安装与集成的方法
CN101751256A (zh) * 2009-12-31 2010-06-23 金蝶软件(中国)有限公司 与第三方系统交换数据的方法和系统
CN102209111A (zh) * 2011-05-20 2011-10-05 重庆广典传媒有限公司 云计算移动网络终端设备开放性跨平台系统
CN102866891A (zh) * 2012-09-12 2013-01-09 惠州Tcl移动通信有限公司 一种基于Android系统的框架集成方法及系统

Also Published As

Publication number Publication date
CN102866891A (zh) 2013-01-09
CN102866891B (zh) 2016-09-14

Similar Documents

Publication Publication Date Title
WO2011050632A1 (zh) 一种宿主程序和插件及插件间进行交互的方法及装置
WO2021190469A1 (zh) 终端设备及其应用程序接口调用控制方法
AU2014386583B2 (en) Inter-process communication method based on application layer of android and basic application communication system
CN102123196B (zh) 在Android手机上实现WinCE/Android混合API的方法
CN111443961B (zh) 终端设备及其跨进程通信方法
WO2021018005A1 (zh) 一种跨进程通信方法、装置及设备
CN100478896C (zh) 构件运行支撑平台接入消息服务的方法
CN101198927B (zh) 受管自动化程序设计模型
CN107659624A (zh) 一种适用于云计算的异构云管理系统及方法
US20230342345A1 (en) Database repairing method and electronic device
US20230082375A1 (en) Permission Reuse Method, Permission Reuse-Based Resource Access Method, and Related Device
WO2014040437A1 (zh) 一种基于Android系统的框架集成方法及系统
CN102158516B (zh) 服务组合编译方法及编译器
JP2010288301A (ja) ポータブルデバイスにおけるマルチメディアレンダリングのためのシステム
CN103390018B (zh) 一种基于SDD的Web服务数据建模与搜索方法
CN104461555A (zh) 一种Home应用中直接操控各个播放应用的方法
CN113795001B (zh) 基于spi进行系统短信发送的方法及装置
CN107818146B (zh) 一种数据库架构方法和框架
CN112115209A (zh) 一种数据扩展的实现方法
CN105933767B (zh) 中间件装置、中间件实现方法和电视机
CN103399735A (zh) 远程函数调用接口中间层开发方法
CN101907993A (zh) 基于SpringDM的动态模型及其在RFID中间件持久层的应用
CN102523128B (zh) 一种远程数据传输中的数据同步方法
CN103294458A (zh) 基于插件的软件开发方法
CN107247594A (zh) 逻辑系统及其实现方法、计算设备及计算机可读存储介质

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: 13836298

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: 13836298

Country of ref document: EP

Kind code of ref document: A1