Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cb9a5468 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Enable Notifications on AndroidTV"

parents 23621825 05f34798
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -5428,7 +5428,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
@@ -5470,10 +5471,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;
        }

+2 −1
Original line number Diff line number Diff line
@@ -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());
+3 −0
Original line number Diff line number Diff line
@@ -3175,6 +3175,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
+2 −0
Original line number Diff line number Diff line
@@ -2970,6 +2970,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" />
+9 −4
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;

/**
@@ -338,7 +339,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);
@@ -363,6 +364,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);
                        }
@@ -370,6 +374,7 @@ abstract public class ManagedServices {
                    }
                }
            }
        }
        rebindServices(false);
    }

Loading