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
This commit is contained in:
Reema Bajwa
2022-11-17 21:24:45 +00:00
parent fe5097cfbd
commit 65a9b5c423
3 changed files with 29 additions and 12 deletions

View File

@@ -72,9 +72,15 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
@Override
protected void launchUiWithProviderData(ArrayList<ProviderData> providerDataList) {
mHandler.post(() -> mCredentialManagerUi.show(RequestInfo.newCreateRequestInfo(
mRequestId, mClientRequest, mIsFirstUiTurn, mClientCallingPackage),
providerDataList));
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) {

View File

@@ -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);
}
}

View File

@@ -68,9 +68,15 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest
@Override
protected void launchUiWithProviderData(ArrayList<ProviderData> providerDataList) {
mHandler.post(() -> mCredentialManagerUi.show(RequestInfo.newGetRequestInfo(
mRequestId, null, mIsFirstUiTurn, ""),
providerDataList));
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