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

Commit c808909d authored by Reema Bajwa's avatar Reema Bajwa Committed by Automerger Merge Worker
Browse files

Merge "Revise logging in session classes" into udc-dev am: 5b160dea am: 79210fb0

parents deef9653 79210fb0
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -27,7 +27,7 @@ import android.credentials.ui.RequestInfo;
import android.os.CancellationSignal;
import android.os.CancellationSignal;
import android.os.RemoteException;
import android.os.RemoteException;
import android.service.credentials.CallingAppInfo;
import android.service.credentials.CallingAppInfo;
import android.util.Log;
import android.util.Slog;


import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Set;
import java.util.Set;
@@ -67,7 +67,8 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta
                .createNewSession(mContext, mUserId, providerInfo,
                .createNewSession(mContext, mUserId, providerInfo,
                        this, remoteCredentialService);
                        this, remoteCredentialService);
        if (providerClearSession != null) {
        if (providerClearSession != null) {
            Log.i(TAG, "In startProviderSession - provider session created and being added");
            Slog.d(TAG, "In startProviderSession - provider session created "
                    + "and being added for: " + providerInfo.getComponentName());
            mProviders.put(providerClearSession.getComponentName().flattenToString(),
            mProviders.put(providerClearSession.getComponentName().flattenToString(),
                    providerClearSession);
                    providerClearSession);
        }
        }
@@ -77,12 +78,12 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta
    @Override // from provider session
    @Override // from provider session
    public void onProviderStatusChanged(ProviderSession.Status status,
    public void onProviderStatusChanged(ProviderSession.Status status,
            ComponentName componentName, ProviderSession.CredentialsSource source) {
            ComponentName componentName, ProviderSession.CredentialsSource source) {
        Log.i(TAG, "in onStatusChanged with status: " + status);
        Slog.d(TAG, "in onStatusChanged with status: " + status + ", and source: " + source);
        if (ProviderSession.isTerminatingStatus(status)) {
        if (ProviderSession.isTerminatingStatus(status)) {
            Log.i(TAG, "in onStatusChanged terminating status");
            Slog.d(TAG, "in onProviderStatusChanged terminating status");
            onProviderTerminated(componentName);
            onProviderTerminated(componentName);
        } else if (ProviderSession.isCompletionStatus(status)) {
        } else if (ProviderSession.isCompletionStatus(status)) {
            Log.i(TAG, "in onStatusChanged isCompletionStatus status");
            Slog.d(TAG, "in onProviderStatusChanged isCompletionStatus status");
            onProviderResponseComplete(componentName);
            onProviderResponseComplete(componentName);
        }
        }
    }
    }
+6 −5
Original line number Original line Diff line number Diff line
@@ -33,7 +33,7 @@ import android.os.CancellationSignal;
import android.os.RemoteException;
import android.os.RemoteException;
import android.service.credentials.CallingAppInfo;
import android.service.credentials.CallingAppInfo;
import android.service.credentials.PermissionUtils;
import android.service.credentials.PermissionUtils;
import android.util.Log;
import android.util.Slog;


import com.android.server.credentials.metrics.ProviderStatusForMetrics;
import com.android.server.credentials.metrics.ProviderStatusForMetrics;


@@ -77,7 +77,8 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
                .createNewSession(mContext, mUserId, providerInfo,
                .createNewSession(mContext, mUserId, providerInfo,
                        this, remoteCredentialService);
                        this, remoteCredentialService);
        if (providerCreateSession != null) {
        if (providerCreateSession != null) {
            Log.i(TAG, "In startProviderSession - provider session created and being added");
            Slog.d(TAG, "In initiateProviderSession - provider session created and "
                    + "being added for: " + providerInfo.getComponentName());
            mProviders.put(providerCreateSession.getComponentName().flattenToString(),
            mProviders.put(providerCreateSession.getComponentName().flattenToString(),
                    providerCreateSession);
                    providerCreateSession);
        }
        }
