當(dāng)前自啟動(dòng)
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
};
實(shí)現(xiàn)機(jī)制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可正常喚起
關(guān)聯(lián)自啟Activity(exported = false)無(wú)法直接喚起,只能引導(dǎo)用戶從主界面進(jìn)入
-
SAMSUNG
鎖屏后經(jīng)常有這種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&禁止喚醒著隆,并沒(méi)有forcestop,除非設(shè)置白名單(即使在白名單中7天未使用也會(huì)禁止喚醒)。
UI不是通過(guò)Setting通贞,而是自帶的StartManager
同樣二級(jí)頁(yè)不可直接喚起
$ 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
不允許自啟動(dòng):
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
允許自啟動(dòng):
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
自啟動(dòng)管理頁(yè)面可直接喚起
VIVO(Funtouch OS):
com.vivo.permissionmanager/.activity.BgStartUpManagerActivity
自啟動(dòng)頁(yè)面無(wú)法喚起
$ 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無(wú)法喚醒stopped包(無(wú)論是否允許自啟動(dòng))
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允許自啟動(dòng)正常喚醒惑折,否則無(wú)法喚醒艾君。并無(wú)ActivityManager log輸出
W/BroadcastQueue: ==/==> com.qihoo.sleep/10235 for broadcast Intent { act=com.example.myapplication.wake flg=0x30 }: XXXX
關(guān)聯(lián)自啟頁(yè)面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
但是可以喚起他們的上一級(jí)Activity