Loading quickstep/ext_tests/src/com/android/quickstep/DebugQuickstepTestInformationHandler.java +7 −82 Original line number Diff line number Diff line Loading @@ -15,24 +15,13 @@ */ 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.Launcher; import com.android.launcher3.R; import com.android.launcher3.testing.DebugTestInformationHandler; import com.android.launcher3.testing.shared.TestProtocol; import com.android.quickstep.TouchInteractionService.TISBinder; import com.android.quickstep.util.TISBindHelper; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.function.Consumer; /** * Class to handle requests from tests, including debug ones, to Quickstep Launcher builds. Loading @@ -49,78 +38,14 @@ public abstract class DebugQuickstepTestInformationHandler extends QuickstepTest @Override public Bundle call(String method, String arg, @Nullable Bundle extras) { Bundle response = new Bundle(); switch (method) { case TestProtocol.REQUEST_ENABLE_MANUAL_TASKBAR_STASHING: runOnTISBinder(tisBinder -> { enableManualTaskbarStashing(tisBinder, true); }); return response; case TestProtocol.REQUEST_DISABLE_MANUAL_TASKBAR_STASHING: runOnTISBinder(tisBinder -> { enableManualTaskbarStashing(tisBinder, false); }); return response; case TestProtocol.REQUEST_UNSTASH_TASKBAR_IF_STASHED: runOnTISBinder(tisBinder -> { enableManualTaskbarStashing(tisBinder, true); // Allow null-pointer to catch illegal states. tisBinder.getTaskbarManager().getCurrentActivityContext() .unstashTaskbarIfStashed(); enableManualTaskbarStashing(tisBinder, 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; } case TestProtocol.REQUEST_RECREATE_TASKBAR: if (TestProtocol.REQUEST_RECREATE_TASKBAR.equals(method)) { // Allow null-pointer to catch illegal states. runOnTISBinder(tisBinder -> tisBinder.getTaskbarManager().recreateTaskbar()); return response; default: } response = super.call(method, arg, extras); if (response != null) return response; return mDebugTestInformationHandler.call(method, arg, extras); } } private void enableManualTaskbarStashing(TISBinder tisBinder, boolean enable) { // Allow null-pointer to catch illegal states. tisBinder.getTaskbarManager().getCurrentActivityContext().enableManualStashingForTests( enable); } /** * Runs the given command on the UI thread, after ensuring we are connected to * TouchInteractionService. */ private void runOnTISBinder(Consumer<TISBinder> connectionCallback) { try { CountDownLatch countDownLatch = new CountDownLatch(1); TISBindHelper helper = MAIN_EXECUTOR.submit(() -> new TISBindHelper(mContext, tisBinder -> { connectionCallback.accept(tisBinder); countDownLatch.countDown(); })).get(); countDownLatch.await(); MAIN_EXECUTOR.submit(helper::onDestroy); } catch (ExecutionException | InterruptedException e) { throw new RuntimeException(e); } } private interface UIThreadCommand { void execute(Launcher launcher); } } quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +2 −2 Original line number Diff line number Diff line Loading @@ -778,8 +778,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext { * stash/unstash the taskbar. */ @VisibleForTesting public void enableManualStashingForTests(boolean enableManualStashing) { mControllers.taskbarStashController.enableManualStashingForTests(enableManualStashing); public void enableManualStashingDuringTests(boolean enableManualStashing) { mControllers.taskbarStashController.enableManualStashingDuringTests(enableManualStashing); } /** Loading quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java +4 −4 Original line number Diff line number Diff line Loading @@ -160,7 +160,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba private boolean mIsImeShowing; private boolean mIsImeSwitcherShowing; private boolean mEnableManualStashingForTests = false; private boolean mEnableManualStashingDuringTests = false; // Evaluate whether the handle should be stashed private final StatePropertyHolder mStatePropertyHolder = new StatePropertyHolder( Loading Loading @@ -240,15 +240,15 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba */ protected boolean supportsManualStashing() { return supportsVisualStashing() && (!Utilities.IS_RUNNING_IN_TEST_HARNESS || mEnableManualStashingForTests); && (!Utilities.IS_RUNNING_IN_TEST_HARNESS || mEnableManualStashingDuringTests); } /** * Enables support for manual stashing. This should only be used to add this functionality * to Launcher specific tests. */ public void enableManualStashingForTests(boolean enableManualStashing) { mEnableManualStashingForTests = enableManualStashing; public void enableManualStashingDuringTests(boolean enableManualStashing) { mEnableManualStashingDuringTests = enableManualStashing; } /** Loading quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java +66 −0 Original line number Diff line number Diff line package com.android.quickstep; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import android.app.Activity; import android.content.Context; import android.content.res.Resources; import android.graphics.Rect; import android.os.Bundle; import androidx.annotation.Nullable; import com.android.launcher3.R; import com.android.launcher3.testing.TestInformationHandler; import com.android.launcher3.testing.shared.TestProtocol; import com.android.launcher3.touch.PagedOrientationHandler; import com.android.quickstep.util.LayoutUtils; import com.android.quickstep.util.TISBindHelper; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.function.Consumer; public class QuickstepTestInformationHandler extends TestInformationHandler { Loading Loading @@ -72,6 +81,37 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { TestProtocol.REQUEST_HAS_TIS, true); return response; } case TestProtocol.REQUEST_ENABLE_MANUAL_TASKBAR_STASHING: runOnTISBinder(tisBinder -> { enableManualTaskbarStashing(tisBinder, true); }); return response; case TestProtocol.REQUEST_DISABLE_MANUAL_TASKBAR_STASHING: runOnTISBinder(tisBinder -> { enableManualTaskbarStashing(tisBinder, false); }); return response; case TestProtocol.REQUEST_UNSTASH_TASKBAR_IF_STASHED: runOnTISBinder(tisBinder -> { enableManualTaskbarStashing(tisBinder, true); // Allow null-pointer to catch illegal states. tisBinder.getTaskbarManager().getCurrentActivityContext() .unstashTaskbarIfStashed(); enableManualTaskbarStashing(tisBinder, 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; } } return super.call(method, arg, extras); Loading @@ -93,4 +133,30 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { protected boolean isLauncherInitialized() { return super.isLauncherInitialized() && TouchInteractionService.isInitialized(); } private void enableManualTaskbarStashing( TouchInteractionService.TISBinder tisBinder, boolean enable) { // Allow null-pointer to catch illegal states. tisBinder.getTaskbarManager().getCurrentActivityContext().enableManualStashingDuringTests( enable); } /** * Runs the given command on the UI thread, after ensuring we are connected to * TouchInteractionService. */ protected void runOnTISBinder(Consumer<TouchInteractionService.TISBinder> connectionCallback) { try { CountDownLatch countDownLatch = new CountDownLatch(1); TISBindHelper helper = MAIN_EXECUTOR.submit(() -> new TISBindHelper(mContext, tisBinder -> { connectionCallback.accept(tisBinder); countDownLatch.countDown(); })).get(); countDownLatch.await(); MAIN_EXECUTOR.execute(helper::onDestroy); } catch (ExecutionException | InterruptedException e) { throw new RuntimeException(e); } } } src/com/android/launcher3/testing/TestInformationProvider.java +11 −1 Original line number Diff line number Diff line Loading @@ -21,10 +21,14 @@ import android.content.ContentValues; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.util.Log; import com.android.launcher3.Utilities; public class TestInformationProvider extends ContentProvider { private static final String TAG = "TestInformationProvider"; @Override public boolean onCreate() { return true; Loading Loading @@ -60,7 +64,13 @@ public class TestInformationProvider extends ContentProvider { if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { TestInformationHandler handler = TestInformationHandler.newInstance(getContext()); handler.init(getContext()); return handler.call(method, arg, extras); Bundle response = handler.call(method, arg, extras); if (response == null) { Log.e(TAG, "Couldn't handle method: " + method + "; current handler=" + handler.getClass().getSimpleName()); } return response; } return null; } Loading Loading
quickstep/ext_tests/src/com/android/quickstep/DebugQuickstepTestInformationHandler.java +7 −82 Original line number Diff line number Diff line Loading @@ -15,24 +15,13 @@ */ 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.Launcher; import com.android.launcher3.R; import com.android.launcher3.testing.DebugTestInformationHandler; import com.android.launcher3.testing.shared.TestProtocol; import com.android.quickstep.TouchInteractionService.TISBinder; import com.android.quickstep.util.TISBindHelper; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.function.Consumer; /** * Class to handle requests from tests, including debug ones, to Quickstep Launcher builds. Loading @@ -49,78 +38,14 @@ public abstract class DebugQuickstepTestInformationHandler extends QuickstepTest @Override public Bundle call(String method, String arg, @Nullable Bundle extras) { Bundle response = new Bundle(); switch (method) { case TestProtocol.REQUEST_ENABLE_MANUAL_TASKBAR_STASHING: runOnTISBinder(tisBinder -> { enableManualTaskbarStashing(tisBinder, true); }); return response; case TestProtocol.REQUEST_DISABLE_MANUAL_TASKBAR_STASHING: runOnTISBinder(tisBinder -> { enableManualTaskbarStashing(tisBinder, false); }); return response; case TestProtocol.REQUEST_UNSTASH_TASKBAR_IF_STASHED: runOnTISBinder(tisBinder -> { enableManualTaskbarStashing(tisBinder, true); // Allow null-pointer to catch illegal states. tisBinder.getTaskbarManager().getCurrentActivityContext() .unstashTaskbarIfStashed(); enableManualTaskbarStashing(tisBinder, 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; } case TestProtocol.REQUEST_RECREATE_TASKBAR: if (TestProtocol.REQUEST_RECREATE_TASKBAR.equals(method)) { // Allow null-pointer to catch illegal states. runOnTISBinder(tisBinder -> tisBinder.getTaskbarManager().recreateTaskbar()); return response; default: } response = super.call(method, arg, extras); if (response != null) return response; return mDebugTestInformationHandler.call(method, arg, extras); } } private void enableManualTaskbarStashing(TISBinder tisBinder, boolean enable) { // Allow null-pointer to catch illegal states. tisBinder.getTaskbarManager().getCurrentActivityContext().enableManualStashingForTests( enable); } /** * Runs the given command on the UI thread, after ensuring we are connected to * TouchInteractionService. */ private void runOnTISBinder(Consumer<TISBinder> connectionCallback) { try { CountDownLatch countDownLatch = new CountDownLatch(1); TISBindHelper helper = MAIN_EXECUTOR.submit(() -> new TISBindHelper(mContext, tisBinder -> { connectionCallback.accept(tisBinder); countDownLatch.countDown(); })).get(); countDownLatch.await(); MAIN_EXECUTOR.submit(helper::onDestroy); } catch (ExecutionException | InterruptedException e) { throw new RuntimeException(e); } } private interface UIThreadCommand { void execute(Launcher launcher); } }
quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +2 −2 Original line number Diff line number Diff line Loading @@ -778,8 +778,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext { * stash/unstash the taskbar. */ @VisibleForTesting public void enableManualStashingForTests(boolean enableManualStashing) { mControllers.taskbarStashController.enableManualStashingForTests(enableManualStashing); public void enableManualStashingDuringTests(boolean enableManualStashing) { mControllers.taskbarStashController.enableManualStashingDuringTests(enableManualStashing); } /** Loading
quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java +4 −4 Original line number Diff line number Diff line Loading @@ -160,7 +160,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba private boolean mIsImeShowing; private boolean mIsImeSwitcherShowing; private boolean mEnableManualStashingForTests = false; private boolean mEnableManualStashingDuringTests = false; // Evaluate whether the handle should be stashed private final StatePropertyHolder mStatePropertyHolder = new StatePropertyHolder( Loading Loading @@ -240,15 +240,15 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba */ protected boolean supportsManualStashing() { return supportsVisualStashing() && (!Utilities.IS_RUNNING_IN_TEST_HARNESS || mEnableManualStashingForTests); && (!Utilities.IS_RUNNING_IN_TEST_HARNESS || mEnableManualStashingDuringTests); } /** * Enables support for manual stashing. This should only be used to add this functionality * to Launcher specific tests. */ public void enableManualStashingForTests(boolean enableManualStashing) { mEnableManualStashingForTests = enableManualStashing; public void enableManualStashingDuringTests(boolean enableManualStashing) { mEnableManualStashingDuringTests = enableManualStashing; } /** Loading
quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java +66 −0 Original line number Diff line number Diff line package com.android.quickstep; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import android.app.Activity; import android.content.Context; import android.content.res.Resources; import android.graphics.Rect; import android.os.Bundle; import androidx.annotation.Nullable; import com.android.launcher3.R; import com.android.launcher3.testing.TestInformationHandler; import com.android.launcher3.testing.shared.TestProtocol; import com.android.launcher3.touch.PagedOrientationHandler; import com.android.quickstep.util.LayoutUtils; import com.android.quickstep.util.TISBindHelper; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.function.Consumer; public class QuickstepTestInformationHandler extends TestInformationHandler { Loading Loading @@ -72,6 +81,37 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { TestProtocol.REQUEST_HAS_TIS, true); return response; } case TestProtocol.REQUEST_ENABLE_MANUAL_TASKBAR_STASHING: runOnTISBinder(tisBinder -> { enableManualTaskbarStashing(tisBinder, true); }); return response; case TestProtocol.REQUEST_DISABLE_MANUAL_TASKBAR_STASHING: runOnTISBinder(tisBinder -> { enableManualTaskbarStashing(tisBinder, false); }); return response; case TestProtocol.REQUEST_UNSTASH_TASKBAR_IF_STASHED: runOnTISBinder(tisBinder -> { enableManualTaskbarStashing(tisBinder, true); // Allow null-pointer to catch illegal states. tisBinder.getTaskbarManager().getCurrentActivityContext() .unstashTaskbarIfStashed(); enableManualTaskbarStashing(tisBinder, 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; } } return super.call(method, arg, extras); Loading @@ -93,4 +133,30 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { protected boolean isLauncherInitialized() { return super.isLauncherInitialized() && TouchInteractionService.isInitialized(); } private void enableManualTaskbarStashing( TouchInteractionService.TISBinder tisBinder, boolean enable) { // Allow null-pointer to catch illegal states. tisBinder.getTaskbarManager().getCurrentActivityContext().enableManualStashingDuringTests( enable); } /** * Runs the given command on the UI thread, after ensuring we are connected to * TouchInteractionService. */ protected void runOnTISBinder(Consumer<TouchInteractionService.TISBinder> connectionCallback) { try { CountDownLatch countDownLatch = new CountDownLatch(1); TISBindHelper helper = MAIN_EXECUTOR.submit(() -> new TISBindHelper(mContext, tisBinder -> { connectionCallback.accept(tisBinder); countDownLatch.countDown(); })).get(); countDownLatch.await(); MAIN_EXECUTOR.execute(helper::onDestroy); } catch (ExecutionException | InterruptedException e) { throw new RuntimeException(e); } } }
src/com/android/launcher3/testing/TestInformationProvider.java +11 −1 Original line number Diff line number Diff line Loading @@ -21,10 +21,14 @@ import android.content.ContentValues; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.util.Log; import com.android.launcher3.Utilities; public class TestInformationProvider extends ContentProvider { private static final String TAG = "TestInformationProvider"; @Override public boolean onCreate() { return true; Loading Loading @@ -60,7 +64,13 @@ public class TestInformationProvider extends ContentProvider { if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { TestInformationHandler handler = TestInformationHandler.newInstance(getContext()); handler.init(getContext()); return handler.call(method, arg, extras); Bundle response = handler.call(method, arg, extras); if (response == null) { Log.e(TAG, "Couldn't handle method: " + method + "; current handler=" + handler.getClass().getSimpleName()); } return response; } return null; } Loading