Merge "Unhardcoded Augmented Autofill debug constants." into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
211ddf7040
@@ -27,6 +27,7 @@ import android.app.Service;
|
|||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.CancellationSignal;
|
import android.os.CancellationSignal;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
@@ -67,9 +68,8 @@ public abstract class AugmentedAutofillService extends Service {
|
|||||||
|
|
||||||
private static final String TAG = AugmentedAutofillService.class.getSimpleName();
|
private static final String TAG = AugmentedAutofillService.class.getSimpleName();
|
||||||
|
|
||||||
// TODO(b/123100811): STOPSHIP use dynamic value, or change to false
|
static boolean sDebug = Build.IS_USER ? false : true;
|
||||||
static final boolean DEBUG = true;
|
static boolean sVerbose = false;
|
||||||
static final boolean VERBOSE = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link Intent} that must be declared as handled by the service.
|
* The {@link Intent} that must be declared as handled by the service.
|
||||||
@@ -87,9 +87,9 @@ public abstract class AugmentedAutofillService extends Service {
|
|||||||
private final IAugmentedAutofillService mInterface = new IAugmentedAutofillService.Stub() {
|
private final IAugmentedAutofillService mInterface = new IAugmentedAutofillService.Stub() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnected() {
|
public void onConnected(boolean debug, boolean verbose) {
|
||||||
mHandler.sendMessage(obtainMessage(AugmentedAutofillService::handleOnConnected,
|
mHandler.sendMessage(obtainMessage(AugmentedAutofillService::handleOnConnected,
|
||||||
AugmentedAutofillService.this));
|
AugmentedAutofillService.this, debug, verbose));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -190,7 +190,12 @@ public abstract class AugmentedAutofillService extends Service {
|
|||||||
public void onDisconnected() {
|
public void onDisconnected() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleOnConnected() {
|
private void handleOnConnected(boolean debug, boolean verbose) {
|
||||||
|
if (sDebug || debug) {
|
||||||
|
Log.d(TAG, "handleOnConnected(): debug=" + debug + ", verbose=" + verbose);
|
||||||
|
}
|
||||||
|
sDebug = debug;
|
||||||
|
sVerbose = verbose;
|
||||||
onConnected();
|
onConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +220,7 @@ public abstract class AugmentedAutofillService extends Service {
|
|||||||
mAutofillProxies.put(sessionId, proxy);
|
mAutofillProxies.put(sessionId, proxy);
|
||||||
} else {
|
} else {
|
||||||
// TODO(b/123099468): figure out if it's ok to reuse the proxy; add logging
|
// TODO(b/123099468): figure out if it's ok to reuse the proxy; add logging
|
||||||
if (DEBUG) Log.d(TAG, "Reusing proxy for session " + sessionId);
|
if (sDebug) Log.d(TAG, "Reusing proxy for session " + sessionId);
|
||||||
proxy.update(focusedId, focusedValue, callback);
|
proxy.update(focusedId, focusedValue, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,11 +253,11 @@ public abstract class AugmentedAutofillService extends Service {
|
|||||||
|
|
||||||
private void handleOnUnbind() {
|
private void handleOnUnbind() {
|
||||||
if (mAutofillProxies == null) {
|
if (mAutofillProxies == null) {
|
||||||
if (DEBUG) Log.d(TAG, "onUnbind(): no proxy to destroy");
|
if (sDebug) Log.d(TAG, "onUnbind(): no proxy to destroy");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final int size = mAutofillProxies.size();
|
final int size = mAutofillProxies.size();
|
||||||
if (DEBUG) Log.d(TAG, "onUnbind(): destroying " + size + " proxies");
|
if (sDebug) Log.d(TAG, "onUnbind(): destroying " + size + " proxies");
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
final AutofillProxy proxy = mAutofillProxies.valueAt(i);
|
final AutofillProxy proxy = mAutofillProxies.valueAt(i);
|
||||||
try {
|
try {
|
||||||
@@ -373,7 +378,7 @@ public abstract class AugmentedAutofillService extends Service {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (rect == null) {
|
if (rect == null) {
|
||||||
if (DEBUG) Log.d(TAG, "getViewCoordinates(" + mFocusedId + ") returned null");
|
if (sDebug) Log.d(TAG, "getViewCoordinates(" + mFocusedId + ") returned null");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
mSmartSuggestion = new SystemPopupPresentationParams(this, rect);
|
mSmartSuggestion = new SystemPopupPresentationParams(this, rect);
|
||||||
@@ -410,7 +415,7 @@ public abstract class AugmentedAutofillService extends Service {
|
|||||||
public void requestShowFillUi(int width, int height, Rect anchorBounds,
|
public void requestShowFillUi(int width, int height, Rect anchorBounds,
|
||||||
IAutofillWindowPresenter presenter) throws RemoteException {
|
IAutofillWindowPresenter presenter) throws RemoteException {
|
||||||
if (mCancellationSignal.isCanceled()) {
|
if (mCancellationSignal.isCanceled()) {
|
||||||
if (VERBOSE) {
|
if (sVerbose) {
|
||||||
Log.v(TAG, "requestShowFillUi() not showing because request is cancelled");
|
Log.v(TAG, "requestShowFillUi() not showing because request is cancelled");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -462,7 +467,7 @@ public abstract class AugmentedAutofillService extends Service {
|
|||||||
case REPORT_EVENT_ON_SUCCESS:
|
case REPORT_EVENT_ON_SUCCESS:
|
||||||
if (mFirstOnSuccessTime == 0) {
|
if (mFirstOnSuccessTime == 0) {
|
||||||
mFirstOnSuccessTime = SystemClock.elapsedRealtime();
|
mFirstOnSuccessTime = SystemClock.elapsedRealtime();
|
||||||
if (DEBUG) {
|
if (sDebug) {
|
||||||
Slog.d(TAG, "Service responded in " + TimeUtils.formatDuration(
|
Slog.d(TAG, "Service responded in " + TimeUtils.formatDuration(
|
||||||
mFirstOnSuccessTime - mFirstRequestTime));
|
mFirstOnSuccessTime - mFirstRequestTime));
|
||||||
}
|
}
|
||||||
@@ -476,7 +481,7 @@ public abstract class AugmentedAutofillService extends Service {
|
|||||||
case REPORT_EVENT_UI_SHOWN:
|
case REPORT_EVENT_UI_SHOWN:
|
||||||
if (mUiFirstShownTime == 0) {
|
if (mUiFirstShownTime == 0) {
|
||||||
mUiFirstShownTime = SystemClock.elapsedRealtime();
|
mUiFirstShownTime = SystemClock.elapsedRealtime();
|
||||||
if (DEBUG) {
|
if (sDebug) {
|
||||||
Slog.d(TAG, "UI shown in " + TimeUtils.formatDuration(
|
Slog.d(TAG, "UI shown in " + TimeUtils.formatDuration(
|
||||||
mUiFirstShownTime - mFirstRequestTime));
|
mUiFirstShownTime - mFirstRequestTime));
|
||||||
}
|
}
|
||||||
@@ -485,7 +490,7 @@ public abstract class AugmentedAutofillService extends Service {
|
|||||||
case REPORT_EVENT_UI_DESTROYED:
|
case REPORT_EVENT_UI_DESTROYED:
|
||||||
if (mUiFirstDestroyedTime == 0) {
|
if (mUiFirstDestroyedTime == 0) {
|
||||||
mUiFirstDestroyedTime = SystemClock.elapsedRealtime();
|
mUiFirstDestroyedTime = SystemClock.elapsedRealtime();
|
||||||
if (DEBUG) {
|
if (sDebug) {
|
||||||
Slog.d(TAG, "UI destroyed in " + TimeUtils.formatDuration(
|
Slog.d(TAG, "UI destroyed in " + TimeUtils.formatDuration(
|
||||||
mUiFirstDestroyedTime - mFirstRequestTime));
|
mUiFirstDestroyedTime - mFirstRequestTime));
|
||||||
}
|
}
|
||||||
@@ -541,7 +546,7 @@ public abstract class AugmentedAutofillService extends Service {
|
|||||||
private void destroy() {
|
private void destroy() {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mFillWindow != null) {
|
if (mFillWindow != null) {
|
||||||
if (DEBUG) Log.d(TAG, "destroying window");
|
if (sDebug) Log.d(TAG, "destroying window");
|
||||||
mFillWindow.destroy();
|
mFillWindow.destroy();
|
||||||
mFillWindow = null;
|
mFillWindow = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package android.service.autofill.augmented;
|
package android.service.autofill.augmented;
|
||||||
|
|
||||||
import static android.service.autofill.augmented.AugmentedAutofillService.DEBUG;
|
import static android.service.autofill.augmented.AugmentedAutofillService.sDebug;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
@@ -48,7 +48,7 @@ public final class FillCallback {
|
|||||||
* could not provide autofill for the request.
|
* could not provide autofill for the request.
|
||||||
*/
|
*/
|
||||||
public void onSuccess(@Nullable FillResponse response) {
|
public void onSuccess(@Nullable FillResponse response) {
|
||||||
if (DEBUG) Log.d(TAG, "onSuccess(): " + response);
|
if (sDebug) Log.d(TAG, "onSuccess(): " + response);
|
||||||
|
|
||||||
mProxy.report(AutofillProxy.REPORT_EVENT_ON_SUCCESS);
|
mProxy.report(AutofillProxy.REPORT_EVENT_ON_SUCCESS);
|
||||||
if (response == null) return;
|
if (response == null) return;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package android.service.autofill.augmented;
|
package android.service.autofill.augmented;
|
||||||
|
|
||||||
import static android.service.autofill.augmented.AugmentedAutofillService.DEBUG;
|
import static android.service.autofill.augmented.AugmentedAutofillService.sDebug;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
@@ -56,7 +56,7 @@ public final class FillController {
|
|||||||
public void autofill(@NonNull List<Pair<AutofillId, AutofillValue>> values) {
|
public void autofill(@NonNull List<Pair<AutofillId, AutofillValue>> values) {
|
||||||
Preconditions.checkNotNull(values);
|
Preconditions.checkNotNull(values);
|
||||||
|
|
||||||
if (DEBUG) {
|
if (sDebug) {
|
||||||
Log.d(TAG, "autofill() with " + values.size() + " values");
|
Log.d(TAG, "autofill() with " + values.size() + " values");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package android.service.autofill.augmented;
|
package android.service.autofill.augmented;
|
||||||
|
|
||||||
import static android.service.autofill.augmented.AugmentedAutofillService.DEBUG;
|
import static android.service.autofill.augmented.AugmentedAutofillService.sDebug;
|
||||||
import static android.service.autofill.augmented.AugmentedAutofillService.VERBOSE;
|
import static android.service.autofill.augmented.AugmentedAutofillService.sVerbose;
|
||||||
|
|
||||||
import static com.android.internal.util.function.pooled.PooledLambda.obtainMessage;
|
import static com.android.internal.util.function.pooled.PooledLambda.obtainMessage;
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ public final class FillWindow implements AutoCloseable {
|
|||||||
* @throws IllegalArgumentException if the area is not compatible with this window
|
* @throws IllegalArgumentException if the area is not compatible with this window
|
||||||
*/
|
*/
|
||||||
public boolean update(@NonNull Area area, @NonNull View rootView, long flags) {
|
public boolean update(@NonNull Area area, @NonNull View rootView, long flags) {
|
||||||
if (DEBUG) {
|
if (sDebug) {
|
||||||
Log.d(TAG, "Updating " + area + " + with " + rootView);
|
Log.d(TAG, "Updating " + area + " + with " + rootView);
|
||||||
}
|
}
|
||||||
// TODO(b/123100712): add test case for null
|
// TODO(b/123100712): add test case for null
|
||||||
@@ -141,7 +141,7 @@ public final class FillWindow implements AutoCloseable {
|
|||||||
mFillView.setOnTouchListener(
|
mFillView.setOnTouchListener(
|
||||||
(view, motionEvent) -> {
|
(view, motionEvent) -> {
|
||||||
if (motionEvent.getAction() == MotionEvent.ACTION_OUTSIDE) {
|
if (motionEvent.getAction() == MotionEvent.ACTION_OUTSIDE) {
|
||||||
if (VERBOSE) Log.v(TAG, "Outside touch detected, hiding the window");
|
if (sVerbose) Log.v(TAG, "Outside touch detected, hiding the window");
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -149,7 +149,7 @@ public final class FillWindow implements AutoCloseable {
|
|||||||
);
|
);
|
||||||
mShowing = false;
|
mShowing = false;
|
||||||
mBounds = new Rect(area.getBounds());
|
mBounds = new Rect(area.getBounds());
|
||||||
if (DEBUG) {
|
if (sDebug) {
|
||||||
Log.d(TAG, "Created FillWindow: params= " + smartSuggestion + " view=" + rootView);
|
Log.d(TAG, "Created FillWindow: params= " + smartSuggestion + " view=" + rootView);
|
||||||
}
|
}
|
||||||
mUpdateCalled = true;
|
mUpdateCalled = true;
|
||||||
@@ -162,7 +162,7 @@ public final class FillWindow implements AutoCloseable {
|
|||||||
/** @hide */
|
/** @hide */
|
||||||
void show() {
|
void show() {
|
||||||
// TODO(b/123100712): check if updated first / throw exception
|
// TODO(b/123100712): check if updated first / throw exception
|
||||||
if (DEBUG) Log.d(TAG, "show()");
|
if (sDebug) Log.d(TAG, "show()");
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
checkNotDestroyedLocked();
|
checkNotDestroyedLocked();
|
||||||
if (mWm == null || mFillView == null) {
|
if (mWm == null || mFillView == null) {
|
||||||
@@ -187,7 +187,7 @@ public final class FillWindow implements AutoCloseable {
|
|||||||
* <p>The window is not destroyed and can be shown again
|
* <p>The window is not destroyed and can be shown again
|
||||||
*/
|
*/
|
||||||
private void hide() {
|
private void hide() {
|
||||||
if (DEBUG) Log.d(TAG, "hide()");
|
if (sDebug) Log.d(TAG, "hide()");
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
checkNotDestroyedLocked();
|
checkNotDestroyedLocked();
|
||||||
if (mWm == null || mFillView == null) {
|
if (mWm == null || mFillView == null) {
|
||||||
@@ -204,7 +204,7 @@ public final class FillWindow implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleShow(WindowManager.LayoutParams p) {
|
private void handleShow(WindowManager.LayoutParams p) {
|
||||||
if (DEBUG) Log.d(TAG, "handleShow()");
|
if (sDebug) Log.d(TAG, "handleShow()");
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mWm != null && mFillView != null) {
|
if (mWm != null && mFillView != null) {
|
||||||
p.flags |= WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
|
p.flags |= WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
|
||||||
@@ -219,7 +219,7 @@ public final class FillWindow implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleHide() {
|
private void handleHide() {
|
||||||
if (DEBUG) Log.d(TAG, "handleHide()");
|
if (sDebug) Log.d(TAG, "handleHide()");
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mWm != null && mFillView != null && mShowing) {
|
if (mWm != null && mFillView != null && mShowing) {
|
||||||
mWm.removeView(mFillView);
|
mWm.removeView(mFillView);
|
||||||
@@ -234,7 +234,7 @@ public final class FillWindow implements AutoCloseable {
|
|||||||
* <p>Once destroyed, this window cannot be used anymore
|
* <p>Once destroyed, this window cannot be used anymore
|
||||||
*/
|
*/
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
if (DEBUG) {
|
if (sDebug) {
|
||||||
Log.d(TAG,
|
Log.d(TAG,
|
||||||
"destroy(): mDestroyed=" + mDestroyed + " mShowing=" + mShowing + " mFillView="
|
"destroy(): mDestroyed=" + mDestroyed + " mShowing=" + mShowing + " mFillView="
|
||||||
+ mFillView);
|
+ mFillView);
|
||||||
@@ -296,13 +296,13 @@ public final class FillWindow implements AutoCloseable {
|
|||||||
@Override
|
@Override
|
||||||
public void show(WindowManager.LayoutParams p, Rect transitionEpicenter,
|
public void show(WindowManager.LayoutParams p, Rect transitionEpicenter,
|
||||||
boolean fitsSystemWindows, int layoutDirection) {
|
boolean fitsSystemWindows, int layoutDirection) {
|
||||||
if (DEBUG) Log.d(TAG, "FillWindowPresenter.show()");
|
if (sDebug) Log.d(TAG, "FillWindowPresenter.show()");
|
||||||
mUiThreadHandler.sendMessage(obtainMessage(FillWindow::handleShow, FillWindow.this, p));
|
mUiThreadHandler.sendMessage(obtainMessage(FillWindow::handleShow, FillWindow.this, p));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hide(Rect transitionEpicenter) {
|
public void hide(Rect transitionEpicenter) {
|
||||||
if (DEBUG) Log.d(TAG, "FillWindowPresenter.hide()");
|
if (sDebug) Log.d(TAG, "FillWindowPresenter.hide()");
|
||||||
mUiThreadHandler.sendMessage(obtainMessage(FillWindow::handleHide, FillWindow.this));
|
mUiThreadHandler.sendMessage(obtainMessage(FillWindow::handleHide, FillWindow.this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import java.util.List;
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
oneway interface IAugmentedAutofillService {
|
oneway interface IAugmentedAutofillService {
|
||||||
void onConnected();
|
void onConnected(boolean debug, boolean verbose);
|
||||||
void onDisconnected();
|
void onDisconnected();
|
||||||
void onFillRequest(int sessionId, in IBinder autofillManagerClient, int taskId,
|
void onFillRequest(int sessionId, in IBinder autofillManagerClient, int taskId,
|
||||||
in ComponentName activityComponent, in AutofillId focusedId,
|
in ComponentName activityComponent, in AutofillId focusedId,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.android.server.autofill;
|
package com.android.server.autofill;
|
||||||
|
|
||||||
import static com.android.server.autofill.Helper.sDebug;
|
import static com.android.server.autofill.Helper.sDebug;
|
||||||
|
import static com.android.server.autofill.Helper.sVerbose;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
@@ -99,7 +100,7 @@ final class RemoteAugmentedAutofillService
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (state) {
|
if (state) {
|
||||||
mService.onConnected();
|
mService.onConnected(sDebug, sVerbose);
|
||||||
} else {
|
} else {
|
||||||
mService.onDisconnected();
|
mService.onDisconnected();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
// main reason being the cases where user tap HOME.
|
// main reason being the cases where user tap HOME.
|
||||||
// Right now it's completely destroying the UI, but we need to decide whether / how to
|
// Right now it's completely destroying the UI, but we need to decide whether / how to
|
||||||
// properly recover it later (for example, if the user switches back to the activity,
|
// properly recover it later (for example, if the user switches back to the activity,
|
||||||
// should it be restored? Right not it kind of is, because Autofill's Session trigger a
|
// should it be restored? Right now it kind of is, because Autofill's Session trigger a
|
||||||
// new FillRequest, which in turn triggers the Augmented Autofill request again)
|
// new FillRequest, which in turn triggers the Augmented Autofill request again)
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -2755,9 +2755,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
viewState.setState(ViewState.STATE_TRIGGERED_AUGMENTED_AUTOFILL);
|
viewState.setState(ViewState.STATE_TRIGGERED_AUGMENTED_AUTOFILL);
|
||||||
final AutofillValue currentValue = viewState.getCurrentValue();
|
final AutofillValue currentValue = viewState.getCurrentValue();
|
||||||
|
|
||||||
// TODO(b/111330312): we might need to add a new state in the AutofillManager to optimize
|
|
||||||
// further AFM -> AFMS calls.
|
|
||||||
|
|
||||||
if (mAugmentedRequestsLogs == null) {
|
if (mAugmentedRequestsLogs == null) {
|
||||||
mAugmentedRequestsLogs = new ArrayList<>();
|
mAugmentedRequestsLogs = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user