Setup Place to Define Provider Metrics

Generating a fixed location to invoke providers where metrics can be
easily placed.

Bug: 253157163
Bug: 253157181
Test: Builds
Change-Id: I4c2b0083093fef5050567dd8b6622e9a0d9a0174
This commit is contained in:
Arpan
2023-02-01 01:07:20 +00:00
parent 9d3188856b
commit 7f02013358
5 changed files with 28 additions and 21 deletions

View File

@@ -45,8 +45,6 @@ import android.os.ICancellationSignal;
import android.os.RemoteException;
import android.os.UserHandle;
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;
@@ -302,11 +300,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;
}
@@ -350,12 +344,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;
}
@@ -468,14 +457,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();
}