Merge "Pipe windowToken for hideSoftInput" into rvc-dev am: 73b1d16d28 am: cec5307235 am: ef8ebae6e5
Change-Id: I391a3ee0e19695ae5b34a8afb329c14bef31b8e5
This commit is contained in:
@@ -219,22 +219,29 @@ class IInputMethodWrapper extends IInputMethod.Stub
|
||||
case DO_REVOKE_SESSION:
|
||||
inputMethod.revokeSession((InputMethodSession)msg.obj);
|
||||
return;
|
||||
case DO_SHOW_SOFT_INPUT:
|
||||
SomeArgs args = (SomeArgs)msg.obj;
|
||||
case DO_SHOW_SOFT_INPUT: {
|
||||
final SomeArgs args = (SomeArgs)msg.obj;
|
||||
inputMethod.showSoftInputWithToken(
|
||||
msg.arg1, (ResultReceiver) args.arg2, (IBinder) args.arg1);
|
||||
args.recycle();
|
||||
return;
|
||||
case DO_HIDE_SOFT_INPUT:
|
||||
inputMethod.hideSoftInput(msg.arg1, (ResultReceiver)msg.obj);
|
||||
}
|
||||
case DO_HIDE_SOFT_INPUT: {
|
||||
final SomeArgs args = (SomeArgs) msg.obj;
|
||||
inputMethod.hideSoftInputWithToken(msg.arg1, (ResultReceiver) args.arg2,
|
||||
(IBinder) args.arg1);
|
||||
args.recycle();
|
||||
return;
|
||||
}
|
||||
case DO_CHANGE_INPUTMETHOD_SUBTYPE:
|
||||
inputMethod.changeInputMethodSubtype((InputMethodSubtype)msg.obj);
|
||||
return;
|
||||
case DO_CREATE_INLINE_SUGGESTIONS_REQUEST:
|
||||
args = (SomeArgs) msg.obj;
|
||||
final SomeArgs args = (SomeArgs) msg.obj;
|
||||
inputMethod.onCreateInlineSuggestionsRequest(
|
||||
(InlineSuggestionsRequestInfo) args.arg1,
|
||||
(IInlineSuggestionsRequestCallback) args.arg2);
|
||||
args.recycle();
|
||||
return;
|
||||
|
||||
}
|
||||
@@ -380,9 +387,9 @@ class IInputMethodWrapper extends IInputMethod.Stub
|
||||
|
||||
@BinderThread
|
||||
@Override
|
||||
public void hideSoftInput(int flags, ResultReceiver resultReceiver) {
|
||||
mCaller.executeOrSendMessage(mCaller.obtainMessageIO(DO_HIDE_SOFT_INPUT,
|
||||
flags, resultReceiver));
|
||||
public void hideSoftInput(IBinder hideInputToken, int flags, ResultReceiver resultReceiver) {
|
||||
mCaller.executeOrSendMessage(mCaller.obtainMessageIOO(DO_HIDE_SOFT_INPUT,
|
||||
flags, hideInputToken, resultReceiver));
|
||||
}
|
||||
|
||||
@BinderThread
|
||||
|
||||
@@ -459,6 +459,16 @@ public class InputMethodService extends AbstractInputMethodService {
|
||||
*/
|
||||
private IBinder mCurShowInputToken;
|
||||
|
||||
/**
|
||||
* An opaque {@link Binder} token of window requesting {@link InputMethodImpl#hideSoftInput}
|
||||
* The original app window token is passed from client app window.
|
||||
* {@link com.android.server.inputmethod.InputMethodManagerService} creates a unique dummy
|
||||
* token to identify this window.
|
||||
* This dummy token is only valid for a single call to {@link InputMethodImpl#hideSoftInput},
|
||||
* after which it is set {@code null} until next call.
|
||||
*/
|
||||
private IBinder mCurHideInputToken;
|
||||
|
||||
final ViewTreeObserver.OnComputeInternalInsetsListener mInsetsComputer = info -> {
|
||||
onComputeInsets(mTmpInsets);
|
||||
if (isExtractViewShown()) {
|
||||
@@ -500,6 +510,7 @@ public class InputMethodService extends AbstractInputMethodService {
|
||||
public class InputMethodImpl extends AbstractInputMethodImpl {
|
||||
|
||||
private boolean mSystemCallingShowSoftInput;
|
||||
private boolean mSystemCallingHideSoftInput;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -634,6 +645,21 @@ public class InputMethodService extends AbstractInputMethodService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @hide
|
||||
*/
|
||||
@MainThread
|
||||
@Override
|
||||
public void hideSoftInputWithToken(int flags, ResultReceiver resultReceiver,
|
||||
IBinder hideInputToken) {
|
||||
mSystemCallingHideSoftInput = true;
|
||||
mCurHideInputToken = hideInputToken;
|
||||
hideSoftInput(flags, resultReceiver);
|
||||
mCurHideInputToken = null;
|
||||
mSystemCallingHideSoftInput = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -641,6 +667,12 @@ public class InputMethodService extends AbstractInputMethodService {
|
||||
@Override
|
||||
public void hideSoftInput(int flags, ResultReceiver resultReceiver) {
|
||||
if (DEBUG) Log.v(TAG, "hideSoftInput()");
|
||||
if (getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.R
|
||||
&& !mSystemCallingHideSoftInput) {
|
||||
Log.e(TAG, "IME shouldn't call hideSoftInput on itself."
|
||||
+ " Use requestHideSelf(int) itself");
|
||||
return;
|
||||
}
|
||||
final boolean wasVisible = mIsPreRendered
|
||||
? mDecorViewVisible && mWindowVisible : isInputViewShown();
|
||||
applyVisibilityInInsetsConsumerIfNecessary(false /* setVisible */);
|
||||
@@ -738,6 +770,15 @@ public class InputMethodService extends AbstractInputMethodService {
|
||||
public void setCurrentShowInputToken(IBinder showInputToken) {
|
||||
mCurShowInputToken = showInputToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public void setCurrentHideInputToken(IBinder hideInputToken) {
|
||||
mCurHideInputToken = hideInputToken;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(b/137800469): Add detailed docs explaining the inline suggestions process.
|
||||
@@ -2172,7 +2213,8 @@ public class InputMethodService extends AbstractInputMethodService {
|
||||
if (!isVisibilityAppliedUsingInsetsConsumer()) {
|
||||
return;
|
||||
}
|
||||
mPrivOps.applyImeVisibility(mCurShowInputToken, setVisible);
|
||||
mPrivOps.applyImeVisibility(setVisible
|
||||
? mCurShowInputToken : mCurHideInputToken, setVisible);
|
||||
}
|
||||
|
||||
private boolean isVisibilityAppliedUsingInsetsConsumer() {
|
||||
|
||||
@@ -348,6 +348,27 @@ public interface InputMethod {
|
||||
* {@link InputMethodManager#RESULT_UNCHANGED_HIDDEN InputMethodManager.RESULT_UNCHANGED_HIDDEN},
|
||||
* {@link InputMethodManager#RESULT_SHOWN InputMethodManager.RESULT_SHOWN}, or
|
||||
* {@link InputMethodManager#RESULT_HIDDEN InputMethodManager.RESULT_HIDDEN}.
|
||||
* @param hideInputToken an opaque {@link android.os.Binder} token to identify which API call
|
||||
* of {@link InputMethodManager#hideSoftInputFromWindow(IBinder, int)}} is associated
|
||||
* with this callback.
|
||||
* @hide
|
||||
*/
|
||||
@MainThread
|
||||
public void hideSoftInputWithToken(int flags, ResultReceiver resultReceiver,
|
||||
IBinder hideInputToken);
|
||||
|
||||
/**
|
||||
* Request that any soft input part of the input method be hidden from the user.
|
||||
* @param flags Provides additional information about the show request.
|
||||
* Currently always 0.
|
||||
* @param resultReceiver The client requesting the show may wish to
|
||||
* be told the impact of their request, which should be supplied here.
|
||||
* The result code should be
|
||||
* {@link InputMethodManager#RESULT_UNCHANGED_SHOWN InputMethodManager.RESULT_UNCHANGED_SHOWN},
|
||||
* {@link InputMethodManager#RESULT_UNCHANGED_HIDDEN
|
||||
* InputMethodManager.RESULT_UNCHANGED_HIDDEN},
|
||||
* {@link InputMethodManager#RESULT_SHOWN InputMethodManager.RESULT_SHOWN}, or
|
||||
* {@link InputMethodManager#RESULT_HIDDEN InputMethodManager.RESULT_HIDDEN}.
|
||||
*/
|
||||
@MainThread
|
||||
public void hideSoftInput(int flags, ResultReceiver resultReceiver);
|
||||
@@ -366,4 +387,13 @@ public interface InputMethod {
|
||||
* @hide
|
||||
*/
|
||||
public void setCurrentShowInputToken(IBinder showInputToken);
|
||||
|
||||
/**
|
||||
* Update token of the client window requesting {@link #hideSoftInput(int, ResultReceiver)}
|
||||
* @param hideInputToken dummy app window token for window requesting
|
||||
* {@link InputMethodManager#hideSoftInputFromWindow(IBinder, int)}
|
||||
* @hide
|
||||
*/
|
||||
public void setCurrentHideInputToken(IBinder hideInputToken);
|
||||
|
||||
}
|
||||
|
||||
@@ -1709,7 +1709,7 @@ public final class InputMethodManager {
|
||||
}
|
||||
|
||||
try {
|
||||
return mService.hideSoftInput(mClient, flags, resultReceiver);
|
||||
return mService.hideSoftInput(mClient, windowToken, flags, resultReceiver);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -1986,7 +1986,8 @@ public final class InputMethodManager {
|
||||
@UnsupportedAppUsage
|
||||
void closeCurrentInput() {
|
||||
try {
|
||||
mService.hideSoftInput(mClient, HIDE_NOT_ALWAYS, null);
|
||||
mService.hideSoftInput(
|
||||
mClient, mCurRootView.getView().getWindowToken(), HIDE_NOT_ALWAYS, null);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user