1.adb shell命令移除:adb shell dumpsys deviceidle whitelist -xxx
调用接口:DeviceIdleController:removePowerSaveWhitelistAppInternal
2.应用卸载事件:Intent.ACTION_PACKAGE_REMOVED
调用接口:DeviceIdleController:removePowerSaveWhitelistAppInternal
3.应用组件发生变化&使用配套设备配对服务(CompanionDeviceManager )&无后台运行权限会触发Doze名单移除
调用接口:
PackageMonitor:Intent.ACTION_PACKAGE_ADDED&Intent.EXTRA_REPLACING/Intent.ACTION_PACKAGE_CHANGED
CompanionDeviceManagerService:onPackageModifiedInternal->
updateSpecialAccessPermissionForAssociatedPackage->updateSpecialAccessPermissionAsSystem
PowerWhitelistManager:removeFromWhitelist
PowerExemptionManager:removeFromPermanentAllowList
IDeviceIdleController:removePowerSaveWhitelistApp
DeviceIdleController:removePowerSaveWhitelistAppInternal
调试代码:
private void onPackageModifiedInternal(@UserIdInt int userId, @NonNull String packageName) {
/*if (DEBUG) */Log.i(TAG, "onPackageModified() u" + userId + "/" + packageName);
// huazhi.su add for test doze white list
if ("com.tencent.mm".equals(packageName)) {
String MAC_ADDRESS = "AA:BB:CC:DD:FF:EE";
AssociationInfo info =
new AssociationInfo(
/* id= */ 10888,
/* userId= */ userId,
"com.tencent.mm",
MacAddress.fromString(MAC_ADDRESS),
"displayName_test",
"deviceProfile_te