diff --git a/Android.bp b/Android.bp index c980a2e50f..3aa93946fd 100644 --- a/Android.bp +++ b/Android.bp @@ -31,7 +31,6 @@ android_library { "androidx.test.uiautomator_uiautomator", "androidx.preference_preference", "SystemUISharedLib", - "SystemUIAnimationLib", ], srcs: [ "tests/tapl/**/*.java", @@ -197,7 +196,6 @@ android_library { "lottie", "SystemUISharedLib", "SystemUI-statsd", - "SystemUIAnimationLib", ], manifest: "quickstep/AndroidManifest.xml", min_sdk_version: "current", @@ -210,6 +208,8 @@ filegroup { srcs: [ "ext_tests/src/**/*.java", "ext_tests/src/**/*.kt", + "quickstep/ext_tests/src/**/*.java", + "quickstep/ext_tests/src/**/*.kt", ], } @@ -289,7 +289,6 @@ android_library { "SystemUISharedLib", "Launcher3CommonDepsLib", "QuickstepResLib", - "SystemUIAnimationLib", ], manifest: "quickstep/AndroidManifest.xml", platform_apis: true, diff --git a/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java b/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java index 02206c0dc9..d16e12c9b8 100644 --- a/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java +++ b/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java @@ -29,8 +29,10 @@ import android.view.View; import androidx.annotation.Keep; import androidx.annotation.Nullable; +import com.android.launcher3.BubbleTextView; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherSettings; +import com.android.launcher3.ShortcutAndWidgetContainer; import java.util.ArrayList; import java.util.Collection; @@ -205,6 +207,32 @@ public class DebugTestInformationHandler extends TestInformationHandler { } } + case TestProtocol.REQUEST_USE_TEST_WORKSPACE_LAYOUT: { + useTestWorkspaceLayout(true); + return response; + } + + case TestProtocol.REQUEST_USE_DEFAULT_WORKSPACE_LAYOUT: { + useTestWorkspaceLayout(false); + return response; + } + + case TestProtocol.REQUEST_HOTSEAT_ICON_NAMES: { + return getLauncherUIProperty(Bundle::putStringArrayList, l -> { + ShortcutAndWidgetContainer hotseatIconsContainer = + l.getHotseat().getShortcutsAndWidgets(); + ArrayList hotseatIconNames = new ArrayList<>(); + + for (int i = 0; i < hotseatIconsContainer.getChildCount(); i++) { + // Use unchecked cast to catch changes in hotseat layout + BubbleTextView icon = (BubbleTextView) hotseatIconsContainer.getChildAt(i); + hotseatIconNames.add((String) icon.getText()); + } + + return hotseatIconNames; + }); + } + case TestProtocol.REQUEST_GET_ACTIVITIES_CREATED_COUNT: { response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, sActivitiesCreatedCount); return response; @@ -223,4 +251,15 @@ public class DebugTestInformationHandler extends TestInformationHandler { return super.call(method, arg, extras); } } + + private void useTestWorkspaceLayout(boolean useTestWorkspaceLayout) { + final long identity = Binder.clearCallingIdentity(); + try { + LauncherSettings.Settings.call(mContext.getContentResolver(), useTestWorkspaceLayout + ? LauncherSettings.Settings.METHOD_SET_USE_TEST_WORKSPACE_LAYOUT_FLAG + : LauncherSettings.Settings.METHOD_CLEAR_USE_TEST_WORKSPACE_LAYOUT_FLAG); + } finally { + Binder.restoreCallingIdentity(identity); + } + } } diff --git a/quickstep/ext_tests/src/com/android/quickstep/DebugQuickstepTestInformationHandler.java b/quickstep/ext_tests/src/com/android/quickstep/DebugQuickstepTestInformationHandler.java new file mode 100644 index 0000000000..e5f0295ff6 --- /dev/null +++ b/quickstep/ext_tests/src/com/android/quickstep/DebugQuickstepTestInformationHandler.java @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2022 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 static com.android.launcher3.util.Executors.MAIN_EXECUTOR; + +import android.content.Context; +import android.content.res.Resources; +import android.os.Bundle; + +import androidx.annotation.Nullable; + +import com.android.launcher3.BaseQuickstepLauncher; +import com.android.launcher3.Launcher; +import com.android.launcher3.R; +import com.android.launcher3.taskbar.LauncherTaskbarUIController; +import com.android.launcher3.testing.DebugTestInformationHandler; +import com.android.launcher3.testing.TestProtocol; + +import java.util.concurrent.ExecutionException; + +/** + * Class to handle requests from tests, including debug ones, to Quickstep Launcher builds. + */ +public abstract class DebugQuickstepTestInformationHandler extends QuickstepTestInformationHandler { + + private final DebugTestInformationHandler mDebugTestInformationHandler; + + public DebugQuickstepTestInformationHandler(Context context) { + super(context); + mDebugTestInformationHandler = new DebugTestInformationHandler(context); + } + + @Override + public Bundle call(String method, String arg, @Nullable Bundle extras) { + Bundle response = new Bundle(); + switch (method) { + case TestProtocol.REQUEST_ENABLE_MANUAL_TASKBAR_STASHING: + runOnUIThread(l -> { + enableManualTaskbarStashing(l, true); + }); + return response; + + case TestProtocol.REQUEST_DISABLE_MANUAL_TASKBAR_STASHING: + runOnUIThread(l -> { + enableManualTaskbarStashing(l, false); + }); + return response; + + case TestProtocol.REQUEST_UNSTASH_TASKBAR_IF_STASHED: + runOnUIThread(l -> { + enableManualTaskbarStashing(l, true); + + BaseQuickstepLauncher quickstepLauncher = (BaseQuickstepLauncher) l; + LauncherTaskbarUIController taskbarUIController = + quickstepLauncher.getTaskbarUIController(); + + // Allow null-pointer to catch illegal states. + taskbarUIController.unstashTaskbarIfStashed(); + + enableManualTaskbarStashing(l, false); + }); + return response; + + case TestProtocol.REQUEST_STASHED_TASKBAR_HEIGHT: { + final Resources resources = mContext.getResources(); + response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, + resources.getDimensionPixelSize(R.dimen.taskbar_stashed_size)); + return response; + } + + default: + response = super.call(method, arg, extras); + if (response != null) return response; + return mDebugTestInformationHandler.call(method, arg, extras); + } + } + + private void enableManualTaskbarStashing(Launcher launcher, boolean enable) { + BaseQuickstepLauncher quickstepLauncher = (BaseQuickstepLauncher) launcher; + LauncherTaskbarUIController taskbarUIController = + quickstepLauncher.getTaskbarUIController(); + + // Allow null-pointer to catch illegal states. + taskbarUIController.enableManualStashingForTests(enable); + } + + /** + * Runs the given command on the UI thread. + */ + private static void runOnUIThread(UIThreadCommand command) { + try { + MAIN_EXECUTOR.submit(() -> { + command.execute(Launcher.ACTIVITY_TRACKER.getCreatedActivity()); + return null; + }).get(); + } catch (ExecutionException | InterruptedException e) { + throw new RuntimeException(e); + } + } + + private interface UIThreadCommand { + + void execute(Launcher launcher); + } +} + diff --git a/quickstep/res/drawable-v28/gesture_tutorial_action_button_background.xml b/quickstep/res/drawable-v28/gesture_tutorial_action_button_background.xml index 57423c2ffc..710482f162 100644 --- a/quickstep/res/drawable-v28/gesture_tutorial_action_button_background.xml +++ b/quickstep/res/drawable-v28/gesture_tutorial_action_button_background.xml @@ -16,5 +16,5 @@ - + \ No newline at end of file diff --git a/quickstep/res/drawable/gesture_tutorial_action_button_background.xml b/quickstep/res/drawable/gesture_tutorial_action_button_background.xml index ac6a52a623..98dc1a5f78 100644 --- a/quickstep/res/drawable/gesture_tutorial_action_button_background.xml +++ b/quickstep/res/drawable/gesture_tutorial_action_button_background.xml @@ -25,7 +25,7 @@ - + \ No newline at end of file diff --git a/quickstep/res/drawable/gesture_tutorial_cancel_button_background.xml b/quickstep/res/drawable/gesture_tutorial_cancel_button_background.xml index 0a34af6475..77626154f8 100644 --- a/quickstep/res/drawable/gesture_tutorial_cancel_button_background.xml +++ b/quickstep/res/drawable/gesture_tutorial_cancel_button_background.xml @@ -17,5 +17,5 @@ android:shape="rectangle"> - + \ No newline at end of file diff --git a/quickstep/res/drawable/gesture_tutorial_finger_dot.xml b/quickstep/res/drawable/gesture_tutorial_finger_dot.xml index 5f8aafd30a..cbb26122db 100644 --- a/quickstep/res/drawable/gesture_tutorial_finger_dot.xml +++ b/quickstep/res/drawable/gesture_tutorial_finger_dot.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/quickstep/res/drawable/gesture_tutorial_loop_back.xml b/quickstep/res/drawable/gesture_tutorial_loop_back.xml index d2909fffc9..ae47709b22 100644 --- a/quickstep/res/drawable/gesture_tutorial_loop_back.xml +++ b/quickstep/res/drawable/gesture_tutorial_loop_back.xml @@ -85,7 +85,7 @@ diff --git a/quickstep/res/drawable/gesture_tutorial_loop_home.xml b/quickstep/res/drawable/gesture_tutorial_loop_home.xml index 931f8c0197..bed35dd0fa 100644 --- a/quickstep/res/drawable/gesture_tutorial_loop_home.xml +++ b/quickstep/res/drawable/gesture_tutorial_loop_home.xml @@ -81,7 +81,7 @@ diff --git a/quickstep/res/drawable/gesture_tutorial_loop_overview.xml b/quickstep/res/drawable/gesture_tutorial_loop_overview.xml index a4c532bdfa..53e8b5fec5 100644 --- a/quickstep/res/drawable/gesture_tutorial_loop_overview.xml +++ b/quickstep/res/drawable/gesture_tutorial_loop_overview.xml @@ -81,7 +81,7 @@ diff --git a/quickstep/res/values/colors.xml b/quickstep/res/values/colors.xml index 671a617f01..8f439a231c 100644 --- a/quickstep/res/values/colors.xml +++ b/quickstep/res/values/colors.xml @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - + #fff #39000000 @@ -41,8 +41,6 @@ #6DA1FF #3C4043 - #FF000000 - #B7F29F #202124 diff --git a/quickstep/res/values/styles.xml b/quickstep/res/values/styles.xml index 6aa488375b..7225220876 100644 --- a/quickstep/res/values/styles.xml +++ b/quickstep/res/values/styles.xml @@ -88,7 +88,8 @@ @@ -100,7 +101,7 @@