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

Commit b98c2ee5 authored by Arpan Kaphle's avatar Arpan Kaphle Committed by Android (Google) Code Review
Browse files

Merge "Adding Final Phase Exception String to Logs" into udc-dev

parents 83d07512 c8c01cc5
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.credentials;
import android.annotation.Nullable;
import android.content.ComponentName;
import android.content.Context;
import android.credentials.ClearCredentialStateException;
import android.credentials.ClearCredentialStateRequest;
import android.credentials.CredentialProviderInfo;
import android.credentials.IClearCredentialStateCallback;
@@ -141,8 +142,9 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta
                return;
            }
        }
        // TODO: Replace with properly defined error type
        respondToClientWithErrorAndFinish("UNKNOWN", "All providers failed");
        String exception = ClearCredentialStateException.TYPE_UNKNOWN;
        mRequestSessionMetric.collectFrameworkException(exception);
        respondToClientWithErrorAndFinish(exception, "All providers failed");
    }

    @Override
+16 −9
Original line number Diff line number Diff line
@@ -141,7 +141,9 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
        } else {
            mRequestSessionMetric.collectChosenProviderStatus(
                    ProviderStatusForMetrics.FINAL_FAILURE.getMetricCode());
            respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREATE_OPTIONS,
            String exception = CreateCredentialException.TYPE_NO_CREATE_OPTIONS;
            mRequestSessionMetric.collectFrameworkException(exception);
            respondToClientWithErrorAndFinish(exception,
                    "Invalid response");
        }
    }
@@ -154,18 +156,21 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR

    @Override
    public void onUiCancellation(boolean isUserCancellation) {
        if (isUserCancellation) {
            respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_USER_CANCELED,
                    "User cancelled the selector");
        } else {
            respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_INTERRUPTED,
                    "The UI was interrupted - please try again.");
        String exception = CreateCredentialException.TYPE_USER_CANCELED;
        String message = "User cancelled the selector";
        if (!isUserCancellation) {
            exception = CreateCredentialException.TYPE_INTERRUPTED;
            message = "The UI was interrupted - please try again.";
        }
        mRequestSessionMetric.collectFrameworkException(exception);
        respondToClientWithErrorAndFinish(exception, message);
    }

    @Override
    public void onUiSelectorInvocationFailure() {
        respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREATE_OPTIONS,
        String exception = CreateCredentialException.TYPE_NO_CREATE_OPTIONS;
        mRequestSessionMetric.collectFrameworkException(exception);
        respondToClientWithErrorAndFinish(exception,
                "No create options available.");
    }

@@ -181,7 +186,9 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
                Slog.i(TAG, "Provider status changed - ui invocation is needed");
                getProviderDataAndInitiateUi();
            } else {
                respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREATE_OPTIONS,
                String exception = CreateCredentialException.TYPE_NO_CREATE_OPTIONS;
                mRequestSessionMetric.collectFrameworkException(exception);
                respondToClientWithErrorAndFinish(exception,
                        "No create options available.");
            }
        }
+22 −11
Original line number Diff line number Diff line
@@ -106,8 +106,10 @@ public class GetRequestSession extends RequestSession<GetCredentialRequest,
        } catch (RemoteException e) {
            mRequestSessionMetric.collectUiReturnedFinalPhase(/*uiReturned=*/ false);
            mCredentialManagerUi.setStatus(CredentialManagerUi.UiStatus.TERMINATED);
            String exception = GetCredentialException.TYPE_UNKNOWN;
            mRequestSessionMetric.collectFrameworkException(exception);
            respondToClientWithErrorAndFinish(
                    GetCredentialException.TYPE_UNKNOWN, "Unable to instantiate selector");
                    exception, "Unable to instantiate selector");
        }
    }

@@ -138,7 +140,9 @@ public class GetRequestSession extends RequestSession<GetCredentialRequest,
        } else {
            mRequestSessionMetric.collectChosenProviderStatus(
                    ProviderStatusForMetrics.FINAL_FAILURE.getMetricCode());
            respondToClientWithErrorAndFinish(GetCredentialException.TYPE_NO_CREDENTIAL,
            String exception = GetCredentialException.TYPE_NO_CREDENTIAL;
            mRequestSessionMetric.collectFrameworkException(exception);
            respondToClientWithErrorAndFinish(exception,
                    "Invalid response from provider");
        }
    }
