All Projects → androidmalin → Androidcomponentplugin

androidmalin / Androidcomponentplugin

Licence: apache-2.0
Android上简单实现四大组件的插件化,供学习使用

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Androidcomponentplugin

FactoryOrchestrator
A cross-platform system service which provides a simple way to run and manage factory line validation, developer inner-loop, diagnostics, and fault analysis workflows.
Stars: ✭ 36 (-88.61%)
Mutual labels:  service, ipc
Discordipc
Connect locally to the Discord client using IPC for a subset of RPC features like Rich Presence and Activity Join/Spectate
Stars: ✭ 66 (-79.11%)
Mutual labels:  ipc, activity
background-service-lib
Essential classes for reliable background services.
Stars: ✭ 24 (-92.41%)
Mutual labels:  service, ipc
Flying Pigeon
flying-pigeon 是一个IPC 跨进程通信组件,底层是匿名内存+Binder , 突破1MB大小限制,无需写AIDL文件,让实现跨进程通信就像写一个接口一样简单
Stars: ✭ 97 (-69.3%)
Mutual labels:  service, ipc
My Android Garage
A quick reference guide for Android development.
Stars: ✭ 66 (-79.11%)
Mutual labels:  service, activity
Inlineactivityresult
Receive the activity result directly after the startActivityForResult with InlineActivityResult
Stars: ✭ 264 (-16.46%)
Mutual labels:  activity
Php Ide Serenata
Atom IDE package that integrates the Serenata server to provide PHP code assistance
Stars: ✭ 277 (-12.34%)
Mutual labels:  service
Use Clipboard Copy
📋 Lightweight copy to clipboard hook for React
Stars: ✭ 256 (-18.99%)
Mutual labels:  hook
MouseInjectDetection
Simple method of checking whether or not mouse movement or buttons (<windows 10) are injected
Stars: ✭ 29 (-90.82%)
Mutual labels:  hook
Pandora
A Manageable, Measurable and Traceable Node.js Application Manager represented by Alibaba powered by TypeScript
Stars: ✭ 3,084 (+875.95%)
Mutual labels:  ipc
Use Editable
A small React hook to turn elements into fully renderable & editable content surfaces, like code editors, using contenteditable (and magic)
Stars: ✭ 291 (-7.91%)
Mutual labels:  hook
Quicklib
Quick development library (AutoMapper, LinQ, IOC Dependency Injection, MemoryCache, Scheduled tasks, Config, Serializers, etc) with crossplatform support for Delphi/Firemonkey (Windows,Linux,OSX/IOS/Android) and freepascal (Windows/Linux).
Stars: ✭ 274 (-13.29%)
Mutual labels:  service
Wechat tweak
♨️ iOS版功能最全的微信插件,支持最新版微信,具备自动抢红包,屏蔽消息和群消息,过滤特定的群聊,防止撤回消息,伪定位 (朋友圈和附近的人),修改微信运动步数和实时取景做聊天页的背景等功能。
Stars: ✭ 265 (-16.14%)
Mutual labels:  hook
Swr
React Hooks for data fetching
Stars: ✭ 20,348 (+6339.24%)
Mutual labels:  hook
Travis Buddy
🚀 Seamless integration between TravisCI and GitHub
Stars: ✭ 262 (-17.09%)
Mutual labels:  service
Azure Service Operator
Azure Service Operator allows you to create Azure resources using kubectl
Stars: ✭ 291 (-7.91%)
Mutual labels:  service
stucco-js
GraphQL server. JavaScript runtime for stucco - GraphQL as a Service
Stars: ✭ 22 (-93.04%)
Mutual labels:  service
Mirage
kernel-mode Anti-Anti-Debug plugin. based on intel vt-x && ept technology
Stars: ✭ 272 (-13.92%)
Mutual labels:  hook
Magnum
Container Infrastructure Management Service for OpenStack. Mirror of code maintained at opendev.org.
Stars: ✭ 289 (-8.54%)
Mutual labels:  service
Radioactive State
☢ Make Your React App Truly Reactive!
Stars: ✭ 273 (-13.61%)
Mutual labels:  hook

Android上简单实现四大组件的插件化

说明:

此项目仅用于学习插件化基本的实现思路,在此基础上学习理解四大组件的运行机制。

实现插件化的重点在于对Android四大组件和资源加载流程的分析和解读。

