Merge "DO NOT MERGE: Disable Fullscreen Magnification tests on XR as they do not apply." into android14-tests-dev
diff --git a/common/device-side/util-axt/src/com/android/compatibility/common/util/XrUtil.java b/common/device-side/util-axt/src/com/android/compatibility/common/util/XrUtil.java
new file mode 100644
index 0000000..a1d2aaf
--- /dev/null
+++ b/common/device-side/util-axt/src/com/android/compatibility/common/util/XrUtil.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2025 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.compatibility.common.util;
+
+import android.content.Context;
+import android.content.res.Resources;
+
+
+/**
+ * XrUtil is used to check properties and configs related to Android XR.
+ */
+public class XrUtil {
+ /**
+ * This checks if we support third party magnification on XR devices. By default,
+ * Android XR does not support third party magnification.
+ */
+ public static boolean supportsXrThirdPartyMagnificationServices(Context context) {
+ return !FeatureUtil.isXrHeadset() || hasXrThirdPartyMagnificationServicesConfig(context);
+ }
+
+
+ private static boolean hasXrThirdPartyMagnificationServicesConfig(Context context) {
+ try {
+ return context.getResources().getBoolean(
+ Resources.getSystem().getIdentifier(
+ "config_supportsXRThirdPartyMagnification", "bool", "android"));
+ } catch (Resources.NotFoundException e) {
+ // Third party magnification is opt-in.
+ return false;
+ }
+ }
+}
+
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityGestureDispatchTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityGestureDispatchTest.java
index dcc7258..1267e80 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityGestureDispatchTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityGestureDispatchTest.java
@@ -1,11 +1,11 @@
/**
* Copyright (C) 2016 The Android Open Source Project
- *
+ * <p>
* 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
- *
+ * <p>
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
* 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
@@ -46,6 +46,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
+import static org.junit.Assume.assumeTrue;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
@@ -77,6 +78,7 @@
import androidx.test.runner.AndroidJUnit4;
import com.android.compatibility.common.util.CddTest;
+import com.android.compatibility.common.util.XrUtil;
import org.hamcrest.Matcher;
import org.junit.AfterClass;
@@ -257,7 +259,7 @@
MotionEvent downEvent = mMotionEvents.get(0);
MotionEvent upEvent = mMotionEvents.get(numEvents - 1);
assertThat(downEvent, both(IS_ACTION_DOWN).and(isAtPoint(startPoint,
- pointTolerance)));
+ pointTolerance)));
assertThat(upEvent, both(IS_ACTION_UP).and(isAtPoint(endPoint, pointTolerance)));
assertEquals(gestureTime, upEvent.getEventTime() - downEvent.getEventTime());
@@ -270,7 +272,7 @@
PointF intermediatePoint = add(startPoint,
times(fractionOfSwipe, diff(endPoint, startPoint)));
assertThat(moveEvent, both(IS_ACTION_MOVE).and(
- isAtPoint(intermediatePoint, pointTolerance)));
+ isAtPoint(intermediatePoint, pointTolerance)));
lastEventTime = moveEvent.getEventTime();
}
}
@@ -367,7 +369,10 @@
}
assumeFalse("Magnification is not supported on Automotive.",
isAutomotive(sInstrumentation.getTargetContext()));
-
+ assumeTrue("Magnification and third-party accessibility services (3.10/C-1-1)"
+ + " are not supported on Android XR by default.",
+ XrUtil.supportsXrThirdPartyMagnificationServices(
+ sInstrumentation.getTargetContext()));
int displayId = mActivity.getWindow().getDecorView().getDisplay().getDisplayId();
if (displayId != Display.DEFAULT_DISPLAY) {
Log.i(TAG, "Magnification is not supported on virtual displays.");
@@ -421,14 +426,14 @@
// Click in the center of the magnification region
dispatch(new GestureDescription.Builder()
- .addStroke(click(magRegionCenterClickPoint))
- .build(),
+ .addStroke(click(magRegionCenterClickPoint))
+ .build(),
GESTURE_COMPLETION_TIMEOUT);
// Click at a slightly offset point
dispatch(new GestureDescription.Builder()
- .addStroke(click(magRegionOffsetClickPoint))
- .build(),
+ .addStroke(click(magRegionOffsetClickPoint))
+ .build(),
GESTURE_COMPLETION_TIMEOUT);
waitForMotionEvents(any(MotionEvent.class), 4);
} finally {
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/FullScreenMagnificationGestureHandlerTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/FullScreenMagnificationGestureHandlerTest.java
index 72bf47f..a7116eb 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/FullScreenMagnificationGestureHandlerTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/FullScreenMagnificationGestureHandlerTest.java
@@ -41,6 +41,7 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
+import static org.junit.Assume.assumeTrue;
import android.accessibility.cts.common.AccessibilityDumpOnFailureRule;
import android.accessibility.cts.common.InstrumentedAccessibilityService;
@@ -63,6 +64,7 @@
import androidx.test.runner.AndroidJUnit4;
import com.android.compatibility.common.util.CddTest;
+import com.android.compatibility.common.util.XrUtil;
import org.junit.After;
import org.junit.Before;
@@ -123,7 +125,10 @@
if (!mHasTouchscreen) return;
assumeFalse("Magnification is not supported on Automotive.",
isAutomotive(mInstrumentation.getTargetContext()));
-
+ assumeTrue("Magnification and third-party accessibility services (3.10/C-1-1)"
+ + " are not supported on Android XR by default.",
+ XrUtil.supportsXrThirdPartyMagnificationServices(
+ mInstrumentation.getTargetContext()));
// Backup and reset magnification settings.
mOriginalIsMagnificationCapabilities = getSecureSettingInt(
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_CAPABILITY,