• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.android.quickstep;
2 
3 import android.app.Activity;
4 import android.content.Context;
5 import android.os.Bundle;
6 
7 import com.android.launcher3.LauncherState;
8 import com.android.launcher3.config.FeatureFlags;
9 import com.android.launcher3.testing.TestInformationHandler;
10 import com.android.launcher3.testing.TestProtocol;
11 import com.android.launcher3.touch.PagedOrientationHandler;
12 import com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController;
13 import com.android.quickstep.util.LayoutUtils;
14 
15 public class QuickstepTestInformationHandler extends TestInformationHandler {
16 
17     protected final Context mContext;
18 
QuickstepTestInformationHandler(Context context)19     public QuickstepTestInformationHandler(Context context) {
20         mContext = context;
21     }
22 
23     @Override
call(String method)24     public Bundle call(String method) {
25         final Bundle response = new Bundle();
26         switch (method) {
27             case TestProtocol.REQUEST_ALL_APPS_TO_OVERVIEW_SWIPE_HEIGHT: {
28                 return getLauncherUIProperty(Bundle::putInt, l -> {
29                     final float progress = LauncherState.OVERVIEW.getVerticalProgress(l)
30                             - LauncherState.ALL_APPS.getVerticalProgress(l);
31                     final float distance = l.getAllAppsController().getShiftRange() * progress;
32                     return (int) distance;
33                 });
34             }
35 
36             case TestProtocol.REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT: {
37                 final float swipeHeight =
38                         LayoutUtils.getDefaultSwipeHeight(mContext, mDeviceProfile);
39                 response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
40                 return response;
41             }
42 
43             case TestProtocol.REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT: {
44                 final float swipeHeight =
45                         LayoutUtils.getShelfTrackingDistance(mContext, mDeviceProfile,
46                                 PagedOrientationHandler.PORTRAIT);
47                 response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
48                 return response;
49             }
50 
51             case TestProtocol.REQUEST_HOTSEAT_TOP: {
52                 return getLauncherUIProperty(
53                         Bundle::putInt, PortraitStatesTouchController::getHotseatTop);
54             }
55 
56             case TestProtocol.REQUEST_OVERVIEW_ACTIONS_ENABLED: {
57                 response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD,
58                         FeatureFlags.ENABLE_OVERVIEW_ACTIONS.get());
59                 return response;
60             }
61 
62             case TestProtocol.REQUEST_OVERVIEW_SHARE_ENABLED: {
63                 response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD,
64                         FeatureFlags.ENABLE_OVERVIEW_SHARE.get());
65                 return response;
66             }
67         }
68 
69         return super.call(method);
70     }
71 
72     @Override
getCurrentActivity()73     protected Activity getCurrentActivity() {
74         RecentsAnimationDeviceState rads = new RecentsAnimationDeviceState(mContext);
75         OverviewComponentObserver observer = new OverviewComponentObserver(mContext, rads);
76         try {
77             return observer.getActivityInterface().getCreatedActivity();
78         } finally {
79             observer.onDestroy();
80             rads.destroy();
81         }
82     }
83 
84     @Override
isLauncherInitialized()85     protected boolean isLauncherInitialized() {
86         return super.isLauncherInitialized() && TouchInteractionService.isInitialized();
87     }
88 }
89