Merge "Sort tests when using BedsteadJUnit4 and allow state to leak." into sc-dev
diff --git a/apps/CameraITS/tests/scene0/test_metadata.py b/apps/CameraITS/tests/scene0/test_metadata.py
index 12b68a4..b0995a7 100644
--- a/apps/CameraITS/tests/scene0/test_metadata.py
+++ b/apps/CameraITS/tests/scene0/test_metadata.py
@@ -51,6 +51,7 @@
logging.debug('Limited: %s', camera_properties_utils.limited(props))
logging.debug('Full or better: %s',
camera_properties_utils.full_or_better(props))
+ logging.debug('Level 3: %s', camera_properties_utils.level3(props))
logging.debug('Capabilities')
logging.debug('Manual sensor: %s',
camera_properties_utils.manual_sensor(props))
diff --git a/apps/CameraITS/tests/scene4/test_aspect_ratio_and_crop.py b/apps/CameraITS/tests/scene4/test_aspect_ratio_and_crop.py
index 842ac73..657f20c 100644
--- a/apps/CameraITS/tests/scene4/test_aspect_ratio_and_crop.py
+++ b/apps/CameraITS/tests/scene4/test_aspect_ratio_and_crop.py
@@ -28,6 +28,7 @@
import its_session_utils
import opencv_processing_utils
+_ANDROID11_API_LEVEL = 30
_CIRCLE_COLOR = 0 # [0: black, 255: white].
_CIRCLE_MIN_AREA = 0.01 # 1% of image size.
_FOV_PERCENT_RTOL = 0.15 # Relative tolerance on circle FoV % to expected.
@@ -50,7 +51,7 @@
def _check_skip_conditions(first_api_level, props):
"""Check the skip conditions based on first API level."""
- if first_api_level < 30: # Original constraint.
+ if first_api_level < _ANDROID11_API_LEVEL: # Original constraint.
camera_properties_utils.skip_unless(camera_properties_utils.read_3a(props))
else: # Loosen from read_3a to enable LIMITED coverage.
camera_properties_utils.skip_unless(
@@ -100,7 +101,8 @@
return format_list
-def _print_failed_test_results(failed_ar, failed_fov, failed_crop):
+def _print_failed_test_results(failed_ar, failed_fov, failed_crop,
+ first_api_level, level_3):
"""Print failed test results."""
if failed_ar:
logging.error('Aspect ratio test summary')
@@ -125,13 +127,17 @@
raise RuntimeError
if failed_fov:
raise RuntimeError
- if failed_crop: # failed_crop = [] if run_crop_test = False.
- raise RuntimeError
+ if first_api_level > _ANDROID11_API_LEVEL:
+ if failed_crop: # failed_crop = [] if run_crop_test = False.
+ raise RuntimeError
+ else:
+ if failed_crop and level_3:
+ raise RuntimeError
def _is_checked_aspect_ratio(first_api_level, w, h):
"""Determine if format aspect ratio is a checked on based of first_API."""
- if first_api_level >= 30:
+ if first_api_level >= _ANDROID11_API_LEVEL:
return True
for ar_check in _AR_CHECKED_PRE_API_30:
@@ -476,6 +482,7 @@
# Determine camera capabilities.
full_or_better = camera_properties_utils.full_or_better(props)
+ level3 = camera_properties_utils.level3(props)
raw_avlb = camera_properties_utils.raw16(props)
debug = self.debug_mode
@@ -559,7 +566,8 @@
image_processing_utils.write_image(img, img_name, True)
# Print any failed test results.
- _print_failed_test_results(failed_ar, failed_fov, failed_crop)
+ _print_failed_test_results(failed_ar, failed_fov, failed_crop,
+ first_api_level, level3)
if __name__ == '__main__':
test_runner.main()
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 2a083c2..51a1287 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -2476,6 +2476,7 @@
<string name="provisioning_byod_capture_image_support">Camera support cross profile image capture</string>
<string name="provisioning_byod_capture_image_support_info">
This test verifies that images can be captured from the managed profile using the primary profile camera.\n
+ If prompted, accept the camera permission after pressing go.\n
1. Capture a picture using the camera.\n
2. Verify that the captured picture is shown.\n
3. Click on the close button.
@@ -2483,6 +2484,7 @@
<string name="provisioning_byod_capture_video_support_with_extra_output">Camera support cross profile video capture (with extra output path)</string>
<string name="provisioning_byod_capture_video_support_info">
This test verifies that videos can be captured from the managed profile using the primary profile camera.\n
+ If prompted, accept the camera permission after pressing go.\n
1. Capture a video using the camera.\n
2. Click on the play button.\n
3. Verify that the captured video is played.\n
@@ -3251,8 +3253,10 @@
<string name="provisioning_byod_no_gps_location_feature">No GPS feature present. Skip test.</string>
<string name="provisioning_byod_location_mode_enable">Enable location</string>
<string name="provisioning_byod_location_mode_enable_toast_location_change">Location changed</string>
+ <string name="provisioning_byod_location_mode_enable_missing_permission">Permission missing</string>
<string name="provisioning_byod_location_mode_enable_instruction">
This test verifies that the location updates can be enabled for the managed profile apps.\n
+ If prompted, accept the location permission after pressing go.\n
1. Press the go button to go to the location settings page, set both the main location switch and the work profile location switch enabled.\n
2. Press home to go to the launcher.\n
3. Move your position a little bit, verify that location updates toast comes up.\n
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/biometrics/AbstractBaseTest.java b/apps/CtsVerifier/src/com/android/cts/verifier/biometrics/AbstractBaseTest.java
index 2938b00..a58a18f 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/biometrics/AbstractBaseTest.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/biometrics/AbstractBaseTest.java
@@ -83,6 +83,11 @@
Toast.makeText(this, s, Toast.LENGTH_SHORT).show();
}
+ void showToastAndLog(String s, Exception e) {
+ Log.d(getTag(), s, e);
+ Toast.makeText(this, s, Toast.LENGTH_SHORT).show();
+ }
+
protected void onBiometricEnrollFinished() {
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/biometrics/AbstractUserAuthenticationTest.java b/apps/CtsVerifier/src/com/android/cts/verifier/biometrics/AbstractUserAuthenticationTest.java
index 92869f3..ace4c7f 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/biometrics/AbstractUserAuthenticationTest.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/biometrics/AbstractUserAuthenticationTest.java
@@ -356,7 +356,7 @@
if (keyUsed != shouldKeyBeUsable) {
showToastAndLog("Test failed. shouldKeyBeUsable: " + shouldKeyBeUsable
- + " keyUsed: " + keyUsed + " Exception: " + exception);
+ + " keyUsed: " + keyUsed + " Exception: " + exception, exception);
if (exception != null) {
exception.printStackTrace();
}
@@ -418,4 +418,9 @@
Log.d(getTag(), s);
Toast.makeText(this, s, Toast.LENGTH_SHORT).show();
}
+
+ private void showToastAndLog(String s, Exception e) {
+ Log.d(getTag(), s, e);
+ Toast.makeText(this, s, Toast.LENGTH_SHORT).show();
+ }
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/biometrics/BiometricStrongTests.java b/apps/CtsVerifier/src/com/android/cts/verifier/biometrics/BiometricStrongTests.java
index f1e1c0f..d5d2199 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/biometrics/BiometricStrongTests.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/biometrics/BiometricStrongTests.java
@@ -249,7 +249,7 @@
updatePassButton();
} catch (Exception e) {
showToastAndLog("Failed to encrypt after biometric was"
- + "authenticated: " + e);
+ + "authenticated: " + e, e);
}
}
});
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/biometrics/CredentialCryptoTests.java b/apps/CtsVerifier/src/com/android/cts/verifier/biometrics/CredentialCryptoTests.java
index 50aee3a..17f49f8 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/biometrics/CredentialCryptoTests.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/biometrics/CredentialCryptoTests.java
@@ -128,7 +128,7 @@
// Expected
Log.d(TAG, "UserNotAuthenticated (expected)");
} catch (Exception e) {
- showToastAndLog("Unexpected exception: " + e);
+ showToastAndLog("Unexpected exception: " + e, e);
}
// Authenticate with credential
@@ -160,7 +160,7 @@
}
updateButton();
} catch (Exception e) {
- showToastAndLog("Unable to encrypt: " + e);
+ showToastAndLog("Unable to encrypt: " + e, e);
}
}
});
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
index a6a25e6..74d50a9 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
@@ -19,6 +19,7 @@
import static android.os.UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES;
import static android.os.UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES_GLOBALLY;
+import android.Manifest;
import android.app.KeyguardManager;
import android.app.Notification;
import android.app.NotificationChannel;
@@ -27,6 +28,7 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -34,6 +36,9 @@
import android.provider.MediaStore;
import android.util.Log;
+import androidx.annotation.NonNull;
+import androidx.core.app.ActivityCompat;
+import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import androidx.core.util.Pair;
@@ -53,7 +58,7 @@
* Note: We have to use a test activity because cross-profile intents only work for activities.
*/
public class ByodHelperActivity extends LocationListenerActivity
- implements DialogCallback {
+ implements DialogCallback, ActivityCompat.OnRequestPermissionsResultCallback {
static final String TAG = "ByodHelperActivity";
@@ -167,6 +172,11 @@
private static final int NOTIFICATION_ID = 7;
private static final String NOTIFICATION_CHANNEL_ID = TAG;
+ private static final int EXECUTE_IMAGE_CAPTURE_TEST = 1;
+ private static final int EXECUTE_VIDEO_CAPTURE_WITH_EXTRA_TEST = 2;
+ private static final int EXECUTE_VIDEO_CAPTURE_WITHOUT_EXTRA_TEST = 3;
+ private static final int EXECUTE_LOCATION_UPDATE_TEST = 4;
+
private NotificationManager mNotificationManager;
private Bundle mOriginalRestrictions;
@@ -274,40 +284,25 @@
IntentFiltersTestHelper.FLAG_INTENTS_FROM_MANAGED);
setResult(intentFiltersSetForManagedIntents? RESULT_OK : RESULT_FAILED, null);
} else if (action.equals(ACTION_CAPTURE_AND_CHECK_IMAGE)) {
- // We need the camera permission to send the image capture intent.
- grantCameraPermissionToSelf();
- Intent captureImageIntent = getCaptureImageIntent();
- Pair<File, Uri> pair = getTempUri("image.jpg");
- mImageFile = pair.first;
- mImageUri = pair.second;
- captureImageIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
- if (captureImageIntent.resolveActivity(getPackageManager()) != null) {
- startActivityForResult(captureImageIntent, REQUEST_IMAGE_CAPTURE);
+ if (hasCameraPermission()) {
+ startCaptureImageIntent();
} else {
- Log.e(TAG, "Capture image intent could not be resolved in managed profile.");
- showToast(R.string.provisioning_byod_capture_media_error);
- finish();
+ requestCameraPermission(EXECUTE_IMAGE_CAPTURE_TEST);
}
return;
} else if (action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITH_EXTRA_OUTPUT) ||
action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITHOUT_EXTRA_OUTPUT)) {
- // We need the camera permission to send the video capture intent.
- grantCameraPermissionToSelf();
- Intent captureVideoIntent = getCaptureVideoIntent();
- int videoCaptureRequestId;
+ final int testRequestCode;
if (action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITH_EXTRA_OUTPUT)) {
- mVideoUri = getTempUri("video.mp4").second;
- captureVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, mVideoUri);
- videoCaptureRequestId = REQUEST_VIDEO_CAPTURE_WITH_EXTRA_OUTPUT;
+ testRequestCode = EXECUTE_VIDEO_CAPTURE_WITH_EXTRA_TEST;
} else {
- videoCaptureRequestId = REQUEST_VIDEO_CAPTURE_WITHOUT_EXTRA_OUTPUT;
+ testRequestCode = EXECUTE_VIDEO_CAPTURE_WITHOUT_EXTRA_TEST;
}
- if (captureVideoIntent.resolveActivity(getPackageManager()) != null) {
- startActivityForResult(captureVideoIntent, videoCaptureRequestId);
+
+ if (hasCameraPermission()) {
+ startCaptureVideoActivity(testRequestCode);
} else {
- Log.e(TAG, "Capture video intent could not be resolved in managed profile.");
- showToast(R.string.provisioning_byod_capture_media_error);
- finish();
+ requestCameraPermission(testRequestCode);
}
return;
} else if (action.equals(ACTION_CAPTURE_AND_CHECK_AUDIO)) {
@@ -356,7 +351,11 @@
DeviceAdminTestReceiver.getReceiverComponentName(), restriction);
}
} else if (action.equals(ACTION_BYOD_SET_LOCATION_AND_CHECK_UPDATES)) {
- handleLocationAction();
+ if (hasLocationPermission()) {
+ handleLocationAction();
+ } else {
+ requestLocationPermission(EXECUTE_LOCATION_UPDATE_TEST);
+ }
return;
} else if (action.equals(ACTION_NOTIFICATION)) {
showNotification(Notification.VISIBILITY_PUBLIC);
@@ -394,6 +393,40 @@
finish();
}
+ private void startCaptureVideoActivity(int testRequestCode) {
+ Intent captureVideoIntent = getCaptureVideoIntent();
+ int videoCaptureRequestId;
+ if (testRequestCode == EXECUTE_VIDEO_CAPTURE_WITH_EXTRA_TEST) {
+ mVideoUri = getTempUri("video.mp4").second;
+ captureVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, mVideoUri);
+ videoCaptureRequestId = REQUEST_VIDEO_CAPTURE_WITH_EXTRA_OUTPUT;
+ } else {
+ videoCaptureRequestId = REQUEST_VIDEO_CAPTURE_WITHOUT_EXTRA_OUTPUT;
+ }
+ if (captureVideoIntent.resolveActivity(getPackageManager()) != null) {
+ startActivityForResult(captureVideoIntent, videoCaptureRequestId);
+ } else {
+ Log.e(TAG, "Capture video intent could not be resolved in managed profile.");
+ showToast(R.string.provisioning_byod_capture_media_error);
+ finish();
+ }
+ }
+
+ private void startCaptureImageIntent() {
+ Intent captureImageIntent = getCaptureImageIntent();
+ Pair<File, Uri> pair = getTempUri("image.jpg");
+ mImageFile = pair.first;
+ mImageUri = pair.second;
+ captureImageIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
+ if (captureImageIntent.resolveActivity(getPackageManager()) != null) {
+ startActivityForResult(captureImageIntent, REQUEST_IMAGE_CAPTURE);
+ } else {
+ Log.e(TAG, "Capture image intent could not be resolved in managed profile.");
+ showToast(R.string.provisioning_byod_capture_media_error);
+ finish();
+ }
+ }
+
private void startInstallerActivity(String pathToApk) {
// Start the installer activity until this activity is rendered to workaround a glitch.
mMainThreadHandler.post(() -> {
@@ -552,10 +585,73 @@
}
}
- private void grantCameraPermissionToSelf() {
- mDevicePolicyManager.setPermissionGrantState(mAdminReceiverComponent, getPackageName(),
- android.Manifest.permission.CAMERA,
- DevicePolicyManager.PERMISSION_GRANT_STATE_GRANTED);
+ private boolean hasCameraPermission() {
+ return ContextCompat.checkSelfPermission(this, android.Manifest.permission.CAMERA)
+ == PackageManager.PERMISSION_GRANTED;
+ }
+
+ private void requestCameraPermission(int requestCode) {
+ ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.CAMERA},
+ requestCode);
+ }
+
+ private boolean hasLocationPermission() {
+ return ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
+ == PackageManager.PERMISSION_GRANTED;
+ }
+
+ private void requestLocationPermission(int requestCode) {
+ ActivityCompat.requestPermissions(this,
+ new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
+ requestCode);
+ }
+
+ /**
+ * Launch the right test based on the request code, after validating the right permission
+ * has been granted.
+ */
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
+ @NonNull int[] grants) {
+ // Test that the right permission was granted.
+ switch(requestCode) {
+ case EXECUTE_IMAGE_CAPTURE_TEST:
+ case EXECUTE_VIDEO_CAPTURE_WITH_EXTRA_TEST:
+ case EXECUTE_VIDEO_CAPTURE_WITHOUT_EXTRA_TEST:
+ if (!permissions[0].equals(android.Manifest.permission.CAMERA)
+ || grants[0] != PackageManager.PERMISSION_GRANTED) {
+ Log.e(TAG, "The test needs camera permission.");
+ showToast(R.string.provisioning_byod_capture_media_error);
+ finish();
+ return;
+ }
+ break;
+ case EXECUTE_LOCATION_UPDATE_TEST:
+ if (!permissions[0].equals(Manifest.permission.ACCESS_FINE_LOCATION)
+ || grants[0] != PackageManager.PERMISSION_GRANTED) {
+ Log.e(TAG, "The test needs location permission.");
+ showToast(R.string.provisioning_byod_location_mode_enable_missing_permission);
+ finish();
+ return;
+ }
+ break;
+ }
+
+ // Execute the right test.
+ switch (requestCode) {
+ case EXECUTE_IMAGE_CAPTURE_TEST:
+ startCaptureImageIntent();
+ break;
+ case EXECUTE_VIDEO_CAPTURE_WITH_EXTRA_TEST:
+ case EXECUTE_VIDEO_CAPTURE_WITHOUT_EXTRA_TEST:
+ startCaptureVideoActivity(requestCode);
+ break;
+ case EXECUTE_LOCATION_UPDATE_TEST:
+ handleLocationAction();
+ break;
+ default:
+ Log.e(TAG, "Unknown action.");
+ finish();
+ }
}
private void sendIntentInsideChooser(Intent toSend) {
@@ -566,21 +662,6 @@
}
@Override
- protected void handleLocationAction() {
- // Grant the locaiton permission to the provile owner on cts-verifier.
- // The permission state does not have to be reverted at the end since the profile onwer
- // is going to be deleted when BYOD tests ends.
- grantLocationPermissionToSelf();
- super.handleLocationAction();
- }
-
- private void grantLocationPermissionToSelf() {
- mDevicePolicyManager.setPermissionGrantState(mAdminReceiverComponent, getPackageName(),
- android.Manifest.permission.ACCESS_FINE_LOCATION,
- DevicePolicyManager.PERMISSION_GRANT_STATE_GRANTED);
- }
-
- @Override
public void onDialogClose() {
finish();
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/net/MultiNetworkConnectivityTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/net/MultiNetworkConnectivityTestActivity.java
index dcc4f37..f1deb8d 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/net/MultiNetworkConnectivityTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/net/MultiNetworkConnectivityTestActivity.java
@@ -554,7 +554,7 @@
final NetworkCallback mWifiNetworkCallback = new NetworkCallback() {
@Override
public void onAvailable(Network network) {
- Log.i(TAG, "Wifi network available " + network.getNetId());
+ Log.i(TAG, "Wifi network available " + network);
stopTimerDisplayIfRequested();
mMultiNetworkValidator.onWifiNetworkConnected(network);
}
@@ -569,7 +569,7 @@
final NetworkCallback mCellularNetworkCallback = new NetworkCallback() {
@Override
public void onAvailable(Network network) {
- Log.i(TAG, "Cellular network available " + network.getNetId());
+ Log.i(TAG, "Cellular network available " + network);
stopTimerDisplayIfRequested();
mMultiNetworkValidator.onCellularNetworkConnected(network);
}
@@ -761,7 +761,7 @@
Network activeNetwork = mConnectivityManager.getActiveNetwork();
NetworkCapabilities activeNetworkCapabilities =
mConnectivityManager.getNetworkCapabilities(activeNetwork);
- Log.i(TAG, "Network capabilities for " + activeNetwork.getNetId() + " "
+ Log.i(TAG, "Network capabilities for " + activeNetwork + " "
+ activeNetworkCapabilities.hasCapability(NET_CAPABILITY_INTERNET));
return activeNetworkCapabilities.hasTransport(transport)
&& activeNetworkCapabilities.hasCapability(NET_CAPABILITY_INTERNET);
@@ -774,7 +774,7 @@
boolean isNetworkConnected(Network network) {
NetworkInfo networkInfo = mConnectivityManager.getNetworkInfo(network);
boolean status = networkInfo != null && networkInfo.isConnectedOrConnecting();
- Log.i(TAG, "Network connection status " + network.getNetId() + " " + status);
+ Log.i(TAG, "Network connection status " + network + " " + status);
return status;
}
@@ -786,7 +786,7 @@
/** Called when a wifi network is connected and available */
void onWifiNetworkConnected(Network network) {
- Log.i(TAG, "Wifi network connected " + network.getNetId());
+ Log.i(TAG, "Wifi network connected " + network);
}
void onWifiNetworkUnavailable() {
diff --git a/common/device-side/bedstead/eventlib/lint-baseline.xml b/common/device-side/bedstead/eventlib/lint-baseline.xml
new file mode 100644
index 0000000..467bd49
--- /dev/null
+++ b/common/device-side/bedstead/eventlib/lint-baseline.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="5" by="lint 4.1.0" client="cli" variant="all" version="4.1.0">
+
+ <issue
+ id="NewApi"
+ message="Class requires API level 28 (current min is 27): `android.app.AppComponentFactory`"
+ errorLine1="public class EventLibAppComponentFactory extends AppComponentFactory {"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/common/device-side/bedstead/eventlib/src/main/java/com/android/eventlib/premade/EventLibAppComponentFactory.java"
+ line="28"
+ column="50"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level R (current min is 27): `android.content.Context#bindServiceAsUser`"
+ errorLine1=" didBind.set(sContext.bindServiceAsUser("
+ errorLine2=" ~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/common/device-side/bedstead/eventlib/src/main/java/com/android/eventlib/RemoteEventQuerier.java"
+ line="197"
+ column="38"/>
+ </issue>
+
+</issues>
diff --git a/common/device-side/bedstead/nene/lint-baseline.xml b/common/device-side/bedstead/nene/lint-baseline.xml
new file mode 100644
index 0000000..6fe256f
--- /dev/null
+++ b/common/device-side/bedstead/nene/lint-baseline.xml
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="5" by="lint 4.1.0" client="cli" variant="all" version="4.1.0">
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 10000 (current min is 27): `AdbUserParser31`"
+ errorLine1=" return new AdbUserParser31(testApis);"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/users/AdbUserParser.java"
+ line="37"
+ column="20"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level R (current min is 27): `AdbUserParser30`"
+ errorLine1=" return new AdbUserParser30(testApis);"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/users/AdbUserParser.java"
+ line="40"
+ column="20"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 29 (current min is 27): `android.app.UiAutomation#adoptShellPermissionIdentity`"
+ errorLine1=" ShellCommandUtils.uiAutomation().adoptShellPermissionIdentity("
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/permissions/Permissions.java"
+ line="196"
+ column="46"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 29 (current min is 27): `android.app.UiAutomation#dropShellPermissionIdentity`"
+ errorLine1=" ShellCommandUtils.uiAutomation().dropShellPermissionIdentity();"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/permissions/Permissions.java"
+ line="240"
+ column="46"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 29 (current min is 27): `android.app.UiAutomation#adoptShellPermissionIdentity`"
+ errorLine1=" ShellCommandUtils.uiAutomation().adoptShellPermissionIdentity();"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/permissions/Permissions.java"
+ line="242"
+ column="46"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 29 (current min is 27): `android.app.UiAutomation#adoptShellPermissionIdentity`"
+ errorLine1=" ShellCommandUtils.uiAutomation().adoptShellPermissionIdentity("
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/permissions/Permissions.java"
+ line="244"
+ column="46"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 31 (current min is 27): `android.app.UiAutomation#executeShellCommandRw`"
+ errorLine1=" ParcelFileDescriptor[] fds = uiAutomation().executeShellCommandRw(command);"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/utils/ShellCommandUtils.java"
+ line="156"
+ column="53"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level R (current min is 27): `java.util.Set#of`"
+ errorLine1=" managedProfileMutableUserType.mBaseType = Set.of(UserType.BaseType.PROFILE);"
+ errorLine2=" ~~">
+ <location
+ file="cts/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/users/Users.java"
+ line="213"
+ column="55"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level R (current min is 27): `java.util.Set#of`"
+ errorLine1=" Set.of(UserType.BaseType.FULL, UserType.BaseType.SYSTEM);"
+ errorLine2=" ~~">
+ <location
+ file="cts/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/users/Users.java"
+ line="224"
+ column="21"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level R (current min is 27): `java.util.Set#of`"
+ errorLine1=" managedProfileMutableUserType.mBaseType = Set.of(UserType.BaseType.FULL);"
+ errorLine2=" ~~">
+ <location
+ file="cts/common/device-side/bedstead/nene/src/main/java/com/android/bedstead/nene/users/Users.java"
+ line="234"
+ column="55"/>
+ </issue>
+
+</issues>
diff --git a/common/device-side/bedstead/testapp/Android.bp b/common/device-side/bedstead/testapp/Android.bp
index e9ced93..5b325c4 100644
--- a/common/device-side/bedstead/testapp/Android.bp
+++ b/common/device-side/bedstead/testapp/Android.bp
@@ -37,7 +37,16 @@
python_binary_host {
name: "index_testapps",
- defaults: ["base_default"],
+ version: {
+ py2: {
+ enabled: false,
+ embedded_launcher: false,
+ },
+ py3: {
+ enabled: true,
+ embedded_launcher: true,
+ },
+ },
main: "tools/index/index_testapps.py",
srcs: [
"tools/index/index_testapps.py",
diff --git a/hostsidetests/appsearch/Android.bp b/hostsidetests/appsearch/Android.bp
index 27193dd..57a33b8 100644
--- a/hostsidetests/appsearch/Android.bp
+++ b/hostsidetests/appsearch/Android.bp
@@ -38,7 +38,7 @@
}
android_test_helper_app {
- name: "CtsAppSearchHostTestHelper",
+ name: "CtsAppSearchHostTestHelperA",
defaults: ["cts_defaults"],
static_libs: [
"AppSearchTestUtils",
@@ -48,12 +48,35 @@
"testng",
],
srcs: [
- "test-apps/AppSearchHostTestHelper/src/**/*.java",
+ "test-apps/AppSearchHostTestHelperA/src/**/*.java",
],
test_suites: [
"cts",
"general-tests",
],
- manifest: "test-apps/AppSearchHostTestHelper/AndroidManifest.xml",
+ manifest: "test-apps/AppSearchHostTestHelperA/AndroidManifest.xml",
+ certificate: ":cts-appsearch-hosttest-helper-cert-a",
+ sdk_version: "test_current",
+}
+
+android_test_helper_app {
+ name: "CtsAppSearchHostTestHelperB",
+ defaults: ["cts_defaults"],
+ static_libs: [
+ "AppSearchTestUtils",
+ "androidx.test.ext.junit",
+ "androidx.test.rules",
+ "compatibility-device-util-axt",
+ "testng",
+ ],
+ srcs: [
+ "test-apps/AppSearchHostTestHelperB/src/**/*.java",
+ ],
+ test_suites: [
+ "cts",
+ "general-tests",
+ ],
+ manifest: "test-apps/AppSearchHostTestHelperB/AndroidManifest.xml",
+ certificate: ":cts-appsearch-hosttest-helper-cert-b",
sdk_version: "test_current",
}
diff --git a/hostsidetests/appsearch/AndroidTest.xml b/hostsidetests/appsearch/AndroidTest.xml
index 1ee8f59..5b8ebc2 100644
--- a/hostsidetests/appsearch/AndroidTest.xml
+++ b/hostsidetests/appsearch/AndroidTest.xml
@@ -23,7 +23,8 @@
<option name="jar" value="CtsAppSearchHostTestCases.jar" />
</test>
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
- <option name="test-file-name" value="CtsAppSearchHostTestHelper.apk" />
+ <option name="test-file-name" value="CtsAppSearchHostTestHelperA.apk" />
+ <option name="test-file-name" value="CtsAppSearchHostTestHelperB.apk" />
<option name="cleanup-apks" value="true" />
</target_preparer>
</configuration>
diff --git a/hostsidetests/appsearch/certs/Android.bp b/hostsidetests/appsearch/certs/Android.bp
new file mode 100644
index 0000000..901140c
--- /dev/null
+++ b/hostsidetests/appsearch/certs/Android.bp
@@ -0,0 +1,13 @@
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+android_app_certificate {
+ name: "cts-appsearch-hosttest-helper-cert-a",
+ certificate: "cts-appsearch-hosttest-helper-cert-a",
+}
+
+android_app_certificate {
+ name: "cts-appsearch-hosttest-helper-cert-b",
+ certificate: "cts-appsearch-hosttest-helper-cert-b",
+}
diff --git a/hostsidetests/appsearch/certs/README b/hostsidetests/appsearch/certs/README
new file mode 100644
index 0000000..cdf8a8f
--- /dev/null
+++ b/hostsidetests/appsearch/certs/README
@@ -0,0 +1,6 @@
+# No password, otherwise building during 'atest' will fail waiting on a password
+# These files shouldn't need to change unless you want to generate new certificates to sign the APKs
+#
+# Generated with:
+development/tools/make_key cts-appsearch-hosttest-helper-cert-a '/CN=cts-appsearch-hosttest-helper-cert-a'
+development/tools/make_key cts-appsearch-hosttest-helper-cert-b '/CN=cts-appsearch-hosttest-helper-cert-b'
diff --git a/hostsidetests/appsearch/certs/cts-appsearch-hosttest-helper-cert-a.pk8 b/hostsidetests/appsearch/certs/cts-appsearch-hosttest-helper-cert-a.pk8
new file mode 100644
index 0000000..eb83160
--- /dev/null
+++ b/hostsidetests/appsearch/certs/cts-appsearch-hosttest-helper-cert-a.pk8
Binary files differ
diff --git a/hostsidetests/appsearch/certs/cts-appsearch-hosttest-helper-cert-a.x509.pem b/hostsidetests/appsearch/certs/cts-appsearch-hosttest-helper-cert-a.x509.pem
new file mode 100644
index 0000000..7065ec6
--- /dev/null
+++ b/hostsidetests/appsearch/certs/cts-appsearch-hosttest-helper-cert-a.x509.pem
@@ -0,0 +1,20 @@
+-----BEGIN CERTIFICATE-----
+MIIDPzCCAiegAwIBAgIUUqwCW73ktfCzcTEJqfa1CTVDBw0wDQYJKoZIhvcNAQEL
+BQAwLzEtMCsGA1UEAwwkY3RzLWFwcHNlYXJjaC1ob3N0dGVzdC1oZWxwZXItY2Vy
+dC1hMB4XDTIxMDQwNjA3MzAwNloXDTQ4MDgyMjA3MzAwNlowLzEtMCsGA1UEAwwk
+Y3RzLWFwcHNlYXJjaC1ob3N0dGVzdC1oZWxwZXItY2VydC1hMIIBIjANBgkqhkiG
+9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnD4a4zm5nLmMgzvM33YVAZBMJvntXmXT9fTn
+rM5b59zgWYONJOcGuKcPmXvYUFih/v4jSp3X2LWKW2Z+Tod8FpGLbxxgW/PfFD2f
+iDM82qOfUxSLBTquZySTlyhqf2pz0ORSnU5poMKGwBzonYx867Nn7foP3G2qec6E
+UN4al9V9jfKauu/zGPsYi0+K//0dBmchD/h+Y/p3tPXdipBWZn33dJLPUFt111Cp
+8F3O/qAUuNh2M8I5gAd5SOxFOp2khNi9uMVikYhtB5wiFu8Z3MLNVoCcsSxRG00A
+A3rMH1e9CjyGXE0oZGtLTBEn92UoLfguMItw8oPMDZyxFrEQOwIDAQABo1MwUTAd
+BgNVHQ4EFgQUtfAJmXoq7OGAp/DlwsG/HY0Aw6UwHwYDVR0jBBgwFoAUtfAJmXoq
+7OGAp/DlwsG/HY0Aw6UwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOC
+AQEAUpcoi3yW3xFb5YWY233FW3XP8x7FQAJ/iIShsHQTDF2SOKOdAeFkWOHLmb4F
+/2Ds57Em4yeHupmGC6FIMwahqEPjyVc8uHak4gb9nokt1Zgtnbk/5IT67kYfinke
+FFtfdikE96JFPfjceMeyVxogeZkFqBND8ZiaJkLllXVwpj9JDCulQzOgmFnNYJQl
+zcllmfKbWfNUciZ+z62gIUFVdJHbGcOdENybxvCMjY+KxSZ3Ir9yvk6nBFs4m8Fm
+N965ant2MNbB1UsPmxem0U0h8mtBVAu8Wu39iTlmflwAicBACVyGGtUyLncZ6ed3
+fYluNNV0KjRiwrAM5sXjYAuEUw==
+-----END CERTIFICATE-----
diff --git a/hostsidetests/appsearch/certs/cts-appsearch-hosttest-helper-cert-b.pk8 b/hostsidetests/appsearch/certs/cts-appsearch-hosttest-helper-cert-b.pk8
new file mode 100644
index 0000000..3113ad3
--- /dev/null
+++ b/hostsidetests/appsearch/certs/cts-appsearch-hosttest-helper-cert-b.pk8
Binary files differ
diff --git a/hostsidetests/appsearch/certs/cts-appsearch-hosttest-helper-cert-b.x509.pem b/hostsidetests/appsearch/certs/cts-appsearch-hosttest-helper-cert-b.x509.pem
new file mode 100644
index 0000000..4085a04
--- /dev/null
+++ b/hostsidetests/appsearch/certs/cts-appsearch-hosttest-helper-cert-b.x509.pem
@@ -0,0 +1,20 @@
+-----BEGIN CERTIFICATE-----
+MIIDPzCCAiegAwIBAgIUQA/e31dngLMvDRzj0fY6CdEvIYYwDQYJKoZIhvcNAQEL
+BQAwLzEtMCsGA1UEAwwkY3RzLWFwcHNlYXJjaC1ob3N0dGVzdC1oZWxwZXItY2Vy
+dC1iMB4XDTIxMDQwNjA3MzEyNFoXDTQ4MDgyMjA3MzEyNFowLzEtMCsGA1UEAwwk
+Y3RzLWFwcHNlYXJjaC1ob3N0dGVzdC1oZWxwZXItY2VydC1iMIIBIjANBgkqhkiG
+9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyTSt0WUtqQUXDgz/8S/Wsl3B8YmZYFDxM+n/
+vuPu0MppzhwhwiUXqLsbI5OghRxyQlpXMgVXuVj3vPc5hwLHGseE97jgd0H2Boxn
+d4eiu5lcttnzea5UIz+8QHjIIoXWtfxkqJO68NfxXgqePbcQzVkE0zpc0OtjbO3R
+h8ry6RO25DsXMAfwKVrGEc7Gnj/sf59+jUp0E80XFJ790e/Rckwg6ilv71ndmRg2
+cnGBoxy3Aydx05cvC8GFPpSjtw2tq1Vx8HCHIgsiMeoKs0oqEzYEflrzchzcUPvg
+SU693lLymqjdADZwJSyHdVVTP/33K5ppNcb407omeYEbeXjP/wIDAQABo1MwUTAd
+BgNVHQ4EFgQUQY62T2k7WNB9YW5NGY+hlnnZYI8wHwYDVR0jBBgwFoAUQY62T2k7
+WNB9YW5NGY+hlnnZYI8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOC
+AQEALrjKluXTpwIr3yxCBI7kjagDWEzeVLjximYbOcZcohDX44NMf7fL2ZpWlLGT
++FyDCz7ZBycOP28Knb/PQKXrLmA9Vr0l7pSXLAQ6a8/Wp6y0p1Bh4g5kBgid+YCl
+u/ediERiRomPItm7W4pFlBilfaG10QzEj1GtxZC7UrXMy+578AW+Nq5AiM34LVtv
+Q2+Suvzvgne+oQAbnQWNFzMj6mw0AvJpTn0qlC8YR0aJLGqHmpMVJfWo2P2OpFjt
+m2ohVkWrUyeXfDQ5idIPn23NzoTWazasKejg9JMPDwkQqE6Zpzx+SPoomTJSsuoI
+m5Q9D6phWIBrQhgPiX8LY9g21g==
+-----END CERTIFICATE-----
diff --git a/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchHostTestBase.java b/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchHostTestBase.java
new file mode 100644
index 0000000..468997f
--- /dev/null
+++ b/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchHostTestBase.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2021 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.appsearch.cts;
+
+import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
+
+public abstract class AppSearchHostTestBase extends BaseHostJUnit4Test {
+ protected static final String TARGET_APK_A = "CtsAppSearchHostTestHelperA.apk";
+ protected static final String TARGET_PKG_A = "android.appsearch.app.a";
+ protected static final String TEST_CLASS_A = TARGET_PKG_A + ".AppSearchDeviceTest";
+ protected static final String TARGET_APK_B = "CtsAppSearchHostTestHelperB.apk";
+ protected static final String TARGET_PKG_B = "android.appsearch.app.b";
+ protected static final String TEST_CLASS_B = TARGET_PKG_B + ".AppSearchDeviceTest";
+
+ protected static final long DEFAULT_INSTRUMENTATION_TIMEOUT_MS = 600_000; // 10min
+
+ protected void runDeviceTestAsUserInPkgA(String testMethod, int userId) throws Exception {
+ runDeviceTests(getDevice(), TARGET_PKG_A, TEST_CLASS_A, testMethod, userId,
+ DEFAULT_INSTRUMENTATION_TIMEOUT_MS);
+ }
+
+ protected void runDeviceTestAsUserInPkgB(String testMethod, int userId) throws Exception {
+ runDeviceTests(getDevice(), TARGET_PKG_B, TEST_CLASS_B, testMethod, userId,
+ DEFAULT_INSTRUMENTATION_TIMEOUT_MS);
+ }
+}
diff --git a/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchMultiUserTest.java b/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchMultiUserTestBase.java
similarity index 62%
rename from hostsidetests/appsearch/src/android/appsearch/cts/AppSearchMultiUserTest.java
rename to hostsidetests/appsearch/src/android/appsearch/cts/AppSearchMultiUserTestBase.java
index 1dc36b9..8696b69 100644
--- a/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchMultiUserTest.java
+++ b/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchMultiUserTestBase.java
@@ -22,8 +22,6 @@
import static org.junit.Assume.assumeTrue;
import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
-import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
-import com.android.tradefed.testtype.junit4.DeviceTestRunOptions;
import org.junit.After;
import org.junit.Before;
@@ -41,12 +39,7 @@
* user.
*/
@RunWith(DeviceJUnit4ClassRunner.class)
-public class AppSearchMultiUserTest extends BaseHostJUnit4Test {
- private static final String TARGET_APK = "CtsAppSearchHostTestHelper.apk";
- private static final String TARGET_PKG = "android.appsearch.app";
- private static final String TEST_CLASS = TARGET_PKG + ".UserDataTest";
-
- private static final long DEFAULT_INSTRUMENTATION_TIMEOUT_MS = 600_000; // 10min
+public class AppSearchMultiUserTestBase extends AppSearchHostTestBase {
private int mInitialUserId;
private int mSecondaryUserId;
@@ -60,31 +53,26 @@
mSecondaryUserId = getDevice().createUser("Test_User");
assertThat(getDevice().startUser(mSecondaryUserId)).isTrue();
- installPackageAsUser(TARGET_APK, /* grantPermissions */true, mInitialUserId);
- installPackageAsUser(TARGET_APK, /* grantPermissions */true, mSecondaryUserId);
+ installPackageAsUser(TARGET_APK_A, /* grantPermission= */true, mInitialUserId);
+ installPackageAsUser(TARGET_APK_A, /* grantPermission= */true, mSecondaryUserId);
- runDeviceTestAsUser("clearTestData", mInitialUserId);
- runDeviceTestAsUser("clearTestData", mSecondaryUserId);
+ runDeviceTestAsUserInPkgA("clearTestData", mInitialUserId);
+ runDeviceTestAsUserInPkgA("clearTestData", mSecondaryUserId);
}
@After
public void tearDown() throws Exception {
- runDeviceTestAsUser("clearTestData", mInitialUserId);
+ runDeviceTestAsUserInPkgA("clearTestData", mInitialUserId);
if (mSecondaryUserId > 0) {
getDevice().removeUser(mSecondaryUserId);
}
}
- private void runDeviceTestAsUser(String testMethod, int userId) throws Exception {
- runDeviceTests(getDevice(), TARGET_PKG, TEST_CLASS, testMethod, userId,
- DEFAULT_INSTRUMENTATION_TIMEOUT_MS);
- }
-
@Test
public void testMultiUser_documentAccess() throws Exception {
- runDeviceTestAsUser("testPutDocuments", mSecondaryUserId);
- runDeviceTestAsUser("testGetDocuments_exist", mSecondaryUserId);
+ runDeviceTestAsUserInPkgA("testPutDocuments", mSecondaryUserId);
+ runDeviceTestAsUserInPkgA("testGetDocuments_exist", mSecondaryUserId);
// Cannot get the document from another user.
- runDeviceTestAsUser("testGetDocuments_nonexist", mInitialUserId);
+ runDeviceTestAsUserInPkgA("testGetDocuments_nonexist", mInitialUserId);
}
}
diff --git a/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchPackageTestBase.java b/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchPackageTestBase.java
new file mode 100644
index 0000000..ef1d089
--- /dev/null
+++ b/hostsidetests/appsearch/src/android/appsearch/cts/AppSearchPackageTestBase.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2021 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.appsearch.cts;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.junit.Assume.assumeTrue;
+
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(DeviceJUnit4ClassRunner.class)
+public class AppSearchPackageTestBase extends AppSearchHostTestBase {
+
+ private int mPrimaryUserId;
+
+ @Before
+ public void setUp() throws Exception {
+ mPrimaryUserId = getDevice().getPrimaryUserId();
+ installPackageAsUser(TARGET_APK_A, /* grantPermission= */true, mPrimaryUserId);
+ installPackageAsUser(TARGET_APK_B, /* grantPermission= */true, mPrimaryUserId);
+ runDeviceTestAsUserInPkgA("clearTestData", mPrimaryUserId);
+ }
+
+ @Test
+ public void testPackageRemove() throws Exception {
+ // package A grants visibility to package B.
+ runDeviceTestAsUserInPkgA("testPutDocuments", mPrimaryUserId);
+ // query the document from another package.
+ runDeviceTestAsUserInPkgB("testGlobalGetDocuments_exist", mPrimaryUserId);
+ // remove the package.
+ uninstallPackage(TARGET_PKG_A);
+ // query the document from another package, verify the document of package A is removed
+ runDeviceTestAsUserInPkgB("testGlobalGetDocuments_nonexist", mPrimaryUserId);
+ }
+}
diff --git a/hostsidetests/appsearch/test-apps/AppSearchHostTestHelper/AndroidManifest.xml b/hostsidetests/appsearch/test-apps/AppSearchHostTestHelperA/AndroidManifest.xml
similarity index 90%
copy from hostsidetests/appsearch/test-apps/AppSearchHostTestHelper/AndroidManifest.xml
copy to hostsidetests/appsearch/test-apps/AppSearchHostTestHelperA/AndroidManifest.xml
index 85eca5b..02545a7 100644
--- a/hostsidetests/appsearch/test-apps/AppSearchHostTestHelper/AndroidManifest.xml
+++ b/hostsidetests/appsearch/test-apps/AppSearchHostTestHelperA/AndroidManifest.xml
@@ -15,12 +15,12 @@
* limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.appsearch.app">
+ package="android.appsearch.app.a">
<application>
<uses-library android:name="android.test.runner" />
</application>
<instrumentation
android:name="androidx.test.runner.AndroidJUnitRunner"
- android:targetPackage="android.appsearch.app" />
+ android:targetPackage="android.appsearch.app.a" />
</manifest>
\ No newline at end of file
diff --git a/hostsidetests/appsearch/test-apps/AppSearchHostTestHelper/src/android/appsearch/app/UserDataTest.java b/hostsidetests/appsearch/test-apps/AppSearchHostTestHelperA/src/android/appsearch/app/a/AppSearchDeviceTest.java
similarity index 79%
rename from hostsidetests/appsearch/test-apps/AppSearchHostTestHelper/src/android/appsearch/app/UserDataTest.java
rename to hostsidetests/appsearch/test-apps/AppSearchHostTestHelperA/src/android/appsearch/app/a/AppSearchDeviceTest.java
index 33c8df5..b097b63 100644
--- a/hostsidetests/appsearch/test-apps/AppSearchHostTestHelper/src/android/appsearch/app/UserDataTest.java
+++ b/hostsidetests/appsearch/test-apps/AppSearchHostTestHelperA/src/android/appsearch/app/a/AppSearchDeviceTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android.appsearch.app;
+package android.appsearch.app.a;
import static com.android.server.appsearch.testing.AppSearchTestUtils.checkIsBatchResultSuccess;
import static com.android.server.appsearch.testing.AppSearchTestUtils.doGet;
@@ -28,6 +28,7 @@
import android.app.appsearch.AppSearchSessionShim;
import android.app.appsearch.GenericDocument;
import android.app.appsearch.GetByUriRequest;
+import android.app.appsearch.PackageIdentifier;
import android.app.appsearch.PutDocumentsRequest;
import android.app.appsearch.SetSchemaRequest;
@@ -35,15 +36,15 @@
import com.android.server.appsearch.testing.AppSearchSessionShimImpl;
+import com.google.common.io.BaseEncoding;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.List;
-
@RunWith(AndroidJUnit4.class)
-public class UserDataTest {
+public class AppSearchDeviceTest {
private static final String DB_NAME = "";
private static final String NAMESPACE = "namespace";
@@ -62,6 +63,19 @@
.setCreationTimestampMillis(12345L)
.build();
+ private static final String PKG_B = "android.appsearch.app.b";
+
+ // To generate, run `apksigner` on the build APK. e.g.
+ // ./apksigner verify --print-certs \
+ // ~/sc-dev/out/soong/.intermediates/cts/tests/appsearch/CtsAppSearchTestHelperA/\
+ // android_common/CtsAppSearchTestHelperA.apk`
+ // to get the SHA-256 digest. All characters need to be uppercase.
+ //
+ // Note: May need to switch the "sdk_version" of the test app from "test_current" to "30" before
+ // building the apk and running apksigner
+ private static final byte[] PKG_B_CERT_SHA256 = BaseEncoding.base16().decode(
+ "3D7A1AAE7AE8B9949BE93E071F3702AA38695B0F99B5FC4B2E8B364AC78FFDB2");
+
private AppSearchSessionShim mDb;
@Before
@@ -73,8 +87,9 @@
@Test
public void testPutDocuments() throws Exception {
// Schema registration
- mDb.setSchema(new SetSchemaRequest.Builder().addSchemas(SCHEMA).build())
- .get();
+ mDb.setSchema(new SetSchemaRequest.Builder().addSchemas(SCHEMA)
+ .setSchemaTypeVisibilityForPackage(SCHEMA.getSchemaType(), /*visible=*/ true,
+ new PackageIdentifier(PKG_B, PKG_B_CERT_SHA256)).build()).get();
// Index a document
AppSearchBatchResult<String, Void> result = checkIsBatchResultSuccess(
diff --git a/hostsidetests/appsearch/test-apps/AppSearchHostTestHelper/AndroidManifest.xml b/hostsidetests/appsearch/test-apps/AppSearchHostTestHelperB/AndroidManifest.xml
similarity index 90%
rename from hostsidetests/appsearch/test-apps/AppSearchHostTestHelper/AndroidManifest.xml
rename to hostsidetests/appsearch/test-apps/AppSearchHostTestHelperB/AndroidManifest.xml
index 85eca5b..e036572 100644
--- a/hostsidetests/appsearch/test-apps/AppSearchHostTestHelper/AndroidManifest.xml
+++ b/hostsidetests/appsearch/test-apps/AppSearchHostTestHelperB/AndroidManifest.xml
@@ -15,12 +15,12 @@
* limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.appsearch.app">
+ package="android.appsearch.app.b">
<application>
<uses-library android:name="android.test.runner" />
</application>
<instrumentation
android:name="androidx.test.runner.AndroidJUnitRunner"
- android:targetPackage="android.appsearch.app" />
+ android:targetPackage="android.appsearch.app.b" />
</manifest>
\ No newline at end of file
diff --git a/hostsidetests/appsearch/test-apps/AppSearchHostTestHelperB/src/android/appsearch/app/b/AppSearchDeviceTest.java b/hostsidetests/appsearch/test-apps/AppSearchHostTestHelperB/src/android/appsearch/app/b/AppSearchDeviceTest.java
new file mode 100644
index 0000000..8159a52
--- /dev/null
+++ b/hostsidetests/appsearch/test-apps/AppSearchHostTestHelperB/src/android/appsearch/app/b/AppSearchDeviceTest.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2021 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.appsearch.app.b;
+
+import static com.android.server.appsearch.testing.AppSearchTestUtils.convertSearchResultsToDocuments;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.app.appsearch.GenericDocument;
+import android.app.appsearch.GlobalSearchSessionShim;
+import android.app.appsearch.SearchSpec;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.android.server.appsearch.testing.GlobalSearchSessionShimImpl;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.List;
+
+@RunWith(AndroidJUnit4.class)
+public class AppSearchDeviceTest {
+
+ private static final String NAMESPACE = "namespace";
+ private static final String URI = "uri";
+ private static final GenericDocument DOCUMENT =
+ new GenericDocument.Builder<>(NAMESPACE, URI, "testSchema")
+ .setPropertyString("subject", "testPut example1")
+ .setCreationTimestampMillis(12345L)
+ .build();
+
+ private GlobalSearchSessionShim mGlobalSearch;
+
+ @Before
+ public void setUp() throws Exception {
+ mGlobalSearch = GlobalSearchSessionShimImpl.createGlobalSearchSession().get();
+ }
+
+ @Test
+ public void testGlobalGetDocuments_exist() throws Exception {
+ List<GenericDocument> outDocuments = convertSearchResultsToDocuments(
+ mGlobalSearch.search(/*queryExpression=*/"",
+ new SearchSpec.Builder().setTermMatch(SearchSpec.TERM_MATCH_PREFIX)
+ .build()));
+ assertThat(outDocuments).containsExactly(DOCUMENT);
+ }
+
+ @Test
+ public void testGlobalGetDocuments_nonexist() throws Exception {
+ List<GenericDocument> outDocuments = convertSearchResultsToDocuments(
+ mGlobalSearch.search(/*queryExpression=*/"",
+ new SearchSpec.Builder().setTermMatch(SearchSpec.TERM_MATCH_PREFIX)
+ .build()));
+ assertThat(outDocuments).isEmpty();
+ }
+}
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/ApkVerityInstallTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/ApkVerityInstallTest.java
index f829175..15e1279 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/ApkVerityInstallTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/ApkVerityInstallTest.java
@@ -29,7 +29,6 @@
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -290,7 +289,6 @@
}
@Test
- @Ignore("IncFs does not support STATX_ATTR_VERITY")
public void testInstallBaseWithFsvSigIncrementally() throws Exception {
assumeSecurityModelCompat();
assumeIncrementalDeliveryFeature();
@@ -304,7 +302,6 @@
}
@Test
- @Ignore("IncFs does not support STATX_ATTR_VERITY")
public void testInstallEverythingWithFsvSigIncrementally() throws Exception {
assumeSecurityModelCompat();
assumeIncrementalDeliveryFeature();
diff --git a/hostsidetests/appsecurity/test-apps/ExternalStorageApp/TEST_MAPPING b/hostsidetests/appsecurity/test-apps/ExternalStorageApp/TEST_MAPPING
index 90a93b0..b08a98e 100644
--- a/hostsidetests/appsecurity/test-apps/ExternalStorageApp/TEST_MAPPING
+++ b/hostsidetests/appsecurity/test-apps/ExternalStorageApp/TEST_MAPPING
@@ -1,5 +1,5 @@
{
- "presubmit": [
+ "presubmit-large": [
{
"name": "CtsAppSecurityHostTestCases",
"options": [
diff --git a/hostsidetests/appsecurity/test-apps/MediaStorageApp/TEST_MAPPING b/hostsidetests/appsecurity/test-apps/MediaStorageApp/TEST_MAPPING
index 90a93b0..b08a98e 100644
--- a/hostsidetests/appsecurity/test-apps/MediaStorageApp/TEST_MAPPING
+++ b/hostsidetests/appsecurity/test-apps/MediaStorageApp/TEST_MAPPING
@@ -1,5 +1,5 @@
{
- "presubmit": [
+ "presubmit-large": [
{
"name": "CtsAppSecurityHostTestCases",
"options": [
diff --git a/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/TEST_MAPPING b/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/TEST_MAPPING
index 90a93b0..b08a98e 100644
--- a/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/TEST_MAPPING
+++ b/hostsidetests/appsecurity/test-apps/MultiUserStorageApp/TEST_MAPPING
@@ -1,5 +1,5 @@
{
- "presubmit": [
+ "presubmit-large": [
{
"name": "CtsAppSecurityHostTestCases",
"options": [
diff --git a/hostsidetests/appsecurity/test-apps/ReadExternalStorageApp/TEST_MAPPING b/hostsidetests/appsecurity/test-apps/ReadExternalStorageApp/TEST_MAPPING
index 90a93b0..b08a98e 100644
--- a/hostsidetests/appsecurity/test-apps/ReadExternalStorageApp/TEST_MAPPING
+++ b/hostsidetests/appsecurity/test-apps/ReadExternalStorageApp/TEST_MAPPING
@@ -1,5 +1,5 @@
{
- "presubmit": [
+ "presubmit-large": [
{
"name": "CtsAppSecurityHostTestCases",
"options": [
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/feature_rose/lint-baseline.xml b/hostsidetests/appsecurity/test-apps/SplitApp/feature_rose/lint-baseline.xml
new file mode 100644
index 0000000..06f2943
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/feature_rose/lint-baseline.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="5" by="lint 4.1.0" client="cli" variant="all" version="4.1.0">
+
+ <issue
+ id="NewApi"
+ message="`android:statusBarColor` requires API level 21 (current min is 4)"
+ errorLine1=" <item name="android:statusBarColor">@color/rose_status_bar_color</item>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/hostsidetests/appsecurity/test-apps/SplitApp/feature_rose/res/values/styles.xml"
+ line="21"
+ column="15"/>
+ </issue>
+
+</issues>
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/feature_warm/lint-baseline.xml b/hostsidetests/appsecurity/test-apps/SplitApp/feature_warm/lint-baseline.xml
new file mode 100644
index 0000000..5e46a6b
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/feature_warm/lint-baseline.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="5" by="lint 4.1.0" client="cli" variant="all" version="4.1.0">
+
+ <issue
+ id="NewApi"
+ message="`android:statusBarColor` requires API level 21 (current min is 4)"
+ errorLine1=" <item name="android:statusBarColor">@color/warm_status_bar_color</item>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/hostsidetests/appsecurity/test-apps/SplitApp/feature_warm/res/values/styles.xml"
+ line="21"
+ column="15"/>
+ </issue>
+
+</issues>
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/lint-baseline.xml b/hostsidetests/appsecurity/test-apps/SplitApp/lint-baseline.xml
new file mode 100644
index 0000000..8a6a9c6
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/lint-baseline.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="5" by="lint 4.1.0" client="cli" variant="all" version="4.1.0">
+
+ <issue
+ id="NewApi"
+ message="`@android:style/Theme.Material` requires API level 21 (current min is 4)"
+ errorLine1=" <style name="Theme_Base" parent="@android:style/Theme.Material">"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/hostsidetests/appsecurity/test-apps/SplitApp/res/values/styles.xml"
+ line="18"
+ column="30"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="`android:navigationBarColor` requires API level 21 (current min is 4)"
+ errorLine1=" <item name="android:navigationBarColor">@color/navigation_bar_color</item>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/hostsidetests/appsecurity/test-apps/SplitApp/res/values/styles.xml"
+ line="21"
+ column="15"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="`android:statusBarColor` requires API level 21 (current min is 4)"
+ errorLine1=" <item name="android:statusBarColor">@color/status_bar_color</item>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/hostsidetests/appsecurity/test-apps/SplitApp/res/values/styles.xml"
+ line="22"
+ column="15"/>
+ </issue>
+
+</issues>
diff --git a/hostsidetests/appsecurity/test-apps/StorageStatsApp/src/com/android/cts/storagestatsapp/StorageStatsTest.java b/hostsidetests/appsecurity/test-apps/StorageStatsApp/src/com/android/cts/storagestatsapp/StorageStatsTest.java
index 9ca02fb..3bfa0ec 100644
--- a/hostsidetests/appsecurity/test-apps/StorageStatsApp/src/com/android/cts/storagestatsapp/StorageStatsTest.java
+++ b/hostsidetests/appsecurity/test-apps/StorageStatsApp/src/com/android/cts/storagestatsapp/StorageStatsTest.java
@@ -81,7 +81,7 @@
* option are enabled.
*/
public void testVerify() throws Exception {
- if (Build.VERSION.FIRST_SDK_INT >= Build.VERSION_CODES.P) {
+ if (Build.VERSION.DEVICE_INITIAL_SDK_INT >= Build.VERSION_CODES.P) {
final StorageStatsManager stats = getContext()
.getSystemService(StorageStatsManager.class);
assertTrue("Devices that first ship with P or newer must enable quotas to "
diff --git a/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/TEST_MAPPING b/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/TEST_MAPPING
index 90a93b0..b08a98e 100644
--- a/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/TEST_MAPPING
+++ b/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/TEST_MAPPING
@@ -1,5 +1,5 @@
{
- "presubmit": [
+ "presubmit-large": [
{
"name": "CtsAppSecurityHostTestCases",
"options": [
diff --git a/hostsidetests/devicepolicy/app/CertInstaller/src/com/android/cts/certinstaller/DirectDelegatedCertInstallerTest.java b/hostsidetests/devicepolicy/app/CertInstaller/src/com/android/cts/certinstaller/DirectDelegatedCertInstallerTest.java
index caa08f7..fa7a21e 100644
--- a/hostsidetests/devicepolicy/app/CertInstaller/src/com/android/cts/certinstaller/DirectDelegatedCertInstallerTest.java
+++ b/hostsidetests/devicepolicy/app/CertInstaller/src/com/android/cts/certinstaller/DirectDelegatedCertInstallerTest.java
@@ -31,6 +31,7 @@
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
+import android.os.Process;
import android.security.AttestedKeyPair;
import android.security.KeyChain;
import android.security.keystore.KeyGenParameterSpec;
@@ -51,6 +52,7 @@
import java.security.cert.CertificateFactory;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.List;
+import java.util.Map;
/*
* Tests the delegated certificate installer functionality.
@@ -236,7 +238,7 @@
/* requestAccess= */ true);
assertThat(mDpm.getKeyPairGrants(TEST_ALIAS))
- .isEqualTo(singleton(singleton(getContext().getPackageName())));
+ .isEqualTo(Map.of(Process.myUid(), singleton(getContext().getPackageName())));
}
public void testIsWifiGrant_default() {
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/latest/AndroidManifest.xml b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/latest/AndroidManifest.xml
index 2af83d7..e691e20 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/latest/AndroidManifest.xml
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/latest/AndroidManifest.xml
@@ -31,6 +31,7 @@
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.CAMERA"/>
+ <uses-permission android:name="android.permission.MODIFY_QUIET_MODE"/>
<!-- Needed to read the serial number during Device ID attestation tests -->
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/KeyManagementTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/KeyManagementTest.java
index 8b464fe..95d6b9c 100755
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/KeyManagementTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/KeyManagementTest.java
@@ -37,6 +37,7 @@
import android.keystore.cts.AuthorizationList;
import android.net.Uri;
import android.os.Build;
+import android.os.Process;
import android.security.AttestedKeyPair;
import android.security.KeyChain;
import android.security.KeyChainAliasCallback;
@@ -49,8 +50,6 @@
import com.android.compatibility.common.util.FakeKeys.FAKE_RSA_1;
-import com.google.common.collect.Sets;
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -74,6 +73,8 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -755,7 +756,6 @@
}
}
-
public void testCanSetKeyPairCert() throws Exception {
final String alias = "com.android.test.set-ec-1";
try {
@@ -854,7 +854,7 @@
TEST_ALIAS, /* requestAccess= */ true);
assertThat(mDevicePolicyManager.getKeyPairGrants(TEST_ALIAS))
- .isEqualTo(singleton(singleton(getWho().getPackageName())));
+ .isEqualTo(Map.of(Process.myUid(), singleton(getWho().getPackageName())));
}
public void testGetKeyPairGrants_GrantedExplicitly() {
@@ -863,7 +863,7 @@
mDevicePolicyManager.grantKeyPairToApp(getWho(), TEST_ALIAS, getWho().getPackageName());
assertThat(mDevicePolicyManager.getKeyPairGrants(TEST_ALIAS))
- .isEqualTo(singleton(singleton(getWho().getPackageName())));
+ .isEqualTo(Map.of(Process.myUid(), singleton(getWho().getPackageName())));
}
public void testGetKeyPairGrants_Revoked() {
@@ -874,23 +874,27 @@
assertThat(mDevicePolicyManager.getKeyPairGrants(TEST_ALIAS)).isEmpty();
}
- public void testGetKeyPairGrants_SharedUid() {
+ public void testGetKeyPairGrants_SharedUid() throws Exception {
mDevicePolicyManager.installKeyPair(getWho(), mFakePrivKey, new Certificate[]{mFakeCert},
TEST_ALIAS, /* requestAccess= */ false);
mDevicePolicyManager.grantKeyPairToApp(getWho(), TEST_ALIAS, SHARED_UID_APP1_PKG);
+ final int sharedUid = mContext.getPackageManager()
+ .getApplicationInfo(SHARED_UID_APP1_PKG, 0).uid;
assertThat(mDevicePolicyManager.getKeyPairGrants(TEST_ALIAS))
- .isEqualTo(singleton(Sets.newHashSet(SHARED_UID_APP1_PKG, SHARED_UID_APP2_PKG)));
+ .isEqualTo(Map.of(sharedUid, Set.of(SHARED_UID_APP1_PKG, SHARED_UID_APP2_PKG)));
}
- public void testGetKeyPairGrants_DifferentUids() {
+ public void testGetKeyPairGrants_DifferentUids() throws Exception {
mDevicePolicyManager.installKeyPair(getWho(), mFakePrivKey, new Certificate[]{mFakeCert},
TEST_ALIAS, /* requestAccess= */ true);
mDevicePolicyManager.grantKeyPairToApp(getWho(), TEST_ALIAS, SHARED_UID_APP1_PKG);
+ final int sharedUid = mContext.getPackageManager()
+ .getApplicationInfo(SHARED_UID_APP1_PKG, 0).uid;
- assertThat(mDevicePolicyManager.getKeyPairGrants(TEST_ALIAS)).isEqualTo(Sets.newHashSet(
- Sets.newHashSet(SHARED_UID_APP1_PKG, SHARED_UID_APP2_PKG),
- singleton(getWho().getPackageName())));
+ assertThat(mDevicePolicyManager.getKeyPairGrants(TEST_ALIAS)).isEqualTo(Map.of(
+ Process.myUid(), singleton(getWho().getPackageName()),
+ sharedUid, Set.of(SHARED_UID_APP1_PKG, SHARED_UID_APP2_PKG)));
}
public void testIsWifiGrant_default() {
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskTest.java
index 5ab2307..606bd55 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskTest.java
@@ -24,6 +24,8 @@
import static android.app.admin.DevicePolicyManager.LOCK_TASK_FEATURE_OVERVIEW;
import static android.app.admin.DevicePolicyManager.LOCK_TASK_FEATURE_SYSTEM_INFO;
+import static com.google.common.truth.Truth.assertWithMessage;
+
import static org.junit.Assert.assertArrayEquals;
import static org.testng.Assert.assertThrows;
@@ -43,9 +45,9 @@
import android.view.KeyEvent;
import androidx.test.InstrumentationRegistry;
-import androidx.test.runner.AndroidJUnit4;
import java.time.Duration;
+import java.util.Set;
import java.util.concurrent.TimeUnit;
public class LockTaskTest extends BaseDeviceAdminTest {
@@ -179,6 +181,20 @@
assertFalse(mDevicePolicyManager.isLockTaskPermitted(TEST_PACKAGE));
}
+ // When OEM defines policy-exempt apps, they are permitted on lock task mode
+ public void testIsLockTaskPermittedIncludesPolicyExemptApps() {
+ Set<String> policyExemptApps = mDevicePolicyManager.getPolicyExemptApps();
+ if (policyExemptApps.isEmpty()) {
+ Log.v(TAG, "OEM doesn't define any policy-exempt app");
+ return;
+ }
+
+ for (String app : policyExemptApps) {
+ assertWithMessage("isLockTaskPermitted(%s)", app)
+ .that(mDevicePolicyManager.isLockTaskPermitted(app)).isTrue();
+ }
+ }
+
// Setting and unsetting the lock task features. The actual UI behavior is tested with CTS
// verifier.
public void testSetLockTaskFeatures() {
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/PersonalAppsSuspensionTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/PersonalAppsSuspensionTest.java
index e4f97fa..6fcd364 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/PersonalAppsSuspensionTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/PersonalAppsSuspensionTest.java
@@ -26,6 +26,9 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
+import android.os.Process;
+import android.os.UserHandle;
+import android.os.UserManager;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
@@ -33,6 +36,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.util.List;
import java.util.concurrent.TimeUnit;
/**
@@ -69,6 +73,28 @@
}
@Test
+ public void testEnableQuietMode() {
+ requestQuietModeEnabledForProfile(true);
+ }
+
+ @Test
+ public void testDisableQuietMode() {
+ requestQuietModeEnabledForProfile(false);
+ }
+
+ private void requestQuietModeEnabledForProfile(boolean enabled) {
+ final UserManager userManager = UserManager.get(mContext);
+ final List<UserHandle> users = userManager.getUserProfiles();
+
+ // Should get primary user itself and its profile.
+ assertThat(users.size()).isEqualTo(2);
+ final UserHandle profileHandle =
+ users.get(0).equals(Process.myUserHandle()) ? users.get(1) : users.get(0);
+
+ userManager.requestQuietModeEnabled(enabled, profileHandle);
+ }
+
+ @Test
public void testComplianceAcknowledgementRequiredReceived() {
final SharedPreferences pref =
mContext.getSharedPreferences(COMPLIANCE_ACK_PREF_NAME, Context.MODE_PRIVATE);
diff --git a/hostsidetests/devicepolicy/app/TestLauncher/Android.bp b/hostsidetests/devicepolicy/app/TestLauncher/Android.bp
deleted file mode 100644
index f13f2bd..0000000
--- a/hostsidetests/devicepolicy/app/TestLauncher/Android.bp
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (C) 2020 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-android_test_helper_app {
- name: "TestLauncher",
- defaults: ["cts_defaults"],
- srcs: ["src/**/*.java"],
- static_libs: [
- "cts-devicepolicy-suspensionchecker",
- ],
- test_suites: [
- "arcts",
- "cts",
- "general-tests",
- "mts",
- ],
-}
diff --git a/hostsidetests/devicepolicy/app/TestLauncher/AndroidManifest.xml b/hostsidetests/devicepolicy/app/TestLauncher/AndroidManifest.xml
deleted file mode 100644
index 596fcd0..0000000
--- a/hostsidetests/devicepolicy/app/TestLauncher/AndroidManifest.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
- * Copyright 2020, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.cts.testlauncher">
- <application android:label="Test Launcher">
- <activity android:name="android.app.Activity"
- android:exported="true">
- <intent-filter>
- <action android:name="android.intent.action.MAIN"/>
- <category android:name="android.intent.category.HOME"/>
- <category android:name="android.intent.category.DEFAULT"/>
- </intent-filter>
- </activity>
- <activity android:name=".QuietModeToggleActivity"
- android:exported="true"/>
- </application>
-
- <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
- android:targetPackage="com.android.cts.testlauncher">
- <meta-data android:name="listener"
- android:value="com.android.cts.runner.CtsTestRunListener"/>
- </instrumentation>
-</manifest>
diff --git a/hostsidetests/devicepolicy/app/TestLauncher/src/com/android/cts/dummylauncher/QuietModeToggleActivity.java b/hostsidetests/devicepolicy/app/TestLauncher/src/com/android/cts/dummylauncher/QuietModeToggleActivity.java
deleted file mode 100644
index fd2a280..0000000
--- a/hostsidetests/devicepolicy/app/TestLauncher/src/com/android/cts/dummylauncher/QuietModeToggleActivity.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.cts.testlauncher;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.os.Process;
-import android.os.UserHandle;
-import android.os.UserManager;
-import android.util.Log;
-
-import java.util.List;
-
-public class QuietModeToggleActivity extends Activity {
- private static final String TAG = "QuietModeToggleActivity";
- private static final String EXTRA_QUIET_MODE_STATE =
- "com.android.cts.testactivity.QUIET_MODE_STATE";
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- toggleQuietMode();
- finish();
- }
-
- private void toggleQuietMode() {
- final boolean quietModeState = getIntent().getBooleanExtra(EXTRA_QUIET_MODE_STATE, false);
- final UserManager userManager = UserManager.get(this);
-
- final List<UserHandle> users = userManager.getUserProfiles();
- if (users.size() != 2) {
- Log.e(TAG, "Unexpected number of profiles: " + users.size());
- return;
- }
-
- final UserHandle profileHandle =
- users.get(0).equals(Process.myUserHandle()) ? users.get(1) : users.get(0);
-
- final String quietModeStateString = quietModeState ? "enabled" : "disabled";
- if (userManager.isQuietModeEnabled(profileHandle) == quietModeState) {
- Log.w(TAG, "Quiet mode is already " + quietModeStateString);
- return;
- }
-
- userManager.requestQuietModeEnabled(quietModeState, profileHandle);
- Log.i(TAG, "Quiet mode for user " + profileHandle + " was set to " + quietModeStateString);
- }
-}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/MixedDeviceOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/MixedDeviceOwnerTest.java
index ad6ca63..a42a731 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/MixedDeviceOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/MixedDeviceOwnerTest.java
@@ -118,6 +118,12 @@
}
@Test
+ public void testIsLockTaskPermitted_includesPolicyExemptApps() throws Exception {
+ runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".LockTaskTest",
+ "testIsLockTaskPermittedIncludesPolicyExemptApps", mDeviceOwnerUserId);
+ }
+
+ @Test
public void testDelegatedCertInstallerDeviceIdAttestation() throws Exception {
setUpDelegatedCertInstallerAndRunTests(() ->
runDeviceTestsAsUser("com.android.cts.certinstaller",
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/OrgOwnedProfileOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/OrgOwnedProfileOwnerTest.java
index 0fd3f3d..408ca489 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/OrgOwnedProfileOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/OrgOwnedProfileOwnerTest.java
@@ -65,19 +65,11 @@
private static final String TEST_LAUNCHER_APK = "TestLauncher.apk";
private static final String TEST_LAUNCHER_COMPONENT =
"com.android.cts.testlauncher/android.app.Activity";
- private static final String QUIET_MODE_TOGGLE_ACTIVITY =
- "com.android.cts.testlauncher/.QuietModeToggleActivity";
- private static final String EXTRA_QUIET_MODE_STATE =
- "com.android.cts.testactivity.QUIET_MODE_STATE";
public static final String SUSPENSION_CHECKER_CLASS =
"com.android.cts.suspensionchecker.ActivityLaunchTest";
- private static final String ACTION_ACKNOWLEDGEMENT_REQUIRED =
- "com.android.cts.deviceandprofileowner.action.ACKNOWLEDGEMENT_REQUIRED";
- private static final String ACTION_ARGUMENT = "broadcast-action";
-
private static final String USER_IS_NOT_STARTED = "User is not started";
- private static final long USER_STOP_TIMEOUT_SEC = 30;
+ private static final long USER_STOP_TIMEOUT_SEC = 60;
protected int mUserId;
private static final String DISALLOW_CONFIG_LOCATION = "no_config_location";
@@ -608,22 +600,15 @@
runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PersonalAppsSuspensionTest",
"testSetManagedProfileMaximumTimeOff1Sec", mUserId);
- final String defaultLauncher = getDefaultLauncher();
- try {
- installAppAsUser(TEST_LAUNCHER_APK, true, true, mPrimaryUserId);
- setAndStartLauncher(TEST_LAUNCHER_COMPONENT);
- toggleQuietMode(true);
- // Verify that at some point personal app becomes impossible to launch.
- runDeviceTestsAsUser(DEVICE_ADMIN_PKG, SUSPENSION_CHECKER_CLASS,
- "testWaitForActivityNotLaunchable", mPrimaryUserId);
- toggleQuietMode(false);
- // Ensure the profile is properly started before wipe broadcast is sent in teardown.
- waitForUserUnlock(mUserId);
- runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PersonalAppsSuspensionTest",
- "testPersonalAppsSuspendedByTimeout", mUserId);
- } finally {
- setAndStartLauncher(defaultLauncher);
- }
+ toggleQuietMode(true);
+ // Verify that at some point personal app becomes impossible to launch.
+ runDeviceTestsAsUser(DEVICE_ADMIN_PKG, SUSPENSION_CHECKER_CLASS,
+ "testWaitForActivityNotLaunchable", mPrimaryUserId);
+ toggleQuietMode(false);
+ // Ensure the profile is properly started before wipe broadcast is sent in teardown.
+ waitForUserUnlock(mUserId);
+ runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PersonalAppsSuspensionTest",
+ "testPersonalAppsSuspendedByTimeout", mUserId);
}
@Test
@@ -634,10 +619,7 @@
runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PersonalAppsSuspensionTest",
"testSetManagedProfileMaximumTimeOff1Year", mUserId);
- final String defaultLauncher = getDefaultLauncher();
try {
- installAppAsUser(TEST_LAUNCHER_APK, true, true, mPrimaryUserId);
- setAndStartLauncher(TEST_LAUNCHER_COMPONENT);
toggleQuietMode(true);
waitForUserStopped(mUserId);
toggleQuietMode(false);
@@ -652,7 +634,6 @@
"testComplianceAcknowledgementNotRequired", mUserId);
} finally {
- setAndStartLauncher(defaultLauncher);
runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PersonalAppsSuspensionTest",
"testClearComplianceSharedPreference", mUserId);
}
@@ -669,10 +650,7 @@
runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PersonalAppsSuspensionTest",
"testSetOverrideOnComplianceAcknowledgementRequired", mUserId);
- final String defaultLauncher = getDefaultLauncher();
try {
- installAppAsUser(TEST_LAUNCHER_APK, true, true, mPrimaryUserId);
- setAndStartLauncher(TEST_LAUNCHER_COMPONENT);
toggleQuietMode(true);
waitForUserStopped(mUserId);
toggleQuietMode(false);
@@ -686,7 +664,6 @@
runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PersonalAppsSuspensionTest",
"testAcknowledgeCompliance", mUserId);
} finally {
- setAndStartLauncher(defaultLauncher);
runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PersonalAppsSuspensionTest",
"testClearComplianceSharedPreference", mUserId);
}
@@ -786,18 +763,8 @@
}
private void toggleQuietMode(boolean quietModeEnable) throws Exception {
- final String str;
- // TV launcher uses intent filter priority to prevent 3p launchers replacing it
- // this causes the activity that toggles quiet mode to be suspended
- // and the profile would never start
- if (isTv()) {
- str = quietModeEnable ? String.format("am stop-user -f %d", mUserId)
- : String.format("am start-user %d", mUserId);
- } else {
- str = String.format("am start-activity -n %s --ez %s %s",
- QUIET_MODE_TOGGLE_ACTIVITY, EXTRA_QUIET_MODE_STATE, quietModeEnable);
- }
- executeShellCommand(str);
+ runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".PersonalAppsSuspensionTest",
+ quietModeEnable ? "testEnableQuietMode" : "testDisableQuietMode", mPrimaryUserId);
}
private void setAndStartLauncher(String component) throws Exception {
diff --git a/hostsidetests/hdmicec/README.md b/hostsidetests/hdmicec/README.md
index 4364e6c..b774e46 100644
--- a/hostsidetests/hdmicec/README.md
+++ b/hostsidetests/hdmicec/README.md
@@ -20,7 +20,13 @@
* HDMI Display (aka a TV) with CEC disabled to avoid interference, or an HDMI fake plug
It is recommended that the playback device has an HDMI physical address of `1.0.0.0` while running
-the tests.
+the tests. In case the DUT takes a physical address other than `1.0.0.0` and this is unavoidable,
+the tests can be configured to expect a different physical address by appending these arguments to
+the tradefed command:
+```
+--module-arg CtsHdmiCecHostTestCases:set-option:cec-phy-addr:<address_in_decimal>
+```
+Thus, for a device that is taking an address `3.0.0.0`, pass `12288` as the `cec-phy-addr` argument.
The CEC adapter may also be installed in-between the TV and the playback device.
diff --git a/hostsidetests/scopedstorage/Android.bp b/hostsidetests/scopedstorage/Android.bp
index c2c0e82..7fa469b 100644
--- a/hostsidetests/scopedstorage/Android.bp
+++ b/hostsidetests/scopedstorage/Android.bp
@@ -170,17 +170,6 @@
]
}
-android_test {
- name: "SignatureStorageTest",
- manifest: "signature/AndroidManifest.xml",
- srcs: ["signature/src/**/*.java"],
- static_libs: ["truth-prebuilt", "cts-scopedstorage-lib"],
- compile_multilib: "both",
- test_suites: ["general-tests", "mts", "cts"],
- sdk_version: "test_current",
- certificate: "platform",
-}
-
java_test_host {
name: "CtsScopedStorageCoreHostTest",
srcs: [
diff --git a/hostsidetests/scopedstorage/AndroidManifest.xml b/hostsidetests/scopedstorage/AndroidManifest.xml
index 9c3653b..2f16b9c 100644
--- a/hostsidetests/scopedstorage/AndroidManifest.xml
+++ b/hostsidetests/scopedstorage/AndroidManifest.xml
@@ -20,7 +20,6 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
- <uses-permission android:name="android.permission.ACCESS_MTP" />
<application android:requestRawExternalStorageAccess="true">
<uses-library android:name="android.test.runner" />
</application>
diff --git a/hostsidetests/scopedstorage/AndroidTest.xml b/hostsidetests/scopedstorage/AndroidTest.xml
index 560ad48..8749087 100644
--- a/hostsidetests/scopedstorage/AndroidTest.xml
+++ b/hostsidetests/scopedstorage/AndroidTest.xml
@@ -23,7 +23,6 @@
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="ScopedStorageTest.apk" />
- <option name="test-file-name" value="SignatureStorageTest.apk" />
<option name="test-file-name" value="LegacyStorageTest.apk" />
<option name="test-file-name" value="CtsScopedStorageTestAppA.apk" />
<option name="test-file-name" value="CtsScopedStorageTestAppB.apk" />
diff --git a/hostsidetests/scopedstorage/PublicVolumeTest.xml b/hostsidetests/scopedstorage/PublicVolumeTest.xml
index e6c1cee..1dc4017 100644
--- a/hostsidetests/scopedstorage/PublicVolumeTest.xml
+++ b/hostsidetests/scopedstorage/PublicVolumeTest.xml
@@ -18,7 +18,6 @@
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="ScopedStorageTest.apk" />
- <option name="test-file-name" value="SignatureStorageTest.apk" />
<option name="test-file-name" value="LegacyStorageTest.apk" />
<option name="test-file-name" value="CtsScopedStorageTestAppA.apk" />
<option name="test-file-name" value="CtsScopedStorageTestAppB.apk" />
diff --git a/hostsidetests/scopedstorage/device/src/android/scopedstorage/cts/device/ScopedStorageBaseDeviceTest.java b/hostsidetests/scopedstorage/device/src/android/scopedstorage/cts/device/ScopedStorageBaseDeviceTest.java
index 5299188..7cad3db 100644
--- a/hostsidetests/scopedstorage/device/src/android/scopedstorage/cts/device/ScopedStorageBaseDeviceTest.java
+++ b/hostsidetests/scopedstorage/device/src/android/scopedstorage/cts/device/ScopedStorageBaseDeviceTest.java
@@ -25,6 +25,7 @@
import static androidx.test.InstrumentationRegistry.getContext;
import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assertWithMessage;
import android.provider.MediaStore;
import android.scopedstorage.cts.lib.TestUtils;
@@ -35,6 +36,8 @@
import java.util.List;
class ScopedStorageBaseDeviceTest {
+ private static final String VOLUME_PUBLIC = "volume_public";
+
@BeforeClass
public static void setup() throws Exception {
createPublicVolume();
@@ -44,9 +47,11 @@
private static void createPublicVolume() throws Exception {
if (TestUtils.getCurrentPublicVolumeName() == null) {
TestUtils.createNewPublicVolume();
+ assertWithMessage("Expected newly created public volume name to be not null")
+ .that(TestUtils.getCurrentPublicVolumeName())
+ .isNotNull();
}
}
-
private static void setupStorage() throws Exception {
if (!getContext().getPackageManager().isInstantApp()) {
pollForExternalStorageState();
@@ -60,7 +65,11 @@
resetDefaultExternalStorageVolume();
TestUtils.assertDefaultVolumeIsPrimary();
} else {
- setExternalStorageVolume(volumeName);
+ final String publicVolumeName = TestUtils.getCurrentPublicVolumeName();
+ assertWithMessage("Expected public volume name to be not null")
+ .that(publicVolumeName)
+ .isNotNull();
+ setExternalStorageVolume(publicVolumeName);
TestUtils.assertDefaultVolumeIsPublic();
}
setupDefaultDirectories();
@@ -69,7 +78,7 @@
static List<String> getTestParameters() {
return Arrays.asList(
MediaStore.VOLUME_EXTERNAL,
- TestUtils.getCurrentPublicVolumeName()
+ VOLUME_PUBLIC
);
}
}
diff --git a/hostsidetests/scopedstorage/device/src/android/scopedstorage/cts/device/ScopedStorageDeviceTest.java b/hostsidetests/scopedstorage/device/src/android/scopedstorage/cts/device/ScopedStorageDeviceTest.java
index 17f5bc7..014c516 100644
--- a/hostsidetests/scopedstorage/device/src/android/scopedstorage/cts/device/ScopedStorageDeviceTest.java
+++ b/hostsidetests/scopedstorage/device/src/android/scopedstorage/cts/device/ScopedStorageDeviceTest.java
@@ -35,6 +35,7 @@
import static android.scopedstorage.cts.lib.TestUtils.assertCantRenameFile;
import static android.scopedstorage.cts.lib.TestUtils.assertDirectoryContains;
import static android.scopedstorage.cts.lib.TestUtils.assertFileContent;
+import static android.scopedstorage.cts.lib.TestUtils.assertMountMode;
import static android.scopedstorage.cts.lib.TestUtils.assertThrows;
import static android.scopedstorage.cts.lib.TestUtils.canOpen;
import static android.scopedstorage.cts.lib.TestUtils.canOpenFileAs;
@@ -125,6 +126,7 @@
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Intent;
+import android.content.pm.ProviderInfo;
import android.database.Cursor;
import android.media.ExifInterface;
import android.net.Uri;
@@ -133,6 +135,8 @@
import android.os.FileUtils;
import android.os.ParcelFileDescriptor;
import android.os.Process;
+import android.os.storage.StorageManager;
+import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.system.ErrnoException;
import android.system.Os;
@@ -3069,6 +3073,35 @@
testTransformsDirCommon(file);
}
+
+ /**
+ * Test mount modes for a platform signed app with ACCESS_MTP permission.
+ */
+ @Test
+ public void testMTPAppWithPlatformSignatureMountMode() throws Exception {
+ final String shellPackageName = "com.android.shell";
+ final int uid = getContext().getPackageManager().getPackageUid(shellPackageName, 0);
+ assertMountMode(shellPackageName, uid, StorageManager.MOUNT_MODE_EXTERNAL_ANDROID_WRITABLE);
+ }
+
+ /**
+ * Test mount modes for ExternalStorageProvider and DownloadsProvider.
+ */
+ @Test
+ public void testExternalStorageProviderAndDownloadsProvider() throws Exception {
+ assertWritableMountModeForProvider(DocumentsContract.EXTERNAL_STORAGE_PROVIDER_AUTHORITY);
+ assertWritableMountModeForProvider(DocumentsContract.DOWNLOADS_PROVIDER_AUTHORITY);
+ }
+
+ private void assertWritableMountModeForProvider(String auth) {
+ final ProviderInfo provider = getContext().getPackageManager()
+ .resolveContentProvider(auth, 0);
+ int uid = provider.applicationInfo.uid;
+ final String packageName = provider.applicationInfo.packageName;
+
+ assertMountMode(packageName, uid, StorageManager.MOUNT_MODE_EXTERNAL_ANDROID_WRITABLE);
+ }
+
private Uri shareAndGetRedactedUri(File file, TestApp testApp) {
final Uri redactedUri = getRedactedUri(file);
getContext().grantUriPermission(testApp.getPackageName(), redactedUri,
diff --git a/hostsidetests/scopedstorage/host/src/android/scopedstorage/cts/host/ScopedStorageHostTest.java b/hostsidetests/scopedstorage/host/src/android/scopedstorage/cts/host/ScopedStorageHostTest.java
index 7eba789..f1236b6 100644
--- a/hostsidetests/scopedstorage/host/src/android/scopedstorage/cts/host/ScopedStorageHostTest.java
+++ b/hostsidetests/scopedstorage/host/src/android/scopedstorage/cts/host/ScopedStorageHostTest.java
@@ -59,15 +59,6 @@
.setDisableIsolatedStorage(true));
}
- /**
- * Runs the given phase of SignatureStorageTest by calling into the device.
- * Throws an exception if the test phase fails.
- */
- void runDeviceTestWithPlatformSignature(String phase) throws Exception {
- assertThat(runDeviceTests("android.scopedstorage.cts.signature",
- "android.scopedstorage.cts.signature.SignatureStorageTest", phase)).isTrue();
- }
-
private void setupExternalStorage() throws Exception {
if (!mIsExternalStorageSetup) {
runDeviceTest("setupExternalStorage");
@@ -158,21 +149,6 @@
}
@Test
- public void testMTPAppWithoutPlatformSignatureCannotAccessAndroidDirs() throws Exception {
- runDeviceTest("testMTPAppWithoutPlatformSignatureCannotAccessAndroidDirs");
- }
-
- @Test
- public void testMTPAppWithPlatformSignatureCanAccessAndroidDirs() throws Exception {
- runDeviceTestWithPlatformSignature("testMTPAppWithPlatformSignatureCanAccessAndroidDirs");
- }
-
- @Test
- public void testExternalStorageProviderAndDownloadsProvider() throws Exception {
- runDeviceTest("testExternalStorageProviderAndDownloadsProvider");
- }
-
- @Test
public void testManageExternalStorageQueryOtherAppsFile() throws Exception {
allowAppOps("android:manage_external_storage");
try {
diff --git a/hostsidetests/scopedstorage/signature/AndroidManifest.xml b/hostsidetests/scopedstorage/signature/AndroidManifest.xml
deleted file mode 100644
index 1f808f8..0000000
--- a/hostsidetests/scopedstorage/signature/AndroidManifest.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2021 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.scopedstorage.cts.signature" >
- <uses-permission android:name="android.permission.ACCESS_MTP" />
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
-
- <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
- android:targetPackage="android.scopedstorage.cts.signature"
- android:label="Signature app tests for scoped storage"/>
-
-</manifest>
diff --git a/hostsidetests/scopedstorage/signature/src/android/scopedstorage/cts/signature/SignatureStorageTest.java b/hostsidetests/scopedstorage/signature/src/android/scopedstorage/cts/signature/SignatureStorageTest.java
deleted file mode 100644
index 0c29dab..0000000
--- a/hostsidetests/scopedstorage/signature/src/android/scopedstorage/cts/signature/SignatureStorageTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2021 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.scopedstorage.cts.signature;
-
-import static android.scopedstorage.cts.lib.TestUtils.adoptShellPermissionIdentity;
-import static android.scopedstorage.cts.lib.TestUtils.assertCanAccessPrivateAppAndroidDataDir;
-import static android.scopedstorage.cts.lib.TestUtils.assertCanAccessPrivateAppAndroidObbDir;
-import static android.scopedstorage.cts.lib.TestUtils.assertMountMode;
-import static android.scopedstorage.cts.lib.TestUtils.dropShellPermissionIdentity;
-
-import static androidx.test.InstrumentationRegistry.getContext;
-
-import android.os.storage.StorageManager;
-
-import androidx.test.runner.AndroidJUnit4;
-
-import com.android.cts.install.lib.TestApp;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Runs the scoped storage tests as Signature app on primary external storage.
- *
- * <p>These tests are also run on a public volume by {@link PublicVolumeTest}.
- */
-@RunWith(AndroidJUnit4.class)
-public class SignatureStorageTest {
- static final String THIS_PACKAGE_NAME = getContext().getPackageName();
- // An app with no permissions
- private static final TestApp APP_B_NO_PERMS = new TestApp("TestAppB",
- "android.scopedstorage.cts.testapp.B.noperms", 1, false,
- "CtsScopedStorageTestAppB.apk");
- /**
- * To help avoid flaky tests, give ourselves a unique nonce to be used for
- * all filesystem paths, so that we don't risk conflicting with previous
- * test runs.
- */
- static final String NONCE = String.valueOf(System.nanoTime());
-
- static final String NONMEDIA_FILE_NAME = "SignatureStorageTest_file_" + NONCE + ".pdf";
- /**
- * Test that signature apps with ACCESS_MTP can access app's private directories in
- * Android/data and Android/obb
- */
- @Test
- @Ignore("b/183377919")
- public void testMTPAppWithPlatformSignatureCanAccessAndroidDirs() throws Exception {
- adoptShellPermissionIdentity(android.Manifest.permission.ACCESS_MTP);
- try {
- assertCanAccessPrivateAppAndroidDataDir(true /*canAccess*/, APP_B_NO_PERMS,
- THIS_PACKAGE_NAME, NONMEDIA_FILE_NAME);
- assertCanAccessPrivateAppAndroidObbDir(true /*canAccess*/, APP_B_NO_PERMS,
- THIS_PACKAGE_NAME, NONMEDIA_FILE_NAME);
- final int uid = getContext().getPackageManager().getPackageUid(THIS_PACKAGE_NAME, 0);
- assertMountMode(THIS_PACKAGE_NAME, uid,
- StorageManager.MOUNT_MODE_EXTERNAL_ANDROID_WRITABLE);
- } finally {
- dropShellPermissionIdentity();
- }
- }
-}
diff --git a/hostsidetests/scopedstorage/src/android/scopedstorage/cts/ScopedStorageTest.java b/hostsidetests/scopedstorage/src/android/scopedstorage/cts/ScopedStorageTest.java
index 48ab8cd..78fc347 100644
--- a/hostsidetests/scopedstorage/src/android/scopedstorage/cts/ScopedStorageTest.java
+++ b/hostsidetests/scopedstorage/src/android/scopedstorage/cts/ScopedStorageTest.java
@@ -76,13 +76,11 @@
import android.Manifest;
import android.app.WallpaperManager;
-import android.content.pm.ProviderInfo;
import android.net.Uri;
import android.os.Environment;
import android.os.ParcelFileDescriptor;
import android.os.storage.StorageManager;
import android.platform.test.annotations.AppModeInstant;
-import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.system.ErrnoException;
import android.system.Os;
@@ -178,33 +176,6 @@
}
@Test
- public void testMTPAppWithoutPlatformSignatureCannotAccessAndroidDirs() throws Exception {
- // TODO(b/183377919): Grant ACCESS_MTP permission via Shell
- assertCanAccessPrivateAppAndroidDataDir(false /*canAccess*/, APP_B_NO_PERMS,
- THIS_PACKAGE_NAME, NONMEDIA_FILE_NAME);
- assertCanAccessPrivateAppAndroidObbDir(false /*canAccess*/, APP_B_NO_PERMS,
- THIS_PACKAGE_NAME, NONMEDIA_FILE_NAME);
- }
-
- /**
- * Test mount modes for ExternalStorageProvider and DownloadsProvider.
- */
- @Test
- public void testExternalStorageProviderAndDownloadsProvider() throws Exception {
- assertWritableMountModeForProvider(DocumentsContract.EXTERNAL_STORAGE_PROVIDER_AUTHORITY);
- assertWritableMountModeForProvider(DocumentsContract.DOWNLOADS_PROVIDER_AUTHORITY);
- }
-
- private void assertWritableMountModeForProvider(String auth) {
- final ProviderInfo provider = getContext().getPackageManager()
- .resolveContentProvider(auth, 0);
- int uid = provider.applicationInfo.uid;
- final String packageName = provider.applicationInfo.packageName;
-
- assertMountMode(packageName, uid, StorageManager.MOUNT_MODE_EXTERNAL_ANDROID_WRITABLE);
- }
-
- @Test
public void testManageExternalStorageCanCreateFilesAnywhere() throws Exception {
pollForManageExternalStorageAllowed();
diff --git a/hostsidetests/statsdatom/src/android/cts/statsdatom/incremental/AppErrorAtomTests.java b/hostsidetests/statsdatom/src/android/cts/statsdatom/incremental/AppErrorAtomTests.java
index 6cc063d..e3204d2 100644
--- a/hostsidetests/statsdatom/src/android/cts/statsdatom/incremental/AppErrorAtomTests.java
+++ b/hostsidetests/statsdatom/src/android/cts/statsdatom/incremental/AppErrorAtomTests.java
@@ -60,6 +60,10 @@
@Before
public void setUp() throws Exception {
+ if (!getDevice().hasFeature(FEATURE_INCREMENTAL_DELIVERY)) {
+ return;
+ }
+ super.setUp();
ConfigUtils.removeConfig(getDevice());
ReportUtils.clearReports(getDevice());
CompatibilityBuildHelper buildHelper = new CompatibilityBuildHelper(mCtsBuild);
@@ -94,6 +98,7 @@
}
getDevice().uninstallPackage(DeviceUtils.STATSD_ATOM_TEST_PKG);
assertFalse(getDevice().isPackageInstalled(DeviceUtils.STATSD_ATOM_TEST_PKG));
+ super.tearDown();
}
public void testAppCrashOnIncremental() throws Exception {
diff --git a/hostsidetests/statsdatom/src/android/cts/statsdatom/lib/DeviceUtils.java b/hostsidetests/statsdatom/src/android/cts/statsdatom/lib/DeviceUtils.java
index e937823..4f2f897 100644
--- a/hostsidetests/statsdatom/src/android/cts/statsdatom/lib/DeviceUtils.java
+++ b/hostsidetests/statsdatom/src/android/cts/statsdatom/lib/DeviceUtils.java
@@ -352,6 +352,10 @@
return device.executeShellCommand("getprop " + prop).replace("\n", "");
}
+ public static boolean isDebuggable(ITestDevice device) throws Exception {
+ return Integer.parseInt(getProperty(device, "ro.debuggable")) == 1;
+ }
+
public static boolean checkDeviceFor(ITestDevice device, String methodName) throws Exception {
try {
runDeviceTestsOnStatsdApp(device, ".Checkers", methodName);
diff --git a/hostsidetests/statsdatom/src/android/cts/statsdatom/statsd/UidAtomTests.java b/hostsidetests/statsdatom/src/android/cts/statsdatom/statsd/UidAtomTests.java
index 0d377ec..81fe295 100644
--- a/hostsidetests/statsdatom/src/android/cts/statsdatom/statsd/UidAtomTests.java
+++ b/hostsidetests/statsdatom/src/android/cts/statsdatom/statsd/UidAtomTests.java
@@ -83,6 +83,7 @@
private static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only";
private static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
private static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture";
+ private static final String FEATURE_TV = "android.hardware.type.television";
private IBuildInfo mCtsBuild;
@@ -208,6 +209,12 @@
}
public void testAppCrashOccurredNative() throws Exception {
+ if (DeviceUtils.hasFeature(getDevice(), FEATURE_TV)
+ && DeviceUtils.isDebuggable(getDevice())) {
+ // Skip TVs that are debuggable because ActivityManager does not properly terminate
+ // the activity in the event of a native crash.
+ return;
+ }
final int atomTag = Atom.APP_CRASH_OCCURRED_FIELD_NUMBER;
ConfigUtils.uploadConfigForPushedAtomWithUid(getDevice(), DeviceUtils.STATSD_ATOM_TEST_PKG,
atomTag, /*uidInAttributionChain=*/false);
diff --git a/tests/AlarmManager/src/android/alarmmanager/cts/ExactAlarmsTest.java b/tests/AlarmManager/src/android/alarmmanager/cts/ExactAlarmsTest.java
index 373b8a2..aa415cd 100644
--- a/tests/AlarmManager/src/android/alarmmanager/cts/ExactAlarmsTest.java
+++ b/tests/AlarmManager/src/android/alarmmanager/cts/ExactAlarmsTest.java
@@ -184,6 +184,8 @@
}
@Test
+ // TODO (b/185181884): Remove once standby buckets can be reliably manipulated from tests.
+ @Ignore("Cannot reliably test bucket manipulation yet")
public void exactAlarmPermissionElevatesBucket() throws Exception {
mDeviceConfigHelper.without("exact_alarm_deny_list").commitAndAwaitPropagation();
diff --git a/tests/app/Android.bp b/tests/app/Android.bp
index f34ff7a..b3e421b 100644
--- a/tests/app/Android.bp
+++ b/tests/app/Android.bp
@@ -88,6 +88,9 @@
min_sdk_version: "14",
manifest: "DownloadManagerApi28Test/AndroidManifest.xml",
test_config: "DownloadManagerApi28Test/AndroidTest.xml",
+ lint: {
+ baseline_filename: "lint-baseline-api-28.xml",
+ },
}
android_test {
@@ -122,6 +125,9 @@
min_sdk_version: "14",
manifest: "DownloadManagerInstallerTest/AndroidManifest.xml",
test_config: "DownloadManagerInstallerTest/AndroidTest.xml",
+ lint: {
+ baseline_filename: "lint-baseline-installer.xml",
+ },
}
android_test {
diff --git a/tests/app/lint-baseline-api-28.xml b/tests/app/lint-baseline-api-28.xml
new file mode 100644
index 0000000..57e7aee
--- /dev/null
+++ b/tests/app/lint-baseline-api-28.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="5" by="lint 4.1.0" client="cli" variant="all" version="4.1.0">
+
+ <issue
+ id="NewApi"
+ message="`@android:style/Theme.Material.Dialog` requires API level 21 (current min is 14)"
+ errorLine1=" <style name="DialogTheme_Test" parent="@android:style/Theme.Material.Dialog">"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/tests/app/app/res/values/styles.xml"
+ line="168"
+ column="36"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="View requires API level 21 (current min is 14): `<Toolbar>`"
+ errorLine1="<Toolbar android:id="@+id/toolbar""
+ errorLine2=" ~~~~~~~">
+ <location
+ file="cts/tests/app/app/res/layout/toolbar_activity.xml"
+ line="23"
+ column="2"/>
+ </issue>
+
+</issues>
diff --git a/tests/app/lint-baseline-installer.xml b/tests/app/lint-baseline-installer.xml
new file mode 100644
index 0000000..57e7aee
--- /dev/null
+++ b/tests/app/lint-baseline-installer.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="5" by="lint 4.1.0" client="cli" variant="all" version="4.1.0">
+
+ <issue
+ id="NewApi"
+ message="`@android:style/Theme.Material.Dialog` requires API level 21 (current min is 14)"
+ errorLine1=" <style name="DialogTheme_Test" parent="@android:style/Theme.Material.Dialog">"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/tests/app/app/res/values/styles.xml"
+ line="168"
+ column="36"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="View requires API level 21 (current min is 14): `<Toolbar>`"
+ errorLine1="<Toolbar android:id="@+id/toolbar""
+ errorLine2=" ~~~~~~~">
+ <location
+ file="cts/tests/app/app/res/layout/toolbar_activity.xml"
+ line="23"
+ column="2"/>
+ </issue>
+
+</issues>
diff --git a/tests/app/lint-baseline.xml b/tests/app/lint-baseline.xml
new file mode 100644
index 0000000..9bd7004
--- /dev/null
+++ b/tests/app/lint-baseline.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="5" by="lint 4.1.0" client="cli" variant="all" version="4.1.0">
+
+ <issue
+ id="NewApi"
+ message="`<vector>` requires API level 21 (current min is 14) or building with Android Gradle plugin 1.4 or higher"
+ errorLine1="<vector xmlns:android="http://schemas.android.com/apk/res/android""
+ errorLine2=" ~~~~~~">
+ <location
+ file="cts/tests/app/res/drawable/ic_android.xml"
+ line="17"
+ column="2"/>
+ </issue>
+
+</issues>
diff --git a/tests/app/shared/lint-baseline.xml b/tests/app/shared/lint-baseline.xml
new file mode 100644
index 0000000..83c4740
--- /dev/null
+++ b/tests/app/shared/lint-baseline.xml
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="5" by="lint 4.1.0" client="cli" variant="all" version="4.1.0">
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 24 (current min is 14): `new java.util.concurrent.CompletableFuture`"
+ errorLine1=" new CompletableFuture<>();"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/tests/app/shared/src/android/app/stubs/shared/AppAccessibilityService.java"
+ line="36"
+ column="13"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 23 (current min is 14): `android.content.Context#getSystemService`"
+ errorLine1=" mWindowManager = getSystemService(WindowManager.class);"
+ errorLine2=" ~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/tests/app/shared/src/android/app/stubs/shared/AppAccessibilityService.java"
+ line="54"
+ column="26"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 24 (current min is 14): `java.util.concurrent.CompletableFuture#obtrudeValue`"
+ errorLine1=" sServiceFuture.obtrudeValue(this);"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/app/shared/src/android/app/stubs/shared/AppAccessibilityService.java"
+ line="71"
+ column="24"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 24 (current min is 14): `new java.util.concurrent.CompletableFuture`"
+ errorLine1=" sServiceFuture = new CompletableFuture<>();"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/tests/app/shared/src/android/app/stubs/shared/AppAccessibilityService.java"
+ line="86"
+ column="26"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 23 (current min is 14): `android.content.Context#getSystemService`"
+ errorLine1=" mNotificationManager = getSystemService(NotificationManager.class);"
+ errorLine2=" ~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/tests/app/shared/src/android/app/stubs/shared/CloseSystemDialogsTestService.java"
+ line="60"
+ column="32"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 26 (current min is 14): `new android.app.Notification.Builder`"
+ errorLine1=" new Notification.Builder(this, NOTIFICATION_CHANNEL_ID)"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/tests/app/shared/src/android/app/stubs/shared/CloseSystemDialogsTestService.java"
+ line="135"
+ column="17"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 16 (current min is 14): `android.app.Notification.Builder#build`"
+ errorLine1=" .build();"
+ errorLine2=" ~~~~~">
+ <location
+ file="cts/tests/app/shared/src/android/app/stubs/shared/CloseSystemDialogsTestService.java"
+ line="138"
+ column="26"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 26 (current min is 14): `new android.app.NotificationChannel`"
+ errorLine1=" NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID,"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/tests/app/shared/src/android/app/stubs/shared/CloseSystemDialogsTestService.java"
+ line="139"
+ column="51"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 26 (current min is 14): `android.app.NotificationManager#createNotificationChannel`"
+ errorLine1=" mNotificationManager.createNotificationChannel(notificationChannel);"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/tests/app/shared/src/android/app/stubs/shared/CloseSystemDialogsTestService.java"
+ line="141"
+ column="30"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 28 (current min is 14): `android.app.Activity#requireViewById`"
+ errorLine1=" get() = requireViewById<FrameLayout>(R.id.content).getChildAt(0)"
+ errorLine2=" ~~~~~~~~~~~~~~~">
+ <location
+ file="cts/tests/app/shared/src/android/app/stubs/shared/NotificationHostActivity.kt"
+ line="39"
+ column="17"/>
+ </issue>
+
+</issues>
diff --git a/tests/app/src/android/app/cts/BroadcastOptionsTest.java b/tests/app/src/android/app/cts/BroadcastOptionsTest.java
index ee976da..c3b4e89 100644
--- a/tests/app/src/android/app/cts/BroadcastOptionsTest.java
+++ b/tests/app/src/android/app/cts/BroadcastOptionsTest.java
@@ -20,6 +20,7 @@
import static junit.framework.Assert.assertNull;
import android.app.BroadcastOptions;
+import android.os.Build;
import android.os.Bundle;
import android.os.PowerExemptionManager;
@@ -146,4 +147,19 @@
assertBroadcastOption_noTemporaryAppAllowList(bo);
}
+
+ @Test
+ public void testMaxManifestReceiverApiLevel() {
+ final BroadcastOptions bo = BroadcastOptions.makeBasic();
+ // No MaxManifestReceiverApiLevel set, the default value should be CUR_DEVELOPMENT.
+ assertEquals(Build.VERSION_CODES.CUR_DEVELOPMENT, bo.getMaxManifestReceiverApiLevel());
+
+ // Set MaxManifestReceiverApiLevel to P.
+ bo.setMaxManifestReceiverApiLevel(Build.VERSION_CODES.P);
+ assertEquals(Build.VERSION_CODES.P, bo.getMaxManifestReceiverApiLevel());
+
+ // Clone the BroadcastOptions and check it too.
+ final BroadcastOptions cloned = cloneViaBundle(bo);
+ assertEquals(Build.VERSION_CODES.P, bo.getMaxManifestReceiverApiLevel());
+ }
}
diff --git a/tests/app/src/android/app/cts/NotificationTemplateTest.kt b/tests/app/src/android/app/cts/NotificationTemplateTest.kt
index c3c85d9..0917767 100644
--- a/tests/app/src/android/app/cts/NotificationTemplateTest.kt
+++ b/tests/app/src/android/app/cts/NotificationTemplateTest.kt
@@ -556,6 +556,28 @@
}
}
+ fun testCallStyle_forIncomingCall_isVideo_hasCorrectActions() {
+ val namedPerson = Person.Builder().setName("Named Person").build()
+ val builder = Notification.Builder(mContext, NOTIFICATION_CHANNEL_ID)
+ .setSmallIcon(R.drawable.ic_media_play)
+ .setStyle(Notification.CallStyle
+ .forIncomingCall(namedPerson, pendingIntent, pendingIntent)
+ .setIsVideo(true))
+ val notification = builder.build()
+ assertThat(notification).isNotNull()
+ assertThat(notification.extras.getBoolean(Notification.EXTRA_CALL_IS_VIDEO)).isTrue()
+ val answerText = mContext.getString(
+ getAndroidRString("call_notification_answer_video_action"))
+ val declineText = mContext.getString(getAndroidRString("call_notification_decline_action"))
+ val hangUpText = mContext.getString(getAndroidRString("call_notification_hang_up_action"))
+ val views = builder.createBigContentView()
+ checkViews(views) {
+ assertThat(requireViewWithText(answerText).visibility).isEqualTo(View.VISIBLE)
+ assertThat(requireViewWithText(declineText).visibility).isEqualTo(View.VISIBLE)
+ assertThat(findViewWithText(hangUpText)).isNull()
+ }
+ }
+
@SmallTest
fun testCallStyle_forOngoingCall_validatesArguments() {
val namedPerson = Person.Builder().setName("Named Person").build()
diff --git a/tests/app/src/android/app/cts/UserHandleTest.java b/tests/app/src/android/app/cts/UserHandleTest.java
index 4f4b829..ec7cc40 100644
--- a/tests/app/src/android/app/cts/UserHandleTest.java
+++ b/tests/app/src/android/app/cts/UserHandleTest.java
@@ -60,15 +60,15 @@
public void testGetUid() {
assertEquals(
UserHandle.getUid(UserHandle.USER_ALL, TEST_APP_ID),
- UserHandle.getUid(UserHandle.ALL, TEST_APP_ID));
+ UserHandle.ALL.getUid(TEST_APP_ID));
assertEquals(
UserHandle.getUid(UserHandle.USER_SYSTEM, TEST_APP_ID),
- UserHandle.getUid(UserHandle.SYSTEM, TEST_APP_ID));
+ UserHandle.SYSTEM.getUid(TEST_APP_ID));
assertEquals(
- UserHandle.getUid(UserHandle.USER_ALL, TEST_APP_ID),
+ UserHandle.ALL.getUid(TEST_APP_ID),
UserHandle.getUid(UserHandle.ALL.getIdentifier(), TEST_APP_ID));
assertEquals(
- UserHandle.getUid(UserHandle.USER_SYSTEM, TEST_APP_ID),
+ UserHandle.SYSTEM.getUid(TEST_APP_ID),
UserHandle.getUid(UserHandle.SYSTEM.getIdentifier(), TEST_APP_ID));
}
}
diff --git a/tests/appsearch/src/com/android/cts/appsearch/external/AppSearchSessionCtsTestBase.java b/tests/appsearch/src/com/android/cts/appsearch/external/AppSearchSessionCtsTestBase.java
index c018951..dd445e0 100644
--- a/tests/appsearch/src/com/android/cts/appsearch/external/AppSearchSessionCtsTestBase.java
+++ b/tests/appsearch/src/com/android/cts/appsearch/external/AppSearchSessionCtsTestBase.java
@@ -57,7 +57,6 @@
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import java.util.ArrayList;
diff --git a/tests/autofillservice/src/android/autofillservice/cts/commontests/ClientSuggestionsCommonTestCase.java b/tests/autofillservice/src/android/autofillservice/cts/commontests/ClientSuggestionsCommonTestCase.java
index af4dea1..442ef4b 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/commontests/ClientSuggestionsCommonTestCase.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/commontests/ClientSuggestionsCommonTestCase.java
@@ -23,10 +23,12 @@
import android.autofillservice.cts.R;
import android.autofillservice.cts.activities.ClientSuggestionsActivity;
import android.autofillservice.cts.testcore.AutofillActivityTestRule;
+import android.autofillservice.cts.testcore.CannedFillResponse;
import android.autofillservice.cts.testcore.CannedFillResponse.CannedDataset;
import android.autofillservice.cts.testcore.ClientAutofillRequestCallback;
import android.autofillservice.cts.testcore.OneTimeTextWatcher;
import android.autofillservice.cts.testcore.UiBot;
+import android.os.Bundle;
import android.platform.test.annotations.AppModeFull;
import android.widget.EditText;
@@ -78,12 +80,162 @@
}
@Test
+ public void testAutoFillNoDatasets_fallbackDefaultService() throws Exception {
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedDataset.Builder()
+ .setField(ID_USERNAME, "dude")
+ .setField(ID_PASSWORD, "sweet")
+ .setPresentation("The Dude", isInlineMode())
+ .build());
+
+ mClientReplier.addResponse(NO_RESPONSE);
+
+ // Trigger autofill.
+ mUiBot.selectByRelativeId(ID_USERNAME);
+ mUiBot.waitForIdle();
+ sReplier.getNextFillRequest();
+ mClientReplier.assertReceivedRequest();
+
+ mActivity.expectAutoFill("dude", "sweet");
+
+ // Select the dataset.
+ mUiBot.selectDataset("The Dude");
+
+ // Check the results.
+ mActivity.assertAutoFilled();
+ }
+
+ @Test
+ @AppModeFull(reason = "testAutoFillNoDatasets_fallbackDefaultService() is enough")
+ public void testManualRequestAfterFallbackDefaultService() throws Exception {
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedDataset.Builder()
+ .setField(ID_USERNAME, "dude")
+ .setField(ID_PASSWORD, "sweet")
+ .setPresentation("The Dude", isInlineMode())
+ .build());
+
+ mClientReplier.addResponse(NO_RESPONSE);
+
+ // Trigger autofill.
+ mUiBot.selectByRelativeId(ID_USERNAME);
+ mUiBot.waitForIdle();
+ sReplier.getNextFillRequest();
+ mClientReplier.assertReceivedRequest();
+
+ // The dataset shown.
+ mUiBot.assertDatasets("The Dude");
+
+ // Set expectations.
+ sReplier.addResponse(new CannedDataset.Builder()
+ .setField(ID_USERNAME, "DUDE")
+ .setField(ID_PASSWORD, "SWEET")
+ .setPresentation("THE DUDE", isInlineMode())
+ .build());
+
+ // Trigger autofill.
+ mActivity.forceAutofillOnUsername();
+ mUiBot.waitForIdle();
+ sReplier.getNextFillRequest();
+ mClientReplier.assertNoUnhandledFillRequests();
+
+ mActivity.expectAutoFill("DUDE", "SWEET");
+
+ // Select the dataset.
+ mUiBot.selectDataset("THE DUDE");
+
+ // Check the results.
+ mActivity.assertAutoFilled();
+ }
+
+ @Test
+ @AppModeFull(reason = "testAutoFillNoDatasets_fallbackDefaultService() is enough")
+ public void testNewFieldAddedAfterFallbackDefaultService() throws Exception {
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedDataset.Builder()
+ .setField(ID_USERNAME, "dude")
+ .setField(ID_PASSWORD, "sweet")
+ .setPresentation("The Dude", isInlineMode())
+ .build());
+
+ mClientReplier.addResponse(NO_RESPONSE);
+
+ // Trigger autofill.
+ mUiBot.selectByRelativeId(ID_USERNAME);
+ mUiBot.waitForIdle();
+ sReplier.getNextFillRequest();
+ mClientReplier.assertReceivedRequest();
+
+ // The dataset shown.
+ mUiBot.assertDatasets("The Dude");
+
+ // Try again, in a field that was added after the first request
+ final EditText child = new EditText(mActivity);
+ child.setId(R.id.empty);
+ mActivity.addChild(child, ID_EMPTY);
+ final OneTimeTextWatcher watcher = new OneTimeTextWatcher("child", child,
+ "new view on the block");
+ child.addTextChangedListener(watcher);
+ sReplier.addResponse(new CannedDataset.Builder()
+ .setField(ID_USERNAME, "dude")
+ .setField(ID_PASSWORD, "sweet")
+ .setField(ID_EMPTY, "new view on the block")
+ .setPresentation("The Dude", isInlineMode())
+ .build());
+
+ mActivity.syncRunOnUiThread(() -> child.requestFocus());
+ mUiBot.waitForIdle();
+ sReplier.getNextFillRequest();
+ mClientReplier.assertNoUnhandledFillRequests();
+
+ mActivity.expectAutoFill("dude", "sweet");
+
+ // Select the dataset.
+ mUiBot.selectDataset("The Dude");
+ mUiBot.waitForIdle();
+
+ // Check the results.
+ mActivity.assertAutoFilled();
+ watcher.assertAutoFilled();
+ }
+
+ @Test
+ public void testNoDatasetsAfterFallbackDefaultService() throws Exception {
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(NO_RESPONSE);
+ mClientReplier.addResponse(NO_RESPONSE);
+
+ // Trigger autofill.
+ mUiBot.selectByRelativeId(ID_USERNAME);
+ mUiBot.waitForIdle();
+
+ mClientReplier.assertReceivedRequest();
+ sReplier.getNextFillRequest();
+
+ // Make sure UI is not shown.
+ mUiBot.assertNoDatasetsEver();
+ }
+
+ @Test
+ @AppModeFull(reason = "testAutoFillOneDataset() is enough")
public void testAutoFillNoDatasets() throws Exception {
// Set service.
enableService();
// Set expectations.
- mClientReplier.addResponse(NO_RESPONSE);
+ setEmptyClientResponse();
// Trigger autofill.
mUiBot.selectByRelativeId(ID_USERNAME);
@@ -101,7 +253,7 @@
enableService();
// Set expectations.
- mClientReplier.addResponse(NO_RESPONSE);
+ setEmptyClientResponse();
// Trigger autofill.
mUiBot.selectByRelativeId(ID_USERNAME);
@@ -151,4 +303,10 @@
}
};
}
+
+ private void setEmptyClientResponse() {
+ mClientReplier.addResponse(new CannedFillResponse.Builder()
+ .setExtras(new Bundle())
+ .build());
+ }
}
diff --git a/tests/camera/src/android/hardware/camera2/cts/CaptureResultTest.java b/tests/camera/src/android/hardware/camera2/cts/CaptureResultTest.java
index c334724..d015959 100644
--- a/tests/camera/src/android/hardware/camera2/cts/CaptureResultTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/CaptureResultTest.java
@@ -669,7 +669,7 @@
// Radial distortion doesn't need to be present for new devices, or old devices that
// opt in the new lens distortion tag.
CameraCharacteristics c = staticInfo.getCharacteristics();
- if (Build.VERSION.FIRST_SDK_INT > Build.VERSION_CODES.O_MR1 ||
+ if (Build.VERSION.DEVICE_INITIAL_SDK_INT > Build.VERSION_CODES.O_MR1 ||
c.get(CameraCharacteristics.LENS_DISTORTION) != null) {
waiverKeys.add(CaptureResult.LENS_RADIAL_DISTORTION);
}
diff --git a/tests/camera/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java b/tests/camera/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java
index e792521..d30349e 100644
--- a/tests/camera/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java
@@ -2549,7 +2549,7 @@
private float[] getLensDistortion(CameraCharacteristics c) {
float[] distortion = null;
float[] newDistortion = c.get(CameraCharacteristics.LENS_DISTORTION);
- if (Build.VERSION.FIRST_SDK_INT > Build.VERSION_CODES.O_MR1 || newDistortion != null) {
+ if (Build.VERSION.DEVICE_INITIAL_SDK_INT > Build.VERSION_CODES.O_MR1 || newDistortion != null) {
// New devices need to use fixed radial distortion definition; old devices can
// opt-in to it
if (newDistortion != null && newDistortion.length == 5) {
diff --git a/tests/devicepolicy/src/android/devicepolicy/cts/DevicePolicyManagerTest.java b/tests/devicepolicy/src/android/devicepolicy/cts/DevicePolicyManagerTest.java
index a029407..c28b2c9 100644
--- a/tests/devicepolicy/src/android/devicepolicy/cts/DevicePolicyManagerTest.java
+++ b/tests/devicepolicy/src/android/devicepolicy/cts/DevicePolicyManagerTest.java
@@ -560,7 +560,6 @@
}
}
-
@RequireFeatures(PackageManager.FEATURE_DEVICE_ADMIN)
@Test
public void getPolicyExemptAppsCanOnlyBeDefinedOnAutomotiveBuilds() throws Exception {
diff --git a/tests/media/src/android/mediav2/cts/EncoderProfileLevelTest.java b/tests/media/src/android/mediav2/cts/EncoderProfileLevelTest.java
index 07e0914..6a5630e 100644
--- a/tests/media/src/android/mediav2/cts/EncoderProfileLevelTest.java
+++ b/tests/media/src/android/mediav2/cts/EncoderProfileLevelTest.java
@@ -797,6 +797,15 @@
Log.w(LOG_TAG, "Skip validation after muxing for mime = " + mMime);
continue;
}
+ // TODO (b/184889671) aac for profile AACObjectHE fails validation
+ // TODO (b/184890155) aac for profile AACObjectLD, AACObjectELD fails validation
+ if (mMime.equals(MediaFormat.MIMETYPE_AUDIO_AAC) &&
+ profile != AACObjectLC) {
+ Log.w(LOG_TAG, "Skip validation after muxing for mime = " + mMime +
+ " profile " + profile);
+ continue;
+ }
+
for (int muxerFormat = MediaMuxer.OutputFormat.MUXER_OUTPUT_FIRST;
muxerFormat <= MediaMuxer.OutputFormat.MUXER_OUTPUT_LAST; muxerFormat++) {
if (!MuxerTest.isCodecContainerPairValid(mMime, muxerFormat)) continue;
diff --git a/tests/netlegacy22.api/Android.mk b/tests/netlegacy22.api/Android.mk
index 53c910d..a2ea8df 100644
--- a/tests/netlegacy22.api/Android.mk
+++ b/tests/netlegacy22.api/Android.mk
@@ -25,9 +25,9 @@
LOCAL_PACKAGE_NAME := CtsNetTestCasesLegacyApi22
-LOCAL_SDK_VERSION := 22
+LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner-axt compatibility-device-util-axt
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner-axt compatibility-device-util-axt android.test.base
# Tag this module as a cts test artifact
LOCAL_COMPATIBILITY_SUITE := cts general-tests
diff --git a/tests/netlegacy22.api/AndroidManifest.xml b/tests/netlegacy22.api/AndroidManifest.xml
index a9411cc..e062e14 100644
--- a/tests/netlegacy22.api/AndroidManifest.xml
+++ b/tests/netlegacy22.api/AndroidManifest.xml
@@ -18,6 +18,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.netlegacy22.api.cts">
+ <uses-sdk android:targetSdkVersion="22" />
+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
diff --git a/tests/netlegacy22.api/OWNERS b/tests/netlegacy22.api/OWNERS
index 3fcbaf3..9b1555e 100644
--- a/tests/netlegacy22.api/OWNERS
+++ b/tests/netlegacy22.api/OWNERS
@@ -1,2 +1,3 @@
# Bug component: 31808
-include ../tests/net/OWNERS
+set noparent
+include platform/packages/modules/Connectivity:/tests/cts/OWNERS
diff --git a/tests/netlegacy22.api/src/android/net/cts/legacy/api22/ConnectivityManagerLegacyTest.java b/tests/netlegacy22.api/src/android/net/cts/legacy/api22/ConnectivityManagerLegacyTest.java
index 4a8a2ad..b7880c7 100644
--- a/tests/netlegacy22.api/src/android/net/cts/legacy/api22/ConnectivityManagerLegacyTest.java
+++ b/tests/netlegacy22.api/src/android/net/cts/legacy/api22/ConnectivityManagerLegacyTest.java
@@ -50,6 +50,7 @@
private static final String HOST_ADDRESS1 = "192.0.2.1";
private static final String HOST_ADDRESS2 = "192.0.2.2";
private static final String HOST_ADDRESS3 = "192.0.2.3";
+ private static final String HOST_ADDRESS4 = "192.0.2.4";
// These are correct as of API level 22, which is what we target here.
private static final int APN_REQUEST_FAILED = 3;
@@ -163,8 +164,13 @@
assertTrue("Couldn't requestRouteToHost using HIPRI.",
mCm.requestRouteToHost(TYPE_MOBILE_HIPRI, ipv4AddrToInt(HOST_ADDRESS1)));
+ assertTrue("Couldn't requestRouteToHostAddress using HIPRI.",
+ mCm.requestRouteToHostAddress(TYPE_MOBILE_HIPRI,
+ InetAddress.getByName(HOST_ADDRESS3)));
+
checkSourceAddress(HOST_ADDRESS1, TYPE_MOBILE);
checkSourceAddress(HOST_ADDRESS2, TYPE_WIFI);
+ checkSourceAddress(HOST_ADDRESS3, TYPE_MOBILE);
// TODO check dns selection
@@ -282,7 +288,7 @@
try {
assertTrue("Network type " + type,
- mCm.requestRouteToHost(type, ipv4AddrToInt(HOST_ADDRESS3)) == expectToWork);
+ mCm.requestRouteToHost(type, ipv4AddrToInt(HOST_ADDRESS4)) == expectToWork);
} catch (Exception e) {
Log.d(TAG, "got exception in requestRouteToHost for type " + type);
assertFalse("Exception received for type " + type, expectToWork);
@@ -291,6 +297,6 @@
//TODO verify route table
}
- assertFalse(mCm.requestRouteToHost(-1, ipv4AddrToInt(HOST_ADDRESS1)));
+ assertFalse(mCm.requestRouteToHost(-1, ipv4AddrToInt(HOST_ADDRESS4)));
}
}
diff --git a/tests/providerui/src/android/providerui/cts/MediaStoreUiTest.java b/tests/providerui/src/android/providerui/cts/MediaStoreUiTest.java
index 49876de..4342810 100644
--- a/tests/providerui/src/android/providerui/cts/MediaStoreUiTest.java
+++ b/tests/providerui/src/android/providerui/cts/MediaStoreUiTest.java
@@ -32,6 +32,7 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.AssetFileDescriptor;
+import android.database.Cursor;
import android.net.Uri;
import android.os.Environment;
import android.os.FileUtils;
@@ -49,6 +50,7 @@
import android.support.test.uiautomator.UiObject;
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.UiObjectNotFoundException;
+import android.support.test.uiautomator.UiScrollable;
import android.support.test.uiautomator.UiSelector;
import android.support.test.uiautomator.Until;
import android.system.Os;
@@ -82,6 +84,8 @@
private static final int REQUEST_CODE = 42;
private static final long TIMEOUT_MILLIS = 30 * DateUtils.SECOND_IN_MILLIS;
+ private static final String MEDIA_DOCUMENTS_PROVIDER_AUTHORITY =
+ "com.android.providers.media.documents";
private Instrumentation mInstrumentation;
private Context mContext;
@@ -91,6 +95,7 @@
private File mFile;
private Uri mMediaStoreUri;
private String mTargetPackageName;
+ private String mDocumentsUiPackageId;
@Parameter(0)
public String mVolumeName;
@@ -105,6 +110,12 @@
mInstrumentation = InstrumentationRegistry.getInstrumentation();
mContext = InstrumentationRegistry.getTargetContext();
mDevice = UiDevice.getInstance(mInstrumentation);
+ final PackageManager pm = mContext.getPackageManager();
+ final Intent intent2 = new Intent(Intent.ACTION_OPEN_DOCUMENT);
+ intent2.addCategory(Intent.CATEGORY_OPENABLE);
+ intent2.setType("*/*");
+ final ResolveInfo ri = pm.resolveActivity(intent2, 0);
+ mDocumentsUiPackageId = ri.activityInfo.packageName;
final Intent intent = new Intent(mContext, GetResultActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -174,7 +185,7 @@
}
@Test
- public void testGetDocumentUri_Symmetry() throws Exception {
+ public void testGetDocumentUri_Symmetry_ExternalStorageProvider() throws Exception {
if (!supportsHardware()) return;
prepareFile();
@@ -192,6 +203,99 @@
assertNotNull(mediaUri);
assertEquals(mMediaStoreUri, mediaUri);
+ assertAccessToMediaUri(mediaUri, mFile);
+ }
+
+ @Test
+ public void testGetMediaUriAccess_MediaDocumentsProvider() throws Exception {
+ if (!supportsHardware()) return;
+
+ prepareFile();
+ clearDocumentsUi();
+ final Intent intent = new Intent();
+ intent.setAction(Intent.ACTION_OPEN_DOCUMENT);
+ intent.addCategory(Intent.CATEGORY_OPENABLE);
+ intent.setType("*/*");
+ mActivity.startActivityForResult(intent, REQUEST_CODE);
+ mDevice.waitForIdle();
+
+ findDocument(mFile.getName()).click();
+ final Result result = mActivity.getResult();
+ final Uri uri = result.data.getData();
+ assertEquals(MEDIA_DOCUMENTS_PROVIDER_AUTHORITY, uri.getAuthority());
+ final Uri mediaUri = MediaStore.getMediaUri(mActivity, uri);
+
+ assertAccessToMediaUri(mediaUri, mFile);
+ }
+
+ private void assertAccessToMediaUri(Uri mediaUri, File file) {
+ final String[] projection = {MediaStore.MediaColumns.DISPLAY_NAME};
+ try (Cursor c = mContext.getContentResolver().query(
+ mediaUri, projection, null, null, null)) {
+ assertTrue(c.moveToFirst());
+ assertEquals(file.getName(), c.getString(0));
+ }
+ }
+
+ /**
+ * Clears the DocumentsUI package data.
+ */
+ protected void clearDocumentsUi() throws Exception {
+ executeShellCommand("pm clear " + getDocumentsUiPackageId());
+ }
+
+ private UiObject findDocument(String label) throws UiObjectNotFoundException {
+ final UiSelector docList = new UiSelector().resourceId(getDocumentsUiPackageId()
+ + ":id/dir_list");
+
+ // Wait for the first list item to appear
+ assertTrue("First list item",
+ new UiObject(docList.childSelector(new UiSelector()))
+ .waitForExists(TIMEOUT_MILLIS));
+
+ try {
+ //Enforce to set the list mode
+ //Because UiScrollable can't reach the real bottom (when WEB_LINKABLE_FILE item)
+ // in grid mode when screen landscape mode
+ new UiObject(new UiSelector().resourceId(getDocumentsUiPackageId()
+ + ":id/sub_menu_list")).click();
+ mDevice.waitForIdle();
+ }catch (UiObjectNotFoundException e){
+ //do nothing, already be in list mode.
+ }
+
+ // Repeat swipe gesture to find our item
+ // (UiScrollable#scrollIntoView does not seem to work well with SwipeRefreshLayout)
+ UiObject targetObject = new UiObject(docList.childSelector(new UiSelector().text(label)));
+ UiObject saveButton = findSaveButton();
+ int stepLimit = 10;
+ while (stepLimit-- > 0) {
+ if (targetObject.exists()) {
+ boolean targetObjectFullyVisible = !saveButton.exists()
+ || targetObject.getVisibleBounds().bottom
+ <= saveButton.getVisibleBounds().top;
+ if (targetObjectFullyVisible) {
+ break;
+ }
+ }
+
+ mDevice.swipe(/* startX= */ mDevice.getDisplayWidth() / 2,
+ /* startY= */ mDevice.getDisplayHeight() / 2,
+ /* endX= */ mDevice.getDisplayWidth() / 2,
+ /* endY= */ 0,
+ /* steps= */ 40);
+ }
+ return targetObject;
+ }
+
+ private UiObject findSaveButton() throws UiObjectNotFoundException {
+ return new UiObject(new UiSelector().resourceId(
+ getDocumentsUiPackageId() + ":id/container_save")
+ .childSelector(new UiSelector().resourceId("android:id/button1")));
+ }
+
+ private String getDocumentsUiPackageId() {
+ return mDocumentsUiPackageId;
}
private boolean supportsHardware() {
diff --git a/tests/signature/api-check/Android.bp b/tests/signature/api-check/Android.bp
index 3f686c2..5e7ff3b 100644
--- a/tests/signature/api-check/Android.bp
+++ b/tests/signature/api-check/Android.bp
@@ -70,12 +70,6 @@
static_libs: ["cts-api-signature-test"],
}
-// Access the hiddenapi-flags.csv file produced by the build.
-hiddenapi_flags {
- name: "cts-hiddenapi-flags-csv",
- filename: "hiddenapi-flags.csv",
-}
-
filegroup {
name: "cts-api-hiddenapi-filter-csv",
srcs: [
@@ -88,7 +82,7 @@
name: "hiddenapi-blocklist-check-defaults",
defaults: ["signature-api-check-defaults"],
java_resources: [
- ":cts-hiddenapi-flags-csv",
+ ":platform-bootclasspath{hiddenapi-flags.csv}",
":cts-api-hiddenapi-filter-csv"
],
jni_libs: [
diff --git a/tests/tests/accounts/common/lint-baseline.xml b/tests/tests/accounts/common/lint-baseline.xml
new file mode 100644
index 0000000..6a95c6c
--- /dev/null
+++ b/tests/tests/accounts/common/lint-baseline.xml
@@ -0,0 +1,697 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="5" by="lint 4.1.0" client="cli" variant="all" version="4.1.0">
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 5 (current min is 1): `android.accounts.AccountManager#get`"
+ errorLine1=" AccountManager am = AccountManager.get(context);"
+ errorLine2=" ~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/AuthenticatorContentProvider.java"
+ line="81"
+ column="44"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 5 (current min is 1): `android.accounts.AccountManager#getAuthenticatorTypes`"
+ errorLine1=" AuthenticatorDescription[] authenticators = am.getAuthenticatorTypes();"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/AuthenticatorContentProvider.java"
+ line="82"
+ column="56"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.AuthenticatorDescription#packageName`"
+ errorLine1=" if (a.packageName.equals(context.getPackageName())) {"
+ errorLine2=" ~~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/AuthenticatorContentProvider.java"
+ line="88"
+ column="17"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 5 (current min is 1): `new android.accounts.Account`"
+ errorLine1=" Account account = new Account(name, a.type);"
+ errorLine2=" ~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/AuthenticatorContentProvider.java"
+ line="90"
+ column="39"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.AuthenticatorDescription#type`"
+ errorLine1=" Account account = new Account(name, a.type);"
+ errorLine2=" ~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/AuthenticatorContentProvider.java"
+ line="90"
+ column="57"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 5 (current min is 1): `android.accounts.AccountManager#addAccountExplicitly`"
+ errorLine1=" am.addAccountExplicitly(account, Fixtures.PREFIX_PASSWORD + name, null);"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/AuthenticatorContentProvider.java"
+ line="91"
+ column="24"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 5 (current min is 1): `android.accounts.AccountManager#get`"
+ errorLine1=" AccountManager am = AccountManager.get(context);"
+ errorLine2=" ~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/AuthenticatorContentProvider.java"
+ line="99"
+ column="44"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 5 (current min is 1): `android.accounts.AccountManager#getAuthenticatorTypes`"
+ errorLine1=" AuthenticatorDescription[] authenticators = am.getAuthenticatorTypes();"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/AuthenticatorContentProvider.java"
+ line="100"
+ column="56"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.AuthenticatorDescription#packageName`"
+ errorLine1=" if (a.packageName.equals(context.getPackageName())) {"
+ errorLine2=" ~~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/AuthenticatorContentProvider.java"
+ line="106"
+ column="17"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 5 (current min is 1): `android.accounts.AccountManager#getAccountsByType`"
+ errorLine1=" Account[] accountsToRemove = am.getAccountsByType(a.type);"
+ errorLine2=" ~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/AuthenticatorContentProvider.java"
+ line="107"
+ column="49"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.AuthenticatorDescription#type`"
+ errorLine1=" Account[] accountsToRemove = am.getAccountsByType(a.type);"
+ errorLine2=" ~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/AuthenticatorContentProvider.java"
+ line="107"
+ column="67"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 22 (current min is 1): `android.accounts.AccountManager#removeAccountExplicitly`"
+ errorLine1=" am.removeAccountExplicitly(account);"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/AuthenticatorContentProvider.java"
+ line="109"
+ column="24"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Cast from `Account` to `Parcelable` requires API level 5 (current min is 1)"
+ errorLine1=" out.writeParcelable(account, flags);"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/tx/ConfirmCredentialsTx.java"
+ line="50"
+ column="29"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 5 (current min is 1): `new android.accounts.Account`"
+ errorLine1=" public static final Account ACCOUNT_UNAFFILIATED_FIXTURE_SUCCESS = new Account("
+ errorLine2=" ~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/Fixtures.java"
+ line="53"
+ column="72"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 5 (current min is 1): `new android.accounts.Account`"
+ errorLine1=" public static final Account ACCOUNT_DEFAULT = new Account("
+ errorLine2=" ~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/Fixtures.java"
+ line="57"
+ column="51"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Cast from `Account` to `Parcelable` requires API level 5 (current min is 1)"
+ errorLine1=" out.writeParcelable(account, flags);"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/tx/GetAccountRemovalAllowedTx.java"
+ line="46"
+ column="29"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Cast from `Account` to `Parcelable` requires API level 5 (current min is 1)"
+ errorLine1=" out.writeParcelable(account, flags);"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/tx/GetAuthTokenTx.java"
+ line="54"
+ column="29"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Cast from `Account` to `Parcelable` requires API level 5 (current min is 1)"
+ errorLine1=" out.writeParcelable(account, flags);"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/tx/HasFeaturesTx.java"
+ line="57"
+ column="29"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Cast from `Account` to `Parcelable` requires API level 5 (current min is 1)"
+ errorLine1=" out.writeParcelable(account, flags);"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/tx/StartUpdateCredentialsSessionTx.java"
+ line="50"
+ column="29"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Class requires API level 5 (current min is 1): `android.accounts.AbstractAccountAuthenticator`"
+ errorLine1="public class TestAccountAuthenticator extends AbstractAccountAuthenticator {"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="39"
+ column="47"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 5 (current min is 1): `new android.accounts.AbstractAccountAuthenticator`"
+ errorLine1=" super(context);"
+ errorLine2=" ~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="47"
+ column="9"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Cast from `AccountAuthenticatorResponse` to `Parcelable` requires API level 5 (current min is 1)"
+ errorLine1=" intent.putExtra(Fixtures.KEY_CALLBACK, response);"
+ errorLine2=" ~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="89"
+ column="52"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 5 (current min is 1): `android.accounts.AccountAuthenticatorResponse#onResult`"
+ errorLine1=" response.onResult(result);"
+ errorLine2=" ~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="101"
+ column="26"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#type`"
+ errorLine1=" if (!mAccountType.equals(account.type)) {"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="111"
+ column="34"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#name`"
+ errorLine1=" if (account.name.startsWith(Fixtures.PREFIX_NAME_SUCCESS)) {"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="120"
+ column="13"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#name`"
+ errorLine1=" result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="123"
+ column="63"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#type`"
+ errorLine1=" result.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type);"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="124"
+ column="63"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#name`"
+ errorLine1=" } else if (account.name.startsWith(Fixtures.PREFIX_NAME_INTERVENE)) {"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="125"
+ column="20"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#name`"
+ errorLine1=" eventualActivityResultData.putExtra(AccountManager.KEY_ACCOUNT_NAME, account.name);"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="129"
+ column="82"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#type`"
+ errorLine1=" eventualActivityResultData.putExtra(AccountManager.KEY_ACCOUNT_TYPE, account.type);"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="130"
+ column="82"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Cast from `AccountAuthenticatorResponse` to `Parcelable` requires API level 5 (current min is 1)"
+ errorLine1=" intent.putExtra(Fixtures.KEY_CALLBACK, response);"
+ errorLine2=" ~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="135"
+ column="52"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 5 (current min is 1): `android.accounts.AccountAuthenticatorResponse#onResult`"
+ errorLine1=" response.onResult(result);"
+ errorLine2=" ~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="147"
+ column="26"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#type`"
+ errorLine1=" if (!mAccountType.equals(account.type)) {"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="158"
+ column="34"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#name`"
+ errorLine1=" if (account.name.startsWith(Fixtures.PREFIX_NAME_SUCCESS)) {"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="167"
+ column="13"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#name`"
+ errorLine1=" result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="174"
+ column="63"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#type`"
+ errorLine1=" result.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type);"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="175"
+ column="63"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#name`"
+ errorLine1=" } else if (account.name.startsWith(Fixtures.PREFIX_NAME_INTERVENE)) {"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="176"
+ column="20"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#name`"
+ errorLine1=" eventualActivityResultData.putExtra(AccountManager.KEY_ACCOUNT_NAME, account.name);"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="184"
+ column="82"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#type`"
+ errorLine1=" eventualActivityResultData.putExtra(AccountManager.KEY_ACCOUNT_TYPE, account.type);"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="185"
+ column="82"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Cast from `AccountAuthenticatorResponse` to `Parcelable` requires API level 5 (current min is 1)"
+ errorLine1=" intent.putExtra(Fixtures.KEY_CALLBACK, response);"
+ errorLine2=" ~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="190"
+ column="52"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 5 (current min is 1): `android.accounts.AccountAuthenticatorResponse#onResult`"
+ errorLine1=" response.onResult(result);"
+ errorLine2=" ~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="203"
+ column="26"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#type`"
+ errorLine1=" if (!mAccountType.equals(account.type)) {"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="222"
+ column="34"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#name`"
+ errorLine1=" if (account.name.startsWith(Fixtures.PREFIX_NAME_SUCCESS)) {"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="231"
+ column="13"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#name`"
+ errorLine1=" result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="233"
+ column="63"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#type`"
+ errorLine1=" result.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type);"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="234"
+ column="63"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#name`"
+ errorLine1=" } else if (account.name.startsWith(Fixtures.PREFIX_NAME_INTERVENE)) {"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="235"
+ column="20"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#name`"
+ errorLine1=" eventualActivityResultData.putExtra(AccountManager.KEY_ACCOUNT_NAME, account.name);"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="238"
+ column="82"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#type`"
+ errorLine1=" eventualActivityResultData.putExtra(AccountManager.KEY_ACCOUNT_TYPE, account.type);"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="239"
+ column="82"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Cast from `AccountAuthenticatorResponse` to `Parcelable` requires API level 5 (current min is 1)"
+ errorLine1=" intent.putExtra(Fixtures.KEY_CALLBACK, response);"
+ errorLine2=" ~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="244"
+ column="52"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 5 (current min is 1): `android.accounts.AccountAuthenticatorResponse#onResult`"
+ errorLine1=" response.onResult(result);"
+ errorLine2=" ~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="256"
+ column="26"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#type`"
+ errorLine1=" if (!mAccountType.equals(account.type)) {"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="266"
+ column="34"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#name`"
+ errorLine1=" if (account.name.startsWith(Fixtures.PREFIX_NAME_SUCCESS)) {"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="274"
+ column="13"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#name`"
+ errorLine1=" } else if (account.name.startsWith(Fixtures.PREFIX_NAME_INTERVENE)) {"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="277"
+ column="20"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Cast from `AccountAuthenticatorResponse` to `Parcelable` requires API level 5 (current min is 1)"
+ errorLine1=" intent.putExtra(Fixtures.KEY_CALLBACK, response);"
+ errorLine2=" ~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="284"
+ column="52"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 5 (current min is 1): `android.accounts.AccountAuthenticatorResponse#onResult`"
+ errorLine1=" response.onResult(result);"
+ errorLine2=" ~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="295"
+ column="26"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#type`"
+ errorLine1=" if (!mAccountType.equals(account.type)) {"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAccountAuthenticator.java"
+ line="365"
+ column="34"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 5 (current min is 1): `android.accounts.AccountAuthenticatorResponse#onResult`"
+ errorLine1=" response.onResult(result.getExtras());"
+ errorLine2=" ~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestAuthenticatorActivity.java"
+ line="33"
+ column="22"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Class requires API level 5 (current min is 1): `android.accounts.AbstractAccountAuthenticator`"
+ errorLine1="public class TestDefaultAuthenticator extends AbstractAccountAuthenticator {"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestDefaultAuthenticator.java"
+ line="34"
+ column="47"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Call requires API level 5 (current min is 1): `new android.accounts.AbstractAccountAuthenticator`"
+ errorLine1=" super(context);"
+ errorLine2=" ~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestDefaultAuthenticator.java"
+ line="39"
+ column="9"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#type`"
+ errorLine1=" if (!mAccountType.equals(account.type)) {"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestDefaultAuthenticator.java"
+ line="108"
+ column="34"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#name`"
+ errorLine1=" result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestDefaultAuthenticator.java"
+ line="112"
+ column="59"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Field requires API level 5 (current min is 1): `android.accounts.Account#type`"
+ errorLine1=" result.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type);"
+ errorLine2=" ~~~~~~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/TestDefaultAuthenticator.java"
+ line="113"
+ column="59"/>
+ </issue>
+
+ <issue
+ id="NewApi"
+ message="Cast from `Account` to `Parcelable` requires API level 5 (current min is 1)"
+ errorLine1=" out.writeParcelable(account, flags);"
+ errorLine2=" ~~~~~~~">
+ <location
+ file="cts/tests/tests/accounts/common/src/android/accounts/cts/common/tx/UpdateCredentialsTx.java"
+ line="54"
+ column="29"/>
+ </issue>
+
+</issues>
diff --git a/tests/tests/app.usage/Android.bp b/tests/tests/app.usage/Android.bp
index 48c225e..29ba591 100644
--- a/tests/tests/app.usage/Android.bp
+++ b/tests/tests/app.usage/Android.bp
@@ -37,6 +37,5 @@
test_suites: [
"cts",
"general-tests",
- "mts"
],
}
diff --git a/tests/tests/app.usage/AndroidTest.xml b/tests/tests/app.usage/AndroidTest.xml
index 26b799d..3dbfb93 100644
--- a/tests/tests/app.usage/AndroidTest.xml
+++ b/tests/tests/app.usage/AndroidTest.xml
@@ -32,8 +32,4 @@
<option name="runtime-hint" value="1m47s" />
<option name="hidden-api-checks" value="false" />
</test>
-
- <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController">
- <option name="mainline-module-package-name" value="com.google.android.extservices" />
- </object>
</configuration>
diff --git a/tests/tests/app.usage/TestApp1/Android.bp b/tests/tests/app.usage/TestApp1/Android.bp
index ad9f9c8..cba5df5 100644
--- a/tests/tests/app.usage/TestApp1/Android.bp
+++ b/tests/tests/app.usage/TestApp1/Android.bp
@@ -37,7 +37,6 @@
test_suites: [
"cts",
"general-tests",
- "mts"
],
sdk_version: "test_current"
}
diff --git a/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java b/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
index cd44651..c1a1eb7 100644
--- a/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
+++ b/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
@@ -238,7 +238,7 @@
@AppModeFull(reason = "No usage events access in instant apps")
@Test
- public void testLastTimeComponentUsed_launchActivity() throws Exception {
+ public void testLastAnyTimeComponentUsed_launchActivity() throws Exception {
mUiDevice.wakeUp();
dismissKeyguard(); // also want to start out with the keyguard dismissed.
@@ -250,14 +250,14 @@
startTime, endTime);
final UsageStats stats = map.get(mTargetPackage);
assertNotNull(stats);
- final long lastTimeComponentUsed = stats.getLastTimeComponentUsed();
+ final long lastTimeComponentUsed = stats.getLastTimeAnyComponentUsed();
assertLessThan(startTime, lastTimeComponentUsed);
assertLessThan(lastTimeComponentUsed, endTime);
}
@AppModeFull(reason = "No usage events access in instant apps")
@Test
- public void testLastTimeComponentUsedGlobal_launchActivity() throws Exception {
+ public void testLastTimeAnyComponentUsedGlobal_launchActivity() throws Exception {
mUiDevice.wakeUp();
dismissKeyguard();
diff --git a/tests/tests/appenumeration/src/android/appenumeration/cts/AppEnumerationTests.java b/tests/tests/appenumeration/src/android/appenumeration/cts/AppEnumerationTests.java
index 4d58580..32ab7ab 100644
--- a/tests/tests/appenumeration/src/android/appenumeration/cts/AppEnumerationTests.java
+++ b/tests/tests/appenumeration/src/android/appenumeration/cts/AppEnumerationTests.java
@@ -630,7 +630,7 @@
public void broadcastAdded_notVisibleDoesNotReceive() throws Exception {
final Result result = sendCommand(QUERIES_NOTHING, TARGET_FILTERS,
/* targetUid */ INVALID_UID, /* intentExtra */ null,
- Constants.ACTION_AWAIT_PACKAGE_ADDED, /* waitForReady */ false);
+ Constants.ACTION_AWAIT_PACKAGE_ADDED, /* waitForReady */ true);
runShellCommand("pm install " + TARGET_FILTERS_APK);
try {
result.await();
@@ -644,7 +644,7 @@
public void broadcastAdded_visibleReceives() throws Exception {
final Result result = sendCommand(QUERIES_ACTIVITY_ACTION, TARGET_FILTERS,
/* targetUid */ INVALID_UID, /* intentExtra */ null,
- Constants.ACTION_AWAIT_PACKAGE_ADDED, /* waitForReady */ false);
+ Constants.ACTION_AWAIT_PACKAGE_ADDED, /* waitForReady */ true);
runShellCommand("pm install " + TARGET_FILTERS_APK);
try {
Assert.assertEquals(TARGET_FILTERS,
@@ -658,7 +658,7 @@
public void reinstallTarget_broadcastRemoved_notVisibleDoesNotReceive() throws Exception {
final Result result = sendCommand(QUERIES_NOTHING, TARGET_FILTERS,
/* targetUid */ INVALID_UID, /* intentExtra */ null,
- Constants.ACTION_AWAIT_PACKAGE_REMOVED, /* waitForReady */ false);
+ Constants.ACTION_AWAIT_PACKAGE_REMOVED, /* waitForReady */ true);
runShellCommand("pm install " + TARGET_FILTERS_APK);
try {
result.await();
@@ -672,7 +672,7 @@
public void reinstallTarget_broadcastRemoved_visibleReceives() throws Exception {
final Result result = sendCommand(QUERIES_ACTIVITY_ACTION, TARGET_FILTERS,
/* targetUid */ INVALID_UID, /* intentExtra */ null,
- Constants.ACTION_AWAIT_PACKAGE_REMOVED, /* waitForReady */ false);
+ Constants.ACTION_AWAIT_PACKAGE_REMOVED, /* waitForReady */ true);
runShellCommand("pm install " + TARGET_FILTERS_APK);
try {
Assert.assertEquals(TARGET_FILTERS,
@@ -687,7 +687,7 @@
ensurePackageIsInstalled(TARGET_STUB, TARGET_STUB_APK);
final Result result = sendCommand(QUERIES_NOTHING, TARGET_STUB,
/* targetUid */ INVALID_UID, /* intentExtra */ null,
- Constants.ACTION_AWAIT_PACKAGE_REMOVED, /* waitForReady */ false);
+ Constants.ACTION_AWAIT_PACKAGE_REMOVED, /* waitForReady */ true);
runShellCommand("pm uninstall " + TARGET_STUB);
try {
result.await();
@@ -702,7 +702,7 @@
ensurePackageIsInstalled(TARGET_STUB, TARGET_STUB_APK);
final Result result = sendCommand(QUERIES_NOTHING_PERM, TARGET_STUB,
/* targetUid */ INVALID_UID, /* intentExtra */ null,
- Constants.ACTION_AWAIT_PACKAGE_REMOVED, /* waitForReady */ false);
+ Constants.ACTION_AWAIT_PACKAGE_REMOVED, /* waitForReady */ true);
runShellCommand("pm uninstall " + TARGET_STUB);
try {
Assert.assertEquals(TARGET_STUB,
diff --git a/tests/tests/appop/src/android/app/appops/cts/AppOpsLoggingTest.kt b/tests/tests/appop/src/android/app/appops/cts/AppOpsLoggingTest.kt
index 8a99f0c..c044b6b 100644
--- a/tests/tests/appop/src/android/app/appops/cts/AppOpsLoggingTest.kt
+++ b/tests/tests/appop/src/android/app/appops/cts/AppOpsLoggingTest.kt
@@ -110,7 +110,6 @@
)
@AppModeFull(reason = "Test relies on other app to connect to. Instant apps can't see other apps")
-@Ignore("b/184491462")
class AppOpsLoggingTest {
private val context = InstrumentationRegistry.getInstrumentation().targetContext as Context
private val appOpsManager = context.getSystemService(AppOpsManager::class.java)
@@ -669,6 +668,7 @@
* Realistic end-to-end test for recording audio
*/
@Test
+ @Ignore
fun recordAudio() {
val ar = AudioRecord.Builder()
.setContext(context.createAttributionContext(TEST_ATTRIBUTION_TAG)).build()
@@ -689,6 +689,7 @@
* Realistic end-to-end test for recording low latency audio
*/
@Test
+ @Ignore
fun recordAudioLowLatency() {
val ar = AudioRecord.Builder()
.setAudioAttributes(AudioAttributes.Builder()
@@ -712,6 +713,7 @@
* Realistic end-to-end test for recording using the public native API with shared, low latency
*/
@Test
+ @Ignore
fun recordAudioNativeLowLatencyShared() {
nativeStartStopAudioRecord(isShared = true, isLowLatency = true,
packageName = context.packageName, attributionTag = TEST_ATTRIBUTION_TAG)
@@ -727,6 +729,7 @@
* mode
*/
@Test
+ @Ignore
fun recordAudioNativeLowLatencyExclusive() {
nativeStartStopAudioRecord(isShared = false, isLowLatency = true,
packageName = context.packageName, attributionTag = TEST_ATTRIBUTION_TAG)
@@ -742,6 +745,7 @@
* mode
*/
@Test
+ @Ignore
fun recordAudioNativeShared() {
nativeStartStopAudioRecord(isShared = true, isLowLatency = false,
packageName = context.packageName, attributionTag = TEST_ATTRIBUTION_TAG)
diff --git a/tests/tests/car/Android.bp b/tests/tests/car/Android.bp
index c3e5890..56699e2 100644
--- a/tests/tests/car/Android.bp
+++ b/tests/tests/car/Android.bp
@@ -27,12 +27,16 @@
// TODO: remove once Android migrates to JUnit 4.12,
// which provides assertThrows
"testng",
+ "libprotobuf-java-lite",
],
libs: [
"android.test.base",
"android.car-test-stubs",
],
- srcs: ["src/**/*.java"],
+ srcs: [
+ "src/**/*.java",
+ ":rotary-service-proto-source",
+ ],
// Tag this module as a cts test artifact
test_suites: [
"cts",
diff --git a/tests/tests/car/src/android/car/cts/CarRotaryImeTest.java b/tests/tests/car/src/android/car/cts/CarRotaryImeTest.java
new file mode 100644
index 0000000..d1f9001
--- /dev/null
+++ b/tests/tests/car/src/android/car/cts/CarRotaryImeTest.java
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2021 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.car.cts;
+
+import static android.provider.Settings.Secure.ENABLED_INPUT_METHODS;
+
+import static com.google.common.truth.Truth.assertWithMessage;
+
+import static org.junit.Assume.assumeTrue;
+
+import android.app.UiAutomation;
+import android.content.ComponentName;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.os.ParcelFileDescriptor;
+import android.provider.Settings;
+import android.view.accessibility.AccessibilityManager;
+
+import androidx.annotation.NonNull;
+import androidx.test.platform.app.InstrumentationRegistry;
+
+import com.android.car.rotary.RotaryProtos;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Arrays;
+
+public final class CarRotaryImeTest {
+ private static final ComponentName ROTARY_SERVICE_COMPONENT_NAME =
+ ComponentName.unflattenFromString("com.android.car.rotary/.RotaryService");
+
+ /** Hidden secure setting for disabled system IMEs. */
+ private static final String DISABLED_SYSTEM_INPUT_METHODS = "disabled_system_input_methods";
+
+ private final Context mContext = InstrumentationRegistry.getInstrumentation().getContext();
+ private final ContentResolver mContentResolver = mContext.getContentResolver();
+ private final AccessibilityManager mAccessibilityManager =
+ mContext.getSystemService(AccessibilityManager.class);
+
+ /**
+ * Tests that, if a rotary input method is specified via the {@code rotary_input_method} string
+ * resource, it's the component name of an existing IME.
+ */
+ @Test
+ public void rotaryInputMethodValidIfSpecified() throws Exception {
+ assumeHasRotaryService();
+
+ String rotaryInputMethod = dumpsysRotaryServiceProto().getRotaryInputMethod();
+
+ assumeTrue("Rotary input method not specified, skipping test",
+ rotaryInputMethod != null && !rotaryInputMethod.isEmpty());
+ assertWithMessage("isValidIme(" + rotaryInputMethod + ")")
+ .that(isValidIme(rotaryInputMethod)).isTrue();
+ }
+
+ /**
+ * The default touch input method must be specified via the {@code default_touch_input_method}
+ * string resource, and it must be the component name of an existing IME.
+ */
+ @Ignore("TODO(b/184390443)")
+ @Test
+ public void defaultTouchInputMethodSpecifiedAndValid() throws Exception {
+ assumeHasRotaryService();
+
+ String defaultTouchInputMethod = dumpsysRotaryServiceProto().getDefaultTouchInputMethod();
+
+ assertWithMessage("defaultTouchInputMethod").that(defaultTouchInputMethod).isNotEmpty();
+ assertWithMessage("isValidIme(" + defaultTouchInputMethod + ")")
+ .that(isValidIme(defaultTouchInputMethod)).isTrue();
+ }
+
+ private RotaryProtos.RotaryService dumpsysRotaryServiceProto() throws IOException {
+ UiAutomation uiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation(
+ UiAutomation.FLAG_DONT_SUPPRESS_ACCESSIBILITY_SERVICES);
+ ParcelFileDescriptor pfd = uiAutomation.executeShellCommand(
+ "dumpsys activity service " + ROTARY_SERVICE_COMPONENT_NAME.flattenToString()
+ + " proto");
+ try (FileInputStream fis = new ParcelFileDescriptor.AutoCloseInputStream(pfd)) {
+ // TODO(b/184973707): Remove this code once ActivityManager supports dumping a service
+ // in proto format.
+ // Skip over:
+ // SERVICE com.android.car.rotary/.RotaryService ... pid=... user=10
+ // __Client:
+ // ____
+ // where underscores represent spaces.
+ byte[] buffer = new byte[1];
+ while (fis.read(buffer) > 0 && buffer[0] != ':') {
+ // Do nothing.
+ }
+ // Skip carriage return and four space indent.
+ fis.skip(5);
+
+ return RotaryProtos.RotaryService.parseFrom(fis);
+ }
+ }
+
+ private void assumeHasRotaryService() {
+ assumeTrue("Rotary service not enabled; skipping test",
+ mAccessibilityManager.getInstalledAccessibilityServiceList().stream().anyMatch(
+ accessibilityServiceInfo ->
+ ROTARY_SERVICE_COMPONENT_NAME.equals(
+ accessibilityServiceInfo.getComponentName())));
+ }
+
+ /** Returns whether {@code flattenedComponentName} is an installed input method. */
+ private boolean isValidIme(@NonNull String flattenedComponentName) {
+ ComponentName componentName = ComponentName.unflattenFromString(flattenedComponentName);
+ return imeSettingContains(ENABLED_INPUT_METHODS, componentName)
+ || imeSettingContains(DISABLED_SYSTEM_INPUT_METHODS, componentName);
+ }
+
+ /**
+ * Fetches the secure setting {@code settingName} containing a colon-separated list of IMEs with
+ * their subtypes and returns whether {@code componentName} is one of the IMEs.
+ */
+ private boolean imeSettingContains(@NonNull String settingName,
+ @NonNull ComponentName componentName) {
+ String colonSeparatedComponentNamesWithSubtypes =
+ Settings.Secure.getString(mContentResolver, settingName);
+ if (colonSeparatedComponentNamesWithSubtypes == null) {
+ return false;
+ }
+ return Arrays.stream(colonSeparatedComponentNamesWithSubtypes.split(":"))
+ .map(componentNameWithSubtypes -> componentNameWithSubtypes.split(";"))
+ .anyMatch(componentNameAndSubtypes -> componentNameAndSubtypes.length >= 1
+ && componentName.equals(
+ ComponentName.unflattenFromString(componentNameAndSubtypes[0])));
+ }
+}
diff --git a/tests/tests/carrierapi/src/android/carrierapi/cts/CarrierApiTest.java b/tests/tests/carrierapi/src/android/carrierapi/cts/CarrierApiTest.java
index da46842..4b67d90 100644
--- a/tests/tests/carrierapi/src/android/carrierapi/cts/CarrierApiTest.java
+++ b/tests/tests/carrierapi/src/android/carrierapi/cts/CarrierApiTest.java
@@ -685,7 +685,7 @@
// invalid. Any p2 values that produce non '9000'/'62xx'/'63xx' status words are treated as
// an error and the channel is not opened. Due to compatibility issues with older devices,
// this check is only enabled for new devices launching on Q+.
- if (Build.VERSION.FIRST_SDK_INT >= Build.VERSION_CODES.Q) {
+ if (Build.VERSION.DEVICE_INITIAL_SDK_INT >= Build.VERSION_CODES.Q) {
int p2 = 0xF0;
IccOpenLogicalChannelResponse response =
mTelephonyManager.iccOpenLogicalChannel("", p2);
@@ -767,7 +767,7 @@
// previous SELECT command. Some devices that launched before Q return TPDUs (instead of
// APDUs) - these devices must issue a subsequent GET RESPONSE command to get the FCP
// template.
- if (Build.VERSION.FIRST_SDK_INT < Build.VERSION_CODES.Q) {
+ if (Build.VERSION.DEVICE_INITIAL_SDK_INT < Build.VERSION_CODES.Q) {
// Conditionally need to send GET RESPONSE apdu based on response from
// TelephonyManager
if (response.startsWith(STATUS_BYTES_REMAINING)) {
diff --git a/tests/tests/content/AndroidTest.xml b/tests/tests/content/AndroidTest.xml
index 9153d34..2ccc20e 100644
--- a/tests/tests/content/AndroidTest.xml
+++ b/tests/tests/content/AndroidTest.xml
@@ -100,7 +100,6 @@
<option name="test-file-name" value="CtsContentPartiallyDirectBootAwareTestApp.apk" />
<option name="test-file-name" value="CtsSyncAccountAccessStubs.apk" />
<option name="test-file-name" value="CtsBinderPermissionTestService.apk" />
- <option name="test-file-name" value="CtsContentTestsHelperApp.apk" />
</target_preparer>
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
diff --git a/tests/tests/content/app/Android.bp b/tests/tests/content/app/Android.bp
deleted file mode 100644
index 0a6a258..0000000
--- a/tests/tests/content/app/Android.bp
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (C) 2020 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-android_test_helper_app {
- name: "CtsContentTestsHelperApp",
- manifest: "AndroidManifest.xml",
- srcs: ["src/**/*.java"],
- // Tag this module as a cts test artifact
- test_suites: [
- "cts",
- "general-tests",
- ],
- sdk_version: "test_current",
-}
diff --git a/tests/tests/content/app/AndroidManifest.xml b/tests/tests/content/app/AndroidManifest.xml
deleted file mode 100644
index 07978ce..0000000
--- a/tests/tests/content/app/AndroidManifest.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- - Copyright (C) 2020 The Android Open Source Project
- -
- - Licensed under the Apache License, Version 2.0 (the "License");
- - you may not use this file except in compliance with the License.
- - You may obtain a copy of the License at
- -
- - http://www.apache.org/licenses/LICENSE-2.0
- -
- - Unless required by applicable law or agreed to in writing, software
- - distributed under the License is distributed on an "AS IS" BASIS,
- - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- - See the License for the specific language governing permissions and
- - limitations under the License.
- -->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="android.content.pm.cts.app">
- <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
- <application>
- <uses-library android:name="android.test.runner" />
- <activity android:name="android.content.pm.cts.app.MainActivity"
- android:exported="true" />
- </application>
-</manifest>
diff --git a/tests/tests/content/app/src/android/content/pm/cts/app/MainActivity.java b/tests/tests/content/app/src/android/content/pm/cts/app/MainActivity.java
deleted file mode 100644
index 4e62a01..0000000
--- a/tests/tests/content/app/src/android/content/pm/cts/app/MainActivity.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.content.pm.cts.app;
-
-import android.app.Activity;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.Bundle;
-import android.os.PatternMatcher;
-import android.os.RemoteCallback;
-
-/**
- * Helper activity to listen for Incremental package state change broadcasts.
- */
-public class MainActivity extends Activity {
- private IncrementalStatesBroadcastReceiver mReceiver;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- final Intent intent = getIntent();
- final String targetPackageName = intent.getStringExtra(Intent.EXTRA_PACKAGE_NAME);
- final RemoteCallback remoteCallback = intent.getParcelableExtra("callback");
- final IntentFilter filter = new IntentFilter();
- filter.addAction(Intent.ACTION_PACKAGE_FULLY_LOADED);
- filter.addDataScheme("package");
- filter.addDataSchemeSpecificPart(targetPackageName, PatternMatcher.PATTERN_LITERAL);
- mReceiver = new IncrementalStatesBroadcastReceiver(targetPackageName, remoteCallback);
- registerReceiver(mReceiver, filter);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- unregisterReceiver(mReceiver);
- }
-
- private class IncrementalStatesBroadcastReceiver extends BroadcastReceiver {
- private final String mPackageName;
- private final RemoteCallback mCallback;
- IncrementalStatesBroadcastReceiver(String packageName, RemoteCallback callback) {
- mPackageName = packageName;
- mCallback = callback;
- }
-
- @Override
- public void onReceive(Context context, Intent intent) {
- final Bundle extras = intent.getExtras();
- final String packageName = extras.getString(Intent.EXTRA_PACKAGE_NAME, "");
- if (!mPackageName.equals(packageName)) {
- return;
- }
- Bundle result = new Bundle();
- result.putString("intent", intent.getAction());
- result.putBundle("extras", intent.getExtras());
- mCallback.sendResult(result);
- }
- }
-}
diff --git a/tests/tests/content/src/android/content/cts/ContentProviderTest.java b/tests/tests/content/src/android/content/cts/ContentProviderTest.java
index 1bc4ddc..b53f9f8 100644
--- a/tests/tests/content/src/android/content/cts/ContentProviderTest.java
+++ b/tests/tests/content/src/android/content/cts/ContentProviderTest.java
@@ -261,29 +261,29 @@
provider.checkUriPermission(uri, android.os.Process.myUid(), 0));
}
- public void testCreateContentUriAsUser_nullUri_throwsNPE() {
+ public void testCreateContentUriForUser_nullUri_throwsNPE() {
assertThrows(
NullPointerException.class,
- () -> ContentProvider.createContentUriAsUser(null, UserHandle.of(7)));
+ () -> ContentProvider.createContentUriForUser(null, UserHandle.of(7)));
}
- public void testCreateContentUriAsUser_nonContentUri_throwsIAE() {
+ public void testCreateContentUriForUser_nonContentUri_throwsIAE() {
final Uri uri = Uri.parse("notcontent://test");
assertThrows(
IllegalArgumentException.class,
- () -> ContentProvider.createContentUriAsUser(uri, UserHandle.of(7)));
+ () -> ContentProvider.createContentUriForUser(uri, UserHandle.of(7)));
}
- public void testCreateContentUriAsUser_UriWithDifferentUserID_throwsIAE() {
+ public void testCreateContentUriForUser_UriWithDifferentUserID_throwsIAE() {
final Uri uri = Uri.parse("content://07@test");
assertThrows(
IllegalArgumentException.class,
- () -> ContentProvider.createContentUriAsUser(uri, UserHandle.of(7)));
+ () -> ContentProvider.createContentUriForUser(uri, UserHandle.of(7)));
}
- public void testCreateContentUriAsUser_UriWithUserID_unchanged() {
+ public void testCreateContentUriForUser_UriWithUserID_unchanged() {
final Uri uri = Uri.parse("content://7@test");
- assertEquals(uri, ContentProvider.createContentUriAsUser(uri, UserHandle.of(7)));
+ assertEquals(uri, ContentProvider.createContentUriForUser(uri, UserHandle.of(7)));
}
private class MockContentProvider extends ContentProvider {
diff --git a/tests/tests/content/src/android/content/cts/wm/OWNERS b/tests/tests/content/src/android/content/cts/wm/OWNERS
deleted file mode 100644
index 940ab87..0000000
--- a/tests/tests/content/src/android/content/cts/wm/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-include /tests/framework/base/windowmanager/OWNERS
-charlesccchen@google.com
diff --git a/tests/tests/content/src/android/content/pm/cts/PackageManagerShellCommandIncrementalTest.java b/tests/tests/content/src/android/content/pm/cts/PackageManagerShellCommandIncrementalTest.java
index 1440aeb..8a89898 100644
--- a/tests/tests/content/src/android/content/pm/cts/PackageManagerShellCommandIncrementalTest.java
+++ b/tests/tests/content/src/android/content/pm/cts/PackageManagerShellCommandIncrementalTest.java
@@ -23,15 +23,12 @@
import android.annotation.NonNull;
import android.app.UiAutomation;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
-import android.net.Uri;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.os.Process;
-import android.os.RemoteCallback;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
@@ -58,6 +55,7 @@
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -76,12 +74,10 @@
import java.util.Optional;
import java.util.Random;
import java.util.Scanner;
-import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -157,18 +153,15 @@
@Test
public void testInstallWithIdSig() throws Exception {
- final Result stateListenerResult = startListeningForBroadcast();
installPackage(TEST_APK);
- assertTrue(stateListenerResult.await());
assertTrue(isAppInstalled(TEST_APP_PACKAGE));
}
@Test
+ @Ignore("Wait until the kernel change lands in RVC branch for the mixed vendor image tests")
public void testBug183952694Fixed() throws Exception {
// first ensure the IncFS is up and running, e.g. if it's a module
- final Result stateListenerResult = startListeningForBroadcast();
installPackage(TEST_APK);
- assertTrue(stateListenerResult.await());
assertTrue(isAppInstalled(TEST_APP_PACKAGE));
// the bug is fixed in the v2 version, or when the specific marker feature is present
@@ -184,9 +177,7 @@
public void testSplitInstallWithIdSig() throws Exception {
// First fully install the apk.
{
- final Result stateListenerResult = startListeningForBroadcast();
installPackage(TEST_APK);
- assertTrue(stateListenerResult.await());
assertTrue(isAppInstalled(TEST_APP_PACKAGE));
}
@@ -215,12 +206,10 @@
File[] files = new File[]{apkfile, splitfile};
String param = Arrays.stream(files).map(
file -> file.getName() + ":" + file.length()).collect(Collectors.joining(" "));
- final Result stateListenerResult = startListeningForBroadcast();
assertEquals("Success\n", executeShellCommand(
String.format("pm install-incremental -t -g -S %s %s",
(apkfile.length() + splitfile.length()), param),
files));
- assertTrue(stateListenerResult.await());
assertTrue(isAppInstalled(TEST_APP_PACKAGE));
assertEquals("base, config.mdpi", getSplits(TEST_APP_PACKAGE));
}
@@ -420,12 +409,10 @@
@Test
public void testInstallWithIdSigInvalidLength() throws Exception {
File file = new File(createApkPath(TEST_APK));
- final Result stateListenerResult = startListeningForBroadcast();
assertTrue(
executeShellCommand("pm install-incremental -t -g -S " + (file.length() - 1),
new File[]{file}).contains(
"Failure"));
- assertFalse(stateListenerResult.await());
assertFalse(isAppInstalled(TEST_APP_PACKAGE));
}
@@ -436,14 +423,12 @@
long length = file.length();
// Streaming happens in blocks of 1024 bytes, new length will not stream the last block.
long newLength = length - (length % 1024 == 0 ? 1024 : length % 1024);
- final Result stateListenerResult = startListeningForBroadcast();
assertTrue(
executeShellCommand(
"pm install-incremental -t -g -S " + length,
new File[] {file},
new long[] {newLength})
.contains("Failure"));
- assertFalse(stateListenerResult.await());
assertFalse(isAppInstalled(TEST_APP_PACKAGE));
}
@@ -752,9 +737,7 @@
setDeviceProperty("incfs_default_timeouts", "5000000:5000000:5000000");
setDeviceProperty("known_digesters_list", CTS_PACKAGE_NAME);
- final Result stateListenerResult = startListeningForBroadcast();
installPackage(TEST_APK);
- assertTrue(stateListenerResult.await());
assertTrue(isAppInstalled(TEST_APP_PACKAGE));
} finally {
executeShellCommand("atrace --async_stop");
@@ -819,9 +802,7 @@
// First fully install the apk and a split0.
{
- final Result stateListenerResult = startListeningForBroadcast();
installPackage(TEST_APK);
- assertTrue(stateListenerResult.await());
assertTrue(isAppInstalled(TEST_APP_PACKAGE));
installSplit(TEST_APK_SPLIT0);
assertEquals("base, config.mdpi", getSplits(TEST_APP_PACKAGE));
@@ -848,13 +829,11 @@
File[] files = new File[]{apkfile, splitfile};
String param = Arrays.stream(files).map(
file -> file.getName() + ":" + file.length()).collect(Collectors.joining(" "));
- final Result stateListenerResult = startListeningForBroadcast();
assertTrue(executeShellCommand(
String.format("pm install-incremental -t -g -S %s %s",
(apkfile.length() + splitfile.length()), param),
files, new long[]{apkfile.length(), newSplitLength}).contains(
"Failure"));
- assertFalse(stateListenerResult.await());
assertFalse(isAppInstalled(TEST_APP_PACKAGE));
}
@@ -1016,14 +995,12 @@
private void installSplit(String splitName) throws Exception {
final File splitfile = new File(createApkPath(splitName));
- final Result stateListenerResult = startListeningForBroadcast();
try (InputStream inputStream = executeShellCommandStream(
"pm install-incremental -t -g -p " + TEST_APP_PACKAGE + " "
+ splitfile.getPath())) {
assertEquals("Success\n", readFullStream(inputStream));
}
- assertTrue(stateListenerResult.await());
}
private void readSplitInChunks(String splitName) throws Exception {
@@ -1078,38 +1055,6 @@
boolean await() throws Exception;
}
- private Result startListeningForBroadcast() {
- final Intent intent = new Intent()
- .setComponent(new ComponentName("android.content.pm.cts.app", "android.content"
- + ".pm.cts.app.MainActivity"))
- // data uri unique to each activity start to ensure actual launch and not just
- // redisplay
- .setData(Uri.parse("test://" + UUID.randomUUID().toString()))
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
- intent.putExtra(Intent.EXTRA_PACKAGE_NAME, TEST_APP_PACKAGE);
- // Should receive at least one fully_loaded broadcast
- final CompletableFuture<Boolean> fullyLoaded = new CompletableFuture<>();
- final RemoteCallback callback = new RemoteCallback(
- bundle -> {
- if (bundle == null) {
- return;
- }
- if (bundle.getString("intent").equals(
- Intent.ACTION_PACKAGE_FULLY_LOADED)) {
- fullyLoaded.complete(true);
- }
- });
- intent.putExtra("callback", callback);
- getContext().startActivity(intent);
- return () -> {
- try {
- return fullyLoaded.get(30, TimeUnit.SECONDS);
- } catch (TimeoutException e) {
- return false;
- }
- };
- }
-
private static String executeShellCommand(String command) throws IOException {
try (InputStream inputStream = executeShellCommandStream(command)) {
return readFullStream(inputStream);
diff --git a/tests/tests/content/src/android/content/wm/cts/OWNERS b/tests/tests/content/src/android/content/wm/cts/OWNERS
new file mode 100644
index 0000000..5ed5c56
--- /dev/null
+++ b/tests/tests/content/src/android/content/wm/cts/OWNERS
@@ -0,0 +1,2 @@
+include platform/frameworks/base:/services/core/java/com/android/server/wm/OWNERS
+charlesccchen@google.com
diff --git a/tests/tests/display/src/android/display/cts/DisplayTest.java b/tests/tests/display/src/android/display/cts/DisplayTest.java
index 0ce4d68..d72a56b 100644
--- a/tests/tests/display/src/android/display/cts/DisplayTest.java
+++ b/tests/tests/display/src/android/display/cts/DisplayTest.java
@@ -77,9 +77,14 @@
import java.util.Optional;
import java.util.Random;
import java.util.Scanner;
+import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.function.Predicate;
import java.util.function.Supplier;
@RunWith(AndroidJUnit4.class)
@@ -272,11 +277,18 @@
*/
@Test
public void
- testGetHdrCapabilitiesWhenUserDisabledFormatsAreNotAllowedReturnsFilteredHdrTypes() {
+ testGetHdrCapabilitiesWhenUserDisabledFormatsAreNotAllowedReturnsFilteredHdrTypes()
+ throws Exception {
final IBinder displayToken = SurfaceControl.getInternalDisplayToken();
SurfaceControl.overrideHdrTypes(displayToken, new int[]{
HdrCapabilities.HDR_TYPE_DOLBY_VISION, HdrCapabilities.HDR_TYPE_HDR10,
HdrCapabilities.HDR_TYPE_HLG, HdrCapabilities.HDR_TYPE_HDR10_PLUS});
+ waitUntil(
+ mDefaultDisplay,
+ mDefaultDisplay ->
+ mDefaultDisplay.getHdrCapabilities().getSupportedHdrTypes().length == 4,
+ Duration.ofSeconds(5));
+ assertEquals(4, mDefaultDisplay.getHdrCapabilities().getSupportedHdrTypes().length);
mDisplayManager.setAreUserDisabledHdrTypesAllowed(false);
int[] emptyUserDisabledFormats = {};
@@ -310,11 +322,18 @@
*/
@Test
public void
- testGetHdrCapabilitiesWhenUserDisabledFormatsAreAllowedReturnsNonFilteredHdrTypes() {
+ testGetHdrCapabilitiesWhenUserDisabledFormatsAreAllowedReturnsNonFilteredHdrTypes()
+ throws Exception {
final IBinder displayToken = SurfaceControl.getInternalDisplayToken();
SurfaceControl.overrideHdrTypes(displayToken, new int[]{
HdrCapabilities.HDR_TYPE_DOLBY_VISION, HdrCapabilities.HDR_TYPE_HDR10,
HdrCapabilities.HDR_TYPE_HLG, HdrCapabilities.HDR_TYPE_HDR10_PLUS});
+ waitUntil(
+ mDefaultDisplay,
+ mDefaultDisplay ->
+ mDefaultDisplay.getHdrCapabilities().getSupportedHdrTypes().length == 4,
+ Duration.ofSeconds(5));
+ assertEquals(4, mDefaultDisplay.getHdrCapabilities().getSupportedHdrTypes().length);
mDisplayManager.setAreUserDisabledHdrTypesAllowed(true);
int[] userDisabledHdrTypes =
@@ -337,12 +356,17 @@
* setUserDisabledHdrTypes, the setting is persisted in Settings.Global.
*/
@Test
- public void testSetUserDisabledHdrTypesStoresDisabledFormatsInSettings()
- throws NumberFormatException {
+ public void testSetUserDisabledHdrTypesStoresDisabledFormatsInSettings() throws Exception {
final IBinder displayToken = SurfaceControl.getInternalDisplayToken();
SurfaceControl.overrideHdrTypes(displayToken, new int[]{
HdrCapabilities.HDR_TYPE_DOLBY_VISION, HdrCapabilities.HDR_TYPE_HDR10,
HdrCapabilities.HDR_TYPE_HLG, HdrCapabilities.HDR_TYPE_HDR10_PLUS});
+ waitUntil(
+ mDefaultDisplay,
+ mDefaultDisplay ->
+ mDefaultDisplay.getHdrCapabilities().getSupportedHdrTypes().length == 4,
+ Duration.ofSeconds(5));
+ assertEquals(4, mDefaultDisplay.getHdrCapabilities().getSupportedHdrTypes().length);
mDisplayManager.setAreUserDisabledHdrTypesAllowed(false);
int[] emptyUserDisabledFormats = {};
@@ -363,6 +387,44 @@
assertEquals(HdrCapabilities.HDR_TYPE_HLG, userDisabledFormats[1]);
}
+ private void waitUntil(Display d, Predicate<Display> pred, Duration maxWait) throws Exception {
+ final int id = d.getDisplayId();
+ final Lock lock = new ReentrantLock();
+ final Condition displayChanged = lock.newCondition();
+ DisplayListener listener = new DisplayListener() {
+ @Override
+ public void onDisplayChanged(int displayId) {
+ if (displayId != id) {
+ return;
+ }
+ lock.lock();
+ try {
+ displayChanged.signal();
+ } finally {
+ lock.unlock();
+ }
+ }
+ @Override
+ public void onDisplayAdded(int displayId) {}
+ @Override
+ public void onDisplayRemoved(int displayId) {}
+ };
+ Handler handler = new Handler(Looper.getMainLooper());
+ mDisplayManager.registerDisplayListener(listener, handler);
+ long remainingNanos = maxWait.toNanos();
+ lock.lock();
+ try {
+ while (!pred.test(mDefaultDisplay)) {
+ if (remainingNanos <= 0L) {
+ throw new TimeoutException();
+ }
+ displayChanged.awaitNanos(remainingNanos);
+ }
+ } finally {
+ lock.unlock();
+ }
+ }
+
/**
* Verify that there is a secondary display.
*/
diff --git a/tests/tests/display/src/android/display/cts/VirtualDisplayTest.java b/tests/tests/display/src/android/display/cts/VirtualDisplayTest.java
index c4db581..051ad1a 100644
--- a/tests/tests/display/src/android/display/cts/VirtualDisplayTest.java
+++ b/tests/tests/display/src/android/display/cts/VirtualDisplayTest.java
@@ -19,6 +19,14 @@
import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS;
import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_TRUSTED;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import android.Manifest;
import android.app.Presentation;
import android.content.Context;
import android.graphics.Color;
@@ -35,7 +43,7 @@
import android.os.Looper;
import android.os.SystemClock;
import android.platform.test.annotations.SecurityTest;
-import android.test.AndroidTestCase;
+import android.provider.Settings;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
@@ -43,6 +51,19 @@
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.runner.AndroidJUnit4;
+
+import com.android.compatibility.common.util.AdoptShellPermissionsRule;
+import com.android.compatibility.common.util.SettingsStateKeeperRule;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.nio.ByteBuffer;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@@ -53,7 +74,8 @@
* This CTS test is unable to test public virtual displays since special permissions
* are required. See also framework VirtualDisplayTest unit tests.
*/
-public class VirtualDisplayTest extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class VirtualDisplayTest {
private static final String TAG = "VirtualDisplayTest";
private static final String NAME = TAG;
@@ -70,6 +92,7 @@
private static final int BLUEISH = 0xff1122ee;
private static final int GREENISH = 0xff33dd44;
+ private Context mContext;
private DisplayManager mDisplayManager;
private Handler mHandler;
private final Lock mImageReaderLock = new ReentrantLock(true /*fair*/);
@@ -79,10 +102,24 @@
private HandlerThread mCheckThread;
private Handler mCheckHandler;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Rule
+ public AdoptShellPermissionsRule mAdoptShellPermissionsRule = new AdoptShellPermissionsRule(
+ InstrumentationRegistry.getInstrumentation().getUiAutomation(),
+ Manifest.permission.WRITE_SECURE_SETTINGS);
+ @ClassRule
+ public static final SettingsStateKeeperRule mAreUserDisabledHdrFormatsAllowedSettingsKeeper =
+ new SettingsStateKeeperRule(InstrumentationRegistry.getTargetContext(),
+ Settings.Global.ARE_USER_DISABLED_HDR_FORMATS_ALLOWED);
+
+ @ClassRule
+ public static final SettingsStateKeeperRule mUserDisabledHdrFormatsSettingsKeeper =
+ new SettingsStateKeeperRule(InstrumentationRegistry.getTargetContext(),
+ Settings.Global.USER_DISABLED_HDR_FORMATS);
+
+ @Before
+ public void setUp() throws Exception {
+ mContext = InstrumentationRegistry.getInstrumentation().getContext();
mDisplayManager = (DisplayManager)mContext.getSystemService(Context.DISPLAY_SERVICE);
mHandler = new Handler(Looper.getMainLooper());
mImageListener = new ImageListener();
@@ -101,9 +138,8 @@
}
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void tearDown() throws Exception {
mImageReaderLock.lock();
try {
mImageReader.close();
@@ -120,6 +156,7 @@
* its own windows on it.
*/
@SecurityTest
+ @Test
public void testPrivateVirtualDisplay() throws Exception {
VirtualDisplay virtualDisplay = mDisplayManager.createVirtualDisplay(NAME,
WIDTH, HEIGHT, DENSITY, mSurface, 0);
@@ -144,6 +181,7 @@
* its own windows on it.
*/
@SecurityTest
+ @Test
public void testPrivatePresentationVirtualDisplay() throws Exception {
VirtualDisplay virtualDisplay = mDisplayManager.createVirtualDisplay(NAME,
WIDTH, HEIGHT, DENSITY, mSurface,
@@ -169,6 +207,7 @@
* its own windows on it where the surface is attached or detached dynamically.
*/
@SecurityTest
+ @Test
public void testPrivateVirtualDisplayWithDynamicSurface() throws Exception {
VirtualDisplay virtualDisplay = mDisplayManager.createVirtualDisplay(NAME,
WIDTH, HEIGHT, DENSITY, null, 0);
@@ -202,6 +241,7 @@
* flag {@link DisplayManager#VIRTUAL_DISPLAY_FLAG_TRUSTED}.
*/
@SecurityTest
+ @Test
public void testUntrustedSysDecorVirtualDisplay() throws Exception {
VirtualDisplay virtualDisplay = mDisplayManager.createVirtualDisplay(NAME,
WIDTH, HEIGHT, DENSITY, mSurface,
@@ -229,6 +269,7 @@
* display without holding the permission {@code ADD_TRUSTED_DISPLAY}.
*/
@SecurityTest
+ @Test
public void testTrustedVirtualDisplay() throws Exception {
try {
VirtualDisplay virtualDisplay = mDisplayManager.createVirtualDisplay(NAME,
@@ -241,6 +282,36 @@
+ "holding the permission ADD_TRUSTED_DISPLAY.");
}
+ @Test
+ public void testHdrApiMethods() {
+ VirtualDisplay virtualDisplay = mDisplayManager.createVirtualDisplay(NAME,
+ WIDTH, HEIGHT, DENSITY, mSurface, /*flags*/ 0);
+ try {
+ assertFalse(virtualDisplay.getDisplay().isHdr());
+ assertNull(virtualDisplay.getDisplay().getHdrCapabilities());
+ } finally {
+ virtualDisplay.release();
+ }
+ }
+
+ @Test
+ public void testGetHdrCapabilitiesWithUserDisabledFormats() {
+ VirtualDisplay virtualDisplay = mDisplayManager.createVirtualDisplay(NAME,
+ WIDTH, HEIGHT, DENSITY, mSurface, /*flags*/ 0);
+ mDisplayManager.setAreUserDisabledHdrTypesAllowed(false);
+ int[] userDisabledHdrTypes = {
+ Display.HdrCapabilities.HDR_TYPE_DOLBY_VISION,
+ Display.HdrCapabilities.HDR_TYPE_HLG};
+ mDisplayManager.setUserDisabledHdrTypes(userDisabledHdrTypes);
+
+ try {
+ assertFalse(virtualDisplay.getDisplay().isHdr());
+ assertNull(virtualDisplay.getDisplay().getHdrCapabilities());
+ } finally {
+ virtualDisplay.release();
+ }
+ }
+
private void assertDisplayRegistered(Display display, int flags) {
assertNotNull("display object must not be null", display);
assertTrue("display must be valid", display.isValid());
@@ -286,7 +357,7 @@
runOnUiThread(new Runnable() {
@Override
public void run() {
- presentation[0] = new TestPresentation(getContext(), display,
+ presentation[0] = new TestPresentation(mContext, display,
color, windowFlags);
presentation[0].show();
}
diff --git a/tests/tests/graphics/src/android/graphics/cts/VulkanPreTransformCtsActivity.java b/tests/tests/graphics/src/android/graphics/cts/VulkanPreTransformCtsActivity.java
index b00a072..227e6d7 100644
--- a/tests/tests/graphics/src/android/graphics/cts/VulkanPreTransformCtsActivity.java
+++ b/tests/tests/graphics/src/android/graphics/cts/VulkanPreTransformCtsActivity.java
@@ -24,13 +24,14 @@
import android.os.Bundle;
import android.util.Log;
import android.view.Surface;
+import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.WindowManager;
/**
* Activity for VulkanPreTransformTest.
*/
-public class VulkanPreTransformCtsActivity extends Activity {
+public class VulkanPreTransformCtsActivity extends Activity implements SurfaceHolder.Callback {
static {
System.loadLibrary("ctsgraphics_jni");
}
@@ -48,7 +49,7 @@
setActivityOrientation();
setContentView(R.layout.vulkan_pretransform_layout);
SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceview);
- mSurface = surfaceView.getHolder().getSurface();
+ surfaceView.getHolder().addCallback(this);
}
private void setActivityOrientation() {
@@ -76,10 +77,36 @@
}
public void testVulkanPreTransform(boolean setPreTransform) {
+ synchronized (this) {
+ if (mSurface == null) {
+ try {
+ // Wait for surfaceCreated callback on UI thread.
+ this.wait();
+ } catch (Exception e) {
+ }
+ }
+ }
nCreateNativeTest(getAssets(), mSurface, setPreTransform);
sOrientationRequested = false;
}
private static native void nCreateNativeTest(
AssetManager manager, Surface surface, boolean setPreTransform);
+
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+ synchronized (this) {
+ mSurface = holder.getSurface();
+ this.notify();
+ }
+ }
+
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format,
+ int width, int height) {
+ }
+
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ }
}
diff --git a/tests/tests/graphics/src/android/graphics/cts/VulkanPreTransformTest.java b/tests/tests/graphics/src/android/graphics/cts/VulkanPreTransformTest.java
index 427ae77..79c8342 100644
--- a/tests/tests/graphics/src/android/graphics/cts/VulkanPreTransformTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/VulkanPreTransformTest.java
@@ -105,9 +105,6 @@
@Before
public void setUp() {
Log.d(TAG, "setUp!");
- // Work around for b/77148807
- // Activity was falsely created before ActivityManager set config change to landscape
- SystemClock.sleep(2000);
mContext = InstrumentationRegistry.getContext();
}
@@ -120,7 +117,6 @@
return;
}
sActivity = mActivityRule.launchActivity(null);
- SystemClock.sleep(5000);
sActivity.testVulkanPreTransform(true);
sActivity.finish();
sActivity = null;
@@ -135,7 +131,6 @@
return;
}
sActivity = mActivityRule.launchActivity(null);
- SystemClock.sleep(5000);
sActivity.testVulkanPreTransform(false);
sActivity.finish();
sActivity = null;
diff --git a/tests/tests/hardware/res/raw/sony_dualsense_usb_register.json b/tests/tests/hardware/res/raw/sony_dualsense_usb_register.json
index f1f19a8..e40d5a6 100644
--- a/tests/tests/hardware/res/raw/sony_dualsense_usb_register.json
+++ b/tests/tests/hardware/res/raw/sony_dualsense_usb_register.json
@@ -38,7 +38,7 @@
"id": 0x09,
"data": [
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
},
{
"id": 0x20,
diff --git a/tests/tests/media/src/android/media/cts/AudioDeviceInfoTest.java b/tests/tests/media/src/android/media/cts/AudioDeviceInfoTest.java
new file mode 100644
index 0000000..a2a90dc
--- /dev/null
+++ b/tests/tests/media/src/android/media/cts/AudioDeviceInfoTest.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2021 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.media.cts;
+
+import static org.junit.Assert.*;
+
+import android.media.AudioDeviceInfo;
+import android.util.Log;
+import androidx.test.runner.AndroidJUnit4;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@NonMediaMainlineTest
+@RunWith(AndroidJUnit4.class)
+public class AudioDeviceInfoTest {
+ private static final Set<Integer> INPUT_TYPES = Stream.of(
+ AudioDeviceInfo.TYPE_BUILTIN_MIC,
+ AudioDeviceInfo.TYPE_BLUETOOTH_SCO,
+ AudioDeviceInfo.TYPE_BLUETOOTH_A2DP,
+ AudioDeviceInfo.TYPE_WIRED_HEADSET,
+ AudioDeviceInfo.TYPE_HDMI,
+ AudioDeviceInfo.TYPE_TELEPHONY,
+ AudioDeviceInfo.TYPE_DOCK,
+ AudioDeviceInfo.TYPE_USB_ACCESSORY,
+ AudioDeviceInfo.TYPE_USB_DEVICE,
+ AudioDeviceInfo.TYPE_USB_HEADSET,
+ AudioDeviceInfo.TYPE_FM_TUNER,
+ AudioDeviceInfo.TYPE_TV_TUNER,
+ AudioDeviceInfo.TYPE_LINE_ANALOG,
+ AudioDeviceInfo.TYPE_LINE_DIGITAL,
+ AudioDeviceInfo.TYPE_IP,
+ AudioDeviceInfo.TYPE_BUS,
+ AudioDeviceInfo.TYPE_REMOTE_SUBMIX,
+ AudioDeviceInfo.TYPE_BLE_HEADSET,
+ AudioDeviceInfo.TYPE_HDMI_ARC,
+ AudioDeviceInfo.TYPE_HDMI_EARC,
+ AudioDeviceInfo.TYPE_ECHO_REFERENCE)
+ .collect(Collectors.toCollection(HashSet::new));
+
+ private static final Set<Integer> OUTPUT_TYPES = Stream.of(
+ AudioDeviceInfo.TYPE_BUILTIN_EARPIECE,
+ AudioDeviceInfo.TYPE_BUILTIN_SPEAKER,
+ AudioDeviceInfo.TYPE_WIRED_HEADSET,
+ AudioDeviceInfo.TYPE_WIRED_HEADPHONES,
+ AudioDeviceInfo.TYPE_BLUETOOTH_SCO,
+ AudioDeviceInfo.TYPE_BLUETOOTH_A2DP,
+ AudioDeviceInfo.TYPE_HDMI,
+ AudioDeviceInfo.TYPE_DOCK,
+ AudioDeviceInfo.TYPE_USB_ACCESSORY,
+ AudioDeviceInfo.TYPE_USB_DEVICE,
+ AudioDeviceInfo.TYPE_USB_HEADSET,
+ AudioDeviceInfo.TYPE_TELEPHONY,
+ AudioDeviceInfo.TYPE_LINE_ANALOG,
+ AudioDeviceInfo.TYPE_HDMI_ARC,
+ AudioDeviceInfo.TYPE_HDMI_EARC,
+ AudioDeviceInfo.TYPE_LINE_DIGITAL,
+ AudioDeviceInfo.TYPE_FM,
+ AudioDeviceInfo.TYPE_AUX_LINE,
+ AudioDeviceInfo.TYPE_IP,
+ AudioDeviceInfo.TYPE_BUS,
+ AudioDeviceInfo.TYPE_HEARING_AID,
+ AudioDeviceInfo.TYPE_BUILTIN_SPEAKER_SAFE,
+ AudioDeviceInfo.TYPE_BLE_HEADSET,
+ AudioDeviceInfo.TYPE_BLE_SPEAKER)
+ .collect(Collectors.toCollection(HashSet::new));
+
+ private static int MAX_TYPE;
+ private static int MIN_TYPE;
+ {
+ int maxType = Integer.MIN_VALUE;
+ int minType = Integer.MAX_VALUE;
+ for (int type : INPUT_TYPES) {
+ minType = Integer.min(minType, type);
+ maxType = Integer.max(maxType, type);
+ }
+ for (int type : OUTPUT_TYPES) {
+ minType = Integer.min(minType, type);
+ maxType = Integer.max(maxType, type);
+ }
+ MIN_TYPE = minType;
+ MAX_TYPE = maxType;
+ }
+
+ /**
+ * Ensure no regression on accepted input device types.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testDeviceTypeIn() throws Exception {
+ for (int type : INPUT_TYPES) {
+ // throws IllegalArgumentException on failure
+ AudioDeviceInfo.enforceValidAudioDeviceTypeIn(type);
+ }
+ }
+
+ /**
+ * Ensure no regression on accepted output device types.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testDeviceTypeOut() throws Exception {
+ for (int type : OUTPUT_TYPES) {
+ // throws IllegalArgumentException on failure
+ AudioDeviceInfo.enforceValidAudioDeviceTypeOut(type);
+ }
+ }
+}
diff --git a/tests/tests/media/src/android/media/cts/DecoderTestXheAac.java b/tests/tests/media/src/android/media/cts/DecoderTestXheAac.java
index 44ddf6fb..d90bf4f 100755
--- a/tests/tests/media/src/android/media/cts/DecoderTestXheAac.java
+++ b/tests/tests/media/src/android/media/cts/DecoderTestXheAac.java
@@ -43,6 +43,8 @@
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -51,6 +53,7 @@
import java.util.List;
@AppModeFull(reason = "DecoderTest is non-instant")
+@RunWith(JUnit4.class)
public class DecoderTestXheAac {
private static final String TAG = "DecoderTestXheAac";
diff --git a/tests/tests/media/src/android/media/cts/MediaMetadataRetrieverTest.java b/tests/tests/media/src/android/media/cts/MediaMetadataRetrieverTest.java
index 7d064b5..0233b73 100644
--- a/tests/tests/media/src/android/media/cts/MediaMetadataRetrieverTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaMetadataRetrieverTest.java
@@ -21,7 +21,6 @@
import static android.media.MediaMetadataRetriever.OPTION_NEXT_SYNC;
import static android.media.MediaMetadataRetriever.OPTION_PREVIOUS_SYNC;
-import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.AssetFileDescriptor;
import android.graphics.Bitmap;
@@ -33,7 +32,6 @@
import android.media.MediaExtractor;
import android.media.MediaFormat;
import android.media.MediaMetadataRetriever;
-import android.media.MediaRecorder;
import android.os.ParcelFileDescriptor;
import android.net.Uri;
import android.os.Build;
@@ -59,7 +57,6 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.function.Function;
@@ -391,7 +388,9 @@
if(!ApiLevelUtil.isAtLeast(Build.VERSION_CODES.R)) {
// The fix for b/154357105 was released in mainline release 30.09.007.01
// See https://android-build.googleplex.com/builds/treetop/googleplex-android-review/11174063
- TestUtils.assumeMainlineModuleAtLeast("com.google.android.media", 300900701);
+ if (TestUtils.skipTestIfMainlineLessThan("com.google.android.media", 300900701)) {
+ return;
+ }
}
setDataSourceFd("sinesweepid3v24ext.mp3");
assertEquals("Mime type was other than expected",
diff --git a/tests/tests/media/src/android/media/cts/PlaybackStateTest.java b/tests/tests/media/src/android/media/cts/PlaybackStateTest.java
index 54ae88b..c68f208 100644
--- a/tests/tests/media/src/android/media/cts/PlaybackStateTest.java
+++ b/tests/tests/media/src/android/media/cts/PlaybackStateTest.java
@@ -283,6 +283,37 @@
}
}
+ public void testIsActive() {
+ int[] activeStates = new int[] {
+ PlaybackState.STATE_FAST_FORWARDING,
+ PlaybackState.STATE_REWINDING,
+ PlaybackState.STATE_SKIPPING_TO_PREVIOUS,
+ PlaybackState.STATE_SKIPPING_TO_NEXT,
+ PlaybackState.STATE_SKIPPING_TO_QUEUE_ITEM,
+ PlaybackState.STATE_BUFFERING,
+ PlaybackState.STATE_CONNECTING,
+ PlaybackState.STATE_PLAYING};
+
+ int[] nonActiveStates = new int[] {
+ PlaybackState.STATE_NONE,
+ PlaybackState.STATE_STOPPED,
+ PlaybackState.STATE_PAUSED,
+ PlaybackState.STATE_ERROR};
+
+ for (int i = 0; i < activeStates.length; i++) {
+ PlaybackState activePlaybackState = new PlaybackState.Builder()
+ .setState(activeStates[i], 0, 1.0f)
+ .build();
+ assertTrue(activePlaybackState.isActive());
+ }
+ for (int i = 0; i < nonActiveStates.length; i++) {
+ PlaybackState nonActivePlaybackState = new PlaybackState.Builder()
+ .setState(nonActiveStates[i], 0, 1.0f)
+ .build();
+ assertFalse(nonActivePlaybackState.isActive());
+ }
+ }
+
private void assertCustomActionEquals(PlaybackState.CustomAction action1,
PlaybackState.CustomAction action2) {
assertEquals(action1.getAction(), action2.getAction());
diff --git a/tests/tests/media/src/android/media/cts/TestUtils.java b/tests/tests/media/src/android/media/cts/TestUtils.java
index fb8212f..ae4cb59 100644
--- a/tests/tests/media/src/android/media/cts/TestUtils.java
+++ b/tests/tests/media/src/android/media/cts/TestUtils.java
@@ -18,16 +18,17 @@
import static android.content.pm.PackageManager.MATCH_APEX;
-import static org.junit.Assume.assumeNoException;
import static org.junit.Assume.assumeTrue;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
+import android.util.Log;
import androidx.test.core.app.ApplicationProvider;
+import org.junit.Assert;
import org.junit.AssumptionViolatedException;
import java.util.Objects;
@@ -36,6 +37,7 @@
* Utilities for tests.
*/
public final class TestUtils {
+ private static String TAG = "TestUtils";
private static final int WAIT_TIME_MS = 1000;
private static final int WAIT_SERVICE_TIME_MS = 5000;
@@ -74,23 +76,60 @@
*
* @param module the apex module name
* @param minVersion the minimum version
- * @throws AssumptionViolatedException if module.minVersion < minVersion
+ * @throws AssumptionViolatedException if module version < minVersion
*/
static void assumeMainlineModuleAtLeast(String module, long minVersion) {
- Context context = ApplicationProvider.getApplicationContext();
- PackageInfo info;
try {
- info = context.getPackageManager().getPackageInfo(module,
- MATCH_APEX);
- long actualVersion = info.getLongVersionCode();
- assumeTrue("Assumed Module " + module + " minVersion " + actualVersion + " >= "
- + minVersion,
- actualVersion >= minVersion);
+ long actualVersion = getModuleVersion(module);
+ assumeTrue("Assume module " + module + " version " + actualVersion + " < minVersion"
+ + minVersion, actualVersion >= minVersion);
} catch (PackageManager.NameNotFoundException e) {
- assumeNoException(e);
+ Assert.fail(e.getMessage());
}
}
+ /**
+ * Checks if {@code module} is < {@code minVersion}
+ *
+ * <p>
+ * {@link AssumptionViolatedException} is not handled properly by {@code JUnit3} so just return
+ * the test
+ * early instead.
+ *
+ * @param module the apex module name
+ * @param minVersion the minimum version
+ * @deprecated convert test to JUnit4 and use
+ * {@link #assumeMainlineModuleAtLeast(String, long)} instead.
+ */
+ @Deprecated
+ static boolean skipTestIfMainlineLessThan(String module, long minVersion) {
+ try {
+ long actualVersion = getModuleVersion(module);
+ if (actualVersion < minVersion) {
+ Log.i(TAG, "Skipping test because Module " + module + " minVersion " + minVersion
+ + " > "
+ + minVersion
+ );
+ return true;
+ } else {
+ return false;
+ }
+ } catch (PackageManager.NameNotFoundException e) {
+ Assert.fail(e.getMessage());
+ return false;
+ }
+ }
+
+ private static long getModuleVersion(String module)
+ throws PackageManager.NameNotFoundException {
+ Context context = ApplicationProvider.getApplicationContext();
+ PackageInfo info;
+ info = context.getPackageManager().getPackageInfo(module,
+ MATCH_APEX);
+ return info.getLongVersionCode();
+ }
+
+
private TestUtils() {
}
diff --git a/tests/tests/mediatranscoding/src/android/media/mediatranscoding/cts/MediaTranscodeManagerTest.java b/tests/tests/mediatranscoding/src/android/media/mediatranscoding/cts/MediaTranscodeManagerTest.java
index bda7f19..14d0cb6 100644
--- a/tests/tests/mediatranscoding/src/android/media/mediatranscoding/cts/MediaTranscodeManagerTest.java
+++ b/tests/tests/mediatranscoding/src/android/media/mediatranscoding/cts/MediaTranscodeManagerTest.java
@@ -475,7 +475,7 @@
afd = mContentResolver.openAssetFileDescriptor(destinationUri, "rw");
builder.setDestinationFileDescriptor(afd.getParcelFileDescriptor());
}
- TranscodingRequest request = builder.build();
+ VideoTranscodingRequest request = builder.build();
Executor listenerExecutor = Executors.newSingleThreadExecutor();
assertEquals(pid, request.getClientPid());
assertEquals(uid, request.getClientUid());
@@ -492,6 +492,7 @@
transcodeCompleteSemaphore.release();
});
assertNotNull(session);
+ assertTrue(compareFormat(videoTrackFormat, request.getVideoTrackFormat()));
if (session != null) {
Log.d(TAG, "testMediaTranscodeManager - Waiting for transcode to cancel.");
@@ -517,6 +518,10 @@
}
}
+ assertEquals(TranscodingSession.STATUS_FINISHED, session.getStatus());
+ assertEquals(TranscodingSession.RESULT_SUCCESS, session.getResult());
+ assertEquals(TranscodingSession.ERROR_NONE, session.getErrorCode());
+
// TODO(hkuang): Validate the transcoded video's width and height, framerate.
// Validates the transcoded video's psnr.
@@ -527,6 +532,17 @@
stats.mAveragePSNR >= PSNR_THRESHOLD);
}
+ private boolean compareFormat(MediaFormat fmt1, MediaFormat fmt2) {
+ if (fmt1 == fmt2) return true;
+ if (fmt1 == null || fmt2 == null) return false;
+
+ return (fmt1.getString(MediaFormat.KEY_MIME) == fmt2.getString(MediaFormat.KEY_MIME) &&
+ fmt1.getInteger(MediaFormat.KEY_WIDTH) == fmt2.getInteger(MediaFormat.KEY_WIDTH) &&
+ fmt1.getInteger(MediaFormat.KEY_HEIGHT) == fmt2.getInteger(MediaFormat.KEY_HEIGHT)
+ && fmt1.getInteger(MediaFormat.KEY_BIT_RATE) == fmt2.getInteger(
+ MediaFormat.KEY_BIT_RATE));
+ }
+
public void testCancelTranscoding() throws Exception {
if (shouldSkip()) {
return;
@@ -556,6 +572,8 @@
});
assertNotNull(session);
+ assertTrue(session.getSessionId() != -1);
+
// Wait for progress update before cancel the transcoding.
session.setOnProgressUpdateListener(listenerExecutor,
new TranscodingSession.OnProgressUpdateListener() {
@@ -564,6 +582,7 @@
if (newProgress > 0) {
statusLatch.countDown();
}
+ assertEquals(newProgress, session.getProgress());
}
});
@@ -573,6 +592,10 @@
Log.d(TAG, "testMediaTranscodeManager - Waiting for transcode to cancel.");
boolean finishedOnTime = transcodeCompleteSemaphore.tryAcquire(
30, TimeUnit.MILLISECONDS);
+
+ assertEquals(TranscodingSession.STATUS_FINISHED, session.getStatus());
+ assertEquals(TranscodingSession.RESULT_CANCELED, session.getResult());
+ assertEquals(TranscodingSession.ERROR_NONE, session.getErrorCode());
assertTrue("Fails to cancel transcoding", finishedOnTime);
}
diff --git a/tests/tests/notificationlegacy/notificationlegacy29/Android.bp b/tests/tests/notificationlegacy/notificationlegacy29/Android.bp
index 179a1bd..0d01e20 100644
--- a/tests/tests/notificationlegacy/notificationlegacy29/Android.bp
+++ b/tests/tests/notificationlegacy/notificationlegacy29/Android.bp
@@ -34,7 +34,6 @@
test_suites: [
"cts",
"general-tests",
- "mts-extservices"
],
sdk_version: "test_current",
target_sdk_version: "29",
diff --git a/tests/tests/notificationlegacy/notificationlegacy29/AndroidTest.xml b/tests/tests/notificationlegacy/notificationlegacy29/AndroidTest.xml
index fbfd309..9421128 100644
--- a/tests/tests/notificationlegacy/notificationlegacy29/AndroidTest.xml
+++ b/tests/tests/notificationlegacy/notificationlegacy29/AndroidTest.xml
@@ -29,8 +29,4 @@
<option name="runtime-hint" value="5m" />
<option name="hidden-api-checks" value="false" />
</test>
-
- <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController">
- <option name="mainline-module-package-name" value="com.google.android.extservices" />
- </object>
</configuration>
diff --git a/tests/tests/os/src/android/os/cts/BuildTest.java b/tests/tests/os/src/android/os/cts/BuildTest.java
index 19e2479..b089a39 100644
--- a/tests/tests/os/src/android/os/cts/BuildTest.java
+++ b/tests/tests/os/src/android/os/cts/BuildTest.java
@@ -322,13 +322,14 @@
+ " is invalid; must be at least VERSION_CODES.BASE",
Build.VERSION.SDK_INT >= Build.VERSION_CODES.BASE);
assertTrue(
- "First SDK version " + Build.VERSION.FIRST_SDK_INT
+ "First SDK version " + Build.VERSION.DEVICE_INITIAL_SDK_INT
+ " is invalid; must be at least VERSION_CODES.BASE",
- Build.VERSION.FIRST_SDK_INT >= Build.VERSION_CODES.BASE);
+ Build.VERSION.DEVICE_INITIAL_SDK_INT >= Build.VERSION_CODES.BASE);
assertTrue(
"Current SDK version " + Build.VERSION.SDK_INT
- + " must be at least first SDK version " + Build.VERSION.FIRST_SDK_INT,
- Build.VERSION.SDK_INT >= Build.VERSION.FIRST_SDK_INT);
+ + " must be at least first SDK version "
+ + Build.VERSION.DEVICE_INITIAL_SDK_INT,
+ Build.VERSION.SDK_INT >= Build.VERSION.DEVICE_INITIAL_SDK_INT);
}
/**
diff --git a/tests/tests/os/src/android/os/cts/CombinedVibrationEffectTest.java b/tests/tests/os/src/android/os/cts/CombinedVibrationTest.java
similarity index 67%
rename from tests/tests/os/src/android/os/cts/CombinedVibrationEffectTest.java
rename to tests/tests/os/src/android/os/cts/CombinedVibrationTest.java
index 90e38a7..8da9be8 100644
--- a/tests/tests/os/src/android/os/cts/CombinedVibrationEffectTest.java
+++ b/tests/tests/os/src/android/os/cts/CombinedVibrationTest.java
@@ -20,7 +20,7 @@
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.fail;
-import android.os.CombinedVibrationEffect;
+import android.os.CombinedVibration;
import android.os.Parcel;
import android.os.VibrationEffect;
@@ -34,60 +34,60 @@
@SmallTest
@RunWith(AndroidJUnit4.class)
-public class CombinedVibrationEffectTest {
+public class CombinedVibrationTest {
private static final VibrationEffect TEST_EFFECT =
VibrationEffect.get(VibrationEffect.EFFECT_CLICK);
- private static final CombinedVibrationEffect TEST_MONO =
- CombinedVibrationEffect.createSynced(TEST_EFFECT);
- private static final CombinedVibrationEffect TEST_STEREO =
- CombinedVibrationEffect.startSynced()
+ private static final CombinedVibration TEST_MONO =
+ CombinedVibration.createParallel(TEST_EFFECT);
+ private static final CombinedVibration TEST_STEREO =
+ CombinedVibration.startParallel()
.addVibrator(1, TEST_EFFECT)
.addVibrator(2, TEST_EFFECT)
.combine();
- private static final CombinedVibrationEffect TEST_SEQUENTIAL =
- CombinedVibrationEffect.startSequential()
+ private static final CombinedVibration TEST_SEQUENTIAL =
+ CombinedVibration.startSequential()
.addNext(TEST_MONO)
.addNext(1, TEST_EFFECT, /* delay= */ 100)
.combine();
@Test
- public void testCreateSynced() {
- CombinedVibrationEffect.Mono synced =
- (CombinedVibrationEffect.Mono) CombinedVibrationEffect.createSynced(TEST_EFFECT);
- assertEquals(TEST_EFFECT, synced.getEffect());
- assertEquals(TEST_EFFECT.getDuration(), synced.getDuration());
+ public void testcreateParallel() {
+ CombinedVibration.Mono mono =
+ (CombinedVibration.Mono) CombinedVibration.createParallel(TEST_EFFECT);
+ assertEquals(TEST_EFFECT, mono.getEffect());
+ assertEquals(TEST_EFFECT.getDuration(), mono.getDuration());
}
@Test
- public void testStartSynced() {
- CombinedVibrationEffect.Stereo synced =
- (CombinedVibrationEffect.Stereo) CombinedVibrationEffect.startSynced()
+ public void testStartParallel() {
+ CombinedVibration.Stereo stereo =
+ (CombinedVibration.Stereo) CombinedVibration.startParallel()
.addVibrator(1, TEST_EFFECT)
.combine();
- assertEquals(1, synced.getEffects().size());
- assertEquals(TEST_EFFECT, synced.getEffects().get(1));
- assertEquals(TEST_EFFECT.getDuration(), synced.getDuration());
+ assertEquals(1, stereo.getEffects().size());
+ assertEquals(TEST_EFFECT, stereo.getEffects().get(1));
+ assertEquals(TEST_EFFECT.getDuration(), stereo.getDuration());
}
@Test
- public void testStartSyncedEmptyCombinationIsInvalid() {
+ public void testStartParallelEmptyCombinationIsInvalid() {
try {
- CombinedVibrationEffect.startSynced().combine();
+ CombinedVibration.startParallel().combine();
fail("Illegal combination, should throw IllegalStateException");
} catch (IllegalStateException expected) {
}
}
@Test
- public void testSyncedEquals() {
- CombinedVibrationEffect otherMono = CombinedVibrationEffect.createSynced(
+ public void testParallelEquals() {
+ CombinedVibration otherMono = CombinedVibration.createParallel(
VibrationEffect.get(VibrationEffect.EFFECT_CLICK));
assertEquals(TEST_MONO, otherMono);
assertEquals(TEST_MONO.hashCode(), otherMono.hashCode());
- CombinedVibrationEffect otherStereo = CombinedVibrationEffect.startSynced()
+ CombinedVibration otherStereo = CombinedVibration.startParallel()
.addVibrator(1, VibrationEffect.get(VibrationEffect.EFFECT_CLICK))
.addVibrator(2, VibrationEffect.get(VibrationEffect.EFFECT_CLICK))
.combine();
@@ -96,15 +96,15 @@
}
@Test
- public void testSyncedNotEqualsDifferentEffect() {
- CombinedVibrationEffect otherMono = CombinedVibrationEffect.createSynced(
+ public void testParallelNotEqualsDifferentEffect() {
+ CombinedVibration otherMono = CombinedVibration.createParallel(
VibrationEffect.get(VibrationEffect.EFFECT_TICK));
assertNotEquals(TEST_MONO, otherMono);
}
@Test
- public void testSyncedNotEqualsDifferentVibrators() {
- CombinedVibrationEffect otherStereo = CombinedVibrationEffect.startSynced()
+ public void testParallelNotEqualsDifferentVibrators() {
+ CombinedVibration otherStereo = CombinedVibration.startParallel()
.addVibrator(5, TEST_EFFECT)
.combine();
assertNotEquals(TEST_STEREO, otherStereo);
@@ -112,15 +112,15 @@
@Test
public void testCreateSequential() {
- CombinedVibrationEffect.Sequential sequential =
- (CombinedVibrationEffect.Sequential) CombinedVibrationEffect.startSequential()
+ CombinedVibration.Sequential sequential =
+ (CombinedVibration.Sequential) CombinedVibration.startSequential()
.addNext(TEST_MONO)
.addNext(TEST_STEREO, /* delay= */ 100)
.addNext(1, TEST_EFFECT)
.combine();
assertEquals(
Arrays.asList(TEST_MONO, TEST_STEREO,
- CombinedVibrationEffect.startSynced().addVibrator(1,
+ CombinedVibration.startParallel().addVibrator(1,
TEST_EFFECT).combine()),
sequential.getEffects());
assertEquals(-1, sequential.getDuration());
@@ -129,7 +129,7 @@
@Test
public void testStartSequentialEmptyCombinationIsInvalid() {
try {
- CombinedVibrationEffect.startSequential().combine();
+ CombinedVibration.startSequential().combine();
fail("Illegal combination, should throw IllegalStateException");
} catch (IllegalStateException expected) {
}
@@ -137,8 +137,8 @@
@Test
public void testSequentialEquals() {
- CombinedVibrationEffect otherSequential =
- CombinedVibrationEffect.startSequential()
+ CombinedVibration otherSequential =
+ CombinedVibration.startSequential()
.addNext(TEST_MONO)
.addNext(1, TEST_EFFECT, /* delay= */ 100)
.combine();
@@ -148,8 +148,8 @@
@Test
public void testSequentialNotEqualsDifferentEffects() {
- CombinedVibrationEffect otherSequential =
- CombinedVibrationEffect.startSequential()
+ CombinedVibration otherSequential =
+ CombinedVibration.startSequential()
.addNext(TEST_STEREO)
.combine();
assertNotEquals(TEST_SEQUENTIAL, otherSequential);
@@ -157,8 +157,8 @@
@Test
public void testSequentialNotEqualsDifferentOrder() {
- CombinedVibrationEffect otherSequential =
- CombinedVibrationEffect.startSequential()
+ CombinedVibration otherSequential =
+ CombinedVibration.startSequential()
.addNext(1, TEST_EFFECT, /* delay= */ 100)
.addNext(TEST_MONO)
.combine();
@@ -167,8 +167,8 @@
@Test
public void testSequentialNotEqualsDifferentDelays() {
- CombinedVibrationEffect otherSequential =
- CombinedVibrationEffect.startSequential()
+ CombinedVibration otherSequential =
+ CombinedVibration.startSequential()
.addNext(TEST_MONO)
.addNext(1, TEST_EFFECT, /* delay= */ 1)
.combine();
@@ -177,8 +177,8 @@
@Test
public void testSequentialNotEqualsDifferentVibrator() {
- CombinedVibrationEffect otherSequential =
- CombinedVibrationEffect.startSequential()
+ CombinedVibration otherSequential =
+ CombinedVibration.startSequential()
.addNext(TEST_MONO)
.addNext(5, TEST_EFFECT, /* delay= */ 100)
.combine();
@@ -186,20 +186,20 @@
}
@Test
- public void testParcelingSyncedMono() {
+ public void testParcelingParallelMono() {
Parcel p = Parcel.obtain();
TEST_MONO.writeToParcel(p, 0);
p.setDataPosition(0);
- CombinedVibrationEffect parceled = CombinedVibrationEffect.CREATOR.createFromParcel(p);
+ CombinedVibration parceled = CombinedVibration.CREATOR.createFromParcel(p);
assertEquals(TEST_MONO, parceled);
}
@Test
- public void testParcelingSyncedStereo() {
+ public void testParcelingParallelStereo() {
Parcel p = Parcel.obtain();
TEST_STEREO.writeToParcel(p, 0);
p.setDataPosition(0);
- CombinedVibrationEffect parceled = CombinedVibrationEffect.CREATOR.createFromParcel(p);
+ CombinedVibration parceled = CombinedVibration.CREATOR.createFromParcel(p);
assertEquals(TEST_STEREO, parceled);
}
@@ -208,7 +208,7 @@
Parcel p = Parcel.obtain();
TEST_SEQUENTIAL.writeToParcel(p, 0);
p.setDataPosition(0);
- CombinedVibrationEffect parceled = CombinedVibrationEffect.CREATOR.createFromParcel(p);
+ CombinedVibration parceled = CombinedVibration.CREATOR.createFromParcel(p);
assertEquals(TEST_SEQUENTIAL, parceled);
}
@@ -227,15 +227,15 @@
}
@Test
- public void testSyncedMonoCombinationDuration() {
- CombinedVibrationEffect effect = CombinedVibrationEffect.createSynced(
+ public void testParallelMonoCombinationDuration() {
+ CombinedVibration effect = CombinedVibration.createParallel(
VibrationEffect.createOneShot(100, 100));
assertEquals(100, effect.getDuration());
}
@Test
- public void testSyncedStereoCombinationDuration() {
- CombinedVibrationEffect effect = CombinedVibrationEffect.startSynced()
+ public void testParallelStereoCombinationDuration() {
+ CombinedVibration effect = CombinedVibration.startParallel()
.addVibrator(1, VibrationEffect.createOneShot(1, 100))
.addVibrator(2, VibrationEffect.createOneShot(100, 100))
.addVibrator(3, VibrationEffect.createOneShot(10, 100))
@@ -244,8 +244,8 @@
}
@Test
- public void testSyncedCombinationUnknownDuration() {
- CombinedVibrationEffect effect = CombinedVibrationEffect.startSynced()
+ public void testParallelCombinationUnknownDuration() {
+ CombinedVibration effect = CombinedVibration.startParallel()
.addVibrator(1, VibrationEffect.get(VibrationEffect.EFFECT_CLICK))
.addVibrator(2, VibrationEffect.createOneShot(100, 100))
.combine();
@@ -253,8 +253,8 @@
}
@Test
- public void testSyncedCombinationRepeatingDuration() {
- CombinedVibrationEffect effect = CombinedVibrationEffect.startSynced()
+ public void testParallelCombinationRepeatingDuration() {
+ CombinedVibration effect = CombinedVibration.startParallel()
.addVibrator(1, VibrationEffect.createWaveform(new long[]{1}, new int[]{1}, 0))
.addVibrator(2, VibrationEffect.get(VibrationEffect.EFFECT_CLICK))
.addVibrator(3, VibrationEffect.createOneShot(100, 100))
@@ -264,7 +264,7 @@
@Test
public void testSequentialCombinationDuration() {
- CombinedVibrationEffect effect = CombinedVibrationEffect.startSequential()
+ CombinedVibration effect = CombinedVibration.startSequential()
.addNext(1, VibrationEffect.createOneShot(10, 100), /* delay= */ 1)
.addNext(1, VibrationEffect.createOneShot(10, 100), /* delay= */ 1)
.addNext(1, VibrationEffect.createOneShot(10, 100), /* delay= */ 1)
@@ -274,7 +274,7 @@
@Test
public void testSequentialCombinationUnknownDuration() {
- CombinedVibrationEffect effect = CombinedVibrationEffect.startSequential()
+ CombinedVibration effect = CombinedVibration.startSequential()
.addNext(1, VibrationEffect.get(VibrationEffect.EFFECT_CLICK))
.addNext(1, VibrationEffect.createOneShot(100, 100))
.combine();
@@ -283,7 +283,7 @@
@Test
public void testSequentialCombinationRepeatingDuration() {
- CombinedVibrationEffect effect = CombinedVibrationEffect.startSequential()
+ CombinedVibration effect = CombinedVibration.startSequential()
.addNext(1, VibrationEffect.createWaveform(new long[]{1}, new int[]{1}, 0))
.addNext(1, VibrationEffect.get(VibrationEffect.EFFECT_CLICK))
.addNext(1, VibrationEffect.createOneShot(100, 100))
diff --git a/tests/tests/os/src/android/os/cts/VibratorManagerTest.java b/tests/tests/os/src/android/os/cts/VibratorManagerTest.java
index ee7f974..398938bb 100644
--- a/tests/tests/os/src/android/os/cts/VibratorManagerTest.java
+++ b/tests/tests/os/src/android/os/cts/VibratorManagerTest.java
@@ -27,7 +27,7 @@
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
-import android.os.CombinedVibrationEffect;
+import android.os.CombinedVibration;
import android.os.SystemClock;
import android.os.VibrationAttributes;
import android.os.VibrationEffect;
@@ -98,7 +98,7 @@
@Test
public void testCancel() {
- mVibratorManager.vibrate(CombinedVibrationEffect.createSynced(
+ mVibratorManager.vibrate(CombinedVibration.createParallel(
VibrationEffect.createOneShot(10_000, VibrationEffect.DEFAULT_AMPLITUDE)));
assertStartsVibrating();
@@ -111,18 +111,18 @@
public void testVibrateOneShot() {
VibrationEffect oneShot =
VibrationEffect.createOneShot(300, VibrationEffect.DEFAULT_AMPLITUDE);
- mVibratorManager.vibrate(CombinedVibrationEffect.createSynced(oneShot));
+ mVibratorManager.vibrate(CombinedVibration.createParallel(oneShot));
assertStartsThenStopsVibrating(300);
oneShot = VibrationEffect.createOneShot(500, 255 /* Max amplitude */);
- mVibratorManager.vibrate(CombinedVibrationEffect.createSynced(oneShot));
+ mVibratorManager.vibrate(CombinedVibration.createParallel(oneShot));
assertStartsVibrating();
mVibratorManager.cancel();
assertStopsVibrating();
oneShot = VibrationEffect.createOneShot(100, 1 /* Min amplitude */);
- mVibratorManager.vibrate(CombinedVibrationEffect.createSynced(oneShot),
+ mVibratorManager.vibrate(CombinedVibration.createParallel(oneShot),
VIBRATION_ATTRIBUTES);
assertStartsVibrating();
}
@@ -133,11 +133,11 @@
final long[] timings = new long[]{100, 200, 300, 400, 500};
final int[] amplitudes = new int[]{64, 128, 255, 128, 64};
VibrationEffect waveform = VibrationEffect.createWaveform(timings, amplitudes, -1);
- mVibratorManager.vibrate(CombinedVibrationEffect.createSynced(waveform));
+ mVibratorManager.vibrate(CombinedVibration.createParallel(waveform));
assertStartsThenStopsVibrating(1500);
waveform = VibrationEffect.createWaveform(timings, amplitudes, 0);
- mVibratorManager.vibrate(CombinedVibrationEffect.createSynced(waveform));
+ mVibratorManager.vibrate(CombinedVibration.createParallel(waveform));
assertStartsVibrating();
mVibratorManager.cancel();
@@ -157,7 +157,7 @@
for (int vibratorId : vibratorIds) {
Vibrator vibrator = mVibratorManager.getVibrator(vibratorId);
mVibratorManager.vibrate(
- CombinedVibrationEffect.startSynced()
+ CombinedVibration.startParallel()
.addVibrator(vibratorId, oneShot)
.combine());
assertStartsVibrating(vibratorId);
diff --git a/tests/tests/permission/src/android/permission/cts/NfcPermissionTest.java b/tests/tests/permission/src/android/permission/cts/NfcPermissionTest.java
index a45fbf8..45dddb2 100644
--- a/tests/tests/permission/src/android/permission/cts/NfcPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/NfcPermissionTest.java
@@ -22,21 +22,35 @@
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
+import android.nfc.NfcAdapter;
+import android.nfc.NfcAdapter.ControllerAlwaysOnStateCallback;
import android.os.Process;
import androidx.test.InstrumentationRegistry;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.Arrays;
import java.util.List;
+import java.util.concurrent.Executor;
import java.util.stream.Collectors;
@RunWith(JUnit4.class)
public final class NfcPermissionTest {
+ private NfcAdapter mNfcAdapter;
+
+ @Before
+ public void setUp() {
+ mNfcAdapter = NfcAdapter.getDefaultAdapter(InstrumentationRegistry.getTargetContext());
+ }
+
+ /**
+ * Verifies that there's only one dedicated app holds the NfcSetControllerAlwaysOnPermission.
+ */
@Test
public void testNfcSetControllerAlwaysOnPermission() {
PackageManager pm = InstrumentationRegistry.getContext().getPackageManager();
@@ -63,4 +77,98 @@
+ "NFC_SET_CONTROLLER_ALWAYS_ON permission.");
}
}
+
+ /**
+ * Verifies that isControllerAlwaysOnSupported() requires Permission.
+ * <p>
+ * Requires Permission: {@link android.Manifest.permission#NFC_SET_CONTROLLER_ALWAYS_ON}.
+ */
+ @Test
+ public void testIsControllerAlwaysOnSupported() {
+ try {
+ mNfcAdapter.isControllerAlwaysOnSupported();
+ fail("mNfcAdapter.isControllerAlwaysOnSupported() did not throw SecurityException"
+ + " as expected");
+ } catch (SecurityException se) {
+ // Expected Exception
+ }
+ }
+
+ /**
+ * Verifies that isControllerAlwaysOn() requires Permission.
+ * <p>
+ * Requires Permission: {@link android.Manifest.permission#NFC_SET_CONTROLLER_ALWAYS_ON}.
+ */
+ @Test
+ public void testIsControllerAlwaysOn() {
+ try {
+ mNfcAdapter.isControllerAlwaysOn();
+ fail("mNfcAdapter.isControllerAlwaysOn() did not throw SecurityException"
+ + " as expected");
+ } catch (SecurityException se) {
+ // Expected Exception
+ }
+ }
+
+ /**
+ * Verifies that setControllerAlwaysOn(true) requires Permission.
+ * <p>
+ * Requires Permission: {@link android.Manifest.permission#NFC_SET_CONTROLLER_ALWAYS_ON}.
+ */
+ @Test
+ public void testSetControllerAlwaysOnTrue() {
+ try {
+ mNfcAdapter.setControllerAlwaysOn(true);
+ fail("mNfcAdapter.setControllerAlwaysOn(true) did not throw SecurityException"
+ + " as expected");
+ } catch (SecurityException se) {
+ // Expected Exception
+ }
+ }
+
+ /**
+ * Verifies that setControllerAlwaysOn(false) requires Permission.
+ * <p>
+ * Requires Permission: {@link android.Manifest.permission#NFC_SET_CONTROLLER_ALWAYS_ON}.
+ */
+ @Test
+ public void testSetControllerAlwaysOnFalse() {
+ try {
+ mNfcAdapter.setControllerAlwaysOn(false);
+ fail("mNfcAdapter.setControllerAlwaysOn(true) did not throw SecurityException"
+ + " as expected");
+ } catch (SecurityException se) {
+ // Expected Exception
+ }
+ }
+
+ /**
+ * Verifies that registerControllerAlwaysOnStateCallback() requires Permission.
+ * <p>
+ * Requires Permission: {@link android.Manifest.permission#NFC_SET_CONTROLLER_ALWAYS_ON}.
+ */
+ @Test
+ public void testRegisterControllerAlwaysOnStateCallback() {
+ try {
+ mNfcAdapter.registerControllerAlwaysOnStateCallback(
+ new SynchronousExecutor(), new AlwaysOnStateListener());
+ fail("mNfcAdapter.registerControllerAlwaysOnStateCallback did not throw"
+ + "SecurityException as expected");
+ } catch (SecurityException se) {
+ // Expected Exception
+ }
+ }
+
+ private class SynchronousExecutor implements Executor {
+ public void execute(Runnable r) {
+ r.run();
+ }
+ }
+
+ private class AlwaysOnStateListener implements ControllerAlwaysOnStateCallback {
+ @Override
+ public void onStateChanged(boolean isEnabled) {
+ // Do nothing
+ }
+ }
}
diff --git a/tests/tests/provider/src/android/provider/cts/media/MediaStoreTest.java b/tests/tests/provider/src/android/provider/cts/media/MediaStoreTest.java
index 949b691..ed33af8 100644
--- a/tests/tests/provider/src/android/provider/cts/media/MediaStoreTest.java
+++ b/tests/tests/provider/src/android/provider/cts/media/MediaStoreTest.java
@@ -212,7 +212,7 @@
final ProviderInfo legacy = getContext().getPackageManager()
.resolveContentProvider(MediaStore.AUTHORITY_LEGACY, 0);
if (legacy == null) {
- if (Build.VERSION.FIRST_SDK_INT >= Build.VERSION_CODES.R) {
+ if (Build.VERSION.DEVICE_INITIAL_SDK_INT >= Build.VERSION_CODES.R) {
// If we're a brand new device, we don't require a legacy
// provider, since there's nothing to upgrade
return;
diff --git a/tests/tests/shortcutmanager/src/android/content/pm/cts/shortcutmanager/ShortcutManagerClientApiTest.java b/tests/tests/shortcutmanager/src/android/content/pm/cts/shortcutmanager/ShortcutManagerClientApiTest.java
index 49c0354..a1475ff 100644
--- a/tests/tests/shortcutmanager/src/android/content/pm/cts/shortcutmanager/ShortcutManagerClientApiTest.java
+++ b/tests/tests/shortcutmanager/src/android/content/pm/cts/shortcutmanager/ShortcutManagerClientApiTest.java
@@ -25,14 +25,21 @@
import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.setDefaultLauncher;
import android.app.PendingIntent;
+import android.app.appsearch.AppSearchManager;
+import android.app.appsearch.SearchResult;
+import android.app.appsearch.SearchSpec;
import android.content.ComponentName;
import android.content.Intent;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
+import android.content.pm.Signature;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.test.suitebuilder.annotation.SmallTest;
+import android.util.ArraySet;
import com.android.compatibility.common.util.CddTest;
@@ -42,6 +49,13 @@
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
/**
* Tests for {@link ShortcutManager} and {@link ShortcutInfo}.
@@ -1414,6 +1428,62 @@
});
}
+ public void testUpdateShortcutVisibility_GrantShortcutAccess() throws Exception {
+ final List<byte[]> certs = new ArrayList<>(1);
+
+ // retrieve cert from package1
+ runWithCallerWithStrictMode(mPackageContext1, () -> {
+ try {
+ final PackageManager pm = mPackageContext1.getPackageManager();
+ final String pkgName = mPackageContext1.getPackageName();
+ PackageInfo packageInfo = pm.getPackageInfo(pkgName, PackageManager.GET_SIGNATURES);
+ for (Signature signature : packageInfo.signatures) {
+ MessageDigest sha256 = MessageDigest.getInstance("SHA-256");
+ certs.add(sha256.digest(signature.toByteArray()));
+ }
+ } catch (PackageManager.NameNotFoundException | NoSuchAlgorithmException e) {
+ }
+ });
+
+ // Push shortcuts for package2 and make them visible to package1
+ runWithCallerWithStrictMode(mPackageContext2, () -> {
+ final ShortcutManager manager = getManager();
+ for (byte[] cert : certs) {
+ manager.updateShortcutVisibility(mPackageContext1.getPackageName(), cert, true);
+ }
+ assertTrue(manager.setDynamicShortcuts(list(
+ makeShortcut("s1", "1a"),
+ makeShortcut("s2", "2a"),
+ makeShortcut("s3", "3a"))));
+ });
+
+ // Verify package1 can see these shortcuts
+ final Executor executor = Executors.newSingleThreadExecutor();
+ runWithCallerWithStrictMode(mPackageContext1, () -> {
+ final AppSearchManager apm = mPackageContext1.getSystemService(
+ AppSearchManager.class);
+ apm.createGlobalSearchSession(executor, res -> {
+ assertTrue(res.getErrorMessage(), res.isSuccess());
+ res.getResultValue().search("", new SearchSpec.Builder()
+ .setTermMatch(SearchSpec.TERM_MATCH_EXACT_ONLY).build()
+ ).getNextPage(executor, page -> {
+ assertTrue(page.getErrorMessage(), page.isSuccess());
+ final List<SearchResult> results = page.getResultValue();
+ final Set<String> shortcuts =
+ new ArraySet<>(results.size());
+ for (SearchResult result : results) {
+ shortcuts.add(result.getGenericDocument().getUri());
+ }
+ final Set<String> expected = new ArraySet<>(3);
+ expected.add("s1");
+ expected.add("s2");
+ expected.add("s3");
+ assertEquals("Unexpected results", expected, shortcuts);
+ });
+ });
+ });
+ }
+
public void testDisableAndEnableShortcut() {
runWithCallerWithStrictMode(mPackageContext1, () -> {
assertTrue(getManager().setDynamicShortcuts(list(
diff --git a/tests/tests/simpleperf/Android.mk b/tests/tests/simpleperf/Android.mk
index 351ff22..23e9245 100644
--- a/tests/tests/simpleperf/Android.mk
+++ b/tests/tests/simpleperf/Android.mk
@@ -21,7 +21,7 @@
libsimpleperf_etm_decoder \
libbacktrace \
libunwindstack \
- libdexfile_external_static \
+ libdexfile_static \
libziparchive \
libz \
libgtest \
diff --git a/tests/tests/telecom/src/android/telecom/cts/ThirdPartyCallScreeningServiceTest.java b/tests/tests/telecom/src/android/telecom/cts/ThirdPartyCallScreeningServiceTest.java
index 6deea62..0b1903b 100644
--- a/tests/tests/telecom/src/android/telecom/cts/ThirdPartyCallScreeningServiceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ThirdPartyCallScreeningServiceTest.java
@@ -378,20 +378,23 @@
contactUri = TestUtils.insertContact(mContentResolver,
TEST_OUTGOING_NUMBER.getSchemeSpecificPart());
}
- Bundle extras = new Bundle();
- extras.putParcelable(TestUtils.EXTRA_PHONE_NUMBER, TEST_OUTGOING_NUMBER);
- // Create a new outgoing call.
- placeAndVerifyCall(extras);
- if (addContact) {
- assertEquals(1, TestUtils.deleteContact(mContentResolver, contactUri));
+ try {
+ Bundle extras = new Bundle();
+ extras.putParcelable(TestUtils.EXTRA_PHONE_NUMBER, TEST_OUTGOING_NUMBER);
+ // Create a new outgoing call.
+ placeAndVerifyCall(extras);
+
+ mInCallCallbacks.getService().disconnectAllCalls();
+ assertNumCalls(mInCallCallbacks.getService(), 0);
+
+ // Wait for it to log.
+ callLogEntryLatch.await(ASYNC_TIMEOUT, TimeUnit.MILLISECONDS);
+ } finally {
+ if (addContact) {
+ assertEquals(1, TestUtils.deleteContact(mContentResolver, contactUri));
+ }
}
-
- mInCallCallbacks.getService().disconnectAllCalls();
- assertNumCalls(mInCallCallbacks.getService(), 0);
-
- // Wait for it to log.
- callLogEntryLatch.await(ASYNC_TIMEOUT, TimeUnit.MILLISECONDS);
}
private Uri addIncoming(boolean disconnectImmediately, boolean addContact) throws Exception {
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java b/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java
index 69e1901..d6dcecd 100644
--- a/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java
@@ -672,7 +672,7 @@
mTelephonyManager.getNetworkOperator();
ShellIdentityUtils.invokeMethodWithShellPermissions(mTelephonyManager,
(tm) -> tm.getPhoneAccountHandle(),
- "android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE");
+ "android.permission.READ_PRIVILEGED_PHONE_STATE");
mTelephonyManager.getSimCountryIso();
mTelephonyManager.getVoiceMailAlphaTag();
mTelephonyManager.isNetworkRoaming();
@@ -993,7 +993,7 @@
PhoneAccountHandle phoneAccountHandle = ShellIdentityUtils.invokeMethodWithShellPermissions(
mTelephonyManager,
(tm) -> tm.getPhoneAccountHandle(),
- "android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE");
+ "android.permission.READ_PRIVILEGED_PHONE_STATE");
assertEquals(phoneAccountHandle, defaultAccount);
}
diff --git a/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsServiceTest.java b/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsServiceTest.java
index 73ac9ac..f5f9804 100644
--- a/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsServiceTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsServiceTest.java
@@ -110,28 +110,57 @@
private static final int TEST_CONFIG_VALUE_INT = 0xDEADBEEF;
private static final String TEST_CONFIG_VALUE_STRING = "DEADBEEF";
- private static final String TEST_RCS_CONFIG_DEFAULT = "<RCSConfig>\n"
- + "\t<rcsVolteSingleRegistration>1</rcsVolteSingleRegistration>\n"
- + "\t<SERVICES>\n"
- + "\t\t<SupportedRCSProfileVersions>UP_2.0</SupportedRCSProfileVersions>\n"
- + "\t\t<ChatAuth>1</ChatAuth>\n"
- + "\t\t<GroupChatAuth>1</GroupChatAuth>\n"
- + "\t\t<ftAuth>1</ftAuth>\n"
- + "\t\t<standaloneMsgAuth>1</standaloneMsgAuth>\n"
- + "\t\t<geolocPushAuth>1</geolocPushAuth>\n"
- + "\t\t<Ext>\n"
- + "\t\t\t<DataOff>\n"
- + "\t\t\t\t<rcsMessagingDataOff>1</rcsMessagingDataOff>\n"
- + "\t\t\t\t<fileTransferDataOff>1</fileTransferDataOff>\n"
- + "\t\t\t\t<mmsDataOff>1</mmsDataOff>\n"
- + "\t\t\t\t<syncDataOff>1</syncDataOff>\n"
- + "\t\t\t</DataOff>\n"
- + "\t\t</Ext>\n"
- + "\t</SERVICES>\n"
- + "</RCSConfig>";
- private static final String TEST_RCS_CONFIG_SINGLE_REGISTRATION_DISABLED = "<RCSConfig>\n"
- + "\t<rcsVolteSingleRegistration>0</rcsVolteSingleRegistration>\n"
- + "</RCSConfig>";
+ private static final String TEST_RCS_CONFIG_DEFAULT = "<?xml version=\"1.0\"?>\n"
+ + "<wap-provisioningdoc version=\"1.1\">\n"
+ + "\t<characteristic type=\"APPLICATION\">\n"
+ + "\t\t<parm name=\"AppID\" value=\"urn:oma:mo:ext-3gpp-ims:1.0\"/>\n"
+ + "\t\t<characteristic type=\"3GPP_IMS\">\n"
+ + "\t\t\t<parm name=\"AppID\" value=\"ap2001\"/>\n"
+ + "\t\t\t<parm name=\"Name\" value=\"RCS IMS Settings\"/>\n"
+ + "\t\t\t<characteristic type=\"Ext\">\n"
+ + "\t\t\t\t<characteristic type=\"GSMA\">\n"
+ + "\t\t\t\t\t<parm name=\"AppRef\" value=\"IMS-Setting\"/>\n"
+ + "\t\t\t\t\t<parm name=\"rcsVolteSingleRegistration\" value=\"1\"/>\n"
+ + "\t\t\t\t</characteristic>\n"
+ + "\t\t\t</characteristic>\n"
+ + "\t\t</characteristic>\n"
+ + "\t\t<characteristic type=\"SERVICES\">\n"
+ + "\t\t\t<parm name=\"SupportedRCSProfileVersions\" value=\"UP2.3\"/>\n"
+ + "\t\t\t<parm name=\"ChatAuth\" value=\"1\"/>\n"
+ + "\t\t\t<parm name=\"GroupChatAuth\" value=\"1\"/>\n"
+ + "\t\t\t<parm name=\"ftAuth\" value=\"1\"/>\n"
+ + "\t\t\t<parm name=\"standaloneMsgAuth\" value=\"1\"/>\n"
+ + "\t\t\t<parm name=\"geolocPushAuth\" value=\"1\"/>\n"
+ + "\t\t\t<characteristic type=\"Ext\">\n"
+ + "\t\t\t\t<characteristic type=\"DataOff\">\n"
+ + "\t\t\t\t\t<parm name=\"rcsMessagingDataOff\" value=\"1\"/>\n"
+ + "\t\t\t\t\t<parm name=\"fileTransferDataOff\" value=\"1\"/>\n"
+ + "\t\t\t\t\t<parm name=\"mmsDataOff\" value=\"1\"/>\n"
+ + "\t\t\t\t\t<parm name=\"syncDataOff\" value=\"1\"/>\n"
+ + "\t\t\t\t\t<characteristic type=\"Ext\"/>\n"
+ + "\t\t\t\t</characteristic>\n"
+ + "\t\t\t</characteristic>\n"
+ + "\t\t</characteristic>\n"
+ + "\t</characteristic>\n"
+ + "</wap-provisioningdoc>\n";
+
+ private static final String TEST_RCS_CONFIG_SINGLE_REGISTRATION_DISABLED =
+ "<?xml version=\"1.0\"?>\n"
+ + "<wap-provisioningdoc version=\"1.1\">\n"
+ + "\t<characteristic type=\"APPLICATION\">\n"
+ + "\t\t<parm name=\"AppID\" value=\"urn:oma:mo:ext-3gpp-ims:1.0\"/>\n"
+ + "\t\t<characteristic type=\"3GPP_IMS\">\n"
+ + "\t\t\t<parm name=\"AppID\" value=\"ap2001\"/>\n"
+ + "\t\t\t<parm name=\"Name\" value=\"RCS IMS Settings\"/>\n"
+ + "\t\t\t<characteristic type=\"Ext\">\n"
+ + "\t\t\t\t<characteristic type=\"GSMA\">\n"
+ + "\t\t\t\t\t<parm name=\"AppRef\" value=\"IMS-Setting\"/>\n"
+ + "\t\t\t\t\t<parm name=\"rcsVolteSingleRegistration\" value=\"0\"/>\n"
+ + "\t\t\t\t</characteristic>\n"
+ + "\t\t\t</characteristic>\n"
+ + "\t\t</characteristic>\n"
+ + "\t</characteristic>\n"
+ + "</wap-provisioningdoc>\n";
private static final String TEST_RCS_PRE_CONFIG = "<RCSPreProvisiniongConfig>\n"
+ "\t<VERS>\n"
+ "\t\t<version>1</version>\n"
@@ -2772,7 +2801,7 @@
buildRcsProvisioningCallback(clientQueue, paramsQueue);
ProvisioningManager provisioningManager =
ProvisioningManager.createForSubscriptionId(sTestSub);
- String configStr = "<test01/>\n" + TEST_RCS_CONFIG_DEFAULT;
+ String configStr = TEST_RCS_CONFIG_DEFAULT;
//notify rcs configuration received, wait rcs gets ready and receives notification
try {
@@ -2802,7 +2831,7 @@
assertTrue(Arrays.equals(
configStr.getBytes(), TestAcsClient.getInstance().getConfig()));
- configStr = "<test02/>\n" + TEST_RCS_CONFIG_DEFAULT;
+ configStr = TEST_RCS_CONFIG_SINGLE_REGISTRATION_DISABLED;
try {
automan.adoptShellPermissionIdentity();
provisioningManager.notifyRcsAutoConfigurationReceived(
diff --git a/tests/tests/telephonyprovider/src/android/telephonyprovider/cts/ServiceStateTest.java b/tests/tests/telephonyprovider/src/android/telephonyprovider/cts/ServiceStateTest.java
index 7318e8b..9c21aa9 100644
--- a/tests/tests/telephonyprovider/src/android/telephonyprovider/cts/ServiceStateTest.java
+++ b/tests/tests/telephonyprovider/src/android/telephonyprovider/cts/ServiceStateTest.java
@@ -16,6 +16,7 @@
package android.telephonyprovider.cts;
+import static android.content.pm.PackageManager.FEATURE_TELEPHONY;
import static android.provider.Telephony.ServiceStateTable.DATA_NETWORK_TYPE;
import static android.provider.Telephony.ServiceStateTable.DATA_REG_STATE;
import static android.provider.Telephony.ServiceStateTable.DUPLEX_MODE;
@@ -27,6 +28,8 @@
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
+import static org.junit.Assume.assumeTrue;
+
import android.Manifest;
import android.content.ContentResolver;
import android.content.ContentValues;
@@ -71,6 +74,8 @@
@Before
public void setUp() {
+ assumeTrue(hasTelephonyFeature());
+
mContentResolver = getInstrumentation().getContext().getContentResolver();
mTelephonyManager =
getInstrumentation().getContext().getSystemService(TelephonyManager.class);
@@ -80,6 +85,10 @@
@After
public void tearDown() {
+ if (!hasTelephonyFeature()) {
+ return;
+ }
+
// Recover the initial ServiceState to remove the impact of manual ServiceState insertion.
insertServiceState(mInitialServiceState);
}
@@ -379,4 +388,9 @@
mObserved.add(uri);
}
}
+
+ private static boolean hasTelephonyFeature() {
+ return getInstrumentation().getContext().getPackageManager().hasSystemFeature(
+ FEATURE_TELEPHONY);
+ }
}
diff --git a/tests/tests/time/src/android/service/timezone/cts/TimeZoneProviderSuggestionTest.java b/tests/tests/time/src/android/service/timezone/cts/TimeZoneProviderSuggestionTest.java
index 3b6a85c..ae4a14d 100644
--- a/tests/tests/time/src/android/service/timezone/cts/TimeZoneProviderSuggestionTest.java
+++ b/tests/tests/time/src/android/service/timezone/cts/TimeZoneProviderSuggestionTest.java
@@ -42,6 +42,17 @@
}
@Test
+ public void testAccessors() {
+ TimeZoneProviderSuggestion suggestion = new TimeZoneProviderSuggestion.Builder()
+ .setTimeZoneIds(ARBITRARY_TIME_ZONE_IDS)
+ .setElapsedRealtimeMillis(ARBITRARY_ELAPSED_REALTIME_MILLIS)
+ .build();
+
+ assertEquals(ARBITRARY_TIME_ZONE_IDS, suggestion.getTimeZoneIds());
+ assertEquals(ARBITRARY_ELAPSED_REALTIME_MILLIS, suggestion.getElapsedRealtimeMillis());
+ }
+
+ @Test
public void testEquals() {
TimeZoneProviderSuggestion.Builder builder1 = new TimeZoneProviderSuggestion.Builder()
.setElapsedRealtimeMillis(ARBITRARY_ELAPSED_REALTIME_MILLIS);
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/EdgeEffectTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/EdgeEffectTests.java
index 3fc9273..6dec22e 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/EdgeEffectTests.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/EdgeEffectTests.java
@@ -344,6 +344,22 @@
}
@Test
+ public void testInvalidPullDistanceDoesNotCrash() {
+ EdgeEffect edgeEffect = new EdgeEffect(getContext());
+ edgeEffect.setType(EdgeEffect.TYPE_STRETCH);
+ // Verify that bad inputs to onPull do not crash
+ edgeEffect.onPull(Float.NaN, Float.NaN);
+
+ edgeEffect.setSize(TEST_WIDTH, TEST_HEIGHT);
+ RenderNode node = new RenderNode("");
+ node.setPosition(0, 0, TEST_WIDTH, TEST_HEIGHT);
+ RecordingCanvas canvas = node.beginRecording();
+
+ edgeEffect.draw(canvas);
+ node.endRecording();
+ }
+
+ @Test
public void testAbsorbThenDrawDoesNotCrash() {
MockVsyncHelper.runOnVsyncThread(() -> {
EdgeEffect edgeEffect = new EdgeEffect(getContext());
diff --git a/tests/tests/view/src/android/view/cts/input/InputDeviceVibratorManagerTest.java b/tests/tests/view/src/android/view/cts/input/InputDeviceVibratorManagerTest.java
index 9a46a3d..fca9854 100644
--- a/tests/tests/view/src/android/view/cts/input/InputDeviceVibratorManagerTest.java
+++ b/tests/tests/view/src/android/view/cts/input/InputDeviceVibratorManagerTest.java
@@ -22,7 +22,7 @@
import android.app.Instrumentation;
import android.hardware.input.InputManager;
-import android.os.CombinedVibrationEffect;
+import android.os.CombinedVibration;
import android.os.SystemClock;
import android.os.VibrationEffect;
import android.os.Vibrator;
@@ -155,7 +155,7 @@
final long totalVibrations = testData.durations.size();
long timeoutMills = 0;
- CombinedVibrationEffect.SyncedCombination comb = CombinedVibrationEffect.startSynced();
+ CombinedVibration.ParallelCombination comb = CombinedVibration.startParallel();
final int[] ids = mVibratorManager.getVibratorIds();
for (int i = 0; i < testData.amplitudes.size(); i++) {
@@ -181,14 +181,14 @@
}
if (testData.amplitudes.size() == 1) {
- CombinedVibrationEffect mono = CombinedVibrationEffect.createSynced(effect);
+ CombinedVibration mono = CombinedVibration.createParallel(effect);
// Start vibration
mVibratorManager.vibrate(mono);
} else { // testData.amplitudes.size() == 2
comb.addVibrator(ids[i], effect);
if (i > 0) {
// Start vibration
- CombinedVibrationEffect stereo = comb.combine();
+ CombinedVibration stereo = comb.combine();
mVibratorManager.vibrate(stereo);
}
}
@@ -222,12 +222,12 @@
@Test
public void testUnsupportedVibrationEffectsPreBaked() {
final int[] ids = mVibratorManager.getVibratorIds();
- CombinedVibrationEffect.SyncedCombination comb = CombinedVibrationEffect.startSynced();
+ CombinedVibration.ParallelCombination comb = CombinedVibration.startParallel();
for (int i = 0; i < ids.length; i++) {
comb.addVibrator(ids[i], VibrationEffect.createPredefined(
VibrationEffect.EFFECT_CLICK));
}
- CombinedVibrationEffect stereo = comb.combine();
+ CombinedVibration stereo = comb.combine();
mVibratorManager.vibrate(stereo);
// Shouldn't get any vibrations for unsupported effects
assertEquals(0, getVibrationCount(1 /* totalVibrations */, 1000 /* timeoutMills */));
@@ -236,12 +236,12 @@
@Test
public void testMixedVibrationEffectsOneShotAndPreBaked() {
final int[] ids = mVibratorManager.getVibratorIds();
- CombinedVibrationEffect.SyncedCombination comb = CombinedVibrationEffect.startSynced();
+ CombinedVibration.ParallelCombination comb = CombinedVibration.startParallel();
comb.addVibrator(ids[0], VibrationEffect.createOneShot(1000,
VibrationEffect.DEFAULT_AMPLITUDE));
comb.addVibrator(ids[1], VibrationEffect.createPredefined(
VibrationEffect.EFFECT_CLICK));
- CombinedVibrationEffect stereo = comb.combine();
+ CombinedVibration stereo = comb.combine();
mVibratorManager.vibrate(stereo);
// Shouldn't get any vibrations for combination of OneShot and Prebaked.
// Prebaked effect is not supported by input device vibrator, if the second effect
@@ -252,12 +252,12 @@
@Test
public void testMixedVibrationEffectsPreBakedAndOneShot() {
final int[] ids = mVibratorManager.getVibratorIds();
- CombinedVibrationEffect.SyncedCombination comb = CombinedVibrationEffect.startSynced();
+ CombinedVibration.ParallelCombination comb = CombinedVibration.startParallel();
comb.addVibrator(ids[0], VibrationEffect.createPredefined(
VibrationEffect.EFFECT_CLICK));
comb.addVibrator(ids[1], VibrationEffect.createOneShot(1000,
VibrationEffect.DEFAULT_AMPLITUDE));
- CombinedVibrationEffect stereo = comb.combine();
+ CombinedVibration stereo = comb.combine();
mVibratorManager.vibrate(stereo);
// Shouldn't get any vibrations for combination of Prebaked and OneShot.
// Prebaked effect is not supported by input device vibrator, if the first effect
@@ -266,10 +266,9 @@
}
@Test
- public void testCombinedVibrationEffectsSingleVibratorId() {
+ public void testCombinedVibrationOnSingleVibratorId() {
final int[] ids = mVibratorManager.getVibratorIds();
- CombinedVibrationEffect.SyncedCombination comb = CombinedVibrationEffect.startSynced();
- int[] vibratorIds = mVibratorManager.getVibratorIds();
+ CombinedVibration.ParallelCombination comb = CombinedVibration.startParallel();
comb.addVibrator(ids[0], VibrationEffect.createOneShot(1000,
VibrationEffect.DEFAULT_AMPLITUDE));
mVibratorManager.vibrate(comb.combine());
diff --git a/tests/tests/widget/res/layout/remoteviews_good.xml b/tests/tests/widget/res/layout/remoteviews_good.xml
index 1878890..c0f2abb 100644
--- a/tests/tests/widget/res/layout/remoteviews_good.xml
+++ b/tests/tests/widget/res/layout/remoteviews_good.xml
@@ -17,6 +17,7 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/remoteViews_good"
+ android:theme="@style/Theme.DeviceDefault.DayNight.TestWidget"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
diff --git a/tests/tests/widget/res/values-night/themes.xml b/tests/tests/widget/res/values-night/themes.xml
new file mode 100644
index 0000000..8791f1e
--- /dev/null
+++ b/tests/tests/widget/res/values-night/themes.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2021 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.
+ -->
+<resources>
+ <style name="Theme.DeviceDefault.DayNight.TestWidget"
+ parent="@android:style/Theme.DeviceDefault.DayNight">
+ <item name="themeDimension">@dimen/remoteviews_theme_dimen</item>
+ <item name="themeDimension2">4.5dp</item>
+ <item name="themeDimension3">5.5dp</item>
+ <item name="themeDimension4">6.5dp</item>
+ <item name="themeColor">#0f00ffff</item>
+ <item name="themeString">Night</item>
+ </style>
+</resources>
\ No newline at end of file
diff --git a/tests/tests/widget/res/values/attrs.xml b/tests/tests/widget/res/values/attrs.xml
index b2bea6f..cff1d56 100644
--- a/tests/tests/widget/res/values/attrs.xml
+++ b/tests/tests/widget/res/values/attrs.xml
@@ -142,6 +142,10 @@
<attr name="themeGravity" />
<attr name="themeTileMode" />
<attr name="themeAngle" />
+ <attr name="themeDimension2" />
+ <attr name="themeDimension3" />
+ <attr name="themeDimension4" />
+ <attr name="themeString" />
<attr name="chronometerStyle" format="string" />
diff --git a/tests/tests/widget/res/values/colors.xml b/tests/tests/widget/res/values/colors.xml
index c947b7a..1b97411 100644
--- a/tests/tests/widget/res/values/colors.xml
+++ b/tests/tests/widget/res/values/colors.xml
@@ -34,4 +34,6 @@
<color name="calendarview_unfocusedmonthdate_new">#4070F0F0</color>
<color name="calendarview_week_number_new">#9090FF</color>
<color name="calendarview_week_separatorline_new">#AFAF00</color>
+
+ <color name="remoteviews_theme_color">#0f00ff00</color>
</resources>
diff --git a/tests/tests/widget/res/values/dimens.xml b/tests/tests/widget/res/values/dimens.xml
index da31065..46f9eda 100644
--- a/tests/tests/widget/res/values/dimens.xml
+++ b/tests/tests/widget/res/values/dimens.xml
@@ -62,4 +62,5 @@
<dimen name="listviewfixed_layout_height">300dp</dimen>
<dimen name="remoteviews_float_dimen">4.5dp</dimen>
+ <dimen name="remoteviews_theme_dimen">7.5123dp</dimen>
</resources>
diff --git a/tests/tests/widget/res/values/strings.xml b/tests/tests/widget/res/values/strings.xml
index 91084e9..0bb9976 100644
--- a/tests/tests/widget/res/values/strings.xml
+++ b/tests/tests/widget/res/values/strings.xml
@@ -215,4 +215,6 @@
<string name="radio_choice_1">choice 1</string>
<string name="radio_choice_2">choice 2</string>
<string name="radio_choice_3">choice 3</string>
+
+ <string name="remoteviews_theme_string">Day</string>
</resources>
diff --git a/tests/tests/widget/res/values/themes.xml b/tests/tests/widget/res/values/themes.xml
new file mode 100644
index 0000000..bbce31f
--- /dev/null
+++ b/tests/tests/widget/res/values/themes.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2021 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.
+ -->
+<resources>
+ <style name="Theme.DeviceDefault.DayNight.TestWidget"
+ parent="@android:style/Theme.DeviceDefault.DayNight">
+ <item name="themeDimension">5.5123dp</item>
+ <item name="themeDimension2">2.5dp</item>
+ <item name="themeDimension3">3.5dp</item>
+ <item name="themeDimension4">4.5dp</item>
+ <item name="themeColor">@color/remoteviews_theme_color</item>
+ <item name="themeString">@string/remoteviews_theme_string</item>
+ </style>
+</resources>
\ No newline at end of file
diff --git a/tests/tests/widget/src/android/widget/cts/RemoteViewsTest.java b/tests/tests/widget/src/android/widget/cts/RemoteViewsTest.java
index 2c78dfe..61a939b 100644
--- a/tests/tests/widget/src/android/widget/cts/RemoteViewsTest.java
+++ b/tests/tests/widget/src/android/widget/cts/RemoteViewsTest.java
@@ -34,6 +34,7 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import android.app.Activity;
@@ -232,9 +233,8 @@
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
assertEquals("", textView.getText().toString());
- mExpectedException.expect(ActionException.class);
mRemoteViews.setTextViewText(R.id.remoteView_absolute, "");
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -246,9 +246,8 @@
assertEquals(mContext.getResources().getDisplayMetrics().scaledDensity * 18,
textView.getTextSize(), 0.001f);
- mExpectedException.expect(Throwable.class);
mRemoteViews.setTextViewTextSize(R.id.remoteView_absolute, TypedValue.COMPLEX_UNIT_SP, 20);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(Throwable.class);
}
@Test
@@ -272,13 +271,13 @@
Icon iconDark = Icon.createWithResource(mContext, R.drawable.icon_blue);
mRemoteViews.setIcon(R.id.remoteView_image, "setImageIcon", iconLight, iconDark);
- applyNightModeThenTest(false, () -> {
+ applyNightModeThenReapplyAndTest(false, () -> {
assertNotNull(image.getDrawable());
BitmapDrawable dLight = (BitmapDrawable) mContext.getDrawable(R.drawable.icon_green);
WidgetTestUtils.assertEquals(dLight.getBitmap(),
((BitmapDrawable) image.getDrawable()).getBitmap());
});
- applyNightModeThenTest(true, () -> {
+ applyNightModeThenReapplyAndTest(true, () -> {
assertNotNull(image.getDrawable());
BitmapDrawable dDark = (BitmapDrawable) mContext.getDrawable(R.drawable.icon_blue);
WidgetTestUtils.assertEquals(dDark.getBitmap(),
@@ -313,9 +312,8 @@
WidgetTestUtils.assertEquals(d.getBitmap(),
((BitmapDrawable) image.getDrawable()).getBitmap());
- mExpectedException.expect(ActionException.class);
mRemoteViews.setImageViewResource(R.id.remoteView_absolute, R.drawable.testimage);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -373,9 +371,8 @@
assertEquals(base1, chronometer.getBase());
assertEquals("invalid", chronometer.getFormat());
- mExpectedException.expect(ActionException.class);
mRemoteViews.setChronometer(R.id.remoteView_absolute, base1, "invalid", true);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -390,9 +387,8 @@
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
assertFalse(chronometer.isCountDown());
- mExpectedException.expect(ActionException.class);
mRemoteViews.setChronometerCountDown(R.id.remoteView_absolute, true);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -416,9 +412,8 @@
assertEquals(50, progress.getProgress());
assertFalse(progress.isIndeterminate());
- mExpectedException.expect(ActionException.class);
mRemoteViews.setProgressBar(R.id.remoteView_relative, 60, 50, false);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -540,9 +535,8 @@
assertNotNull(image.getDrawable());
WidgetTestUtils.assertEquals(bitmap, ((BitmapDrawable) image.getDrawable()).getBitmap());
- mExpectedException.expect(ActionException.class);
mRemoteViews.setImageViewBitmap(R.id.remoteView_absolute, bitmap);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -557,9 +551,8 @@
assertNotNull(image.getDrawable());
WidgetTestUtils.assertEquals(bitmap, ((BitmapDrawable) image.getDrawable()).getBitmap());
- mExpectedException.expect(ActionException.class);
mRemoteViews.setBitmap(R.id.remoteView_absolute, "setImageBitmap", bitmap);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -572,9 +565,8 @@
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
assertTrue(progress.isIndeterminate());
- mExpectedException.expect(ActionException.class);
mRemoteViews.setBoolean(R.id.remoteView_relative, "setIndeterminate", false);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -591,9 +583,26 @@
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
assertEquals("", textView.getText().toString());
- mExpectedException.expect(ActionException.class);
mRemoteViews.setCharSequence(R.id.remoteView_absolute, "setText", "");
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
+ }
+
+ @Test
+ public void testSetCharSequenceAttr() throws Throwable {
+ mRemoteViews.setCharSequenceAttr(R.id.remoteView_text, "setText", R.attr.themeString);
+ applyNightModeThenApplyAndTest(false, () -> {
+ TextView textView = (TextView) mResult.findViewById(R.id.remoteView_text);
+ assertEquals("Day", textView.getText().toString());
+ });
+
+ applyNightModeThenApplyAndTest(true, () -> {
+ TextView textView = (TextView) mResult.findViewById(R.id.remoteView_text);
+ assertEquals("Night", textView.getText().toString());
+ });
+
+ mRemoteViews.setCharSequenceAttr(R.id.remoteView_absolute, "setText",
+ R.attr.themeColor);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -624,9 +633,8 @@
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
assertEquals(format, chronometer.getFormat());
- mExpectedException.expect(ActionException.class);
mRemoteViews.setString(R.id.remoteView_image, "setFormat", format);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -649,9 +657,8 @@
mContext.getResources(), R.raw.testimage, imageViewBitmap.getConfig());
WidgetTestUtils.assertEquals(expectedBitmap, imageViewBitmap);
- mExpectedException.expect(ActionException.class);
mRemoteViews.setUri(R.id.remoteView_absolute, "setImageURI", uri);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
} finally {
// remove the test image file
imagefile.delete();
@@ -670,9 +677,8 @@
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
assertSame(ColorStateList.valueOf(R.color.testcolor2), textView.getTextColors());
- mExpectedException.expect(ActionException.class);
mRemoteViews.setTextColor(R.id.remoteView_absolute, R.color.testcolor1);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -693,10 +699,9 @@
TestUtils.verifyCompoundDrawables(textView, -1, R.drawable.icon_red, R.drawable.icon_black,
R.drawable.icon_green);
- mExpectedException.expect(Throwable.class);
mRemoteViews.setTextViewCompoundDrawables(R.id.remoteView_absolute, 0,
R.drawable.start, R.drawable.failed, 0);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(Throwable.class);
}
@Test
@@ -727,10 +732,9 @@
TestUtils.verifyCompoundDrawables(textViewRtl, R.drawable.icon_red, -1,
R.drawable.icon_black, R.drawable.icon_green);
- mExpectedException.expect(Throwable.class);
mRemoteViews.setTextViewCompoundDrawablesRelative(R.id.remoteView_absolute, 0,
R.drawable.start, R.drawable.failed, 0);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(Throwable.class);
}
@LargeTest
@@ -811,9 +815,8 @@
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
assertEquals(base2, chronometer.getBase());
- mExpectedException.expect(ActionException.class);
mRemoteViews.setLong(R.id.remoteView_absolute, "setBase", base1);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -825,9 +828,8 @@
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
assertEquals(0.5f, linearLayout.getWeightSum(), 0.001f);
- mExpectedException.expect(ActionException.class);
mRemoteViews.setFloat(R.id.remoteView_absolute, "setWeightSum", 1.0f);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -840,9 +842,8 @@
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
assertEquals(b, customView.getByteField());
- mExpectedException.expect(ActionException.class);
mRemoteViews.setByte(R.id.remoteView_absolute, "setByteField", b);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -854,9 +855,8 @@
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
assertEquals('q', customView.getCharField());
- mExpectedException.expect(ActionException.class);
mRemoteViews.setChar(R.id.remoteView_absolute, "setCharField", 'w');
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -868,9 +868,8 @@
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
assertEquals(0.5, customView.getDoubleField(), 0.001f);
- mExpectedException.expect(ActionException.class);
mRemoteViews.setDouble(R.id.remoteView_absolute, "setDoubleField", 1.0);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -883,9 +882,8 @@
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
assertEquals(s, customView.getShortField());
- mExpectedException.expect(ActionException.class);
mRemoteViews.setShort(R.id.remoteView_absolute, "setShortField", s);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -902,9 +900,8 @@
assertEquals("brexit", fromRemote.getString("STR", ""));
assertEquals(2016, fromRemote.getInt("INT", 0));
- mExpectedException.expect(ActionException.class);
mRemoteViews.setBundle(R.id.remoteView_absolute, "setBundleField", bundle);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -922,9 +919,8 @@
assertEquals("brexit", fromRemote.getStringExtra("STR"));
assertEquals(2016, fromRemote.getIntExtra("INT", 0));
- mExpectedException.expect(ActionException.class);
mRemoteViews.setIntent(R.id.remoteView_absolute, "setIntentField", intent);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -1143,6 +1139,83 @@
}
@Test
+ public void testSetViewLayoutMarginAttr() throws Throwable {
+ mRemoteViews.setViewLayoutMarginAttr(
+ R.id.remoteView_text, MARGIN_LEFT, R.attr.themeDimension);
+ mRemoteViews.setViewLayoutMarginAttr(
+ R.id.remoteView_text, MARGIN_TOP, R.attr.themeDimension2);
+ mRemoteViews.setViewLayoutMarginAttr(
+ R.id.remoteView_text, MARGIN_RIGHT, R.attr.themeDimension3);
+ mRemoteViews.setViewLayoutMarginAttr(
+ R.id.remoteView_text, MARGIN_BOTTOM, R.attr.themeDimension4);
+
+ applyNightModeThenApplyAndTest(false, () -> {
+ View textView = mResult.findViewById(R.id.remoteView_text);
+ DisplayMetrics displayMetrics = textView.getResources().getDisplayMetrics();
+ assertMargins(
+ textView,
+ resolveDimenOffset(5.5f, COMPLEX_UNIT_DIP, displayMetrics),
+ resolveDimenOffset(2.5f, COMPLEX_UNIT_DIP, displayMetrics),
+ resolveDimenOffset(3.5f, COMPLEX_UNIT_DIP, displayMetrics),
+ resolveDimenOffset(4.5f, COMPLEX_UNIT_DIP, displayMetrics));
+ });
+
+ applyNightModeThenApplyAndTest(true, () -> {
+ View textView = mResult.findViewById(R.id.remoteView_text);
+ DisplayMetrics displayMetrics = textView.getResources().getDisplayMetrics();
+ assertMargins(
+ textView,
+ resolveDimenOffset(7.5123f, COMPLEX_UNIT_DIP, displayMetrics),
+ resolveDimenOffset(4.5f, COMPLEX_UNIT_DIP, displayMetrics),
+ resolveDimenOffset(5.5f, COMPLEX_UNIT_DIP, displayMetrics),
+ resolveDimenOffset(6.5f, COMPLEX_UNIT_DIP, displayMetrics));
+ });
+
+ mRemoteViews.setViewLayoutMarginAttr(
+ R.id.remoteView_text, MARGIN_LEFT, R.attr.themeColor);
+ assertThrowsOnReapply(ActionException.class);
+ }
+
+ @Test
+ public void testSetViewLayoutMarginAttr_layoutDirection() throws Throwable {
+ View textViewLtr = mResult.findViewById(R.id.remoteView_text_ltr);
+ DisplayMetrics displayMetrics = textViewLtr.getResources().getDisplayMetrics();
+ mRemoteViews.setViewLayoutMarginAttr(
+ R.id.remoteView_text_ltr, MARGIN_START, R.attr.themeDimension);
+ mRemoteViews.setViewLayoutMarginAttr(
+ R.id.remoteView_text_ltr, MARGIN_TOP, R.attr.themeDimension2);
+ mRemoteViews.setViewLayoutMarginAttr(
+ R.id.remoteView_text_ltr, MARGIN_END, R.attr.themeDimension3);
+ mRemoteViews.setViewLayoutMarginAttr(
+ R.id.remoteView_text_ltr, MARGIN_BOTTOM, R.attr.themeDimension4);
+ mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
+ assertMargins(
+ textViewLtr,
+ resolveDimenOffset(5.5f, COMPLEX_UNIT_DIP, displayMetrics),
+ resolveDimenOffset(2.5f, COMPLEX_UNIT_DIP, displayMetrics),
+ resolveDimenOffset(3.5f, COMPLEX_UNIT_DIP, displayMetrics),
+ resolveDimenOffset(4.5f, COMPLEX_UNIT_DIP, displayMetrics));
+
+ View textViewRtl = mResult.findViewById(R.id.remoteView_text_rtl);
+ displayMetrics = textViewRtl.getResources().getDisplayMetrics();
+ mRemoteViews.setViewLayoutMarginAttr(
+ R.id.remoteView_text_rtl, MARGIN_START, R.attr.themeDimension);
+ mRemoteViews.setViewLayoutMarginAttr(
+ R.id.remoteView_text_rtl, MARGIN_TOP, R.attr.themeDimension2);
+ mRemoteViews.setViewLayoutMarginAttr(
+ R.id.remoteView_text_rtl, MARGIN_END, R.attr.themeDimension3);
+ mRemoteViews.setViewLayoutMarginAttr(
+ R.id.remoteView_text_rtl, MARGIN_BOTTOM, R.attr.themeDimension4);
+ mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
+ assertMargins(
+ textViewRtl,
+ resolveDimenOffset(3.5f, COMPLEX_UNIT_DIP, displayMetrics),
+ resolveDimenOffset(2.5f, COMPLEX_UNIT_DIP, displayMetrics),
+ resolveDimenOffset(5.5123f, COMPLEX_UNIT_DIP, displayMetrics),
+ resolveDimenOffset(4.5f, COMPLEX_UNIT_DIP, displayMetrics));
+ }
+
+ @Test
public void testSetViewLayoutWidth() throws Throwable {
View textView = mResult.findViewById(R.id.remoteView_text);
DisplayMetrics displayMetrics = textView.getResources().getDisplayMetrics();
@@ -1174,6 +1247,20 @@
}
@Test
+ public void testSetViewLayoutWidthAttr() throws Throwable {
+ View textView = mResult.findViewById(R.id.remoteView_text);
+ mRemoteViews.setViewLayoutWidthAttr(R.id.remoteView_text, R.attr.themeDimension);
+ mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
+ assertEquals(
+ resolveDimenSize(5.5123f, COMPLEX_UNIT_DIP,
+ textView.getResources().getDisplayMetrics()),
+ textView.getLayoutParams().width);
+
+ mRemoteViews.setViewLayoutWidthAttr(R.id.remoteView_text, R.attr.themeColor);
+ assertThrowsOnReapply(ActionException.class);
+ }
+
+ @Test
public void testSetViewLayoutHeight() throws Throwable {
View textView = mResult.findViewById(R.id.remoteView_text);
DisplayMetrics displayMetrics = textView.getResources().getDisplayMetrics();
@@ -1205,6 +1292,21 @@
}
@Test
+ public void testSetViewLayoutHeightAttr() throws Throwable {
+ View textView = mResult.findViewById(R.id.remoteView_text);
+ mRemoteViews.setViewLayoutHeightAttr(R.id.remoteView_text, R.attr.themeDimension);
+ mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
+ assertEquals(
+ resolveDimenSize(5.5123f, COMPLEX_UNIT_DIP,
+ textView.getResources().getDisplayMetrics()),
+ textView.getLayoutParams().height);
+
+ mRemoteViews.setViewLayoutHeightAttr(
+ R.id.remoteView_text, R.attr.themeColor);
+ assertThrowsOnReapply(ActionException.class);
+ }
+
+ @Test
public void testSetIntDimen_fromResources() throws Throwable {
TextView textView = (TextView) mResult.findViewById(R.id.remoteView_text);
int expectedValue = mContext.getResources().getDimensionPixelSize(R.dimen.popup_row_height);
@@ -1214,10 +1316,9 @@
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
assertEquals(expectedValue, textView.getCompoundDrawablePadding());
- mExpectedException.expect(ActionException.class);
mRemoteViews.setIntDimen(R.id.remoteView_text, "setCompoundDrawablePadding",
R.color.testcolor1);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -1243,13 +1344,36 @@
assertEquals(resolveDimenSize(12f, TypedValue.COMPLEX_UNIT_PX, displayMetrics),
textView.getCompoundDrawablePadding());
- mExpectedException.expect(ActionException.class);
mRemoteViews.setIntDimen(R.id.remoteView_text, "setCompoundDrawablePadding",
12f, 123456);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
+ public void testSetIntDimenAttr() throws Throwable {
+ mRemoteViews.setIntDimenAttr(R.id.remoteView_text, "setCompoundDrawablePadding",
+ R.attr.themeDimension);
+ applyNightModeThenApplyAndTest(false, () -> {
+ TextView textView = (TextView) mResult.findViewById(R.id.remoteView_text);
+ assertEquals(resolveDimenSize(5.5123f, COMPLEX_UNIT_DIP,
+ textView.getResources().getDisplayMetrics()),
+ textView.getCompoundDrawablePadding());
+ });
+
+ applyNightModeThenApplyAndTest(true, () -> {
+ TextView textView = (TextView) mResult.findViewById(R.id.remoteView_text);
+ assertEquals(resolveDimenSize(7.5123f, COMPLEX_UNIT_DIP,
+ textView.getResources().getDisplayMetrics()),
+ textView.getCompoundDrawablePadding());
+ });
+
+ mRemoteViews.setIntDimenAttr(R.id.remoteView_text, "setCompoundDrawablePadding",
+ R.attr.themeColor);
+ assertThrowsOnReapply(ActionException.class);
+ }
+
+
+ @Test
public void testSetFloatDimen_fromResources() throws Throwable {
TextView textView = (TextView) mResult.findViewById(R.id.remoteView_text);
@@ -1259,9 +1383,8 @@
assertEquals(textView.getResources().getDimension(R.dimen.remoteviews_float_dimen),
textView.getTextScaleX(), 1e-4f);
- mExpectedException.expect(ActionException.class);
mRemoteViews.setFloatDimen(R.id.remoteView_text, "setTextScaleX", R.color.testcolor1);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -1287,10 +1410,30 @@
assertEquals(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, 3.5f, displayMetrics),
textView.getTextScaleX(), 1e-4f);
- mExpectedException.expect(ActionException.class);
mRemoteViews.setFloatDimen(R.id.remoteView_text, "setTextScaleX",
3.5f, 123456);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
+ }
+
+ @Test
+ public void testSetFloatDimenAttr() throws Throwable {
+ mRemoteViews.setFloatDimenAttr(R.id.remoteView_text, "setTextScaleX",
+ R.attr.themeDimension);
+ applyNightModeThenApplyAndTest(false, () -> {
+ TextView textView = (TextView) mResult.findViewById(R.id.remoteView_text);
+ assertEquals(TypedValue.applyDimension(COMPLEX_UNIT_DIP, 5.5123f,
+ textView.getResources().getDisplayMetrics()), textView.getTextScaleX(), 1e-4f);
+ });
+
+ applyNightModeThenApplyAndTest(true, () -> {
+ TextView textView = (TextView) mResult.findViewById(R.id.remoteView_text);
+ assertEquals(TypedValue.applyDimension(COMPLEX_UNIT_DIP, 7.5123f,
+ textView.getResources().getDisplayMetrics()), textView.getTextScaleX(), 1e-4f);
+ });
+
+ mRemoteViews.setFloatDimenAttr(R.id.remoteView_text, "setTextScaleX",
+ R.attr.themeColor);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -1300,11 +1443,30 @@
mRemoteViews.setColor(R.id.remoteView_text, "setTextColor", R.color.testcolor1);
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
- assertEquals(ColorStateList.valueOf(expectedValue), textView.getTextColors());
+ assertSameColorStateList(ColorStateList.valueOf(expectedValue), textView.getTextColors());
- mExpectedException.expect(ActionException.class);
mRemoteViews.setColor(R.id.remoteView_text, "setTextColor", R.dimen.popup_row_height);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
+ }
+
+ @Test
+ public void testSetColorAttr() throws Throwable {
+ // Ensure the configuration is "light"
+ mRemoteViews.setColorAttr(R.id.remoteView_text, "setTextColor", R.attr.themeColor);
+
+ applyNightModeThenApplyAndTest(false, () -> {
+ TextView textView = (TextView) mResult.findViewById(R.id.remoteView_text);
+ assertSameColorStateList(ColorStateList.valueOf(0x0f00ff00), textView.getTextColors());
+ });
+
+ // Switch to night mode
+ applyNightModeThenApplyAndTest(true, () -> {
+ TextView textView = (TextView) mResult.findViewById(R.id.remoteView_text);
+ assertSameColorStateList(ColorStateList.valueOf(0x0f00ffff), textView.getTextColors());
+ });
+
+ mRemoteViews.setColorAttr(R.id.remoteView_text, "setTextColor", R.attr.themeDimension);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -1316,7 +1478,7 @@
new int[] {Color.BLACK, Color.WHITE});
mRemoteViews.setColorStateList(R.id.remoteView_progress, "setProgressTintList", tintList);
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
- assertEquals(tintList, progressBar.getProgressTintList());
+ assertSameColorStateList(tintList, progressBar.getProgressTintList());
mRemoteViews.setColorStateList(R.id.remoteView_progress, "setProgressTintList", null);
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
@@ -1325,12 +1487,32 @@
TextView textView = mResult.findViewById(R.id.remoteView_text);
mRemoteViews.setColorStateList(R.id.remoteView_text, "setTextColor", tintList);
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
- assertEquals(tintList, textView.getTextColors());
+ assertSameColorStateList(tintList, textView.getTextColors());
ColorStateList solid = ColorStateList.valueOf(Color.RED);
mRemoteViews.setColorStateList(R.id.remoteView_text, "setBackgroundTintList", solid);
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
- assertEquals(solid, textView.getBackgroundTintList());
+ assertSameColorStateList(solid, textView.getBackgroundTintList());
+ }
+
+ @Test
+ public void testSetColorStateListAttr() throws Throwable {
+ mRemoteViews.setColorStateListAttr(R.id.remoteView_progress, "setProgressTintList",
+ R.attr.themeColor);
+ applyNightModeThenApplyAndTest(false, () -> {
+ ProgressBar progressBar = mResult.findViewById(R.id.remoteView_progress);
+ assertSameColorStateList(ColorStateList.valueOf(0x0f00ff00),
+ progressBar.getProgressTintList());
+ });
+
+ applyNightModeThenApplyAndTest(true, () -> {
+ ProgressBar progressBar = mResult.findViewById(R.id.remoteView_progress);
+ assertSameColorStateList(ColorStateList.valueOf(0x0f00ffff),
+ progressBar.getProgressTintList());
+ });
+
+ mRemoteViews.setColorAttr(R.id.remoteView_text, "setTextColor", R.attr.themeDimension);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -1338,12 +1520,16 @@
TextView textView = (TextView) mResult.findViewById(R.id.remoteView_text);
mRemoteViews.setColorInt(R.id.remoteView_text, "setTextColor", Color.BLACK, Color.WHITE);
- applyNightModeThenTest(
+ applyNightModeThenReapplyAndTest(
false,
- () -> assertEquals(ColorStateList.valueOf(Color.BLACK), textView.getTextColors()));
- applyNightModeThenTest(
+ () -> assertSameColorStateList(ColorStateList.valueOf(Color.BLACK),
+ textView.getTextColors())
+ );
+ applyNightModeThenReapplyAndTest(
true,
- () -> assertEquals(ColorStateList.valueOf(Color.WHITE), textView.getTextColors()));
+ () -> assertSameColorStateList(ColorStateList.valueOf(Color.WHITE),
+ textView.getTextColors())
+ );
}
@Test
@@ -1354,19 +1540,18 @@
mRemoteViews.setColorStateList(R.id.remoteView_text, "setTextColor",
R.color.testcolorstatelist1);
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
- assertEquals(expectedValue, textView.getTextColors());
+ assertSameColorStateList(expectedValue, textView.getTextColors());
mRemoteViews.setColorStateList(R.id.remoteView_text, "setTextColor",
R.color.testcolor1);
mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
expectedValue = mContext.getResources().getColorStateList(R.color.testcolor1,
mContext.getTheme());
- assertEquals(expectedValue, textView.getTextColors());
+ assertSameColorStateList(expectedValue, textView.getTextColors());
- mExpectedException.expect(ActionException.class);
mRemoteViews.setColorStateList(R.id.remoteView_text, "setTextColor",
R.dimen.popup_row_height);
- mRemoteViews.reapply(mContext, mResult);
+ assertThrowsOnReapply(ActionException.class);
}
@Test
@@ -1376,8 +1561,10 @@
ColorStateList darkMode = ColorStateList.valueOf(Color.WHITE);
mRemoteViews.setColorStateList(R.id.remoteView_text, "setTextColor", lightMode, darkMode);
- applyNightModeThenTest(false, () -> assertEquals(lightMode, textView.getTextColors()));
- applyNightModeThenTest(true, () -> assertEquals(darkMode, textView.getTextColors()));
+ applyNightModeThenReapplyAndTest(false,
+ () -> assertSameColorStateList(lightMode, textView.getTextColors()));
+ applyNightModeThenReapplyAndTest(true,
+ () -> assertSameColorStateList(darkMode, textView.getTextColors()));
}
@Test
@@ -1424,6 +1611,38 @@
}
@Test
+ public void testSetViewOutlinePreferredRadiusAttr() throws Throwable {
+ mRemoteViews.setViewOutlinePreferredRadiusAttr(
+ R.id.remoteViews_good, R.attr.themeDimension);
+
+ applyNightModeThenApplyAndTest(false,
+ () -> {
+ View root = mResult.findViewById(R.id.remoteViews_good);
+ assertEquals(
+ TypedValue.applyDimension(COMPLEX_UNIT_DIP, 5.5123f,
+ root.getResources().getDisplayMetrics()),
+ ((RemoteViews.RemoteViewOutlineProvider)
+ root.getOutlineProvider()).getRadius(),
+ 0.1 /* delta */);
+ });
+
+ applyNightModeThenApplyAndTest(true,
+ () -> {
+ View root = mResult.findViewById(R.id.remoteViews_good);
+ assertEquals(
+ TypedValue.applyDimension(COMPLEX_UNIT_DIP, 7.5123f,
+ root.getResources().getDisplayMetrics()),
+ ((RemoteViews.RemoteViewOutlineProvider)
+ root.getOutlineProvider()).getRadius(),
+ 0.1 /* delta */);
+ });
+
+ mRemoteViews.setViewOutlinePreferredRadiusAttr(
+ R.id.remoteViews_good, R.attr.themeColor);
+ assertThrowsOnReapply(ActionException.class);
+ }
+
+ @Test
public void testSetSwitchChecked() throws Throwable {
Switch toggle = mResult.findViewById(R.id.remoteView_switch);
@@ -1526,8 +1745,23 @@
* Sets the night mode, reapplies the remote views, runs test, and then restores the previous
* night mode.
*/
- private void applyNightModeThenTest(
+ private void applyNightModeThenReapplyAndTest(boolean nightMode, ThrowingRunnable test)
+ throws Throwable {
+ applyNightModeAndTest(nightMode, () -> mRemoteViews.reapply(mContext, mResult), test);
+ }
+
+ /**
+ * Sets the night mode, reapplies the remote views, runs test, and then restores the previous
+ * night mode.
+ */
+ private void applyNightModeThenApplyAndTest(
boolean nightMode, ThrowingRunnable test) throws Throwable {
+ applyNightModeAndTest(nightMode,
+ () -> mResult = mRemoteViews.apply(mContext, null), test);
+ }
+
+ private void applyNightModeAndTest(
+ boolean nightMode, Runnable uiThreadSetup, ThrowingRunnable test) throws Throwable {
final String nightModeText = runShellCommand("cmd uimode night");
final String[] nightModeSplit = nightModeText.split(":");
if (nightModeSplit.length != 2) {
@@ -1537,7 +1771,7 @@
try {
runShellCommand("cmd uimode night " + (nightMode ? "yes" : "no"));
- mActivityRule.runOnUiThread(() -> mRemoteViews.reapply(mContext, mResult));
+ mActivityRule.runOnUiThread(uiThreadSetup);
test.run();
} finally {
runShellCommand("cmd uimode night " + initialNightMode);
@@ -1576,4 +1810,12 @@
mIntent = intent;
}
}
+
+ private void assertSameColorStateList(ColorStateList expected, ColorStateList actual) {
+ assertEquals(expected.toString(), actual.toString());
+ }
+
+ private <T extends Throwable> void assertThrowsOnReapply(Class<T> klass) throws Throwable {
+ assertThrows(klass, () -> mRemoteViews.reapply(mContext, mResult));
+ }
}
diff --git a/tests/tests/wifi/src/android/net/wifi/cts/CoexUnsafeChannelTest.java b/tests/tests/wifi/src/android/net/wifi/cts/CoexUnsafeChannelTest.java
index 8b1cec7..a955143 100644
--- a/tests/tests/wifi/src/android/net/wifi/cts/CoexUnsafeChannelTest.java
+++ b/tests/tests/wifi/src/android/net/wifi/cts/CoexUnsafeChannelTest.java
@@ -16,6 +16,8 @@
package android.net.wifi.cts;
+import static android.net.wifi.CoexUnsafeChannel.POWER_CAP_NONE;
+
import android.net.wifi.CoexUnsafeChannel;
import android.net.wifi.WifiScanner;
import android.test.AndroidTestCase;
@@ -33,26 +35,17 @@
public void testNoPowerCapConstructor() {
CoexUnsafeChannel unsafeChannel = new CoexUnsafeChannel(TEST_BAND, TEST_CHANNEL);
- assertEquals(unsafeChannel.getBand(), TEST_BAND);
- assertEquals(unsafeChannel.getChannel(), TEST_CHANNEL);
- assertFalse(unsafeChannel.isPowerCapAvailable());
+ assertEquals(TEST_BAND, unsafeChannel.getBand());
+ assertEquals(TEST_CHANNEL, unsafeChannel.getChannel());
+ assertEquals(POWER_CAP_NONE, unsafeChannel.getPowerCapDbm());
}
public void testPowerCapConstructor() {
CoexUnsafeChannel unsafeChannel = new CoexUnsafeChannel(TEST_BAND, TEST_CHANNEL,
TEST_POWER_CAP_DBM);
- assertEquals(unsafeChannel.getBand(), TEST_BAND);
- assertEquals(unsafeChannel.getChannel(), TEST_CHANNEL);
- assertTrue(unsafeChannel.isPowerCapAvailable());
- assertEquals(unsafeChannel.getPowerCapDbm(), TEST_POWER_CAP_DBM);
- }
-
- public void testSetPowerCap() {
- CoexUnsafeChannel unsafeChannel = new CoexUnsafeChannel(TEST_BAND, TEST_CHANNEL);
-
- unsafeChannel.setPowerCapDbm(TEST_POWER_CAP_DBM);
-
- assertEquals(unsafeChannel.getPowerCapDbm(), TEST_POWER_CAP_DBM);
+ assertEquals(TEST_BAND, unsafeChannel.getBand());
+ assertEquals(TEST_CHANNEL, unsafeChannel.getChannel());
+ assertEquals(TEST_POWER_CAP_DBM, unsafeChannel.getPowerCapDbm());
}
}
diff --git a/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java b/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java
index 3ca5d3c..e86630e 100644
--- a/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java
+++ b/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java
@@ -29,6 +29,7 @@
import static org.junit.Assert.assertNotEquals;
+import android.annotation.NonNull;
import android.app.UiAutomation;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -1118,8 +1119,8 @@
}
/**
- * Verify that {@link WifiManager#addetworkPrivileged} throws a SecurityException when called
- * by a normal app.
+ * Verify that {@link WifiManager#addNetworkPrivileged(WifiConfiguration)} throws a
+ * SecurityException when called by a normal app.
*/
public void testAddNetworkPrivilegedNotAllowedForNormalApps() {
if (!WifiFeature.isWifiSupported(getContext())) {
@@ -1140,7 +1141,8 @@
}
/**
- * Verify {@link WifiManager#addetworkPrivileged} throws an exception when null is the input.
+ * Verify {@link WifiManager#addNetworkPrivileged(WifiConfiguration)} throws an exception when
+ * null is the input.
*/
public void testAddNetworkPrivilegedBadInput() {
if (!WifiFeature.isWifiSupported(getContext())) {
@@ -1163,8 +1165,8 @@
}
/**
- * Verify {@link WifiManager#addetworkPrivileged} returns the proper failure status code
- * when adding an enterprise config with mandatory fields not filled in.
+ * Verify {@link WifiManager#addNetworkPrivileged(WifiConfiguration)} returns the proper
+ * failure status code when adding an enterprise config with mandatory fields not filled in.
*/
public void testAddNetworkPrivilegedFailureBadEnterpriseConfig() {
if (!WifiFeature.isWifiSupported(getContext())) {
@@ -1193,8 +1195,8 @@
}
/**
- * Verify {@link WifiManager#addetworkPrivileged} works properly when the calling app has
- * permissions.
+ * Verify {@link WifiManager#addNetworkPrivileged(WifiConfiguration)} works properly when the
+ * calling app has permissions.
*/
public void testAddNetworkPrivilegedSuccess() {
if (!WifiFeature.isWifiSupported(getContext())) {
@@ -3894,14 +3896,19 @@
public class TestCoexCallback extends WifiManager.CoexCallback {
private Object mCoexLock;
private int mOnCoexUnsafeChannelChangedCount;
+ private List<CoexUnsafeChannel> mCoexUnsafeChannels;
+ private int mCoexRestrictions;
TestCoexCallback(Object lock) {
mCoexLock = lock;
}
@Override
- public void onCoexUnsafeChannelsChanged() {
+ public void onCoexUnsafeChannelsChanged(
+ @NonNull List<CoexUnsafeChannel> unsafeChannels, int restrictions) {
synchronized (mCoexLock) {
+ mCoexUnsafeChannels = unsafeChannels;
+ mCoexRestrictions = restrictions;
mOnCoexUnsafeChannelChangedCount++;
mCoexLock.notify();
}
@@ -3912,6 +3919,14 @@
return mOnCoexUnsafeChannelChangedCount;
}
}
+
+ public List<CoexUnsafeChannel> getCoexUnsafeChannels() {
+ return mCoexUnsafeChannels;
+ }
+
+ public int getCoexRestrictions() {
+ return mCoexRestrictions;
+ }
}
/**
@@ -3926,17 +3941,11 @@
}
try {
- mWifiManager.setCoexUnsafeChannels(Collections.emptySet(), 0);
+ mWifiManager.setCoexUnsafeChannels(Collections.emptyList(), 0);
fail("setCoexUnsafeChannels should not succeed - privileged call");
} catch (SecurityException e) {
// expected
}
- try {
- mWifiManager.getCoexUnsafeChannels();
- fail("getCoexUnsafeChannels should not succeed - privileged call");
- } catch (SecurityException e) {
- // expected
- }
final TestCoexCallback callback = new TestCoexCallback(mLock);
try {
mWifiManager.registerCoexCallback(mExecutor, callback);
@@ -3967,45 +3976,40 @@
// These below API's only work with privileged permissions (obtained via shell identity
// for test)
UiAutomation uiAutomation = InstrumentationRegistry.getInstrumentation().getUiAutomation();
- Set<CoexUnsafeChannel> prevUnsafeChannels = null;
+ List<CoexUnsafeChannel> prevUnsafeChannels = null;
int prevRestrictions = -1;
try {
uiAutomation.adoptShellPermissionIdentity();
- // Save the current state to reset after the test.
- prevUnsafeChannels = mWifiManager.getCoexUnsafeChannels();
- prevRestrictions = mWifiManager.getCoexRestrictions();
-
- // Register callback
final TestCoexCallback callback = new TestCoexCallback(mLock);
- mWifiManager.registerCoexCallback(mExecutor, callback);
- Set<CoexUnsafeChannel> unsafeChannels = new HashSet<>();
- unsafeChannels.add(new CoexUnsafeChannel(WIFI_BAND_24_GHZ, 6));
- final int restrictions = COEX_RESTRICTION_WIFI_DIRECT | COEX_RESTRICTION_SOFTAP
- | COEX_RESTRICTION_WIFI_AWARE;
-
+ final List<CoexUnsafeChannel> testUnsafeChannels = new ArrayList<>();
+ testUnsafeChannels.add(new CoexUnsafeChannel(WIFI_BAND_24_GHZ, 6));
+ final int testRestrictions = COEX_RESTRICTION_WIFI_DIRECT
+ | COEX_RESTRICTION_SOFTAP | COEX_RESTRICTION_WIFI_AWARE;
synchronized (mLock) {
try {
- mWifiManager.setCoexUnsafeChannels(unsafeChannels, restrictions);
- // Callback should be called if the default algorithm is disabled.
+ mWifiManager.registerCoexCallback(mExecutor, callback);
+ // Callback should be called after registering
mLock.wait(TEST_WAIT_DURATION_MS);
+ assertEquals(1, callback.getOnCoexUnsafeChannelChangedCount());
+ // Store the previous coex channels and set new coex channels
+ prevUnsafeChannels = callback.getCoexUnsafeChannels();
+ prevRestrictions = callback.getCoexRestrictions();
+ mWifiManager.setCoexUnsafeChannels(testUnsafeChannels, testRestrictions);
+ mLock.wait(TEST_WAIT_DURATION_MS);
+ // Unregister callback and try setting again
mWifiManager.unregisterCoexCallback(callback);
- mWifiManager.setCoexUnsafeChannels(unsafeChannels, restrictions);
+ mWifiManager.setCoexUnsafeChannels(testUnsafeChannels, testRestrictions);
// Callback should not be called here since it was unregistered.
mLock.wait(TEST_WAIT_DURATION_MS);
} catch (InterruptedException e) {
fail("Thread interrupted unexpectedly while waiting on mLock");
}
}
-
- if (callback.getOnCoexUnsafeChannelChangedCount() == 0) {
- // Default algorithm enabled, setter should have done nothing
- assertEquals(prevUnsafeChannels, mWifiManager.getCoexUnsafeChannels());
- assertEquals(prevRestrictions, mWifiManager.getCoexRestrictions());
- } else if (callback.getOnCoexUnsafeChannelChangedCount() == 1) {
+ if (callback.getOnCoexUnsafeChannelChangedCount() == 2) {
// Default algorithm disabled, setter should set the getter values.
- assertEquals(unsafeChannels, mWifiManager.getCoexUnsafeChannels());
- assertEquals(restrictions, mWifiManager.getCoexRestrictions());
- } else {
+ assertEquals(testUnsafeChannels, callback.getCoexUnsafeChannels());
+ assertEquals(testRestrictions, callback.getCoexRestrictions());
+ } else if (callback.getOnCoexUnsafeChannelChangedCount() != 1) {
fail("Coex callback called " + callback.mOnCoexUnsafeChannelChangedCount
+ " times. Expected 0 or 1 calls." );
}
diff --git a/tools/cts-tradefed/res/config/cts-on-gsi-exclude.xml b/tools/cts-tradefed/res/config/cts-on-gsi-exclude.xml
index 1323093..0dab29e 100644
--- a/tools/cts-tradefed/res/config/cts-on-gsi-exclude.xml
+++ b/tools/cts-tradefed/res/config/cts-on-gsi-exclude.xml
@@ -59,4 +59,7 @@
<!-- No Statsd -->
<option name="compatibility:exclude-filter" value="CtsStatsdHostTestCases" />
+ <!-- b/183234756, b/80388296, b/110260628, b/159295445, b/159294948 CtsDevicePolicyManagerTestCases -->
+ <option name="compatibility:exclude-filter" value="CtsDevicePolicyManagerTestCases" />
+
</configuration>