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

Commit 9888ccd2 authored by Jerry Shi's avatar Jerry Shi Committed by Android Build Coastguard Worker
Browse files

Add nullness check to avoid crashing.

Bug: 317445993
Test: unit Test
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:7663410341f784b096593227cf9a7312ac0fb73e)
Merged-In: I7e229455ea54f4f6a152884f981f008f06d8ddf6
Change-Id: I7e229455ea54f4f6a152884f981f008f06d8ddf6
parent 4ece5732
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -65,7 +65,6 @@ import android.util.Slog;
import android.util.SparseArray;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.content.PackageMonitor;
import com.android.server.credentials.metrics.ApiName;
import com.android.server.credentials.metrics.ApiStatus;
import com.android.server.infra.AbstractMasterSystemService;
@@ -1204,6 +1203,9 @@ public final class CredentialManagerService
        // If the app being removed matches any of the package names from
        // this list then don't add it in the output.
        Set<String> providers = new HashSet<>();
        if (rawProviders == null || packageName == null) {
            return providers;
        }
        for (String rawComponentName : rawProviders.split(":")) {
            if (TextUtils.isEmpty(rawComponentName)
                    || rawComponentName.equals("null")) {
+6 −0
Original line number Diff line number Diff line
@@ -52,6 +52,12 @@ public final class CredentialManagerServiceTest {
        assertThat(providers.size()).isEqualTo(0);
    }

    @Test
    public void getStoredProviders_nullValue_success() {
        Set<String> providers = CredentialManagerService.getStoredProviders(null, null);
        assertThat(providers.size()).isEqualTo(0);
    }

    @Test
    public void getStoredProviders_success() {
        Set<String> providers =