mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 11:18:21 +00:00
Add Assistant Home button support in Launcher TAPL
When using apps that switch to car mode (e.g. Maps) while in 3 button navigation mode, the default navbar is not visible and instead the overlay from Assistant is being rendered that also has the Home button. For tests that involve apps switching to car mode, when we want to go home we want to be able to press that button. Bug: 282758103 Test: n/a Change-Id: I88c420f321dcfd39164e20e97d39f90bf1e5d8d8
This commit is contained in:
@@ -21,7 +21,6 @@ import static android.content.pm.PackageManager.DONT_KILL_APP;
|
||||
import static android.content.pm.PackageManager.MATCH_ALL;
|
||||
import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS;
|
||||
import static android.view.MotionEvent.AXIS_GESTURE_SWIPE_FINGER_COUNT;
|
||||
|
||||
import static com.android.launcher3.tapl.Folder.FOLDER_CONTENT_RES_ID;
|
||||
import static com.android.launcher3.tapl.TestHelpers.getOverviewPackageName;
|
||||
import static com.android.launcher3.testing.shared.TestProtocol.NORMAL_STATE_ORDINAL;
|
||||
@@ -29,12 +28,14 @@ import static com.android.launcher3.testing.shared.TestProtocol.NORMAL_STATE_ORD
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Instrumentation;
|
||||
import android.app.UiAutomation;
|
||||
import android.app.UiModeManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentProviderClient;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ProviderInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Insets;
|
||||
import android.graphics.Point;
|
||||
@@ -181,6 +182,8 @@ public final class LauncherInstrumentation {
|
||||
static final long DEFAULT_POLL_INTERVAL = 1000;
|
||||
private static final String SYSTEMUI_PACKAGE = "com.android.systemui";
|
||||
private static final String ANDROID_PACKAGE = "android";
|
||||
private static final String ASSISTANT_PACKAGE = "com.google.android.googlequicksearchbox";
|
||||
private static final String ASSISTANT_GO_HOME_RES_ID = "home_icon";
|
||||
|
||||
private static WeakReference<VisibleContainer> sActiveContainer = new WeakReference<>(null);
|
||||
|
||||
@@ -1055,7 +1058,7 @@ public final class LauncherInstrumentation {
|
||||
action = "clicking home button";
|
||||
|
||||
runToState(
|
||||
waitForNavigationUiObject("home")::click,
|
||||
getHomeButton()::click,
|
||||
NORMAL_STATE_ORDINAL,
|
||||
!hasLauncherObject(WORKSPACE_RES_ID)
|
||||
&& (hasLauncherObject(APPS_RES_ID)
|
||||
@@ -1238,6 +1241,28 @@ public final class LauncherInstrumentation {
|
||||
return object;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private UiObject2 getHomeButton() {
|
||||
UiModeManager uiManager =
|
||||
(UiModeManager) getContext().getSystemService(Context.UI_MODE_SERVICE);
|
||||
if (uiManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_CAR) {
|
||||
return waitForAssistantHomeButton();
|
||||
} else {
|
||||
return waitForNavigationUiObject("home");
|
||||
}
|
||||
}
|
||||
|
||||
/* Assistant Home button is present when system is in car mode. */
|
||||
@NonNull
|
||||
UiObject2 waitForAssistantHomeButton() {
|
||||
final UiObject2 object = mDevice.wait(
|
||||
Until.findObject(By.res(ASSISTANT_PACKAGE, ASSISTANT_GO_HOME_RES_ID)),
|
||||
WAIT_TIME_MS);
|
||||
assertNotNull(
|
||||
"Can't find an assistant UI object with id: " + ASSISTANT_GO_HOME_RES_ID, object);
|
||||
return object;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
UiObject2 waitForNavigationUiObject(String resId) {
|
||||
String resPackage = getNavigationButtonResPackage();
|
||||
|
||||
Reference in New Issue
Block a user