Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1338b12 authored by Charles Chen's avatar Charles Chen
Browse files

Make InputMethodService be an UI context

IMS handles configuration and display changes from the server side
and render views to inteact with users. Thus IMS should be marked as
an UI context

fixes: 157027563
Test: atest ContextTest
Change-Id: I0a2307c4764acf8b9fc0254a9ee2fc8a344bb7ef
parent 3a9c93d4
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -260,4 +260,10 @@ public abstract class AbstractInputMethodService extends Service
     */
    public void notifyUserActionIfNecessary() {
    }

    /** @hide */
    @Override
    public final boolean isUiContext() {
        return true;
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -23,12 +23,14 @@ import static android.view.Display.DEFAULT_DISPLAY;
import static com.google.common.truth.Truth.assertThat;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import android.app.ActivityThread;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.hardware.display.DisplayManager;
import android.hardware.display.VirtualDisplay;
import android.inputmethodservice.InputMethodService;
import android.media.ImageReader;
import android.os.UserHandle;
import android.view.Display;
@@ -135,6 +137,13 @@ public class ContextTest {
        assertThat(systemUiContext.isUiContext()).isTrue();
    }

    @Test
    public void testIsUiContext_InputMethodService_returnsTrue() {
        final InputMethodService ims = new InputMethodService();

        assertTrue(ims.isUiContext());
    }

    @Test
    public void testGetDisplayFromDisplayContextDerivedContextOnPrimaryDisplay() {
        verifyGetDisplayFromDisplayContextDerivedContext(false /* onSecondaryDisplay */);