插件化代码的编写,涉及到的知识点主要有java中的反射,动态代理,静态代理以及android中的AIDL跨进程通信,binder机制,ClassLoader加载机制,四大组件的运行原理等等。

本项目代码主要参考维术插件化系列博客示例代码。在此基础上做了大量的版本适配(android4.0 ~ android10,android R),以及对代码增加了大量的注释。 维术插件化系列博客和示例代码,写的特别好,值得反复学习和思考,在此特别感谢。

万事开头难,学习的过程是辛苦的,对遇到的知识点采用各个击破的方法,对四大组件流程分析文章进行反复的阅读和理解,日积月累,会有所收获。

示例代码适配情况如下:

版本\组件 api Activity Service BroadcastReceiver ContentProvider
androidR R
android29 10.0
android28 9.0
android27 8.1
android26 8.0
android25 7.1.1
android24 7.0
android23 6.0
android22 5.1
android21 5.0
android19 4.4
android18 4.3
android17 4.2
android16 4.1
android15 4.0.3

✅表示测试通过.

本项目特色:

  1. Activity的插件化,提供了2种方式:Hook IActivityManager和Hook Instrumentation
  2. 加载插件中的类,提供了2种方式去Hook BaseDexClassLoader
  3. 示例代码均提供详尽的注释,提供插件化入门的基础知识点
  4. 提供方便的调试脚本
  5. 提供了通用的项目gradle配置和混淆配置

要彻底搞清楚代码,需要提前掌握的知识点如下:

  1. 反射的使用1
  2. 反射的使用2
  3. 泛型
  4. 动态代理
  5. AIDL通信
  6. Activity启动流程以及其中涉及到的两次跨进程通信
  7. Handler消息处理机制

问题思考

  1. 如何确保我们启动的未注册的Activity,有正常的Activity生命周期?

源码探索系列29---插件化基础之启动插件的Activity

  1. 从整体宏观的角度看,我们到底做了什么?

  2. 对PackageManager的hook,为什么要hook两个地方

hook技术(三)对AMS&PMS进行Hook

@Override
public PackageManager getPackageManager() {
    if (mPackageManager != null) {
        return mPackageManager;
    }
    IPackageManager pm = ActivityThread.getPackageManager();
    if (pm != null) {
        return (mPackageManager = new ApplicationPackageManager(this pm));
    }
    return null;
}

由于系统的执行肯定在我们代码之前,所以系统先生成了一个pm,这个是原生的pm,然后保存在ApplicationPackageManager中, 使得以后使用ContextImp.getPackageManager()都返回这个IPackageManager 对象。 就算我们后来替换了ActivityThread.getPackageManager(),但是也不影响mPackageManager 里面之前包装好的。 所以我们还需要改变mPackageManager 里面的原来的pm对象。

  1. Hook AMS和Hook Instrumentation两种方式的区别?

  2. 为什么偶尔出现pre-verified异常? 这个问题属于dex热修复范畴。首先出现这个问题的充分条件: (1) 一个“独善其身”的A.dex(所有的类引用都在本dex内,没有跨dex调用) (2) 另一个B.dex包含(1)中的某个类XiaoMing (3) 一个类加载器同时加载了(1)跟(2),查找时(2)优先于(1) 当程序试图调用XiaoMing时,在B中发现了,但是回头一看XiaoMing早已被A包养了。遂崩溃。 通常我们并不满足(1)。插件并非独立的,或多或少依赖于宿主包或者公共库,难以“独善其身”,无法被打上CLASS_ISPREVERIFIED标签。 当出现这个问题时,请确认在不同的插件中是否引用了同一个第三方库或者其不同版本。

参考文章列表

  1. Android:学习AIDL,这一篇文章就够了(上)
  2. Android:学习AIDL,这一篇文章就够了(下)
  3. 大白话说Java反射:入门、使用、原理
  4. Hook机制之动态代理
  5. Android插件化原理解析——Hook机制之Binder Hook
  6. Android 插件化原理解析——Activity生命周期管理
  7. Android 插件化原理解析——插件加载机制
  8. Android插件化原理解析——广播的管理
  9. Android 插件化原理解析——Service的插件化
  10. Android插件化原理解析——ContentProvider的插件化
  11. Android 插件化原理解析——Hook机制之AMS&PMS
  12. Android系统篇之----Hook系统的AMS服务实现应用启动的拦截功能
  13. Android插件化的兼容性(中):Android P的适配
  14. Android Hook Activity 的几种姿势

License

AndroidComponentPlugin is Apache License 2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].