Merge "Remove IME surface when hidden" into rvc-dev am: 05b07c2657
Change-Id: I38ab29054ed6a26f70e2e8582702f6e7002ca225
This commit is contained in:
@@ -53,6 +53,7 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
|
|||||||
private static final int DO_FINISH_SESSION = 110;
|
private static final int DO_FINISH_SESSION = 110;
|
||||||
private static final int DO_VIEW_CLICKED = 115;
|
private static final int DO_VIEW_CLICKED = 115;
|
||||||
private static final int DO_NOTIFY_IME_HIDDEN = 120;
|
private static final int DO_NOTIFY_IME_HIDDEN = 120;
|
||||||
|
private static final int DO_REMOVE_IME_SURFACE = 130;
|
||||||
|
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
HandlerCaller mCaller;
|
HandlerCaller mCaller;
|
||||||
@@ -136,6 +137,10 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
|
|||||||
mInputMethodSession.notifyImeHidden();
|
mInputMethodSession.notifyImeHidden();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
case DO_REMOVE_IME_SURFACE: {
|
||||||
|
mInputMethodSession.removeImeSurface();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Log.w(TAG, "Unhandled message code: " + msg.what);
|
Log.w(TAG, "Unhandled message code: " + msg.what);
|
||||||
}
|
}
|
||||||
@@ -183,6 +188,11 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
|
|||||||
mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_NOTIFY_IME_HIDDEN));
|
mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_NOTIFY_IME_HIDDEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeImeSurface() {
|
||||||
|
mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_REMOVE_IME_SURFACE));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateCursor(Rect newCursor) {
|
public void updateCursor(Rect newCursor) {
|
||||||
mCaller.executeOrSendMessage(
|
mCaller.executeOrSendMessage(
|
||||||
|
|||||||
@@ -814,6 +814,13 @@ public class InputMethodService extends AbstractInputMethodService {
|
|||||||
onPreRenderedWindowVisibilityChanged(false /* setVisible */);
|
onPreRenderedWindowVisibilityChanged(false /* setVisible */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeImeSurface() {
|
||||||
|
if (!mShowInputRequested && !mWindowVisible) {
|
||||||
|
// hiding a window removes its surface.
|
||||||
|
mWindow.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setImeWindowStatus(int visibilityFlags, int backDisposition) {
|
private void setImeWindowStatus(int visibilityFlags, int backDisposition) {
|
||||||
mPrivOps.setImeWindowStatus(visibilityFlags, backDisposition);
|
mPrivOps.setImeWindowStatus(visibilityFlags, backDisposition);
|
||||||
}
|
}
|
||||||
@@ -932,6 +939,14 @@ public class InputMethodService extends AbstractInputMethodService {
|
|||||||
public final void notifyImeHidden() {
|
public final void notifyImeHidden() {
|
||||||
InputMethodService.this.notifyImeHidden();
|
InputMethodService.this.notifyImeHidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify IME that surface can be now removed.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public final void removeImeSurface() {
|
||||||
|
InputMethodService.this.removeImeSurface();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -296,6 +296,12 @@ final class MultiClientInputMethodClientCallbackAdaptor {
|
|||||||
// no-op for multi-session since IME is responsible controlling navigation bar buttons.
|
// no-op for multi-session since IME is responsible controlling navigation bar buttons.
|
||||||
reportNotSupported();
|
reportNotSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeImeSurface() {
|
||||||
|
// no-op for multi-session
|
||||||
|
reportNotSupported();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class MultiClientInputMethodSessionImpl
|
private static final class MultiClientInputMethodSessionImpl
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
package android.view;
|
package android.view;
|
||||||
|
|
||||||
import static android.view.InsetsState.ITYPE_IME;
|
import static android.view.InsetsState.ITYPE_IME;
|
||||||
import static android.view.InsetsState.toPublicType;
|
|
||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.inputmethodservice.InputMethodService;
|
import android.inputmethodservice.InputMethodService;
|
||||||
@@ -99,6 +98,15 @@ public final class ImeInsetsSourceConsumer extends InsetsSourceConsumer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void hide(boolean animationFinished) {
|
||||||
|
super.hide();
|
||||||
|
if (animationFinished) {
|
||||||
|
// remove IME surface as IME has finished hide animation.
|
||||||
|
removeSurface();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request {@link InputMethodManager} to show the IME.
|
* Request {@link InputMethodManager} to show the IME.
|
||||||
* @return @see {@link android.view.InsetsSourceConsumer.ShowResult}.
|
* @return @see {@link android.view.InsetsSourceConsumer.ShowResult}.
|
||||||
@@ -127,6 +135,11 @@ public final class ImeInsetsSourceConsumer extends InsetsSourceConsumer {
|
|||||||
getImm().notifyImeHidden();
|
getImm().notifyImeHidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeSurface() {
|
||||||
|
getImm().removeImeSurface();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setControl(@Nullable InsetsSourceControl control, int[] showTypes,
|
public void setControl(@Nullable InsetsSourceControl control, int[] showTypes,
|
||||||
int[] hideTypes) {
|
int[] hideTypes) {
|
||||||
|
|||||||
@@ -694,7 +694,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
|
|||||||
if (shown) {
|
if (shown) {
|
||||||
showDirectly(controller.getTypes());
|
showDirectly(controller.getTypes());
|
||||||
} else {
|
} else {
|
||||||
hideDirectly(controller.getTypes());
|
hideDirectly(controller.getTypes(), true /* animationFinished */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -852,10 +852,10 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
|
|||||||
: LAYOUT_INSETS_DURING_ANIMATION_HIDDEN);
|
: LAYOUT_INSETS_DURING_ANIMATION_HIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hideDirectly(@InsetsType int types) {
|
private void hideDirectly(@InsetsType int types, boolean animationFinished) {
|
||||||
final ArraySet<Integer> internalTypes = InsetsState.toInternalType(types);
|
final ArraySet<Integer> internalTypes = InsetsState.toInternalType(types);
|
||||||
for (int i = internalTypes.size() - 1; i >= 0; i--) {
|
for (int i = internalTypes.size() - 1; i >= 0; i--) {
|
||||||
getSourceConsumer(internalTypes.valueAt(i)).hide();
|
getSourceConsumer(internalTypes.valueAt(i)).hide(animationFinished);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -887,7 +887,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
|
|||||||
if (layoutDuringAnimation == LAYOUT_INSETS_DURING_ANIMATION_SHOWN) {
|
if (layoutDuringAnimation == LAYOUT_INSETS_DURING_ANIMATION_SHOWN) {
|
||||||
showDirectly(types);
|
showDirectly(types);
|
||||||
} else {
|
} else {
|
||||||
hideDirectly(types);
|
hideDirectly(types, false /* animationFinished */);
|
||||||
}
|
}
|
||||||
if (mViewRoot.mView == null) {
|
if (mViewRoot.mView == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -16,12 +16,10 @@
|
|||||||
|
|
||||||
package android.view;
|
package android.view;
|
||||||
|
|
||||||
import static android.view.InsetsController.ANIMATION_TYPE_NONE;
|
|
||||||
import static android.view.InsetsState.toPublicType;
|
import static android.view.InsetsState.toPublicType;
|
||||||
|
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.util.MutableShort;
|
|
||||||
import android.view.InsetsState.InternalInsetsType;
|
import android.view.InsetsState.InternalInsetsType;
|
||||||
import android.view.SurfaceControl.Transaction;
|
import android.view.SurfaceControl.Transaction;
|
||||||
import android.view.WindowInsets.Type.InsetsType;
|
import android.view.WindowInsets.Type.InsetsType;
|
||||||
@@ -137,6 +135,10 @@ public class InsetsSourceConsumer {
|
|||||||
setRequestedVisible(false);
|
setRequestedVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hide(boolean animationFinished) {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when current window gains focus
|
* Called when current window gains focus
|
||||||
*/
|
*/
|
||||||
@@ -200,6 +202,13 @@ public class InsetsSourceConsumer {
|
|||||||
// no-op for types that always return ShowResult#SHOW_IMMEDIATELY.
|
// no-op for types that always return ShowResult#SHOW_IMMEDIATELY.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove surface on which this consumer type is drawn.
|
||||||
|
*/
|
||||||
|
public void removeSurface() {
|
||||||
|
// no-op for types that always return ShowResult#SHOW_IMMEDIATELY.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets requested visibility from the client, regardless of whether we are able to control it at
|
* Sets requested visibility from the client, regardless of whether we are able to control it at
|
||||||
* the moment.
|
* the moment.
|
||||||
|
|||||||
@@ -2055,6 +2055,21 @@ public final class InputMethodManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify IME directly to remove surface as it is no longer visible.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public void removeImeSurface() {
|
||||||
|
synchronized (mH) {
|
||||||
|
try {
|
||||||
|
if (mCurMethod != null) {
|
||||||
|
mCurMethod.removeImeSurface();
|
||||||
|
}
|
||||||
|
} catch (RemoteException re) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report the current selection range.
|
* Report the current selection range.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -191,4 +191,10 @@ public interface InputMethodSession {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void notifyImeHidden();
|
public void notifyImeHidden();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify IME directly to remove surface as it is no longer visible.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public void removeImeSurface();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,4 +50,6 @@ oneway interface IInputMethodSession {
|
|||||||
void updateCursorAnchorInfo(in CursorAnchorInfo cursorAnchorInfo);
|
void updateCursorAnchorInfo(in CursorAnchorInfo cursorAnchorInfo);
|
||||||
|
|
||||||
void notifyImeHidden();
|
void notifyImeHidden();
|
||||||
|
|
||||||
|
void removeImeSurface();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user