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
This commit is contained in:
parent
571e51161c
commit
ab3963ddcf
|
@ -25,7 +25,7 @@ android_library {
|
|||
"tests/tapl/**/*.java",
|
||||
"src/com/android/launcher3/util/SecureSettingsObserver.java",
|
||||
"src/com/android/launcher3/ResourceUtils.java",
|
||||
"src/com/android/launcher3/TestProtocol.java",
|
||||
"src/com/android/launcher3/testing/TestProtocol.java",
|
||||
],
|
||||
manifest: "tests/tapl/AndroidManifest.xml",
|
||||
platform_apis: true,
|
||||
|
|
|
@ -176,5 +176,12 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<provider
|
||||
android:name="com.android.launcher3.testing.TestInformationProvider"
|
||||
android:authorities="${packageName}.TestInfo"
|
||||
android:readPermission="android.permission.WRITE_SECURE_SETTINGS"
|
||||
android:writePermission="android.permission.WRITE_SECURE_SETTINGS"
|
||||
android:exported="true"
|
||||
android:enabled="false" />
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
|
@ -73,14 +73,6 @@
|
|||
</intent-filter>
|
||||
</provider>
|
||||
|
||||
<provider
|
||||
android:name="com.android.quickstep.TestInformationProvider"
|
||||
android:authorities="${packageName}.TestInfo"
|
||||
android:readPermission="android.permission.WRITE_SECURE_SETTINGS"
|
||||
android:writePermission="android.permission.WRITE_SECURE_SETTINGS"
|
||||
android:exported="true">
|
||||
</provider>
|
||||
|
||||
<service
|
||||
android:name="com.android.launcher3.uioverrides.dynamicui.WallpaperManagerCompatVL$ColorExtractionService"
|
||||
tools:node="remove" />
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
<string name="stats_log_manager_class" translatable="false">com.android.quickstep.logging.StatsLogCompatManager</string>
|
||||
|
||||
<string name="test_information_handler_class" translatable="false">com.android.quickstep.QuickstepTestInformationHandler</string>
|
||||
|
||||
<!-- The number of thumbnails and icons to keep in the cache. The thumbnail cache size also
|
||||
determines how many thumbnails will be fetched in the background. -->
|
||||
<integer name="recentsThumbnailCacheSize">3</integer>
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package com.android.quickstep;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.launcher3.testing.TestInformationHandler;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.uioverrides.states.OverviewState;
|
||||
import com.android.quickstep.util.LayoutUtils;
|
||||
|
||||
public class QuickstepTestInformationHandler extends TestInformationHandler {
|
||||
|
||||
public QuickstepTestInformationHandler(Context context) { }
|
||||
|
||||
@Override
|
||||
public Bundle call(String method) {
|
||||
final Bundle response = new Bundle();
|
||||
switch (method) {
|
||||
case TestProtocol.REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT: {
|
||||
final float swipeHeight =
|
||||
OverviewState.getDefaultSwipeHeight(mDeviceProfile);
|
||||
response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
|
||||
return response;
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT: {
|
||||
final float swipeHeight =
|
||||
LayoutUtils.getShelfTrackingDistance(mContext, mDeviceProfile);
|
||||
response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
return super.call(method);
|
||||
}
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
/*
|
||||
* 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.quickstep;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
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.TestProtocol;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.uioverrides.states.OverviewState;
|
||||
import com.android.quickstep.util.LayoutUtils;
|
||||
|
||||
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) {
|
||||
final Bundle response = new Bundle();
|
||||
final Context context = getContext();
|
||||
final DeviceProfile deviceProfile = InvariantDeviceProfile.INSTANCE.
|
||||
get(context).getDeviceProfile(context);
|
||||
final LauncherAppState launcherAppState = LauncherAppState.getInstanceNoCreate();
|
||||
final Launcher launcher = launcherAppState != null ?
|
||||
(Launcher) launcherAppState.getModel().getCallback() : null;
|
||||
|
||||
switch (method) {
|
||||
case TestProtocol.REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT: {
|
||||
final float swipeHeight =
|
||||
OverviewState.getDefaultSwipeHeight(deviceProfile);
|
||||
response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
|
||||
break;
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT: {
|
||||
final float swipeHeight =
|
||||
LayoutUtils.getShelfTrackingDistance(context, deviceProfile);
|
||||
response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
|
||||
break;
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_ALL_APPS_TO_OVERVIEW_SWIPE_HEIGHT: {
|
||||
if (launcher == null) return null;
|
||||
|
||||
final float progress = LauncherState.OVERVIEW.getVerticalProgress(launcher)
|
||||
- LauncherState.ALL_APPS.getVerticalProgress(launcher);
|
||||
final float distance =
|
||||
launcher.getAllAppsController().getShiftRange() * progress;
|
||||
response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) distance);
|
||||
break;
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT: {
|
||||
if (launcher == null) return null;
|
||||
|
||||
final float progress = LauncherState.NORMAL.getVerticalProgress(launcher)
|
||||
- LauncherState.ALL_APPS.getVerticalProgress(launcher);
|
||||
final float distance =
|
||||
launcher.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;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -71,6 +71,7 @@
|
|||
<string name="main_process_initializer_class" translatable="false"></string>
|
||||
<string name="system_shortcut_factory_class" translatable="false"></string>
|
||||
<string name="app_launch_tracker_class" translatable="false"></string>
|
||||
<string name="test_information_handler_class" translatable="false"></string>
|
||||
|
||||
<!-- Package name of the default wallpaper picker. -->
|
||||
<string name="wallpaper_picker_package" translatable="false"></string>
|
||||
|
|
|
@ -34,6 +34,7 @@ import com.android.launcher3.LauncherSettings.Favorites;
|
|||
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 abstract class BaseDraggingActivity extends BaseActivity
|
|||
|
||||
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 @@ public abstract class BaseDraggingActivity extends BaseActivity
|
|||
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);
|
||||
|
|
|
@ -110,6 +110,7 @@ import com.android.launcher3.popup.PopupDataProvider;
|
|||
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 class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
|||
|
||||
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);
|
||||
|
|
|
@ -18,13 +18,13 @@ package com.android.launcher3;
|
|||
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;
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ import com.android.launcher3.anim.AnimatorPlaybackController;
|
|||
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 @@ public class LauncherStateManager {
|
|||
}
|
||||
|
||||
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 @@ public class LauncherStateManager {
|
|||
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;
|
||||
|
|
|
@ -20,8 +20,6 @@ import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
|
|||
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.graphics.RotationMode;
|
|||
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 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
|||
|
||||
@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 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
|||
}
|
||||
|
||||
// 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);
|
||||
|
|
|
@ -43,7 +43,7 @@ import com.android.launcher3.ItemInfo;
|
|||
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;
|
||||
|
|
|
@ -23,7 +23,7 @@ import android.view.accessibility.AccessibilityEvent;
|
|||
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;
|
||||
|
|
|
@ -41,6 +41,7 @@ import com.android.launcher3.Launcher;
|
|||
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 @@ public class DragController implements DragDriver.EventListener, TouchController
|
|||
}
|
||||
|
||||
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 @@ public class DragController implements DragDriver.EventListener, TouchController
|
|||
|
||||
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 @@ public class DragController implements DragDriver.EventListener, TouchController
|
|||
* 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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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.
|
|
@ -47,6 +47,7 @@ import com.android.launcher3.WorkspaceItemInfo;
|
|||
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 @@ public class ItemClickHandler {
|
|||
}
|
||||
|
||||
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 @@ public class ItemClickHandler {
|
|||
|
||||
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 @@ public class ItemClickHandler {
|
|||
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 @@ public class ItemClickHandler {
|
|||
|
||||
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;
|
||||
|
|
|
@ -41,6 +41,7 @@ import android.widget.FrameLayout;
|
|||
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 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext>
|
|||
|
||||
@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 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext>
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -32,7 +32,7 @@ else
|
|||
LOCAL_SRC_FILES := $(call all-java-files-under, tapl) \
|
||||
../src/com/android/launcher3/ResourceUtils.java \
|
||||
../src/com/android/launcher3/util/SecureSettingsObserver.java \
|
||||
../src/com/android/launcher3/TestProtocol.java
|
||||
../src/com/android/launcher3/testing/TestProtocol.java
|
||||
endif
|
||||
|
||||
LOCAL_MODULE := ub-launcher-aosp-tapl
|
||||
|
|
|
@ -27,7 +27,7 @@ import androidx.test.uiautomator.Direction;
|
|||
import androidx.test.uiautomator.UiObject2;
|
||||
|
||||
import com.android.launcher3.ResourceUtils;
|
||||
import com.android.launcher3.TestProtocol;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
|
||||
/**
|
||||
* Operations on AllApps opened from Home. Also a parent for All Apps opened from Overview.
|
||||
|
|
|
@ -16,14 +16,14 @@
|
|||
|
||||
package com.android.launcher3.tapl;
|
||||
|
||||
import static com.android.launcher3.TestProtocol.OVERVIEW_STATE_ORDINAL;
|
||||
import static com.android.launcher3.testing.TestProtocol.OVERVIEW_STATE_ORDINAL;
|
||||
|
||||
import android.graphics.Point;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.test.uiautomator.UiObject2;
|
||||
|
||||
import com.android.launcher3.TestProtocol;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
|
||||
/**
|
||||
* Operations on AllApps opened from Overview.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package com.android.launcher3.tapl;
|
||||
|
||||
import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
|
||||
import static com.android.launcher3.testing.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.os.SystemClock;
|
||||
|
@ -24,7 +24,7 @@ import android.view.MotionEvent;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.launcher3.TestProtocol;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
|
||||
/**
|
||||
* Indicates the base state with a UI other than Overview running as foreground. It can also
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package com.android.launcher3.tapl;
|
||||
|
||||
import static com.android.launcher3.TestProtocol.OVERVIEW_STATE_ORDINAL;
|
||||
import static com.android.launcher3.testing.TestProtocol.OVERVIEW_STATE_ORDINAL;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import androidx.test.uiautomator.UiDevice;
|
|||
import androidx.test.uiautomator.UiObject2;
|
||||
import androidx.test.uiautomator.Until;
|
||||
|
||||
import com.android.launcher3.TestProtocol;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
|
||||
/**
|
||||
* Ancestor for AppIcon and AppMenuItem.
|
||||
|
|
|
@ -16,16 +16,23 @@
|
|||
|
||||
package com.android.launcher3.tapl;
|
||||
|
||||
import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
|
||||
import static com.android.launcher3.TestProtocol.NORMAL_STATE_ORDINAL;
|
||||
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
|
||||
import static android.content.pm.PackageManager.DONT_KILL_APP;
|
||||
import static android.content.pm.PackageManager.MATCH_ALL;
|
||||
import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS;
|
||||
|
||||
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.tapl.TestHelpers.getOverviewPackageName;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Instrumentation;
|
||||
import android.app.UiAutomation;
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ProviderInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
|
@ -53,7 +60,7 @@ import androidx.test.uiautomator.UiDevice;
|
|||
import androidx.test.uiautomator.UiObject2;
|
||||
import androidx.test.uiautomator.Until;
|
||||
|
||||
import com.android.launcher3.TestProtocol;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.systemui.shared.system.QuickStepContract;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
@ -149,9 +156,10 @@ public final class LauncherInstrumentation {
|
|||
getLauncherPackageName() :
|
||||
targetPackage;
|
||||
|
||||
String testProviderAuthority = authorityPackage + ".TestInfo";
|
||||
mTestProviderUri = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(authorityPackage + ".TestInfo")
|
||||
.authority(testProviderAuthority)
|
||||
.build();
|
||||
|
||||
try {
|
||||
|
@ -160,6 +168,25 @@ public final class LauncherInstrumentation {
|
|||
} catch (IOException e) {
|
||||
fail(e.toString());
|
||||
}
|
||||
|
||||
|
||||
PackageManager pm = getContext().getPackageManager();
|
||||
ProviderInfo pi = pm.resolveContentProvider(
|
||||
testProviderAuthority, MATCH_ALL | MATCH_DISABLED_COMPONENTS);
|
||||
ComponentName cn = new ComponentName(pi.packageName, pi.name);
|
||||
|
||||
if (pm.getComponentEnabledSetting(cn) != COMPONENT_ENABLED_STATE_ENABLED) {
|
||||
if (TestHelpers.isInLauncherProcess()) {
|
||||
getContext().getPackageManager().setComponentEnabledSetting(
|
||||
cn, COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP);
|
||||
} else {
|
||||
try {
|
||||
mDevice.executeShellCommand("pm enable " + cn.flattenToString());
|
||||
} catch (IOException e) {
|
||||
fail(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context getContext() {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package com.android.launcher3.tapl;
|
||||
|
||||
import static com.android.launcher3.TestProtocol.ALL_APPS_STATE_ORDINAL;
|
||||
import static com.android.launcher3.testing.TestProtocol.ALL_APPS_STATE_ORDINAL;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.test.uiautomator.UiObject2;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package com.android.launcher3.tapl;
|
||||
|
||||
import static com.android.launcher3.TestProtocol.ALL_APPS_STATE_ORDINAL;
|
||||
import static com.android.launcher3.testing.TestProtocol.ALL_APPS_STATE_ORDINAL;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
|
||||
|
@ -30,7 +30,7 @@ import androidx.annotation.Nullable;
|
|||
import androidx.test.uiautomator.Direction;
|
||||
import androidx.test.uiautomator.UiObject2;
|
||||
|
||||
import com.android.launcher3.TestProtocol;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
|
||||
/**
|
||||
* Operations on the workspace screen.
|
||||
|
|
Loading…
Reference in New Issue