Skip to content

Commit 9f2c436

Browse files
Taran SinghAndroid (Google) Code Review
authored andcommitted
Merge "Allow IME to show when control target differs from DC target" into rvc-dev
2 parents 77db95c + 9bebe19 commit 9f2c436

2 files changed

Lines changed: 68 additions & 2 deletions

File tree

services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818

1919
import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_IME;
2020

21+
import android.graphics.PixelFormat;
2122
import android.view.InsetsSource;
2223
import android.view.WindowInsets;
2324

25+
import com.android.internal.annotations.VisibleForTesting;
2426
import com.android.server.protolog.common.ProtoLog;
2527

2628
/**
@@ -107,7 +109,8 @@ void abortShowImePostLayout() {
107109
mShowImeRunner = null;
108110
}
109111

110-
private boolean isImeTargetFromDisplayContentAndImeSame() {
112+
@VisibleForTesting
113+
boolean isImeTargetFromDisplayContentAndImeSame() {
111114
// IMMS#mLastImeTargetWindow always considers focused window as
112115
// IME target, however DisplayContent#computeImeTarget() can compute
113116
// a different IME target.
@@ -118,6 +121,7 @@ private boolean isImeTargetFromDisplayContentAndImeSame() {
118121
// TODO(b/139861270): Remove the child & sublayer check once IMMS is aware of
119122
// actual IME target.
120123
final WindowState dcTarget = mDisplayContent.mInputMethodTarget;
124+
final InsetsControlTarget controlTarget = mDisplayContent.mInputMethodControlTarget;
121125
if (dcTarget == null || mImeTargetFromIme == null) {
122126
return false;
123127
}
@@ -127,6 +131,9 @@ private boolean isImeTargetFromDisplayContentAndImeSame() {
127131
return (!dcTarget.isClosing() && mImeTargetFromIme == dcTarget)
128132
|| (mImeTargetFromIme != null && dcTarget.getParentWindow() == mImeTargetFromIme
129133
&& dcTarget.mSubLayer > mImeTargetFromIme.mSubLayer)
130-
|| mImeTargetFromIme == mDisplayContent.getImeFallback();
134+
|| mImeTargetFromIme == mDisplayContent.getImeFallback()
135+
// If IME target is transparent but control target matches requesting window.
136+
|| (controlTarget == mImeTargetFromIme
137+
&& PixelFormat.formatHasAlpha(dcTarget.mAttrs.format));
131138
}
132139
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright (C) 2020 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.android.server.wm;
18+
19+
import static android.view.InsetsState.ITYPE_IME;
20+
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
21+
22+
import static org.junit.Assert.assertTrue;
23+
24+
import android.graphics.PixelFormat;
25+
import android.platform.test.annotations.Presubmit;
26+
import android.view.InsetsSource;
27+
28+
import androidx.test.filters.SmallTest;
29+
30+
import org.junit.Before;
31+
import org.junit.Test;
32+
import org.junit.runner.RunWith;
33+
34+
@SmallTest
35+
@Presubmit
36+
@RunWith(WindowTestRunner.class)
37+
public class ImeInsetsSourceProviderTest extends WindowTestsBase {
38+
39+
private InsetsSource mImeSource = new InsetsSource(ITYPE_IME);
40+
private ImeInsetsSourceProvider mImeProvider;
41+
42+
@Before
43+
public void setUp() throws Exception {
44+
mImeSource.setVisible(true);
45+
mImeProvider = new ImeInsetsSourceProvider(mImeSource,
46+
mDisplayContent.getInsetsStateController(), mDisplayContent);
47+
}
48+
49+
@Test
50+
public void testTransparentControlTargetWindowCanShowIme() {
51+
final WindowState appWin = createWindow(null, TYPE_APPLICATION, "app");
52+
final WindowState popup = createWindow(appWin, TYPE_APPLICATION, "popup");
53+
mDisplayContent.mInputMethodControlTarget = popup;
54+
mDisplayContent.mInputMethodTarget = appWin;
55+
popup.mAttrs.format = PixelFormat.TRANSPARENT;
56+
mImeProvider.scheduleShowImePostLayout(appWin);
57+
assertTrue(mImeProvider.isImeTargetFromDisplayContentAndImeSame());
58+
}
59+
}

0 commit comments

Comments
 (0)