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

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

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

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


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


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