Merge "fix the problem that testNetworkSettingsPermission case can not detect all apps whose holding the NETWORK_SETTINGS permission"
diff --git a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/LocaleDeviceInfo.java b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/LocaleDeviceInfo.java
index e7cb095..424c41e 100644
--- a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/LocaleDeviceInfo.java
+++ b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/LocaleDeviceInfo.java
@@ -15,10 +15,12 @@
*/
package com.android.compatibility.common.deviceinfo;
+import android.icu.util.ULocale;
import com.android.compatibility.common.util.DeviceInfoStore;
import java.util.Arrays;
import java.util.List;
+import java.util.stream.Collectors;
/**
* Locale device info collector.
@@ -34,5 +36,14 @@
locales.add("en_US");
}
store.addListResult("locale", locales);
+
+ List<String> icuLocales = Arrays.stream(ULocale.getAvailableLocales())
+ .map((uLocale -> uLocale.toLanguageTag()))
+ .collect(Collectors.toList());
+ if (icuLocales.isEmpty()) {
+ // default locale
+ icuLocales.add(ULocale.US.toLanguageTag());
+ }
+ store.addListResult("icu_locale", icuLocales);
}
}
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskHostDrivenTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskHostDrivenTest.java
index 932943a..58a14e6 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskHostDrivenTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskHostDrivenTest.java
@@ -35,10 +35,6 @@
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
/**
* Test class that is meant to be driven from the host and can't be run alone, which is required
* for tests that include rebooting or other connection-breaking steps. For this reason, this class
@@ -46,7 +42,6 @@
* device. Therefore, the host is responsible for making sure the tests leave the device in a clean
* state after running.
*/
-@RunWith(AndroidJUnit4.class)
public class LockTaskHostDrivenTest extends BaseDeviceAdminTest {
private static final String TAG = LockTaskHostDrivenTest.class.getName();
@@ -62,7 +57,6 @@
private TelecomManager mTelcomManager;
private DevicePolicyManager mDevicePolicyManager;
- @Before
public void setUp() {
mUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
mContext = InstrumentationRegistry.getContext();
@@ -72,7 +66,6 @@
mDevicePolicyManager = mContext.getSystemService(DevicePolicyManager.class);
}
- @Test
public void startLockTask() throws Exception {
Log.d(TAG, "startLockTask on host-driven test (no cleanup)");
setLockTaskPackages(mContext.getPackageName());
@@ -81,7 +74,6 @@
mUiDevice.waitForIdle();
}
- @Test
public void cleanupLockTask() {
Log.d(TAG, "cleanupLockTask on host-driven test");
mDevicePolicyManager.clearPackagePersistentPreferredActivities(
@@ -97,7 +89,6 @@
* On low-RAM devices, this test can take too long to finish, so the test runner can incorrectly
* assume it's finished. Therefore, only use it once in a given test.
*/
- @Test
public void testLockTaskIsActiveAndCantBeInterrupted() throws Exception {
Log.d(TAG, "testLockTaskIsActiveAndCantBeInterrupted on host-driven test");
waitAndCheckLockedActivityIsResumed();
@@ -118,7 +109,6 @@
mUiDevice.waitForIdle();
}
- @Test
public void testLockTaskIsExitedIfNotWhitelisted() throws Exception {
Log.d(TAG, "testLockTaskIsExitedIfNotWhitelisted on host-driven test");
@@ -141,7 +131,6 @@
assertEquals(ActivityManager.LOCK_TASK_MODE_NONE, mActivityManager.getLockTaskModeState());
}
- @Test
public void testLockTaskCanLaunchDefaultDialer() throws Exception {
if (!hasTelephonyFeature()) {
Log.d(TAG, "testLockTaskCanLaunchDefaultDialer skipped");
@@ -178,7 +167,6 @@
mActivityManager.getLockTaskModeState());
}
- @Test
public void testLockTaskCanLaunchEmergencyDialer() throws Exception {
if (!hasTelephonyFeature()) {
Log.d(TAG, "testLockTaskCanLaunchEmergencyDialer skipped");
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskTest.java
index 37f1be3..2f9bc37 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskTest.java
@@ -40,14 +40,8 @@
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
import java.util.concurrent.TimeUnit;
-@RunWith(AndroidJUnit4.class)
public class LockTaskTest extends BaseDeviceAdminTest {
private static final String TAG = "LockTaskTest";
@@ -143,7 +137,6 @@
private ActivityManager mActivityManager;
private DevicePolicyManager mDevicePolicyManager;
- @Before
public void setUp() {
mContext = InstrumentationRegistry.getContext();
@@ -161,14 +154,12 @@
mContext.registerReceiver(mReceiver, filter);
}
- @After
public void tearDown() {
mDevicePolicyManager.setLockTaskPackages(ADMIN_COMPONENT, new String[0]);
mContext.unregisterReceiver(mReceiver);
}
// Setting and unsetting the lock task packages.
- @Test
public void testSetLockTaskPackages() {
final String[] packages = new String[] { TEST_PACKAGE, "some.other.package" };
mDevicePolicyManager.setLockTaskPackages(ADMIN_COMPONENT, packages);
@@ -182,7 +173,6 @@
// Setting and unsetting the lock task features. The actual UI behavior is tested with CTS
// verifier.
- @Test
public void testSetLockTaskFeatures() {
final int[] flags = new int[] {
LOCK_TASK_FEATURE_SYSTEM_INFO,
@@ -216,7 +206,6 @@
}
// Start lock task, verify that ActivityManager knows thats what is going on.
- @Test
public void testStartLockTask() throws Exception {
mDevicePolicyManager.setLockTaskPackages(ADMIN_COMPONENT, new String[] { PACKAGE_NAME });
startLockTask(UTILITY_ACTIVITY);
@@ -232,7 +221,6 @@
// Verifies that the act of finishing is blocked by ActivityManager in lock task.
// This results in onDestroy not being called until stopLockTask is called before finish.
- @Test
public void testCannotFinish() throws Exception {
mDevicePolicyManager.setLockTaskPackages(ADMIN_COMPONENT, new String[] { PACKAGE_NAME });
startLockTask(UTILITY_ACTIVITY);
@@ -246,7 +234,6 @@
}
// Verifies that updating the whitelisting during lock task mode finishes the locked task.
- @Test
public void testUpdateWhitelisting() throws Exception {
mDevicePolicyManager.setLockTaskPackages(ADMIN_COMPONENT, new String[] { PACKAGE_NAME });
startLockTask(UTILITY_ACTIVITY);
@@ -264,7 +251,6 @@
// Verifies that removing the whitelist authorization immediately finishes the corresponding
// locked task. The other locked task(s) should remain locked.
- @Test
public void testUpdateWhitelisting_twoTasks() throws Exception {
mDevicePolicyManager.setLockTaskPackages(ADMIN_COMPONENT, new String[] { PACKAGE_NAME,
RECEIVER_ACTIVITY_PACKAGE_NAME});
@@ -298,7 +284,6 @@
// This launches an activity that is in the current task.
// This should always be permitted as a part of lock task (since it isn't a new task).
- @Test
public void testStartActivity_withinTask() throws Exception {
mDevicePolicyManager.setLockTaskPackages(ADMIN_COMPONENT, new String[] { PACKAGE_NAME });
startLockTask(UTILITY_ACTIVITY);
@@ -319,7 +304,6 @@
// This launches a whitelisted activity that is not part of the current task.
// This should be permitted as a part of lock task.
- @Test
public void testStartActivity_outsideTaskWhitelisted() throws Exception {
mDevicePolicyManager.setLockTaskPackages(ADMIN_COMPONENT, new String[] { PACKAGE_NAME,
RECEIVER_ACTIVITY_PACKAGE_NAME});
@@ -338,7 +322,6 @@
// This launches a non-whitelisted activity that is not part of the current task.
// This should be blocked.
- @Test
public void testStartActivity_outsideTaskNonWhitelisted() throws Exception {
mDevicePolicyManager.setLockTaskPackages(ADMIN_COMPONENT, new String[] { PACKAGE_NAME });
startLockTask(UTILITY_ACTIVITY);
@@ -355,7 +338,6 @@
// Test the lockTaskMode flag for an activity declaring if_whitelisted.
// Whitelist the activity and verify that lock task mode is started.
- @Test
public void testManifestArgument_whitelisted() throws Exception {
mDevicePolicyManager.setLockTaskPackages(ADMIN_COMPONENT, new String[] { PACKAGE_NAME });
startAndWait(getLockTaskUtility(UTILITY_ACTIVITY_IF_WHITELISTED));
@@ -370,7 +352,6 @@
// Test the lockTaskMode flag for an activity declaring if_whitelisted.
// Don't whitelist the activity and verify that lock task mode is not started.
- @Test
public void testManifestArgument_nonWhitelisted() throws Exception {
startAndWait(getLockTaskUtility(UTILITY_ACTIVITY_IF_WHITELISTED));
waitForResume();
@@ -384,7 +365,6 @@
// Test the lockTaskMode flag for an activity declaring if_whitelisted.
// An activity locked via manifest argument cannot finish without calling stopLockTask.
- @Test
public void testManifestArgument_cannotFinish() throws Exception {
mDevicePolicyManager.setLockTaskPackages(ADMIN_COMPONENT, new String[] { PACKAGE_NAME });
startAndWait(getLockTaskUtility(UTILITY_ACTIVITY_IF_WHITELISTED));
@@ -400,7 +380,6 @@
// Test the lockTaskMode flag for an activity declaring if_whitelisted.
// Verifies that updating the whitelisting during lock task mode finishes the locked task.
- @Test
public void testManifestArgument_updateWhitelisting() throws Exception {
mDevicePolicyManager.setLockTaskPackages(ADMIN_COMPONENT, new String[] { PACKAGE_NAME });
startAndWait(getLockTaskUtility(UTILITY_ACTIVITY_IF_WHITELISTED));
@@ -418,7 +397,6 @@
}
// Start lock task with ActivityOptions
- @Test
public void testActivityOptions_whitelisted() throws Exception {
mDevicePolicyManager.setLockTaskPackages(ADMIN_COMPONENT, new String[] { PACKAGE_NAME });
startLockTaskWithOptions(UTILITY_ACTIVITY);
@@ -433,9 +411,13 @@
}
// Starting a non-whitelisted activity with ActivityOptions is not allowed
- @Test(expected = SecurityException.class)
public void testActivityOptions_nonWhitelisted() throws Exception {
- startLockTaskWithOptions(UTILITY_ACTIVITY);
+ try {
+ startLockTaskWithOptions(UTILITY_ACTIVITY);
+ fail();
+ } catch (SecurityException e) {
+ // pass
+ }
}
/**
diff --git a/hostsidetests/theme/app/src/android/theme/app/AssetBucketVerifier.java b/hostsidetests/theme/app/src/android/theme/app/AssetBucketVerifier.java
new file mode 100644
index 0000000..09875b1
--- /dev/null
+++ b/hostsidetests/theme/app/src/android/theme/app/AssetBucketVerifier.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2019 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.theme.app;
+
+import android.content.Context;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+class AssetBucketVerifier {
+ /** Asset file to verify. */
+ private static final String ASSET_NAME = "ic_star_black_16dp.png";
+
+ /** Densities at which {@link #ASSET_NAME} may be defined. */
+ private static final int[] DENSITIES_DPI = new int[] {
+ 160, // mdpi
+ 240, // hdpi
+ 320, // xhdpi
+ 480, // xxhdpi
+ 640, // xxxhdpi
+ };
+
+ /** Bucket names corresponding to {@link #DENSITIES_DPI} entries. */
+ private static final String[] DENSITIES_NAME = new String[] {
+ "mdpi",
+ "hdpi",
+ "xhdpi",
+ "xxhdpi",
+ "xxxhdpi"
+ };
+
+ static class Result {
+ String expectedAtDensity;
+ List<String> foundAtDensity;
+ }
+
+ static Result verifyAssetBucket(Context context) {
+ List<String> foundAtDensity = new ArrayList<>();
+ String expectedAtDensity = null;
+
+ int deviceDensityDpi = context.getResources().getConfiguration().densityDpi;
+ for (int i = 0; i < DENSITIES_DPI.length; i++) {
+ // Find the matching or next-highest density bucket.
+ if (expectedAtDensity == null && DENSITIES_DPI[i] >= deviceDensityDpi) {
+ expectedAtDensity = DENSITIES_NAME[i];
+ }
+
+ // Try to load and close the asset from the current density.
+ try {
+ context.getAssets().openNonAssetFd(1,
+ "res/drawable-" + DENSITIES_NAME[i] + "-v4/" + ASSET_NAME).close();
+ foundAtDensity.add(DENSITIES_NAME[i]);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ if (expectedAtDensity == null) {
+ expectedAtDensity = DENSITIES_NAME[DENSITIES_NAME.length - 1];
+ }
+
+ Result result = new Result();
+ result.expectedAtDensity = expectedAtDensity;
+ result.foundAtDensity = foundAtDensity;
+ return result;
+ }
+}
diff --git a/hostsidetests/theme/app/src/android/theme/app/GenerateImagesActivity.java b/hostsidetests/theme/app/src/android/theme/app/GenerateImagesActivity.java
index a41e426..9ee5a65 100644
--- a/hostsidetests/theme/app/src/android/theme/app/GenerateImagesActivity.java
+++ b/hostsidetests/theme/app/src/android/theme/app/GenerateImagesActivity.java
@@ -59,14 +59,41 @@
// Useful for local testing. Not required for CTS harness.
getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);
- mOutputDir = setupOutputDirectory();
- if (mOutputDir == null) {
- finish("Failed to create output directory " + mOutputDir.getAbsolutePath(), false);
+ // Make sure the device has reasonable assets.
+ String assetDensityFailureMsg = checkAssetDensity();
+ if (assetDensityFailureMsg != null) {
+ finish("Failed to verify device assets: "+ assetDensityFailureMsg, false);
} else {
- generateNextImage();
+ mOutputDir = setupOutputDirectory();
+ if (mOutputDir == null) {
+ finish("Failed to create output directory: " + OUT_DIR, false);
+ } else {
+ generateNextImage();
+ }
}
}
+ private String checkAssetDensity() {
+ AssetBucketVerifier.Result result = AssetBucketVerifier.verifyAssetBucket(this);
+
+ String message;
+ if (result.foundAtDensity.contains(result.expectedAtDensity)) {
+ message = null;
+ } else if (result.foundAtDensity.isEmpty()) {
+ message = "Failed to find expected device assets at any density";
+ } else {
+ StringBuilder foundAtDensityStr = new StringBuilder(result.foundAtDensity.get(0));
+ for (int i = 1; i < result.foundAtDensity.size(); i++) {
+ foundAtDensityStr.append(", ");
+ foundAtDensityStr.append(result.foundAtDensity.get(i));
+ }
+ message = "Failed to find device assets at expected density ("
+ + result.expectedAtDensity + "), but found at " + foundAtDensityStr;
+ }
+
+ return message;
+ }
+
private File setupOutputDirectory() {
mOutputDir = new File(Environment.getExternalStorageDirectory(), OUT_DIR);
ThemeTestUtils.deleteDirectory(mOutputDir);
@@ -99,8 +126,9 @@
private void generateNextImage() {
// Keep trying themes until one works.
boolean success = false;
- while (++mCurrentTheme < THEMES.length && !success) {
+ while (mCurrentTheme < THEMES.length && !success) {
success = launchThemeDeviceActivity();
+ mCurrentTheme++;
}
// If we ran out of themes, we're done.
diff --git a/tests/jdwp/runner/host-side/src/com/android/compatibility/testtype/LibcoreTest.java b/tests/jdwp/runner/host-side/src/com/android/compatibility/testtype/LibcoreTest.java
index 980315a..12131e5 100644
--- a/tests/jdwp/runner/host-side/src/com/android/compatibility/testtype/LibcoreTest.java
+++ b/tests/jdwp/runner/host-side/src/com/android/compatibility/testtype/LibcoreTest.java
@@ -20,6 +20,7 @@
import com.android.tradefed.config.Option;
import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.invoker.TestInformation;
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.testtype.AndroidJUnitTest;
@@ -55,7 +56,7 @@
* {@inheritDoc}
*/
@Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
+ public void run(TestInformation testInfo, ITestInvocationListener listener) throws DeviceNotAvailableException {
List<String> coreExpectations = getCoreExpectations();
if (!coreExpectations.isEmpty()) {
addInstrumentationArg(INSTRUMENTATION_ARG_NAME, ArrayUtil.join(",", coreExpectations));
@@ -70,7 +71,7 @@
"Setting --class and --method to null to avoid conflict with --test-package "
+ "option.");
}
- super.run(listener);
+ super.run(testInfo, listener);
}
private List<String> getCoreExpectations() throws DeviceNotAvailableException {
diff --git a/tests/tests/binder_ndk/libbinder_ndk_test/aidl_api/libbinder_ndk_test_interface/1/test_package/ITest.aidl b/tests/tests/binder_ndk/libbinder_ndk_test/aidl_api/libbinder_ndk_test_interface/1/test_package/ITest.aidl
index 72d5985..887cbe0 100644
--- a/tests/tests/binder_ndk/libbinder_ndk_test/aidl_api/libbinder_ndk_test_interface/1/test_package/ITest.aidl
+++ b/tests/tests/binder_ndk/libbinder_ndk_test/aidl_api/libbinder_ndk_test_interface/1/test_package/ITest.aidl
@@ -27,6 +27,7 @@
String RepeatString(String value);
@nullable String RepeatNullableString(@nullable String value);
test_package.RegularPolygon RepeatPolygon(in test_package.RegularPolygon value);
+ @nullable test_package.RegularPolygon RepeatNullablePolygon(in @nullable test_package.RegularPolygon value);
void RenamePolygon(inout test_package.RegularPolygon value, String newName);
boolean[] RepeatBooleanArray(in boolean[] input, out boolean[] repeated);
byte[] RepeatByteArray(in byte[] input, out byte[] repeated);
diff --git a/tests/tests/binder_ndk/libbinder_ndk_test/aidl_api/libbinder_ndk_test_interface/2/test_package/ITest.aidl b/tests/tests/binder_ndk/libbinder_ndk_test/aidl_api/libbinder_ndk_test_interface/2/test_package/ITest.aidl
index 891cf0b..c489e56 100644
--- a/tests/tests/binder_ndk/libbinder_ndk_test/aidl_api/libbinder_ndk_test_interface/2/test_package/ITest.aidl
+++ b/tests/tests/binder_ndk/libbinder_ndk_test/aidl_api/libbinder_ndk_test_interface/2/test_package/ITest.aidl
@@ -27,6 +27,7 @@
String RepeatString(String value);
@nullable String RepeatNullableString(@nullable String value);
test_package.RegularPolygon RepeatPolygon(in test_package.RegularPolygon value);
+ @nullable test_package.RegularPolygon RepeatNullablePolygon(in @nullable test_package.RegularPolygon value);
void RenamePolygon(inout test_package.RegularPolygon value, String newName);
boolean[] RepeatBooleanArray(in boolean[] input, out boolean[] repeated);
byte[] RepeatByteArray(in byte[] input, out byte[] repeated);
diff --git a/tests/tests/binder_ndk/libbinder_ndk_test/itest_impl.h b/tests/tests/binder_ndk/libbinder_ndk_test/itest_impl.h
index 812eb04..a8c30ba 100644
--- a/tests/tests/binder_ndk/libbinder_ndk_test/itest_impl.h
+++ b/tests/tests/binder_ndk/libbinder_ndk_test/itest_impl.h
@@ -207,6 +207,11 @@
*_aidl_return = in_value;
return ::ndk::ScopedAStatus(AStatus_newOk());
}
+ ::ndk::ScopedAStatus RepeatNullablePolygon(const std::optional<RegularPolygon>& in_value,
+ std::optional<RegularPolygon>* _aidl_return) override {
+ *_aidl_return = in_value;
+ return ::ndk::ScopedAStatus(AStatus_newOk());
+ }
::ndk::ScopedAStatus RenamePolygon(RegularPolygon* value,
const std::string& newName) override {
value->name = newName;
diff --git a/tests/tests/binder_ndk/libbinder_ndk_test/test_native_aidl_client.cpp b/tests/tests/binder_ndk/libbinder_ndk_test/test_native_aidl_client.cpp
index 2608830..24dc52a 100644
--- a/tests/tests/binder_ndk/libbinder_ndk_test/test_native_aidl_client.cpp
+++ b/tests/tests/binder_ndk/libbinder_ndk_test/test_native_aidl_client.cpp
@@ -401,9 +401,22 @@
RegularPolygon defaultPolygon = {"hexagon", 6, 2.0f};
RegularPolygon outputPolygon;
ASSERT_OK(iface->RepeatPolygon(defaultPolygon, &outputPolygon));
- EXPECT_EQ("hexagon", outputPolygon.name);
- EXPECT_EQ(defaultPolygon.numSides, outputPolygon.numSides);
- EXPECT_EQ(defaultPolygon.sideLength, outputPolygon.sideLength);
+ EXPECT_EQ(defaultPolygon, outputPolygon);
+}
+
+TEST_P(NdkBinderTest_Aidl, RepeatNullNullablePolygon) {
+ std::optional<RegularPolygon> defaultPolygon;
+ std::optional<RegularPolygon> outputPolygon;
+ ASSERT_OK(iface->RepeatNullablePolygon(defaultPolygon, &outputPolygon));
+ EXPECT_EQ(defaultPolygon, outputPolygon);
+}
+
+TEST_P(NdkBinderTest_Aidl, RepeatPresentNullablePolygon) {
+ std::optional<RegularPolygon> defaultPolygon =
+ std::optional<RegularPolygon>({"septagon", 7, 3.0f});
+ std::optional<RegularPolygon> outputPolygon;
+ ASSERT_OK(iface->RepeatNullablePolygon(defaultPolygon, &outputPolygon));
+ EXPECT_EQ(defaultPolygon, outputPolygon);
}
TEST_P(NdkBinderTest_Aidl, InsAndOuts) {
diff --git a/tests/tests/binder_ndk/libbinder_ndk_test/test_package/ITest.aidl b/tests/tests/binder_ndk/libbinder_ndk_test/test_package/ITest.aidl
index 669f683..8166e87 100644
--- a/tests/tests/binder_ndk/libbinder_ndk_test/test_package/ITest.aidl
+++ b/tests/tests/binder_ndk/libbinder_ndk_test/test_package/ITest.aidl
@@ -71,6 +71,7 @@
@nullable String RepeatNullableString(@nullable String value);
RegularPolygon RepeatPolygon(in RegularPolygon value);
+ @nullable RegularPolygon RepeatNullablePolygon(in @nullable RegularPolygon value);
// Testing inout
void RenamePolygon(inout RegularPolygon value, String newName);
diff --git a/tests/tests/binder_ndk/src/android/binder/cts/JavaClientTest.java b/tests/tests/binder_ndk/src/android/binder/cts/JavaClientTest.java
index 01429f6..21c40c7 100644
--- a/tests/tests/binder_ndk/src/android/binder/cts/JavaClientTest.java
+++ b/tests/tests/binder_ndk/src/android/binder/cts/JavaClientTest.java
@@ -294,6 +294,36 @@
}
@Test
+ public void testRepeatUnexpectedNullPolygon() throws RemoteException {
+ try {
+ RegularPolygon result = mInterface.RepeatPolygon(null);
+ } catch (NullPointerException e) {
+ // non-@nullable C++ result can't handle null Polygon
+ return;
+ }
+ // Java always works w/ nullptr
+ assertEquals("JAVA", mExpectedName);
+ }
+
+ @Test
+ public void testRepeatNullNullablePolygon() throws RemoteException {
+ RegularPolygon result = mInterface.RepeatNullablePolygon(null);
+ assertEquals(null, result);
+ }
+
+ @Test
+ public void testRepeatPresentNullablePolygon() throws RemoteException {
+ RegularPolygon polygon = new RegularPolygon();
+ polygon.name = "septagon";
+ polygon.numSides = 7;
+ polygon.sideLength = 9.0f;
+
+ RegularPolygon result = mInterface.RepeatNullablePolygon(polygon);
+
+ assertPolygonEquals(polygon, result);
+ }
+
+ @Test
public void testInsAndOuts() throws RemoteException {
RegularPolygon polygon = new RegularPolygon();
mInterface.RenamePolygon(polygon, "Jerry");
diff --git a/tests/tests/binder_ndk/src/android/binder/cts/TestImpl.java b/tests/tests/binder_ndk/src/android/binder/cts/TestImpl.java
index 828d11e..872c166 100644
--- a/tests/tests/binder_ndk/src/android/binder/cts/TestImpl.java
+++ b/tests/tests/binder_ndk/src/android/binder/cts/TestImpl.java
@@ -194,6 +194,11 @@
}
@Override
+ public RegularPolygon RepeatNullablePolygon(RegularPolygon in_value) {
+ return in_value;
+ }
+
+ @Override
public void RenamePolygon(RegularPolygon value, String name) {
value.name = name;
}
diff --git a/tests/tests/media/src/android/media/cts/AudioFormatTest.java b/tests/tests/media/src/android/media/cts/AudioFormatTest.java
index 221dcfa..6ca4a3b 100644
--- a/tests/tests/media/src/android/media/cts/AudioFormatTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioFormatTest.java
@@ -176,14 +176,23 @@
// Test case 7: Check frame size for compressed, float formats.
public void testFrameSize() throws Exception {
- final AudioFormat formatMp3 = new AudioFormat.Builder()
- .setEncoding(AudioFormat.ENCODING_MP3)
- .setSampleRate(44100)
- .setChannelMask(AudioFormat.CHANNEL_OUT_STEREO)
- .build();
+ int[] encodings = {
+ AudioFormat.ENCODING_MP3,
+ AudioFormat.ENCODING_AAC_LC,
+ AudioFormat.ENCODING_AAC_HE_V1,
+ AudioFormat.ENCODING_AAC_HE_V2,
+ AudioFormat.ENCODING_OPUS
+ };
+ for (int encoding : encodings) {
+ final AudioFormat format = new AudioFormat.Builder()
+ .setEncoding(encoding)
+ .setSampleRate(44100)
+ .setChannelMask(AudioFormat.CHANNEL_OUT_STEREO)
+ .build();
- assertEquals("MP3 AudioFormat has the wrong frame size",
- 1, formatMp3.getFrameSizeInBytes());
+ assertEquals("AudioFormat with encoding " + encoding + " has the wrong frame size",
+ 1, format.getFrameSizeInBytes());
+ }
final AudioFormat formatPcmFloat = new AudioFormat.Builder()
.setEncoding(AudioFormat.ENCODING_PCM_FLOAT)
diff --git a/tests/tests/media/src/android/media/cts/AudioTrackOffloadTest.java b/tests/tests/media/src/android/media/cts/AudioTrackOffloadTest.java
index aa0d50b..5d46c3a 100644
--- a/tests/tests/media/src/android/media/cts/AudioTrackOffloadTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioTrackOffloadTest.java
@@ -17,6 +17,7 @@
package android.media.cts;
+import android.annotation.RawRes;
import android.content.res.AssetFileDescriptor;
import android.media.AudioAttributes;
import android.media.AudioFormat;
@@ -34,18 +35,12 @@
public class AudioTrackOffloadTest extends CtsAndroidTestCase {
private static final String TAG = "AudioTrackOffloadTest";
- private static final int MP3_BUFF_SIZE = 192 * 1024 * 3 / 8; // 3s for 192kbps MP3
+ private static final int BUFFER_SIZE_SEC = 3;
private static final int PRESENTATION_END_TIMEOUT_MS = 8 * 1000; // 8s
private static final AudioAttributes DEFAULT_ATTR = new AudioAttributes.Builder().build();
- private static final AudioFormat DEFAULT_FORMAT = new AudioFormat.Builder()
- .setEncoding(AudioFormat.ENCODING_MP3)
- .setSampleRate(44100)
- .setChannelMask(AudioFormat.CHANNEL_OUT_STEREO)
- .build();
-
public void testIsOffloadSupportedNullFormat() throws Exception {
try {
final boolean offloadableFormat = AudioManager.isOffloadedPlaybackSupported(null,
@@ -59,30 +54,43 @@
public void testIsOffloadSupportedNullAttributes() throws Exception {
try {
final boolean offloadableFormat = AudioManager.isOffloadedPlaybackSupported(
- DEFAULT_FORMAT, null);
+ getAudioFormatWithEncoding(AudioFormat.ENCODING_MP3), null);
fail("Shouldn't be able to use null AudioAttributes in isOffloadedPlaybackSupported()");
} catch (NullPointerException e) {
// ok, NPE is expected here
}
}
-
public void testExerciseIsOffloadSupported() throws Exception {
- final boolean offloadableFormat =
- AudioManager.isOffloadedPlaybackSupported(DEFAULT_FORMAT, DEFAULT_ATTR);
+ final boolean offloadableFormat = AudioManager.isOffloadedPlaybackSupported(
+ getAudioFormatWithEncoding(AudioFormat.ENCODING_MP3), DEFAULT_ATTR);
}
- public void testAudioTrackOffload() throws Exception {
+ public void testMP3AudioTrackOffload() throws Exception {
+ testAudioTrackOffload(R.raw.sine1khzs40dblong,
+ /* bitRateInkbps= */ 192,
+ getAudioFormatWithEncoding(AudioFormat.ENCODING_MP3));
+ }
+
+ public void testOpusAudioTrackOffload() throws Exception {
+ testAudioTrackOffload(R.raw.testopus,
+ /* bitRateInkbps= */ 118, // Average
+ getAudioFormatWithEncoding(AudioFormat.ENCODING_OPUS));
+ }
+
+ /** Test offload of an audio resource that MUST be at least 3sec long. */
+ private void testAudioTrackOffload(@RawRes int audioRes, int bitRateInkbps,
+ AudioFormat audioFormat) throws Exception {
AudioTrack track = null;
+ int bufferSizeInBytes3sec = bitRateInkbps * 1024 * 3 / 8;
+ try (AssetFileDescriptor audioToOffload = getContext().getResources()
+ .openRawResourceFd(audioRes);
+ InputStream audioInputStream = audioToOffload.createInputStream()) {
- try (AssetFileDescriptor mp3ToOffload = getContext().getResources()
- .openRawResourceFd(R.raw.sine1khzs40dblong);
- InputStream mp3InputStream = mp3ToOffload.createInputStream()) {
-
- long mp3ToOffloadLength = mp3ToOffload.getLength();
- if (!AudioManager.isOffloadedPlaybackSupported(DEFAULT_FORMAT, DEFAULT_ATTR)) {
- Log.i(TAG, "skipping test testPlayback");
+ if (!AudioManager.isOffloadedPlaybackSupported(audioFormat, DEFAULT_ATTR)) {
+ Log.i(TAG, "skipping testAudioTrackOffload as offload encoding "
+ + audioFormat.getEncoding() + " is not supported");
// cannot test if offloading is not supported
return;
}
@@ -90,9 +98,9 @@
// format is offloadable, test playback head is progressing
track = new AudioTrack.Builder()
.setAudioAttributes(DEFAULT_ATTR)
- .setAudioFormat(DEFAULT_FORMAT)
+ .setAudioFormat(audioFormat)
.setTransferMode(AudioTrack.MODE_STREAM)
- .setBufferSizeInBytes(MP3_BUFF_SIZE)
+ .setBufferSizeInBytes(bufferSizeInBytes3sec)
.setOffloadedPlayback(true).build();
assertNotNull("Couldn't create offloaded AudioTrack", track);
assertEquals("Unexpected track sample rate", 44100, track.getSampleRate());
@@ -105,8 +113,10 @@
} catch (Exception e) { }
track.registerStreamEventCallback(mExec, mCallback);
- final byte[] data = new byte[MP3_BUFF_SIZE];
- final int read = mp3InputStream.read(data);
+ final byte[] data = new byte[bufferSizeInBytes3sec];
+ final int read = audioInputStream.read(data);
+ assertEquals("Could not read enough audio from the resource file",
+ bufferSizeInBytes3sec, read);
track.play();
int written = 0;
@@ -145,6 +155,14 @@
}
}
+ private static AudioFormat getAudioFormatWithEncoding(int encoding) {
+ return new AudioFormat.Builder()
+ .setEncoding(encoding)
+ .setSampleRate(44100)
+ .setChannelMask(AudioFormat.CHANNEL_OUT_STEREO)
+ .build();
+ }
+
private Executor mExec = new Executor() {
@Override
public void execute(Runnable command) {
diff --git a/tests/tests/permission2/res/raw/android_manifest.xml b/tests/tests/permission2/res/raw/android_manifest.xml
index 7fc29e2..436db62 100644
--- a/tests/tests/permission2/res/raw/android_manifest.xml
+++ b/tests/tests/permission2/res/raw/android_manifest.xml
@@ -305,6 +305,7 @@
<protected-broadcast android:name="android.net.nsd.STATE_CHANGED" />
<protected-broadcast android:name="android.nfc.action.ADAPTER_STATE_CHANGED" />
+ <protected-broadcast android:name="android.nfc.action.PREFERRED_PAYMENT_CHANGED" />
<protected-broadcast android:name="android.nfc.action.TRANSACTION_DETECTED" />
<protected-broadcast android:name="com.android.nfc.action.LLCP_UP" />
<protected-broadcast android:name="com.android.nfc.action.LLCP_DOWN" />
@@ -1696,6 +1697,14 @@
<permission android:name="android.permission.NFC_TRANSACTION_EVENT"
android:protectionLevel="normal" />
+ <!-- Allows applications to receive NFC preferred payment service information.
+ <p>Protection level: normal
+ -->
+ <permission android:name="android.permission.NFC_PREFERRED_PAYMENT_INFO"
+ android:description="@string/permdesc_preferredPaymentInfo"
+ android:label="@string/permlab_preferredPaymentInfo"
+ android:protectionLevel="normal" />
+
<!-- @SystemApi Allows an internal user to use privileged ConnectivityManager APIs.
@hide -->
<permission android:name="android.permission.CONNECTIVITY_INTERNAL"
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/CarrierServiceTest.java b/tests/tests/telephony/current/src/android/telephony/cts/CarrierServiceTest.java
index c0fd028..dfe4275 100644
--- a/tests/tests/telephony/current/src/android/telephony/cts/CarrierServiceTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/cts/CarrierServiceTest.java
@@ -29,8 +29,6 @@
import android.test.ServiceTestCase;
import android.util.Log;
-import org.junit.Test;
-
public class CarrierServiceTest extends ServiceTestCase<CarrierServiceTest.TestCarrierService> {
private static final String TAG = CarrierServiceTest.class.getSimpleName();
@@ -56,14 +54,12 @@
&& telephonyManager.getPhoneCount() > 0;
}
- @Test
public void testNotifyCarrierNetworkChange_true() {
if (!mHasCellular) return;
notifyCarrierNetworkChange(true);
}
- @Test
public void testNotifyCarrierNetworkChange_false() {
if (!mHasCellular) return;
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/SmsMessageTest.java b/tests/tests/telephony/current/src/android/telephony/cts/SmsMessageTest.java
index 165c5cd..8c855db 100644
--- a/tests/tests/telephony/current/src/android/telephony/cts/SmsMessageTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/cts/SmsMessageTest.java
@@ -103,6 +103,7 @@
assertEquals(MESSAGE_BODY1, sms.getMessageBody());
assertEquals(TPLAYER_LENGTH_FOR_PDU, SmsMessage.getTPLayerLengthForPDU(pdu));
int[] result = SmsMessage.calculateLength(sms.getMessageBody(), true);
+ assertEquals(6, result.length);
assertEquals(SMS_NUMBER1, result[0]);
assertEquals(sms.getMessageBody().length(), result[1]);
assertRemaining(sms.getMessageBody().length(), result[2], SmsMessage.MAX_USER_DATA_SEPTETS);
@@ -135,6 +136,7 @@
assertEquals(MESSAGE_BODY2, sms.getMessageBody());
CharSequence msgBody = sms.getMessageBody();
result = SmsMessage.calculateLength(msgBody, false);
+ assertEquals(6, result.length);
assertEquals(SMS_NUMBER2, result[0]);
assertEquals(sms.getMessageBody().length(), result[1]);
assertRemaining(sms.getMessageBody().length(), result[2], SmsMessage.MAX_USER_DATA_SEPTETS);
@@ -146,6 +148,7 @@
sms = SmsMessage.createFromPdu(hexStringToByteArray(pdu), SmsMessage.FORMAT_3GPP);
assertEquals(MESSAGE_BODY3, sms.getMessageBody());
result = SmsMessage.calculateLength(sms.getMessageBody(), true);
+ assertEquals(6, result.length);
assertEquals(SMS_NUMBER3, result[0]);
assertEquals(sms.getMessageBody().length(), result[1]);
assertRemaining(sms.getMessageBody().length(), result[2], SmsMessage.MAX_USER_DATA_SEPTETS);
@@ -317,6 +320,7 @@
}
int[] result = SmsMessage.calculateLength(LONG_TEXT_WITH_32BIT_CHARS, false);
+ assertEquals(6, result.length);
assertEquals(3, result[0]);
assertEquals(LONG_TEXT_WITH_32BIT_CHARS.length(), result[1]);
// 3 parts, each with (SmsMessage.MAX_USER_DATA_BYTES_WITH_HEADER / 2) 16-bit
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java b/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java
index baf2c81..853bf9d 100644
--- a/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java
@@ -87,6 +87,7 @@
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
@@ -1595,8 +1596,25 @@
assertEquals(0, cq.getCodecType());
}
+
+ // Reference: packages/services/Telephony/ecc/input/eccdata.txt
+ private static final Map<String, String> EMERGENCY_NUMBERS_FOR_COUNTRIES =
+ new HashMap<String, String>() {{
+ put("au", "000");
+ put("ca", "911");
+ put("de", "112");
+ put("gb", "999");
+ put("in", "112");
+ put("jp", "110");
+ put("sg", "999");
+ put("tw", "110");
+ put("us", "911");
+ }};
+
/**
* Tests TelephonyManager.getEmergencyNumberList.
+ *
+ * Also enforce country-specific emergency number in CTS.
*/
@Test
public void testGetEmergencyNumberList() {
@@ -1611,58 +1629,29 @@
checkEmergencyNumberFormat(emergencyNumberList);
int defaultSubId = mSubscriptionManager.getDefaultSubscriptionId();
-
- // 112 and 911 should always be available
- // Reference: 3gpp 22.101, Section 10 - Emergency Calls
- assertTrue(checkIfEmergencyNumberListHasSpecificAddress(
- emergencyNumberList.get(defaultSubId), "911"));
- assertTrue(checkIfEmergencyNumberListHasSpecificAddress(
- emergencyNumberList.get(defaultSubId), "112"));
-
- // 000, 08, 110, 118, 119, and 999 should be always available when sim is absent
- // Reference: 3gpp 22.101, Section 10 - Emergency Calls
- if (mTelephonyManager.getPhoneCount() > 0
- && mSubscriptionManager.getSimStateForSlotIndex(0)
- == TelephonyManager.SIM_STATE_ABSENT) {
- assertTrue(checkIfEmergencyNumberListHasSpecificAddress(
- emergencyNumberList.get(defaultSubId), "000"));
- assertTrue(checkIfEmergencyNumberListHasSpecificAddress(
- emergencyNumberList.get(defaultSubId), "08"));
- assertTrue(checkIfEmergencyNumberListHasSpecificAddress(
- emergencyNumberList.get(defaultSubId), "110"));
- assertTrue(checkIfEmergencyNumberListHasSpecificAddress(
- emergencyNumberList.get(defaultSubId), "118"));
- assertTrue(checkIfEmergencyNumberListHasSpecificAddress(
- emergencyNumberList.get(defaultSubId), "119"));
- assertTrue(checkIfEmergencyNumberListHasSpecificAddress(
- emergencyNumberList.get(defaultSubId), "999"));
+ for (Map.Entry<String, String> entry : EMERGENCY_NUMBERS_FOR_COUNTRIES.entrySet()) {
+ if (mTelephonyManager.getNetworkCountryIso().equals(entry.getKey())) {
+ assertTrue(checkIfEmergencyNumberListHasSpecificAddress(
+ emergencyNumberList.get(defaultSubId), entry.getValue()));
+ }
}
}
/**
* Tests TelephonyManager.isEmergencyNumber.
+ *
+ * Also enforce country-specific emergency number in CTS.
*/
@Test
public void testIsEmergencyNumber() {
if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
return;
}
- // 112 and 911 should always be available
- // Reference: 3gpp 22.101, Section 10 - Emergency Calls
- assertTrue(mTelephonyManager.isEmergencyNumber("911"));
- assertTrue(mTelephonyManager.isEmergencyNumber("112"));
- // 000, 08, 110, 118, 119, and 999 should be always available when sim is absent
- // Reference: 3gpp 22.101, Section 10 - Emergency Calls
- if (mTelephonyManager.getPhoneCount() > 0
- && mSubscriptionManager.getSimStateForSlotIndex(0)
- == TelephonyManager.SIM_STATE_ABSENT) {
- assertTrue(mTelephonyManager.isEmergencyNumber("000"));
- assertTrue(mTelephonyManager.isEmergencyNumber("08"));
- assertTrue(mTelephonyManager.isEmergencyNumber("110"));
- assertTrue(mTelephonyManager.isEmergencyNumber("118"));
- assertTrue(mTelephonyManager.isEmergencyNumber("119"));
- assertTrue(mTelephonyManager.isEmergencyNumber("999"));
+ for (Map.Entry<String, String> entry : EMERGENCY_NUMBERS_FOR_COUNTRIES.entrySet()) {
+ if (mTelephonyManager.getNetworkCountryIso().equals(entry.getKey())) {
+ assertTrue(mTelephonyManager.isEmergencyNumber(entry.getValue()));
+ }
}
}
diff --git a/tests/tests/tethering/src/android/tethering/cts/TetheringManagerTest.java b/tests/tests/tethering/src/android/tethering/cts/TetheringManagerTest.java
index 9efb8f3..043d04f 100644
--- a/tests/tests/tethering/src/android/tethering/cts/TetheringManagerTest.java
+++ b/tests/tests/tethering/src/android/tethering/cts/TetheringManagerTest.java
@@ -33,6 +33,7 @@
import org.junit.runner.RunWith;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
@@ -163,13 +164,13 @@
if (state == null || state.mErrored == null) return;
if (state.mErrored.size() > 0) {
- fail("Found failed tethering interfaces: " + state.mErrored.toArray());
+ fail("Found failed tethering interfaces: " + Arrays.toString(state.mErrored.toArray()));
}
}
private void assertNoActiveIfaces(final TetherState state) {
if (state.mActive != null && state.mActive.size() > 0) {
- fail("Found active tethering interface: " + state.mActive.toArray());
+ fail("Found active tethering interface: " + Arrays.toString(state.mActive.toArray()));
}
}
}
diff --git a/tests/tests/theme/AndroidTest.xml b/tests/tests/theme/AndroidTest.xml
index fa00709..426f366 100644
--- a/tests/tests/theme/AndroidTest.xml
+++ b/tests/tests/theme/AndroidTest.xml
@@ -18,6 +18,7 @@
<option name="config-descriptor:metadata" key="component" value="uitoolkit" />
<option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
<option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
+ <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsThemeDeviceTestCases.apk" />