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

Commit 774b3788 authored by Achim Thesmann's avatar Achim Thesmann
Browse files

Fix AlarmManagerServiceTest to use API

Use the ActivityOptions API instead of accessing the underlying Bundle.

The Bundle representing the ActivityOptions is internal and may change,
so accessing it directly should be avoided where possible.

Test: atest AlarmManagerServiceTest
Bug: 341140181
Flag: EXEMPT bugfix

Change-Id: I655bc055ff7d243870e230dd93821206edd5242e
parent 3bbbc1a6
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -3094,13 +3094,14 @@ public final class AlarmManagerServiceTest {
        ArgumentCaptor<Bundle> bundleCaptor = ArgumentCaptor.forClass(Bundle.class);
        verify(alarmPi).send(eq(mMockContext), eq(0), any(Intent.class),
                any(), any(Handler.class), isNull(), bundleCaptor.capture());
        Bundle bundle = bundleCaptor.getValue();
        if (idleOptions != null) {
            assertEquals(idleOptions, bundleCaptor.getValue());
            assertEquals(idleOptions, bundle);
        } else {
            assertFalse("BAL flag needs to be false in alarm manager",
                    bundleCaptor.getValue().getBoolean(
                            ActivityOptions.KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED,
                            true));
            ActivityOptions options = ActivityOptions.fromBundle(bundle);
            assertEquals("BAL should not be allowed in alarm manager",
                    ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_DENIED,
                    options.getPendingIntentBackgroundActivityStartMode());
        }
    }