Commit e12209c4 authored by Tao Bai's avatar Tao Bai Committed by Commit Bot

[WebView autofill] Add runtime log

The log can be enabled by run
setprop log.tag.AwAutofillManager DEBUG

Bug: 843277
Change-Id: I136d300b4fa11e42b3acce0f41ad832b56ff9938
Reviewed-on: https://chromium-review.googlesource.com/1091302Reviewed-by: default avatarChangwan Ryu <changwan@chromium.org>
Commit-Queue: Tao Bai <michaelbai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565472}
parent 3596e659
...@@ -24,8 +24,8 @@ import java.util.Iterator; ...@@ -24,8 +24,8 @@ import java.util.Iterator;
*/ */
@TargetApi(Build.VERSION_CODES.O) @TargetApi(Build.VERSION_CODES.O)
public class AwAutofillManager { public class AwAutofillManager {
private static final String TAG = "AwAutofillManager"; // Don't change TAG, it is used for runtime log.
private static final boolean DEBUG = false; public static final String TAG = "AwAutofillManager";
/** /**
* The observer of suggestion window. * The observer of suggestion window.
...@@ -56,7 +56,7 @@ public class AwAutofillManager { ...@@ -56,7 +56,7 @@ public class AwAutofillManager {
private ArrayList<WeakReference<InputUIObserver>> mInputUIObservers; private ArrayList<WeakReference<InputUIObserver>> mInputUIObservers;
public AwAutofillManager(Context context) { public AwAutofillManager(Context context) {
if (DEBUG) Log.i(TAG, "constructor"); log("constructor");
mAutofillManager = context.getSystemService(AutofillManager.class); mAutofillManager = context.getSystemService(AutofillManager.class);
mDisabled = mAutofillManager == null || !mAutofillManager.isEnabled(); mDisabled = mAutofillManager == null || !mAutofillManager.isEnabled();
if (mDisabled) return; if (mDisabled) return;
...@@ -67,19 +67,19 @@ public class AwAutofillManager { ...@@ -67,19 +67,19 @@ public class AwAutofillManager {
public void notifyVirtualValueChanged(View parent, int childId, AutofillValue value) { public void notifyVirtualValueChanged(View parent, int childId, AutofillValue value) {
if (mDisabled || checkAndWarnIfDestroyed()) return; if (mDisabled || checkAndWarnIfDestroyed()) return;
if (DEBUG) Log.i(TAG, "notifyVirtualValueChanged"); log("notifyVirtualValueChanged");
mAutofillManager.notifyValueChanged(parent, childId, value); mAutofillManager.notifyValueChanged(parent, childId, value);
} }
public void commit(int submissionSource) { public void commit(int submissionSource) {
if (mDisabled || checkAndWarnIfDestroyed()) return; if (mDisabled || checkAndWarnIfDestroyed()) return;
if (DEBUG) Log.i(TAG, "commit source:" + submissionSource); log("commit source:" + submissionSource);
mAutofillManager.commit(); mAutofillManager.commit();
} }
public void cancel() { public void cancel() {
if (mDisabled || checkAndWarnIfDestroyed()) return; if (mDisabled || checkAndWarnIfDestroyed()) return;
if (DEBUG) Log.i(TAG, "cancel"); log("cancel");
mAutofillManager.cancel(); mAutofillManager.cancel();
} }
...@@ -92,31 +92,31 @@ public class AwAutofillManager { ...@@ -92,31 +92,31 @@ public class AwAutofillManager {
return; return;
} }
if (checkAndWarnIfDestroyed()) return; if (checkAndWarnIfDestroyed()) return;
if (DEBUG) Log.i(TAG, "notifyVirtualViewEntered"); log("notifyVirtualViewEntered");
mAutofillManager.notifyViewEntered(parent, childId, absBounds); mAutofillManager.notifyViewEntered(parent, childId, absBounds);
} }
public void notifyVirtualViewExited(View parent, int childId) { public void notifyVirtualViewExited(View parent, int childId) {
if (mDisabled || checkAndWarnIfDestroyed()) return; if (mDisabled || checkAndWarnIfDestroyed()) return;
if (DEBUG) Log.i(TAG, "notifyVirtualViewExited"); log("notifyVirtualViewExited");
mAutofillManager.notifyViewExited(parent, childId); mAutofillManager.notifyViewExited(parent, childId);
} }
public void requestAutofill(View parent, int virtualId, Rect absBounds) { public void requestAutofill(View parent, int virtualId, Rect absBounds) {
if (mDisabled || checkAndWarnIfDestroyed()) return; if (mDisabled || checkAndWarnIfDestroyed()) return;
if (DEBUG) Log.i(TAG, "requestAutofill"); log("requestAutofill");
mAutofillManager.requestAutofill(parent, virtualId, absBounds); mAutofillManager.requestAutofill(parent, virtualId, absBounds);
} }
public boolean isAutofillInputUIShowing() { public boolean isAutofillInputUIShowing() {
if (mDisabled || checkAndWarnIfDestroyed()) return false; if (mDisabled || checkAndWarnIfDestroyed()) return false;
if (DEBUG) Log.i(TAG, "isAutofillInputUIShowing: " + mIsAutofillInputUIShowing); log("isAutofillInputUIShowing: " + mIsAutofillInputUIShowing);
return mIsAutofillInputUIShowing; return mIsAutofillInputUIShowing;
} }
public void destroy() { public void destroy() {
if (mDisabled || checkAndWarnIfDestroyed()) return; if (mDisabled || checkAndWarnIfDestroyed()) return;
if (DEBUG) Log.i(TAG, "destroy"); log("destroy");
mAutofillManager.unregisterCallback(mMonitor); mAutofillManager.unregisterCallback(mMonitor);
mAutofillManager = null; mAutofillManager = null;
mDestroyed = true; mDestroyed = true;
...@@ -163,4 +163,10 @@ public class AwAutofillManager { ...@@ -163,4 +163,10 @@ public class AwAutofillManager {
observer.onInputUIShown(); observer.onInputUIShown();
} }
} }
public static void log(String log) {
// Use 'setprop log.tag.AwAutofillManager DEBUG' to enable the log at runtime.
// Log.i() instead of Log.d() is used here because log.d() is stripped out in release build.
if (Log.isLoggable(TAG, Log.DEBUG)) Log.i(TAG, log);
}
} }
...@@ -255,6 +255,8 @@ public class AwAutofillProvider extends AutofillProvider { ...@@ -255,6 +255,8 @@ public class AwAutofillProvider extends AutofillProvider {
// return. // return.
if (mRequest == null) return; if (mRequest == null) return;
mRequest.fillViewStructure(structure); mRequest.fillViewStructure(structure);
AwAutofillManager.log(
"onProvideAutoFillVirtualStructure fields:" + structure.getChildCount());
mAutofillUMA.onVirtualStructureProvided(); mAutofillUMA.onVirtualStructureProvided();
} }
...@@ -262,6 +264,7 @@ public class AwAutofillProvider extends AutofillProvider { ...@@ -262,6 +264,7 @@ public class AwAutofillProvider extends AutofillProvider {
public void autofill(final SparseArray<AutofillValue> values) { public void autofill(final SparseArray<AutofillValue> values) {
if (mNativeAutofillProvider != 0 && mRequest != null && mRequest.autofill((values))) { if (mNativeAutofillProvider != 0 && mRequest != null && mRequest.autofill((values))) {
autofill(mNativeAutofillProvider, mRequest.mFormData); autofill(mNativeAutofillProvider, mRequest.mFormData);
AwAutofillManager.log("autofill values:" + values.size());
mAutofillUMA.onAutofill(); mAutofillUMA.onAutofill();
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment