diff options
author | Bo Liu <boliu@chromium.org> | 2016-02-19 17:47:55 -0800 |
---|---|---|
committer | Bo Liu <boliu@chromium.org> | 2016-02-20 01:49:40 +0000 |
commit | c8d3b08522638341d1b9851110ca3c40e18f1181 (patch) | |
tree | 2a877e29742bcc4e9e53f2a07c7401764fb7073a /content/public | |
parent | cfc72459a64480090d3271f9a83a909eadc4618c (diff) | |
download | chromium_src-c8d3b08522638341d1b9851110ca3c40e18f1181.zip chromium_src-c8d3b08522638341d1b9851110ca3c40e18f1181.tar.gz chromium_src-c8d3b08522638341d1b9851110ca3c40e18f1181.tar.bz2 |
[Merge m49] Compile out Java IME logs using a static boolean.
We were relying on Proguard to strip out Log.d, but we run Proguard
-dontoptimize on some release build configurations, which means
nothing is stripped.
BUG=583143
Review URL: https://codereview.chromium.org/1664443002
Cr-Commit-Position: refs/heads/master@{#373188}
(cherry picked from commit 45044228c2d41acc658b435d079d462d88fafb90)
Review URL: https://codereview.chromium.org/1714153003 .
Cr-Commit-Position: refs/branch-heads/2623@{#465}
Cr-Branched-From: 92d77538a86529ca35f9220bd3cd512cbea1f086-refs/heads/master@{#369907}
Diffstat (limited to 'content/public')
2 files changed, 49 insertions, 34 deletions
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java b/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java index 2376c47..ece8e2d 100644 --- a/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java +++ b/content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.java @@ -30,6 +30,7 @@ import java.util.Locale; */ public class AdapterInputConnection extends BaseInputConnection { private static final String TAG = "cr_Ime"; + private static final boolean DEBUG_LOGS = false; /** * Selection value should be -1 if not known. See EditorInfo.java for details. */ @@ -132,7 +133,9 @@ public class AdapterInputConnection extends BaseInputConnection { outAttrs.initialSelEnd = initialSelEnd; mLastUpdateSelectionStart = outAttrs.initialSelStart; mLastUpdateSelectionEnd = outAttrs.initialSelEnd; - Log.d(TAG, "Constructor called with outAttrs: %s", dumpEditorInfo(outAttrs)); + if (DEBUG_LOGS) { + Log.w(TAG, "Constructor called with outAttrs: %s", dumpEditorInfo(outAttrs)); + } } private static String dumpEditorInfo(EditorInfo editorInfo) { @@ -171,7 +174,7 @@ public class AdapterInputConnection extends BaseInputConnection { @VisibleForTesting public void updateState(String text, int selectionStart, int selectionEnd, int compositionStart, int compositionEnd, boolean isNonImeChange) { - Log.d(TAG, "updateState [%s] [%s %s] [%s %s] [%b]", text, selectionStart, + if (DEBUG_LOGS) Log.w(TAG, "updateState [%s] [%s %s] [%s %s] [%b]", text, selectionStart, selectionEnd, compositionStart, compositionEnd, isNonImeChange); // If this update is from the IME, no further state modification is necessary because the // state should have been updated already by the IM framework directly. @@ -210,7 +213,7 @@ public class AdapterInputConnection extends BaseInputConnection { @Override public Editable getEditable() { Editable editable = getEditableInternal(); - Log.d(TAG, "getEditable: %s", dumpEditable(editable)); + if (DEBUG_LOGS) Log.w(TAG, "getEditable: %s", dumpEditable(editable)); return editable; } @@ -236,8 +239,8 @@ public class AdapterInputConnection extends BaseInputConnection { && mLastUpdateCompositionEnd == compositionEnd) { return; } - Log.d(TAG, "updateSelectionIfRequired [%d %d] [%d %d]", selectionStart, selectionEnd, - compositionStart, compositionEnd); + if (DEBUG_LOGS) Log.w(TAG, "updateSelectionIfRequired [%d %d] [%d %d]", selectionStart, + selectionEnd, compositionStart, compositionEnd); // updateSelection should be called every time the selection or composition changes // if it happens not within a batch edit, or at the end of each top level batch edit. mImeAdapter.updateSelection(selectionStart, selectionEnd, compositionStart, compositionEnd); @@ -252,7 +255,7 @@ public class AdapterInputConnection extends BaseInputConnection { */ @Override public boolean setComposingText(CharSequence text, int newCursorPosition) { - Log.d(TAG, "setComposingText [%s] [%d]", text, newCursorPosition); + if (DEBUG_LOGS) Log.w(TAG, "setComposingText [%s] [%d]", text, newCursorPosition); mPendingAccent = 0; super.setComposingText(text, newCursorPosition); updateSelectionIfRequired(); @@ -264,7 +267,7 @@ public class AdapterInputConnection extends BaseInputConnection { */ @Override public boolean commitText(CharSequence text, int newCursorPosition) { - Log.d(TAG, "commitText [%s] [%d]", text, newCursorPosition); + if (DEBUG_LOGS) Log.w(TAG, "commitText [%s] [%d]", text, newCursorPosition); mPendingAccent = 0; super.commitText(text, newCursorPosition); updateSelectionIfRequired(); @@ -276,7 +279,7 @@ public class AdapterInputConnection extends BaseInputConnection { */ @Override public boolean performEditorAction(int actionCode) { - Log.d(TAG, "performEditorAction [%d]", actionCode); + if (DEBUG_LOGS) Log.w(TAG, "performEditorAction [%d]", actionCode); return mImeAdapter.performEditorAction(actionCode); } @@ -285,7 +288,7 @@ public class AdapterInputConnection extends BaseInputConnection { */ @Override public boolean performContextMenuAction(int id) { - Log.d(TAG, "performContextMenuAction [%d]", id); + if (DEBUG_LOGS) Log.w(TAG, "performContextMenuAction [%d]", id); return mImeAdapter.performContextMenuAction(id); } @@ -295,7 +298,7 @@ public class AdapterInputConnection extends BaseInputConnection { */ @Override public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) { - Log.d(TAG, "getExtractedText"); + if (DEBUG_LOGS) Log.w(TAG, "getExtractedText"); Editable editable = getEditableInternal(); ExtractedText et = new ExtractedText(); et.text = editable.toString(); @@ -311,7 +314,7 @@ public class AdapterInputConnection extends BaseInputConnection { */ @Override public boolean beginBatchEdit() { - Log.d(TAG, "beginBatchEdit [%b]", (mNumNestedBatchEdits == 0)); + if (DEBUG_LOGS) Log.w(TAG, "beginBatchEdit [%b]", (mNumNestedBatchEdits == 0)); mNumNestedBatchEdits++; return true; } @@ -323,7 +326,7 @@ public class AdapterInputConnection extends BaseInputConnection { public boolean endBatchEdit() { if (mNumNestedBatchEdits == 0) return false; --mNumNestedBatchEdits; - Log.d(TAG, "endBatchEdit [%b]", (mNumNestedBatchEdits == 0)); + if (DEBUG_LOGS) Log.w(TAG, "endBatchEdit [%b]", (mNumNestedBatchEdits == 0)); if (mNumNestedBatchEdits == 0) updateSelectionIfRequired(); return mNumNestedBatchEdits != 0; } @@ -350,7 +353,10 @@ public class AdapterInputConnection extends BaseInputConnection { private boolean deleteSurroundingTextImpl( int beforeLength, int afterLength, boolean fromPhysicalKey) { - Log.d(TAG, "deleteSurroundingText [%d %d %b]", beforeLength, afterLength, fromPhysicalKey); + if (DEBUG_LOGS) { + Log.w(TAG, "deleteSurroundingText [%d %d %b]", beforeLength, afterLength, + fromPhysicalKey); + } if (mPendingAccent != 0) { finishComposingText(); @@ -390,8 +396,10 @@ public class AdapterInputConnection extends BaseInputConnection { */ @Override public boolean sendKeyEvent(KeyEvent event) { - Log.d(TAG, "sendKeyEvent [%d] [%d] [%d]", event.getAction(), event.getKeyCode(), - event.getUnicodeChar()); + if (DEBUG_LOGS) { + Log.w(TAG, "sendKeyEvent [%d] [%d] [%d]", event.getAction(), event.getKeyCode(), + event.getUnicodeChar()); + } int action = event.getAction(); int keycode = event.getKeyCode(); @@ -466,7 +474,7 @@ public class AdapterInputConnection extends BaseInputConnection { */ @Override public boolean finishComposingText() { - Log.d(TAG, "finishComposingText"); + if (DEBUG_LOGS) Log.w(TAG, "finishComposingText"); mPendingAccent = 0; if (getComposingSpanStart(getEditableInternal()) @@ -486,7 +494,7 @@ public class AdapterInputConnection extends BaseInputConnection { */ @Override public boolean setSelection(int start, int end) { - Log.d(TAG, "setSelection [%d %d]", start, end); + if (DEBUG_LOGS) Log.w(TAG, "setSelection [%d %d]", start, end); int textLength = getEditableInternal().length(); if (start < 0 || end < 0 || start > textLength || end > textLength) return true; super.setSelection(start, end); @@ -498,7 +506,7 @@ public class AdapterInputConnection extends BaseInputConnection { * Call this when restartInput() is called. */ void onRestartInput() { - Log.d(TAG, "onRestartInput"); + if (DEBUG_LOGS) Log.w(TAG, "onRestartInput"); mNumNestedBatchEdits = 0; mPendingAccent = 0; } @@ -508,7 +516,7 @@ public class AdapterInputConnection extends BaseInputConnection { */ @Override public boolean setComposingRegion(int start, int end) { - Log.d(TAG, "setComposingRegion [%d %d]", start, end); + if (DEBUG_LOGS) Log.w(TAG, "setComposingRegion [%d %d]", start, end); Editable editable = getEditableInternal(); int textLength = editable.length(); int a = Math.min(start, end); diff --git a/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java b/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java index 2b0c174..75bb44f 100644 --- a/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java +++ b/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java @@ -53,6 +53,7 @@ import org.chromium.ui.picker.InputDialogContainer; @JNINamespace("content") public class ImeAdapter { private static final String TAG = "cr_Ime"; + private static final boolean DEBUG_LOGS = false; private static final int COMPOSITION_KEY_CODE = 229; @@ -143,7 +144,7 @@ public class ImeAdapter { // ImeAdapter#dispatchKeyEvent(). if (mTextInputType == TextInputType.NONE) { mInputConnection = null; - Log.d(TAG, "onCreateInputConnection returns null."); + if (DEBUG_LOGS) Log.w(TAG, "onCreateInputConnection returns null."); // InputMethodService evaluates fullscreen mode even when the new input connection is // null. This makes sure IME doesn't enter fullscreen mode or open custom UI. outAttrs.imeOptions = @@ -161,7 +162,7 @@ public class ImeAdapter { int initialSelEnd = outAttrs.initialSelEnd = Selection.getSelectionEnd(mEditable); mInputConnection = mInputConnectionFactory.get( mViewEmbedder.getAttachedView(), this, initialSelStart, initialSelEnd, outAttrs); - Log.d(TAG, "onCreateInputConnection"); + if (DEBUG_LOGS) Log.w(TAG, "onCreateInputConnection"); return mInputConnection; } @@ -247,8 +248,10 @@ public class ImeAdapter { */ public void updateKeyboardVisibility(int textInputType, int textInputFlags, boolean showIfNeeded) { - Log.d(TAG, "updateKeyboardVisibility: type [%d->%d], flags [%d], show [%b], ", - mTextInputType, textInputType, textInputFlags, showIfNeeded); + if (DEBUG_LOGS) { + Log.w(TAG, "updateKeyboardVisibility: type [%d->%d], flags [%d], show [%b], ", + mTextInputType, textInputType, textInputFlags, showIfNeeded); + } mTextInputFlags = textInputFlags; if (mTextInputType != textInputType) { mTextInputType = textInputType; @@ -307,7 +310,7 @@ public class ImeAdapter { * Show soft keyboard only if it is the current keyboard configuration. */ private void showSoftKeyboard() { - Log.d(TAG, "showSoftKeyboard"); + if (DEBUG_LOGS) Log.w(TAG, "showSoftKeyboard"); mInputMethodManagerWrapper.showSoftInput( mViewEmbedder.getAttachedView(), 0, mViewEmbedder.getNewShowKeyboardReceiver()); if (mViewEmbedder.getAttachedView().getResources().getConfiguration().keyboard @@ -320,7 +323,7 @@ public class ImeAdapter { * Hide soft keyboard. */ private void hideKeyboard() { - Log.d(TAG, "hideKeyboard"); + if (DEBUG_LOGS) Log.w(TAG, "hideKeyboard"); View view = mViewEmbedder.getAttachedView(); if (mInputMethodManagerWrapper.isActive(view)) { // NOTE: we should not set ResultReceiver here. Otherwise, IMM will own ContentViewCore @@ -346,7 +349,9 @@ public class ImeAdapter { // Deep copy newConfig so that we can notice the difference. mCurrentConfig = new Configuration(newConfig); - Log.d(TAG, "onKeyboardConfigurationChanged: mTextInputType [%d]", mTextInputType); + if (DEBUG_LOGS) { + Log.w(TAG, "onKeyboardConfigurationChanged: mTextInputType [%d]", mTextInputType); + } if (mTextInputType != TextInputType.NONE) { restartInput(); // By default, we show soft keyboard on keyboard changes. This is useful @@ -361,7 +366,7 @@ public class ImeAdapter { * @param gainFocus True if we're gaining focus. */ public void onViewFocusChanged(boolean gainFocus) { - Log.d(TAG, "onViewFocusChanged: gainFocus [%b]", gainFocus); + if (DEBUG_LOGS) Log.w(TAG, "onViewFocusChanged: gainFocus [%b]", gainFocus); if (!gainFocus) hideKeyboard(); } @@ -369,7 +374,7 @@ public class ImeAdapter { * Move cursor to the end of the current selection. */ public void moveCursorToSelectionEnd() { - Log.d(TAG, "movecursorToEnd"); + if (DEBUG_LOGS) Log.w(TAG, "movecursorToEnd"); if (mInputConnection != null) { int selectionEnd = Selection.getSelectionEnd(mEditable); mInputConnection.setSelection(selectionEnd, selectionEnd); @@ -390,7 +395,7 @@ public class ImeAdapter { } public boolean dispatchKeyEvent(KeyEvent event) { - Log.d(TAG, "dispatchKeyEvent: action [%d], keycode [%d]", event.getAction(), + if (DEBUG_LOGS) Log.w(TAG, "dispatchKeyEvent: action [%d], keycode [%d]", event.getAction(), event.getKeyCode()); if (mInputConnection != null) { return mInputConnection.sendKeyEvent(event); @@ -424,7 +429,7 @@ public class ImeAdapter { * @see BaseInputConnection#performContextMenuAction(int) */ boolean performContextMenuAction(int id) { - Log.d(TAG, "performContextMenuAction: id [%d]", id); + if (DEBUG_LOGS) Log.w(TAG, "performContextMenuAction: id [%d]", id); return mViewEmbedder.performContextMenuAction(id); } @@ -556,7 +561,7 @@ public class ImeAdapter { @CalledByNative private void focusedNodeChanged(boolean isEditable) { - Log.d(TAG, "focusedNodeChanged: isEditable [%b]", isEditable); + if (DEBUG_LOGS) Log.w(TAG, "focusedNodeChanged: isEditable [%b]", isEditable); if (mTextInputType != TextInputType.NONE && mInputConnection != null && isEditable) { restartInput(); } @@ -564,7 +569,9 @@ public class ImeAdapter { @CalledByNative private void populateUnderlinesFromSpans(CharSequence text, long underlines) { - Log.d(TAG, "populateUnderlinesFromSpans: text [%s], underlines [%d]", text, underlines); + if (DEBUG_LOGS) { + Log.w(TAG, "populateUnderlinesFromSpans: text [%s], underlines [%d]", text, underlines); + } if (!(text instanceof SpannableString)) return; SpannableString spannableString = ((SpannableString) text); @@ -584,13 +591,13 @@ public class ImeAdapter { @CalledByNative private void cancelComposition() { - Log.d(TAG, "cancelComposition"); + if (DEBUG_LOGS) Log.w(TAG, "cancelComposition"); if (mInputConnection != null) restartInput(); } @CalledByNative private void detach() { - Log.d(TAG, "detach"); + if (DEBUG_LOGS) Log.w(TAG, "detach"); mNativeImeAdapterAndroid = 0; } |