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

Commit 05f34798 authored by Kristian Monsen's avatar Kristian Monsen
Browse files

Enable Notifications on AndroidTV

Also fix some tests that were broken on TV.

Test: runtest systemui-notification

Change-Id: Icf4e5a1e02c3075b466305023c986ada52e9ec93
parent bf813dbd
Loading
Loading
Loading
Loading
+9 −4
Original line number Original line Diff line number Diff line
@@ -5427,7 +5427,8 @@ public class Notification implements Parcelable
         *
         *
         * @hide
         * @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);
            String templateClass = n.extras.getString(EXTRA_TEMPLATE);


            // Only strip views for known Styles because we won't know how to
            // Only strip views for known Styles because we won't know how to
@@ -5469,10 +5470,14 @@ public class Notification implements Parcelable
                clone.extras.remove(EXTRA_REBUILD_HEADS_UP_CONTENT_VIEW_ACTION_COUNT);
                clone.extras.remove(EXTRA_REBUILD_HEADS_UP_CONTENT_VIEW_ACTION_COUNT);
            }
            }
            if (isLowRam) {
            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(Notification.TvExtender.EXTRA_TV_EXTENDER);
                    clone.extras.remove(WearableExtender.EXTRA_WEARABLE_EXTENSIONS);
                    clone.extras.remove(WearableExtender.EXTRA_WEARABLE_EXTENSIONS);
                    clone.extras.remove(CarExtender.EXTRA_CAR_EXTENDER);
                    clone.extras.remove(CarExtender.EXTRA_CAR_EXTENDER);
                }
                }
            }
            return clone;
            return clone;
        }
        }


+2 −1
Original line number Original line Diff line number Diff line
@@ -399,7 +399,8 @@ public class NotificationManager {


        ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
        ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
        boolean isLowRam = am.isLowRamDevice();
        boolean isLowRam = am.isLowRamDevice();
        final Notification copy = Builder.maybeCloneStrippedForDelivery(notification, isLowRam);
        final Notification copy = Builder.maybeCloneStrippedForDelivery(notification, isLowRam,
                mContext);
        try {
        try {
            service.enqueueNotificationWithTag(pkg, mContext.getOpPackageName(), tag, id,
            service.enqueueNotificationWithTag(pkg, mContext.getOpPackageName(), tag, id,
                    copy, user.getIdentifier());
                    copy, user.getIdentifier());
+3 −0
Original line number Original line Diff line number Diff line
@@ -3175,6 +3175,9 @@
    <!-- An array of packages for which notifications cannot be blocked. -->
    <!-- An array of packages for which notifications cannot be blocked. -->
    <string-array translatable="false" name="config_nonBlockableNotificationPackages" />
    <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.
    <!-- 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
         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
         animations. Note that this is only a default and will be overridden by a
+2 −0
Original line number Original line Diff line number Diff line
@@ -2970,6 +2970,8 @@


  <java-symbol type="array" name="config_nonBlockableNotificationPackages" />
  <java-symbol type="array" name="config_nonBlockableNotificationPackages" />


  <java-symbol type="array" name="config_allowedManagedServicesOnLowRamDevices" />

  <!-- Screen-size-dependent modes for picker dialogs. -->
  <!-- Screen-size-dependent modes for picker dialogs. -->
  <java-symbol type="integer" name="time_picker_mode" />
  <java-symbol type="integer" name="time_picker_mode" />
  <java-symbol type="integer" name="date_picker_mode" />
  <java-symbol type="integer" name="date_picker_mode" />
+9 −4
Original line number Original line Diff line number Diff line
@@ -73,6 +73,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.List;
import java.util.Objects;
import java.util.Objects;
import java.util.Set;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Collectors;


/**
/**
@@ -338,7 +339,7 @@ abstract public class ManagedServices {
        loadAllowedComponentsFromSettings();
        loadAllowedComponentsFromSettings();
    }
    }


    public void readXml(XmlPullParser parser)
    public void readXml(XmlPullParser parser, Predicate<String> allowedManagedServicePackages)
            throws XmlPullParserException, IOException {
            throws XmlPullParserException, IOException {
        // upgrade xml
        // upgrade xml
        int xmlVersion = XmlUtils.readIntAttribute(parser, ATT_VERSION, 0);
        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 int userId = XmlUtils.readIntAttribute(parser, ATT_USER_ID, 0);
                    final boolean isPrimary =
                    final boolean isPrimary =
                            XmlUtils.readBooleanAttribute(parser, ATT_IS_PRIMARY, true);
                            XmlUtils.readBooleanAttribute(parser, ATT_IS_PRIMARY, true);

                    if (allowedManagedServicePackages == null ||
                            allowedManagedServicePackages.test(getPackageName(approved))) {
                        if (mUm.getUserInfo(userId) != null) {
                        if (mUm.getUserInfo(userId) != null) {
                            addApprovedList(approved, userId, isPrimary);
                            addApprovedList(approved, userId, isPrimary);
                        }
                        }
@@ -370,6 +374,7 @@ abstract public class ManagedServices {
                    }
                    }
                }
                }
            }
            }
        }
        rebindServices(false);
        rebindServices(false);
    }
    }


Loading