当前自启动
private final String[] mActions = new String[] {
Intent.ACTION_PACKAGE_CHANGED, Intent.ACTION_PACKAGE_ADDED, Intent.ACTION_PACKAGE_REMOVED, Intent.ACTION_PACKAGE_REPLACED, Intent.ACTION_BOOT_COMPLETED,
ConnectivityManager.CONNECTIVITY_ACTION, "android.intent.action.ANY_DATA_STATE", "android.intent.action.NEW_OUTGOING_CALL", "android.intent.action.PHONE_STATE", Intent.ACTION_USER_PRESENT,
"android.net.wifi.STATE_CHANGE", "android.net.wifi.WIFI_STATE_CHANGED", Intent.ACTION_TIME_CHANGED, BluetoothAdapter.ACTION_STATE_CHANGED, Intent.ACTION_POWER_CONNECTED,
Intent.ACTION_POWER_DISCONNECTED, "android.net.conn.CONNECTIVITY_CHANGE", Intent.ACTION_MEDIA_EJECT, Intent.ACTION_MEDIA_MOUNTED
};
实现机制PackageManager.setComponentEnableSetting
adb shell pm grant com.qihoo.sleep android.permission.CHANGE_COMPONENT_ENABLED_STATE
Operation not allowed: java.lang.SecurityException: Permission android.permission.CHANGE_COMPONENT_ENABLED_STATE is not a changeable permission type
Rom自身方案
-
HUAWEI(EMUI)
com.huawei.systemmanager
自启主界面Activity可正常唤起
关联自启Activity(exported = false)无法直接唤起,只能引导用户从主界面进入
-
SAMSUNG
锁屏后经常有这种log:
E/MARsPolicyManager: Package: com.baidu.yuedu hostingType: broadcast is Restricted by policy: autorunpolicy(4) caller is: ProcessRecord{726fc06 1267:system/1000}
E/MARsPolicyManager: Package: com.financial360.nicaifu hostingType: broadcast is Restricted by policy: autorunpolicy(4) caller is: ProcessRecord{726fc06 1267:system/1000}
锁屏后kb&禁止唤醒,并没有forcestop,除非设置白名单(即使在白名单中7天未使用也会禁止唤醒)。
UI不是通过Setting,而是自带的StartManager
同样二级页不可直接唤起
$ adb shell am start -n com.samsung.android.sm/.ui.ram.RamActivity
Starting: Intent { cmp=com.samsung.android.sm/.ui.ram.RamActivity }
java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=com.samsung.android.sm/.ui.ram.RamActivity } from null (pid=22393, uid=2000) not exported from uid 1000
at android.os.Parcel.readException(Parcel.java:1620)
at android.os.Parcel.readException(Parcel.java:1573)
at android.app.ActivityManagerProxy.startActivityAsUser(ActivityManagerNative.java:3170)
at com.android.commands.am.Am.runStart(Am.java:903)
at com.android.commands.am.Am.onRun(Am.java:362)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
at com.android.commands.am.Am.main(Am.java:103)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:257)
-
MIUI
不允许自启动:
broadcast唤醒失败
W/BroadcastQueueInjector: Unable to launch app com.qihoo.cleandroid_cn/10285 for broadcast Intent { act=com.qihoo360.mobilesafe.opti.schedule.ACTION_INIT_SCHEDULE flg=0x30 pkg=com.qihoo.cleandroid_cn }: process is not permitted to auto start
service唤醒失败
W/WakePathChecker: MIUILOG-WAKEPATH: call was rejected by wakepath. userId= 0 caller= com.example.myapplication2 callee= com.qihoo.cleandroid_cn classname=com.qihoo360.mobilesafe.opti.service.ExportedService action=com.qihoo.cleandroid_cn.QihooAlliance wakeType=8
允许自启动:
broadcast唤醒成功
D/WtComponentManager: start the package is com.qihoo.cleandroid_cn the call is com.example.myapplication2 startType is 4
D/BroadcastLimitPolicy: [ALLOW] [broadcast] callerPackage com.example.myapplication2 start process with Intent { act=com.qihoo360.mobilesafe.opti.schedule.ACTION_INIT_SCHEDULE flg=0x30 pkg=com.qihoo.cleandroid_cn } componentName com.qihoo.cleandroid_cn/com.qihoo360.mobilesafe.opti.schedule.ScheduleInitReceiver [reason:3]
service唤醒失败
D/WtComponentManager: start the package is com.qihoo.cleandroid_cn the call is com.example.myapplication2 startType is 2
D/LimitPushControlPolicy: check if com.qihoo.cleandroid_cn:resident is a push
D/LimitPushControlPolicy: com.qihoo.cleandroid_cn:resident is not a push
W/ActivityManager: Background start not allowed: service Intent { act=com.qihoo.cleandroid_cn.QihooAlliance pkg=com.qihoo.cleandroid_cn } to com.qihoo.cleandroid_cn/com.qihoo360.mobilesafe.opti.service.ExportedService from pid=21944 uid=10120 pkg=com.example.myapplication2
小米安全中心:com.miui.securitycenter
自启动管理页面可直接唤起
VIVO(Funtouch OS):
com.vivo.permissionmanager/.activity.BgStartUpManagerActivity
自启动页面无法唤起
$ adb shell am start -n com.vivo.permissionmanager/.activity.BgStartUpManagerActivity
Starting: Intent { cmp=com.vivo.permissionmanager/.activity.BgStartUpManagerActivity }
java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=com.vivo.permissionmanager/.activity.BgStartUpManagerActivity } from null (pid=28141, uid=2000) not exported from uid 1000
at android.os.Parcel.readException(Parcel.java:1684)
at android.os.Parcel.readException(Parcel.java:1637)
at android.app.ActivityManagerProxy.startActivityAsUser(ActivityManagerNative.java:3228)
at com.android.commands.am.Am.runStart(Am.java:643)
at com.android.commands.am.Am.onRun(Am.java:394)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:51)
at com.android.commands.am.Am.main(Am.java:124)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:262)
service无法唤醒stopped包(无论是否允许自启动)
W/ActivityManager: mCallerApp.pid =5980,mCallerApp.uid=10237
W/ActivityManager: mCallingPidFilter=5980,mCallingUidFilter=10237
W/ActivityManager: ==/==>: com.qihoo.sleep/10235 for service callerPackage com.qihoo.waker Intent { act=com.example.myapplication.wake pkg=com.qihoo.sleep }: XXXX
broadcast允许自启动正常唤醒,否则无法唤醒。并无ActivityManager log输出
W/BroadcastQueue: ==/==> com.qihoo.sleep/10235 for broadcast Intent { act=com.example.myapplication.wake flg=0x30 }: XXXX
关联自启页面Activity
adb shell am start -n com.vivo.appfilter/.activity.StartupManagerActivityRom30
OPPO(ColorOS)
com.coloros.safecenter
$ adb shell am start -n com.coloros.safecenter/.startupapp.AssociateStartActivity
Starting: Intent { cmp=com.coloros.safecenter/.startupapp.AssociateStartActivity }
java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=com.coloros.safecenter/.startupapp.AssociateStartActivity } from null (pid=10855, uid=2000) requires oppo.permission.OPPO_COMPONENT_SAFE
at android.os.Parcel.readException(Parcel.java:1694)
at android.os.Parcel.readException(Parcel.java:1647)
at android.app.ActivityManagerProxy.startActivityAsUser(ActivityManagerNative.java:3232)
at com.android.commands.am.Am.runStart(Am.java:635)
at com.android.commands.am.Am.onRun(Am.java:388)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:51)
at com.android.commands.am.Am.main(Am.java:121)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:364)
adb shell cmd package list permissions -f > ./1.txt
- permission:oppo.permission.OPPO_COMPONENT_SAFE
package:oppo
label:null
description:null
protectionLevel:signature|privileged
但是可以唤起他们的上一级Activity