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 Diff line number Diff line
@@ -67,7 +67,7 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta
                .createNewSession(mContext, mUserId, providerInfo,
                        this, remoteCredentialService);
        if (providerClearSession != null) {
            Slog.d(TAG, "In startProviderSession - provider session created "
            Slog.i(TAG, "Provider session created "
                    + "and being added for: " + providerInfo.getComponentName());
            mProviders.put(providerClearSession.getComponentName().flattenToString(),
                    providerClearSession);
@@ -78,12 +78,12 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta
    @Override // from provider session
    public void onProviderStatusChanged(ProviderSession.Status status,
            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)) {
            Slog.d(TAG, "in onProviderStatusChanged terminating status");
            Slog.i(TAG, "Provider terminating status");
            onProviderTerminated(componentName);
        } else if (ProviderSession.isCompletionStatus(status)) {
            Slog.d(TAG, "in onProviderStatusChanged isCompletionStatus status");
            Slog.i(TAG, "Provider has completion status");
            onProviderResponseComplete(componentName);
        }
    }
+4 −4
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
                .createNewSession(mContext, mUserId, providerInfo,
                        this, remoteCredentialService);
        if (providerCreateSession != null) {
            Slog.d(TAG, "In initiateProviderSession - provider session created and "
            Slog.i(TAG, "Provider session created and "
                    + "being added for: " + providerInfo.getComponentName());
            mProviders.put(providerCreateSession.getComponentName().flattenToString(),
                    providerCreateSession);
@@ -127,7 +127,7 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
    @Override
    public void onFinalResponseReceived(ComponentName componentName,
            @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.collectChosenMetricViaCandidateTransfer(mProviders.get(
                componentName.flattenToString()).mProviderSessionMetric
@@ -170,13 +170,13 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
    @Override
    public void onProviderStatusChanged(ProviderSession.Status status,
            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,
        // 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.
        if (!isAnyProviderPending()) {
            if (isUiInvocationNeeded()) {
                Slog.d(TAG, "in onProviderStatusChanged - isUiInvocationNeeded");
                Slog.i(TAG, "Provider status changed - ui invocation is needed");
                getProviderDataAndInitiateUi();
            } else {
                respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREATE_OPTIONS,
+9 −10
Original line number Diff line number Diff line
@@ -436,7 +436,7 @@ public final class CredentialManagerService
                IGetCredentialCallback callback,
                final String callingPackage) {
            final long timestampBegan = System.nanoTime();
            Slog.d(TAG, "starting executeGetCredential with callingPackage: "
            Slog.i(TAG, "starting executeGetCredential with callingPackage: "
                    + callingPackage);
            ICancellationSignal cancelTransport = CancellationSignal.createTransport();

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

@@ -672,7 +672,7 @@ public final class CredentialManagerService
                MetricUtilities.logApiCalledInitialPhase(initMetric,
                        session.mRequestSessionMetric.returnIncrementSequence());
            } 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
        public boolean isEnabledCredentialProviderService(
                ComponentName componentName, String callingPackage) {
            Slog.d(TAG, "isEnabledCredentialProviderService with componentName: "
            Slog.i(TAG, "isEnabledCredentialProviderService with componentName: "
                    + componentName.flattenToString());

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

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


@@ -961,7 +961,6 @@ public final class CredentialManagerService
        @Override
        @GuardedBy("mLock")
        public void onFinishRequestSession(@UserIdInt int userId, IBinder token) {
            Slog.i(TAG, "In onFinishRequestSession");
            if (mRequestSessions.get(userId) != null) {
                mRequestSessions.get(userId).remove(token);
            }
+6 −6
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ public final class CredentialManagerServiceImpl extends
            @NonNull Object lock, int userId, String serviceName)
            throws PackageManager.NameNotFoundException {
        super(master, lock, userId);
        Slog.d(TAG, "CredentialManagerServiceImpl constructed for: " + serviceName);
        Slog.i(TAG, "CredentialManagerServiceImpl constructed for: " + serviceName);
        synchronized (mLock) {
            newServiceInfoLocked(ComponentName.unflattenFromString(serviceName));
        }
@@ -63,7 +63,7 @@ public final class CredentialManagerServiceImpl extends
            @NonNull CredentialManagerService master,
            @NonNull Object lock, int userId, CredentialProviderInfo providerInfo) {
        super(master, lock, userId);
        Slog.d(TAG, "CredentialManagerServiceImpl constructed for: "
        Slog.i(TAG, "CredentialManagerServiceImpl constructed for: "
                + providerInfo.getServiceInfo().getComponentName().flattenToString());
        mInfo = providerInfo;
    }
@@ -74,11 +74,11 @@ public final class CredentialManagerServiceImpl extends
            throws PackageManager.NameNotFoundException {
        // TODO : Test update flows with multiple providers
        if (mInfo != null) {
            Slog.d(TAG, "newServiceInfoLocked, mInfo not null : "
            Slog.i(TAG, "newServiceInfoLocked, mInfo not null : "
                    + mInfo.getServiceInfo().getComponentName().flattenToString() + " , "
                    + serviceComponent.flattenToString());
        } else {
            Slog.d(TAG, "newServiceInfoLocked, mInfo null, "
            Slog.i(TAG, "newServiceInfoLocked, mInfo null, "
                    + serviceComponent.flattenToString());
        }
        mInfo = CredentialProviderInfoFactory.create(
@@ -95,11 +95,11 @@ public final class CredentialManagerServiceImpl extends
    public ProviderSession initiateProviderSessionForRequestLocked(
            RequestSession requestSession, List<String> 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;
        }
        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");
            return null;
        }
+4 −4
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ public class GetRequestSession extends RequestSession<GetCredentialRequest,
                .createNewSession(mContext, mUserId, providerInfo,
                        this, remoteCredentialService);
        if (providerGetSession != null) {
            Slog.d(TAG, "In startProviderSession - provider session created and "
            Slog.i(TAG, "Provider session created and "
                    + "being added for: " + providerInfo.getComponentName());
            mProviders.put(providerGetSession.getComponentName().flattenToString(),
                    providerGetSession);
@@ -114,7 +114,7 @@ public class GetRequestSession extends RequestSession<GetCredentialRequest,
    @Override
    public void onFinalResponseReceived(ComponentName componentName,
            @Nullable GetCredentialResponse response) {
        Slog.d(TAG, "onFinalResponseReceived from: " + componentName.flattenToString());
        Slog.i(TAG, "onFinalResponseReceived from: " + componentName.flattenToString());
        mRequestSessionMetric.collectUiResponseData(/*uiReturned=*/ true, System.nanoTime());
        mRequestSessionMetric.collectChosenMetricViaCandidateTransfer(
                mProviders.get(componentName.flattenToString())
@@ -158,7 +158,7 @@ public class GetRequestSession extends RequestSession<GetCredentialRequest,
    @Override
    public void onProviderStatusChanged(ProviderSession.Status status,
            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);

        // 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
            // selected after the UI has been invoked which has a separate code path.
            if (isUiInvocationNeeded()) {
                Slog.d(TAG, "in onProviderStatusChanged - isUiInvocationNeeded");
                Slog.i(TAG, "Provider status changed - ui invocation is needed");
                getProviderDataAndInitiateUi();
            } else {
                respondToClientWithErrorAndFinish(GetCredentialException.TYPE_NO_CREDENTIAL,
Loading