summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVadim Tryshev <vadimt@google.com>2018-07-25 16:29:06 -0700
committerVadim Tryshev <vadimt@google.com>2018-08-02 14:15:05 -0700
commitff3fa34a7ab5feb0bbe11893022a832be73536d5 (patch)
tree4ef7e91e914194cf9e1a19dc27b945c871473a28 /src
parent899c08aee8dba224ac12b5dce27ec1635f4ad07e (diff)
downloadandroid_packages_apps_Trebuchet-ff3fa34a7ab5feb0bbe11893022a832be73536d5.tar.gz
android_packages_apps_Trebuchet-ff3fa34a7ab5feb0bbe11893022a832be73536d5.tar.bz2
android_packages_apps_Trebuchet-ff3fa34a7ab5feb0bbe11893022a832be73536d5.zip
Fixing scrolling up in App Apps.
Done by scrolling only when scroll position is not zero. This way, the scroll gesture can't close All Apps. Bug: 110103162 Test: TaplTests suite Change-Id: Icfe47d2bcc0210ae221df169d6c35cd1be10ff86
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/Utilities.java4
-rw-r--r--src/com/android/launcher3/allapps/AllAppsContainerView.java14
-rw-r--r--src/com/android/launcher3/compat/AccessibilityManagerCompat.java59
3 files changed, 70 insertions, 7 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 7c5bb1af8..a8513185e 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -602,4 +602,8 @@ public final class Utilities {
msg.setAsynchronous(true);
handler.sendMessage(msg);
}
+
+ public interface Consumer<T> {
+ void accept(T var1);
+ }
}
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index fdf32af6d..40cf0f3d0 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -21,6 +21,7 @@ import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
+import android.os.Bundle;
import android.os.Process;
import android.support.animation.DynamicAnimation;
import android.support.annotation.NonNull;
@@ -48,6 +49,7 @@ import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
+import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.keyboard.FocusedItemDecorator;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
@@ -549,4 +551,16 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
&& verticalFadingEdge);
}
}
+
+ @Override
+ public boolean performAccessibilityAction(int action, Bundle arguments) {
+ if (AccessibilityManagerCompat.processTestRequest(
+ mLauncher, "TAPL_GET_SCROLL", action, arguments,
+ response ->
+ response.putInt("scrollY", getActiveRecyclerView().getCurrentScrollY()))) {
+ return true;
+ }
+
+ return super.performAccessibilityAction(action, arguments);
+ }
}
diff --git a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
index 29fc2bc60..32fb5332c 100644
--- a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
+++ b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
@@ -18,9 +18,11 @@ package com.android.launcher3.compat;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.Context;
+import android.os.Bundle;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
+import android.view.accessibility.AccessibilityNodeInfo;
import com.android.launcher3.Utilities;
@@ -49,17 +51,60 @@ public class AccessibilityManagerCompat {
}
public static void sendEventToTest(Context context, String eventTag) {
- if (!Utilities.IS_RUNNING_IN_TEST_HARNESS) return;
+ final AccessibilityManager accessibilityManager = getAccessibilityManagerForTest(context);
+ if (accessibilityManager == null) return;
+ sendEventToTest(accessibilityManager, eventTag, null);
+ }
+
+ private static void sendEventToTest(
+ AccessibilityManager accessibilityManager, String eventTag, Bundle data) {
+ final AccessibilityEvent e = AccessibilityEvent.obtain(
+ AccessibilityEvent.TYPE_ANNOUNCEMENT);
+ e.setClassName(eventTag);
+ e.setParcelableData(data);
+ accessibilityManager.sendAccessibilityEvent(e);
+ }
+
+ /**
+ * Returns accessibility manager to be used for communication with UI Automation tests.
+ * The tests may exchange custom accessibility messages with the launcher; the accessibility
+ * manager is used in these communications.
+ *
+ * If the launcher runs not under a test, the return is null, and no attempt to process or send
+ * custom accessibility messages should be made.
+ */
+ private static AccessibilityManager getAccessibilityManagerForTest(Context context) {
+ // If not running in a test harness, don't participate in test exchanges.
+ if (!Utilities.IS_RUNNING_IN_TEST_HARNESS) return null;
+
+ // Additional safety check: when running under UI Automation, accessibility is enabled,
+ // but the list of accessibility services is empty. Return null if this is not the case.
final AccessibilityManager accessibilityManager = getManager(context);
- if (accessibilityManager.isEnabled() &&
+ if (!accessibilityManager.isEnabled() ||
accessibilityManager.getEnabledAccessibilityServiceList(
- AccessibilityServiceInfo.FEEDBACK_ALL_MASK).size() == 0) {
+ AccessibilityServiceInfo.FEEDBACK_ALL_MASK).size() > 0) {
+ return null;
+ }
+
+ return accessibilityManager;
+ }
+
+ public static boolean processTestRequest(Context context, String eventTag, int action,
+ Bundle request, Utilities.Consumer<Bundle> responseFiller) {
+ final AccessibilityManager accessibilityManager = getAccessibilityManagerForTest(context);
+ if (accessibilityManager == null) return false;
- final AccessibilityEvent e = AccessibilityEvent.obtain(
- AccessibilityEvent.TYPE_ANNOUNCEMENT);
- e.setClassName(eventTag);
- accessibilityManager.sendAccessibilityEvent(e);
+ // The test sends a request via a ACTION_SET_TEXT.
+ if (action == AccessibilityNodeInfo.ACTION_SET_TEXT &&
+ eventTag.equals(request.getCharSequence(
+ AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE))) {
+ final Bundle response = new Bundle();
+ responseFiller.accept(response);
+ AccessibilityManagerCompat.sendEventToTest(
+ accessibilityManager, eventTag + "_RESPONSE", response);
+ return true;
}
+ return false;
}
}