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

Commit 3ec553e2 authored by Gavin Corkery's avatar Gavin Corkery Committed by Android (Google) Code Review
Browse files

Merge "Remove NPE in onPackageFailure" into rvc-dev

parents 3bdd15fb 9da918c7
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -354,6 +354,10 @@ public class PackageWatchdog {
     */
     */
    public void onPackageFailure(List<VersionedPackage> packages,
    public void onPackageFailure(List<VersionedPackage> packages,
            @FailureReasons int failureReason) {
            @FailureReasons int failureReason) {
        if (packages == null) {
            Slog.w(TAG, "Could not resolve a list of failing packages");
            return;
        }
        mLongTaskHandler.post(() -> {
        mLongTaskHandler.post(() -> {
            synchronized (mLock) {
            synchronized (mLock) {
                if (mAllObservers.isEmpty()) {
                if (mAllObservers.isEmpty()) {
+14 −0
Original line number Original line Diff line number Diff line
@@ -1063,6 +1063,20 @@ public class PackageWatchdogTest {
        assertThat(bootObserver2.mitigatedBootLoop()).isFalse();
        assertThat(bootObserver2.mitigatedBootLoop()).isFalse();
    }
    }


    /**
     * Ensure that passing a null list of failed packages does not cause any mitigation logic to
     * execute.
     */
    @Test
    public void testNullFailedPackagesList() {
        PackageWatchdog watchdog = createWatchdog();
        TestObserver observer1 = new TestObserver(OBSERVER_NAME_1);
        watchdog.startObservingHealth(observer1, List.of(APP_A), LONG_DURATION);

        raiseFatalFailureAndDispatch(watchdog, null, PackageWatchdog.FAILURE_REASON_APP_CRASH);
        assertThat(observer1.mMitigatedPackages).isEmpty();
    }

    private void adoptShellPermissions(String... permissions) {
    private void adoptShellPermissions(String... permissions) {
        InstrumentationRegistry
        InstrumentationRegistry
                .getInstrumentation()
                .getInstrumentation()