Loading core/java/android/app/ActivityManager.java +11 −1 Original line number Diff line number Diff line Loading @@ -5167,11 +5167,21 @@ public class ActivityManager { * @hide */ public static void broadcastStickyIntent(Intent intent, int appOp, Bundle options, int userId) { broadcastStickyIntent(intent, null, appOp, options, userId); } /** * Convenience for sending a sticky broadcast. For internal use only. * * @hide */ public static void broadcastStickyIntent(Intent intent, String[] excludedPackages, int appOp, Bundle options, int userId) { try { getService().broadcastIntentWithFeature( null, null, intent, null, null, Activity.RESULT_OK, null, null, null /*requiredPermissions*/, null /*excludedPermissions*/, null /*excludedPackages*/, appOp, options, false, true, userId); excludedPackages, appOp, options, false, true, userId); } catch (RemoteException ex) { } } Loading services/core/java/com/android/server/BatteryService.java +19 −2 Original line number Diff line number Diff line Loading @@ -167,6 +167,8 @@ public final class BatteryService extends SystemService { private int mBatteryNearlyFullLevel; private int mShutdownBatteryTemperature; private static String sSystemUiPackage; private int mPlugType; private int mLastPlugType = -1; // Extra state so we can detect first run Loading Loading @@ -228,6 +230,8 @@ public final class BatteryService extends SystemService { com.android.internal.R.integer.config_lowBatteryCloseWarningBump); mShutdownBatteryTemperature = mContext.getResources().getInteger( com.android.internal.R.integer.config_shutdownBatteryTemperature); sSystemUiPackage = mContext.getResources().getString( com.android.internal.R.string.config_systemUi); mBatteryLevelsEventQueue = new ArrayDeque<>(); mMetricsLogger = new MetricsLogger(); Loading Loading @@ -750,8 +754,21 @@ public final class BatteryService extends SystemService { + ", info:" + mHealthInfo.toString()); } mHandler.post(() -> ActivityManager.broadcastStickyIntent(intent, AppOpsManager.OP_NONE, mBatteryChangedOptions, UserHandle.USER_ALL)); mHandler.post(() -> broadcastBatteryChangedIntent(intent, mBatteryChangedOptions)); } private static void broadcastBatteryChangedIntent(Intent intent, Bundle options) { // TODO (293959093): It is important that SystemUI receives this broadcast as soon as // possible. Ideally, it should be using binder callbacks but until then, dispatch this // as a foreground broadcast to SystemUI. final Intent fgIntent = new Intent(intent); fgIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); fgIntent.setPackage(sSystemUiPackage); ActivityManager.broadcastStickyIntent(fgIntent, AppOpsManager.OP_NONE, options, UserHandle.USER_ALL); ActivityManager.broadcastStickyIntent(intent, new String[] {sSystemUiPackage}, AppOpsManager.OP_NONE, options, UserHandle.USER_ALL); } private void sendBatteryLevelChangedIntentLocked() { Loading Loading
core/java/android/app/ActivityManager.java +11 −1 Original line number Diff line number Diff line Loading @@ -5167,11 +5167,21 @@ public class ActivityManager { * @hide */ public static void broadcastStickyIntent(Intent intent, int appOp, Bundle options, int userId) { broadcastStickyIntent(intent, null, appOp, options, userId); } /** * Convenience for sending a sticky broadcast. For internal use only. * * @hide */ public static void broadcastStickyIntent(Intent intent, String[] excludedPackages, int appOp, Bundle options, int userId) { try { getService().broadcastIntentWithFeature( null, null, intent, null, null, Activity.RESULT_OK, null, null, null /*requiredPermissions*/, null /*excludedPermissions*/, null /*excludedPackages*/, appOp, options, false, true, userId); excludedPackages, appOp, options, false, true, userId); } catch (RemoteException ex) { } } Loading
services/core/java/com/android/server/BatteryService.java +19 −2 Original line number Diff line number Diff line Loading @@ -167,6 +167,8 @@ public final class BatteryService extends SystemService { private int mBatteryNearlyFullLevel; private int mShutdownBatteryTemperature; private static String sSystemUiPackage; private int mPlugType; private int mLastPlugType = -1; // Extra state so we can detect first run Loading Loading @@ -228,6 +230,8 @@ public final class BatteryService extends SystemService { com.android.internal.R.integer.config_lowBatteryCloseWarningBump); mShutdownBatteryTemperature = mContext.getResources().getInteger( com.android.internal.R.integer.config_shutdownBatteryTemperature); sSystemUiPackage = mContext.getResources().getString( com.android.internal.R.string.config_systemUi); mBatteryLevelsEventQueue = new ArrayDeque<>(); mMetricsLogger = new MetricsLogger(); Loading Loading @@ -750,8 +754,21 @@ public final class BatteryService extends SystemService { + ", info:" + mHealthInfo.toString()); } mHandler.post(() -> ActivityManager.broadcastStickyIntent(intent, AppOpsManager.OP_NONE, mBatteryChangedOptions, UserHandle.USER_ALL)); mHandler.post(() -> broadcastBatteryChangedIntent(intent, mBatteryChangedOptions)); } private static void broadcastBatteryChangedIntent(Intent intent, Bundle options) { // TODO (293959093): It is important that SystemUI receives this broadcast as soon as // possible. Ideally, it should be using binder callbacks but until then, dispatch this // as a foreground broadcast to SystemUI. final Intent fgIntent = new Intent(intent); fgIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); fgIntent.setPackage(sSystemUiPackage); ActivityManager.broadcastStickyIntent(fgIntent, AppOpsManager.OP_NONE, options, UserHandle.USER_ALL); ActivityManager.broadcastStickyIntent(intent, new String[] {sSystemUiPackage}, AppOpsManager.OP_NONE, options, UserHandle.USER_ALL); } private void sendBatteryLevelChangedIntentLocked() { Loading