Merge "Handle input method switch properly for inline suggestions" into rvc-dev am: 43c04e1457
Change-Id: I21548467191ffa806084840eb609dc6d6a8db20c
This commit is contained in:
@@ -249,6 +249,9 @@ public final class AutofillManagerService
|
|||||||
resolver.registerContentObserver(Settings.Global.getUriFor(
|
resolver.registerContentObserver(Settings.Global.getUriFor(
|
||||||
Settings.Global.AUTOFILL_MAX_VISIBLE_DATASETS), false, observer,
|
Settings.Global.AUTOFILL_MAX_VISIBLE_DATASETS), false, observer,
|
||||||
UserHandle.USER_ALL);
|
UserHandle.USER_ALL);
|
||||||
|
resolver.registerContentObserver(Settings.Secure.getUriFor(
|
||||||
|
Settings.Secure.SELECTED_INPUT_METHOD_SUBTYPE), false, observer,
|
||||||
|
UserHandle.USER_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from AbstractMasterSystemService
|
@Override // from AbstractMasterSystemService
|
||||||
@@ -263,6 +266,9 @@ public final class AutofillManagerService
|
|||||||
case Settings.Global.AUTOFILL_MAX_VISIBLE_DATASETS:
|
case Settings.Global.AUTOFILL_MAX_VISIBLE_DATASETS:
|
||||||
setMaxVisibleDatasetsFromSettings();
|
setMaxVisibleDatasetsFromSettings();
|
||||||
break;
|
break;
|
||||||
|
case Settings.Secure.SELECTED_INPUT_METHOD_SUBTYPE:
|
||||||
|
handleInputMethodSwitch(userId);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Slog.w(TAG, "Unexpected property (" + property + "); updating cache instead");
|
Slog.w(TAG, "Unexpected property (" + property + "); updating cache instead");
|
||||||
// fall through
|
// fall through
|
||||||
@@ -273,6 +279,23 @@ public final class AutofillManagerService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleInputMethodSwitch(@UserIdInt int userId) {
|
||||||
|
// TODO(b/156903336): Used the SettingsObserver with a background thread maybe slow to
|
||||||
|
// respond to the IME switch in certain situations.
|
||||||
|
// See: services/core/java/com/android/server/FgThread.java
|
||||||
|
// In particular, the shared background thread could be doing relatively long-running
|
||||||
|
// operations like saving state to disk (in addition to simply being a background priority),
|
||||||
|
// which can cause operations scheduled on it to be delayed for a user-noticeable amount
|
||||||
|
// of time.
|
||||||
|
|
||||||
|
synchronized (mLock) {
|
||||||
|
final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
|
||||||
|
if (service != null) {
|
||||||
|
service.onSwitchInputMethod();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void onDeviceConfigChange(@NonNull Set<String> keys) {
|
private void onDeviceConfigChange(@NonNull Set<String> keys) {
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
|||||||
@@ -1564,6 +1564,16 @@ final class AutofillManagerServiceImpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onSwitchInputMethod() {
|
||||||
|
synchronized (mLock) {
|
||||||
|
final int sessionCount = mSessions.size();
|
||||||
|
for (int i = 0; i < sessionCount; i++) {
|
||||||
|
final Session session = mSessions.valueAt(i);
|
||||||
|
session.onSwitchInputMethodLocked();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "AutofillManagerServiceImpl: [userId=" + mUserId
|
return "AutofillManagerServiceImpl: [userId=" + mUserId
|
||||||
|
|||||||
@@ -312,6 +312,43 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
*/
|
*/
|
||||||
private final AssistDataReceiverImpl mAssistReceiver = new AssistDataReceiverImpl();
|
private final AssistDataReceiverImpl mAssistReceiver = new AssistDataReceiverImpl();
|
||||||
|
|
||||||
|
void onSwitchInputMethodLocked() {
|
||||||
|
if (mExpiredResponse) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldExpireResponseOnInputMethodSwitch()) {
|
||||||
|
// Set the old response expired, so the next action (ACTION_VIEW_ENTERED) can trigger
|
||||||
|
// a new fill request.
|
||||||
|
mExpiredResponse = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean shouldExpireResponseOnInputMethodSwitch() {
|
||||||
|
// One of below cases will need a new fill request to update the inline spec for the new
|
||||||
|
// input method.
|
||||||
|
// 1. The autofill provider supports inline suggestion and the render service is available.
|
||||||
|
// 2. Had triggered the augmented autofill and the render service is available. Whether the
|
||||||
|
// augmented autofill triggered by:
|
||||||
|
// a. Augmented autofill only
|
||||||
|
// b. The autofill provider respond null
|
||||||
|
if (mService.getRemoteInlineSuggestionRenderServiceLocked() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isInlineSuggestionsEnabledByAutofillProviderLocked()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final ViewState state = mViewStates.get(mCurrentViewId);
|
||||||
|
if (state != null
|
||||||
|
&& (state.getState() & ViewState.STATE_TRIGGERED_AUGMENTED_AUTOFILL) != 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO(b/151867668): improve how asynchronous data dependencies are handled, without using
|
* TODO(b/151867668): improve how asynchronous data dependencies are handled, without using
|
||||||
* CountDownLatch.
|
* CountDownLatch.
|
||||||
|
|||||||
Reference in New Issue
Block a user