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

Commit bec597e4 authored by Joanne Chung's avatar Joanne Chung
Browse files

Disable log default dumps in debug ROM

We enable the logs dump in debug rom, we should only dump logs when
the debug flag is on.

Bug: 182433547
Test: Make sure the flag is disable after test and enable during test.

Change-Id: I0a719ee9c545b4e66f3414d7f57f3d959004071e
parent 293b6bf6
Loading
Loading
Loading
Loading
+4 −13
Original line number Original line Diff line number Diff line
@@ -25,7 +25,6 @@ import android.annotation.NonNull;
import android.annotation.WorkerThread;
import android.annotation.WorkerThread;
import android.app.Activity;
import android.app.Activity;
import android.content.Context;
import android.content.Context;
import android.os.Build;
import android.os.Handler;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.HandlerThread;
import android.os.Process;
import android.os.Process;
@@ -62,10 +61,7 @@ import java.util.function.BiConsumer;
 */
 */
public class UiTranslationController {
public class UiTranslationController {


    // TODO(b/182433547): remove Build.IS_DEBUGGABLE before ship. Enable the logging in debug build
    public static final boolean DEBUG = Log.isLoggable(UiTranslationManager.LOG_TAG, Log.DEBUG);
    //  to help the debug during the development phase
    public static final boolean DEBUG = Log.isLoggable(UiTranslationManager.LOG_TAG, Log.DEBUG)
            || Build.IS_DEBUGGABLE;


    private static final String TAG = "UiTranslationController";
    private static final String TAG = "UiTranslationController";
    @NonNull
    @NonNull
@@ -220,9 +216,7 @@ public class UiTranslationController {
            }
            }
            pw.print(outerPrefix); pw.print("padded views: "); pw.println(mViewsToPadContent);
            pw.print(outerPrefix); pw.print("padded views: "); pw.println(mViewsToPadContent);
        }
        }
        // TODO(b/182433547): we will remove debug rom condition before S release then we change
        if (DEBUG) {
        //  change this back to "DEBUG"
        if (Log.isLoggable(UiTranslationManager.LOG_TAG, Log.DEBUG)) {
            dumpViewByTraversal(outerPrefix, pw);
            dumpViewByTraversal(outerPrefix, pw);
        }
        }
    }
    }
