Forcibly show IME even hardware keyboard is conencted

If device under test has a hardware keyboard connected, usually IME
wouldn't show up and the test fails.

Bug: 160930110
Test: atest SystemUITests:GlobalActionsImeTest
Change-Id: I741155cf1119de981477aed93e3ef9b437c87147
This commit is contained in:
Tadashi G. Takaoka
2020-10-01 11:18:41 +09:00
parent 83aefc5e2e
commit f68359aad4

View File

@@ -16,6 +16,7 @@
package com.android.systemui.globalactions;
import static android.provider.Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD;
import static android.view.WindowInsets.Type.ime;
import static org.junit.Assert.assertEquals;
@@ -24,9 +25,11 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import android.app.Activity;
import android.content.ContentResolver;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.SystemClock;
import android.provider.Settings;
import android.view.View;
import android.view.WindowInsets;
import android.view.WindowInsetsController;
@@ -41,6 +44,7 @@ import androidx.test.rule.ActivityTestRule;
import com.android.systemui.SysuiTestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -54,8 +58,23 @@ public class GlobalActionsImeTest extends SysuiTestCase {
public ActivityTestRule<TestActivity> mActivityTestRule = new ActivityTestRule<>(
TestActivity.class, false, false);
private int mOriginalShowImeWithHardKeyboard;
@Before
public void setUp() {
final ContentResolver contentResolver = mContext.getContentResolver();
mOriginalShowImeWithHardKeyboard = Settings.Secure.getInt(
contentResolver, SHOW_IME_WITH_HARD_KEYBOARD, 0);
// Forcibly shows IME even when hardware keyboard is connected.
// To change USER_SYSTEM settings, we have to use settings shell command.
executeShellCommand("settings put secure " + SHOW_IME_WITH_HARD_KEYBOARD + " 1");
}
@After
public void tearDown() {
// To restore USER_SYSTEM settings, we have to use settings shell command.
executeShellCommand("settings put secure "
+ SHOW_IME_WITH_HARD_KEYBOARD + " " + mOriginalShowImeWithHardKeyboard);
executeShellCommand("input keyevent HOME");
}