summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-05 18:37:16 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-05 18:37:16 +0000
commitc99b9dfef8635a15f402e77caa941df0ec86722f (patch)
tree0639a3d5b9e5abbfeeb94a048db01bd328b2945e
parent84f034e5f36195ff96055d37bf6473910451fa53 (diff)
parent05dcb2cb5181c8324e1233cd37efbc04d9035538 (diff)
downloadcts-android14-mainline-mediaprovider-release.tar.gz
Snap for 11180127 from 05dcb2cb5181c8324e1233cd37efbc04d9035538 to mainline-mediaprovider-releaseaml_mpr_341411070android14-mainline-mediaprovider-release
Change-Id: I1d381f4a72170071ed9f220eb6c5f6ca6681b664
-rw-r--r--tests/framework/base/windowmanager/src/android/server/wm/DisplayHashManagerTest.java23
-rw-r--r--tests/signature/api-check/system-annotation/AndroidTest.xml1
-rw-r--r--tests/tests/car/src/android/car/cts/CarPropertyManagerTest.java27
-rw-r--r--tests/tests/car/src/android/car/cts/utils/VehiclePropertyVerifier.java20
-rw-r--r--tests/tests/media/common/src/android/media/cts/MediaProjectionActivity.java95
-rw-r--r--tests/tests/permissionpolicy/res/raw/android_manifest.xml4
-rw-r--r--tests/tests/wifi/src/android/net/wifi/aware/cts/SingleDeviceTest.java4
7 files changed, 134 insertions, 40 deletions
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/DisplayHashManagerTest.java b/tests/framework/base/windowmanager/src/android/server/wm/DisplayHashManagerTest.java
index 09b253c51b6..01f71b0c6ec 100644
--- a/tests/framework/base/windowmanager/src/android/server/wm/DisplayHashManagerTest.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/DisplayHashManagerTest.java
@@ -18,6 +18,7 @@ package android.server.wm;
import static android.server.wm.UiDeviceUtils.pressUnlockButton;
import static android.server.wm.UiDeviceUtils.pressWakeupButton;
+import static android.server.wm.WindowManagerState.STATE_RESUMED;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_INVALID_BOUNDS;
@@ -35,6 +36,7 @@ import static org.junit.Assert.assertNull;
import android.app.Activity;
import android.app.Instrumentation;
import android.app.KeyguardManager;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
@@ -42,6 +44,7 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.PowerManager;
+import android.os.SystemClock;
import android.platform.test.annotations.Presubmit;
import android.service.displayhash.DisplayHashParams;
import android.util.Size;
@@ -78,6 +81,8 @@ import java.util.concurrent.TimeUnit;
@Presubmit
public class DisplayHashManagerTest {
private static final int WAIT_TIME_S = 5;
+ private static final int TIMEOUT_MS = 1000;
+ private static final int SLEEP_TIMEOUT_MS = 200;
private final Point mCenter = new Point();
private final Point mTestViewSize = new Point(200, 300);
@@ -416,7 +421,9 @@ public class DisplayHashManagerTest {
committedCallbackLatch.await(WAIT_TIME_S, TimeUnit.SECONDS);
} catch (InterruptedException e) {
}
- waitForAllActivitiesResumed();
+ ComponentName componentName = ComponentName.unflattenFromString(
+ "android.server.wm/android.server.wm.DisplayHashManagerTest$TestActivity");
+ waitForActivityResumed(TIMEOUT_MS, componentName);
byte[] expectedImageHash = new byte[]{-1, -1, 127, -1, -1, -1, 127, 127};
@@ -430,6 +437,20 @@ public class DisplayHashManagerTest {
assertArrayEquals(expectedImageHash, verifiedDisplayHash.getImageHash());
}
+ private void waitForActivityResumed(int timeoutMs, ComponentName componentName) {
+ long endTime = System.currentTimeMillis() + timeoutMs;
+ while (endTime > System.currentTimeMillis()) {
+ mWmState.computeState();
+ if (mWmState.hasActivityState(componentName, STATE_RESUMED)) {
+ SystemClock.sleep(SLEEP_TIMEOUT_MS);
+ mWmState.computeState();
+ break;
+ }
+ SystemClock.sleep(SLEEP_TIMEOUT_MS);
+ mWmState.computeState();
+ }
+ }
+
@Test
public void testDisplayHashParams() {
int width = 10;
diff --git a/tests/signature/api-check/system-annotation/AndroidTest.xml b/tests/signature/api-check/system-annotation/AndroidTest.xml
index f5d4db2e46a..d08de888bff 100644
--- a/tests/signature/api-check/system-annotation/AndroidTest.xml
+++ b/tests/signature/api-check/system-annotation/AndroidTest.xml
@@ -38,6 +38,7 @@
<option name="instrumentation-arg" key="expected-api-files" value="system-current.api.gz,system-removed.api.gz,car-system-current.api.gz,car-system-removed.api.gz" />
<option name="instrumentation-arg" key="annotation-for-exact-match" value="@android.annotation.SystemApi\(client=PRIVILEGED_APPS\)" />
<option name="runtime-hint" value="30s" />
+ <option name="test-timeout" value="500000" />
<!-- Disable hidden API checks (http://b/171459260). -->
<option name="hidden-api-checks" value="false" />
<!-- disable isolated storage so tests can access dynamic config stored in /sdcard. -->
diff --git a/tests/tests/car/src/android/car/cts/CarPropertyManagerTest.java b/tests/tests/car/src/android/car/cts/CarPropertyManagerTest.java
index d3db6dcdf43..292091bd8c1 100644
--- a/tests/tests/car/src/android/car/cts/CarPropertyManagerTest.java
+++ b/tests/tests/car/src/android/car/cts/CarPropertyManagerTest.java
@@ -1090,6 +1090,7 @@ public final class CarPropertyManagerTest extends AbstractCarTestCase {
getInfoVinVerifier(),
getInfoMakeVerifier(),
getInfoModelVerifier(),
+ getInfoModelYearVerifier(),
getInfoFuelCapacityVerifier(),
getInfoFuelTypeVerifier(),
getInfoEvBatteryCapacityVerifier(),
@@ -1498,8 +1499,8 @@ public final class CarPropertyManagerTest extends AbstractCarTestCase {
Integer.class, mCarPropertyManager)
.setAllPossibleEnumValues(possibleEnumValues)
.setDependentOnProperty(VehiclePropertyIds.HANDS_ON_DETECTION_ENABLED,
- ImmutableSet.of(Car.PERMISSION_READ_ADAS_SETTINGS,
- Car.PERMISSION_CONTROL_ADAS_SETTINGS))
+ ImmutableSet.of(Car.PERMISSION_READ_DRIVER_MONITORING_SETTINGS,
+ Car.PERMISSION_CONTROL_DRIVER_MONITORING_SETTINGS))
.verifyErrorStates()
.addReadPermission(Car.PERMISSION_READ_DRIVER_MONITORING_STATES)
.build();
@@ -1529,8 +1530,8 @@ public final class CarPropertyManagerTest extends AbstractCarTestCase {
Integer.class, mCarPropertyManager)
.setAllPossibleEnumValues(possibleEnumValues)
.setDependentOnProperty(VehiclePropertyIds.HANDS_ON_DETECTION_ENABLED,
- ImmutableSet.of(Car.PERMISSION_READ_ADAS_SETTINGS,
- Car.PERMISSION_CONTROL_ADAS_SETTINGS))
+ ImmutableSet.of(Car.PERMISSION_READ_DRIVER_MONITORING_SETTINGS,
+ Car.PERMISSION_CONTROL_DRIVER_MONITORING_SETTINGS))
.verifyErrorStates()
.addReadPermission(Car.PERMISSION_READ_DRIVER_MONITORING_STATES)
.build();
@@ -1708,10 +1709,26 @@ public final class CarPropertyManagerTest extends AbstractCarTestCase {
}
@Test
- public void testInfoModelYearIfSupported() {
+ public void testInfoModelIfSupported() {
getInfoModelVerifier().verify();
}
+ private VehiclePropertyVerifier<Integer> getInfoModelYearVerifier() {
+ return VehiclePropertyVerifier.newBuilder(
+ VehiclePropertyIds.INFO_MODEL_YEAR,
+ CarPropertyConfig.VEHICLE_PROPERTY_ACCESS_READ,
+ VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL,
+ CarPropertyConfig.VEHICLE_PROPERTY_CHANGE_MODE_STATIC,
+ Integer.class, mCarPropertyManager)
+ .addReadPermission(Car.PERMISSION_CAR_INFO)
+ .build();
+ }
+
+ @Test
+ public void testInfoModelYearIfSupported() {
+ getInfoModelYearVerifier().verify();
+ }
+
private VehiclePropertyVerifier<Float> getInfoFuelCapacityVerifier() {
return VehiclePropertyVerifier.newBuilder(
VehiclePropertyIds.INFO_FUEL_CAPACITY,
diff --git a/tests/tests/car/src/android/car/cts/utils/VehiclePropertyVerifier.java b/tests/tests/car/src/android/car/cts/utils/VehiclePropertyVerifier.java
index 20a1c69ecd8..5bea216ef0c 100644
--- a/tests/tests/car/src/android/car/cts/utils/VehiclePropertyVerifier.java
+++ b/tests/tests/car/src/android/car/cts/utils/VehiclePropertyVerifier.java
@@ -1678,25 +1678,25 @@ public class VehiclePropertyVerifier<T> {
verifyHvacTemperatureIsValid(suggestedTempInFahrenheit, minTempInFahrenheitTimesTen,
maxTempInFahrenheitTimesTen, incrementInFahrenheitTimesTen);
- int suggestedTempInCelsiusTimesTen = suggestedTempInCelsius.intValue() * 10;
- int suggestedTempInFahrenheitTimesTen = suggestedTempInFahrenheit.intValue() * 10;
+ int suggestedTempInCelsiusTimesTen = (int) (suggestedTempInCelsius * 10f);
+ int suggestedTempInFahrenheitTimesTen = (int) (suggestedTempInFahrenheit * 10f);
int numIncrementsCelsius =
- (suggestedTempInCelsiusTimesTen - minTempInCelsiusTimesTen)
- / incrementInCelsiusTimesTen;
+ Math.round((suggestedTempInCelsiusTimesTen - minTempInCelsiusTimesTen)
+ / incrementInCelsiusTimesTen.floatValue());
int numIncrementsFahrenheit =
- (suggestedTempInFahrenheitTimesTen - minTempInFahrenheitTimesTen)
- / incrementInFahrenheitTimesTen;
+ Math.round((suggestedTempInFahrenheitTimesTen - minTempInFahrenheitTimesTen)
+ / incrementInFahrenheitTimesTen.floatValue());
assertWithMessage(
- "The temperature in Celsius must be equivalent to the temperature in"
- + " Fahrenheit.")
+ "The temperature in celsius must map to the same temperature in fahrenheit"
+ + " using the HVAC_TEMPERATURE_SET config array: "
+ + hvacTemperatureSetConfigArray)
.that(numIncrementsFahrenheit)
.isEqualTo(numIncrementsCelsius);
}
public static void verifyHvacTemperatureIsValid(float temp, int minTempTimesTen,
int maxTempTimesTen, int incrementTimesTen) {
- Float tempMultiplied = temp * 10.0f;
- int intTempTimesTen = tempMultiplied.intValue();
+ int intTempTimesTen = (int) (temp * 10f);
assertWithMessage(
"The temperature value " + intTempTimesTen + " must be at least "
+ minTempTimesTen + " and at most " + maxTempTimesTen)
diff --git a/tests/tests/media/common/src/android/media/cts/MediaProjectionActivity.java b/tests/tests/media/common/src/android/media/cts/MediaProjectionActivity.java
index 2223bc0ca54..b78e4ae7c95 100644
--- a/tests/tests/media/common/src/android/media/cts/MediaProjectionActivity.java
+++ b/tests/tests/media/common/src/android/media/cts/MediaProjectionActivity.java
@@ -22,10 +22,13 @@ import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.Resources;
import android.media.projection.MediaProjection;
import android.media.projection.MediaProjectionManager;
import android.os.Bundle;
import android.support.test.uiautomator.By;
+import android.support.test.uiautomator.BySelector;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.UiObjectNotFoundException;
@@ -49,6 +52,11 @@ public class MediaProjectionActivity extends Activity {
private static final int PERMISSION_CODE = 1;
private static final int PERMISSION_DIALOG_WAIT_MS = 1000;
private static final String ACCEPT_RESOURCE_ID = "android:id/button1";
+ private static final String SYSTEM_UI_PACKAGE = "com.android.systemui";
+ private static final String SPINNER_RESOURCE_ID =
+ SYSTEM_UI_PACKAGE + ":id/screen_share_mode_spinner";
+ private static final String ENTIRE_SCREEN_STRING_RES_NAME =
+ "screen_share_permission_dialog_option_entire_screen";
private MediaProjectionManager mProjectionManager;
private MediaProjection mMediaProjection;
@@ -137,34 +145,81 @@ public class MediaProjectionActivity extends Activity {
/** The permission dialog will be auto-opened by the activity - find it and accept */
public void dismissPermissionDialog() {
// Ensure the device is initialized before interacting with any UI elements.
- final UiDevice uiDevice = UiDevice.getInstance(
- InstrumentationRegistry.getInstrumentation());
-
- // Scroll down the dialog; on a device with a small screen the buttons may be below the
- // warning text.
+ UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
final boolean isWatch = getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH);
- if (isWatch) {
- final UiScrollable scrollable = new UiScrollable(new UiSelector().scrollable(true));
- try {
- if (!scrollable.scrollIntoView(new UiSelector().resourceId(ACCEPT_RESOURCE_ID))) {
- Log.e(TAG, "Didn't find the accept button when scrolling");
- return;
- }
- Log.d(TAG, "This is a watch; we finished scrolling down to the buttons");
- } catch (UiObjectNotFoundException e) {
- Log.d(TAG, "This is a watch, but there was no scrolling (the UI may not be "
- + "scrollable");
+ if (!isWatch) {
+ // if not testing on a watch device, then we need to select the entire screen option
+ // before pressing "Start recording" button.
+ if (!selectEntireScreenOption()) {
+ Log.e(TAG, "Couldn't select entire screen option");
}
}
+ pressStartRecording(isWatch);
+ }
+
+ private boolean selectEntireScreenOption() {
+ UiObject2 spinner = waitForObject(By.res(SPINNER_RESOURCE_ID));
+ if (spinner == null) {
+ Log.e(TAG, "Couldn't find spinner to select projection mode");
+ return false;
+ }
+ spinner.click();
- UiObject2 acceptButton = uiDevice.wait(Until.findObject(By.res(ACCEPT_RESOURCE_ID)),
- PERMISSION_DIALOG_WAIT_MS);
- if (acceptButton != null) {
+ UiObject2 entireScreenOption = waitForObject(By.text(getEntireScreenString()));
+ if (entireScreenOption == null) {
+ Log.e(TAG, "Couldn't find entire screen option");
+ return false;
+ }
+ entireScreenOption.click();
+ return true;
+ }
+
+ private String getEntireScreenString() {
+ Resources sysUiResources;
+ try {
+ sysUiResources = getPackageManager().getResourcesForApplication(SYSTEM_UI_PACKAGE);
+ } catch (NameNotFoundException e) {
+ return null;
+ }
+ int resourceId =
+ sysUiResources.getIdentifier(
+ ENTIRE_SCREEN_STRING_RES_NAME, /* defType= */ "string", SYSTEM_UI_PACKAGE);
+ return sysUiResources.getString(resourceId);
+ }
+
+ private void pressStartRecording(boolean isWatch) {
+ if (isWatch) {
+ scrollToStartRecordingButton();
+ }
+ UiObject2 startRecordingButton = waitForObject(By.res(ACCEPT_RESOURCE_ID));
+ if (startRecordingButton == null) {
+ Log.e(TAG, "Couldn't find start recording button");
+ } else {
Log.d(TAG, "found permission dialog after searching all windows, clicked");
- acceptButton.click();
+ startRecordingButton.click();
}
}
+ /** When testing on a small screen device, scrolls to a Start Recording button. */
+ private void scrollToStartRecordingButton() {
+ // Scroll down the dialog; on a device with a small screen the elements may not be visible.
+ final UiScrollable scrollable = new UiScrollable(new UiSelector().scrollable(true));
+ try {
+ if (!scrollable.scrollIntoView(new UiSelector().resourceId(ACCEPT_RESOURCE_ID))) {
+ Log.e(TAG, "Didn't find " + ACCEPT_RESOURCE_ID + " when scrolling");
+ return;
+ }
+ Log.d(TAG, "This is a watch; we finished scrolling down to the ui elements");
+ } catch (UiObjectNotFoundException e) {
+ Log.d(TAG, "This is a watch, but there was no scrolling (UI may not be scrollable");
+ }
+ }
+
+ private UiObject2 waitForObject(BySelector selector) {
+ UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+ return uiDevice.wait(Until.findObject(selector), PERMISSION_DIALOG_WAIT_MS);
+ }
+
@Override
protected void onResume() {
Log.i(TAG, "onResume");
diff --git a/tests/tests/permissionpolicy/res/raw/android_manifest.xml b/tests/tests/permissionpolicy/res/raw/android_manifest.xml
index fa6033ec367..83c658bce7a 100644
--- a/tests/tests/permissionpolicy/res/raw/android_manifest.xml
+++ b/tests/tests/permissionpolicy/res/raw/android_manifest.xml
@@ -5960,7 +5960,7 @@
<!-- @hide @SystemApi Allows an application to observe usage time of apps. The app can register
for callbacks when apps reach a certain usage time limit, etc. -->
<permission android:name="android.permission.OBSERVE_APP_USAGE"
- android:protectionLevel="signature|privileged" />
+ android:protectionLevel="signature|privileged|role" />
<!-- @hide @TestApi @SystemApi Allows an application to change the app idle state of an app.
<p>Not for use by third-party applications. -->
@@ -6591,7 +6591,7 @@
it will be ignored.
@hide -->
<permission android:name="android.permission.MODIFY_DAY_NIGHT_MODE"
- android:protectionLevel="signature|privileged" />
+ android:protectionLevel="signature|privileged|role" />
<!-- @SystemApi Allows entering or exiting car mode using a specified priority.
This permission is required to use UiModeManager while specifying a priority for the calling
diff --git a/tests/tests/wifi/src/android/net/wifi/aware/cts/SingleDeviceTest.java b/tests/tests/wifi/src/android/net/wifi/aware/cts/SingleDeviceTest.java
index 74fdf642e09..a23a8904b4f 100644
--- a/tests/tests/wifi/src/android/net/wifi/aware/cts/SingleDeviceTest.java
+++ b/tests/tests/wifi/src/android/net/wifi/aware/cts/SingleDeviceTest.java
@@ -680,8 +680,8 @@ public class SingleDeviceTest extends WifiJUnit3TestBase {
Characteristics characteristics = mWifiAwareManager.getCharacteristics();
assertNotNull("Wi-Fi Aware characteristics are null", characteristics);
assertEquals("Service Name Length", characteristics.getMaxServiceNameLength(), 255);
- assertEquals("Service Specific Information Length",
- characteristics.getMaxServiceSpecificInfoLength(), 255);
+ assertTrue("Service Specific Information Length",
+ characteristics.getMaxServiceSpecificInfoLength() >= 255);
assertEquals("Match Filter Length", characteristics.getMaxMatchFilterLength(), 255);
assertNotEquals("Cipher suites", characteristics.getSupportedCipherSuites(), 0);
assertTrue("Max number of NDP", characteristics.getNumberOfSupportedDataPaths() > 0);