Moving TestInformationProvider to Launcher3 so that it can be used for
testing Launcher3 without quickstep
Also keeping the provider as disabled until needed
Change-Id: Ib5f459e02ae551724b390f3b74f43d601568d749
diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java
index bd6ac90..f69b172 100644
--- a/src/com/android/launcher3/BaseDraggingActivity.java
+++ b/src/com/android/launcher3/BaseDraggingActivity.java
@@ -34,6 +34,7 @@
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.model.AppLaunchTracker;
import com.android.launcher3.shortcuts.DeepShortcutManager;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.uioverrides.DisplayRotationListener;
import com.android.launcher3.uioverrides.WallpaperColorInfo;
import com.android.launcher3.util.Themes;
@@ -134,8 +135,8 @@
public boolean startActivitySafely(View v, Intent intent, @Nullable ItemInfo item,
@Nullable String sourceContainer) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_START_TAG,
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_START_TAG,
"startActivitySafely 1");
}
if (mIsSafeModeEnabled && !Utilities.isSystemApp(this, intent)) {
@@ -161,8 +162,8 @@
startShortcutIntentSafely(intent, optsBundle, item, sourceContainer);
} else if (user == null || user.equals(Process.myUserHandle())) {
// Could be launching some bookkeeping activity
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_START_TAG,
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_START_TAG,
"startActivitySafely 2");
}
startActivity(intent, optsBundle);
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 35113d2..7790475 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -110,6 +110,7 @@
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.states.InternalStateHandler;
import com.android.launcher3.states.RotationHelper;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.touch.ItemClickHandler;
import com.android.launcher3.uioverrides.UiFactory;
import com.android.launcher3.userevent.nano.LauncherLogProto;
@@ -1782,8 +1783,8 @@
public boolean startActivitySafely(View v, Intent intent, ItemInfo item,
@Nullable String sourceContainer) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_START_TAG,
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_START_TAG,
"startActivitySafely outer");
}
boolean success = super.startActivitySafely(v, intent, item, sourceContainer);
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index eff58a7..3a92dfb 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -18,13 +18,13 @@
import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_AUTO;
import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS;
import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
-import static com.android.launcher3.TestProtocol.ALL_APPS_STATE_ORDINAL;
-import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
-import static com.android.launcher3.TestProtocol.NORMAL_STATE_ORDINAL;
-import static com.android.launcher3.TestProtocol.OVERVIEW_PEEK_STATE_ORDINAL;
-import static com.android.launcher3.TestProtocol.OVERVIEW_STATE_ORDINAL;
-import static com.android.launcher3.TestProtocol.QUICK_SWITCH_STATE_ORDINAL;
-import static com.android.launcher3.TestProtocol.SPRING_LOADED_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.ALL_APPS_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.NORMAL_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.OVERVIEW_PEEK_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.OVERVIEW_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.QUICK_SWITCH_STATE_ORDINAL;
+import static com.android.launcher3.testing.TestProtocol.SPRING_LOADED_STATE_ORDINAL;
import static com.android.launcher3.anim.Interpolators.ACCEL_2;
import static com.android.launcher3.states.RotationHelper.REQUEST_NONE;
diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java
index 49ae338..3edd838 100644
--- a/src/com/android/launcher3/LauncherStateManager.java
+++ b/src/com/android/launcher3/LauncherStateManager.java
@@ -48,6 +48,7 @@
import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.anim.PropertySetter.AnimatedPropertySetter;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.uioverrides.UiFactory;
import java.io.PrintWriter;
@@ -447,8 +448,8 @@
}
private void onStateTransitionStart(LauncherState state) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_DRAG_TAG,
"onStateTransitionStart");
}
if (mState != state) {
@@ -576,8 +577,8 @@
private final AnimatorSet mAnim;
public StartAnimRunnable(AnimatorSet anim) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_DRAG_TAG,
"StartAnimRunnable");
}
mAnim = anim;
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index d19f9cd..f784226 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -20,8 +20,6 @@
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_TRANSITION_MS;
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
-import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT;
-import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.SPRING_LOADED;
@@ -86,6 +84,7 @@
import com.android.launcher3.pageindicators.WorkspacePageIndicator;
import com.android.launcher3.popup.PopupContainerWithArrow;
import com.android.launcher3.shortcuts.ShortcutDragPreviewProvider;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.touch.WorkspaceTouchListener;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
@@ -371,8 +370,8 @@
@Override
public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_DRAG_TAG,
"onDragStart 1");
}
if (ENFORCE_DRAG_EVENT_ORDER) {
@@ -425,8 +424,8 @@
}
// Always enter the spring loaded mode
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_DRAG_TAG,
"onDragStart 2");
}
mLauncher.getStateManager().goToState(SPRING_LOADED);
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 63682c7..d8094ea 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -43,7 +43,7 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
-import com.android.launcher3.TestProtocol;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.config.FeatureFlags;
diff --git a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
index 86f773f..8e59d32 100644
--- a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
+++ b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java
@@ -23,7 +23,7 @@
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
-import com.android.launcher3.TestProtocol;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.Utilities;
import java.util.function.Consumer;
diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java
index bf692fe..9d3c8f7 100644
--- a/src/com/android/launcher3/dragndrop/DragController.java
+++ b/src/com/android/launcher3/dragndrop/DragController.java
@@ -41,6 +41,7 @@
import com.android.launcher3.R;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.accessibility.DragViewStateAnnouncer;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.TouchController;
@@ -472,8 +473,8 @@
}
private void handleMoveEvent(int x, int y) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_DRAG_TAG,
"handleMoveEvent 1");
}
mDragObject.dragView.move(x, y);
@@ -492,8 +493,8 @@
if (mIsInPreDrag && mOptions.preDragCondition != null
&& mOptions.preDragCondition.shouldStartDrag(mDistanceSinceScroll)) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_DRAG_TAG,
"handleMoveEvent 2");
}
callOnDragStart();
@@ -533,8 +534,8 @@
* Call this from a drag source view.
*/
public boolean onControllerTouchEvent(MotionEvent ev) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_DRAG_TAG,
"onControllerTouchEvent");
}
if (mDragDriver == null || mOptions == null || mOptions.isAccessibleDrag) {
diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java
new file mode 100644
index 0000000..b8476aa
--- /dev/null
+++ b/src/com/android/launcher3/testing/TestInformationHandler.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.launcher3.testing;
+
+import android.content.Context;
+import android.os.Bundle;
+
+import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.InvariantDeviceProfile;
+import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherAppState;
+import com.android.launcher3.LauncherState;
+import com.android.launcher3.R;
+import com.android.launcher3.util.ResourceBasedOverride;
+
+public class TestInformationHandler implements ResourceBasedOverride {
+
+ public static TestInformationHandler newInstance(Context context) {
+ return Overrides.getObject(TestInformationHandler.class,
+ context, R.string.test_information_handler_class);
+ }
+
+ protected Context mContext;
+ protected DeviceProfile mDeviceProfile;
+ protected LauncherAppState mLauncherAppState;
+ protected Launcher mLauncher;
+
+ public void init(Context context) {
+ mContext = context;
+ mDeviceProfile = InvariantDeviceProfile.INSTANCE.
+ get(context).getDeviceProfile(context);
+ mLauncherAppState = LauncherAppState.getInstanceNoCreate();
+ mLauncher = mLauncherAppState != null ?
+ (Launcher) mLauncherAppState.getModel().getCallback() : null;
+ }
+
+ public Bundle call(String method) {
+ final Bundle response = new Bundle();
+ switch (method) {
+ case TestProtocol.REQUEST_ALL_APPS_TO_OVERVIEW_SWIPE_HEIGHT: {
+ if (mLauncher == null) return null;
+
+ final float progress = LauncherState.OVERVIEW.getVerticalProgress(mLauncher)
+ - LauncherState.ALL_APPS.getVerticalProgress(mLauncher);
+ final float distance = mLauncher.getAllAppsController().getShiftRange() * progress;
+ response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) distance);
+ break;
+ }
+
+ case TestProtocol.REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT: {
+ if (mLauncher == null) return null;
+
+ final float progress = LauncherState.NORMAL.getVerticalProgress(mLauncher)
+ - LauncherState.ALL_APPS.getVerticalProgress(mLauncher);
+ final float distance = mLauncher.getAllAppsController().getShiftRange() * progress;
+ response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) distance);
+ break;
+ }
+
+ case TestProtocol.REQUEST_ENABLE_DEBUG_TRACING:
+ TestProtocol.sDebugTracing = true;
+ break;
+
+ case TestProtocol.REQUEST_DISABLE_DEBUG_TRACING:
+ TestProtocol.sDebugTracing = false;
+ break;
+ }
+ return response;
+ }
+}
diff --git a/src/com/android/launcher3/testing/TestInformationProvider.java b/src/com/android/launcher3/testing/TestInformationProvider.java
new file mode 100644
index 0000000..bd177c0
--- /dev/null
+++ b/src/com/android/launcher3/testing/TestInformationProvider.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3.testing;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Bundle;
+
+import com.android.launcher3.Utilities;
+
+public class TestInformationProvider extends ContentProvider {
+ @Override
+ public boolean onCreate() {
+ return true;
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues contentValues, String s, String[] strings) {
+ return 0;
+ }
+
+ @Override
+ public int delete(Uri uri, String s, String[] strings) {
+ return 0;
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues contentValues) {
+ return null;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ return null;
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] strings, String s, String[] strings1, String s1) {
+ return null;
+ }
+
+ @Override
+ public Bundle call(String method, String arg, Bundle extras) {
+ if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
+ TestInformationHandler handler = TestInformationHandler.newInstance(getContext());
+ handler.init(getContext());
+ return handler.call(method);
+ }
+ return null;
+ }
+}
diff --git a/src/com/android/launcher3/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java
similarity index 98%
rename from src/com/android/launcher3/TestProtocol.java
rename to src/com/android/launcher3/testing/TestProtocol.java
index a0440e8..9fd44a1 100644
--- a/src/com/android/launcher3/TestProtocol.java
+++ b/src/com/android/launcher3/testing/TestProtocol.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher3;
+package com.android.launcher3.testing;
/**
* Protocol for custom accessibility events for communication with UI Automation tests.
diff --git a/src/com/android/launcher3/touch/ItemClickHandler.java b/src/com/android/launcher3/touch/ItemClickHandler.java
index 99b9f25..f858dc4 100644
--- a/src/com/android/launcher3/touch/ItemClickHandler.java
+++ b/src/com/android/launcher3/touch/ItemClickHandler.java
@@ -47,6 +47,7 @@
import com.android.launcher3.compat.AppWidgetManagerCompat;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderIcon;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.widget.PendingAppWidgetHostView;
import com.android.launcher3.widget.WidgetAddFlowHandler;
@@ -66,15 +67,15 @@
}
private static void onClick(View v, String sourceContainer) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_START_TAG,
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_START_TAG,
"onClick 1");
}
// Make sure that rogue clicks don't get through while allapps is launching, or after the
// view has detached (it's possible for this to happen if the view is removed mid touch).
if (v.getWindowToken() == null) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_START_TAG,
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_START_TAG,
"onClick 2");
}
return;
@@ -82,8 +83,8 @@
Launcher launcher = Launcher.getLauncher(v.getContext());
if (!launcher.getWorkspace().isFinishedSwitchingState()) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_START_TAG,
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_START_TAG,
"onClick 3");
}
return;
@@ -97,8 +98,8 @@
onClickFolderIcon(v);
}
} else if (tag instanceof AppInfo) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_START_TAG,
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_START_TAG,
"onClick 4");
}
startAppShortcutOrInfoActivity(v, (AppInfo) tag, launcher,
@@ -232,8 +233,8 @@
private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher,
@Nullable String sourceContainer) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_START_TAG,
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_START_TAG,
"startAppShortcutOrInfoActivity");
}
Intent intent;
diff --git a/src/com/android/launcher3/views/BaseDragLayer.java b/src/com/android/launcher3/views/BaseDragLayer.java
index 4964182..001951a 100644
--- a/src/com/android/launcher3/views/BaseDragLayer.java
+++ b/src/com/android/launcher3/views/BaseDragLayer.java
@@ -41,6 +41,7 @@
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.InsettableFrameLayout;
import com.android.launcher3.Utilities;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
import com.android.launcher3.util.TouchController;
@@ -213,8 +214,8 @@
@Override
public boolean onTouchEvent(MotionEvent ev) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_DRAG_TAG,
"onTouchEvent " + ev);
}
int action = ev.getAction();
@@ -226,8 +227,8 @@
}
if (mActiveController != null) {
- if (com.android.launcher3.TestProtocol.sDebugTracing) {
- android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ if (TestProtocol.sDebugTracing) {
+ android.util.Log.d(TestProtocol.NO_DRAG_TAG,
"onTouchEvent 1");
}
return mActiveController.onControllerTouchEvent(ev);