• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.quickstep.inputconsumers;
17 
18 import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_BACKGROUND;
19 import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME;
20 import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_GESTURE;
21 import static com.android.quickstep.OverviewComponentObserver.startHomeIntentSafely;
22 
23 import android.content.Context;
24 import android.graphics.PointF;
25 import android.view.MotionEvent;
26 
27 import com.android.launcher3.BaseActivity;
28 import com.android.launcher3.BaseDraggingActivity;
29 import com.android.launcher3.logger.LauncherAtom;
30 import com.android.launcher3.testing.TestLogging;
31 import com.android.launcher3.testing.shared.TestProtocol;
32 import com.android.quickstep.GestureState;
33 import com.android.quickstep.InputConsumer;
34 import com.android.quickstep.RecentsAnimationDeviceState;
35 import com.android.quickstep.util.TriggerSwipeUpTouchTracker;
36 import com.android.systemui.shared.system.InputMonitorCompat;
37 
38 public class OverviewWithoutFocusInputConsumer implements InputConsumer,
39         TriggerSwipeUpTouchTracker.OnSwipeUpListener {
40     private static final String TAG = "OverviewWithoutFocusInputConsumer";
41 
42     private final Context mContext;
43     private final InputMonitorCompat mInputMonitor;
44     private final TriggerSwipeUpTouchTracker mTriggerSwipeUpTracker;
45     private final GestureState mGestureState;
46 
OverviewWithoutFocusInputConsumer(Context context, RecentsAnimationDeviceState deviceState, GestureState gestureState, InputMonitorCompat inputMonitor, boolean disableHorizontalSwipe)47     public OverviewWithoutFocusInputConsumer(Context context,
48             RecentsAnimationDeviceState deviceState, GestureState gestureState,
49             InputMonitorCompat inputMonitor, boolean disableHorizontalSwipe) {
50         mContext = context;
51         mGestureState = gestureState;
52         mInputMonitor = inputMonitor;
53         mTriggerSwipeUpTracker = new TriggerSwipeUpTouchTracker(context, disableHorizontalSwipe,
54                 deviceState.getNavBarPosition(), this);
55     }
56 
57     @Override
getType()58     public int getType() {
59         return TYPE_OVERVIEW_WITHOUT_FOCUS;
60     }
61 
62     @Override
allowInterceptByParent()63     public boolean allowInterceptByParent() {
64         return !mTriggerSwipeUpTracker.interceptedTouch();
65     }
66 
67     @Override
onMotionEvent(MotionEvent ev)68     public void onMotionEvent(MotionEvent ev) {
69         mTriggerSwipeUpTracker.onMotionEvent(ev);
70     }
71 
72     @Override
onSwipeUpTouchIntercepted()73     public void onSwipeUpTouchIntercepted() {
74         if (mInputMonitor != null) {
75             TestLogging.recordEvent(TestProtocol.SEQUENCE_PILFER, "pilferPointers");
76             mInputMonitor.pilferPointers();
77         }
78     }
79 
80     @Override
onSwipeUp(boolean wasFling, PointF finalVelocity)81     public void onSwipeUp(boolean wasFling, PointF finalVelocity) {
82         startHomeIntentSafely(mContext, mGestureState.getHomeIntent(), null, TAG);
83         BaseActivity activity = BaseDraggingActivity.fromContext(mContext);
84         int state = (mGestureState != null && mGestureState.getEndTarget() != null)
85                 ? mGestureState.getEndTarget().containerType
86                 : LAUNCHER_STATE_HOME;
87         activity.getStatsLogManager().logger()
88                 .withSrcState(LAUNCHER_STATE_BACKGROUND)
89                 .withDstState(state)
90                 .withContainerInfo(LauncherAtom.ContainerInfo.newBuilder()
91                         .setWorkspace(
92                                 LauncherAtom.WorkspaceContainer.newBuilder()
93                                         .setPageIndex(-1))
94                         .build())
95                 .log(LAUNCHER_HOME_GESTURE);
96     }
97 }
98