Merge "Fix talkback in split mode" into main
This commit is contained in:
commit
09623dd5e5
9 files changed
+111
-61
No files matched your search
@@ -52,6 +52,7 @@ filegroup {
|
||||
"tests/src/com/android/quickstep/TaplOverviewIconTest.java",
|
||||
"tests/src/com/android/quickstep/TaplTestsQuickstep.java",
|
||||
"tests/src/com/android/quickstep/TaplTestsSplitscreen.java",
|
||||
"tests/src/com/android/quickstep/util/SplitScreenTestUtils.kt",
|
||||
"tests/src/com/android/launcher3/testcomponent/ExcludeFromRecentsTestActivity.java",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ class DigitalWellBeingToast(
|
||||
|
||||
private fun setNoLimit() {
|
||||
hasLimit = false
|
||||
taskView.contentDescription = task.titleDescription
|
||||
setContentDescription(appUsageLimitTimeMs = -1, appRemainingTimeMs = -1)
|
||||
replaceBanner(null)
|
||||
appRemainingTimeMs = -1
|
||||
}
|
||||
@@ -110,9 +110,14 @@ class DigitalWellBeingToast(
|
||||
setOnClickListener(::openAppUsageSettings)
|
||||
}
|
||||
replaceBanner(toast)
|
||||
setContentDescription(appUsageLimitTimeMs, appRemainingTimeMs)
|
||||
}
|
||||
|
||||
taskView.contentDescription =
|
||||
private fun setContentDescription(appUsageLimitTimeMs: Long, appRemainingTimeMs: Long) {
|
||||
val taskContainer: TaskContainer = taskView.getTaskContainerById(task.key.id) ?: return
|
||||
val contentDescription =
|
||||
getContentDescriptionForTask(task, appUsageLimitTimeMs, appRemainingTimeMs)
|
||||
taskContainer.snapshotView.contentDescription = contentDescription
|
||||
}
|
||||
|
||||
fun initialize(task: Task) {
|
||||
|
||||
@@ -171,4 +171,18 @@ class TaskContainer(
|
||||
thumbnailViewDeprecated.setOverlayEnabled(enabled)
|
||||
}
|
||||
}
|
||||
|
||||
fun addChildForAccessibility(outChildren: ArrayList<View>) {
|
||||
addAccessibleChildToList(iconView.asView(), outChildren)
|
||||
addAccessibleChildToList(snapshotView, outChildren)
|
||||
showWindowsView?.let { addAccessibleChildToList(it, outChildren) }
|
||||
}
|
||||
|
||||
private fun addAccessibleChildToList(view: View, outChildren: ArrayList<View>) {
|
||||
if (view.includeForAccessibility()) {
|
||||
outChildren.add(view)
|
||||
} else {
|
||||
view.addChildrenForAccessibility(outChildren)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1662,6 +1662,12 @@ constructor(
|
||||
return thumbnailBounds.contains(x.toInt(), y.toInt())
|
||||
}
|
||||
|
||||
override fun addChildrenForAccessibility(outChildren: ArrayList<View>) {
|
||||
(if (isLayoutRtl) taskContainers.reversed() else taskContainers).forEach {
|
||||
it.addChildForAccessibility(outChildren)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "TaskView"
|
||||
const val FLAG_UPDATE_ICON = 1
|
||||
|
||||
@@ -15,20 +15,18 @@
|
||||
*/
|
||||
package com.android.quickstep;
|
||||
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.platform.test.annotations.PlatinumTest;
|
||||
|
||||
import com.android.launcher3.tapl.Overview;
|
||||
import com.android.launcher3.tapl.OverviewTask.OverviewSplitTask;
|
||||
import com.android.launcher3.tapl.OverviewTaskMenu;
|
||||
import com.android.launcher3.ui.AbstractLauncherUiTest;
|
||||
import com.android.launcher3.uioverrides.QuickstepLauncher;
|
||||
import com.android.launcher3.util.rule.TestStabilityRule;
|
||||
import com.android.quickstep.util.SplitScreenTestUtils;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -70,39 +68,17 @@ public class TaplOverviewIconTest extends AbstractLauncherUiTest<QuickstepLaunch
|
||||
|
||||
@Test
|
||||
public void testSplitTaskTapBothIconMenus() {
|
||||
createAndLaunchASplitPair();
|
||||
Overview overview = SplitScreenTestUtils.createAndLaunchASplitPairInOverview(mLauncher);
|
||||
|
||||
OverviewTaskMenu taskMenu =
|
||||
mLauncher.goHome().switchToOverview().getCurrentTask().tapMenu();
|
||||
OverviewTaskMenu taskMenu = overview.getCurrentTask().tapMenu();
|
||||
assertTrue("App info item not appearing in expanded task menu.",
|
||||
taskMenu.hasMenuItem("App info"));
|
||||
taskMenu.touchOutsideTaskMenuToDismiss();
|
||||
|
||||
OverviewTaskMenu splitMenu =
|
||||
mLauncher.goHome().switchToOverview().getCurrentTask().tapMenu(
|
||||
OverviewTaskMenu splitMenu = overview.getCurrentTask().tapMenu(
|
||||
OverviewSplitTask.SPLIT_BOTTOM_OR_RIGHT);
|
||||
assertTrue("App info item not appearing in expanded split task's menu.",
|
||||
splitMenu.hasMenuItem("App info"));
|
||||
splitMenu.touchOutsideTaskMenuToDismiss();
|
||||
}
|
||||
|
||||
private void createAndLaunchASplitPair() {
|
||||
clearAllRecentTasks();
|
||||
|
||||
startTestActivity(2);
|
||||
startTestActivity(3);
|
||||
|
||||
if (mLauncher.isTablet() && !mLauncher.isGridOnlyOverviewEnabled()) {
|
||||
mLauncher.goHome().switchToOverview().getOverviewActions()
|
||||
.clickSplit()
|
||||
.getTestActivityTask(2)
|
||||
.open();
|
||||
} else {
|
||||
mLauncher.goHome().switchToOverview().getCurrentTask()
|
||||
.tapMenu()
|
||||
.tapSplitMenuItem()
|
||||
.getCurrentTask()
|
||||
.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -478,7 +478,8 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
// assertTrue("Launcher internal state didn't remain in Overview",
|
||||
// isInState(() -> LauncherState.OVERVIEW));
|
||||
// overview.getCurrentTask().dismiss();
|
||||
// executeOnLauncher(launcher -> assertTrue("Grid did not rebalance after multiple dismissals",
|
||||
// executeOnLauncher(launcher -> assertTrue("Grid did not rebalance after multiple
|
||||
// dismissals",
|
||||
// (Math.abs(getTopRowTaskCountForTablet(launcher) - getBottomRowTaskCountForTablet(
|
||||
// launcher)) <= 1)));
|
||||
|
||||
@@ -589,7 +590,8 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest {
|
||||
if (overview.hasTasks()) {
|
||||
currentTask = overview.getCurrentTask();
|
||||
assertFalse("Found ExcludeFromRecentsTestActivity after entering Overview from Home",
|
||||
currentTask.containsContentDescription("ExcludeFromRecents")
|
||||
currentTask.containsContentDescription(
|
||||
"ExcludeFromRecents")
|
||||
|| currentTask.containsContentDescription(null));
|
||||
} else {
|
||||
// Presumably the test started with 0 tasks and remains that way after going home.
|
||||
|
||||
@@ -17,8 +17,6 @@ package com.android.quickstep;
|
||||
|
||||
|
||||
import static com.android.launcher3.config.FeatureFlags.enableSplitContextually;
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
|
||||
import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -33,7 +31,7 @@ import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import com.android.launcher3.tapl.Overview;
|
||||
import com.android.launcher3.tapl.Taskbar;
|
||||
import com.android.launcher3.tapl.TaskbarAppIcon;
|
||||
import com.android.launcher3.util.rule.TestStabilityRule;
|
||||
import com.android.quickstep.util.SplitScreenTestUtils;
|
||||
import com.android.wm.shell.Flags;
|
||||
|
||||
import org.junit.After;
|
||||
@@ -110,9 +108,8 @@ public class TaplTestsSplitscreen extends AbstractQuickStepTest {
|
||||
assumeTrue("App pairs feature is currently not enabled, no test needed",
|
||||
Flags.enableAppPairs());
|
||||
|
||||
createAndLaunchASplitPair();
|
||||
Overview overview = SplitScreenTestUtils.createAndLaunchASplitPairInOverview(mLauncher);
|
||||
|
||||
Overview overview = mLauncher.goHome().switchToOverview();
|
||||
if (mLauncher.isGridOnlyOverviewEnabled() || !mLauncher.isTablet()) {
|
||||
assertTrue("Save app pair menu item is missing",
|
||||
overview.getCurrentTask()
|
||||
@@ -156,24 +153,4 @@ public class TaplTestsSplitscreen extends AbstractQuickStepTest {
|
||||
TaskbarAppIcon firstApp = taskbar.getAppIcon(firstAppName);
|
||||
firstApp.launchIntoSplitScreen();
|
||||
}
|
||||
|
||||
private void createAndLaunchASplitPair() {
|
||||
clearAllRecentTasks();
|
||||
|
||||
startTestActivity(2);
|
||||
startTestActivity(3);
|
||||
|
||||
if (mLauncher.isTablet() && !mLauncher.isGridOnlyOverviewEnabled()) {
|
||||
mLauncher.goHome().switchToOverview().getOverviewActions()
|
||||
.clickSplit()
|
||||
.getTestActivityTask(2)
|
||||
.open();
|
||||
} else {
|
||||
mLauncher.goHome().switchToOverview().getCurrentTask()
|
||||
.tapMenu()
|
||||
.tapSplitMenuItem()
|
||||
.getCurrentTask()
|
||||
.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2024 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.util
|
||||
|
||||
import androidx.test.uiautomator.By
|
||||
import com.android.launcher3.tapl.LauncherInstrumentation
|
||||
import com.android.launcher3.tapl.Overview
|
||||
import com.android.launcher3.tapl.OverviewTask
|
||||
import com.android.launcher3.ui.AbstractLauncherUiTest
|
||||
|
||||
object SplitScreenTestUtils {
|
||||
|
||||
/** Creates 2 tasks and makes a split mode pair. Also asserts the accessibility labels. */
|
||||
@JvmStatic
|
||||
fun createAndLaunchASplitPairInOverview(launcher: LauncherInstrumentation): Overview {
|
||||
clearAllRecentTasks(launcher)
|
||||
|
||||
AbstractLauncherUiTest.startTestActivity(2)
|
||||
AbstractLauncherUiTest.startTestActivity(3)
|
||||
|
||||
val overView = launcher.goHome().switchToOverview()
|
||||
if (launcher.isTablet && !launcher.isGridOnlyOverviewEnabled) {
|
||||
overView.overviewActions.clickSplit().getTestActivityTask(2).open()
|
||||
} else {
|
||||
overView.currentTask.tapMenu().tapSplitMenuItem().currentTask.open()
|
||||
}
|
||||
|
||||
val overviewWithSplitPair = launcher.goHome().switchToOverview()
|
||||
val currentTask = overviewWithSplitPair.currentTask
|
||||
currentTask.containsContentDescription(
|
||||
By.pkg(AbstractLauncherUiTest.getAppPackageName()).text("TestActivity3").toString(),
|
||||
OverviewTask.OverviewSplitTask.SPLIT_TOP_OR_LEFT
|
||||
)
|
||||
currentTask.containsContentDescription(
|
||||
By.pkg(AbstractLauncherUiTest.getAppPackageName()).text("TestActivity2").toString(),
|
||||
OverviewTask.OverviewSplitTask.SPLIT_BOTTOM_OR_RIGHT
|
||||
)
|
||||
return overviewWithSplitPair
|
||||
}
|
||||
|
||||
private fun clearAllRecentTasks(launcher: LauncherInstrumentation) {
|
||||
if (launcher.recentTasks.isNotEmpty()) {
|
||||
launcher.goHome().switchToOverview().dismissAllTasks()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -284,8 +284,9 @@ public final class OverviewTask {
|
||||
*
|
||||
* TODO(b/326565120): remove Nullable support once the bug causing it to be null is fixed.
|
||||
*/
|
||||
public boolean containsContentDescription(@Nullable String expected) {
|
||||
String actual = mTask.getContentDescription();
|
||||
public boolean containsContentDescription(@Nullable String expected,
|
||||
OverviewSplitTask overviewSplitTask) {
|
||||
String actual = findObjectInTask(overviewSplitTask.snapshotRes).getContentDescription();
|
||||
if (actual == null && expected == null) {
|
||||
return true;
|
||||
}
|
||||
@@ -295,6 +296,14 @@ public final class OverviewTask {
|
||||
return actual.contains(expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given String is contained in this Task's contentDescription. Also returns
|
||||
* true if both Strings are null
|
||||
*/
|
||||
public boolean containsContentDescription(@Nullable String expected) {
|
||||
return containsContentDescription(expected, DEFAULT);
|
||||
}
|
||||
|
||||
private TaskViewType getType() {
|
||||
String resourceName = mTask.getResourceName();
|
||||
if (resourceName.endsWith("task_view_grouped")) {
|
||||
|
||||
Reference in new issue
Block a user