Apply getImeControlTarget() only for IME insets

On an external display, getImeControlTarget returns the remote control
target of the defaul display. This is not desirable for non-IME insets.

Test: dumpsys and check the control target on external display.
Bug: 184325245
Change-Id: I79ee5caacb91d828e28ddb884cf6b8cbdea64386
This commit is contained in:
Yunfan Chen
2021-05-26 06:43:29 +00:00
parent 475d21c364
commit 4e6fb0bcba
2 changed files with 11 additions and 5 deletions

View File

@@ -29,6 +29,7 @@ import static com.android.server.wm.ImeInsetsSourceProviderProto.IS_IME_LAYOUT_D
import static com.android.server.wm.WindowManagerService.H.UPDATE_MULTI_WINDOW_STACKS; import static com.android.server.wm.WindowManagerService.H.UPDATE_MULTI_WINDOW_STACKS;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Trace; import android.os.Trace;
import android.util.proto.ProtoOutputStream; import android.util.proto.ProtoOutputStream;
import android.view.InsetsSource; import android.view.InsetsSource;
@@ -90,6 +91,16 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
onSourceChanged(); onSourceChanged();
} }
@Override
void updateControlForTarget(@Nullable InsetsControlTarget target, boolean force) {
if (target != null && target.getWindow() != null) {
// ime control target could be a different window.
// Refer WindowState#getImeControlTarget().
target = target.getWindow().getImeControlTarget();
}
super.updateControlForTarget(target, force);
}
private void onSourceChanged() { private void onSourceChanged() {
if (mLastSource.equals(mSource)) { if (mLastSource.equals(mSource)) {
return; return;

View File

@@ -307,11 +307,6 @@ class InsetsSourceProvider {
// to control the window for now. // to control the window for now.
return; return;
} }
if (target != null && target.getWindow() != null) {
// ime control target could be a different window.
// Refer WindowState#getImeControlTarget().
target = target.getWindow().getImeControlTarget();
}
if (mWin != null && mWin.getSurfaceControl() == null) { if (mWin != null && mWin.getSurfaceControl() == null) {
// if window doesn't have a surface, set it null and return. // if window doesn't have a surface, set it null and return.