Merge "DO NOT MERGE: Skip four cases for automotive device due to notification cannot be shown on unlock screen with PIN code." into pie-cts-dev
diff --git a/CleanSpec.mk b/CleanSpec.mk
index a7121ad..e42e0d9 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -47,6 +47,9 @@
$(call add-clean-step, rm -rf $(HOST_OUT_INTERMEDIATES)/EXECUTABLES/vm-tests-tf_intermediates)
$(call add-clean-step, rm -rf $(OUT_DIR)/host/common/obj/JAVA_LIBRARIES/cts-tradefed_intermediates/com/android/compatibility/SuiteInfo.java)
$(call add-clean-step, rm -rf $(HOST_OUT)/cts/android-cts/testcases/CtsUiHostTestCases*)
+$(call add-clean-step, rm -rf $(HOST_OUT)/cts_instant/android-cts_instant/testcases/CtsJobSchedulerTestCases*)
+$(call add-clean-step, rm -rf $(HOST_OUT)/cts_instant/android-cts_instant/testcases/CtsUiHostTestCases*)
+$(call add-clean-step, rm -rf $(HOST_OUT)/cts_instant/android-cts_instant/testcases/CtsDpiTestCases2*)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
diff --git a/apps/CameraITS/pymodules/its/cv2image.py b/apps/CameraITS/pymodules/its/cv2image.py
index 21804e9..2004846 100644
--- a/apps/CameraITS/pymodules/its/cv2image.py
+++ b/apps/CameraITS/pymodules/its/cv2image.py
@@ -51,7 +51,7 @@
"""
def __init__(self, chart_file, height, distance, scale_start, scale_stop,
- scale_step):
+ scale_step, camera_id=None):
"""Initial constructor for class.
Args:
@@ -61,6 +61,7 @@
scale_start: float; start value for scaling for chart search
scale_stop: float; stop value for scaling for chart search
scale_step: float; step value for scaling for chart search
+ camera_id: int; camera used for extractor
"""
self._file = chart_file
self._height = height
@@ -70,7 +71,7 @@
self._scale_step = scale_step
self.xnorm, self.ynorm, self.wnorm, self.hnorm, self.scale = its.image.chart_located_per_argv()
if not self.xnorm:
- with its.device.ItsSession() as cam:
+ with its.device.ItsSession(camera_id) as cam:
props = cam.get_camera_properties()
if its.caps.read_3a(props):
self.locate(cam, props)
diff --git a/apps/CameraITS/pymodules/its/device.py b/apps/CameraITS/pymodules/its/device.py
index 1c3c2c1..8b02230 100644
--- a/apps/CameraITS/pymodules/its/device.py
+++ b/apps/CameraITS/pymodules/its/device.py
@@ -216,6 +216,9 @@
break
proc.kill()
+ def __init__(self, camera_id=None):
+ self._camera_id = camera_id
+
def __enter__(self):
# Initialize device id and adb command.
self.device_id = get_device_id()
@@ -225,7 +228,7 @@
self.__init_socket_port()
self.__close_camera()
- self.__open_camera()
+ self.__open_camera(self._camera_id)
return self
def __exit__(self, type, value, traceback):
@@ -258,12 +261,17 @@
buf = numpy.frombuffer(buf, dtype=numpy.uint8)
return jobj, buf
- def __open_camera(self):
- # Get the camera ID to open as an argument.
- camera_id = 0
- for s in sys.argv[1:]:
- if s[:7] == "camera=" and len(s) > 7:
- camera_id = int(s[7:])
+ def __open_camera(self, camera_id):
+ # Get the camera ID to open if it is an argument as a single camera.
+ # This allows passing camera=# to individual tests at command line
+ # and camera=#,#,# or an no camera argv with tools/run_all_tests.py.
+ if not camera_id:
+ camera_id = 0
+ for s in sys.argv[1:]:
+ if s[:7] == "camera=" and len(s) > 7:
+ camera_ids = s[7:].split(",")
+ if len(camera_ids) == 1:
+ camera_id = camera_ids[0]
cmd = {"cmdName":"open", "cameraId":camera_id}
self.sock.send(json.dumps(cmd) + "\n")
data,_ = self.__read_response_from_socket()
diff --git a/apps/CameraITS/tests/scene0/test_gyro_bias.py b/apps/CameraITS/tests/scene0/test_gyro_bias.py
index 86445fe..44be95f 100644
--- a/apps/CameraITS/tests/scene0/test_gyro_bias.py
+++ b/apps/CameraITS/tests/scene0/test_gyro_bias.py
@@ -39,7 +39,8 @@
with its.device.ItsSession() as cam:
props = cam.get_camera_properties()
# Only run test if the appropriate caps are claimed.
- its.caps.skip_unless(its.caps.sensor_fusion(props))
+ its.caps.skip_unless(its.caps.sensor_fusion(props) and
+ cam.get_sensors().get("gyro"))
print "Collecting gyro events"
cam.start_sensor_events()
diff --git a/apps/CameraITS/tests/scene0/test_read_write.py b/apps/CameraITS/tests/scene0/test_read_write.py
index 3c56fba..1b76806 100644
--- a/apps/CameraITS/tests/scene0/test_read_write.py
+++ b/apps/CameraITS/tests/scene0/test_read_write.py
@@ -21,7 +21,7 @@
NAME = os.path.basename(__file__).split('.')[0]
RTOL_EXP_GAIN = 0.97
-TEST_EXP_RANGE = [1E6, 1E9] # ns [1ms, 1s]
+TEST_EXP_RANGE = [6E6, 1E9] # ns [6ms, 1s]
def main():
diff --git a/apps/CameraITS/tests/scene1/test_exposure.py b/apps/CameraITS/tests/scene1/test_exposure.py
index 460fe7c..cac49d0 100644
--- a/apps/CameraITS/tests/scene1/test_exposure.py
+++ b/apps/CameraITS/tests/scene1/test_exposure.py
@@ -33,7 +33,7 @@
THRESH_ROUND_DOWN_GAIN = 0.1
THRESH_ROUND_DOWN_EXP = 0.03
THRESH_ROUND_DOWN_EXP0 = 1.00 # tol at 0ms exp; theoretical limit @ 4-line exp
-THRESH_EXP_KNEE = 1E6 # exposures less than 1ms have relaxed tol
+THRESH_EXP_KNEE = 6E6 # exposures less than knee have relaxed tol
def get_raw_active_array_size(props):
@@ -67,9 +67,7 @@
its.caps.skip_unless(its.caps.compute_target_exposure(props) and
its.caps.per_frame_control(props))
- process_raw = (its.caps.compute_target_exposure(props) and
- its.caps.per_frame_control(props) and
- its.caps.raw16(props) and
+ process_raw = (its.caps.raw16(props) and
its.caps.manual_sensor(props))
debug = its.caps.debug_mode()
@@ -112,7 +110,7 @@
assert 0 <= e_test - e_res < e_test * thresh_round_down_exp, e_msg
s_e_product_res = s_res * e_res
request_result_ratio = s_e_product / s_e_product_res
- print 'Capture result s:', s_test, 'e:', e_test
+ print 'Capture result s:', s_res, 'e:', e_res
img = its.image.convert_capture_to_rgb_image(cap)
its.image.write_image(img, '%s_mult=%3.2f.jpg' % (NAME, m))
tile = its.image.get_image_patch(img, 0.45, 0.45, 0.1, 0.1)
diff --git a/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py b/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py
index bc00d5f..265fc33 100644
--- a/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py
+++ b/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py
@@ -430,7 +430,8 @@
props = cam.get_camera_properties()
its.caps.skip_unless(its.caps.sensor_fusion(props) and
its.caps.manual_sensor(props) and
- props["android.lens.facing"] != FACING_EXTERNAL)
+ props["android.lens.facing"] != FACING_EXTERNAL and
+ cam.get_sensors().get("gyro"))
print "Starting sensor event collection"
cam.start_sensor_events()
diff --git a/apps/CameraITS/tools/run_all_tests.py b/apps/CameraITS/tools/run_all_tests.py
index a6e0402..4cc0151 100644
--- a/apps/CameraITS/tools/run_all_tests.py
+++ b/apps/CameraITS/tools/run_all_tests.py
@@ -73,9 +73,9 @@
}
-def calc_camera_fov():
+def calc_camera_fov(camera_id):
"""Determine the camera field of view from internal params."""
- with ItsSession() as cam:
+ with ItsSession(camera_id) as cam:
props = cam.get_camera_properties()
try:
focal_l = props['android.lens.info.availableFocalLengths'][0]
@@ -101,11 +101,11 @@
return socket_fail
-def skip_sensor_fusion():
+def skip_sensor_fusion(camera_id):
"""Determine if sensor fusion test is skipped for this camera."""
skip_code = SKIP_RET_CODE
- with ItsSession() as cam:
+ with ItsSession(camera_id) as cam:
props = cam.get_camera_properties()
if (its.caps.sensor_fusion(props) and its.caps.manual_sensor(props) and
props['android.lens.facing'] is not FACING_EXTERNAL):
@@ -174,7 +174,6 @@
tmp_dir = None
skip_scene_validation = False
chart_distance = CHART_DISTANCE
- chart_height = CHART_HEIGHT
for s in sys.argv[1:]:
if s[:7] == "camera=" and len(s) > 7:
@@ -277,7 +276,7 @@
assert wake_code == 0
for camera_id in camera_ids:
- camera_fov = calc_camera_fov()
+ camera_fov = calc_camera_fov(camera_id)
# Loop capturing images until user confirm test scene is correct
camera_id_arg = "camera=" + camera_id
print "Preparing to run ITS on camera", camera_id
@@ -303,7 +302,7 @@
out_path = os.path.join(topdir, camera_id, scene+".jpg")
out_arg = "out=" + out_path
if scene == 'sensor_fusion':
- skip_code = skip_sensor_fusion()
+ skip_code = skip_sensor_fusion(camera_id)
if rot_rig_id or skip_code == SKIP_RET_CODE:
validate_switch = False
if skip_scene_validation:
@@ -335,13 +334,15 @@
print "Start running ITS on camera %s, %s" % (camera_id, scene)
# Extract chart from scene for scene3 once up front
chart_loc_arg = ''
+ chart_height = CHART_HEIGHT
if scene == 'scene3':
if float(camera_fov) < 90 and np.isclose(chart_distance, 22,
rtol=0.1):
chart_height *= 0.67
chart = its.cv2image.Chart(SCENE3_FILE, chart_height,
chart_distance, CHART_SCALE_START,
- CHART_SCALE_STOP, CHART_SCALE_STEP)
+ CHART_SCALE_STOP, CHART_SCALE_STEP,
+ camera_id)
chart_loc_arg = 'chart_loc=%.2f,%.2f,%.2f,%.2f,%.3f' % (
chart.xnorm, chart.ynorm, chart.wnorm, chart.hnorm,
chart.scale)
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 117f3b3..d64345b 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -18,7 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.verifier"
android:versionCode="5"
- android:versionName="9.0_r2">
+ android:versionName="9.0_r6">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28"/>
@@ -2006,7 +2006,7 @@
</intent-filter>
<meta-data android:name="test_category" android:value="@string/test_category_notifications" />
<meta-data android:name="test_excluded_features"
- android:value="android.hardware.type.watch:android.software.leanback" />
+ android:value="android.hardware.type.watch:android.software.leanback:android.hardware.type.automotive" />
</activity>
<activity android:name=".vr.VrListenerVerifierActivity"
@@ -3246,6 +3246,9 @@
<meta-data
android:name="test_required_features"
android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<receiver android:name=".voicemail.VoicemailBroadcastReceiver">
@@ -3268,6 +3271,9 @@
<meta-data
android:name="test_required_features"
android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<activity
@@ -3284,6 +3290,9 @@
<meta-data
android:name="test_required_features"
android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<service android:name=".dialer.DialerCallTestService"
@@ -3308,6 +3317,9 @@
<meta-data
android:name="test_required_features"
android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<activity
@@ -3324,6 +3336,9 @@
<meta-data
android:name="test_required_features"
android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<activity
@@ -3340,6 +3355,9 @@
<meta-data
android:name="test_required_features"
android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<activity
@@ -3356,6 +3374,9 @@
<meta-data
android:name="test_required_features"
android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<service
@@ -3400,6 +3421,9 @@
<meta-data
android:name="test_required_features"
android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<activity
@@ -3416,6 +3440,9 @@
<meta-data
android:name="test_required_features"
android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<activity
@@ -3432,6 +3459,9 @@
<meta-data
android:name="test_required_features"
android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<activity
@@ -3448,6 +3478,9 @@
<meta-data
android:name="test_required_features"
android:value="android.hardware.telephony"/>
+ <meta-data
+ android:name="test_required_configs"
+ android:value="config_voice_capable"/>
</activity>
<service android:name="com.android.cts.verifier.telecom.CtsConnectionService"
diff --git a/apps/CtsVerifier/res/layout/camera_fov_calibration_photo_capture.xml b/apps/CtsVerifier/res/layout/camera_fov_calibration_photo_capture.xml
index 7f8efa0..c142b15 100644
--- a/apps/CtsVerifier/res/layout/camera_fov_calibration_photo_capture.xml
+++ b/apps/CtsVerifier/res/layout/camera_fov_calibration_photo_capture.xml
@@ -49,7 +49,6 @@
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:padding="10sp"
- android:popupBackground="#ffffff"
android:textSize="18sp" />
</RelativeLayout>
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 055d881..89b4efa 100755
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -2177,9 +2177,9 @@
<string name="device_admin_notification">This is device admin notification</string>
<string name="device_admin_keyguard_disable_camera">Disable camera</string>
<string name="device_admin_keyguard_disable_camera_instruction">
- Please press the Go button to lock the screen. Then try to open the camera
- from the lower right corner of the screen. Expected result is you cannot
- open the camera from lock screen and it will ask for password instead.\n
+ Please press the Go button to lock the screen. Expected result is you cannot
+ see the camera icon on the lower right corner of the screen, or if there is one, you cannot
+ open the camera using it before you are asked for a password.\n
Also, it shouldn\'t be possible to open the camera on the lockscreen by
any other device specific gesture (such as double press on power button).
</string>
@@ -2690,7 +2690,7 @@
<string name="negative_device_owner">No Device Owner Tests</string>
<string name="device_owner_negative_category">No Device Owner Tests</string>
<string name="device_owner_provisioning_negative">Device owner provisioning</string>
- <string name="device_owner_provisioning_negative_info">The device owner provisioning test verifies that setting up a corporate owned device can only be done on a factory reset device.\n\nPlease click the "Start provisioning" button, and when you see a warning dialog telling the device can\'t be set up, select "pass". Otherwise, select "fail".</string>
+ <string name="device_owner_provisioning_negative_info">The device owner provisioning test verifies that setting up a corporate owned device can only be done on a factory reset device.\n\nPlease click the "Start provisioning" button, and when you see a warning dialog telling the device is already set up, select "pass". Otherwise, select "fail".</string>
<string name="start_device_owner_provisioning_button">Start provisioning</string>
<string name="enterprise_privacy_quick_settings_negative">Quick settings disclosure</string>
<string name="enterprise_privacy_quick_settings_negative_info">
@@ -2975,8 +2975,8 @@
<string name="device_owner_disallow_usb_file_transfer_test_info">
Please press below button to set the \"disallow USB file transfer\" restriction.\n
If a USB notification appears, open the notification and check that the
- \"Transfer files (MTP)\" and \"Transfer photos (PTP)\" cannot be selected and trigger a
- support message when trying to select them.\n
+ \"Transfer files (MTP)\" and \"Transfer photos (PTP)\" options either are not displayed,
+ or they trigger a support message when trying to select them.\n
Check if you can mount the device as a USB drive on your desktop computer. The test is
successful if you cannot mount the device, and files from your phone cannot be
downloaded through USB.\n
@@ -3260,7 +3260,10 @@
<string name="disallow_config_mobile_networks">Disallow config mobile networks</string>
<string name="disallow_config_mobile_networks_action">Configuring mobile networks</string>
<string name="disallow_config_tethering">Disallow config tethering</string>
- <string name="disallow_config_tethering_action">Configuring tethering and portable hotspots</string>
+ <string name="disallow_config_tethering_action">
+ Configuring tethering and portable hotspots.\n
+ NOTE: If the device does not support tethering please skip this test and mark it as passing.\n
+ </string>
<string name="disallow_config_wifi">Disallow config Wi-Fi</string>
<string name="disallow_config_wifi_action">Modifying Wi-Fi configuration</string>
<string name="disallow_debugging_features">Disallow debugging features</string>
@@ -3278,13 +3281,37 @@
<string name="disallow_outgoing_beam">Disallow outgoing beam</string>
<string name="disallow_outgoing_beam_action">Switching on android beam</string>
<string name="disallow_remove_user">Disallow remove user</string>
- <string name="disallow_remove_user_action">Removing other users (please create a user and attempt to remove it to verify)</string>
+ <string name="device_owner_disallow_remove_user_info">
+ Please press \'Create uninitialized user\' to create a user that is not set up. Then press the
+ \'Set restriction\' button to set the user restriction. Then press \'Go\' to open \'Settings\',
+ and manually find and open \'Multiple users\' setting. \n\n
+
+ Mark this test as passed if:\n\n
+ - The uninitialized user cannot be removed.\n
+ - \'Remove user\' option is disabled with an info icon on it. Clicking on it triggers a support dialog.\n\n
+
+ Use the Back button to return to this page.
+ </string>
+ <string name="managed_user_disallow_remove_user_info">
+ Please press the \'Set restriction\' button to set the user restriction.
+ Then press \'Go\' to open \'Settings\', and manually find and open \'Multiple users\' setting. \n\n
+
+ Mark this test as passed if one of the following conditions is met:\n\n
+ - \'Remove user\' option is disabled with an info icon on it. Clicking on it triggers a support dialog.\n
+ - \'Remove user\' option cannot be found.\n \n
+
+ Use the Back button to return to this page.
+ </string>
+ <string name="device_owner_disallow_remove_user_create_user">Create uninitialized user</string>
<string name="disallow_remove_managed_profile">Disallow remove managed profile</string>
<string name="disallow_remove_managed_profile_action">Removing the work profile. It shouldn\'t be possible neither from the Accounts screen nor the Device Administrators screen (after selecting the Device Administrator that corresponds to the badged version of \"CTS Verifier\")</string>
<string name="disallow_share_location">Disallow share location</string>
<string name="disallow_share_location_action">Turning on location sharing</string>
<string name="disallow_uninstall_apps">Disallow uninstall apps</string>
- <string name="disallow_uninstall_apps_action">Uninstalling applications from the work profile (badged applications) other than CtsVerifier</string>
+ <string name="disallow_uninstall_apps_action">
+ a. If testing in work profile: uninstall applications from the work profile (badged applications) other than CtsVerifier and system apps. \n
+ b. Otherwise: uninstall applications other than CtsVerifier and system apps
+ </string>
<string name="disallow_unified_challenge">Disallow unified challenge</string>
<string name="disallow_unified_challenge_action">Setting one lock for both personal and work profiles. IMPORTANT: Separate work lock should be set prior to this test in Set work lock test</string>
<string name="disallow_keyguard_unredacted_notifications">Disallow lockscreen unredacted notification</string>
@@ -4016,6 +4043,10 @@
<string name="uapButtonsBtnDLbl">Button D - voice assist</string>
<string name="uapButtonsRecognized">Recognized</string>
<string name="uapButtonsNotRecognized">Not Recognized</string>
+ <string name="uapButtonsDisableAssistantTitle">Disable Google Assistant</string>
+ <string name="uapButtonsDisableAssistant">For this test to succeed it may be necessary
+ to disable the Google Assistant (Settings / Google / Search / Google Assistant Settings /
+ Devices / <device name> / Google Assistant)</string>
<!-- Audio general text -->
<string name="audio_general_headset_port_exists">Does this device have a headset port?</string>
@@ -4389,14 +4420,14 @@
<!-- USB Audio Peripheral Play Test -->
<string name="usbaudio_play_test"> USB Audio Peripheral Play Test</string>
<string name="usbaudio_play_info">
- This test requires that you have connected a mandated USB Audio Interface peripheral and
+ This test requires that you have connected a USB Audio Interface peripheral and
some way to monitor the output. Press the \"Play\" button and verify that a tone is produced.
</string>
<!-- USB Audio Peripheral Record Test -->
<string name="usbaudio_record_test"> USB Audio Peripheral Record Test</string>
<string name="usbaudio_record_info">
- This test requires that you have connected a mandated USB Audio Interface peripheral.
+ This test requires that you have connected a USB Audio Interface peripheral.
Connect the outputs to the inputs (with patch cables). Start playback by pressing the
\"Record Loopback\" button and verify that the recorded signal is displayed in the wave
display view. (It may be necessary to adjust the input controls on the peripheral).
@@ -4405,9 +4436,11 @@
<!-- USB Audio Peripheral Buttons Test -->
<string name="usbaudio_buttons_test"> USB Audio Peripheral Buttons Test</string>
<string name="usbaudio_buttons_info">
- This test requires that you have connected a mandated USB Audio headset. Press each
- \"transport\" button and verify that it is recognized by the test.
- </string>
+ This test requires that you have connected a USB Audio headset that supports the
+ Android USB audio headset buttons specification. Press each
+ \"transport\" button and verify that it is recognized by the test. When each of the
+ buttons has been recognized the \"pass\" button will be enabled.
+ </string>
<!-- Telecom tests -->
<string name="telecom_enable_phone_account_test"> Telecom Enable Phone Account Test</string>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/ManifestTestListAdapter.java b/apps/CtsVerifier/src/com/android/cts/verifier/ManifestTestListAdapter.java
index 44e2e0f..a339a43 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/ManifestTestListAdapter.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/ManifestTestListAdapter.java
@@ -22,6 +22,7 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
+import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.ListView;
@@ -99,6 +100,10 @@
private static final String TEST_APPLICABLE_FEATURES_META_DATA = "test_applicable_features";
+ private static final String TEST_REQUIRED_CONFIG_META_DATA = "test_required_configs";
+
+ private static final String CONFIG_VOICE_CAPABLE = "config_voice_capable";
+
private final HashSet<String> mDisabledTests;
private Context mContext;
@@ -188,10 +193,11 @@
String testName = info.activityInfo.name;
Intent intent = getActivityIntent(info.activityInfo);
String[] requiredFeatures = getRequiredFeatures(info.activityInfo.metaData);
+ String[] requiredConfigs = getRequiredConfigs(info.activityInfo.metaData);
String[] excludedFeatures = getExcludedFeatures(info.activityInfo.metaData);
String[] applicableFeatures = getApplicableFeatures(info.activityInfo.metaData);
TestListItem item = TestListItem.newTest(title, testName, intent, requiredFeatures,
- excludedFeatures, applicableFeatures);
+ requiredConfigs, excludedFeatures, applicableFeatures);
String testCategory = getTestCategory(mContext, info.activityInfo.metaData);
addTestToCategory(testsByCategory, testCategory, item);
@@ -229,6 +235,19 @@
}
}
+ static String[] getRequiredConfigs(Bundle metaData) {
+ if (metaData == null) {
+ return null;
+ } else {
+ String value = metaData.getString(TEST_REQUIRED_CONFIG_META_DATA);
+ if (value == null) {
+ return null;
+ } else {
+ return value.split(":");
+ }
+ }
+ }
+
static String[] getExcludedFeatures(Bundle metaData) {
if (metaData == null) {
return null;
@@ -305,10 +324,29 @@
return true;
}
+ private boolean matchAllConfigs(String[] configs) {
+ if (configs != null) {
+ TelephonyManager telephonyManager =
+ (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+ for (String config : configs) {
+ switch(config) {
+ case CONFIG_VOICE_CAPABLE:
+ if (!telephonyManager.isVoiceCapable()) {
+ return false;
+ }
+ default:
+ break;
+ }
+ }
+ }
+ return true;
+ }
+
List<TestListItem> filterTests(List<TestListItem> tests) {
List<TestListItem> filteredTests = new ArrayList<TestListItem>();
for (TestListItem test : tests) {
- if (!hasAnyFeature(test.excludedFeatures) && hasAllFeatures(test.requiredFeatures)) {
+ if (!hasAnyFeature(test.excludedFeatures) && hasAllFeatures(test.requiredFeatures)
+ && matchAllConfigs(test.requiredConfigs)) {
if (test.applicableFeatures == null || hasAnyFeature(test.applicableFeatures)) {
filteredTests.add(test);
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/TestListAdapter.java b/apps/CtsVerifier/src/com/android/cts/verifier/TestListAdapter.java
index 642b951..d9ea84f 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/TestListAdapter.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/TestListAdapter.java
@@ -91,6 +91,9 @@
/** Features necessary to run this test. */
final String[] requiredFeatures;
+ /** Configs necessary to run this test. */
+ final String[] requiredConfigs;
+
/** Features such that, if any present, the test gets excluded from being shown. */
final String[] excludedFeatures;
@@ -117,20 +120,27 @@
}
public static TestListItem newTest(String title, String testName, Intent intent,
+ String[] requiredFeatures, String[] requiredConfigs, String[] excludedFeatures,
+ String[] applicableFeatures) {
+ return new TestListItem(title, testName, intent, requiredFeatures, requiredConfigs,
+ excludedFeatures, applicableFeatures);
+ }
+
+ public static TestListItem newTest(String title, String testName, Intent intent,
String[] requiredFeatures, String[] excludedFeatures, String[] applicableFeatures) {
- return new TestListItem(title, testName, intent, requiredFeatures, excludedFeatures,
+ return new TestListItem(title, testName, intent, requiredFeatures, null, excludedFeatures,
applicableFeatures);
}
public static TestListItem newTest(String title, String testName, Intent intent,
String[] requiredFeatures, String[] excludedFeatures) {
- return new TestListItem(title, testName, intent, requiredFeatures, excludedFeatures,
+ return new TestListItem(title, testName, intent, requiredFeatures, null, excludedFeatures,
null);
}
public static TestListItem newTest(String title, String testName, Intent intent,
String[] requiredFeatures) {
- return new TestListItem(title, testName, intent, requiredFeatures, null, null);
+ return new TestListItem(title, testName, intent, requiredFeatures, null, null, null);
}
public static TestListItem newCategory(Context context, int titleResId) {
@@ -138,15 +148,22 @@
}
public static TestListItem newCategory(String title) {
- return new TestListItem(title, null, null, null, null, null);
+ return new TestListItem(title, null, null, null, null, null, null);
}
protected TestListItem(String title, String testName, Intent intent,
String[] requiredFeatures, String[] excludedFeatures, String[] applicableFeatures) {
+ this(title, testName, intent, requiredFeatures, null, excludedFeatures, applicableFeatures);
+ }
+
+ protected TestListItem(String title, String testName, Intent intent,
+ String[] requiredFeatures, String[] requiredConfigs, String[] excludedFeatures,
+ String[] applicableFeatures) {
this.title = title;
this.testName = testName;
this.intent = intent;
this.requiredFeatures = requiredFeatures;
+ this.requiredConfigs = requiredConfigs;
this.excludedFeatures = excludedFeatures;
this.applicableFeatures = applicableFeatures;
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/RingerModeActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/RingerModeActivity.java
index e5b73e8..fdb57fc 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/RingerModeActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/RingerModeActivity.java
@@ -118,7 +118,8 @@
tests.add(new TestVibrateNotificationDndOn());
tests.add(new TestVibrateRingerDndOn());
tests.add(new TestSetRingerModePolicyAccessDndOn());
- tests.add(new TestVolumeDndAffectedStreamDndOn());
+ // TODO: Add a @TestApi method to query the VolumPolicy
+ //tests.add(new TestVolumeDndAffectedStreamDndOn());
tests.add(new TestAdjustVolumeInPriorityOnlyAllowAlarmsMediaMode());
tests.add(new SetModeAllTest());
@@ -126,7 +127,8 @@
tests.add(new TestVibrateNotification());
tests.add(new TestVibrateRinger());
tests.add(new TestSetRingerModePolicyAccess());
- tests.add(new TestVolumeDndAffectedStream());
+ // TODO: Add a @TestApi method to query the VolumPolicy
+ //tests.add(new TestVolumeDndAffectedStream());
tests.add(new TestVolume());
tests.add(new TestMuteStreams());
tests.add(new EnableSoundEffects());
@@ -632,17 +634,12 @@
return;
}
- mAudioManager.setRingerMode(RINGER_MODE_VIBRATE);
if (mHasVibrator) {
+ mAudioManager.setRingerMode(RINGER_MODE_VIBRATE);
if (RINGER_MODE_VIBRATE != mAudioManager.getRingerMode()) {
setFailed();
return;
}
- } else {
- if (RINGER_MODE_NORMAL != mAudioManager.getRingerMode()) {
- setFailed();
- return;
- }
}
status = PASS;
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralActivity.java
index 7fdf403..140757d 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralActivity.java
@@ -44,6 +44,8 @@
protected AudioDeviceInfo mOutputDevInfo;
protected AudioDeviceInfo mInputDevInfo;
+ protected final boolean mIsMandatedRequired;
+
// This will be overriden...
protected int mSystemSampleRate = 48000;
@@ -53,9 +55,12 @@
private TextView mPeripheralNameTx;
- public USBAudioPeripheralActivity() {
+ public USBAudioPeripheralActivity(boolean mandatedRequired) {
super();
+ // determine if to show "UNSUPPORTED" if the mandated peripheral is required.
+ mIsMandatedRequired = mandatedRequired;
+
mProfileManager.loadProfiles();
}
@@ -99,7 +104,7 @@
productName = mInputDevInfo.getProductName().toString();
}
String ctrlText;
- if (mSelectedProfile == null) {
+ if (mSelectedProfile == null && mIsMandatedRequired) {
ctrlText = productName + " - UNSUPPORTED";
} else {
ctrlText = productName;
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 07a99da..ef67708 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralAttributesActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralAttributesActivity.java
@@ -32,6 +32,10 @@
private TextView mTestStatusTx;
+ public USBAudioPeripheralAttributesActivity() {
+ super(true); // Mandated peripheral is required
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralButtonsActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralButtonsActivity.java
index 87b2149..de3ce7f 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralButtonsActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralButtonsActivity.java
@@ -16,6 +16,8 @@
package com.android.cts.verifier.audio;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
@@ -45,6 +47,23 @@
private TextView mBtnBStatusTxt;
private TextView mBtnCStatusTxt;
+ public USBAudioPeripheralButtonsActivity() {
+ super(false); // Mandated peripheral is NOT required
+ }
+
+ private void showDisableAssistantDialog() {
+ AlertDialog.Builder builder =
+ new AlertDialog.Builder(this, android.R.style.Theme_Material_Dialog_Alert);
+ builder.setTitle(getResources().getString(R.string.uapButtonsDisableAssistantTitle));
+ builder.setMessage(getResources().getString(R.string.uapButtonsDisableAssistant));
+ builder.setPositiveButton(android.R.string.yes,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {}
+ });
+ builder.setIcon(android.R.drawable.ic_dialog_alert);
+ builder.show();
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -62,12 +81,12 @@
setPassFailButtonClickListeners();
setInfoResources(R.string.usbaudio_buttons_test, R.string.usbaudio_buttons_info, -1);
+
+ showDisableAssistantDialog();
}
private void showButtonsState() {
- int ctrlColor = mIsPeripheralAttached && mSelectedProfile != null
- ? Color.WHITE
- : Color.GRAY;
+ int ctrlColor = mIsPeripheralAttached ? Color.WHITE : Color.GRAY;
mBtnALabelTxt.setTextColor(ctrlColor);
mBtnAStatusTxt.setTextColor(ctrlColor);
mBtnBLabelTxt.setTextColor(ctrlColor);
@@ -81,23 +100,13 @@
mHasBtnB ? R.string.uapButtonsRecognized : R.string.uapButtonsNotRecognized));
mBtnCStatusTxt.setText(getString(
mHasBtnC ? R.string.uapButtonsRecognized : R.string.uapButtonsNotRecognized));
+
+ calculateMatch();
}
private void calculateMatch() {
- if (mIsPeripheralAttached && mSelectedProfile != null) {
- ProfileButtonAttributes mButtonAttributes = mSelectedProfile.getButtonAttributes();
- boolean match = mButtonAttributes != null;
- boolean interceptedVolume = getResources().getBoolean(Resources.getSystem()
- .getIdentifier("config_handleVolumeKeysInWindowManager", "bool", "android"));
- if (match && mButtonAttributes.mHasBtnA != mHasBtnA) {
- match = false;
- }
- if (match && mButtonAttributes.mHasBtnB != mHasBtnB && !interceptedVolume) {
- match = false;
- }
- if (match && mButtonAttributes.mHasBtnC != mHasBtnC && !interceptedVolume) {
- match = false;
- }
+ if (mIsPeripheralAttached) {
+ boolean match = mHasBtnA && mHasBtnB && mHasBtnC;
Log.i(TAG, "match:" + match);
getPassButton().setEnabled(match);
} else {
@@ -107,29 +116,27 @@
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
- Log.i(TAG, "onKeyDown(" + keyCode + ")");
- if (mSelectedProfile != null) {
- switch (keyCode) {
- // Function A control event
- case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
- mHasBtnA = true;
- break;
-
- // Function B control event
- case KeyEvent.KEYCODE_VOLUME_UP:
- mHasBtnB = true;
- break;
-
- // Function C control event
- case KeyEvent.KEYCODE_VOLUME_DOWN:
- mHasBtnC = true;
- break;
- }
-
- showButtonsState();
- calculateMatch();
+ // Log.i(TAG, "onKeyDown(" + keyCode + ")");
+ switch (keyCode) {
+ // Function A control event
+ case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
+ mHasBtnA = true;
+ break;
+
+ // Function B control event
+ case KeyEvent.KEYCODE_VOLUME_UP:
+ mHasBtnB = true;
+ break;
+
+ // Function C control event
+ case KeyEvent.KEYCODE_VOLUME_DOWN:
+ mHasBtnC = true;
+ break;
}
+ showButtonsState();
+ calculateMatch();
+
return super.onKeyDown(keyCode, event);
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralPlayActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralPlayActivity.java
index 640d489..de9016a 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralPlayActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralPlayActivity.java
@@ -31,6 +31,10 @@
private Button mPlayBtn;
private LocalClickListener mButtonClickListener = new LocalClickListener();
+ public USBAudioPeripheralPlayActivity() {
+ super(false); // Mandated peripheral is NOT required
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -52,8 +56,8 @@
// USBAudioPeripheralActivity
// Headset not publicly available, violates CTS Verifier additional equipment guidelines.
public void updateConnectStatus() {
- mPlayBtn.setEnabled(mIsPeripheralAttached && mSelectedProfile != null);
- getPassButton().setEnabled(mSelectedProfile != null && mOutputDevInfo != null);
+ mPlayBtn.setEnabled(mIsPeripheralAttached);
+ getPassButton().setEnabled(mIsPeripheralAttached);
}
public class LocalClickListener implements View.OnClickListener {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralPlayerActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralPlayerActivity.java
index 33417d1..fc666aa 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralPlayerActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralPlayerActivity.java
@@ -41,6 +41,10 @@
private static final int WAVBUFF_SIZE_IN_SAMPLES = 2048;
+ public USBAudioPeripheralPlayerActivity(boolean requiresMandatePeripheral) {
+ super(requiresMandatePeripheral); // Mandated peripheral is NOT required
+ }
+
protected void setupPlayer() {
mSystemBufferSize =
StreamPlayer.calcNumBurstFrames((AudioManager)getSystemService(Context.AUDIO_SERVICE));
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralRecordActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralRecordActivity.java
index 5772461..268201c 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralRecordActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/USBAudioPeripheralRecordActivity.java
@@ -49,6 +49,10 @@
private WaveScopeView mWaveView = null;
+ public USBAudioPeripheralRecordActivity() {
+ super(false); // Mandated peripheral is NOT required
+ }
+
private void connectWaveView() {
// Log.i(TAG, "connectWaveView() rec:" + (mRecorder != null));
if (mRecorder != null) {
@@ -73,7 +77,12 @@
mRecorder.stop();
}
+ // no reason to do more than 2
int numChans = USBDeviceInfoHelper.calcMaxChannelCount(mInputDevInfo);
+ if (numChans > 2) {
+ numChans = 2;
+ }
+ Log.i(TAG, " numChans:" + numChans);
if (mRecorder.open(numChans, mSystemSampleRate, mSystemBufferSize)) {
connectWaveView(); // Setup the WaveView
@@ -136,9 +145,9 @@
// USBAudioPeripheralActivity
//
public void updateConnectStatus() {
- mRecordBtn.setEnabled(mIsPeripheralAttached && mSelectedProfile != null);
- mRecordLoopbackBtn.setEnabled(mIsPeripheralAttached && mSelectedProfile != null);
- getPassButton().setEnabled(mSelectedProfile != null && mOutputDevInfo != null);
+ mRecordBtn.setEnabled(mIsPeripheralAttached);
+ mRecordLoopbackBtn.setEnabled(mIsPeripheralAttached);
+ getPassButton().setEnabled(mIsPeripheralAttached);
}
public class LocalClickListener implements View.OnClickListener {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/audiolib/AudioUtils.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/audiolib/AudioUtils.java
index 7190af9..55b7f9a 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/audiolib/AudioUtils.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/audiolib/AudioUtils.java
@@ -32,9 +32,6 @@
}
public static int countToIndexMask(int chanCount) {
- // From the documentation for AudioFormat:
- // The canonical channel index masks by channel count are given by the formula
- // (1 << channelCount) - 1.
return (1 << chanCount) - 1;
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/audiolib/StreamPlayer.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/audiolib/StreamPlayer.java
index 12f1853..bebc2a7 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/audiolib/StreamPlayer.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/audiolib/StreamPlayer.java
@@ -131,7 +131,7 @@
allocBurstBuffer();
return true;
} catch (UnsupportedOperationException ex) {
- Log.i(TAG, "Couldn't open AudioTrack: " + ex);
+ Log.e(TAG, "Couldn't open AudioTrack: " + ex);
mAudioTrack = null;
return false;
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/audiolib/StreamRecorder.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/audiolib/StreamRecorder.java
index d9094e5..2ec742e4 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/audiolib/StreamRecorder.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/audiolib/StreamRecorder.java
@@ -120,22 +120,33 @@
mNumChannels = numChans;
mSampleRate = sampleRate;
- int chanPosMask = AudioUtils.countToInPositionMask(numChans);
- int bufferSizeInBytes = 2048; // Some, non-critical value
+ final int frameSize =
+ AudioUtils.calcFrameSizeInBytes(AudioFormat.ENCODING_PCM_FLOAT, mNumChannels);
+ final int bufferSizeInBytes = frameSize * 64; // Some, non-critical value
+
+ AudioFormat.Builder formatBuilder = new AudioFormat.Builder();
+ formatBuilder.setEncoding(AudioFormat.ENCODING_PCM_FLOAT);
+ formatBuilder.setSampleRate(mSampleRate);
+
+ if (numChans <= 2) {
+ // There is currently a bug causing channel INDEX masks to fail.
+ // for channels counts of <= 2, use channel POSITION
+ final int chanPosMask = AudioUtils.countToInPositionMask(numChans);
+ formatBuilder.setChannelMask(chanPosMask);
+ } else {
+ // There are no INPUT channel-position masks for > 2 channels
+ final int chanIndexMask = AudioUtils.countToIndexMask(numChans);
+ formatBuilder.setChannelIndexMask(chanIndexMask);
+ }
+
+ AudioRecord.Builder builder = new AudioRecord.Builder();
+ builder.setAudioFormat(formatBuilder.build());
try {
- mAudioRecord = new AudioRecord.Builder()
- .setAudioFormat(new AudioFormat.Builder()
- .setEncoding(AudioFormat.ENCODING_PCM_FLOAT)
- .setSampleRate(mSampleRate)
- .setChannelMask(chanPosMask)
- .build())
- .setBufferSizeInBytes(bufferSizeInBytes)
- .build();
-
+ mAudioRecord = builder.build();
return true;
} catch (UnsupportedOperationException ex) {
- Log.i(TAG, "Couldn't open AudioRecord: " + ex);
+ Log.e(TAG, "Couldn't open AudioRecord: " + ex);
mAudioRecord = null;
return false;
}
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 9cec7fa..a56cd3f 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
@@ -46,7 +46,11 @@
private static final String mBuiltInprofiles =
"<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>" +
- "<ProfileList Version=\"1.0.0\">" +
+ "<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\"/>" +
+ "</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\" />" +
@@ -59,6 +63,18 @@
"<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\" />" +
"</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\"/>" +
+ "</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\"/>" +
+ "</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\"/>" +
+ "</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\" />" +
"<InputDevInfo ChanCounts=\"1,2\" ChanPosMasks=\"12,16\" ChanIndexMasks=\"3\" Encodings=\"4\" SampleRates=\"48000\" />" +
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientService.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientService.java
index 28d08cd..1fd6a2b 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientService.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleClientService.java
@@ -1292,7 +1292,15 @@
int state = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE);
switch (state) {
case BluetoothDevice.BOND_BONDED:
- mBluetoothGatt = connectGatt(device, mContext, false, mSecure, mGattCallbacks);
+ if ((mBluetoothGatt == null) &&
+ (device.getType() != BluetoothDevice.DEVICE_TYPE_CLASSIC)) {
+ if (DEBUG) {
+ Log.d(TAG, "onReceive:BOND_BONDED: calling connectGatt device="
+ + device + ", mSecure=" + mSecure);
+ }
+ mBluetoothGatt = connectGatt(device, mContext, false, mSecure,
+ mGattCallbacks);
+ }
break;
case BluetoothDevice.BOND_NONE:
notifyError("Failed to create bond.");
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsService.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsService.java
index e8cf2ef..fc2374e 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsService.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsService.java
@@ -1728,6 +1728,14 @@
.left;
int aay = ItsUtils.getActiveArrayCropRegion(mCameraCharacteristics)
.top;
+
+ if (w == aaw) {
+ aax = 0;
+ }
+ if (h == aah) {
+ aay = 0;
+ }
+
int gw = mCaptureStatsGridWidth;
int gh = mCaptureStatsGridHeight;
float[] stats = StatsImage.computeStatsImage(
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsTestActivity.java
index 7fa4e1a..d6feb51 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsTestActivity.java
@@ -77,6 +77,7 @@
private static final int MAX_SUMMARY_LEN = 200;
private final ResultReceiver mResultsReceiver = new ResultReceiver();
+ private boolean mReceiverRegistered = false;
// Initialized in onCreate
ArrayList<String> mToBeTestedCameraIds = null;
@@ -401,13 +402,16 @@
Log.d(TAG, "register ITS result receiver");
IntentFilter filter = new IntentFilter(ACTION_ITS_RESULT);
registerReceiver(mResultsReceiver, filter);
+ mReceiverRegistered = true;
}
}
@Override
public void onDestroy() {
Log.d(TAG, "unregister ITS result receiver");
- unregisterReceiver(mResultsReceiver);
+ if (mReceiverRegistered) {
+ unregisterReceiver(mResultsReceiver);
+ }
super.onDestroy();
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/orientation/CameraOrientationActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/orientation/CameraOrientationActivity.java
index 49b34fd..d753d6a 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/orientation/CameraOrientationActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/orientation/CameraOrientationActivity.java
@@ -465,6 +465,10 @@
int viewHeight = mFormatView.getHeight();
int newWidth, newHeight;
+ if (viewWidth == 0 || viewHeight == 0){
+ return;
+ }
+
if (mPreviewOrientations.get(mNextPreviewOrientation) == 0
|| mPreviewOrientations.get(mNextPreviewOrientation) == 180) {
// make preview width same as output image width,
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
index 395eac0..81e1e9f 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
@@ -277,6 +277,7 @@
boolean hasTelephony = false;
boolean hasBluetooth = false;
boolean hasIllegalFeature = false;
+ boolean hasTelevision = false;
// get list of all features device thinks it has, & store in a HashMap
// for fast lookups
@@ -343,6 +344,8 @@
if (apiVersion >= Build.VERSION_CODES.ECLAIR_MR1) {
Collections.addAll(features, ALL_ECLAIR_FEATURES);
}
+
+ hasTelevision = getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEVISION);
for (Feature f : features) {
HashMap<String, Object> row = new HashMap<String, Object>();
listViewData.add(row);
@@ -358,6 +361,9 @@
// it's required, but device doesn't report it. Boo, set the
// bogus icon
statusIcon = R.drawable.fs_error;
+ if (hasTelevision && PackageManager.FEATURE_LOCATION.equals(f.name)) {
+ statusIcon = R.drawable.fs_indeterminate;
+ }
} else {
// device doesn't report it, but it's not req'd, so can't tell
// if there's a problem
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/location/GpsTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/location/GpsTestActivity.java
index 4909497..c779a2a 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/location/GpsTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/location/GpsTestActivity.java
@@ -19,6 +19,8 @@
import com.android.cts.verifier.PassFailButtons;
import com.android.cts.verifier.R;
+import com.android.compatibility.common.util.CddTest;
+
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
@@ -41,6 +43,7 @@
/**
* CTS Verifier case for verifying GPS.
*/
+@CddTest(requirement="7.3.3/C-1-1")
public class GpsTestActivity extends PassFailButtons.Activity implements PassFailLog {
private LocationManager mLocationManager;
private TextView mTextView;
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/location/base/EmergencyCallBaseTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/location/base/EmergencyCallBaseTestActivity.java
index 531b40b..e25f758 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/location/base/EmergencyCallBaseTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/location/base/EmergencyCallBaseTestActivity.java
@@ -57,11 +57,19 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ // skip current test if device doesn't support cellular
+ if (!EmergencyCallUtil.isPhoneDevice(this)) {
+ String skipInfo = getResources().getString(R.string.emergency_call_skip_info);
+ TestResult.setPassedResult(this, super.getClass().getName(), skipInfo);
+ Toast toast = Toast.makeText(getApplicationContext(), skipInfo, Toast.LENGTH_LONG);
+ toast.show();
+ this.finish();
+ return;
+ }
// override the test info
mTextView.setText(R.string.location_emergency_call_test_info);
EmergencyCallUtil.setDefaultDialer(this, this.getPackageName());
setPassFailButtonClickListeners();
-
}
@Override
@@ -74,15 +82,7 @@
@Override
public void onClick(View target) {
- // skip current test if device doesn't support cellular
- if (!EmergencyCallUtil.isPhoneDevice(this)) {
- String skipInfo = getResources().getString(R.string.emergency_call_skip_info);
- TestResult.setPassedResult(this, super.getClass().getName(), skipInfo);
- Toast toast = Toast.makeText(getApplicationContext(), skipInfo, Toast.LENGTH_LONG);
- toast.show();
- this.finish();
- return;
- }
+
AlertDialog.Builder builder = new AlertDialog.Builder(this);
final FrameLayout frameView = new FrameLayout(this);
builder.setView(frameView);
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
index 5f90b66..67f82d0 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
@@ -647,12 +647,14 @@
.show();
}
- mWidgetTest = TestListItem.newTest(this,
- R.string.provisioning_byod_work_profile_widget,
- WorkProfileWidgetActivity.class.getName(),
- new Intent(WorkProfileWidgetActivity.ACTION_TEST_WORK_PROFILE_WIDGET),
- new String[] {PackageManager.FEATURE_APP_WIDGETS});
- adapter.add(mWidgetTest);
+ if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_APP_WIDGETS)) {
+ mWidgetTest = TestListItem.newTest(this,
+ R.string.provisioning_byod_work_profile_widget,
+ WorkProfileWidgetActivity.class.getName(),
+ new Intent(WorkProfileWidgetActivity.ACTION_TEST_WORK_PROFILE_WIDGET),
+ new String[]{PackageManager.FEATURE_APP_WIDGETS});
+ adapter.add(mWidgetTest);
+ }
}
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 75d884f..0022518 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceOwnerPositiveTestActivity.java
@@ -77,6 +77,7 @@
private static final String MANAGED_USER_TEST_ID = "MANAGED_USER_UI";
private static final String REMOVE_DEVICE_OWNER_TEST_ID = "REMOVE_DEVICE_OWNER";
private static final String DISALLOW_AMBIENT_DISPLAY_ID = "DISALLOW_AMBIENT_DISPLAY";
+ private static final String DISALLOW_REMOVE_USER_TEST_ID = "DISALLOW_REMOVE_USER";
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -400,6 +401,22 @@
new ButtonInfo(
R.string.device_owner_settings_go,
new Intent(Settings.ACTION_SETTINGS))}));
+
+ // DISALLOW_REMOVE_USER
+ adapter.add(createInteractiveTestItem(this, DISALLOW_REMOVE_USER_TEST_ID,
+ R.string.disallow_remove_user,
+ R.string.device_owner_disallow_remove_user_info,
+ new ButtonInfo[]{
+ new ButtonInfo(
+ R.string.device_owner_disallow_remove_user_create_user,
+ createCreateManagedUserWithoutSetupIntent()),
+ new ButtonInfo(
+ R.string.device_owner_user_restriction_set,
+ CommandReceiverActivity.createSetUserRestrictionIntent(
+ UserManager.DISALLOW_REMOVE_USER, true)),
+ new ButtonInfo(
+ R.string.device_owner_settings_go,
+ new Intent(Settings.ACTION_SETTINGS))}));
}
// Network logging UI
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/LockTaskUiTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/LockTaskUiTestActivity.java
index b04ec47..82612f7 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/LockTaskUiTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/LockTaskUiTestActivity.java
@@ -36,6 +36,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.PackageManager;
import android.database.DataSetObserver;
import android.os.AsyncTask;
import android.os.Bundle;
@@ -125,47 +126,57 @@
}
private void addTestsToAdapter(final ArrayTestListAdapter adapter) {
- adapter.add(createSetLockTaskFeaturesTest(
- TEST_ID_DEFAULT,
- LOCK_TASK_FEATURE_NONE,
- R.string.device_owner_lock_task_ui_default_test,
- R.string.device_owner_lock_task_ui_default_test_info));
+ if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
+ adapter.add(createSetLockTaskFeaturesTest(
+ TEST_ID_DEFAULT,
+ LOCK_TASK_FEATURE_NONE,
+ R.string.device_owner_lock_task_ui_default_test,
+ R.string.device_owner_lock_task_ui_default_test_info));
- adapter.add(createSetLockTaskFeaturesTest(
- TEST_ID_SYSTEM_INFO,
- LOCK_TASK_FEATURE_SYSTEM_INFO,
- R.string.device_owner_lock_task_ui_system_info_test,
- R.string.device_owner_lock_task_ui_system_info_test_info));
+ adapter.add(createSetLockTaskFeaturesTest(
+ TEST_ID_SYSTEM_INFO,
+ LOCK_TASK_FEATURE_SYSTEM_INFO,
+ R.string.device_owner_lock_task_ui_system_info_test,
+ R.string.device_owner_lock_task_ui_system_info_test_info));
+ }
- adapter.add(createSetLockTaskFeaturesTest(
- TEST_ID_NOTIFICATIONS,
- LOCK_TASK_FEATURE_HOME | LOCK_TASK_FEATURE_NOTIFICATIONS,
- R.string.device_owner_lock_task_ui_notifications_test,
- R.string.device_owner_lock_task_ui_notifications_test_info));
+ if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
+ adapter.add(createSetLockTaskFeaturesTest(
+ TEST_ID_NOTIFICATIONS,
+ LOCK_TASK_FEATURE_HOME | LOCK_TASK_FEATURE_NOTIFICATIONS,
+ R.string.device_owner_lock_task_ui_notifications_test,
+ R.string.device_owner_lock_task_ui_notifications_test_info));
+ }
- adapter.add(createSetLockTaskFeaturesTest(
- TEST_ID_HOME,
- LOCK_TASK_FEATURE_HOME,
- R.string.device_owner_lock_task_ui_home_test,
- R.string.device_owner_lock_task_ui_home_test_info));
+ if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
+ adapter.add(createSetLockTaskFeaturesTest(
+ TEST_ID_HOME,
+ LOCK_TASK_FEATURE_HOME,
+ R.string.device_owner_lock_task_ui_home_test,
+ R.string.device_owner_lock_task_ui_home_test_info));
+ }
- adapter.add(createSetLockTaskFeaturesTest(
- TEST_ID_RECENTS,
- LOCK_TASK_FEATURE_HOME | LOCK_TASK_FEATURE_OVERVIEW,
- R.string.device_owner_lock_task_ui_recents_test,
- R.string.device_owner_lock_task_ui_recents_test_info));
+ if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
+ adapter.add(createSetLockTaskFeaturesTest(
+ TEST_ID_RECENTS,
+ LOCK_TASK_FEATURE_HOME | LOCK_TASK_FEATURE_OVERVIEW,
+ R.string.device_owner_lock_task_ui_recents_test,
+ R.string.device_owner_lock_task_ui_recents_test_info));
+ }
- adapter.add(createSetLockTaskFeaturesTest(
- TEST_ID_GLOBAL_ACTIONS,
- LOCK_TASK_FEATURE_GLOBAL_ACTIONS,
- R.string.device_owner_lock_task_ui_global_actions_test,
- R.string.device_owner_lock_task_ui_global_actions_test_info));
+ if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
+ adapter.add(createSetLockTaskFeaturesTest(
+ TEST_ID_GLOBAL_ACTIONS,
+ LOCK_TASK_FEATURE_GLOBAL_ACTIONS,
+ R.string.device_owner_lock_task_ui_global_actions_test,
+ R.string.device_owner_lock_task_ui_global_actions_test_info));
- adapter.add(createSetLockTaskFeaturesTest(
- TEST_ID_KEYGUARD,
- LOCK_TASK_FEATURE_KEYGUARD,
- R.string.device_owner_lock_task_ui_keyguard_test,
- R.string.device_owner_lock_task_ui_keyguard_test_info));
+ adapter.add(createSetLockTaskFeaturesTest(
+ TEST_ID_KEYGUARD,
+ LOCK_TASK_FEATURE_KEYGUARD,
+ R.string.device_owner_lock_task_ui_keyguard_test,
+ R.string.device_owner_lock_task_ui_keyguard_test_info));
+ }
final Intent stopLockTaskIntent = new Intent(this, LockTaskUiTestActivity.class);
stopLockTaskIntent.setAction(ACTION_STOP_LOCK_TASK);
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ManagedUserPositiveTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ManagedUserPositiveTestActivity.java
index aa20b68..dd2a639 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ManagedUserPositiveTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ManagedUserPositiveTestActivity.java
@@ -24,6 +24,7 @@
import android.content.pm.PackageManager;
import android.database.DataSetObserver;
import android.os.Bundle;
+import android.os.UserManager;
import android.provider.Settings;
import com.android.cts.verifier.ArrayTestListAdapter;
@@ -49,6 +50,7 @@
private static final String DISABLE_STATUS_BAR_TEST_ID = "DISABLE_STATUS_BAR";
private static final String DISABLE_KEYGUARD_TEST_ID = "DISABLE_KEYGUARD";
private static final String POLICY_TRANSPARENCY_TEST_ID = "POLICY_TRANSPARENCY";
+ private static final String DISALLOW_REMOVE_USER_TEST_ID = "DISALLOW_REMOVE_USER";
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -148,6 +150,19 @@
CommandReceiverActivity.COMMAND_SET_KEYGUARD_DISABLED,
false))}));
+ // DISALLOW_REMOVE_USER
+ adapter.add(createInteractiveTestItem(this, DISALLOW_REMOVE_USER_TEST_ID,
+ R.string.disallow_remove_user,
+ R.string.managed_user_disallow_remove_user_info,
+ new ButtonInfo[]{
+ new ButtonInfo(
+ R.string.device_owner_user_restriction_set,
+ CommandReceiverActivity.createSetUserRestrictionIntent(
+ UserManager.DISALLOW_REMOVE_USER, true)),
+ new ButtonInfo(
+ R.string.device_owner_settings_go,
+ new Intent(Settings.ACTION_SETTINGS))}));
+
// Policy Transparency
final Intent policyTransparencyTestIntent = new Intent(this,
PolicyTransparencyTestListActivity.class);
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/UserRestrictions.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/UserRestrictions.java
index 1be781b..f004ace 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/UserRestrictions.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/UserRestrictions.java
@@ -47,7 +47,6 @@
UserManager.DISALLOW_NETWORK_RESET,
UserManager.DISALLOW_OUTGOING_BEAM,
UserManager.DISALLOW_REMOVE_MANAGED_PROFILE,
- UserManager.DISALLOW_REMOVE_USER,
UserManager.DISALLOW_SHARE_LOCATION,
UserManager.DISALLOW_UNINSTALL_APPS,
UserManager.DISALLOW_UNIFIED_PASSWORD,
@@ -77,7 +76,6 @@
R.string.disallow_network_reset,
R.string.disallow_outgoing_beam,
R.string.disallow_remove_managed_profile,
- R.string.disallow_remove_user,
R.string.disallow_share_location,
R.string.disallow_uninstall_apps,
R.string.disallow_unified_challenge,
@@ -105,7 +103,6 @@
R.string.disallow_network_reset_action,
R.string.disallow_outgoing_beam_action,
R.string.disallow_remove_managed_profile_action,
- R.string.disallow_remove_user_action,
R.string.disallow_share_location_action,
R.string.disallow_uninstall_apps_action,
R.string.disallow_unified_challenge_action,
@@ -133,7 +130,6 @@
Settings.ACTION_SETTINGS,
Settings.ACTION_NFC_SETTINGS,
Settings.ACTION_SETTINGS,
- Settings.ACTION_SETTINGS,
Settings.ACTION_LOCATION_SOURCE_SETTINGS,
Settings.ACTION_APPLICATION_SETTINGS,
Settings.ACTION_SECURITY_SETTINGS,
@@ -175,14 +171,12 @@
UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES,
UserManager.DISALLOW_MODIFY_ACCOUNTS,
UserManager.DISALLOW_OUTGOING_BEAM,
- UserManager.DISALLOW_REMOVE_USER,
UserManager.DISALLOW_SHARE_LOCATION,
UserManager.DISALLOW_UNINSTALL_APPS,
UserManager.DISALLOW_CONFIG_DATE_TIME,
UserManager.DISALLOW_CONFIG_LOCATION,
UserManager.DISALLOW_CONFIG_SCREEN_TIMEOUT,
- UserManager.DISALLOW_CONFIG_BRIGHTNESS,
- UserManager.DISALLOW_AMBIENT_DISPLAY);
+ UserManager.DISALLOW_CONFIG_BRIGHTNESS);
public static String getRestrictionLabel(Context context, String restriction) {
final UserRestrictionItem item = findRestrictionItem(restriction);
@@ -238,7 +232,6 @@
final PackageManager pm = context.getPackageManager();
switch (restriction) {
case UserManager.DISALLOW_ADD_USER:
- case UserManager.DISALLOW_REMOVE_USER:
return UserManager.supportsMultipleUsers();
case UserManager.DISALLOW_ADJUST_VOLUME:
return pm.hasSystemFeature(PackageManager.FEATURE_AUDIO_OUTPUT);
diff --git a/apps/VpnApp/notalwayson/AndroidManifest.xml b/apps/VpnApp/notalwayson/AndroidManifest.xml
index 58d2bf9..b356369 100644
--- a/apps/VpnApp/notalwayson/AndroidManifest.xml
+++ b/apps/VpnApp/notalwayson/AndroidManifest.xml
@@ -19,6 +19,7 @@
<uses-sdk android:minSdkVersion="22"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<application android:label="@string/app">
<activity android:name=".VpnClient">
diff --git a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/PackageDeviceInfo.java b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/PackageDeviceInfo.java
index e2459d0..16f7610 100644
--- a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/PackageDeviceInfo.java
+++ b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/PackageDeviceInfo.java
@@ -32,6 +32,8 @@
private static final String VERSION_NAME = "version_name";
private static final String SYSTEM_PRIV = "system_priv";
private static final String PRIV_APP_DIR = "/system/priv-app";
+ private static final String MIN_SDK = "min_sdk";
+ private static final String TARGET_SDK = "target_sdk";
@Override
protected void collectDeviceInfo(DeviceInfoStore store) throws Exception {
@@ -45,6 +47,9 @@
if (pkg.applicationInfo != null) {
String dir = pkg.applicationInfo.sourceDir;
store.addResult(SYSTEM_PRIV, dir != null && dir.startsWith(PRIV_APP_DIR));
+
+ store.addResult(MIN_SDK, pkg.applicationInfo.minSdkVersion);
+ store.addResult(TARGET_SDK, pkg.applicationInfo.targetSdkVersion);
}
store.endGroup();
}
diff --git a/common/device-side/util/src/com/android/compatibility/common/util/ApiLevelUtil.java b/common/device-side/util/src/com/android/compatibility/common/util/ApiLevelUtil.java
index a49e949..943ebc7 100644
--- a/common/device-side/util/src/com/android/compatibility/common/util/ApiLevelUtil.java
+++ b/common/device-side/util/src/com/android/compatibility/common/util/ApiLevelUtil.java
@@ -46,7 +46,7 @@
}
public static boolean isAtLeast(String version) {
- return Build.VERSION.SDK_INT > resolveVersionString(version);
+ return Build.VERSION.SDK_INT >= resolveVersionString(version);
}
public static boolean isAtMost(int version) {
diff --git a/common/device-side/util/src/com/android/compatibility/common/util/AppStandbyUtils.java b/common/device-side/util/src/com/android/compatibility/common/util/AppStandbyUtils.java
index a1adc02..eb94b60 100644
--- a/common/device-side/util/src/com/android/compatibility/common/util/AppStandbyUtils.java
+++ b/common/device-side/util/src/com/android/compatibility/common/util/AppStandbyUtils.java
@@ -59,7 +59,8 @@
public static boolean isAppStandbyEnabledAtRuntime() {
final String result =
SystemUtil.runShellCommand("settings get global app_standby_enabled").trim();
- final boolean boolResult = result.equals("1");
+ // framework considers null value as enabled.
+ final boolean boolResult = result.equals("1") || result.equals("null");
Log.d(TAG, "AppStandby is " + (boolResult ? "enabled" : "disabled") + " at runtime.");
return boolResult;
}
diff --git a/common/device-side/util/src/com/android/compatibility/common/util/BusinessLogicDeviceExecutor.java b/common/device-side/util/src/com/android/compatibility/common/util/BusinessLogicDeviceExecutor.java
index 130bf69..7d7aaf0 100644
--- a/common/device-side/util/src/com/android/compatibility/common/util/BusinessLogicDeviceExecutor.java
+++ b/common/device-side/util/src/com/android/compatibility/common/util/BusinessLogicDeviceExecutor.java
@@ -17,6 +17,7 @@
package com.android.compatibility.common.util;
import android.content.Context;
+import android.text.TextUtils;
import android.util.Log;
import java.lang.reflect.Method;
@@ -56,6 +57,22 @@
* {@inheritDoc}
*/
@Override
+ public void logDebug(String format, Object... args) {
+ Log.d(LOG_TAG, String.format(format, args));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String formatExecutionString(String method, String... args) {
+ return String.format("%s(%s)", method, TextUtils.join(", ", args));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
protected ResolvedMethod getResolvedMethod(Class cls, String methodName, String... args)
throws ClassNotFoundException {
List<Method> nameMatches = getMethodsWithName(cls, methodName);
diff --git a/hostsidetests/api/Android.mk b/hostsidetests/api/Android.mk
deleted file mode 100644
index 11f1e9d..0000000
--- a/hostsidetests/api/Android.mk
+++ /dev/null
@@ -1,45 +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 := CtsUnofficialApisUsageTestCases
-LOCAL_MODULE_TAGS := tests
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_SDK_VERSION := current
-LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed compatibility-host-util
-LOCAL_STATIC_JAVA_LIBRARIES := dexlib2 doclava jsilver guavalib antlr-runtime host-jdk-tools-prebuilt \
- compatibility-host-util
-
-# These are list of api txt files that are considered as approved APIs
-LOCAL_JAVA_RESOURCE_FILES := $(addprefix frameworks/base/,\
-api/current.txt \
-api/system-current.txt \
-test-base/api/android-test-base-current.txt \
-test-runner/api/android-test-runner-current.txt \
-test-mock/api/android-test-mock-current.txt)
-
-# API 27 is added since some support libraries are using old APIs
-LOCAL_JAVA_RESOURCE_FILES += prebuilts/sdk/api/27.txt
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE_TAGS := optional
-LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := host-jdk-tools-prebuilt:../../../$(HOST_JDK_TOOLS_JAR)
-include $(BUILD_HOST_PREBUILT)
diff --git a/hostsidetests/api/AndroidTest.xml b/hostsidetests/api/AndroidTest.xml
deleted file mode 100644
index df163b0..0000000
--- a/hostsidetests/api/AndroidTest.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<configuration description="Config for CTS unofficial APIs usage test cases">
- <option name="test-suite-tag" value="cts" />
- <option name="config-descriptor:metadata" key="component" value="systems" />
- <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
- <option name="jar" value="CtsUnofficialApisUsageTestCases.jar" />
- <option name="runtime-hint" value="30s" />
- </test>
-</configuration>
diff --git a/hostsidetests/api/src/com/android/cts/api/ApprovedApis.java b/hostsidetests/api/src/com/android/cts/api/ApprovedApis.java
deleted file mode 100644
index c68fe91..0000000
--- a/hostsidetests/api/src/com/android/cts/api/ApprovedApis.java
+++ /dev/null
@@ -1,225 +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 com.android.cts.api;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringJoiner;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import com.google.doclava.ClassInfo;
-import com.google.doclava.FieldInfo;
-import com.google.doclava.MethodInfo;
-import com.google.doclava.ParameterInfo;
-import com.google.doclava.TypeInfo;
-import com.google.doclava.apicheck.ApiFile;
-import com.google.doclava.apicheck.ApiInfo;
-import com.google.doclava.apicheck.ApiParseException;
-
-/**
- * Parses API text files (e.g. current.txt) into classes, methods, and fields.
- */
-public class ApprovedApis {
- private final Map<String, DefinedClass> definedApiClasses = new HashMap<>();
- private final Map<String, DefinedMethod> definedApiMethods = new HashMap<>();
- private final Map<String, DefinedField> definedApiFields = new HashMap<>();
-
- public ApprovedApis(Stream<File> apiFiles) {
- apiFiles.forEach(file -> parse(file));
-
- // build the maps for methods and fields
- definedApiMethods.putAll(definedApiClasses.values().stream()
- .flatMap(c -> c.getMethods().stream()) // all methods from all classes
- .collect(Collectors.toMap(DefinedMethod::getFullSignature,
- Function.identity()))); // map by their full signatures
-
- definedApiFields.putAll(definedApiClasses.values().stream()
- .flatMap(c -> c.getFields().stream()) // all fields from all classes
- .collect(Collectors.toMap(DefinedField::getFullSignature,
- Function.identity()))); // map by their full signatures
-
- if (UnofficialApisUsageTest.DEBUG) {
- System.err.println("-------------------API------------------");
-
- definedApiClasses.values().stream().sorted()
- .forEach(def -> System.err.println(" Defined class: " + def.getName()));
-
- definedApiMethods.values().stream().sorted()
- .forEach(def -> System.err
- .println(" Defined method: " + def.getFullSignature()));
-
- definedApiFields.values().stream().sorted()
- .forEach(def -> System.err
- .println(" Defined field: " + def.getFullSignature()));
- }
- }
-
- public Map<String, DefinedClass> getDefinedClasses() {
- return definedApiClasses;
- }
-
- public Map<String, DefinedMethod> getDefinedMethods() {
- return definedApiMethods;
- }
-
- public Map<String, DefinedField> getDefinedFields() {
- return definedApiFields;
- }
-
- private void parse(File apiFile) {
- try {
- InputStream is = null;
- try {
- is = this.getClass().getResourceAsStream(apiFile.toString());
- ApiInfo apiInfo = ApiFile.parseApi(apiFile.toString(), is);
- apiInfo.getPackages().values().stream()
- .flatMap(packageInfo -> packageInfo.allClasses().values().stream())
- .forEach(classInfo -> {
- DefinedClass c = definedApiClasses.get(classInfo.qualifiedName());
- if (c != null) {
- // if the same class has already been defined by other api file,
- // then update it
- DefinedClass newClass = definedClassFrom(classInfo);
- c.addNewMembers(newClass.getMethods(), newClass.getFields());
- } else {
- c = definedClassFrom(classInfo);
- definedApiClasses.put(c.getName(), c);
- }
- });
-
- } finally {
- if (is != null) {
- is.close();
- }
- }
- } catch (ApiParseException | IOException e) {
- throw new RuntimeException("Failed to parse " + apiFile, e);
- }
- }
-
- private static DefinedClass definedClassFrom(ClassInfo def) {
- String name = def.qualifiedName();
- String superClassName = def.superclassName();
- Collection<String> interfaces = def.interfaces().stream().map(ClassInfo::qualifiedName)
- .collect(Collectors.toList());
-
- Collection<DefinedMethod> methods = new ArrayList<>(
- def.allConstructors().size() + def.selfMethods().size());
- Collection<DefinedField> fields = new ArrayList<>(
- def.enumConstants().size() + def.selfFields().size());
-
- methods = Stream.concat(
- def.allConstructors().stream().map(ApprovedApis::definedMethodFromConstructor),
- def.selfMethods().stream().map(ApprovedApis::definedMethodFromMethod))
- .collect(Collectors.toSet());
-
- fields = Stream.concat(def.enumConstants().stream(), def.selfFields().stream())
- .map(ApprovedApis::definedFieldFrom).collect(Collectors.toSet());
-
- return new DefinedClass(name, superClassName, interfaces, methods, fields);
- }
-
- private static DefinedMethod definedMethodFromConstructor(MethodInfo def) {
- return definedMethodFrom(def, true);
- }
-
- private static DefinedMethod definedMethodFromMethod(MethodInfo def) {
- return definedMethodFrom(def, false);
- }
-
- private static DefinedMethod definedMethodFrom(MethodInfo def, boolean isCtor) {
- StringBuffer sb = new StringBuffer();
- if (isCtor) {
- sb.append("<init>");
- } else {
- sb.append(def.name());
- }
- sb.append('(');
- StringJoiner joiner = new StringJoiner(",");
- for (int i = 0; i < def.parameters().size(); i++) {
- ParameterInfo param = def.parameters().get(i);
- TypeInfo type = param.type();
- TypeInfo typeParameterType = def.getTypeParameter(type.qualifiedTypeName());
- String typeName;
- if (typeParameterType != null) {
- List<TypeInfo> bounds = typeParameterType.extendsBounds();
- if (bounds == null || bounds.size() == 0) {
- typeName = "java.lang.Object" + type.dimension();
- } else {
- typeName = bounds.get(0).qualifiedTypeName() + type.dimension();
- }
- } else {
- typeName = type.qualifiedTypeName() + type.dimension();
- }
- if (i == def.parameters().size() - 1 && def.isVarArgs()) {
- typeName += "[]";
- }
- joiner.add(typeName);
- }
- sb.append(joiner.toString());
- sb.append(')');
- if (!isCtor) {
- TypeInfo type = def.returnType();
- TypeInfo typeParameterType = def.getTypeParameter(type.qualifiedTypeName());
- if (typeParameterType != null) {
- List<TypeInfo> bounds = typeParameterType.extendsBounds();
- if (bounds == null || bounds.size() != 1) {
- sb.append("java.lang.Object" + type.dimension());
- } else {
- sb.append(bounds.get(0).qualifiedTypeName() + type.dimension());
- }
- } else {
- sb.append(type.qualifiedTypeName() + type.dimension());
- }
- }
-
- String signature = sb.toString();
- String containingClass = def.containingClass().qualifiedName();
- return new DefinedMethod(signature, containingClass);
- }
-
- private static DefinedField definedFieldFrom(FieldInfo def) {
- StringBuffer sb = new StringBuffer(def.name());
- sb.append(":");
-
- TypeInfo type = def.type();
- TypeInfo typeParameterType = def.containingClass()
- .getTypeParameter(type.qualifiedTypeName());
- if (typeParameterType != null) {
- List<TypeInfo> bounds = typeParameterType.extendsBounds();
- if (bounds == null || bounds.size() != 1) {
- sb.append("java.lang.Object" + type.dimension());
- } else {
- sb.append(bounds.get(0).qualifiedTypeName() + type.dimension());
- }
- } else {
- sb.append(type.qualifiedTypeName() + type.dimension());
- }
-
- String signature = sb.toString();
- String containingClass = def.containingClass().qualifiedName();
- return new DefinedField(signature, containingClass);
- }
-}
diff --git a/hostsidetests/api/src/com/android/cts/api/DefinedClass.java b/hostsidetests/api/src/com/android/cts/api/DefinedClass.java
deleted file mode 100644
index e4adc71..0000000
--- a/hostsidetests/api/src/com/android/cts/api/DefinedClass.java
+++ /dev/null
@@ -1,111 +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 com.android.cts.api;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.stream.Collectors;
-
-/**
- * A class defined in a DEX or in an API file
- */
-public final class DefinedClass implements Comparable<DefinedClass> {
- private final String name;
- private final String superClassName;
- private final Collection<String> interfaceNames;
- private final Collection<DefinedMethod> methods;
- private final Collection<DefinedField> fields;
- private final Collection<String> methodSignatures;
- private final Collection<String> fieldSignatures;
-
- DefinedClass(String name, String superClassName, Collection<String> interfaceNames,
- Collection<DefinedMethod> methods, Collection<DefinedField> fields) {
- this.name = name;
- this.superClassName = superClassName;
- this.interfaceNames = interfaceNames;
- // these are Set instead of List to eliminate duplication from multiple api files
- this.methods = new HashSet<>();
- this.fields = new HashSet<>();
-
- // signatures is okay to be list because they are always re-generated
- // in addMembersFrom
- this.methodSignatures = new ArrayList<>();
- this.fieldSignatures = new ArrayList<>();
-
- addNewMembers(methods, fields);
- }
-
- void addNewMembers(Collection<DefinedMethod> newMethods, Collection<DefinedField> newFields) {
- methods.addAll(newMethods);
- fields.addAll(newFields);
-
- // re-generate the signatures list
- methodSignatures.clear();
- methodSignatures.addAll(methods.stream()
- .map(DefinedMethod::getSignature)
- .collect(Collectors.toList()));
-
- fieldSignatures.clear();
- fieldSignatures.addAll(fields.stream()
- .map(DefinedField::getSignature)
- .collect(Collectors.toList()));
- }
-
- /**
- * Returns canonical name of a class
- */
- public String getName() {
- return name;
- }
-
- String getSuperClass() {
- return superClassName;
- }
-
- Collection<String> getInterfaces() {
- return interfaceNames;
- }
-
- Collection<DefinedMethod> getMethods() {
- return methods;
- }
-
- Collection<DefinedField> getFields() {
- return fields;
- }
-
- Collection<String> getMethodSignatures() {
- return methodSignatures;
- }
-
- Collection<String> getFieldSignatures() {
- return fieldSignatures;
- }
-
- boolean isEnum() {
- return getSuperClass().equals("java.lang.Enum");
- }
-
- @Override
- public int compareTo(DefinedClass o) {
- if (o != null) {
- return getName().compareTo(o.getName());
- }
- return 0;
- }
-}
diff --git a/hostsidetests/api/src/com/android/cts/api/DefinedField.java b/hostsidetests/api/src/com/android/cts/api/DefinedField.java
deleted file mode 100644
index 0fe1796..0000000
--- a/hostsidetests/api/src/com/android/cts/api/DefinedField.java
+++ /dev/null
@@ -1,73 +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 com.android.cts.api;
-
-/**
- * A field or enum constant defined in a DEX or in an API file
- */
-public final class DefinedField implements Comparable<DefinedField> {
- private final String signature;
- private final String definingClass;
-
- DefinedField(String signature, String definingClass) {
- this.signature = signature;
- this.definingClass = definingClass;
- }
-
- /**
- * Returns name:type
- */
- String getSignature() {
- return signature;
- }
-
- /**
- * Returns class.name:type
- */
- public String getFullSignature() {
- return getDefiningClass() + "." + getSignature();
- }
-
- String getDefiningClass() {
- return definingClass;
- }
-
- @Override
- public int compareTo(DefinedField o) {
- if (o != null) {
- return getFullSignature().compareTo(o.getFullSignature());
- }
- return 0;
- }
-
- @Override
- public int hashCode() {
- return getFullSignature().hashCode();
- }
-
- /**
- * Fields are fully identified by their full signature. Two fields with same signature are
- * considered to be the same.
- */
- @Override
- public boolean equals(Object o) {
- if (o != null && o instanceof DefinedField) {
- return getFullSignature().equals(((DefinedField) o).getFullSignature());
- }
- return false;
- }
-}
diff --git a/hostsidetests/api/src/com/android/cts/api/DefinedMethod.java b/hostsidetests/api/src/com/android/cts/api/DefinedMethod.java
deleted file mode 100644
index 9d78157..0000000
--- a/hostsidetests/api/src/com/android/cts/api/DefinedMethod.java
+++ /dev/null
@@ -1,73 +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 com.android.cts.api;
-
-/**
- * A method or constructor defined in a DEX or in an API file
- */
-public final class DefinedMethod implements Comparable<DefinedMethod> {
- private final String signature;
- private final String definingClass;
-
- DefinedMethod(String signature, String definingClass) {
- this.signature = signature;
- this.definingClass = definingClass;
- }
-
- /**
- * Returns name(arg1,arg2,...)type. For constructor, name is <init> and type is empty.
- */
- String getSignature() {
- return signature;
- }
-
- /**
- * Returns class.name(arg1,arg2,...)type. For constructor, name is <init> and type is empty.
- */
- public String getFullSignature() {
- return getDefiningClass() + "." + getSignature();
- }
-
- String getDefiningClass() {
- return definingClass;
- }
-
- @Override
- public int compareTo(DefinedMethod o) {
- if (o != null) {
- return getFullSignature().compareTo(o.getFullSignature());
- }
- return 0;
- }
-
- @Override
- public int hashCode() {
- return getFullSignature().hashCode();
- }
-
- /**
- * Methods are fully identified by their full signature. Two methods with same signature are
- * considered to be the same.
- */
- @Override
- public boolean equals(Object o) {
- if (o != null && o instanceof DefinedMethod) {
- return getFullSignature().equals(((DefinedMethod) o).getFullSignature());
- }
- return false;
- }
-}
diff --git a/hostsidetests/api/src/com/android/cts/api/DexAnalyzer.java b/hostsidetests/api/src/com/android/cts/api/DexAnalyzer.java
deleted file mode 100644
index d2d9ade..0000000
--- a/hostsidetests/api/src/com/android/cts/api/DexAnalyzer.java
+++ /dev/null
@@ -1,560 +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 com.android.cts.api;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringJoiner;
-import java.util.function.Function;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
-
-import org.jf.dexlib2.DexFileFactory;
-import org.jf.dexlib2.DexFileFactory.DexFileNotFoundException;
-import org.jf.dexlib2.Opcodes;
-import org.jf.dexlib2.ReferenceType;
-import org.jf.dexlib2.dexbacked.DexBackedClassDef;
-import org.jf.dexlib2.dexbacked.DexBackedDexFile;
-import org.jf.dexlib2.dexbacked.DexBackedField;
-import org.jf.dexlib2.dexbacked.DexBackedMethod;
-import org.jf.dexlib2.dexbacked.reference.DexBackedFieldReference;
-import org.jf.dexlib2.dexbacked.reference.DexBackedMethodReference;
-import org.jf.dexlib2.dexbacked.reference.DexBackedTypeReference;
-
-public class DexAnalyzer {
- private static Map<Character, String> primitiveTypes = new HashMap<>();
- static {
- primitiveTypes.put('Z', "boolean");
- primitiveTypes.put('B', "byte");
- primitiveTypes.put('C', "char");
- primitiveTypes.put('S', "short");
- primitiveTypes.put('I', "int");
- primitiveTypes.put('J', "long");
- primitiveTypes.put('F', "float");
- primitiveTypes.put('D', "double");
- primitiveTypes.put('V', "void");
- }
-
- // [[Lcom/foo/bar/MyClass$Inner; becomes
- // com.foo.bar.MyClass.Inner[][]
- // and [[I becomes int[][]
- private static String toCanonicalName(String name) {
- int arrayDepth = 0;
- for (int i = 0; i < name.length(); i++) {
- if (name.charAt(i) == '[') {
- arrayDepth++;
- } else {
- break;
- }
- }
-
- // test the first character.
- final char firstChar = name.charAt(arrayDepth);
- if (primitiveTypes.containsKey(firstChar)) {
- name = primitiveTypes.get(firstChar);
- } else if (firstChar == 'L') {
- // omit the leading 'L' and the trailing ';'
- name = name.substring(arrayDepth + 1, name.length() - 1);
-
- // replace '/' and '$' to '.'
- name = name.replace('/', '.').replace('$', '.');
- } else {
- throw new RuntimeException("Invalid type name " + name);
- }
-
- // add []'s, if any
- if (arrayDepth > 0) {
- for (int i = 0; i < arrayDepth; i++) {
- name += "[]";
- }
- }
- return name;
- }
-
- public static abstract class Ref {
- private final List<String> fromList; // list of files that this reference was found
-
- protected Ref(String from) {
- fromList = new ArrayList<>();
- fromList.add(from);
- }
-
- void merge(Ref other) {
- this.fromList.addAll(other.fromList);
- }
-
- String printReferencedFrom() {
- StringJoiner joiner = new StringJoiner(", ");
- fromList.stream().forEach(name -> joiner.add(name));
- return joiner.toString();
- }
- }
-
- public static class TypeRef extends Ref implements Comparable<TypeRef> {
- private final DexBackedTypeReference ref;
- private final String name;
-
- TypeRef(DexBackedTypeReference ref, String from) {
- super(from);
- this.ref = ref;
- name = toCanonicalName(ref.getType());
- }
-
- String getName() {
- return name;
- }
-
- boolean isArray() {
- return ref.getType().charAt(0) == '[';
- }
-
- boolean isPrimitiveType() {
- String name = ref.getType();
- if (name.length() == 1) {
- return primitiveTypes.containsKey(name.charAt(0));
- } else if (name.charAt(0) == '[') {
- return primitiveTypes.containsKey(name.replaceAll("\\[+", "").charAt(0));
- }
- return false;
- }
-
- @Override
- public int compareTo(TypeRef o) {
- if (o != null) {
- return getName().compareTo(o.getName());
- }
- return 0;
- }
- }
-
- // common parent class for MethodRef and FieldRef
- public static abstract class MemberRef extends Ref implements Comparable<MemberRef> {
- private final String signature;
- private String definingClass;
-
- protected MemberRef(String signature, String initialDefiningClass, String from) {
- super(from);
- this.signature = signature;
- // This might be incorrect since DexBacked[Method|Field]Reference.getDefiningClass()
- // only returns the type name of the target object. For example,
- //
- // class Super { void foo() {...} }
- // class Child extends Super { }
- // Child obj = new Child();
- // obj.foo();
- //
- // then method reference for `obj.foo()` is `Child.foo()` since obj is declared as type
- // Child. The true defining class is somewhere in the type hierarchy, which is Super
- // in this case.
- definingClass = initialDefiningClass;
- }
-
- String getSignature() {
- return signature;
- }
-
- String getDefiningClass() {
- return definingClass;
- }
-
- void setDefiningClass(String name) {
- definingClass = name;
- }
-
- String getFullSignature() {
- return getDefiningClass() + "." + getSignature();
- }
-
- @Override
- public int compareTo(MemberRef o) {
- if (o != null) {
- return getFullSignature().compareTo(o.getFullSignature());
- }
- return 0;
- }
- }
-
- public static class MethodRef extends MemberRef {
- private final boolean isConstructor;
-
- MethodRef(DexBackedMethodReference ref, String from) {
- super(makeSignature(ref), toCanonicalName(ref.getDefiningClass()), from);
- isConstructor = ref.getName().equals("<init>");
- }
-
- private static String makeSignature(DexBackedMethodReference ref) {
- StringBuffer sb = new StringBuffer();
- sb.append(ref.getName());
- sb.append('(');
- StringJoiner joiner = new StringJoiner(",");
- for (String param : ref.getParameterTypes()) {
- joiner.add(toCanonicalName(param));
- }
- sb.append(joiner.toString());
- sb.append(')');
- if (!ref.getName().equals("<init>")) {
- sb.append(toCanonicalName(ref.getReturnType()));
- }
- return sb.toString();
- }
-
- boolean isConstructor() {
- return isConstructor;
- }
- }
-
- public static class FieldRef extends MemberRef {
- FieldRef(DexBackedFieldReference ref, String from) {
- super(makeSignature(ref), toCanonicalName(ref.getDefiningClass()), from);
- }
-
- private static String makeSignature(DexBackedFieldReference ref) {
- return ref.getName() + ":" + toCanonicalName(ref.getType());
- }
- }
-
- private final Map<String, DefinedClass> definedClassesInDex = new HashMap<>();
- private final Map<String, DefinedMethod> definedMethodsInDex = new HashMap<>();
- private final Map<String, DefinedField> definedFieldsInDex = new HashMap<>();
-
- private final Map<String, TypeRef> typeReferences = new HashMap<>();
- private final Map<String, MethodRef> methodReferences = new HashMap<>();
- private final Map<String, FieldRef> fieldReferences = new HashMap<>();
-
- private final ApprovedApis approvedApis;
-
- public DexAnalyzer(Stream<PulledFile> files, ApprovedApis approvedApis) {
- this.approvedApis = approvedApis;
-
- files.forEach(file -> parse(file));
-
- // Maps for methods and fields are constructed AFTER all files are parsed.
- // This is because different dex files can have the same class with different sets of
- // members - if they are statically linking to the same class which are built
- // with source code at different times. In that case, members of the classes are
- // merged together.
- definedMethodsInDex.putAll(definedClassesInDex.values().stream()
- .map(DefinedClass::getMethods)
- .flatMap(methods -> methods.stream())
- .collect(Collectors.toMap(DefinedMethod::getFullSignature,
- Function.identity())));
-
- definedFieldsInDex.putAll(definedClassesInDex.values().stream()
- .map(DefinedClass::getFields)
- .flatMap(fields -> fields.stream())
- .collect(
- Collectors.toMap(DefinedField::getFullSignature, Function.identity())));
-
- if (UnofficialApisUsageTest.DEBUG) {
- definedClassesInDex.values().stream().sorted()
- .forEach(def -> System.err.println(" Defined class: " + def.getName()));
-
- definedMethodsInDex.values().stream().sorted()
- .forEach(def -> System.err
- .println(" Defined method: " + def.getFullSignature()));
-
- definedFieldsInDex.values().stream().sorted()
- .forEach(def -> System.err
- .println(" Defined field: " + def.getFullSignature()));
-
- typeReferences.values().stream().sorted().forEach(
- ref -> System.err.println(" type ref: " + ref.getName()));
- methodReferences.values().stream().sorted().forEach(
- ref -> System.err.println(" method ref: " + ref.getFullSignature()));
- fieldReferences.values().stream().sorted().forEach(
- ref -> System.err.println(" field ref: " + ref.getFullSignature()));
- }
-
- updateDefiningClassInReferences();
- }
-
- /**
- * Parse a dex file to extract symbols defined in the file and symbols referenced from the file
- */
- private void parse(PulledFile file) {
- if (UnofficialApisUsageTest.DEBUG) {
- System.err.println("Analyzing file: " + file.pathInDevice);
- }
-
- try {
- parseInner(file, "classes.dex");
- } catch (DexFileNotFoundException e) {
- // classes.dex must exist
- throw new RuntimeException("classes.dex" + " not found in " + file, e);
- }
-
- int i = 2;
- while (true) {
- try {
- parseInner(file, String.format("classes%d.dex", i++));
- } catch (DexFileNotFoundException e) {
- // failing to find additional dex files is okay. we just stop trying.
- break;
- }
- }
- }
-
- private void parseInner(PulledFile file, String dexEntry) throws DexFileNotFoundException {
- try {
- DexBackedDexFile dexFile = DexFileFactory.loadDexEntry(file.fileInHost, dexEntry, true,
- Opcodes.getDefault());
-
- // 1. extract defined symbols and add them to the maps
- dexFile.getClasses().stream().forEach(classDef -> {
- // If the same class is found (defined from one of the previous files), then
- // merge the members of this class to the old class.
- DefinedClass c = definedClassFrom(classDef);
- if (definedClassesInDex.containsKey(c.getName())) {
- definedClassesInDex.get(c.getName()).addNewMembers(c.getMethods(),
- c.getFields());
- } else {
- definedClassesInDex.put(c.getName(), c);
- }
- });
-
- // 2. extract referenced symbols and add then to the sets
- // Note that these *Ref classes are identified by their names or full signatures.
- // This is required since a same reference can be created by different dex files.
-
- // array types and primitive types are filtered-out
- dexFile.getReferences(ReferenceType.TYPE).stream()
- .map(t -> new TypeRef((DexBackedTypeReference) t, file.pathInDevice))
- .filter(((Predicate<TypeRef>) TypeRef::isArray).negate())
- .filter(((Predicate<TypeRef>) TypeRef::isPrimitiveType).negate())
- .forEach(ref -> {
- if (typeReferences.containsKey(ref.getName())) {
- typeReferences.get(ref.getName()).merge(ref);
- } else {
- typeReferences.put(ref.getName(), ref);
- }
- });
-
- dexFile.getReferences(ReferenceType.METHOD).stream()
- .map(m -> new MethodRef((DexBackedMethodReference) m, file.pathInDevice))
- .forEach(ref -> {
- if (methodReferences.containsKey(ref.getFullSignature())) {
- methodReferences.get(ref.getFullSignature()).merge(ref);
- } else {
- methodReferences.put(ref.getFullSignature(), ref);
- }
- });
-
- dexFile.getReferences(ReferenceType.FIELD).stream()
- .map(f -> new FieldRef((DexBackedFieldReference) f, file.pathInDevice))
- .forEach(ref -> {
- if (fieldReferences.containsKey(ref.getFullSignature())) {
- fieldReferences.get(ref.getFullSignature()).merge(ref);
- } else {
- fieldReferences.put(ref.getFullSignature(), ref);
- }
- });
-
- } catch (IOException e) {
- throw new RuntimeException("Cannot parse dex file in " + file, e);
- }
- }
-
- /**
- * For For each method/field reference, try to find a class defining it. If found, update the
- * reference in the set since its full signature has changed.
- */
- private void updateDefiningClassInReferences() {
- Stream.concat(methodReferences.values().stream(), fieldReferences.values().stream())
- .forEach(ref -> {
- DefinedClass c = findDefiningClass(ref);
- if (c != null && !ref.getDefiningClass().equals(c.getName())) {
- ref.setDefiningClass(c.getName());
- }
- });
- }
-
- /**
- * Try to find a true class defining the given member.
- */
- private DefinedClass findDefiningClass(MemberRef ref) {
- return findMemberInner(ref, ref.getDefiningClass());
- }
-
- /**
- * Try to find a class defining a member by from the given class up to the parent classes
- */
- private DefinedClass findMemberInner(MemberRef ref, String className) {
- final Function<DefinedClass, Collection<String>> getMethods = (DefinedClass c) -> c
- .getMethodSignatures();
- final Function<DefinedClass, Collection<String>> getFields = (DefinedClass c) -> c
- .getFieldSignatures();
-
- Function<DefinedClass, Collection<String>> getMembers = ref instanceof MethodRef
- ? getMethods
- : getFields;
-
- final boolean classFoundInDex = definedClassesInDex.containsKey(className);
- final boolean classFoundInApi = approvedApis.getDefinedClasses().containsKey(className);
- if (!classFoundInDex && !classFoundInApi) {
- // unknown class.
- return null;
- }
-
- if (classFoundInDex) {
- DefinedClass c = definedClassesInDex.get(className);
- if (getMembers.apply(c).contains(ref.getSignature())) {
- // method was found in the class
- return c;
- }
- }
-
- if (classFoundInApi) {
- DefinedClass c = approvedApis.getDefinedClasses().get(className);
- if (getMembers.apply(c).contains(ref.getSignature())) {
- // method was found in the class
- return c;
- }
- }
-
- // member was not found in the class. try finding in parent classes.
- // first gather the name of parent classes both from dex and api
- Set<String> parentClasses = new HashSet<>();
- if (classFoundInDex) {
- DefinedClass c = definedClassesInDex.get(className);
- parentClasses.add(c.getSuperClass());
- parentClasses.addAll(c.getInterfaces());
- }
- if (classFoundInApi) {
- DefinedClass c = approvedApis.getDefinedClasses().get(className);
- parentClasses.add(c.getSuperClass());
- parentClasses.addAll(c.getInterfaces());
- }
- // null can be in parentClasses, because null might have been added as getSuperClass() is
- // null for java.lang.Object
- parentClasses.remove(null);
-
- for (String pc : parentClasses) {
- DefinedClass foundClass = findMemberInner(ref, pc);
- if (foundClass != null) {
- return foundClass;
- }
- }
- return null;
- }
-
- private static class SkipIfNeeded implements Predicate<Ref> {
- @Override
- public boolean test(Ref ref) {
- String className = (ref instanceof TypeRef) ?
- ((TypeRef)ref).getName() : ((MemberRef)ref).getDefiningClass();
- if (className.endsWith("[]")) {
- // Reference to array type is skipped
- return true;
- }
- if (className.startsWith("dalvik.annotation.")
- || className.startsWith("javax.annotation.")) {
- // These annotation classes are not part of API but they are not explicitly used.
- return true;
- }
- if (className.startsWith("java.lang.")) {
- // core java libraries are exempted.
- return true;
- }
- if (ref instanceof MemberRef) {
- MemberRef memberRef = (MemberRef)ref;
- if (memberRef.getFullSignature().equals(
- "android.os.SystemProperties.set(java.lang.String,java.lang.String)void")) {
- // SystemProperties.set is exceptionally allowed.
- // TODO(b/73750660): remove this when sysprops are publicized via IDs.
- return true;
- }
- }
- return false;
- }
- }
-
- // for each type, method and field references, find the ones that are found neither in dex
- // nor in api
- public Stream<TypeRef> collectUndefinedTypeReferences() {
- return typeReferences.values().stream()
- .filter(ref -> !definedClassesInDex.containsKey(ref.getName())
- && !approvedApis.getDefinedClasses().containsKey(ref.getName()))
- .filter((new SkipIfNeeded()).negate());
- }
-
- public Stream<MethodRef> collectUndefinedMethodReferences() {
- return methodReferences.values().stream()
- .filter(ref -> !definedMethodsInDex.containsKey(ref.getFullSignature())
- && !approvedApis.getDefinedMethods().containsKey(ref.getFullSignature()))
- .filter((new SkipIfNeeded()).negate());
- }
-
- public Stream<FieldRef> collectUndefinedFieldReferences() {
- return fieldReferences.values().stream()
- .filter(ref -> !definedFieldsInDex.containsKey(ref.getFullSignature())
- && !approvedApis.getDefinedFields().containsKey(ref.getFullSignature()))
- .filter((new SkipIfNeeded()).negate());
- }
-
- private static DefinedClass definedClassFrom(DexBackedClassDef def) {
- String name = toCanonicalName(def.getType());
- String superClassName = toCanonicalName(def.getSuperclass());
- Collection<String> interfaceNames = def.getInterfaces().stream()
- .map(n -> toCanonicalName(n))
- .collect(Collectors.toList());
-
- Collection<DefinedMethod> methods = StreamSupport
- .stream(def.getMethods().spliterator(), false /* parallel */)
- .map(DexAnalyzer::definedMethodFrom).collect(Collectors.toList());
-
- Collection<DefinedField> fields = StreamSupport
- .stream(def.getFields().spliterator(), false /* parallel */)
- .map(DexAnalyzer::definedFieldFrom).collect(Collectors.toList());
-
- return new DefinedClass(name, superClassName, interfaceNames, methods, fields);
- }
-
- private static DefinedMethod definedMethodFrom(DexBackedMethod def) {
- StringBuffer sb = new StringBuffer();
- sb.append(def.getName());
- sb.append('(');
- StringJoiner joiner = new StringJoiner(",");
- for (String param : def.getParameterTypes()) {
- joiner.add(toCanonicalName(param));
- }
- sb.append(joiner.toString());
- sb.append(')');
- final boolean isConstructor = def.getName().equals("<init>");
- if (!isConstructor) {
- sb.append(toCanonicalName(def.getReturnType()));
- }
-
- String signature = sb.toString();
- String definingClass = toCanonicalName(def.getDefiningClass());
- return new DefinedMethod(signature, definingClass);
- }
-
- private static DefinedField definedFieldFrom(DexBackedField def) {
- String signature = def.getName() + ":" + toCanonicalName(def.getType());
- String definingClass = toCanonicalName(def.getDefiningClass());
- return new DefinedField(signature, definingClass);
- }
-}
diff --git a/hostsidetests/api/src/com/android/cts/api/FilePuller.java b/hostsidetests/api/src/com/android/cts/api/FilePuller.java
deleted file mode 100644
index 5e3b7cb..0000000
--- a/hostsidetests/api/src/com/android/cts/api/FilePuller.java
+++ /dev/null
@@ -1,94 +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 com.android.cts.api;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-
-import com.android.ddmlib.IShellOutputReceiver;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-
-/**
- * Pulls files from a non-rooted device
- */
-class FilePuller {
- private final ITestDevice device;
- private final Path hostDir;
-
- FilePuller(ITestDevice device) {
- this.device = device;
- try {
- hostDir = Files.createTempDirectory("pulled_files");
- hostDir.toFile().deleteOnExit();
- } catch (IOException e) {
- throw new RuntimeException("Cannot create directory for pulled files", e);
- }
- }
-
- void clean() {
- hostDir.toFile().delete();
- }
-
- PulledFile pullFromDevice(String path, String name) {
- try {
- File outputFile = new File(hostDir.toFile(), name);
- FileOutputStream outputStream = new FileOutputStream(outputFile);
-
- // For files on vendor partition, `adb shell pull` does not work on non-rooted device,
- // due to the permission. Thus using `cat` to copy file content to outside of the
- // device, which might a little bit slower than adb pull, but should be acceptable for
- // testing.
- device.executeShellCommand(String.format("cat %s", path),
- new IShellOutputReceiver() {
-
- @Override
- public void addOutput(byte[] data, int offset, int len) {
- try {
- outputStream.write(data, offset, len);
- } catch (IOException e) {
- throw new RuntimeException("Error pulling file " + path, e);
- }
- }
-
- @Override
- public void flush() {
- try {
- outputStream.close();
- } catch (IOException e) {
- throw new RuntimeException("Error saving file " + path,
- e);
- }
- }
-
- @Override
- public boolean isCancelled() {
- // don't cancel at any time.
- return false;
- }
- });
- return new PulledFile(outputFile, path);
- } catch (DeviceNotAvailableException e) {
- throw new RuntimeException("Cannot connect to the device", e);
- } catch (IOException e) {
- throw new RuntimeException("Failed to pull file " + path, e);
- }
- }
-}
diff --git a/hostsidetests/api/src/com/android/cts/api/PulledFile.java b/hostsidetests/api/src/com/android/cts/api/PulledFile.java
deleted file mode 100644
index 4742d52..0000000
--- a/hostsidetests/api/src/com/android/cts/api/PulledFile.java
+++ /dev/null
@@ -1,29 +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 com.android.cts.api;
-
-import java.io.File;
-
-class PulledFile {
- final File fileInHost;
- final String pathInDevice;
-
- PulledFile(File fileInHost, String pathInDevice) {
- this.fileInHost = fileInHost;
- this.pathInDevice = pathInDevice;
- }
-}
diff --git a/hostsidetests/api/src/com/android/cts/api/UnofficialApisUsageTest.java b/hostsidetests/api/src/com/android/cts/api/UnofficialApisUsageTest.java
deleted file mode 100644
index 6ecefb0f..0000000
--- a/hostsidetests/api/src/com/android/cts/api/UnofficialApisUsageTest.java
+++ /dev/null
@@ -1,250 +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 com.android.cts.api;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Stream;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import com.android.compatibility.common.util.PropertyUtil;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
-import com.android.tradefed.testtype.DeviceTestCase;
-
-/**
- * Ensures that java modules in vendor partition on the device are not using any non-approved APIs
- */
-@RunWith(DeviceJUnit4ClassRunner.class)
-public class UnofficialApisUsageTest extends DeviceTestCase {
- public final static boolean DEBUG = true;
- private ITestDevice device;
- private FilePuller filePuller;
-
- @Override
- protected void setUp() throws Exception {
- device = getDevice();
- filePuller = new FilePuller(device);
- }
-
- @Override
- protected void tearDown() throws Exception {
- filePuller.clean();
- }
-
- private static class JavaModule {
- enum Type {
- JAR, APK,
- }
-
- public final String name;
- public final String path;
- public final Type type;
-
- private JavaModule(String name, String path, Type type) {
- this.name = name;
- this.path = path;
- this.type = type;
- }
-
- public static JavaModule newPackageFromLine(String line) {
- // package:/path/to/apk=com.foo.bar
- line = line.split(":")[1]; // filter-out "package:" prefix
- int separatorPos = line.lastIndexOf('=');
- String path = line.substring(0, separatorPos);
- String name = line.substring(separatorPos + 1);
- return new JavaModule(name, path, Type.APK);
- }
-
- public static JavaModule newLibraryFromLine(String line) {
- // com.foo.bar -> (jar) /path/to/jar
- String[] tokens = line.trim().split(" ");
- String name = tokens[0];
- String type = tokens[3];
- String path = tokens[4];
- return new JavaModule(name, path, type.equals("(jar)") ? Type.JAR : Type.APK);
- }
- }
-
- private Stream<JavaModule> getPackages() throws DeviceNotAvailableException {
- return Arrays.stream(device.executeShellCommand("cmd package list packages -f").split("\n"))
- .map(line -> JavaModule.newPackageFromLine(line));
- }
-
- private Stream<JavaModule> getLibraries() throws DeviceNotAvailableException {
- // cmd package list libraries only shows the name of the libraries, but not their paths.
- // Until it shows the paths as well, let's use the old dumpsys package.
- return Arrays.stream(device.executeShellCommand("dumpsys package libraries").split("\n"))
- .skip(1) // for "Libraries:" header
- .map(line -> JavaModule.newLibraryFromLine(line))
- .filter(module -> module.type == JavaModule.Type.JAR); // only jars
- }
-
- private String getRealPath(String path) {
- try {
- return device.executeShellCommand(String.format("realpath %s", path));
- } catch (DeviceNotAvailableException e) {
- throw new RuntimeException("Cannot connect to device", e);
- }
- }
-
- /**
- * Tests whether the downloaded file has code or not, by examining the existence of classes.dex
- * in it
- */
- private boolean hasCode(File file) {
- try {
- ZipFile zipFile = null;
- try {
- zipFile = new ZipFile(file);
- Enumeration<? extends ZipEntry> entries = zipFile.entries();
- while (entries.hasMoreElements()) {
- ZipEntry e = entries.nextElement();
- if (e.getName().equals("classes.dex")) {
- return true;
- }
- }
- } finally {
- if (zipFile != null) {
- zipFile.close();
- }
- }
- return false;
- } catch (IOException e) {
- throw new RuntimeException("Error while examining whether code is in " + file, e);
- }
- }
-
- /**
- * These tests are required only for the Treble-ized devices launching with P or later.
- *
- * @throws DeviceNotAvailableException
- */
- private boolean isTestRequired() throws DeviceNotAvailableException {
- return PropertyUtil.propertyEquals(device, "ro.treble.enabled", "true")
- && PropertyUtil.getFirstApiLevel(device) > 27 /* O_MR1 */;
- }
-
- /**
- * The main test. If there is any type/method/field reference to unknown type/method/field, then
- * it indicates that vendors are using non-approved APIs.
- */
- @Test
- public void testNonApiReferences() throws Exception {
- if (!isTestRequired()) {
- return;
- }
- Stream<PulledFile> pulledFiles;
- Stream<File> apiFiles;
- ApprovedApis approvedApis;
- DexAnalyzer extractedApis;
-
- try {
- // pulls packages and libraries which are in vendor partition and have code.
- pulledFiles = Stream.concat(getPackages(), getLibraries())
- .filter(module -> getRealPath(module.path).startsWith("/vendor"))
- .map(module -> filePuller.pullFromDevice(module.path, module.name))
- .filter(file -> hasCode(file.fileInHost));
-
- } catch (DeviceNotAvailableException e) {
- throw new RuntimeException("Cannot connect to device", e);
- }
-
- apiFiles = Arrays.stream(new String[] {
- "/current.txt",
- "/system-current.txt",
- "/android-test-base-current.txt",
- "/android-test-runner-current.txt",
- "/android-test-mock-current.txt",
- "/27.txt"
- }).map(name -> new File(name));
-
- approvedApis = new ApprovedApis(apiFiles);
- extractedApis = new DexAnalyzer(pulledFiles, approvedApis);
-
- StringBuilder sb = new StringBuilder(10000);
- extractedApis.collectUndefinedTypeReferences().sorted().forEach(
- ref -> sb.append("Undefined type ref: " + ref.getName() + " from: "
- + ref.printReferencedFrom() + "\n"));
- extractedApis.collectUndefinedMethodReferences().sorted().forEach(
- ref -> sb.append("Undefined method ref: " + ref.getFullSignature() + " from: "
- + ref.printReferencedFrom() + "\n"));
- extractedApis.collectUndefinedFieldReferences().sorted().forEach(
- ref -> sb.append("Undefined field ref: " + ref.getFullSignature() + " from: "
- + ref.printReferencedFrom() + "\n"));
- if (sb.length() != 0) {
- fail(sb.toString());
- }
- }
-
- /**
- * Ensures that vendor apps are not targeting pre-P SDK.
- */
- @Test
- public void testTargetSdk() throws Exception {
- if (!isTestRequired()) {
- return;
- }
- StringBuilder output = new StringBuilder();
- Pattern p = Pattern.compile(".*targetSdk=(.*)\n");
- getPackages()
- .filter(module -> getRealPath(module.path).startsWith("/vendor"))
- .forEach(module -> {
- try {
- // This is very dependent on how the information is shown in the dump.
- // Sould be checked for amendment whenever the format changes in
- // dumpPackagesLPr in Settings.java
- // 1. targetSdk version is shown as 'targetSdk=<number>'.
- // 2: tail -1 is for the case when an apk is updated in the data partition.
- // In that case, we get dumps for two packages (first for the updated one,
- // and then for the original one). Among these two, we use targetSdk for
- // the original one (the last dump), because the updated one can be
- // uninstalled or wiped out at any time.
- String result = device.executeShellCommand(
- "dumpsys package " + module.name + " | grep targetSdk= | tail -1");
- Matcher m = p.matcher(result);
- if (m.matches() && m.groupCount() == 1) {
- String versionString = m.group(1);
- int versionInt = Integer.parseInt(versionString);
- if (versionInt <= 27) {
- output.append("Vendor package " + module.name
- + " is targeting old SDK: " + versionString + "\n");
- }
- } else {
- output.append(
- "Failed to get targetSDK for vendor package " + module.name
- + "\n");
- }
- } catch (DeviceNotAvailableException e) {
- output.append("Failed to get info for vendor package " + module.name
- + ". Cause: " + e.getMessage() + "\n");
- }
- });
- if (output.length() != 0) {
- fail(output.toString());
- }
- }
-}
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/CorruptApkTests.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/CorruptApkTests.java
index 6849d0c..8ac50af 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/CorruptApkTests.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/CorruptApkTests.java
@@ -15,18 +15,23 @@
*/
package android.appsecurity.cts;
-import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertFalse;
+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;
+import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.result.InputStreamSource;
+import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.testtype.DeviceTestCase;
import com.android.tradefed.testtype.IBuildReceiver;
import com.android.tradefed.util.FileUtil;
import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
import java.io.File;
@@ -35,104 +40,114 @@
* Set of tests that verify that corrupt APKs are properly rejected by PackageManager and
* do not cause the system to crash.
*/
-@AppModeFull // TODO: Needs porting to instant
public class CorruptApkTests extends DeviceTestCase implements IBuildReceiver {
- private final String B71360999_PKG = "com.android.appsecurity.b71360999";
- private final String B71361168_PKG = "com.android.appsecurity.b71361168";
- private final String B79488511_PKG = "com.android.appsecurity.b79488511";
private IBuildInfo mBuildInfo;
+ /** A container for information about the system_server process. */
+ private class SystemServerInformation {
+ final long mPid;
+ final long mStartTime;
+
+ SystemServerInformation(long pid, long startTime) {
+ this.mPid = pid;
+ this.mStartTime = startTime;
+ }
+
+ @Override
+ public boolean equals(Object actual) {
+ return (actual instanceof SystemServerInformation)
+ && mPid == ((SystemServerInformation) actual).mPid
+ && mStartTime == ((SystemServerInformation) actual).mStartTime;
+ }
+ }
+
+ /** Retrieves the process id and elapsed run time of system_server. */
+ private SystemServerInformation retrieveInfo() throws DeviceNotAvailableException {
+ ITestDevice device = getDevice();
+
+ // Retrieve the process id of system_server
+ String pidResult = device.executeShellCommand("pidof system_server").trim();
+ assertNotNull("Failed to retrieve pid of system_server", pidResult);
+ long pid = 0;
+ try {
+ pid = Long.parseLong(pidResult);
+ } catch (NumberFormatException | IndexOutOfBoundsException e) {
+ fail("Unable to parse pid of system_server '" + pidResult + "'");
+ }
+
+ // Retrieve the start time of system_server
+ long startTime = 0;
+ String pidStats = device.executeShellCommand("cat /proc/" + pid + "/stat");
+ assertNotNull("Failed to retrieve stat of system_server with pid '" + pid + "'", pidStats);
+ try {
+ String startTimeJiffies = pidStats.split("\\s+")[21];
+ startTime = Long.parseLong(startTimeJiffies);
+ } catch (NumberFormatException | IndexOutOfBoundsException e) {
+ fail("Unable to parse system_server stat file '" + pidStats + "'");
+ }
+
+ return new SystemServerInformation(pid, startTime);
+ }
+
@Override
public void setBuild(IBuildInfo buildInfo) {
mBuildInfo = buildInfo;
}
+ /** Uninstall any test APKs already present on device. */
+ private void uninstallApks() throws DeviceNotAvailableException {
+ ITestDevice device = getDevice();
+ device.uninstallPackage("com.android.appsecurity.b71360999");
+ device.uninstallPackage("com.android.appsecurity.b71361168");
+ device.uninstallPackage("com.android.appsecurity.b79488511");
+ }
+
@Before
@Override
public void setUp() throws Exception {
super.setUp();
- uninstall(B71360999_PKG);
- uninstall(B71361168_PKG);
- uninstall(B79488511_PKG);
+ uninstallApks();
}
@After
@Override
public void tearDown() throws Exception {
super.tearDown();
- uninstall(B71360999_PKG);
- uninstall(B71361168_PKG);
- uninstall(B79488511_PKG);
- }
-
- /** Uninstall the apk if the test failed previously. */
- public void uninstall(String pkg) throws Exception {
- ITestDevice device = getDevice();
- if (device.getInstalledPackageNames().contains(pkg)) {
- device.uninstallPackage(pkg);
- }
+ uninstallApks();
}
/**
- * Tests that apks described in b/71360999 do not install successfully.
+ * Asserts that installing the application does not cause a native error causing system_server
+ * to crash (typically the result of a buffer overflow or an out-of-bounds read).
*/
- public void testFailToInstallCorruptStringPoolHeader_b71360999() throws Exception {
- final String APK_PATH = "CtsCorruptApkTests_b71360999.apk";
- assertInstallNoFatalError(APK_PATH, B71360999_PKG);
- }
+ private void assertInstallDoesNotCrashSystem(String apk) throws Exception {
+ SystemServerInformation beforeInfo = retrieveInfo();
- /**
- * Tests that apks described in b/71361168 do not install successfully.
- */
- public void testFailToInstallCorruptStringPoolHeader_b71361168() throws Exception {
- final String APK_PATH = "CtsCorruptApkTests_b71361168.apk";
- assertInstallNoFatalError(APK_PATH, B71361168_PKG);
- }
-
- /**
- * Tests that apks described in b/79488511 do not install successfully.
- */
- public void testFailToInstallCorruptStringPoolHeader_b79488511() throws Exception {
- final String APK_PATH = "CtsCorruptApkTests_b79488511.apk";
- assertInstallNoFatalError(APK_PATH, B79488511_PKG);
- }
-
- /**
- * Assert that installing the app does not cause a native error caused by a buffer overflow
- * or an out-of-bounds read.
- **/
- private void assertInstallNoFatalError(String filename, String pkg) throws Exception {
- ITestDevice device = getDevice();
- device.clearLogcat();
-
- final String result = device.installPackage(
- new CompatibilityBuildHelper(mBuildInfo).getTestFile(filename),
- true /*reinstall*/);
-
- // Starting from P, corrupt apks should always fail to install
- if (device.getApiLevel() >= 28) {
- assertThat(result).isNotNull();
- assertThat(result).isNotEmpty();
- assertThat(device.getInstalledPackageNames()).doesNotContain(pkg);
+ final String result = getDevice().installPackage(
+ new CompatibilityBuildHelper(mBuildInfo).getTestFile(apk),
+ false /*reinstall*/);
+ CLog.logAndDisplay(LogLevel.INFO, "Result: '" + result + "'");
+ if (result != null) {
+ assertFalse("Install package segmentation faulted",
+ result.toLowerCase().contains("segmentation fault"));
}
- // This catches if the device fails to install the app because a segmentation fault
- // or out of bounds read created by the bug occurs
- File tmpTxtFile = null;
- InputStreamSource source = device.getLogcat(200 * 1024);
- try {
- assertNotNull(source);
- tmpTxtFile = FileUtil.createTempFile("logcat", ".txt");
- FileUtil.writeToFile(source.createInputStream(), tmpTxtFile);
- String s = FileUtil.readStringFromFile(tmpTxtFile);
- assertFalse(s.contains("SIGSEGV"));
- assertFalse(s.contains("==ERROR"));
- } finally {
- source.close();
- if (tmpTxtFile != null) {
- FileUtil.deleteFile(tmpTxtFile);
- }
- }
+ assertEquals("system_server restarted", beforeInfo, retrieveInfo());
+ }
+
+ /** Tests that installing the APK described in b/71360999 does not crash the device. */
+ public void testSafeInstallOfCorruptAPK_b71360999() throws Exception {
+ assertInstallDoesNotCrashSystem("CtsCorruptApkTests_b71360999.apk");
+ }
+
+ /** Tests that installing the APK described in b/71361168 does not crash the device. */
+ public void testSafeInstallOfCorruptAPK_b71361168() throws Exception {
+ assertInstallDoesNotCrashSystem("CtsCorruptApkTests_b71361168.apk");
+ }
+
+ /** Tests that installing the APK described in b/79488511 does not crash the device. */
+ public void testSafeInstallOfCorruptAPK_b79488511() throws Exception {
+ assertInstallDoesNotCrashSystem("CtsCorruptApkTests_b79488511.apk");
}
}
\ No newline at end of file
diff --git a/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/ScopedDirectoryAccessClientTest.java b/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/ScopedDirectoryAccessClientTest.java
index dc44bafb..135a0f7 100644
--- a/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/ScopedDirectoryAccessClientTest.java
+++ b/hostsidetests/appsecurity/test-apps/DocumentClient/src/com/android/cts/documentclient/ScopedDirectoryAccessClientTest.java
@@ -353,11 +353,10 @@
final boolean gotIt = mDevice.wait(Until.hasObject(By.text(dir)), TIMEOUT);
assertTrue("object with text'(" + dir + "') not visible yet", gotIt);
// TODO: find a better way to get the toggle rather then getting all
- final List<UiObject2> toggles = mDevice.findObjects(By.res("android:id/switch_widget"));
- assertEquals("should have just one toggle: " + toggles, 1, toggles.size());
- final UiObject2 toggle = toggles.get(0);
+ UiObject2 toggle = getUniqueToggle();
assertFalse("toggle for '" + dir + "' should not be checked", toggle.isChecked());
toggle.click();
+ toggle = getUniqueToggle();
assertTrue("toggle for '" + dir + "' should be checked", toggle.isChecked());
// Close app screen.
@@ -395,11 +394,10 @@
final boolean gotIt = mDevice.wait(Until.hasObject(By.text(dir)), TIMEOUT);
assertTrue("object with text'(" + dir + "') not visible yet", gotIt);
// TODO: find a better way to get the toggle rather then getting all
- final List<UiObject2> toggles = mDevice.findObjects(By.res("android:id/switch_widget"));
- assertEquals("should have just one toggle: " + toggles, 1, toggles.size());
- final UiObject2 toggle = toggles.get(0);
+ UiObject2 toggle = getUniqueToggle();
assertTrue("toggle for '" + dir + "' should be checked", toggle.isChecked());
toggle.click();
+ toggle = getUniqueToggle();
assertFalse("toggle for '" + dir + "' should not be checked", toggle.isChecked());
// Close app screen.
@@ -414,6 +412,12 @@
assertActivityFailed();
}
+ private UiObject2 getUniqueToggle() {
+ List<UiObject2> toggles = mDevice.findObjects(By.res("android:id/switch_widget"));
+ assertEquals("should have just one toggle: " + toggles, 1, toggles.size());
+ return toggles.get(0);
+ }
+
private void launchDirectoryAccessSettingsScreenAndSelectApp() {
final Intent intent = new Intent(Settings.ACTION_STORAGE_VOLUME_ACCESS_SETTINGS)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
diff --git a/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java b/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
index 1d0f83e..38cdb3c 100644
--- a/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
+++ b/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
@@ -19,6 +19,7 @@
import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_AWARE;
import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_UNAWARE;
+import android.app.KeyguardManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -56,6 +57,7 @@
private Context mCe;
private Context mDe;
private PackageManager mPm;
+ private KeyguardManager mKm;
private UiDevice mDevice;
private AwareActivity mActivity;
@@ -67,6 +69,7 @@
mCe = getInstrumentation().getContext();
mDe = mCe.createDeviceProtectedStorageContext();
mPm = mCe.getPackageManager();
+ mKm = (KeyguardManager) mCe.getSystemService(Context.KEYGUARD_SERVICE);
mDevice = UiDevice.getInstance(getInstrumentation());
assertNotNull(mDevice);
@@ -100,7 +103,9 @@
public void testTearDown() throws Exception {
// Just in case, always try tearing down keyguard
- dismissKeyguard();
+ if (mKm.isKeyguardLocked()) {
+ dismissKeyguard();
+ }
mActivity = launchActivity(getInstrumentation().getTargetContext().getPackageName(),
AwareActivity.class, null);
diff --git a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/NormalApp/src/com/android/cts/normalapp/ClientTest.java b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/NormalApp/src/com/android/cts/normalapp/ClientTest.java
index 2265dec..48a1b5d 100644
--- a/hostsidetests/appsecurity/test-apps/EphemeralTestApp/NormalApp/src/com/android/cts/normalapp/ClientTest.java
+++ b/hostsidetests/appsecurity/test-apps/EphemeralTestApp/NormalApp/src/com/android/cts/normalapp/ClientTest.java
@@ -441,6 +441,10 @@
final int originalSetting = Secure.getInt(contentResolver, Secure.INSTANT_APPS_ENABLED, 1);
Secure.putInt(contentResolver, Secure.INSTANT_APPS_ENABLED, 0);
try {
+ Thread.sleep(1000);
+ } catch (Exception e) {
+ }
+ try {
// start the ephemeral activity; using VIEW/BROWSABLE with setting disabled
try {
final Intent startViewIntent = new Intent(Intent.ACTION_VIEW)
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 80a1578..f187504 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
@@ -487,10 +487,18 @@
}
private void doTestGrantUriPermissionFail(Uri uri) {
- grantUriPermissionFail(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION, false);
- grantUriPermissionFail(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION, false);
- grantUriPermissionFail(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION, true);
- grantUriPermissionFail(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION, true);
+ for (boolean service : new boolean[] { false, true }) {
+ for (int flags : new int[] {
+ Intent.FLAG_GRANT_READ_URI_PERMISSION, Intent.FLAG_GRANT_WRITE_URI_PERMISSION
+ }) {
+ grantUriPermissionFail(uri,
+ flags, service);
+ grantUriPermissionFail(uri,
+ flags | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION, service);
+ grantUriPermissionFail(uri,
+ flags | Intent.FLAG_GRANT_PREFIX_URI_PERMISSION, service);
+ }
+ }
}
/**
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/res/raw/ringer.mp3 b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/res/raw/ringer.mp3
new file mode 100644
index 0000000..aa052e7
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/res/raw/ringer.mp3
Binary files differ
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 d44b782..e66d041 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
@@ -20,6 +20,7 @@
import android.content.pm.PackageManager;
import android.media.AudioManager;
import android.media.MediaPlayer;
+import android.net.Uri;
import android.provider.Settings;
import android.os.SystemClock;
import android.os.UserManager;
@@ -84,8 +85,9 @@
return;
}
+ Uri uri = Uri.parse("android.resource://" + mContext.getPackageName() + "/" + R.raw.ringer);
MediaPlayer mediaPlayer = new MediaPlayer();
- mediaPlayer.setDataSource(mContext, Settings.System.DEFAULT_RINGTONE_URI);
+ mediaPlayer.setDataSource(mContext, uri);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.prepare();
mediaPlayer.setLooping(true);
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/SetSystemSettingTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/SetSystemSettingTest.java
index 0fbbee1..3030e35 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/SetSystemSettingTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/SetSystemSettingTest.java
@@ -19,6 +19,7 @@
import android.os.UserHandle;
import android.provider.Settings;
+import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
/**
* Test {@link DevicePolicyManager#setSystemSetting}.
*/
@@ -36,8 +37,23 @@
}
public void testSetBrightness() {
- testSetBrightnessWithValue(TEST_BRIGHTNESS_1);
- testSetBrightnessWithValue(TEST_BRIGHTNESS_2);
+ final int mode = Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
+ if(mode == SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
+
+ mDevicePolicyManager.setSystemSetting(ADMIN_RECEIVER_COMPONENT,
+ Settings.System.SCREEN_BRIGHTNESS_MODE, "0");
+
+ testSetBrightnessWithValue(TEST_BRIGHTNESS_1);
+ testSetBrightnessWithValue(TEST_BRIGHTNESS_2);
+ mDevicePolicyManager.setSystemSetting(ADMIN_RECEIVER_COMPONENT,
+ Settings.System.SCREEN_BRIGHTNESS_MODE,
+ mode == SCREEN_BRIGHTNESS_MODE_AUTOMATIC? "1" : "0");
+ }
+ else {
+ testSetBrightnessWithValue(TEST_BRIGHTNESS_1);
+ testSetBrightnessWithValue(TEST_BRIGHTNESS_2);
+ }
}
public void testSetSystemSettingsFailsForNonWhitelistedSettings() throws Exception {
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
old mode 100644
new mode 100755
index bbe68559..3227770
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/CreateAndManageUserTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/CreateAndManageUserTest.java
@@ -379,6 +379,8 @@
localBroadcastManager.registerReceiver(broadcastReceiver,
new IntentFilter(BasicAdminReceiver.ACTION_USER_STOPPED));
+ Thread.sleep(USER_SWITCH_DELAY);
+
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 4fa6235..e5598bb 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.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 @@
*/
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 @@
private int mSavedAutoTimeConfig;
private LocalDate mSavedSystemDate;
private boolean mRestoreDate;
+ private int mSavedAirplaneMode;
@Override
protected void setUp() throws Exception {
@@ -75,6 +85,12 @@
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 @@
// 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 @@
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/src/com/android/cts/devicepolicy/CustomDeviceOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CustomDeviceOwnerTest.java
index 7b568af..eca6953 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CustomDeviceOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CustomDeviceOwnerTest.java
@@ -43,9 +43,6 @@
protected static final String ACCOUNT_MANAGEMENT_APK
= "CtsAccountManagementDevicePolicyApp.apk";
- // Dequeue time of PACKAGE_ADDED intent for two test packages.
- private static final int BROADCAST_WAIT_TIME_MILLIS = 10000; // 10 seconds
-
@Override
public void tearDown() throws Exception {
if (mHasFeature) {
@@ -75,8 +72,9 @@
assertTrue(setDeviceOwner(DEVICE_OWNER_ADMIN_COMPONENT, mPrimaryUserId,
/*expectFailure*/ false));
- // Waiting for the broadcast idle state.
- Thread.sleep(BROADCAST_WAIT_TIME_MILLIS);
+ // Wait broadcast idle to ensure the owner changed broadcast has been sent.
+ waitForBroadcastIdle();
+
runDeviceTestsAsUser(INTENT_RECEIVER_PKG, testClass,
"testOwnerChangedBroadcastReceived", mPrimaryUserId);
} finally {
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
old mode 100644
new mode 100755
index 0146826..28dd552
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
@@ -408,34 +408,42 @@
if (!mHasFeature) {
return;
}
+ // Backup stay awake setting because testGenerateLogs() will turn it off.
+ final String stayAwake = getDevice().getSetting("global", "stay_on_while_plugged_in");
+ try {
+ // Turn logging on.
+ executeDeviceTestMethod(".SecurityLoggingTest", "testEnablingSecurityLogging");
+ // Reboot to ensure ro.device_owner is set to true in logd and logging is on.
+ rebootAndWaitUntilReady();
- // Turn logging on.
- executeDeviceTestMethod(".SecurityLoggingTest", "testEnablingSecurityLogging");
- // Reboot to ensure ro.device_owner is set to true in logd and logging is on.
- rebootAndWaitUntilReady();
-
- // Generate various types of events on device side and check that they are logged.
- executeDeviceTestMethod(".SecurityLoggingTest", "testGenerateLogs");
- getDevice().executeShellCommand("dpm force-security-logs");
- executeDeviceTestMethod(".SecurityLoggingTest", "testVerifyGeneratedLogs");
-
- // Reboot the device, so the security event ids are reset.
- rebootAndWaitUntilReady();
-
- // Verify event ids are consistent across a consecutive batch.
- for (int batchNumber = 0; batchNumber < 3; batchNumber++) {
- generateDummySecurityLogs();
+ // Generate various types of events on device side and check that they are logged.
+ executeDeviceTestMethod(".SecurityLoggingTest", "testGenerateLogs");
getDevice().executeShellCommand("dpm force-security-logs");
- executeDeviceTestMethod(".SecurityLoggingTest", "testVerifyLogIds",
- Collections.singletonMap(ARG_SECURITY_LOGGING_BATCH_NUMBER,
- Integer.toString(batchNumber)));
- }
+ executeDeviceTestMethod(".SecurityLoggingTest", "testVerifyGeneratedLogs");
- // Immediately attempting to fetch events again should fail.
- executeDeviceTestMethod(".SecurityLoggingTest",
- "testSecurityLoggingRetrievalRateLimited");
- // Turn logging off.
- executeDeviceTestMethod(".SecurityLoggingTest", "testDisablingSecurityLogging");
+ // Reboot the device, so the security event ids are reset.
+ rebootAndWaitUntilReady();
+
+ // Verify event ids are consistent across a consecutive batch.
+ for (int batchNumber = 0; batchNumber < 3; batchNumber++) {
+ generateDummySecurityLogs();
+ getDevice().executeShellCommand("dpm force-security-logs");
+ executeDeviceTestMethod(".SecurityLoggingTest", "testVerifyLogIds",
+ Collections.singletonMap(ARG_SECURITY_LOGGING_BATCH_NUMBER,
+ Integer.toString(batchNumber)));
+ }
+
+ // Immediately attempting to fetch events again should fail.
+ executeDeviceTestMethod(".SecurityLoggingTest",
+ "testSecurityLoggingRetrievalRateLimited");
+ // Turn logging off.
+ executeDeviceTestMethod(".SecurityLoggingTest", "testDisablingSecurityLogging");
+ } finally {
+ // Restore stay awake setting.
+ if (stayAwake != null) {
+ getDevice().setSetting("global", "stay_on_while_plugged_in", stayAwake);
+ }
+ }
}
private void generateDummySecurityLogs() throws DeviceNotAvailableException {
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/MixedManagedProfileOwnerTestApi25.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/MixedManagedProfileOwnerTestApi25.java
index 23324a3..fd5b2bf 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/MixedManagedProfileOwnerTestApi25.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/MixedManagedProfileOwnerTestApi25.java
@@ -79,6 +79,9 @@
return;
}
+ // Make sure user initialization is complete before proceeding.
+ waitForBroadcastIdle();
+
// Lock FBE and verify resetPassword is disabled
executeDeviceTestMethod(FBE_HELPER_CLASS, "testSetPassword");
rebootAndWaitUntilReady();
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/UserActivityEmulator.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/UserActivityEmulator.java
index 0b17b17..a5fcf4e 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/UserActivityEmulator.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/UserActivityEmulator.java
@@ -30,7 +30,15 @@
public UserActivityEmulator(ITestDevice device) throws DeviceNotAvailableException {
// Figure out screen size. Output is something like "Physical size: 1440x2880".
mDevice = device;
- final String output = mDevice.executeShellCommand("wm size");
+ String outputString = mDevice.executeShellCommand ("wm size");
+
+ // In case that "Override size" follows by separator like
+ // "Physical size: 1440x2960\nOverride size: 1080x2220"
+ if (outputString.contains("Override")) {
+ outputString = outputString.split(System.getProperty("line.separator"))[1];
+ }
+
+ final String output = outputString;
final String[] sizes = output.split(" ")[2].split("x");
mWidth = Integer.valueOf(sizes[0].trim());
mHeight = Integer.valueOf(sizes[1].trim());
diff --git a/hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java b/hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java
index 65cb2a5..9234387 100644
--- a/hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java
+++ b/hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java
@@ -490,7 +490,7 @@
}
private void assertApproximateTimeInState(int index, long duration) throws Exception {
- assertValueRange("st", "", index, (long) (0.8 * duration), 2 * duration);
+ assertValueRange("st", "", index, (long) (0.7 * duration), 2 * duration);
}
/**
diff --git a/hostsidetests/jvmti/allocation-tracking/app/src/android/jvmti/cts/JvmtiTrackingTest.java b/hostsidetests/jvmti/allocation-tracking/app/src/android/jvmti/cts/JvmtiTrackingTest.java
index 7a13e79..6c22f37 100644
--- a/hostsidetests/jvmti/allocation-tracking/app/src/android/jvmti/cts/JvmtiTrackingTest.java
+++ b/hostsidetests/jvmti/allocation-tracking/app/src/android/jvmti/cts/JvmtiTrackingTest.java
@@ -22,16 +22,12 @@
import art.Main;
/**
- * Check tagging-related functionality.
+ * Check tracking-related functionality.
*/
public class JvmtiTrackingTest extends JvmtiTestBase {
@Before
public void setUp() throws Exception {
- // Bind our native methods.
- Main.bindAgentJNI("android/jvmti/cts/JvmtiTrackingTest",
- getClass().getClassLoader());
-
prefetchClassNames();
}
diff --git a/hostsidetests/jvmti/attaching/host/src/android/jvmti/cts/JvmtiAttachingHostTest.java b/hostsidetests/jvmti/attaching/host/src/android/jvmti/cts/JvmtiAttachingHostTest.java
index becabe1..9269a27 100644
--- a/hostsidetests/jvmti/attaching/host/src/android/jvmti/cts/JvmtiAttachingHostTest.java
+++ b/hostsidetests/jvmti/attaching/host/src/android/jvmti/cts/JvmtiAttachingHostTest.java
@@ -49,6 +49,7 @@
private CompatibilityBuildHelper mBuildHelper;
private IAbi mAbi;
+ private int mCurrentUser;
@Override
public void setBuild(IBuildInfo arg0) {
@@ -66,6 +67,11 @@
private final static String AGENT = "libctsjvmtiattachagent.so";
+ @Override
+ protected void setUp() throws Exception {
+ mCurrentUser = getDevice().getCurrentUser();
+ }
+
public void testJvmtiAttachDuringBind() throws Exception {
runJvmtiAgentLoadTest((ITestDevice device, String pkg, String apk, String abiName) -> {
try {
@@ -79,7 +85,8 @@
public void testJvmtiAttachEarly() throws Exception {
runJvmtiAgentLoadTest((ITestDevice device, String pkg, String apk, String abiName) -> {
try {
- String pwd = device.executeShellCommand("run-as " + pkg + " pwd");
+ String pwd = device.executeShellCommand(
+ "run-as " + pkg + " --user " + mCurrentUser + " pwd");
if (pwd == null) {
throw new RuntimeException("pwd failed");
}
@@ -125,7 +132,8 @@
public void testJvmtiAgentAppExternal() throws Exception {
runJvmtiAgentLoadTest((ITestDevice device, String pkg, String apk, String abiName) -> {
try {
- String pwd = device.executeShellCommand("run-as " + pkg + " pwd");
+ String pwd = device.executeShellCommand(
+ "run-as " + pkg + " --user " + mCurrentUser + " pwd");
if (pwd == null) {
throw new RuntimeException("pwd failed");
}
@@ -219,13 +227,14 @@
}
String runAsCp = device.executeShellCommand(
- "run-as " + pkg + " cp " + libInTmp + " " + libInDataData);
+ "run-as " + pkg + " --user " + mCurrentUser +
+ " cp " + libInTmp + " " + libInDataData);
if (runAsCp != null && !runAsCp.trim().isEmpty()) {
throw new RuntimeException(runAsCp.trim());
}
- String runAsChmod = device
- .executeShellCommand("run-as " + pkg + " chmod a+x " + libInDataData);
+ String runAsChmod = device.executeShellCommand(
+ "run-as " + pkg + " --user " + mCurrentUser + " chmod a+x " + libInDataData);
if (runAsChmod != null && !runAsChmod.trim().isEmpty()) {
throw new RuntimeException(runAsChmod.trim());
}
diff --git a/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiHostTest.java b/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiHostTest.java
index f80492c..edc685a 100644
--- a/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiHostTest.java
+++ b/hostsidetests/jvmti/base/host/src/android/jvmti/cts/JvmtiHostTest.java
@@ -59,6 +59,7 @@
private CompatibilityBuildHelper mBuildHelper;
private IAbi mAbi;
+ private int mCurrentUser;
@Override
public void setBuild(IBuildInfo arg0) {
@@ -70,6 +71,11 @@
mAbi = arg0;
}
+ @Override
+ protected void setUp() throws Exception {
+ mCurrentUser = getDevice().getCurrentUser();
+ }
+
public void testJvmti() throws Exception {
final ITestDevice device = getDevice();
@@ -123,7 +129,8 @@
@Override
public void run() {
try {
- String pwd = mDevice.executeShellCommand("run-as " + mPkg + " pwd");
+ String pwd = mDevice.executeShellCommand(
+ "run-as " + mPkg + " --user " + mCurrentUser + " pwd");
if (pwd == null) {
throw new RuntimeException("pwd failed");
}
@@ -165,13 +172,15 @@
}
String runAsCp = mDevice.executeShellCommand(
- "run-as " + mPkg + " cp " + libInTmp + " " + libInDataData);
+ "run-as " + mPkg + " --user " + mCurrentUser +
+ " cp " + libInTmp + " " + libInDataData);
if (runAsCp != null && !runAsCp.trim().isEmpty()) {
throw new RuntimeException(runAsCp.trim());
}
- String runAsChmod = mDevice
- .executeShellCommand("run-as " + mPkg + " chmod a+x " + libInDataData);
+ String runAsChmod = mDevice.executeShellCommand(
+ "run-as " + mPkg + " --user " + mCurrentUser +
+ " chmod a+x " + libInDataData);
if (runAsChmod != null && !runAsChmod.trim().isEmpty()) {
throw new RuntimeException(runAsChmod.trim());
}
diff --git a/hostsidetests/jvmti/base/jni/cts_agent.cpp b/hostsidetests/jvmti/base/jni/cts_agent.cpp
index 665a47e..3f3a836 100644
--- a/hostsidetests/jvmti/base/jni/cts_agent.cpp
+++ b/hostsidetests/jvmti/base/jni/cts_agent.cpp
@@ -25,12 +25,26 @@
namespace art {
+extern void register_art_Main(jvmtiEnv*, JNIEnv*);
+extern void register_android_jvmti_cts_JvmtiRedefineClassesTest(jvmtiEnv*, JNIEnv*);
+extern void register_android_jvmti_cts_JvmtiTaggingTest(jvmtiEnv*, JNIEnv*);
+extern void register_android_jvmti_cts_JvmtiTrackingTest(jvmtiEnv*, JNIEnv*);
+
static void InformMainAttach(jvmtiEnv* jenv,
JNIEnv* env,
const char* class_name,
const char* method_name) {
+ // Register native methods from available classes
+ // The agent is used with each test class, but we don't know which class is currently available.
+ // For that reason, we try to register the native methods in each one. Each function returns
+ // without throwing an error if the specified class can't be found.
+ register_art_Main(jenv, env);
+ register_android_jvmti_cts_JvmtiRedefineClassesTest(jenv, env);
+ register_android_jvmti_cts_JvmtiTaggingTest(jenv, env);
+ register_android_jvmti_cts_JvmtiTrackingTest(jenv, env);
+
// Use JNI to load the class.
- ScopedLocalRef<jclass> klass(env, FindClass(jenv, env, class_name, nullptr));
+ ScopedLocalRef<jclass> klass(env, GetClass(jenv, env, class_name, nullptr));
CHECK(klass.get() != nullptr) << class_name;
jmethodID method = env->GetStaticMethodID(klass.get(), method_name, "()V");
diff --git a/hostsidetests/jvmti/base/jni/redefine.cpp b/hostsidetests/jvmti/base/jni/redefine.cpp
index f96108c..1a044ca 100644
--- a/hostsidetests/jvmti/base/jni/redefine.cpp
+++ b/hostsidetests/jvmti/base/jni/redefine.cpp
@@ -23,6 +23,7 @@
#include "android-base/logging.h"
#include "android-base/macros.h"
+#include "jni_binder.h"
#include "jni_helper.h"
#include "jvmti_helper.h"
#include "jvmti.h"
@@ -172,5 +173,40 @@
env->ReleaseByteArrayElements(dex_bytes, redef_bytes, 0);
}
+static JNINativeMethod gMethods[] = {
+ { "redefineClass", "(Ljava/lang/Class;[B)I",
+ (void*)Java_android_jvmti_cts_JvmtiRedefineClassesTest_redefineClass },
+
+ { "retransformClass", "(Ljava/lang/Class;)I",
+ (void*)Java_android_jvmti_cts_JvmtiRedefineClassesTest_retransformClass },
+
+ { "setTransformationEvent", "(Z)V",
+ (void*)Java_android_jvmti_cts_JvmtiRedefineClassesTest_setTransformationEvent },
+
+ { "clearTransformations", "()V",
+ (void*)Java_android_jvmti_cts_JvmtiRedefineClassesTest_clearTransformations },
+
+ { "setPopTransformations", "(Z)V",
+ (void*)Java_android_jvmti_cts_JvmtiRedefineClassesTest_setPopTransformations },
+
+ { "pushTransformationResult", "(Ljava/lang/String;[B)V",
+ (void*)Java_android_jvmti_cts_JvmtiRedefineClassesTest_pushTransformationResult },
+};
+
+void register_android_jvmti_cts_JvmtiRedefineClassesTest(jvmtiEnv* jenv, JNIEnv* env) {
+ ScopedLocalRef<jclass> klass(env, GetClass(jenv, env,
+ "android/jvmti/cts/JvmtiRedefineClassesTest", nullptr));
+ if (klass.get() == nullptr) {
+ env->ExceptionClear();
+ return;
+ }
+
+ env->RegisterNatives(klass.get(), gMethods, sizeof(gMethods) / sizeof(JNINativeMethod));
+ if (env->ExceptionCheck()) {
+ env->ExceptionClear();
+ LOG(ERROR) << "Could not register natives for JvmtiRedefineClassesTest class";
+ }
+}
+
} // namespace art
diff --git a/hostsidetests/jvmti/base/jni/tagging.cpp b/hostsidetests/jvmti/base/jni/tagging.cpp
index 372805b..35d83d7 100644
--- a/hostsidetests/jvmti/base/jni/tagging.cpp
+++ b/hostsidetests/jvmti/base/jni/tagging.cpp
@@ -18,6 +18,7 @@
#include "android-base/logging.h"
#include "android-base/macros.h"
+#include "jni_binder.h"
#include "jni_helper.h"
#include "jvmti_helper.h"
#include "jvmti.h"
@@ -127,5 +128,48 @@
return CreateObjectArray(env, 3, "java/lang/Object", callback);
}
+static JNINativeMethod gMethodsForMain[] = {
+ { "setTag", "(Ljava/lang/Object;J)V",
+ (void*)Java_android_jvmti_cts_JniBindings_setTag },
+
+ { "getTag", "(Ljava/lang/Object;)J",
+ (void*)Java_android_jvmti_cts_JniBindings_getTag },
+};
+
+void register_art_Main(jvmtiEnv* jenv, JNIEnv* env) {
+ ScopedLocalRef<jclass> klass(env, GetClass(jenv, env, "art/Main", nullptr));
+ if (klass.get() == nullptr) {
+ env->ExceptionClear();
+ return;
+ }
+
+ env->RegisterNatives(klass.get(), gMethodsForMain,
+ sizeof(gMethodsForMain) / sizeof(JNINativeMethod));
+ if (env->ExceptionCheck()) {
+ env->ExceptionClear();
+ LOG(ERROR) << "Could not register natives for Main class";
+ }
+}
+
+static JNINativeMethod gMethods[] = {
+ { "getTaggedObjects", "([JZZ)[Ljava/lang/Object;",
+ (void*)Java_android_jvmti_cts_JvmtiTaggingTest_getTaggedObjects },
+};
+
+void register_android_jvmti_cts_JvmtiTaggingTest(jvmtiEnv* jenv, JNIEnv* env) {
+ ScopedLocalRef<jclass> klass(env, GetClass(jenv, env,
+ "android/jvmti/cts/JvmtiTaggingTest", nullptr));
+ if (klass.get() == nullptr) {
+ env->ExceptionClear();
+ return;
+ }
+
+ env->RegisterNatives(klass.get(), gMethods, sizeof(gMethods) / sizeof(JNINativeMethod));
+ if (env->ExceptionCheck()) {
+ env->ExceptionClear();
+ LOG(ERROR) << "Could not register natives for JvmtiTaggingTest class";
+ }
+}
+
} // namespace art
diff --git a/hostsidetests/jvmti/base/jni/tracking.cpp b/hostsidetests/jvmti/base/jni/tracking.cpp
index a07d653..425fd63 100644
--- a/hostsidetests/jvmti/base/jni/tracking.cpp
+++ b/hostsidetests/jvmti/base/jni/tracking.cpp
@@ -21,6 +21,7 @@
#include "android-base/logging.h"
#include "android-base/stringprintf.h"
+#include "jni_binder.h"
#include "jvmti_helper.h"
#include "scoped_local_ref.h"
#include "scoped_utf_chars.h"
@@ -93,4 +94,30 @@
return env->NewStringUTF(result.c_str());
}
+static JNINativeMethod gMethods[] = {
+ { "setupObjectAllocCallback", "(Z)V",
+ (void*)Java_android_jvmti_cts_JvmtiTrackingTest_setupObjectAllocCallback },
+
+ { "enableAllocationTracking", "(Ljava/lang/Thread;Z)V",
+ (void*)Java_android_jvmti_cts_JvmtiTrackingTest_enableAllocationTracking },
+
+ { "getAndResetAllocationTrackingString", "()Ljava/lang/String;",
+ (void*)Java_android_jvmti_cts_JvmtiTrackingTest_getAndResetAllocationTrackingString },
+};
+
+void register_android_jvmti_cts_JvmtiTrackingTest(jvmtiEnv* jenv, JNIEnv* env) {
+ ScopedLocalRef<jclass> klass(env, GetClass(jenv, env,
+ "android/jvmti/cts/JvmtiTrackingTest", nullptr));
+ if (klass.get() == nullptr) {
+ env->ExceptionClear();
+ return;
+ }
+
+ env->RegisterNatives(klass.get(), gMethods, sizeof(gMethods) / sizeof(JNINativeMethod));
+ if (env->ExceptionCheck()) {
+ env->ExceptionClear();
+ LOG(ERROR) << "Could not register natives for JvmtiTrackingTest class";
+ }
+}
+
} // namespace art
diff --git a/hostsidetests/multiuser/src/android/host/multiuser/BaseMultiUserTest.java b/hostsidetests/multiuser/src/android/host/multiuser/BaseMultiUserTest.java
index 3fcbba9..01e7795 100644
--- a/hostsidetests/multiuser/src/android/host/multiuser/BaseMultiUserTest.java
+++ b/hostsidetests/multiuser/src/android/host/multiuser/BaseMultiUserTest.java
@@ -29,13 +29,13 @@
* Base class for multi user tests.
*/
public class BaseMultiUserTest implements IDeviceTest {
- protected static final int USER_SYSTEM = 0; // From the UserHandle class.
-
/** Whether multi-user is supported. */
protected boolean mSupportsMultiUser;
protected boolean mIsSplitSystemUser;
+ protected int mInitialUserId;
protected int mPrimaryUserId;
- /** Users we shouldn't delete in the tests */
+
+ /** Users we shouldn't delete in the tests. */
private ArrayList<Integer> mFixedUsers;
private ITestDevice mDevice;
@@ -44,22 +44,21 @@
public void setUp() throws Exception {
mSupportsMultiUser = getDevice().getMaxNumberOfUsersSupported() > 1;
mIsSplitSystemUser = checkIfSplitSystemUser();
+
+ mInitialUserId = getDevice().getCurrentUser();
mPrimaryUserId = getDevice().getPrimaryUserId();
- mFixedUsers = new ArrayList<>();
- mFixedUsers.add(mPrimaryUserId);
- if (mPrimaryUserId != USER_SYSTEM) {
- mFixedUsers.add(USER_SYSTEM);
- }
- getDevice().switchUser(mPrimaryUserId);
- removeTestUsers();
+
+ // Test should not modify / remove any of the existing users.
+ mFixedUsers = getDevice().listUsers();
}
@After
public void tearDown() throws Exception {
- if (getDevice().getCurrentUser() != mPrimaryUserId) {
- CLog.w("User changed during test. Switching back to " + mPrimaryUserId);
- getDevice().switchUser(mPrimaryUserId);
+ if (getDevice().getCurrentUser() != mInitialUserId) {
+ CLog.w("User changed during test. Switching back to " + mInitialUserId);
+ getDevice().switchUser(mInitialUserId);
}
+ // Remove the users created during this test.
removeTestUsers();
}
@@ -131,4 +130,4 @@
|| "1".equals(commandOuput) || "true".equals(commandOuput)
|| "on".equals(commandOuput);
}
-}
\ No newline at end of file
+}
diff --git a/hostsidetests/multiuser/src/android/host/multiuser/CreateUsersNoAppCrashesTest.java b/hostsidetests/multiuser/src/android/host/multiuser/CreateUsersNoAppCrashesTest.java
index 9a4f829..1d8a13e 100644
--- a/hostsidetests/multiuser/src/android/host/multiuser/CreateUsersNoAppCrashesTest.java
+++ b/hostsidetests/multiuser/src/android/host/multiuser/CreateUsersNoAppCrashesTest.java
@@ -45,19 +45,11 @@
*/
@RunWith(DeviceJUnit4ClassRunner.class)
public class CreateUsersNoAppCrashesTest extends BaseMultiUserTest {
- private int mInitialUserId;
- private static final long LOGCAT_POLL_INTERVAL_MS = 5000;
+ private static final long LOGCAT_POLL_INTERVAL_MS = 1000;
private static final long USER_SWITCH_COMPLETE_TIMEOUT_MS = 180000;
@Rule public AppCrashRetryRule appCrashRetryRule = new AppCrashRetryRule();
- @Before
- public void setUp() throws Exception {
- CLog.e("setup_CreateUsersNoAppCrashesTest");
- super.setUp();
- mInitialUserId = getDevice().getCurrentUser();
- }
-
@Presubmit
@Test
public void testCanCreateGuestUser() throws Exception {
@@ -70,7 +62,6 @@
false /* ephemeral */);
assertSwitchToNewUser(userId);
assertSwitchToUser(userId, mInitialUserId);
-
}
@Presubmit
diff --git a/hostsidetests/os/src/android/os/cts/OsHostTests.java b/hostsidetests/os/src/android/os/cts/OsHostTests.java
index 086f787..c557c9e 100644
--- a/hostsidetests/os/src/android/os/cts/OsHostTests.java
+++ b/hostsidetests/os/src/android/os/cts/OsHostTests.java
@@ -86,12 +86,22 @@
*/
@AppModeFull(reason = "Error message is different for instant app (Activity does not exist)")
public void testNonExportedActivities() throws Exception {
- // Attempt to launch the non-exported activity in the test app
- CollectingOutputReceiver outputReceiver = new CollectingOutputReceiver();
- mDevice.executeShellCommand(START_NON_EXPORTED_ACTIVITY_COMMAND, outputReceiver);
- final String output = outputReceiver.getOutput();
+ // Run as unroot
+ boolean wasRoot = mDevice.isAdbRoot();
+ try {
+ mDevice.disableAdbRoot();
+ // Attempt to launch the non-exported activity in the test app
+ CollectingOutputReceiver outputReceiver = new CollectingOutputReceiver();
+ mDevice.executeShellCommand(START_NON_EXPORTED_ACTIVITY_COMMAND, outputReceiver);
+ final String output = outputReceiver.getOutput();
- assertTrue(output.contains("Permission Denial") && output.contains(" not exported"));
+ assertTrue(output.contains("Permission Denial") && output.contains(" not exported"));
+ } finally {
+ // Restore back to original root state
+ if (wasRoot) {
+ mDevice.enableAdbRoot();
+ }
+ }
}
public void testIntentFilterHostValidation() throws Exception {
diff --git a/hostsidetests/security/Android.mk b/hostsidetests/security/Android.mk
index e25b96c..cdf71dc 100644
--- a/hostsidetests/security/Android.mk
+++ b/hostsidetests/security/Android.mk
@@ -18,8 +18,6 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_RESOURCE_DIRS := res
-
LOCAL_MODULE_TAGS := optional
# tag this module as a cts test artifact
diff --git a/hostsidetests/security/AndroidTest.xml b/hostsidetests/security/AndroidTest.xml
index 1282bd02..17921bf 100755
--- a/hostsidetests/security/AndroidTest.xml
+++ b/hostsidetests/security/AndroidTest.xml
@@ -16,137 +16,6 @@
<configuration description="Config for the CTS Security host tests">
<option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="security" />
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
- <option name="cleanup" value="true" />
- <option name="push" value="CVE-2016-8460->/data/local/tmp/CVE-2016-8460" />
- <option name="push" value="CVE-2016-8482->/data/local/tmp/CVE-2016-8482" />
- <option name="push" value="CVE-2016-6730->/data/local/tmp/CVE-2016-6730" />
- <option name="push" value="CVE-2016-6731->/data/local/tmp/CVE-2016-6731" />
- <option name="push" value="CVE-2016-6732->/data/local/tmp/CVE-2016-6732" />
- <option name="push" value="CVE-2016-6733->/data/local/tmp/CVE-2016-6733" />
- <option name="push" value="CVE-2016-6734->/data/local/tmp/CVE-2016-6734" />
- <option name="push" value="CVE-2016-6735->/data/local/tmp/CVE-2016-6735" />
- <option name="push" value="CVE-2016-6736->/data/local/tmp/CVE-2016-6736" />
- <option name="push" value="CVE-2016-8424->/data/local/tmp/CVE-2016-8424" />
- <option name="push" value="CVE-2016-8425->/data/local/tmp/CVE-2016-8425" />
- <option name="push" value="CVE-2016-8426->/data/local/tmp/CVE-2016-8426" />
- <option name="push" value="CVE-2016-8427->/data/local/tmp/CVE-2016-8427" />
- <option name="push" value="CVE-2016-8428->/data/local/tmp/CVE-2016-8428" />
- <option name="push" value="CVE-2016-8429->/data/local/tmp/CVE-2016-8429" />
- <option name="push" value="CVE-2016-8430->/data/local/tmp/CVE-2016-8430" />
- <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 -->
- <option name="push" value="CVE-2016-0844->/data/local/tmp/CVE-2016-0844" />
- <option name="push" value="CVE-2016-2419->/data/local/tmp/CVE-2016-2419" />
-
- <!--__________________-->
- <!-- Bulletin 2016-05 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
- <option name="push" value="CVE-2016-2460->/data/local/tmp/CVE-2016-2460" />
-
- <!--__________________-->
- <!-- 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 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
- <option name="push" value="CVE-2016-2471->/data/local/tmp/CVE-2016-2471" />
-
- <!--__________________-->
- <!-- Bulletin 2016-10 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
-
- <!--__________________-->
- <!-- Bulletin 2016-11 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
-
- <!--__________________-->
- <!-- Bulletin 2016-12 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
-
- <!--__________________-->
- <!-- Bulletin 2017-01 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
-
- <!--__________________-->
- <!-- Bulletin 2017-02 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
- <option name="push" value="CVE-2017-0426->/data/local/tmp/CVE-2017-0426" />
-
- <!--__________________-->
- <!-- Bulletin 2017-03 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
- <option name="push" value="CVE-2017-0479->/data/local/tmp/CVE-2017-0479" />
- <option name="push" value="CVE-2017-0334->/data/local/tmp/CVE-2017-0334" />
- <option name="push" value="CVE-2016-8479->/data/local/tmp/CVE-2016-8479" />
- <option name="push" value="CVE-2017-0508->/data/local/tmp/CVE-2017-0508" />
- <option name="push" value="CVE-2017-0333->/data/local/tmp/CVE-2017-0333" />
-
- <!--__________________-->
- <!-- Bulletin 2017-04 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
- <option name="push" value="CVE-2016-10229->/data/local/tmp/CVE-2016-10229" />
- <option name="push" value="CVE-2014-3145->/data/local/tmp/CVE-2014-3145"/>
- <option name="push" value="CVE-2017-0553->/data/local/tmp/CVE-2017-0553"/>
-
- <!--__________________-->
- <!-- Bulletin 2017-05 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
-
- <!--__________________-->
- <!-- Bulletin 2017-06 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
-
- <!--__________________-->
- <!-- Bulletin 2017-07 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
- <option name="push" value="CVE-2016-2109->/data/local/tmp/CVE-2016-2109"/>
-
- <!--__________________-->
- <!-- Bulletin 2017-08 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
-
- <!--__________________-->
- <!-- Bulletin 2017-09 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
- <option name="push" value="Bug-38195738->/data/local/tmp/Bug-38195738" />
-
- <!--__________________-->
- <!-- Bulletin 2017-10 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
-
- <!--__________________-->
- <!-- Bulletin 2017-11 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
-
- <!--__________________-->
- <!-- Bulletin 2017-12 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
- <option name="push" value="CVE-2017-6262->/data/local/tmp/CVE-2017-6262" />
-
- <!--__________________-->
- <!-- Bulletin 2018-01 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
-
- <!--__________________-->
- <!-- Bulletin 2018-02 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
- <option name="push" value="CVE-2017-13232->/data/local/tmp/CVE-2017-13232" />
-
- <!--__________________-->
- <!-- Bulletin 2018-03 -->
- <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
- <option name="push" value="CVE-2017-13253->/data/local/tmp/CVE-2017-13253" />
-
- <option name="append-bitness" value="true" />
- </target_preparer>
<test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
<option name="jar" value="CtsSecurityHostTestCases.jar" />
diff --git a/hostsidetests/security/res/add-debug.apk b/hostsidetests/security/res/add-debug.apk
deleted file mode 100644
index dff9cb6..0000000
--- a/hostsidetests/security/res/add-debug.apk
+++ /dev/null
Binary files differ
diff --git a/hostsidetests/security/res/crash_mod.apk b/hostsidetests/security/res/crash_mod.apk
deleted file mode 100644
index 4991294..0000000
--- a/hostsidetests/security/res/crash_mod.apk
+++ /dev/null
Binary files differ
diff --git a/hostsidetests/security/res/poc b/hostsidetests/security/res/poc
deleted file mode 100644
index 8b6f012..0000000
--- a/hostsidetests/security/res/poc
+++ /dev/null
Binary files differ
diff --git a/hostsidetests/security/res/test-case b/hostsidetests/security/res/test-case
deleted file mode 100644
index bac4af1..0000000
--- a/hostsidetests/security/res/test-case
+++ /dev/null
Binary files differ
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8424/Android.mk b/hostsidetests/security/securityPatch/CVE-2016-8424/Android.mk
deleted file mode 100644
index 204ace1..0000000
--- a/hostsidetests/security/securityPatch/CVE-2016-8424/Android.mk
+++ /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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := CVE-2016-8424
-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 general-tests sts
-LOCAL_CTS_TEST_PACKAGE := android.security.cts
-
-LOCAL_ARM_MODE := arm
-LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
-LOCAL_CFLAGS += -Wno-incompatible-pointer-types -Wno-unused-variable
-LOCAL_LDFLAGS += -fPIE -pie
-include $(BUILD_CTS_EXECUTABLE)
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8424/poc.c b/hostsidetests/security/securityPatch/CVE-2016-8424/poc.c
deleted file mode 100644
index 4460b88..0000000
--- a/hostsidetests/security/securityPatch/CVE-2016-8424/poc.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2017 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 <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <dirent.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <stdio.h>
-#include <string.h>
-#include <dlfcn.h>
-#include <sys/time.h>
-#include <sys/mman.h>
-#include <sys/syscall.h>
-#include <sys/resource.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <sched.h>
-
-
-struct nvmap_handle_param {
- __u32 handle; /* nvmap handle */
- __u32 param; /* size/align/base/heap etc. */
- unsigned long result; /* returns requested info*/
-};
-
-struct nvmap_create_handle {
- union {
- __u32 id; /* FromId */
- __u32 size; /* CreateHandle */
- __s32 fd; /* DmaBufFd or FromFd */
- };
- __u32 handle; /* returns nvmap handle */
-};
-
-#define NVMAP_IOC_MAGIC 'N'
-#define NVMAP_IOC_CREATE _IOWR(NVMAP_IOC_MAGIC, 0, struct nvmap_create_handle)
-#define NVMAP_IOC_PARAM _IOWR(NVMAP_IOC_MAGIC, 8, struct nvmap_handle_param)
-#define NVMAP_IOC_GET_ID _IOWR(NVMAP_IOC_MAGIC, 13, struct nvmap_create_handle)
-#define NVMAP_IOC_GET_FD _IOWR(NVMAP_IOC_MAGIC, 15, struct nvmap_create_handle)
-#define NVMAP_IOC_FREE _IO(NVMAP_IOC_MAGIC, 4)
-
-int g_fd = -1;
-static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-struct nvmap_create_handle* g_allocation = NULL;
-
-int open_driver() {
- char* dev_path = "/dev/nvmap";
- g_fd = open(dev_path, O_RDWR);
- if (g_fd < 0) {
- printf("[*] open file(%s) failed, errno=%d\n", dev_path, errno);
- } else {
- printf("[*] open file(%s) succ!\n", dev_path);
- }
- return g_fd;
-}
-
-void trigger_nvmap_create() {
- ioctl(g_fd, NVMAP_IOC_CREATE, g_allocation);
- //printf("[*] NVMAP_IOC_CREATE, fd(%d), last error = %d\n", g_allocation->handle, errno);
-}
-
-void trigger_nvmap_free() {
- static int data = 1024;
- ioctl(g_fd, NVMAP_IOC_FREE, data);
- //printf("[*] NVMAP_IOC_FREE last error = %d\n", errno);
-}
-
-void setup_privi_and_affinity(int privi, unsigned long cpu_mask) {
- setpriority(PRIO_PROCESS, gettid(), privi);
- printf("[*] setpriority(%d) errno = %d\n", privi, errno);
-
- /* bind process to a CPU*/
- if (sched_setaffinity(gettid(), sizeof(cpu_mask), &cpu_mask) < 0) {
- printf("[*] sched_setaffinity(%ld) errno = %d\n", cpu_mask, errno);
- }
-}
-
-void prepare_data() {
- void* data = calloc(1, 0x1000);
-
- g_allocation = (struct nvmap_create_handle*)data;
- g_allocation->size = 1024;
-
- mprotect(data, 0x1000, PROT_READ);
- printf("[*] mprotect, error = %d\n", errno);
-}
-static int init = 0;
-void* race_thread(void* arg) {
- setup_privi_and_affinity(0, 2);
-
- int i;
- while (1) {
- if (init == 0) {
- pthread_mutex_lock(&mutex);
- pthread_cond_wait(&cond, &mutex);
- pthread_mutex_unlock(&mutex);
- init = 1;
- }
- trigger_nvmap_free();
- }
-}
-
-int main(int argc, char**argv) {
- setup_privi_and_affinity(0, 1);
- if (open_driver() < 0) {
- return -1;
- }
- prepare_data();
- pthread_t tid;
- pthread_create(&tid, NULL, race_thread, NULL);
- sleep(1);
- while (1) {
- if (init == 0)
- pthread_cond_signal(&cond);
- trigger_nvmap_create();
- }
- return 0;
-}
diff --git a/hostsidetests/security/src/android/security/cts/KernelConfigTest.java b/hostsidetests/security/src/android/security/cts/KernelConfigTest.java
index 00962d0..09bee64 100644
--- a/hostsidetests/security/src/android/security/cts/KernelConfigTest.java
+++ b/hostsidetests/security/src/android/security/cts/KernelConfigTest.java
@@ -108,7 +108,7 @@
*
* @throws Exception
*/
- @CddTest(requirement="9.7")
+ @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",
@@ -121,8 +121,11 @@
*
* @throws Exception
*/
- @CddTest(requirement="9.7")
+ @CddTest(requirement="9.7/C-0-8")
public void testConfigROData() throws Exception {
+ if (configSet.contains("CONFIG_UH_RKP=y"))
+ return;
+
assertTrue("Linux kernel must have RO data enabled: " +
"CONFIG_DEBUG_RODATA=y or CONFIG_STRICT_KERNEL_RWX=y",
configSet.contains("CONFIG_DEBUG_RODATA=y") ||
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_01.java b/hostsidetests/security/src/android/security/cts/Poc17_01.java
deleted file mode 100644
index 4fd98b7..0000000
--- a/hostsidetests/security/src/android/security/cts/Poc17_01.java
+++ /dev/null
@@ -1,33 +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 android.security.cts;
-
-import android.platform.test.annotations.SecurityTest;
-
-@SecurityTest
-public class Poc17_01 extends SecurityTestCase {
-
- /**
- * b/31799863
- */
- @SecurityTest
- public void testPocCVE_2016_8482() throws Exception {
- if(containsDriver(getDevice(), "/dev/nvmap")) {
- AdbUtils.runPoc("CVE-2016-8482", getDevice(), 60);
- }
- }
-}
diff --git a/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java b/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java
index d3f4001..0041563 100644
--- a/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java
+++ b/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java
@@ -386,7 +386,8 @@
*/
public static boolean isFullTrebleDevice(ITestDevice device)
throws DeviceNotAvailableException {
- return PropertyUtil.getFirstApiLevel(device) > 26;
+ return PropertyUtil.getFirstApiLevel(device) > 26 &&
+ PropertyUtil.propertyEquals(device, "ro.treble.enabled", "true");
}
private boolean isFullTrebleDevice() throws DeviceNotAvailableException {
@@ -399,7 +400,8 @@
*/
public static boolean isCompatiblePropertyEnforcedDevice(ITestDevice device)
throws DeviceNotAvailableException {
- return PropertyUtil.getFirstApiLevel(device) > 27;
+ return PropertyUtil.propertyEquals(
+ device, "ro.actionable_compatible_property.enabled", "true");
}
// NOTE: cts/tools/selinux depends on this method. Rename/change with caution.
diff --git a/hostsidetests/securitybulletin/Android.mk b/hostsidetests/securitybulletin/Android.mk
new file mode 100644
index 0000000..a07fbbd
--- /dev/null
+++ b/hostsidetests/securitybulletin/Android.mk
@@ -0,0 +1,39 @@
+# Copyright (C) 2014 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_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_JAVA_RESOURCE_DIRS := res
+
+LOCAL_MODULE_TAGS := optional
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+
+# Must match the package name in CtsTestCaseList.mk
+LOCAL_MODULE := CtsSecurityBulletinHostTestCases
+
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed compatibility-host-util
+
+LOCAL_CTS_TEST_PACKAGE := android.host.security
+
+include $(BUILD_CTS_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/securitybulletin/AndroidTest.xml b/hostsidetests/securitybulletin/AndroidTest.xml
new file mode 100644
index 0000000..f40737f
--- /dev/null
+++ b/hostsidetests/securitybulletin/AndroidTest.xml
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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 the CTS Security bulletin host tests">
+ <option name="test-suite-tag" value="cts" />
+ <option name="config-descriptor:metadata" key="component" value="security" />
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+ <option name="cleanup" value="true" />
+ <option name="push" value="CVE-2016-8460->/data/local/tmp/CVE-2016-8460" />
+ <option name="push" value="CVE-2016-8482->/data/local/tmp/CVE-2016-8482" />
+ <option name="push" value="CVE-2016-6730->/data/local/tmp/CVE-2016-6730" />
+ <option name="push" value="CVE-2016-6731->/data/local/tmp/CVE-2016-6731" />
+ <option name="push" value="CVE-2016-6732->/data/local/tmp/CVE-2016-6732" />
+ <option name="push" value="CVE-2016-6733->/data/local/tmp/CVE-2016-6733" />
+ <option name="push" value="CVE-2016-6734->/data/local/tmp/CVE-2016-6734" />
+ <option name="push" value="CVE-2016-6735->/data/local/tmp/CVE-2016-6735" />
+ <option name="push" value="CVE-2016-6736->/data/local/tmp/CVE-2016-6736" />
+ <option name="push" value="CVE-2016-8425->/data/local/tmp/CVE-2016-8425" />
+ <option name="push" value="CVE-2016-8426->/data/local/tmp/CVE-2016-8426" />
+ <option name="push" value="CVE-2016-8427->/data/local/tmp/CVE-2016-8427" />
+ <option name="push" value="CVE-2016-8428->/data/local/tmp/CVE-2016-8428" />
+ <option name="push" value="CVE-2016-8429->/data/local/tmp/CVE-2016-8429" />
+ <option name="push" value="CVE-2016-8430->/data/local/tmp/CVE-2016-8430" />
+ <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 -->
+ <option name="push" value="CVE-2016-0844->/data/local/tmp/CVE-2016-0844" />
+ <option name="push" value="CVE-2016-2419->/data/local/tmp/CVE-2016-2419" />
+
+ <!--__________________-->
+ <!-- Bulletin 2016-05 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+ <option name="push" value="CVE-2016-2460->/data/local/tmp/CVE-2016-2460" />
+
+ <!--__________________-->
+ <!-- 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 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+ <option name="push" value="CVE-2016-2471->/data/local/tmp/CVE-2016-2471" />
+
+ <!--__________________-->
+ <!-- Bulletin 2016-10 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+
+ <!--__________________-->
+ <!-- Bulletin 2016-11 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+
+ <!--__________________-->
+ <!-- Bulletin 2016-12 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+
+ <!--__________________-->
+ <!-- Bulletin 2017-01 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+
+ <!--__________________-->
+ <!-- Bulletin 2017-02 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+ <option name="push" value="CVE-2017-0426->/data/local/tmp/CVE-2017-0426" />
+
+ <!--__________________-->
+ <!-- Bulletin 2017-03 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+ <option name="push" value="CVE-2017-0479->/data/local/tmp/CVE-2017-0479" />
+ <option name="push" value="CVE-2017-0334->/data/local/tmp/CVE-2017-0334" />
+ <option name="push" value="CVE-2016-8479->/data/local/tmp/CVE-2016-8479" />
+ <option name="push" value="CVE-2017-0508->/data/local/tmp/CVE-2017-0508" />
+ <option name="push" value="CVE-2017-0333->/data/local/tmp/CVE-2017-0333" />
+
+ <!--__________________-->
+ <!-- Bulletin 2017-04 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+ <option name="push" value="CVE-2016-10229->/data/local/tmp/CVE-2016-10229" />
+ <option name="push" value="CVE-2014-3145->/data/local/tmp/CVE-2014-3145"/>
+ <option name="push" value="CVE-2017-0553->/data/local/tmp/CVE-2017-0553"/>
+
+ <!--__________________-->
+ <!-- Bulletin 2017-05 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+
+ <!--__________________-->
+ <!-- Bulletin 2017-06 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+
+ <!--__________________-->
+ <!-- Bulletin 2017-07 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+ <option name="push" value="CVE-2016-2109->/data/local/tmp/CVE-2016-2109"/>
+
+ <!--__________________-->
+ <!-- Bulletin 2017-08 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+
+ <!--__________________-->
+ <!-- Bulletin 2017-09 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+ <option name="push" value="Bug-38195738->/data/local/tmp/Bug-38195738" />
+
+ <!--__________________-->
+ <!-- Bulletin 2017-10 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+
+ <!--__________________-->
+ <!-- Bulletin 2017-11 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+
+ <!--__________________-->
+ <!-- Bulletin 2017-12 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+ <option name="push" value="CVE-2017-6262->/data/local/tmp/CVE-2017-6262" />
+
+ <!--__________________-->
+ <!-- Bulletin 2018-01 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+
+ <!--__________________-->
+ <!-- Bulletin 2018-02 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+ <option name="push" value="CVE-2017-13232->/data/local/tmp/CVE-2017-13232" />
+
+ <!--__________________-->
+ <!-- Bulletin 2018-03 -->
+ <!-- Please add tests solely from this bulletin below to avoid merge conflict -->
+ <option name="push" value="CVE-2017-13253->/data/local/tmp/CVE-2017-13253" />
+
+ <option name="append-bitness" value="true" />
+ </target_preparer>
+
+ <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+ <option name="jar" value="CtsSecurityBulletinHostTestCases.jar" />
+ <option name="runtime-hint" value="8m40s" />
+ </test>
+</configuration>
diff --git a/hostsidetests/security/res/cve_2016_3916.apk b/hostsidetests/securitybulletin/res/cve_2016_3916.apk
similarity index 100%
rename from hostsidetests/security/res/cve_2016_3916.apk
rename to hostsidetests/securitybulletin/res/cve_2016_3916.apk
Binary files differ
diff --git a/hostsidetests/security/res/cve_2017_0859.mp4 b/hostsidetests/securitybulletin/res/cve_2017_0859.mp4
similarity index 100%
rename from hostsidetests/security/res/cve_2017_0859.mp4
rename to hostsidetests/securitybulletin/res/cve_2017_0859.mp4
Binary files differ
diff --git a/hostsidetests/security/securityPatch/Android.mk b/hostsidetests/securitybulletin/securityPatch/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/Android.mk
diff --git a/hostsidetests/security/securityPatch/Bug-38195738/Android.mk b/hostsidetests/securitybulletin/securityPatch/Bug-38195738/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/Bug-38195738/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/Bug-38195738/Android.mk
diff --git a/hostsidetests/security/securityPatch/Bug-38195738/poc.c b/hostsidetests/securitybulletin/securityPatch/Bug-38195738/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/Bug-38195738/poc.c
rename to hostsidetests/securitybulletin/securityPatch/Bug-38195738/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2014-3145/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2014-3145/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2014-3145/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2014-3145/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2014-3145/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2014-3145/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2014-3145/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2014-3145/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-0844/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-0844/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-0844/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-0844/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-0844/local_poc.h b/hostsidetests/securitybulletin/securityPatch/CVE-2016-0844/local_poc.h
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-0844/local_poc.h
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-0844/local_poc.h
diff --git a/hostsidetests/security/securityPatch/CVE-2016-0844/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-0844/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-0844/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-0844/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-10229/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-10229/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-10229/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-10229/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-10229/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-10229/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-10229/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-10229/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-2109/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2109/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-2109/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-2109/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-2109/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2109/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-2109/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-2109/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-2419/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2419/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-2419/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-2419/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-2419/poc.cpp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2419/poc.cpp
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-2419/poc.cpp
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-2419/poc.cpp
diff --git a/hostsidetests/security/securityPatch/CVE-2016-2460/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2460/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-2460/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-2460/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-2460/poc.cpp b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2460/poc.cpp
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-2460/poc.cpp
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-2460/poc.cpp
diff --git a/hostsidetests/security/securityPatch/CVE-2016-2471/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2471/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-2471/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-2471/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-2471/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2471/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-2471/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-2471/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-2504/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2504/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-2504/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-2504/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-2504/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-2504/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-2504/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-2504/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-3809/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-3809/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-3809/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-3809/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-3809/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-3809/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-3809/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-3809/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-3818/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-3818/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-3818/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-3818/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-3818/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-3818/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-3818/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-3818/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6730/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6730/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-6730/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-6730/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6730/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6730/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-6730/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-6730/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6731/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6731/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-6731/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-6731/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6731/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6731/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-6731/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-6731/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6732/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6732/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-6732/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-6732/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6732/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6732/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-6732/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-6732/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6733/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6733/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-6733/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-6733/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6733/local_pwn.h b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6733/local_pwn.h
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-6733/local_pwn.h
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-6733/local_pwn.h
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6733/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6733/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-6733/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-6733/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6734/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6734/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-6734/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-6734/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6734/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6734/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-6734/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-6734/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6735/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6735/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-6735/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-6735/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6735/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6735/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-6735/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-6735/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6736/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6736/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-6736/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-6736/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-6736/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-6736/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-6736/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-6736/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8425/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8425/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8425/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8425/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8425/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8425/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8425/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8425/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8426/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8426/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8426/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8426/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8426/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8426/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8426/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8426/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8427/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8427/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8427/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8427/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8427/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8427/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8427/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8427/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8428/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8428/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8428/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8428/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8428/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8428/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8428/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8428/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8429/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8429/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8429/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8429/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8429/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8429/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8429/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8429/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8430/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8430/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8430/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8430/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8430/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8430/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8430/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8430/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8431/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8431/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8431/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8431/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8431/local_poc.h b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8431/local_poc.h
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8431/local_poc.h
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8431/local_poc.h
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8431/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8431/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8431/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8431/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8432/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8432/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8432/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8432/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8432/local_poc.h b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8432/local_poc.h
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8432/local_poc.h
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8432/local_poc.h
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8432/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8432/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8432/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8432/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8434/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8434/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8434/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8434/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8434/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8434/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8434/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8434/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8460/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8460/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8460/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8460/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8460/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8460/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8460/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8460/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8479/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8479/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8479/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8479/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8479/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8479/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8479/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8479/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8482/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8482/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8482/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8482/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2016-8482/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2016-8482/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2016-8482/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2016-8482/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0333/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-0333/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0333/local_poc.h b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/local_poc.h
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-0333/local_poc.h
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/local_poc.h
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0333/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-0333/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-0333/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0334/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0334/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-0334/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-0334/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0334/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0334/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-0334/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-0334/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0426/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0426/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-0426/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-0426/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0426/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0426/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-0426/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-0426/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0479/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0479/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-0479/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-0479/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0479/poc.cpp b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0479/poc.cpp
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-0479/poc.cpp
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-0479/poc.cpp
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0508/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0508/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-0508/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-0508/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0508/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0508/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-0508/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-0508/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0553/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0553/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-0553/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-0553/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2017-0553/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2017-0553/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-0553/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-0553/poc.c
diff --git a/hostsidetests/security/securityPatch/CVE-2017-13232/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-13232/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-13232/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-13232/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2017-13232/poc.cpp b/hostsidetests/securitybulletin/securityPatch/CVE-2017-13232/poc.cpp
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-13232/poc.cpp
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-13232/poc.cpp
diff --git a/hostsidetests/security/securityPatch/CVE-2017-13253/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-13253/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-13253/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-13253/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2017-13253/poc.cpp b/hostsidetests/securitybulletin/securityPatch/CVE-2017-13253/poc.cpp
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-13253/poc.cpp
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-13253/poc.cpp
diff --git a/hostsidetests/security/securityPatch/CVE-2017-6262/Android.mk b/hostsidetests/securitybulletin/securityPatch/CVE-2017-6262/Android.mk
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-6262/Android.mk
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-6262/Android.mk
diff --git a/hostsidetests/security/securityPatch/CVE-2017-6262/local_poc.h b/hostsidetests/securitybulletin/securityPatch/CVE-2017-6262/local_poc.h
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-6262/local_poc.h
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-6262/local_poc.h
diff --git a/hostsidetests/security/securityPatch/CVE-2017-6262/poc.c b/hostsidetests/securitybulletin/securityPatch/CVE-2017-6262/poc.c
similarity index 100%
rename from hostsidetests/security/securityPatch/CVE-2017-6262/poc.c
rename to hostsidetests/securitybulletin/securityPatch/CVE-2017-6262/poc.c
diff --git a/hostsidetests/security/src/android/security/cts/AdbUtils.java b/hostsidetests/securitybulletin/src/android/security/cts/AdbUtils.java
similarity index 100%
rename from hostsidetests/security/src/android/security/cts/AdbUtils.java
rename to hostsidetests/securitybulletin/src/android/security/cts/AdbUtils.java
diff --git a/hostsidetests/security/src/android/security/cts/Poc16_04.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_04.java
similarity index 100%
rename from hostsidetests/security/src/android/security/cts/Poc16_04.java
rename to hostsidetests/securitybulletin/src/android/security/cts/Poc16_04.java
diff --git a/hostsidetests/security/src/android/security/cts/Poc16_05.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_05.java
similarity index 100%
rename from hostsidetests/security/src/android/security/cts/Poc16_05.java
rename to hostsidetests/securitybulletin/src/android/security/cts/Poc16_05.java
diff --git a/hostsidetests/security/src/android/security/cts/Poc16_07.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_07.java
similarity index 100%
rename from hostsidetests/security/src/android/security/cts/Poc16_07.java
rename to hostsidetests/securitybulletin/src/android/security/cts/Poc16_07.java
diff --git a/hostsidetests/security/src/android/security/cts/Poc16_08.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_08.java
similarity index 100%
rename from hostsidetests/security/src/android/security/cts/Poc16_08.java
rename to hostsidetests/securitybulletin/src/android/security/cts/Poc16_08.java
diff --git a/hostsidetests/security/src/android/security/cts/Poc16_09.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_09.java
similarity index 100%
rename from hostsidetests/security/src/android/security/cts/Poc16_09.java
rename to hostsidetests/securitybulletin/src/android/security/cts/Poc16_09.java
diff --git a/hostsidetests/securitybulletin/src/android/security/cts/Poc16_10.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_10.java
new file mode 100644
index 0000000..158071d
--- /dev/null
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_10.java
@@ -0,0 +1,40 @@
+/**
+ * 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 android.security.cts;
+
+import android.platform.test.annotations.SecurityTest;
+
+@SecurityTest
+public class Poc16_10 extends SecurityTestCase {
+
+ /**
+ * b/30741779
+ */
+ @SecurityTest
+ public void testPocCVE_2016_3916() throws Exception {
+ AdbUtils.installApk("/cve_2016_3916.apk", getDevice());
+ AdbUtils.runCommandLine("logcat -c" , getDevice());
+
+ AdbUtils.runCommandLine("am start -n com.trendmicro.wish_wu.camera2/" +
+ "com.trendmicro.wish_wu.camera2.Camera2TestActivity", getDevice());
+ Thread.sleep(10000);
+ String logcat = AdbUtils.runCommandLine("logcat -d", getDevice());
+ assertNotMatches("[\\s\\n\\S]*Fatal signal 11 \\(SIGSEGV\\)" +
+ "[\\s\\n\\S]*>>> /system/bin/" +
+ "mediaserver <<<[\\s\\n\\S]*", logcat);
+ }
+}
diff --git a/hostsidetests/security/src/android/security/cts/Poc16_10.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_11.java
similarity index 76%
rename from hostsidetests/security/src/android/security/cts/Poc16_10.java
rename to hostsidetests/securitybulletin/src/android/security/cts/Poc16_11.java
index 5641aee..da8da31 100644
--- a/hostsidetests/security/src/android/security/cts/Poc16_10.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc16_11.java
@@ -19,7 +19,7 @@
import android.platform.test.annotations.SecurityTest;
@SecurityTest
-public class Poc16_10 extends SecurityTestCase {
+public class Poc16_11 extends SecurityTestCase {
/**
* b/30904789
@@ -90,21 +90,4 @@
AdbUtils.runPoc("CVE-2016-6736", getDevice(), 60);
}
}
-
- /**
- * b/30741779
- */
- @SecurityTest
- public void testPocCVE_2016_3916() throws Exception {
- AdbUtils.installApk("/cve_2016_3916.apk", getDevice());
- AdbUtils.runCommandLine("logcat -c" , getDevice());
-
- AdbUtils.runCommandLine("am start -n com.trendmicro.wish_wu.camera2/" +
- "com.trendmicro.wish_wu.camera2.Camera2TestActivity", getDevice());
- Thread.sleep(10000);
- String logcat = AdbUtils.runCommandLine("logcat -d", getDevice());
- assertNotMatches("[\\s\\n\\S]*Fatal signal 11 \\(SIGSEGV\\)" +
- "[\\s\\n\\S]*>>> /system/bin/" +
- "mediaserver <<<[\\s\\n\\S]*", logcat);
- }
}
diff --git a/hostsidetests/security/src/android/security/cts/Poc16_12.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_01.java
similarity index 92%
rename from hostsidetests/security/src/android/security/cts/Poc16_12.java
rename to hostsidetests/securitybulletin/src/android/security/cts/Poc17_01.java
index 8ae30d6..3446507 100644
--- a/hostsidetests/security/src/android/security/cts/Poc16_12.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_01.java
@@ -19,20 +19,10 @@
import android.platform.test.annotations.SecurityTest;
@SecurityTest
-public class Poc16_12 extends SecurityTestCase {
+public class Poc17_01 extends SecurityTestCase {
//Criticals
/**
- * b/31606947
- */
- @SecurityTest
- public void testPocCVE_2016_8424() throws Exception {
- if(containsDriver(getDevice(), "/dev/nvmap")) {
- AdbUtils.runPoc("CVE-2016-8424", getDevice(), 60);
- }
- }
-
- /**
* b/31797770
*/
@SecurityTest
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_02.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_02.java
similarity index 82%
rename from hostsidetests/security/src/android/security/cts/Poc17_02.java
rename to hostsidetests/securitybulletin/src/android/security/cts/Poc17_02.java
index 44f7d27..fc68707 100644
--- a/hostsidetests/security/src/android/security/cts/Poc17_02.java
+++ b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_02.java
@@ -29,4 +29,14 @@
String logcatOut = AdbUtils.runCommandLine("logcat -d", getDevice());
assertNotMatches("[\\s\\n\\S]*Bugreports file in wrong path[\\s\\n\\S]*", logcatOut);
}
+
+ /**
+ * b/31799863
+ */
+ @SecurityTest
+ public void testPocCVE_2016_8482() throws Exception {
+ if(containsDriver(getDevice(), "/dev/nvmap")) {
+ AdbUtils.runPoc("CVE-2016-8482", getDevice(), 60);
+ }
+ }
}
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_03.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_03.java
similarity index 100%
rename from hostsidetests/security/src/android/security/cts/Poc17_03.java
rename to hostsidetests/securitybulletin/src/android/security/cts/Poc17_03.java
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_04.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_04.java
similarity index 100%
rename from hostsidetests/security/src/android/security/cts/Poc17_04.java
rename to hostsidetests/securitybulletin/src/android/security/cts/Poc17_04.java
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_05.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_05.java
similarity index 100%
rename from hostsidetests/security/src/android/security/cts/Poc17_05.java
rename to hostsidetests/securitybulletin/src/android/security/cts/Poc17_05.java
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_07.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_07.java
similarity index 100%
rename from hostsidetests/security/src/android/security/cts/Poc17_07.java
rename to hostsidetests/securitybulletin/src/android/security/cts/Poc17_07.java
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_09.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_09.java
similarity index 100%
rename from hostsidetests/security/src/android/security/cts/Poc17_09.java
rename to hostsidetests/securitybulletin/src/android/security/cts/Poc17_09.java
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_11.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_11.java
similarity index 100%
rename from hostsidetests/security/src/android/security/cts/Poc17_11.java
rename to hostsidetests/securitybulletin/src/android/security/cts/Poc17_11.java
diff --git a/hostsidetests/security/src/android/security/cts/Poc17_12.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc17_12.java
similarity index 100%
rename from hostsidetests/security/src/android/security/cts/Poc17_12.java
rename to hostsidetests/securitybulletin/src/android/security/cts/Poc17_12.java
diff --git a/hostsidetests/security/src/android/security/cts/Poc18_02.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc18_02.java
similarity index 100%
rename from hostsidetests/security/src/android/security/cts/Poc18_02.java
rename to hostsidetests/securitybulletin/src/android/security/cts/Poc18_02.java
diff --git a/hostsidetests/security/src/android/security/cts/Poc18_03.java b/hostsidetests/securitybulletin/src/android/security/cts/Poc18_03.java
similarity index 100%
rename from hostsidetests/security/src/android/security/cts/Poc18_03.java
rename to hostsidetests/securitybulletin/src/android/security/cts/Poc18_03.java
diff --git a/hostsidetests/security/src/android/security/cts/SecurityTestCase.java b/hostsidetests/securitybulletin/src/android/security/cts/SecurityTestCase.java
similarity index 100%
rename from hostsidetests/security/src/android/security/cts/SecurityTestCase.java
rename to hostsidetests/securitybulletin/src/android/security/cts/SecurityTestCase.java
diff --git a/hostsidetests/statsd/src/android/cts/statsd/atom/AtomTestCase.java b/hostsidetests/statsd/src/android/cts/statsd/atom/AtomTestCase.java
index 225ebf5..02bc735 100644
--- a/hostsidetests/statsd/src/android/cts/statsd/atom/AtomTestCase.java
+++ b/hostsidetests/statsd/src/android/cts/statsd/atom/AtomTestCase.java
@@ -654,4 +654,11 @@
return hasIt == requiredAnswer;
}
+ /**
+ * Determines if the device has |file|.
+ */
+ protected boolean doesFileExist(String file) throws Exception {
+ return getDevice().doesFileExist(file);
+ }
+
}
diff --git a/hostsidetests/statsd/src/android/cts/statsd/atom/HostAtomTests.java b/hostsidetests/statsd/src/android/cts/statsd/atom/HostAtomTests.java
index 71fac10..cc3b47c 100644
--- a/hostsidetests/statsd/src/android/cts/statsd/atom/HostAtomTests.java
+++ b/hostsidetests/statsd/src/android/cts/statsd/atom/HostAtomTests.java
@@ -31,6 +31,7 @@
import com.android.os.AtomsProto.RemainingBatteryCapacity;
import com.android.os.StatsLog.EventMetricData;
+import java.io.File;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
@@ -48,6 +49,10 @@
private static final String FEATURE_TELEPHONY = "android.hardware.telephony";
private static final String FEATURE_WATCH = "android.hardware.type.watch";
+ // Either file must exist to read kernel wake lock stats.
+ private static final String WAKE_LOCK_FILE = "/proc/wakelocks";
+ private static final String WAKE_SOURCES_FILE = "/d/wakeup_sources";
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -382,7 +387,7 @@
}
public void testKernelWakelock() throws Exception {
- if (statsdDisabled()) {
+ if (statsdDisabled() || !kernelWakelockStatsExist()) {
return;
}
StatsdConfig.Builder config = getPulledConfig();
@@ -408,6 +413,15 @@
assertTrue(atom.getKernelWakelock().hasTime());
}
+ // Returns true iff either |WAKE_LOCK_FILE| or |WAKE_SOURCES_FILE| exists.
+ private boolean kernelWakelockStatsExist() {
+ try {
+ return doesFileExist(WAKE_LOCK_FILE) || doesFileExist(WAKE_SOURCES_FILE);
+ } catch(Exception e) {
+ return false;
+ }
+ }
+
public void testWifiActivityInfo() throws Exception {
if (statsdDisabled()) {
return;
diff --git a/hostsidetests/statsd/src/android/cts/statsd/atom/UidAtomTests.java b/hostsidetests/statsd/src/android/cts/statsd/atom/UidAtomTests.java
index a8e4574..331872d 100644
--- a/hostsidetests/statsd/src/android/cts/statsd/atom/UidAtomTests.java
+++ b/hostsidetests/statsd/src/android/cts/statsd/atom/UidAtomTests.java
@@ -228,7 +228,7 @@
Thread.sleep(WAIT_TIME_SHORT);
setAppBreadcrumbPredicate();
- Thread.sleep(WAIT_TIME_SHORT);
+ Thread.sleep(WAIT_TIME_LONG);
List<Atom> atomList = getGaugeMetricDataList();
diff --git a/hostsidetests/theme/app/src/android/theme/app/ThemeDeviceActivity.java b/hostsidetests/theme/app/src/android/theme/app/ThemeDeviceActivity.java
index 8709f14..9469a0c 100644
--- a/hostsidetests/theme/app/src/android/theme/app/ThemeDeviceActivity.java
+++ b/hostsidetests/theme/app/src/android/theme/app/ThemeDeviceActivity.java
@@ -18,6 +18,7 @@
import android.app.Activity;
import android.content.Intent;
+import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.theme.app.modifiers.DatePickerModifier;
@@ -76,6 +77,11 @@
mTheme = THEMES[themeIndex];
setTheme(mTheme.id);
+
+ // Force text scaling to 1.0 regardless of system default.
+ Configuration config = new Configuration();
+ config.fontScale = 1.0f;
+ getResources().updateConfiguration(config, null);
setContentView(R.layout.theme_test);
mViewGroup = (ReferenceViewGroup) findViewById(R.id.reference_view_group);
diff --git a/hostsidetests/theme/assets/24/400dpi.zip b/hostsidetests/theme/assets/24/400dpi.zip
new file mode 100755
index 0000000..b76e564
--- /dev/null
+++ b/hostsidetests/theme/assets/24/400dpi.zip
@@ -0,0 +1 @@
+<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>hostsidetests/theme/assets/26/400dpi.zip - platform/cts - Git at Google</title><link rel="stylesheet" type="text/css" href="/+static/base.8PwAX-dsywmU2hx_vi_YSA.cache.css"><link rel="stylesheet" type="text/css" href="/+static/prettify/prettify.pZ5FqzM6cPxAflH0va2Ucw.cache.css"><!-- default customHeadTagPart --></head><body class="Site"><header class="Site-header"><div class="Header"><a class="Header-image" href="/"><img src="//www.gstatic.com/images/branding/lockups/2x/lockup_git_color_108x24dp.png" width="108" height="24" alt="Google Git"></a><div class="Header-menu"> <a class="Header-menuItem" href="https://accounts.google.com/AccountChooser?service=gerritcodereview&continue=https://android.googlesource.com/login/platform/cts/%2B/android-cts-8.0_r14/hostsidetests/theme/assets/26/400dpi.zip">Sign in</a> </div></div></header><div class="Site-content"><div class="Container "><div class="Breadcrumbs"><a class="Breadcrumbs-crumb" href="/?format=HTML">android</a> / <a class="Breadcrumbs-crumb" href="/platform/">platform</a> / <a class="Breadcrumbs-crumb" href="/platform/cts/">cts</a> / <a class="Breadcrumbs-crumb" href="/platform/cts/+/android-cts-8.0_r14">android-cts-8.0_r14</a> / <a class="Breadcrumbs-crumb" href="/platform/cts/+/android-cts-8.0_r14/">.</a> / <a class="Breadcrumbs-crumb" href="/platform/cts/+/android-cts-8.0_r14/hostsidetests">hostsidetests</a> / <a class="Breadcrumbs-crumb" href="/platform/cts/+/android-cts-8.0_r14/hostsidetests/theme">theme</a> / <a class="Breadcrumbs-crumb" href="/platform/cts/+/android-cts-8.0_r14/hostsidetests/theme/assets">assets</a> / <a class="Breadcrumbs-crumb" href="/platform/cts/+/android-cts-8.0_r14/hostsidetests/theme/assets/26">26</a> / <span class="Breadcrumbs-crumb">400dpi.zip</span></div><div class="u-sha1 u-monospace BlobSha1">blob: d624bd54df060b534c62c07b8cf8b70b126b8f58 [<a href="/platform/cts/+/android-cts-8.0_r14/hostsidetests/theme/assets/26/400dpi.zip">file</a>] [<a href="/platform/cts/+log/android-cts-8.0_r14/hostsidetests/theme/assets/26/400dpi.zip">log</a>] [<a href="/platform/cts/+blame/android-cts-8.0_r14/hostsidetests/theme/assets/26/400dpi.zip">blame</a>]</div><div class="FileContents-binary">8615086-byte binary file</div></div> <!-- Container --></div> <!-- Site-content --><footer class="Site-footer"><div class="Footer"><span class="Footer-poweredBy">Powered by <a href="https://gerrit.googlesource.com/gitiles/">Gitiles</a>| <a href="https://policies.google.com/privacy">Privacy</a></span><span class="Footer-formats"><a class="u-monospace Footer-formatsItem" href="?format=TEXT">txt</a> <a class="u-monospace Footer-formatsItem" href="?format=JSON">json</a></span></div></footer></body></html>
\ No newline at end of file
diff --git a/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java b/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java
index e559f18..3ac1314 100644
--- a/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java
+++ b/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java
@@ -89,7 +89,7 @@
super.setUp();
mDevice = getDevice();
-
+ mDevice.executeShellCommand("settings put system font_scale 1.0");
final String density = getDensityBucketForDevice(mDevice);
final String referenceZipAssetPath = String.format("/%s.zip", density);
mReferences = extractReferenceImages(referenceZipAssetPath);
@@ -273,7 +273,8 @@
final Pattern p = Pattern.compile("Override density: (\\d+)");
final Matcher m = p.matcher(output);
if (m.find()) {
- return Integer.parseInt(m.group(1));
+ throw new RuntimeException("Cannot test device running at non-default density: "
+ + Integer.parseInt(m.group(1)));
}
final String densityProp;
diff --git a/hostsidetests/ui/Android.mk b/hostsidetests/ui/Android.mk
index 90fdad2..5450454 100644
--- a/hostsidetests/ui/Android.mk
+++ b/hostsidetests/ui/Android.mk
@@ -30,8 +30,8 @@
LOCAL_CTS_TEST_PACKAGE := android.ui.cts
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := general-tests cts_instant
+# *Not* tagged as a cts test artifact intentionally: b/109660132
+LOCAL_COMPATIBILITY_SUITE := general-tests
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/tests/JobScheduler/Android.mk b/tests/JobScheduler/Android.mk
index 9cb148b..622c06e 100755
--- a/tests/JobScheduler/Android.mk
+++ b/tests/JobScheduler/Android.mk
@@ -30,7 +30,7 @@
LOCAL_SRC_FILES += $(call all-java-files-under, JobTestApp/src)
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests cts_instant
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
# Must match the package name in CtsTestCaseList.mk
LOCAL_PACKAGE_NAME := CtsJobSchedulerTestCases
diff --git a/tests/accessibilityservice/AndroidManifest.xml b/tests/accessibilityservice/AndroidManifest.xml
index 5214410..029dc51 100644
--- a/tests/accessibilityservice/AndroidManifest.xml
+++ b/tests/accessibilityservice/AndroidManifest.xml
@@ -30,38 +30,38 @@
<activity
android:label="@string/accessibility_end_to_end_test_activity"
android:name=".activities.AccessibilityEndToEndActivity"
- android:screenOrientation="portrait"/>
+ android:screenOrientation="locked"/>
<activity
android:label="@string/accessibility_query_window_test_activity"
android:name=".activities.AccessibilityWindowQueryActivity"
android:supportsPictureInPicture="true"
- android:screenOrientation="portrait"/>
+ android:screenOrientation="locked"/>
<activity
android:label="@string/accessibility_view_tree_reporting_test_activity"
android:name=".activities.AccessibilityViewTreeReportingActivity"
- android:screenOrientation="portrait"/>
+ android:screenOrientation="locked"/>
<activity
android:label="@string/accessibility_focus_and_input_focus_sync_test_activity"
android:name=".activities.AccessibilityFocusAndInputFocusSyncActivity"
- android:screenOrientation="portrait"/>
+ android:screenOrientation="locked"/>
<activity
android:label="@string/accessibility_text_traversal_test_activity"
android:name=".activities.AccessibilityTextTraversalActivity"
- android:screenOrientation="portrait"/>
+ android:screenOrientation="locked"/>
<activity android:label="Activity for testing window accessibility reporting"
android:name=".activities.AccessibilityWindowReportingActivity"
android:supportsPictureInPicture="true"
- android:screenOrientation="portrait"/>
+ android:screenOrientation="locked"/>
<activity
android:label="Full screen activity for gesture dispatch testing"
android:name=".AccessibilityGestureDispatchTest$GestureDispatchActivity"
- android:screenOrientation="portrait" />
+ android:screenOrientation="locked" />
<activity
android:label="@string/accessibility_soft_keyboard_modes_activity"
diff --git a/tests/app/app/AndroidManifest.xml b/tests/app/app/AndroidManifest.xml
index e05b8b4..fe340c9 100644
--- a/tests/app/app/AndroidManifest.xml
+++ b/tests/app/app/AndroidManifest.xml
@@ -51,7 +51,7 @@
android:multiArch="true"
android:name="android.app.stubs.MockApplication"
android:supportsRtl="true"
- android:usesCleartextTraffic="true">
+ android:networkSecurityConfig="@xml/network_security_config">
<uses-library android:name="android.test.runner" />
<uses-library android:name="org.apache.http.legacy" android:required="false" />
diff --git a/tests/app/app/res/xml/network_security_config.xml b/tests/app/app/res/xml/network_security_config.xml
new file mode 100644
index 0000000..cb4b34f
--- /dev/null
+++ b/tests/app/app/res/xml/network_security_config.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<network-security-config>
+ <base-config cleartextTrafficPermitted="true">
+ </base-config>
+ <!-- Cleartext traffic is explicitly permitted to example.com and all subdomains -->
+ <domain-config cleartextTrafficPermitted="true">
+ <domain includeSubdomains="true">example.com</domain>
+ </domain-config>
+ <domain-config cleartextTrafficPermitted="true">
+ <domain includeSubdomains="true">localhost</domain>
+ </domain-config>
+</network-security-config>
diff --git a/tests/app/app/src/android/app/stubs/ExpandableListTestActivity.java b/tests/app/app/src/android/app/stubs/ExpandableListTestActivity.java
index ab377d9..f38348c 100644
--- a/tests/app/app/src/android/app/stubs/ExpandableListTestActivity.java
+++ b/tests/app/app/src/android/app/stubs/ExpandableListTestActivity.java
@@ -26,6 +26,7 @@
import android.view.ContextMenu;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
+import android.support.test.InstrumentationRegistry;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.SimpleExpandableListAdapter;
@@ -114,23 +115,29 @@
return RESULT_OK;
}
- private int testSelecte() {
+ private int testSelect() {
final ExpandableListView v = getExpandableListView();
- for (int i = 0; i < 20; i++) {
- v.expandGroup(i);
- setSelectedGroup(i);
- for (int k = 0; k < 15; k++) {
- setSelectedChild(i, k, false);
- if (ExpandableListView.getPackedPositionForChild(i, k) != getSelectedPosition())
- return RESULT_CANCELED;
- }
+ try {
+ // Make sure the touch mode is disabled since selection doesn't work in touch mode.
+ InstrumentationRegistry.getInstrumentation().setInTouchMode(false);
+ for (int i = 0; i < 20; i++) {
+ v.expandGroup(i);
+ setSelectedGroup(i);
+ for (int k = 0; k < 15; k++) {
+ setSelectedChild(i, k, false);
+ if (ExpandableListView.getPackedPositionForChild(i, k) != getSelectedPosition())
+ return RESULT_CANCELED;
+ }
- for (int k = 0; k < 15; k++) {
- setSelectedChild(i, k, true);
- if (ExpandableListView.getPackedPositionForChild(i, k) != getSelectedPosition())
- return RESULT_CANCELED;
+ for (int k = 0; k < 15; k++) {
+ setSelectedChild(i, k, true);
+ if (ExpandableListView.getPackedPositionForChild(i, k) != getSelectedPosition())
+ return RESULT_CANCELED;
+ }
+ v.collapseGroup(i);
}
- v.collapseGroup(i);
+ } finally {
+ InstrumentationRegistry.getInstrumentation().setInTouchMode(true);
}
return RESULT_OK;
}
@@ -140,7 +147,7 @@
super.onResume();
final String action = getIntent().getAction();
if (LaunchpadActivity.EXPANDLIST_SELECT.equals(action)) {
- setResult(testSelecte());
+ setResult(testSelect());
} else if (LaunchpadActivity.EXPANDLIST_VIEW.equals(action)) {
setResult(testView());
} else if (LaunchpadActivity.EXPANDLIST_CALLBACK.equals(action)) {
diff --git a/tests/app/src/android/app/cts/ActivityManagerProcessStateTest.java b/tests/app/src/android/app/cts/ActivityManagerProcessStateTest.java
index 7924d93..ae58e43 100644
--- a/tests/app/src/android/app/cts/ActivityManagerProcessStateTest.java
+++ b/tests/app/src/android/app/cts/ActivityManagerProcessStateTest.java
@@ -914,10 +914,12 @@
* Test that the foreground service app op does prevent the foreground state.
*/
public void testForegroundServiceAppOp() throws Exception {
+ // Use default timeout value 5000
final ServiceProcessController controller = new ServiceProcessController(mContext,
- getInstrumentation(), STUB_PACKAGE_NAME, mAllProcesses, WAIT_TIME);
+ getInstrumentation(), STUB_PACKAGE_NAME, mAllProcesses);
+ // Use default timeout value 5000
final ServiceConnectionHandler conn = new ServiceConnectionHandler(mContext,
- mServiceIntent, WAIT_TIME);
+ mServiceIntent);
final WatchUidRunner uidWatcher = controller.getUidWatcher();
try {
@@ -1007,7 +1009,8 @@
uidWatcher.waitFor(WatchUidRunner.CMD_ACTIVE, null);
uidWatcher.waitFor(WatchUidRunner.CMD_UNCACHED, null);
uidWatcher.waitFor(WatchUidRunner.CMD_PROCSTATE, WatchUidRunner.STATE_FG_SERVICE);
-
+ // Remove tempwhitelist avoid temp white list block idle command and app crash occur.
+ executeShellCmd("cmd deviceidle tempwhitelist -r " + SIMPLE_PACKAGE_NAME);
// Good, now stop the service and wait for it to go away.
mContext.stopService(mServiceStartForegroundIntent);
conn.waitForDisconnect();
diff --git a/tests/app/src/android/app/cts/ActivityManagerTest.java b/tests/app/src/android/app/cts/ActivityManagerTest.java
index be30de1..747c52e 100644
--- a/tests/app/src/android/app/cts/ActivityManagerTest.java
+++ b/tests/app/src/android/app/cts/ActivityManagerTest.java
@@ -437,11 +437,13 @@
* lifetime tests.
*/
private void launchHome() throws Exception {
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.addCategory(Intent.CATEGORY_HOME);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mContext.startActivity(intent);
- Thread.sleep(WAIT_TIME);
+ if (!noHomeScreen()) {
+ Intent intent = new Intent(Intent.ACTION_MAIN);
+ intent.addCategory(Intent.CATEGORY_HOME);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ mContext.startActivity(intent);
+ Thread.sleep(WAIT_TIME);
+ }
}
/**
diff --git a/tests/app/src/android/app/cts/SystemFeaturesTest.java b/tests/app/src/android/app/cts/SystemFeaturesTest.java
index 40774c7..871503f 100644
--- a/tests/app/src/android/app/cts/SystemFeaturesTest.java
+++ b/tests/app/src/android/app/cts/SystemFeaturesTest.java
@@ -43,6 +43,8 @@
import android.telephony.TelephonyManager;
import android.test.InstrumentationTestCase;
+import com.android.compatibility.common.util.PropertyUtil;
+
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashSet;
@@ -495,6 +497,7 @@
!mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEVISION) &&
!mPackageManager.hasSystemFeature(PackageManager.FEATURE_WATCH) &&
!mPackageManager.hasSystemFeature(PackageManager.FEATURE_EMBEDDED) &&
+ !isAndroidEmulator() &&
!mPackageManager.hasSystemFeature(PackageManager.FEATURE_PC)) {
// USB accessory mode is only a requirement for devices with USB ports supporting
// peripheral mode. As there is no public API to distinguish a device with only host
@@ -504,7 +507,7 @@
}
}
- public void testWifiFeature() throws Exception {
+ public void testWifiFeature() throws Exception {
if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_WIFI)) {
// no WiFi, skip the test
return;
@@ -519,6 +522,13 @@
}
}
+ public void testAudioOutputFeature() throws Exception {
+ if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE) ||
+ mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEVISION)) {
+ assertAvailable(PackageManager.FEATURE_AUDIO_OUTPUT);
+ }
+ }
+
private void assertAvailable(String feature) {
assertTrue("PackageManager#hasSystemFeature should return true for " + feature,
mPackageManager.hasSystemFeature(feature));
@@ -543,6 +553,10 @@
}
}
+ private boolean isAndroidEmulator() {
+ return PropertyUtil.propertyEquals("ro.kernel.qemu", "1");
+ }
+
private void assertFeature(boolean exist, String feature) {
if (exist) {
assertAvailable(feature);
diff --git a/tests/app/src/android/app/cts/WallpaperManagerTest.java b/tests/app/src/android/app/cts/WallpaperManagerTest.java
index e267503..9694d17 100644
--- a/tests/app/src/android/app/cts/WallpaperManagerTest.java
+++ b/tests/app/src/android/app/cts/WallpaperManagerTest.java
@@ -100,6 +100,52 @@
}
@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;
@@ -226,33 +272,30 @@
* Suggesting desired dimensions is only a hint to the system that can be ignored.
*
* Test if the desired minimum width or height the WallpaperManager returns
- * is greater than 0. If so, then we check whether that the size is at least the
- * as big as the screen.
+ * is greater than 0.
*/
@Test
public void suggestDesiredDimensionsTest() {
final Point min = getScreenSize();
final int w = min.x * 3;
final int h = min.y * 2;
- assertDesiredMinimum(new Point(min.x / 2, min.y / 2), min);
+ assertDesiredDimension(new Point(min.x / 2, min.y / 2), new Point(min.x / 2, min.y / 2));
- assertDesiredMinimum(new Point(w, h), min);
+ assertDesiredDimension(new Point(w, h), new Point(w, h));
- assertDesiredMinimum(new Point(min.x / 2, h), min);
+ assertDesiredDimension(new Point(min.x / 2, h), new Point(min.x / 2, h));
- assertDesiredMinimum(new Point(w, min.y / 2), min);
+ assertDesiredDimension(new Point(w, min.y / 2), new Point(w, min.y / 2));
}
- private void assertDesiredMinimum(Point suggestedSize, Point minSize) {
+ private void assertDesiredDimension(Point suggestedSize, Point expectedSize) {
mWallpaperManager.suggestDesiredDimensions(suggestedSize.x, suggestedSize.y);
Point actualSize = new Point(mWallpaperManager.getDesiredMinimumWidth(),
mWallpaperManager.getDesiredMinimumHeight());
- if (actualSize.x > 0 || actualSize.y > 0) {
- if ((actualSize.x < minSize.x || actualSize.y < minSize.y)) {
- throw new AssertionError("Expected at least x: " + minSize.x + " y: "
- + minSize.y + ", got x: " + actualSize.x +
- " y: " + actualSize.y);
- }
+ if (actualSize.x <= 0 || actualSize.y <= 0) {
+ throw new AssertionError("Expected x: " + expectedSize.x + " y: "
+ + expectedSize.y + ", got x: " + actualSize.x +
+ " y: " + actualSize.y);
}
}
diff --git a/tests/autofillservice/AndroidManifest.xml b/tests/autofillservice/AndroidManifest.xml
index 5feaf8d46..805bd67 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/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java b/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java
index 642e372..a32351a 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java
@@ -80,7 +80,7 @@
mUiBot.setScreenOrientation(UiBot.PORTRAIT);
try {
runShellCommand("wm size 1080x1920");
- runShellCommand("wm density 420");
+ runShellCommand("wm density 320");
saveUiRestoredAfterTappingLinkTest(
PostSaveLinkTappedAction.ROTATE_THEN_TAP_BACK_BUTTON);
} finally {
diff --git a/tests/autofillservice/src/android/autofillservice/cts/OutOfProcessLoginActivity.java b/tests/autofillservice/src/android/autofillservice/cts/OutOfProcessLoginActivity.java
index 6f6b75a..ff955dd 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/OutOfProcessLoginActivity.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/OutOfProcessLoginActivity.java
@@ -89,6 +89,7 @@
Log.e(TAG, "could write destroyed marker: " + e);
}
super.onDestroy();
+ sInstance = null;
}
/**
@@ -127,4 +128,8 @@
sInstance.finish();
}
}
+
+ public static boolean hasInstance() {
+ return sInstance != null;
+ }
}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/SessionLifecycleTest.java b/tests/autofillservice/src/android/autofillservice/cts/SessionLifecycleTest.java
index 1ae4418..18ef5aa 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/SessionLifecycleTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/SessionLifecycleTest.java
@@ -34,8 +34,11 @@
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
+import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;
+import android.app.ActivityManager;
+import android.content.Context;
import android.app.PendingIntent;
import android.app.assist.AssistStructure;
import android.content.Intent;
@@ -44,6 +47,7 @@
import android.os.SystemClock;
import android.platform.test.annotations.AppModeFull;
import android.support.test.uiautomator.UiObject2;
+import android.util.Log;
import android.view.autofill.AutofillValue;
import org.junit.After;
@@ -57,6 +61,8 @@
*/
@AppModeFull // This test requires android.permission.WRITE_EXTERNAL_STORAGE
public class SessionLifecycleTest extends AutoFillServiceTestCase {
+ private static final String TAG = "SessionLifecycleTest";
+
private static final String ID_BUTTON = "button";
private static final String ID_CANCEL = "cancel";
@@ -103,6 +109,10 @@
+ "-n android.autofillservice.cts/.OutOfProcessLoginActivityFinisherReceiver");
mUiBot.assertGoneByRelativeId(ID_USERNAME, Timeouts.ACTIVITY_RESURRECTION);
+ if (!OutOfProcessLoginActivity.hasInstance()) {
+ Log.v(TAG, "@After: Not waiting for oop activity to be destroyed");
+ return;
+ }
// Waiting for activity to be destroyed (destroy marker appears)
eventually("getDestroyedMarker()", () -> {
return getDestroyedMarker(getContext()).exists();
@@ -141,6 +151,9 @@
@Test
public void testDatasetAuthResponseWhileAutofilledAppIsLifecycled() throws Exception {
assumeTrue("Rotation is supported", Helper.isRotationSupported(mContext));
+ final ActivityManager activityManager = (ActivityManager) getContext()
+ .getSystemService(Context.ACTIVITY_SERVICE);
+ assumeFalse(activityManager.isLowRamDevice());
// Set service.
enableService();
diff --git a/tests/camera/src/android/hardware/camera2/cts/CameraDeviceTest.java b/tests/camera/src/android/hardware/camera2/cts/CameraDeviceTest.java
index 98fa7af..f72fcd7 100644
--- a/tests/camera/src/android/hardware/camera2/cts/CameraDeviceTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/CameraDeviceTest.java
@@ -1097,7 +1097,7 @@
}
for (int inFormat : inputFormats) {
- int outputFormats [] = config.getValidOutputFormatsForInput(inputFormat);
+ int outputFormats [] = config.getValidOutputFormatsForInput(inFormat);
for (int outFormat : outputFormats) {
if (inFormat == outFormat) {
inputFormat = inFormat;
diff --git a/tests/framework/base/activitymanager/AndroidManifest.xml b/tests/framework/base/activitymanager/AndroidManifest.xml
old mode 100644
new mode 100755
index 5b9672b..f442cdb6
--- a/tests/framework/base/activitymanager/AndroidManifest.xml
+++ b/tests/framework/base/activitymanager/AndroidManifest.xml
@@ -23,6 +23,7 @@
<uses-permission android:name="android.permission.MANAGE_ACTIVITY_STACKS" />
<uses-permission android:name="android.permission.ACTIVITY_EMBEDDING" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
+ <uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<application android:label="CtsActivityManagerDeviceTestCases">
<uses-library android:name="android.test.runner" />
diff --git a/tests/framework/base/activitymanager/app/src/android/server/am/AssistantVoiceInteractionService.java b/tests/framework/base/activitymanager/app/src/android/server/am/AssistantVoiceInteractionService.java
index b772ce2..30f7a85 100644
--- a/tests/framework/base/activitymanager/app/src/android/server/am/AssistantVoiceInteractionService.java
+++ b/tests/framework/base/activitymanager/app/src/android/server/am/AssistantVoiceInteractionService.java
@@ -29,10 +29,14 @@
private boolean mReady;
+ private boolean mStarted;
+ private Bundle mExtras;
+
@Override
public void onReady() {
super.onReady();
mReady = true;
+ showSessionIfReady();
}
@Override
@@ -43,13 +47,18 @@
stopSelf();
return START_NOT_STICKY;
}
- if (mReady) {
- Bundle extras = intent.getExtras() != null ? intent.getExtras() : new Bundle();
- showSession(extras, 0);
- }
+ mExtras = intent.getExtras() != null ? intent.getExtras() : new Bundle();
+ mStarted = true;
+ showSessionIfReady();
return START_NOT_STICKY;
}
+ private void showSessionIfReady() {
+ if (mReady && mStarted) {
+ showSession(mExtras, 0);
+ }
+ };
+
/**
* Starts the assistant voice interaction service, which initiates a new session that starts
* the assistant activity.
diff --git a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerActivityVisibilityTests.java b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerActivityVisibilityTests.java
index 1ea220a..ee16237 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerActivityVisibilityTests.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerActivityVisibilityTests.java
@@ -238,6 +238,8 @@
// Launch a different activity on top.
launchActivity(BROADCAST_RECEIVER_ACTIVITY);
mAmWmState.waitForActivityState(BROADCAST_RECEIVER_ACTIVITY, STATE_RESUMED);
+ // Wait for transition complete.
+ mAmWmState.waitForValidState(MOVE_TASK_TO_BACK_ACTIVITY);
final boolean shouldBeVisible =
!mAmWmState.getAmState().isBehindOpaqueActivities(MOVE_TASK_TO_BACK_ACTIVITY);
mAmWmState.assertVisibility(MOVE_TASK_TO_BACK_ACTIVITY, shouldBeVisible);
diff --git a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerAmProfileTests.java b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerAmProfileTests.java
index 6f2ec8d..74f4546 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerAmProfileTests.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerAmProfileTests.java
@@ -26,14 +26,9 @@
import static org.junit.Assert.assertTrue;
import android.content.ComponentName;
-import android.support.test.InstrumentationRegistry;
-import org.junit.Before;
import org.junit.Test;
-import java.io.File;
-import java.io.FileInputStream;
-
/**
* Build/Install/Run:
* atest CtsActivityManagerDeviceTestCases:ActivityManagerAmProfileTests
@@ -46,17 +41,6 @@
private static final String FIRST_WORD_NO_STREAMING = "*version\n";
private static final String FIRST_WORD_STREAMING = "SLOW"; // Magic word set by runtime.
- private String mReadableFilePath = null;
-
- @Before
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mReadableFilePath = InstrumentationRegistry.getContext()
- .getExternalFilesDir(null)
- .getPath() + "/profile.trace";
- }
-
/**
* Test am profile functionality with the following 3 configurable options:
* starting the activity before start profiling? yes;
@@ -122,10 +106,11 @@
launchActivity(DEBUGGABLE_APP_ACTIVITY);
executeShellCommand(getStopProfileCmd(DEBUGGABLE_APP_ACTIVITY));
- // Sleep for 0.1 second (100 milliseconds) so the generation of the profiling
+
+ // Sleep for 0.3 second (300 milliseconds) so the generation of the profiling
// file is complete.
try {
- Thread.sleep(100);
+ Thread.sleep(300);
} catch (InterruptedException e) {
//ignored
}
@@ -160,28 +145,17 @@
private void verifyOutputFileFormat(final boolean streaming) throws Exception {
// This is a hack. The am service has to write to /data/local/tmp because it doesn't have
- // access to the sdcard but the test app can't read there
- executeShellCommand("mv " + OUTPUT_FILE_PATH + " " + mReadableFilePath);
+ // access to the sdcard. The test cannot read from /data/local/tmp. This allows us to
+ // scan the content to validate what is needed for this test.
+ final String firstLine = executeShellCommand("head -1 " + OUTPUT_FILE_PATH);
final String expectedFirstWord = streaming ? FIRST_WORD_STREAMING : FIRST_WORD_NO_STREAMING;
- final byte[] data = readFile(mReadableFilePath);
- assertThat("data size", data.length, greaterThanOrEqualTo(expectedFirstWord.length()));
- final String actualFirstWord = new String(data, 0, expectedFirstWord.length());
+ assertThat(
+ "data size", firstLine.length(), greaterThanOrEqualTo(expectedFirstWord.length()));
+ final String actualFirstWord = firstLine.substring(0, expectedFirstWord.length());
assertEquals("Unexpected first word", expectedFirstWord, actualFirstWord);
// Clean up.
- executeShellCommand("rm -f " + OUTPUT_FILE_PATH + " " + mReadableFilePath);
- }
-
- private static byte[] readFile(String clientPath) throws Exception {
- final File file = new File(clientPath);
- assertTrue("File not found on client: " + clientPath, file.isFile());
- final int size = (int) file.length();
- final byte[] bytes = new byte[size];
- try (final FileInputStream fis = new FileInputStream(file)) {
- final int readSize = fis.read(bytes, 0, bytes.length);
- assertEquals("Read all data", bytes.length, readSize);
- return bytes;
- }
+ executeShellCommand("rm -f " + OUTPUT_FILE_PATH);
}
}
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 44281b2..41f4006 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerAppConfigurationTests.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerAppConfigurationTests.java
@@ -404,14 +404,14 @@
assumeTrue("Skipping test: no rotation support", supportsRotation());
LogSeparator logSeparator = separateLogs();
- launchActivity(PORTRAIT_ORIENTATION_ACTIVITY);
+ launchActivity(PORTRAIT_ORIENTATION_ACTIVITY, WINDOWING_MODE_FULLSCREEN);
mAmWmState.assertVisibility(PORTRAIT_ORIENTATION_ACTIVITY, true /* visible */);
assertLifecycleCounts(PORTRAIT_ORIENTATION_ACTIVITY, logSeparator, 1 /* create */,
1 /* start */, 1 /* resume */, 0 /* pause */, 0 /* stop */, 0 /* destroy */,
0 /* config */);
- launchActivity(LANDSCAPE_ORIENTATION_ACTIVITY);
+ launchActivity(LANDSCAPE_ORIENTATION_ACTIVITY, WINDOWING_MODE_FULLSCREEN);
mAmWmState.assertVisibility(LANDSCAPE_ORIENTATION_ACTIVITY, true /* visible */);
assertLifecycleCounts(PORTRAIT_ORIENTATION_ACTIVITY, logSeparator, 1 /* create */,
@@ -421,7 +421,7 @@
1 /* start */, 1 /* resume */, 0 /* pause */, 0 /* stop */, 0 /* destroy */,
0 /* config */);
- launchActivity(PORTRAIT_ORIENTATION_ACTIVITY);
+ launchActivity(PORTRAIT_ORIENTATION_ACTIVITY, WINDOWING_MODE_FULLSCREEN);
mAmWmState.assertVisibility(PORTRAIT_ORIENTATION_ACTIVITY, true /* visible */);
assertLifecycleCounts(PORTRAIT_ORIENTATION_ACTIVITY, logSeparator, 2 /* create */,
@@ -526,6 +526,7 @@
// Request portrait
executeShellCommand(REQUEST_PORTRAIT_BROADCAST);
mAmWmState.waitForLastOrientation(SCREEN_ORIENTATION_PORTRAIT);
+ waitForBroadcastActivityReady(SCREEN_ORIENTATION_PORTRAIT);
// Finish activity
executeShellCommand(FINISH_ACTIVITY_BROADCAST);
@@ -553,6 +554,7 @@
launchActivityInNewTask(BROADCAST_RECEIVER_ACTIVITY);
executeShellCommand(REQUEST_LANDSCAPE_BROADCAST);
mAmWmState.waitForLastOrientation(SCREEN_ORIENTATION_LANDSCAPE);
+ waitForBroadcastActivityReady(SCREEN_ORIENTATION_LANDSCAPE);
executeShellCommand(FINISH_ACTIVITY_BROADCAST);
// Verify that activity brought to front is in originally requested orientation.
@@ -570,6 +572,7 @@
launchActivityInNewTask(BROADCAST_RECEIVER_ACTIVITY);
executeShellCommand(REQUEST_PORTRAIT_BROADCAST);
mAmWmState.waitForLastOrientation(SCREEN_ORIENTATION_PORTRAIT);
+ waitForBroadcastActivityReady(SCREEN_ORIENTATION_PORTRAIT);
executeShellCommand(FINISH_ACTIVITY_BROADCAST);
// Verify that activity brought to front is in originally requested orientation.
@@ -694,6 +697,7 @@
// Request portrait
executeShellCommand(REQUEST_PORTRAIT_BROADCAST);
mAmWmState.waitForLastOrientation(SCREEN_ORIENTATION_PORTRAIT);
+ waitForBroadcastActivityReady(SCREEN_ORIENTATION_PORTRAIT);
// Finish activity
executeShellCommand(MOVE_TASK_TO_BACK_BROADCAST);
@@ -883,6 +887,11 @@
return display.getDisplayRect();
}
+ private void waitForBroadcastActivityReady(int orientation) {
+ mAmWmState.waitForActivityOrientation(BROADCAST_RECEIVER_ACTIVITY, orientation);
+ mAmWmState.waitForActivityState(BROADCAST_RECEIVER_ACTIVITY, STATE_RESUMED);
+ }
+
/**
* Test launching an activity which requests specific UI mode during creation.
*/
diff --git a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerGetConfigTests.java b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerGetConfigTests.java
index 7f431c8..f625fdd 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerGetConfigTests.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerGetConfigTests.java
@@ -334,8 +334,13 @@
slibNames, deviceConfig.sharedLibraries);
FeatureInfo[] features = mPm.getSystemAvailableFeatures();
- Arrays.sort(features, (o1, o2) ->
- (o1.name == o2.name ? 0 : (o1.name == null ? -1 : o1.name.compareTo(o2.name))));
+ Arrays.sort(features, (o1, o2) -> {
+ if (o1.name == o2.name) return 0;
+ if (o1.name == null) return -1;
+ if (o2.name == null) return 1;
+ return o1.name.compareTo(o2.name);
+ });
+
int size = 0;
for (int i = 0; i < features.length; i++) {
if (features[i].name != null) {
diff --git a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerPinnedStackTests.java b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerPinnedStackTests.java
index a873c09..dbc93b4 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerPinnedStackTests.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerPinnedStackTests.java
@@ -565,7 +565,7 @@
// Launch first PIP activity
launchActivity(PIP_ACTIVITY, EXTRA_ENTER_PIP, "true");
- waitForEnterPip(PIP_ACTIVITY);
+ waitForEnterPipAnimationComplete(PIP_ACTIVITY);
// Launch second PIP activity
launchActivity(PIP_ACTIVITY2, EXTRA_ENTER_PIP, "true");
@@ -610,17 +610,14 @@
launchActivity(TEST_ACTIVITY);
// Launch an auto pip activity
- launchActivity(PIP_ACTIVITY,
- EXTRA_ENTER_PIP, "true",
- EXTRA_REENTER_PIP_ON_EXIT, "true");
+ launchActivity(PIP_ACTIVITY, EXTRA_ENTER_PIP, "true");
waitForEnterPip(PIP_ACTIVITY);
assertPinnedStackExists();
// Relaunch the activity to fullscreen to trigger the activity to exit and re-enter pip
launchActivity(PIP_ACTIVITY);
- mAmWmState.waitForWithAmState(amState ->
- amState.getFrontStackWindowingMode(DEFAULT_DISPLAY) == WINDOWING_MODE_FULLSCREEN,
- "Waiting for PIP to exit to fullscreen");
+ waitForExitPipToFullscreen(PIP_ACTIVITY);
+ executeShellCommand("am broadcast -a " + ACTION_ENTER_PIP);
waitForEnterPipAnimationComplete(PIP_ACTIVITY);
mAmWmState.assertVisibility(TEST_ACTIVITY, true);
}
diff --git a/tests/framework/base/activitymanager/src/android/server/am/DisplaySizeTest.java b/tests/framework/base/activitymanager/src/android/server/am/DisplaySizeTest.java
index 98e3ba7..83ceabd 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/DisplaySizeTest.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/DisplaySizeTest.java
@@ -93,10 +93,12 @@
EXTRA_LAUNCH_ANOTHER_ACTIVITY, getActivityName(TEST_ACTIVITY));
executeShellCommand(startActivityOnTop);
mAmWmState.assertActivityDisplayed(TEST_ACTIVITY);
+ final LogSeparator logSeparator = separateLogs();
try (final ScreenDensitySession screenDensitySession = new ScreenDensitySession()) {
screenDensitySession.setUnsupportedDensity();
+ assertActivityLifecycle(TEST_ACTIVITY, true /* relaunched */, logSeparator);
pressBackButton();
mAmWmState.assertActivityDisplayed(SMALLEST_WIDTH_ACTIVITY);
diff --git a/tests/framework/base/activitymanager/src/android/server/am/KeyguardTests.java b/tests/framework/base/activitymanager/src/android/server/am/KeyguardTests.java
old mode 100644
new mode 100755
index a53993b..bf3d1ea
--- a/tests/framework/base/activitymanager/src/android/server/am/KeyguardTests.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/KeyguardTests.java
@@ -327,6 +327,7 @@
pressBackButton();
mAmWmState.waitForKeyguardShowingAndNotOccluded();
mAmWmState.waitForDisplayUnfrozen();
+ mAmWmState.waitForAppTransitionIdle();
mAmWmState.assertSanity();
mAmWmState.assertHomeActivityVisible(false);
mAmWmState.assertKeyguardShowingAndNotOccluded();
diff --git a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleKeyguardTests.java b/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleKeyguardTests.java
index 12bfc64..95fc60e 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleKeyguardTests.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleKeyguardTests.java
@@ -22,6 +22,9 @@
@Test
public void testSingleLaunch() throws Exception {
+ if (!supportsSecureLock()) {
+ return;
+ }
try (final LockScreenSession lockScreenSession = new LockScreenSession()) {
lockScreenSession.setLockCredential().gotoKeyguard();
diff --git a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleTests.java b/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleTests.java
index 9903653..153a4cc 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleTests.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleTests.java
@@ -150,12 +150,14 @@
occludedActivityState(translucentActivity, topOpaqueActivity),
state(topOpaqueActivity, ON_RESUME));
- getLifecycleLog().clear();
try (final RotationSession rotationSession = new RotationSession()) {
if (!supportsLockedUserRotation(
rotationSession, translucentActivity.getDisplay().getDisplayId())) {
return;
}
+
+ getLifecycleLog().clear();
+
final int current = rotationSession.get();
// Set new rotation to cause a configuration change.
switch (current) {
diff --git a/tests/framework/base/activitymanager/util/src/android/server/am/ActivityAndWindowManagersState.java b/tests/framework/base/activitymanager/util/src/android/server/am/ActivityAndWindowManagersState.java
index fe1f588..f503f98 100644
--- a/tests/framework/base/activitymanager/util/src/android/server/am/ActivityAndWindowManagersState.java
+++ b/tests/framework/base/activitymanager/util/src/android/server/am/ActivityAndWindowManagersState.java
@@ -269,6 +269,19 @@
"***Waiting for LastOrientation: " + orientation);
}
+ /**
+ * Wait for orientation for the Activity
+ */
+ void waitForActivityOrientation(ComponentName activityName, int orientation) {
+ waitForWithAmState(amState -> {
+ final ActivityTask task = amState.getTaskByActivity(activityName);
+ if (task == null) {
+ return false;
+ }
+ return task.mFullConfiguration.orientation == orientation;
+ }, "***Waiting for Activity orientation: " + orientation);
+ }
+
void waitForDisplayUnfrozen() {
waitForWithWmState(state -> !state.isDisplayFrozen(),
"***Waiting for Display unfrozen");
diff --git a/tests/framework/base/windowmanager/dndsourceapp/AndroidManifest.xml b/tests/framework/base/windowmanager/dndsourceapp/AndroidManifest.xml
index e7b3453..c044981 100644
--- a/tests/framework/base/windowmanager/dndsourceapp/AndroidManifest.xml
+++ b/tests/framework/base/windowmanager/dndsourceapp/AndroidManifest.xml
@@ -18,7 +18,8 @@
package="android.server.wm.dndsourceapp"
android:targetSandboxVersion="2">
<application android:label="CtsDnDSource">
- <activity android:name="android.server.wm.dndsourceapp.DragSource">
+ <activity android:name="android.server.wm.dndsourceapp.DragSource"
+ android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
diff --git a/tests/framework/base/windowmanager/dndtargetapp/AndroidManifest.xml b/tests/framework/base/windowmanager/dndtargetapp/AndroidManifest.xml
index 09a0bc9..7d50b70 100644
--- a/tests/framework/base/windowmanager/dndtargetapp/AndroidManifest.xml
+++ b/tests/framework/base/windowmanager/dndtargetapp/AndroidManifest.xml
@@ -18,7 +18,8 @@
package="android.server.wm.dndtargetapp"
android:targetSandboxVersion="2">
<application android:label="CtsDnDTarget">
- <activity android:name="android.server.wm.dndtargetapp.DropTarget">
+ <activity android:name="android.server.wm.dndtargetapp.DropTarget"
+ android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
diff --git a/tests/leanbackjank/app/res/layout/icon_header_item.xml b/tests/leanbackjank/app/res/layout/icon_header_item.xml
index 56c8488..ce4942d 100644
--- a/tests/leanbackjank/app/res/layout/icon_header_item.xml
+++ b/tests/leanbackjank/app/res/layout/icon_header_item.xml
@@ -17,6 +17,8 @@
<androidx.leanback.widget.NonOverlappingLinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
+ android:focusable="true"
+ android:focusableInTouchMode="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
diff --git a/tests/leanbackjank/src/android/leanbackjank/cts/CtsDeviceLeanback.java b/tests/leanbackjank/src/android/leanbackjank/cts/CtsDeviceLeanback.java
index ded9ea1..0c19395 100644
--- a/tests/leanbackjank/src/android/leanbackjank/cts/CtsDeviceLeanback.java
+++ b/tests/leanbackjank/src/android/leanbackjank/cts/CtsDeviceLeanback.java
@@ -32,7 +32,7 @@
private static final long WAIT_TIMEOUT = 5 * MILLIS_PER_SECOND;
private static final int SCROLL_COUNT = 100;
private static final int SCROLL_INTERVAL_MILLIS = 200;
- private static final int PRE_SCROLL_DELAY_MILLIS = 0;
+ private static final int PRE_SCROLL_DELAY_MILLIS = 500;
private static final int PRE_SCROLL_IDLE_TIME = 2 * MILLIS_PER_SECOND;
private static final int SAMPLING_DURATION_SECONDS = 2;
private static final int SAMPLING_DURATION_MILLIS =
diff --git a/tests/libcore/wycheproof-bc/AndroidTest.xml b/tests/libcore/wycheproof-bc/AndroidTest.xml
index 2e92706..8e455bf 100644
--- a/tests/libcore/wycheproof-bc/AndroidTest.xml
+++ b/tests/libcore/wycheproof-bc/AndroidTest.xml
@@ -30,7 +30,7 @@
<option name="instrumentation-arg" key="filter"
value="com.android.cts.core.runner.ExpectationBasedFilter" />
<option name="core-expectation" value="/knownfailures.txt" />
- <option name="runtime-hint" value="10m"/>
- <option name="test-timeout" value="600000" />
+ <option name="runtime-hint" value="16m"/>
+ <option name="test-timeout" value="3600000" />
</test>
</configuration>
diff --git a/tests/openglperf2/AndroidTest.xml b/tests/openglperf2/AndroidTest.xml
index 4ac0455..c0612be 100644
--- a/tests/openglperf2/AndroidTest.xml
+++ b/tests/openglperf2/AndroidTest.xml
@@ -23,7 +23,5 @@
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="android.opengl2.cts" />
<option name="runtime-hint" value="4m" />
- <!-- test-timeout unit is ms, value = 100 min -->
- <option name="test-timeout" value="6000000" />
</test>
</configuration>
diff --git a/tests/sensor/jni/nativeTestHelper.cpp b/tests/sensor/jni/nativeTestHelper.cpp
index 3c7df9a..69eeba6 100644
--- a/tests/sensor/jni/nativeTestHelper.cpp
+++ b/tests/sensor/jni/nativeTestHelper.cpp
@@ -33,7 +33,11 @@
jclass exClass;
const char *className = "java/lang/AssertionError";
exClass = env->FindClass(className);
- env->ThrowNew(exClass, msg);
+ jmethodID constructor = env->GetMethodID(exClass, "<init>",
+ "(Ljava/lang/String;Ljava/lang/Throwable;)V");
+ jstring msgStr = env->NewStringUTF(msg);
+ jobject exception = env->NewObject(exClass, constructor, msgStr, nullptr);
+ env->Throw(static_cast<jthrowable>(exception));
free(msg);
}
diff --git a/tests/sensor/src/android/hardware/cts/SensorSupportTest.java b/tests/sensor/src/android/hardware/cts/SensorSupportTest.java
index 23c122d..7988ef3 100644
--- a/tests/sensor/src/android/hardware/cts/SensorSupportTest.java
+++ b/tests/sensor/src/android/hardware/cts/SensorSupportTest.java
@@ -18,10 +18,13 @@
import android.content.Context;
import android.content.pm.PackageManager;
+import android.content.res.Configuration;
import android.hardware.Sensor;
import android.hardware.SensorDirectChannel;
import android.hardware.SensorManager;
+import com.android.compatibility.common.util.CddTest;
+
/**
* Checks if Hifi sensors or VR High performance mode sensors
* are supported. When supported, checks individual support for
@@ -39,6 +42,7 @@
private SensorManager mSensorManager;
private boolean mAreHifiSensorsSupported;
private boolean mVrHighPerformanceModeSupported;
+ private boolean mIsVrHeadset;
@Override
public void setUp() {
@@ -46,32 +50,40 @@
// Tests will only run if either HIFI_SENSORS or VR high performance mode is supported.
mAreHifiSensorsSupported = pm.hasSystemFeature(PackageManager.FEATURE_HIFI_SENSORS);
mVrHighPerformanceModeSupported = pm.hasSystemFeature(PackageManager.FEATURE_VR_MODE_HIGH_PERFORMANCE);
+ mIsVrHeadset = (getContext().getResources().getConfiguration().uiMode
+ & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_VR_HEADSET;
if (mAreHifiSensorsSupported || mVrHighPerformanceModeSupported) {
mSensorManager =
(SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE);
}
}
+ @CddTest(requirement="7.9.2/C-1-19,C-1-20")
public void testSupportsAccelerometer() {
checkSupportsSensor(Sensor.TYPE_ACCELEROMETER);
}
+ @CddTest(requirement="7.9.2/C-1-19,C-1-20")
public void testSupportsAccelerometerUncalibrated() {
checkSupportsSensor(Sensor.TYPE_ACCELEROMETER_UNCALIBRATED);
}
+ @CddTest(requirement="7.9.2/C-1-19,C-1-20")
public void testSupportsGyroscope() {
checkSupportsSensor(Sensor.TYPE_GYROSCOPE);
}
+ @CddTest(requirement="7.9.2/C-1-19,C-1-20")
public void testSupportsGyroscopeUncalibrated() {
checkSupportsSensor(Sensor.TYPE_GYROSCOPE_UNCALIBRATED);
}
+ @CddTest(requirement="7.9.2/C-1-19,C-1-20")
public void testSupportsGeoMagneticField() {
checkSupportsSensor(Sensor.TYPE_MAGNETIC_FIELD);
}
+ @CddTest(requirement="7.9.2/C-1-19,C-1-20")
public void testSupportsMagneticFieldUncalibrated() {
checkSupportsSensor(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED);
}
@@ -120,7 +132,7 @@
if (mAreHifiSensorsSupported || isVrSensor) {
Sensor sensor = mSensorManager.getDefaultSensor(sensorType);
assertTrue(sensor != null);
- if (isVrSensor) {
+ if (isVrSensor && mIsVrHeadset) {
assertTrue(sensor.isDirectChannelTypeSupported(SensorDirectChannel.TYPE_HARDWARE_BUFFER));
}
}
diff --git a/tests/signature/api-check/system-annotation/Android.mk b/tests/signature/api-check/system-annotation/Android.mk
index d740d0f..53f1e56 100644
--- a/tests/signature/api-check/system-annotation/Android.mk
+++ b/tests/signature/api-check/system-annotation/Android.mk
@@ -22,5 +22,7 @@
LOCAL_SIGNATURE_API_FILES := \
system-current.api \
system-removed.api \
+ car-system-current.api \
+ car-system-removed.api \
include $(LOCAL_PATH)/../build_signature_apk.mk
diff --git a/tests/signature/api-check/system-annotation/AndroidTest.xml b/tests/signature/api-check/system-annotation/AndroidTest.xml
index 56a4cca..5d2f13f 100644
--- a/tests/signature/api-check/system-annotation/AndroidTest.xml
+++ b/tests/signature/api-check/system-annotation/AndroidTest.xml
@@ -26,6 +26,12 @@
<target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
<option name="push" value="system-removed.api->/data/local/tmp/signature-test/system-removed.api" />
</target_preparer>
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+ <option name="push" value="car-system-current.api->/data/local/tmp/signature-test/car-system-current.api" />
+ </target_preparer>
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+ <option name="push" value="car-system-removed.api->/data/local/tmp/signature-test/car-system-removed.api" />
+ </target_preparer>
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsSystemApiAnnotationTestCases.apk" />
@@ -34,7 +40,7 @@
<option name="package" value="android.signature.cts.api.system_annotation" />
<option name="runner" value="repackaged.android.test.InstrumentationTestRunner" />
<option name="class" value="android.signature.cts.api.AnnotationTest" />
- <option name="instrumentation-arg" key="expected-api-files" value="system-current.api,system-removed.api" />
+ <option name="instrumentation-arg" key="expected-api-files" value="system-current.api,system-removed.api,car-system-current.api,car-system-removed.api" />
<option name="instrumentation-arg" key="annotation-for-exact-match" value="android.annotation.SystemApi" />
<option name="runtime-hint" value="30s" />
</test>
diff --git a/tests/signature/api/Android.mk b/tests/signature/api/Android.mk
index b257c5e..c9c2a60 100644
--- a/tests/signature/api/Android.mk
+++ b/tests/signature/api/Android.mk
@@ -42,6 +42,8 @@
$(eval $(call build_xml_api_file,android-test-base-current.api,frameworks/base/test-base/api/android-test-base-current.txt))
$(eval $(call build_xml_api_file,android-test-mock-current.api,frameworks/base/test-mock/api/android-test-mock-current.txt))
$(eval $(call build_xml_api_file,android-test-runner-current.api,frameworks/base/test-runner/api/android-test-runner-current.txt))
+$(eval $(call build_xml_api_file,car-system-current.api,packages/services/Car/car-lib/api/system-current.txt))
+$(eval $(call build_xml_api_file,car-system-removed.api,packages/services/Car/car-lib/api/system-removed.txt))
$(foreach ver,$(PLATFORM_SYSTEMSDK_VERSIONS),\
$(if $(call math_is_number,$(ver)),\
$(eval $(call build_xml_api_file,system-$(ver).api,prebuilts/sdk/system-api/$(ver).txt))\
diff --git a/tests/signature/dex-checker/dex-checker.cpp b/tests/signature/dex-checker/dex-checker.cpp
index 4a80e02..61d9e32 100644
--- a/tests/signature/dex-checker/dex-checker.cpp
+++ b/tests/signature/dex-checker/dex-checker.cpp
@@ -49,7 +49,8 @@
ScopedUtfChars utf_type(env, type);
jfieldID fid = env->GetFieldID(klass, utf_name.c_str(), utf_type.c_str());
if (env->ExceptionCheck()) {
- env->ExceptionClear();
+ // GetFieldID could have thrown either NoSuchFieldError or ExceptionInInitializerError.
+ // Do not clear the exception, let Java code handle it.
return nullptr;
}
return env->ToReflectedField(klass, fid, /* static */ false);
@@ -62,7 +63,8 @@
ScopedUtfChars utf_type(env, type);
jfieldID fid = env->GetStaticFieldID(klass, utf_name.c_str(), utf_type.c_str());
if (env->ExceptionCheck()) {
- env->ExceptionClear();
+ // GetStaticFieldID could have thrown either NoSuchFieldError or ExceptionInInitializerError.
+ // Do not clear the exception, let Java code handle it.
return nullptr;
}
return env->ToReflectedField(klass, fid, /* static */ true);
@@ -75,7 +77,8 @@
ScopedUtfChars utf_signature(env, signature);
jmethodID mid = env->GetMethodID(klass, utf_name.c_str(), utf_signature.c_str());
if (env->ExceptionCheck()) {
- env->ExceptionClear();
+ // GetMethodID could have thrown either NoSuchMethodError or ExceptionInInitializerError.
+ // Do not clear the exception, let Java code handle it.
return nullptr;
}
return env->ToReflectedMethod(klass, mid, /* static */ false);
@@ -88,7 +91,8 @@
ScopedUtfChars utf_signature(env, signature);
jmethodID mid = env->GetStaticMethodID(klass, utf_name.c_str(), utf_signature.c_str());
if (env->ExceptionCheck()) {
- env->ExceptionClear();
+ // GetStaticMethodID could have thrown either NoSuchMethodError or ExceptionInInitializerError.
+ // Do not clear the exception, let Java code handle it.
return nullptr;
}
return env->ToReflectedMethod(klass, mid, /* static */ true);
diff --git a/tests/signature/intent-check/DynamicConfig.xml b/tests/signature/intent-check/DynamicConfig.xml
index 6c7aace..10b4834 100644
--- a/tests/signature/intent-check/DynamicConfig.xml
+++ b/tests/signature/intent-check/DynamicConfig.xml
@@ -23,6 +23,13 @@
Bug: 78574873 android.intent.action.INSTALL_EPHEMERAL_PACKAGE
Bug: 78574873 android.intent.action.RESOLVE_EPHEMERAL_PACKAGE
Bug: 78574873 android.intent.action.EPHEMERAL_RESOLVER_SETTINGS
+ Bug: 115799975 android.intent.action.ACTION_AIRPLANE_MODE_CHANGED
+ Will be removed after v17 of CS.apk is released.
+ Bug: 117590943 android.intent.action.View
+ Fixed in GMSCore v14.7.68.
+ Bug: 67109014 android.intent.action.BADGE_COUNT_UPDATE // Samsung is sending
+ //new corrected intent and the old intent in P.
+ //Target date for fix is under disucssion for BADGE_COUNT_UPDATE
-->
<dynamicConfig>
<entry key ="intent_whitelist">
@@ -34,5 +41,8 @@
<value>android.intent.action.INSTALL_EPHEMERAL_PACKAGE</value>
<value>android.intent.action.RESOLVE_EPHEMERAL_PACKAGE</value>
<value>android.intent.action.EPHEMERAL_RESOLVER_SETTINGS</value>
+ <value>android.intent.action.ACTION_AIRPLANE_MODE_CHANGED</value>
+ <value>android.intent.action.View</value>
+ <value>android.intent.action.BADGE_COUNT_UPDATE</value>
</entry>
</dynamicConfig>
diff --git a/tests/signature/src/android/signature/cts/DexMemberChecker.java b/tests/signature/src/android/signature/cts/DexMemberChecker.java
index 528e868..1efdbad 100644
--- a/tests/signature/src/android/signature/cts/DexMemberChecker.java
+++ b/tests/signature/src/android/signature/cts/DexMemberChecker.java
@@ -16,6 +16,7 @@
package android.signature.cts;
+import android.util.Log;
import java.lang.reflect.Constructor;
import java.lang.reflect.Executable;
import java.lang.reflect.Field;
@@ -24,6 +25,7 @@
import java.util.List;
public class DexMemberChecker {
+ public static final String TAG = "DexMemberChecker";
public interface Observer {
void classAccessible(boolean accessible, DexMember member);
@@ -85,17 +87,39 @@
observer.fieldAccessibleViaReflection(
hasMatchingField_Reflection(klass, field),
field);
- observer.fieldAccessibleViaJni(
- hasMatchingField_JNI(klass, field),
- field);
+ try {
+ observer.fieldAccessibleViaJni(
+ hasMatchingField_JNI(klass, field),
+ field);
+ } catch (ExceptionInInitializerError | UnsatisfiedLinkError | NoClassDefFoundError e) {
+ if ((e instanceof NoClassDefFoundError)
+ && !(e.getCause() instanceof ExceptionInInitializerError)
+ && !(e.getCause() instanceof UnsatisfiedLinkError)) {
+ throw e;
+ }
+
+ // Could not initialize the class. Skip JNI test.
+ Log.w(TAG, "JNI failed for " + dexMember.toString(), e);
+ }
} else if (dexMember instanceof DexMethod) {
DexMethod method = (DexMethod) dexMember;
observer.methodAccessibleViaReflection(
hasMatchingMethod_Reflection(klass, method),
method);
- observer.methodAccessibleViaJni(
- hasMatchingMethod_JNI(klass, method),
- method);
+ try {
+ observer.methodAccessibleViaJni(
+ hasMatchingMethod_JNI(klass, method),
+ method);
+ } catch (ExceptionInInitializerError | UnsatisfiedLinkError | NoClassDefFoundError e) {
+ if ((e instanceof NoClassDefFoundError)
+ && !(e.getCause() instanceof ExceptionInInitializerError)
+ && !(e.getCause() instanceof UnsatisfiedLinkError)) {
+ throw e;
+ }
+
+ // Could not initialize the class. Skip JNI test.
+ Log.w(TAG, "JNI failed for " + dexMember.toString(), e);
+ }
} else {
throw new IllegalStateException("Unexpected type of dex member");
}
@@ -134,10 +158,25 @@
}
private static boolean hasMatchingField_JNI(Class<?> klass, DexField dexField) {
- Field ifield = getField_JNI(klass, dexField.getName(), dexField.getDexType());
- Field sfield = getStaticField_JNI(klass, dexField.getName(), dexField.getDexType());
- return (ifield != null && ifield.getDeclaringClass() == klass) ||
- (sfield != null && sfield.getDeclaringClass() == klass);
+ try {
+ Field ifield = getField_JNI(klass, dexField.getName(), dexField.getDexType());
+ if (ifield.getDeclaringClass() == klass) {
+ return true;
+ }
+ } catch (NoSuchFieldError e) {
+ // Not found.
+ }
+
+ try {
+ Field sfield = getStaticField_JNI(klass, dexField.getName(), dexField.getDexType());
+ if (sfield.getDeclaringClass() == klass) {
+ return true;
+ }
+ } catch (NoSuchFieldError e) {
+ // Not found.
+ }
+
+ return false;
}
private static boolean hasMatchingMethod_Reflection(Class<?> klass, DexMethod dexMethod) {
@@ -163,11 +202,29 @@
}
private static boolean hasMatchingMethod_JNI(Class<?> klass, DexMethod dexMethod) {
- Executable imethod = getMethod_JNI(klass, dexMethod.getName(), dexMethod.getDexSignature());
- Executable smethod = dexMethod.isConstructor() ? null :
- getStaticMethod_JNI(klass, dexMethod.getName(), dexMethod.getDexSignature());
- return (imethod != null && imethod.getDeclaringClass() == klass) ||
- (smethod != null && smethod.getDeclaringClass() == klass);
+ try {
+ Executable imethod = getMethod_JNI(
+ klass, dexMethod.getName(), dexMethod.getDexSignature());
+ if (imethod.getDeclaringClass() == klass) {
+ return true;
+ }
+ } catch (NoSuchMethodError e) {
+ // Not found.
+ }
+
+ if (!dexMethod.isConstructor()) {
+ try {
+ Executable smethod =
+ getStaticMethod_JNI(klass, dexMethod.getName(), dexMethod.getDexSignature());
+ if (smethod.getDeclaringClass() == klass) {
+ return true;
+ }
+ } catch (NoSuchMethodError e) {
+ // Not found.
+ }
+ }
+
+ return false;
}
private static native Field getField_JNI(Class<?> klass, String name, String type);
diff --git a/tests/tests/car/Android.mk b/tests/tests/car/Android.mk
index 7310085..049a8a6 100644
--- a/tests/tests/car/Android.mk
+++ b/tests/tests/car/Android.mk
@@ -24,7 +24,10 @@
# When built, explicitly put it in the data partition.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android-support-test \
+ compatibility-device-util \
+ ctstestrunner
LOCAL_JAVA_LIBRARIES := android.car android.test.base.stubs
diff --git a/tests/tests/car/AndroidManifest.xml b/tests/tests/car/AndroidManifest.xml
index 984d896..76e2e3c 100644
--- a/tests/tests/car/AndroidManifest.xml
+++ b/tests/tests/car/AndroidManifest.xml
@@ -17,6 +17,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.car.cts">
<uses-feature android:name="android.hardware.type.automotive" />
+ <uses-permission android:name="android.car.permission.CAR_EXTERIOR_ENVIRONMENT" />
+ <uses-permission android:name="android.car.permission.CAR_INFO" />
+
<application>
<uses-library android:name="android.test.runner" />
</application>
diff --git a/tests/tests/car/AndroidTest.xml b/tests/tests/car/AndroidTest.xml
index c931169..558e7be 100644
--- a/tests/tests/car/AndroidTest.xml
+++ b/tests/tests/car/AndroidTest.xml
@@ -23,4 +23,5 @@
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="android.car.cts" />
</test>
+ <object type="module_controller" class="com.android.tradefed.testtype.suite.module.CarModuleController"/>
</configuration>
diff --git a/tests/tests/car/src/android/car/cts/CarApiTestBase.java b/tests/tests/car/src/android/car/cts/CarApiTestBase.java
index d982c1b..7cf6a73 100644
--- a/tests/tests/car/src/android/car/cts/CarApiTestBase.java
+++ b/tests/tests/car/src/android/car/cts/CarApiTestBase.java
@@ -16,18 +16,31 @@
package android.car.cts;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assume.assumeTrue;
+
import android.car.Car;
import android.content.ComponentName;
+import android.content.Context;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.Looper;
+import android.support.test.InstrumentationRegistry;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.FeatureUtil;
+
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
+import org.junit.After;
-public class CarApiTestBase extends AndroidTestCase {
+public abstract class CarApiTestBase {
protected static final long DEFAULT_WAIT_TIMEOUT_MS = 1000;
private Car mCar;
@@ -39,18 +52,21 @@
assertTrue(Looper.getMainLooper().isCurrentThread());
}
- @Override
protected void setUp() throws Exception {
- super.setUp();
- mCar = Car.createCar(getContext(), mConnectionListener, null);
+ assumeTrue(FeatureUtil.isAutomotive());
+
+ Context context =
+ InstrumentationRegistry.getInstrumentation().getTargetContext();
+ mCar = Car.createCar(context, mConnectionListener, null);
mCar.connect();
mConnectionListener.waitForConnection(DEFAULT_WAIT_TIMEOUT_MS);
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- mCar.disconnect();
+ @After
+ public void disconnectCar() throws Exception {
+ if (mCar != null) {
+ mCar.disconnect();
+ }
}
protected synchronized Car getCar() {
diff --git a/tests/tests/car/src/android/car/cts/CarAppFocusManagerTest.java b/tests/tests/car/src/android/car/cts/CarAppFocusManagerTest.java
index 2dd0a81..910819d 100644
--- a/tests/tests/car/src/android/car/cts/CarAppFocusManagerTest.java
+++ b/tests/tests/car/src/android/car/cts/CarAppFocusManagerTest.java
@@ -15,30 +15,44 @@
*/
package android.car.cts;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import static android.car.CarAppFocusManager.APP_FOCUS_REQUEST_SUCCEEDED;
import static android.car.CarAppFocusManager.APP_FOCUS_TYPE_NAVIGATION;
import static android.car.CarAppFocusManager.APP_FOCUS_TYPE_VOICE_COMMAND;
import android.car.Car;
import android.car.CarAppFocusManager;
+import android.content.Context;
import android.platform.test.annotations.RequiresDevice;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
+
import android.util.Log;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
+import org.junit.After;
import org.junit.Assert;
-
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
@SmallTest
@RequiresDevice
+@RunWith(AndroidJUnit4.class)
public class CarAppFocusManagerTest extends CarApiTestBase {
private static final String TAG = CarAppFocusManagerTest.class.getSimpleName();
private CarAppFocusManager mManager;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
mManager = (CarAppFocusManager) getCar().getCarManager(Car.APP_FOCUS_SERVICE);
assertNotNull(mManager);
@@ -57,6 +71,7 @@
}
+ @Test
public void testSetActiveNullListener() throws Exception {
try {
mManager.requestAppFocus(CarAppFocusManager.APP_FOCUS_TYPE_NAVIGATION, null);
@@ -66,6 +81,7 @@
}
}
+ @Test
public void testRegisterNull() throws Exception {
try {
mManager.addFocusListener(null, 0);
@@ -75,6 +91,7 @@
}
}
+ @Test
public void testRegisterUnregister() throws Exception {
FocusChangedListerner listener = new FocusChangedListerner();
FocusChangedListerner listener2 = new FocusChangedListerner();
@@ -84,10 +101,14 @@
mManager.removeFocusListener(listener2);
}
+ @Test
public void testFocusChange() throws Exception {
+ Context context =
+ InstrumentationRegistry.getInstrumentation().getTargetContext();
+
DefaultServiceConnectionListener connectionListener =
new DefaultServiceConnectionListener();
- Car car2 = Car.createCar(getContext(), connectionListener, null);
+ Car car2 = Car.createCar(context, connectionListener, null);
car2.connect();
connectionListener.waitForConnection(DEFAULT_WAIT_TIMEOUT_MS);
CarAppFocusManager manager2 = (CarAppFocusManager)
@@ -216,10 +237,13 @@
manager2.removeFocusListener(change2);
}
+ @Test
public void testFilter() throws Exception {
DefaultServiceConnectionListener connectionListener =
new DefaultServiceConnectionListener();
- Car car2 = Car.createCar(getContext(), connectionListener);
+ Context context =
+ InstrumentationRegistry.getInstrumentation().getTargetContext();
+ Car car2 = Car.createCar(context, connectionListener);
car2.connect();
connectionListener.waitForConnection(DEFAULT_WAIT_TIMEOUT_MS);
CarAppFocusManager manager2 = (CarAppFocusManager)
@@ -274,6 +298,7 @@
CarAppFocusManager.APP_FOCUS_TYPE_NAVIGATION, false));
}
+ @Test
public void testMultipleChangeListenersPerManager() throws Exception {
FocusChangedListerner listener = new FocusChangedListerner();
FocusChangedListerner listener2 = new FocusChangedListerner();
diff --git a/tests/tests/car/src/android/car/cts/CarInfoManagerTest.java b/tests/tests/car/src/android/car/cts/CarInfoManagerTest.java
index e9de083..51cd291 100644
--- a/tests/tests/car/src/android/car/cts/CarInfoManagerTest.java
+++ b/tests/tests/car/src/android/car/cts/CarInfoManagerTest.java
@@ -15,29 +15,38 @@
*/
package android.car.cts;
+import static org.junit.Assert.assertNotNull;
+
import android.car.Car;
import android.car.CarInfoManager;
import android.os.Bundle;
import android.platform.test.annotations.RequiresDevice;
+import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
@SmallTest
@RequiresDevice
+@RunWith(AndroidJUnit4.class)
public class CarInfoManagerTest extends CarApiTestBase {
private CarInfoManager mCarInfoManager;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
mCarInfoManager = (CarInfoManager) getCar().getCarManager(Car.INFO_SERVICE);
}
+ @Test
public void testVehicleId() throws Exception {
assertNotNull(mCarInfoManager.getVehicleId());
}
+ @Test
public void testNullables() throws Exception {
// no guarantee of existence. just call and check if it throws exception.
mCarInfoManager.getManufacturer();
diff --git a/tests/tests/car/src/android/car/cts/CarPackageManagerTest.java b/tests/tests/car/src/android/car/cts/CarPackageManagerTest.java
index 4ba2cbf..0c3aebc 100644
--- a/tests/tests/car/src/android/car/cts/CarPackageManagerTest.java
+++ b/tests/tests/car/src/android/car/cts/CarPackageManagerTest.java
@@ -15,20 +15,35 @@
*/
package android.car.cts;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import android.car.Car;
import android.car.CarNotConnectedException;
import android.car.content.pm.CarPackageManager;
+import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.platform.test.annotations.RequiresDevice;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
import java.util.List;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
@SmallTest
@RequiresDevice
+@RunWith(AndroidJUnit4.class)
public class CarPackageManagerTest extends CarApiTestBase {
private CarPackageManager mCarPm;
@@ -37,14 +52,14 @@
/** Name of the meta-data attribute for the automotive application XML resource */
private static final String METADATA_ATTRIBUTE = "android.car.application";
-
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
mCarPm = (CarPackageManager) getCar().getCarManager(Car.PACKAGE_SERVICE);
}
- public void testActivityDistractionOptimized() throws Exception {
+ @Test
+ public void testActivityDistractionOptimized() throws Exception {
assertFalse(mCarPm.isActivityDistractionOptimized("com.basic.package", "DummyActivity"));
// Real system activity is not allowed as well.
assertFalse(mCarPm.isActivityDistractionOptimized("com.android.phone", "CallActivity"));
@@ -69,8 +84,10 @@
}
}
+ @Test
public void testSystemActivitiesAllowed() throws CarNotConnectedException {
- List<PackageInfo> packages = getContext().getPackageManager().getInstalledPackages(
+ Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ List<PackageInfo> packages = context.getPackageManager().getInstalledPackages(
PackageManager.GET_ACTIVITIES | PackageManager.GET_META_DATA);
for (PackageInfo info : packages) {
@@ -95,6 +112,8 @@
}
}
+ @Test
+ @Ignore // Enable when b/120125891 is fixed
public void testServiceDistractionOptimized() throws Exception {
assertFalse(mCarPm.isServiceDistractionOptimized("com.basic.package", ""));
assertTrue(mCarPm.isServiceDistractionOptimized("com.android.settings", "Any"));
diff --git a/tests/tests/car/src/android/car/cts/CarSensorManagerTest.java b/tests/tests/car/src/android/car/cts/CarSensorManagerTest.java
index 21358a6..3b9d8eb 100644
--- a/tests/tests/car/src/android/car/cts/CarSensorManagerTest.java
+++ b/tests/tests/car/src/android/car/cts/CarSensorManagerTest.java
@@ -16,30 +16,50 @@
package android.car.cts;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotNull;
+
import android.car.Car;
import android.car.hardware.CarSensorEvent;
import android.car.hardware.CarSensorManager;
import android.platform.test.annotations.RequiresDevice;
+import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
+import com.android.compatibility.common.util.CddTest;
+
+import java.util.stream.IntStream;
+
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
@SmallTest
@RequiresDevice
+@RunWith(AndroidJUnit4.class)
public class CarSensorManagerTest extends CarApiTestBase {
- private CarSensorManager mCarSensorManager;
+ private int[] mSupportedSensors;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
super.setUp();
- mCarSensorManager = (CarSensorManager) getCar().getCarManager(Car.SENSOR_SERVICE);
+ CarSensorManager carSensorManager =
+ (CarSensorManager) getCar().getCarManager(Car.SENSOR_SERVICE);
+ mSupportedSensors = carSensorManager.getSupportedSensors();
+ assertNotNull(mSupportedSensors);
}
+ @CddTest(requirement="2.5.1")
+ @Test
+ @Ignore // Enable when b/120125891 is fixed
public void testRequiredSensorsForDrivingState() throws Exception {
- int[] supportedSensors = mCarSensorManager.getSupportedSensors();
- assertNotNull(supportedSensors);
boolean foundSpeed = false;
boolean foundGear = false;
- for (int sensor: supportedSensors) {
+ for (int sensor: mSupportedSensors) {
if (sensor == CarSensorManager.SENSOR_TYPE_CAR_SPEED) {
foundSpeed = true;
} else if ( sensor == CarSensorManager.SENSOR_TYPE_GEAR) {
@@ -51,4 +71,12 @@
}
assertTrue(foundGear && foundSpeed);
}
+
+ @CddTest(requirement="2.5.1")
+ @Test
+ public void testMustSupportNightSensor() {
+ assertTrue("Must support SENSOR_TYPE_NIGHT",
+ IntStream.of(mSupportedSensors)
+ .anyMatch(x -> x == CarSensorManager.SENSOR_TYPE_NIGHT));
+ }
}
diff --git a/tests/tests/car/src/android/car/cts/CarTest.java b/tests/tests/car/src/android/car/cts/CarTest.java
index 61b16bb..e406008 100644
--- a/tests/tests/car/src/android/car/cts/CarTest.java
+++ b/tests/tests/car/src/android/car/cts/CarTest.java
@@ -15,30 +15,53 @@
*/
package android.car.cts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
+
import android.car.Car;
import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.platform.test.annotations.RequiresDevice;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
+import com.android.compatibility.common.util.FeatureUtil;
+
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
@SmallTest
@RequiresDevice
-public class CarTest extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class CarTest {
private static final long DEFAULT_WAIT_TIMEOUT_MS = 2000;
private Car mCar;
private DefaultServiceConnectionListener mServiceConnectionListener;
+ @Before
+ public void setUp() {
+ assumeTrue(FeatureUtil.isAutomotive());
+ }
+
+ @Test
public void testConnection() throws Exception {
mServiceConnectionListener = new DefaultServiceConnectionListener();
- mCar = Car.createCar(getContext(), mServiceConnectionListener);
+ mCar = Car.createCar(
+ InstrumentationRegistry.getInstrumentation().getTargetContext(),
+ mServiceConnectionListener);
assertFalse(mCar.isConnected());
assertFalse(mCar.isConnecting());
mCar.connect();
diff --git a/tests/tests/car/src/android/car/cts/ExceptionsTest.java b/tests/tests/car/src/android/car/cts/ExceptionsTest.java
index 904650f..4a14de9 100644
--- a/tests/tests/car/src/android/car/cts/ExceptionsTest.java
+++ b/tests/tests/car/src/android/car/cts/ExceptionsTest.java
@@ -15,18 +15,35 @@
*/
package android.car.cts;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assume.assumeTrue;
+
import android.car.CarNotConnectedException;
import android.platform.test.annotations.RequiresDevice;
-import android.test.AndroidTestCase;
+import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
+import com.android.compatibility.common.util.FeatureUtil;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
@SmallTest
@RequiresDevice
-public class ExceptionsTest extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class ExceptionsTest {
private static final String MESSAGE = "Oops!";
private static final Exception CAUSE = new RuntimeException();
+ @Before
+ public void setUp() {
+ assumeTrue(FeatureUtil.isAutomotive());
+ }
+
+ @Test
public void testCarNotConnectedException() {
CarNotConnectedException exception = new CarNotConnectedException();
assertNull(exception.getMessage());
diff --git a/tests/tests/carrierapi/src/android/carrierapi/cts/NetworkScanApiTest.java b/tests/tests/carrierapi/src/android/carrierapi/cts/NetworkScanApiTest.java
index 0ed6395..77d2f82 100644
--- a/tests/tests/carrierapi/src/android/carrierapi/cts/NetworkScanApiTest.java
+++ b/tests/tests/carrierapi/src/android/carrierapi/cts/NetworkScanApiTest.java
@@ -184,24 +184,43 @@
}
}
- private RadioAccessSpecifier getRadioAccessSpecifier(CellInfo cellInfo) {
- RadioAccessSpecifier ras;
- if (cellInfo instanceof CellInfoLte) {
- int ranLte = AccessNetworkConstants.AccessNetworkType.EUTRAN;
- int[] lteChannels = {((CellInfoLte) cellInfo).getCellIdentity().getEarfcn()};
- ras = new RadioAccessSpecifier(ranLte, null /* bands */, lteChannels);
- } else if (cellInfo instanceof CellInfoWcdma) {
- int ranLte = AccessNetworkConstants.AccessNetworkType.UTRAN;
- int[] wcdmaChannels = {((CellInfoWcdma) cellInfo).getCellIdentity().getUarfcn()};
- ras = new RadioAccessSpecifier(ranLte, null /* bands */, wcdmaChannels);
- } else if (cellInfo instanceof CellInfoGsm) {
- int ranGsm = AccessNetworkConstants.AccessNetworkType.GERAN;
- int[] gsmChannels = {((CellInfoGsm) cellInfo).getCellIdentity().getArfcn()};
- ras = new RadioAccessSpecifier(ranGsm, null /* bands */, gsmChannels);
- } else {
- ras = null;
+ private List<RadioAccessSpecifier> getRadioAccessSpecifier(List<CellInfo> allCellInfo) {
+ List<RadioAccessSpecifier> radioAccessSpecifier = new ArrayList<>();
+ List<Integer> lteChannels = new ArrayList<>();
+ List<Integer> wcdmaChannels = new ArrayList<>();
+ List<Integer> gsmChannels = new ArrayList<>();
+ for (int i = 0; i < allCellInfo.size(); i++) {
+ CellInfo cellInfo = allCellInfo.get(i);
+ if (cellInfo instanceof CellInfoLte) {
+ lteChannels.add(((CellInfoLte) cellInfo).getCellIdentity().getEarfcn());
+ } else if (cellInfo instanceof CellInfoWcdma) {
+ wcdmaChannels.add(((CellInfoWcdma) cellInfo).getCellIdentity().getUarfcn());
+ } else if (cellInfo instanceof CellInfoGsm) {
+ gsmChannels.add(((CellInfoGsm) cellInfo).getCellIdentity().getArfcn());
+ }
}
- return ras;
+ if (!lteChannels.isEmpty()) {
+ Log.d(TAG, "lte channels" + lteChannels.toString());
+ int ranLte = AccessNetworkConstants.AccessNetworkType.EUTRAN;
+ radioAccessSpecifier.add(
+ new RadioAccessSpecifier(ranLte, null /* bands */,
+ lteChannels.stream().mapToInt(i->i).toArray()));
+ }
+ if (!wcdmaChannels.isEmpty()) {
+ Log.d(TAG, "wcdma channels" + wcdmaChannels.toString());
+ int ranWcdma = AccessNetworkConstants.AccessNetworkType.UTRAN;
+ radioAccessSpecifier.add(
+ new RadioAccessSpecifier(ranWcdma, null /* bands */,
+ wcdmaChannels.stream().mapToInt(i->i).toArray()));
+ }
+ if (!gsmChannels.isEmpty()) {
+ Log.d(TAG, "gsm channels" + gsmChannels.toString());
+ int ranGsm = AccessNetworkConstants.AccessNetworkType.GERAN;
+ radioAccessSpecifier.add(
+ new RadioAccessSpecifier(ranGsm, null /* bands */,
+ gsmChannels.stream().mapToInt(i->i).toArray()));
+ }
+ return radioAccessSpecifier;
}
/**
@@ -228,14 +247,9 @@
}
// Construct a NetworkScanRequest
- List<RadioAccessSpecifier> radioAccessSpecifier = new ArrayList<>();
- for (int i = 0; i < allCellInfo.size(); i++) {
- RadioAccessSpecifier ras = getRadioAccessSpecifier(allCellInfo.get(i));
- if (ras != null) {
- radioAccessSpecifier.add(ras);
- }
- }
- if (radioAccessSpecifier.size() == 0) {
+ List<RadioAccessSpecifier> radioAccessSpecifier = getRadioAccessSpecifier(allCellInfo);
+ Log.d(TAG, "number of radioAccessSpecifier: " + radioAccessSpecifier.size());
+ if (radioAccessSpecifier.isEmpty()) {
RadioAccessSpecifier gsm = new RadioAccessSpecifier(
AccessNetworkConstants.AccessNetworkType.GERAN,
null /* bands */,
@@ -301,7 +315,7 @@
* To test its constructor and getters.
*/
@Test
- public void testNetworkScanRequest_ConstructorAndGetters(){
+ public void testNetworkScanRequest_ConstructorAndGetters() {
NetworkScanRequest networkScanRequest = new NetworkScanRequest(
SCAN_TYPE,
RADIO_ACCESS_SPECIFIERS,
diff --git a/tests/tests/contactsproviderwipe/src/android/provider/cts/contactsproviderwipe/ContactsContract_Wipe.java b/tests/tests/contactsproviderwipe/src/android/provider/cts/contactsproviderwipe/ContactsContract_Wipe.java
index 713e547..1981853 100644
--- a/tests/tests/contactsproviderwipe/src/android/provider/cts/contactsproviderwipe/ContactsContract_Wipe.java
+++ b/tests/tests/contactsproviderwipe/src/android/provider/cts/contactsproviderwipe/ContactsContract_Wipe.java
@@ -133,7 +133,7 @@
final String result = concatResult(readAll(
InstrumentationRegistry.getInstrumentation().getUiAutomation().executeShellCommand(
- "pm clear " + providerPackage)));
+ "pm clear --user current " + providerPackage)));
Log.i(TAG, "Result:" + result);
assertEquals("Success", result);
diff --git a/tests/tests/content/src/android/content/cts/ContextWrapperTest.java b/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
index 408855d..a01e9e0 100644
--- a/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
+++ b/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
@@ -340,7 +340,6 @@
// Test databaseList()
List<String> list = Arrays.asList(mContextWrapper.databaseList());
- assertEquals(2, list.size());
assertTrue("1) database list: " + list, list.contains(DATABASE_NAME1));
assertTrue("2) database list: " + list, list.contains(DATABASE_NAME2));
diff --git a/tests/tests/dpi/Android.mk b/tests/tests/dpi/Android.mk
index 951827d..960bed8 100644
--- a/tests/tests/dpi/Android.mk
+++ b/tests/tests/dpi/Android.mk
@@ -17,7 +17,7 @@
include $(CLEAR_VARS)
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner junit
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner junit compatibility-device-util
LOCAL_JAVA_LIBRARIES := android.test.runner.stubs android.test.base.stubs
diff --git a/tests/tests/dpi/src/android/dpi/cts/ConfigurationScreenLayoutTest.java b/tests/tests/dpi/src/android/dpi/cts/ConfigurationScreenLayoutTest.java
index d7c9366..a7b2692 100644
--- a/tests/tests/dpi/src/android/dpi/cts/ConfigurationScreenLayoutTest.java
+++ b/tests/tests/dpi/src/android/dpi/cts/ConfigurationScreenLayoutTest.java
@@ -49,6 +49,14 @@
tearDown();
return;
}
+ if (isPC()) {
+ // The test skips mainly for Chromebook clamshell mode. For Chromebook clamshell mode
+ // with non-rotated landscape physical screen, the portrait window/activity has special
+ // behavior with black background on both sides to make the window/activity look
+ // portrait, which returns smaller screen layout size.
+ tearDown();
+ return;
+ }
int expectedScreenLayout = computeScreenLayout();
int expectedSize = expectedScreenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
int expectedLong = expectedScreenLayout & Configuration.SCREENLAYOUT_LONG_MASK;
@@ -163,4 +171,9 @@
return (supportsLandscape && supportsPortrait)
|| (!supportsLandscape && !supportsPortrait);
}
+
+ // Check if it is a PC device
+ private boolean isPC() {
+ return hasDeviceFeature(PackageManager.FEATURE_PC);
+ }
}
diff --git a/tests/tests/dpi/src/android/dpi/cts/ConfigurationTest.java b/tests/tests/dpi/src/android/dpi/cts/ConfigurationTest.java
index 144bdde..7ac5246 100644
--- a/tests/tests/dpi/src/android/dpi/cts/ConfigurationTest.java
+++ b/tests/tests/dpi/src/android/dpi/cts/ConfigurationTest.java
@@ -24,6 +24,9 @@
import android.view.Display;
import android.view.WindowManager;
+import com.android.compatibility.common.util.CddTest;
+import com.android.compatibility.common.util.FeatureUtil;
+
import java.util.HashSet;
import java.util.Set;
@@ -32,26 +35,35 @@
*/
public class ConfigurationTest extends AndroidTestCase {
- @Presubmit
- public void testScreenConfiguration() {
+ private DisplayMetrics mMetrics;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
WindowManager windowManager =
(WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
Display display = windowManager.getDefaultDisplay();
- DisplayMetrics metrics = new DisplayMetrics();
- display.getMetrics(metrics);
+ mMetrics = new DisplayMetrics();
+ display.getMetrics(mMetrics);
+ }
- double xInches = (double) metrics.widthPixels / metrics.xdpi;
- double yInches = (double) metrics.heightPixels / metrics.ydpi;
+ @Presubmit
+ public void testScreenConfiguration() {
+ double xInches = (double) mMetrics.widthPixels / mMetrics.xdpi;
+ double yInches = (double) mMetrics.heightPixels / mMetrics.ydpi;
double diagonalInches = Math.sqrt(Math.pow(xInches, 2) + Math.pow(yInches, 2));
double minSize = 2.5d;
- if (getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) {
+ if (FeatureUtil.isWatch()) {
// Watches have a different minimum diagonal.
minSize = 1.0d;
+ } else if (FeatureUtil.isAutomotive()) {
+ // Cars have a different minimum diagonal.
+ minSize = 6.0d;
}
assertTrue("Screen diagonal must be at least " + minSize + " inches: " + diagonalInches,
diagonalInches >= minSize);
- double density = 160.0d * metrics.density;
+ double density = 160.0d * mMetrics.density;
assertTrue("Screen density must be at least 100 dpi: " + density, density >= 100.0d);
Set<Integer> allowedDensities = new HashSet<Integer>();
@@ -72,10 +84,22 @@
allowedDensities.add(DisplayMetrics.DENSITY_560);
allowedDensities.add(DisplayMetrics.DENSITY_XXXHIGH);
assertTrue("DisplayMetrics#densityDpi must be one of the DisplayMetrics.DENSITY_* values: "
- + allowedDensities, allowedDensities.contains(metrics.densityDpi));
+ + allowedDensities, allowedDensities.contains(mMetrics.densityDpi));
- assertEquals(metrics.density,
- (float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT,
+ assertEquals(mMetrics.density,
+ (float) mMetrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT,
0.5f / DisplayMetrics.DENSITY_DEFAULT);
}
+
+ @CddTest(requirement="2.5.1")
+ public void testAutomotiveMinimumScreenSize() {
+ if (!FeatureUtil.isAutomotive()) {
+ return;
+ }
+ float dpHeight = mMetrics.heightPixels / mMetrics.density;
+ float dpWidth = mMetrics.widthPixels / mMetrics.density;
+
+ assertTrue("Height must be >= 480dp, found: " + dpHeight, dpHeight >= 480);
+ assertTrue("Width must be >= 750dp, found: " + dpWidth, dpWidth >= 750);
+ }
}
diff --git a/tests/tests/dpi2/Android.mk b/tests/tests/dpi2/Android.mk
index de8f65a..f366781 100644
--- a/tests/tests/dpi2/Android.mk
+++ b/tests/tests/dpi2/Android.mk
@@ -33,6 +33,6 @@
LOCAL_SDK_VERSION := current
# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests cts_instant
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/graphics/jni/VulkanPreTransformTestHelpers.cpp b/tests/tests/graphics/jni/VulkanPreTransformTestHelpers.cpp
index 7019ea4..beaa315 100644
--- a/tests/tests/graphics/jni/VulkanPreTransformTestHelpers.cpp
+++ b/tests/tests/graphics/jni/VulkanPreTransformTestHelpers.cpp
@@ -246,7 +246,7 @@
}
}
-int32_t SwapchainInfo::init(bool setPreTransform) {
+int32_t SwapchainInfo::init(bool setPreTransform, int* outPreTransformHint) {
VkSurfaceCapabilitiesKHR surfaceCapabilities;
VK_CALL(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(mDeviceInfo->gpu(), mDeviceInfo->surface(),
&surfaceCapabilities));
@@ -297,6 +297,10 @@
std::swap(mDisplaySize.width, mDisplaySize.height);
}
+ if (outPreTransformHint) {
+ *outPreTransformHint = preTransform;
+ }
+
const uint32_t queueFamilyIndex = mDeviceInfo->queueFamilyIndex();
const VkSwapchainCreateInfoKHR swapchainCreateInfo = {
.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
diff --git a/tests/tests/graphics/jni/VulkanPreTransformTestHelpers.h b/tests/tests/graphics/jni/VulkanPreTransformTestHelpers.h
index f876aad..21174b4 100644
--- a/tests/tests/graphics/jni/VulkanPreTransformTestHelpers.h
+++ b/tests/tests/graphics/jni/VulkanPreTransformTestHelpers.h
@@ -54,7 +54,7 @@
public:
SwapchainInfo(const DeviceInfo* const deviceInfo);
~SwapchainInfo();
- int32_t init(bool setPreTransform);
+ int32_t init(bool setPreTransform, int* outPreTransformHint);
VkFormat format() const { return mFormat; }
VkExtent2D displaySize() const { return mDisplaySize; }
VkSwapchainKHR swapchain() const { return mSwapchain; }
diff --git a/tests/tests/graphics/jni/android_graphics_cts_BasicVulkanGpuTest.cpp b/tests/tests/graphics/jni/android_graphics_cts_BasicVulkanGpuTest.cpp
index c9ed883..6c90941 100644
--- a/tests/tests/graphics/jni/android_graphics_cts_BasicVulkanGpuTest.cpp
+++ b/tests/tests/graphics/jni/android_graphics_cts_BasicVulkanGpuTest.cpp
@@ -75,9 +75,6 @@
// Could not initialize Vulkan due to lack of device support, skip test.
return;
}
- VkImageRenderer renderer(&init, kTestImageWidth, kTestImageHeight,
- formatDesc.vkFormat, formatDesc.pixelWidth);
- ASSERT(renderer.init(env, assetMgr), "Unable to initialize VkRenderer.");
// Create and initialize buffer based on parameters.
AHardwareBuffer_Desc hwbDesc{
@@ -96,6 +93,10 @@
return;
}
+ VkImageRenderer renderer(&init, kTestImageWidth, kTestImageHeight,
+ formatDesc.vkFormat, formatDesc.pixelWidth);
+ ASSERT(renderer.init(env, assetMgr), "Unable to initialize VkRenderer.");
+
// Populate the buffer with well-defined data.
AHardwareBuffer_describe(buffer, &hwbDesc);
uint8_t *bufferAddr;
diff --git a/tests/tests/graphics/jni/android_graphics_cts_CameraVulkanGpuTest.cpp b/tests/tests/graphics/jni/android_graphics_cts_CameraVulkanGpuTest.cpp
index f96e39c..24721c3 100644
--- a/tests/tests/graphics/jni/android_graphics_cts_CameraVulkanGpuTest.cpp
+++ b/tests/tests/graphics/jni/android_graphics_cts_CameraVulkanGpuTest.cpp
@@ -33,16 +33,6 @@
AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE;
static constexpr uint32_t kTestImageCount = 3;
-// Checks if a vector has more than 10 unique values, in which case we consider
-// it noisy.
-bool isNoisy(const std::vector<uint32_t> &data) {
- std::set<uint32_t> values_seen;
- for (uint32_t value : data) {
- values_seen.insert(value);
- }
- return values_seen.size() > 10;
-}
-
} // namespace
// A basic test which does the following:
@@ -94,8 +84,7 @@
vkImage.semaphore(), vkImage.isSamplerImmutable(), &imageData),
"Could not render/read-back Vulkan pixels.");
- // Ensure that we see noise.
- ASSERT(isNoisy(imageData), "Camera data should be noisy.");
+ // TODO(b/110025779): We should find a way to validate pixels.
}
static JNINativeMethod gMethods[] = {
diff --git a/tests/tests/graphics/jni/android_graphics_cts_VulkanPreTransformCtsActivity.cpp b/tests/tests/graphics/jni/android_graphics_cts_VulkanPreTransformCtsActivity.cpp
index 2a347b2..16fc851 100644
--- a/tests/tests/graphics/jni/android_graphics_cts_VulkanPreTransformCtsActivity.cpp
+++ b/tests/tests/graphics/jni/android_graphics_cts_VulkanPreTransformCtsActivity.cpp
@@ -33,14 +33,14 @@
namespace {
-jboolean validatePixelValues(JNIEnv* env, jboolean setPreTransform) {
+jboolean validatePixelValues(JNIEnv* env, jboolean setPreTransform, jint preTransformHint) {
jclass clazz = env->FindClass("android/graphics/cts/VulkanPreTransformTest");
- jmethodID mid = env->GetStaticMethodID(clazz, "validatePixelValuesAfterRotation", "(Z)Z");
+ jmethodID mid = env->GetStaticMethodID(clazz, "validatePixelValuesAfterRotation", "(ZI)Z");
if (mid == 0) {
ALOGE("Failed to find method ID");
return false;
}
- return env->CallStaticBooleanMethod(clazz, mid, setPreTransform);
+ return env->CallStaticBooleanMethod(clazz, mid, setPreTransform, preTransformHint);
}
void createNativeTest(JNIEnv* env, jclass /*clazz*/, jobject jAssetManager, jobject jSurface,
@@ -50,6 +50,7 @@
ASSERT(jSurface, "jSurface is NULL");
DeviceInfo deviceInfo;
+ int preTransformHint;
int ret = deviceInfo.init(env, jSurface);
ASSERT(ret >= 0, "Failed to initialize Vulkan device");
if (ret > 0) {
@@ -58,7 +59,7 @@
}
SwapchainInfo swapchainInfo(&deviceInfo);
- ASSERT(!swapchainInfo.init(setPreTransform), "Failed to initialize Vulkan swapchain");
+ ASSERT(!swapchainInfo.init(setPreTransform, &preTransformHint), "Failed to initialize Vulkan swapchain");
Renderer renderer(&deviceInfo, &swapchainInfo);
ASSERT(!renderer.init(env, jAssetManager), "Failed to initialize Vulkan renderer");
@@ -67,7 +68,7 @@
ASSERT(!renderer.drawFrame(), "Failed to draw frame");
}
- ASSERT(validatePixelValues(env, setPreTransform), "Not properly rotated");
+ ASSERT(validatePixelValues(env, setPreTransform, preTransformHint), "Not properly rotated");
}
const std::array<JNINativeMethod, 1> JNI_METHODS = {{
diff --git a/tests/tests/graphics/src/android/graphics/cts/CameraVulkanGpuTest.java b/tests/tests/graphics/src/android/graphics/cts/CameraVulkanGpuTest.java
index 5906c899..8598b84 100644
--- a/tests/tests/graphics/src/android/graphics/cts/CameraVulkanGpuTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/CameraVulkanGpuTest.java
@@ -24,6 +24,9 @@
import org.junit.Test;
import org.junit.runner.RunWith;
+import android.os.Build;
+import com.android.compatibility.common.util.PropertyUtil;
+
@SmallTest
@RunWith(AndroidJUnit4.class)
public class CameraVulkanGpuTest {
@@ -40,6 +43,11 @@
return;
}
+ if(PropertyUtil.getFirstApiLevel() < Build.VERSION.SDK_INT){
+ // HAL3 is not required for P upgrade devices.
+ return;
+ }
+
loadCameraAndVerifyFrameImport(InstrumentationRegistry.getContext().getAssets());
}
diff --git a/tests/tests/graphics/src/android/graphics/cts/VulkanPreTransformCtsActivity.java b/tests/tests/graphics/src/android/graphics/cts/VulkanPreTransformCtsActivity.java
index 0194044..32cb757 100644
--- a/tests/tests/graphics/src/android/graphics/cts/VulkanPreTransformCtsActivity.java
+++ b/tests/tests/graphics/src/android/graphics/cts/VulkanPreTransformCtsActivity.java
@@ -57,18 +57,15 @@
return;
}
- if (((WindowManager) getSystemService(Context.WINDOW_SERVICE))
- .getDefaultDisplay()
- .getRotation()
- != Surface.ROTATION_0) {
- throw new RuntimeException("Display not in natural orientation");
+ if (getRotation() == Surface.ROTATION_0) {
+ if (getResources().getConfiguration().orientation
+ == Configuration.ORIENTATION_LANDSCAPE) {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+ } else {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+ }
}
- if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
- } else {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
- }
sOrientationRequested = true;
}
diff --git a/tests/tests/graphics/src/android/graphics/cts/VulkanPreTransformTest.java b/tests/tests/graphics/src/android/graphics/cts/VulkanPreTransformTest.java
index 06f92d3..d368f0e 100644
--- a/tests/tests/graphics/src/android/graphics/cts/VulkanPreTransformTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/VulkanPreTransformTest.java
@@ -19,16 +19,18 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import android.content.Context;
+import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.SystemClock;
+import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
import android.util.Log;
import android.view.PixelCopy;
-import android.view.Surface;
import android.view.SurfaceView;
import com.android.compatibility.common.util.SynchronousPixelCopy;
@@ -41,7 +43,7 @@
/*
* testVulkanPreTransformSetToMatchCurrentTransform()
*
- * For devices rotating 90 degree CW when orientation changes.
+ * For devices rotating 90 degrees.
*
* Buffer Screen
* --------- ---------
@@ -50,7 +52,16 @@
* | B | Y | | R | B |
* --------- ---------
*
- * For devices rotating 90 degree CCW when orientation changes.
+ * For devices rotating 180 degrees.
+ *
+ * Buffer Screen
+ * --------- ---------
+ * | R | G | | Y | B |
+ * --------- ---------
+ * | B | Y | | G | R |
+ * --------- ---------
+ *
+ * For devices rotating 270 degrees.
*
* Buffer Screen
* --------- ---------
@@ -59,6 +70,15 @@
* | B | Y | | Y | G |
* --------- ---------
*
+ * For devices not rotating.
+ *
+ * Buffer Screen
+ * --------- ---------
+ * | R | G | | R | G |
+ * --------- ---------
+ * | B | Y | | B | Y |
+ * --------- ---------
+ *
* testVulkanPreTransformNotSetToMatchCurrentTransform()
*
* Buffer Screen
@@ -75,6 +95,7 @@
private static final String TAG = "vulkan";
private static final boolean DEBUG = false;
private static VulkanPreTransformCtsActivity sActivity = null;
+ private Context mContext;
@Rule
public ActivityTestRule<VulkanPreTransformCtsActivity> mActivityRule =
@@ -86,11 +107,17 @@
// Work around for b/77148807
// Activity was falsely created before ActivityManager set config change to landscape
SystemClock.sleep(2000);
+ mContext = InstrumentationRegistry.getContext();
}
@Test
public void testVulkanPreTransformSetToMatchCurrentTransform() throws Throwable {
Log.d(TAG, "testVulkanPreTransformSetToMatchCurrentTransform start");
+ if (!hasDeviceFeature(PackageManager.FEATURE_SCREEN_PORTRAIT)
+ || !hasDeviceFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE)) {
+ Log.d(TAG, "Rotation is not supported on this device.");
+ return;
+ }
sActivity = mActivityRule.launchActivity(null);
sActivity.testVulkanPreTransform(true);
sActivity.finish();
@@ -100,12 +127,21 @@
@Test
public void testVulkanPreTransformNotSetToMatchCurrentTransform() throws Throwable {
Log.d(TAG, "testVulkanPreTransformNotSetToMatchCurrentTransform start");
+ if (!hasDeviceFeature(PackageManager.FEATURE_SCREEN_PORTRAIT)
+ || !hasDeviceFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE)) {
+ Log.d(TAG, "Rotation is not supported on this device.");
+ return;
+ }
sActivity = mActivityRule.launchActivity(null);
sActivity.testVulkanPreTransform(false);
sActivity.finish();
sActivity = null;
}
+ private boolean hasDeviceFeature(final String requiredFeature) {
+ return mContext.getPackageManager().hasSystemFeature(requiredFeature);
+ }
+
private static Bitmap takeScreenshot() {
assertNotNull("sActivity should not be null", sActivity);
Rect srcRect = new Rect();
@@ -130,29 +166,33 @@
+ Math.abs(actualB - expectedB);
}
- private static boolean validatePixelValuesAfterRotation(boolean setPreTransform) {
+ private static boolean validatePixelValuesAfterRotation(
+ boolean setPreTransform, int preTransformHint) {
Bitmap bitmap = takeScreenshot();
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int diff = 0;
- if (!setPreTransform) {
+ if (!setPreTransform || preTransformHint == 0x1 /*VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR*/) {
diff += pixelDiff(bitmap.getPixel(0, 0), 255, 0, 0);
diff += pixelDiff(bitmap.getPixel(width - 1, 0), 0, 255, 0);
diff += pixelDiff(bitmap.getPixel(0, height - 1), 0, 0, 255);
diff += pixelDiff(bitmap.getPixel(width - 1, height - 1), 255, 255, 0);
- } else if (sActivity.getRotation() == Surface.ROTATION_270) {
- // For devices rotating 90 degree CCW when orientation changes.
- diff += pixelDiff(bitmap.getPixel(0, 0), 0, 0, 255);
- diff += pixelDiff(bitmap.getPixel(width - 1, 0), 255, 0, 0);
- diff += pixelDiff(bitmap.getPixel(0, height - 1), 255, 255, 0);
- diff += pixelDiff(bitmap.getPixel(width - 1, height - 1), 0, 255, 0);
- } else {
- // For devices rotating 90 degree CW when orientation changes.
+ } else if (preTransformHint == 0x2 /*VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR*/) {
diff += pixelDiff(bitmap.getPixel(0, 0), 0, 255, 0);
diff += pixelDiff(bitmap.getPixel(width - 1, 0), 255, 255, 0);
diff += pixelDiff(bitmap.getPixel(0, height - 1), 255, 0, 0);
diff += pixelDiff(bitmap.getPixel(width - 1, height - 1), 0, 0, 255);
+ } else if (preTransformHint == 0x4 /*VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR*/) {
+ diff += pixelDiff(bitmap.getPixel(0, 0), 255, 255, 0);
+ diff += pixelDiff(bitmap.getPixel(width - 1, 0), 0, 0, 255);
+ diff += pixelDiff(bitmap.getPixel(0, height - 1), 0, 255, 0);
+ diff += pixelDiff(bitmap.getPixel(width - 1, height - 1), 255, 0, 0);
+ } else { /* 0x8 : VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR*/
+ diff += pixelDiff(bitmap.getPixel(0, 0), 0, 0, 255);
+ diff += pixelDiff(bitmap.getPixel(width - 1, 0), 255, 0, 0);
+ diff += pixelDiff(bitmap.getPixel(0, height - 1), 255, 255, 0);
+ diff += pixelDiff(bitmap.getPixel(width - 1, height - 1), 0, 255, 0);
}
return diff < 10;
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/AnimatedImageDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/AnimatedImageDrawableTest.java
index a3f116e..3780124 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/AnimatedImageDrawableTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/AnimatedImageDrawableTest.java
@@ -350,7 +350,12 @@
drawable.start();
assertTrue(drawable.isRunning());
+ });
+ cb.waitForStart();
+ cb.assertStarted(true);
+
+ mActivityRule.runOnUiThread(() -> {
drawable.stop();
assertFalse(drawable.isRunning());
});
@@ -358,7 +363,6 @@
// This duration may be overkill, but we need to wait for the message
// to post. Increasing it should help with flakiness on bots.
cb.waitForEnd(DURATION * 3);
- cb.assertStarted(true);
cb.assertEnded(true);
}
diff --git a/tests/tests/hardware/src/android/hardware/cts/LowRamDeviceTest.java b/tests/tests/hardware/src/android/hardware/cts/LowRamDeviceTest.java
index 82756d1..da9fca8 100644
--- a/tests/tests/hardware/src/android/hardware/cts/LowRamDeviceTest.java
+++ b/tests/tests/hardware/src/android/hardware/cts/LowRamDeviceTest.java
@@ -147,7 +147,7 @@
}
@Test
- @CddTest(requirement="7.6.2")
+ @CddTest(requirement="7.6.2/H-0-1")
public void testMinSharedDataPartitionSize() {
assertDataPartitionMinimumSize(
"Shared data",
@@ -156,7 +156,7 @@
}
@Test
- @CddTest(requirement="7.6.1/H-9-2,7.6.1/H-10-1")
+ @CddTest(requirement="7.6.1/H-9-2,T-0-1,A-0-1,7.6.1/H-10-1")
public void testMinDataPartitionSize() {
long totalMemoryMb = getTotalMemory() / ONE_MEGABYTE;
boolean lowRam = totalMemoryMb <= LOW_RAM_MAX;
diff --git a/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java b/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java
index a30db52..1bc5f8c 100644
--- a/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java
+++ b/tests/tests/jni/src/android/jni/cts/LinkerNamespacesHelper.java
@@ -40,9 +40,7 @@
private final static String PRODUCT_CONFIG_DIR = "/product/etc/";
private final static String SYSTEM_CONFIG_FILE = PUBLIC_CONFIG_DIR + "public.libraries.txt";
private final static Pattern EXTENSION_CONFIG_FILE_PATTERN = Pattern.compile(
- "public\\.libraries-([A-Za-z0-9\\-_]+)\\.txt");
- private final static Pattern EXTENSION_LIBRARY_FILE_PATTERN = Pattern.compile(
- "lib[^.]+\\.([A-Za-z0-9\\-_]+)\\.so");
+ "public\\.libraries-([A-Za-z0-9\\-_.]+)\\.txt");
private final static String VENDOR_CONFIG_FILE = "/vendor/etc/public.libraries.txt";
private final static String[] PUBLIC_SYSTEM_LIBRARIES = {
"libaaudio.so",
@@ -126,8 +124,12 @@
// libFoo.acme.so
List<String> libNames = readPublicLibrariesFile(configFile);
for (String lib : libNames) {
- Matcher libMatcher = EXTENSION_LIBRARY_FILE_PATTERN.matcher(lib);
- if (libMatcher.matches() && libMatcher.group(1).equals(companyName)) {
+ int space = lib.lastIndexOf(' ');
+ if (space != -1) {
+ // Drop 64 or 32 from 'libFoo.so 64'
+ lib = lib.substring(0, space);
+ }
+ if (lib.endsWith("." + companyName + ".so")) {
libs.add(lib);
} else {
return "Library \"" + lib + "\" in " + configFile.toString()
diff --git a/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java b/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java
index 7db0f61..4bd6965 100644
--- a/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java
+++ b/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java
@@ -1345,46 +1345,6 @@
assertPrivateKeyEntryEquals(actual, "RSA", FAKE_RSA_KEY_1, FAKE_RSA_USER_1, FAKE_RSA_CA_1);
}
- public void testKeyStore_SetEntry_PrivateKeyEntry_Params_Unencrypted_Failure() throws Exception {
- // The Android Keystore requires encrypted storage which is only decryptable with a key
- // bound to a credential provided by the user. By default, the Keystore waits for the user
- // to set a lock screen PIN or password and uses this credential to set up an encrypted
- // storage space itself. In that implementation, the Keystore should not be initialized when
- // no lock screen PIN or password has been set. This is what the test verifies.
- //
- // If your environment already provides encrypted storage which is only decryptable with a
- // key bound to another credential provided by the user, you may initialize the Keystore
- // immediately and get a waiver for this test.
- KeyguardManager keyguardManager =
- (KeyguardManager) getContext().getSystemService(Context.KEYGUARD_SERVICE);
- assertNotNull(keyguardManager);
- assertFalse("Secure lock screen must not be configured", keyguardManager.isDeviceSecure());
-
- mKeyStore.load(null, null);
-
- KeyFactory keyFact = KeyFactory.getInstance("RSA");
- PrivateKey expectedKey = keyFact.generatePrivate(new PKCS8EncodedKeySpec(FAKE_RSA_KEY_1));
-
- final CertificateFactory f = CertificateFactory.getInstance("X.509");
-
- final Certificate[] expectedChain = new Certificate[2];
- expectedChain[0] = f.generateCertificate(new ByteArrayInputStream(FAKE_RSA_USER_1));
- expectedChain[1] = f.generateCertificate(new ByteArrayInputStream(FAKE_RSA_CA_1));
-
- PrivateKeyEntry entry = new PrivateKeyEntry(expectedKey, expectedChain);
-
- try {
- mKeyStore.setEntry(TEST_ALIAS_1, entry,
- new KeyStoreParameter.Builder(getContext())
- .setEncryptionRequired(true)
- .build());
- fail("Shouldn't be able to insert encrypted entry when KeyStore uninitialized");
- } catch (KeyStoreException expected) {
- }
-
- assertNull(mKeyStore.getEntry(TEST_ALIAS_1, null));
- }
-
public void testKeyStore_SetEntry_PrivateKeyEntry_Overwrites_PrivateKeyEntry_Unencrypted_Success()
throws Exception {
mKeyStore.load(null, null);
diff --git a/tests/tests/keystore/src/android/keystore/cts/CipherTest.java b/tests/tests/keystore/src/android/keystore/cts/CipherTest.java
index e75a60f..3f9f758 100644
--- a/tests/tests/keystore/src/android/keystore/cts/CipherTest.java
+++ b/tests/tests/keystore/src/android/keystore/cts/CipherTest.java
@@ -279,7 +279,10 @@
public void performDeviceLock() {
mLockCredential.sleepDevice();
- SystemClock.sleep(200);
+ KeyguardManager keyguardManager = (KeyguardManager)getContext().getSystemService(Context.KEYGUARD_SERVICE);
+ for (int i = 0; i < 25 && !keyguardManager.isDeviceLocked(); i++) {
+ SystemClock.sleep(200);
+ }
}
public void performDeviceUnlock() throws Exception {
diff --git a/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java b/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java
index 80e28d1..6b925d4 100644
--- a/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java
+++ b/tests/tests/keystore/src/android/keystore/cts/KeyAttestationTest.java
@@ -690,6 +690,7 @@
case 2:
case 3:
+ case 4:
assertThat(teeEnforcedDigests, is(expectedDigests));
break;
diff --git a/tests/tests/location/src/android/location/cts/GnssLocationValuesTest.java b/tests/tests/location/src/android/location/cts/GnssLocationValuesTest.java
index d2499a0..2d64612 100644
--- a/tests/tests/location/src/android/location/cts/GnssLocationValuesTest.java
+++ b/tests/tests/location/src/android/location/cts/GnssLocationValuesTest.java
@@ -63,6 +63,13 @@
* only test them if the hardware is later than 2017
*/
public void testAccuracyFields() throws Exception {
+ // Checks if GPS hardware feature is present, skips test (pass) if not,
+ // and hard asserts that Location/GPS (Provider) is turned on if is Cts Verifier.
+ if (!TestMeasurementUtil.canTestRunOnCurrentDevice(mTestLocationManager,
+ TAG, MIN_HARDWARE_YEAR_MEASUREMENTS_REQUIRED, isCtsVerifierTest())) {
+ return;
+ }
+
SoftAssert softAssert = new SoftAssert(TAG);
mTestLocationManager.requestLocationUpdates(mLocationListener);
boolean success = mLocationListener.await();
@@ -122,6 +129,13 @@
* check whether all fields' value make sense
*/
public void testLocationRegularFields() throws Exception {
+ // Checks if GPS hardware feature is present, skips test (pass) if not,
+ // and hard asserts that Location/GPS (Provider) is turned on if is Cts Verifier.
+ if (!TestMeasurementUtil.canTestRunOnCurrentDevice(mTestLocationManager,
+ TAG, MIN_HARDWARE_YEAR_MEASUREMENTS_REQUIRED, isCtsVerifierTest())) {
+ return;
+ }
+
mTestLocationManager.requestLocationUpdates(mLocationListener);
boolean success = mLocationListener.await();
SoftAssert.failOrWarning(isMeasurementTestStrict(),
diff --git a/tests/tests/location/src/android/location/cts/GnssMeasurementValuesTest.java b/tests/tests/location/src/android/location/cts/GnssMeasurementValuesTest.java
index 216989f..8e2c3f8 100644
--- a/tests/tests/location/src/android/location/cts/GnssMeasurementValuesTest.java
+++ b/tests/tests/location/src/android/location/cts/GnssMeasurementValuesTest.java
@@ -20,6 +20,8 @@
import android.location.GnssMeasurementsEvent;
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
+
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -76,6 +78,7 @@
* It only performs sanity checks for the measurements received.
* This tests uses actual data retrieved from GPS HAL.
*/
+ @CddTest(requirement="7.3.3/C-3-2,C-3-3")
public void testListenForGnssMeasurements() throws Exception {
// Checks if GPS hardware feature is present, skips test (pass) if not,
// and hard asserts that Location/GPS (Provider) is turned on if is Cts Verifier.
diff --git a/tests/tests/location/src/android/location/cts/GnssMeasurementWhenNoLocationTest.java b/tests/tests/location/src/android/location/cts/GnssMeasurementWhenNoLocationTest.java
index 5edca64..9af7a7d 100644
--- a/tests/tests/location/src/android/location/cts/GnssMeasurementWhenNoLocationTest.java
+++ b/tests/tests/location/src/android/location/cts/GnssMeasurementWhenNoLocationTest.java
@@ -22,6 +22,8 @@
import android.platform.test.annotations.AppModeFull;
import android.util.Log;
+import com.android.compatibility.common.util.SystemUtil;
+
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
@@ -100,91 +102,115 @@
return;
}
- // Clear A-GPS and skip the test if the operation fails.
- if (!mTestLocationManager.sendExtraCommand(AGPS_DELETE_COMMAND)) {
- Log.i(TAG, "A-GPS failed to clear. Skip test.");
- return;
+ // Set the device in airplane mode so that the GPS assistance data cannot be downloaded.
+ // This results in GNSS measurements being reported before a location is reported.
+ // NOTE: Changing global setting airplane_mode_on is not allowed in CtsVerifier application.
+ // Hence, airplane mode is turned on only when this test is run as a regular CTS test
+ // and not when it is invoked through CtsVerifier.
+ boolean isAirplaneModeOffBeforeTest = true;
+ if (!isCtsVerifierTest()) {
+ // Record the state of the airplane mode before the test so that we can restore it
+ // after the test.
+ isAirplaneModeOffBeforeTest = !TestUtils.isAirplaneModeOn();
+ if (isAirplaneModeOffBeforeTest) {
+ TestUtils.setAirplaneModeOn(getContext(), true);
+ }
}
- // Register for GPS measurements.
- mMeasurementListener = new TestGnssMeasurementListener(TAG, EVENTS_COUNT);
- mTestLocationManager.registerGnssMeasurementCallback(mMeasurementListener);
+ try {
+ // Clear A-GPS and skip the test if the operation fails.
+ if (!mTestLocationManager.sendExtraCommand(AGPS_DELETE_COMMAND)) {
+ Log.i(TAG, "A-GPS failed to clear. Skip test.");
+ return;
+ }
- // Register for Gps Status updates.
- mGpsStatusListener = new TestGpsStatusListener(EVENTS_COUNT, mTestLocationManager);
- mTestLocationManager.addGpsStatusListener(mGpsStatusListener);
+ // Register for GPS measurements.
+ mMeasurementListener = new TestGnssMeasurementListener(TAG, EVENTS_COUNT);
+ mTestLocationManager.registerGnssMeasurementCallback(mMeasurementListener);
- // Register for location updates.
- mLocationListener = new TestLocationListener(LOCATIONS_COUNT);
- mTestLocationManager.requestLocationUpdates(mLocationListener);
+ // Register for Gps Status updates.
+ mGpsStatusListener = new TestGpsStatusListener(EVENTS_COUNT, mTestLocationManager);
+ mTestLocationManager.addGpsStatusListener(mGpsStatusListener);
- mMeasurementListener.awaitStatus();
- if (!mMeasurementListener.verifyStatus(isMeasurementTestStrict())) {
- return; // exit peacefully (if not already asserted out inside verifyStatus)
+ // Register for location updates.
+ mLocationListener = new TestLocationListener(LOCATIONS_COUNT);
+ mTestLocationManager.requestLocationUpdates(mLocationListener);
+
+ mMeasurementListener.awaitStatus();
+ if (!mMeasurementListener.verifyStatus(isMeasurementTestStrict())) {
+ return; // exit peacefully (if not already asserted out inside verifyStatus)
+ }
+
+ // Wait for two measurement events - this is better than waiting for a location
+ // calculation because the test generally completes much faster.
+ mMeasurementListener.await();
+
+ Log.i(TAG, "mLocationListener.isLocationReceived(): "
+ + mLocationListener.isLocationReceived());
+
+ SoftAssert.failOrWarning(isMeasurementTestStrict(),
+ "No Satellites are visible. Device may be indoors. Retry outdoors?",
+ mGpsStatusListener.isGpsStatusReceived());
+
+ List<GnssMeasurementsEvent> events = mMeasurementListener.getEvents();
+ Log.i(TAG, "Number of GPS measurement events received = " + events.size());
+
+ if (events.isEmpty()) {
+ SoftAssert.failOrWarning(isMeasurementTestStrict(),
+ "No measurement events received",
+ false);
+ return; // All of the following checks rely on there being measurements
+ }
+
+ // Ensure that after getting a few (at least 2) measurement events, that we still
+ // don't have location (i.e. that we got measurements before location.) Fail, if
+ // strict, warn, if not.
+ SoftAssert.failOrWarning(isMeasurementTestStrict(),
+ "Location was received before " + events.size() +
+ " GnssMeasurementEvents with measurements were reported. " +
+ "Test expects at least " + EVENTS_COUNT +
+ " GnssMeasurementEvents before a location, given the cold start" +
+ " start. Ensure no other active GPS apps (so the cold start" +
+ " command works) and retry?",
+ !mLocationListener.isLocationReceived());
+ if (mLocationListener.isLocationReceived() && !isMeasurementTestStrict()) {
+ return; // allow a (passing) return, if not strict, otherwise continue
+ }
+
+ // If device has received measurements also verify
+ // that mandatory fields of GnssMeasurement are in expected ranges.
+ GnssMeasurementsEvent firstEvent = events.get(0);
+ Collection<GnssMeasurement> gpsMeasurements = firstEvent.getMeasurements();
+ int satelliteCount = gpsMeasurements.size();
+ int[] gpsPrns = new int[satelliteCount];
+ int i = 0;
+ for (GnssMeasurement measurement : gpsMeasurements) {
+ gpsPrns[i] = measurement.getSvid();
+ ++i;
+ }
+ Log.i(TAG, "First GnssMeasurementsEvent with PRNs=" + Arrays.toString(gpsPrns));
+
+ SoftAssert softAssert = new SoftAssert(TAG);
+ long timeInNs = firstEvent.getClock().getTimeNanos();
+ softAssert.assertTrue("GPS measurement satellite count check: ",
+ timeInNs, // event time in ns
+ "satelliteCount > 0", // expected value
+ Integer.toString(satelliteCount), // actual value
+ satelliteCount > 0); // condition
+
+ TestMeasurementUtil.assertGnssClockFields(firstEvent.getClock(), softAssert, timeInNs);
+
+ // Verify mandatory fields of GnssMeasurement
+ for (GnssMeasurement measurement : gpsMeasurements) {
+ TestMeasurementUtil.assertAllGnssMeasurementMandatoryFields(mTestLocationManager,
+ measurement, softAssert, timeInNs);
+ }
+ softAssert.assertAll();
+ } finally {
+ // Set the airplane mode back to off if it was off before this test.
+ if (!isCtsVerifierTest() && isAirplaneModeOffBeforeTest) {
+ TestUtils.setAirplaneModeOn(getContext(), false);
+ }
}
-
- // Wait for two measurement events - this is better than waiting for a location calculation
- // because the test generally completes much faster.
- mMeasurementListener.await();
-
- Log.i(TAG, "mLocationListener.isLocationReceived(): "
- + mLocationListener.isLocationReceived());
-
- SoftAssert.failOrWarning(isMeasurementTestStrict(),
- "No Satellites are visible. Device may be indoors. Retry outdoors?",
- mGpsStatusListener.isGpsStatusReceived());
-
- List<GnssMeasurementsEvent> events = mMeasurementListener.getEvents();
- Log.i(TAG, "Number of GPS measurement events received = " + events.size());
-
- if (events.isEmpty()) {
- SoftAssert.failOrWarning(isMeasurementTestStrict(), "No measurement events received",
- false);
- return; // All of the following checks rely on there being measurements
- }
-
- // Ensure that after getting a few (at least 2) measurement events, that we still don't have
- // location (i.e. that we got measurements before location.) Fail, if strict, warn, if not.
- SoftAssert.failOrWarning(isMeasurementTestStrict(),
- "Location was received before " + events.size() +
- " GnssMeasurementEvents with measurements were reported. " +
- "Test expects at least " + EVENTS_COUNT +
- " GnssMeasurementEvents before a location, given the cold start start. " +
- "Ensure no other active GPS apps (so the cold start command works) " +
- "and retry?",
- !mLocationListener.isLocationReceived());
- if (mLocationListener.isLocationReceived() && !isMeasurementTestStrict()) {
- return; // allow a (passing) return, if not strict, otherwise continue
- }
-
- // If device has received measurements also verify
- // that mandatory fields of GnssMeasurement are in expected ranges.
- GnssMeasurementsEvent firstEvent = events.get(0);
- Collection<GnssMeasurement> gpsMeasurements = firstEvent.getMeasurements();
- int satelliteCount = gpsMeasurements.size();
- int[] gpsPrns = new int[satelliteCount];
- int i = 0;
- for (GnssMeasurement measurement : gpsMeasurements) {
- gpsPrns[i] = measurement.getSvid();
- ++i;
- }
- Log.i(TAG, "First GnssMeasurementsEvent with PRNs=" + Arrays.toString(gpsPrns));
-
- SoftAssert softAssert = new SoftAssert(TAG);
- long timeInNs = firstEvent.getClock().getTimeNanos();
- softAssert.assertTrue("GPS measurement satellite count check: ",
- timeInNs, // event time in ns
- "satelliteCount > 0", // expected value
- Integer.toString(satelliteCount), // actual value
- satelliteCount > 0); // condition
-
- TestMeasurementUtil.assertGnssClockFields(firstEvent.getClock(), softAssert, timeInNs);
-
- // Verify mandatory fields of GnssMeasurement
- for (GnssMeasurement measurement : gpsMeasurements) {
- TestMeasurementUtil.assertAllGnssMeasurementMandatoryFields(mTestLocationManager,
- measurement, softAssert, timeInNs);
- }
- softAssert.assertAll();
}
}
diff --git a/tests/tests/location/src/android/location/cts/GnssNavigationMessageTest.java b/tests/tests/location/src/android/location/cts/GnssNavigationMessageTest.java
index af5e943..99c4067 100644
--- a/tests/tests/location/src/android/location/cts/GnssNavigationMessageTest.java
+++ b/tests/tests/location/src/android/location/cts/GnssNavigationMessageTest.java
@@ -42,6 +42,7 @@
private static final String TAG = "GpsNavMsgTest";
private static final int EVENTS_COUNT = 5;
private TestGnssNavigationMessageListener mTestGnssNavigationMessageListener;
+ private TestLocationListener mLocationListener;
@Override
protected void setUp() throws Exception {
@@ -51,6 +52,10 @@
@Override
protected void tearDown() throws Exception {
+ // Unregister listeners
+ if (mLocationListener != null) {
+ mTestLocationManager.removeLocationUpdates(mLocationListener);
+ }
// Unregister GnssNavigationMessageListener
if (mTestGnssNavigationMessageListener != null) {
mTestLocationManager
@@ -73,6 +78,9 @@
return;
}
+ mLocationListener = new TestLocationListener(EVENTS_COUNT);
+ mTestLocationManager.requestLocationUpdates(mLocationListener);
+
// Register Gps Navigation Message Listener.
mTestGnssNavigationMessageListener =
new TestGnssNavigationMessageListener(TAG, EVENTS_COUNT);
diff --git a/tests/tests/location/src/android/location/cts/GnssStatusTest.java b/tests/tests/location/src/android/location/cts/GnssStatusTest.java
index 1f7ffa4..07aa083 100644
--- a/tests/tests/location/src/android/location/cts/GnssStatusTest.java
+++ b/tests/tests/location/src/android/location/cts/GnssStatusTest.java
@@ -3,6 +3,8 @@
import android.location.GnssStatus;
import android.util.Log;
+import com.android.compatibility.common.util.CddTest;
+
public class GnssStatusTest extends GnssTestCase {
private static final String TAG = "GnssStatusTest";
@@ -56,6 +58,7 @@
/**
* Tests values of {@link GnssStatus}.
*/
+ @CddTest(requirement="7.3.3/C-1-4")
public void testGnssStatusValues() throws InterruptedException {
// Checks if GPS hardware feature is present, skips test (pass) if not,
// and hard asserts that Location/GPS (Provider) is turned on if is Cts Verifier.
diff --git a/tests/tests/location/src/android/location/cts/GnssTestCase.java b/tests/tests/location/src/android/location/cts/GnssTestCase.java
index e1c5e88..a128c95 100644
--- a/tests/tests/location/src/android/location/cts/GnssTestCase.java
+++ b/tests/tests/location/src/android/location/cts/GnssTestCase.java
@@ -16,11 +16,10 @@
package android.location.cts;
import android.os.Build;
+import android.os.SystemProperties;
import android.test.AndroidTestCase;
import android.util.Log;
-import com.android.compatibility.common.util.PropertyUtil;
-
/**
* Base Test Case class for all Gnss Tests.
*/
@@ -38,7 +37,7 @@
// On devices using newer hardware, GNSS measurement support is required.
protected boolean isMeasurementTestStrict() {
// Enforce strict measurement test on devices with first API level at least P.
- if (PropertyUtil.getFirstApiLevel() >= Build.VERSION_CODES.P) {
+ if (SystemProperties.getInt("ro.product.first_api_level", 0) >= Build.VERSION_CODES.P) {
return true;
}
@@ -53,4 +52,4 @@
public boolean isCtsVerifierTest() {
return mCtsVerifierTest;
}
-}
\ No newline at end of file
+}
diff --git a/tests/tests/location/src/android/location/cts/GnssTtffTests.java b/tests/tests/location/src/android/location/cts/GnssTtffTests.java
index 335de07..af0e025 100644
--- a/tests/tests/location/src/android/location/cts/GnssTtffTests.java
+++ b/tests/tests/location/src/android/location/cts/GnssTtffTests.java
@@ -86,12 +86,12 @@
*/
private void ensureNetworkStatus(){
assertTrue("Device has to connect to Wifi or Cellular to complete this test.",
- isConnectedToWifiOrCellular(getContext()));
+ TestUtils.isConnectedToWifiOrCellular(getContext()));
}
private boolean hasCellularData() {
- ConnectivityManager connManager = getConnectivityManager(getContext());
+ ConnectivityManager connManager = TestUtils.getConnectivityManager(getContext());
NetworkInfo cellularNetworkInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
// check whether the cellular data is ON if the device has cellular capability
if (cellularNetworkInfo == null) {
@@ -143,44 +143,4 @@
softAssert.assertTrue("Test case: " + testName +", TTFF should be less than " + threshold
+ " . In current test, TTFF value is: " + ttffTimeMillis, ttffTimeMillis < threshold);
}
-
- /**
- * Returns whether the device is currently connected to a wifi or cellular.
- *
- * @param context {@link Context} object
- * @return {@code true} if connected to Wifi or Cellular; {@code false} otherwise
- */
- public static boolean isConnectedToWifiOrCellular(Context context) {
- NetworkInfo info = getActiveNetworkInfo(context);
- return info != null
- && info.isConnected()
- && (info.getType() == ConnectivityManager.TYPE_WIFI
- || info.getType() == ConnectivityManager.TYPE_MOBILE);
- }
-
- /**
- * Gets the active network info.
- *
- * @param context {@link Context} object
- * @return {@link NetworkInfo}
- */
- private static NetworkInfo getActiveNetworkInfo(Context context) {
- ConnectivityManager cm = getConnectivityManager(context);
- if (cm != null) {
- return cm.getActiveNetworkInfo();
- }
- return null;
- }
-
- /**
- * Gets the connectivity manager.
- *
- * @param context {@link Context} object
- * @return {@link ConnectivityManager}
- */
- private static ConnectivityManager getConnectivityManager(Context context) {
- return (ConnectivityManager) context.getApplicationContext()
- .getSystemService(Context.CONNECTIVITY_SERVICE);
- }
-
-}
\ No newline at end of file
+}
diff --git a/tests/tests/location/src/android/location/cts/TestGnssMeasurementListener.java b/tests/tests/location/src/android/location/cts/TestGnssMeasurementListener.java
index 3a64c46..87a3f77 100644
--- a/tests/tests/location/src/android/location/cts/TestGnssMeasurementListener.java
+++ b/tests/tests/location/src/android/location/cts/TestGnssMeasurementListener.java
@@ -37,7 +37,7 @@
private boolean filterByEventSize = false;
// Timeout in sec for count down latch wait
private static final int STATUS_TIMEOUT_IN_SEC = 10;
- private static final int MEAS_TIMEOUT_IN_SEC = 60;
+ private static final int MEAS_TIMEOUT_IN_SEC = 75;
private static final int C_TO_N0_THRESHOLD_DB_HZ = 18;
private volatile int mStatus = -1;
diff --git a/tests/tests/location/src/android/location/cts/TestMeasurementUtil.java b/tests/tests/location/src/android/location/cts/TestMeasurementUtil.java
index 940146e..2ca0c2c 100644
--- a/tests/tests/location/src/android/location/cts/TestMeasurementUtil.java
+++ b/tests/tests/location/src/android/location/cts/TestMeasurementUtil.java
@@ -24,6 +24,7 @@
import android.location.GnssStatus;
import android.location.LocationManager;
import android.os.Build;
+import android.os.SystemProperties;
import android.util.Log;
import java.util.Arrays;
@@ -55,7 +56,6 @@
private static final int YEAR_2016 = 2016;
private static final int YEAR_2017 = 2017;
- private static final int YEAR_2018 = 2018;
private enum GnssBand {
GNSS_L1,
@@ -815,10 +815,10 @@
public static void verifyGnssCarrierFrequency(SoftAssert softAssert,
TestLocationManager testLocationManager,
boolean hasCarrierFrequency, float carrierFrequencyHz) {
- // Enforcing CarrierFrequencyHz check only for year 2018+
- if (testLocationManager.getLocationManager().getGnssYearOfHardware() >= YEAR_2018) {
+ // Enforcing CarrierFrequencyHz present only for devices shipped with P+.
+ if (SystemProperties.getInt("ro.product.first_api_level", 0) >= Build.VERSION_CODES.P) {
softAssert.assertTrue("Measurement has Carrier Frequency: " + hasCarrierFrequency,
- hasCarrierFrequency);
+ hasCarrierFrequency);
}
if (hasCarrierFrequency) {
diff --git a/tests/tests/location/src/android/location/cts/TestUtils.java b/tests/tests/location/src/android/location/cts/TestUtils.java
index 3c3f21d..3a0100b 100644
--- a/tests/tests/location/src/android/location/cts/TestUtils.java
+++ b/tests/tests/location/src/android/location/cts/TestUtils.java
@@ -18,16 +18,25 @@
import android.content.Context;
import android.content.pm.PackageManager;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
import android.util.Log;
+import com.android.compatibility.common.util.SystemUtil;
+
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
public class TestUtils {
+ private static final String TAG = "LocationTestUtils";
+
private static final long STANDARD_WAIT_TIME_MS = 50;
private static final long STANDARD_SLEEP_TIME_MS = 50;
+ private static final int DATA_CONNECTION_CHECK_INTERVAL_MS = 500;
+ private static final int DATA_CONNECTION_CHECK_COUNT = 10; // 500 * 10 - Roughly 5 secs wait
+
public static boolean waitFor(CountDownLatch latch, int timeInSec) throws InterruptedException {
// Since late 2014, if the main thread has been occupied for long enough, Android will
// increase its priority. Such new behavior can causes starvation to the background thread -
@@ -67,7 +76,85 @@
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS)) {
return true;
}
- Log.w("LocationTestUtils", "GPS feature not present on device, skipping GPS test.");
+ Log.w(TAG, "GPS feature not present on device, skipping GPS test.");
return false;
}
+
+ /**
+ * Returns whether the device is currently connected to a wifi or cellular.
+ *
+ * @param context {@link Context} object
+ * @return {@code true} if connected to Wifi or Cellular; {@code false} otherwise
+ */
+ public static boolean isConnectedToWifiOrCellular(Context context) {
+ NetworkInfo info = getActiveNetworkInfo(context);
+ return info != null
+ && info.isConnected()
+ && (info.getType() == ConnectivityManager.TYPE_WIFI
+ || info.getType() == ConnectivityManager.TYPE_MOBILE);
+ }
+
+ /**
+ * Gets the active network info.
+ *
+ * @param context {@link Context} object
+ * @return {@link NetworkInfo}
+ */
+ private static NetworkInfo getActiveNetworkInfo(Context context) {
+ ConnectivityManager cm = getConnectivityManager(context);
+ if (cm != null) {
+ return cm.getActiveNetworkInfo();
+ }
+ return null;
+ }
+
+ /**
+ * Gets the connectivity manager.
+ *
+ * @param context {@link Context} object
+ * @return {@link ConnectivityManager}
+ */
+ public static ConnectivityManager getConnectivityManager(Context context) {
+ return (ConnectivityManager) context.getApplicationContext()
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ }
+
+ /**
+ * Returns {@code true} if the setting {@code airplane_mode_on} is set to 1.
+ */
+ public static boolean isAirplaneModeOn() {
+ return SystemUtil.runShellCommand("settings get global airplane_mode_on")
+ .trim().equals("1");
+ }
+
+ /**
+ * Changes the setting {@code airplane_mode_on} to 1 if {@code enableAirplaneMode}
+ * is {@code true}. Otherwise, it is set to 0.
+ *
+ * <p>Waits for a certain time duration for network connections to turn on/off based on
+ * {@code enableAirplaneMode}.
+ */
+ public static void setAirplaneModeOn(Context context,
+ boolean enableAirplaneMode) throws InterruptedException {
+ Log.i(TAG, "Setting airplane_mode_on to " + enableAirplaneMode);
+ SystemUtil.runShellCommand("cmd connectivity airplane-mode "
+ + (enableAirplaneMode ? "enable" : "disable"));
+
+ // Wait for a few seconds until the airplane mode changes take effect. The airplane mode on
+ // state and the WiFi/cell connected state are opposite. So, we wait while they are the
+ // same or until the specified time interval expires.
+ //
+ // Note that in unusual cases where the WiFi/cell are not in a connected state before
+ // turning on airplane mode, then turning off airplane mode won't restore either of
+ // these connections, and then the wait time below will be wasteful.
+ int dataConnectionCheckCount = DATA_CONNECTION_CHECK_COUNT;
+ while (enableAirplaneMode == isConnectedToWifiOrCellular(context)) {
+ if (--dataConnectionCheckCount <= 0) {
+ Log.w(TAG, "Airplane mode " + (enableAirplaneMode ? "on" : "off")
+ + " setting did not take effect on WiFi/cell connected state.");
+ return;
+ }
+ Thread.sleep(DATA_CONNECTION_CHECK_INTERVAL_MS);
+ }
+ }
}
diff --git a/tests/tests/media/libimagereaderjni/AImageReaderCts.cpp b/tests/tests/media/libimagereaderjni/AImageReaderCts.cpp
index c098f5f..bf7aacc 100644
--- a/tests/tests/media/libimagereaderjni/AImageReaderCts.cpp
+++ b/tests/tests/media/libimagereaderjni/AImageReaderCts.cpp
@@ -348,7 +348,7 @@
// Verity that outFenceFd's value will be changed by
// AImageReader_acquireNextImageAsync.
ret = AImageReader_acquireNextImageAsync(reader, &outImage, &outFenceFd);
- if (ret != AMEDIA_OK || outImage == nullptr || outFenceFd != kDummyFenceFd) {
+ if (ret != AMEDIA_OK || outImage == nullptr || outFenceFd == 0) {
ALOGE("Failed to acquire image, ret=%d, outIamge=%p, outFenceFd=%d.", ret, outImage,
outFenceFd);
return;
diff --git a/tests/tests/media/src/android/media/cts/AudioTrackTest.java b/tests/tests/media/src/android/media/cts/AudioTrackTest.java
index 2baf410..47a3a31 100644
--- a/tests/tests/media/src/android/media/cts/AudioTrackTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioTrackTest.java
@@ -1483,7 +1483,7 @@
final double TEST_SWEEP = 100;
final int TEST_LOOPS = 1;
final double TEST_FREQUENCY = 400;
- final long WAIT_TIME_MS = 50; // compensate for cold start when run in isolation.
+ final long WAIT_TIME_MS = 150; // compensate for cold start when run in isolation.
final double TEST_LOOP_DURATION = 0.25;
playOnceStaticData(TEST_NAME, TEST_MODE, TEST_STREAM_TYPE, TEST_SWEEP,
diff --git a/tests/tests/media/src/android/media/cts/DecoderConformanceTest.java b/tests/tests/media/src/android/media/cts/DecoderConformanceTest.java
index f1f16a8..58293f9 100644
--- a/tests/tests/media/src/android/media/cts/DecoderConformanceTest.java
+++ b/tests/tests/media/src/android/media/cts/DecoderConformanceTest.java
@@ -138,6 +138,7 @@
mExtractor.setDataSource(testFd.getFileDescriptor(), testFd.getStartOffset(), testFd.getLength());
mExtractor.selectTrack(0);
+ mDecoder = MediaCodec.createByCodecName(decoderName);
MediaCodecInfo codecInfo = mDecoder.getCodecInfo();
MediaCodecInfo.CodecCapabilities caps = codecInfo.getCapabilitiesForType(mime);
if (!caps.isFormatSupported(mExtractor.getTrackFormat(0))) {
@@ -153,7 +154,6 @@
}
try {
- mDecoder = MediaCodec.createByCodecName(decoderName);
if (MediaUtils.verifyDecoder(mDecoder, mExtractor, frameMD5Sums)) {
return Status.PASS;
}
diff --git a/tests/tests/media/src/android/media/cts/DecoderTest.java b/tests/tests/media/src/android/media/cts/DecoderTest.java
index c1f72f8..2193d33 100755
--- a/tests/tests/media/src/android/media/cts/DecoderTest.java
+++ b/tests/tests/media/src/android/media/cts/DecoderTest.java
@@ -702,10 +702,10 @@
public void testVp9HdrStaticMetadata() throws Exception {
final String staticInfo =
- "00 d0 84 80 3e c2 33 c4 86 4c 1d b8 0b 13 3d 42" +
- "40 e8 03 64 00 e8 03 2c 01 " ;
+ "00 d0 84 80 3e c2 33 c4 86 4c 1d b8 0b 13 3d 42 " +
+ "40 e8 03 64 00 e8 03 2c 01 " ;
testHdrStaticMetadata(R.raw.video_1280x720_vp9_hdr_static_3mbps,
- staticInfo, true /*metadataInContainer*/);
+ staticInfo, true /*metadataInContainer*/, "testVp9HdrStaticMetadata");
}
public void testH265HDR10StaticMetadata() throws Exception {
@@ -716,13 +716,14 @@
// Media frameworks puts the display primaries in RGB order, here we verify the three
// primaries are indeed in this order and fail otherwise.
final String staticInfo =
- "00 d0 84 80 3e c2 33 c4 86 4c 1d b8 0b 13 3d 42" +
- "40 e8 03 00 00 e8 03 90 01 " ;
+ "00 d0 84 80 3e c2 33 c4 86 4c 1d b8 0b 13 3d 42 " +
+ "40 e8 03 00 00 e8 03 90 01 " ;
testHdrStaticMetadata(R.raw.video_1280x720_hevc_hdr10_static_3mbps,
- staticInfo, false /*metadataInContainer*/);
+ staticInfo, false /*metadataInContainer*/, "testH265HDR10StaticMetadata");
}
- private void testHdrStaticMetadata(int res, String pattern, boolean metadataInContainer)
+ private void testHdrStaticMetadata(
+ int res, String pattern, boolean metadataInContainer, String testName)
throws Exception {
AssetFileDescriptor infd = null;
MediaExtractor extractor = null;
@@ -746,7 +747,8 @@
assertTrue("Extractor failed to extract video track",
format != null && trackIndex >= 0);
if (metadataInContainer) {
- verifyHdrStaticInfo("Extractor failed to extract static info", format, pattern);
+ verifyHdrStaticInfo("Extractor failed to extract static info",
+ format, pattern, metadataInContainer, testName);
}
extractor.selectTrack(trackIndex);
@@ -798,7 +800,7 @@
codec.releaseOutputBuffer(index, false);
verifyHdrStaticInfo("Output buffer has wrong static info",
- bufferFormat, pattern);
+ bufferFormat, pattern, metadataInContainer, testName);
mOutputReceived = true;
latch.countDown();
}
@@ -834,7 +836,7 @@
public void onOutputFormatChanged(MediaCodec codec, MediaFormat format) {
Log.i(TAG, "got output format: " + format);
verifyHdrStaticInfo("Output format has wrong static info",
- format, pattern);
+ format, pattern, metadataInContainer, testName);
}
});
decoder.configure(format, surface, null/*crypto*/, 0/*flags*/);
@@ -857,13 +859,32 @@
}
}
- private void verifyHdrStaticInfo(String reason, MediaFormat format, String pattern) {
+ private void verifyHdrStaticInfo(
+ String reason, MediaFormat format, String pattern,
+ boolean failOnMismatch, String testName) {
ByteBuffer staticMetadataBuffer = format.containsKey("hdr-static-info") ?
format.getByteBuffer("hdr-static-info") : null;
assertTrue(reason + ": empty",
staticMetadataBuffer != null && staticMetadataBuffer.remaining() > 0);
- assertTrue(reason + ": mismatch",
- Arrays.equals(loadByteArrayFromString(pattern), staticMetadataBuffer.array()));
+
+ if (!Arrays.equals(loadByteArrayFromString(pattern), staticMetadataBuffer.array())) {
+ // log mismatch
+ DeviceReportLog log = new DeviceReportLog("CtsMediaTestCases", testName);
+
+ log.addValue("reason", reason + ": mismatch", ResultType.NEUTRAL, ResultUnit.NONE);
+ StringBuilder sb = new StringBuilder();
+ for (byte b : staticMetadataBuffer.array()) {
+ sb.append(String.format("%02X ", b));
+ }
+ log.addValue("metadata_actual", sb.toString(), ResultType.NEUTRAL, ResultUnit.NONE);
+ log.addValue("metadata_expected", pattern, ResultType.NEUTRAL, ResultUnit.NONE);
+ log.setSummary("result", 0, ResultType.HIGHER_BETTER, ResultUnit.COUNT);
+ log.submit(getInstrumentation());
+
+ if (failOnMismatch) {
+ fail(reason + ": mismatch");
+ }
+ }
}
// helper to load byte[] from a String
diff --git a/tests/tests/media/src/android/media/cts/EqualizerTest.java b/tests/tests/media/src/android/media/cts/EqualizerTest.java
index a8bd98a..7c405a5 100644
--- a/tests/tests/media/src/android/media/cts/EqualizerTest.java
+++ b/tests/tests/media/src/android/media/cts/EqualizerTest.java
@@ -27,7 +27,7 @@
public class EqualizerTest extends PostProcTestBase {
private String TAG = "EqualizerTest";
- private final static int MIN_NUMBER_OF_BANDS = 4;
+ private final static int MIN_NUMBER_OF_BANDS = 2;
private final static int MAX_LEVEL_RANGE_LOW = 0; // 0dB
private final static int MIN_LEVEL_RANGE_HIGH = 0; // 0dB
private final static int TEST_FREQUENCY_MILLIHERTZ = 1000000; // 1kHz
diff --git a/tests/tests/media/src/android/media/cts/MediaExtractorTest.java b/tests/tests/media/src/android/media/cts/MediaExtractorTest.java
index 2718c3b..7dc9130 100644
--- a/tests/tests/media/src/android/media/cts/MediaExtractorTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaExtractorTest.java
@@ -126,6 +126,7 @@
}
public void testGetAudioPresentations() throws Exception {
+ TestMediaDataSource dataSource = setDataSource(R.raw.testvideo);
List<AudioPresentation> presentations = mExtractor.getAudioPresentations(0 /*trackIndex*/);
assertNotNull(presentations);
assertTrue(presentations.isEmpty());
diff --git a/tests/tests/media/src/android/media/cts/MediaSessionManagerTest.java b/tests/tests/media/src/android/media/cts/MediaSessionManagerTest.java
index 1d77473..926abd8 100644
--- a/tests/tests/media/src/android/media/cts/MediaSessionManagerTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaSessionManagerTest.java
@@ -226,6 +226,11 @@
session.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS
| MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS);
session.setCallback(callback, handler);
+ PlaybackState state = new PlaybackState.Builder()
+ .setState(PlaybackState.STATE_PLAYING, 0, 1.0f).build();
+ // Fake the media session service so this session can take the media key events.
+ session.setPlaybackState(state);
+ session.setActive(true);
// A media playback is also needed to receive media key events.
Utils.assertMediaPlaybackStarted(context);
diff --git a/tests/tests/media/src/android/media/cts/VpxCodecTestBase.java b/tests/tests/media/src/android/media/cts/VpxCodecTestBase.java
index 20c9d3a..48faf49 100644
--- a/tests/tests/media/src/android/media/cts/VpxCodecTestBase.java
+++ b/tests/tests/media/src/android/media/cts/VpxCodecTestBase.java
@@ -367,24 +367,27 @@
/**
* Packs YUV420 frame by moving it to a smaller size buffer with stride and slice
- * height equal to the original frame width and height.
+ * height equal to the crop window.
*/
- private static byte[] PackYUV420(int width, int height,
+ private static byte[] PackYUV420(int left, int top, int width, int height,
int stride, int sliceHeight, byte[] src) {
byte[] dst = new byte[width * height * 3 / 2];
// Y copy.
for (int i = 0; i < height; i++) {
- System.arraycopy(src, i * stride, dst, i * width, width);
+ System.arraycopy(src, (i + top) * stride + left, dst, i * width, width);
}
// U and V copy.
int u_src_offset = stride * sliceHeight;
int v_src_offset = u_src_offset + u_src_offset / 4;
int u_dst_offset = width * height;
int v_dst_offset = u_dst_offset + u_dst_offset / 4;
+ // Downsample and align to floor-2 for crop origin.
+ left /= 2;
+ top /= 2;
for (int i = 0; i < height / 2; i++) {
- System.arraycopy(src, u_src_offset + i * (stride / 2),
+ System.arraycopy(src, u_src_offset + (i + top) * (stride / 2) + left,
dst, u_dst_offset + i * (width / 2), width / 2);
- System.arraycopy(src, v_src_offset + i * (stride / 2),
+ System.arraycopy(src, v_src_offset + (i + top) * (stride / 2) + left,
dst, v_dst_offset + i * (width / 2), width / 2);
}
return dst;
@@ -532,6 +535,10 @@
int frameCount = ivf.getFrameCount();
int frameStride = frameWidth;
int frameSliceHeight = frameHeight;
+ int cropLeft = 0;
+ int cropTop = 0;
+ int cropWidth = frameWidth;
+ int cropHeight = frameHeight;
assertTrue(frameWidth > 0);
assertTrue(frameHeight > 0);
assertTrue(frameCount > 0);
@@ -634,6 +641,28 @@
" x " + frameSliceHeight);
frameStride = Math.max(frameWidth, frameStride);
frameSliceHeight = Math.max(frameHeight, frameSliceHeight);
+
+ // Parse crop window for the area of recording decoded frame data.
+ if (format.containsKey("crop-left")) {
+ cropLeft = format.getInteger("crop-left");
+ }
+ if (format.containsKey("crop-top")) {
+ cropTop = format.getInteger("crop-top");
+ }
+ if (format.containsKey("crop-right")) {
+ cropWidth = format.getInteger("crop-right") - cropLeft + 1;
+ } else {
+ cropWidth = frameWidth;
+ }
+ if (format.containsKey("crop-bottom")) {
+ cropHeight = format.getInteger("crop-bottom") - cropTop + 1;
+ } else {
+ cropHeight = frameHeight;
+ }
+ Log.d(TAG, "Frame crop window origin: " + cropLeft + " x " + cropTop
+ + ", size: " + cropWidth + " x " + cropHeight);
+ cropWidth = Math.min(frameWidth - cropLeft, cropWidth);
+ cropHeight = Math.min(frameHeight - cropTop, cropHeight);
}
result = decoder.dequeueOutputBuffer(bufferInfo, DEFAULT_DEQUEUE_TIMEOUT_US);
}
@@ -660,11 +689,11 @@
frame = NV12ToYUV420(frameWidth, frameHeight,
frameStride, frameSliceHeight, frame);
}
- int writeLength = Math.min(frameWidth * frameHeight * 3 / 2, frame.length);
+ int writeLength = Math.min(cropWidth * cropHeight * 3 / 2, frame.length);
// Pack frame if necessary.
if (writeLength < frame.length &&
- (frameStride > frameWidth || frameSliceHeight > frameHeight)) {
- frame = PackYUV420(frameWidth, frameHeight,
+ (frameStride > cropWidth || frameSliceHeight > cropHeight)) {
+ frame = PackYUV420(cropLeft, cropTop, cropWidth, cropHeight,
frameStride, frameSliceHeight, frame);
}
yuv.write(frame, 0, writeLength);
diff --git a/tests/tests/multiuser/src/android/multiuser/cts/SplitSystemUserTest.java b/tests/tests/multiuser/src/android/multiuser/cts/SplitSystemUserTest.java
index 3e9122b..45fd6d8 100644
--- a/tests/tests/multiuser/src/android/multiuser/cts/SplitSystemUserTest.java
+++ b/tests/tests/multiuser/src/android/multiuser/cts/SplitSystemUserTest.java
@@ -20,27 +20,20 @@
import android.os.UserManager;
import android.test.InstrumentationTestCase;
-import android.util.Log;
public class SplitSystemUserTest extends InstrumentationTestCase {
- private static final String TAG = SplitSystemUserTest.class.getSimpleName();
-
public void testSplitSystemUserIsDisabled() throws Exception {
- // Verify that am get-current-user and UserManager.isSystemUser both return 0
- String curUser = SystemUtil.runShellCommand(getInstrumentation(), "am get-current-user");
- Log.i(TAG, "am get-current-user: " + curUser);
- assertEquals("Test must be running under user 0", "0", trim(curUser));
- UserManager um = getInstrumentation().getContext().getSystemService(UserManager.class);
- assertTrue("Test must be running under system user", um.isSystemUser());
-
- // Check that ro.fw.system_user_split property is not set
+ // Check that ro.fw.system_user_split property is not set.
String splitEnabledStr = trim(SystemUtil.runShellCommand(getInstrumentation(),
"getprop ro.fw.system_user_split"));
boolean splitEnabled = "y".equals(splitEnabledStr) || "yes".equals(splitEnabledStr)
|| "1".equals(splitEnabledStr) || "true".equals(splitEnabledStr)
|| "on".equals(splitEnabledStr);
assertFalse("ro.fw.system_user_split must not be enabled", splitEnabled);
+
+ // Check UserManager.isSplitSystemUser returns false as well.
+ assertFalse("UserManager.isSplitSystemUser must be false", UserManager.isSplitSystemUser());
}
private static String trim(String s) {
diff --git a/tests/tests/nativehardware/jni/AHardwareBufferGLTest.cpp b/tests/tests/nativehardware/jni/AHardwareBufferGLTest.cpp
index 00bb83c..fd0d37b 100644
--- a/tests/tests/nativehardware/jni/AHardwareBufferGLTest.cpp
+++ b/tests/tests/nativehardware/jni/AHardwareBufferGLTest.cpp
@@ -502,29 +502,14 @@
}
)glsl";
-const char* kSsboVertexShaderEs31 = R"glsl(#version 310 es
- in vec2 aPosition;
- in float aDepth;
- uniform mediump float uScale;
+const char* kSsboComputeShaderEs31 = R"glsl(#version 310 es
+ layout(local_size_x = 1) in;
layout(std430, binding=0) buffer Output {
- vec2 data[];
+ uint data[];
} bOutput;
- out mediump vec2 vTexCoords;
void main() {
- bOutput.data[gl_VertexID] = aPosition;
- vTexCoords = (vec2(1.0) + aPosition) * 0.5;
- gl_Position.xy = aPosition * uScale;
- gl_Position.z = aDepth;
- gl_Position.w = 1.0;
- }
-)glsl";
-
-const char* kColorFragmentShaderEs3x = R"glsl(
- precision mediump float;
- uniform lowp vec4 uColor;
- out mediump vec4 color;
- void main() {
- color = uColor;
+ bOutput.data[gl_GlobalInvocationID.x] =
+ gl_GlobalInvocationID.x * 3u;
}
)glsl";
@@ -702,32 +687,41 @@
mDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(mDisplay, NULL, NULL);
+ // Try creating an OpenGL ES 3.x context and fall back to 2.x if that fails.
+ // Create two contexts for cross-context image sharing tests.
EGLConfig first_config;
- EGLint const config_attrib_list[] = {
+ EGLint config_attrib_list[] = {
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR,
EGL_NONE
};
EGLint num_config = 0;
eglChooseConfig(mDisplay, config_attrib_list, &first_config, 1, &num_config);
- ASSERT_LT(0, num_config);
+ if (num_config == 0) {
+ // There are no configs with the ES 3.0 bit, fall back to ES 2.0.
+ config_attrib_list[8] = EGL_NONE;
+ config_attrib_list[9] = EGL_NONE;
+ eglChooseConfig(mDisplay, config_attrib_list, &first_config, 1, &num_config);
+ }
+ ASSERT_GT(num_config, 0);
- // Try creating an OpenGL ES 3.x context and fall back to 2.x if that fails.
- // Create two contexts for cross-context image sharing tests.
EGLint context_attrib_list[] = {
EGL_CONTEXT_CLIENT_VERSION, 3,
EGL_NONE
};
- mContext[0] = eglCreateContext(mDisplay, first_config, EGL_NO_CONTEXT, context_attrib_list);
+ // Try creating an ES 3.0 context, but don't bother if there were no ES 3.0 compatible configs.
+ if (config_attrib_list[9] != EGL_NONE) {
+ mContext[0] = eglCreateContext(mDisplay, first_config, EGL_NO_CONTEXT, context_attrib_list);
+ }
+ // If we don't have a context yet, fall back to ES 2.0.
if (mContext[0] == EGL_NO_CONTEXT) {
context_attrib_list[1] = 2;
mContext[0] = eglCreateContext(mDisplay, first_config, EGL_NO_CONTEXT, context_attrib_list);
- mContext[1] = eglCreateContext(mDisplay, first_config, EGL_NO_CONTEXT, context_attrib_list);
- } else {
- mContext[1] = eglCreateContext(mDisplay, first_config, EGL_NO_CONTEXT, context_attrib_list);
}
+ mContext[1] = eglCreateContext(mDisplay, first_config, EGL_NO_CONTEXT, context_attrib_list);
ASSERT_NE(EGL_NO_CONTEXT, mContext[0]);
ASSERT_NE(EGL_NO_CONTEXT, mContext[1]);
@@ -847,6 +841,12 @@
"GL_EXT_EGL_image_storage");
return false;
}
+ if (desc.usage & AHARDWAREBUFFER_USAGE_GPU_MIPMAP_COMPLETE &&
+ !HasGLExtension("GL_EXT_EGL_image_storage")) {
+ ALOGI("Test skipped: mipmapped hardware buffers require "
+ "GL_EXT_EGL_image_storage");
+ return false;
+ }
int result = AHardwareBuffer_allocate(&desc, &mBuffer);
// Skip if this format cannot be allocated.
@@ -983,6 +983,7 @@
internal_format = GL_DEPTH_STENCIL_OES;
format = GL_DEPTH_STENCIL;
type = GL_UNSIGNED_INT_24_8;
+ break;
default:
FAIL() << "Unrecognized GL format"; break;
}
@@ -1217,8 +1218,9 @@
mGLVersion / 10, mGLVersion % 10);
return;
}
+ const int kBufferElements = 16;
AHardwareBuffer_Desc desc = GetParam();
- desc.width = sizeof kQuadPositions;
+ desc.width = kBufferElements * sizeof(int);
desc.usage = AHARDWAREBUFFER_USAGE_CPU_READ_RARELY | AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER;
if (!SetUpBuffer(desc)) return;
@@ -1229,30 +1231,44 @@
}
// Clear the buffer to zero
- std::vector<float> zero_data(desc.width / sizeof(float), 0.f);
- glBufferSubData(GL_SHADER_STORAGE_BUFFER, 0, desc.width, zero_data.data());
+ std::vector<unsigned int> expected_data(kBufferElements, 0U);
+ glBufferSubData(GL_SHADER_STORAGE_BUFFER, 0, desc.width, expected_data.data());
glFinish();
- // Write into the buffer with a shader
- SetUpFramebuffer(40, 40, 0, kRenderbuffer);
- SetUpProgram(kSsboVertexShaderEs31, std::string("#version 310 es") + kColorFragmentShaderEs3x,
- kQuadPositions, 0.5f);
+ // Write into the buffer with a compute shader
+ GLint status = 0;
+ mProgram = glCreateProgram();
+ GLuint shader = glCreateShader(GL_COMPUTE_SHADER);
+ glShaderSource(shader, 1, &kSsboComputeShaderEs31, nullptr);
+ glCompileShader(shader);
+ glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
+ ASSERT_EQ(GL_TRUE, status) << "Compute shader compilation failed";
+ glAttachShader(mProgram, shader);
+ glLinkProgram(mProgram);
+ glGetProgramiv(mProgram, GL_LINK_STATUS, &status);
+ ASSERT_EQ(GL_TRUE, status) << "Shader program linking failed";
+ glDetachShader(mProgram, shader);
+ glDeleteShader(shader);
+ glUseProgram(mProgram);
+ ASSERT_EQ(GLenum{GL_NO_ERROR}, glGetError());
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, mBufferObjects[mWhich]);
- glDrawArrays(GL_TRIANGLES, 0, kQuadVertexCount);
+ glDispatchCompute(kBufferElements, 1, 1);
+ glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT);
glFinish();
EXPECT_EQ(GLenum{GL_NO_ERROR}, glGetError());
// Inspect the data written into the buffer using CPU access.
MakeCurrent(0);
- float* data = nullptr;
+ unsigned int* data = nullptr;
int result = AHardwareBuffer_lock(mBuffer, AHARDWAREBUFFER_USAGE_CPU_READ_RARELY,
-1, nullptr, reinterpret_cast<void**>(&data));
ASSERT_EQ(NO_ERROR, result);
std::ostringstream s;
- for (int i = 0; i < 12; ++i) {
+ for (int i = 0; i < kBufferElements; ++i) {
+ expected_data[i] = static_cast<unsigned int>(i * 3);
s << data[i] << ", ";
}
- EXPECT_EQ(0, memcmp(kQuadPositions, data, desc.width)) << s.str();
+ EXPECT_EQ(0, memcmp(expected_data.data(), data, desc.width)) << s.str();
AHardwareBuffer_unlock(mBuffer, nullptr);
}
diff --git a/tests/tests/nativehardware/jni/AHardwareBufferTest.cpp b/tests/tests/nativehardware/jni/AHardwareBufferTest.cpp
index 324ab9e..116771a 100644
--- a/tests/tests/nativehardware/jni/AHardwareBufferTest.cpp
+++ b/tests/tests/nativehardware/jni/AHardwareBufferTest.cpp
@@ -324,7 +324,7 @@
AHardwareBuffer* buffer = NULL;
AHardwareBuffer_Desc desc = {};
desc.width = 120;
- desc.width = 240;
+ desc.height = 240;
desc.layers = 1;
desc.usage = AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT | AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN;
desc.format = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
diff --git a/tests/tests/nativehardware/src/android/hardware/nativehardware/cts/HardwareBufferVrTest.java b/tests/tests/nativehardware/src/android/hardware/nativehardware/cts/HardwareBufferVrTest.java
index 0c4d250..ff022fc 100644
--- a/tests/tests/nativehardware/src/android/hardware/nativehardware/cts/HardwareBufferVrTest.java
+++ b/tests/tests/nativehardware/src/android/hardware/nativehardware/cts/HardwareBufferVrTest.java
@@ -17,16 +17,26 @@
package android.hardware.nativehardware.cts;
import android.content.pm.PackageManager;
+import android.content.res.Configuration;
import android.hardware.HardwareBuffer;
import android.test.AndroidTestCase;
+import com.android.compatibility.common.util.CddTest;
+
/**
* Checks whether layered buffers are supported when VR feature is present.
*/
public class HardwareBufferVrTest extends AndroidTestCase {
+
+ @CddTest(requirement="7.9.2/C-1-10")
public void testLayeredBuffersForVr() throws AssertionError {
+ boolean mIsVrHeadset = (getContext().getResources().getConfiguration().uiMode
+ & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_VR_HEADSET;
+
+ // Some phones upgrading from older Android versions have the high performance VR feature,
+ // but cannot meet this requirement. Only actually check it for standalone VR headsets.
PackageManager pm = getContext().getPackageManager();
- if (!pm.hasSystemFeature(PackageManager.FEATURE_VR_MODE_HIGH_PERFORMANCE)) {
+ if (!pm.hasSystemFeature(PackageManager.FEATURE_VR_MODE_HIGH_PERFORMANCE) || !mIsVrHeadset) {
return;
}
final long flags = HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE | HardwareBuffer.USAGE_GPU_COLOR_OUTPUT;
diff --git a/tests/tests/opengl/src/android/opengl/cts/OpenGlEsVersionTest.java b/tests/tests/opengl/src/android/opengl/cts/OpenGlEsVersionTest.java
index b8f334d..c599d65 100644
--- a/tests/tests/opengl/src/android/opengl/cts/OpenGlEsVersionTest.java
+++ b/tests/tests/opengl/src/android/opengl/cts/OpenGlEsVersionTest.java
@@ -26,6 +26,7 @@
import android.content.pm.ConfigurationInfo;
import android.content.pm.FeatureInfo;
import android.content.pm.PackageManager;
+import android.content.res.Configuration;
import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
@@ -171,21 +172,32 @@
if (!supportsVrHighPerformance())
return;
restartActivityWithClientVersion(3);
+ final boolean isVrHeadset = (mActivity.getResources().getConfiguration().uiMode
+ & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_VR_HEADSET;
String extensions = mActivity.getExtensionsString();
final String requiredList[] = {
- "GL_EXT_EGL_image_array",
- "GL_EXT_external_buffer",
- "GL_EXT_multisampled_render_to_texture2",
+ "GL_EXT_multisampled_render_to_texture",
"GL_EXT_protected_textures",
"GL_OVR_multiview",
"GL_OVR_multiview2",
"GL_OVR_multiview_multisampled_render_to_texture",
};
+ final String vrHeadsetRequiredList[] = {
+ "GL_EXT_EGL_image_array",
+ "GL_EXT_external_buffer",
+ "GL_EXT_multisampled_render_to_texture2",
+ };
- for (int i = 0; i < requiredList.length; ++i) {
- assertTrue("Required extension for VR high-performance is missing: " + requiredList[i],
- hasExtension(extensions, requiredList[i]));
+ for (String requiredExtension : requiredList) {
+ assertTrue("Required extension for VR high-performance is missing: " + requiredExtension,
+ hasExtension(extensions, requiredExtension));
+ }
+ if (isVrHeadset) {
+ for (String requiredExtension : vrHeadsetRequiredList) {
+ assertTrue("Required extension for VR high-performance is missing: " + requiredExtension,
+ hasExtension(extensions, requiredExtension));
+ }
}
EGL10 egl = (EGL10) EGLContext.getEGL();
@@ -194,17 +206,25 @@
final String requiredEglList[] = {
"EGL_ANDROID_front_buffer_auto_refresh",
"EGL_ANDROID_get_native_client_buffer",
- "EGL_EXT_image_gl_colorspace",
"EGL_EXT_protected_content",
"EGL_IMG_context_priority",
"EGL_KHR_fence_sync",
"EGL_KHR_mutable_render_buffer",
"EGL_KHR_wait_sync",
};
+ final String vrHeadsetRequiredEglList[] = {
+ "EGL_EXT_image_gl_colorspace",
+ };
- for (int i = 0; i < requiredEglList.length; ++i) {
- assertTrue("Required EGL extension for VR high-performance is missing: " +
- requiredEglList[i], hasExtension(extensions, requiredEglList[i]));
+ for (String requiredExtension : requiredEglList) {
+ assertTrue("Required EGL extension for VR high-performance is missing: " + requiredExtension,
+ hasExtension(extensions, requiredExtension));
+ }
+ if (isVrHeadset) {
+ for (String requiredExtension : vrHeadsetRequiredEglList) {
+ assertTrue("Required EGL extension for VR high-performance is missing: " + requiredExtension,
+ hasExtension(extensions, requiredExtension));
+ }
}
}
@CddTest(requirement="7.1.4.1/C-6-1")
diff --git a/tests/tests/os/src/android/os/cts/BuildTest.java b/tests/tests/os/src/android/os/cts/BuildTest.java
index 7336fc0..b371ad1 100644
--- a/tests/tests/os/src/android/os/cts/BuildTest.java
+++ b/tests/tests/os/src/android/os/cts/BuildTest.java
@@ -43,7 +43,7 @@
/** Tests that check the values of {@link Build#CPU_ABI} and {@link Build#CPU_ABI2}. */
public void testCpuAbi() throws Exception {
runTestCpuAbiCommon();
- if (VMRuntime.getRuntime().is64Bit()) {
+ if (android.os.Process.is64Bit()) {
runTestCpuAbi64();
} else {
runTestCpuAbi32();
diff --git a/tests/tests/os/src/android/os/cts/ParcelTest.java b/tests/tests/os/src/android/os/cts/ParcelTest.java
index c65c61b..987ab00 100644
--- a/tests/tests/os/src/android/os/cts/ParcelTest.java
+++ b/tests/tests/os/src/android/os/cts/ParcelTest.java
@@ -19,7 +19,11 @@
import java.io.FileDescriptor;
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import android.content.pm.Signature;
import android.os.BadParcelableException;
@@ -3225,4 +3229,58 @@
assertEquals(42, list.get(0).getValue());
assertEquals(56, list.get(1).getValue());
}
+
+ public void testMaliciousMapWrite() {
+ class MaliciousMap<K, V> extends HashMap<K, V> {
+ public int fakeSize = 0;
+ public boolean armed = false;
+
+ class FakeEntrySet extends HashSet<Entry<K, V>> {
+ public FakeEntrySet(Collection<? extends Entry<K, V>> c) {
+ super(c);
+ }
+
+ @Override
+ public int size() {
+ if (armed) {
+ // Only return fake size on next call, to mitigate unexpected behavior.
+ armed = false;
+ return fakeSize;
+ } else {
+ return super.size();
+ }
+ }
+ }
+
+ @Override
+ public Set<Map.Entry<K, V>> entrySet() {
+ return new FakeEntrySet(super.entrySet());
+ }
+ }
+
+ Parcel parcel = Parcel.obtain();
+
+ // Fake having more Map entries than there really are
+ MaliciousMap map = new MaliciousMap<String, String>();
+ map.fakeSize = 1;
+ map.armed = true;
+ try {
+ parcel.writeMap(map);
+ fail("Should have thrown a BadParcelableException");
+ } catch (BadParcelableException bpe) {
+ // good
+ }
+
+ // Fake having fewer Map entries than there really are
+ map = new MaliciousMap<String, String>();
+ map.put("key", "value");
+ map.fakeSize = 0;
+ map.armed = true;
+ try {
+ parcel.writeMap(map);
+ fail("Should have thrown a BadParcelableException");
+ } catch (BadParcelableException bpe) {
+ // good
+ }
+ }
}
diff --git a/tests/tests/permission/src/android/permission/cts/AppOpsTest.java b/tests/tests/permission/src/android/permission/cts/AppOpsTest.java
index 547af7e..745d859 100644
--- a/tests/tests/permission/src/android/permission/cts/AppOpsTest.java
+++ b/tests/tests/permission/src/android/permission/cts/AppOpsTest.java
@@ -235,16 +235,6 @@
}
@SmallTest
- public void testAllOpsHaveOpString() {
- Set<String> opStrs = new HashSet<>();
- for (String opStr : AppOpsManager.getOpStrs()) {
- assertNotNull("Each app op must have an operation string defined", opStr);
- opStrs.add(opStr);
- }
- assertEquals("Not all op strings are unique", AppOpsManager._NUM_OP, opStrs.size());
- }
-
- @SmallTest
public void testOpCodesUnique() {
String[] opStrs = AppOpsManager.getOpStrs();
Set<Integer> opCodes = new HashSet<>();
diff --git a/tests/tests/permission2/Android.mk b/tests/tests/permission2/Android.mk
index e44cd14..c8b71c5 100755
--- a/tests/tests/permission2/Android.mk
+++ b/tests/tests/permission2/Android.mk
@@ -28,7 +28,8 @@
LOCAL_STATIC_JAVA_LIBRARIES := \
compatibility-device-util \
- ctstestrunner
+ ctstestrunner \
+ guava
LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/permission2/src/android/permission2/cts/PrivappPermissionsTest.java b/tests/tests/permission2/src/android/permission2/cts/PrivappPermissionsTest.java
index 585f9c6..517f451 100644
--- a/tests/tests/permission2/src/android/permission2/cts/PrivappPermissionsTest.java
+++ b/tests/tests/permission2/src/android/permission2/cts/PrivappPermissionsTest.java
@@ -16,27 +16,40 @@
package android.permission2.cts;
-import com.android.compatibility.common.util.SystemUtil;
+import static android.content.pm.PackageInfo.REQUESTED_PERMISSION_GRANTED;
+import static android.content.pm.PackageManager.GET_PERMISSIONS;
+import static android.content.pm.PackageManager.MATCH_FACTORY_ONLY;
+import static android.content.pm.PackageManager.MATCH_UNINSTALLED_PACKAGES;
+
+import static com.google.common.collect.Maps.filterValues;
+import static com.google.common.collect.Sets.difference;
+import static com.google.common.collect.Sets.intersection;
+import static com.google.common.collect.Sets.newHashSet;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PermissionInfo;
import android.support.test.InstrumentationRegistry;
import android.test.AndroidTestCase;
+import android.text.TextUtils;
+import android.util.ArrayMap;
import android.util.Log;
+import com.android.compatibility.common.util.PropertyUtil;
+import com.android.compatibility.common.util.SystemUtil;
+
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
-import static android.content.pm.PackageManager.GET_PERMISSIONS;
-import static android.content.pm.PackageManager.MATCH_FACTORY_ONLY;
-
/**
* Tests enforcement of signature|privileged permission whitelist:
* <ul>
@@ -65,8 +78,11 @@
}
List<PackageInfo> installedPackages = pm
- .getInstalledPackages(PackageManager.MATCH_UNINSTALLED_PACKAGES);
+ .getInstalledPackages(MATCH_UNINSTALLED_PACKAGES | GET_PERMISSIONS);
+ installedPackages.sort(Comparator.comparing(p -> p.packageName));
+ Map<String, Set<String>> packagesGrantedNotInWhitelist = new HashMap<>();
+ Map<String, Set<String>> packagesNotGrantedNotRemovedNotInDenylist = new HashMap<>();
for (PackageInfo pkg : installedPackages) {
String packageName = pkg.packageName;
if (!pkg.applicationInfo.isPrivilegedApp()
@@ -74,57 +90,116 @@
continue;
}
- Set<String> requestedPrivPermissions = new TreeSet<>();
- Set<String> grantedPrivPermissions = new TreeSet<>();
- PackageInfo factoryPackageInfo = pm
+ PackageInfo factoryPkg = pm
.getPackageInfo(packageName, MATCH_FACTORY_ONLY | GET_PERMISSIONS);
- assertNotNull("No system image version found for " + packageName, factoryPackageInfo);
- String[] requestedPermissions = factoryPackageInfo.requestedPermissions;
- int[] requestedPermissionsFlags = factoryPackageInfo.requestedPermissionsFlags;
+ assertNotNull("No system image version found for " + packageName, factoryPkg);
- if (requestedPermissions == null || requestedPermissions.length == 0) {
- continue;
+ Set<String> factoryRequestedPrivPermissions;
+ if (factoryPkg.requestedPermissions == null) {
+ factoryRequestedPrivPermissions = Collections.emptySet();
+ } else {
+ factoryRequestedPrivPermissions = intersection(
+ newHashSet(factoryPkg.requestedPermissions), platformPrivPermissions);
}
- // Collect 2 sets: requestedPermissions and grantedPrivPermissions
- for (int i = 0; i < requestedPermissions.length; i++) {
- String permission = requestedPermissions[i];
- if (platformPrivPermissions.contains(permission)) {
- requestedPrivPermissions.add(permission);
- if ((requestedPermissionsFlags[i]
- & PackageInfo.REQUESTED_PERMISSION_GRANTED) != 0) {
- grantedPrivPermissions.add(permission);
+
+ Map<String, Boolean> requestedPrivPermissions = new ArrayMap<>();
+ if (pkg.requestedPermissions != null) {
+ for (int i = 0; i < pkg.requestedPermissions.length; i++) {
+ String permission = pkg.requestedPermissions[i];
+ if (platformPrivPermissions.contains(permission)) {
+ requestedPrivPermissions.put(permission,
+ (pkg.requestedPermissionsFlags[i] & REQUESTED_PERMISSION_GRANTED)
+ != 0);
}
}
}
+
// If an app is requesting any privileged permissions, log the details and verify
// that granted permissions are whitelisted
- if (!requestedPrivPermissions.isEmpty()) {
- Set<String> notGranted = new TreeSet<>(requestedPrivPermissions);
- notGranted.removeAll(grantedPrivPermissions);
+ if (!factoryRequestedPrivPermissions.isEmpty() && !requestedPrivPermissions.isEmpty()) {
+ Set<String> granted = filterValues(requestedPrivPermissions,
+ isGranted -> isGranted).keySet();
+
+ Set<String> factoryNotGranted = difference(factoryRequestedPrivPermissions,
+ granted);
+
+ // priv permissions that the system package requested, but the current package not
+ // anymore
+ Set<String> removed = difference(factoryRequestedPrivPermissions,
+ requestedPrivPermissions.keySet());
+
Set<String> whitelist = getPrivAppPermissions(packageName);
Set<String> denylist = getPrivAppDenyPermissions(packageName);
- Log.i(TAG, "Application " + packageName + "."
- + " Requested permissions: " + requestedPrivPermissions + "."
- + " Granted permissions: " + grantedPrivPermissions + "."
- + " Not granted: " + notGranted + "."
- + " Whitelisted: " + whitelist + "."
- + " Denylisted: " + denylist);
+ String msg = "Application " + packageName + "\n"
+ + " Factory requested permissions:\n"
+ + getPrintableSet(" ", factoryRequestedPrivPermissions)
+ + " Granted:\n"
+ + getPrintableSet(" ", granted)
+ + " Removed:\n"
+ + getPrintableSet(" ", removed)
+ + " Whitelisted:\n"
+ + getPrintableSet(" ", whitelist)
+ + " Denylisted:\n"
+ + getPrintableSet(" ", denylist)
+ + " Factory not granted:\n"
+ + getPrintableSet(" ", factoryNotGranted);
- Set<String> grantedNotInWhitelist = new TreeSet<>(grantedPrivPermissions);
- grantedNotInWhitelist.removeAll(whitelist);
- Set<String> notGrantedNotInDenylist = new TreeSet<>(notGranted);
- notGrantedNotInDenylist.removeAll(denylist);
+ for (String line : msg.split("\n")) {
+ Log.i(TAG, line);
- assertTrue("Not whitelisted permissions are granted for package "
- + packageName + ": " + grantedNotInWhitelist,
- grantedNotInWhitelist.isEmpty());
+ // Prevent log from truncating output
+ Thread.sleep(10);
+ }
- assertTrue("Requested permissions not granted for package "
- + packageName + ": " + notGrantedNotInDenylist,
- notGrantedNotInDenylist.isEmpty());
+ Set<String> grantedNotInWhitelist = difference(granted, whitelist);
+ Set<String> factoryNotGrantedNotRemovedNotInDenylist = difference(difference(
+ factoryNotGranted, removed), denylist);
+
+ if (!grantedNotInWhitelist.isEmpty()) {
+ packagesGrantedNotInWhitelist.put(packageName, grantedNotInWhitelist);
+ }
+
+ if (!factoryNotGrantedNotRemovedNotInDenylist.isEmpty()) {
+ packagesNotGrantedNotRemovedNotInDenylist.put(packageName,
+ factoryNotGrantedNotRemovedNotInDenylist);
+ }
}
}
+ StringBuilder message = new StringBuilder();
+ if (!packagesGrantedNotInWhitelist.isEmpty()) {
+ message.append("Not whitelisted permissions are granted: "
+ + packagesGrantedNotInWhitelist.toString());
+ }
+ if (!packagesNotGrantedNotRemovedNotInDenylist.isEmpty()) {
+ if (message.length() != 0) {
+ message.append(", ");
+ }
+ message.append("Requested permissions not granted: "
+ + packagesNotGrantedNotRemovedNotInDenylist.toString());
+ }
+ if (!packagesGrantedNotInWhitelist.isEmpty()
+ || !packagesNotGrantedNotRemovedNotInDenylist.isEmpty()) {
+ fail(message.toString());
+ }
+ }
+
+ private <T> String getPrintableSet(String indendation, Set<T> set) {
+ if (set.isEmpty()) {
+ return "";
+ }
+
+ StringBuilder sb = new StringBuilder();
+
+ for (T e : new TreeSet<>(set)) {
+ if (!TextUtils.isEmpty(e.toString().trim())) {
+ sb.append(indendation);
+ sb.append(e);
+ sb.append("\n");
+ }
+ }
+
+ return sb.toString();
}
private Set<String> getPrivAppPermissions(String packageName) throws IOException {
diff --git a/tests/tests/provider/src/android/provider/cts/BlockedNumberContractTest.java b/tests/tests/provider/src/android/provider/cts/BlockedNumberContractTest.java
index 4ef28f4..30fdf24 100644
--- a/tests/tests/provider/src/android/provider/cts/BlockedNumberContractTest.java
+++ b/tests/tests/provider/src/android/provider/cts/BlockedNumberContractTest.java
@@ -26,6 +26,7 @@
import android.net.Uri;
import android.provider.BlockedNumberContract;
import android.provider.BlockedNumberContract.BlockedNumbers;
+import android.telephony.TelephonyManager;
import junit.framework.Assert;
@@ -69,6 +70,13 @@
}
public void testProviderInteractionsAsRegularApp_fails() {
+ TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
+ // Don't run this test if we're carrier privileged.
+ if (telephonyManager.checkCarrierPrivilegesForPackage(mContext.getPackageName())
+ == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
+ return;
+ }
+
try {
mAddedUris.add(mContentResolver.insert(
BlockedNumbers.CONTENT_URI, getContentValues("1234567890")));
diff --git a/tests/tests/provider/src/android/provider/cts/CalendarTest.java b/tests/tests/provider/src/android/provider/cts/CalendarTest.java
index 8db5e45..fcd873a 100644
--- a/tests/tests/provider/src/android/provider/cts/CalendarTest.java
+++ b/tests/tests/provider/src/android/provider/cts/CalendarTest.java
@@ -2516,8 +2516,8 @@
// instances, and it's stored as minutes since midnight in the device's time zone.
// Things won't be consistent if the event and the device have different ideas about DST.
String timeZone = eventValues.getAsString(Events.EVENT_TIMEZONE);
- String testStart = "1999-04-18T00:00:00";
- String testEnd = "1999-05-16T23:59:59";
+ String testStart = "1999-07-02T00:00:00";
+ String testEnd = "1999-08-04T23:59:59";
String[] projection = { Instances.BEGIN, Instances.START_MINUTE, Instances.END_MINUTE };
Cursor instances = getInstances(timeZone, testStart, testEnd, projection,
diff --git a/tests/tests/provider/src/android/provider/cts/MediaStoreUiTest.java b/tests/tests/provider/src/android/provider/cts/MediaStoreUiTest.java
index b54a5e5..6ce81a0 100644
--- a/tests/tests/provider/src/android/provider/cts/MediaStoreUiTest.java
+++ b/tests/tests/provider/src/android/provider/cts/MediaStoreUiTest.java
@@ -16,12 +16,19 @@
package android.provider.cts;
+import static android.Manifest.permission.ACCESS_COARSE_LOCATION;
+import static android.Manifest.permission.ACCESS_FINE_LOCATION;
+import static android.Manifest.permission.CAMERA;
+import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
+import static android.Manifest.permission.RECORD_AUDIO;
+import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
+
import android.app.Activity;
-import android.app.UiAutomation;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.UriPermission;
+import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.media.ExifInterface;
@@ -41,7 +48,6 @@
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.UiSelector;
import android.support.test.uiautomator.Until;
-import androidx.core.content.FileProvider;
import android.test.InstrumentationTestCase;
import android.text.format.DateUtils;
import android.util.Log;
@@ -53,9 +59,14 @@
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import androidx.core.content.FileProvider;
+
public class MediaStoreUiTest extends InstrumentationTestCase {
private static final String TAG = "MediaStoreUiTest";
@@ -141,6 +152,13 @@
try { mDevice.findObject(sel).click(); } catch (Throwable ignored) { }
}
+ private void maybeGrantRuntimePermission(String pkg, Set<String> requested, String permission) {
+ if (requested.contains(permission)) {
+ InstrumentationRegistry.getInstrumentation().getUiAutomation()
+ .grantRuntimePermission(pkg, permission);
+ }
+ }
+
/**
* Verify that whoever handles {@link MediaStore#ACTION_IMAGE_CAPTURE} can
* correctly write the contents into a passed {@code content://} Uri.
@@ -167,14 +185,18 @@
final String pkg = ri.activityInfo.packageName;
Log.d(TAG, "We're probably launching " + ri);
+ final PackageInfo pi = context.getPackageManager().getPackageInfo(pkg,
+ PackageManager.GET_PERMISSIONS);
+ final Set<String> req = new HashSet<>();
+ req.addAll(Arrays.asList(pi.requestedPermissions));
+
// Grant them all the permissions they might want
- final UiAutomation ui = InstrumentationRegistry.getInstrumentation().getUiAutomation();
- ui.grantRuntimePermission(pkg, android.Manifest.permission.CAMERA);
- ui.grantRuntimePermission(pkg, android.Manifest.permission.ACCESS_COARSE_LOCATION);
- ui.grantRuntimePermission(pkg, android.Manifest.permission.ACCESS_FINE_LOCATION);
- ui.grantRuntimePermission(pkg, android.Manifest.permission.RECORD_AUDIO);
- ui.grantRuntimePermission(pkg, android.Manifest.permission.READ_EXTERNAL_STORAGE);
- ui.grantRuntimePermission(pkg, android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
+ maybeGrantRuntimePermission(pkg, req, CAMERA);
+ maybeGrantRuntimePermission(pkg, req, ACCESS_COARSE_LOCATION);
+ maybeGrantRuntimePermission(pkg, req, ACCESS_FINE_LOCATION);
+ maybeGrantRuntimePermission(pkg, req, RECORD_AUDIO);
+ maybeGrantRuntimePermission(pkg, req, READ_EXTERNAL_STORAGE);
+ maybeGrantRuntimePermission(pkg, req, WRITE_EXTERNAL_STORAGE);
SystemClock.sleep(DateUtils.SECOND_IN_MILLIS);
mActivity.startActivityForResult(intent, REQUEST_CODE);
diff --git a/tests/tests/provider/src/android/provider/cts/Settings_SystemTest.java b/tests/tests/provider/src/android/provider/cts/Settings_SystemTest.java
index badc88e..bbdf714 100644
--- a/tests/tests/provider/src/android/provider/cts/Settings_SystemTest.java
+++ b/tests/tests/provider/src/android/provider/cts/Settings_SystemTest.java
@@ -149,6 +149,11 @@
c.close();
// restore the fontScale
+ try {
+ // Delay helps ActivityManager in completing its previous font-change processing.
+ Thread.sleep(1000);
+ } catch (Exception e){}
+
cfg.fontScale = store;
assertTrue(System.putConfiguration(cr, cfg));
}
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_ContactsTest.java b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_ContactsTest.java
index 3c56aba..c5fdc1a 100644
--- a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_ContactsTest.java
+++ b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_ContactsTest.java
@@ -206,8 +206,6 @@
final TestContact contact = rawContact.getContact().load();
contact.load();
- assertEquals(0L, contact.getLong(Contacts.TIMES_CONTACTED));
- assertEquals(0L, contact.getLong(Contacts.LAST_TIME_CONTACTED));
final long now = System.currentTimeMillis();
@@ -218,8 +216,6 @@
ContactUtil.update(mResolver, contact.getId(), values);
contact.load();
- assertEquals(3L, contact.getLong(Contacts.TIMES_CONTACTED));
- assertEquals(now / 86400 * 86400, contact.getLong(Contacts.LAST_TIME_CONTACTED));
// This is also the same as markAsContacted().
values.clear();
@@ -227,8 +223,6 @@
ContactUtil.update(mResolver, contact.getId(), values);
contact.load();
- assertEquals(4L, contact.getLong(Contacts.TIMES_CONTACTED));
- assertEquals(now / 86400 * 86400, contact.getLong(Contacts.LAST_TIME_CONTACTED));
values.clear();
values.put(Contacts.TIMES_CONTACTED, 10);
@@ -236,27 +230,17 @@
ContactUtil.update(mResolver, contact.getId(), values);
contact.load();
- assertEquals(10L, contact.getLong(Contacts.TIMES_CONTACTED));
- assertEquals(now / 86400 * 86400, contact.getLong(Contacts.LAST_TIME_CONTACTED));
}
- /**
- * Make sure the rounded usage stats values are also what the callers would see in where
- * clauses.
- *
- * This tests both contacts and raw_contacts.
- */
public void testContactUpdateDelete_usageStats_visibilityInWhere() throws Exception {
final TestRawContact rawContact = mBuilder.newRawContact().insert().load();
final TestContact contact = rawContact.getContact().load();
- // To make things more predictable, inline markAsContacted here with a known timestamp.
final long now = (System.currentTimeMillis() / 86400 * 86400) + 86400 * 5 + 123;
ContentValues values = new ContentValues();
values.put(Contacts.LAST_TIME_CONTACTED, now);
- // This makes the internal TIMES_CONTACTED 35. But the visible value is still 30.
for (int i = 0; i < 35; i++) {
ContactUtil.update(mResolver, contact.getId(), values);
}
@@ -264,12 +248,6 @@
contact.load();
rawContact.load();
- assertEquals(now / 86400 * 86400, contact.getLong(Contacts.LAST_TIME_CONTACTED));
- assertEquals(30, contact.getLong(Contacts.TIMES_CONTACTED));
-
- assertEquals(now / 86400 * 86400, rawContact.getLong(Contacts.LAST_TIME_CONTACTED));
- assertEquals(30, rawContact.getLong(Contacts.TIMES_CONTACTED));
-
final ContentValues cv = new ContentValues();
cv.put(Contacts.STARRED, 1);
@@ -277,12 +255,7 @@
(Contacts.LAST_TIME_CONTACTED + "=P1 AND " + Contacts.TIMES_CONTACTED + "=P2")
.replaceAll("P1", String.valueOf(now / 86400 * 86400))
.replaceAll("P2", "30");
- assertEquals(1, mResolver.update(Contacts.CONTENT_URI, cv, where, null));
- assertEquals(1, mResolver.update(RawContacts.CONTENT_URI, cv, where, null));
- // Also delete. This will actually delete the row, so we can test it only for one of the
- // contact or the raw contact.
- assertEquals(1, mResolver.delete(RawContacts.CONTENT_URI, where, null));
rawContact.setAlreadyDeleted();
contact.setAlreadyDeleted();
}
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DataUsageTest.java b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DataUsageTest.java
index d5ab172..befbeb8 100644
--- a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DataUsageTest.java
+++ b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DataUsageTest.java
@@ -93,28 +93,20 @@
long[] dataIds = setupRawContactDataItems(ids.mRawContactId);
- assertDataUsageEquals(dataIds, 0, 0, 0, 0);
-
updateMultipleAndAssertUpdateSuccess(new long[] {dataIds[1], dataIds[2]});
- assertDataUsageEquals(dataIds, 0, 1, 1, 0);
updateMultipleAndAssertUpdateSuccess(new long[]{dataIds[1], dataIds[2]});
- assertDataUsageEquals(dataIds, 0, 2, 2, 0);
for (int i = 3; i <= 10; i++) {
updateMultipleAndAssertUpdateSuccess(new long[]{dataIds[1]});
}
- assertDataUsageEquals(dataIds, 0, 10, 2, 0);
updateMultipleAndAssertUpdateSuccess(new long[]{dataIds[0], dataIds[1]});
- assertDataUsageEquals(dataIds, 1, 10, 2, 0);
for (int i = 12; i <= 19; i++) {
updateMultipleAndAssertUpdateSuccess(new long[]{dataIds[1]});
- assertDataUsageEquals(dataIds, 1, 10, 2, 0);
}
updateMultipleAndAssertUpdateSuccess(new long[]{dataIds[1]});
- assertDataUsageEquals(dataIds, 1, 20, 2, 0);
deleteDataUsage();
RawContactUtil.delete(mResolver, ids.mRawContactId, true);
@@ -142,7 +134,6 @@
.appendQueryParameter(DataUsageFeedback.USAGE_TYPE,
DataUsageFeedback.USAGE_TYPE_CALL).build();
int result = mResolver.update(uri, new ContentValues(), null, null);
- assertTrue(result > 0);
}
/**
@@ -154,42 +145,6 @@
.appendQueryParameter(DataUsageFeedback.USAGE_TYPE,
DataUsageFeedback.USAGE_TYPE_CALL).build();
int result = mResolver.update(uri, new ContentValues(), null, null);
- assertTrue(result > 0);
-
- assertDataUsageEquals(dataId, assertValue);
- }
-
- /**
- * Assert that the given data ids have usage values in the respective order.
- */
- private void assertDataUsageEquals(long[] dataIds, int... expectedValues) {
- if (dataIds.length != expectedValues.length) {
- throw new IllegalArgumentException("dataIds and expectedValues must be the same size");
- }
-
- for (int i = 0; i < dataIds.length; i++) {
- assertDataUsageEquals(dataIds[i], expectedValues[i]);
- }
- }
-
- /**
- * Assert a single data item has a specific usage value.
- */
- private void assertDataUsageEquals(long dataId, int expectedValue) {
- // Query and assert value is expected.
- String[] projection = new String[]{ContactsContract.Data.TIMES_USED};
- String[] record = DataUtil.queryById(mResolver, dataId, projection);
- assertNotNull(record);
- long actual = 0;
- // Tread null as 0
- if (record[0] != null) {
- actual = Long.parseLong(record[0]);
- }
- assertEquals(expectedValue, actual);
-
- // Also make sure the rounded value is used in 'where' too.
- assertEquals("Query should match", 1, DataUtil.queryById(mResolver, dataId, projection,
- "ifnull(" + Data.TIMES_USED + ",0)=" + expectedValue, null).length);
}
private void deleteDataUsage() {
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DumpFileProviderTest.java b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DumpFileProviderTest.java
index 18006b2..3a2f670 100644
--- a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DumpFileProviderTest.java
+++ b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_DumpFileProviderTest.java
@@ -29,7 +29,6 @@
private static final String[] NOT_ALLOWED_FILES = {
"not_allowed.txt",
"../A-contacts-db.zip", // ".." is not allowed.
- "/A-contacts-db.zip", // "/" is not allowed
"-contacts-db.zip", // no name prefix
"asdf-contacts-db.zip"};
@@ -88,7 +87,7 @@
return;
}
- fail("IllegalArgumentException expected but not thrown.");
+ fail("IllegalArgumentException expected but not thrown: " + uri);
}
private void assertOpenFileDescriptorThrowsError(Uri uri) {
@@ -101,6 +100,6 @@
}
- fail("IllegalArgumentException expected but not thrown.");
+ fail("IllegalArgumentException expected but not thrown: " + uri);
}
}
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_FrequentsStrequentsTest.java b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_FrequentsStrequentsTest.java
index 2231bd2f..f06c859 100644
--- a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_FrequentsStrequentsTest.java
+++ b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_FrequentsStrequentsTest.java
@@ -196,11 +196,6 @@
// Contact the third contact twice.
markDataAsUsed(mDataIds[2], 2);
-
- // The strequents uri should now return contact 2, 3, 1 in order due to ranking by
- // data usage.
- assertCursorStoredValuesWithContactsFilter(Contacts.CONTENT_STREQUENT_URI, ids,
- false, sContentValues[1], sContentValues[2], sContentValues[0]);
}
/**
@@ -220,13 +215,6 @@
// Contact the third contact twice, and mark it as used
markDataAsUsed(mDataIds[2], 2);
starContact(ids[2]);
-
- // The strequents uri should now return contact 3, 2, 1 in order. Contact 3 is ranked first
- // because it is starred, followed by contacts 2 and 1 due to their data usage ranking.
- // Note that contact 3 is only returned once (as a starred contact) even though it is also
- // a frequently contacted contact.
- assertCursorStoredValuesWithContactsFilter(Contacts.CONTENT_STREQUENT_URI, ids,
- false, sContentValues[2], sContentValues[1], sContentValues[0]);
}
/**
@@ -243,10 +231,6 @@
// Construct a uri that filters for the query string "ta".
Uri uri = Contacts.CONTENT_STREQUENT_FILTER_URI.buildUpon().appendEncodedPath("ta").build();
-
- // Only contact 1 and 2 should be returned (sorted in alphabetical order) due to the
- // filtered query.
- assertCursorStoredValuesWithContactsFilter(uri, ids, false, sContentValues[1], sContentValues[0]);
}
public void testStrequents_projection() throws Exception {
@@ -303,10 +287,6 @@
// Construct a uri for phone only favorites.
Uri uri = Contacts.CONTENT_STREQUENT_URI.buildUpon().
appendQueryParameter(ContactsContract.STREQUENT_PHONE_ONLY, "true").build();
-
- // Only the contacts with phone numbers are returned, in frequency ranking order.
- assertCursorStoredValuesWithContactsFilter(uri, mDataIds, false,
- sContentValues[2], sContentValues[0]);
}
public void testStrequents_phoneOnly_projection() throws Exception {
@@ -342,11 +322,6 @@
// Contact the third contact twice.
markDataAsUsed(mDataIds[2], 2);
-
- // The frequents uri should now return contact 2, 3, 1 in order due to ranking by
- // data usage.
- assertCursorStoredValuesWithContactsFilter(Contacts.CONTENT_FREQUENT_URI, ids,
- true /* inOrder */, sContentValues[1], sContentValues[2], sContentValues[0]);
}
public void testFrequent_projection() throws Exception {
diff --git a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_RawContactsTest.java b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_RawContactsTest.java
index 7c971b3..d937005 100644
--- a/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_RawContactsTest.java
+++ b/tests/tests/provider/src/android/provider/cts/contacts/ContactsContract_RawContactsTest.java
@@ -243,8 +243,6 @@
.insert();
rawContact.load();
- assertEquals(12340, rawContact.getLong(RawContacts.TIMES_CONTACTED));
- assertEquals(now / 86400 * 86400, rawContact.getLong(RawContacts.LAST_TIME_CONTACTED));
}
{
@@ -255,8 +253,6 @@
.insert();
rawContact.load();
- assertEquals(5L, rawContact.getLong(RawContacts.TIMES_CONTACTED));
- assertEquals(0, rawContact.getLong(RawContacts.LAST_TIME_CONTACTED));
}
{
TestRawContact rawContact = mBuilder.newRawContact()
@@ -266,8 +262,6 @@
.insert();
rawContact.load();
- assertEquals(0L, rawContact.getLong(RawContacts.TIMES_CONTACTED));
- assertEquals(now / 86400 * 86400, rawContact.getLong(RawContacts.LAST_TIME_CONTACTED));
}
}
@@ -283,24 +277,17 @@
.insert();
rawContact.load();
- assertEquals(12340L, rawContact.getLong(RawContacts.TIMES_CONTACTED));
- assertEquals(now / 86400 * 86400, rawContact.getLong(RawContacts.LAST_TIME_CONTACTED));
values.clear();
values.put(RawContacts.TIMES_CONTACTED, 99999);
RawContactUtil.update(mResolver, rawContact.getId(), values);
rawContact.load();
- assertEquals(99990L, rawContact.getLong(RawContacts.TIMES_CONTACTED));
- assertEquals(now / 86400 * 86400, rawContact.getLong(RawContacts.LAST_TIME_CONTACTED));
values.clear();
values.put(RawContacts.LAST_TIME_CONTACTED, now + 86400);
RawContactUtil.update(mResolver, rawContact.getId(), values);
rawContact.load();
- assertEquals(99990L, rawContact.getLong(RawContacts.TIMES_CONTACTED));
- assertEquals((now / 86400 * 86400) + 86400,
- rawContact.getLong(RawContacts.LAST_TIME_CONTACTED));
}
}
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
index 7328762..c85f8b7 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
Binary files differ
diff --git a/tests/tests/secure_element/access_control/AccessControlApp1/src/android/omapi/accesscontrol1/cts/AccessControlTest.java b/tests/tests/secure_element/access_control/AccessControlApp1/src/android/omapi/accesscontrol1/cts/AccessControlTest.java
old mode 100644
new mode 100755
index 22b8432..4ea5b596
--- a/tests/tests/secure_element/access_control/AccessControlApp1/src/android/omapi/accesscontrol1/cts/AccessControlTest.java
+++ b/tests/tests/secure_element/access_control/AccessControlApp1/src/android/omapi/accesscontrol1/cts/AccessControlTest.java
@@ -18,6 +18,7 @@
package android.omapi.accesscontrol1.cts;
+import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
import static org.junit.Assume.assumeTrue;
@@ -38,7 +39,7 @@
import android.se.omapi.SEService.OnConnectedListener;
import android.se.omapi.Session;
import android.support.test.InstrumentationRegistry;
-
+import android.os.Build;
import com.android.compatibility.common.util.PropertyUtil;
public class AccessControlTest {
@@ -162,6 +163,7 @@
@Before
public void setUp() throws Exception {
+ assumeTrue(PropertyUtil.getFirstApiLevel() > Build.VERSION_CODES.O_MR1);
assumeTrue(supportsHardware());
seService = new SEService(InstrumentationRegistry.getContext(), new SynchronousExecutor(), mListener);
connectionTimer = new Timer();
@@ -239,121 +241,121 @@
}
private void testSelectableAid(byte[] aid) {
- Session session = null;
- Channel channel = null;
try {
waitForConnection();
Reader[] readers = seService.getReaders();
for (Reader reader : readers) {
- assertTrue(reader.isSecureElementPresent());
- session = reader.openSession();
- assertNotNull("Null Session", session);
- channel = session.openLogicalChannel(aid, (byte) 0x00);
- assertNotNull("Null Channel", channel);
- byte[] selectResponse = channel.getSelectResponse();
- assertNotNull("Null Select Response", selectResponse);
- assertEquals(selectResponse[selectResponse.length - 1] & 0xFF, 0x00);
- assertEquals(selectResponse[selectResponse.length - 2] & 0xFF, 0x90);
- assertTrue("Select Response is not complete", verifyBerTlvData(selectResponse));
+ Session session = null;
+ Channel channel = null;
+ try {
+ assertTrue(reader.isSecureElementPresent());
+ session = reader.openSession();
+ assertNotNull("Null Session", session);
+ channel = session.openLogicalChannel(aid, (byte) 0x00);
+ assertNotNull("Null Channel", channel);
+ byte[] selectResponse = channel.getSelectResponse();
+ assertNotNull("Null Select Response", selectResponse);
+ assertThat(selectResponse[selectResponse.length - 1] & 0xFF, is(0x00));
+ assertThat(selectResponse[selectResponse.length - 2] & 0xFF, is(0x90));
+ assertTrue("Select Response is not complete", verifyBerTlvData(selectResponse));
+ } finally {
+ if (channel != null) channel.close();
+ if (session != null) session.close();
+ }
}
} catch (Exception e) {
fail("Unexpected Exception " + e);
- } finally{
- if (channel != null)
- channel.close();
- if (session != null)
- session.close();
}
}
private void testUnauthorisedAid(byte[] aid) {
- Session session = null;
- Channel channel = null;
try {
waitForConnection();
Reader[] readers = seService.getReaders();
-
for (Reader reader : readers) {
- assertTrue(reader.isSecureElementPresent());
- session = reader.openSession();
- assertNotNull("Null Session", session);
- channel = session.openLogicalChannel(aid, (byte) 0x00);
- fail("SecurityException Expected ");
+ Session session = null;
+ Channel channel = null;
+ try {
+ assertTrue(reader.isSecureElementPresent());
+ session = reader.openSession();
+ assertNotNull("Null Session", session);
+ try {
+ channel = session.openLogicalChannel(aid, (byte) 0x00);
+ fail("SecurityException Expected");
+ } catch (SecurityException e) {
+ // Expected
+ }
+ } finally {
+ if (channel != null) channel.close();
+ if (session != null) session.close();
+ }
}
- } catch(SecurityException ex){ }
- catch (Exception e) {
+ } catch (Exception e) {
fail("Unexpected Exception " + e);
}
- if (channel != null)
- channel.close();
- if (session != null)
- session.close();
}
private void testTransmitAPDU(byte[] aid, byte[] apdu) {
- Session session = null;
- Channel channel = null;
try {
waitForConnection();
Reader[] readers = seService.getReaders();
-
for (Reader reader : readers) {
- assertTrue(reader.isSecureElementPresent());
- session = reader.openSession();
- assertNotNull("Null Session", session);
- channel = session.openLogicalChannel(aid, (byte) 0x00);
- assertNotNull("Null Channel", channel);
- byte[] selectResponse = channel.getSelectResponse();
- assertNotNull("Null Select Response", selectResponse);
- assertEquals(selectResponse[selectResponse.length - 1] & 0xFF, 0x00);
- assertEquals(selectResponse[selectResponse.length - 2] & 0xFF, 0x90);
- assertTrue("Select Response is not complete", verifyBerTlvData(selectResponse));
- byte[] apduResponse = channel.transmit(apdu);
- assertNotNull("Null Channel", apduResponse);
+ Session session = null;
+ Channel channel = null;
+ try {
+ assertTrue(reader.isSecureElementPresent());
+ session = reader.openSession();
+ assertNotNull("Null Session", session);
+ channel = session.openLogicalChannel(aid, (byte) 0x00);
+ assertNotNull("Null Channel", channel);
+ byte[] selectResponse = channel.getSelectResponse();
+ assertNotNull("Null Select Response", selectResponse);
+ assertThat(selectResponse[selectResponse.length - 1] & 0xFF, is(0x00));
+ assertThat(selectResponse[selectResponse.length - 2] & 0xFF, is(0x90));
+ assertTrue("Select Response is not complete", verifyBerTlvData(selectResponse));
+ byte[] apduResponse = channel.transmit(apdu);
+ assertNotNull("Null Channel", apduResponse);
+ } finally {
+ if (channel != null) channel.close();
+ if (session != null) session.close();
+ }
}
} catch (Exception e) {
fail("Unexpected Exception " + e);
}
- if (channel != null)
- channel.close();
- if (session != null)
- session.close();
}
private void testUnauthorisedAPDU(byte[] aid, byte[] apdu) {
- Session session = null;
- Channel channel = null;
- boolean exceptionOnTransmit = false;
try {
waitForConnection();
Reader[] readers = seService.getReaders();
-
for (Reader reader : readers) {
- assertTrue(reader.isSecureElementPresent());
- session = reader.openSession();
- assertNotNull("Null Session", session);
- channel = session.openLogicalChannel(aid, (byte) 0x00);
- assertNotNull("Null Channel", channel);
- byte[] selectResponse = channel.getSelectResponse();
- assertNotNull("Null Select Response", selectResponse);
- assertEquals(selectResponse[selectResponse.length - 1] & 0xFF, 0x00);
- assertEquals(selectResponse[selectResponse.length - 2] & 0xFF, 0x90);
- assertTrue("Select Response is not complete", verifyBerTlvData(selectResponse));
- exceptionOnTransmit = true;
- channel.transmit(apdu);
- fail("Security Exception is expected");
+ Session session = null;
+ Channel channel = null;
+ try {
+ assertTrue(reader.isSecureElementPresent());
+ session = reader.openSession();
+ assertNotNull("Null Session", session);
+ channel = session.openLogicalChannel(aid, (byte) 0x00);
+ assertNotNull("Null Channel", channel);
+ byte[] selectResponse = channel.getSelectResponse();
+ assertNotNull("Null Select Response", selectResponse);
+ assertThat(selectResponse[selectResponse.length - 1] & 0xFF, is(0x00));
+ assertThat(selectResponse[selectResponse.length - 2] & 0xFF, is(0x90));
+ assertTrue("Select Response is not complete", verifyBerTlvData(selectResponse));
+ try {
+ channel.transmit(apdu);
+ fail("Security Exception is expected");
+ } catch (SecurityException e) {
+ // Expected
+ }
+ } finally {
+ if (channel != null) channel.close();
+ if (session != null) session.close();
+ }
}
- } catch (SecurityException ex) {
- if (!exceptionOnTransmit) {
- fail("Unexpected SecurityException onSelect" + ex);
- }
} catch (Exception e) {
- fail("Unexpected Exception " + e);
- } finally {
- if(channel != null)
- channel.close();
- if (session != null)
- session.close();
+ fail("Unexpected Exception " + e);
}
}
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
index 072f2af..b8a978d 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
Binary files differ
diff --git a/tests/tests/secure_element/access_control/AccessControlApp2/src/android/omapi/accesscontrol2/cts/AccessControlTest.java b/tests/tests/secure_element/access_control/AccessControlApp2/src/android/omapi/accesscontrol2/cts/AccessControlTest.java
old mode 100644
new mode 100755
index 3adc1c9..5998cea
--- a/tests/tests/secure_element/access_control/AccessControlApp2/src/android/omapi/accesscontrol2/cts/AccessControlTest.java
+++ b/tests/tests/secure_element/access_control/AccessControlApp2/src/android/omapi/accesscontrol2/cts/AccessControlTest.java
@@ -18,6 +18,7 @@
package android.omapi.accesscontrol2.cts;
+import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
import static org.junit.Assume.assumeTrue;
@@ -38,7 +39,7 @@
import android.se.omapi.SEService.OnConnectedListener;
import android.se.omapi.Session;
import android.support.test.InstrumentationRegistry;
-
+import android.os.Build;
import com.android.compatibility.common.util.PropertyUtil;
public class AccessControlTest {
@@ -161,6 +162,7 @@
@Before
public void setUp() throws Exception {
+ assumeTrue(PropertyUtil.getFirstApiLevel() > Build.VERSION_CODES.O_MR1);
assumeTrue(supportsHardware());
seService = new SEService(InstrumentationRegistry.getContext(), new SynchronousExecutor(), mListener);
connectionTimer = new Timer();
@@ -238,121 +240,121 @@
}
private void testSelectableAid(byte[] aid) {
- Session session = null;
- Channel channel = null;
try {
waitForConnection();
Reader[] readers = seService.getReaders();
for (Reader reader : readers) {
- assertTrue(reader.isSecureElementPresent());
- session = reader.openSession();
- assertNotNull("Null Session", session);
- channel = session.openLogicalChannel(aid, (byte) 0x00);
- assertNotNull("Null Channel", channel);
- byte[] selectResponse = channel.getSelectResponse();
- assertNotNull("Null Select Response", selectResponse);
- assertEquals(selectResponse[selectResponse.length - 1] & 0xFF, 0x00);
- assertEquals(selectResponse[selectResponse.length - 2] & 0xFF, 0x90);
- assertTrue("Select Response is not complete", verifyBerTlvData(selectResponse));
+ Session session = null;
+ Channel channel = null;
+ try {
+ assertTrue(reader.isSecureElementPresent());
+ session = reader.openSession();
+ assertNotNull("Null Session", session);
+ channel = session.openLogicalChannel(aid, (byte) 0x00);
+ assertNotNull("Null Channel", channel);
+ byte[] selectResponse = channel.getSelectResponse();
+ assertNotNull("Null Select Response", selectResponse);
+ assertThat(selectResponse[selectResponse.length - 1] & 0xFF, is(0x00));
+ assertThat(selectResponse[selectResponse.length - 2] & 0xFF, is(0x90));
+ assertTrue("Select Response is not complete", verifyBerTlvData(selectResponse));
+ } finally {
+ if (channel != null) channel.close();
+ if (session != null) session.close();
+ }
}
} catch (Exception e) {
fail("Unexpected Exception " + e);
- } finally{
- if (channel != null)
- channel.close();
- if (session != null)
- session.close();
}
}
private void testUnauthorisedAid(byte[] aid) {
- Session session = null;
- Channel channel = null;
try {
waitForConnection();
Reader[] readers = seService.getReaders();
-
for (Reader reader : readers) {
- assertTrue(reader.isSecureElementPresent());
- session = reader.openSession();
- assertNotNull("Null Session", session);
- channel = session.openLogicalChannel(aid, (byte)0x00);
- fail("SecurityException Expected ");
+ Session session = null;
+ Channel channel = null;
+ try {
+ assertTrue(reader.isSecureElementPresent());
+ session = reader.openSession();
+ assertNotNull("Null Session", session);
+ try {
+ channel = session.openLogicalChannel(aid, (byte) 0x00);
+ fail("SecurityException Expected");
+ } catch (SecurityException e) {
+ // Expected
+ }
+ } finally {
+ if (channel != null) channel.close();
+ if (session != null) session.close();
+ }
}
- } catch(SecurityException ex){ }
- catch (Exception e) {
+ } catch (Exception e) {
fail("Unexpected Exception " + e);
}
- if (channel != null)
- channel.close();
- if (session != null)
- session.close();
}
private void testTransmitAPDU(byte[] aid, byte[] apdu) {
- Session session = null;
- Channel channel = null;
try {
waitForConnection();
Reader[] readers = seService.getReaders();
-
for (Reader reader : readers) {
- assertTrue(reader.isSecureElementPresent());
- session = reader.openSession();
- assertNotNull("Null Session", session);
- channel = session.openLogicalChannel(aid, (byte)0x00);
- assertNotNull("Null Channel", channel);
- byte[] selectResponse = channel.getSelectResponse();
- assertNotNull("Null Select Response", selectResponse);
- assertEquals(selectResponse[selectResponse.length - 1] & 0xFF, 0x00);
- assertEquals(selectResponse[selectResponse.length - 2] & 0xFF, 0x90);
- assertTrue("Select Response is not complete", verifyBerTlvData(selectResponse));
- byte[] apduResponse = channel.transmit(apdu);
- assertNotNull("Null Channel", apduResponse);
+ Session session = null;
+ Channel channel = null;
+ try {
+ assertTrue(reader.isSecureElementPresent());
+ session = reader.openSession();
+ assertNotNull("Null Session", session);
+ channel = session.openLogicalChannel(aid, (byte) 0x00);
+ assertNotNull("Null Channel", channel);
+ byte[] selectResponse = channel.getSelectResponse();
+ assertNotNull("Null Select Response", selectResponse);
+ assertThat(selectResponse[selectResponse.length - 1] & 0xFF, is(0x00));
+ assertThat(selectResponse[selectResponse.length - 2] & 0xFF, is(0x90));
+ assertTrue("Select Response is not complete", verifyBerTlvData(selectResponse));
+ byte[] apduResponse = channel.transmit(apdu);
+ assertNotNull("Null Channel", apduResponse);
+ } finally {
+ if (channel != null) channel.close();
+ if (session != null) session.close();
+ }
}
} catch (Exception e) {
fail("Unexpected Exception " + e);
}
- if (channel != null)
- channel.close();
- if (session != null)
- session.close();
}
private void testUnauthorisedAPDU(byte[] aid, byte[] apdu) {
- Session session = null;
- Channel channel = null;
- boolean exceptionOnTransmit = false;
try {
waitForConnection();
Reader[] readers = seService.getReaders();
-
for (Reader reader : readers) {
- assertTrue(reader.isSecureElementPresent());
- session = reader.openSession();
- assertNotNull("Null Session", session);
- channel = session.openLogicalChannel(aid, (byte) 0x00);
- assertNotNull("Null Channel", channel);
- byte[] selectResponse = channel.getSelectResponse();
- assertNotNull("Null Select Response", selectResponse);
- assertEquals(selectResponse[selectResponse.length - 1] & 0xFF, 0x00);
- assertEquals(selectResponse[selectResponse.length - 2] & 0xFF, 0x90);
- assertTrue("Select Response is not complete", verifyBerTlvData(selectResponse));
- exceptionOnTransmit = true;
- channel.transmit(apdu);
- fail("Security Exception is expected");
+ Session session = null;
+ Channel channel = null;
+ try {
+ assertTrue(reader.isSecureElementPresent());
+ session = reader.openSession();
+ assertNotNull("Null Session", session);
+ channel = session.openLogicalChannel(aid, (byte) 0x00);
+ assertNotNull("Null Channel", channel);
+ byte[] selectResponse = channel.getSelectResponse();
+ assertNotNull("Null Select Response", selectResponse);
+ assertThat(selectResponse[selectResponse.length - 1] & 0xFF, is(0x00));
+ assertThat(selectResponse[selectResponse.length - 2] & 0xFF, is(0x90));
+ assertTrue("Select Response is not complete", verifyBerTlvData(selectResponse));
+ try {
+ channel.transmit(apdu);
+ fail("Security Exception is expected");
+ } catch (SecurityException e) {
+ // Expected
+ }
+ } finally {
+ if (channel != null) channel.close();
+ if (session != null) session.close();
+ }
}
- } catch (SecurityException ex) {
- if (!exceptionOnTransmit) {
- fail("Unexpected SecurityException onSelect" + ex);
- }
} catch (Exception e) {
- fail("Unexpected Exception " + e);
- } finally {
- if(channel != null)
- channel.close();
- if (session != null)
- session.close();
+ fail("Unexpected Exception " + e);
}
}
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
index 10939c6..b3c4054 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
Binary files differ
diff --git a/tests/tests/secure_element/access_control/AccessControlApp3/src/android/omapi/accesscontrol3/cts/AccessControlTest.java b/tests/tests/secure_element/access_control/AccessControlApp3/src/android/omapi/accesscontrol3/cts/AccessControlTest.java
old mode 100644
new mode 100755
index 7071628..cdf8893
--- a/tests/tests/secure_element/access_control/AccessControlApp3/src/android/omapi/accesscontrol3/cts/AccessControlTest.java
+++ b/tests/tests/secure_element/access_control/AccessControlApp3/src/android/omapi/accesscontrol3/cts/AccessControlTest.java
@@ -18,6 +18,7 @@
package android.omapi.accesscontrol3.cts;
+import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
import static org.junit.Assume.assumeTrue;
@@ -38,7 +39,7 @@
import android.se.omapi.SEService.OnConnectedListener;
import android.se.omapi.Session;
import android.support.test.InstrumentationRegistry;
-
+import android.os.Build;
import com.android.compatibility.common.util.PropertyUtil;
public class AccessControlTest {
@@ -171,6 +172,7 @@
@Before
public void setUp() throws Exception {
+ assumeTrue(PropertyUtil.getFirstApiLevel() > Build.VERSION_CODES.O_MR1);
assumeTrue(supportsHardware());
seService = new SEService(InstrumentationRegistry.getContext(), new SynchronousExecutor(), mListener);
connectionTimer = new Timer();
@@ -241,121 +243,121 @@
}
private void testSelectableAid(byte[] aid) {
- Session session = null;
- Channel channel = null;
try {
waitForConnection();
Reader[] readers = seService.getReaders();
for (Reader reader : readers) {
- assertTrue(reader.isSecureElementPresent());
- session = reader.openSession();
- assertNotNull("Null Session", session);
- channel = session.openLogicalChannel(aid, (byte)0x00);
- assertNotNull("Null Channel", channel);
- byte[] selectResponse = channel.getSelectResponse();
- assertNotNull("Null Select Response", selectResponse);
- assertEquals(selectResponse[selectResponse.length - 1] & 0xFF, 0x00);
- assertEquals(selectResponse[selectResponse.length - 2] & 0xFF, 0x90);
- assertTrue("Select Response is not complete", verifyBerTlvData(selectResponse));
+ Session session = null;
+ Channel channel = null;
+ try {
+ assertTrue(reader.isSecureElementPresent());
+ session = reader.openSession();
+ assertNotNull("Null Session", session);
+ channel = session.openLogicalChannel(aid, (byte) 0x00);
+ assertNotNull("Null Channel", channel);
+ byte[] selectResponse = channel.getSelectResponse();
+ assertNotNull("Null Select Response", selectResponse);
+ assertThat(selectResponse[selectResponse.length - 1] & 0xFF, is(0x00));
+ assertThat(selectResponse[selectResponse.length - 2] & 0xFF, is(0x90));
+ assertTrue("Select Response is not complete", verifyBerTlvData(selectResponse));
+ } finally {
+ if (channel != null) channel.close();
+ if (session != null) session.close();
+ }
}
} catch (Exception e) {
fail("Unexpected Exception " + e);
- } finally{
- if (channel != null)
- channel.close();
- if (session != null)
- session.close();
}
}
private void testUnauthorisedAid(byte[] aid) {
- Session session = null;
- Channel channel = null;
try {
waitForConnection();
Reader[] readers = seService.getReaders();
-
for (Reader reader : readers) {
- assertTrue(reader.isSecureElementPresent());
- session = reader.openSession();
- assertNotNull("Null Session", session);
- channel = session.openLogicalChannel(aid, (byte)0x00);
- fail("SecurityException Expected ");
+ Session session = null;
+ Channel channel = null;
+ try {
+ assertTrue(reader.isSecureElementPresent());
+ session = reader.openSession();
+ assertNotNull("Null Session", session);
+ try {
+ channel = session.openLogicalChannel(aid, (byte) 0x00);
+ fail("SecurityException Expected");
+ } catch (SecurityException e) {
+ // Expected
+ }
+ } finally {
+ if (channel != null) channel.close();
+ if (session != null) session.close();
+ }
}
- } catch(SecurityException ex){ }
- catch (Exception e) {
+ } catch (Exception e) {
fail("Unexpected Exception " + e);
}
- if (channel != null)
- channel.close();
- if (session != null)
- session.close();
}
private void testTransmitAPDU(byte[] aid, byte[] apdu) {
- Session session = null;
- Channel channel = null;
try {
waitForConnection();
Reader[] readers = seService.getReaders();
-
for (Reader reader : readers) {
- assertTrue(reader.isSecureElementPresent());
- session = reader.openSession();
- assertNotNull("Null Session", session);
- channel = session.openLogicalChannel(aid, (byte)0x00);
- assertNotNull("Null Channel", channel);
- byte[] selectResponse = channel.getSelectResponse();
- assertNotNull("Null Select Response", selectResponse);
- assertEquals(selectResponse[selectResponse.length - 1] & 0xFF, 0x00);
- assertEquals(selectResponse[selectResponse.length - 2] & 0xFF, 0x90);
- assertTrue("Select Response is not complete", verifyBerTlvData(selectResponse));
- byte[] apduResponse = channel.transmit(apdu);
- assertNotNull("Null Channel", apduResponse);
+ Session session = null;
+ Channel channel = null;
+ try {
+ assertTrue(reader.isSecureElementPresent());
+ session = reader.openSession();
+ assertNotNull("Null Session", session);
+ channel = session.openLogicalChannel(aid, (byte) 0x00);
+ assertNotNull("Null Channel", channel);
+ byte[] selectResponse = channel.getSelectResponse();
+ assertNotNull("Null Select Response", selectResponse);
+ assertThat(selectResponse[selectResponse.length - 1] & 0xFF, is(0x00));
+ assertThat(selectResponse[selectResponse.length - 2] & 0xFF, is(0x90));
+ assertTrue("Select Response is not complete", verifyBerTlvData(selectResponse));
+ byte[] apduResponse = channel.transmit(apdu);
+ assertNotNull("Null Channel", apduResponse);
+ } finally {
+ if (channel != null) channel.close();
+ if (session != null) session.close();
+ }
}
} catch (Exception e) {
fail("Unexpected Exception " + e);
}
- if (channel != null)
- channel.close();
- if (session != null)
- session.close();
}
private void testUnauthorisedAPDU(byte[] aid, byte[] apdu) {
- Session session = null;
- Channel channel = null;
- boolean exceptionOnTransmit = false;
try {
waitForConnection();
Reader[] readers = seService.getReaders();
-
for (Reader reader : readers) {
- assertTrue(reader.isSecureElementPresent());
- session = reader.openSession();
- assertNotNull("Null Session", session);
- channel = session.openLogicalChannel(aid, (byte)0x00);
- assertNotNull("Null Channel", channel);
- byte[] selectResponse = channel.getSelectResponse();
- assertNotNull("Null Select Response", selectResponse);
- assertEquals(selectResponse[selectResponse.length - 1] & 0xFF, 0x00);
- assertEquals(selectResponse[selectResponse.length - 2] & 0xFF, 0x90);
- assertTrue("Select Response is not complete", verifyBerTlvData(selectResponse));
- exceptionOnTransmit = true;
- channel.transmit(apdu);
- fail("Security Exception is expected");
+ Session session = null;
+ Channel channel = null;
+ try {
+ assertTrue(reader.isSecureElementPresent());
+ session = reader.openSession();
+ assertNotNull("Null Session", session);
+ channel = session.openLogicalChannel(aid, (byte) 0x00);
+ assertNotNull("Null Channel", channel);
+ byte[] selectResponse = channel.getSelectResponse();
+ assertNotNull("Null Select Response", selectResponse);
+ assertThat(selectResponse[selectResponse.length - 1] & 0xFF, is(0x00));
+ assertThat(selectResponse[selectResponse.length - 2] & 0xFF, is(0x90));
+ assertTrue("Select Response is not complete", verifyBerTlvData(selectResponse));
+ try {
+ channel.transmit(apdu);
+ fail("Security Exception is expected");
+ } catch (SecurityException e) {
+ // Expected
+ }
+ } finally {
+ if (channel != null) channel.close();
+ if (session != null) session.close();
+ }
}
- } catch (SecurityException ex) {
- if (!exceptionOnTransmit) {
- fail("Unexpected SecurityException onSelect" + ex);
- }
} catch (Exception e) {
- fail("Unexpected Exception " + e);
- } finally {
- if(channel != null)
- channel.close();
- if (session != null)
- session.close();
+ fail("Unexpected Exception " + e);
}
}
diff --git a/tests/tests/secure_element/omapi/src/android/omapi/cts/OmapiTest.java b/tests/tests/secure_element/omapi/src/android/omapi/cts/OmapiTest.java
old mode 100644
new mode 100755
index 438857d..c9d21bb
--- a/tests/tests/secure_element/omapi/src/android/omapi/cts/OmapiTest.java
+++ b/tests/tests/secure_element/omapi/src/android/omapi/cts/OmapiTest.java
@@ -42,7 +42,7 @@
import android.se.omapi.SEService.OnConnectedListener;
import android.se.omapi.Session;
import android.support.test.InstrumentationRegistry;
-
+import android.os.Build;
import com.android.compatibility.common.util.PropertyUtil;
public class OmapiTest {
@@ -159,6 +159,7 @@
@Before
public void setUp() throws Exception {
+ assumeTrue(PropertyUtil.getFirstApiLevel() > Build.VERSION_CODES.O_MR1);
assumeTrue(supportsHardware());
seService = new SEService(InstrumentationRegistry.getContext(), new SynchronousExecutor(), mListener);
connectionTimer = new Timer();
diff --git a/tests/tests/security/res/raw/bug_36592202.ogg b/tests/tests/security/res/raw/bug_36592202.ogg
deleted file mode 100755
index 868e630..0000000
--- a/tests/tests/security/res/raw/bug_36592202.ogg
+++ /dev/null
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_63522067_1_hevc.mp4 b/tests/tests/security/res/raw/bug_63522067_1_hevc.mp4
deleted file mode 100644
index 261e173..0000000
--- a/tests/tests/security/res/raw/bug_63522067_1_hevc.mp4
+++ /dev/null
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_63522067_2_hevc.mp4 b/tests/tests/security/res/raw/bug_63522067_2_hevc.mp4
deleted file mode 100644
index e8f1c41..0000000
--- a/tests/tests/security/res/raw/bug_63522067_2_hevc.mp4
+++ /dev/null
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_63522067_3_hevc.mp4 b/tests/tests/security/res/raw/bug_63522067_3_hevc.mp4
deleted file mode 100644
index ecc10cb..0000000
--- a/tests/tests/security/res/raw/bug_63522067_3_hevc.mp4
+++ /dev/null
Binary files differ
diff --git a/tests/tests/security/res/raw/bug_63522067_4_hevc.mp4 b/tests/tests/security/res/raw/bug_63522067_4_hevc.mp4
deleted file mode 100644
index 34851ad..0000000
--- a/tests/tests/security/res/raw/bug_63522067_4_hevc.mp4
+++ /dev/null
Binary files differ
diff --git a/tests/tests/security/res/raw/cve_2016_3828.mp4 b/tests/tests/security/res/raw/cve_2016_3828.mp4
deleted file mode 100755
index 88109cb..0000000
--- a/tests/tests/security/res/raw/cve_2016_3828.mp4
+++ /dev/null
Binary files differ
diff --git a/tests/tests/security/src/android/security/cts/ListeningPortsTest.java b/tests/tests/security/src/android/security/cts/ListeningPortsTest.java
index 6d7c5e2..0e3c72b5 100644
--- a/tests/tests/security/src/android/security/cts/ListeningPortsTest.java
+++ b/tests/tests/security/src/android/security/cts/ListeningPortsTest.java
@@ -19,7 +19,6 @@
import android.content.pm.PackageManager;
import android.os.Process;
import android.os.UserHandle;
-import android.platform.test.annotations.SecurityTest;
import android.test.AndroidTestCase;
import android.util.Log;
import com.android.compatibility.common.util.FeatureUtil;
@@ -43,7 +42,6 @@
* into computer systems remotely, and minimizing the number of open ports
* is considered a security best practice.
*/
-@SecurityTest
public class ListeningPortsTest extends AndroidTestCase {
private static final String TAG = "ListeningPortsTest";
diff --git a/tests/tests/security/src/android/security/cts/MotionEventTest.java b/tests/tests/security/src/android/security/cts/MotionEventTest.java
index db29704..4a8cc780 100644
--- a/tests/tests/security/src/android/security/cts/MotionEventTest.java
+++ b/tests/tests/security/src/android/security/cts/MotionEventTest.java
@@ -124,7 +124,8 @@
FutureTask<Point> task = new FutureTask<>(() -> {
final int[] viewLocation = new int[2];
viewHolder[0].getLocationOnScreen(viewLocation);
- return new Point(viewLocation[0], viewLocation[1]);
+ // 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);
});
mActivity.runOnUiThread(task);
Point viewLocation = task.get(5, TimeUnit.SECONDS);
diff --git a/tests/tests/security/src/android/security/cts/StagefrightTest.java b/tests/tests/security/src/android/security/cts/StagefrightTest.java
old mode 100755
new mode 100644
index 4e128bc..a137e67
--- a/tests/tests/security/src/android/security/cts/StagefrightTest.java
+++ b/tests/tests/security/src/android/security/cts/StagefrightTest.java
@@ -33,8 +33,6 @@
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
-import android.media.MediaDrm;
-import android.media.MediaDrm.MediaDrmStateException;
import android.media.MediaExtractor;
import android.media.MediaFormat;
import android.media.MediaMetadataRetriever;
@@ -55,11 +53,8 @@
import java.io.InputStream;
import java.net.URL;
import java.nio.ByteBuffer;
-import java.io.FileOutputStream;
-import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.UUID;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
@@ -95,11 +90,6 @@
}
@SecurityTest
- public void testStagefright_cve_2016_3828() throws Exception {
- doStagefrightTest(R.raw.cve_2016_3828);
- }
-
- @SecurityTest
public void testStagefright_bug_64710074() throws Exception {
doStagefrightTest(R.raw.bug_64710074);
}
@@ -547,14 +537,6 @@
}
@SecurityTest
- public void testStagefright_bug_63522067() throws Exception {
- doStagefrightTestRawBlob(R.raw.bug_63522067_1_hevc, "video/hevc", 320, 420);
- doStagefrightTestRawBlob(R.raw.bug_63522067_2_hevc, "video/hevc", 320, 420);
- doStagefrightTestRawBlob(R.raw.bug_63522067_3_hevc, "video/hevc", 320, 420);
- doStagefrightTestRawBlob(R.raw.bug_63522067_4_hevc, "video/hevc", 320, 420);
- }
-
- @SecurityTest
public void testStagefright_bug_25765591() throws Exception {
doStagefrightTest(R.raw.bug_25765591);
}
@@ -610,56 +592,6 @@
}
@SecurityTest
- public void testStagefright_bug_36592202() throws Exception {
- Resources resources = getInstrumentation().getContext().getResources();
- AssetFileDescriptor fd = resources.openRawResourceFd(R.raw.bug_36592202);
- int page_size = 25627;
- byte [] blob = new byte[page_size];
-
- // 127 bytes read and 25500 zeros constitute one Ogg page
- FileInputStream fis = fd.createInputStream();
- int numRead = fis.read(blob);
- fis.close();
-
- // Creating temp file
- final File tempFile = File.createTempFile("poc_tmp", ".ogg", null);
-
- try {
- final FileOutputStream tempFos = new FileOutputStream(tempFile.getAbsolutePath());
- int bytesWritten = 0;
- // Repeat data till size is ~1 GB
- for (int i = 0; i < 50000; i++) {
- tempFos.write(blob);
- bytesWritten += page_size;
- }
- tempFos.close();
-
- final int fileSize = bytesWritten;
- int timeout = (10 * 60 * 1000);
-
- runWithTimeout(new Runnable() {
- @Override
- public void run() {
- try {
- doStagefrightTestMediaCodec(tempFile.getAbsolutePath());
- } catch (Exception | AssertionError e) {
- if (!tempFile.delete()) {
- Log.e(TAG, "Failed to delete temporary PoC file");
- }
- fail("Operation was not successful");
- }
- }
- }, timeout);
- } catch (Exception e) {
- fail("Failed to test b/36592202");
- } finally {
- if (!tempFile.delete()) {
- Log.e(TAG, "Failed to delete temporary PoC file");
- }
- }
- }
-
- @SecurityTest
public void testStagefright_bug_30822755() throws Exception {
doStagefrightTest(R.raw.bug_30822755);
}
@@ -670,39 +602,6 @@
}
@SecurityTest
- public void testStagefright_bug_37710346() throws Exception {
- UUID CLEARKEY_SCHEME_UUID = new UUID(0x1077efecc0b24d02L, 0xace33c1e52e2fb4bL);
-
- String drmInitString = "0000003470737368" +
- "01000000" +
- "1077efecc0b24d02" +
- "ace33c1e52e2fb4b" +
- "10000001" +
- "60061e017e477e87" +
- "7e57d00d1ed00d1e" +
- "00000000";
- int len = drmInitString.length();
- byte[] drmInitData = new byte[len / 2];
- for (int i = 0; i < len; i += 2) {
- drmInitData[i / 2] = (byte) ((Character.digit(drmInitString.charAt(i), 16) << 4) +
- Character.digit(drmInitString.charAt(i + 1), 16));
- }
-
- try {
- MediaDrm drm = new MediaDrm(CLEARKEY_SCHEME_UUID);
- byte[] sessionId;
- String initDataType = "video/mp4";
-
- sessionId = drm.openSession();
- MediaDrm.KeyRequest drmRequest = drm.getKeyRequest(sessionId, drmInitData,
- initDataType, MediaDrm.KEY_TYPE_STREAMING, null);
- } catch (Exception e) {
- if (!(e instanceof MediaDrmStateException))
- fail("media drm server died");
- }
- }
-
- @SecurityTest
public void testStagefright_cve_2015_3873_b_23248776() throws Exception {
doStagefrightTest(R.raw.cve_2015_3873_b_23248776);
}
diff --git a/tests/tests/security/src/android/security/cts/VerifiedBootTest.java b/tests/tests/security/src/android/security/cts/VerifiedBootTest.java
index a3209fc..8d388cc 100644
--- a/tests/tests/security/src/android/security/cts/VerifiedBootTest.java
+++ b/tests/tests/security/src/android/security/cts/VerifiedBootTest.java
@@ -21,6 +21,7 @@
import android.platform.test.annotations.SecurityTest;
import android.test.AndroidTestCase;
import com.android.compatibility.common.util.PropertyUtil;
+import com.android.compatibility.common.util.CddTest;
@SecurityTest
public class VerifiedBootTest extends AndroidTestCase {
@@ -42,6 +43,7 @@
* A device without the feature flag android.hardware.ram.normal is exempt if
* it launched on a pre-P level.
*/
+ @CddTest(requirement="9.10/C-1-1,C-2-1")
public void testVerifiedBootSupport() throws Exception {
if (PropertyUtil.getFirstApiLevel() < Build.VERSION_CODES.O_MR1) {
return;
diff --git a/tests/tests/shortcutmanager/packages/packagemanifest_nonshared/AndroidManifest.xml b/tests/tests/shortcutmanager/packages/packagemanifest_nonshared/AndroidManifest.xml
index d2cc04a..cd30602 100755
--- a/tests/tests/shortcutmanager/packages/packagemanifest_nonshared/AndroidManifest.xml
+++ b/tests/tests/shortcutmanager/packages/packagemanifest_nonshared/AndroidManifest.xml
@@ -23,6 +23,14 @@
<activity android:name="Launcher" android:enabled="true" android:exported="false">
</activity>
+
+ <activity-alias android:name="HomeActivity"
+ android:targetActivity="Launcher">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity-alias>
</application>
</manifest>
diff --git a/tests/tests/shortcutmanager/src/android/content/pm/cts/shortcutmanager/ShortcutManagerFakingPublisherTest.java b/tests/tests/shortcutmanager/src/android/content/pm/cts/shortcutmanager/ShortcutManagerFakingPublisherTest.java
new file mode 100644
index 0000000..baa47b0
--- /dev/null
+++ b/tests/tests/shortcutmanager/src/android/content/pm/cts/shortcutmanager/ShortcutManagerFakingPublisherTest.java
@@ -0,0 +1,178 @@
+/*
+ * 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.content.pm.cts.shortcutmanager;
+
+import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.assertExpectException;
+import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.list;
+import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.runCommand;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.pm.ShortcutInfo;
+import android.platform.test.annotations.SecurityTest;
+import android.support.test.InstrumentationRegistry;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import org.junit.Assume;
+
+/**
+ * CTS for b/109824443.
+ */
+@SmallTest
+@SecurityTest
+public class ShortcutManagerFakingPublisherTest extends ShortcutManagerCtsTestsBase {
+ private static final String ANOTHER_PACKAGE =
+ "android.content.pm.cts.shortcutmanager.packages.package4";
+
+ private static final ComponentName ANOTHER_HOME_ACTIVITY = new ComponentName(
+ ANOTHER_PACKAGE, "android.content.pm.cts.shortcutmanager.packages.HomeActivity");
+
+ private static final String INVALID_ID =
+ "[ShortcutManagerFakingPublisherTest.shortcut_that_should_not_be_created]";
+
+ @Override
+ protected String getOverrideConfig() {
+ return "reset_interval_sec=999999,"
+ + "max_updates_per_interval=999999,"
+ + "max_shortcuts=10"
+ + "max_icon_dimension_dp=96,"
+ + "max_icon_dimension_dp_lowram=96,"
+ + "icon_format=PNG,"
+ + "icon_quality=100";
+ }
+
+ public void testSpoofingPublisher() {
+ final Context myContext = getTestContext();
+ final Context anotherContext;
+ try {
+ anotherContext = getTestContext().createPackageContext(ANOTHER_PACKAGE, 0);
+ } catch (NameNotFoundException e) {
+ fail("Unable to create package context for " + ANOTHER_PACKAGE);
+ return;
+ }
+ final ShortcutInfo invalid = new ShortcutInfo.Builder(anotherContext, INVALID_ID)
+ .setShortLabel(INVALID_ID)
+ .setIntent(new Intent(Intent.ACTION_VIEW))
+ .setActivity(ANOTHER_HOME_ACTIVITY)
+ .build();
+
+ // Check set.
+ runWithCaller(mPackageContext1, () -> {
+ getManager().removeAllDynamicShortcuts();
+
+ assertShortcutPackageMismatch("setDynamicShortcuts1", mPackageContext1, () -> {
+ getManager().setDynamicShortcuts(list(
+ invalid));
+ });
+ assertInvalidShortcutNotCreated();
+ assertShortcutPackageMismatch("setDynamicShortcuts2A", mPackageContext1, () -> {
+ getManager().setDynamicShortcuts(list(
+ invalid,
+ makeShortcut("s1", "title1")));
+ });
+ assertInvalidShortcutNotCreated();
+ assertShortcutPackageMismatch("setDynamicShortcuts2B", mPackageContext1, () -> {
+ getManager().setDynamicShortcuts(list(
+ makeShortcut("s1", "title1"),
+ invalid));
+ });
+ assertInvalidShortcutNotCreated();
+ });
+
+ // Check add.
+ runWithCaller(mPackageContext1, () -> {
+ getManager().removeAllDynamicShortcuts();
+
+ assertShortcutPackageMismatch("addDynamicShortcuts1", mPackageContext1, () -> {
+ getManager().addDynamicShortcuts(list(
+ invalid));
+ });
+ assertInvalidShortcutNotCreated();
+ assertShortcutPackageMismatch("addDynamicShortcuts2A", mPackageContext1, () -> {
+ getManager().addDynamicShortcuts(list(
+ invalid,
+ makeShortcut("s1", "title1")));
+ });
+ assertInvalidShortcutNotCreated();
+ assertShortcutPackageMismatch("addDynamicShortcuts2B", mPackageContext1, () -> {
+ getManager().addDynamicShortcuts(list(
+ makeShortcut("s1", "title1"),
+ invalid));
+ });
+ assertInvalidShortcutNotCreated();
+ });
+
+ // Check update.
+ runWithCaller(mPackageContext1, () -> {
+ getManager().removeAllDynamicShortcuts();
+
+ assertShortcutPackageMismatch("updateShortcuts1", mPackageContext1, () -> {
+ getManager().updateShortcuts(list(
+ invalid));
+ });
+ assertInvalidShortcutNotCreated();
+ assertShortcutPackageMismatch("updateShortcuts2A", mPackageContext1, () -> {
+ getManager().updateShortcuts(list(
+ invalid,
+ makeShortcut("s1", "title1")));
+ });
+ assertInvalidShortcutNotCreated();
+ assertShortcutPackageMismatch("updateShortcuts2B", mPackageContext1, () -> {
+ getManager().updateShortcuts(list(
+ makeShortcut("s1", "title1"),
+ invalid));
+ });
+ assertInvalidShortcutNotCreated();
+ });
+
+ // requestPin (API26 and above)
+ runWithCaller(mPackageContext1, () -> {
+ getManager().removeAllDynamicShortcuts();
+
+ assertShortcutPackageMismatch("requestPinShortcut", mPackageContext1, () -> {
+ getManager().requestPinShortcut(invalid, null);
+ });
+ assertInvalidShortcutNotCreated();
+ });
+
+ // createShortcutResultIntent (API26 and above)
+ runWithCaller(mPackageContext1, () -> {
+ getManager().removeAllDynamicShortcuts();
+
+ assertShortcutPackageMismatch("createShortcutResultIntent", mPackageContext1, () -> {
+ getManager().createShortcutResultIntent(invalid);
+ });
+ assertInvalidShortcutNotCreated();
+ });
+ }
+
+ private void assertInvalidShortcutNotCreated() {
+ for (String s : runCommand(InstrumentationRegistry.getInstrumentation(),
+ "dumpsys shortcut")) {
+ assertFalse("dumpsys shortcut contained invalid ID", s.contains(INVALID_ID));
+ }
+ }
+
+ private void assertShortcutPackageMismatch(String method, Context callerContext, Runnable r) {
+ assertExpectException(
+ "Caller=" + callerContext.getPackageName() + ", method=" + method,
+ SecurityException.class, "Shortcut package name mismatch",
+ () -> runWithCaller(callerContext, () -> r.run())
+ );
+ }
+}
diff --git a/tests/tests/systemui/src/android/systemui/cts/LightBarTestBase.java b/tests/tests/systemui/src/android/systemui/cts/LightBarTestBase.java
index dde2ce1..14d4bcb 100644
--- a/tests/tests/systemui/src/android/systemui/cts/LightBarTestBase.java
+++ b/tests/tests/systemui/src/android/systemui/cts/LightBarTestBase.java
@@ -26,10 +26,11 @@
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Bitmap;
+import android.graphics.Rect;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import android.util.Log;
-import android.view.KeyEvent;
+import android.view.DisplayCutout;
import android.view.WindowInsets;
import java.io.File;
@@ -37,6 +38,8 @@
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Locale;
public class LightBarTestBase {
@@ -45,6 +48,8 @@
public static final Path DUMP_PATH = FileSystems.getDefault()
.getPath("/sdcard/LightBarTestBase/");
+ private ArrayList<Rect> mCutouts;
+
protected Bitmap takeStatusBarScreenshot(LightBarBaseActivity activity) {
Bitmap fullBitmap = getInstrumentation().getUiAutomation().takeScreenshot();
return Bitmap.createBitmap(fullBitmap, 0, 0, activity.getWidth(), activity.getTop());
@@ -144,18 +149,42 @@
int[] pixels = new int[bitmap.getHeight() * bitmap.getWidth()];
bitmap.getPixels(pixels, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
+ loadCutout(activity);
int backgroundColorPixelCount = 0;
+ int shiftY = activity.getBottom();
for (int i = 0; i < pixels.length; i++) {
- if (pixels[i] == backgroundColor) {
+ int x = i % bitmap.getWidth();
+ int y = i / bitmap.getWidth();
+
+ if (pixels[i] == backgroundColor
+ || isInsideCutout(x, shiftY + y)) {
backgroundColorPixelCount++;
}
}
assumeNavigationBarChangesColor(backgroundColorPixelCount, pixels.length);
+ int diffCount = 0;
for (int col = 0; col < bitmap.getWidth(); col++) {
+ if (isInsideCutout(col, shiftY)) {
+ continue;
+ }
+
if (dividerColor != pixels[col]) {
+ diffCount++;
+ }
+ }
+
+ boolean success = false;
+ try {
+ assertLessThan(String.format(Locale.ENGLISH,
+ "There are invalid color pixels. expected= 0x%08x", dividerColor),
+ 0.3f, (float) diffCount / (float)bitmap.getWidth(),
+ "Is the divider colored according to android:navigationBarDividerColor "
+ + " in the theme?");
+ success = true;
+ } finally {
+ if (!success) {
dumpBitmap(bitmap, methodName);
- fail("Invalid color exptected=" + dividerColor + " actual=" + pixels[col]);
}
}
}
@@ -164,4 +193,39 @@
assumeTrue("Not enough background pixels. The navigation bar may not be able to change "
+ "color.", backgroundColorPixelCount > 0.3f * totalPixel);
}
+
+ protected ArrayList loadCutout(LightBarBaseActivity activity) {
+ mCutouts = new ArrayList<>();
+ InstrumentationRegistry.getInstrumentation().runOnMainSync(()-> {
+ WindowInsets windowInsets = activity.getRootWindowInsets();
+ DisplayCutout displayCutout = windowInsets.getDisplayCutout();
+ if (displayCutout != null) {
+ mCutouts.addAll(displayCutout.getBoundingRects());
+ }
+ });
+ return mCutouts;
+ }
+
+ protected boolean isInsideCutout(int x, int y) {
+ for (Rect cutout : mCutouts) {
+ if (cutout.contains(x, y)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected void assertMoreThan(String what, float expected, float actual, String hint) {
+ if (!(actual > expected)) {
+ fail(what + ": expected more than " + expected * 100 + "%, but only got " + actual * 100
+ + "%; " + hint);
+ }
+ }
+
+ protected void assertLessThan(String what, float expected, float actual, String hint) {
+ if (!(actual < expected)) {
+ fail(what + ": expected less than " + expected * 100 + "%, but got " + actual * 100
+ + "%; " + hint);
+ }
+ }
}
diff --git a/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java b/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java
index 3f86067..c9234d7 100644
--- a/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java
+++ b/tests/tests/systemui/src/android/systemui/cts/LightBarTests.java
@@ -20,13 +20,11 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import android.app.ActivityManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.UiAutomation;
import android.content.Context;
-import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.SystemClock;
@@ -96,7 +94,7 @@
Thread.sleep(WAIT_TIME);
Bitmap bitmap = takeStatusBarScreenshot(mActivityRule.getActivity());
- Stats s = evaluateLightBarBitmap(bitmap, Color.RED /* background */);
+ Stats s = evaluateLightBarBitmap(bitmap, Color.RED /* background */, 0);
assertLightStats(bitmap, s);
mNm.cancelAll();
@@ -116,8 +114,9 @@
injectCanceledTap(x, y);
Thread.sleep(WAIT_TIME);
- Bitmap bitmap = takeNavigationBarScreenshot(mActivityRule.getActivity());
- Stats s = evaluateLightBarBitmap(bitmap, Color.RED /* background */);
+ LightBarActivity activity = mActivityRule.getActivity();
+ Bitmap bitmap = takeNavigationBarScreenshot(activity);
+ Stats s = evaluateLightBarBitmap(bitmap, Color.RED /* background */, activity.getBottom());
assertLightStats(bitmap, s);
}
@@ -156,16 +155,16 @@
assumeNavigationBarChangesColor(s.backgroundPixels, s.totalPixels());
assertMoreThan("Not enough pixels colored as in the spec", 0.3f,
- (float) s.iconPixels / s.foregroundPixels(),
+ (float) s.iconPixels / (float) s.foregroundPixels(),
"Are the bar icons colored according to the spec "
+ "(60% black and 24% black)?");
assertLessThan("Too many lighter pixels lighter than the background", 0.05f,
- (float) s.sameHueLightPixels / s.foregroundPixels(),
+ (float) s.sameHueLightPixels / (float) s.foregroundPixels(),
"Are the bar icons dark?");
assertLessThan("Too many pixels with a changed hue", 0.05f,
- (float) s.unexpectedHuePixels / s.foregroundPixels(),
+ (float) s.unexpectedHuePixels / (float) s.foregroundPixels(),
"Are the bar icons color-free?");
success = true;
@@ -176,20 +175,6 @@
}
}
- private void assertMoreThan(String what, float expected, float actual, String hint) {
- if (!(actual > expected)) {
- fail(what + ": expected more than " + expected * 100 + "%, but only got " + actual * 100
- + "%; " + hint);
- }
- }
-
- private void assertLessThan(String what, float expected, float actual, String hint) {
- if (!(actual < expected)) {
- fail(what + ": expected less than " + expected * 100 + "%, but got " + actual * 100
- + "%; " + hint);
- }
- }
-
private void requestLightBars(final int background) throws Throwable {
final LightBarActivity activity = mActivityRule.getActivity();
activity.runOnUiThread(() -> {
@@ -225,12 +210,21 @@
}
}
- private Stats evaluateLightBarBitmap(Bitmap bitmap, int background) {
+ private Stats evaluateLightBarBitmap(Bitmap bitmap, int background, int shiftY) {
int iconColor = 0x99000000;
int iconPartialColor = 0x3d000000;
int mixedIconColor = mixSrcOver(background, iconColor);
int mixedIconPartialColor = mixSrcOver(background, iconPartialColor);
+ float [] hsvMixedIconColor = new float[3];
+ float [] hsvMixedPartialColor = new float[3];
+ Color.RGBToHSV(Color.red(mixedIconColor), Color.green(mixedIconColor),
+ Color.blue(mixedIconColor), hsvMixedIconColor);
+ Color.RGBToHSV(Color.red(mixedIconPartialColor), Color.green(mixedIconPartialColor),
+ Color.blue(mixedIconPartialColor), hsvMixedPartialColor);
+
+ float maxHsvValue = Math.max(hsvMixedIconColor[2], hsvMixedPartialColor[2]);
+ float minHsvValue = Math.min(hsvMixedIconColor[2], hsvMixedPartialColor[2]);
int[] pixels = new int[bitmap.getHeight() * bitmap.getWidth()];
bitmap.getPixels(pixels, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
@@ -238,14 +232,26 @@
Stats s = new Stats();
float eps = 0.005f;
+ loadCutout(mActivityRule.getActivity());
+ float [] hsvPixel = new float[3];
+ int i = 0;
for (int c : pixels) {
+ int x = i % bitmap.getWidth();
+ int y = i / bitmap.getWidth();
+ i++;
+ if (isInsideCutout(x, shiftY + y)) {
+ continue;
+ }
+
if (isColorSame(c, background)) {
s.backgroundPixels++;
continue;
}
// What we expect the icons to be colored according to the spec.
- if (isColorSame(c, mixedIconColor) || isColorSame(c, mixedIconPartialColor)) {
+ Color.RGBToHSV(Color.red(c), Color.green(c), Color.blue(c), hsvPixel);
+ if (isColorSame(c, mixedIconColor) || isColorSame(c, mixedIconPartialColor)
+ || (hsvPixel[2] >= minHsvValue && hsvPixel[2] <= maxHsvValue)) {
s.iconPixels++;
continue;
}
diff --git a/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java b/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java
index 36db13a..ba8be5e 100755
--- a/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ConnectionServiceTest.java
@@ -176,9 +176,11 @@
// GIVEN a managed call
placeAndVerifyCall();
- verifyConnectionForOutgoingCall().setActive();
+ Connection outgoing = verifyConnectionForOutgoingCall();
+ outgoing.setActive();
assertTrue(connectionService.waitForEvent(
MockConnectionService.EVENT_CONNECTION_SERVICE_FOCUS_GAINED));
+ assertCallState(mInCallCallbacks.getService().getLastCall(), Call.STATE_ACTIVE);
// WHEN place another call has the same ConnectionService as the existing call
placeAndVerifyCall();
diff --git a/tests/tests/telephony/src/android/telephony/cts/SubscriptionManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/SubscriptionManagerTest.java
index f544694..3b8656b 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 @@
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 @@
}
/**
- * 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/telephony/src/android/telephony/cts/TelephonyManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
index 9f2139a..a9bcb39 100644
--- a/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
@@ -40,6 +40,8 @@
import android.telephony.CellLocation;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
@@ -557,10 +559,21 @@
return;
}
- for (int i = 0; i < mTelephonyManager.getPhoneCount(); i++) {
- String meid = mTelephonyManager.getMeid(i);
- if (!TextUtils.isEmpty(meid)) {
- assertMeidEsn(meid);
+ SubscriptionManager sm = (SubscriptionManager) getContext()
+ .getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
+ List<SubscriptionInfo> subInfos = sm.getActiveSubscriptionInfoList();
+
+ if (subInfos != null) {
+ for (SubscriptionInfo subInfo : subInfos) {
+ int slotIndex = subInfo.getSimSlotIndex();
+ int subId = subInfo.getSubscriptionId();
+ TelephonyManager tm = mTelephonyManager.createForSubscriptionId(subId);
+ if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) {
+ String meid = mTelephonyManager.getMeid(slotIndex);
+ if (!TextUtils.isEmpty(meid)) {
+ assertMeidEsn(meid);
+ }
+ }
}
}
diff --git a/tests/tests/view/AndroidManifest.xml b/tests/tests/view/AndroidManifest.xml
index a9cb2cd..4217959 100644
--- a/tests/tests/view/AndroidManifest.xml
+++ b/tests/tests/view/AndroidManifest.xml
@@ -297,7 +297,7 @@
</activity>
<activity android:name="android.view.cts.DragDropActivity"
- android:screenOrientation="portrait"
+ android:screenOrientation="locked"
android:label="DragDropActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
diff --git a/tests/tests/view/src/android/view/cts/DragDropTest.java b/tests/tests/view/src/android/view/cts/DragDropTest.java
index 2ae12f0..d53d8c3 100644
--- a/tests/tests/view/src/android/view/cts/DragDropTest.java
+++ b/tests/tests/view/src/android/view/cts/DragDropTest.java
@@ -241,7 +241,7 @@
long downTime = SystemClock.uptimeMillis();
MotionEvent event = MotionEvent.obtain(downTime, downTime, action,
destLoc[0] + offset, destLoc[1] + offset, 1);
- event.setSource(InputDevice.SOURCE_TOUCHSCREEN);
+ event.setSource(InputDevice.SOURCE_MOUSE);
mAutomation.injectInputEvent(event, false);
});
diff --git a/tests/tests/view/src/android/view/cts/KeyEventInterceptTest.java b/tests/tests/view/src/android/view/cts/KeyEventInterceptTest.java
index 598552b..32f5358 100644
--- a/tests/tests/view/src/android/view/cts/KeyEventInterceptTest.java
+++ b/tests/tests/view/src/android/view/cts/KeyEventInterceptTest.java
@@ -44,6 +44,9 @@
* KEYCODE_HOME
* This test launches an Activity and inject KeyEvents with the corresponding key codes.
* The test will fail if any of these keys are received by the activity.
+ * Note: The ASSIST tests were removed because they caused a side-effect of launching the
+ * assistant asynchronously (as intended), which causes problems with tests which happen to
+ * be running later and lose focus/visibility because of that extra window.
*/
@MediumTest
@RunWith(AndroidJUnit4.class)
@@ -63,16 +66,6 @@
}
@Test
- public void testKeyCodeAssist() {
- testKey(KeyEvent.KEYCODE_ASSIST);
- }
-
- @Test
- public void testKeyCodeVoiceAssist() {
- testKey(KeyEvent.KEYCODE_VOICE_ASSIST);
- }
-
- @Test
public void testKeyCodeHome() {
testKey(KeyEvent.KEYCODE_HOME);
}
diff --git a/tests/tests/view/src/android/view/cts/TextureViewCtsActivity.java b/tests/tests/view/src/android/view/cts/TextureViewCtsActivity.java
index 52a0a8d..8b0d4c7 100644
--- a/tests/tests/view/src/android/view/cts/TextureViewCtsActivity.java
+++ b/tests/tests/view/src/android/view/cts/TextureViewCtsActivity.java
@@ -371,6 +371,12 @@
if (mIsEGLWideGamut && !extensions.contains("EXT_pixel_format_float")) {
mEGLExtensionUnsupported = true;
}
+ // If the extension is present but the device doesn't claim to have a wide color gamut
+ // display then it might not return any actual float formats.
+ if (mIsEGLWideGamut && !mEGLExtensionUnsupported
+ && !getWindowManager().getDefaultDisplay().isWideColorGamut()) {
+ mEGLExtensionUnsupported = true;
+ }
mEglConfig = chooseEglConfig();
if (mEglConfig == null) {
diff --git a/tests/tests/view/src/android/view/cts/TextureViewTest.java b/tests/tests/view/src/android/view/cts/TextureViewTest.java
index 88ac1f5..431b27d 100644
--- a/tests/tests/view/src/android/view/cts/TextureViewTest.java
+++ b/tests/tests/view/src/android/view/cts/TextureViewTest.java
@@ -45,6 +45,7 @@
import com.android.compatibility.common.util.SynchronousPixelCopy;
import com.android.compatibility.common.util.WidgetTestUtils;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -118,6 +119,7 @@
}
@Test
+ @Ignore // Temporary, see b/111801626
public void testRotateScale() throws Throwable {
final TextureViewCtsActivity activity = mActivityRule.launchActivity(null);
final TextureView textureView = activity.getTextureView();
@@ -157,6 +159,7 @@
}
@Test
+ @Ignore // Temporary, see b/111801626
public void testTransformScale() throws Throwable {
final TextureViewCtsActivity activity = mActivityRule.launchActivity(null);
final TextureView textureView = activity.getTextureView();
diff --git a/tests/tests/webkit/src/android/webkit/cts/TestHtmlConstants.java b/tests/tests/webkit/src/android/webkit/cts/TestHtmlConstants.java
index 68d944b..2996c76 100644
--- a/tests/tests/webkit/src/android/webkit/cts/TestHtmlConstants.java
+++ b/tests/tests/webkit/src/android/webkit/cts/TestHtmlConstants.java
@@ -69,6 +69,7 @@
public static final String STOP_LOADING_URL = "webkit/test_stop_loading.html";
public static final String BLANK_TAG_URL = "webkit/blank_tag.html";
public static final String PAGE_WITH_LINK_URL = "webkit/page_with_link.html";
+ public static final String URL_IN_PAGE_WITH_LINK = "http://foo.com/";
// Not a real page, just triggers a 404 response.
public static final String NON_EXISTENT_PAGE_URL = "webkit/generate_404.html";
public static final String BAD_IMAGE_PAGE_URL = "webkit/test_bad_image_url.html";
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
index ae875a5..8cfaec3 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
@@ -554,6 +554,7 @@
if (!NullWebViewUtils.isWebViewAvailable()) {
return;
}
+ mSettings.setTextSize(TextSize.NORMAL);
assertEquals(TextSize.NORMAL, mSettings.getTextSize());
mSettings.setTextSize(TextSize.LARGER);
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
index 58e59e5..3ce66ac 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
@@ -137,6 +137,7 @@
final WebView childWebView = mOnUiThread.createWebView();
+ WebViewOnUiThread childWebViewOnUiThread = new WebViewOnUiThread(this, childWebView);
mOnUiThread.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onCreateWindow(
@@ -152,21 +153,26 @@
return true;
}
});
- mOnUiThread.loadUrl(mWebServer.getAssetUrl(TestHtmlConstants.BLANK_TAG_URL));
+ {
+ final int childCallCount = childWebViewClient.getShouldOverrideUrlLoadingCallCount();
+ mOnUiThread.loadUrl(mWebServer.getAssetUrl(TestHtmlConstants.BLANK_TAG_URL));
- new PollingCheck(TEST_TIMEOUT) {
- @Override
- protected boolean check() {
- return childWebViewClient.hasOnPageFinishedCalled();
- }
- }.run();
- assertEquals(mWebServer.getAssetUrl(TestHtmlConstants.PAGE_WITH_LINK_URL),
- childWebViewClient.getLastShouldOverrideUrl());
+ new PollingCheck(TEST_TIMEOUT) {
+ @Override
+ protected boolean check() {
+ return childWebViewClient.hasOnPageFinishedCalled();
+ }
+ }.run();
+ new PollingCheck(TEST_TIMEOUT) {
+ @Override
+ protected boolean check() {
+ return childWebViewClient.getShouldOverrideUrlLoadingCallCount() > childCallCount;
+ }
+ }.run();
+ assertEquals(mWebServer.getAssetUrl(TestHtmlConstants.PAGE_WITH_LINK_URL),
+ childWebViewClient.getLastShouldOverrideUrl());
+ }
- // Now test a navigation within the page
- //TODO(hush) Enable this portion when b/12804986 is fixed.
- /*
- WebViewOnUiThread childWebViewOnUiThread = new WebViewOnUiThread(this, childWebView);
final int childCallCount = childWebViewClient.getShouldOverrideUrlLoadingCallCount();
final int mainCallCount = mainWebViewClient.getShouldOverrideUrlLoadingCallCount();
clickOnLinkUsingJs("link", childWebViewOnUiThread);
@@ -177,8 +183,8 @@
}
}.run();
assertEquals(mainCallCount, mainWebViewClient.getShouldOverrideUrlLoadingCallCount());
- assertEquals(TEST_URL, childWebViewClient.getLastShouldOverrideUrl());
- */
+ assertEquals(
+ TestHtmlConstants.URL_IN_PAGE_WITH_LINK, childWebViewClient.getLastShouldOverrideUrl());
}
private void clickOnLinkUsingJs(final String linkId, WebViewOnUiThread webViewOnUiThread) {
@@ -781,7 +787,6 @@
@Override
public void onLoadResource(WebView view, String url) {
super.onLoadResource(view, url);
- assertTrue(mOnPageStartedCalled);
mOnLoadResourceCalled = true;
}
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index 4bedbb1..f5f3139 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -1361,7 +1361,7 @@
assertNull(mWebView.getUrl());
String imgUrl = TestHtmlConstants.SMALL_IMG_URL; // relative
// Snippet of HTML that will prevent favicon requests to the test server.
- final String HTML_HEADER = "<html><head><link rel=\"shortcut icon\" href=\"#\" /></head>";
+ final String HTML_HEADER = "<html><head><link rel=\"shortcut icon\" href=\"%23\" /></head>";
// Trying to resolve a relative URL against a data URL without a base URL
// will fail and we won't make a request to the test web server.
@@ -1968,8 +1968,8 @@
final String imgUrl = mWebServer.getAssetUrl(TestHtmlConstants.LARGE_IMG_URL);
mOnUiThread.loadDataAndWaitForCompletion(
"<html><head><title>Title</title><style type=\"text/css\">"
- + "#imgElement { -webkit-transform: translate3d(0,0,1); }"
- + "#imgElement.finish { -webkit-transform: translate3d(0,0,0);"
+ + "%23imgElement { -webkit-transform: translate3d(0,0,1); }"
+ + "%23imgElement.finish { -webkit-transform: translate3d(0,0,0);"
+ " -webkit-transition-duration: 1ms; }</style>"
+ "<script type=\"text/javascript\">function imgLoad() {"
+ "imgElement = document.getElementById('imgElement');"
diff --git a/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java b/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java
index f9103e6..2c483d7 100644
--- a/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java
+++ b/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java
@@ -32,6 +32,7 @@
import android.app.Instrumentation;
import android.content.Context;
import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.Point;
@@ -79,6 +80,7 @@
private static final int CONTENT_SIZE_DP = 30;
private Instrumentation mInstrumentation;
+ private Context mContext;
private PopupWindowCtsActivity mActivity;
private PopupWindow mPopupWindow;
private TextView mTextView;
@@ -90,6 +92,7 @@
@Before
public void setup() {
mInstrumentation = InstrumentationRegistry.getInstrumentation();
+ mContext = InstrumentationRegistry.getContext();
mActivity = mActivityRule.getActivity();
}
@@ -632,6 +635,7 @@
public void testShowAtLocation() throws Throwable {
int[] popupContentViewInWindowXY = new int[2];
int[] popupContentViewOnScreenXY = new int[2];
+ Rect containingRect = new Rect();
mPopupWindow = createPopupWindow(createPopupContent(CONTENT_SIZE_DP, CONTENT_SIZE_DP));
// Do not attach within the decor; we will be measuring location
@@ -655,11 +659,12 @@
assertTrue(mPopupWindow.isShowing());
mPopupWindow.getContentView().getLocationInWindow(popupContentViewInWindowXY);
mPopupWindow.getContentView().getLocationOnScreen(popupContentViewOnScreenXY);
+ upperAnchor.getWindowDisplayFrame(containingRect);
assertTrue(popupContentViewInWindowXY[0] >= 0);
assertTrue(popupContentViewInWindowXY[1] >= 0);
- assertEquals(popupContentViewInWindowXY[0] + xOff, popupContentViewOnScreenXY[0]);
- assertEquals(popupContentViewInWindowXY[1] + yOff, popupContentViewOnScreenXY[1]);
+ assertEquals(containingRect.left + popupContentViewInWindowXY[0] + xOff, popupContentViewOnScreenXY[0]);
+ assertEquals(containingRect.top + popupContentViewInWindowXY[1] + yOff, popupContentViewOnScreenXY[1]);
dismissPopup();
}
@@ -940,6 +945,7 @@
int[] fstXY = new int[2];
int[] sndXY = new int[2];
int[] viewInWindowXY = new int[2];
+ Rect containingRect = new Rect();
final Point popupPos = new Point();
mActivityRule.runOnUiThread(() -> {
@@ -959,6 +965,7 @@
showPopup();
mPopupWindow.getContentView().getLocationInWindow(viewInWindowXY);
final View containerView = mActivity.findViewById(R.id.main_container);
+ containerView.getWindowDisplayFrame(containingRect);
// update if it is not shown
mActivityRule.runOnUiThread(() -> mPopupWindow.update(80, 80));
@@ -980,8 +987,8 @@
assertEquals(50, mPopupWindow.getHeight());
mPopupWindow.getContentView().getLocationOnScreen(fstXY);
- assertEquals(popupPos.x + viewInWindowXY[0], fstXY[0]);
- assertEquals(popupPos.y + viewInWindowXY[1], fstXY[1]);
+ assertEquals(containingRect.left + popupPos.x + viewInWindowXY[0], fstXY[0]);
+ assertEquals(containingRect.top + popupPos.y + viewInWindowXY[1], fstXY[1]);
popupPos.set(windowInsets.getStableInsetLeft() + 4, windowInsets.getStableInsetTop());
@@ -995,8 +1002,8 @@
assertEquals(50, mPopupWindow.getHeight());
mPopupWindow.getContentView().getLocationOnScreen(sndXY);
- assertEquals(popupPos.x + viewInWindowXY[0], sndXY[0]);
- assertEquals(popupPos.y + viewInWindowXY[1], sndXY[1]);
+ assertEquals(containingRect.left + popupPos.x + viewInWindowXY[0], sndXY[0]);
+ assertEquals(containingRect.top + popupPos.y + viewInWindowXY[1], sndXY[1]);
dismissPopup();
}
@@ -1332,6 +1339,11 @@
for (int i = 0; i < 2; i++) {
final int orientation = orientationValues[i];
+ if (orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
+ && !hasDeviceFeature(PackageManager.FEATURE_SCREEN_PORTRAIT)) {
+ // skip test for devices not supporting portrait orientation
+ continue;
+ }
mActivity.runOnUiThread(() ->
mActivity.setRequestedOrientation(orientation));
mActivity.waitForConfigurationChanged();
@@ -1600,6 +1612,10 @@
return window;
}
+ private boolean hasDeviceFeature(final String requiredFeature) {
+ return mContext.getPackageManager().hasSystemFeature(requiredFeature);
+ }
+
private void showPopup(int resourceId) throws Throwable {
mActivityRule.runOnUiThread(() -> {
if (mPopupWindow == null || mPopupWindow.isShowing()) {
diff --git a/tests/vr/jni/VrExtensionsJni.cpp b/tests/vr/jni/VrExtensionsJni.cpp
index 4ab4e2a..a5d9db3 100644
--- a/tests/vr/jni/VrExtensionsJni.cpp
+++ b/tests/vr/jni/VrExtensionsJni.cpp
@@ -86,10 +86,19 @@
ASSERT((a) != (b), "assert failed on (" #a ") at " __FILE__ ":%d", __LINE__)
#define ASSERT_GT(a, b) \
ASSERT((a) > (b), "assert failed on (" #a ") at " __FILE__ ":%d", __LINE__)
-#define ASSERT_NEAR(a, b, delta) \
- ASSERT((a - delta) <= (b) && (b) <= (a + delta), \
+#define ASSERT_NEAR_RGBA(a, b, delta) \
+ ASSERT(areNearRgba(a, b, delta), \
"assert failed on (" #a ") at " __FILE__ ":%d", __LINE__)
+bool areNearRgba(int32_t actual, int32_t expected, int delta) {
+ for (int shift = 0; shift < 32; shift += 8) {
+ if (std::abs((actual >> shift & 0xFF) - (expected >> shift & 0xFF)) > delta) {
+ return false;
+ }
+ }
+ return true;
+}
+
void fail(JNIEnv* env, const char* format, ...) {
va_list args;
va_start(args, format);
@@ -107,8 +116,8 @@
int nsamples) {
ASSERT_GT(desc.layers, 1);
AHardwareBuffer* hwbuffer = nullptr;
- int error = AHardwareBuffer_allocate(&desc, &hwbuffer);
- ASSERT_FALSE(error);
+ // If the format is unsupported and allocation fails, skip the test.
+ if (AHardwareBuffer_allocate(&desc, &hwbuffer) != NO_ERROR) return;
// Create EGLClientBuffer from the AHardwareBuffer.
EGLClientBuffer native_buffer = eglGetNativeClientBufferANDROID(hwbuffer);
ASSERT_TRUE(native_buffer);
@@ -256,7 +265,8 @@
JNIEnv* env, jclass /* unused */) {
// First, check for EXT_external_buffer in the extension string.
auto exts = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
- ASSERT_TRUE(exts && strstr(exts, "GL_EXT_external_buffer"));
+ ASSERT_TRUE(exts);
+ if (strstr(exts, "GL_EXT_external_buffer") == nullptr) return;
// Next, load entry points provided by extensions.
LOAD_PROC(eglGetNativeClientBufferANDROID, PFNEGLGETNATIVECLIENTBUFFERANDROID);
ASSERT_NE(eglGetNativeClientBufferANDROID, nullptr);
@@ -638,20 +648,20 @@
uint32_t middle_pixel;
// First do a sanity check with plain old pre-linearized textures.
testLinearMagnification(env, 0, &middle_pixel);
- ASSERT_NEAR(middle_pixel, kExpectedMiddlePixel_NoSrgb, 1);
+ ASSERT_NEAR_RGBA(middle_pixel, kExpectedMiddlePixel_NoSrgb, 1);
testLinearMagnification(env, SrgbFlag::kHardwareBuffer, &middle_pixel);
- ASSERT_NEAR(middle_pixel, kExpectedMiddlePixel_NoSrgb, 1);
+ ASSERT_NEAR_RGBA(middle_pixel, kExpectedMiddlePixel_NoSrgb, 1);
// Try a "normally allocated" OpenGL texture with an sRGB source format.
testLinearMagnification(env, SrgbFlag::kSrgbFormat, &middle_pixel);
- ASSERT_NEAR(middle_pixel, kExpectedMiddlePixel_LinearizeBeforeFiltering, 1);
+ ASSERT_NEAR_RGBA(middle_pixel, kExpectedMiddlePixel_LinearizeBeforeFiltering, 1);
// Try EGL_EXT_image_gl_colorspace.
if (egl_colorspace_supported) {
testLinearMagnification(env, SrgbFlag::kHardwareBuffer | SrgbFlag::kEglColorspaceDefault, &middle_pixel);
- ASSERT_NEAR(middle_pixel, kExpectedMiddlePixel_NoSrgb, 1);
+ ASSERT_NEAR_RGBA(middle_pixel, kExpectedMiddlePixel_NoSrgb, 1);
testLinearMagnification(env, SrgbFlag::kHardwareBuffer | SrgbFlag::kEglColorspaceLinear, &middle_pixel);
- ASSERT_NEAR(middle_pixel, kExpectedMiddlePixel_NoSrgb, 1);
+ ASSERT_NEAR_RGBA(middle_pixel, kExpectedMiddlePixel_NoSrgb, 1);
testLinearMagnification(env, SrgbFlag::kHardwareBuffer | SrgbFlag::kEglColorspaceSrgb, &middle_pixel);
- ASSERT_NEAR(middle_pixel, kExpectedMiddlePixel_LinearizeBeforeFiltering, 1);
+ ASSERT_NEAR_RGBA(middle_pixel, kExpectedMiddlePixel_LinearizeBeforeFiltering, 1);
}
// Blending test.
@@ -660,19 +670,19 @@
uint32_t final_color;
// First do a sanity check with plain old pre-linearized textures.
testFramebufferBlending(env, 0, &final_color);
- ASSERT_NEAR(final_color, kExpectedBlendedPixel_NoSrgb, 1);
+ ASSERT_NEAR_RGBA(final_color, kExpectedBlendedPixel_NoSrgb, 1);
testFramebufferBlending(env, SrgbFlag::kHardwareBuffer, &final_color);
- ASSERT_NEAR(final_color, kExpectedBlendedPixel_NoSrgb, 1);
+ ASSERT_NEAR_RGBA(final_color, kExpectedBlendedPixel_NoSrgb, 1);
// Try a "normally allocated" OpenGL texture with an sRGB source format.
testFramebufferBlending(env, SrgbFlag::kSrgbFormat, &final_color);
- ASSERT_NEAR(final_color, kExpectedBlendedPixel_Srgb, 1);
+ ASSERT_NEAR_RGBA(final_color, kExpectedBlendedPixel_Srgb, 1);
// Try EGL_EXT_image_gl_colorspace.
if (egl_colorspace_supported) {
testFramebufferBlending(env, SrgbFlag::kHardwareBuffer | SrgbFlag::kEglColorspaceDefault, &final_color);
- ASSERT_NEAR(final_color, kExpectedBlendedPixel_NoSrgb, 1);
+ ASSERT_NEAR_RGBA(final_color, kExpectedBlendedPixel_NoSrgb, 1);
testFramebufferBlending(env, SrgbFlag::kHardwareBuffer | SrgbFlag::kEglColorspaceLinear, &final_color);
- ASSERT_NEAR(final_color, kExpectedBlendedPixel_NoSrgb, 1);
+ ASSERT_NEAR_RGBA(final_color, kExpectedBlendedPixel_NoSrgb, 1);
testFramebufferBlending(env, SrgbFlag::kHardwareBuffer | SrgbFlag::kEglColorspaceSrgb, &final_color);
- ASSERT_NEAR(final_color, kExpectedBlendedPixel_Srgb, 1);
+ ASSERT_NEAR_RGBA(final_color, kExpectedBlendedPixel_Srgb, 1);
}
}
diff --git a/tests/vr/src/android/vr/cts/VrFeaturesTest.java b/tests/vr/src/android/vr/cts/VrFeaturesTest.java
index caf1ade..a0c6457 100644
--- a/tests/vr/src/android/vr/cts/VrFeaturesTest.java
+++ b/tests/vr/src/android/vr/cts/VrFeaturesTest.java
@@ -21,6 +21,8 @@
import android.os.Process;
import android.test.ActivityInstrumentationTestCase2;
+import com.android.compatibility.common.util.CddTest;
+
public class VrFeaturesTest extends ActivityInstrumentationTestCase2<CtsActivity> {
private CtsActivity mActivity;
@@ -28,6 +30,7 @@
super(CtsActivity.class);
}
+ @CddTest(requirement="7.9.2/C-1-2")
public void testLacksDeprecatedVrModeFeature() {
mActivity = getActivity();
boolean hasVrMode = mActivity.getPackageManager().hasSystemFeature(
@@ -40,6 +43,7 @@
}
}
+ @CddTest(requirement="7.9.2/C-1-3")
public void testSustainedPerformanceModeSupported() {
mActivity = getActivity();
PowerManager pm = (PowerManager) mActivity.getSystemService(Context.POWER_SERVICE);