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

Commit 678678fc authored by Sarah Kim's avatar Sarah Kim Committed by Android (Google) Code Review
Browse files

Merge "Validate notification canceled intent before processing" into main

parents 12adb88b 7b1f2131
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -494,6 +494,10 @@ public class SlicePurchaseBroadcastReceiver extends BroadcastReceiver{
    }

    private void onUserCanceled(@NonNull Context context, @NonNull Intent intent) {
        if (!isIntentValid(intent)) {
            loge("Ignoring onUserCanceled called with invalid intent.");
            return;
        }
        int capability = intent.getIntExtra(SlicePurchaseController.EXTRA_PREMIUM_CAPABILITY,
                SlicePurchaseController.PREMIUM_CAPABILITY_INVALID);
        logd("onUserCanceled: " + TelephonyManager.convertPremiumCapabilityToString(capability));
+4 −4
Original line number Diff line number Diff line
@@ -262,10 +262,10 @@ public class SlicePurchaseBroadcastReceiverTest {

    @Test
    public void testNotificationCanceled() {
        displayPerformanceBoostNotification();

        // send ACTION_NOTIFICATION_CANCELED
        doReturn("com.android.phone.slice.action.NOTIFICATION_CANCELED").when(mIntent).getAction();
        doReturn(TelephonyManager.PREMIUM_CAPABILITY_PRIORITIZE_LATENCY).when(mIntent).getIntExtra(
                eq(SlicePurchaseController.EXTRA_PREMIUM_CAPABILITY), anyInt());
        mSlicePurchaseBroadcastReceiver.onReceive(mContext, mIntent);

        // verify notification was canceled
@@ -276,7 +276,7 @@ public class SlicePurchaseBroadcastReceiverTest {
    }

    @Test
    public void testNotificationTimeout() throws Exception {
    public void testNotificationTimeout() {
        displayPerformanceBoostNotification();

        // send ACTION_SLICE_PURCHASE_APP_RESPONSE_TIMEOUT
@@ -353,7 +353,7 @@ public class SlicePurchaseBroadcastReceiverTest {
        verify(mNotificationManager, never()).notifyAsUser(
                eq(SlicePurchaseBroadcastReceiver.PERFORMANCE_BOOST_NOTIFICATION_TAG),
                eq(TelephonyManager.PREMIUM_CAPABILITY_PRIORITIZE_LATENCY),
                any(),
                any(Notification.class),
                eq(UserHandle.ALL));
        verify(mNotificationShownIntent, never()).send();