summaryrefslogtreecommitdiff
path: root/core/java/android/widget/TextView.java
diff options
context:
space:
mode:
authorJoanne Chung <joannechung@google.com>2021-03-10 22:25:16 +0800
committerJoanne Chung <joannechung@google.com>2021-03-11 16:34:44 +0800
commit3cda8bd49fba84b76eba8962b93b3ec704214e40 (patch)
tree06132ca6d064431871c70d6234cf54123b698ad8 /core/java/android/widget/TextView.java
parent2d60140ef022ce78339d31f6d99a95e4ab151e79 (diff)
Add debug logs to help clarify the issue
We receive translation doesn't work issues but we don't have enough log information to help debugging the issue. To help clarify issue - Add more information when dumpsys activity information - We use Log.isLoggable() to control if the debug log need to be printed. But for the development phase, we enable print log on the debuggable ROM, we will delete it before platform release. Bug: 181975692 Test: manual. adb shell dumpsys activity <myactivity> --translation (Can find dumpsys result of sample app in bug 182433547) Change-Id: I4a9a1667a544fc4d1654c5f297d365a8288b1f4a
Diffstat (limited to 'core/java/android/widget/TextView.java')
-rw-r--r--core/java/android/widget/TextView.java19
1 files changed, 18 insertions, 1 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index fdc66fcb81d8..9e97f9aaed42 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -195,6 +195,7 @@ import android.view.textclassifier.TextLinks;
import android.view.textservice.SpellCheckerSubtype;
import android.view.textservice.TextServicesManager;
import android.view.translation.TranslationRequestValue;
+import android.view.translation.UiTranslationController;
import android.view.translation.ViewTranslationRequest;
import android.view.translation.ViewTranslationResponse;
import android.widget.RemoteViews.RemoteView;
@@ -13835,6 +13836,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
@Override
public ViewTranslationRequest onCreateTranslationRequest() {
if (mText == null || mText.length() == 0) {
+ // TODO(b/182433547): remove before S release
+ if (UiTranslationController.DEBUG) {
+ Log.w(LOG_TAG, "Cannot create translation request for the empty text.");
+ }
return null;
}
// Not translate password, editable text and not important for translation
@@ -13842,6 +13847,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// text selection apis, not support in S.
boolean isPassword = isAnyPasswordInputType() || hasPasswordTransformationMethod();
if (isTextEditable() || isPassword || isTextSelectable()) {
+ // TODO(b/182433547): remove before S release
+ if (UiTranslationController.DEBUG) {
+ Log.w(LOG_TAG, "Cannot create translation request. editable = " + isTextEditable()
+ + ", isPassword = " + isPassword + ", selectable = " + isTextSelectable());
+ }
return null;
}
// TODO(b/176488462): apply the view's important for translation property
@@ -13870,6 +13880,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// Restore to original text content.
if (mTranslationTransformation != null) {
setTransformationMethod(mTranslationTransformation.getOriginalTransformationMethod());
+ } else {
+ // TODO(b/182433547): remove before S release
+ Log.w(LOG_TAG, "onPauseUiTranslation(): no translated text.");
}
}
@@ -13889,7 +13902,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (mTranslationTransformation != null) {
setTransformationMethod(mTranslationTransformation);
} else {
- Log.w(LOG_TAG, "onResumeTranslatedText(): no translated text.");
+ // TODO(b/182433547): remove before S release
+ Log.w(LOG_TAG, "onRestoreUiTranslation(): no translated text.");
}
}
@@ -13910,6 +13924,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (mTranslationTransformation != null) {
setTransformationMethod(mTranslationTransformation.getOriginalTransformationMethod());
mTranslationTransformation = null;
+ } else {
+ // TODO(b/182433547): remove before S release
+ Log.w(LOG_TAG, "onFinishUiTranslation(): no translated text.");
}
}