@@ -396,7 +390,6 @@ public class UiTranslationController {
            for (int i = 0; i < resultCount; i++) {
            for (int i = 0; i < resultCount; i++) {
                final ViewTranslationResponse response = translatedResult.valueAt(i);
                final ViewTranslationResponse response = translatedResult.valueAt(i);
                if (DEBUG) {
                if (DEBUG) {
                    // TODO(b/182433547): remove before S release
                    Log.v(TAG, "onTranslationCompleted: "
                    Log.v(TAG, "onTranslationCompleted: "
                            + sanitizedViewTranslationResponse(response));
                            + sanitizedViewTranslationResponse(response));
                }
                }
@@ -617,8 +610,8 @@ public class UiTranslationController {
                for (int i = 0; i < viewCounts; i++) {
                for (int i = 0; i < viewCounts; i++) {
                    final View view = views.valueAt(i).get();
                    final View view = views.valueAt(i).get();
                    if (DEBUG) {
                    if (DEBUG) {
                        // TODO(b/182433547): remove before S release
                        Log.d(TAG, "runForEachView for autofillId = " + (view != null
                        Log.d(TAG, "runForEachView: view= " + view);
                                ? view.getAutofillId() : " null"));
                    }
                    }
                    if (view == null || view.getViewTranslationCallback() == null) {
                    if (view == null || view.getViewTranslationCallback() == null) {
                        if (DEBUG) {
                        if (DEBUG) {
@@ -679,8 +672,6 @@ public class UiTranslationController {
        }
        }
    }
    }


    // TODO(b/182433547): maybe remove below before S release

    /**
    /**
     * Returns a sanitized string representation of {@link ViewTranslationRequest};
     * Returns a sanitized string representation of {@link ViewTranslationRequest};
     */
     */
+0 −3
Original line number Original line Diff line number Diff line
@@ -13901,7 +13901,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    public void onCreateViewTranslationRequest(@NonNull int[] supportedFormats,
    public void onCreateViewTranslationRequest(@NonNull int[] supportedFormats,
            @NonNull Consumer<ViewTranslationRequest> requestsCollector) {
            @NonNull Consumer<ViewTranslationRequest> requestsCollector) {
        if (supportedFormats == null || supportedFormats.length == 0) {
        if (supportedFormats == null || supportedFormats.length == 0) {
            // TODO(b/182433547): remove before S release
            if (UiTranslationController.DEBUG) {
            if (UiTranslationController.DEBUG) {
                Log.w(LOG_TAG, "Do not provide the support translation formats.");
                Log.w(LOG_TAG, "Do not provide the support translation formats.");
            }
            }
@@ -13912,7 +13911,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        // Support Text translation
        // Support Text translation
        if (ArrayUtils.contains(supportedFormats, TranslationSpec.DATA_FORMAT_TEXT)) {
        if (ArrayUtils.contains(supportedFormats, TranslationSpec.DATA_FORMAT_TEXT)) {
            if (mText == null || mText.length() == 0) {
            if (mText == null || mText.length() == 0) {
                // TODO(b/182433547): remove before S release
                if (UiTranslationController.DEBUG) {
                if (UiTranslationController.DEBUG) {
                    Log.w(LOG_TAG, "Cannot create translation request for the empty text.");
                    Log.w(LOG_TAG, "Cannot create translation request for the empty text.");
                }
                }
@@ -13926,7 +13924,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            //  it, it needs broader changes to text APIs, we only allow to translate non selectable
            //  it, it needs broader changes to text APIs, we only allow to translate non selectable
            //  and editable text in S.
            //  and editable text in S.
            if (isTextEditable() || isPassword || isTextSelectable()) {
            if (isTextEditable() || isPassword || isTextSelectable()) {
                // TODO(b/182433547): remove before S release
                if (UiTranslationController.DEBUG) {
                if (UiTranslationController.DEBUG) {
                    Log.w(LOG_TAG, "Cannot create translation request. editable = "
                    Log.w(LOG_TAG, "Cannot create translation request. editable = "
                            + isTextEditable() + ", isPassword = " + isPassword + ", selectable = "
                            + isTextEditable() + ", isPassword = " + isPassword + ", selectable = "
+1 −7
Original line number Original line Diff line number Diff line
@@ -22,7 +22,6 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.content.res.ColorStateList;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.Color;
import android.os.Build;
import android.text.TextUtils;
import android.text.TextUtils;
import android.text.method.TransformationMethod;
import android.text.method.TransformationMethod;
import android.text.method.TranslationTransformationMethod;
import android.text.method.TranslationTransformationMethod;
@@ -43,10 +42,7 @@ public class TextViewTranslationCallback implements ViewTranslationCallback {


    private static final String TAG = "TextViewTranslationCb";
    private static final String TAG = "TextViewTranslationCb";


    // TODO(b/182433547): remove Build.IS_DEBUGGABLE before ship. Enable the logging in debug build
    private static final boolean DEBUG = Log.isLoggable(UiTranslationManager.LOG_TAG, Log.DEBUG);
    //  to help the debug during the development phase
    private static final boolean DEBUG = Log.isLoggable(UiTranslationManager.LOG_TAG, Log.DEBUG)
            || Build.IS_DEBUGGABLE;


    private TranslationTransformationMethod mTranslationTransformation;
    private TranslationTransformationMethod mTranslationTransformation;
    private boolean mIsShowingTranslation = false;
    private boolean mIsShowingTranslation = false;
@@ -124,7 +120,6 @@ public class TextViewTranslationCallback implements ViewTranslationCallback {
            }
            }
        } else {
        } else {
            if (DEBUG) {
            if (DEBUG) {
                // TODO(b/182433547): remove before S release
                Log.w(TAG, "onHideTranslation(): no translated text.");
                Log.w(TAG, "onHideTranslation(): no translated text.");
            }
            }
            return false;
            return false;
@@ -145,7 +140,6 @@ public class TextViewTranslationCallback implements ViewTranslationCallback {
            mContentDescription = null;
            mContentDescription = null;
        } else {
        } else {
            if (DEBUG) {
            if (DEBUG) {
                // TODO(b/182433547): remove before S release
                Log.w(TAG, "onClearTranslation(): no translated text.");
                Log.w(TAG, "onClearTranslation(): no translated text.");
            }
            }
            return false;
            return false;