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

Commit b5ce61c1 authored by Arpan Kaphle's avatar Arpan Kaphle
Browse files

Optimizing Log Messages

This aims to remove redundant messages, and converts logs to Slogs.
It considers the go/greenlog message.

Bug: 278591970
Bug: 270568738
Test: Build Test (Log statements only)
Change-Id: I4a175501cb2cb85891c31c9f31b31cbd17bcd870
parent 79492ead
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -67,7 +67,7 @@ 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) {
            Slog.d(TAG, "In startProviderSession - provider session created "
            Slog.i(TAG, "Provider session created "
                    + "and being added for: " + providerInfo.getComponentName());
                    + "and being added for: " + providerInfo.getComponentName());
            mProviders.put(providerClearSession.getComponentName().flattenToString(),
            mProviders.put(providerClearSession.getComponentName().flattenToString(),
                    providerClearSession);
                    providerClearSession);
@@ -78,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) {
        Slog.d(TAG, "in onStatusChanged with status: " + status + ", and source: " + source);
        Slog.i(TAG, "Provider changed with status: " + status + ", and source: " + source);
        if (ProviderSession.isTerminatingStatus(status)) {
        if (ProviderSession.isTerminatingStatus(status)) {
            Slog.d(TAG, "in onProviderStatusChanged terminating status");
            Slog.i(TAG, "Provider terminating status");
            onProviderTerminated(componentName);
            onProviderTerminated(componentName);
        } else if (ProviderSession.isCompletionStatus(status)) {
        } else if (ProviderSession.isCompletionStatus(status)) {
            Slog.d(TAG, "in onProviderStatusChanged isCompletionStatus status");
            Slog.i(TAG, "Provider has completion status");
            onProviderResponseComplete(componentName);
            onProviderResponseComplete(componentName);
        }
        }
    }
    }
+4 −4
Original line number Original line Diff line number Diff line
@@ -79,7 +79,7 @@ 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) {
            Slog.d(TAG, "In initiateProviderSession - provider session created and "
            Slog.i(TAG, "Provider session created and "
                    + "being added for: " + providerInfo.getComponentName());
                    + "being added for: " + providerInfo.getComponentName());
            mProviders.put(providerCreateSession.getComponentName().flattenToString(),
            mProviders.put(providerCreateSession.getComponentName().flattenToString(),
                    providerCreateSession);
                    providerCreateSession);
@@ -127,7 +127,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) {
        Slog.d(TAG, "onFinalCredentialReceived from: " + componentName.flattenToString());
        Slog.i(TAG, "Final credential received 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
@@ -170,13 +170,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) {
        Slog.d(TAG, "in onStatusChanged with status: " + status + ", and source: " + source);
        Slog.i(TAG, "Provider status changed: " + 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()) {
                Slog.d(TAG, "in onProviderStatusChanged - isUiInvocationNeeded");
                Slog.i(TAG, "Provider status changed - ui invocation is needed");
                getProviderDataAndInitiateUi();
                getProviderDataAndInitiateUi();
            } else {
            } else {
                respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREATE_OPTIONS,
                respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREATE_OPTIONS,
+9 −10
Original line number Original line Diff line number Diff line
@@ -436,7 +436,7 @@ public final class CredentialManagerService
                IGetCredentialCallback callback,
                IGetCredentialCallback callback,
                final String callingPackage) {
                final String callingPackage) {
            final long timestampBegan = System.nanoTime();
            final long timestampBegan = System.nanoTime();
            Slog.d(TAG, "starting executeGetCredential with callingPackage: "
            Slog.i(TAG, "starting executeGetCredential with callingPackage: "
                    + callingPackage);
                    + callingPackage);
            ICancellationSignal cancelTransport = CancellationSignal.createTransport();
            ICancellationSignal cancelTransport = CancellationSignal.createTransport();


@@ -471,7 +471,7 @@ public final class CredentialManagerService
                            GetCredentialException.TYPE_NO_CREDENTIAL,
                            GetCredentialException.TYPE_NO_CREDENTIAL,
                            "No credentials available on this device.");
                            "No credentials available on this device.");
                } catch (RemoteException e) {
                } catch (RemoteException e) {
                    Slog.i(
                    Slog.e(
                            TAG,
                            TAG,
                            "Issue invoking onError on IGetCredentialCallback "
                            "Issue invoking onError on IGetCredentialCallback "
                                    + "callback: "
                                    + "callback: "
@@ -527,7 +527,7 @@ public final class CredentialManagerService
                                    false, null,
                                    false, null,
                                    false, false, null));
                                    false, false, null));
                } catch (RemoteException e) {
                } catch (RemoteException e) {
                    Slog.i(
                    Slog.e(
                            TAG,
                            TAG,
                            "Issue invoking onError on IGetCredentialCallback "
                            "Issue invoking onError on IGetCredentialCallback "
                                    + "callback: "
                                    + "callback: "
@@ -606,7 +606,7 @@ public final class CredentialManagerService
                ICreateCredentialCallback callback,
                ICreateCredentialCallback callback,
                String callingPackage) {
                String callingPackage) {
            final long timestampBegan = System.nanoTime();
            final long timestampBegan = System.nanoTime();
            Slog.d(TAG, "starting executeCreateCredential with callingPackage: "
            Slog.i(TAG, "starting executeCreateCredential with callingPackage: "
                    + callingPackage);
                    + callingPackage);
            ICancellationSignal cancelTransport = CancellationSignal.createTransport();
            ICancellationSignal cancelTransport = CancellationSignal.createTransport();


@@ -672,7 +672,7 @@ public final class CredentialManagerService
                MetricUtilities.logApiCalledInitialPhase(initMetric,
                MetricUtilities.logApiCalledInitialPhase(initMetric,
                        session.mRequestSessionMetric.returnIncrementSequence());
                        session.mRequestSessionMetric.returnIncrementSequence());
            } catch (Exception e) {
            } catch (Exception e) {
                Slog.w(TAG, "Unexpected error during metric logging: ", e);
                Slog.i(TAG, "Unexpected error during metric logging: ", e);
            }
            }
        }
        }


