Switching swipe-up to overview to using test info provider
Also moving test provider to Quickstep to have access to the new info;
and now Launcher3 doesn't have it.
Bug: 123904290
Change-Id: I653376610e83839d102beb9c0604950dd314e8ba
diff --git a/AndroidManifest-common.xml b/AndroidManifest-common.xml
index 5a2d0fe..819e6bc 100644
--- a/AndroidManifest-common.xml
+++ b/AndroidManifest-common.xml
@@ -152,14 +152,6 @@
android:writePermission="${packageName}.permission.WRITE_SETTINGS"
android:readPermission="${packageName}.permission.READ_SETTINGS" />
- <provider
- android:name="com.android.launcher3.TestInformationProvider"
- android:authorities="${packageName}.TestInfo"
- android:readPermission="android.permission.WRITE_SECURE_SETTINGS"
- android:writePermission="android.permission.WRITE_SECURE_SETTINGS"
- android:exported="true">
- </provider>
-
<!--
The content provider for exposing various launcher grid options.
TODO: Enable when all apps columns are correct
diff --git a/go/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java b/go/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
index 47e0e61..5382607 100644
--- a/go/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
+++ b/go/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
@@ -84,9 +84,11 @@
super.onBackPressed(launcher);
}
-
public static float getDefaultSwipeHeight(Launcher launcher) {
- DeviceProfile dp = launcher.getDeviceProfile();
+ return getDefaultSwipeHeight(launcher.getDeviceProfile());
+ }
+
+ public static float getDefaultSwipeHeight(DeviceProfile dp) {
return dp.allAppsCellHeightPx - dp.allAppsIconTextSizePx;
}
}
diff --git a/quickstep/AndroidManifest.xml b/quickstep/AndroidManifest.xml
index 62d0500..97fc284 100644
--- a/quickstep/AndroidManifest.xml
+++ b/quickstep/AndroidManifest.xml
@@ -73,6 +73,14 @@
</intent-filter>
</provider>
+ <provider
+ android:name="com.android.quickstep.TestInformationProvider"
+ android:authorities="${packageName}.TestInfo"
+ android:readPermission="android.permission.WRITE_SECURE_SETTINGS"
+ android:writePermission="android.permission.WRITE_SECURE_SETTINGS"
+ android:exported="true">
+ </provider>
+
<service
android:name="com.android.launcher3.uioverrides.dynamicui.WallpaperManagerCompatVL$ColorExtractionService"
tools:node="remove" />
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewState.java
index f4ea9f9..79e127a 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewState.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewState.java
@@ -26,6 +26,7 @@
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
@@ -132,7 +133,10 @@
}
public static float getDefaultSwipeHeight(Launcher launcher) {
- DeviceProfile dp = launcher.getDeviceProfile();
+ return getDefaultSwipeHeight(launcher.getDeviceProfile());
+ }
+
+ public static float getDefaultSwipeHeight(DeviceProfile dp) {
return dp.allAppsCellHeightPx - dp.allAppsIconTextSizePx;
}
diff --git a/quickstep/src/com/android/quickstep/TestInformationProvider.java b/quickstep/src/com/android/quickstep/TestInformationProvider.java
new file mode 100644
index 0000000..0c478d2
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/TestInformationProvider.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2019 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.quickstep;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Bundle;
+
+import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.InvariantDeviceProfile;
+import com.android.launcher3.TestProtocol;
+import com.android.launcher3.Utilities;
+import com.android.launcher3.uioverrides.OverviewState;
+import com.android.quickstep.util.LayoutUtils;
+
+public class TestInformationProvider extends ContentProvider {
+ @Override
+ public boolean onCreate() {
+ return true;
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues contentValues, String s, String[] strings) {
+ return 0;
+ }
+
+ @Override
+ public int delete(Uri uri, String s, String[] strings) {
+ return 0;
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues contentValues) {
+ return null;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ return null;
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] strings, String s, String[] strings1, String s1) {
+ return null;
+ }
+
+ @Override
+ public Bundle call(String method, String arg, Bundle extras) {
+ if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
+ final Bundle response = new Bundle();
+ final Context context = getContext();
+ final DeviceProfile deviceProfile = InvariantDeviceProfile.INSTANCE.
+ get(context).getDeviceProfile(context);
+
+ switch (method) {
+ case TestProtocol.REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT: {
+ final float swipeHeight =
+ OverviewState.getDefaultSwipeHeight(deviceProfile);
+ response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
+ break;
+ }
+ case TestProtocol.REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT: {
+ final float swipeHeight =
+ LayoutUtils.getShelfTrackingDistance(context, deviceProfile);
+ response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
+ break;
+ }
+ }
+ return response;
+ }
+ return null;
+ }
+}
diff --git a/src/com/android/launcher3/TestInformationProvider.java b/src/com/android/launcher3/TestInformationProvider.java
deleted file mode 100644
index acdb194..0000000
--- a/src/com/android/launcher3/TestInformationProvider.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2019 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.launcher3;
-
-import android.content.ContentProvider;
-import android.content.ContentValues;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.Bundle;
-
-public class TestInformationProvider extends ContentProvider {
- @Override
- public boolean onCreate() {
- return true;
- }
-
- @Override
- public int update(Uri uri, ContentValues contentValues, String s, String[] strings) {
- return 0;
- }
-
- @Override
- public int delete(Uri uri, String s, String[] strings) {
- return 0;
- }
-
- @Override
- public Uri insert(Uri uri, ContentValues contentValues) {
- return null;
- }
-
- @Override
- public String getType(Uri uri) {
- return null;
- }
-
- @Override
- public Cursor query(Uri uri, String[] strings, String s, String[] strings1, String s1) {
- return null;
- }
-
- @Override
- public Bundle call(String method, String arg, Bundle extras) {
- if (TestProtocol.IS_TEST_INFO_ENABLED.equals(method)) {
- final Bundle response = new Bundle();
- response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD,
- Utilities.IS_RUNNING_IN_TEST_HARNESS);
- return response;
- }
- return null;
- }
-}
diff --git a/src/com/android/launcher3/TestProtocol.java b/src/com/android/launcher3/TestProtocol.java
index 2870d3b..5f752cc 100644
--- a/src/com/android/launcher3/TestProtocol.java
+++ b/src/com/android/launcher3/TestProtocol.java
@@ -31,6 +31,9 @@
public static final int ALL_APPS_STATE_ORDINAL = 3;
public static final int BACKGROUND_APP_STATE_ORDINAL = 4;
- public static final String IS_TEST_INFO_ENABLED = "is-test-info-enabled";
public static final String TEST_INFO_RESPONSE_FIELD = "response";
+ public static final String REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT =
+ "home-to-overview-swipe-height";
+ public static final String REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT =
+ "background-to-overview-swipe-height";
}
diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java
index 606cf37..3220691 100644
--- a/tests/tapl/com/android/launcher3/tapl/Background.java
+++ b/tests/tapl/com/android/launcher3/tapl/Background.java
@@ -22,11 +22,14 @@
import static org.junit.Assert.assertTrue;
+import android.view.ViewConfiguration;
+
import androidx.annotation.NonNull;
import androidx.test.uiautomator.By;
-import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.Until;
+import com.android.launcher3.TestProtocol;
+
/**
* Indicates the base state with a UI other than Overview running as foreground. It can also
* indicate Launcher as long as Launcher is not in Overview state.
@@ -59,20 +62,24 @@
protected void goToOverviewUnchecked(int expectedState) {
if (mLauncher.isSwipeUpEnabled()) {
- final int height = mLauncher.getDevice().getDisplayHeight();
- final UiObject2 navBar = mLauncher.getSystemUiObject("navigation_bar_frame");
+ final int centerX = mLauncher.getDevice().getDisplayWidth() / 2;
+ final int startY = getSwipeStartY();
+ final int swipeHeight = mLauncher.getTestInfo(
+ getSwipeHeightRequestName()).
+ getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
+ final int slop = ViewConfiguration.get(mLauncher.getContext()).getScaledTouchSlop();
- int swipeLength = Math.round(getSwipeLength() * mLauncher.getDisplayDensity());
- mLauncher.swipe(
- navBar.getVisibleBounds().centerX(), navBar.getVisibleBounds().centerY(),
- navBar.getVisibleBounds().centerX(), height - swipeLength,
- expectedState);
+ mLauncher.swipe(centerX, startY, centerX, startY - swipeHeight - slop, expectedState);
} else {
mLauncher.getSystemUiObject("recent_apps").click();
}
}
- protected int getSwipeLength() {
- return 200;
+ protected String getSwipeHeightRequestName() {
+ return TestProtocol.REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT;
+ }
+
+ protected int getSwipeStartY() {
+ return mLauncher.getSystemUiObject("home").getVisibleBounds().centerY();
}
}
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 7a27fa4..926e470 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -18,9 +18,11 @@
import static com.android.systemui.shared.system.SettingsCompat.SWIPE_UP_SETTING_NAME;
+import android.app.ActivityManager;
import android.app.Instrumentation;
import android.app.UiAutomation;
import android.content.ContentResolver;
+import android.content.Context;
import android.graphics.Point;
import android.net.Uri;
import android.os.Bundle;
@@ -106,7 +108,13 @@
mInstrumentation = instrumentation;
mDevice = UiDevice.getInstance(instrumentation);
- final String testPackage = mInstrumentation.getContext().getPackageName();
+ // Launcher should run in test harness so that custom accessibility protocol between
+ // Launcher and TAPL is enabled. In-process tests enable this protocol with a direct call
+ // into Launcher.
+ assertTrue("Device must run in a test harness",
+ TestHelpers.isInLauncherProcess() || ActivityManager.isRunningInTestHarness());
+
+ final String testPackage = getContext().getPackageName();
final String targetPackage = mInstrumentation.getTargetContext().getPackageName();
// Launcher package. As during inproc tests the tested launcher may not be selected as the
@@ -127,13 +135,14 @@
} catch (IOException e) {
fail(e.toString());
}
+ }
- // Launcher should run in test harness so that custom test protocols between Launcher and
- // TAPL are enabled. In-process tests enable this protocol with a direct call into Launcher.
- final Bundle response = mInstrumentation.getContext().getContentResolver().call(
- mTestProviderUri, TestProtocol.IS_TEST_INFO_ENABLED, null, null);
- assertTrue("Launcher is not running in test harness",
- response.getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, false));
+ Context getContext() {
+ return mInstrumentation.getContext();
+ }
+
+ Bundle getTestInfo(String request) {
+ return getContext().getContentResolver().call(mTestProviderUri, request, null, null);
}
void setActiveContainer(VisibleContainer container) {
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index 5cd41f9..819e10d 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -28,6 +28,8 @@
import androidx.test.uiautomator.Direction;
import androidx.test.uiautomator.UiObject2;
+import com.android.launcher3.TestProtocol;
+
/**
* Operations on the workspace screen.
*/
@@ -162,7 +164,12 @@
}
@Override
- protected int getSwipeLength() {
- return 100;
+ protected String getSwipeHeightRequestName() {
+ return TestProtocol.REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT;
+ }
+
+ @Override
+ protected int getSwipeStartY() {
+ return mLauncher.waitForLauncherObject("hotseat").getVisibleBounds().top;
}
}
\ No newline at end of file