Android 应用插件化及其进程关系梳理
插件应用的AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"coreApp="true"package="com.demo.phone"android:sharedUserId="android.uid.phone"><uses-sdk android:minSdkVersion="28" /><uses-permission android:name="android.permission.POST_NOTIFICATIONS"/><applicationandroid:defaultToDeviceProtectedStorage="true"android:directBootAware="true"android:label="@string/phone_label"android:process="com.android.phone"android:supportsRtl="true"android:theme="@style/Theme.Settings"><activity android:name="com.demo.MainActivity"android:exported="true"><intent-filter><action android:name="android.intent.action.MAIN" /></intent-filter></activity><!-- 定义插件接口PhonePlugin,并且插件在清单列表中声明为 Service --><!-- Must declare plugin as Service,the action should the same as IPluginTest.action(stay consistent) --><service android:name="com.demo.phone.PhonePlugin"android:exported="true"><intent-filter><action android:name="com.demo.plugin.phone"/></intent-filter></service><activity android:name="com.demo.phone.PhoneActivity"android:label="@string/phone_settings"android:exported="true"android:configChanges="orientation|keyboardHidden|screenSize"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.DEFAULT" /></intent-filter><intent-filter android:priority="1"><action android:name="android.settings.PHONE_SETTINGS" /> <!--这个自定义或者用原生的--><category android:name="android.intent.category.DEFAULT" /></intent-filter><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.DEFAULT" /><category android:name="android.intent.category.VOICE_LAUNCH" /></intent-filter></activity>
说明运行在Phone进程(待优化)
android:sharedUserId="android.uid.phone"
android:process="com.android.phone"