Revise logging in provider sessions
Bug: 270568738
Test: built locally
Change-Id: Ibe984d89bb554ad6ab3efca0132c1ab99de323b4
diff --git a/services/credentials/java/com/android/server/credentials/GetRequestSession.java b/services/credentials/java/com/android/server/credentials/GetRequestSession.java
index aeb4801..208a4be 100644
--- a/services/credentials/java/com/android/server/credentials/GetRequestSession.java
+++ b/services/credentials/java/com/android/server/credentials/GetRequestSession.java
@@ -161,7 +161,8 @@
@Override
public void onProviderStatusChanged(ProviderSession.Status status,
ComponentName componentName, ProviderSession.CredentialsSource source) {
- Slog.d(TAG, "in onStatusChanged with status: " + status + ", and source: " + source);
+ Slog.d(TAG, "in onStatusChanged for: " + componentName + ", with status: "
+ + status + ", and source: " + source);
// Auth entry was selected, and it did not have any underlying credentials
if (status == ProviderSession.Status.NO_CREDENTIALS_FROM_AUTH_ENTRY) {
diff --git a/services/credentials/java/com/android/server/credentials/ProviderClearSession.java b/services/credentials/java/com/android/server/credentials/ProviderClearSession.java
index 0c3d3f4..9ec0ecd 100644
--- a/services/credentials/java/com/android/server/credentials/ProviderClearSession.java
+++ b/services/credentials/java/com/android/server/credentials/ProviderClearSession.java
@@ -26,7 +26,6 @@
import android.os.ICancellationSignal;
import android.service.credentials.CallingAppInfo;
import android.service.credentials.ClearCredentialStateRequest;
-import android.util.Log;
import android.util.Slog;
/**
@@ -81,7 +80,7 @@
@Override
public void onProviderResponseSuccess(@Nullable Void response) {
- Log.i(TAG, "in onProviderResponseSuccess");
+ Slog.d(TAG, "Remote provider responded with a valid response: " + mComponentName);
mProviderResponseSet = true;
updateStatusAndInvokeCallback(Status.COMPLETE,
/*source=*/ CredentialsSource.REMOTE_PROVIDER);
@@ -105,7 +104,7 @@
updateStatusAndInvokeCallback(Status.SERVICE_DEAD,
/*source=*/ CredentialsSource.REMOTE_PROVIDER);
} else {
- Slog.i(TAG, "Component names different in onProviderServiceDied - "
+ Slog.w(TAG, "Component names different in onProviderServiceDied - "
+ "this should not happen");
}
}
diff --git a/services/credentials/java/com/android/server/credentials/ProviderCreateSession.java b/services/credentials/java/com/android/server/credentials/ProviderCreateSession.java
index 8b9255a..09433db 100644
--- a/services/credentials/java/com/android/server/credentials/ProviderCreateSession.java
+++ b/services/credentials/java/com/android/server/credentials/ProviderCreateSession.java
@@ -37,7 +37,6 @@
import android.service.credentials.CreateEntry;
import android.service.credentials.CredentialProviderService;
import android.service.credentials.RemoteEntry;
-import android.util.Log;
import android.util.Pair;
import android.util.Slog;
@@ -93,7 +92,8 @@
createRequestSession.mHybridService
);
}
- Log.i(TAG, "Unable to create provider session");
+ Slog.d(TAG, "Unable to create provider session for: "
+ + providerInfo.getComponentName());
return null;
}
@@ -122,7 +122,6 @@
return new CreateCredentialRequest(callingAppInfo, capability,
clientRequest.getCredentialData());
}
- Log.i(TAG, "Unable to create provider request - capabilities do not match");
return null;
}
@@ -146,7 +145,7 @@
@Override
public void onProviderResponseSuccess(
@Nullable BeginCreateCredentialResponse response) {
- Log.i(TAG, "in onProviderResponseSuccess");
+ Slog.d(TAG, "Remote provider responded with a valid response: " + mComponentName);
onSetInitialRemoteResponse(response);
}
@@ -169,7 +168,7 @@
updateStatusAndInvokeCallback(Status.SERVICE_DEAD,
/*source=*/ CredentialsSource.REMOTE_PROVIDER);
} else {
- Slog.i(TAG, "Component names different in onProviderServiceDied - "
+ Slog.w(TAG, "Component names different in onProviderServiceDied - "
+ "this should not happen");
}
}
@@ -180,7 +179,6 @@
}
private void onSetInitialRemoteResponse(BeginCreateCredentialResponse response) {
- Log.i(TAG, "onSetInitialRemoteResponse with save entries");
mProviderResponse = response;
mProviderResponseDataHandler.addResponseContent(response.getCreateEntries(),
response.getRemoteCreateEntry());
@@ -199,14 +197,12 @@
@Nullable
protected CreateCredentialProviderData prepareUiData()
throws IllegalArgumentException {
- Log.i(TAG, "In prepareUiData");
if (!ProviderSession.isUiInvokingStatus(getStatus())) {
- Log.i(TAG, "In prepareUiData not in uiInvokingStatus");
+ Slog.d(TAG, "No data for UI from: " + mComponentName.flattenToString());
return null;
}
if (mProviderResponse != null && !mProviderResponseDataHandler.isEmptyResponse()) {
- Log.i(TAG, "In prepareUiData save entries not null");
return mProviderResponseDataHandler.toCreateCredentialProviderData();
}
return null;
@@ -218,7 +214,7 @@
switch (entryType) {
case SAVE_ENTRY_KEY:
if (mProviderResponseDataHandler.getCreateEntry(entryKey) == null) {
- Log.i(TAG, "Unexpected save entry key");
+ Slog.w(TAG, "Unexpected save entry key");
invokeCallbackOnInternalInvalidState();
return;
}
@@ -226,14 +222,14 @@
break;
case REMOTE_ENTRY_KEY:
if (mProviderResponseDataHandler.getRemoteEntry(entryKey) == null) {
- Log.i(TAG, "Unexpected remote entry key");
+ Slog.w(TAG, "Unexpected remote entry key");
invokeCallbackOnInternalInvalidState();
return;
}
onRemoteEntrySelected(providerPendingIntentResponse);
break;
default:
- Log.i(TAG, "Unsupported entry type selected");
+ Slog.w(TAG, "Unsupported entry type selected");
invokeCallbackOnInternalInvalidState();
}
}
@@ -268,7 +264,7 @@
if (credentialResponse != null) {
mCallbacks.onFinalResponseReceived(mComponentName, credentialResponse);
} else {
- Log.i(TAG, "onSaveEntrySelected - no response or error found in pending "
+ Slog.w(TAG, "onSaveEntrySelected - no response or error found in pending "
+ "intent response");
invokeCallbackOnInternalInvalidState();
}
@@ -284,14 +280,14 @@
private CreateCredentialException maybeGetPendingIntentException(
ProviderPendingIntentResponse pendingIntentResponse) {
if (pendingIntentResponse == null) {
- Log.i(TAG, "pendingIntentResponse is null");
+ Slog.w(TAG, "pendingIntentResponse is null");
return new CreateCredentialException(CreateCredentialException.TYPE_NO_CREATE_OPTIONS);
}
if (PendingIntentResultHandler.isValidResponse(pendingIntentResponse)) {
CreateCredentialException exception = PendingIntentResultHandler
.extractCreateCredentialException(pendingIntentResponse.getResultData());
if (exception != null) {
- Log.i(TAG, "Pending intent contains provider exception");
+ Slog.d(TAG, "Pending intent contains provider exception");
return exception;
}
} else if (PendingIntentResultHandler.isCancelledResponse(pendingIntentResponse)) {
@@ -343,7 +339,7 @@
public void setRemoteEntry(@Nullable RemoteEntry remoteEntry) {
if (!enforceRemoteEntryRestrictions(mExpectedRemoteEntryProviderService)) {
- Log.i(TAG, "Remote entry being dropped as it does not meet the restriction"
+ Slog.w(TAG, "Remote entry being dropped as it does not meet the restriction"
+ "checks.");
return;
}
diff --git a/services/credentials/java/com/android/server/credentials/ProviderGetSession.java b/services/credentials/java/com/android/server/credentials/ProviderGetSession.java
index 8d3d064..0c2b563 100644
--- a/services/credentials/java/com/android/server/credentials/ProviderGetSession.java
+++ b/services/credentials/java/com/android/server/credentials/ProviderGetSession.java
@@ -115,7 +115,8 @@
getRequestSession.mHybridService
);
}
- Log.i(TAG, "Unable to create provider session");
+ Slog.d(TAG, "Unable to create provider session for: "
+ + providerInfo.getComponentName());
return null;
}
@@ -146,17 +147,15 @@
android.credentials.GetCredentialRequest clientRequest,
CredentialProviderInfo info
) {
+ Slog.d(TAG, "Filtering request options for: " + info.getComponentName());
List<CredentialOption> filteredOptions = new ArrayList<>();
for (CredentialOption option : clientRequest.getCredentialOptions()) {
if (providerCapabilities.contains(option.getType())
&& isProviderAllowed(option, info.getComponentName())
&& checkSystemProviderRequirement(option, info.isSystemProvider())) {
- Log.i(TAG, "In createProviderRequest - capability found : "
- + option.getType());
+ Slog.d(TAG, "Option of type: " + option.getType() + " meets all filtering"
+ + "conditions");
filteredOptions.add(option);
- } else {
- Log.i(TAG, "In createProviderRequest - capability not "
- + "found, or provider not allowed : " + option.getType());
}
}
if (!filteredOptions.isEmpty()) {
@@ -165,15 +164,14 @@
.setCredentialOptions(
filteredOptions).build();
}
- Log.i(TAG, "In createProviderRequest - returning null");
+ Slog.d(TAG, "No options filtered");
return null;
}
private static boolean isProviderAllowed(CredentialOption option, ComponentName componentName) {
if (!option.getAllowedProviders().isEmpty() && !option.getAllowedProviders().contains(
componentName)) {
- Log.d(TAG, "Provider allow list specified but does not contain this provider: "
- + componentName.flattenToString());
+ Slog.d(TAG, "Provider allow list specified but does not contain this provider");
return false;
}
return true;
@@ -182,7 +180,7 @@
private static boolean checkSystemProviderRequirement(CredentialOption option,
boolean isSystemProvider) {
if (option.isSystemProviderRequired() && !isSystemProvider) {
- Log.d(TAG, "System provider required, but this service is not a system provider");
+ Slog.d(TAG, "System provider required, but this service is not a system provider");
return false;
}
return true;
@@ -210,6 +208,7 @@
/** Called when the provider response has been updated by an external source. */
@Override // Callback from the remote provider
public void onProviderResponseSuccess(@Nullable BeginGetCredentialResponse response) {
+ Slog.d(TAG, "Remote provider responded with a valid response: " + mComponentName);
onSetInitialRemoteResponse(response);
}
@@ -231,7 +230,7 @@
updateStatusAndInvokeCallback(Status.SERVICE_DEAD,
/*source=*/ CredentialsSource.REMOTE_PROVIDER);
} else {
- Slog.i(TAG, "Component names different in onProviderServiceDied - "
+ Slog.w(TAG, "Component names different in onProviderServiceDied - "
+ "this should not happen");
}
}
@@ -244,13 +243,14 @@
@Override // Selection call from the request provider
protected void onUiEntrySelected(String entryType, String entryKey,
ProviderPendingIntentResponse providerPendingIntentResponse) {
- Log.i(TAG, "onUiEntrySelected with entryKey: " + entryKey);
+ Slog.d(TAG, "onUiEntrySelected with entryType: " + entryType + ", and entryKey: "
+ + entryKey);
switch (entryType) {
case CREDENTIAL_ENTRY_KEY:
CredentialEntry credentialEntry = mProviderResponseDataHandler
.getCredentialEntry(entryKey);
if (credentialEntry == null) {
- Log.i(TAG, "Unexpected credential entry key");
+ Slog.w(TAG, "Unexpected credential entry key");
invokeCallbackOnInternalInvalidState();
return;
}
@@ -259,7 +259,7 @@
case ACTION_ENTRY_KEY:
Action actionEntry = mProviderResponseDataHandler.getActionEntry(entryKey);
if (actionEntry == null) {
- Log.i(TAG, "Unexpected action entry key");
+ Slog.w(TAG, "Unexpected action entry key");
invokeCallbackOnInternalInvalidState();
return;
}
@@ -269,21 +269,21 @@
Action authenticationEntry = mProviderResponseDataHandler
.getAuthenticationAction(entryKey);
if (authenticationEntry == null) {
- Log.i(TAG, "Unexpected authenticationEntry key");
+ Slog.w(TAG, "Unexpected authenticationEntry key");
invokeCallbackOnInternalInvalidState();
return;
}
boolean additionalContentReceived =
onAuthenticationEntrySelected(providerPendingIntentResponse);
if (additionalContentReceived) {
- Log.i(TAG, "Additional content received - removing authentication entry");
+ Slog.d(TAG, "Additional content received - removing authentication entry");
mProviderResponseDataHandler.removeAuthenticationAction(entryKey);
if (!mProviderResponseDataHandler.isEmptyResponse()) {
updateStatusAndInvokeCallback(Status.CREDENTIALS_RECEIVED,
/*source=*/ CredentialsSource.AUTH_ENTRY);
}
} else {
- Log.i(TAG, "Additional content not received");
+ Slog.d(TAG, "Additional content not received from authentication entry");
mProviderResponseDataHandler
.updateAuthEntryWithNoCredentialsReceived(entryKey);
updateStatusAndInvokeCallback(Status.NO_CREDENTIALS_FROM_AUTH_ENTRY,
@@ -294,12 +294,12 @@
if (mProviderResponseDataHandler.getRemoteEntry(entryKey) != null) {
onRemoteEntrySelected(providerPendingIntentResponse);
} else {
- Log.i(TAG, "Unexpected remote entry key");
+ Slog.d(TAG, "Unexpected remote entry key");
invokeCallbackOnInternalInvalidState();
}
break;
default:
- Log.i(TAG, "Unsupported entry type selected");
+ Slog.w(TAG, "Unsupported entry type selected");
invokeCallbackOnInternalInvalidState();
}
}
@@ -320,26 +320,24 @@
@Override // Call from request session to data to be shown on the UI
@Nullable
protected GetCredentialProviderData prepareUiData() throws IllegalArgumentException {
- Log.i(TAG, "In prepareUiData");
if (!ProviderSession.isUiInvokingStatus(getStatus())) {
- Log.i(TAG, "In prepareUiData - provider does not want to show UI: "
- + mComponentName.flattenToString());
+ Slog.d(TAG, "No data for UI from: " + mComponentName.flattenToString());
return null;
}
if (mProviderResponse != null && !mProviderResponseDataHandler.isEmptyResponse()) {
return mProviderResponseDataHandler.toGetCredentialProviderData();
}
- Log.i(TAG, "In prepareUiData response null");
+ Slog.d(TAG, "In prepareUiData response null");
return null;
}
- private Intent setUpFillInIntent(@NonNull String id) {
+ private Intent setUpFillInIntentWithFinalRequest(@NonNull String id) {
// TODO: Determine if we should skip this entry if entry id is not set, or is set
// but does not resolve to a valid option. For now, not skipping it because
// it may be possible that the provider adds their own extras and expects to receive
// those and complete the flow.
if (mBeginGetOptionToCredentialOptionMap.get(id) == null) {
- Log.i(TAG, "Id from Credential Entry does not resolve to a valid option");
+ Slog.w(TAG, "Id from Credential Entry does not resolve to a valid option");
return new Intent();
}
return new Intent().putExtra(CredentialProviderService.EXTRA_GET_CREDENTIAL_REQUEST,
@@ -382,7 +380,8 @@
getCredentialResponse);
return;
}
- Log.i(TAG, "Pending intent response contains no credential, or error");
+ Slog.d(TAG, "Pending intent response contains no credential, or error "
+ + "for a credential entry");
invokeCallbackOnInternalInvalidState();
}
@@ -390,14 +389,12 @@
private GetCredentialException maybeGetPendingIntentException(
ProviderPendingIntentResponse pendingIntentResponse) {
if (pendingIntentResponse == null) {
- Log.i(TAG, "pendingIntentResponse is null");
return null;
}
if (PendingIntentResultHandler.isValidResponse(pendingIntentResponse)) {
GetCredentialException exception = PendingIntentResultHandler
.extractGetCredentialException(pendingIntentResponse.getResultData());
if (exception != null) {
- Log.i(TAG, "Pending intent contains provider exception");
return exception;
}
} else if (PendingIntentResultHandler.isCancelledResponse(pendingIntentResponse)) {
@@ -463,7 +460,7 @@
/** Returns true if either an exception or a response is found. */
private void onActionEntrySelected(ProviderPendingIntentResponse
providerPendingIntentResponse) {
- Log.i(TAG, "onActionEntrySelected");
+ Slog.d(TAG, "onActionEntrySelected");
onCredentialEntrySelected(providerPendingIntentResponse);
}
@@ -559,7 +556,8 @@
String id = generateUniqueId();
Entry entry = new Entry(CREDENTIAL_ENTRY_KEY,
id, credentialEntry.getSlice(),
- setUpFillInIntent(credentialEntry.getBeginGetCredentialOptionId()));
+ setUpFillInIntentWithFinalRequest(credentialEntry
+ .getBeginGetCredentialOptionId()));
mUiCredentialEntries.put(id, new Pair<>(credentialEntry, entry));
mCredentialEntryTypes.add(credentialEntry.getType());
}
@@ -574,9 +572,7 @@
public void addAuthenticationAction(Action authenticationAction,
@AuthenticationEntry.Status int status) {
- Log.i(TAG, "In addAuthenticationAction");
String id = generateUniqueId();
- Log.i(TAG, "In addAuthenticationAction, id : " + id);
AuthenticationEntry entry = new AuthenticationEntry(
AUTHENTICATION_ACTION_ENTRY_KEY,
id, authenticationAction.getSlice(),
@@ -591,7 +587,7 @@
public void setRemoteEntry(@Nullable RemoteEntry remoteEntry) {
if (!enforceRemoteEntryRestrictions(mExpectedRemoteEntryProviderService)) {
- Log.i(TAG, "Remote entry being dropped as it does not meet the restriction"
+ Slog.w(TAG, "Remote entry being dropped as it does not meet the restriction"
+ " checks.");
return;
}
@@ -715,7 +711,6 @@
== AuthenticationEntry.STATUS_UNLOCKED_BUT_EMPTY_MOST_RECENT)
.findFirst();
if (previousMostRecentAuthEntry.isEmpty()) {
- Log.i(TAG, "In updatePreviousMostRecentAuthEntry - previous entry not found");
return;
}
String id = previousMostRecentAuthEntry.get().getKey();
diff --git a/services/credentials/java/com/android/server/credentials/ProviderRegistryGetSession.java b/services/credentials/java/com/android/server/credentials/ProviderRegistryGetSession.java
index 24292ef2..c10f564 100644
--- a/services/credentials/java/com/android/server/credentials/ProviderRegistryGetSession.java
+++ b/services/credentials/java/com/android/server/credentials/ProviderRegistryGetSession.java
@@ -33,7 +33,7 @@
import android.service.credentials.CallingAppInfo;
import android.service.credentials.CredentialEntry;
import android.service.credentials.CredentialProviderService;
-import android.telecom.Log;
+import android.util.Slog;
import com.android.internal.annotations.VisibleForTesting;
@@ -145,14 +145,12 @@
private List<Entry> prepareUiCredentialEntries(
@NonNull List<CredentialEntry> credentialEntries) {
- Log.i(TAG, "in prepareUiProviderDataWithCredentials");
List<Entry> credentialUiEntries = new ArrayList<>();
// Populate the credential entries
for (CredentialEntry credentialEntry : credentialEntries) {
String entryId = generateUniqueId();
mUiCredentialEntries.put(entryId, credentialEntry);
- Log.i(TAG, "in prepareUiProviderData creating ui entry with id " + entryId);
credentialUiEntries.add(new Entry(CREDENTIAL_ENTRY_KEY, entryId,
credentialEntry.getSlice(),
setUpFillInIntent()));
@@ -172,15 +170,13 @@
@Override
protected ProviderData prepareUiData() {
- Log.i(TAG, "In prepareUiData");
if (!ProviderSession.isUiInvokingStatus(getStatus())) {
- Log.i(TAG, "In prepareUiData - provider does not want to show UI: "
- + mComponentName.flattenToString());
+ Slog.d(TAG, "No date for UI coming from: " + mComponentName.flattenToString());
return null;
}
if (mProviderResponse == null) {
- Log.i(TAG, "In prepareUiData response null");
- throw new IllegalStateException("Response must be in completion mode");
+ Slog.w(TAG, "In prepareUiData but response is null. This is strange.");
+ return null;
}
return new GetCredentialProviderData.Builder(
mComponentName.flattenToString()).setActionChips(null)
@@ -200,13 +196,13 @@
case CREDENTIAL_ENTRY_KEY:
CredentialEntry credentialEntry = mUiCredentialEntries.get(entryKey);
if (credentialEntry == null) {
- Log.i(TAG, "Unexpected credential entry key");
+ Slog.w(TAG, "Unexpected credential entry key");
return;
}
onCredentialEntrySelected(credentialEntry, providerPendingIntentResponse);
break;
default:
- Log.i(TAG, "Unsupported entry type selected");
+ Slog.w(TAG, "Unsupported entry type selected");
}
}
@@ -233,10 +229,8 @@
}
return;
}
-
- Log.i(TAG, "Pending intent response contains no credential, or error");
}
- Log.i(TAG, "CredentialEntry does not have a credential or a pending intent result");
+ Slog.w(TAG, "CredentialEntry does not have a credential or a pending intent result");
}
@Override
@@ -279,14 +273,13 @@
protected GetCredentialException maybeGetPendingIntentException(
ProviderPendingIntentResponse pendingIntentResponse) {
if (pendingIntentResponse == null) {
- android.util.Log.i(TAG, "pendingIntentResponse is null");
return null;
}
if (PendingIntentResultHandler.isValidResponse(pendingIntentResponse)) {
GetCredentialException exception = PendingIntentResultHandler
.extractGetCredentialException(pendingIntentResponse.getResultData());
if (exception != null) {
- android.util.Log.i(TAG, "Pending intent contains provider exception");
+ Slog.d(TAG, "Pending intent contains provider exception");
return exception;
}
} else if (PendingIntentResultHandler.isCancelledResponse(pendingIntentResponse)) {
diff --git a/services/credentials/java/com/android/server/credentials/ProviderSession.java b/services/credentials/java/com/android/server/credentials/ProviderSession.java
index d165756..d02a8c1 100644
--- a/services/credentials/java/com/android/server/credentials/ProviderSession.java
+++ b/services/credentials/java/com/android/server/credentials/ProviderSession.java
@@ -29,7 +29,6 @@
import android.credentials.ui.ProviderPendingIntentResponse;
import android.os.ICancellationSignal;
import android.os.RemoteException;
-import android.util.Log;
import android.util.Slog;
import com.android.server.credentials.metrics.ProviderSessionMetric;
@@ -253,7 +252,7 @@
@Nullable ComponentName expectedRemoteEntryProviderService) {
// Check if the service is the one set by the OEM. If not silently reject this entry
if (!mComponentName.equals(expectedRemoteEntryProviderService)) {
- Log.i(TAG, "Remote entry being dropped as it is not from the service "
+ Slog.w(TAG, "Remote entry being dropped as it is not from the service "
+ "configured by the OEM.");
return false;
}
@@ -270,15 +269,12 @@
return true;
}
} catch (SecurityException e) {
- Log.i(TAG, "Error getting info for "
- + mComponentName.flattenToString() + ": " + e.getMessage());
+ Slog.e(TAG, "Error getting info for " + mComponentName.flattenToString(), e);
return false;
} catch (PackageManager.NameNotFoundException e) {
- Log.i(TAG, "Error getting info for "
- + mComponentName.flattenToString() + ": " + e.getMessage());
+ Slog.i(TAG, "Error getting info for " + mComponentName.flattenToString(), e);
return false;
}
- Log.i(TAG, "In enforceRemoteEntryRestrictions - remote entry checks fail");
return false;
}