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

Commit dc70cf94 authored by Reema Bajwa's avatar Reema Bajwa
Browse files

Copy option data in begin requests

Test: built locally

Change-Id: If44befceeccaf6ac29e7402c0c9acd8ac150d50b
parent deae386e
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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;
    }

+4 −7
Original line number Diff line number Diff line
@@ -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();
    }

+9 −4
Original line number Diff line number Diff line
@@ -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;
+14 −8
Original line number Diff line number Diff line
@@ -96,14 +96,20 @@ public final class ProviderGetSession extends ProviderSession<BeginGetCredential
        if (filteredRequest != null) {
            Map<String, CredentialOption> beginGetOptionToCredentialOptionMap =
                    new HashMap<>();
            BeginGetCredentialRequest beginGetCredentialRequest = constructQueryPhaseRequest(
            return new ProviderGetSession(
                    context,
                    providerInfo,
                    getRequestSession,
                    userId,
                    remoteCredentialService,
                    constructQueryPhaseRequest(
                            filteredRequest, getRequestSession.mClientAppInfo,
                            getRequestSession.mClientRequest.alwaysSendAppInfoToProvider(),
                    beginGetOptionToCredentialOptionMap);
            return new ProviderGetSession(context, providerInfo, getRequestSession, userId,
                    remoteCredentialService, beginGetCredentialRequest, filteredRequest,
                            beginGetOptionToCredentialOptionMap),
                    filteredRequest,
                    getRequestSession.mClientAppInfo,
                    beginGetOptionToCredentialOptionMap);
                    beginGetOptionToCredentialOptionMap
            );
        }
        Log.i(TAG, "Unable to create provider session");
        return null;
@@ -167,7 +173,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. */