Merge "Destroy Save UI when it's hidden without a pending restoration." into oc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
415c7aadd0
@@ -624,7 +624,7 @@ final class AutofillManagerServiceImpl {
|
|||||||
|
|
||||||
void destroySessionsLocked() {
|
void destroySessionsLocked() {
|
||||||
if (mSessions.size() == 0) {
|
if (mSessions.size() == 0) {
|
||||||
mUi.destroyAll(AutofillManager.NO_SESSION, null, null);
|
mUi.destroyAll(null, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (mSessions.size() > 0) {
|
while (mSessions.size() > 0) {
|
||||||
|
|||||||
@@ -969,9 +969,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
if (sDebug) Slog.d(TAG, "Good news, everyone! All checks passed, show save UI!");
|
if (sDebug) Slog.d(TAG, "Good news, everyone! All checks passed, show save UI!");
|
||||||
mService.setSaveShown(id);
|
mService.setSaveShown(id);
|
||||||
final IAutoFillManagerClient client = getClient();
|
final IAutoFillManagerClient client = getClient();
|
||||||
mPendingSaveUi = new PendingUi(mActivityToken);
|
mPendingSaveUi = new PendingUi(mActivityToken, id, client);
|
||||||
getUiForShowing().showSaveUi(mService.getServiceLabel(), saveInfo,
|
getUiForShowing().showSaveUi(mService.getServiceLabel(), saveInfo,
|
||||||
valueFinder, mPackageName, this, mPendingSaveUi, id, client);
|
valueFinder, mPackageName, this, mPendingSaveUi);
|
||||||
if (client != null) {
|
if (client != null) {
|
||||||
try {
|
try {
|
||||||
client.setSaveUiState(id, true);
|
client.setSaveUiState(id, true);
|
||||||
@@ -1715,7 +1715,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
if (mDestroyed) {
|
if (mDestroyed) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
mUi.destroyAll(id, getClient(), this);
|
mUi.destroyAll(mPendingSaveUi, this);
|
||||||
mUi.clearCallback(this);
|
mUi.clearCallback(this);
|
||||||
mDestroyed = true;
|
mDestroyed = true;
|
||||||
mMetricsLogger.action(MetricsEvent.AUTOFILL_SESSION_FINISHED, mPackageName);
|
mMetricsLogger.action(MetricsEvent.AUTOFILL_SESSION_FINISHED, mPackageName);
|
||||||
@@ -1731,7 +1731,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
|
|
||||||
mPendingSaveUi = null;
|
mPendingSaveUi = null;
|
||||||
removeSelfLocked();
|
removeSelfLocked();
|
||||||
mUi.destroyAll(id, getClient(), this);
|
mUi.destroyAll(mPendingSaveUi, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import android.text.TextUtils;
|
|||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.view.autofill.AutofillId;
|
import android.view.autofill.AutofillId;
|
||||||
import android.view.autofill.AutofillManager;
|
import android.view.autofill.AutofillManager;
|
||||||
import android.view.autofill.IAutoFillManagerClient;
|
|
||||||
import android.view.autofill.IAutofillWindowPresenter;
|
import android.view.autofill.IAutofillWindowPresenter;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@@ -247,8 +246,7 @@ public final class AutoFillUI {
|
|||||||
*/
|
*/
|
||||||
public void showSaveUi(@NonNull CharSequence providerLabel, @NonNull SaveInfo info,
|
public void showSaveUi(@NonNull CharSequence providerLabel, @NonNull SaveInfo info,
|
||||||
@NonNull ValueFinder valueFinder, @NonNull String packageName,
|
@NonNull ValueFinder valueFinder, @NonNull String packageName,
|
||||||
@NonNull AutoFillUiCallback callback, @NonNull PendingUi pendingUi,
|
@NonNull AutoFillUiCallback callback, @NonNull PendingUi pendingSaveUi) {
|
||||||
int sessionId, @Nullable IAutoFillManagerClient client) {
|
|
||||||
if (sVerbose) Slog.v(TAG, "showSaveUi() for " + packageName + ": " + info);
|
if (sVerbose) Slog.v(TAG, "showSaveUi() for " + packageName + ": " + info);
|
||||||
int numIds = 0;
|
int numIds = 0;
|
||||||
numIds += info.getRequiredIds() == null ? 0 : info.getRequiredIds().length;
|
numIds += info.getRequiredIds() == null ? 0 : info.getRequiredIds().length;
|
||||||
@@ -263,8 +261,8 @@ public final class AutoFillUI {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
hideAllUiThread(callback);
|
hideAllUiThread(callback);
|
||||||
mSaveUi = new SaveUi(mContext, pendingUi, providerLabel, info, valueFinder,
|
mSaveUi = new SaveUi(mContext, pendingSaveUi, providerLabel, info, valueFinder,
|
||||||
mOverlayControl, client, new SaveUi.OnSaveListener() {
|
mOverlayControl, new SaveUi.OnSaveListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSave() {
|
public void onSave() {
|
||||||
log.setType(MetricsProto.MetricsEvent.TYPE_ACTION);
|
log.setType(MetricsProto.MetricsEvent.TYPE_ACTION);
|
||||||
@@ -272,7 +270,7 @@ public final class AutoFillUI {
|
|||||||
if (mCallback != null) {
|
if (mCallback != null) {
|
||||||
mCallback.save();
|
mCallback.save();
|
||||||
}
|
}
|
||||||
destroySaveUiUiThread(sessionId, client);
|
destroySaveUiUiThread(pendingSaveUi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -290,7 +288,7 @@ public final class AutoFillUI {
|
|||||||
if (mCallback != null) {
|
if (mCallback != null) {
|
||||||
mCallback.cancelSave();
|
mCallback.cancelSave();
|
||||||
}
|
}
|
||||||
destroySaveUiUiThread(sessionId, client);
|
destroySaveUiUiThread(pendingSaveUi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -331,9 +329,9 @@ public final class AutoFillUI {
|
|||||||
/**
|
/**
|
||||||
* Destroy all UI affordances.
|
* Destroy all UI affordances.
|
||||||
*/
|
*/
|
||||||
public void destroyAll(int sessionId, @Nullable IAutoFillManagerClient client,
|
public void destroyAll(@Nullable PendingUi pendingSaveUi,
|
||||||
@Nullable AutoFillUiCallback callback) {
|
@Nullable AutoFillUiCallback callback) {
|
||||||
mHandler.post(() -> destroyAllUiThread(sessionId, client, callback));
|
mHandler.post(() -> destroyAllUiThread(pendingSaveUi, callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dump(PrintWriter pw) {
|
public void dump(PrintWriter pw) {
|
||||||
@@ -363,18 +361,20 @@ public final class AutoFillUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@android.annotation.UiThread
|
@android.annotation.UiThread
|
||||||
private void hideSaveUiUiThread(@Nullable AutoFillUiCallback callback) {
|
@Nullable
|
||||||
|
private PendingUi hideSaveUiUiThread(@Nullable AutoFillUiCallback callback) {
|
||||||
if (sVerbose) {
|
if (sVerbose) {
|
||||||
Slog.v(TAG, "hideSaveUiUiThread(): mSaveUi=" + mSaveUi + ", callback=" + callback
|
Slog.v(TAG, "hideSaveUiUiThread(): mSaveUi=" + mSaveUi + ", callback=" + callback
|
||||||
+ ", mCallback=" + mCallback);
|
+ ", mCallback=" + mCallback);
|
||||||
}
|
}
|
||||||
if (mSaveUi != null && (callback == null || callback == mCallback)) {
|
if (mSaveUi != null && (callback == null || callback == mCallback)) {
|
||||||
mSaveUi.hide();
|
return mSaveUi.hide();
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@android.annotation.UiThread
|
@android.annotation.UiThread
|
||||||
private void destroySaveUiUiThread(int sessionId, @Nullable IAutoFillManagerClient client) {
|
private void destroySaveUiUiThread(@Nullable PendingUi pendingSaveUi) {
|
||||||
if (mSaveUi == null) {
|
if (mSaveUi == null) {
|
||||||
// Calling destroySaveUiUiThread() twice is normal - it usually happens when the
|
// Calling destroySaveUiUiThread() twice is normal - it usually happens when the
|
||||||
// first call is made after the SaveUI is hidden and the second when the session is
|
// first call is made after the SaveUI is hidden and the second when the session is
|
||||||
@@ -383,13 +383,13 @@ public final class AutoFillUI {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sDebug) Slog.d(TAG, "destroySaveUiUiThread(): id=" + sessionId);
|
if (sDebug) Slog.d(TAG, "destroySaveUiUiThread(): " + pendingSaveUi);
|
||||||
mSaveUi.destroy();
|
mSaveUi.destroy();
|
||||||
mSaveUi = null;
|
mSaveUi = null;
|
||||||
if (client != null) {
|
if (pendingSaveUi != null) {
|
||||||
try {
|
try {
|
||||||
if (sDebug) Slog.d(TAG, "destroySaveUiUiThread(): notifying client");
|
if (sDebug) Slog.d(TAG, "destroySaveUiUiThread(): notifying client");
|
||||||
client.setSaveUiState(sessionId, false);
|
pendingSaveUi.client.setSaveUiState(pendingSaveUi.id, false);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.e(TAG, "Error notifying client to set save UI state to hidden: " + e);
|
Slog.e(TAG, "Error notifying client to set save UI state to hidden: " + e);
|
||||||
}
|
}
|
||||||
@@ -397,15 +397,22 @@ public final class AutoFillUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@android.annotation.UiThread
|
@android.annotation.UiThread
|
||||||
private void destroyAllUiThread(int sessionId, @Nullable IAutoFillManagerClient client,
|
private void destroyAllUiThread(@Nullable PendingUi pendingSaveUi,
|
||||||
@Nullable AutoFillUiCallback callback) {
|
@Nullable AutoFillUiCallback callback) {
|
||||||
hideFillUiUiThread(callback);
|
hideFillUiUiThread(callback);
|
||||||
destroySaveUiUiThread(sessionId, client);
|
destroySaveUiUiThread(pendingSaveUi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@android.annotation.UiThread
|
@android.annotation.UiThread
|
||||||
private void hideAllUiThread(@Nullable AutoFillUiCallback callback) {
|
private void hideAllUiThread(@Nullable AutoFillUiCallback callback) {
|
||||||
hideFillUiUiThread(callback);
|
hideFillUiUiThread(callback);
|
||||||
hideSaveUiUiThread(callback);
|
final PendingUi pendingSaveUi = hideSaveUiUiThread(callback);
|
||||||
|
if (pendingSaveUi != null && pendingSaveUi.getState() == PendingUi.STATE_FINISHED) {
|
||||||
|
if (sDebug) {
|
||||||
|
Slog.d(TAG, "hideAllUiThread(): "
|
||||||
|
+ "destroying Save UI because pending restoration is finished");
|
||||||
|
}
|
||||||
|
destroySaveUiUiThread(pendingSaveUi);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.android.server.autofill.ui;
|
|||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.util.DebugUtils;
|
import android.util.DebugUtils;
|
||||||
|
import android.view.autofill.IAutoFillManagerClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class used to handle a pending Autofill affordance such as the Save UI.
|
* Helper class used to handle a pending Autofill affordance such as the Save UI.
|
||||||
@@ -34,15 +35,19 @@ public final class PendingUi {
|
|||||||
|
|
||||||
private final IBinder mToken;
|
private final IBinder mToken;
|
||||||
private int mState;
|
private int mState;
|
||||||
|
public final int id;
|
||||||
|
public final IAutoFillManagerClient client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
*
|
*
|
||||||
* @param token token used to identify this pending UI.
|
* @param token token used to identify this pending UI.
|
||||||
*/
|
*/
|
||||||
public PendingUi(@NonNull IBinder token) {
|
public PendingUi(@NonNull IBinder token, int id, @NonNull IAutoFillManagerClient client) {
|
||||||
mToken = token;
|
mToken = token;
|
||||||
mState = STATE_CREATED;
|
mState = STATE_CREATED;
|
||||||
|
this.id = id;
|
||||||
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,7 +81,7 @@ public final class PendingUi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PendingUi: [token=" + mToken + ", state="
|
return "PendingUi: [token=" + mToken + ", id=" + id + ", state="
|
||||||
+ DebugUtils.flagsToString(PendingUi.class, "STATE_", mState) + "]";
|
+ DebugUtils.flagsToString(PendingUi.class, "STATE_", mState) + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ final class SaveUi {
|
|||||||
SaveUi(@NonNull Context context, @NonNull PendingUi pendingUi,
|
SaveUi(@NonNull Context context, @NonNull PendingUi pendingUi,
|
||||||
@NonNull CharSequence providerLabel, @NonNull SaveInfo info,
|
@NonNull CharSequence providerLabel, @NonNull SaveInfo info,
|
||||||
@NonNull ValueFinder valueFinder, @NonNull OverlayControl overlayControl,
|
@NonNull ValueFinder valueFinder, @NonNull OverlayControl overlayControl,
|
||||||
@NonNull IAutoFillManagerClient client, @NonNull OnSaveListener listener) {
|
@NonNull OnSaveListener listener) {
|
||||||
mPendingUi= pendingUi;
|
mPendingUi= pendingUi;
|
||||||
mListener = new OneTimeListener(listener);
|
mListener = new OneTimeListener(listener);
|
||||||
mOverlayControl = overlayControl;
|
mOverlayControl = overlayControl;
|
||||||
@@ -206,7 +206,7 @@ final class SaveUi {
|
|||||||
final IBinder token = mPendingUi.getToken();
|
final IBinder token = mPendingUi.getToken();
|
||||||
intent.putExtra(AutofillManager.EXTRA_RESTORE_SESSION_TOKEN, token);
|
intent.putExtra(AutofillManager.EXTRA_RESTORE_SESSION_TOKEN, token);
|
||||||
try {
|
try {
|
||||||
client.startIntentSender(pendingIntent.getIntentSender(),
|
pendingUi.client.startIntentSender(pendingIntent.getIntentSender(),
|
||||||
intent);
|
intent);
|
||||||
mPendingUi.setState(PendingUi.STATE_PENDING);
|
mPendingUi.setState(PendingUi.STATE_PENDING);
|
||||||
if (sDebug) {
|
if (sDebug) {
|
||||||
@@ -318,13 +318,14 @@ final class SaveUi {
|
|||||||
mOverlayControl.hideOverlays();
|
mOverlayControl.hideOverlays();
|
||||||
}
|
}
|
||||||
|
|
||||||
void hide() {
|
PendingUi hide() {
|
||||||
if (sVerbose) Slog.v(TAG, "Hiding save dialog.");
|
if (sVerbose) Slog.v(TAG, "Hiding save dialog.");
|
||||||
try {
|
try {
|
||||||
mDialog.hide();
|
mDialog.hide();
|
||||||
} finally {
|
} finally {
|
||||||
mOverlayControl.showOverlays();
|
mOverlayControl.showOverlays();
|
||||||
}
|
}
|
||||||
|
return mPendingUi;
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroy() {
|
void destroy() {
|
||||||
|
|||||||
Reference in New Issue
Block a user