Removing code duplication for getting swipe-up setting
This is between Tapl and Launcher
Bug: 110103162
Test: TaplTests suite
Change-Id: I5b458438834204ca257f45c707577b4d2793fb4e
diff --git a/tests/Android.mk b/tests/Android.mk
index c8e554d..c7a222a 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -37,7 +37,8 @@
include $(CLEAR_VARS)
LOCAL_STATIC_JAVA_LIBRARIES := android-support-test ub-uiautomator
-LOCAL_SRC_FILES := $(call all-java-files-under, tapl)
+LOCAL_SRC_FILES := $(call all-java-files-under, tapl) \
+ ../quickstep/src/com/android/quickstep/SwipeUpSetting.java
LOCAL_SDK_VERSION := current
LOCAL_MODULE := ub-launcher-aosp-tapl
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 19fa391..c3f27ee 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -22,7 +22,6 @@
import android.app.ActivityManager;
import android.app.UiAutomation;
-import android.content.res.Resources;
import android.os.Bundle;
import android.provider.Settings;
import android.support.annotation.NonNull;
@@ -35,6 +34,8 @@
import android.support.test.uiautomator.Until;
import android.view.accessibility.AccessibilityEvent;
+import com.android.quickstep.SwipeUpSetting;
+
import java.lang.ref.WeakReference;
import java.util.concurrent.TimeoutException;
@@ -78,10 +79,6 @@
private static final String WIDGETS_RES_ID = "widgets_list_view";
static final String LAUNCHER_PKG = "com.google.android.apps.nexuslauncher";
static final int WAIT_TIME_MS = 60000;
- private static final String SWIPE_UP_SETTING_AVAILABLE_RES_NAME =
- "config_swipe_up_gesture_setting_available";
- private static final String SWIPE_UP_ENABLED_DEFAULT_RES_NAME =
- "config_swipe_up_gesture_default";
private static final String SYSTEMUI_PACKAGE = "com.android.systemui";
private static WeakReference<VisibleContainer> sActiveContainer = new WeakReference<>(null);
@@ -95,8 +92,8 @@
public LauncherInstrumentation(UiDevice device) {
mDevice = device;
final boolean swipeUpEnabledDefault =
- !getSystemBooleanRes(SWIPE_UP_SETTING_AVAILABLE_RES_NAME) ||
- getSystemBooleanRes(SWIPE_UP_ENABLED_DEFAULT_RES_NAME);
+ !SwipeUpSetting.isSwipeUpSettingAvailable() ||
+ SwipeUpSetting.isSwipeUpEnabledDefaultValue();
mSwipeUpEnabled = Settings.Secure.getInt(
InstrumentationRegistry.getTargetContext().getContentResolver(),
"swipe_up_to_switch_apps_enabled",
@@ -104,13 +101,6 @@
assertTrue("Device must run in a test harness", ActivityManager.isRunningInTestHarness());
}
- private boolean getSystemBooleanRes(String resName) {
- final Resources res = Resources.getSystem();
- final int resId = res.getIdentifier(resName, "bool", "android");
- assertTrue("Resource not found: " + resName, resId != 0);
- return res.getBoolean(resId);
- }
-
void setActiveContainer(VisibleContainer container) {
sActiveContainer = new WeakReference<>(container);
}