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

Commit f5c5e730 authored by Rohan Shah's avatar Rohan Shah Committed by android-build-merger
Browse files

Merge "[Notif] Write AppUid earlier in NotificationInfo" into pi-dev

am: f07d10e3

Change-Id: I06db3710595420f259d8b37c48e2ed31550361c9
parents e5893a78 f07d10e3
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
        mIsForeground =
                (mSbn.getNotification().flags & Notification.FLAG_FOREGROUND_SERVICE) != 0;
        mIsForBlockingHelper = isForBlockingHelper;
        mAppUid = mSbn.getUid();

        int numTotalChannels = mINotificationManager.getNumNotificationChannelsForPackage(
                pkg, mAppUid, false /* includeDeleted */);
@@ -173,9 +174,9 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
        } else  {
            // Special behavior for the Default channel if no other channels have been defined.
            mIsSingleDefaultChannel = mNumNotificationChannels == 1
                    && mSingleNotificationChannel.getId()
                    .equals(NotificationChannel.DEFAULT_CHANNEL_ID)
                    && numTotalChannels <= 1;
                    && mSingleNotificationChannel.getId().equals(
                            NotificationChannel.DEFAULT_CHANNEL_ID)
                    && numTotalChannels == 1;
        }

        try {
@@ -210,7 +211,6 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
                            | PackageManager.MATCH_DIRECT_BOOT_UNAWARE
                            | PackageManager.MATCH_DIRECT_BOOT_AWARE);
            if (info != null) {
                mAppUid = mSbn.getUid();
                mAppName = String.valueOf(mPm.getApplicationLabel(info));
                pkgicon = mPm.getApplicationIcon(info);
            }
+12 −0
Original line number Diff line number Diff line
@@ -217,6 +217,18 @@ public class NotificationInfoTest extends SysuiTestCase {
        assertEquals(GONE, textView.getVisibility());
    }

    @Test
    public void testBindNotification_DefaultChannelUsesChannelNameIfMoreChannelsExist()
            throws Exception {
        // Package has one channel by default.
        when(mMockINotificationManager.getNumNotificationChannelsForPackage(
                eq(TEST_PACKAGE_NAME), eq(TEST_UID), anyBoolean())).thenReturn(10);
        mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
                TEST_PACKAGE_NAME, mDefaultNotificationChannel, 1, mSbn, null, null, null, null);
        final TextView textView = mNotificationInfo.findViewById(R.id.channel_name);
        assertEquals(VISIBLE, textView.getVisibility());
    }

    @Test
    public void testBindNotification_UnblockablePackageUsesChannelName() throws Exception {
        mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,