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

Commit 4552300e authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Trim invalid users

Change-Id: Ie7eab5c38ed7c6a58dcf2fa8c568fb576306852a
Fixes: 64725440
Test: runtest systemui-notification
parent cb507b82
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -99,6 +99,7 @@ abstract public class ManagedServices {
    protected final Object mMutex;
    private final UserProfiles mUserProfiles;
    private final IPackageManager mPm;
    private final UserManager mUm;
    private final Config mConfig;

    // contains connections to all connected services, including app services
@@ -138,6 +139,7 @@ abstract public class ManagedServices {
        mPm = pm;
        mConfig = getConfig();
        mApprovalLevel = APPROVAL_BY_COMPONENT;
        mUm = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
    }

    abstract protected Config getConfig();
@@ -296,7 +298,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 (mUm.getUserInfo(userId) != null) {
                        addApprovedList(approved, userId, isPrimary);
                    }
                    mUseXml = true;
                }
            }
+16 −0
Original line number Diff line number Diff line
@@ -254,6 +254,14 @@ public class ManagedServicesTest extends NotificationTestCase {
            loadXml(service);

            verifyExpectedApprovedEntries(service);

            int[] invalidUsers = new int[] {98, 99};
            for (int invalidUser : invalidUsers) {
                assertFalse("service type " + service.mApprovalLevel + ":"
                                + invalidUser + " is allowed for user " + invalidUser,
                        service.isPackageOrComponentAllowed(
                                String.valueOf(invalidUser), invalidUser));
            }
        }
    }

@@ -616,6 +624,14 @@ public class ManagedServicesTest extends NotificationTestCase {
            xml.append(getXmlEntry(
                    mExpectedSecondary.get(service.mApprovalLevel).get(userId), userId, false));
        }
        xml.append("<" + ManagedServices.TAG_MANAGED_SERVICES + " "
                        + ManagedServices.ATT_USER_ID + "=\"99\" "
                        + ManagedServices.ATT_IS_PRIMARY + "=\"true\" "
                        + ManagedServices.ATT_APPROVED_LIST + "=\"99\" />\n");
        xml.append("<" + ManagedServices.TAG_MANAGED_SERVICES + " "
                + ManagedServices.ATT_USER_ID + "=\"98\" "
                + ManagedServices.ATT_IS_PRIMARY + "=\"false\" "
                + ManagedServices.ATT_APPROVED_LIST + "=\"98\" />\n");
        xml.append("</" + service.getConfig().xmlTag + ">");

        XmlPullParser parser = Xml.newPullParser();