Merge "Setup Place to Define Provider Metrics"

This commit is contained in:
Arpan Kaphle
2023-02-01 22:10:29 +00:00
committed by Android (Google) Code Review
5 changed files with 28 additions and 21 deletions

View File

@@ -49,8 +49,6 @@ import android.os.RemoteException;
import android.os.UserHandle;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.service.credentials.BeginCreateCredentialRequest;
import android.service.credentials.BeginGetCredentialRequest;
import android.service.credentials.CallingAppInfo;
import android.service.credentials.CredentialProviderInfo;
import android.text.TextUtils;
@@ -364,11 +362,7 @@ public final class CredentialManagerService
}
// Iterate over all provider sessions and invoke the request
providerSessions.forEach(
providerGetSession -> providerGetSession
.getRemoteCredentialService().onBeginGetCredential(
(BeginGetCredentialRequest) providerGetSession.getProviderRequest(),
/*callback=*/providerGetSession));
providerSessions.forEach(ProviderSession::invokeSession);
return cancelTransport;
}
@@ -412,12 +406,7 @@ public final class CredentialManagerService
// Iterate over all provider sessions and invoke the request
providerSessions.forEach(
providerCreateSession -> providerCreateSession
.getRemoteCredentialService()
.onCreateCredential(
(BeginCreateCredentialRequest)
providerCreateSession.getProviderRequest(),
/* callback= */ providerCreateSession));
ProviderSession::invokeSession);
return cancelTransport;
}
@@ -530,14 +519,7 @@ public final class CredentialManagerService
// Iterate over all provider sessions and invoke the request
providerSessions.forEach(
providerClearSession -> {
providerClearSession
.getRemoteCredentialService()
.onClearCredentialState(
(android.service.credentials.ClearCredentialStateRequest)
providerClearSession.getProviderRequest(),
/* callback= */ providerClearSession);
});
ProviderSession::invokeSession);
return cancelTransport;
}

View File

@@ -115,4 +115,11 @@ public final class ProviderClearSession extends ProviderSession<ClearCredentialS
ProviderPendingIntentResponse providerPendingIntentResponse) {
//Not applicable for clearCredential as response is not picked by the user
}
@Override
protected void invokeSession() {
this.mRemoteCredentialService.onClearCredentialState(
this.getProviderRequest(),
/*callback=*/this);
}
}

View File

@@ -197,6 +197,13 @@ public final class ProviderCreateSession extends ProviderSession<
}
}
@Override
protected void invokeSession() {
this.mRemoteCredentialService.onCreateCredential(
this.getProviderRequest(),
/*callback=*/this);
}
private List<Entry> prepareUiSaveEntries(@NonNull List<CreateEntry> saveEntries) {
Log.i(TAG, "in populateUiSaveEntries");
List<Entry> uiSaveEntries = new ArrayList<>();

View File

@@ -230,6 +230,13 @@ public final class ProviderGetSession extends ProviderSession<BeginGetCredential
}
}
@Override
protected void invokeSession() {
this.mRemoteCredentialService.onBeginGetCredential(
this.getProviderRequest(),
/*callback=*/this);
}
@Override // Call from request session to data to be shown on the UI
@Nullable protected GetCredentialProviderData prepareUiData() throws IllegalArgumentException {
Log.i(TAG, "In prepareUiData");

View File

@@ -208,4 +208,8 @@ public abstract class ProviderSession<T, R>
/** Should be overridden to handle the selected entry from the UI. */
protected abstract void onUiEntrySelected(String entryType, String entryId,
ProviderPendingIntentResponse providerPendingIntentResponse);
/** Should be overridden to invoke the provider at a defined location. Helpful for
* situations such as metric generation. */
protected abstract void invokeSession();
}