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

Commit 65a9b5c4 authored by Reema Bajwa's avatar Reema Bajwa
Browse files

Invoke Credential Manager UI from the apps process through a pending

intent generated by the framework
Test: Locally built & deployed
Bug: 253155429

Change-Id: I26b5ef385eb4997aafb1e8b321a658e4c09725a0
parent fe5097cf
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -72,9 +72,15 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR

    @Override
    protected void launchUiWithProviderData(ArrayList<ProviderData> providerDataList) {
        mHandler.post(() -> mCredentialManagerUi.show(RequestInfo.newCreateRequestInfo(
        try {
            mClientCallback.onPendingIntent(mCredentialManagerUi.createPendingIntent(
                    RequestInfo.newCreateRequestInfo(
                            mRequestId, mClientRequest, mIsFirstUiTurn, mClientCallingPackage),
                    providerDataList));
        } catch (RemoteException e) {
            Log.i(TAG, "Issue with invoking pending intent: " + e.getMessage());
            // TODO: Propagate failure
        }
    }

    private void respondToClientAndFinish(CreateCredentialResponse response) {
+11 −6
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.server.credentials;

import android.annotation.NonNull;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.credentials.ui.IntentFactory;
@@ -79,14 +80,18 @@ public class CredentialManagerUi {
    }

    /**
     * Surfaces the Credential Manager bottom sheet UI.
     * Creates a {@link PendingIntent} to be used to invoke the credential manager selector UI,
     * by the calling app process.
     * @param requestInfo the information about the request
     * @param providerDataList the list of provider data from remote providers
     */
    public void show(RequestInfo requestInfo, ArrayList<ProviderData> providerDataList) {
        Log.i(TAG, "In show");
    public PendingIntent createPendingIntent(
            RequestInfo requestInfo, ArrayList<ProviderData> providerDataList) {
        Log.i(TAG, "In createPendingIntent");
        Intent intent = IntentFactory.newIntent(requestInfo, providerDataList, new ArrayList<>(),
                mResultReceiver);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mContext.startActivity(intent);
                mResultReceiver).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        //TODO: Determine if a specific request code is needed
        return PendingIntent.getActivity(
                mContext, /*requestCode=*/0, intent, PendingIntent.FLAG_IMMUTABLE);
    }
}
+9 −3
Original line number Diff line number Diff line
@@ -68,9 +68,15 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest

    @Override
    protected void launchUiWithProviderData(ArrayList<ProviderData> providerDataList) {
        mHandler.post(() -> mCredentialManagerUi.show(RequestInfo.newGetRequestInfo(
        try {
            mClientCallback.onPendingIntent(mCredentialManagerUi.createPendingIntent(
                    RequestInfo.newGetRequestInfo(
                    mRequestId, null, mIsFirstUiTurn, ""),
                    providerDataList));
        } catch (RemoteException e) {
            Log.i(TAG, "Issue with invoking pending intent: " + e.getMessage());
            // TODO: Propagate failure
        }
    }

    @Override // from provider session