Force hiding fill UI when it's destroyed.

The bug describes a scenaior where drop down UI is not removed even when
tapping on other fields. Forcing hiding dropdown UI fix this issue. For
reason why it would fix it needs more understanding.

Test: atest CtsAutoFillServiceTestCases
Bug: b/290917485

Change-Id: Id4940093aad5dcb290a494245052ba2ce9321aec
This commit is contained in:
Haoran Zhang
2023-07-19 18:48:03 +00:00
parent 338ade29ba
commit e257fbd9f6
5 changed files with 38 additions and 1 deletions

View File

@@ -4213,6 +4213,14 @@ public final class AutofillManager {
}
}
@Override
public void requestHideFillUiWhenDestroyed(int sessionId, AutofillId id) {
final AutofillManager afm = mAfm.get();
if (afm != null) {
afm.post(() -> afm.requestHideFillUi(id, true));
}
}
@Override
public void notifyNoFillUi(int sessionId, AutofillId id, int sessionFinishedState) {
final AutofillManager afm = mAfm.get();

View File

@@ -78,6 +78,11 @@ oneway interface IAutoFillManagerClient {
*/
void requestHideFillUi(int sessionId, in AutofillId id);
/**
* Requests hiding the fill UI when it's destroyed
*/
void requestHideFillUiWhenDestroyed(int sessionId, in AutofillId id);
/**
* Notifies no fill UI will be shown, and also mark the state as finished if necessary (if
* sessionFinishedState != 0).

View File

@@ -2401,6 +2401,21 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
}
}
@Override
public void requestHideFillUiWhenDestroyed(AutofillId id) {
synchronized (mLock) {
// NOTE: We allow this call in a destroyed state as the UI is
// asked to go away after we get destroyed, so let it do that.
try {
mClient.requestHideFillUiWhenDestroyed(this.id, id);
} catch (RemoteException e) {
Slog.e(TAG, "Error requesting to hide fill UI", e);
}
mInlineSessionController.hideInlineSuggestionsUiLocked(id);
}
}
// AutoFillUiCallback
@Override
public void cancelSession() {

View File

@@ -95,6 +95,7 @@ public final class AutoFillUI {
void requestShowFillUi(AutofillId id, int width, int height,
IAutofillWindowPresenter presenter);
void requestHideFillUi(AutofillId id);
void requestHideFillUiWhenDestroyed(AutofillId id);
void startIntentSenderAndFinishSession(IntentSender intentSender);
void startIntentSender(IntentSender intentSender, Intent intent);
void dispatchUnhandledKey(AutofillId id, KeyEvent keyEvent);
@@ -288,6 +289,13 @@ public final class AutoFillUI {
}
}
@Override
public void requestHideFillUiWhenDestroyed() {
if (mCallback != null) {
mCallback.requestHideFillUiWhenDestroyed(focusedId);
}
}
@Override
public void startIntentSender(IntentSender intentSender) {
if (mCallback != null) {

View File

@@ -91,6 +91,7 @@ final class FillUi {
void requestShowFillUi(int width, int height,
IAutofillWindowPresenter windowPresenter);
void requestHideFillUi();
void requestHideFillUiWhenDestroyed();
void startIntentSender(IntentSender intentSender);
void dispatchUnhandledKey(KeyEvent keyEvent);
void cancelSession();
@@ -482,7 +483,7 @@ final class FillUi {
}
mCallback.onDestroy();
if (notifyClient) {
mCallback.requestHideFillUi();
mCallback.requestHideFillUiWhenDestroyed();
}
mDestroyed = true;
}