@@ -732,7 +732,7 @@ public final class CredentialManagerService
        @Override
        @Override
        public boolean isEnabledCredentialProviderService(
        public boolean isEnabledCredentialProviderService(
                ComponentName componentName, String callingPackage) {
                ComponentName componentName, String callingPackage) {
            Slog.d(TAG, "isEnabledCredentialProviderService with componentName: "
            Slog.i(TAG, "isEnabledCredentialProviderService with componentName: "
                    + componentName.flattenToString());
                    + componentName.flattenToString());


            // TODO(253157366): Check additional set of services.
            // TODO(253157366): Check additional set of services.
@@ -828,7 +828,7 @@ public final class CredentialManagerService
                IClearCredentialStateCallback callback,
                IClearCredentialStateCallback callback,
                String callingPackage) {
                String callingPackage) {
            final long timestampBegan = System.nanoTime();
            final long timestampBegan = System.nanoTime();
            Slog.d(TAG, "starting clearCredentialState with callingPackage: "
            Slog.i(TAG, "starting clearCredentialState with callingPackage: "
                    + callingPackage);
                    + callingPackage);
            final int userId = UserHandle.getCallingUserId();
            final int userId = UserHandle.getCallingUserId();
            int callingUid = Binder.getCallingUid();
            int callingUid = Binder.getCallingUid();
@@ -881,7 +881,7 @@ public final class CredentialManagerService
        public void registerCredentialDescription(
        public void registerCredentialDescription(
                RegisterCredentialDescriptionRequest request, String callingPackage)
                RegisterCredentialDescriptionRequest request, String callingPackage)
                throws IllegalArgumentException, NonCredentialProviderCallerException {
                throws IllegalArgumentException, NonCredentialProviderCallerException {
            Slog.d(TAG, "registerCredentialDescription with callingPackage: " + callingPackage);
            Slog.i(TAG, "registerCredentialDescription with callingPackage: " + callingPackage);


            if (!isCredentialDescriptionApiEnabled()) {
            if (!isCredentialDescriptionApiEnabled()) {
                throw new UnsupportedOperationException();
                throw new UnsupportedOperationException();
@@ -899,7 +899,7 @@ public final class CredentialManagerService
        public void unregisterCredentialDescription(
        public void unregisterCredentialDescription(
                UnregisterCredentialDescriptionRequest request, String callingPackage)
                UnregisterCredentialDescriptionRequest request, String callingPackage)
                throws IllegalArgumentException {
                throws IllegalArgumentException {
            Slog.d(TAG, "unregisterCredentialDescription with callingPackage: "
            Slog.i(TAG, "unregisterCredentialDescription with callingPackage: "
                    + callingPackage);
                    + callingPackage);




@@ -961,7 +961,6 @@ public final class CredentialManagerService
        @Override
        @Override
        @GuardedBy("mLock")
        @GuardedBy("mLock")
        public void onFinishRequestSession(@UserIdInt int userId, IBinder token) {
        public void onFinishRequestSession(@UserIdInt int userId, IBinder token) {
            Slog.i(TAG, "In onFinishRequestSession");
            if (mRequestSessions.get(userId) != null) {
            if (mRequestSessions.get(userId) != null) {
                mRequestSessions.get(userId).remove(token);
                mRequestSessions.get(userId).remove(token);
            }
            }
+6 −6
Original line number Original line Diff line number Diff line
@@ -48,7 +48,7 @@ public final class CredentialManagerServiceImpl extends
            @NonNull Object lock, int userId, String serviceName)
            @NonNull Object lock, int userId, String serviceName)
            throws PackageManager.NameNotFoundException {
            throws PackageManager.NameNotFoundException {
        super(master, lock, userId);
        super(master, lock, userId);
        Slog.d(TAG, "CredentialManagerServiceImpl constructed for: " + serviceName);
        Slog.i(TAG, "CredentialManagerServiceImpl constructed for: " + serviceName);
        synchronized (mLock) {
        synchronized (mLock) {
            newServiceInfoLocked(ComponentName.unflattenFromString(serviceName));
            newServiceInfoLocked(ComponentName.unflattenFromString(serviceName));
        }
        }
@@ -63,7 +63,7 @@ public final class CredentialManagerServiceImpl extends
            @NonNull CredentialManagerService master,
            @NonNull CredentialManagerService master,
            @NonNull Object lock, int userId, CredentialProviderInfo providerInfo) {
            @NonNull Object lock, int userId, CredentialProviderInfo providerInfo) {
        super(master, lock, userId);
        super(master, lock, userId);
        Slog.d(TAG, "CredentialManagerServiceImpl constructed for: "
        Slog.i(TAG, "CredentialManagerServiceImpl constructed for: "
                + providerInfo.getServiceInfo().getComponentName().flattenToString());
                + providerInfo.getServiceInfo().getComponentName().flattenToString());
        mInfo = providerInfo;
        mInfo = providerInfo;
    }
    }
@@ -74,11 +74,11 @@ public final class CredentialManagerServiceImpl extends
            throws PackageManager.NameNotFoundException {
            throws PackageManager.NameNotFoundException {
        // TODO : Test update flows with multiple providers
        // TODO : Test update flows with multiple providers
        if (mInfo != null) {
        if (mInfo != null) {
            Slog.d(TAG, "newServiceInfoLocked, mInfo not null : "
            Slog.i(TAG, "newServiceInfoLocked, mInfo not null : "
                    + mInfo.getServiceInfo().getComponentName().flattenToString() + " , "
                    + mInfo.getServiceInfo().getComponentName().flattenToString() + " , "
                    + serviceComponent.flattenToString());
                    + serviceComponent.flattenToString());
        } else {
        } else {
            Slog.d(TAG, "newServiceInfoLocked, mInfo null, "
            Slog.i(TAG, "newServiceInfoLocked, mInfo null, "
                    + serviceComponent.flattenToString());
                    + serviceComponent.flattenToString());
        }
        }
        mInfo = CredentialProviderInfoFactory.create(
        mInfo = CredentialProviderInfoFactory.create(
@@ -95,11 +95,11 @@ public final class CredentialManagerServiceImpl extends
    public ProviderSession initiateProviderSessionForRequestLocked(
    public ProviderSession initiateProviderSessionForRequestLocked(
            RequestSession requestSession, List<String> requestOptions) {
            RequestSession requestSession, List<String> requestOptions) {
        if (!requestOptions.isEmpty() && !isServiceCapableLocked(requestOptions)) {
        if (!requestOptions.isEmpty() && !isServiceCapableLocked(requestOptions)) {
            Slog.d(TAG, "Service does not have the required capabilities");
            Slog.i(TAG, "Service does not have the required capabilities");
            return null;
            return null;
        }
        }
        if (mInfo == null) {
        if (mInfo == null) {
            Slog.w(TAG, "in initiateProviderSessionForRequest in CredManServiceImpl, "
            Slog.w(TAG, "Initiating provider session for request "
                    + "but mInfo is null. This shouldn't happen");
                    + "but mInfo is null. This shouldn't happen");
            return null;
            return null;
        }
        }
+4 −4
Original line number Original line Diff line number Diff line
@@ -72,7 +72,7 @@ public class GetRequestSession extends RequestSession<GetCredentialRequest,
                .createNewSession(mContext, mUserId, providerInfo,
                .createNewSession(mContext, mUserId, providerInfo,
                        this, remoteCredentialService);
                        this, remoteCredentialService);
        if (providerGetSession != null) {
        if (providerGetSession != null) {
            Slog.d(TAG, "In startProviderSession - provider session created and "
            Slog.i(TAG, "Provider session created and "
                    + "being added for: " + providerInfo.getComponentName());
                    + "being added for: " + providerInfo.getComponentName());
            mProviders.put(providerGetSession.getComponentName().flattenToString(),
            mProviders.put(providerGetSession.getComponentName().flattenToString(),
                    providerGetSession);
                    providerGetSession);
@@ -114,7 +114,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) {
        Slog.d(TAG, "onFinalResponseReceived from: " + componentName.flattenToString());
        Slog.i(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())
@@ -158,7 +158,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) {
        Slog.d(TAG, "in onStatusChanged for: " + componentName + ", with status: "
        Slog.i(TAG, "Status changed for: " + componentName + ", with status: "
                + status + ", and source: " + source);
                + 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
@@ -172,7 +172,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()) {
                Slog.d(TAG, "in onProviderStatusChanged - isUiInvocationNeeded");
                Slog.i(TAG, "Provider status changed - ui invocation is needed");
                getProviderDataAndInitiateUi();
                getProviderDataAndInitiateUi();
            } else {
            } else {
                respondToClientWithErrorAndFinish(GetCredentialException.TYPE_NO_CREDENTIAL,
                respondToClientWithErrorAndFinish(GetCredentialException.TYPE_NO_CREDENTIAL,
Loading