@@ -152,18 +156,21 @@ public class GetRequestSession extends RequestSession<GetCredentialRequest,

    @Override
    public void onUiCancellation(boolean isUserCancellation) {
        if (isUserCancellation) {
            respondToClientWithErrorAndFinish(GetCredentialException.TYPE_USER_CANCELED,
                    "User cancelled the selector");
        } else {
            respondToClientWithErrorAndFinish(GetCredentialException.TYPE_INTERRUPTED,
                    "The UI was interrupted - please try again.");
        String exception = GetCredentialException.TYPE_NO_CREDENTIAL;
        String message = "User cancelled the selector";
        if (!isUserCancellation) {
            exception = GetCredentialException.TYPE_INTERRUPTED;
            message = "The UI was interrupted - please try again.";
        }
        mRequestSessionMetric.collectFrameworkException(exception);
        respondToClientWithErrorAndFinish(exception, message);
    }

    @Override
    public void onUiSelectorInvocationFailure() {
        respondToClientWithErrorAndFinish(GetCredentialException.TYPE_NO_CREDENTIAL,
        String exception = GetCredentialException.TYPE_NO_CREDENTIAL;
        mRequestSessionMetric.collectFrameworkException(exception);
        respondToClientWithErrorAndFinish(exception,
                "No credentials available.");
    }

@@ -187,7 +194,9 @@ public class GetRequestSession extends RequestSession<GetCredentialRequest,
                Slog.i(TAG, "Provider status changed - ui invocation is needed");
                getProviderDataAndInitiateUi();
            } else {
                respondToClientWithErrorAndFinish(GetCredentialException.TYPE_NO_CREDENTIAL,
                String exception = GetCredentialException.TYPE_NO_CREDENTIAL;
                mRequestSessionMetric.collectFrameworkException(exception);
                respondToClientWithErrorAndFinish(exception,
                        "No credentials available");
            }
        }
@@ -208,7 +217,9 @@ public class GetRequestSession extends RequestSession<GetCredentialRequest,

        // Respond to client if all auth entries are empty and nothing else to show on the UI
        if (providerDataContainsEmptyAuthEntriesOnly()) {
            respondToClientWithErrorAndFinish(GetCredentialException.TYPE_NO_CREDENTIAL,
            String exception = GetCredentialException.TYPE_NO_CREDENTIAL;
            mRequestSessionMetric.collectFrameworkException(exception);
            respondToClientWithErrorAndFinish(exception,
                    "No credentials available");
        }
    }
+11 −4
Original line number Diff line number Diff line
@@ -48,12 +48,15 @@ public class MetricUtilities {
    public static final String DEFAULT_STRING = "";
    public static final int[] DEFAULT_REPEATED_INT_32 = new int[0];
    public static final String[] DEFAULT_REPEATED_STR = new String[0];
    public static final boolean[] DEFAULT_REPEATED_BOOL = new boolean[0];
    // Used for single count metric emits, such as singular amounts of various types
    public static final int UNIT = 1;
    // Used for zero count metric emits, such as zero amounts of various types
    public static final int ZERO = 0;
    // The number of characters at the end of the string to use as a key
    public static final int DELTA_CUT = 20;
    public static final int DELTA_RESPONSES_CUT = 20;
    // The cut for exception strings from the end - used to keep metrics small
    public static final int DELTA_EXCEPTION_CUT = 30;

    /**
     * This retrieves the uid of any package name, given a context and a component name for the
@@ -165,8 +168,10 @@ public class MetricUtilities {
                    finalPhaseMetric.getResponseCollective().getUniqueResponseStrings(),
                    /* per_classtype_counts */
                    finalPhaseMetric.getResponseCollective().getUniqueResponseCounts(),
                    /* framework_exception_unique_classtypes */
                    DEFAULT_STRING
                    /* framework_exception_unique_classtype */
                    finalPhaseMetric.getFrameworkException(),
                    /* primary_indicated */
                    false
            );
        } catch (Exception e) {
            Slog.w(TAG, "Unexpected error during final provider uid emit: " + e);
@@ -268,7 +273,9 @@ public class MetricUtilities {
                    /* per_classtype_counts */
                    initialPhaseMetric.getUniqueRequestCounts(),
                    /* api_name */
                    initialPhaseMetric.getApiName()
                    initialPhaseMetric.getApiName(),
                    /* primary_candidates_indicated */
                    DEFAULT_REPEATED_BOOL
            );
        } catch (Exception e) {
            Slog.w(TAG, "Unexpected error during candidate provider uid metric emit: " + e);
+0 −1
Original line number Diff line number Diff line
@@ -209,7 +209,6 @@ public abstract class ProviderSession<T, R>
                isCompletionStatus(status), mProviderSessionUid);
        mCallbacks.onProviderStatusChanged(status, mComponentName, source);
    }

    /** Common method that transfers metrics from the init phase to candidates */
    protected void startCandidateMetrics() {
        mProviderSessionMetric.collectCandidateMetricSetupViaInitialMetric(
Loading