From c31d0a8456dc29b293726360eb1785b1e232a6e3 Mon Sep 17 00:00:00 2001 From: Reema Bajwa Date: Tue, 13 Jun 2023 18:15:04 +0000 Subject: [PATCH] Propagate the right permission information on empty prepare response This is a bug discovered by our QA team. The bug causes the calling app to crash and hence, is critical to fix. Bug: 286519644 Test: Built & deployed locally on device Change-Id: Ie66e667dd0b8f581402e2e6202dee6c532e6d165 --- .../credentials/CredentialManagerService.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/services/credentials/java/com/android/server/credentials/CredentialManagerService.java b/services/credentials/java/com/android/server/credentials/CredentialManagerService.java index cadee6f06aad9..a1199d99f1c3d 100644 --- a/services/credentials/java/com/android/server/credentials/CredentialManagerService.java +++ b/services/credentials/java/com/android/server/credentials/CredentialManagerService.java @@ -21,6 +21,7 @@ import static android.Manifest.permission.CREDENTIAL_MANAGER_SET_ORIGIN; import static android.content.Context.CREDENTIAL_SERVICE; import static android.content.pm.PackageManager.PERMISSION_GRANTED; +import android.Manifest; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UserIdInt; @@ -55,6 +56,7 @@ import android.provider.DeviceConfig; import android.provider.Settings; import android.service.credentials.CallingAppInfo; import android.service.credentials.CredentialProviderInfoFactory; +import android.service.credentials.PermissionUtils; import android.text.TextUtils; import android.util.Pair; import android.util.Slog; @@ -546,11 +548,16 @@ public final class CredentialManagerService if (providerSessions.isEmpty()) { try { - // TODO: fix prepareGetCredentialCallback.onResponse( - new PrepareGetCredentialResponseInternal( - false, null, - false, false, null)); + new PrepareGetCredentialResponseInternal(PermissionUtils.hasPermission( + mContext, + callingPackage, + Manifest.permission + .CREDENTIAL_MANAGER_QUERY_CANDIDATE_CREDENTIALS), + /*credentialResultTypes=*/null, + /*hasAuthenticationResults=*/false, + /*hasRemoteResults=*/false, + /*pendingIntent=*/null)); } catch (RemoteException e) { Slog.e( TAG,