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

Commit 76634103 authored by Jerry Shi's avatar Jerry Shi
Browse files

Add nullness check to avoid crashing.

Bug: 317445993
Test: unit Test
Change-Id: I7e229455ea54f4f6a152884f981f008f06d8ddf6
parent 8382b022
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 =