summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-07-13 17:10:00 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-07-13 17:10:00 +0000
commit3a70ae058b1376285d03d791666457c1353bf3c5 (patch)
treead6d88f91f55ca01288f16c6ad4f886896588196
parentd4b7835dd637800ff861c409feb7946f42068809 (diff)
parentee7ac59e52437ef85ec6f8feb12cab809e387842 (diff)
downloadcts-android14-mainline-adbd-release.tar.gz
Snap for 10491609 from ee7ac59e52437ef85ec6f8feb12cab809e387842 to mainline-adbd-releaseaml_adb_340912530aml_adb_340912350aml_adb_340912200aml_adb_340912000android14-mainline-adbd-release
Change-Id: Ifbfe30ca33586ab9badbc33fcaa943aaf3ef41ea
-rwxr-xr-xapps/CameraITS/tools/run_all_tests.py6
-rw-r--r--apps/CtsVerifier/AndroidManifest.xml6
-rw-r--r--apps/CtsVerifier/src/com/android/cts/verifier/ManifestTestListAdapter.java8
-rw-r--r--common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/users/UserReference.java9
-rw-r--r--common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/users/Users.java5
-rw-r--r--hostsidetests/appcompat/compatchanges/src/com/android/cts/appcompat/CompatChangesValidConfigTest.java6
-rw-r--r--hostsidetests/appsearch/src/android/appsearch/cts/AppSearchMultiUserTest.java2
-rw-r--r--hostsidetests/appsearch/src/android/appsearch/cts/AppSearchPackageTest.java2
-rw-r--r--hostsidetests/appsearch/src/android/appsearch/cts/ContactsIndexerMultiUserTest.java8
-rw-r--r--hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java61
-rw-r--r--hostsidetests/scopedstorage/host/src/android/scopedstorage/cts/host/LegacyStorageHostTest.java5
-rw-r--r--hostsidetests/scopedstorage/legacy/src/android/scopedstorage/cts/legacy/LegacyStorageTest.java29
-rw-r--r--tests/PhotoPicker/src/android/photopicker/cts/PhotoPickerBannersTest.java1
-rw-r--r--tests/PhotoPicker/src/android/photopicker/cts/PickerProviderMediaGenerator.java19
-rw-r--r--tests/PhotoPicker/src/android/photopicker/cts/cloudproviders/CloudProviderPrimary.java2
-rw-r--r--tests/PhotoPicker/src/android/photopicker/cts/cloudproviders/CloudProviderSecondary.java2
-rw-r--r--tests/accessibilityservice/src/android/accessibilityservice/cts/FullScreenMagnificationGestureHandlerTest.java5
-rw-r--r--tests/app/StorageDelegator/Android.bp1
-rw-r--r--tests/app/app/Android.bp1
-rw-r--r--tests/autofillservice/src/android/autofillservice/cts/dialog/LoginActivityTest.java49
-rw-r--r--tests/autofillservice/src/android/autofillservice/cts/dropdown/LoginActivityTest.java43
-rw-r--r--tests/autofillservice/src/android/autofillservice/cts/testcore/UiBot.java4
-rw-r--r--tests/camera/src/android/hardware/camera2/cts/RobustnessTest.java15
-rw-r--r--tests/devicepolicy/src/android/devicepolicy/cts/ScreenCaptureDisabledTest.java6
-rw-r--r--tests/devicepolicy/telephony/src/android/devicepolicy/cts/telephony/WorkProfileTelephonyTest.java6
-rw-r--r--tests/framework/base/windowmanager/src/android/server/wm/PinnedStackTests.java8
-rw-r--r--tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsAnimationControllerTests.java24
-rw-r--r--tests/inputmethod/src/android/view/inputmethod/cts/InputMethodPickerTest.java3
-rw-r--r--tests/tests/content/src/android/content/pm/cts/PackageManagerShellCommandIncrementalTest.java2
-rw-r--r--tests/tests/hibernation/src/android/hibernation/cts/AppHibernationUtils.kt30
-rw-r--r--tests/tests/icu/CtsIcu4cTestCases.xml4
-rw-r--r--tests/tests/media/decoder/src/android/media/decoder/cts/DecodeOnlyTest.java149
-rw-r--r--tests/tests/media/decoder/src/android/media/decoder/cts/DecoderRenderTest.java6
-rw-r--r--tests/tests/os/Android.bp1
-rw-r--r--tests/tests/sharesheet/src/android/sharesheet/cts/CtsSharesheetDeviceTest.java12
-rw-r--r--tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/RetrieveConnectionInfoAndReturnStatusService.java5
-rw-r--r--tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/RetrieveScanResultsAndReturnStatusService.java5
-rw-r--r--tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/RetrieveTransportInfoAndReturnStatusService.java8
-rw-r--r--tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/TriggerScanAndReturnStatusService.java5
-rw-r--r--tests/tests/wifi/src/android/net/wifi/aware/cts/SingleDeviceTest.java29
-rw-r--r--tests/tests/wifi/src/android/net/wifi/cts/ConcurrencyTest.java31
-rw-r--r--tests/tests/wifi/src/android/net/wifi/cts/ConnectedNetworkScorerTest.java173
-rw-r--r--tests/tests/wifi/src/android/net/wifi/cts/TestHelper.java7
-rw-r--r--tests/tests/wifi/src/android/net/wifi/cts/WifiLocationInfoBackgroundTest.java (renamed from tests/tests/wifi/src/android/net/wifi/cts/WifiLocationInfoTest.java)249
-rw-r--r--tests/tests/wifi/src/android/net/wifi/cts/WifiLocationInfoForegroundTest.java272
-rw-r--r--tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java10
-rw-r--r--tests/tests/wifi/src/android/net/wifi/cts/WifiResourceUtil.java70
-rw-r--r--tests/videocodec/src/android/videocodec/cts/VideoDecodeEditEncodeTest.java2
-rw-r--r--tests/videocodec/src/android/videocodec/cts/VideoEncoderAdaptiveBitRateTest.java4
-rw-r--r--tests/videocodec/src/android/videocodec/cts/VideoEncoderFrameRateTest.java4
-rw-r--r--tests/videocodec/src/android/videocodec/cts/VideoEncoderIntraFrameIntervalTest.java4
-rw-r--r--tests/videocodec/src/android/videocodec/cts/VideoEncoderMaxBFrameTest.java4
-rw-r--r--tests/videocodec/src/android/videocodec/cts/VideoEncoderMinMaxTest.java4
-rw-r--r--tests/videocodec/src/android/videocodec/cts/VideoEncoderMultiResTest.java4
-rw-r--r--tests/videocodec/src/android/videocodec/cts/VideoEncoderPsnrTest.java4
-rw-r--r--tests/videocodec/src/android/videocodec/cts/VideoEncoderQualityRegressionTest.java22
-rw-r--r--tests/videocodec/src/android/videocodec/cts/VideoEncoderTargetBitrateTest.java4
-rw-r--r--tools/cts-tradefed/Android.bp2
58 files changed, 1011 insertions, 451 deletions
diff --git a/apps/CameraITS/tools/run_all_tests.py b/apps/CameraITS/tools/run_all_tests.py
index 1115a9388ba..b55e61d117d 100755
--- a/apps/CameraITS/tools/run_all_tests.py
+++ b/apps/CameraITS/tools/run_all_tests.py
@@ -163,7 +163,11 @@ SUB_CAMERA_TESTS = {
}
_LIGHTING_CONTROL_TESTS = [
- 'test_auto_flash.py'
+ 'test_auto_flash.py',
+ 'test_preview_min_frame_rate.py',
+ 'test_led_snapshot.py',
+ 'test_night_extension.py',
+ 'test_hdr_extension.py',
]
_DST_SCENE_DIR = '/sdcard/Download/'
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 015f9a6122b..5745d794116 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -18,7 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.verifier"
android:versionCode="5"
- android:versionName="14_r1">
+ android:versionName="14_r2">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="34"/>
@@ -4628,10 +4628,6 @@
<meta-data android:name="test_excluded_features"
android:value="android.hardware.type.television:android.software.leanback:android.hardware.type.automotive" />
<meta-data android:name="display_mode" android:value="single_display_mode" />
- <meta-data
- android:name="test_required_configs"
- android:value="config_battery_supported" />
- <meta-data android:name="CddTest" android:value="7.3/C-1-5" />
</activity>
<service
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/ManifestTestListAdapter.java b/apps/CtsVerifier/src/com/android/cts/verifier/ManifestTestListAdapter.java
index e44903d4a14..f285f0fec3f 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/ManifestTestListAdapter.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/ManifestTestListAdapter.java
@@ -33,7 +33,6 @@ import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.ListView;
-import com.android.compatibility.common.util.BatteryUtils;
import com.android.cts.verifier.TestListActivity.DisplayMode;
import com.android.modules.utils.build.SdkLevel;
@@ -149,8 +148,6 @@ public class ManifestTestListAdapter extends TestListAdapter {
private static final String TEST_PASS_MODE = "test_pass_mode";
- private static final String CONFIG_BATTERY_SUPPORTED = "config_battery_supported";
-
private static final String CONFIG_NO_EMULATOR = "config_no_emulator";
private static final String CONFIG_VOICE_CAPABLE = "config_voice_capable";
@@ -506,11 +503,6 @@ public class ManifestTestListAdapter extends TestListAdapter {
exception);
}
break;
- case CONFIG_BATTERY_SUPPORTED:
- if (!BatteryUtils.hasBattery()) {
- return false;
- }
- break;
case CONFIG_QUICK_SETTINGS_SUPPORTED:
if (!getSystemResourceFlag(context, "config_quickSettingsSupported")) {
return false;
diff --git a/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/users/UserReference.java b/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/users/UserReference.java
index ab243516a68..61cdd7515ed 100644
--- a/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/users/UserReference.java
+++ b/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/users/UserReference.java
@@ -929,7 +929,12 @@ public final class UserReference implements AutoCloseable {
return user;
}
+ /**
+ * Note: This method should not be run on < S.
+ */
private UserInfo userInfo() {
+ Versions.requireMinimumVersion(S);
+
return users().filter(ui -> ui.id == id()).findFirst()
.orElseThrow(() -> new NeneException("User does not exist " + this));
}
@@ -967,6 +972,10 @@ public final class UserReference implements AutoCloseable {
* Get the reason this user cannot be switched to. Null if none.
*/
public String getSwitchToUserError() {
+ if (!Versions.meetsMinimumSdkVersionRequirement(S)) {
+ return null;
+ }
+
if (TestApis.users().isHeadlessSystemUserMode() && equals(TestApis.users().system())) {
return "Cannot switch to system user on HSUM devices";
}
diff --git a/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/users/Users.java b/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/users/Users.java
index 80edf68fbfe..9c257af607f 100644
--- a/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/users/Users.java
+++ b/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/users/Users.java
@@ -575,7 +575,12 @@ public final class Users {
return UserManager.supportsMultipleUsers();
}
+ /**
+ * Note: This method should not be run on < S.
+ */
static Stream<UserInfo> users() {
+ Versions.requireMinimumVersion(S);
+
if (Permissions.sIgnorePermissions.get()) {
return sUserManager.getUsers(
/* excludePartial= */ false,
diff --git a/hostsidetests/appcompat/compatchanges/src/com/android/cts/appcompat/CompatChangesValidConfigTest.java b/hostsidetests/appcompat/compatchanges/src/com/android/cts/appcompat/CompatChangesValidConfigTest.java
index e475a41ac2e..51daffd70a3 100644
--- a/hostsidetests/appcompat/compatchanges/src/com/android/cts/appcompat/CompatChangesValidConfigTest.java
+++ b/hostsidetests/appcompat/compatchanges/src/com/android/cts/appcompat/CompatChangesValidConfigTest.java
@@ -39,6 +39,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
public final class CompatChangesValidConfigTest extends CompatChangeGatingTestCase {
private static final long RESTRICT_STORAGE_ACCESS_FRAMEWORK = 141600225L;
+ private static final long SPLIT_AS_STREAM_RETURNS_SINGLE_EMPTY_STRING = 288845345L;
private static final String FEATURE_WATCH = "android.hardware.type.watch";
private static final Set<String> OVERRIDES_ALLOWLIST = ImmutableSet.of(
@@ -168,6 +169,11 @@ public final class CompatChangesValidConfigTest extends CompatChangeGatingTestCa
}
}
}
+
+ // Exclude SPLIT_AS_STREAM_RETURNS_SINGLE_EMPTY_STRING
+ // This feature is enabled only from U for apps targeting SDK 34+, see b/288845345
+ changes.removeIf(c -> c.changeId == SPLIT_AS_STREAM_RETURNS_SINGLE_EMPTY_STRING);
+
return changes;
}
diff --git a/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchMultiUserTest.java b/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchMultiUserTest.java
index b318d55480e..e1223580811 100644
--- a/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchMultiUserTest.java
+++ b/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchMultiUserTest.java
@@ -26,6 +26,7 @@ import com.android.tradefed.testtype.junit4.AfterClassWithInfo;
import com.android.tradefed.testtype.junit4.BeforeClassWithInfo;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -45,6 +46,7 @@ import java.util.Map;
* <p>Unlock your device when test locally.
*/
@RunWith(DeviceJUnit4ClassRunner.class)
+@Ignore("b/290690596 Re-enable tests after fixing flaky behavior.")
public class AppSearchMultiUserTest extends AppSearchHostTestBase {
private static int sInitialUserId;
diff --git a/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchPackageTest.java b/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchPackageTest.java
index e9b29936f82..ecf488a0982 100644
--- a/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchPackageTest.java
+++ b/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchPackageTest.java
@@ -23,6 +23,7 @@ import com.android.tradefed.util.RunUtil;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -39,6 +40,7 @@ import org.junit.runner.RunWith;
* <p>Unlock your device when test locally.
*/
@RunWith(DeviceJUnit4ClassRunner.class)
+@Ignore("b/290690596 Re-enable tests after fixing flaky behavior.")
public class AppSearchPackageTest extends AppSearchHostTestBase {
private int mPrimaryUserId;
diff --git a/hostsidetests/appsearch/src/android/appsearch/cts/ContactsIndexerMultiUserTest.java b/hostsidetests/appsearch/src/android/appsearch/cts/ContactsIndexerMultiUserTest.java
index 245f0c0ac4a..1e667679a4f 100644
--- a/hostsidetests/appsearch/src/android/appsearch/cts/ContactsIndexerMultiUserTest.java
+++ b/hostsidetests/appsearch/src/android/appsearch/cts/ContactsIndexerMultiUserTest.java
@@ -39,6 +39,8 @@ import java.util.Collections;
* <p>Unlock your device when testing locally.
*/
@RunWith(DeviceJUnit4ClassRunner.class)
+@Ignore("b/285969557 Re-enable tests after figuring out a better way to wait for lifecycle "
+ + "events to complete")
public class ContactsIndexerMultiUserTest extends AppSearchHostTestBase {
private static int sSecondaryUserId;
@@ -90,9 +92,6 @@ public class ContactsIndexerMultiUserTest extends AppSearchHostTestBase {
}
@Test
- @Ignore
- // TODO(b/285969557) Re-enable test after figuring out a better way to wait for lifecycle events
- // to complete
public void testMultiUser_CiDisabled_cancelsFullUpdateJobs() throws Exception {
setCiEnabled(getDevice(), false);
startUserAndInstallPackage();
@@ -102,9 +101,6 @@ public class ContactsIndexerMultiUserTest extends AppSearchHostTestBase {
}
@Test
- @Ignore
- // TODO(b/285969557) Re-enable test after figuring out a better way to wait for lifecycle events
- // to complete
public void testMultiUser_CiDisabledAndThenEnabled_schedulesFullUpdateJobs() throws Exception {
setCiEnabled(getDevice(), false);
setCiEnabled(getDevice(), true);
diff --git a/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java b/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java
index a31088616c3..466060d1e23 100644
--- a/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java
+++ b/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/DocumentsClientTest.java
@@ -18,6 +18,8 @@ package com.android.cts.documentclient;
import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION;
import static android.content.Intent.FLAG_GRANT_WRITE_URI_PERMISSION;
+import static android.os.SystemClock.uptimeMillis;
+import static android.text.format.DateUtils.SECOND_IN_MILLIS;
import android.app.Activity;
import android.content.ContentResolver;
@@ -42,7 +44,6 @@ import android.support.test.uiautomator.UiScrollable;
import android.support.test.uiautomator.UiSelector;
import android.test.MoreAsserts;
import android.text.TextUtils;
-import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -78,29 +79,52 @@ public class DocumentsClientTest extends DocumentsClientTestCase {
private static final Duration SCROLL_ACKNOWLEDGEMENT_TIMEOUT = Duration.ofMillis(500);
private long mOriginalScrollAcknowledgementTimeout;
- private UiSelector findRootListSelector() throws UiObjectNotFoundException {
+ private UiSelector findRootListSelector() {
return new UiSelector().resourceId(
getDocumentsUiPackageId() + ":id/container_roots").childSelector(
new UiSelector().resourceId(getDocumentsUiPackageId() + ":id/roots_list"));
}
- private void revealRoot(UiSelector rootsList, String label) throws UiObjectNotFoundException {
- // We might need to expand drawer if not visible
- if (!new UiObject(rootsList).waitForExists(TIMEOUT)) {
- Log.d(TAG, "Failed to find roots list; trying to expand");
- final UiSelector hamburger = new UiSelector().resourceId(
- getDocumentsUiPackageId() + ":id/toolbar").childSelector(
- new UiSelector().className("android.widget.ImageButton").clickable(true));
- new UiObject(hamburger).click();
- }
+ private UiSelector toolbarSelector() {
+ return new UiSelector().resourceId(getDocumentsUiPackageId() + ":id/toolbar");
+ }
- // Wait for the first list item to appear
- assertTrue("First list item",
- new UiObject(rootsList.childSelector(new UiSelector())).waitForExists(TIMEOUT));
+ private UiSelector hamburgerButtonSelector() {
+ return toolbarSelector().childSelector(
+ new UiSelector().className("android.widget.ImageButton").clickable(true));
+ }
+
+ private void revealRoot(UiSelector rootsListSelector, String label)
+ throws UiObjectNotFoundException {
+ waitForRootList(rootsListSelector);
// Now scroll around to find our item
- new UiScrollable(rootsList).scrollIntoView(new UiSelector().text(label));
+ new UiScrollable(rootsListSelector).scrollIntoView(new UiSelector().text(label));
+ }
+
+
+ private void waitForRootList(UiSelector rootsListSelector) throws UiObjectNotFoundException {
+ final UiObject rootList = new UiObject(rootsListSelector);
+ final UiObject hamburgerBtn = new UiObject(hamburgerButtonSelector());
+ boolean hamburgerBtnClicked = false;
+
+ final long startMills = uptimeMillis();
+ while (!rootList.waitForExists(SECOND_IN_MILLIS)) {
+ if (uptimeMillis() - startMills > TIMEOUT) break;
+
+ // We could not find the root list, this might be because the drawer is not visible.
+ // See if the drawer opening hamburger button exists, and if so click on it.
+ if (!hamburgerBtnClicked && hamburgerBtn.exists()) {
+ hamburgerBtn.click();
+ hamburgerBtnClicked = true;
+ }
+ }
+
+ // Wait for the first list item to appear
+ assertTrue("Could not find any items in the root list",
+ new UiObject(rootsListSelector.childSelector(new UiSelector()))
+ .waitForExists(TIMEOUT - (uptimeMillis() - startMills)));
}
private UiObject findSearchViewTextField() {
@@ -175,13 +199,12 @@ public class DocumentsClientTest extends DocumentsClientTestCase {
.childSelector(new UiSelector().resourceId("android:id/button1")));
}
- private UiObject findPositiveButton() throws UiObjectNotFoundException {
+ private UiObject findPositiveButton() {
return new UiObject(new UiSelector().resourceId("android:id/button1"));
}
- private boolean checkToolbarTitleEquals(String label) throws UiObjectNotFoundException {
- final UiObject title = new UiObject(new UiSelector().resourceId(
- getDocumentsUiPackageId() + ":id/toolbar").childSelector(
+ private boolean checkToolbarTitleEquals(String label) {
+ final UiObject title = new UiObject(toolbarSelector().childSelector(
new UiSelector().className("android.widget.TextView").text(label)));
return title.waitForExists(TIMEOUT);
diff --git a/hostsidetests/scopedstorage/host/src/android/scopedstorage/cts/host/LegacyStorageHostTest.java b/hostsidetests/scopedstorage/host/src/android/scopedstorage/cts/host/LegacyStorageHostTest.java
index 5638e41c0de..e0dc9463ee1 100644
--- a/hostsidetests/scopedstorage/host/src/android/scopedstorage/cts/host/LegacyStorageHostTest.java
+++ b/hostsidetests/scopedstorage/host/src/android/scopedstorage/cts/host/LegacyStorageHostTest.java
@@ -304,6 +304,11 @@ public class LegacyStorageHostTest extends BaseHostTestCase {
runDeviceTest("testUpdateToExternalDirsViaRelativePath");
}
+ @Test
+ public void testInsertToOtherAppPrivateDirFails() throws Exception {
+ runDeviceTest("testInsertToOtherAppPrivateDirFails");
+ }
+
private void allowAppOps(String... ops) throws Exception {
for (String op : ops) {
executeShellCommand("cmd appops set --uid android.scopedstorage.cts.legacy "
diff --git a/hostsidetests/scopedstorage/legacy/src/android/scopedstorage/cts/legacy/LegacyStorageTest.java b/hostsidetests/scopedstorage/legacy/src/android/scopedstorage/cts/legacy/LegacyStorageTest.java
index 40c9063f0a6..33a838ed42d 100644
--- a/hostsidetests/scopedstorage/legacy/src/android/scopedstorage/cts/legacy/LegacyStorageTest.java
+++ b/hostsidetests/scopedstorage/legacy/src/android/scopedstorage/cts/legacy/LegacyStorageTest.java
@@ -1139,6 +1139,35 @@ public class LegacyStorageTest {
verifyUpdateToExternalPrivateDirsViaRelativePath_denied();
}
+ @Test
+ public void testInsertToOtherAppPrivateDirFails() throws Exception {
+ try {
+ ContentValues values = new ContentValues();
+ values.put(MediaStore.Files.FileColumns.DATA,
+ "/storage/emulated/0/Android/media/com.example.aospoc/../../../../../../../."
+ + "./../../storage/emulated/0/Android/data/com.android"
+ + ".gallery3d/secret.txt/../../../../../../../../../../../../."
+ + "./storage/emulated/0/Android/data/com.android.gallery3d/text.txt");
+
+ getContentResolver().insert(MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL),
+ values);
+ fail("Insertion expected to fail for private path");
+ } catch (IllegalArgumentException expected) {
+ }
+
+ try {
+ ContentValues values = new ContentValues();
+ values.put(MediaStore.Files.FileColumns.RELATIVE_PATH,
+ "Android/data/com.example.aospoc/");
+ values.put(MediaStore.Files.FileColumns.DISPLAY_NAME, "text.txt");
+
+ getContentResolver().insert(MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL),
+ values);
+ fail("Insertion expected to fail for private path");
+ } catch (IllegalArgumentException expected) {
+ }
+ }
+
private static void assertCanCreateFile(File file) throws IOException {
if (file.exists()) {
file.delete();
diff --git a/tests/PhotoPicker/src/android/photopicker/cts/PhotoPickerBannersTest.java b/tests/PhotoPicker/src/android/photopicker/cts/PhotoPickerBannersTest.java
index 9c4d411ef5c..315a1dc0145 100644
--- a/tests/PhotoPicker/src/android/photopicker/cts/PhotoPickerBannersTest.java
+++ b/tests/PhotoPicker/src/android/photopicker/cts/PhotoPickerBannersTest.java
@@ -122,6 +122,7 @@ public class PhotoPickerBannersTest extends PhotoPickerBaseTest {
}
@Test
+ @Ignore("b/290892213")
public void testChooseAppBannerOnDismiss() throws Exception {
// 1. Setting up the 'Choose App' banner.
setCloudMediaInfoForChooseAppBanner();
diff --git a/tests/PhotoPicker/src/android/photopicker/cts/PickerProviderMediaGenerator.java b/tests/PhotoPicker/src/android/photopicker/cts/PickerProviderMediaGenerator.java
index 216b5de1d1f..32a874a9974 100644
--- a/tests/PhotoPicker/src/android/photopicker/cts/PickerProviderMediaGenerator.java
+++ b/tests/PhotoPicker/src/android/photopicker/cts/PickerProviderMediaGenerator.java
@@ -19,6 +19,7 @@ package android.photopicker.cts;
import static android.provider.CloudMediaProviderContract.AlbumColumns;
import static android.provider.CloudMediaProviderContract.EXTRA_ALBUM_ID;
import static android.provider.CloudMediaProviderContract.EXTRA_MEDIA_COLLECTION_ID;
+import static android.provider.CloudMediaProviderContract.EXTRA_PAGE_SIZE;
import static android.provider.CloudMediaProviderContract.EXTRA_SYNC_GENERATION;
import static android.provider.CloudMediaProviderContract.MediaCollectionInfo;
import static android.provider.CloudMediaProviderContract.MediaColumns;
@@ -91,23 +92,25 @@ public class PickerProviderMediaGenerator {
mPrivateDir = context.getFilesDir();
}
- public Cursor getMedia(long generation, String albumId, String mimeType, long sizeBytes) {
+ public Cursor getMedia(long generation, String albumId, String mimeType, long sizeBytes,
+ int pageSize) {
final Cursor cursor = getCursor(mMedia, generation, albumId, mimeType, sizeBytes,
/* isDeleted */ false);
- cursor.setExtras(buildCursorExtras(mCollectionId, generation > 0, albumId != null));
+ cursor.setExtras(buildCursorExtras(mCollectionId, generation > 0, albumId != null,
+ pageSize > -1));
return cursor;
}
public Cursor getAlbums(String mimeType, long sizeBytes) {
final Cursor cursor = getCursor(mAlbums, mimeType, sizeBytes);
- cursor.setExtras(buildCursorExtras(mCollectionId, false, false));
+ cursor.setExtras(buildCursorExtras(mCollectionId, false, false, false));
return cursor;
}
public Cursor getDeletedMedia(long generation) {
final Cursor cursor = getCursor(mDeletedMedia, generation, /* albumId */ null,
/* mimeType */ null, /* sizeBytes */ 0, /* isDeleted */ true);
- cursor.setExtras(buildCursorExtras(mCollectionId, generation > 0, false));
+ cursor.setExtras(buildCursorExtras(mCollectionId, generation > 0, false, false));
return cursor;
}
@@ -128,7 +131,7 @@ public class PickerProviderMediaGenerator {
}
public Bundle buildCursorExtras(String mediaCollectionId, boolean honoredSyncGeneration,
- boolean honoredAlbumdId) {
+ boolean honoredAlbumdId, boolean honoredPageSize) {
final ArrayList<String> honoredArgs = new ArrayList<>();
if (honoredSyncGeneration) {
honoredArgs.add(EXTRA_SYNC_GENERATION);
@@ -137,6 +140,10 @@ public class PickerProviderMediaGenerator {
honoredArgs.add(EXTRA_ALBUM_ID);
}
+ if (honoredPageSize) {
+ honoredArgs.add(EXTRA_PAGE_SIZE);
+ }
+
final Bundle bundle = new Bundle();
bundle.putString(EXTRA_MEDIA_COLLECTION_ID, mediaCollectionId);
bundle.putStringArrayList(ContentResolver.EXTRA_HONORED_ARGS, honoredArgs);
@@ -425,6 +432,7 @@ public class PickerProviderMediaGenerator {
public final String mimeType;
public final long sizeBytes;
public final long generation;
+ public final int pageSize;
public QueryExtras(Bundle bundle) {
if (bundle == null) {
@@ -435,6 +443,7 @@ public class PickerProviderMediaGenerator {
mimeType = bundle.getString(Intent.EXTRA_MIME_TYPES, null);
sizeBytes = bundle.getLong(CloudMediaProviderContract.EXTRA_SIZE_LIMIT_BYTES, 0);
generation = bundle.getLong(CloudMediaProviderContract.EXTRA_SYNC_GENERATION, 0);
+ pageSize = bundle.getInt(CloudMediaProviderContract.EXTRA_PAGE_SIZE, -1);
}
}
}
diff --git a/tests/PhotoPicker/src/android/photopicker/cts/cloudproviders/CloudProviderPrimary.java b/tests/PhotoPicker/src/android/photopicker/cts/cloudproviders/CloudProviderPrimary.java
index 3f801950dcf..1b90695098e 100644
--- a/tests/PhotoPicker/src/android/photopicker/cts/cloudproviders/CloudProviderPrimary.java
+++ b/tests/PhotoPicker/src/android/photopicker/cts/cloudproviders/CloudProviderPrimary.java
@@ -65,7 +65,7 @@ public class CloudProviderPrimary extends CloudMediaProvider {
final QueryExtras queryExtras = new QueryExtras(extras);
return mMediaGenerator.getMedia(queryExtras.generation, queryExtras.albumId,
- queryExtras.mimeType, queryExtras.sizeBytes);
+ queryExtras.mimeType, queryExtras.sizeBytes, queryExtras.pageSize);
}
@Override
diff --git a/tests/PhotoPicker/src/android/photopicker/cts/cloudproviders/CloudProviderSecondary.java b/tests/PhotoPicker/src/android/photopicker/cts/cloudproviders/CloudProviderSecondary.java
index f5bde67be1b..a951e7cc2c4 100644
--- a/tests/PhotoPicker/src/android/photopicker/cts/cloudproviders/CloudProviderSecondary.java
+++ b/tests/PhotoPicker/src/android/photopicker/cts/cloudproviders/CloudProviderSecondary.java
@@ -50,7 +50,7 @@ public class CloudProviderSecondary extends CloudMediaProvider {
final QueryExtras queryExtras = new QueryExtras(extras);
return mMediaGenerator.getMedia(queryExtras.generation, queryExtras.albumId,
- queryExtras.mimeType, queryExtras.sizeBytes);
+ queryExtras.mimeType, queryExtras.sizeBytes, queryExtras.pageSize);
}
@Override
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/FullScreenMagnificationGestureHandlerTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/FullScreenMagnificationGestureHandlerTest.java
index 3feb8230713..e114da5d817 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/FullScreenMagnificationGestureHandlerTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/FullScreenMagnificationGestureHandlerTest.java
@@ -279,9 +279,12 @@ public class FullScreenMagnificationGestureHandlerTest {
dispatch(doubleTap(mTapLocation));
mTouchListener.assertPropagated(ACTION_DOWN, ACTION_UP, ACTION_DOWN, ACTION_UP);
+ // Smaller display devices does not have much screen space in Zoomed state
+ PackageManager pm = mInstrumentation.getTargetContext().getPackageManager();
+ int y = (pm.hasSystemFeature(pm.FEATURE_WATCH)) ? 5 : 29;
dispatch(swipe(
mTapLocation,
- add(mTapLocation, 0, 29)));
+ add(mTapLocation, 0, y)));
mTouchListener.assertPropagated(ACTION_DOWN, ACTION_MOVE, ACTION_UP);
}
diff --git a/tests/app/StorageDelegator/Android.bp b/tests/app/StorageDelegator/Android.bp
index 9e1b7468c04..bd389584d91 100644
--- a/tests/app/StorageDelegator/Android.bp
+++ b/tests/app/StorageDelegator/Android.bp
@@ -28,6 +28,7 @@ android_test {
// Tag this module as a cts test artifact
test_suites: [
+ "cts",
"general-tests",
"sts",
],
diff --git a/tests/app/app/Android.bp b/tests/app/app/Android.bp
index 4044073d3b8..098f2b5571d 100644
--- a/tests/app/app/Android.bp
+++ b/tests/app/app/Android.bp
@@ -124,6 +124,7 @@ android_test {
],
// Tag this module as a cts test artifact
test_suites: [
+ "cts",
"general-tests",
"sts",
],
diff --git a/tests/autofillservice/src/android/autofillservice/cts/dialog/LoginActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/dialog/LoginActivityTest.java
index bab038cc97a..0e43f33592d 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/dialog/LoginActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/dialog/LoginActivityTest.java
@@ -36,6 +36,7 @@ import static android.view.View.AUTOFILL_HINT_USERNAME;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assume.assumeTrue;
import android.autofillservice.cts.R;
@@ -50,13 +51,16 @@ import android.autofillservice.cts.testcore.Helper;
import android.autofillservice.cts.testcore.IdMode;
import android.autofillservice.cts.testcore.InstrumentedAutoFillService.FillRequest;
import android.content.Intent;
+import android.graphics.drawable.Icon;
import android.platform.test.annotations.FlakyTest;
import android.util.Log;
import android.view.View;
+import android.widget.RemoteViews;
import androidx.test.uiautomator.UiObject2;
import com.android.compatibility.common.util.CddTest;
+import com.android.compatibility.common.util.RetryableException;
import org.junit.After;
import org.junit.Test;
@@ -977,6 +981,51 @@ public class LoginActivityTest extends AutoFillServiceTestCase.ManualActivityLau
assertThat(v.isCredential()).isFalse();
}
+ @Test
+ public void remoteViews_doesNotSpillAcrossUsers() throws Exception {
+ enableFillDialogFeature(sContext);
+ enableService();
+
+ RemoteViews header = createPresentation("Dialog Header");
+ RemoteViews dialogRv = createPresentation("Dialog Presentation");
+ // bad url, should not be displayed
+ header.setImageViewIcon(R.id.icon, Icon.createWithContentUri(
+ "content://1000@com.android.contacts/display_photo/1"));
+ dialogRv.setImageViewIcon(R.id.icon, Icon.createWithContentUri(
+ "content://1000@com.android.contacts/display_photo/1"));
+
+ // Set response with a dataset
+ final CannedFillResponse.Builder builder = new CannedFillResponse.Builder()
+ .addDataset(new CannedDataset.Builder()
+ .setField(ID_USERNAME, "dude")
+ .setField(ID_PASSWORD, "sweet")
+ .setPresentation(createPresentation("Dropdown Presentation"))
+ .setDialogPresentation(dialogRv)
+ .build())
+ .setDialogHeader(header)
+ .setDialogTriggerIds(ID_PASSWORD);
+ sReplier.addResponse(builder.build());
+
+ // Start activity and autofill
+ LoginActivity activity = startLoginActivity();
+ mUiBot.waitForIdleSync();
+
+ sReplier.getNextFillRequest();
+ mUiBot.waitForIdleSync();
+
+ // Click on password field to trigger fill dialog
+ mUiBot.selectByRelativeId(ID_PASSWORD);
+ mUiBot.waitForIdleSync();
+
+ // Asserts that the header is not shown
+ assertThrows(RetryableException.class,
+ () -> mUiBot.findFillDialogHeaderPicker());
+
+ // Asserts that the
+ assertThrows(RetryableException.class,
+ () -> mUiBot.findFillDialogDatasetPicker());
+ }
+
private FieldsNoPasswordActivity startNoPasswordActivity() throws Exception {
final Intent intent = new Intent(mContext, FieldsNoPasswordActivity.class)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
diff --git a/tests/autofillservice/src/android/autofillservice/cts/dropdown/LoginActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/dropdown/LoginActivityTest.java
index 6e324034603..5d71d8c7fb1 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/dropdown/LoginActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/dropdown/LoginActivityTest.java
@@ -75,6 +75,8 @@ import static com.android.compatibility.common.util.ShellUtils.tap;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
+import static org.junit.Assert.assertThrows;
+
import android.app.PendingIntent;
import android.app.assist.AssistStructure.ViewNode;
import android.autofillservice.cts.R;
@@ -104,6 +106,7 @@ import android.content.IntentFilter;
import android.content.IntentSender;
import android.graphics.Color;
import android.graphics.Rect;
+import android.graphics.drawable.Icon;
import android.os.Bundle;
import android.os.SystemClock;
import android.platform.test.annotations.AppModeFull;
@@ -1468,6 +1471,46 @@ public class LoginActivityTest extends LoginActivityCommonTestCase {
mActivity.assertAutoFilled();
}
+ @Test
+ public void remoteViews_doesNotSpillAcrossUsers() throws Exception {
+ // Set service.
+ enableService();
+
+
+ RemoteViews firstRv = createPresentation("hello");
+ RemoteViews secondRv = createPresentation("world");
+
+ // bad url, should not be displayed
+ firstRv.setImageViewIcon(R.id.icon,
+ Icon.createWithContentUri("content://1000@com.android.contacts/display_photo/1"));
+ secondRv.setImageViewIcon(R.id.icon,
+ Icon.createWithContentUri("content://1000@com.android.contacts/display_photo/1"));
+
+ // Set expectations.
+ sReplier.addResponse(new CannedFillResponse.Builder()
+ .addDataset(new CannedDataset.Builder()
+ .setField(ID_USERNAME, "dude", firstRv)
+ .setField(ID_PASSWORD, "sweet", secondRv)
+ .build())
+ .setHeader(firstRv)
+ .setFooter(secondRv)
+ .build());
+
+ mActivity.expectAutoFill("dude", "sweet");
+
+ // Trigger auto-fill.
+ requestFocusOnUsername();
+ sReplier.getNextFillRequest();
+
+ // Asser that the dataset is not shown
+ assertThrows(RetryableException.class,
+ () -> mUiBot.assertDatasets("The Dude"));
+
+ // Assert that header/footer is not shown
+ assertThrows(RetryableException.class,
+ () -> mUiBot.assertDatasetsWithBorders("hello", "world", "The Dude"));
+ }
+
/**
* Tests the scenario where the service uses custom remote views for different fields (username
* and password), but each dataset has a different number of fields.
diff --git a/tests/autofillservice/src/android/autofillservice/cts/testcore/UiBot.java b/tests/autofillservice/src/android/autofillservice/cts/testcore/UiBot.java
index ec19cf46b44..95a232a0717 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/testcore/UiBot.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/testcore/UiBot.java
@@ -1477,11 +1477,11 @@ public class UiBot {
return waitForObject(FILL_DIALOG_SELECTOR, UI_DATASET_PICKER_TIMEOUT);
}
- private UiObject2 findFillDialogDatasetPicker() throws Exception {
+ public UiObject2 findFillDialogDatasetPicker() throws Exception {
return waitForObject(FILL_DIALOG_DATASET_SELECTOR, UI_DATASET_PICKER_TIMEOUT);
}
- private UiObject2 findFillDialogHeaderPicker() throws Exception {
+ public UiObject2 findFillDialogHeaderPicker() throws Exception {
return waitForObject(FILL_DIALOG_HEADER_SELECTOR, UI_DATASET_PICKER_TIMEOUT);
}
diff --git a/tests/camera/src/android/hardware/camera2/cts/RobustnessTest.java b/tests/camera/src/android/hardware/camera2/cts/RobustnessTest.java
index 7bdd2a3560b..5347ff95bae 100644
--- a/tests/camera/src/android/hardware/camera2/cts/RobustnessTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/RobustnessTest.java
@@ -3124,8 +3124,8 @@ public class RobustnessTest extends Camera2AndroidTestCase {
CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP_MAXIMUM_RESOLUTION);
mMaxRawSize = (rawSizes.length != 0) ? CameraTestUtils.getMaxSize(rawSizes) : null;
- mMaxResolutionRawSize = (maxResConfigs != null)
- ? CameraTestUtils.getMaxSize(
+ mMaxResolutionRawSize = sm.isUltraHighResolutionSensor() ?
+ CameraTestUtils.getMaxSize(
maxResConfigs.getOutputSizes(ImageFormat.RAW_SENSOR))
: null;
@@ -3144,7 +3144,7 @@ public class RobustnessTest extends Camera2AndroidTestCase {
mMaxJpegSizes[RECORD] = getMaxRecordingSize(cameraId);
}
- if (maxResConfigs != null) {
+ if (sm.isUltraHighResolutionSensor()) {
mMaxYuvSizes[MAX_RES] = CameraTestUtils.getMaxSize(
maxResConfigs.getOutputSizes(ImageFormat.YUV_420_888));
mMaxJpegSizes[MAX_RES] = CameraTestUtils.getMaxSize(
@@ -3302,8 +3302,9 @@ public class RobustnessTest extends Camera2AndroidTestCase {
mMaxPrivInputSizes[INPUT_MAXIMUM] = privInputSizes != null
? CameraTestUtils.getMaxSize(privInputSizes)
: null;
- Size[] maxResPrivInputSizes = maxResConfigs != null
- ? maxResConfigs.getInputSizes(ImageFormat.PRIVATE)
+ Size[] maxResPrivInputSizes =
+ sm.isUltraHighResolutionSensor() ?
+ maxResConfigs.getInputSizes(ImageFormat.PRIVATE)
: null;
mMaxPrivInputSizes[INPUT_MAX_RES] = maxResPrivInputSizes != null
? CameraTestUtils.getMaxSize(maxResPrivInputSizes)
@@ -3313,8 +3314,8 @@ public class RobustnessTest extends Camera2AndroidTestCase {
mMaxYuvInputSizes[INPUT_MAXIMUM] = yuvInputSizes != null
? CameraTestUtils.getMaxSize(yuvInputSizes)
: null;
- Size[] maxResYuvInputSizes = maxResConfigs != null
- ? maxResConfigs.getInputSizes(ImageFormat.YUV_420_888)
+ Size[] maxResYuvInputSizes = sm.isUltraHighResolutionSensor() ?
+ maxResConfigs.getInputSizes(ImageFormat.YUV_420_888)
: null;
mMaxYuvInputSizes[INPUT_MAX_RES] = maxResYuvInputSizes != null
? CameraTestUtils.getMaxSize(maxResYuvInputSizes)
diff --git a/tests/devicepolicy/src/android/devicepolicy/cts/ScreenCaptureDisabledTest.java b/tests/devicepolicy/src/android/devicepolicy/cts/ScreenCaptureDisabledTest.java
index ebcfbb9fc21..24e7ba61a90 100644
--- a/tests/devicepolicy/src/android/devicepolicy/cts/ScreenCaptureDisabledTest.java
+++ b/tests/devicepolicy/src/android/devicepolicy/cts/ScreenCaptureDisabledTest.java
@@ -510,6 +510,12 @@ public final class ScreenCaptureDisabledTest {
sLocalDevicePolicyManager.getScreenCaptureDisabled(/* admin= */ null)).isTrue();
} finally {
+ TestApis.flags().set(
+ NAMESPACE_DEVICE_POLICY_MANAGER, ENABLE_DEVICE_POLICY_ENGINE_FLAG, "false");
+ sDeviceState.dpc().devicePolicyManager().setScreenCaptureDisabled(
+ sDeviceState.dpc().componentName(), /* disabled= */ false);
+ TestApis.flags().set(
+ NAMESPACE_DEVICE_POLICY_MANAGER, ENABLE_DEVICE_POLICY_ENGINE_FLAG, "true");
sDeviceState.dpc().devicePolicyManager().setScreenCaptureDisabled(
sDeviceState.dpc().componentName(), /* disabled= */ false);
TestApis.flags().set(
diff --git a/tests/devicepolicy/telephony/src/android/devicepolicy/cts/telephony/WorkProfileTelephonyTest.java b/tests/devicepolicy/telephony/src/android/devicepolicy/cts/telephony/WorkProfileTelephonyTest.java
index 5782d74fefa..35a371c073d 100644
--- a/tests/devicepolicy/telephony/src/android/devicepolicy/cts/telephony/WorkProfileTelephonyTest.java
+++ b/tests/devicepolicy/telephony/src/android/devicepolicy/cts/telephony/WorkProfileTelephonyTest.java
@@ -62,7 +62,6 @@ import android.telecom.Call;
import android.telecom.InCallService;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
-import android.telephony.PhoneNumberUtils;
import android.telephony.SmsManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -140,9 +139,8 @@ public final class WorkProfileTelephonyTest {
try (PermissionContext p = TestApis.permissions().withPermission(READ_PHONE_NUMBERS)) {
SubscriptionManager subscriptionManager = sContext.getSystemService(
SubscriptionManager.class);
- mDestinationNumber = PhoneNumberUtils.formatNumberToE164(
- subscriptionManager.getPhoneNumber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID),
- mTelephonyManager.getSimCountryIso());
+ mDestinationNumber =
+ subscriptionManager.getPhoneNumber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID);
}
}
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/PinnedStackTests.java b/tests/framework/base/windowmanager/src/android/server/wm/PinnedStackTests.java
index 4c3521ebc22..c9f5566fee4 100644
--- a/tests/framework/base/windowmanager/src/android/server/wm/PinnedStackTests.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/PinnedStackTests.java
@@ -856,7 +856,7 @@ public class PinnedStackTests extends ActivityManagerTestBase {
launchActivity(PIP_ACTIVITY);
mBroadcastActionTrigger.doAction(ACTION_ENTER_PIP);
waitForEnterPipAnimationComplete(PIP_ACTIVITY);
- int defaultDisplayWindowingMode = getDefaultDisplayWindowingMode(PIP_ACTIVITY);
+ int defaultDisplayWindowingMode = getDisplayAreaWindowingMode(PIP_ACTIVITY);
// Launch second PIP activity
launchActivity(PIP_ACTIVITY2, extraString(EXTRA_ENTER_PIP, "true"));
@@ -1840,10 +1840,8 @@ public class PinnedStackTests extends ActivityManagerTestBase {
assertTrue(displayRect.contains(pinnedStackBounds));
}
- private int getDefaultDisplayWindowingMode(ComponentName activityName) {
- Task task = mWmState.getTaskByActivity(activityName);
- return mWmState.getDisplay(task.mDisplayId)
- .getWindowingMode();
+ private int getDisplayAreaWindowingMode(ComponentName activityName) {
+ return mWmState.getTaskDisplayArea(activityName).getWindowingMode();
}
/**
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsAnimationControllerTests.java b/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsAnimationControllerTests.java
index 79f39ccd770..77d02a068bd 100644
--- a/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsAnimationControllerTests.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsAnimationControllerTests.java
@@ -160,8 +160,10 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase
public void setUpWindowInsetsAnimationControllerTests() throws Throwable {
assumeFalse(
"In Automotive, auxiliary inset changes can happen when IME inset changes, so "
- + "allow Automotive skip IME inset animation tests.",
- isCar() && mType == ime());
+ + "allow Automotive skip IME inset animation tests."
+ + "And if config_remoteInsetsControllerControlsSystemBars is enabled,"
+ + "SystemBar controls doesn't work, so allow skip inset animation tests.",
+ isCar() && (mType == ime() || remoteInsetsControllerControlsSystemBars()));
assertEquals("Test precondition failed: ValueAnimator.getDurationScale()",
1f, ValueAnimator.getDurationScale(), 0.001);
@@ -267,8 +269,6 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase
@Presubmit
@Test
public void testControl_andCancel() throws Throwable {
- assumeFalse(isCar() && remoteInsetsControllerControlsSystemBars() && mType != ime());
-
retryIfCancelled(() -> {
runOnUiThread(() -> {
setupAnimationListener();
@@ -289,8 +289,6 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase
@Test
public void testControl_andImmediatelyCancel() throws Throwable {
- assumeFalse(isCar() && remoteInsetsControllerControlsSystemBars() && mType != ime());
-
retryIfCancelled(() -> {
runOnUiThread(() -> {
setupAnimationListener();
@@ -308,8 +306,6 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase
@Presubmit
@Test
public void testControl_immediately_show() throws Throwable {
- assumeFalse(isCar() && remoteInsetsControllerControlsSystemBars() && mType != ime());
-
retryIfCancelled(() -> {
setVisibilityAndWait(mType, false);
@@ -333,8 +329,6 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase
@Presubmit
@Test
public void testControl_immediately_hide() throws Throwable {
- assumeFalse(isCar() && remoteInsetsControllerControlsSystemBars() && mType != ime());
-
retryIfCancelled(() -> {
setVisibilityAndWait(mType, true);
@@ -358,8 +352,6 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase
@Presubmit
@Test
public void testControl_transition_show() throws Throwable {
- assumeFalse(isCar() && remoteInsetsControllerControlsSystemBars() && mType != ime());
-
retryIfCancelled(() -> {
setVisibilityAndWait(mType, false);
@@ -381,8 +373,6 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase
@Presubmit
@Test
public void testControl_transition_hide() throws Throwable {
- assumeFalse(isCar() && remoteInsetsControllerControlsSystemBars() && mType != ime());
-
retryIfCancelled(() -> {
setVisibilityAndWait(mType, true);
@@ -404,8 +394,6 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase
@Presubmit
@Test
public void testControl_transition_show_interpolator() throws Throwable {
- assumeFalse(isCar() && remoteInsetsControllerControlsSystemBars() && mType != ime());
-
retryIfCancelled(() -> {
mInterpolator = new DecelerateInterpolator();
setVisibilityAndWait(mType, false);
@@ -428,8 +416,6 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase
@Presubmit
@Test
public void testControl_transition_hide_interpolator() throws Throwable {
- assumeFalse(isCar() && remoteInsetsControllerControlsSystemBars() && mType != ime());
-
retryIfCancelled(() -> {
mInterpolator = new AccelerateInterpolator();
setVisibilityAndWait(mType, true);
@@ -451,8 +437,6 @@ public class WindowInsetsAnimationControllerTests extends WindowManagerTestBase
@Test
public void testControl_andLoseControl() throws Throwable {
- assumeFalse(isCar() && remoteInsetsControllerControlsSystemBars() && mType != ime());
-
retryIfCancelled(() -> {
mInterpolator = new AccelerateInterpolator();
setVisibilityAndWait(mType, true);
diff --git a/tests/inputmethod/src/android/view/inputmethod/cts/InputMethodPickerTest.java b/tests/inputmethod/src/android/view/inputmethod/cts/InputMethodPickerTest.java
index a545e263222..bfad2fddbfe 100644
--- a/tests/inputmethod/src/android/view/inputmethod/cts/InputMethodPickerTest.java
+++ b/tests/inputmethod/src/android/view/inputmethod/cts/InputMethodPickerTest.java
@@ -75,6 +75,9 @@ public class InputMethodPickerTest extends MultiDisplayTestBase {
@After
public void tearDown() throws Exception {
+ if (!mContext.getPackageManager().hasSystemFeature(FEATURE_INPUT_METHODS)) {
+ return;
+ }
closeSystemDialogsAndWait();
}
diff --git a/tests/tests/content/src/android/content/pm/cts/PackageManagerShellCommandIncrementalTest.java b/tests/tests/content/src/android/content/pm/cts/PackageManagerShellCommandIncrementalTest.java
index 581f838c7e5..58d84368385 100644
--- a/tests/tests/content/src/android/content/pm/cts/PackageManagerShellCommandIncrementalTest.java
+++ b/tests/tests/content/src/android/content/pm/cts/PackageManagerShellCommandIncrementalTest.java
@@ -403,7 +403,7 @@ public class PackageManagerShellCommandIncrementalTest {
try {
mSession.start(Executors.newSingleThreadExecutor(),
IncrementalDeviceConnection.Factory.reliableExpectInstallationFailure());
- mSession.waitForAnyCompletion(3, TimeUnit.SECONDS);
+ mSession.waitForAnyCompletion(30, TimeUnit.SECONDS);
} finally {
getUiAutomation().dropShellPermissionIdentity();
}
diff --git a/tests/tests/hibernation/src/android/hibernation/cts/AppHibernationUtils.kt b/tests/tests/hibernation/src/android/hibernation/cts/AppHibernationUtils.kt
index fc9b77a5e43..88a8a325bef 100644
--- a/tests/tests/hibernation/src/android/hibernation/cts/AppHibernationUtils.kt
+++ b/tests/tests/hibernation/src/android/hibernation/cts/AppHibernationUtils.kt
@@ -126,23 +126,19 @@ fun runBootCompleteReceiver(context: Context, testTag: String) {
}
fun runAppHibernationJob(context: Context, tag: String) {
- // Sometimes first run observes stale package data
- // so run twice to prevent that
- repeat(2) {
- val userId = Process.myUserHandle().identifier
- val permissionControllerPackageName =
- context.packageManager.permissionControllerPackageName
- runShellCommandOrThrow("cmd jobscheduler run -u " +
- "$userId -f " +
- "$permissionControllerPackageName 2")
- eventually({
- Thread.sleep(JOB_RUN_WAIT_TIME)
- val jobState = runShellCommandOrThrow("cmd jobscheduler get-job-state -u " +
- "$userId " +
- "$permissionControllerPackageName 2")
- assertTrue("Job expected waiting but is $jobState", jobState.contains("waiting"))
- }, JOB_RUN_TIMEOUT)
- }
+ val userId = Process.myUserHandle().identifier
+ val permissionControllerPackageName =
+ context.packageManager.permissionControllerPackageName
+ runShellCommandOrThrow("cmd jobscheduler run -u " +
+ "$userId -f " +
+ "$permissionControllerPackageName 2")
+ eventually({
+ Thread.sleep(JOB_RUN_WAIT_TIME)
+ val jobState = runShellCommandOrThrow("cmd jobscheduler get-job-state -u " +
+ "$userId " +
+ "$permissionControllerPackageName 2")
+ assertTrue("Job expected waiting but is $jobState", jobState.contains("waiting"))
+ }, JOB_RUN_TIMEOUT)
}
fun runPermissionEventCleanupJob(context: Context) {
diff --git a/tests/tests/icu/CtsIcu4cTestCases.xml b/tests/tests/icu/CtsIcu4cTestCases.xml
index 70cdca53a9b..1ecdaa98a9d 100644
--- a/tests/tests/icu/CtsIcu4cTestCases.xml
+++ b/tests/tests/icu/CtsIcu4cTestCases.xml
@@ -67,8 +67,8 @@
<option name="set-option" value="module-name:intltest" />
<option name="set-option" value="runtime-hint:1m30s" />
<option name="set-option" value="no-fail-data-errors:true" />
- <!-- test-timeout unit is ms, value = 10 minutes -->
- <option name="set-option" value="native-test-timeout:600000" />
+ <!-- test-timeout unit is ms, value = 18 minutes -->
+ <option name="set-option" value="native-test-timeout:1080000" />
<!-- Sample include-filter to run a subset of tests in utility-->
<!-- <option name="set-option" value="include-filter:intltest.utility" /> -->
</test>
diff --git a/tests/tests/media/decoder/src/android/media/decoder/cts/DecodeOnlyTest.java b/tests/tests/media/decoder/src/android/media/decoder/cts/DecodeOnlyTest.java
index 34387673dc3..018b284d9f7 100644
--- a/tests/tests/media/decoder/src/android/media/decoder/cts/DecodeOnlyTest.java
+++ b/tests/tests/media/decoder/src/android/media/decoder/cts/DecodeOnlyTest.java
@@ -35,6 +35,7 @@ import android.media.cts.MediaTestBase;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
+import android.os.HandlerThread;
import android.os.Looper;
import android.platform.test.annotations.AppModeFull;
@@ -54,16 +55,19 @@ import org.junit.runner.RunWith;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.time.Duration;
+import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Queue;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Supplier;
@MediaHeavyPresubmitTest
@AppModeFull(reason = "There should be no instant apps specific behavior related to decoders")
-// BUFFER_FLAG_DECODE_ONLY was added in Android U.
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE, codeName = "UpsideDownCake")
@RunWith(AndroidJUnit4.class)
@ApiTest(apis = {"android.media.MediaCodec#BUFFER_FLAG_DECODE_ONLY"})
@@ -170,7 +174,6 @@ public class DecodeOnlyTest extends MediaTestBase {
testNonTunneledTrickPlay(VP9_VIDEO);
}
-
private void testNonTunneledTrickPlay(String fileName) throws Exception {
Preconditions.assertTestFileExists(MEDIA_DIR_STRING + fileName);
// create the video extractor
@@ -184,7 +187,6 @@ public class DecodeOnlyTest extends MediaTestBase {
MediaFormat videoFormat = videoExtractor.getTrackFormat(videoTrackIndex);
String mime = videoFormat.getString(MediaFormat.KEY_MIME);
MediaCodec videoCodec = MediaCodec.createDecoderByType(mime);
- videoCodec.configure(videoFormat, getActivity().getSurfaceHolder().getSurface(), null, 0);
AtomicBoolean done = new AtomicBoolean(false);
List<Long> expectedPresentationTimes = new ArrayList<>();
@@ -250,6 +252,7 @@ public class DecodeOnlyTest extends MediaTestBase {
}
});
+ videoCodec.configure(videoFormat, getActivity().getSurfaceHolder().getSurface(), null, 0);
// start the video the codec with track selected
videoCodec.start();
@@ -289,7 +292,6 @@ public class DecodeOnlyTest extends MediaTestBase {
codecName != null);
videoFormat.setInteger(MediaFormat.KEY_AUDIO_SESSION_ID, audioSessionId);
MediaCodec videoCodec = MediaCodec.createByCodecName(codecName);
- videoCodec.configure(videoFormat, getActivity().getSurfaceHolder().getSurface(), null, 0);
// create the audio extractor
MediaExtractor audioExtractor = createMediaExtractor(fileName);
@@ -302,7 +304,6 @@ public class DecodeOnlyTest extends MediaTestBase {
MediaFormat audioFormat = audioExtractor.getTrackFormat(audioTrackIndex);
String mime = audioFormat.getString(MediaFormat.KEY_MIME);
MediaCodec audioCodec = MediaCodec.createDecoderByType(mime);
- audioCodec.configure(audioFormat, null, null, 0);
// audio track used by audio codec
AudioTrack audioTrack = createAudioTrack(audioFormat, audioSessionId);
@@ -354,9 +355,15 @@ public class DecodeOnlyTest extends MediaTestBase {
}
});
-
+ videoCodec.configure(videoFormat, getActivity().getSurfaceHolder().getSurface(), null, 0);
AtomicBoolean done = new AtomicBoolean(false);
- audioCodec.setCallback(new AudioCallback(audioCodec, audioExtractor, audioTrack, done));
+ // Since data is written to AudioTrack in a blocking manner, run it in a separate thread to
+ // not block other operations.
+ HandlerThread audioThread = new HandlerThread("audioThread");
+ audioThread.start();
+ audioCodec.setCallback(new AudioCallback(audioCodec, audioExtractor, audioTrack, done),
+ new Handler(audioThread.getLooper()));
+ audioCodec.configure(audioFormat, null, null, 0);
List<Long> renderedPresentationTimes = new ArrayList<>();
@@ -424,7 +431,6 @@ public class DecodeOnlyTest extends MediaTestBase {
codecName != null);
videoFormat.setInteger(MediaFormat.KEY_AUDIO_SESSION_ID, audioSessionId);
MediaCodec videoCodec = MediaCodec.createByCodecName(codecName);
- videoCodec.configure(videoFormat, getActivity().getSurfaceHolder().getSurface(), null, 0);
// create the audio extractor
MediaExtractor audioExtractor = createMediaExtractor(fileName);
@@ -437,50 +443,77 @@ public class DecodeOnlyTest extends MediaTestBase {
MediaFormat audioFormat = audioExtractor.getTrackFormat(audioTrackIndex);
String mime = audioFormat.getString(MediaFormat.KEY_MIME);
MediaCodec audioCodec = MediaCodec.createDecoderByType(mime);
- audioCodec.configure(audioFormat, null, null, 0);
// audio track used by audio codec
AudioTrack audioTrack = createAudioTrack(audioFormat, audioSessionId);
// Frames at 2s of each file are not key frame
AtomicLong seekTime = new AtomicLong(2000 * 1000);
- boolean isPeeking = setKeyTunnelPeek(videoCodec, initialPeek ? 1 : 0);
videoExtractor.seekTo(seekTime.get(), MediaExtractor.SEEK_TO_PREVIOUS_SYNC);
audioExtractor.seekTo(seekTime.get(), MediaExtractor.SEEK_TO_PREVIOUS_SYNC);
List<Long> expectedPresentationTimes = new ArrayList<>();
- AtomicBoolean done = new AtomicBoolean(false);
+ // Setting it to true so that buffers are not queued in the beginning.
+ AtomicBoolean done = new AtomicBoolean(true);
AtomicBoolean hasDecodeOnlyFrames = new AtomicBoolean(false);
- videoCodec.setCallback(new MediaCodec.Callback() {
- // before queueing a frame, check if it is the last frame and set the EOS flag
- // to the frame if that's the case. If the frame is to be only decoded
- // (any frame before the seek timestamp), then set the DECODE_ONLY flag to the frame.
- // Only frames not tagged with EOS or DECODE_ONLY are expected to be rendered and added
- // to expectedPresentationTimes
+ class VideoAsyncHandler extends MediaCodec.Callback {
+ private final Queue<Integer> mAvailableInputIndices = new ArrayDeque<>();
+ private final Lock mLock = new ReentrantLock();
+
+ private void queueInput(MediaCodec codec, int index) {
+ ByteBuffer inputBuffer = codec.getInputBuffer(index);
+ int sampleSize = videoExtractor.readSampleData(inputBuffer, 0);
+ long presentationTime = videoExtractor.getSampleTime();
+ int flags = videoExtractor.getSampleFlags();
+ if (sampleSize < 0) {
+ flags = MediaCodec.BUFFER_FLAG_END_OF_STREAM;
+ sampleSize = 0;
+ } else if (presentationTime < seekTime.get()) {
+ flags = MediaCodec.BUFFER_FLAG_DECODE_ONLY;
+ hasDecodeOnlyFrames.set(true);
+ } else {
+ expectedPresentationTimes.add(presentationTime);
+ }
+ codec.queueInputBuffer(index, 0, sampleSize, presentationTime, flags);
+ videoExtractor.advance();
+ }
+
@Override
public void onInputBufferAvailable(MediaCodec codec, int index) {
- if (!done.get()) {
- ByteBuffer inputBuffer = videoCodec.getInputBuffer(index);
- int sampleSize = videoExtractor.readSampleData(inputBuffer, 0);
- long presentationTime = videoExtractor.getSampleTime();
- int flags = videoExtractor.getSampleFlags();
- if (sampleSize < 0) {
- flags = MediaCodec.BUFFER_FLAG_END_OF_STREAM;
- sampleSize = 0;
- } else if (presentationTime < seekTime.get()) {
- flags = MediaCodec.BUFFER_FLAG_DECODE_ONLY;
- hasDecodeOnlyFrames.set(true);
+ mLock.lock();
+ try {
+ if (!done.get()) {
+ queueInput(codec, index);
} else {
- expectedPresentationTimes.add(presentationTime);
+ mAvailableInputIndices.offer(index);
}
- videoCodec.queueInputBuffer(index, 0, sampleSize, presentationTime, flags);
- videoExtractor.advance();
+ } finally {
+ mLock.unlock();
+ }
+ }
+
+ public void startProcess() {
+ mLock.lock();
+ try {
+ done.set(false);
+ while (!mAvailableInputIndices.isEmpty()) {
+ queueInput(videoCodec, mAvailableInputIndices.poll());
+ }
+ } finally {
+ mLock.unlock();
+ }
+ }
+
+ public void clearBufferQueue() {
+ mLock.lock();
+ try {
+ mAvailableInputIndices.clear();
+ } finally {
+ mLock.unlock();
}
}
- // nothing to do here - in tunneled mode, the frames are rendered directly by the
- // hardware, they are not sent back to the codec for extra processing
@Override
public void onOutputBufferAvailable(MediaCodec codec, int index,
MediaCodec.BufferInfo info) {
@@ -496,9 +529,18 @@ public class DecodeOnlyTest extends MediaTestBase {
public void onOutputFormatChanged(MediaCodec codec, MediaFormat format) {
}
- });
+ }
- audioCodec.setCallback(new AudioCallback(audioCodec, audioExtractor, audioTrack, done));
+ VideoAsyncHandler videoAsyncHandler = new VideoAsyncHandler();
+ videoCodec.setCallback(videoAsyncHandler);
+ videoCodec.configure(videoFormat, getActivity().getSurfaceHolder().getSurface(), null, 0);
+ // Since data is written to AudioTrack in a blocking manner, run it in a separate thread to
+ // not block other operations.
+ HandlerThread audioThread = new HandlerThread("audioThread");
+ audioThread.start();
+ audioCodec.setCallback(new AudioCallback(audioCodec, audioExtractor, audioTrack, done),
+ new Handler(audioThread.getLooper()));
+ audioCodec.configure(audioFormat, null, null, 0);
List<Long> renderedPresentationTimes = new ArrayList<>();
// play for 500ms
@@ -518,6 +560,10 @@ public class DecodeOnlyTest extends MediaTestBase {
// start media playback
videoCodec.start();
audioCodec.start();
+ // Set peeking value after MediaCodec.start() is called.
+ boolean isPeeking = setKeyTunnelPeek(videoCodec, initialPeek ? 1 : 0);
+ // start to queue video frames
+ videoAsyncHandler.startProcess();
// When video codecs are started, large chunks of contiguous physical memory need to be
// allocated, which, on low-RAM devices, can trigger high CPU usage for moving memory
@@ -564,8 +610,7 @@ public class DecodeOnlyTest extends MediaTestBase {
Thread.sleep(500);
videoCodec.flush();
audioCodec.flush();
- // Set peek on when it was off, and set it off when it was on.
- isPeeking = setKeyTunnelPeek(videoCodec, isPeeking ? 0 : 1);
+ videoAsyncHandler.clearBufferQueue();
// Frames at 7s of each file are not key frame, and there is non-zero key frame before it
seekTime.set(7000 * 1000);
@@ -587,12 +632,14 @@ public class DecodeOnlyTest extends MediaTestBase {
}, new Handler(Looper.getMainLooper()));
// Restart media playback
- done.set(false);
firstTunnelFrameReady.set(false);
videoCodec.start();
audioCodec.start();
+ // Set peek on when it was off, and set it off when it was on.
+ isPeeking = setKeyTunnelPeek(videoCodec, isPeeking ? 0 : 1);
+ videoAsyncHandler.startProcess();
sleepUntil(firstTunnelFrameReady::get, Duration.ofSeconds(firstFrameReadyTimeoutSeconds));
- assertTrue(String.format("onFirstTunnelFrameReady not called within %d milliseconds",
+ assertTrue(String.format("onFirstTunnelFrameReady not called within %d seconds",
firstFrameReadyTimeoutSeconds), firstTunnelFrameReady.get());
// Sleep for 1s here to ensure that either (1) when peek is on, high-latency display
@@ -735,9 +782,27 @@ public class DecodeOnlyTest extends MediaTestBase {
byte[] audioArray = new byte[info.size];
outputBuffer.get(audioArray);
outputBuffer.clear();
- mAudioTrack.write(ByteBuffer.wrap(audioArray), info.size,
- AudioTrack.WRITE_BLOCKING,
- info.presentationTimeUs * 1000);
+ ByteBuffer audioData = ByteBuffer.wrap(audioArray);
+ int writtenSize = 0;
+ while (true) {
+ int written = mAudioTrack.write(audioData, info.size - writtenSize,
+ AudioTrack.WRITE_BLOCKING, info.presentationTimeUs * 1000);
+ if (written >= 0) {
+ writtenSize += written;
+ if (writtenSize >= info.size) {
+ break;
+ }
+ // When audio track is not in playing state, the write operation does not
+ // block in WRITE_BLOCKING mode. And when audio track is full, the audio
+ // data can not be fully written. Must sleep here to wait for free spaces.
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException ignored) {
+ }
+ } else {
+ Assert.fail("AudioTrack write failure.");
+ }
+ }
mAudioCodec.releaseOutputBuffer(index, false);
}
}
diff --git a/tests/tests/media/decoder/src/android/media/decoder/cts/DecoderRenderTest.java b/tests/tests/media/decoder/src/android/media/decoder/cts/DecoderRenderTest.java
index 2b74b7ec591..8088bbb4432 100644
--- a/tests/tests/media/decoder/src/android/media/decoder/cts/DecoderRenderTest.java
+++ b/tests/tests/media/decoder/src/android/media/decoder/cts/DecoderRenderTest.java
@@ -86,7 +86,7 @@ public class DecoderRenderTest extends MediaTestBase {
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE, codeName = "UpsideDownCake")
public void onFrameRendered_indicatesAllFramesRendered_toDisplay_vp9() throws Exception {
onFrameRendered_indicatesAllFramesRendered(
- "bbb_s1_640x360_webm_vp9_0p21_1600kbps_30fps_vorbis_stereo_128kbps_48000hz.webm",
+ "video_480x360_webm_vp9_333kbps_25fps_vorbis_stereo_128kbps_48000hz.webm",
getActivity().getSurfaceHolder().getSurface());
}
@@ -98,9 +98,9 @@ public class DecoderRenderTest extends MediaTestBase {
@ApiTest(apis = {"android.media.MediaCodec.OnFrameRenderedListener#onFrameRendered"})
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE, codeName = "UpsideDownCake")
public void onFrameRendered_indicatesAllFramesRendered_toTexture_vp9() throws Exception {
- OutputSurface outputSurface = new OutputSurface(640, 360);
+ OutputSurface outputSurface = new OutputSurface(480, 360);
onFrameRendered_indicatesAllFramesRendered(
- "bbb_s1_640x360_webm_vp9_0p21_1600kbps_30fps_vorbis_stereo_128kbps_48000hz.webm",
+ "video_480x360_webm_vp9_333kbps_25fps_vorbis_stereo_128kbps_48000hz.webm",
outputSurface.getSurface());
}
diff --git a/tests/tests/os/Android.bp b/tests/tests/os/Android.bp
index b78514d0be1..fd7ff3a447d 100644
--- a/tests/tests/os/Android.bp
+++ b/tests/tests/os/Android.bp
@@ -61,6 +61,7 @@ android_test {
"cts",
"general-tests",
"sts",
+ "mts-documentsui",
],
sdk_version: "test_current",
libs: [
diff --git a/tests/tests/sharesheet/src/android/sharesheet/cts/CtsSharesheetDeviceTest.java b/tests/tests/sharesheet/src/android/sharesheet/cts/CtsSharesheetDeviceTest.java
index 91219651a4b..593d3c98624 100644
--- a/tests/tests/sharesheet/src/android/sharesheet/cts/CtsSharesheetDeviceTest.java
+++ b/tests/tests/sharesheet/src/android/sharesheet/cts/CtsSharesheetDeviceTest.java
@@ -271,7 +271,9 @@ public class CtsSharesheetDeviceTest {
// Note: EII and ECT cap is not tested here
showsExtraInitialIntents();
- showsExtraChooserTargets();
+ if (!mActivityManager.isLowRamDevice()) {
+ showsExtraChooserTargets();
+ }
isSharingShortcutDirectShareEnabled();
}, () -> {
@@ -659,6 +661,10 @@ public class CtsSharesheetDeviceTest {
@Test
@ApiTest(apis = "android.content.Intent#EXTRA_CHOOSER_TARGETS")
public void testChooserTargets() throws Throwable {
+ assumeFalse(
+ "EXTRA_CHOOSER_TARGETS not required on low RAM devices",
+ mActivityManager.isLowRamDevice());
+
final CountDownLatch appStarted = new CountDownLatch(1);
final AtomicReference<Intent> targetLaunchIntent = new AtomicReference<>();
@@ -698,6 +704,10 @@ public class CtsSharesheetDeviceTest {
@Test
@ApiTest(apis = "android.content.Intent#EXTRA_CHOOSER_TARGETS")
public void testChooserTargetsRefinement() throws Throwable {
+ assumeFalse(
+ "EXTRA_CHOOSER_TARGETS not required on low RAM devices",
+ mActivityManager.isLowRamDevice());
+
final CountDownLatch broadcastInvoked = new CountDownLatch(1);
final CountDownLatch appStarted = new CountDownLatch(1);
final AtomicReference<Intent> targetLaunchIntent = new AtomicReference<>();
diff --git a/tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/RetrieveConnectionInfoAndReturnStatusService.java b/tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/RetrieveConnectionInfoAndReturnStatusService.java
index 23080541a58..f150cf24f05 100644
--- a/tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/RetrieveConnectionInfoAndReturnStatusService.java
+++ b/tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/RetrieveConnectionInfoAndReturnStatusService.java
@@ -34,6 +34,11 @@ public class RetrieveConnectionInfoAndReturnStatusService extends JobService {
public boolean onStartJob(JobParameters jobParameters) {
ResultReceiver resultReceiver =
jobParameters.getTransientExtras().getParcelable(RESULT_RECEIVER_EXTRA);
+ try {
+ Thread.sleep(5_000);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
WifiManager wifiManager = getSystemService(WifiManager.class);
boolean succeeded;
try {
diff --git a/tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/RetrieveScanResultsAndReturnStatusService.java b/tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/RetrieveScanResultsAndReturnStatusService.java
index 4918e39df52..e932277e227 100644
--- a/tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/RetrieveScanResultsAndReturnStatusService.java
+++ b/tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/RetrieveScanResultsAndReturnStatusService.java
@@ -34,6 +34,11 @@ public class RetrieveScanResultsAndReturnStatusService extends JobService {
public boolean onStartJob(JobParameters jobParameters) {
ResultReceiver resultReceiver =
jobParameters.getTransientExtras().getParcelable(RESULT_RECEIVER_EXTRA);
+ try {
+ Thread.sleep(5_000);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
WifiManager wifiManager = getSystemService(WifiManager.class);
boolean succeeded;
try {
diff --git a/tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/RetrieveTransportInfoAndReturnStatusService.java b/tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/RetrieveTransportInfoAndReturnStatusService.java
index 1476455a091..4c53083ab33 100644
--- a/tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/RetrieveTransportInfoAndReturnStatusService.java
+++ b/tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/RetrieveTransportInfoAndReturnStatusService.java
@@ -20,11 +20,8 @@ import static android.net.wifi.cts.app.RetrieveTransportInfoAndReturnStatusActiv
import android.app.job.JobParameters;
import android.app.job.JobService;
-import android.content.Intent;
import android.net.ConnectivityManager;
-import android.net.wifi.WifiManager;
import android.os.ResultReceiver;
-import android.util.Log;
/**
* A service that retrieves transport Info and returns status.
@@ -38,6 +35,11 @@ public class RetrieveTransportInfoAndReturnStatusService extends JobService {
public boolean onStartJob(JobParameters jobParameters) {
ResultReceiver resultReceiver =
jobParameters.getTransientExtras().getParcelable(RESULT_RECEIVER_EXTRA);
+ try {
+ Thread.sleep(5_000);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
ConnectivityManager connectivityManager = getSystemService(ConnectivityManager.class);
resultReceiver.send(
canRetrieveSsidFromTransportInfo(TAG, connectivityManager) ? 1 : 0, null);
diff --git a/tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/TriggerScanAndReturnStatusService.java b/tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/TriggerScanAndReturnStatusService.java
index 2f6a2eda0d1..18d2f439552 100644
--- a/tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/TriggerScanAndReturnStatusService.java
+++ b/tests/tests/wifi/CtsWifiLocationTestApp/src/android/net/wifi/cts/app/TriggerScanAndReturnStatusService.java
@@ -34,6 +34,11 @@ public class TriggerScanAndReturnStatusService extends JobService {
public boolean onStartJob(JobParameters jobParameters) {
ResultReceiver resultReceiver =
jobParameters.getTransientExtras().getParcelable(RESULT_RECEIVER_EXTRA);
+ try {
+ Thread.sleep(5_000);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
WifiManager wifiManager = getSystemService(WifiManager.class);
boolean succeeded;
try {
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 9dd00fb6b02..74fdf642e09 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
@@ -73,6 +73,7 @@ import androidx.test.filters.SdkSuppress;
import androidx.test.platform.app.InstrumentationRegistry;
import com.android.compatibility.common.util.ApiLevelUtil;
+import com.android.compatibility.common.util.ApiTest;
import com.android.compatibility.common.util.ShellIdentityUtils;
import java.util.ArrayDeque;
@@ -1121,7 +1122,9 @@ public class SingleDeviceTest extends WifiJUnit3TestBase {
* Validate successful suspend/resume with a publish session.
*/
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
- public void testSuspendResumeSuccessWithPublishSession() {
+ @ApiTest(apis = {"android.net.wifi.aware.DiscoverySession#suspend",
+ "android.net.wifi.aware.DiscoverySession#resume"})
+ public void testSuspendResumeFailWithoutNdpOnPublishSession() {
if (!TestUtils.shouldTestWifiAware(getContext())) {
return;
}
@@ -1155,18 +1158,12 @@ public class SingleDeviceTest extends WifiJUnit3TestBase {
// 2. suspend
discoverySession.suspend();
- assertTrue("Publish session suspended",
- discoveryCb.waitForCallback(
- DiscoverySessionCallbackTest.ON_SESSION_SUSPEND_SUCCEEDED));
- assertFalse(discoveryCb.waitForCallback(
+ assertTrue(discoveryCb.waitForCallback(
DiscoverySessionCallbackTest.ON_SESSION_SUSPEND_FAILED));
// 3. resume
discoverySession.resume();
- assertTrue("Publish session resumed",
- discoveryCb.waitForCallback(
- DiscoverySessionCallbackTest.ON_SESSION_RESUME_SUCCEEDED));
- assertFalse(discoveryCb.waitForCallback(
+ assertTrue(discoveryCb.waitForCallback(
DiscoverySessionCallbackTest.ON_SESSION_RESUME_FAILED));
// 4. destroy
@@ -1422,7 +1419,9 @@ public class SingleDeviceTest extends WifiJUnit3TestBase {
* Validate successful suspend/resume with a subscribe session.
*/
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
- public void testSuspendResumeSuccessWithSubscribeSession() {
+ @ApiTest(apis = {"android.net.wifi.aware.DiscoverySession#suspend",
+ "android.net.wifi.aware.DiscoverySession#resume"})
+ public void testSuspendResumeFailWithoutNdpOnSubscribeSession() {
if (!TestUtils.shouldTestWifiAware(getContext())) {
return;
}
@@ -1457,18 +1456,12 @@ public class SingleDeviceTest extends WifiJUnit3TestBase {
// 2. suspend
discoverySession.suspend();
- assertTrue("Subscribe session suspended",
- discoveryCb.waitForCallback(
- DiscoverySessionCallbackTest.ON_SESSION_SUSPEND_SUCCEEDED));
- assertFalse(discoveryCb.waitForCallback(
+ assertTrue(discoveryCb.waitForCallback(
DiscoverySessionCallbackTest.ON_SESSION_SUSPEND_FAILED));
// 3. resume
discoverySession.resume();
- assertTrue("Subscribe session resumed",
- discoveryCb.waitForCallback(
- DiscoverySessionCallbackTest.ON_SESSION_RESUME_SUCCEEDED));
- assertFalse(discoveryCb.waitForCallback(
+ assertTrue(discoveryCb.waitForCallback(
DiscoverySessionCallbackTest.ON_SESSION_RESUME_FAILED));
// 4. destroy
diff --git a/tests/tests/wifi/src/android/net/wifi/cts/ConcurrencyTest.java b/tests/tests/wifi/src/android/net/wifi/cts/ConcurrencyTest.java
index 6a2d168dab6..0105dad1ffc 100644
--- a/tests/tests/wifi/src/android/net/wifi/cts/ConcurrencyTest.java
+++ b/tests/tests/wifi/src/android/net/wifi/cts/ConcurrencyTest.java
@@ -68,6 +68,7 @@ import androidx.test.filters.SdkSuppress;
import androidx.test.platform.app.InstrumentationRegistry;
import com.android.compatibility.common.util.ApiLevelUtil;
+import com.android.compatibility.common.util.ApiTest;
import com.android.compatibility.common.util.PollingCheck;
import com.android.compatibility.common.util.ShellIdentityUtils;
@@ -489,6 +490,7 @@ public class ConcurrencyTest extends WifiJUnit4TestBase {
removeAllPersistentGroups();
}
+ @ApiTest(apis = {"android.net.wifi.p2p.WifiP2pManager#requestP2pState"})
@Test
public void testConcurrency() {
sWifiP2pManager.requestP2pState(sWifiP2pChannel, new WifiP2pManager.P2pStateListener() {
@@ -505,6 +507,9 @@ public class ConcurrencyTest extends WifiJUnit4TestBase {
assertEquals(WifiP2pManager.WIFI_P2P_STATE_ENABLED, MY_RESPONSE.p2pState);
}
+ @ApiTest(apis = {"android.net.wifi.p2p.WifiP2pManager#requestDiscoveryState",
+ "android.net.wifi.p2p.WifiP2pManager#discoverPeers",
+ "android.net.wifi.p2p.WifiP2pManager#stopPeerDiscovery"})
@Test
public void testRequestDiscoveryState() {
sWifiP2pManager.requestDiscoveryState(
@@ -559,6 +564,9 @@ public class ConcurrencyTest extends WifiJUnit4TestBase {
sWifiP2pManager.stopPeerDiscovery(sWifiP2pChannel, null);
}
+ @ApiTest(apis = {"android.net.wifi.p2p.WifiP2pManager#requestNetworkInfo",
+ "android.net.wifi.p2p.WifiP2pManager#createGroup",
+ "android.net.wifi.p2p.WifiP2pManager#removeGroup"})
@Test
public void testRequestNetworkInfo() {
sWifiP2pManager.requestNetworkInfo(sWifiP2pChannel,
@@ -660,6 +668,7 @@ public class ConcurrencyTest extends WifiJUnit4TestBase {
return MY_RESPONSE.deviceName;
}
+ @ApiTest(apis = {"android.net.wifi.p2p.WifiP2pManager#setDeviceName"})
@Test
public void testSetDeviceName() {
String testDeviceName = "test";
@@ -705,6 +714,8 @@ public class ConcurrencyTest extends WifiJUnit4TestBase {
return MY_RESPONSE.persistentGroups;
}
+ @ApiTest(apis = {"android.net.wifi.p2p.WifiP2pManager#requestPersistentGroupInfo",
+ "android.net.wifi.p2p.WifiP2pManager#factoryReset"})
@Test
public void testPersistentGroupOperation() {
sWifiP2pManager.createGroup(sWifiP2pChannel, sActionListener);
@@ -767,6 +778,9 @@ public class ConcurrencyTest extends WifiJUnit4TestBase {
assertEquals(0, persistentGroups.getGroupList().size());
}
+ @ApiTest(apis = {"android.net.wifi.p2p.WifiP2pManager#setWifiP2pChannels",
+ "android.net.wifi.p2p.WifiP2pManager#startListening",
+ "android.net.wifi.p2p.WifiP2pManager#stopListening"})
@Test
public void testP2pListening() {
ShellIdentityUtils.invokeWithShellPermissions(() -> {
@@ -788,6 +802,10 @@ public class ConcurrencyTest extends WifiJUnit4TestBase {
assertTrue(MY_RESPONSE.success);
}
+ @ApiTest(apis = {"android.net.wifi.p2p.WifiP2pManager#setServiceResponseListener",
+ "android.net.wifi.p2p.WifiP2pManager#addLocalService",
+ "android.net.wifi.p2p.WifiP2pManager#clearLocalServices",
+ "android.net.wifi.p2p.WifiP2pManager#removeLocalService"})
@Test
public void testP2pService() {
// This only store the listener to the WifiP2pManager internal variable, nothing to fail.
@@ -826,6 +844,7 @@ public class ConcurrencyTest extends WifiJUnit4TestBase {
assertTrue(MY_RESPONSE.success);
}
+ @ApiTest(apis = {"android.net.wifi.p2p.WifiP2pManager#removeClient"})
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.TIRAMISU)
@Test
public void testRemoveClient() {
@@ -846,6 +865,7 @@ public class ConcurrencyTest extends WifiJUnit4TestBase {
assertTrue(MY_RESPONSE.success);
}
+ @ApiTest(apis = {"android.net.wifi.p2p.WifiP2pManager#discoverPeersOnSpecificFrequency"})
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.TIRAMISU)
@Test
public void testDiscoverPeersOnSpecificFreq() {
@@ -905,6 +925,7 @@ public class ConcurrencyTest extends WifiJUnit4TestBase {
sWifiP2pManager.stopPeerDiscovery(sWifiP2pChannel, null);
}
+ @ApiTest(apis = {"android.net.wifi.p2p.WifiP2pManager#discoverPeersOnSocialChannels"})
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.TIRAMISU)
@Test
public void testDiscoverPeersOnSocialChannelsOnly() {
@@ -964,6 +985,7 @@ public class ConcurrencyTest extends WifiJUnit4TestBase {
sWifiP2pManager.stopPeerDiscovery(sWifiP2pChannel, null);
}
+ @ApiTest(apis = {"android.net.wifi.p2p.WifiP2pConfig.Builder#setGroupClientIpProvisioningMode"})
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.TIRAMISU)
@Test
public void testP2pConnectDoesNotThrowExceptionWhenGroupOwnerIpv6IsNotProvided() {
@@ -981,6 +1003,7 @@ public class ConcurrencyTest extends WifiJUnit4TestBase {
assertFalse(MY_RESPONSE.success);
}
+ @ApiTest(apis = {"android.net.wifi.p2p.WifiP2pManager#setVendorElements"})
@Test
public void testP2pSetVendorElements() {
@@ -1002,6 +1025,8 @@ public class ConcurrencyTest extends WifiJUnit4TestBase {
}
/** Test IEs whose size is greater than the maximum allowed size. */
+ @ApiTest(apis = {"android.net.wifi.p2p.WifiP2pManager"
+ + "#getP2pMaxAllowedVendorElementsLengthBytes"})
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.TIRAMISU)
@Test
public void testP2pSetVendorElementsOverMaximumAllowedSize() {
@@ -1023,6 +1048,9 @@ public class ConcurrencyTest extends WifiJUnit4TestBase {
}
/** Test that external approver APIs. */
+ @ApiTest(apis = {"android.net.wifi.p2p.WifiP2pManager#addExternalApprover",
+ "android.net.wifi.p2p.WifiP2pManager#setConnectionRequestResult",
+ "android.net.wifi.p2p.WifiP2pManager#removeExternalApprover"})
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.TIRAMISU)
@Test
public void testP2pExternalApprover() {
@@ -1087,6 +1115,7 @@ public class ConcurrencyTest extends WifiJUnit4TestBase {
}
/** Test setWfdInfo() API. */
+ @ApiTest(apis = {"android.net.wifi.p2p.WifiP2pManager#setWfdInfo"})
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
@Test
public void testP2pSetWfdInfo() {
@@ -1104,6 +1133,7 @@ public class ConcurrencyTest extends WifiJUnit4TestBase {
/**
* Tests {@link WifiP2pManager#getListenState(WifiP2pManager.Channel, Executor, Consumer)}
*/
+ @ApiTest(apis = {"android.net.wifi.p2p.WifiP2pManager#getListenState"})
@Test
public void testGetListenState() {
Consumer<Integer> testListenStateListener = new Consumer<Integer>() {
@@ -1142,6 +1172,7 @@ public class ConcurrencyTest extends WifiJUnit4TestBase {
assertEquals(WifiP2pManager.WIFI_P2P_LISTEN_STOPPED, MY_RESPONSE.listenState);
}
+ @ApiTest(apis = {"android.net.wifi.WifiP2pManager#getListenState"})
@Test
public void testWpsInfo() {
WpsInfo info = new WpsInfo();
diff --git a/tests/tests/wifi/src/android/net/wifi/cts/ConnectedNetworkScorerTest.java b/tests/tests/wifi/src/android/net/wifi/cts/ConnectedNetworkScorerTest.java
index 02128cedf6c..d6a89f1daae 100644
--- a/tests/tests/wifi/src/android/net/wifi/cts/ConnectedNetworkScorerTest.java
+++ b/tests/tests/wifi/src/android/net/wifi/cts/ConnectedNetworkScorerTest.java
@@ -74,8 +74,9 @@ import com.android.compatibility.common.util.ShellIdentityUtils;
import com.google.common.collect.Range;
-import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -96,81 +97,93 @@ import java.util.concurrent.TimeUnit;
@LargeTest
@RunWith(AndroidJUnit4.class)
public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
- private Context mContext;
- private WifiManager mWifiManager;
- private ConnectivityManager mConnectivityManager;
- private UiDevice mUiDevice;
- private TestHelper mTestHelper;
- private TelephonyManager mTelephonyManager;
+ private static Context sContext;
+ private static WifiManager sWifiManager;
+ private static ConnectivityManager sConnectivityManager;
+ private static UiDevice sUiDevice;
+ private static TestHelper sTestHelper;
+ private static TelephonyManager sTelephonyManager;
- private boolean mWasVerboseLoggingEnabled;
+ private static boolean sWasVerboseLoggingEnabled;
private static final int WIFI_CONNECT_TIMEOUT_MILLIS = 30_000;
private static final int TIMEOUT = 12_000;
private static final int WAIT_DURATION = 5_000;
- @Before
- public void setUp() throws Exception {
- mContext = InstrumentationRegistry.getInstrumentation().getContext();
+ private static boolean sShouldRunTest = false;
+ private static boolean sWasScanThrottleEnabled;
- // skip the test if WiFi is not supported
- assumeTrue(WifiFeature.isWifiSupported(mContext));
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ sContext = InstrumentationRegistry.getInstrumentation().getContext();
+
+ if (!WifiFeature.isWifiSupported(sContext)) {
+ return;
+ }
+ sShouldRunTest = true;
- mWifiManager = mContext.getSystemService(WifiManager.class);
- assertThat(mWifiManager).isNotNull();
+ sWifiManager = sContext.getSystemService(WifiManager.class);
+ assertThat(sWifiManager).isNotNull();
// Location mode must be enabled, otherwise the connection info will be redacted.
- assertThat(Objects.requireNonNull(mContext.getSystemService(LocationManager.class))
+ assertThat(Objects.requireNonNull(sContext.getSystemService(LocationManager.class))
.isLocationEnabled()).isTrue();
- mConnectivityManager = mContext.getSystemService(ConnectivityManager.class);
+ sConnectivityManager = sContext.getSystemService(ConnectivityManager.class);
// turn on verbose logging for tests
- mWasVerboseLoggingEnabled = ShellIdentityUtils.invokeWithShellPermissions(
- () -> mWifiManager.isVerboseLoggingEnabled());
+ sWasVerboseLoggingEnabled = ShellIdentityUtils.invokeWithShellPermissions(
+ () -> sWifiManager.isVerboseLoggingEnabled());
+ ShellIdentityUtils.invokeWithShellPermissions(
+ () -> sWifiManager.setVerboseLoggingEnabled(true));
+ sWasScanThrottleEnabled = ShellIdentityUtils.invokeWithShellPermissions(
+ () -> sWifiManager.isScanThrottleEnabled());
ShellIdentityUtils.invokeWithShellPermissions(
- () -> mWifiManager.setVerboseLoggingEnabled(true));
+ () -> sWifiManager.setScanThrottleEnabled(false));
// enable Wifi
- if (!mWifiManager.isWifiEnabled()) {
- ShellIdentityUtils.invokeWithShellPermissions(() -> mWifiManager.setWifiEnabled(true));
+ if (!sWifiManager.isWifiEnabled()) {
+ ShellIdentityUtils.invokeWithShellPermissions(() -> sWifiManager.setWifiEnabled(true));
}
- PollingCheck.check("Wifi not enabled", TIMEOUT, () -> mWifiManager.isWifiEnabled());
+ PollingCheck.check("Wifi not enabled", TIMEOUT, () -> sWifiManager.isWifiEnabled());
// turn screen on
- mUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+ sUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
- mTestHelper = new TestHelper(mContext, mUiDevice);
- mTestHelper.turnScreenOn();
-
- // Clear any existing app state before each test.
- if (WifiBuildCompat.isPlatformOrWifiModuleAtLeastS(mContext)) {
- ShellIdentityUtils.invokeWithShellPermissions(
- () -> mWifiManager.removeAppState(myUid(), mContext.getPackageName()));
- }
+ sTestHelper = new TestHelper(sContext, sUiDevice);
+ sTestHelper.turnScreenOn();
// check we have >= 1 saved network
List<WifiConfiguration> savedNetworks = ShellIdentityUtils.invokeWithShellPermissions(
- () -> mWifiManager.getConfiguredNetworks());
+ () -> sWifiManager.getConfiguredNetworks());
assertWithMessage("Need at least one saved network").that(savedNetworks).isNotEmpty();
+ sTelephonyManager = sContext.getSystemService(TelephonyManager.class);
+ }
+ @Before
+ public void setUp() throws Exception {
+ assumeTrue(sShouldRunTest);
+ // Clear any existing app state before each test.
+ ShellIdentityUtils.invokeWithShellPermissions(
+ () -> sWifiManager.removeAppState(myUid(), sContext.getPackageName()));
// ensure Wifi is connected
- ShellIdentityUtils.invokeWithShellPermissions(() -> mWifiManager.reconnect());
+ ShellIdentityUtils.invokeWithShellPermissions(() -> sWifiManager.reconnect());
PollingCheck.check(
"Wifi not connected",
WIFI_CONNECT_TIMEOUT_MILLIS,
- () -> mWifiManager.getConnectionInfo().getNetworkId() != -1);
- mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
+ () -> sWifiManager.getConnectionInfo().getNetworkId() != -1);
}
- @After
- public void tearDown() throws Exception {
- if (!WifiFeature.isWifiSupported(mContext)) return;
- if (!mWifiManager.isWifiEnabled()) {
- ShellIdentityUtils.invokeWithShellPermissions(() -> mWifiManager.setWifiEnabled(true));
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ if (!sShouldRunTest) return;
+ if (!sWifiManager.isWifiEnabled()) {
+ ShellIdentityUtils.invokeWithShellPermissions(() -> sWifiManager.setWifiEnabled(true));
}
- mTestHelper.turnScreenOff();
+ sTestHelper.turnScreenOff();
+ ShellIdentityUtils.invokeWithShellPermissions(
+ () -> sWifiManager.setVerboseLoggingEnabled(sWasVerboseLoggingEnabled));
ShellIdentityUtils.invokeWithShellPermissions(
- () -> mWifiManager.setVerboseLoggingEnabled(mWasVerboseLoggingEnabled));
+ () -> sWifiManager.setScanThrottleEnabled(sWasScanThrottleEnabled));
}
private static class TestUsabilityStatsListener implements
@@ -210,7 +223,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
new TestUsabilityStatsListener(countDownLatch);
try {
uiAutomation.adoptShellPermissionIdentity();
- mWifiManager.addOnWifiUsabilityStatsListener(
+ sWifiManager.addOnWifiUsabilityStatsListener(
Executors.newSingleThreadExecutor(), usabilityStatsListener);
// Wait for new usability stats (while connected & screen on this is triggered
// by platform periodically).
@@ -226,7 +239,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
assertThat(statsEntry.getTotalTxRetries()).isAtLeast(0L);
assertThat(statsEntry.getTotalTxBad()).isAtLeast(0L);
assertThat(statsEntry.getTotalRxSuccess()).isAtLeast(0L);
- if (mWifiManager.isEnhancedPowerReportingSupported()) {
+ if (sWifiManager.isEnhancedPowerReportingSupported()) {
assertThat(statsEntry.getTotalRadioOnTimeMillis()).isAtLeast(0L);
assertThat(statsEntry.getTotalRadioTxTimeMillis()).isAtLeast(0L);
assertThat(statsEntry.getTotalRadioRxTimeMillis()).isAtLeast(0L);
@@ -296,9 +309,9 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
assertEquals(10, contentionStats.getContentionNumSamples());
// Note that -1 is also a possible returned value for utilization ratio.
assertThat(statsEntry.getChannelUtilizationRatio()).isIn(Range.closed(-1, 255));
- if (mTelephonyManager != null) {
+ if (sTelephonyManager != null) {
boolean isCellularDataAvailable =
- mTelephonyManager.getDataState() == TelephonyManager.DATA_CONNECTED;
+ sTelephonyManager.getDataState() == TelephonyManager.DATA_CONNECTED;
assertEquals(isCellularDataAvailable, statsEntry.isCellularDataAvailable());
} else {
assertFalse(statsEntry.isCellularDataAvailable());
@@ -466,7 +479,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
assertThat(statsEntry.isSameRegisteredCell()).isFalse();
}
} finally {
- mWifiManager.removeOnWifiUsabilityStatsListener(usabilityStatsListener);
+ sWifiManager.removeOnWifiUsabilityStatsListener(usabilityStatsListener);
uiAutomation.dropShellPermissionIdentity();
}
}
@@ -480,7 +493,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
try {
uiAutomation.adoptShellPermissionIdentity();
// update scoring with dummy values.
- mWifiManager.updateWifiUsabilityScore(0, 50, 50);
+ sWifiManager.updateWifiUsabilityScore(0, 50, 50);
} finally {
uiAutomation.dropShellPermissionIdentity();
}
@@ -495,7 +508,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
UiAutomation uiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
try {
uiAutomation.adoptShellPermissionIdentity();
- assertTrue(mWifiManager.setWifiScoringEnabled(true));
+ assertTrue(sWifiManager.setWifiScoringEnabled(true));
} finally {
uiAutomation.dropShellPermissionIdentity();
}
@@ -629,10 +642,10 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
try {
uiAutomation.adoptShellPermissionIdentity();
// Clear any external scorer already active on the device.
- mWifiManager.clearWifiConnectedNetworkScorer();
+ sWifiManager.clearWifiConnectedNetworkScorer();
Thread.sleep(500);
- mWifiManager.setWifiConnectedNetworkScorer(
+ sWifiManager.setWifiConnectedNetworkScorer(
Executors.newSingleThreadExecutor(), connectedNetworkScorer);
// Since we're already connected, wait for onStart to be invoked.
assertThat(countDownLatchScorer.await(TIMEOUT, TimeUnit.MILLISECONDS)).isTrue();
@@ -647,7 +660,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
scoreUpdateObserver.notifyScoreUpdate(connectedNetworkScorer.startSessionId, 50);
// Register the usability listener
- mWifiManager.addOnWifiUsabilityStatsListener(
+ sWifiManager.addOnWifiUsabilityStatsListener(
Executors.newSingleThreadExecutor(), usabilityStatsListener);
// Trigger a usability stats update.
scoreUpdateObserver.triggerUpdateOfWifiUsabilityStats(
@@ -669,12 +682,12 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
scoreUpdateObserver.blocklistCurrentBssid(-1);
}
// Now disconnect from the network.
- mWifiManager.disconnect();
+ sWifiManager.disconnect();
// Wait for it to be disconnected.
PollingCheck.check(
"Wifi not disconnected",
TIMEOUT,
- () -> mWifiManager.getConnectionInfo().getNetworkId() == -1);
+ () -> sWifiManager.getConnectionInfo().getNetworkId() == -1);
disconnected = true;
// Wait for stop to be invoked and ensure that the session id matches.
@@ -691,16 +704,16 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
connectedNetworkScorer.onStop(200);
assertEquals(200, connectedNetworkScorer.stopSessionId.intValue());
} finally {
- mWifiManager.removeOnWifiUsabilityStatsListener(usabilityStatsListener);
- mWifiManager.clearWifiConnectedNetworkScorer();
+ sWifiManager.removeOnWifiUsabilityStatsListener(usabilityStatsListener);
+ sWifiManager.clearWifiConnectedNetworkScorer();
if (disconnected) {
- mWifiManager.reconnect();
+ sWifiManager.reconnect();
// Wait for it to be reconnected.
PollingCheck.check(
"Wifi not reconnected",
WIFI_CONNECT_TIMEOUT_MILLIS,
- () -> mWifiManager.getConnectionInfo().getNetworkId() != -1);
+ () -> sWifiManager.getConnectionInfo().getNetworkId() != -1);
}
uiAutomation.dropShellPermissionIdentity();
}
@@ -721,10 +734,10 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
try {
uiAutomation.adoptShellPermissionIdentity();
// Clear any external scorer already active on the device.
- mWifiManager.clearWifiConnectedNetworkScorer();
+ sWifiManager.clearWifiConnectedNetworkScorer();
Thread.sleep(500);
- mWifiManager.setWifiConnectedNetworkScorer(
+ sWifiManager.setWifiConnectedNetworkScorer(
Executors.newSingleThreadExecutor(), connectedNetworkScorer);
// Since we're already connected, wait for onStart to be invoked.
assertThat(countDownLatchScorer.await(TIMEOUT, TimeUnit.MILLISECONDS)).isTrue();
@@ -740,7 +753,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
connectedNetworkScorer.resetCountDownLatch(countDownLatchScorer);
// Restart wifi subsystem.
- mWifiManager.restartWifiSubsystem();
+ sWifiManager.restartWifiSubsystem();
// wait for scorer to stop session due to network disconnection.
assertThat(countDownLatchScorer.await(TIMEOUT, TimeUnit.MILLISECONDS)).isTrue();
@@ -752,7 +765,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
PollingCheck.check(
"Wifi not connected",
WIFI_CONNECT_TIMEOUT_MILLIS * 2,
- () -> mWifiManager.getConnectionInfo().getNetworkId() != -1);
+ () -> sWifiManager.getConnectionInfo().getNetworkId() != -1);
// Followed by a new onStart() after the connection.
// Note: There is a 5 second delay between stop/start when restartWifiSubsystem() is
@@ -764,7 +777,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
assertThat(connectedNetworkScorer.scoreUpdateObserver).isSameInstanceAs(
prevScoreUpdateObserver);
} finally {
- mWifiManager.clearWifiConnectedNetworkScorer();
+ sWifiManager.clearWifiConnectedNetworkScorer();
uiAutomation.dropShellPermissionIdentity();
}
}
@@ -793,27 +806,27 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
READ_WIFI_CREDENTIAL);
// Clear any external scorer already active on the device.
- mWifiManager.clearWifiConnectedNetworkScorer();
+ sWifiManager.clearWifiConnectedNetworkScorer();
Thread.sleep(500);
- savedNetworks = mWifiManager.getPrivilegedConfiguredNetworks();
+ savedNetworks = sWifiManager.getPrivilegedConfiguredNetworks();
WifiConfiguration testNetwork =
- TestHelper.findMatchingSavedNetworksWithBssid(mWifiManager, savedNetworks, 1)
+ TestHelper.findMatchingSavedNetworksWithBssid(sWifiManager, savedNetworks, 1)
.get(0);
// Disconnect & disable auto-join on the saved network to prevent auto-connect from
// interfering with the test.
for (WifiConfiguration savedNetwork : savedNetworks) {
- mWifiManager.disableNetwork(savedNetwork.networkId);
+ sWifiManager.disableNetwork(savedNetwork.networkId);
}
// Wait for Wifi to be disconnected.
PollingCheck.check(
"Wifi not disconnected",
20000,
- () -> mWifiManager.getConnectionInfo().getNetworkId() == -1);
+ () -> sWifiManager.getConnectionInfo().getNetworkId() == -1);
assertThat(testNetwork).isNotNull();
// Register the external scorer.
- mWifiManager.setWifiConnectedNetworkScorer(
+ sWifiManager.setWifiConnectedNetworkScorer(
Executors.newSingleThreadExecutor(), connectedNetworkScorer);
// Now connect using the provided connection initiator
@@ -824,7 +837,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
assertThat(connectedNetworkScorer.startSessionId).isNull();
// Now disconnect from the network.
- mConnectivityManager.unregisterNetworkCallback(networkCallback);
+ sConnectivityManager.unregisterNetworkCallback(networkCallback);
networkCallback = null;
// We should not receive the stop either
@@ -834,14 +847,14 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
assertThat(connectedNetworkScorer.stopSessionId).isNull();
} finally {
executorService.shutdownNow();
- mWifiManager.clearWifiConnectedNetworkScorer();
+ sWifiManager.clearWifiConnectedNetworkScorer();
if (networkCallback != null) {
- mConnectivityManager.unregisterNetworkCallback(networkCallback);
+ sConnectivityManager.unregisterNetworkCallback(networkCallback);
}
// Re-enable the networks after the test.
if (savedNetworks != null) {
for (WifiConfiguration savedNetwork : savedNetworks) {
- mWifiManager.enableNetwork(savedNetwork.networkId, false);
+ sWifiManager.enableNetwork(savedNetwork.networkId, false);
}
}
uiAutomation.dropShellPermissionIdentity();
@@ -859,9 +872,9 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
// Connect using wifi network specifier.
WifiNetworkSpecifier specifier =
TestHelper.createSpecifierBuilderWithCredentialFromSavedNetwork(
- testNetwork, false)
+ testNetwork, true)
.build();
- return mTestHelper.testConnectionFlowWithSpecifierWithShellIdentity(
+ return sTestHelper.testConnectionFlowWithSpecifierWithShellIdentity(
testNetwork, specifier, false);
}
);
@@ -882,7 +895,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
if (restrictedNetworkCapabilities.contains(NET_CAPABILITY_OEM_PRIVATE)) {
suggestionBuilder.setOemPrivate(true);
}
- return mTestHelper.testConnectionFlowWithSuggestionWithShellIdentity(
+ return sTestHelper.testConnectionFlowWithSuggestionWithShellIdentity(
testNetwork, suggestionBuilder.build(), executorService,
restrictedNetworkCapabilities, false/* restrictedNetwork */);
}
@@ -930,8 +943,8 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
WifiSsid ssid = WifiSsid.fromBytes(new byte[]{0x12, 0x34, 0x56});
byte[] oui = new byte[]{0x00, 0x01, 0x02};
List<DhcpOption> options = new ArrayList<DhcpOption>();
- mWifiManager.addCustomDhcpOptions(ssid, oui, options);
- mWifiManager.removeCustomDhcpOptions(ssid, oui);
+ sWifiManager.addCustomDhcpOptions(ssid, oui, options);
+ sWifiManager.removeCustomDhcpOptions(ssid, oui);
} finally {
uiAutomation.dropShellPermissionIdentity();
}
@@ -950,7 +963,7 @@ public class ConnectedNetworkScorerTest extends WifiJUnit4TestBase {
WifiSsid ssid = WifiSsid.fromBytes(new byte[]{0x12, 0x34, 0x56});
byte[] oui = new byte[]{0x00, 0x01, 0x02};
List<DhcpOption> options = new ArrayList<DhcpOption>();
- mWifiManager.addCustomDhcpOptions(ssid, oui, options);
+ sWifiManager.addCustomDhcpOptions(ssid, oui, options);
fail("Expected SecurityException");
} catch (SecurityException e) {
// expected
diff --git a/tests/tests/wifi/src/android/net/wifi/cts/TestHelper.java b/tests/tests/wifi/src/android/net/wifi/cts/TestHelper.java
index 5d5e9bb6df7..fca2868830d 100644
--- a/tests/tests/wifi/src/android/net/wifi/cts/TestHelper.java
+++ b/tests/tests/wifi/src/android/net/wifi/cts/TestHelper.java
@@ -673,6 +673,7 @@ public class TestHelper {
@Override
public void onUserSelectionCallbackRegistration(
WifiManager.NetworkRequestUserSelectionCallback userSelectionCallback) {
+ Log.d(TAG, "onUserSelectionCallbackRegistration");
synchronized (mLock) {
onRegistrationCalled = true;
this.userSelectionCallback = userSelectionCallback;
@@ -682,6 +683,7 @@ public class TestHelper {
@Override
public void onAbort() {
+ Log.d(TAG, "onAbort");
synchronized (mLock) {
onAbortCalled = true;
mLock.notify();
@@ -690,6 +692,7 @@ public class TestHelper {
@Override
public void onMatch(List<ScanResult> scanResults) {
+ Log.d(TAG, "onMatch");
synchronized (mLock) {
// This can be invoked multiple times. So, ignore after the first one to avoid
// disturbing the rest of the test sequence.
@@ -702,6 +705,7 @@ public class TestHelper {
@Override
public void onUserSelectionConnectSuccess(WifiConfiguration config) {
+ Log.d(TAG, "onUserSelectionConnectSuccess");
synchronized (mLock) {
onConnectSuccessCalled = true;
mLock.notify();
@@ -710,6 +714,7 @@ public class TestHelper {
@Override
public void onUserSelectionConnectFailure(WifiConfiguration config) {
+ Log.d(TAG, "onUserSelectionConnectFailure");
synchronized (mLock) {
onConnectFailureCalled = true;
mLock.notify();
@@ -821,6 +826,7 @@ public class TestHelper {
Thread.sleep(1_000);
// Start the UI interactions.
uiThread.start();
+ assertThat(localOnlyListener.await(DURATION_MILLIS)).isFalse();
// now wait for callback
assertThat(testNetworkCallback.waitForAnyCallback(DURATION_NETWORK_CONNECTION_MILLIS))
.isTrue();
@@ -840,7 +846,6 @@ public class TestHelper {
assertThat(wifiInfo.isPrimary()).isTrue();
}
}
- assertThat(localOnlyListener.await(DURATION_NETWORK_CONNECTION_MILLIS)).isFalse();
assertThat(localOnlyListener.onFailureCalled).isFalse();
}
} catch (Throwable e /* catch assertions & exceptions */) {
diff --git a/tests/tests/wifi/src/android/net/wifi/cts/WifiLocationInfoTest.java b/tests/tests/wifi/src/android/net/wifi/cts/WifiLocationInfoBackgroundTest.java
index 3d3a7c2b19e..77eb96ee900 100644
--- a/tests/tests/wifi/src/android/net/wifi/cts/WifiLocationInfoTest.java
+++ b/tests/tests/wifi/src/android/net/wifi/cts/WifiLocationInfoBackgroundTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 The Android Open Source Project
+ * Copyright (C) 2023 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.
@@ -33,51 +33,43 @@ import android.os.PowerManager;
import android.platform.test.annotations.AppModeFull;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.LargeTest;
import androidx.test.filters.SdkSuppress;
-import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.rule.ActivityTestRule;
+import com.android.compatibility.common.util.ApiTest;
import com.android.compatibility.common.util.PollingCheck;
import com.android.compatibility.common.util.ShellIdentityUtils;
import com.android.compatibility.common.util.SystemUtil;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.List;
-/**
- * Tests location sensitive APIs exposed by Wi-Fi.
- * Ensures that permissions on these APIs are properly enforced.
- */
@AppModeFull(reason = "Cannot get WifiManager in instant app mode")
-@SmallTest
+@LargeTest
@RunWith(AndroidJUnit4.class)
-public class WifiLocationInfoTest extends WifiJUnit4TestBase {
+@ApiTest(apis = {"Manifest.permission#ACCESS_BACKGROUND_LOCATION"})
+public class WifiLocationInfoBackgroundTest extends WifiJUnit4TestBase{
private static final String TAG = "WifiLocationInfoTest";
private static final String WIFI_LOCATION_TEST_APP_APK_PATH =
"/data/local/tmp/cts/wifi/CtsWifiLocationTestApp.apk";
private static final String WIFI_LOCATION_TEST_APP_PACKAGE_NAME =
"android.net.wifi.cts.app";
- private static final String WIFI_LOCATION_TEST_APP_TRIGGER_SCAN_ACTIVITY =
- WIFI_LOCATION_TEST_APP_PACKAGE_NAME + ".TriggerScanAndReturnStatusActivity";
private static final String WIFI_LOCATION_TEST_APP_TRIGGER_SCAN_SERVICE =
WIFI_LOCATION_TEST_APP_PACKAGE_NAME + ".TriggerScanAndReturnStatusService";
- private static final String WIFI_LOCATION_TEST_APP_RETRIEVE_SCAN_RESULTS_ACTIVITY =
- WIFI_LOCATION_TEST_APP_PACKAGE_NAME + ".RetrieveScanResultsAndReturnStatusActivity";
private static final String WIFI_LOCATION_TEST_APP_RETRIEVE_SCAN_RESULTS_SERVICE =
WIFI_LOCATION_TEST_APP_PACKAGE_NAME + ".RetrieveScanResultsAndReturnStatusService";
- private static final String WIFI_LOCATION_TEST_APP_RETRIEVE_CONNECTION_INFO_ACTIVITY =
- WIFI_LOCATION_TEST_APP_PACKAGE_NAME + ".RetrieveConnectionInfoAndReturnStatusActivity";
private static final String WIFI_LOCATION_TEST_APP_RETRIEVE_CONNECTION_INFO_SERVICE =
WIFI_LOCATION_TEST_APP_PACKAGE_NAME + ".RetrieveConnectionInfoAndReturnStatusService";
- private static final String WIFI_LOCATION_TEST_APP_RETRIEVE_TRANSPORT_INFO_ACTIVITY =
- WIFI_LOCATION_TEST_APP_PACKAGE_NAME + ".RetrieveTransportInfoAndReturnStatusActivity";
private static final String WIFI_LOCATION_TEST_APP_RETRIEVE_TRANSPORT_INFO_SERVICE =
WIFI_LOCATION_TEST_APP_PACKAGE_NAME + ".RetrieveTransportInfoAndReturnStatusService";
@@ -88,179 +80,139 @@ public class WifiLocationInfoTest extends WifiJUnit4TestBase {
public final ActivityTestRule<WaitForResultActivity> mActivityRule =
new ActivityTestRule<>(WaitForResultActivity.class);
- private Context mContext;
- private WifiManager mWifiManager;
- private boolean mWasVerboseLoggingEnabled;
- private boolean mWasScanThrottleEnabled;
- private PowerManager mPower;
- private PowerManager.WakeLock mLock;
+ private static Context sContext;
+ private static WifiManager sWifiManager;
+ private static boolean sWasVerboseLoggingEnabled;
+ private static boolean sWasScanThrottleEnabled;
+ private static PowerManager sPower;
+ private static PowerManager.WakeLock sLock;
- @Before
- public void setUp() throws Exception {
- mContext = InstrumentationRegistry.getInstrumentation().getContext();
- // skip the test if WiFi is not supported
- assumeTrue(WifiFeature.isWifiSupported(mContext));
+ private static boolean sShouldRunTest = false;
- mWifiManager = mContext.getSystemService(WifiManager.class);
- assertThat(mWifiManager).isNotNull();
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ sContext = InstrumentationRegistry.getInstrumentation().getContext();
+ if (!WifiFeature.isWifiSupported(sContext)) {
+ return;
+ }
+ sShouldRunTest = true;
- installApp(WIFI_LOCATION_TEST_APP_APK_PATH);
+ sWifiManager = sContext.getSystemService(WifiManager.class);
+ assertThat(sWifiManager).isNotNull();
// turn on verbose logging for tests
- mWasVerboseLoggingEnabled = ShellIdentityUtils.invokeWithShellPermissions(
- () -> mWifiManager.isVerboseLoggingEnabled());
+ sWasVerboseLoggingEnabled = ShellIdentityUtils.invokeWithShellPermissions(
+ () -> sWifiManager.isVerboseLoggingEnabled());
ShellIdentityUtils.invokeWithShellPermissions(
- () -> mWifiManager.setVerboseLoggingEnabled(true));
+ () -> sWifiManager.setVerboseLoggingEnabled(true));
// Disable scan throttling for tests.
- mWasScanThrottleEnabled = ShellIdentityUtils.invokeWithShellPermissions(
- () -> mWifiManager.isScanThrottleEnabled());
+ sWasScanThrottleEnabled = ShellIdentityUtils.invokeWithShellPermissions(
+ () -> sWifiManager.isScanThrottleEnabled());
ShellIdentityUtils.invokeWithShellPermissions(
- () -> mWifiManager.setScanThrottleEnabled(false));
+ () -> sWifiManager.setScanThrottleEnabled(false));
// enable Wifi
- if (!mWifiManager.isWifiEnabled()) setWifiEnabled(true);
- PollingCheck.check("Wifi not enabled", DURATION_MS, () -> mWifiManager.isWifiEnabled());
+ if (!sWifiManager.isWifiEnabled()) setWifiEnabled(true);
+ PollingCheck.check("Wifi not enabled", DURATION_MS, () -> sWifiManager.isWifiEnabled());
// check we have >= 1 saved network
List<WifiConfiguration> savedNetworks = ShellIdentityUtils.invokeWithShellPermissions(
- () -> mWifiManager.getConfiguredNetworks());
+ () -> sWifiManager.getConfiguredNetworks());
assertWithMessage("Need at least one saved network").that(savedNetworks).isNotEmpty();
// ensure Wifi is connected
- ShellIdentityUtils.invokeWithShellPermissions(() -> mWifiManager.reconnect());
+ ShellIdentityUtils.invokeWithShellPermissions(() -> sWifiManager.reconnect());
PollingCheck.check(
"Wifi not connected",
WIFI_CONNECT_TIMEOUT_MILLIS,
- () -> mWifiManager.getConnectionInfo().getNetworkId() != -1);
- mPower = mContext.getSystemService(PowerManager.class);
- mLock = mPower.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
+ () -> sWifiManager.getConnectionInfo().getNetworkId() != -1);
+ sPower = sContext.getSystemService(PowerManager.class);
+ sLock = sPower.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
+ turnScreenOff();
}
- @After
- public void tearDown() throws Exception {
- if (!WifiFeature.isWifiSupported(mContext)) return;
+ @Before
+ public void setUp() throws InterruptedException {
+ // skip the test if WiFi is not supported
+ assumeTrue(sShouldRunTest);
+ installApp(WIFI_LOCATION_TEST_APP_APK_PATH);
+ }
+
+ @After
+ public void teardown() throws InterruptedException {
+ if (!sShouldRunTest) {
+ return;
+ }
uninstallApp(WIFI_LOCATION_TEST_APP_PACKAGE_NAME);
+ }
- if (!mWifiManager.isWifiEnabled()) setWifiEnabled(true);
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ if (!sShouldRunTest) return;
+ if (!sWifiManager.isWifiEnabled()) setWifiEnabled(true);
ShellIdentityUtils.invokeWithShellPermissions(
- () -> mWifiManager.setScanThrottleEnabled(mWasScanThrottleEnabled));
+ () -> sWifiManager.setScanThrottleEnabled(sWasScanThrottleEnabled));
ShellIdentityUtils.invokeWithShellPermissions(
- () -> mWifiManager.setVerboseLoggingEnabled(mWasVerboseLoggingEnabled));
- if (mLock != null && mLock.isHeld()) {
- mLock.release();
- }
+ () -> sWifiManager.setVerboseLoggingEnabled(sWasVerboseLoggingEnabled));
+ turnScreenOn();
}
- private void setWifiEnabled(boolean enable) throws Exception {
- ShellIdentityUtils.invokeWithShellPermissions(() -> mWifiManager.setWifiEnabled(enable));
+ private static void setWifiEnabled(boolean enable) throws Exception {
+ ShellIdentityUtils.invokeWithShellPermissions(() -> sWifiManager.setWifiEnabled(enable));
}
- private void turnScreenOn() throws Exception {
- if (mLock.isHeld()) mLock.release();
- InstrumentationRegistry.getInstrumentation().getUiAutomation().executeShellCommand(
- "input keyevent KEYCODE_WAKEUP");
- InstrumentationRegistry.getInstrumentation().getUiAutomation().executeShellCommand(""
- + "wm dismiss-keyguard");
- // Since the screen on/off intent is ordered, they will not be sent right now.
- Thread.sleep(5_000);
+ private static void turnScreenOn() throws Exception {
+ if (sLock.isHeld()) sLock.release();
+ SystemUtil.runShellCommand("input keyevent KEYCODE_WAKEUP");
+ SystemUtil.runShellCommand("wm dismiss-keyguard");
}
- private void turnScreenOff() throws Exception {
- if (!mLock.isHeld()) mLock.acquire();
- InstrumentationRegistry.getInstrumentation().getUiAutomation().executeShellCommand(
- "input keyevent KEYCODE_SLEEP");
- // Since the screen on/off intent is ordered, they will not be sent right now.
- Thread.sleep(5_000);
+ private static void turnScreenOff() throws Exception {
+ if (!sLock.isHeld()) sLock.acquire();
+ SystemUtil.runShellCommand("input keyevent KEYCODE_SLEEP");
}
- private void installApp(String apk) throws InterruptedException {
+ private static void installApp(String apk) throws InterruptedException {
String installResult = SystemUtil.runShellCommand("pm install -r -d " + apk);
assertThat(installResult.trim()).isEqualTo("Success");
}
- private void uninstallApp(String pkg) throws InterruptedException {
+ private static void uninstallApp(String pkg) throws InterruptedException {
String uninstallResult = SystemUtil.runShellCommand(
"pm uninstall " + pkg);
assertThat(uninstallResult.trim()).isEqualTo("Success");
}
- private void startFgActivityAndAssertStatusIs(
- ComponentName componentName, boolean status) throws Exception {
- turnScreenOn();
-
- WaitForResultActivity activity = mActivityRule.getActivity();
- activity.startActivityToWaitForResult(componentName);
- assertThat(activity.waitForActivityResult(DURATION_MS)).isEqualTo(status);
- }
-
private void startBgServiceAndAssertStatusIs(
ComponentName componentName, boolean status) throws Exception {
- turnScreenOff();
-
WaitForResultActivity activity = mActivityRule.getActivity();
activity.startServiceToWaitForResult(componentName);
assertThat(activity.waitForServiceResult(DURATION_MS)).isEqualTo(status);
}
- private void triggerScanFgActivityAndAssertStatusIs(boolean status) throws Exception {
- startFgActivityAndAssertStatusIs(new ComponentName(WIFI_LOCATION_TEST_APP_PACKAGE_NAME,
- WIFI_LOCATION_TEST_APP_TRIGGER_SCAN_ACTIVITY), status);
- }
-
private void triggerScanBgServiceAndAssertStatusIs(boolean status) throws Exception {
startBgServiceAndAssertStatusIs(new ComponentName(WIFI_LOCATION_TEST_APP_PACKAGE_NAME,
WIFI_LOCATION_TEST_APP_TRIGGER_SCAN_SERVICE), status);
}
- private void retrieveScanResultsFgActivityAndAssertStatusIs(boolean status) throws Exception {
- startFgActivityAndAssertStatusIs(new ComponentName(WIFI_LOCATION_TEST_APP_PACKAGE_NAME,
- WIFI_LOCATION_TEST_APP_RETRIEVE_SCAN_RESULTS_ACTIVITY), status);
- }
-
private void retrieveScanResultsBgServiceAndAssertStatusIs(boolean status) throws Exception {
startBgServiceAndAssertStatusIs(new ComponentName(WIFI_LOCATION_TEST_APP_PACKAGE_NAME,
WIFI_LOCATION_TEST_APP_RETRIEVE_SCAN_RESULTS_SERVICE), status);
}
- private void retrieveConnectionInfoFgActivityAndAssertStatusIs(boolean status)
- throws Exception {
- startFgActivityAndAssertStatusIs(new ComponentName(WIFI_LOCATION_TEST_APP_PACKAGE_NAME,
- WIFI_LOCATION_TEST_APP_RETRIEVE_CONNECTION_INFO_ACTIVITY), status);
- }
-
private void retrieveConnectionInfoBgServiceAndAssertStatusIs(boolean status) throws Exception {
startBgServiceAndAssertStatusIs(new ComponentName(WIFI_LOCATION_TEST_APP_PACKAGE_NAME,
WIFI_LOCATION_TEST_APP_RETRIEVE_CONNECTION_INFO_SERVICE), status);
}
- private void retrieveTransportInfoFgActivityAndAssertStatusIs(boolean status)
- throws Exception {
- startFgActivityAndAssertStatusIs(new ComponentName(WIFI_LOCATION_TEST_APP_PACKAGE_NAME,
- WIFI_LOCATION_TEST_APP_RETRIEVE_TRANSPORT_INFO_ACTIVITY), status);
- }
-
private void retrieveTransportInfoBgServiceAndAssertStatusIs(boolean status) throws Exception {
startBgServiceAndAssertStatusIs(new ComponentName(WIFI_LOCATION_TEST_APP_PACKAGE_NAME,
WIFI_LOCATION_TEST_APP_RETRIEVE_TRANSPORT_INFO_SERVICE), status);
}
@Test
- public void testScanTriggerNotAllowedForForegroundActivityWithNoLocationPermission()
- throws Exception {
- triggerScanFgActivityAndAssertStatusIs(false);
- }
-
- @Test
- public void testScanTriggerAllowedForForegroundActivityWithFineLocationPermission()
- throws Exception {
- InstrumentationRegistry.getInstrumentation().getUiAutomation().grantRuntimePermission(
- WIFI_LOCATION_TEST_APP_PACKAGE_NAME, ACCESS_FINE_LOCATION);
- triggerScanFgActivityAndAssertStatusIs(true);
- }
-
- @Test
- public void testScanTriggerAllowedForBackgroundServiceWithBackgroundLocationPermission()
+ public void testScanTriggerAllowedWithBackgroundLocationPermission()
throws Exception {
InstrumentationRegistry.getInstrumentation().getUiAutomation().grantRuntimePermission(
WIFI_LOCATION_TEST_APP_PACKAGE_NAME, ACCESS_FINE_LOCATION);
@@ -270,7 +222,7 @@ public class WifiLocationInfoTest extends WifiJUnit4TestBase {
}
@Test
- public void testScanTriggerNotAllowedForBackgroundServiceWithFineLocationPermission()
+ public void testScanTriggerNotAllowedWithFineLocationPermission()
throws Exception {
InstrumentationRegistry.getInstrumentation().getUiAutomation().grantRuntimePermission(
WIFI_LOCATION_TEST_APP_PACKAGE_NAME, ACCESS_FINE_LOCATION);
@@ -278,21 +230,7 @@ public class WifiLocationInfoTest extends WifiJUnit4TestBase {
}
@Test
- public void testScanResultsRetrievalNotAllowedForForegroundActivityWithNoLocationPermission()
- throws Exception {
- retrieveScanResultsFgActivityAndAssertStatusIs(false);
- }
-
- @Test
- public void testScanResultsRetrievalAllowedForForegroundActivityWithFineLocationPermission()
- throws Exception {
- InstrumentationRegistry.getInstrumentation().getUiAutomation().grantRuntimePermission(
- WIFI_LOCATION_TEST_APP_PACKAGE_NAME, ACCESS_FINE_LOCATION);
- retrieveScanResultsFgActivityAndAssertStatusIs(true);
- }
-
- @Test
- public void testScanResultsRetrievalAllowedForBackgroundServiceWithBackgroundLocationPermission()
+ public void testScanResultsRetrievalAllowedWithBackgroundLocationPermission()
throws Exception {
InstrumentationRegistry.getInstrumentation().getUiAutomation().grantRuntimePermission(
WIFI_LOCATION_TEST_APP_PACKAGE_NAME, ACCESS_FINE_LOCATION);
@@ -302,7 +240,7 @@ public class WifiLocationInfoTest extends WifiJUnit4TestBase {
}
@Test
- public void testScanResultsRetrievalNotAllowedForBackgroundServiceWithFineLocationPermission()
+ public void testScanResultsRetrievalNotAllowedWithFineLocationPermission()
throws Exception {
InstrumentationRegistry.getInstrumentation().getUiAutomation().grantRuntimePermission(
WIFI_LOCATION_TEST_APP_PACKAGE_NAME, ACCESS_FINE_LOCATION);
@@ -310,22 +248,7 @@ public class WifiLocationInfoTest extends WifiJUnit4TestBase {
}
@Test
- public void testConnectionInfoRetrievalNotAllowedForForegroundActivityWithNoLocationPermission()
- throws Exception {
- retrieveConnectionInfoFgActivityAndAssertStatusIs(false);
- }
-
- @Test
- public void testConnectionInfoRetrievalAllowedForForegroundActivityWithFineLocationPermission()
- throws Exception {
- InstrumentationRegistry.getInstrumentation().getUiAutomation().grantRuntimePermission(
- WIFI_LOCATION_TEST_APP_PACKAGE_NAME, ACCESS_FINE_LOCATION);
- retrieveConnectionInfoFgActivityAndAssertStatusIs(true);
- }
-
- @Test
- public void
- testConnectionInfoRetrievalAllowedForBackgroundServiceWithBackgroundLocationPermission()
+ public void testConnectionInfoRetrievalAllowedWithBackgroundLocationPermission()
throws Exception {
InstrumentationRegistry.getInstrumentation().getUiAutomation().grantRuntimePermission(
WIFI_LOCATION_TEST_APP_PACKAGE_NAME, ACCESS_FINE_LOCATION);
@@ -335,34 +258,17 @@ public class WifiLocationInfoTest extends WifiJUnit4TestBase {
}
@Test
- public void
- testConnectionInfoRetrievalNotAllowedForBackgroundServiceWithFineLocationPermission()
+ public void testConnectionInfoRetrievalNotAllowedWithFineLocationPermission()
throws Exception {
InstrumentationRegistry.getInstrumentation().getUiAutomation().grantRuntimePermission(
WIFI_LOCATION_TEST_APP_PACKAGE_NAME, ACCESS_FINE_LOCATION);
retrieveConnectionInfoBgServiceAndAssertStatusIs(false);
}
- @SdkSuppress(minSdkVersion = Build.VERSION_CODES.S)
- @Test
- public void testTransportInfoRetrievalNotAllowedForForegroundActivityWithNoLocationPermission()
- throws Exception {
- retrieveTransportInfoFgActivityAndAssertStatusIs(false);
- }
-
- @SdkSuppress(minSdkVersion = Build.VERSION_CODES.S)
- @Test
- public void testTransportInfoRetrievalAllowedForForegroundActivityWithFineLocationPermission()
- throws Exception {
- InstrumentationRegistry.getInstrumentation().getUiAutomation().grantRuntimePermission(
- WIFI_LOCATION_TEST_APP_PACKAGE_NAME, ACCESS_FINE_LOCATION);
- retrieveTransportInfoFgActivityAndAssertStatusIs(true);
- }
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.S)
@Test
- public void
- testTransportInfoRetrievalAllowedForBackgroundServiceWithBackgroundLocationPermission()
+ public void testTransportInfoRetrievalAllowedWithBackgroundLocationPermission()
throws Exception {
InstrumentationRegistry.getInstrumentation().getUiAutomation().grantRuntimePermission(
WIFI_LOCATION_TEST_APP_PACKAGE_NAME, ACCESS_FINE_LOCATION);
@@ -373,8 +279,7 @@ public class WifiLocationInfoTest extends WifiJUnit4TestBase {
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.S)
@Test
- public void
- testTransportInfoRetrievalNotAllowedForBackgroundServiceWithFineLocationPermission()
+ public void testTransportInfoRetrievalNotAllowedWithFineLocationPermission()
throws Exception {
InstrumentationRegistry.getInstrumentation().getUiAutomation().grantRuntimePermission(
WIFI_LOCATION_TEST_APP_PACKAGE_NAME, ACCESS_FINE_LOCATION);
diff --git a/tests/tests/wifi/src/android/net/wifi/cts/WifiLocationInfoForegroundTest.java b/tests/tests/wifi/src/android/net/wifi/cts/WifiLocationInfoForegroundTest.java
new file mode 100644
index 00000000000..cb37a0a8328
--- /dev/null
+++ b/tests/tests/wifi/src/android/net/wifi/cts/WifiLocationInfoForegroundTest.java
@@ -0,0 +1,272 @@
+/*
+ * Copyright (C) 2020 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 android.net.wifi.cts;
+
+import static android.Manifest.permission.ACCESS_FINE_LOCATION;
+
+import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assertWithMessage;
+
+import static org.junit.Assume.assumeTrue;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
+import android.os.Build;
+import android.os.PowerManager;
+import android.platform.test.annotations.AppModeFull;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.LargeTest;
+import androidx.test.filters.SdkSuppress;
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.rule.ActivityTestRule;
+
+import com.android.compatibility.common.util.ApiTest;
+import com.android.compatibility.common.util.PollingCheck;
+import com.android.compatibility.common.util.ShellIdentityUtils;
+import com.android.compatibility.common.util.SystemUtil;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.List;
+
+/**
+ * Tests location sensitive APIs exposed by Wi-Fi.
+ * Ensures that permissions on these APIs are properly enforced.
+ */
+@AppModeFull(reason = "Cannot get WifiManager in instant app mode")
+@LargeTest
+@RunWith(AndroidJUnit4.class)
+@ApiTest(apis = {"Manifest.permission#ACCESS_FINE_LOCATION"})
+public class WifiLocationInfoForegroundTest extends WifiJUnit4TestBase {
+ private static final String TAG = "WifiLocationInfoTest";
+
+ private static final String WIFI_LOCATION_TEST_APP_APK_PATH =
+ "/data/local/tmp/cts/wifi/CtsWifiLocationTestApp.apk";
+ private static final String WIFI_LOCATION_TEST_APP_PACKAGE_NAME =
+ "android.net.wifi.cts.app";
+ private static final String WIFI_LOCATION_TEST_APP_TRIGGER_SCAN_ACTIVITY =
+ WIFI_LOCATION_TEST_APP_PACKAGE_NAME + ".TriggerScanAndReturnStatusActivity";
+ private static final String WIFI_LOCATION_TEST_APP_RETRIEVE_SCAN_RESULTS_ACTIVITY =
+ WIFI_LOCATION_TEST_APP_PACKAGE_NAME + ".RetrieveScanResultsAndReturnStatusActivity";
+ private static final String WIFI_LOCATION_TEST_APP_RETRIEVE_CONNECTION_INFO_ACTIVITY =
+ WIFI_LOCATION_TEST_APP_PACKAGE_NAME + ".RetrieveConnectionInfoAndReturnStatusActivity";
+ private static final String WIFI_LOCATION_TEST_APP_RETRIEVE_TRANSPORT_INFO_ACTIVITY =
+ WIFI_LOCATION_TEST_APP_PACKAGE_NAME + ".RetrieveTransportInfoAndReturnStatusActivity";
+
+ private static final int DURATION_MS = 10_000;
+ private static final int WIFI_CONNECT_TIMEOUT_MILLIS = 30_000;
+
+ @Rule
+ public final ActivityTestRule<WaitForResultActivity> mActivityRule =
+ new ActivityTestRule<>(WaitForResultActivity.class);
+
+ private static Context sContext;
+ private static WifiManager sWifiManager;
+ private static boolean sWasVerboseLoggingEnabled;
+ private static boolean sWasScanThrottleEnabled;
+ private static PowerManager sPower;
+ private static PowerManager.WakeLock sLock;
+
+ private static boolean sShouldRunTest = false;
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ sContext = InstrumentationRegistry.getInstrumentation().getContext();
+ if (!WifiFeature.isWifiSupported(sContext)) {
+ return;
+ }
+ sShouldRunTest = true;
+
+ sWifiManager = sContext.getSystemService(WifiManager.class);
+ assertThat(sWifiManager).isNotNull();
+
+ // turn on verbose logging for tests
+ sWasVerboseLoggingEnabled = ShellIdentityUtils.invokeWithShellPermissions(
+ () -> sWifiManager.isVerboseLoggingEnabled());
+ ShellIdentityUtils.invokeWithShellPermissions(
+ () -> sWifiManager.setVerboseLoggingEnabled(true));
+ // Disable scan throttling for tests.
+ sWasScanThrottleEnabled = ShellIdentityUtils.invokeWithShellPermissions(
+ () -> sWifiManager.isScanThrottleEnabled());
+ ShellIdentityUtils.invokeWithShellPermissions(
+ () -> sWifiManager.setScanThrottleEnabled(false));
+
+ // enable Wifi
+ if (!sWifiManager.isWifiEnabled()) setWifiEnabled(true);
+ PollingCheck.check("Wifi not enabled", DURATION_MS, () -> sWifiManager.isWifiEnabled());
+
+ // check we have >= 1 saved network
+ List<WifiConfiguration> savedNetworks = ShellIdentityUtils.invokeWithShellPermissions(
+ () -> sWifiManager.getConfiguredNetworks());
+ assertWithMessage("Need at least one saved network").that(savedNetworks).isNotEmpty();
+
+ // ensure Wifi is connected
+ ShellIdentityUtils.invokeWithShellPermissions(() -> sWifiManager.reconnect());
+ PollingCheck.check(
+ "Wifi not connected",
+ WIFI_CONNECT_TIMEOUT_MILLIS,
+ () -> sWifiManager.getConnectionInfo().getNetworkId() != -1);
+ sPower = sContext.getSystemService(PowerManager.class);
+ sLock = sPower.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
+ turnScreenOn();
+ }
+
+ @Before
+ public void setUp() throws InterruptedException {
+ // skip the test if WiFi is not supported
+ assumeTrue(sShouldRunTest);
+ installApp(WIFI_LOCATION_TEST_APP_APK_PATH);
+
+ }
+
+ @After
+ public void teardown() throws InterruptedException {
+ if (!sShouldRunTest) {
+ return;
+ }
+ uninstallApp(WIFI_LOCATION_TEST_APP_PACKAGE_NAME);
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ if (!sShouldRunTest) return;
+ if (!sWifiManager.isWifiEnabled()) setWifiEnabled(true);
+ ShellIdentityUtils.invokeWithShellPermissions(
+ () -> sWifiManager.setScanThrottleEnabled(sWasScanThrottleEnabled));
+ ShellIdentityUtils.invokeWithShellPermissions(
+ () -> sWifiManager.setVerboseLoggingEnabled(sWasVerboseLoggingEnabled));
+ }
+
+ private static void setWifiEnabled(boolean enable) throws Exception {
+ ShellIdentityUtils.invokeWithShellPermissions(() -> sWifiManager.setWifiEnabled(enable));
+ }
+
+ private static void turnScreenOn() throws Exception {
+ if (sLock.isHeld()) sLock.release();
+ SystemUtil.runShellCommand("input keyevent KEYCODE_WAKEUP");
+ SystemUtil.runShellCommand("wm dismiss-keyguard");
+ }
+
+ private static void installApp(String apk) throws InterruptedException {
+ String installResult = SystemUtil.runShellCommand("pm install -r -d " + apk);
+ assertThat(installResult.trim()).isEqualTo("Success");
+ }
+
+ private static void uninstallApp(String pkg) throws InterruptedException {
+ String uninstallResult = SystemUtil.runShellCommand(
+ "pm uninstall " + pkg);
+ assertThat(uninstallResult.trim()).isEqualTo("Success");
+ }
+
+ private void startFgActivityAndAssertStatusIs(
+ ComponentName componentName, boolean status) throws Exception {
+ turnScreenOn();
+
+ WaitForResultActivity activity = mActivityRule.getActivity();
+ activity.startActivityToWaitForResult(componentName);
+ assertThat(activity.waitForActivityResult(DURATION_MS)).isEqualTo(status);
+ }
+
+ private void triggerScanFgActivityAndAssertStatusIs(boolean status) throws Exception {
+ startFgActivityAndAssertStatusIs(new ComponentName(WIFI_LOCATION_TEST_APP_PACKAGE_NAME,
+ WIFI_LOCATION_TEST_APP_TRIGGER_SCAN_ACTIVITY), status);
+ }
+
+ private void retrieveScanResultsFgActivityAndAssertStatusIs(boolean status) throws Exception {
+ startFgActivityAndAssertStatusIs(new ComponentName(WIFI_LOCATION_TEST_APP_PACKAGE_NAME,
+ WIFI_LOCATION_TEST_APP_RETRIEVE_SCAN_RESULTS_ACTIVITY), status);
+ }
+
+ private void retrieveConnectionInfoFgActivityAndAssertStatusIs(boolean status)
+ throws Exception {
+ startFgActivityAndAssertStatusIs(new ComponentName(WIFI_LOCATION_TEST_APP_PACKAGE_NAME,
+ WIFI_LOCATION_TEST_APP_RETRIEVE_CONNECTION_INFO_ACTIVITY), status);
+ }
+
+ private void retrieveTransportInfoFgActivityAndAssertStatusIs(boolean status)
+ throws Exception {
+ startFgActivityAndAssertStatusIs(new ComponentName(WIFI_LOCATION_TEST_APP_PACKAGE_NAME,
+ WIFI_LOCATION_TEST_APP_RETRIEVE_TRANSPORT_INFO_ACTIVITY), status);
+ }
+
+ @Test
+ public void testScanTriggerNotAllowedForForegroundActivityWithNoLocationPermission()
+ throws Exception {
+ triggerScanFgActivityAndAssertStatusIs(false);
+ }
+
+ @Test
+ public void testScanTriggerAllowedForForegroundActivityWithFineLocationPermission()
+ throws Exception {
+ InstrumentationRegistry.getInstrumentation().getUiAutomation().grantRuntimePermission(
+ WIFI_LOCATION_TEST_APP_PACKAGE_NAME, ACCESS_FINE_LOCATION);
+ triggerScanFgActivityAndAssertStatusIs(true);
+ }
+
+ @Test
+ public void testScanResultsRetrievalNotAllowedForForegroundActivityWithNoLocationPermission()
+ throws Exception {
+ retrieveScanResultsFgActivityAndAssertStatusIs(false);
+ }
+
+ @Test
+ public void testScanResultsRetrievalAllowedForForegroundActivityWithFineLocationPermission()
+ throws Exception {
+ InstrumentationRegistry.getInstrumentation().getUiAutomation().grantRuntimePermission(
+ WIFI_LOCATION_TEST_APP_PACKAGE_NAME, ACCESS_FINE_LOCATION);
+ retrieveScanResultsFgActivityAndAssertStatusIs(true);
+ }
+
+ @Test
+ public void testConnectionInfoRetrievalNotAllowedForForegroundActivityWithNoLocationPermission()
+ throws Exception {
+ retrieveConnectionInfoFgActivityAndAssertStatusIs(false);
+ }
+
+ @Test
+ public void testConnectionInfoRetrievalAllowedForForegroundActivityWithFineLocationPermission()
+ throws Exception {
+ InstrumentationRegistry.getInstrumentation().getUiAutomation().grantRuntimePermission(
+ WIFI_LOCATION_TEST_APP_PACKAGE_NAME, ACCESS_FINE_LOCATION);
+ retrieveConnectionInfoFgActivityAndAssertStatusIs(true);
+ }
+
+ @SdkSuppress(minSdkVersion = Build.VERSION_CODES.S)
+ @Test
+ public void testTransportInfoRetrievalNotAllowedForForegroundActivityWithNoLocationPermission()
+ throws Exception {
+ retrieveTransportInfoFgActivityAndAssertStatusIs(false);
+ }
+
+ @SdkSuppress(minSdkVersion = Build.VERSION_CODES.S)
+ @Test
+ public void testTransportInfoRetrievalAllowedForForegroundActivityWithFineLocationPermission()
+ throws Exception {
+ InstrumentationRegistry.getInstrumentation().getUiAutomation().grantRuntimePermission(
+ WIFI_LOCATION_TEST_APP_PACKAGE_NAME, ACCESS_FINE_LOCATION);
+ retrieveTransportInfoFgActivityAndAssertStatusIs(true);
+ }
+}
diff --git a/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java b/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java
index ece91c27238..5ef22538e56 100644
--- a/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java
+++ b/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java
@@ -1454,26 +1454,26 @@ public class WifiManagerTest extends WifiJUnit4TestBase {
@Override
public void onScanResultsAvailable(List<ScanResult> scanResults) {
- latch.countDown();
mScanResults = scanResults;
+ latch.countDown();
}
@Override
public void onRegisterSuccess() {
- latch.countDown();
mRegisterSuccess = true;
+ latch.countDown();
}
@Override
public void onRegisterFailed(int reason) {
- latch.countDown();
mRegisterFailedReason = reason;
+ latch.countDown();
}
@Override
public void onRemoved(int reason) {
- latch.countDown();
mRemovedReason = reason;
+ latch.countDown();
}
public boolean isRegisterSuccess() {
@@ -5935,7 +5935,7 @@ public class WifiManagerTest extends WifiJUnit4TestBase {
try {
uiAutomation.adoptShellPermissionIdentity();
boolean enabled = DeviceConfig.getBoolean(DEVICE_CONFIG_NAMESPACE,
- "application_qos_policy_api_enabled", false);
+ "application_qos_policy_api_enabled", true);
// If the feature flag is disabled, verify that all policies are rejected.
if (!enabled) {
diff --git a/tests/tests/wifi/src/android/net/wifi/cts/WifiResourceUtil.java b/tests/tests/wifi/src/android/net/wifi/cts/WifiResourceUtil.java
new file mode 100644
index 00000000000..21cbd311453
--- /dev/null
+++ b/tests/tests/wifi/src/android/net/wifi/cts/WifiResourceUtil.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2023 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 android.net.wifi.cts;
+
+import static org.junit.Assert.assertEquals;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.content.res.Resources;
+
+import java.io.File;
+import java.util.List;
+
+public class WifiResourceUtil {
+ private static final String ACTION_RESOURCES_APK =
+ "com.android.server.wifi.intent.action.SERVICE_WIFI_RESOURCES_APK";
+
+ private static final String WIFI_APEX_NAME = "com.android.wifi";
+
+ private static final String WIFI_APEX_PATH =
+ new File("/apex", WIFI_APEX_NAME).getAbsolutePath();
+
+ private final Resources sWifiResources;
+ private final Context sContext;
+ private String sWifiResourcesPackageName;
+
+ public WifiResourceUtil(Context context) {
+ sContext = context;
+ sWifiResources = getWifiResources();
+ }
+
+ private Resources getWifiResources() {
+ final PackageManager pm = sContext.getPackageManager();
+ List<ResolveInfo> resolveInfos;
+ resolveInfos = pm.queryIntentActivities(new Intent(ACTION_RESOURCES_APK),
+ PackageManager.MATCH_SYSTEM_ONLY);
+ // remove apps that don't live in the Wifi apex
+ resolveInfos.removeIf(info ->
+ !info.activityInfo.applicationInfo.sourceDir.startsWith(WIFI_APEX_PATH));
+
+ assertEquals(1, resolveInfos.size());
+ sWifiResourcesPackageName = resolveInfos.get(0).activityInfo.applicationInfo.packageName;
+ try {
+ return sContext.createPackageContext(sWifiResourcesPackageName, 0).getResources();
+ } catch (PackageManager.NameNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public boolean getWifiBoolean(String name) throws PackageManager.NameNotFoundException {
+ return sWifiResources.getBoolean(sWifiResources.getIdentifier(name, "bool",
+ sWifiResourcesPackageName));
+ }
+}
diff --git a/tests/videocodec/src/android/videocodec/cts/VideoDecodeEditEncodeTest.java b/tests/videocodec/src/android/videocodec/cts/VideoDecodeEditEncodeTest.java
index 443bf296171..802e6429af1 100644
--- a/tests/videocodec/src/android/videocodec/cts/VideoDecodeEditEncodeTest.java
+++ b/tests/videocodec/src/android/videocodec/cts/VideoDecodeEditEncodeTest.java
@@ -417,7 +417,7 @@ public class VideoDecodeEditEncodeTest {
formats.add(decoderFormat);
ArrayList<String> decoders = CodecTestBase.selectCodecs(RES_MEDIA_TYPE, formats, null,
false, SELECT_SWITCH);
- assertTrue("Could not find decoder for format : " + decoderFormat, decoders.size() > 0);
+ assumeTrue("Could not find decoder for format : " + decoderFormat, decoders.size() > 0);
String decoderName = decoders.get(0);
// build encoder format and check if it is supported by the current component
diff --git a/tests/videocodec/src/android/videocodec/cts/VideoEncoderAdaptiveBitRateTest.java b/tests/videocodec/src/android/videocodec/cts/VideoEncoderAdaptiveBitRateTest.java
index 3a5d7c18ed7..c6e69911a06 100644
--- a/tests/videocodec/src/android/videocodec/cts/VideoEncoderAdaptiveBitRateTest.java
+++ b/tests/videocodec/src/android/videocodec/cts/VideoEncoderAdaptiveBitRateTest.java
@@ -21,8 +21,8 @@ import static android.media.MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_VBR;
import static android.mediav2.common.cts.CodecTestBase.ComponentClass.HARDWARE;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeNotNull;
import android.media.MediaCodec;
import android.media.MediaFormat;
@@ -201,7 +201,7 @@ public class VideoEncoderAdaptiveBitRateTest extends VideoEncoderValidationTestB
areFormatsSupported(mCodecName, mMediaType, formats));
RawResource res = RES_YUV_MAP.getOrDefault(mCRes.uniqueLabel(), null);
- assertNotNull("no raw resource found for testing config : " + mEncCfgParams[0] + mTestConfig
+ assumeNotNull("no raw resource found for testing config : " + mEncCfgParams[0] + mTestConfig
+ mTestEnv + DIAGNOSTICS, res);
int limit = mSegmentBitRates.length * SEGMENT_DURATION * mEncCfgParams[0].mFrameRate;
encodeToMemory(mCodecName, mEncCfgParams[0], res, limit, true, false);
diff --git a/tests/videocodec/src/android/videocodec/cts/VideoEncoderFrameRateTest.java b/tests/videocodec/src/android/videocodec/cts/VideoEncoderFrameRateTest.java
index 87294d71967..f71867ce4bf 100644
--- a/tests/videocodec/src/android/videocodec/cts/VideoEncoderFrameRateTest.java
+++ b/tests/videocodec/src/android/videocodec/cts/VideoEncoderFrameRateTest.java
@@ -19,8 +19,8 @@ package android.videocodec.cts;
import static android.mediav2.common.cts.CodecTestBase.ComponentClass.HARDWARE;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeNotNull;
import static org.junit.Assume.assumeTrue;
import android.media.MediaFormat;
@@ -143,7 +143,7 @@ public class VideoEncoderFrameRateTest extends VideoEncoderValidationTestBase {
int refSize = -1;
boolean testSkipped = false;
RawResource res = RES_YUV_MAP.getOrDefault(mCRes.uniqueLabel(), null);
- assertNotNull("no raw resource found for testing config : " + mEncCfgParams[0] + mTestConfig
+ assumeNotNull("no raw resource found for testing config : " + mEncCfgParams[0] + mTestConfig
+ mTestEnv + DIAGNOSTICS, res);
for (float scaleFactor : scaleFactors) {
EncoderConfigParams cfg = mEncCfgParams[0].getBuilder()
diff --git a/tests/videocodec/src/android/videocodec/cts/VideoEncoderIntraFrameIntervalTest.java b/tests/videocodec/src/android/videocodec/cts/VideoEncoderIntraFrameIntervalTest.java
index 9be24853b08..481bc4595fe 100644
--- a/tests/videocodec/src/android/videocodec/cts/VideoEncoderIntraFrameIntervalTest.java
+++ b/tests/videocodec/src/android/videocodec/cts/VideoEncoderIntraFrameIntervalTest.java
@@ -24,8 +24,8 @@ import static android.media.MediaFormat.PICTURE_TYPE_P;
import static android.mediav2.common.cts.CodecTestBase.ComponentClass.HARDWARE;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeNotNull;
import android.media.MediaFormat;
import android.mediav2.common.cts.BitStreamUtils;
@@ -152,7 +152,7 @@ public class VideoEncoderIntraFrameIntervalTest extends VideoEncoderValidationTe
Assume.assumeTrue("Encoder: " + mCodecName + " doesn't support format: " + format,
areFormatsSupported(mCodecName, mMediaType, formats));
RawResource res = RES_YUV_MAP.getOrDefault(mCRes.uniqueLabel(), null);
- assertNotNull("no raw resource found for testing config : " + mEncCfgParams[0] + mTestConfig
+ assumeNotNull("no raw resource found for testing config : " + mEncCfgParams[0] + mTestConfig
+ mTestEnv + DIAGNOSTICS, res);
encodeToMemory(mCodecName, mEncCfgParams[0], res, FRAME_LIMIT, false, false);
assertEquals("encoder did not encode the requested number of frames \n"
diff --git a/tests/videocodec/src/android/videocodec/cts/VideoEncoderMaxBFrameTest.java b/tests/videocodec/src/android/videocodec/cts/VideoEncoderMaxBFrameTest.java
index 96101e15337..311d2e068f2 100644
--- a/tests/videocodec/src/android/videocodec/cts/VideoEncoderMaxBFrameTest.java
+++ b/tests/videocodec/src/android/videocodec/cts/VideoEncoderMaxBFrameTest.java
@@ -21,8 +21,8 @@ import static android.media.MediaFormat.PICTURE_TYPE_I;
import static android.media.MediaFormat.PICTURE_TYPE_P;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeNotNull;
import android.media.MediaFormat;
import android.mediav2.common.cts.BitStreamUtils;
@@ -137,7 +137,7 @@ public class VideoEncoderMaxBFrameTest extends VideoEncoderValidationTestBase {
Assume.assumeTrue("Encoder: " + mCodecName + " doesn't support format: " + format,
areFormatsSupported(mCodecName, mMediaType, formats));
RawResource res = RES_YUV_MAP.getOrDefault(mCRes.uniqueLabel(), null);
- assertNotNull("no raw resource found for testing config : " + mEncCfgParams[0] + mTestConfig
+ assumeNotNull("no raw resource found for testing config : " + mEncCfgParams[0] + mTestConfig
+ mTestEnv + DIAGNOSTICS, res);
encodeToMemory(mCodecName, mEncCfgParams[0], res, FRAME_LIMIT, false, false);
assertEquals("encoder did not encode the requested number of frames \n"
diff --git a/tests/videocodec/src/android/videocodec/cts/VideoEncoderMinMaxTest.java b/tests/videocodec/src/android/videocodec/cts/VideoEncoderMinMaxTest.java
index 9d6dc6bf4ae..170b5a89e97 100644
--- a/tests/videocodec/src/android/videocodec/cts/VideoEncoderMinMaxTest.java
+++ b/tests/videocodec/src/android/videocodec/cts/VideoEncoderMinMaxTest.java
@@ -21,8 +21,8 @@ import static android.media.MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_VBR;
import static android.mediav2.common.cts.CodecTestBase.ComponentClass.HARDWARE;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeNotNull;
import static org.junit.Assume.assumeTrue;
import android.media.MediaCodecInfo;
@@ -301,7 +301,7 @@ public class VideoEncoderMinMaxTest extends VideoEncoderValidationTestBase {
assertTrue("Encoder: " + mCodecName + " doesn't support format: " + format,
areFormatsSupported(mCodecName, mMediaType, formats));
RawResource res = RES_YUV_MAP.getOrDefault(mCRes.uniqueLabel(), null);
- assertNotNull("no raw resource found for testing config : " + mEncCfgParams[0]
+ assumeNotNull("no raw resource found for testing config : " + mEncCfgParams[0]
+ mTestConfig + mTestEnv + DIAGNOSTICS, res);
encodeToMemory(mCodecName, mEncCfgParams[0], res, FRAME_LIMIT, false, true);
CompareStreams cs = null;
diff --git a/tests/videocodec/src/android/videocodec/cts/VideoEncoderMultiResTest.java b/tests/videocodec/src/android/videocodec/cts/VideoEncoderMultiResTest.java
index d2f48cdd4eb..f95ac495e67 100644
--- a/tests/videocodec/src/android/videocodec/cts/VideoEncoderMultiResTest.java
+++ b/tests/videocodec/src/android/videocodec/cts/VideoEncoderMultiResTest.java
@@ -21,8 +21,8 @@ import static android.media.MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_VBR;
import static android.mediav2.common.cts.CodecTestBase.ComponentClass.HARDWARE;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeNotNull;
import android.media.MediaFormat;
import android.mediav2.common.cts.CompareStreams;
@@ -186,7 +186,7 @@ public class VideoEncoderMultiResTest extends VideoEncoderValidationTestBase {
Assume.assumeTrue("Encoder: " + mCodecName + " doesn't support format: " + format,
areFormatsSupported(mCodecName, mMediaType, formats));
RawResource res = RES_YUV_MAP.getOrDefault(mCRes.uniqueLabel(), null);
- assertNotNull("no raw resource found for testing config : " + mEncCfgParams[0] + mTestConfig
+ assumeNotNull("no raw resource found for testing config : " + mEncCfgParams[0] + mTestConfig
+ mTestEnv + DIAGNOSTICS, res);
encodeToMemory(mCodecName, mEncCfgParams[0], res, FRAME_LIMIT, false, true);
assertEquals("Output width is different from configured width \n" + mTestConfig
diff --git a/tests/videocodec/src/android/videocodec/cts/VideoEncoderPsnrTest.java b/tests/videocodec/src/android/videocodec/cts/VideoEncoderPsnrTest.java
index 97189ace129..3f0086b6410 100644
--- a/tests/videocodec/src/android/videocodec/cts/VideoEncoderPsnrTest.java
+++ b/tests/videocodec/src/android/videocodec/cts/VideoEncoderPsnrTest.java
@@ -21,8 +21,8 @@ import static android.media.MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_VBR;
import static android.mediav2.common.cts.CodecTestBase.ComponentClass.HARDWARE;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeNotNull;
import android.media.MediaFormat;
import android.mediav2.common.cts.CompareStreams;
@@ -141,7 +141,7 @@ public class VideoEncoderPsnrTest extends VideoEncoderValidationTestBase {
Assume.assumeTrue("Encoder: " + mCodecName + " doesn't support format: " + format,
areFormatsSupported(mCodecName, mMediaType, formats));
RawResource res = RES_YUV_MAP.getOrDefault(mCRes.uniqueLabel(), null);
- assertNotNull("no raw resource found for testing config : " + mEncCfgParams[0] + mTestConfig
+ assumeNotNull("no raw resource found for testing config : " + mEncCfgParams[0] + mTestConfig
+ mTestEnv + DIAGNOSTICS, res);
encodeToMemory(mCodecName, mEncCfgParams[0], res, FRAME_LIMIT, false, true);
CompareStreams cs = null;
diff --git a/tests/videocodec/src/android/videocodec/cts/VideoEncoderQualityRegressionTest.java b/tests/videocodec/src/android/videocodec/cts/VideoEncoderQualityRegressionTest.java
index b714c72cb7b..beb6067417b 100644
--- a/tests/videocodec/src/android/videocodec/cts/VideoEncoderQualityRegressionTest.java
+++ b/tests/videocodec/src/android/videocodec/cts/VideoEncoderQualityRegressionTest.java
@@ -20,10 +20,13 @@ import static android.media.MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_CBR;
import static android.media.MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_VBR;
import static android.mediav2.common.cts.CodecTestBase.ComponentClass.HARDWARE;
import static android.videocodec.cts.VideoEncoderValidationTestBase.BIRTHDAY_FULLHD_LANDSCAPE;
+import static android.videocodec.cts.VideoEncoderValidationTestBase.DIAGNOSTICS;
+import static android.videocodec.cts.VideoEncoderValidationTestBase.logAllFilesInCacheDir;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeNotNull;
import static org.junit.Assume.assumeTrue;
import android.media.MediaFormat;
@@ -40,6 +43,7 @@ import com.android.compatibility.common.util.ApiTest;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assume;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -103,9 +107,16 @@ public class VideoEncoderQualityRegressionTest {
@BeforeClass
public static void decodeResourceToYuv() throws IOException, InterruptedException {
- DecodeStreamToYuv yuvRes = new DecodeStreamToYuv(RES.mMediaType, RES.mResFile, FRAME_LIMIT,
- LOG_TAG);
- sActiveRawRes = yuvRes.getDecodedYuv();
+ logAllFilesInCacheDir(true);
+ try {
+ DecodeStreamToYuv yuv = new DecodeStreamToYuv(RES.mMediaType, RES.mResFile,
+ FRAME_LIMIT, LOG_TAG);
+ sActiveRawRes = yuv.getDecodedYuv();
+ } catch (Exception e) {
+ DIAGNOSTICS.append(String.format("\nWhile decoding the resource : %s,"
+ + " encountered exception : %s was thrown", RES, e));
+ logAllFilesInCacheDir(false);
+ }
}
@AfterClass
@@ -114,6 +125,11 @@ public class VideoEncoderQualityRegressionTest {
sActiveRawRes = null;
}
+ @Before
+ public void setUp() {
+ assumeNotNull("no raw resource found for testing : ", sActiveRawRes);
+ }
+
@After
public void tearDown() {
for (String tmpFile : mTmpFiles) {
diff --git a/tests/videocodec/src/android/videocodec/cts/VideoEncoderTargetBitrateTest.java b/tests/videocodec/src/android/videocodec/cts/VideoEncoderTargetBitrateTest.java
index 05db1a7553e..1b6763bb4b6 100644
--- a/tests/videocodec/src/android/videocodec/cts/VideoEncoderTargetBitrateTest.java
+++ b/tests/videocodec/src/android/videocodec/cts/VideoEncoderTargetBitrateTest.java
@@ -21,7 +21,7 @@ import static android.media.MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_VBR;
import static android.mediav2.common.cts.CodecTestBase.ComponentClass.HARDWARE;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assume.assumeNotNull;
import android.media.MediaCodec;
import android.media.MediaFormat;
@@ -182,7 +182,7 @@ public class VideoEncoderTargetBitrateTest extends VideoEncoderValidationTestBas
Assume.assumeTrue("Encoder: " + mCodecName + " doesn't support format: " + format,
areFormatsSupported(mCodecName, mMediaType, formats));
RawResource res = RES_YUV_MAP.getOrDefault(mCRes.uniqueLabel(), null);
- assertNotNull("no raw resource found for testing config : " + mEncCfgParams[0] + mTestConfig
+ assumeNotNull("no raw resource found for testing config : " + mEncCfgParams[0] + mTestConfig
+ mTestEnv + DIAGNOSTICS, res);
encodeToMemory(mCodecName, mEncCfgParams[0], res, FRAME_LIMIT, true, false);
assertEquals("encoder did not encode the requested number of frames \n"
diff --git a/tools/cts-tradefed/Android.bp b/tools/cts-tradefed/Android.bp
index c0ae41a0c1e..b699bdec0f4 100644
--- a/tools/cts-tradefed/Android.bp
+++ b/tools/cts-tradefed/Android.bp
@@ -34,7 +34,7 @@ tradefed_binary_host {
wrapper: "etc/cts-tradefed",
short_name: "CTS",
full_name: "Compatibility Test Suite",
- version: "14_r1",
+ version: "14_r2",
static_libs: ["cts-tradefed-harness"],
required: ["compatibility-host-util"],
}