Loading core/java/android/app/Notification.java +9 −4 Original line number Diff line number Diff line Loading @@ -5553,7 +5553,8 @@ public class Notification implements Parcelable * * @hide */ public static Notification maybeCloneStrippedForDelivery(Notification n, boolean isLowRam) { public static Notification maybeCloneStrippedForDelivery(Notification n, boolean isLowRam, Context context) { String templateClass = n.extras.getString(EXTRA_TEMPLATE); // Only strip views for known Styles because we won't know how to Loading Loading @@ -5595,10 +5596,14 @@ public class Notification implements Parcelable clone.extras.remove(EXTRA_REBUILD_HEADS_UP_CONTENT_VIEW_ACTION_COUNT); } if (isLowRam) { String[] allowedServices = context.getResources().getStringArray( R.array.config_allowedManagedServicesOnLowRamDevices); if (allowedServices.length == 0) { clone.extras.remove(Notification.TvExtender.EXTRA_TV_EXTENDER); clone.extras.remove(WearableExtender.EXTRA_WEARABLE_EXTENSIONS); clone.extras.remove(CarExtender.EXTRA_CAR_EXTENDER); } } return clone; } Loading core/java/android/app/NotificationManager.java +2 −1 Original line number Diff line number Diff line Loading @@ -399,7 +399,8 @@ public class NotificationManager { ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); boolean isLowRam = am.isLowRamDevice(); final Notification copy = Builder.maybeCloneStrippedForDelivery(notification, isLowRam); final Notification copy = Builder.maybeCloneStrippedForDelivery(notification, isLowRam, mContext); try { service.enqueueNotificationWithTag(pkg, mContext.getOpPackageName(), tag, id, copy, user.getIdentifier()); Loading core/res/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -3181,6 +3181,9 @@ <!-- An array of packages for which notifications cannot be blocked. --> <string-array translatable="false" name="config_nonBlockableNotificationPackages" /> <!-- An array of packages which can listen for notifications on low ram devices. --> <string-array translatable="false" name="config_allowedManagedServicesOnLowRamDevices" /> <!-- The default value for transition animation scale found in developer settings. 1.0 corresponds to 1x animator scale, 0 means that there will be no transition animations. Note that this is only a default and will be overridden by a Loading core/res/res/values/symbols.xml +2 −0 Original line number Diff line number Diff line Loading @@ -2980,6 +2980,8 @@ <java-symbol type="array" name="config_nonBlockableNotificationPackages" /> <java-symbol type="array" name="config_allowedManagedServicesOnLowRamDevices" /> <!-- Screen-size-dependent modes for picker dialogs. --> <java-symbol type="integer" name="time_picker_mode" /> <java-symbol type="integer" name="date_picker_mode" /> Loading services/core/java/com/android/server/notification/ManagedServices.java +10 −4 Original line number Diff line number Diff line Loading @@ -72,6 +72,8 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.function.Predicate; import java.util.stream.Collectors; /** * Manages the lifecycle of application-provided services bound by system server. Loading Loading @@ -336,7 +338,7 @@ abstract public class ManagedServices { loadAllowedComponentsFromSettings(); } public void readXml(XmlPullParser parser) public void readXml(XmlPullParser parser, Predicate<String> allowedManagedServicePackages) throws XmlPullParserException, IOException { // upgrade xml int xmlVersion = XmlUtils.readIntAttribute(parser, ATT_VERSION, 0); Loading @@ -361,6 +363,9 @@ abstract public class ManagedServices { final int userId = XmlUtils.readIntAttribute(parser, ATT_USER_ID, 0); final boolean isPrimary = XmlUtils.readBooleanAttribute(parser, ATT_IS_PRIMARY, true); if (allowedManagedServicePackages == null || allowedManagedServicePackages.test(getPackageName(approved))) { if (mUm.getUserInfo(userId) != null) { addApprovedList(approved, userId, isPrimary); } Loading @@ -368,6 +373,7 @@ abstract public class ManagedServices { } } } } rebindServices(false); } Loading Loading
core/java/android/app/Notification.java +9 −4 Original line number Diff line number Diff line Loading @@ -5553,7 +5553,8 @@ public class Notification implements Parcelable * * @hide */ public static Notification maybeCloneStrippedForDelivery(Notification n, boolean isLowRam) { public static Notification maybeCloneStrippedForDelivery(Notification n, boolean isLowRam, Context context) { String templateClass = n.extras.getString(EXTRA_TEMPLATE); // Only strip views for known Styles because we won't know how to Loading Loading @@ -5595,10 +5596,14 @@ public class Notification implements Parcelable clone.extras.remove(EXTRA_REBUILD_HEADS_UP_CONTENT_VIEW_ACTION_COUNT); } if (isLowRam) { String[] allowedServices = context.getResources().getStringArray( R.array.config_allowedManagedServicesOnLowRamDevices); if (allowedServices.length == 0) { clone.extras.remove(Notification.TvExtender.EXTRA_TV_EXTENDER); clone.extras.remove(WearableExtender.EXTRA_WEARABLE_EXTENSIONS); clone.extras.remove(CarExtender.EXTRA_CAR_EXTENDER); } } return clone; } Loading
core/java/android/app/NotificationManager.java +2 −1 Original line number Diff line number Diff line Loading @@ -399,7 +399,8 @@ public class NotificationManager { ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); boolean isLowRam = am.isLowRamDevice(); final Notification copy = Builder.maybeCloneStrippedForDelivery(notification, isLowRam); final Notification copy = Builder.maybeCloneStrippedForDelivery(notification, isLowRam, mContext); try { service.enqueueNotificationWithTag(pkg, mContext.getOpPackageName(), tag, id, copy, user.getIdentifier()); Loading
core/res/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -3181,6 +3181,9 @@ <!-- An array of packages for which notifications cannot be blocked. --> <string-array translatable="false" name="config_nonBlockableNotificationPackages" /> <!-- An array of packages which can listen for notifications on low ram devices. --> <string-array translatable="false" name="config_allowedManagedServicesOnLowRamDevices" /> <!-- The default value for transition animation scale found in developer settings. 1.0 corresponds to 1x animator scale, 0 means that there will be no transition animations. Note that this is only a default and will be overridden by a Loading
core/res/res/values/symbols.xml +2 −0 Original line number Diff line number Diff line Loading @@ -2980,6 +2980,8 @@ <java-symbol type="array" name="config_nonBlockableNotificationPackages" /> <java-symbol type="array" name="config_allowedManagedServicesOnLowRamDevices" /> <!-- Screen-size-dependent modes for picker dialogs. --> <java-symbol type="integer" name="time_picker_mode" /> <java-symbol type="integer" name="date_picker_mode" /> Loading
services/core/java/com/android/server/notification/ManagedServices.java +10 −4 Original line number Diff line number Diff line Loading @@ -72,6 +72,8 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.function.Predicate; import java.util.stream.Collectors; /** * Manages the lifecycle of application-provided services bound by system server. Loading Loading @@ -336,7 +338,7 @@ abstract public class ManagedServices { loadAllowedComponentsFromSettings(); } public void readXml(XmlPullParser parser) public void readXml(XmlPullParser parser, Predicate<String> allowedManagedServicePackages) throws XmlPullParserException, IOException { // upgrade xml int xmlVersion = XmlUtils.readIntAttribute(parser, ATT_VERSION, 0); Loading @@ -361,6 +363,9 @@ abstract public class ManagedServices { final int userId = XmlUtils.readIntAttribute(parser, ATT_USER_ID, 0); final boolean isPrimary = XmlUtils.readBooleanAttribute(parser, ATT_IS_PRIMARY, true); if (allowedManagedServicePackages == null || allowedManagedServicePackages.test(getPackageName(approved))) { if (mUm.getUserInfo(userId) != null) { addApprovedList(approved, userId, isPrimary); } Loading @@ -368,6 +373,7 @@ abstract public class ManagedServices { } } } } rebindServices(false); } Loading