@@ -120,7 +121,7 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
    @Override
    @Override
    public void onFinalResponseReceived(ComponentName componentName,
    public void onFinalResponseReceived(ComponentName componentName,
            @Nullable CreateCredentialResponse response) {
            @Nullable CreateCredentialResponse response) {
        Log.i(TAG, "onFinalCredentialReceived from: " + componentName.flattenToString());
        Slog.d(TAG, "onFinalCredentialReceived from: " + componentName.flattenToString());
        mRequestSessionMetric.collectUiResponseData(/*uiReturned=*/ true, System.nanoTime());
        mRequestSessionMetric.collectUiResponseData(/*uiReturned=*/ true, System.nanoTime());
        mRequestSessionMetric.collectChosenMetricViaCandidateTransfer(mProviders.get(
        mRequestSessionMetric.collectChosenMetricViaCandidateTransfer(mProviders.get(
                componentName.flattenToString()).mProviderSessionMetric
                componentName.flattenToString()).mProviderSessionMetric
@@ -163,13 +164,13 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
    @Override
    @Override
    public void onProviderStatusChanged(ProviderSession.Status status,
    public void onProviderStatusChanged(ProviderSession.Status status,
            ComponentName componentName, ProviderSession.CredentialsSource source) {
            ComponentName componentName, ProviderSession.CredentialsSource source) {
        Log.i(TAG, "in onProviderStatusChanged with status: " + status);
        Slog.d(TAG, "in onStatusChanged with status: " + status + ", and source: " + source);
        // If all provider responses have been received, we can either need the UI,
        // If all provider responses have been received, we can either need the UI,
        // or we need to respond with error. The only other case is the entry being
        // or we need to respond with error. The only other case is the entry being
        // selected after the UI has been invoked which has a separate code path.
        // selected after the UI has been invoked which has a separate code path.
        if (!isAnyProviderPending()) {
        if (!isAnyProviderPending()) {
            if (isUiInvocationNeeded()) {
            if (isUiInvocationNeeded()) {
                Log.i(TAG, "in onProviderStatusChanged - isUiInvocationNeeded");
                Slog.d(TAG, "in onProviderStatusChanged - isUiInvocationNeeded");
                getProviderDataAndInitiateUi();
                getProviderDataAndInitiateUi();
            } else {
            } else {
                respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREATE_OPTIONS,
                respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREATE_OPTIONS,
+6 −5
Original line number Original line Diff line number Diff line
@@ -30,7 +30,7 @@ import android.credentials.ui.RequestInfo;
import android.os.CancellationSignal;
import android.os.CancellationSignal;
import android.os.RemoteException;
import android.os.RemoteException;
import android.service.credentials.CallingAppInfo;
import android.service.credentials.CallingAppInfo;
import android.util.Log;
import android.util.Slog;


import com.android.server.credentials.metrics.ProviderStatusForMetrics;
import com.android.server.credentials.metrics.ProviderStatusForMetrics;


@@ -77,7 +77,8 @@ public class GetRequestSession extends RequestSession<GetCredentialRequest,
                .createNewSession(mContext, mUserId, providerInfo,
                .createNewSession(mContext, mUserId, providerInfo,
                        this, remoteCredentialService);
                        this, remoteCredentialService);
        if (providerGetSession != null) {
        if (providerGetSession != null) {
            Log.i(TAG, "In startProviderSession - provider session created and being added");
            Slog.d(TAG, "In startProviderSession - provider session created and "
                    + "being added for: " + providerInfo.getComponentName());
            mProviders.put(providerGetSession.getComponentName().flattenToString(),
            mProviders.put(providerGetSession.getComponentName().flattenToString(),
                    providerGetSession);
                    providerGetSession);
        }
        }
@@ -116,7 +117,7 @@ public class GetRequestSession extends RequestSession<GetCredentialRequest,
    @Override
    @Override
    public void onFinalResponseReceived(ComponentName componentName,
    public void onFinalResponseReceived(ComponentName componentName,
            @Nullable GetCredentialResponse response) {
            @Nullable GetCredentialResponse response) {
        Log.i(TAG, "onFinalCredentialReceived from: " + componentName.flattenToString());
        Slog.d(TAG, "onFinalResponseReceived from: " + componentName.flattenToString());
        mRequestSessionMetric.collectUiResponseData(/*uiReturned=*/ true, System.nanoTime());
        mRequestSessionMetric.collectUiResponseData(/*uiReturned=*/ true, System.nanoTime());
        mRequestSessionMetric.collectChosenMetricViaCandidateTransfer(
        mRequestSessionMetric.collectChosenMetricViaCandidateTransfer(
                mProviders.get(componentName.flattenToString())
                mProviders.get(componentName.flattenToString())
@@ -160,7 +161,7 @@ public class GetRequestSession extends RequestSession<GetCredentialRequest,
    @Override
    @Override
    public void onProviderStatusChanged(ProviderSession.Status status,
    public void onProviderStatusChanged(ProviderSession.Status status,
            ComponentName componentName, ProviderSession.CredentialsSource source) {
            ComponentName componentName, ProviderSession.CredentialsSource source) {
        Log.i(TAG, "in onStatusChanged with status: " + status + "and source: " + source);
        Slog.d(TAG, "in onStatusChanged with status: " + status + ", and source: " + source);


        // Auth entry was selected, and it did not have any underlying credentials
        // Auth entry was selected, and it did not have any underlying credentials
        if (status == ProviderSession.Status.NO_CREDENTIALS_FROM_AUTH_ENTRY) {
        if (status == ProviderSession.Status.NO_CREDENTIALS_FROM_AUTH_ENTRY) {
@@ -173,7 +174,7 @@ public class GetRequestSession extends RequestSession<GetCredentialRequest,
            // or we need to respond with error. The only other case is the entry being
            // or we need to respond with error. The only other case is the entry being
            // selected after the UI has been invoked which has a separate code path.
            // selected after the UI has been invoked which has a separate code path.
            if (isUiInvocationNeeded()) {
            if (isUiInvocationNeeded()) {
                Log.i(TAG, "in onProviderStatusChanged - isUiInvocationNeeded");
                Slog.d(TAG, "in onProviderStatusChanged - isUiInvocationNeeded");
                getProviderDataAndInitiateUi();
                getProviderDataAndInitiateUi();
            } else {
            } else {
                respondToClientWithErrorAndFinish(GetCredentialException.TYPE_NO_CREDENTIAL,
                respondToClientWithErrorAndFinish(GetCredentialException.TYPE_NO_CREDENTIAL,
+5 −5
Original line number Original line Diff line number Diff line
@@ -33,7 +33,6 @@ import android.os.CancellationSignal;
import android.os.RemoteException;
import android.os.RemoteException;
import android.service.credentials.CallingAppInfo;
import android.service.credentials.CallingAppInfo;
import android.service.credentials.PermissionUtils;
import android.service.credentials.PermissionUtils;
import android.util.Log;
import android.util.Slog;
import android.util.Slog;


import java.util.ArrayList;
import java.util.ArrayList;
@@ -67,6 +66,9 @@ public class PrepareGetRequestSession extends GetRequestSession {
    @Override
    @Override
    public void onProviderStatusChanged(ProviderSession.Status status, ComponentName componentName,
    public void onProviderStatusChanged(ProviderSession.Status status, ComponentName componentName,
            ProviderSession.CredentialsSource source) {
            ProviderSession.CredentialsSource source) {
        Slog.d(TAG, "in onProviderStatusChanged with status: " + status + ", and "
                + "source: " + source);

        switch (source) {
        switch (source) {
            case REMOTE_PROVIDER:
            case REMOTE_PROVIDER:
                // Remote provider's status changed. We should check if all providers are done, and
                // Remote provider's status changed. We should check if all providers are done, and
@@ -123,7 +125,7 @@ public class PrepareGetRequestSession extends GetRequestSession {
                            hasPermission,
                            hasPermission,
                            credentialTypes, hasAuthenticationResults, hasRemoteResults, uiIntent));
                            credentialTypes, hasAuthenticationResults, hasRemoteResults, uiIntent));
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "EXCEPTION while mPendingCallback.onResponse", e);
            Slog.e(TAG, "EXCEPTION while mPendingCallback.onResponse", e);
        }
        }
    }
    }


@@ -138,7 +140,7 @@ public class PrepareGetRequestSession extends GetRequestSession {
                            /*hasRemoteResults=*/ false,
                            /*hasRemoteResults=*/ false,
                            /*pendingIntent=*/ null));
                            /*pendingIntent=*/ null));
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "EXCEPTION while mPendingCallback.onResponse", e);
            Slog.e(TAG, "EXCEPTION while mPendingCallback.onResponse", e);
        }
        }
    }
    }


@@ -179,10 +181,8 @@ public class PrepareGetRequestSession extends GetRequestSession {
    private PendingIntent getUiIntent() {
    private PendingIntent getUiIntent() {
        ArrayList<ProviderData> providerDataList = new ArrayList<>();
        ArrayList<ProviderData> providerDataList = new ArrayList<>();
        for (ProviderSession session : mProviders.values()) {
        for (ProviderSession session : mProviders.values()) {
            Log.i(TAG, "preparing data for : " + session.getComponentName());
            ProviderData providerData = session.prepareUiData();
            ProviderData providerData = session.prepareUiData();
            if (providerData != null) {
            if (providerData != null) {
                Log.i(TAG, "Provider data is not null");
                providerDataList.add(providerData);
                providerDataList.add(providerData);
            }
            }
        }
        }
+7 −14
Original line number Original line Diff line number Diff line
@@ -32,7 +32,6 @@ import android.os.Looper;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserHandle;
import android.service.credentials.CallingAppInfo;
import android.service.credentials.CallingAppInfo;
import android.util.Log;
import android.util.Slog;
import android.util.Slog;


import com.android.internal.R;
import com.android.internal.R;
@@ -179,7 +178,7 @@ abstract class RequestSession<T, U, V> implements CredentialManagerUi.Credential
    @Override // from CredentialManagerUiCallbacks
    @Override // from CredentialManagerUiCallbacks
    public void onUiSelection(UserSelectionDialogResult selection) {
    public void onUiSelection(UserSelectionDialogResult selection) {
        if (mRequestSessionStatus == RequestSessionStatus.COMPLETE) {
        if (mRequestSessionStatus == RequestSessionStatus.COMPLETE) {
            Log.i(TAG, "Request has already been completed. This is strange.");
            Slog.w(TAG, "Request has already been completed. This is strange.");
            return;
            return;
        }
        }
        if (isSessionCancelled()) {
        if (isSessionCancelled()) {
@@ -187,13 +186,11 @@ abstract class RequestSession<T, U, V> implements CredentialManagerUi.Credential
            return;
            return;
        }
        }
        String providerId = selection.getProviderId();
        String providerId = selection.getProviderId();
        Log.i(TAG, "onUiSelection, providerId: " + providerId);
        ProviderSession providerSession = mProviders.get(providerId);
        ProviderSession providerSession = mProviders.get(providerId);
        if (providerSession == null) {
        if (providerSession == null) {
            Log.i(TAG, "providerSession not found in onUiSelection");
            Slog.w(TAG, "providerSession not found in onUiSelection. This is strange.");
            return;
            return;
        }
        }
        Log.i(TAG, "Provider session found");
        mRequestSessionMetric.collectMetricPerBrowsingSelect(selection,
        mRequestSessionMetric.collectMetricPerBrowsingSelect(selection,
                providerSession.mProviderSessionMetric.getCandidatePhasePerProviderMetric());
                providerSession.mProviderSessionMetric.getCandidatePhasePerProviderMetric());
        providerSession.onUiEntrySelected(selection.getEntryKey(),
        providerSession.onUiEntrySelected(selection.getEntryKey(),
@@ -247,15 +244,13 @@ abstract class RequestSession<T, U, V> implements CredentialManagerUi.Credential
    void getProviderDataAndInitiateUi() {
    void getProviderDataAndInitiateUi() {
        ArrayList<ProviderData> providerDataList = getProviderDataForUi();
        ArrayList<ProviderData> providerDataList = getProviderDataForUi();
        if (!providerDataList.isEmpty()) {
        if (!providerDataList.isEmpty()) {
            Log.i(TAG, "provider list not empty about to initiate ui");
            launchUiWithProviderData(providerDataList);
            launchUiWithProviderData(providerDataList);
        }
        }
    }
    }


    @NonNull
    @NonNull
    protected ArrayList<ProviderData> getProviderDataForUi() {
    protected ArrayList<ProviderData> getProviderDataForUi() {
        Log.i(TAG, "In getProviderDataAndInitiateUi");
        Slog.d(TAG, "In getProviderDataAndInitiateUi providers size: " + mProviders.size());
        Log.i(TAG, "In getProviderDataAndInitiateUi providers size: " + mProviders.size());
        ArrayList<ProviderData> providerDataList = new ArrayList<>();
        ArrayList<ProviderData> providerDataList = new ArrayList<>();
        mRequestSessionMetric.logCandidatePhaseMetrics(mProviders);
        mRequestSessionMetric.logCandidatePhaseMetrics(mProviders);


@@ -265,10 +260,8 @@ abstract class RequestSession<T, U, V> implements CredentialManagerUi.Credential
        }
        }


        for (ProviderSession session : mProviders.values()) {
        for (ProviderSession session : mProviders.values()) {
            Log.i(TAG, "preparing data for : " + session.getComponentName());
            ProviderData providerData = session.prepareUiData();
            ProviderData providerData = session.prepareUiData();
            if (providerData != null) {
            if (providerData != null) {
                Log.i(TAG, "Provider data is not null");
                providerDataList.add(providerData);
                providerDataList.add(providerData);
            }
            }
        }
        }
@@ -284,7 +277,7 @@ abstract class RequestSession<T, U, V> implements CredentialManagerUi.Credential
        mRequestSessionMetric.collectFinalPhaseProviderMetricStatus(/*has_exception=*/ false,
        mRequestSessionMetric.collectFinalPhaseProviderMetricStatus(/*has_exception=*/ false,
                ProviderStatusForMetrics.FINAL_SUCCESS);
                ProviderStatusForMetrics.FINAL_SUCCESS);
        if (mRequestSessionStatus == RequestSessionStatus.COMPLETE) {
        if (mRequestSessionStatus == RequestSessionStatus.COMPLETE) {
            Log.i(TAG, "Request has already been completed. This is strange.");
            Slog.w(TAG, "Request has already been completed. This is strange.");
            return;
            return;
        }
        }
        if (isSessionCancelled()) {
        if (isSessionCancelled()) {
@@ -300,7 +293,7 @@ abstract class RequestSession<T, U, V> implements CredentialManagerUi.Credential
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            mRequestSessionMetric.collectFinalPhaseProviderMetricStatus(
            mRequestSessionMetric.collectFinalPhaseProviderMetricStatus(
                    /*has_exception=*/ true, ProviderStatusForMetrics.FINAL_FAILURE);
                    /*has_exception=*/ true, ProviderStatusForMetrics.FINAL_FAILURE);
            Log.i(TAG, "Issue while responding to client with a response : " + e.getMessage());
            Slog.e(TAG, "Issue while responding to client with a response : " + e);
            mRequestSessionMetric.logApiCalledAtFinish(
            mRequestSessionMetric.logApiCalledAtFinish(
                    /*apiStatus=*/ ApiStatus.FAILURE.getMetricCode());
                    /*apiStatus=*/ ApiStatus.FAILURE.getMetricCode());
        }
        }
@@ -317,7 +310,7 @@ abstract class RequestSession<T, U, V> implements CredentialManagerUi.Credential
        mRequestSessionMetric.collectFinalPhaseProviderMetricStatus(
        mRequestSessionMetric.collectFinalPhaseProviderMetricStatus(
                /*has_exception=*/ true, ProviderStatusForMetrics.FINAL_FAILURE);
                /*has_exception=*/ true, ProviderStatusForMetrics.FINAL_FAILURE);
        if (mRequestSessionStatus == RequestSessionStatus.COMPLETE) {
        if (mRequestSessionStatus == RequestSessionStatus.COMPLETE) {
            Log.i(TAG, "Request has already been completed. This is strange.");
            Slog.w(TAG, "Request has already been completed. This is strange.");
            return;
            return;
        }
        }
        if (isSessionCancelled()) {
        if (isSessionCancelled()) {
@@ -330,7 +323,7 @@ abstract class RequestSession<T, U, V> implements CredentialManagerUi.Credential
        try {
        try {
            invokeClientCallbackError(errorType, errorMsg);
            invokeClientCallbackError(errorType, errorMsg);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.i(TAG, "Issue while responding to client with error : " + e.getMessage());
            Slog.e(TAG, "Issue while responding to client with error : " + e);
        }
        }
        boolean isUserCanceled = errorType.contains(MetricUtilities.USER_CANCELED_SUBSTRING);
        boolean isUserCanceled = errorType.contains(MetricUtilities.USER_CANCELED_SUBSTRING);
        mRequestSessionMetric.logFailureOrUserCancel(isUserCanceled);
        mRequestSessionMetric.logFailureOrUserCancel(isUserCanceled);