OSDN Git Service

Add onAssistantGestureCompletion to SystemUiProxy
authorMiranda Kephart <mkephart@google.com>
Fri, 17 May 2019 17:55:37 +0000 (13:55 -0400)
committerMiranda Kephart <mkephart@google.com>
Mon, 20 May 2019 14:53:15 +0000 (10:53 -0400)
Allows passing the incoming velocity for gestures. This lets
SystemUI react differently to flings vs drags.

Bug: 132356358
Test: manual
Change-Id: I91df5801eb3399c94320307ccdbeca7763075984

packages/SystemUI/shared/src/com/android/systemui/shared/recents/ISystemUiProxy.aidl
packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java

index b826b30..77bb514 100644 (file)
@@ -73,6 +73,12 @@ interface ISystemUiProxy {
     void onAssistantProgress(float progress) = 12;
 
     /**
+    * Proxies the assistant gesture fling velocity (in pixels per millisecond) upon completion.
+    * Velocity is 0 for drag gestures.
+    */
+    void onAssistantGestureCompletion(float velocity) = 18;
+
+    /**
      * Start the assistant.
      */
     void startAssistant(in Bundle bundle) = 13;
index a3b2c95..51bd9f8 100644 (file)
@@ -203,6 +203,14 @@ public class AssistManager implements ConfigurationChangedReceiver {
         // intentional no-op, vendor's AssistManager implementation should override if needed.
     }
 
+    /** Called when the user has invoked the assistant with the incoming velocity, in pixels per
+     * millisecond. For invocations without a velocity (e.g. slow drag), the velocity is set to
+     * zero.
+     */
+    public void onAssistantGestureCompletion(float velocity) {
+        // intentional no-op, vendor's AssistManager implementation should override if needed.
+    }
+
     public void hideAssist() {
         mAssistUtils.hideCurrentSession();
     }
index 51d259b..738f893 100644 (file)
@@ -271,6 +271,19 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
         }
 
         @Override
+        public void onAssistantGestureCompletion(float velocity) {
+            if (!verifyCaller("onAssistantGestureCompletion")) {
+                return;
+            }
+            long token = Binder.clearCallingIdentity();
+            try {
+                mHandler.post(() -> notifyAssistantGestureCompletion(velocity));
+            } finally {
+                Binder.restoreCallingIdentity(token);
+            }
+        }
+
+        @Override
         public void startAssistant(Bundle bundle) {
             if (!verifyCaller("startAssistant")) {
                 return;
@@ -684,6 +697,12 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
         }
     }
 
+    private void notifyAssistantGestureCompletion(float velocity) {
+        for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) {
+            mConnectionCallbacks.get(i).onAssistantGestureCompletion(velocity);
+        }
+    }
+
     private void notifyStartAssistant(Bundle bundle) {
         for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) {
             mConnectionCallbacks.get(i).startAssistant(bundle);
@@ -732,6 +751,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
         default void onQuickScrubStarted() {}
         default void onBackButtonAlphaChanged(float alpha, boolean animate) {}
         default void onAssistantProgress(@FloatRange(from = 0.0, to = 1.0) float progress) {}
+        default void onAssistantGestureCompletion(float velocity) {}
         default void startAssistant(Bundle bundle) {}
     }
 }