Merge "Copy option data in begin requests"

This commit is contained in:
Reema Bajwa
2023-02-09 18:43:47 +00:00
committed by Android (Google) Code Review
4 changed files with 30 additions and 22 deletions

View File

@@ -25,8 +25,6 @@ import android.os.Parcelable;
import com.android.internal.util.Preconditions;
import java.util.Objects;
/**
* Request for beginning a create credential request.
*
@@ -54,7 +52,9 @@ public class BeginCreateCredentialRequest implements Parcelable {
@Nullable CallingAppInfo callingAppInfo) {
mType = Preconditions.checkStringNotEmpty(type,
"type must not be null or empty");
mData = Objects.requireNonNull(data, "data must not be null");
Bundle dataCopy = new Bundle();
dataCopy.putAll(data);
mData = dataCopy;
mCallingAppInfo = callingAppInfo;
}

View File

@@ -16,8 +16,6 @@
package android.service.credentials;
import static java.util.Objects.requireNonNull;
import android.annotation.NonNull;
import android.annotation.SuppressLint;
import android.os.Bundle;
@@ -60,9 +58,7 @@ public class BeginGetCredentialOption implements Parcelable {
private final Bundle mCandidateQueryData;
/**
* Returns the unique id associated with this request. Providers must pass this id
* to the constructor of {@link CredentialEntry} while creating a candidate credential
* entry for this request option.
* Returns the unique id associated with this request. This is for internal use only.
*/
@NonNull
public String getId() {
@@ -127,8 +123,9 @@ public class BeginGetCredentialOption implements Parcelable {
@NonNull Bundle candidateQueryData) {
mId = id;
mType = Preconditions.checkStringNotEmpty(type, "type must not be empty");
mCandidateQueryData = requireNonNull(
candidateQueryData, "candidateQueryData must not be null");
Bundle bundle = new Bundle();
bundle.putAll(candidateQueryData);
mCandidateQueryData = bundle;
addIdToBundle();
}

View File

@@ -77,14 +77,19 @@ public final class ProviderCreateSession extends ProviderSession<
createRequestSession.mClientRequest,
createRequestSession.mClientAppInfo);
if (providerCreateRequest != null) {
BeginCreateCredentialRequest providerBeginCreateRequest =
return new ProviderCreateSession(
context,
providerInfo,
createRequestSession,
userId,
remoteCredentialService,
constructQueryPhaseRequest(createRequestSession.mClientRequest.getType(),
createRequestSession.mClientRequest.getCandidateQueryData(),
createRequestSession.mClientAppInfo,
createRequestSession
.mClientRequest.alwaysSendAppInfoToProvider());
return new ProviderCreateSession(context, providerInfo, createRequestSession, userId,
remoteCredentialService, providerBeginCreateRequest, providerCreateRequest);
.mClientRequest.alwaysSendAppInfoToProvider()),
providerCreateRequest
);
}
Log.i(TAG, "Unable to create provider session");
return null;

View File

@@ -97,14 +97,20 @@ public final class ProviderGetSession extends ProviderSession<BeginGetCredential
if (filteredRequest != null) {
Map<String, CredentialOption> beginGetOptionToCredentialOptionMap =
new HashMap<>();
BeginGetCredentialRequest beginGetCredentialRequest = constructQueryPhaseRequest(
filteredRequest, getRequestSession.mClientAppInfo,
getRequestSession.mClientRequest.alwaysSendAppInfoToProvider(),
beginGetOptionToCredentialOptionMap);
return new ProviderGetSession(context, providerInfo, getRequestSession, userId,
remoteCredentialService, beginGetCredentialRequest, filteredRequest,
return new ProviderGetSession(
context,
providerInfo,
getRequestSession,
userId,
remoteCredentialService,
constructQueryPhaseRequest(
filteredRequest, getRequestSession.mClientAppInfo,
getRequestSession.mClientRequest.alwaysSendAppInfoToProvider(),
beginGetOptionToCredentialOptionMap),
filteredRequest,
getRequestSession.mClientAppInfo,
beginGetOptionToCredentialOptionMap);
beginGetOptionToCredentialOptionMap
);
}
Log.i(TAG, "Unable to create provider session");
return null;
@@ -168,7 +174,7 @@ public final class ProviderGetSession extends ProviderSession<BeginGetCredential
mCompleteRequest = completeGetRequest;
mCallingAppInfo = callingAppInfo;
setStatus(Status.PENDING);
mBeginGetOptionToCredentialOptionMap = beginGetOptionToCredentialOptionMap;
mBeginGetOptionToCredentialOptionMap = new HashMap<>(beginGetOptionToCredentialOptionMap);
}
/** Called when the provider response has been updated by an external source. */