Merge "Allow IME to show when control target differs from DC target" into rvc-dev am: 9f2c436699 am: 71035a25cc
Change-Id: I61df802f11f1dc6676b4234a841e7fa50dacfc3f
This commit is contained in:
@@ -18,9 +18,11 @@ package com.android.server.wm;
|
|||||||
|
|
||||||
import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_IME;
|
import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_IME;
|
||||||
|
|
||||||
|
import android.graphics.PixelFormat;
|
||||||
import android.view.InsetsSource;
|
import android.view.InsetsSource;
|
||||||
import android.view.WindowInsets;
|
import android.view.WindowInsets;
|
||||||
|
|
||||||
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.server.protolog.common.ProtoLog;
|
import com.android.server.protolog.common.ProtoLog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,7 +109,8 @@ class ImeInsetsSourceProvider extends InsetsSourceProvider {
|
|||||||
mShowImeRunner = null;
|
mShowImeRunner = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isImeTargetFromDisplayContentAndImeSame() {
|
@VisibleForTesting
|
||||||
|
boolean isImeTargetFromDisplayContentAndImeSame() {
|
||||||
// IMMS#mLastImeTargetWindow always considers focused window as
|
// IMMS#mLastImeTargetWindow always considers focused window as
|
||||||
// IME target, however DisplayContent#computeImeTarget() can compute
|
// IME target, however DisplayContent#computeImeTarget() can compute
|
||||||
// a different IME target.
|
// a different IME target.
|
||||||
@@ -118,6 +121,7 @@ class ImeInsetsSourceProvider extends InsetsSourceProvider {
|
|||||||
// TODO(b/139861270): Remove the child & sublayer check once IMMS is aware of
|
// TODO(b/139861270): Remove the child & sublayer check once IMMS is aware of
|
||||||
// actual IME target.
|
// actual IME target.
|
||||||
final WindowState dcTarget = mDisplayContent.mInputMethodTarget;
|
final WindowState dcTarget = mDisplayContent.mInputMethodTarget;
|
||||||
|
final InsetsControlTarget controlTarget = mDisplayContent.mInputMethodControlTarget;
|
||||||
if (dcTarget == null || mImeTargetFromIme == null) {
|
if (dcTarget == null || mImeTargetFromIme == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -127,6 +131,9 @@ class ImeInsetsSourceProvider extends InsetsSourceProvider {
|
|||||||
return (!dcTarget.isClosing() && mImeTargetFromIme == dcTarget)
|
return (!dcTarget.isClosing() && mImeTargetFromIme == dcTarget)
|
||||||
|| (mImeTargetFromIme != null && dcTarget.getParentWindow() == mImeTargetFromIme
|
|| (mImeTargetFromIme != null && dcTarget.getParentWindow() == mImeTargetFromIme
|
||||||
&& dcTarget.mSubLayer > mImeTargetFromIme.mSubLayer)
|
&& dcTarget.mSubLayer > mImeTargetFromIme.mSubLayer)
|
||||||
|| mImeTargetFromIme == mDisplayContent.getImeFallback();
|
|| mImeTargetFromIme == mDisplayContent.getImeFallback()
|
||||||
|
// If IME target is transparent but control target matches requesting window.
|
||||||
|
|| (controlTarget == mImeTargetFromIme
|
||||||
|
&& PixelFormat.formatHasAlpha(dcTarget.mAttrs.format));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.server.wm;
|
||||||
|
|
||||||
|
import static android.view.InsetsState.ITYPE_IME;
|
||||||
|
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import android.graphics.PixelFormat;
|
||||||
|
import android.platform.test.annotations.Presubmit;
|
||||||
|
import android.view.InsetsSource;
|
||||||
|
|
||||||
|
import androidx.test.filters.SmallTest;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
|
@Presubmit
|
||||||
|
@RunWith(WindowTestRunner.class)
|
||||||
|
public class ImeInsetsSourceProviderTest extends WindowTestsBase {
|
||||||
|
|
||||||
|
private InsetsSource mImeSource = new InsetsSource(ITYPE_IME);
|
||||||
|
private ImeInsetsSourceProvider mImeProvider;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
mImeSource.setVisible(true);
|
||||||
|
mImeProvider = new ImeInsetsSourceProvider(mImeSource,
|
||||||
|
mDisplayContent.getInsetsStateController(), mDisplayContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTransparentControlTargetWindowCanShowIme() {
|
||||||
|
final WindowState appWin = createWindow(null, TYPE_APPLICATION, "app");
|
||||||
|
final WindowState popup = createWindow(appWin, TYPE_APPLICATION, "popup");
|
||||||
|
mDisplayContent.mInputMethodControlTarget = popup;
|
||||||
|
mDisplayContent.mInputMethodTarget = appWin;
|
||||||
|
popup.mAttrs.format = PixelFormat.TRANSPARENT;
|
||||||
|
mImeProvider.scheduleShowImePostLayout(appWin);
|
||||||
|
assertTrue(mImeProvider.isImeTargetFromDisplayContentAndImeSame());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user