summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-prod (mdb) <android-build-team-robot@google.com>2019-02-22 00:13:48 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-02-22 00:13:48 +0000
commitc4decf0f65f439b7910c7c2af98d303b1f0e674c (patch)
tree669a932ed02a1b48bc6fdd1ef804fd69ef35d916
parentff224c2665dfcda61a1f74041dc5b3f6c993de30 (diff)
parentf24d560843364ec0b131a715117a7c06461307d6 (diff)
downloadcts-sparse-5328317-L31800000277234039.tar.gz
Merge "Snap for 5328068 from 11ae54f6b2c6a726e78ecc140fc237c6d7312593 to pie-cts-release" into pie-cts-releasesparse-5328317-L31800000277234039sparse-5328317-L12000000275679952
-rw-r--r--apps/CameraITS/tests/scene0/test_param_sensitivity_burst.py2
-rw-r--r--apps/CtsVerifier/AndroidManifest.xml2
-rw-r--r--apps/CtsVerifier/res/layout-small-dpad/widget_layout.xml97
-rw-r--r--apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsService.java3
-rw-r--r--apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVXCheckTestActivity.java2
-rw-r--r--common/device-side/util/src/com/android/compatibility/common/util/BlockedNumberService.java96
-rw-r--r--common/device-side/util/src/com/android/compatibility/common/util/BlockedNumberUtil.java92
-rw-r--r--common/device-side/util/src/com/android/compatibility/common/util/PropertyUtil.java2
-rw-r--r--common/device-side/util/src/com/android/compatibility/common/util/WidgetTestUtils.java3
-rw-r--r--hostsidetests/appsecurity/src/android/appsecurity/cts/AdoptableHostTest.java12
-rw-r--r--hostsidetests/appsecurity/src/android/appsecurity/cts/AppSecurityTests.java25
-rw-r--r--hostsidetests/appsecurity/src/android/appsecurity/cts/ClassloaderSplitsTest.java23
-rw-r--r--hostsidetests/appsecurity/src/android/appsecurity/cts/IsolatedSplitsTests.java53
-rw-r--r--hostsidetests/appsecurity/src/android/appsecurity/cts/MajorVersionTest.java28
-rw-r--r--hostsidetests/appsecurity/src/android/appsecurity/cts/PackageResolutionHostTest.java6
-rw-r--r--hostsidetests/appsecurity/src/android/appsecurity/cts/SplitTests.java51
-rw-r--r--hostsidetests/appsecurity/src/android/appsecurity/cts/UsesLibraryHostTest.java13
-rw-r--r--hostsidetests/appsecurity/src/android/appsecurity/cts/Utils.java13
-rw-r--r--hostsidetests/backup/AndroidTest.xml3
-rw-r--r--hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskHostDrivenTest.java42
-rw-r--r--hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/DummyConnectionService.java6
-rw-r--r--hostsidetests/gputools/src/android/gputools/cts/CtsRootlessGpuDebugHostTest.java46
-rw-r--r--hostsidetests/incident/AndroidTest.xml3
-rw-r--r--hostsidetests/inputmethodservice/deviceside/devicetest/src/android/inputmethodservice/cts/devicetest/InputMethodServiceDeviceTest.java6
-rw-r--r--hostsidetests/security/src/android/security/cts/SELinuxHostTest.java3
-rw-r--r--hostsidetests/statsd/src/android/cts/statsd/atom/DeviceAtomTestCase.java5
-rw-r--r--hostsidetests/theme/assets/28/360dpi.zipbin7795829 -> 7789422 bytes
-rw-r--r--tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityVolumeTest.java3
-rw-r--r--tests/admin/AndroidTest.xml4
-rw-r--r--tests/app/AndroidTest.xml1
-rw-r--r--tests/app/src/android/app/cts/SystemFeaturesTest.java23
-rw-r--r--tests/autofillservice/AndroidManifest.xml3
-rw-r--r--tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java2
-rw-r--r--tests/autofillservice/src/android/autofillservice/cts/UiBot.java25
-rw-r--r--tests/backup/AndroidTest.xml5
-rw-r--r--tests/camera/AndroidTest.xml4
-rw-r--r--tests/camera/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java6
-rw-r--r--tests/camera/src/android/hardware/cts/CameraTest.java8
-rwxr-xr-xtests/framework/base/activitymanager/app/AndroidManifest.xml12
-rw-r--r--tests/framework/base/activitymanager/src/android/server/am/ActivityManagerManifestLayoutTests.java4
-rw-r--r--tests/framework/base/activitymanager/src/android/server/am/ActivityManagerPinnedStackTests.java25
-rw-r--r--tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerTestBase.java6
-rw-r--r--tests/sensor/src/android/hardware/cts/SensorParameterRangeTest.java22
-rw-r--r--tests/tests/car/AndroidManifest.xml11
-rw-r--r--tests/tests/car/src/android/car/cts/CarBluetoothTest.java361
-rw-r--r--tests/tests/car/src/android/car/cts/CarPackageManagerTest.java49
-rw-r--r--tests/tests/car/src/android/car/cts/CarSensorManagerTest.java1
-rw-r--r--tests/tests/car/src/android/car/cts/drivingstate/DistractionOptimizedActivity.java6
-rw-r--r--tests/tests/car/src/android/car/cts/drivingstate/NonDistractionOptimizedActivity.java6
-rw-r--r--tests/tests/content/AndroidTest.xml1
-rw-r--r--tests/tests/display/Android.mk2
-rw-r--r--tests/tests/display/AndroidManifest.xml2
-rw-r--r--tests/tests/display/src/android/display/cts/BrightnessTest.java9
-rw-r--r--tests/tests/display/src/android/display/cts/DisplayTest.java17
-rwxr-xr-xtests/tests/gesture/Android.mk2
-rwxr-xr-xtests/tests/gesture/AndroidManifest.xml2
-rw-r--r--tests/tests/location/src/android/location/cts/TestMeasurementUtil.java1
-rwxr-xr-xtests/tests/media/src/android/media/cts/DecoderTest.java14
-rw-r--r--tests/tests/midi/AndroidTest.xml3
-rw-r--r--tests/tests/os/src/android/os/cts/EnvironmentTest.java13
-rw-r--r--tests/tests/packageinstaller/adminpackageinstaller/AndroidTest.xml4
-rw-r--r--tests/tests/preference2/src/android/preference2/cts/TestUtils.java15
-rw-r--r--tests/tests/provider/AndroidTest.xml4
-rw-r--r--tests/tests/telecom/AndroidManifest.xml9
-rw-r--r--tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java15
-rw-r--r--tests/tests/telephony/AndroidManifest.xml10
-rw-r--r--tests/tests/telephony/src/android/telephony/cts/CarrierConfigManagerTest.java9
-rwxr-xr-xtests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java19
-rw-r--r--tests/tests/telephony/src/android/telephony/cts/SubscriptionManagerTest.java34
-rw-r--r--tests/tests/telephony4/Android.mk48
-rw-r--r--tests/tests/telephony4/AndroidManifest.xml32
-rw-r--r--tests/tests/telephony4/AndroidTest.xml27
-rw-r--r--tests/tests/telephony4/certs/android_telephony_cts_testkey.pk8bin0 -> 2375 bytes
-rw-r--r--tests/tests/telephony4/certs/android_telephony_cts_testkey.x509.pem30
-rw-r--r--tests/tests/telephony4/src/android/telephony4/cts/SimRestrictedApisTest.java (renamed from tests/tests/telephony/src/android/telephony/cts/SimRestrictedApisTest.java)52
-rw-r--r--tests/tests/text/src/android/text/cts/StaticLayoutLineBreakingTest.java2
-rw-r--r--tests/tests/view/res/layout/focus_finder_layout.xml3
-rw-r--r--tests/tests/view/res/values-ldpi/dimens.xml20
-rw-r--r--tests/tests/view/src/android/view/cts/FocusFinderTest.java27
-rw-r--r--tests/tests/view/src/android/view/cts/PixelCopyViewProducerActivity.java2
-rw-r--r--tests/tests/view/src/android/view/cts/PixelCopyWideGamutViewProducerActivity.java2
-rw-r--r--tests/tests/view/src/android/view/cts/WindowTest.java2
-rw-r--r--tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java58
-rw-r--r--tests/tests/webkit/src/android/webkit/cts/WebViewSslTest.java23
-rw-r--r--tests/tests/widget/src/android/widget/cts/AbsListViewTest.java24
85 files changed, 1374 insertions, 387 deletions
diff --git a/apps/CameraITS/tests/scene0/test_param_sensitivity_burst.py b/apps/CameraITS/tests/scene0/test_param_sensitivity_burst.py
index dfd9ed80500..b7161414ce7 100644
--- a/apps/CameraITS/tests/scene0/test_param_sensitivity_burst.py
+++ b/apps/CameraITS/tests/scene0/test_param_sensitivity_burst.py
@@ -19,7 +19,7 @@ import its.objects
import its.target
NUM_STEPS = 3
-ERROR_TOLERANCE = 0.97 # Allow ISO to be rounded down by 3%
+ERROR_TOLERANCE = 0.96 # Allow ISO to be rounded down by 4%
def main():
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index f2640e51b3f..72e43e2461a 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -18,7 +18,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.verifier"
android:versionCode="5"
- android:versionName="9.0_r6">
+ android:versionName="9.0_r7">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28"/>
diff --git a/apps/CtsVerifier/res/layout-small-dpad/widget_layout.xml b/apps/CtsVerifier/res/layout-small-dpad/widget_layout.xml
new file mode 100644
index 00000000000..518be889de0
--- /dev/null
+++ b/apps/CtsVerifier/res/layout-small-dpad/widget_layout.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginTop="@dimen/widget_margin_top"
+ android:layout_marginBottom="@dimen/widget_margin_bottom"
+ android:layout_marginLeft="@dimen/widget_margin_left"
+ android:layout_marginRight="@dimen/widget_margin_right"
+ android:padding="1dp"
+ android:background="#fff">
+
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingLeft="4dp"
+ android:paddingTop="4dp"
+ android:paddingBottom="4dp"
+ android:paddingRight="4dp"
+ android:layout_gravity="center"
+ android:background="#fff">
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="top|left"
+ android:layout_marginBottom="8dp"
+ android:fontFamily="sans-serif"
+ android:textSize="16sp"
+ android:text="@string/widget_name"
+ android:freezesText="true"/>
+
+ <TextView
+ android:id="@+id/instruction"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="12dp"
+ android:fontFamily="sans-serif-light"
+ android:textSize="14sp"
+ android:freezesText="true"/>
+
+ <TextView
+ android:id="@+id/data"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="12dp"
+ android:layout_gravity="center_horizontal"
+ android:fontFamily="sans-serif-light"
+ android:textSize="14sp"/>
+
+ <ListView
+ android:id="@+id/list"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:layout_marginBottom="12dp"
+ android:padding="1dp"
+ android:background="#fff"
+ android:visibility="gone"/>
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom|center_horizontal"
+ android:orientation="horizontal">
+ <Button
+ android:id="@+id/fail"
+ android:layout_marginRight="8dp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:minWidth="100dp"
+ android:text="@string/widget_fail" />
+ <Button
+ android:id="@+id/pass"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:minWidth="100dp"
+ android:text="@string/widget_pass" />
+ </LinearLayout>
+
+ </LinearLayout>
+</FrameLayout>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsService.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsService.java
index fc2374e75e2..db45452d99e 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsService.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsService.java
@@ -359,7 +359,8 @@ public class ItsService extends Service implements SensorEventListener {
// Initialize memory quota on this device
for (String camId : devices) {
CameraCharacteristics chars = mCameraManager.getCameraCharacteristics(camId);
- Size maxYuvSize = ItsUtils.getYuvOutputSizes(chars)[0];
+ Size maxYuvSize = ItsUtils.getMaxOutputSize(
+ chars, ImageFormat.YUV_420_888);
// 4 bytes per pixel for RGBA8888 Bitmap and at least 3 Bitmaps per CDD
int quota = maxYuvSize.getWidth() * maxYuvSize.getHeight() * 4 * 3;
if (quota > mMemoryQuota) {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVXCheckTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVXCheckTestActivity.java
index 789de6852e4..9fbeba2dc99 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVXCheckTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RVCVXCheckTestActivity.java
@@ -167,7 +167,7 @@ public class RVCVXCheckTestActivity
// acquire a partial wake lock just in case CPU fall asleep
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
- PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
+ PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK,
"RVCVXCheckAnalyzer");
wl.acquire();
diff --git a/common/device-side/util/src/com/android/compatibility/common/util/BlockedNumberService.java b/common/device-side/util/src/com/android/compatibility/common/util/BlockedNumberService.java
new file mode 100644
index 00000000000..360c0787212
--- /dev/null
+++ b/common/device-side/util/src/com/android/compatibility/common/util/BlockedNumberService.java
@@ -0,0 +1,96 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+import static android.provider.BlockedNumberContract.BlockedNumbers.COLUMN_ORIGINAL_NUMBER;
+import static android.provider.BlockedNumberContract.BlockedNumbers.CONTENT_URI;
+
+import android.app.IntentService;
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.ResultReceiver;
+import android.util.Log;
+
+/**
+ * A service to handle interactions with the BlockedNumberProvider. The BlockedNumberProvider
+ * can only be accessed by the primary user. This service can be run as a singleton service
+ * which will then be able to access the BlockedNumberProvider from a test running in a
+ * secondary user.
+ */
+public class BlockedNumberService extends IntentService {
+
+ static final String INSERT_ACTION = "android.telecom.cts.InsertBlockedNumber";
+ static final String DELETE_ACTION = "android.telecom.cts.DeleteBlockedNumber";
+ static final String PHONE_NUMBER_EXTRA = "number";
+ static final String URI_EXTRA = "uri";
+ static final String ROWS_EXTRA = "rows";
+ static final String RESULT_RECEIVER_EXTRA = "resultReceiver";
+
+ private static final String TAG = "CtsBlockNumberSvc";
+
+ private ContentResolver mContentResolver;
+
+ public BlockedNumberService() {
+ super(BlockedNumberService.class.getName());
+ }
+
+ @Override
+ public void onHandleIntent(Intent intent) {
+ Log.i(TAG, "Starting BlockedNumberService service: " + intent);
+ if (intent == null) {
+ return;
+ }
+ Bundle bundle;
+ mContentResolver = getContentResolver();
+ switch (intent.getAction()) {
+ case INSERT_ACTION:
+ bundle = insertBlockedNumber(intent.getStringExtra(PHONE_NUMBER_EXTRA));
+ break;
+ case DELETE_ACTION:
+ bundle = deleteBlockedNumber(Uri.parse(intent.getStringExtra(URI_EXTRA)));
+ break;
+ default:
+ bundle = new Bundle();
+ break;
+ }
+ ResultReceiver receiver = intent.getParcelableExtra(RESULT_RECEIVER_EXTRA);
+ receiver.send(0, bundle);
+ }
+
+ private Bundle insertBlockedNumber(String number) {
+ Log.i(TAG, "insertBlockedNumber: " + number);
+
+ ContentValues cv = new ContentValues();
+ cv.put(COLUMN_ORIGINAL_NUMBER, number);
+ Uri uri = mContentResolver.insert(CONTENT_URI, cv);
+ Bundle bundle = new Bundle();
+ bundle.putString(URI_EXTRA, uri.toString());
+ return bundle;
+ }
+
+ private Bundle deleteBlockedNumber(Uri uri) {
+ Log.i(TAG, "deleteBlockedNumber: " + uri);
+
+ int rows = mContentResolver.delete(uri, null, null);
+ Bundle bundle = new Bundle();
+ bundle.putInt(ROWS_EXTRA, rows);
+ return bundle;
+ }
+}
diff --git a/common/device-side/util/src/com/android/compatibility/common/util/BlockedNumberUtil.java b/common/device-side/util/src/com/android/compatibility/common/util/BlockedNumberUtil.java
new file mode 100644
index 00000000000..e5a0ce49b73
--- /dev/null
+++ b/common/device-side/util/src/com/android/compatibility/common/util/BlockedNumberUtil.java
@@ -0,0 +1,92 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+import static com.android.compatibility.common.util.BlockedNumberService.DELETE_ACTION;
+import static com.android.compatibility.common.util.BlockedNumberService.INSERT_ACTION;
+import static com.android.compatibility.common.util.BlockedNumberService.PHONE_NUMBER_EXTRA;
+import static com.android.compatibility.common.util.BlockedNumberService.RESULT_RECEIVER_EXTRA;
+import static com.android.compatibility.common.util.BlockedNumberService.ROWS_EXTRA;
+import static com.android.compatibility.common.util.BlockedNumberService.URI_EXTRA;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.ResultReceiver;
+
+import junit.framework.TestCase;
+
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Utility for starting the blocked number service.
+ */
+public class BlockedNumberUtil {
+
+ private static final int TIMEOUT = 2;
+
+ private BlockedNumberUtil() {}
+
+ /** Insert a phone number into the blocked number provider and returns the resulting Uri. */
+ public static Uri insertBlockedNumber(Context context, String phoneNumber) {
+ Intent intent = new Intent(INSERT_ACTION);
+ intent.putExtra(PHONE_NUMBER_EXTRA, phoneNumber);
+
+ return Uri.parse(runBlockedNumberService(context, intent).getString(URI_EXTRA));
+ }
+
+ /** Remove a number from the blocked number provider and returns the number of rows deleted. */
+ public static int deleteBlockedNumber(Context context, Uri uri) {
+ Intent intent = new Intent(DELETE_ACTION);
+ intent.putExtra(URI_EXTRA, uri.toString());
+
+ return runBlockedNumberService(context, intent).getInt(ROWS_EXTRA);
+ }
+
+ /** Start the blocked number service. */
+ static Bundle runBlockedNumberService(Context context, Intent intent) {
+ // Temporarily allow background service
+ SystemUtil.runShellCommand("cmd deviceidle tempwhitelist " + context.getPackageName());
+
+ final Semaphore semaphore = new Semaphore(0);
+ final Bundle result = new Bundle();
+
+ ResultReceiver receiver = new ResultReceiver(new Handler(Looper.getMainLooper())) {
+ @Override
+ protected void onReceiveResult(int resultCode, Bundle resultData) {
+ result.putAll(resultData);
+ semaphore.release();
+ }
+ };
+ intent.putExtra(RESULT_RECEIVER_EXTRA, receiver);
+ intent.setComponent(new ComponentName(context, BlockedNumberService.class));
+
+ context.startService(intent);
+
+ try {
+ TestCase.assertTrue(semaphore.tryAcquire(TIMEOUT, TimeUnit.SECONDS));
+ } catch (InterruptedException e) {
+ TestCase.fail("Timed out waiting for result from BlockedNumberService");
+ }
+ return result;
+ }
+}
diff --git a/common/device-side/util/src/com/android/compatibility/common/util/PropertyUtil.java b/common/device-side/util/src/com/android/compatibility/common/util/PropertyUtil.java
index 08fe4410b88..b98acee26b3 100644
--- a/common/device-side/util/src/com/android/compatibility/common/util/PropertyUtil.java
+++ b/common/device-side/util/src/com/android/compatibility/common/util/PropertyUtil.java
@@ -16,8 +16,6 @@
package com.android.compatibility.common.util;
-import com.android.compatibility.common.util.SystemUtil;
-
import android.os.Build;
import android.support.test.InstrumentationRegistry;
diff --git a/common/device-side/util/src/com/android/compatibility/common/util/WidgetTestUtils.java b/common/device-side/util/src/com/android/compatibility/common/util/WidgetTestUtils.java
index 3d98c56c4c5..a80d8bbaa44 100644
--- a/common/device-side/util/src/com/android/compatibility/common/util/WidgetTestUtils.java
+++ b/common/device-side/util/src/com/android/compatibility/common/util/WidgetTestUtils.java
@@ -39,7 +39,8 @@ import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import static android.view.ViewTreeObserver.*;
+import static android.view.ViewTreeObserver.OnDrawListener;
+import static android.view.ViewTreeObserver.OnGlobalLayoutListener;
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
/**
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/AdoptableHostTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/AdoptableHostTest.java
index ad98fa218e2..2e782725702 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/AdoptableHostTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/AdoptableHostTest.java
@@ -117,6 +117,18 @@ public class AdoptableHostTest extends BaseHostJUnit4Test {
// Unmount, remount and verify
getDevice().executeShellCommand("sm unmount " + vol.volId);
getDevice().executeShellCommand("sm mount " + vol.volId);
+
+ int attempt = 0;
+ String pkgPath = getDevice().executeShellCommand("pm path " + PKG);
+ while ((pkgPath == null || pkgPath.isEmpty()) && attempt++ < 15) {
+ Thread.sleep(1000);
+ pkgPath = getDevice().executeShellCommand("pm path " + PKG);
+ }
+
+ if (pkgPath == null || pkgPath.isEmpty()) {
+ throw new AssertionError("Package not ready yet");
+ }
+
runDeviceTests(PKG, CLASS, "testDataNotInternal");
runDeviceTests(PKG, CLASS, "testDataRead");
runDeviceTests(PKG, CLASS, "testNative");
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/AppSecurityTests.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/AppSecurityTests.java
index 3231d0c5671..f8f866de541 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/AppSecurityTests.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/AppSecurityTests.java
@@ -173,14 +173,15 @@ public class AppSecurityTests extends BaseHostJUnit4Test {
assertNull(String.format("failed to install app with data. Reason: %s", installResult),
installResult);
// run appwithdata's tests to create private data
- runDeviceTests(APP_WITH_DATA_PKG, APP_WITH_DATA_CLASS, APP_WITH_DATA_CREATE_METHOD);
+ runDeviceTestsAsCurrentUser(
+ APP_WITH_DATA_PKG, APP_WITH_DATA_CLASS, APP_WITH_DATA_CREATE_METHOD);
installResult = getDevice().installPackage(getTestAppFile(APP_ACCESS_DATA_APK),
false, options);
assertNull(String.format("failed to install app access data. Reason: %s",
installResult), installResult);
// run appaccessdata's tests which attempt to access appwithdata's private data
- runDeviceTests(APP_ACCESS_DATA_PKG);
+ runDeviceTestsAsCurrentUser(APP_ACCESS_DATA_PKG);
} finally {
getDevice().uninstallPackage(APP_WITH_DATA_PKG);
getDevice().uninstallPackage(APP_ACCESS_DATA_PKG);
@@ -204,7 +205,8 @@ public class AppSecurityTests extends BaseHostJUnit4Test {
assertNull(String.format("failed to install app with data. Reason: %s", installResult),
installResult);
// run appwithdata's tests to create private data
- runDeviceTests(APP_WITH_DATA_PKG, APP_WITH_DATA_CLASS, APP_WITH_DATA_CREATE_METHOD);
+ runDeviceTestsAsCurrentUser(
+ APP_WITH_DATA_PKG, APP_WITH_DATA_CLASS, APP_WITH_DATA_CREATE_METHOD);
getDevice().uninstallPackage(APP_WITH_DATA_PKG);
@@ -213,7 +215,7 @@ public class AppSecurityTests extends BaseHostJUnit4Test {
assertNull(String.format("failed to install app with data second time. Reason: %s",
installResult), installResult);
// run appwithdata's 'check if file exists' test
- runDeviceTests(APP_WITH_DATA_PKG, APP_WITH_DATA_CLASS,
+ runDeviceTestsAsCurrentUser(APP_WITH_DATA_PKG, APP_WITH_DATA_CLASS,
APP_WITH_DATA_CHECK_NOEXIST_METHOD);
} finally {
getDevice().uninstallPackage(APP_WITH_DATA_PKG);
@@ -247,7 +249,7 @@ public class AppSecurityTests extends BaseHostJUnit4Test {
// run INSTRUMENT_DIFF_CERT_PKG tests
// this test will attempt to call startInstrumentation directly and verify
// SecurityException is thrown
- runDeviceTests(INSTRUMENT_DIFF_CERT_PKG);
+ runDeviceTestsAsCurrentUser(INSTRUMENT_DIFF_CERT_PKG);
} finally {
getDevice().uninstallPackage(TARGET_INSTRUMENT_PKG);
getDevice().uninstallPackage(INSTRUMENT_DIFF_CERT_PKG);
@@ -285,7 +287,7 @@ public class AppSecurityTests extends BaseHostJUnit4Test {
assertNull(String.format("failed to install permission app with diff cert. Reason: %s",
installResult), installResult);
// run PERMISSION_DIFF_CERT_PKG tests which try to access the permission
- runDeviceTests(PERMISSION_DIFF_CERT_PKG);
+ runDeviceTestsAsCurrentUser(PERMISSION_DIFF_CERT_PKG);
} finally {
getDevice().uninstallPackage(DECLARE_PERMISSION_PKG);
getDevice().uninstallPackage(DECLARE_PERMISSION_COMPAT_PKG);
@@ -304,7 +306,14 @@ public class AppSecurityTests extends BaseHostJUnit4Test {
assertTrue("Error text", output.contains("Error"));
}
- private void runDeviceTests(String packageName) throws DeviceNotAvailableException {
- runDeviceTests(packageName, null);
+ private void runDeviceTestsAsCurrentUser(String packageName)
+ throws DeviceNotAvailableException {
+ Utils.runDeviceTestsAsCurrentUser(getDevice(), packageName, null, null);
+ }
+
+ private void runDeviceTestsAsCurrentUser(
+ String packageName, String className, String methodName)
+ throws DeviceNotAvailableException {
+ Utils.runDeviceTestsAsCurrentUser(getDevice(), packageName, className, methodName);
}
}
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/ClassloaderSplitsTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/ClassloaderSplitsTest.java
index 6830f305deb..edcbd97b6e8 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/ClassloaderSplitsTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/ClassloaderSplitsTest.java
@@ -16,6 +16,7 @@
package android.appsecurity.cts;
import android.platform.test.annotations.AppModeFull;
+import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
import com.android.tradefed.testtype.IBuildReceiver;
import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
@@ -61,32 +62,32 @@ public class ClassloaderSplitsTest extends BaseHostJUnit4Test implements IBuildR
@AppModeFull // TODO: Needs porting to instant
public void testBaseClassLoader() throws Exception {
new InstallMultiple().addApk(APK_BASE).run();
- runDeviceTests(getDevice(), PKG, TEST_CLASS, "testBaseClassLoader");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "testBaseClassLoader");
}
@Test
@AppModeFull // TODO: Needs porting to instant
public void testFeatureAClassLoader() throws Exception {
new InstallMultiple().addApk(APK_BASE).addApk(APK_FEATURE_A).run();
- runDeviceTests(getDevice(), PKG, TEST_CLASS, "testBaseClassLoader");
- runDeviceTests(getDevice(), PKG, TEST_CLASS, "testFeatureAClassLoader");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "testBaseClassLoader");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "testFeatureAClassLoader");
}
@Test
@AppModeFull // TODO: Needs porting to instant
public void testFeatureBClassLoader() throws Exception {
new InstallMultiple().addApk(APK_BASE).addApk(APK_FEATURE_A).addApk(APK_FEATURE_B).run();
- runDeviceTests(getDevice(), PKG, TEST_CLASS, "testBaseClassLoader");
- runDeviceTests(getDevice(), PKG, TEST_CLASS, "testFeatureAClassLoader");
- runDeviceTests(getDevice(), PKG, TEST_CLASS, "testFeatureBClassLoader");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "testBaseClassLoader");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "testFeatureAClassLoader");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "testFeatureBClassLoader");
}
@Test
@AppModeFull // TODO: Needs porting to instant
public void testReceiverClassLoaders() throws Exception {
new InstallMultiple().addApk(APK_BASE).addApk(APK_FEATURE_A).addApk(APK_FEATURE_B).run();
- runDeviceTests(getDevice(), PKG, TEST_CLASS, "testBaseClassLoader");
- runDeviceTests(getDevice(), PKG, TEST_CLASS, "testAllReceivers");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "testBaseClassLoader");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "testAllReceivers");
}
private class InstallMultiple extends BaseInstallMultiple<InstallMultiple> {
@@ -94,4 +95,10 @@ public class ClassloaderSplitsTest extends BaseHostJUnit4Test implements IBuildR
super(getDevice(), getBuild(), null);
}
}
+
+ private void runDeviceTestsAsCurrentUser(
+ String packageName, String testClassName, String testMethodName)
+ throws DeviceNotAvailableException {
+ Utils.runDeviceTestsAsCurrentUser(getDevice(), packageName, testClassName, testMethodName);
+ }
}
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/IsolatedSplitsTests.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/IsolatedSplitsTests.java
index dc08b6cd763..a9ac9b03366 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/IsolatedSplitsTests.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/IsolatedSplitsTests.java
@@ -17,6 +17,7 @@ package android.appsecurity.cts;
import android.platform.test.annotations.AppModeFull;
import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.testtype.DeviceTestCase;
import com.android.tradefed.testtype.IBuildReceiver;
@@ -58,12 +59,12 @@ public class IsolatedSplitsTests extends DeviceTestCase implements IBuildReceive
public void testInstallBase() throws Exception {
new InstallMultiple().addApk(APK_BASE).run();
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadDefault");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadDefault");
}
public void testInstallBaseAndConfigSplit() throws Exception {
new InstallMultiple().addApk(APK_BASE).addApk(APK_BASE_pl).run();
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadPolishLocale");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadPolishLocale");
}
public void testInstallMissingDependency() throws Exception {
@@ -72,52 +73,52 @@ public class IsolatedSplitsTests extends DeviceTestCase implements IBuildReceive
public void testInstallOneFeatureSplit() throws Exception {
new InstallMultiple().addApk(APK_BASE).addApk(APK_FEATURE_A).run();
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadDefault");
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadFeatureADefault");
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadFeatureAReceivers");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadDefault");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadFeatureADefault");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadFeatureAReceivers");
}
public void testInstallOneFeatureSplitAndConfigSplits() throws Exception {
new InstallMultiple().addApk(APK_BASE).addApk(APK_FEATURE_A).addApk(APK_BASE_pl)
.addApk(APK_FEATURE_A_pl).run();
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadPolishLocale");
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadFeatureAPolishLocale");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadPolishLocale");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadFeatureAPolishLocale");
}
public void testInstallDependentFeatureSplits() throws Exception {
new InstallMultiple().addApk(APK_BASE).addApk(APK_FEATURE_A).addApk(APK_FEATURE_B).run();
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadDefault");
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadFeatureADefault");
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadFeatureBDefault");
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadFeatureAAndBReceivers");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadDefault");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadFeatureADefault");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadFeatureBDefault");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadFeatureAAndBReceivers");
}
public void testInstallDependentFeatureSplitsAndConfigSplits() throws Exception {
new InstallMultiple().addApk(APK_BASE).addApk(APK_FEATURE_A).addApk(APK_FEATURE_B)
.addApk(APK_BASE_pl).addApk(APK_FEATURE_A_pl).addApk(APK_FEATURE_B_pl).run();
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadPolishLocale");
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadFeatureAPolishLocale");
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadFeatureBPolishLocale");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadPolishLocale");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadFeatureAPolishLocale");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadFeatureBPolishLocale");
}
public void testInstallAllFeatureSplits() throws Exception {
new InstallMultiple().addApk(APK_BASE).addApk(APK_FEATURE_A).addApk(APK_FEATURE_B)
.addApk(APK_FEATURE_C).run();
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadDefault");
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadFeatureADefault");
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadFeatureBDefault");
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadFeatureCDefault");
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadFeatureAAndBAndCReceivers");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadDefault");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadFeatureADefault");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadFeatureBDefault");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadFeatureCDefault");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadFeatureAAndBAndCReceivers");
}
public void testInstallAllFeatureSplitsAndConfigSplits() throws Exception {
new InstallMultiple().addApk(APK_BASE).addApk(APK_FEATURE_A).addApk(APK_FEATURE_B)
.addApk(APK_FEATURE_C).addApk(APK_BASE_pl).addApk(APK_FEATURE_A_pl)
.addApk(APK_FEATURE_C_pl).run();
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadDefault");
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadFeatureADefault");
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadFeatureBDefault");
- Utils.runDeviceTests(getDevice(), PKG, TEST_CLASS, "shouldLoadFeatureCDefault");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadDefault");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadFeatureADefault");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadFeatureBDefault");
+ runDeviceTestsAsCurrentUser(PKG, TEST_CLASS, "shouldLoadFeatureCDefault");
}
@Override
@@ -130,4 +131,10 @@ public class IsolatedSplitsTests extends DeviceTestCase implements IBuildReceive
super(getDevice(), mBuildInfo, null);
}
}
+
+ private void runDeviceTestsAsCurrentUser(
+ String packageName, String testClassName, String testMethodName)
+ throws DeviceNotAvailableException {
+ Utils.runDeviceTestsAsCurrentUser(getDevice(), packageName, testClassName, testMethodName);
+ }
}
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/MajorVersionTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/MajorVersionTest.java
index e1d913e55f9..512a753b905 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/MajorVersionTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/MajorVersionTest.java
@@ -71,7 +71,7 @@ public class MajorVersionTest extends DeviceTestCase implements IAbiReceiver, IB
assertNull(getDevice().installPackage(
mBuildHelper.getTestFile(APK_000000000000ffff), false, false));
assertTrue(getDevice().getInstalledPackageNames().contains(PKG));
- runVersionDeviceTests("testCheckVersion");
+ runDeviceTestsAsCurrentUser("testCheckVersion");
getDevice().uninstallPackage(PKG);
}
@@ -79,7 +79,7 @@ public class MajorVersionTest extends DeviceTestCase implements IAbiReceiver, IB
assertNull(getDevice().installPackage(
mBuildHelper.getTestFile(APK_000000ff00000000), false, false));
assertTrue(getDevice().getInstalledPackageNames().contains(PKG));
- runVersionDeviceTests("testCheckVersion");
+ runDeviceTestsAsCurrentUser("testCheckVersion");
getDevice().uninstallPackage(PKG);
}
@@ -87,19 +87,19 @@ public class MajorVersionTest extends DeviceTestCase implements IAbiReceiver, IB
assertNull(getDevice().installPackage(
mBuildHelper.getTestFile(APK_000000000000ffff), false, false));
assertTrue(getDevice().getInstalledPackageNames().contains(PKG));
- runVersionDeviceTests("testCheckVersion");
+ runDeviceTestsAsCurrentUser("testCheckVersion");
assertNull(getDevice().installPackage(
mBuildHelper.getTestFile(APK_00000000ffffffff), true, false));
assertTrue(getDevice().getInstalledPackageNames().contains(PKG));
- runVersionDeviceTests("testCheckVersion");
+ runDeviceTestsAsCurrentUser("testCheckVersion");
assertNull(getDevice().installPackage(
mBuildHelper.getTestFile(APK_000000ff00000000), true, false));
assertTrue(getDevice().getInstalledPackageNames().contains(PKG));
- runVersionDeviceTests("testCheckVersion");
+ runDeviceTestsAsCurrentUser("testCheckVersion");
assertNull(getDevice().installPackage(
mBuildHelper.getTestFile(APK_000000ffffffffff), true, false));
assertTrue(getDevice().getInstalledPackageNames().contains(PKG));
- runVersionDeviceTests("testCheckVersion");
+ runDeviceTestsAsCurrentUser("testCheckVersion");
getDevice().uninstallPackage(PKG);
}
@@ -107,29 +107,29 @@ public class MajorVersionTest extends DeviceTestCase implements IAbiReceiver, IB
assertNull(getDevice().installPackage(
mBuildHelper.getTestFile(APK_000000ffffffffff), false, false));
assertTrue(getDevice().getInstalledPackageNames().contains(PKG));
- runVersionDeviceTests("testCheckVersion");
+ runDeviceTestsAsCurrentUser("testCheckVersion");
assertEquals("INSTALL_FAILED_VERSION_DOWNGRADE", getDevice().installPackage(
mBuildHelper.getTestFile(APK_00000000ffffffff), true, false));
assertTrue(getDevice().getInstalledPackageNames().contains(PKG));
- runVersionDeviceTests("testCheckVersion");
+ runDeviceTestsAsCurrentUser("testCheckVersion");
assertEquals("INSTALL_FAILED_VERSION_DOWNGRADE", getDevice().installPackage(
mBuildHelper.getTestFile(APK_000000ff00000000), true, false));
assertTrue(getDevice().getInstalledPackageNames().contains(PKG));
- runVersionDeviceTests("testCheckVersion");
+ runDeviceTestsAsCurrentUser("testCheckVersion");
assertEquals("INSTALL_FAILED_VERSION_DOWNGRADE", getDevice().installPackage(
mBuildHelper.getTestFile(APK_000000000000ffff), true, false));
assertTrue(getDevice().getInstalledPackageNames().contains(PKG));
- runVersionDeviceTests("testCheckVersion");
+ runDeviceTestsAsCurrentUser("testCheckVersion");
getDevice().uninstallPackage(PKG);
}
- private void runVersionDeviceTests(String testMethodName)
+ private void runDeviceTestsAsCurrentUser(String testMethodName)
throws DeviceNotAvailableException {
- runDeviceTests(PKG, PKG + ".VersionTest", testMethodName);
+ runDeviceTestsAsCurrentUser(PKG, PKG + ".VersionTest", testMethodName);
}
- private void runDeviceTests(String packageName, String testClassName, String testMethodName)
+ private void runDeviceTestsAsCurrentUser(String packageName, String testClassName, String testMethodName)
throws DeviceNotAvailableException {
- Utils.runDeviceTests(getDevice(), packageName, testClassName, testMethodName);
+ Utils.runDeviceTestsAsCurrentUser(getDevice(), packageName, testClassName, testMethodName);
}
}
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/PackageResolutionHostTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/PackageResolutionHostTest.java
index 8e409bb4e60..d918ffff40a 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/PackageResolutionHostTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/PackageResolutionHostTest.java
@@ -56,7 +56,7 @@ public class PackageResolutionHostTest extends BaseAppSecurityTest {
@AppModeFull // TODO: Needs porting to instant
public void testResolveOrderedActivity() throws Exception {
getDevice().installPackage(mBuildHelper.getTestFile(TINY_APK), true);
- Utils.runDeviceTests(getDevice(), TINY_PKG,
+ Utils.runDeviceTestsAsCurrentUser(getDevice(), TINY_PKG,
".PackageResolutionTest", "queryActivityOrdered");
getDevice().uninstallPackage(TINY_PKG);
}
@@ -65,7 +65,7 @@ public class PackageResolutionHostTest extends BaseAppSecurityTest {
@AppModeFull // TODO: Needs porting to instant
public void testResolveOrderedService() throws Exception {
getDevice().installPackage(mBuildHelper.getTestFile(TINY_APK), true);
- Utils.runDeviceTests(getDevice(), TINY_PKG,
+ Utils.runDeviceTestsAsCurrentUser(getDevice(), TINY_PKG,
".PackageResolutionTest", "queryServiceOrdered");
getDevice().uninstallPackage(TINY_PKG);
}
@@ -74,7 +74,7 @@ public class PackageResolutionHostTest extends BaseAppSecurityTest {
@AppModeFull // TODO: Needs porting to instant
public void testResolveOrderedReceiver() throws Exception {
getDevice().installPackage(mBuildHelper.getTestFile(TINY_APK), true);
- Utils.runDeviceTests(getDevice(), TINY_PKG,
+ Utils.runDeviceTestsAsCurrentUser(getDevice(), TINY_PKG,
".PackageResolutionTest", "queryReceiverOrdered");
getDevice().uninstallPackage(TINY_PKG);
}
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/SplitTests.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/SplitTests.java
index f8841cbd9e9..0884818f80a 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/SplitTests.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/SplitTests.java
@@ -127,7 +127,7 @@ public class SplitTests extends DeviceTestCase implements IAbiReceiver, IBuildRe
private void testSingleBase(boolean instant) throws Exception {
new InstallMultiple().addApk(APK)
.addArg(instant ? "--instant" : "").run();
- runDeviceTests(PKG, CLASS, "testSingleBase");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testSingleBase");
}
@AppModeInstant
@@ -143,7 +143,7 @@ public class SplitTests extends DeviceTestCase implements IAbiReceiver, IBuildRe
private void testDensitySingle(boolean instant) throws Exception {
new InstallMultiple().addApk(APK).addApk(APK_mdpi)
.addArg(instant ? "--instant" : "").run();
- runDeviceTests(PKG, CLASS, "testDensitySingle");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testDensitySingle");
}
@AppModeInstant
@@ -159,7 +159,7 @@ public class SplitTests extends DeviceTestCase implements IAbiReceiver, IBuildRe
private void testDensityAll(boolean instant) throws Exception {
new InstallMultiple().addApk(APK).addApk(APK_mdpi).addApk(APK_hdpi).addApk(APK_xhdpi)
.addApk(APK_xxhdpi).addArg(instant ? "--instant" : "").run();
- runDeviceTests(PKG, CLASS, "testDensityAll");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testDensityAll");
}
/**
@@ -183,12 +183,12 @@ public class SplitTests extends DeviceTestCase implements IAbiReceiver, IBuildRe
private void testDensityBest(boolean instant) throws Exception {
new InstallMultiple().addApk(APK).addApk(APK_mdpi)
.addArg(instant ? "--instant" : "").run();
- runDeviceTests(PKG, CLASS, "testDensityBest1");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testDensityBest1");
// Now splice in an additional split which offers better resources
new InstallMultiple().inheritFrom(PKG).addApk(APK_xxhdpi)
.addArg(instant ? "--instant" : "").run();
- runDeviceTests(PKG, CLASS, "testDensityBest2");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testDensityBest2");
}
/**
@@ -212,7 +212,7 @@ public class SplitTests extends DeviceTestCase implements IAbiReceiver, IBuildRe
private void testApi(boolean instant) throws Exception {
new InstallMultiple().addApk(APK).addApk(APK_v7)
.addArg(instant ? "--instant" : "").run();
- runDeviceTests(PKG, CLASS, "testApi");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testApi");
}
@AppModeInstant
@@ -228,7 +228,7 @@ public class SplitTests extends DeviceTestCase implements IAbiReceiver, IBuildRe
private void testLocale(boolean instant) throws Exception {
new InstallMultiple().addApk(APK).addApk(APK_de).addApk(APK_fr)
.addArg(instant ? "--instant" : "").run();
- runDeviceTests(PKG, CLASS, "testLocale");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testLocale");
}
/**
@@ -256,7 +256,7 @@ public class SplitTests extends DeviceTestCase implements IAbiReceiver, IBuildRe
new InstallMultiple().addApk(APK).addApk(apk)
.addArg(instant ? "--instant" : "").run();
- runDeviceTests(PKG, CLASS, "testNative");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testNative");
}
/**
@@ -288,7 +288,7 @@ public class SplitTests extends DeviceTestCase implements IAbiReceiver, IBuildRe
new InstallMultiple().useNaturalAbi().addApk(APK).addApk(apk)
.addArg(instant ? "--instant" : "").run();
- runDeviceTests(PKG, CLASS, "testNative");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testNative");
}
/**
@@ -343,7 +343,7 @@ public class SplitTests extends DeviceTestCase implements IAbiReceiver, IBuildRe
inst.useNaturalAbi();
}
inst.run();
- runDeviceTests(PKG, CLASS, "testNative");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testNative");
}
@AppModeInstant
@@ -451,7 +451,7 @@ public class SplitTests extends DeviceTestCase implements IAbiReceiver, IBuildRe
private void testDiffRevision(boolean instant) throws Exception {
new InstallMultiple().addApk(APK).addApk(APK_DIFF_REVISION_v7)
.addArg(instant ? "--instant" : "").run();
- runDeviceTests(PKG, CLASS, "testRevision0_12");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testRevision0_12");
}
@AppModeInstant
@@ -467,10 +467,10 @@ public class SplitTests extends DeviceTestCase implements IAbiReceiver, IBuildRe
private void testDiffRevisionInheritBase(boolean instant) throws Exception {
new InstallMultiple().addApk(APK).addApk(APK_v7)
.addArg(instant ? "--instant" : "").run();
- runDeviceTests(PKG, CLASS, "testRevision0_0");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testRevision0_0");
new InstallMultiple().inheritFrom(PKG).addApk(APK_DIFF_REVISION_v7)
.addArg(instant ? "--instant" : "").run();
- runDeviceTests(PKG, CLASS, "testRevision0_12");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testRevision0_12");
}
@AppModeInstant
@@ -486,10 +486,10 @@ public class SplitTests extends DeviceTestCase implements IAbiReceiver, IBuildRe
private void testDiffRevisionInheritSplit(boolean instant) throws Exception {
new InstallMultiple().addApk(APK).addApk(APK_v7)
.addArg(instant ? "--instant" : "").run();
- runDeviceTests(PKG, CLASS, "testRevision0_0");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testRevision0_0");
new InstallMultiple().inheritFrom(PKG).addApk(APK_DIFF_REVISION)
.addArg(instant ? "--instant" : "").run();
- runDeviceTests(PKG, CLASS, "testRevision12_0");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testRevision12_0");
}
@AppModeInstant
@@ -522,7 +522,7 @@ public class SplitTests extends DeviceTestCase implements IAbiReceiver, IBuildRe
private void testFeatureBase(boolean instant) throws Exception {
new InstallMultiple().addApk(APK).addApk(APK_FEATURE)
.addArg(instant ? "--instant" : "").run();
- runDeviceTests(PKG, CLASS, "testFeatureBase");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testFeatureBase");
}
@AppModeInstant
@@ -538,7 +538,7 @@ public class SplitTests extends DeviceTestCase implements IAbiReceiver, IBuildRe
private void testFeatureApiInstant(boolean instant) throws Exception {
new InstallMultiple().addApk(APK).addApk(APK_FEATURE).addApk(APK_FEATURE_v7)
.addArg(instant ? "--instant" : "").run();
- runDeviceTests(PKG, CLASS, "testFeatureApi");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testFeatureApi");
}
@AppModeFull
@@ -571,10 +571,10 @@ public class SplitTests extends DeviceTestCase implements IAbiReceiver, IBuildRe
if (instant) {
// Poke the full app so it can see the instant app.
- runDeviceTests(PKG_NO_RESTART, CLASS_NO_RESTART, "testPokeFullApp");
+ runDeviceTestsAsCurrentUser(PKG_NO_RESTART, CLASS_NO_RESTART, "testPokeFullApp");
}
- runDeviceTests(PKG, CLASS, "testBaseInstalled");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testBaseInstalled");
new InstallMultiple()
.addArg(instant ? "--instant" : "")
@@ -582,7 +582,7 @@ public class SplitTests extends DeviceTestCase implements IAbiReceiver, IBuildRe
.inheritFrom(PKG_NO_RESTART)
.addApk(APK_NO_RESTART_FEATURE)
.run();
- runDeviceTests(PKG, CLASS, "testFeatureInstalled");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testFeatureInstalled");
}
/**
@@ -604,10 +604,10 @@ public class SplitTests extends DeviceTestCase implements IAbiReceiver, IBuildRe
private void testClearCodeCache(boolean instant) throws Exception {
new InstallMultiple().addApk(APK)
.addArg(instant ? "--instant" : "").run();
- runDeviceTests(PKG, CLASS, "testCodeCacheWrite");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testCodeCacheWrite");
new InstallMultiple().addArg("-r").addApk(APK_DIFF_VERSION)
.addArg(instant ? "--instant" : "").run();
- runDeviceTests(PKG, CLASS, "testCodeCacheRead");
+ runDeviceTestsAsCurrentUser(PKG, CLASS, "testCodeCacheRead");
}
private class InstallMultiple extends BaseInstallMultiple<InstallMultiple> {
@@ -616,8 +616,9 @@ public class SplitTests extends DeviceTestCase implements IAbiReceiver, IBuildRe
}
}
- public void runDeviceTests(String packageName, String testClassName, String testMethodName)
- throws DeviceNotAvailableException {
- Utils.runDeviceTests(getDevice(), packageName, testClassName, testMethodName);
+ public void runDeviceTestsAsCurrentUser(
+ String packageName, String testClassName, String testMethodName)
+ throws DeviceNotAvailableException {
+ Utils.runDeviceTestsAsCurrentUser(getDevice(), packageName, testClassName, testMethodName);
}
}
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/UsesLibraryHostTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/UsesLibraryHostTest.java
index a8c3dd955f7..7ac3efb9826 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/UsesLibraryHostTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/UsesLibraryHostTest.java
@@ -69,21 +69,22 @@ public class UsesLibraryHostTest extends DeviceTestCase implements IAbiReceiver,
public void testUsesLibrary() throws Exception {
assertNull(getDevice().installPackage(mBuildHelper.getTestFile(APK), false, false));
- runDeviceTests(PKG, ".UsesLibraryTest", "testUsesLibrary");
+ runDeviceTestsAsCurrentUser(PKG, ".UsesLibraryTest", "testUsesLibrary");
}
public void testMissingLibrary() throws Exception {
assertNull(getDevice().installPackage(mBuildHelper.getTestFile(APK), false, false));
- runDeviceTests(PKG, ".UsesLibraryTest", "testMissingLibrary");
+ runDeviceTestsAsCurrentUser(PKG, ".UsesLibraryTest", "testMissingLibrary");
}
public void testDuplicateLibrary() throws Exception {
assertNull(getDevice().installPackage(mBuildHelper.getTestFile(APK), false, false));
- runDeviceTests(PKG, ".UsesLibraryTest", "testDuplicateLibrary");
+ runDeviceTestsAsCurrentUser(PKG, ".UsesLibraryTest", "testDuplicateLibrary");
}
- private void runDeviceTests(String packageName, String testClassName, String testMethodName)
- throws DeviceNotAvailableException {
- Utils.runDeviceTests(getDevice(), packageName, testClassName, testMethodName);
+ private void runDeviceTestsAsCurrentUser(
+ String packageName, String testClassName, String testMethodName)
+ throws DeviceNotAvailableException {
+ Utils.runDeviceTestsAsCurrentUser(getDevice(), packageName, testClassName, testMethodName);
}
}
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/Utils.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/Utils.java
index c63720f79b1..e62297bca18 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/Utils.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/Utils.java
@@ -32,6 +32,19 @@ import java.util.concurrent.TimeUnit;
public class Utils {
public static final int USER_SYSTEM = 0;
+ public static void runDeviceTestsAsCurrentUser(ITestDevice device, String packageName,
+ String testClassName, String testMethodName) throws DeviceNotAvailableException {
+ runDeviceTests(device, packageName, testClassName, testMethodName, device.getCurrentUser(),
+ null);
+ }
+
+ public static void runDeviceTestsAsCurrentUser(ITestDevice device, String packageName,
+ String testClassName, String testMethodName, Map<String, String> testArgs)
+ throws DeviceNotAvailableException {
+ runDeviceTests(device, packageName, testClassName, testMethodName, device.getCurrentUser(),
+ testArgs);
+ }
+
public static void runDeviceTests(ITestDevice device, String packageName, String testClassName,
String testMethodName) throws DeviceNotAvailableException {
runDeviceTests(device, packageName, testClassName, testMethodName, USER_SYSTEM, null);
diff --git a/hostsidetests/backup/AndroidTest.xml b/hostsidetests/backup/AndroidTest.xml
index 868e20f1fc0..b78cd07b06b 100644
--- a/hostsidetests/backup/AndroidTest.xml
+++ b/hostsidetests/backup/AndroidTest.xml
@@ -16,6 +16,9 @@
<configuration description="Config for CTS Backup host test cases">
<option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="backup" />
+ <target_preparer class="com.android.tradefed.targetprep.SwitchUserTargetPreparer">
+ <option name="user-type" value="system" />
+ </target_preparer>
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsFullbackupApp.apk" />
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskHostDrivenTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskHostDrivenTest.java
index 1d6105d2c77..1b8a2fa3071 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskHostDrivenTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskHostDrivenTest.java
@@ -20,6 +20,7 @@ import static junit.framework.Assert.assertTrue;
import android.app.ActivityManager;
import android.app.admin.DevicePolicyManager;
+import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -30,6 +31,7 @@ import android.support.test.uiautomator.UiDevice;
import android.util.Log;
import org.junit.Before;
+import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -45,6 +47,8 @@ public class LockTaskHostDrivenTest {
private static final String TAG = LockTaskHostDrivenTest.class.getName();
+ private static final int ACTIVITY_RESUMED_TIMEOUT_MILLIS = 20000; // 20 seconds
+
private static final String LOCK_TASK_ACTIVITY
= LockTaskUtilityActivityIfWhitelisted.class.getName();
@@ -53,14 +57,45 @@ public class LockTaskHostDrivenTest {
private ActivityManager mActivityManager;
private DevicePolicyManager mDevicePolicyManager;
+ private volatile boolean mIsActivityResumed;
+ private final Object mActivityResumedLock = new Object();
+
+ private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ Log.d(TAG, "onReceive: " + action);
+ if (LockTaskUtilityActivity.RESUME_ACTION.equals(action)) {
+ synchronized (mActivityResumedLock) {
+ mIsActivityResumed = true;
+ mActivityResumedLock.notify();
+ }
+ } else if (LockTaskUtilityActivity.PAUSE_ACTION.equals(action)) {
+ synchronized (mActivityResumedLock) {
+ mIsActivityResumed = false;
+ mActivityResumedLock.notify();
+ }
+ }
+ }
+ };
+
@Before
public void setUp() {
mContext = InstrumentationRegistry.getContext();
mDevicePolicyManager = mContext.getSystemService(DevicePolicyManager.class);
mActivityManager = mContext.getSystemService(ActivityManager.class);
mUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(LockTaskUtilityActivity.RESUME_ACTION);
+ filter.addAction(LockTaskUtilityActivity.PAUSE_ACTION);
+ mContext.registerReceiver(mReceiver, filter);
}
+ @After
+ public void tearDown() {
+ mContext.unregisterReceiver(mReceiver);
+ }
+
@Test
public void startLockTask() throws Exception {
Log.d(TAG, "startLockTask on host-driven test (no cleanup)");
@@ -77,6 +112,13 @@ public class LockTaskHostDrivenTest {
public void testLockTaskIsActiveAndCantBeInterrupted() throws Exception {
mUiDevice.waitForIdle();
+ // We need to wait until the LockTaskActivity is ready
+ // since com.android.cts.deviceowner can be killed by AMS for reason "start instr".
+ synchronized (mActivityResumedLock) {
+ if (!mIsActivityResumed) {
+ mActivityResumedLock.wait(ACTIVITY_RESUMED_TIMEOUT_MILLIS);
+ }
+ }
checkLockedActivityIsRunning();
mUiDevice.pressBack();
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/DummyConnectionService.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/DummyConnectionService.java
index b00e0a43fcf..7579cf7b792 100644
--- a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/DummyConnectionService.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/DummyConnectionService.java
@@ -126,7 +126,7 @@ public class DummyConnectionService extends ConnectionService {
}
/**
- * Hang up the call after 1 second in a background thread.
+ * Hang up the call after 5 second in a background thread.
* TODO: It is better if we could have a callback to know when we can disconnect the call.
*/
private static void hangUpAsync(final Connection connection) {
@@ -135,7 +135,7 @@ public class DummyConnectionService extends ConnectionService {
@Override
public void run() {
try {
- Thread.sleep(1000);
+ Thread.sleep(5000);
connection.setDisconnected(new DisconnectCause(cause));
} catch (InterruptedException ex) {
// let it be
@@ -143,4 +143,4 @@ public class DummyConnectionService extends ConnectionService {
}
}).start();
}
-} \ No newline at end of file
+}
diff --git a/hostsidetests/gputools/src/android/gputools/cts/CtsRootlessGpuDebugHostTest.java b/hostsidetests/gputools/src/android/gputools/cts/CtsRootlessGpuDebugHostTest.java
index 96096fbd53f..c17436bbef7 100644
--- a/hostsidetests/gputools/src/android/gputools/cts/CtsRootlessGpuDebugHostTest.java
+++ b/hostsidetests/gputools/src/android/gputools/cts/CtsRootlessGpuDebugHostTest.java
@@ -15,15 +15,10 @@
*/
package android.gputools.cts;
-import android.platform.test.annotations.Presubmit;
-
-import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
import com.android.tradefed.testtype.IDeviceTest;
-import com.android.ddmlib.Log;
-
import java.util.Scanner;
import org.junit.After;
@@ -218,11 +213,14 @@ public class CtsRootlessGpuDebugHostTest implements IDeviceTest {
setupLayer(LAYER_A_LIB);
setupLayer(LAYER_B_LIB);
+
// Copy them over to our DEBUG app
- mDevice.executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_A_LIB, "|", "run-as", DEBUG_APP,
- "sh", "-c", "\'cat", ">", LAYER_A_LIB, ";", "chmod", "700", LAYER_A_LIB + "\'");
- mDevice.executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_B_LIB, "|", "run-as", DEBUG_APP,
- "sh", "-c", "\'cat", ">", LAYER_B_LIB, ";", "chmod", "700", LAYER_B_LIB + "\'");
+ mDevice.executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_A_LIB, "|",
+ "run-as", DEBUG_APP, "--user", Integer.toString(mDevice.getCurrentUser()),
+ "sh", "-c", "\'cat", ">", LAYER_A_LIB, ";", "chmod", "700", LAYER_A_LIB + "\'");
+ mDevice.executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_B_LIB, "|",
+ "run-as", DEBUG_APP, "--user", Integer.toString(mDevice.getCurrentUser()),
+ "sh", "-c", "\'cat", ">", LAYER_B_LIB, ";", "chmod", "700", LAYER_B_LIB + "\'");
// Kick off our DEBUG app
mDevice.executeAdbCommand("shell", "am", "start", "-n", DEBUG_APP + "/" + ACTIVITY);
@@ -259,8 +257,9 @@ public class CtsRootlessGpuDebugHostTest implements IDeviceTest {
setupLayer(LAYER_A_LIB);
// Attempt to copy them over to our RELEASE app (this should fail)
- mDevice.executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_A_LIB, "|", "run-as", RELEASE_APP,
- "sh", "-c", "\'cat", ">", LAYER_A_LIB, ";", "chmod", "700", LAYER_A_LIB + "\'", "||", "echo", "run-as", "failed");
+ mDevice.executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_A_LIB, "|",
+ "run-as", RELEASE_APP, "--user", Integer.toString(mDevice.getCurrentUser()),
+ "sh", "-c", "\'cat", ">", LAYER_A_LIB, ";", "chmod", "700", LAYER_A_LIB + "\'", "||", "echo", "run-as", "failed");
// Kick off our RELEASE app
mDevice.executeAdbCommand("shell", "am", "start", "-n", RELEASE_APP + "/" + ACTIVITY);
@@ -291,8 +290,9 @@ public class CtsRootlessGpuDebugHostTest implements IDeviceTest {
setupLayer(LAYER_A_LIB);
// Copy it over to our DEBUG app
- mDevice.executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_A_LIB, "|", "run-as", DEBUG_APP,
- "sh", "-c", "\'cat", ">", LAYER_A_LIB, ";", "chmod", "700", LAYER_A_LIB + "\'");
+ mDevice.executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_A_LIB, "|",
+ "run-as", DEBUG_APP, "--user", Integer.toString(mDevice.getCurrentUser()),
+ "sh", "-c", "\'cat", ">", LAYER_A_LIB, ";", "chmod", "700", LAYER_A_LIB + "\'");
// Kick off our DEBUG app
mDevice.executeAdbCommand("shell", "am", "start", "-n", DEBUG_APP + "/" + ACTIVITY);
@@ -323,8 +323,9 @@ public class CtsRootlessGpuDebugHostTest implements IDeviceTest {
setupLayer(LAYER_A_LIB);
// Copy it over to our DEBUG app
- mDevice.executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_A_LIB, "|", "run-as", DEBUG_APP,
- "sh", "-c", "\'cat", ">", LAYER_A_LIB, ";", "chmod", "700", LAYER_A_LIB + "\'");
+ mDevice.executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_A_LIB, "|",
+ "run-as", DEBUG_APP, "--user", Integer.toString(mDevice.getCurrentUser()),
+ "sh", "-c", "\'cat", ">", LAYER_A_LIB, ";", "chmod", "700", LAYER_A_LIB + "\'");
// Kick off our DEBUG app
mDevice.executeAdbCommand("shell", "am", "start", "-n", DEBUG_APP + "/" + ACTIVITY);
@@ -355,8 +356,9 @@ public class CtsRootlessGpuDebugHostTest implements IDeviceTest {
setupLayer(LAYER_A_LIB);
// Copy it over to our DEBUG app
- mDevice.executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_A_LIB, "|", "run-as", DEBUG_APP,
- "sh", "-c", "\'cat", ">", LAYER_A_LIB, ";", "chmod", "700", LAYER_A_LIB + "\'");
+ mDevice.executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_A_LIB, "|",
+ "run-as", DEBUG_APP, "--user", Integer.toString(mDevice.getCurrentUser()),
+ "sh", "-c", "\'cat", ">", LAYER_A_LIB, ";", "chmod", "700", LAYER_A_LIB + "\'");
// Kick off our DEBUG app
mDevice.executeAdbCommand("shell", "am", "start", "-n", DEBUG_APP + "/" + ACTIVITY);
@@ -418,10 +420,12 @@ public class CtsRootlessGpuDebugHostTest implements IDeviceTest {
setupLayer(LAYER_B_LIB);
// Copy them over to our DEBUG app
- mDevice.executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_A_LIB, "|", "run-as", DEBUG_APP,
- "sh", "-c", "\'cat", ">", LAYER_A_LIB, ";", "chmod", "700", LAYER_A_LIB + "\'");
- mDevice.executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_B_LIB, "|", "run-as", DEBUG_APP,
- "sh", "-c", "\'cat", ">", LAYER_B_LIB, ";", "chmod", "700", LAYER_B_LIB + "\'");
+ mDevice.executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_A_LIB, "|",
+ "run-as", DEBUG_APP, "--user", Integer.toString(mDevice.getCurrentUser()),
+ "sh", "-c", "\'cat", ">", LAYER_A_LIB, ";", "chmod", "700", LAYER_A_LIB + "\'");
+ mDevice.executeAdbCommand("shell", "cat", "/data/local/tmp/" + LAYER_B_LIB, "|",
+ "run-as", DEBUG_APP, "--user", Integer.toString(mDevice.getCurrentUser()),
+ "sh", "-c", "\'cat", ">", LAYER_B_LIB, ";", "chmod", "700", LAYER_B_LIB + "\'");
// Enable layerB with system properties
mDevice.executeAdbCommand("shell", "setprop", "debug.vulkan.layers " + LAYER_B_NAME);
diff --git a/hostsidetests/incident/AndroidTest.xml b/hostsidetests/incident/AndroidTest.xml
index 641b516feb8..18a73fa2acd 100644
--- a/hostsidetests/incident/AndroidTest.xml
+++ b/hostsidetests/incident/AndroidTest.xml
@@ -16,6 +16,9 @@
<configuration description="Config for CTS Incident host test cases">
<option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="metrics" />
+ <target_preparer class="com.android.tradefed.targetprep.SwitchUserTargetPreparer">
+ <option name="user-type" value="system" />
+ </target_preparer>
<test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
<option name="jar" value="CtsIncidentHostTestCases.jar" />
</test>
diff --git a/hostsidetests/inputmethodservice/deviceside/devicetest/src/android/inputmethodservice/cts/devicetest/InputMethodServiceDeviceTest.java b/hostsidetests/inputmethodservice/deviceside/devicetest/src/android/inputmethodservice/cts/devicetest/InputMethodServiceDeviceTest.java
index 348ea99fc16..9b8e4e02172 100644
--- a/hostsidetests/inputmethodservice/deviceside/devicetest/src/android/inputmethodservice/cts/devicetest/InputMethodServiceDeviceTest.java
+++ b/hostsidetests/inputmethodservice/deviceside/devicetest/src/android/inputmethodservice/cts/devicetest/InputMethodServiceDeviceTest.java
@@ -50,6 +50,7 @@ import android.inputmethodservice.cts.common.test.ShellCommandUtils;
import android.inputmethodservice.cts.devicetest.SequenceMatcher.MatchResult;
import android.os.SystemClock;
import android.support.test.runner.AndroidJUnit4;
+import android.support.test.uiautomator.UiObject2;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -211,7 +212,8 @@ public class InputMethodServiceDeviceTest {
final long startActivityTime = SystemClock.uptimeMillis();
helper.launchActivity(EditTextAppConstants.PACKAGE, EditTextAppConstants.CLASS,
EditTextAppConstants.URI);
- helper.findUiObject(EditTextAppConstants.EDIT_TEXT_RES_NAME).click();
+ final UiObject2 editText = helper.findUiObject(EditTextAppConstants.EDIT_TEXT_RES_NAME);
+ editText.click();
pollingCheck(() -> helper.queryAllEvents()
.filter(isNewerThan(startActivityTime))
@@ -226,7 +228,7 @@ public class InputMethodServiceDeviceTest {
helper.shell(ShellCommandUtils.uninstallPackage(Ime1Constants.PACKAGE));
helper.shell(ShellCommandUtils.setCurrentImeSync(Ime2Constants.IME_ID));
- helper.findUiObject(EditTextAppConstants.EDIT_TEXT_RES_NAME).click();
+ editText.click();
pollingCheck(() -> helper.queryAllEvents()
.filter(isNewerThan(imeForceStopTime))
.anyMatch(isFrom(Ime2Constants.CLASS).and(isType(ON_START_INPUT))),
diff --git a/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java b/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java
index 0041563c9cf..b32a05480f1 100644
--- a/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java
+++ b/hostsidetests/security/src/android/security/cts/SELinuxHostTest.java
@@ -891,6 +891,9 @@ public class SELinuxHostTest extends DeviceTestCase implements IBuildReceiver, I
* @throws Exception
*/
public void testCoredomainViolators() throws Exception {
+ if (!isFullTrebleDevice()) {
+ return;
+ }
assertSepolicyTests("CoredomainViolations", "/treble_sepolicy_tests");
}
diff --git a/hostsidetests/statsd/src/android/cts/statsd/atom/DeviceAtomTestCase.java b/hostsidetests/statsd/src/android/cts/statsd/atom/DeviceAtomTestCase.java
index c14a89f077f..351826c9382 100644
--- a/hostsidetests/statsd/src/android/cts/statsd/atom/DeviceAtomTestCase.java
+++ b/hostsidetests/statsd/src/android/cts/statsd/atom/DeviceAtomTestCase.java
@@ -152,8 +152,9 @@ public class DeviceAtomTestCase extends AtomTestCase {
* Gets the uid of the test app.
*/
protected int getUid() throws Exception {
- String uidLine = getDevice().executeShellCommand("cmd package list packages -U "
- + DEVICE_SIDE_TEST_PACKAGE);
+ int currentUser = getDevice().getCurrentUser();
+ String uidLine = getDevice().executeShellCommand("cmd package list packages -U --user "
+ + currentUser + " " + DEVICE_SIDE_TEST_PACKAGE);
String[] uidLineParts = uidLine.split(":");
// 3rd entry is package uid
assertTrue(uidLineParts.length > 2);
diff --git a/hostsidetests/theme/assets/28/360dpi.zip b/hostsidetests/theme/assets/28/360dpi.zip
index 3e1f801dab5..40b434bf997 100644
--- a/hostsidetests/theme/assets/28/360dpi.zip
+++ b/hostsidetests/theme/assets/28/360dpi.zip
Binary files differ
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityVolumeTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityVolumeTest.java
index 99836999448..b59b3eb9c7f 100644
--- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityVolumeTest.java
+++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityVolumeTest.java
@@ -71,7 +71,8 @@ public class AccessibilityVolumeTest {
return;
}
final int startingVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_ACCESSIBILITY);
- final int otherVolume = (startingVolume == 0) ? 1 : startingVolume - 1;
+ final int minVolume = mAudioManager.getStreamMinVolume(AudioManager.STREAM_ACCESSIBILITY);
+ final int otherVolume = (startingVolume == minVolume) ? (minVolume + 1) : startingVolume - 1;
final InstrumentedAccessibilityService service = InstrumentedAccessibilityService
.enableService(mInstrumentation, InstrumentedAccessibilityService.class);
try {
diff --git a/tests/admin/AndroidTest.xml b/tests/admin/AndroidTest.xml
index 7f1a7ad8a7b..94115bdb882 100644
--- a/tests/admin/AndroidTest.xml
+++ b/tests/admin/AndroidTest.xml
@@ -16,6 +16,10 @@
<configuration description="Config for the CTS device admin tests">
<option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="framework" />
+ <target_preparer class="com.android.tradefed.targetprep.SwitchUserTargetPreparer">
+ <option name="user-type" value="system" />
+ </target_preparer>
+
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="install-arg" value="-t" />
diff --git a/tests/app/AndroidTest.xml b/tests/app/AndroidTest.xml
index fbc5c384853..69505c359d4 100644
--- a/tests/app/AndroidTest.xml
+++ b/tests/app/AndroidTest.xml
@@ -27,6 +27,7 @@
<option name="test-file-name" value="CtsCantSaveState2.apk" />
</target_preparer>
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
<option name="package" value="android.app.cts" />
<option name="runtime-hint" value="6m38s" />
<option name="hidden-api-checks" value="false"/>
diff --git a/tests/app/src/android/app/cts/SystemFeaturesTest.java b/tests/app/src/android/app/cts/SystemFeaturesTest.java
index 871503fd646..15e7ed75f7e 100644
--- a/tests/app/src/android/app/cts/SystemFeaturesTest.java
+++ b/tests/app/src/android/app/cts/SystemFeaturesTest.java
@@ -187,7 +187,20 @@ public class SystemFeaturesTest extends InstrumentationTestCase {
assertFeature(manualPostProcessing,
PackageManager.FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING);
assertFeature(raw, PackageManager.FEATURE_CAMERA_CAPABILITY_RAW);
- assertFeature(motionTracking, PackageManager.FEATURE_CAMERA_AR);
+ if (!motionTracking) {
+ // FEATURE_CAMERA_AR requires the presence of
+ // CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING but
+ // MOTION_TRACKING does not require the presence of FEATURE_CAMERA_AR
+ //
+ // Logic table:
+ // AR= F T
+ // MT=F Y N
+ // =T Y Y
+ //
+ // So only check the one disallowed condition: No motion tracking and FEATURE_CAMERA_AR is
+ // available
+ assertNotAvailable(PackageManager.FEATURE_CAMERA_AR);
+ }
}
private void checkFrontCamera() {
@@ -489,16 +502,14 @@ public class SystemFeaturesTest extends InstrumentationTestCase {
}
public void testUsbAccessory() {
- // USB accessory mode is only a requirement for devices with USB ports supporting
- // peripheral mode. As there is no public API to distinguish a device with only host
- // mode support from having both peripheral and host support, the test may have
- // false negatives.
if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE) &&
!mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEVISION) &&
!mPackageManager.hasSystemFeature(PackageManager.FEATURE_WATCH) &&
!mPackageManager.hasSystemFeature(PackageManager.FEATURE_EMBEDDED) &&
!isAndroidEmulator() &&
- !mPackageManager.hasSystemFeature(PackageManager.FEATURE_PC)) {
+ !mPackageManager.hasSystemFeature(PackageManager.FEATURE_PC) &&
+ mPackageManager.hasSystemFeature(PackageManager.FEATURE_MICROPHONE) &&
+ mPackageManager.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN)) {
// USB accessory mode is only a requirement for devices with USB ports supporting
// peripheral mode. As there is no public API to distinguish a device with only host
// mode support from having both peripheral and host support, the test may have
diff --git a/tests/autofillservice/AndroidManifest.xml b/tests/autofillservice/AndroidManifest.xml
index 805bd67c36f..75b9920fa09 100644
--- a/tests/autofillservice/AndroidManifest.xml
+++ b/tests/autofillservice/AndroidManifest.xml
@@ -29,7 +29,8 @@
<uses-library android:name="android.test.runner" />
- <activity android:name=".LoginActivity" >
+ <activity android:name=".LoginActivity"
+ android:screenOrientation="portrait">
<intent-filter>
<!-- This intent filter is not really needed by CTS, but it maks easier to launch
this app during CTS development... -->
diff --git a/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java b/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java
index a32351a48ab..f5a4f89049a 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/CustomDescriptionWithLinkTestCase.java
@@ -19,6 +19,8 @@ import static android.autofillservice.cts.common.ShellHelper.runShellCommand;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assume.assumeTrue;
+
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
diff --git a/tests/autofillservice/src/android/autofillservice/cts/UiBot.java b/tests/autofillservice/src/android/autofillservice/cts/UiBot.java
index 5eefb0df903..d6199eb349f 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/UiBot.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/UiBot.java
@@ -93,6 +93,9 @@ final class UiBot {
"autofill_picker_accessibility_title";
private static final String RESOURCE_STRING_SAVE_SNACKBAR_ACCESSIBILITY_TITLE =
"autofill_save_accessibility_title";
+ private static final String RESOURCE_BOOLEAN_CONFIG_FORCE_DEFAULT_ORIENTATION =
+ "config_forceDefaultOrientation";
+
static final BySelector DATASET_PICKER_SELECTOR = By.res("android", RESOURCE_ID_DATASET_PICKER);
private static final BySelector SAVE_UI_SELECTOR = By.res("android", RESOURCE_ID_SAVE_SNACKBAR);
@@ -865,4 +868,24 @@ final class UiBot {
SystemClock.sleep(timeout);
}
}
-}
+
+ private boolean getBoolean(String id) {
+ final Resources resources = mContext.getResources();
+ final int booleanId = resources.getIdentifier(id, "bool", "android");
+ return resources.getBoolean(booleanId);
+ }
+
+ /**
+ * Returns {@code true} if display rotation is supported, {@code false} otherwise.
+ */
+ public boolean isScreenRotationSupported() {
+ try {
+ return !getBoolean(RESOURCE_BOOLEAN_CONFIG_FORCE_DEFAULT_ORIENTATION);
+ } catch (Resources.NotFoundException e) {
+ Log.d(TAG, "Resource not found: "
+ + RESOURCE_BOOLEAN_CONFIG_FORCE_DEFAULT_ORIENTATION
+ + ". Assume rotation supported");
+ return true;
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/backup/AndroidTest.xml b/tests/backup/AndroidTest.xml
index 8e0bfa01ef3..9b6ab65b8b2 100644
--- a/tests/backup/AndroidTest.xml
+++ b/tests/backup/AndroidTest.xml
@@ -17,6 +17,11 @@
<configuration description="Config for CTS Backup test cases">
<option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="backup" />
+
+ <target_preparer class="com.android.tradefed.targetprep.SwitchUserTargetPreparer">
+ <option name="user-type" value="system" />
+ </target_preparer>
+
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsFullBackupApp.apk" />
diff --git a/tests/camera/AndroidTest.xml b/tests/camera/AndroidTest.xml
index 2a2cdc94dc7..b2b66953bfe 100644
--- a/tests/camera/AndroidTest.xml
+++ b/tests/camera/AndroidTest.xml
@@ -23,7 +23,7 @@
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="android.camera.cts" />
<option name="runtime-hint" value="12m7s" />
- <!-- test-timeout unit is ms, value = 200 min -->
- <option name="test-timeout" value="12000000" />
+ <!-- test-timeout unit is ms, value = 300 min -->
+ <option name="test-timeout" value="18000000" />
</test>
</configuration>
diff --git a/tests/camera/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java b/tests/camera/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java
index 78f752345f8..9339535f304 100644
--- a/tests/camera/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java
@@ -250,7 +250,8 @@ public class ExtendedCameraCharacteristicsTest extends AndroidTestCase {
// Handle FullHD special case first
if (jpegSizesList.contains(FULLHD)) {
- if (hwLevel >= LEVEL_3 || hwLevel == FULL || (hwLevel == LIMITED &&
+ if (compareHardwareLevel(hwLevel, LEVEL_3) >= 0 || hwLevel == FULL ||
+ (hwLevel == LIMITED &&
maxVideoSize.getWidth() >= FULLHD.getWidth() &&
maxVideoSize.getHeight() >= FULLHD.getHeight())) {
boolean yuvSupportFullHD = yuvSizesList.contains(FULLHD) ||
@@ -278,7 +279,8 @@ public class ExtendedCameraCharacteristicsTest extends AndroidTestCase {
jpegSizesList.removeAll(toBeRemoved);
}
- if (hwLevel >= LEVEL_3 || hwLevel == FULL || hwLevel == LIMITED) {
+ if (compareHardwareLevel(hwLevel, LEVEL_3) >= 0 || hwLevel == FULL ||
+ hwLevel == LIMITED) {
if (!yuvSizesList.containsAll(jpegSizesList)) {
for (Size s : jpegSizesList) {
if (!yuvSizesList.contains(s)) {
diff --git a/tests/camera/src/android/hardware/cts/CameraTest.java b/tests/camera/src/android/hardware/cts/CameraTest.java
index 81b42ef8664..9bced256b87 100644
--- a/tests/camera/src/android/hardware/cts/CameraTest.java
+++ b/tests/camera/src/android/hardware/cts/CameraTest.java
@@ -1219,14 +1219,14 @@ public class CameraTest extends ActivityInstrumentationTestCase2<CameraCtsActivi
Camera.Parameters parameters = mCamera.getParameters();
SurfaceHolder surfaceHolder;
surfaceHolder = getActivity().getSurfaceView().getHolder();
- CamcorderProfile profile = CamcorderProfile.get(cameraId,
- CamcorderProfile.QUALITY_LOW);
+ CamcorderProfile profile = null; // Used for built-in camera
Camera.Size videoSize = null; // Used for external camera
// Set the preview size.
if (mIsExternalCamera) {
videoSize = setupExternalCameraRecord(parameters);
} else {
+ profile = CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_LOW);
setPreviewSizeByProfile(parameters, profile);
}
@@ -2729,13 +2729,13 @@ public class CameraTest extends ActivityInstrumentationTestCase2<CameraCtsActivi
Parameters parameters = mCamera.getParameters();
SurfaceHolder holder = getActivity().getSurfaceView().getHolder();
- CamcorderProfile profile = CamcorderProfile.get(cameraId,
- CamcorderProfile.QUALITY_LOW);
+ CamcorderProfile profile = null; // for built-in camera
Camera.Size videoSize = null; // for external camera
if (mIsExternalCamera) {
videoSize = setupExternalCameraRecord(parameters);
} else {
+ profile = CamcorderProfile.get(cameraId, CamcorderProfile.QUALITY_LOW);
setPreviewSizeByProfile(parameters, profile);
}
diff --git a/tests/framework/base/activitymanager/app/AndroidManifest.xml b/tests/framework/base/activitymanager/app/AndroidManifest.xml
index c977b376faa..2b9119025c1 100755
--- a/tests/framework/base/activitymanager/app/AndroidManifest.xml
+++ b/tests/framework/base/activitymanager/app/AndroidManifest.xml
@@ -179,10 +179,10 @@
android:resizeableActivity="true"
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout"
android:exported="true">
- <layout android:defaultWidth="25%"
- android:defaultHeight="35%"
+ <layout android:defaultWidth="50%"
+ android:defaultHeight="70%"
android:gravity="top|right"
- android:minWidth="90dp"
+ android:minWidth="50dp"
android:minHeight="80dp"
/>
</activity>
@@ -190,10 +190,10 @@
android:resizeableActivity="true"
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout"
android:exported="true">
- <layout android:defaultWidth="25%"
- android:defaultHeight="35%"
+ <layout android:defaultWidth="50%"
+ android:defaultHeight="70%"
android:gravity="bottom|left"
- android:minWidth="90dp"
+ android:minWidth="50dp"
android:minHeight="80dp"
/>
</activity>
diff --git a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerManifestLayoutTests.java b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerManifestLayoutTests.java
index 6b5c7c1569b..b491a9fd1fe 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerManifestLayoutTests.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerManifestLayoutTests.java
@@ -49,8 +49,8 @@ public class ActivityManagerManifestLayoutTests extends ActivityManagerTestBase
// Test parameters
private static final int DEFAULT_WIDTH_DP = 240;
private static final int DEFAULT_HEIGHT_DP = 160;
- private static final float DEFAULT_WIDTH_FRACTION = 0.25f;
- private static final float DEFAULT_HEIGHT_FRACTION = 0.35f;
+ private static final float DEFAULT_WIDTH_FRACTION = 0.50f;
+ private static final float DEFAULT_HEIGHT_FRACTION = 0.70f;
private static final int MIN_WIDTH_DP = 100;
private static final int MIN_HEIGHT_DP = 80;
diff --git a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerPinnedStackTests.java b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerPinnedStackTests.java
index dbc93b47806..af151876f98 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerPinnedStackTests.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerPinnedStackTests.java
@@ -207,7 +207,12 @@ public class ActivityManagerPinnedStackTests extends ActivityManagerTestBase {
try (final RotationSession rotationSession = new RotationSession()) {
rotationSession.set(ROTATION_0);
-
+ mAmWmState.waitForWithWmState((wmState1) -> {
+ Rect db = wmState1.getDefaultPinnedStackBounds();
+ Rect sb = wmState1.getStableBounds();
+ return (db.width() > 0 && db.height() > 0) &&
+ (sb.contains(db));
+ }, "Waiting for valid bounds..");
WindowManagerState wmState = mAmWmState.getWmState();
wmState.computeState();
Rect defaultPipBounds = wmState.getDefaultPinnedStackBounds();
@@ -216,6 +221,12 @@ public class ActivityManagerPinnedStackTests extends ActivityManagerTestBase {
assertTrue(stableBounds.contains(defaultPipBounds));
rotationSession.set(ROTATION_90);
+ mAmWmState.waitForWithWmState((wmState1) -> {
+ Rect db = wmState1.getDefaultPinnedStackBounds();
+ Rect sb = wmState1.getStableBounds();
+ return (db.width() > 0 && db.height() > 0) &&
+ (sb.contains(db));
+ }, "Waiting for valid bounds...");
wmState = mAmWmState.getWmState();
wmState.computeState();
defaultPipBounds = wmState.getDefaultPinnedStackBounds();
@@ -236,6 +247,12 @@ public class ActivityManagerPinnedStackTests extends ActivityManagerTestBase {
try (final RotationSession rotationSession = new RotationSession()) {
rotationSession.set(ROTATION_0);
+ mAmWmState.waitForWithWmState((wmState1) -> {
+ Rect db = wmState1.getPinnedStackMovementBounds();
+ Rect sb = wmState1.getStableBounds();
+ return (db.width() > 0 && db.height() > 0) &&
+ (sb.contains(db));
+ }, "Waiting for valid bounds...");
WindowManagerState wmState = mAmWmState.getWmState();
wmState.computeState();
Rect pipMovementBounds = wmState.getPinnedStackMovementBounds();
@@ -244,6 +261,12 @@ public class ActivityManagerPinnedStackTests extends ActivityManagerTestBase {
assertTrue(stableBounds.contains(pipMovementBounds));
rotationSession.set(ROTATION_90);
+ mAmWmState.waitForWithWmState((wmState1) -> {
+ Rect db = wmState1.getPinnedStackMovementBounds();
+ Rect sb = wmState1.getStableBounds();
+ return (db.width() > 0 && db.height() > 0) &&
+ (sb.contains(db));
+ }, "Waiting for valid bounds...");
wmState = mAmWmState.getWmState();
wmState.computeState();
pipMovementBounds = wmState.getPinnedStackMovementBounds();
diff --git a/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerTestBase.java b/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerTestBase.java
index 59ea4abfe7d..5c5ac8917ae 100644
--- a/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerTestBase.java
+++ b/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerTestBase.java
@@ -25,6 +25,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
+import static android.content.pm.PackageManager.FEATURE_AUTOMOTIVE;
import static android.content.pm.PackageManager.FEATURE_EMBEDDED;
import static android.content.pm.PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT;
import static android.content.pm.PackageManager.FEATURE_LEANBACK;
@@ -516,7 +517,8 @@ public abstract class ActivityManagerTestBase {
protected boolean supportsInsecureLock() {
return !hasDeviceFeature(FEATURE_LEANBACK)
&& !hasDeviceFeature(FEATURE_WATCH)
- && !hasDeviceFeature(FEATURE_EMBEDDED);
+ && !hasDeviceFeature(FEATURE_EMBEDDED)
+ && !hasDeviceFeature(FEATURE_AUTOMOTIVE);
}
protected boolean isWatch() {
@@ -803,7 +805,7 @@ public abstract class ActivityManagerTestBase {
protected int getDeviceRotation(int displayId) {
final String displays = runCommandAndPrintOutput("dumpsys display displays").trim();
Pattern pattern = Pattern.compile(
- "(mDisplayId=" + displayId + ")([\\s\\S]*)(mOverrideDisplayInfo)(.*)"
+ "(mDisplayId=" + displayId + ")([\\s\\S]*?)(mOverrideDisplayInfo)(.*)"
+ "(rotation)(\\s+)(\\d+)");
Matcher matcher = pattern.matcher(displays);
if (matcher.find()) {
diff --git a/tests/sensor/src/android/hardware/cts/SensorParameterRangeTest.java b/tests/sensor/src/android/hardware/cts/SensorParameterRangeTest.java
index 44135bc6637..c1c9fab2d15 100644
--- a/tests/sensor/src/android/hardware/cts/SensorParameterRangeTest.java
+++ b/tests/sensor/src/android/hardware/cts/SensorParameterRangeTest.java
@@ -77,23 +77,23 @@ public class SensorParameterRangeTest extends SensorTestCase {
public void testAccelerometerRange() {
checkSensorRangeAndFrequency(
- mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
+ Sensor.TYPE_ACCELEROMETER,
ACCELEROMETER_MAX_RANGE,
ACCELEROMETER_MIN_FREQUENCY,
ACCELEROMETER_MAX_FREQUENCY);
- }
+ }
- public void testGyroscopeRange() {
+ public void testGyroscopeRange() {
checkSensorRangeAndFrequency(
- mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE),
+ Sensor.TYPE_GYROSCOPE,
GYRO_MAX_RANGE,
GYRO_MIN_FREQUENCY,
GYRO_MAX_FREQUENCY);
- }
+ }
public void testMagnetometerRange() {
checkSensorRangeAndFrequency(
- mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD),
+ Sensor.TYPE_MAGNETIC_FIELD,
MAGNETOMETER_MAX_RANGE,
MAGNETOMETER_MIN_FREQUENCY,
MAGNETOMETER_MAX_FREQUENCY);
@@ -102,7 +102,7 @@ public class SensorParameterRangeTest extends SensorTestCase {
public void testPressureRange() {
if (mHasHifiSensors) {
checkSensorRangeAndFrequency(
- mSensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE),
+ Sensor.TYPE_PRESSURE,
PRESSURE_MAX_RANGE,
PRESSURE_MIN_FREQUENCY,
PRESSURE_MAX_FREQUENCY);
@@ -110,8 +110,14 @@ public class SensorParameterRangeTest extends SensorTestCase {
}
private void checkSensorRangeAndFrequency(
- Sensor sensor, double maxRange, double minFrequency, double maxFrequency) {
+ int sensorType, double maxRange, double minFrequency, double maxFrequency) {
if (!mHasHifiSensors && !mVrModeHighPerformance) return;
+
+ Sensor sensor = mSensorManager.getDefaultSensor(sensorType);
+ if (sensor == null) {
+ fail(String.format("Must support sensor type %d", sensorType));
+ }
+
assertTrue(String.format("%s Range actual=%.2f expected=%.2f %s",
sensor.getName(), sensor.getMaximumRange(), maxRange,
SensorCtsHelper.getUnitsForSensor(sensor)),
diff --git a/tests/tests/car/AndroidManifest.xml b/tests/tests/car/AndroidManifest.xml
index 76e2e3c0bf8..cce4761d79b 100644
--- a/tests/tests/car/AndroidManifest.xml
+++ b/tests/tests/car/AndroidManifest.xml
@@ -19,9 +19,18 @@
<uses-feature android:name="android.hardware.type.automotive" />
<uses-permission android:name="android.car.permission.CAR_EXTERIOR_ENVIRONMENT" />
<uses-permission android:name="android.car.permission.CAR_INFO" />
-
+ <uses-permission android:name="android.car.permission.CAR_POWERTRAIN" />
+ <uses-permission android:name="android.car.permission.CAR_SPEED" />
+ <uses-permission android:name="android.permission.BLUETOOTH" />
+ <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<application>
<uses-library android:name="android.test.runner" />
+ <activity android:name=".drivingstate.DistractionOptimizedActivity">
+ <meta-data android:name="distractionOptimized" android:value="true"/>
+ </activity>
+ <activity android:name=".drivingstate.NonDistractionOptimizedActivity">
+ <meta-data android:name="distractionOptimized" android:value="false"/>
+ </activity>
</application>
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
diff --git a/tests/tests/car/src/android/car/cts/CarBluetoothTest.java b/tests/tests/car/src/android/car/cts/CarBluetoothTest.java
new file mode 100644
index 00000000000..8eca0750b39
--- /dev/null
+++ b/tests/tests/car/src/android/car/cts/CarBluetoothTest.java
@@ -0,0 +1,361 @@
+/*
+ * 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.car.cts;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
+
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothManager;
+import android.bluetooth.BluetoothProfile;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.platform.test.annotations.RequiresDevice;
+import android.test.suitebuilder.annotation.SmallTest;
+import android.util.Log;
+import android.util.SparseArray;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+import com.android.compatibility.common.util.CddTest;
+import com.android.compatibility.common.util.FeatureUtil;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Contains the tests to prove compliance with android automotive specific bluetooth requirements.
+ */
+@SmallTest
+@RequiresDevice
+@RunWith(AndroidJUnit4.class)
+public class CarBluetoothTest {
+ private static final String TAG = "CarBluetoothTest";
+ private static final boolean DBG = false;
+ private Context mContext;
+
+ // Bluetooth Core objects
+ private BluetoothManager mBluetoothManager;
+ private BluetoothAdapter mBluetoothAdapter;
+
+ // Timeout for waiting for an adapter state change
+ private static final int BT_ADAPTER_TIMEOUT_MS = 8000; // ms
+
+ // Objects to block until the adapter has reached a desired state
+ private ReentrantLock mBluetoothAdapterLock;
+ private Condition mConditionAdapterStateReached;
+ private int mDesiredState;
+ private int mOriginalState;
+
+ /**
+ * Handles BluetoothAdapter state changes and signals when we've reached a desired state
+ */
+ private class BluetoothAdapterReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+
+ // Decode the intent
+ String action = intent.getAction();
+
+ // Watch for BluetoothAdapter intents only
+ if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) {
+ int newState = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1);
+ if (DBG) {
+ Log.d(TAG, "Bluetooth adapter state changed: " + newState);
+ }
+
+ // Signal if the state is set to the one we're waiting on. If its not and we got a
+ // STATE_OFF event then handle the unexpected off event. Note that we could
+ // proactively turn the adapter back on to continue testing. For now we'll just
+ // log it
+ mBluetoothAdapterLock.lock();
+ try {
+ if (mDesiredState == newState) {
+ mConditionAdapterStateReached.signal();
+ } else if (newState == BluetoothAdapter.STATE_OFF) {
+ Log.w(TAG, "Bluetooth turned off unexpectedly while test was running.");
+ }
+ } finally {
+ mBluetoothAdapterLock.unlock();
+ }
+ }
+ }
+ }
+ private BluetoothAdapterReceiver mBluetoothAdapterReceiver;
+
+ private void waitForAdapterOn() {
+ if (DBG) {
+ Log.d(TAG, "Waiting for adapter to be on...");
+ }
+ waitForAdapterState(BluetoothAdapter.STATE_ON);
+ }
+
+ private void waitForAdapterOff() {
+ if (DBG) {
+ Log.d(TAG, "Waiting for adapter to be off...");
+ }
+ waitForAdapterState(BluetoothAdapter.STATE_OFF);
+ }
+
+ // Wait for the bluetooth adapter to be in a given state
+ private void waitForAdapterState(int desiredState) {
+ if (DBG) {
+ Log.d(TAG, "Waiting for adapter state " + desiredState);
+ }
+ mBluetoothAdapterLock.lock();
+ try {
+ // Update the desired state so that we'll signal when we get there
+ mDesiredState = desiredState;
+ if (desiredState == BluetoothAdapter.STATE_ON) {
+ mBluetoothAdapter.enable();
+ } else {
+ mBluetoothAdapter.disable();
+ }
+
+ // Wait until we're reached that desired state
+ while (desiredState != mBluetoothAdapter.getState()) {
+ if (!mConditionAdapterStateReached.await(
+ BT_ADAPTER_TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
+ Log.e(TAG, "Timeout while waiting for Bluetooth adapter state " + desiredState);
+ break;
+ }
+ }
+ } catch (InterruptedException e) {
+ Log.w(TAG, "waitForAdapterState(" + desiredState + "): interrupted", e);
+ } finally {
+ mBluetoothAdapterLock.unlock();
+ }
+ }
+
+ // Utility class to hold profile information and state
+ private static class ProfileInfo {
+ final String mName;
+ boolean mConnected;
+
+ public ProfileInfo(String name) {
+ mName = name;
+ mConnected = false;
+ }
+ }
+
+ // Automotive required profiles and meta data. Profile defaults to 'not connected' and name
+ // is used in debug and error messages
+ private static SparseArray<ProfileInfo> sRequiredBluetoothProfiles = new SparseArray();
+ static {
+ sRequiredBluetoothProfiles.put(BluetoothProfile.A2DP_SINK,
+ new ProfileInfo("A2DP Sink")); // 11
+ sRequiredBluetoothProfiles.put(BluetoothProfile.AVRCP_CONTROLLER,
+ new ProfileInfo("AVRCP Controller")); // 12
+ sRequiredBluetoothProfiles.put(BluetoothProfile.HEADSET_CLIENT,
+ new ProfileInfo("HSP Client")); // 16
+ sRequiredBluetoothProfiles.put(BluetoothProfile.PBAP_CLIENT,
+ new ProfileInfo("PBAP Client")); // 17
+ }
+ private static final int MAX_PROFILES_SUPPORTED = sRequiredBluetoothProfiles.size();
+
+ // Configurable timeout for waiting for profile proxies to connect
+ private static final int PROXY_CONNECTIONS_TIMEOUT_MS = 1000; // ms
+
+ // Objects to block until all profile proxy connections have finished, or the timeout occurs
+ private Condition mConditionAllProfilesConnected;
+ private ReentrantLock mProfileConnectedLock;
+ private int mProfilesSupported;
+
+ // Capture profile proxy connection events
+ private final class ProfileServiceListener implements BluetoothProfile.ServiceListener {
+ @Override
+ public void onServiceConnected(int profile, BluetoothProfile proxy) {
+ if (DBG) {
+ Log.d(TAG, "Profile '" + profile + "' has connected");
+ }
+ mProfileConnectedLock.lock();
+ try {
+ sRequiredBluetoothProfiles.get(profile).mConnected = true;
+ mProfilesSupported++;
+ if (mProfilesSupported == MAX_PROFILES_SUPPORTED) {
+ mConditionAllProfilesConnected.signal();
+ }
+ } finally {
+ mProfileConnectedLock.unlock();
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected(int profile) {
+ if (DBG) {
+ Log.d(TAG, "Profile '" + profile + "' has disconnected");
+ }
+ mProfileConnectedLock.lock();
+ try {
+ sRequiredBluetoothProfiles.get(profile).mConnected = false;
+ mProfilesSupported--;
+ } finally {
+ mProfileConnectedLock.unlock();
+ }
+ }
+ }
+
+ // Initiate connections to all profiles and wait until we connect to all, or time out
+ private void waitForProfileConnections() {
+ if (DBG) {
+ Log.d(TAG, "Starting profile proxy connections...");
+ }
+ mProfileConnectedLock.lock();
+ try {
+ // Attempt connection to each required profile
+ for (int i = 0; i < sRequiredBluetoothProfiles.size(); i++) {
+ int profile = sRequiredBluetoothProfiles.keyAt(i);
+ mBluetoothAdapter.getProfileProxy(mContext, new ProfileServiceListener(), profile);
+ }
+
+ // Wait for the Adapter to be disabled
+ while (mProfilesSupported != MAX_PROFILES_SUPPORTED) {
+ if (!mConditionAllProfilesConnected.await(
+ PROXY_CONNECTIONS_TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
+ Log.e(TAG, "Timeout while waiting for Profile Connections");
+ break;
+ }
+ }
+ } catch (InterruptedException e) {
+ Log.w(TAG, "waitForProfileConnections: interrupted", e);
+ } finally {
+ mProfileConnectedLock.unlock();
+ }
+
+ if (DBG) {
+ Log.d(TAG, "Proxy connection attempts complete. Connected " + mProfilesSupported
+ + "/" + MAX_PROFILES_SUPPORTED + " profiles");
+ }
+ }
+
+ // Check and make sure each profile is connected. If any are not supported then build an
+ // error string to report each missing profile and assert a failure
+ private void checkProfileConnections() {
+ if (DBG) {
+ Log.d(TAG, "Checking for all required profiles");
+ }
+ mProfileConnectedLock.lock();
+ try {
+ if (mProfilesSupported != MAX_PROFILES_SUPPORTED) {
+ if (DBG) {
+ Log.d(TAG, "Some profiles failed to connect");
+ }
+ StringBuilder e = new StringBuilder();
+ for (int i = 0; i < sRequiredBluetoothProfiles.size(); i++) {
+ int profile = sRequiredBluetoothProfiles.keyAt(i);
+ String name = sRequiredBluetoothProfiles.get(profile).mName;
+ if (!sRequiredBluetoothProfiles.get(profile).mConnected) {
+ if (e.length() == 0) {
+ e.append("Missing Profiles: ");
+ } else {
+ e.append(", ");
+ }
+ e.append(name + " (" + profile + ")");
+
+ if (DBG) {
+ Log.d(TAG, name + " failed to connect");
+ }
+ }
+ }
+ fail(e.toString());
+ }
+ } finally {
+ mProfileConnectedLock.unlock();
+ }
+ }
+
+ // Set the connection status for each profile to false
+ private void clearProfileStatuses() {
+ if (DBG) {
+ Log.d(TAG, "Setting all profiles to 'disconnected'");
+ }
+ for (int i = 0; i < sRequiredBluetoothProfiles.size(); i++) {
+ int profile = sRequiredBluetoothProfiles.keyAt(i);
+ sRequiredBluetoothProfiles.get(profile).mConnected = false;
+ }
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ if (DBG) {
+ Log.d(TAG, "Setting up Automotive Bluetooth test. Device is "
+ + (FeatureUtil.isAutomotive() ? "" : "not ") + "automotive");
+ }
+
+ // Automotive only
+ assumeTrue(FeatureUtil.isAutomotive());
+
+ // Get the context
+ mContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+
+ // Get bluetooth core objects so we can get proxies/check for profile existence
+ mBluetoothManager = (BluetoothManager) mContext.getSystemService(
+ Context.BLUETOOTH_SERVICE);
+ mBluetoothAdapter = mBluetoothManager.getAdapter();
+
+ // Initialize all the profile connection variables
+ mProfilesSupported = 0;
+ mProfileConnectedLock = new ReentrantLock();
+ mConditionAllProfilesConnected = mProfileConnectedLock.newCondition();
+ clearProfileStatuses();
+
+ // Register the adapter receiver and initialize adapter state wait objects
+ mDesiredState = -1; // Set and checked by waitForAdapterState()
+ mBluetoothAdapterLock = new ReentrantLock();
+ mConditionAdapterStateReached = mBluetoothAdapterLock.newCondition();
+ mBluetoothAdapterReceiver = new BluetoothAdapterReceiver();
+ IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
+ mContext.registerReceiver(mBluetoothAdapterReceiver, filter);
+
+ // Make sure Bluetooth is enabled before the test
+ waitForAdapterOn();
+ assertTrue(mBluetoothAdapter.isEnabled());
+ }
+
+ @After
+ public void tearDown() {
+ waitForAdapterOff();
+ mContext.unregisterReceiver(mBluetoothAdapterReceiver);
+ }
+
+ // [A-0-2] : Android Automotive devices must support the following Bluetooth profiles:
+ // * Hands Free Profile (HFP) [Phone calling]
+ // * Audio Distribution Profile (A2DP) [Media playback]
+ // * Audio/Video Remote Control Profile (AVRCP) [Media playback control]
+ // * Phone Book Access Profile (PBAP) [Contact sharing/receiving]
+ //
+ // This test fires off connections to each required profile (which are asynchronous in nature)
+ // and waits for all of them to connect (proving they are there and implemented), or for the
+ // configured timeout. If all required profiles connect, the test passes.
+ @Test
+ @CddTest(requirement = "7.4.3/A-0-2")
+ public void testRequiredBluetoothProfilesExist() throws Exception {
+ if (DBG) {
+ Log.d(TAG, "Begin testRequiredBluetoothProfilesExist()");
+ }
+ assertNotNull(mBluetoothAdapter);
+ waitForProfileConnections();
+ checkProfileConnections();
+ }
+}
diff --git a/tests/tests/car/src/android/car/cts/CarPackageManagerTest.java b/tests/tests/car/src/android/car/cts/CarPackageManagerTest.java
index 0c3aebc8a45..ec795725b5e 100644
--- a/tests/tests/car/src/android/car/cts/CarPackageManagerTest.java
+++ b/tests/tests/car/src/android/car/cts/CarPackageManagerTest.java
@@ -82,50 +82,19 @@ public class CarPackageManagerTest extends CarApiTestBase {
} catch (IllegalArgumentException expected) {
// Expected.
}
- }
+ }
@Test
- public void testSystemActivitiesAllowed() throws CarNotConnectedException {
- Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
- List<PackageInfo> packages = context.getPackageManager().getInstalledPackages(
- PackageManager.GET_ACTIVITIES | PackageManager.GET_META_DATA);
-
- for (PackageInfo info : packages) {
- if (info.applicationInfo == null) {
- continue;
- }
- if ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0 ||
- ((info.applicationInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0)) {
-
- Bundle metaData = info.applicationInfo.metaData;
- if (metaData == null || metaData.getInt(METADATA_ATTRIBUTE, 0) == 0) {
- continue; // No car metadata, ignoring this app.
- }
-
- if (info.activities != null && info.activities.length > 0) {
- String activity = info.activities[0].name;
- String packageName = info.packageName;
- assertTrue("Failed for package: " + packageName + ", activity: " + activity,
- mCarPm.isActivityDistractionOptimized(packageName, activity));
- }
- }
- }
+ public void testDistractionOptimizedActivityIsAllowed() throws CarNotConnectedException {
+ // This test relies on test activity in installed apk, and AndroidManifest declaration.
+ assertTrue(mCarPm.isActivityDistractionOptimized("android.car.cts",
+ "android.car.cts.drivingstate.DistractionOptimizedActivity"));
}
@Test
- @Ignore // Enable when b/120125891 is fixed
- public void testServiceDistractionOptimized() throws Exception {
- assertFalse(mCarPm.isServiceDistractionOptimized("com.basic.package", ""));
- assertTrue(mCarPm.isServiceDistractionOptimized("com.android.settings", "Any"));
- assertTrue(mCarPm.isServiceDistractionOptimized("com.android.settings", ""));
- assertTrue(mCarPm.isServiceDistractionOptimized("com.android.settings", null));
-
- try {
- mCarPm.isServiceDistractionOptimized(null, "Any");
- fail();
- } catch (IllegalArgumentException expected) {
- // Expected.
- }
+ public void testNonDistractionOptimizedActivityNotAllowed() throws CarNotConnectedException {
+ // This test relies on test activity in installed apk, and AndroidManifest declaration.
+ assertFalse(mCarPm.isActivityDistractionOptimized("android.car.cts",
+ "android.car.cts.drivingstate.NonDistractionOptimizedActivity"));
}
-
}
diff --git a/tests/tests/car/src/android/car/cts/CarSensorManagerTest.java b/tests/tests/car/src/android/car/cts/CarSensorManagerTest.java
index 3b9d8eb5bf5..d19d04d3cee 100644
--- a/tests/tests/car/src/android/car/cts/CarSensorManagerTest.java
+++ b/tests/tests/car/src/android/car/cts/CarSensorManagerTest.java
@@ -55,7 +55,6 @@ public class CarSensorManagerTest extends CarApiTestBase {
@CddTest(requirement="2.5.1")
@Test
- @Ignore // Enable when b/120125891 is fixed
public void testRequiredSensorsForDrivingState() throws Exception {
boolean foundSpeed = false;
boolean foundGear = false;
diff --git a/tests/tests/car/src/android/car/cts/drivingstate/DistractionOptimizedActivity.java b/tests/tests/car/src/android/car/cts/drivingstate/DistractionOptimizedActivity.java
new file mode 100644
index 00000000000..00440b6dce7
--- /dev/null
+++ b/tests/tests/car/src/android/car/cts/drivingstate/DistractionOptimizedActivity.java
@@ -0,0 +1,6 @@
+package android.car.cts.drivingstate;
+
+import android.app.Activity;
+
+public class DistractionOptimizedActivity extends Activity {
+} \ No newline at end of file
diff --git a/tests/tests/car/src/android/car/cts/drivingstate/NonDistractionOptimizedActivity.java b/tests/tests/car/src/android/car/cts/drivingstate/NonDistractionOptimizedActivity.java
new file mode 100644
index 00000000000..0c75a3adb53
--- /dev/null
+++ b/tests/tests/car/src/android/car/cts/drivingstate/NonDistractionOptimizedActivity.java
@@ -0,0 +1,6 @@
+package android.car.cts.drivingstate;
+
+import android.app.Activity;
+
+public class NonDistractionOptimizedActivity extends Activity {
+}
diff --git a/tests/tests/content/AndroidTest.xml b/tests/tests/content/AndroidTest.xml
index 58305dd93cd..4b226312ba5 100644
--- a/tests/tests/content/AndroidTest.xml
+++ b/tests/tests/content/AndroidTest.xml
@@ -35,6 +35,7 @@
</target_preparer>
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
<option name="package" value="android.content.cts" />
<option name="runtime-hint" value="21m30s" />
<option name="hidden-api-checks" value="false" />
diff --git a/tests/tests/display/Android.mk b/tests/tests/display/Android.mk
index 97a1492efb0..99efc20211b 100644
--- a/tests/tests/display/Android.mk
+++ b/tests/tests/display/Android.mk
@@ -27,7 +27,7 @@ LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := androidx.test.rules
LOCAL_JAVA_LIBRARIES := android.test.base.stubs
diff --git a/tests/tests/display/AndroidManifest.xml b/tests/tests/display/AndroidManifest.xml
index cc2d1546b2d..41d1688e59c 100644
--- a/tests/tests/display/AndroidManifest.xml
+++ b/tests/tests/display/AndroidManifest.xml
@@ -35,7 +35,7 @@
<!-- self-instrumenting test package. -->
<instrumentation
- android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:name="androidx.test.runner.AndroidJUnitRunner"
android:targetPackage="android.display.cts"
android:label="CTS tests of android.display">
</instrumentation>
diff --git a/tests/tests/display/src/android/display/cts/BrightnessTest.java b/tests/tests/display/src/android/display/cts/BrightnessTest.java
index f0ebc202d02..6b01df23533 100644
--- a/tests/tests/display/src/android/display/cts/BrightnessTest.java
+++ b/tests/tests/display/src/android/display/cts/BrightnessTest.java
@@ -19,7 +19,6 @@ package android.display.cts;
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;
@@ -34,11 +33,12 @@ import android.hardware.display.DisplayManager;
import android.os.ParcelFileDescriptor;
import android.os.PowerManager;
import android.provider.Settings;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.filters.MediumTest;
-import android.support.test.runner.AndroidJUnit4;
import android.util.Pair;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.MediumTest;
+import androidx.test.runner.AndroidJUnit4;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -46,7 +46,6 @@ import org.junit.runner.RunWith;
import java.io.FileDescriptor;
import java.io.FileInputStream;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
diff --git a/tests/tests/display/src/android/display/cts/DisplayTest.java b/tests/tests/display/src/android/display/cts/DisplayTest.java
index c7ea939c08c..cb8e7cddf6e 100644
--- a/tests/tests/display/src/android/display/cts/DisplayTest.java
+++ b/tests/tests/display/src/android/display/cts/DisplayTest.java
@@ -21,7 +21,6 @@ import static org.junit.Assert.*;
import android.app.Activity;
import android.app.Instrumentation;
import android.app.Presentation;
-import android.app.UiAutomation;
import android.app.UiModeManager;
import android.content.Context;
import android.content.Intent;
@@ -36,9 +35,6 @@ import android.os.Handler;
import android.os.Looper;
import android.os.ParcelFileDescriptor;
import android.platform.test.annotations.Presubmit;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
-import android.support.test.rule.ActivityTestRule;
import android.test.InstrumentationTestCase;
import android.util.DisplayMetrics;
import android.view.Display;
@@ -47,11 +43,9 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.Scanner;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.rule.ActivityTestRule;
+import androidx.test.runner.AndroidJUnit4;
import org.junit.After;
import org.junit.Before;
@@ -59,6 +53,11 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Scanner;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
@RunWith(AndroidJUnit4.class)
public class DisplayTest {
diff --git a/tests/tests/gesture/Android.mk b/tests/tests/gesture/Android.mk
index 570a9b4d4a1..4be4beddc0b 100755
--- a/tests/tests/gesture/Android.mk
+++ b/tests/tests/gesture/Android.mk
@@ -27,7 +27,7 @@ LOCAL_PROGUARD_ENABLED := disabled
LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := androidx.test.rules
# Tag this module as a cts test artifact
LOCAL_COMPATIBILITY_SUITE := cts vts general-tests cts_instant
diff --git a/tests/tests/gesture/AndroidManifest.xml b/tests/tests/gesture/AndroidManifest.xml
index eed0ffd6c97..28a2c7ae362 100755
--- a/tests/tests/gesture/AndroidManifest.xml
+++ b/tests/tests/gesture/AndroidManifest.xml
@@ -25,7 +25,7 @@
<!-- self-instrumenting test package. -->
<instrumentation
- android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:name="androidx.test.runner.AndroidJUnitRunner"
android:targetPackage="android.gesture.cts"
android:label="CTS tests of android.gesture">
</instrumentation>
diff --git a/tests/tests/location/src/android/location/cts/TestMeasurementUtil.java b/tests/tests/location/src/android/location/cts/TestMeasurementUtil.java
index 222591b35df..26aedf8d70b 100644
--- a/tests/tests/location/src/android/location/cts/TestMeasurementUtil.java
+++ b/tests/tests/location/src/android/location/cts/TestMeasurementUtil.java
@@ -68,6 +68,7 @@ public final class TestMeasurementUtil {
// android/hardware/libhardware/include/hardware/gps.h
public static final Set<Integer> GNSS_NAVIGATION_MESSAGE_TYPE =
new HashSet<Integer>(Arrays.asList(
+ GnssNavigationMessage.TYPE_UNKNOWN,
GnssNavigationMessage.TYPE_GPS_L1CA,
GnssNavigationMessage.TYPE_GPS_L2CNAV,
GnssNavigationMessage.TYPE_GPS_L5CNAV,
diff --git a/tests/tests/media/src/android/media/cts/DecoderTest.java b/tests/tests/media/src/android/media/cts/DecoderTest.java
index 2193d333e79..6192c0f99f4 100755
--- a/tests/tests/media/src/android/media/cts/DecoderTest.java
+++ b/tests/tests/media/src/android/media/cts/DecoderTest.java
@@ -2442,7 +2442,19 @@ public class DecoderTest extends MediaPlayerTestBase {
// start decode loop
MediaCodec.BufferInfo info = new MediaCodec.BufferInfo();
- final long kTimeOutUs = 5000; // 5ms timeout
+ MediaFormat outFormat = codec.getOutputFormat();
+ long kTimeOutUs = 5000; // 5ms timeout
+ String outMime = format.getString(MediaFormat.KEY_MIME);
+ if ((surface == null) && (outMime != null) && outMime.startsWith("video/")) {
+ int outWidth = outFormat.getInteger(MediaFormat.KEY_WIDTH);
+ int outHeight = outFormat.getInteger(MediaFormat.KEY_HEIGHT);
+ // in the 4K decoding case in byte buffer mode, set kTimeOutUs to 10ms as decode may
+ // involve a memcpy
+ if (outWidth * outHeight >= 8000000) {
+ kTimeOutUs = 10000;
+ }
+ }
+
boolean sawInputEOS = false;
boolean sawOutputEOS = false;
int deadDecoderCounter = 0;
diff --git a/tests/tests/midi/AndroidTest.xml b/tests/tests/midi/AndroidTest.xml
index d8d12e2c8c0..23c305e5934 100644
--- a/tests/tests/midi/AndroidTest.xml
+++ b/tests/tests/midi/AndroidTest.xml
@@ -16,6 +16,9 @@
<configuration description="Config for CTS MIDI test cases">
<option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="media" />
+ <target_preparer class="com.android.tradefed.targetprep.SwitchUserTargetPreparer">
+ <option name="user-type" value="system" />
+ </target_preparer>
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsMidiTestCases.apk" />
diff --git a/tests/tests/os/src/android/os/cts/EnvironmentTest.java b/tests/tests/os/src/android/os/cts/EnvironmentTest.java
index 6f259c3a1fa..0f2ac62f166 100644
--- a/tests/tests/os/src/android/os/cts/EnvironmentTest.java
+++ b/tests/tests/os/src/android/os/cts/EnvironmentTest.java
@@ -81,14 +81,17 @@ public class EnvironmentTest extends TestCase {
// inodes can result in wasted space.
final long maxsize = stat.f_blocks * stat.f_frsize;
final long maxInodes = maxsize / 4096;
- final long minsize = stat.f_bavail * stat.f_frsize;
- final long minInodes = minsize / 32768;
+ // Assuming the smallest storage would be 4GB, min # of free inodes
+ // in EXT4/F2FS must be larger than 128k for Android to work properly.
+ final long minInodes = 128 * 1024;
- if (stat.f_ffree >= minInodes && stat.f_ffree <= maxInodes) {
+ if (stat.f_ffree >= minInodes && stat.f_ffree <= maxInodes
+ && stat.f_favail <= stat.f_ffree) {
// Sweet, sounds great!
} else {
- fail("Number of inodes " + stat.f_ffree + " not within sane range for partition of "
- + minsize + "," + maxsize + " bytes; expected [" + minInodes + "," + maxInodes + "]");
+ fail("Number of inodes " + stat.f_ffree + "/" + stat.f_favail
+ + " not within sane range for partition of " + maxsize + " bytes; expected ["
+ + minInodes + "," + maxInodes + "]");
}
}
}
diff --git a/tests/tests/packageinstaller/adminpackageinstaller/AndroidTest.xml b/tests/tests/packageinstaller/adminpackageinstaller/AndroidTest.xml
index 2e4a4fe8897..c83c61281b9 100644
--- a/tests/tests/packageinstaller/adminpackageinstaller/AndroidTest.xml
+++ b/tests/tests/packageinstaller/adminpackageinstaller/AndroidTest.xml
@@ -18,6 +18,10 @@
<option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="framework" />
+ <target_preparer class="com.android.tradefed.targetprep.SwitchUserTargetPreparer">
+ <option name="user-type" value="system"/>
+ </target_preparer>
+
<target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
<option name="run-command" value="mkdir -p /data/local/tmp/cts/packageinstaller/" />
<option name="teardown-command" value="rm -rf /data/local/tmp/cts"/>
diff --git a/tests/tests/preference2/src/android/preference2/cts/TestUtils.java b/tests/tests/preference2/src/android/preference2/cts/TestUtils.java
index e00e6589f4b..dd25f59c3dd 100644
--- a/tests/tests/preference2/src/android/preference2/cts/TestUtils.java
+++ b/tests/tests/preference2/src/android/preference2/cts/TestUtils.java
@@ -69,10 +69,16 @@ public class TestUtils {
// Crop the right side for scrollbar which might or might not be visible. On wearable
// devices the scroll bar is a curve and occupies 20% of the right side.
int xToCut = isOnWatchUiMode() ? bt.getWidth() / 5 : bt.getWidth() / 20;
+ int yToCut = statusBarHeight;
+
+ if (isLandscape()) {
+ xToCut += navigationBarHeight;
+ } else {
+ yToCut += navigationBarHeight;
+ }
bt = Bitmap.createBitmap(
- bt, 0, statusBarHeight, bt.getWidth() - xToCut,
- bt.getHeight() - statusBarHeight - navigationBarHeight);
+ bt, 0, statusBarHeight, bt.getWidth() - xToCut, bt.getHeight() - yToCut);
return bt;
}
@@ -240,4 +246,9 @@ public class TestUtils {
throw new RuntimeException("Failed to run command: " + cmd, e);
}
}
+
+ private boolean isLandscape() {
+ return mInstrumentation.getTargetContext().getResources().getConfiguration().orientation ==
+ Configuration.ORIENTATION_LANDSCAPE;
+ }
}
diff --git a/tests/tests/provider/AndroidTest.xml b/tests/tests/provider/AndroidTest.xml
index aaa818c3800..b1dbcc602e0 100644
--- a/tests/tests/provider/AndroidTest.xml
+++ b/tests/tests/provider/AndroidTest.xml
@@ -16,11 +16,15 @@
<configuration description="Config for CTS Provider test cases">
<option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="framework" />
+ <target_preparer class="com.android.tradefed.targetprep.SwitchUserTargetPreparer">
+ <option name="user-type" value="system"/>
+ </target_preparer>
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsProviderTestCases.apk" />
</target_preparer>
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
<option name="package" value="android.provider.cts" />
<option name="runtime-hint" value="7m19s" />
<option name="hidden-api-checks" value="false" />
diff --git a/tests/tests/telecom/AndroidManifest.xml b/tests/tests/telecom/AndroidManifest.xml
index cce9785aee7..6d2ed72b229 100644
--- a/tests/tests/telecom/AndroidManifest.xml
+++ b/tests/tests/telecom/AndroidManifest.xml
@@ -71,6 +71,15 @@
</intent-filter>
</service>
+ <service android:name="com.android.compatibility.common.util.BlockedNumberService"
+ android:exported="true"
+ android:singleUser="true" >
+ <intent-filter>
+ <action android:name="android.telecom.cts.InsertBlockedNumber"/>
+ <action android:name="android.telecom.cts.DeleteBlockedNumber"/>
+ </intent-filter>
+ </service>
+
<receiver android:name="android.telecom.cts.MockMissedCallNotificationReceiver">
<intent-filter>
<action android:name="android.telecom.action.SHOW_MISSED_CALLS_NOTIFICATION" />
diff --git a/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java b/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java
index 871f3e4ff95..954112ba24d 100644
--- a/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java
@@ -17,13 +17,14 @@
package android.telecom.cts;
import static android.telecom.cts.TestUtils.*;
+import static com.android.compatibility.common.util.BlockedNumberUtil.deleteBlockedNumber;
+import static com.android.compatibility.common.util.BlockedNumberUtil.insertBlockedNumber;
import android.app.UiModeManager;
import android.content.ContentValues;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
-import android.provider.BlockedNumberContract;
import android.telecom.CallAudioState;
import android.telecom.Call;
import android.telecom.Connection;
@@ -393,17 +394,17 @@ public class ExtendedInCallServiceTest extends BaseTelecomTestWithMockServices {
assertNull(mInCallCallbacks.getService());
} finally {
if (blockedUri != null) {
- mContext.getContentResolver().delete(blockedUri, null, null);
+ unblockNumber(blockedUri);
}
}
}
private Uri blockNumber(Uri phoneNumberUri) {
- ContentValues cv = new ContentValues();
- cv.put(BlockedNumberContract.BlockedNumbers.COLUMN_ORIGINAL_NUMBER,
- phoneNumberUri.getSchemeSpecificPart());
- return mContext.getContentResolver().insert(
- BlockedNumberContract.BlockedNumbers.CONTENT_URI, cv);
+ return insertBlockedNumber(mContext, phoneNumberUri.getSchemeSpecificPart());
+ }
+
+ private int unblockNumber(Uri uri) {
+ return deleteBlockedNumber(mContext, uri);
}
public void testAnswerIncomingCallAsVideo_SendsCorrectVideoState() {
diff --git a/tests/tests/telephony/AndroidManifest.xml b/tests/tests/telephony/AndroidManifest.xml
index b6840a343d0..236014545e1 100644
--- a/tests/tests/telephony/AndroidManifest.xml
+++ b/tests/tests/telephony/AndroidManifest.xml
@@ -30,6 +30,7 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
+ <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
<uses-permission android:name="android.telephony.embms.cts.permission.TEST_BROADCAST"/>
<permission android:name="android.telephony.embms.cts.permission.TEST_BROADCAST"
@@ -119,6 +120,15 @@
</service>
+ <service android:name="com.android.compatibility.common.util.BlockedNumberService"
+ android:exported="true"
+ android:singleUser="true" >
+ <intent-filter>
+ <action android:name="android.telecom.cts.InsertBlockedNumber"/>
+ <action android:name="android.telecom.cts.DeleteBlockedNumber"/>
+ </intent-filter>
+ </service>
+
<activity android:name="android.telephony.cts.StubDialerActvity">
<intent-filter>
<action android:name="android.intent.action.DIAL"/>
diff --git a/tests/tests/telephony/src/android/telephony/cts/CarrierConfigManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/CarrierConfigManagerTest.java
index f6b30d84061..e1854ccf093 100644
--- a/tests/tests/telephony/src/android/telephony/cts/CarrierConfigManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/CarrierConfigManagerTest.java
@@ -50,7 +50,12 @@ public class CarrierConfigManagerTest extends AndroidTestCase {
}
private boolean isSimCardPresent() {
- return mTelephonyManager.getSimState() != TelephonyManager.SIM_STATE_ABSENT;
+ return mTelephonyManager.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE &&
+ mTelephonyManager.getSimState() != TelephonyManager.SIM_STATE_ABSENT;
+ }
+
+ private boolean isSimCardAbsent() {
+ return mTelephonyManager.getSimState() == TelephonyManager.SIM_STATE_ABSENT;
}
private void checkConfig(PersistableBundle config) {
@@ -59,7 +64,7 @@ public class CarrierConfigManagerTest extends AndroidTestCase {
return;
}
assertNotNull("CarrierConfigManager should not return null config", config);
- if (!isSimCardPresent()) {
+ if (isSimCardAbsent()) {
// Static default in CarrierConfigManager will be returned when no sim card present.
assertEquals("Config doesn't match static default.",
config.getBoolean(CarrierConfigManager.KEY_ADDITIONAL_CALL_SETTING_BOOL), true);
diff --git a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
index 74f9d130252..89814aa6413 100755
--- a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
@@ -16,11 +16,12 @@
package android.telephony.cts;
+import static com.android.compatibility.common.util.BlockedNumberUtil.deleteBlockedNumber;
+import static com.android.compatibility.common.util.BlockedNumberUtil.insertBlockedNumber;
import android.app.PendingIntent;
import android.app.UiAutomation;
import android.content.BroadcastReceiver;
-import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -29,7 +30,6 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.os.SystemClock;
-import android.provider.BlockedNumberContract;
import android.provider.Telephony;
import android.telephony.SmsMessage;
import android.telephony.TelephonyManager;
@@ -118,7 +118,7 @@ public class SmsManagerTest extends InstrumentationTestCase {
@Override
protected void tearDown() throws Exception {
if (mBlockedNumberUri != null) {
- mContext.getContentResolver().delete(mBlockedNumberUri, null, null);
+ unblockNumber(mBlockedNumberUri);
mBlockedNumberUri = null;
}
if (mTestAppSetAsDefaultSmsApp) {
@@ -398,17 +398,18 @@ public class SmsManagerTest extends InstrumentationTestCase {
getSmsManager().sendTextMessage(destAddr, null, text, sentIntent, deliveredIntent);
}
- private void blockNumber(String phoneNumber) {
- ContentValues cv = new ContentValues();
- cv.put(BlockedNumberContract.BlockedNumbers.COLUMN_ORIGINAL_NUMBER, phoneNumber);
- mBlockedNumberUri = mContext.getContentResolver().insert(
- BlockedNumberContract.BlockedNumbers.CONTENT_URI, cv);
+ private void blockNumber(String number) {
+ mBlockedNumberUri = insertBlockedNumber(mContext, number);
+ }
+
+ private void unblockNumber(Uri uri) {
+ deleteBlockedNumber(mContext, uri);
}
private void setDefaultSmsApp(boolean setToSmsApp)
throws Exception {
String command = String.format(
- "appops set %s WRITE_SMS %s",
+ "appops set --user 0 %s WRITE_SMS %s",
mContext.getPackageName(),
setToSmsApp ? "allow" : "default");
assertTrue("Setting default SMS app failed : " + setToSmsApp,
diff --git a/tests/tests/telephony/src/android/telephony/cts/SubscriptionManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/SubscriptionManagerTest.java
index 3b8656b60a6..4e1cb8bff32 100644
--- a/tests/tests/telephony/src/android/telephony/cts/SubscriptionManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SubscriptionManagerTest.java
@@ -64,44 +64,10 @@ public class SubscriptionManagerTest {
private int mSubId;
private String mPackageName;
- /**
- * Callback used in testRegisterNetworkCallback that allows caller to block on
- * {@code onAvailable}.
- */
- private static class TestNetworkCallback extends ConnectivityManager.NetworkCallback {
- private final CountDownLatch mAvailableLatch = new CountDownLatch(1);
-
- public void waitForAvailable() throws InterruptedException {
- assertTrue("Cellular network did not come up after 5 seconds",
- mAvailableLatch.await(5, TimeUnit.SECONDS));
- }
-
- @Override
- public void onAvailable(Network network) {
- mAvailableLatch.countDown();
- }
- }
-
@BeforeClass
public static void setUpClass() throws Exception {
InstrumentationRegistry.getInstrumentation().getUiAutomation()
.executeShellCommand("svc wifi disable");
-
- final TestNetworkCallback callback = new TestNetworkCallback();
- final ConnectivityManager cm = InstrumentationRegistry.getContext()
- .getSystemService(ConnectivityManager.class);
- cm.registerNetworkCallback(new NetworkRequest.Builder()
- .addTransportType(TRANSPORT_CELLULAR)
- .addCapability(NET_CAPABILITY_INTERNET)
- .build(), callback);
- try {
- // Wait to get callback for availability of internet
- callback.waitForAvailable();
- } catch (InterruptedException e) {
- fail("NetworkCallback wait was interrupted.");
- } finally {
- cm.unregisterNetworkCallback(callback);
- }
}
@AfterClass
diff --git a/tests/tests/telephony4/Android.mk b/tests/tests/telephony4/Android.mk
new file mode 100644
index 00000000000..293224fd03a
--- /dev/null
+++ b/tests/tests/telephony4/Android.mk
@@ -0,0 +1,48 @@
+# 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.
+
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+# don't include this package in any target
+LOCAL_MODULE_TAGS := optional
+# and when built explicitly put it in the data partition
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_JAVA_LIBRARIES := telephony-common \
+ android.test.runner.stubs \
+ android.test.base.stubs
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ ctstestrunner \
+ compatibility-device-util \
+ truth-prebuilt
+
+LOCAL_HOST_SHARED_LIBRARIES := compatibility-device-telephony-preconditions
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := CtsSimRestrictedApisTestCases
+LOCAL_PRIVATE_PLATFORM_APIS := true
+
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
+
+LOCAL_CERTIFICATE := cts/tests/tests/telephony4/certs/android_telephony_cts_testkey
+
+
+include $(BUILD_CTS_PACKAGE)
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/telephony4/AndroidManifest.xml b/tests/tests/telephony4/AndroidManifest.xml
new file mode 100644
index 00000000000..b292bb1284e
--- /dev/null
+++ b/tests/tests/telephony4/AndroidManifest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.telephony4.cts">
+
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.telephony4.cts"
+ android:label="CTS tests of android.telephony4">
+ <meta-data android:name="listener"
+ android:value="com.android.cts.runner.CtsTestRunListener" />
+ </instrumentation>
+
+</manifest>
+
diff --git a/tests/tests/telephony4/AndroidTest.xml b/tests/tests/telephony4/AndroidTest.xml
new file mode 100644
index 00000000000..636ecbb1983
--- /dev/null
+++ b/tests/tests/telephony4/AndroidTest.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Config for CTS Telephony4 test cases">
+ <option name="test-suite-tag" value="cts" />
+ <option name="config-descriptor:metadata" key="component" value="telecom" />
+ <option name="not-shardable" value="true" />
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
+ <option name="test-file-name" value="CtsSimRestrictedApisTestCases.apk" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="android.telephony4.cts" />
+ </test>
+</configuration>
diff --git a/tests/tests/telephony4/certs/android_telephony_cts_testkey.pk8 b/tests/tests/telephony4/certs/android_telephony_cts_testkey.pk8
new file mode 100644
index 00000000000..f83d5ed78a5
--- /dev/null
+++ b/tests/tests/telephony4/certs/android_telephony_cts_testkey.pk8
Binary files differ
diff --git a/tests/tests/telephony4/certs/android_telephony_cts_testkey.x509.pem b/tests/tests/telephony4/certs/android_telephony_cts_testkey.x509.pem
new file mode 100644
index 00000000000..29ffd6a844f
--- /dev/null
+++ b/tests/tests/telephony4/certs/android_telephony_cts_testkey.x509.pem
@@ -0,0 +1,30 @@
+-----BEGIN CERTIFICATE-----
+MIIF9TCCA92gAwIBAgIVAIja2SQYIM1wfIrwgObEUdBk/MfkMA0GCSqGSIb3DQEBCwUAMIGKMQsw
+CQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEU
+MBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxJjAkBgNVBAMMHWFuZHJvaWRf
+dGVsZXBob255X2N0c190ZXN0a2V5MB4XDTE5MDExMTE5MzMwM1oXDTQ5MDExMTE5MzMwM1owgYox
+CzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3
+MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEmMCQGA1UEAwwdYW5kcm9p
+ZF90ZWxlcGhvbnlfY3RzX3Rlc3RrZXkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC9
+IXCTl7o3J6gy5YleQRFm5Xahth5hwpC7b/cfZiSW25AqNLZRcZJZDwYiJIpqOu773Hr5fEZMV5c1
+tYivwdwKnoGlWiqrpvwafIQxsAPtKoiSsB6r6Zx4hZBDzf5M+PRi3ieUrPrwaiGeVy1n4nPhcpHy
+bzE2G+ZkfzxRYRmmObi8+UC4lkI2dL1Y17hjNmWpeJrfhvl67K2gMmAtwjW2UxhyOcACg8Mya1eA
+VyqQgiEfMb52FK1opshHnGpIcLjY7UT1IesOZpWu3OWqiOw/KCU+nJaEemYFYceGR14RGfKk9r1N
+hcRhZLXPfZHr9TPsJ/O/oKrF3Q+TxoUJIhQ3lcYREftrqMZNDUUANENnfd1Bviu2atschG5Ohchk
+MiuKDadMl++LOkfGjoTikQXUHGxb4GIfgLJDmkp6+Andc2iZ2pRPm6zQmHXWmcwtz3RvyGtK0oYJ
+xwpVy0InE/Ao1sH8LrYvBPWKDVHbG2v+ydYYrx39ScBLgXQ4gxmTNU8+YX3zXVaGWMPuVP2GfyBl
+O+fl27RZO/XZlC28TQEMAvytSyeTs4blubRlLgcf9wAv774a797g7uSRSZ+8aqumatPrtZnhBojU
+2U4zuQilE5JGIIvM5ZGWUNMMkY5bB4bnw36oSK7kup8dyLlT7Jgfpc5RuzYPKzU+OcH/k0SeZwID
+AQABo1AwTjAMBgNVHRMEBTADAQH/MB0GA1UdDgQWBBR4+8+XqYU6x7dqy/fwqz5eG2TQIjAfBgNV
+HSMEGDAWgBR4+8+XqYU6x7dqy/fwqz5eG2TQIjANBgkqhkiG9w0BAQsFAAOCAgEAaxTiY0j+Xgig
+WnsfqJRCV7Qn6LFhCyS2zc96g+m0CkiPLW83BFkVND9JaAUVw3GIUKDEtZkUy3v5L4//QmfdYIbH
+IBX5d/GJAVkH4MRFb47Mr2qu6t33eNiDaRzJe5WIQ+3qI1P0/2ihqKOAEC8OSWQWzY8eWB9O4vKp
+U/0JENOcSTfthce7dDhCCqw3P0Xmo9xW1x9YqcAPzNcQE7Lm68MeOB9esoTlIFS7R9tRp17pBU8Y
+Lw9WSRFy6jBYX1Wf83M96+WPNQensLymnXMDuwJhoNV5MnGMkqsASfkzZwLxcLRKlt4gJ4gmmPlM
+mIeJCcMvUJIMOlYcNEiBF4i4CkzA/ThxPRXSCZdQKjzM5YG7Sj3uEJTYgDq+50k/nKnhqKymZhQN
+pXtax3/2ivonWfNaWWIYBEY3aRQTb3IwTRjM1ib6Aj4sIjATzP0vowmYoQf/iv5HKYyndyRcy4zR
+LeOUbU5Hk0Rhc896eOFshwuB8VQ/6kiIPWN4VRNXn/hjT+p5y+ww8IM1crLV+ftdRDhDKbgxNfo1
+R1uhZgRryzWBmFEz6wSKDctdVeZ087e3pfze+V3/hrT2gevoYtcMHT7+qmNssnDbUinXJicQAQBn
+Wl2lx+PwyRnQ1dAozjcpytqXNmRF/881E2MvtdAN5Y4F5d0fh32Yi455xQ5UNb0=
+-----END CERTIFICATE-----
+
diff --git a/tests/tests/telephony/src/android/telephony/cts/SimRestrictedApisTest.java b/tests/tests/telephony4/src/android/telephony4/cts/SimRestrictedApisTest.java
index b15a4e8801f..dd56952d852 100644
--- a/tests/tests/telephony/src/android/telephony/cts/SimRestrictedApisTest.java
+++ b/tests/tests/telephony4/src/android/telephony4/cts/SimRestrictedApisTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android.telephony.cts;
+package android.telephony4.cts;
import android.content.Context;
import android.telephony.SmsManager;
@@ -67,21 +67,6 @@ public class SimRestrictedApisTest extends AndroidTestCase {
}
/**
- * Tests the TelephonyManager.setLine1NumberForDisplay(long, string, string) API. This makes a
- * call to setLine1NumberForDisplay() API and expects a SecurityException since the test apk is
- * not signed by the certificate on the SIM.
- */
- public void testSetLine1NumberForDisplay2() {
- try {
- if (isSimCardPresent()) {
- TelephonyManager.getDefault().setLine1NumberForDisplay(0, "", "");
- fail("Expected SecurityException. App doesn't have carrier privileges.");
- }
- } catch (SecurityException expected) {
- }
- }
-
- /**
* Tests the TelephonyManager.iccOpenLogicalChannel() API. This makes a call to
* iccOpenLogicalChannel() API and expects a SecurityException since the test apk is not signed
* by certificate on the SIM.
@@ -89,7 +74,8 @@ public class SimRestrictedApisTest extends AndroidTestCase {
public void testIccOpenLogicalChannel() {
try {
if (isSimCardPresent()) {
- TelephonyManager.getDefault().iccOpenLogicalChannel("");
+ TelephonyManager.getDefault().iccCloseLogicalChannel(
+ TelephonyManager.getDefault().iccOpenLogicalChannel("").getChannel());
fail("Expected SecurityException. App doesn't have carrier privileges.");
}
} catch (SecurityException expected) {
@@ -171,41 +157,13 @@ public class SimRestrictedApisTest extends AndroidTestCase {
}
/**
- * Tests the TelephonyManager.nvWriteItem() API. This makes a call to nvWriteItem() API and
- * expects a SecurityException since the test apk is not signed by a certificate on the SIM.
- */
- public void testNvWriteItem() {
- try {
- if (isSimCardPresent()) {
- TelephonyManager.getDefault().nvWriteItem(0, "");
- fail("Expected SecurityException. App doesn't have carrier privileges.");
- }
- } catch (SecurityException expected) {
- }
- }
-
- /**
- * Tests the TelephonyManager.nvWriteCdmaPrl() API. This makes a call to nvWriteCdmaPrl() API
- * and expects a SecurityException since the test apk is not signed by a certificate on the SIM.
- */
- public void testNvWriteCdmaPrl() {
- try {
- if (isSimCardPresent()) {
- TelephonyManager.getDefault().nvWriteCdmaPrl(null);
- fail("Expected SecurityException. App doesn't have carrier privileges.");
- }
- } catch (SecurityException expected) {
- }
- }
-
- /**
* Tests the TelephonyManager.nvResetConfig() API. This makes a call to nvResetConfig() API and
* expects a SecurityException since the test apk is not signed by a certificate on the SIM.
*/
public void testNvResetConfig() {
try {
if (isSimCardPresent()) {
- TelephonyManager.getDefault().nvResetConfig(0);
+ TelephonyManager.getDefault().nvResetConfig(1);
fail("Expected SecurityException. App doesn't have carrier privileges.");
}
} catch (SecurityException expected) {
@@ -246,7 +204,7 @@ public class SimRestrictedApisTest extends AndroidTestCase {
* Tests that the test apk doesn't have carrier previliges.
*/
public void testHasCarrierPrivileges() {
- if (TelephonyManager.getDefault().hasCarrierPrivileges()) {
+ if (mTelephonyManager.hasCarrierPrivileges()) {
fail("App unexpectedly has carrier privileges");
}
}
diff --git a/tests/tests/text/src/android/text/cts/StaticLayoutLineBreakingTest.java b/tests/tests/text/src/android/text/cts/StaticLayoutLineBreakingTest.java
index adb8f975b08..870dd345025 100644
--- a/tests/tests/text/src/android/text/cts/StaticLayoutLineBreakingTest.java
+++ b/tests/tests/text/src/android/text/cts/StaticLayoutLineBreakingTest.java
@@ -18,7 +18,7 @@ package android.text.cts;
import static org.junit.Assert.assertEquals;
-import android.content.Context;;
+import android.content.Context;
import android.graphics.Typeface;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
diff --git a/tests/tests/view/res/layout/focus_finder_layout.xml b/tests/tests/view/res/layout/focus_finder_layout.xml
index 8f4dffbaa46..1dea6846cce 100644
--- a/tests/tests/view/res/layout/focus_finder_layout.xml
+++ b/tests/tests/view/res/layout/focus_finder_layout.xml
@@ -22,8 +22,7 @@
android:layout_alignParentTop="true">
<TableRow>
<android.view.cts.TestButton android:id="@+id/top_left_button"
- android:layout_width="20dp"
- android:layout_marginRight="40dp"
+ android:layout_width="60dp"
android:layout_height="match_parent"
android:text="TL" />
<android.view.cts.TestButton android:id="@+id/top_right_button"
diff --git a/tests/tests/view/res/values-ldpi/dimens.xml b/tests/tests/view/res/values-ldpi/dimens.xml
new file mode 100644
index 00000000000..5b79a3e9333
--- /dev/null
+++ b/tests/tests/view/res/values-ldpi/dimens.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<resources>
+ <dimen name="hover_target_margin">6dp</dimen>
+ <dimen name="hover_target_size">12dp</dimen>
+ <dimen name="hover_target_size_double">24dp</dimen>
+</resources>
diff --git a/tests/tests/view/src/android/view/cts/FocusFinderTest.java b/tests/tests/view/src/android/view/cts/FocusFinderTest.java
index 25051111440..465b218c000 100644
--- a/tests/tests/view/src/android/view/cts/FocusFinderTest.java
+++ b/tests/tests/view/src/android/view/cts/FocusFinderTest.java
@@ -121,13 +121,14 @@ public class FocusFinderTest {
* | | |
* +---+---+
*/
- Rect rect = new Rect();
- mTopLeft.getDrawingRect(rect);
- rect.offset(mTopLeft.getWidth() / 2, 0);
- rect.inset(mTopLeft.getWidth() / 4, mTopLeft.getHeight() / 4);
+ int buttonHalfWidth = mTopLeft.getWidth() / 2;
+ Rect topRect = new Rect(mTopLeft.getLeft() + buttonHalfWidth,
+ mTopLeft.getTop(),
+ mTopLeft.getRight() + buttonHalfWidth,
+ mTopLeft.getBottom());
- verifytNextFocusFromRect(rect, View.FOCUS_LEFT, mTopLeft);
- verifytNextFocusFromRect(rect, View.FOCUS_RIGHT, mTopRight);
+ verifytNextFocusFromRect(topRect, View.FOCUS_LEFT, mTopLeft);
+ verifytNextFocusFromRect(topRect, View.FOCUS_RIGHT, mTopRight);
/*
* Create a small rectangle on the border between the top left and bottom left buttons.
@@ -138,12 +139,14 @@ public class FocusFinderTest {
* | | |
* +---+---+
*/
- mTopLeft.getDrawingRect(rect);
- rect.offset(0, mTopRight.getHeight() / 2);
- rect.inset(mTopLeft.getWidth() / 4, mTopLeft.getHeight() / 4);
-
- verifytNextFocusFromRect(rect, View.FOCUS_UP, mTopLeft);
- verifytNextFocusFromRect(rect, View.FOCUS_DOWN, mBottomLeft);
+ int buttonHalfHeight = mTopLeft.getHeight() / 2;
+ Rect leftRect = new Rect(mTopLeft.getLeft(),
+ mTopLeft.getTop() + buttonHalfHeight,
+ mTopLeft.getRight(),
+ mTopLeft.getBottom() + buttonHalfHeight);
+
+ verifytNextFocusFromRect(leftRect, View.FOCUS_UP, mTopLeft);
+ verifytNextFocusFromRect(leftRect, View.FOCUS_DOWN, mBottomLeft);
}
private void verifytNextFocusFromRect(Rect rect, int direction, View expectedNextFocus) {
diff --git a/tests/tests/view/src/android/view/cts/PixelCopyViewProducerActivity.java b/tests/tests/view/src/android/view/cts/PixelCopyViewProducerActivity.java
index 69e1e7f8372..054de455cfc 100644
--- a/tests/tests/view/src/android/view/cts/PixelCopyViewProducerActivity.java
+++ b/tests/tests/view/src/android/view/cts/PixelCopyViewProducerActivity.java
@@ -65,6 +65,8 @@ public class PixelCopyViewProducerActivity extends Activity implements OnDrawLis
mContent = new ColoredGrid(this);
setContentView(mContent);
+ View view = this.getWindow().getDecorView();
+ view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
mContent.getViewTreeObserver().addOnDrawListener(this);
mContent.setOnApplyWindowInsetsListener(this);
}
diff --git a/tests/tests/view/src/android/view/cts/PixelCopyWideGamutViewProducerActivity.java b/tests/tests/view/src/android/view/cts/PixelCopyWideGamutViewProducerActivity.java
index f6970956eba..d8a512d72c4 100644
--- a/tests/tests/view/src/android/view/cts/PixelCopyWideGamutViewProducerActivity.java
+++ b/tests/tests/view/src/android/view/cts/PixelCopyWideGamutViewProducerActivity.java
@@ -64,6 +64,8 @@ public class PixelCopyWideGamutViewProducerActivity extends Activity implements
mContent = new WideGamutBitmapView(this);
setContentView(mContent);
+ View view = this.getWindow().getDecorView();
+ view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
mContent.getViewTreeObserver().addOnDrawListener(this);
}
diff --git a/tests/tests/view/src/android/view/cts/WindowTest.java b/tests/tests/view/src/android/view/cts/WindowTest.java
index 41ad595c699..94b3cebd68d 100644
--- a/tests/tests/view/src/android/view/cts/WindowTest.java
+++ b/tests/tests/view/src/android/view/cts/WindowTest.java
@@ -704,8 +704,6 @@ public class WindowTest {
mPresentation.button1.getWidth() / 2,
mPresentation.button1.getY() + mPresentation.button1.getHeight() / 2);
assertTrue(waitingSemaphore.tryAcquire(5, TimeUnit.SECONDS));
-
- destroyPresentation();
}
private void checkPresentationButtonFocus(final boolean button1Focused,
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
index 8cfaec31320..a9b0d9ed427 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
@@ -105,10 +105,9 @@ public class WebSettingsTest extends ActivityInstrumentationTestCase2<WebViewCts
* compatibility definition (tokens in angle brackets are variables, tokens in square
* brackets are optional):
* <p/>
- * Mozilla/5.0 (Linux;[ U;] Android <version>;[ <language>-<country>;]
- * [<devicemodel>;] Build/<buildID>; wv) AppleWebKit/<major>.<minor> (KHTML, like Gecko)
- * Version/<major>.<minor> Chrome/<major>.<minor>.<branch>.<build>[ Mobile]
- * Safari/<major>.<minor>
+ * Mozilla/5.0 (Linux; Android <version>; [<devicemodel>;] [Build/<buildID>;] wv)
+ * AppleWebKit/<major>.<minor> (KHTML, like Gecko) Version/<major>.<minor>
+ * Chrome/<major>.<minor>.<branch>.<build>[ Mobile] Safari/<major>.<minor>
*/
public void testUserAgentString_default() {
if (!NullWebViewUtils.isWebViewAvailable()) {
@@ -116,43 +115,34 @@ public class WebSettingsTest extends ActivityInstrumentationTestCase2<WebViewCts
}
final String actualUserAgentString = mSettings.getUserAgentString();
Log.i(LOG_TAG, String.format("Checking user agent string %s", actualUserAgentString));
+
+ String expectedRelease, expectedModel;
+ if ("REL".equals(Build.VERSION.CODENAME)) {
+ expectedRelease = Pattern.quote(Build.VERSION.RELEASE);
+ expectedModel = Pattern.quote(Build.MODEL);
+ } else {
+ // Non-release builds don't include real release version/model, be lenient.
+ expectedRelease = expectedModel = "[^;]+";
+ }
+
+ // Build expected regex inserting the appropriate variables, as this is easier to
+ // understand and get right than matching any possible useragent and comparing the
+ // variables afterward.
final String patternString =
- "Mozilla/5\\.0 \\(Linux;( U;)? Android ([^;]+);( (\\w+)-(\\w+);)?" +
- "\\s?(.*)\\sBuild/(.+); wv\\) AppleWebKit/(\\d+)\\.(\\d+) " +
- "\\(KHTML, like Gecko\\) " +
- "Version/\\d+\\.\\d+ Chrome/\\d+\\.\\d+\\.\\d+\\.\\d+( Mobile)? " +
- "Safari/(\\d+)\\.(\\d+)";
- // Groups used:
- // 1 - SSL encryption strength token " U;" (optional)
- // 2 - Android version
- // 3 - full locale string (optional)
- // 4 - country
- // 5 - language
- // 6 - device model (optional)
- // 7 - build ID
- // 8 - AppleWebKit major version number
- // 9 - AppleWebKit minor version number
- // 10 - " Mobile" string (optional)
- // 11 - Safari major version number
- // 12 - Safari minor version number
+ Pattern.quote("Mozilla/5.0 (Linux; Android ") + expectedRelease + "; " +
+ "(" + expectedModel + "; )?" + // Optional
+ "(Build/" + Pattern.quote(Build.ID) + "; )?" + // Optional
+ Pattern.quote("wv) ") +
+ "AppleWebKit/\\d+\\.\\d+ " +
+ Pattern.quote("(KHTML, like Gecko) Version/4.0 ") +
+ "Chrome/\\d+\\.\\d+\\.\\d+\\.\\d+ " +
+ "(Mobile )?Safari/\\d+\\.\\d+";
Log.i(LOG_TAG, String.format("Trying to match pattern %s", patternString));
final Pattern userAgentExpr = Pattern.compile(patternString);
Matcher patternMatcher = userAgentExpr.matcher(actualUserAgentString);
assertTrue(String.format("User agent string did not match expected pattern. \nExpected " +
"pattern:\n%s\nActual:\n%s", patternString, actualUserAgentString),
patternMatcher.find());
- if (patternMatcher.group(3) != null) {
- Locale currentLocale = Locale.getDefault();
- assertEquals(currentLocale.getLanguage().toLowerCase(), patternMatcher.group(4));
- assertEquals(currentLocale.getCountry().toLowerCase(), patternMatcher.group(5));
- }
- if ("REL".equals(Build.VERSION.CODENAME)) {
- // Model is only added in release builds
- assertEquals(Build.MODEL, patternMatcher.group(6));
- // Release version is valid only in release builds
- assertEquals(Build.VERSION.RELEASE, patternMatcher.group(2));
- }
- assertEquals(Build.ID, patternMatcher.group(7));
}
public void testAccessUserAgentString() throws Exception {
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewSslTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewSslTest.java
index 688fc3386f0..08de5240e83 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewSslTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewSslTest.java
@@ -731,12 +731,23 @@ public class WebViewSslTest extends ActivityInstrumentationTestCase2<WebViewCtsA
mOnUiThread.clearSslPreferences();
mOnUiThread.loadUrlAndWaitForCompletion(url);
// Page NOT loaded OK...
- // In this case, we must NOT have received the onReceivedSslError callback as that is for
- // recoverable (e.g. server auth) errors, whereas failing mandatory client auth is non-
- // recoverable and should drop straight through to a load error.
- assertFalse(webViewClient.wasOnReceivedSslErrorCalled());
- assertFalse(TestHtmlConstants.HELLO_WORLD_TITLE.equals(mOnUiThread.getTitle()));
- assertEquals(WebViewClient.ERROR_FAILED_SSL_HANDSHAKE, webViewClient.onReceivedErrorCode());
+ //
+ // In this test, we expect both a recoverable and non-recoverable error:
+ //
+ // 1. WebView does not trust the test server's certificate. This is a recoverable error, so
+ // WebView invokes #onReceivedSslError (and the WebViewClient calls #proceed). We don't
+ // specifically intend to test this part of the scenario, but we can't easily mock out
+ // WebView's certificate roots.
+ // 2. WebView proceeds with the handshake without providing client authentication. The
+ // server fails the client. This is non-recoverable, so WebView invokes
+ // #onReceivedError.
+ //
+ // We only assert the second error, since earlier WebView versions had a bug in which
+ // WebView hit error 2 first, which prevented it from hitting error 1.
+ assertFalse("Title should not be updated, since page load should have failed",
+ TestHtmlConstants.HELLO_WORLD_TITLE.equals(mOnUiThread.getTitle()));
+ assertEquals("Expected ERROR_FAILED_SSL_HANDSHAKE in onReceivedError",
+ WebViewClient.ERROR_FAILED_SSL_HANDSHAKE, webViewClient.onReceivedErrorCode());
}
public void testProceedClientCertRequest() throws Throwable {
diff --git a/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java b/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java
index 7bbc08a1d37..49b0f6416f2 100644
--- a/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java
@@ -763,7 +763,7 @@ public class AbsListViewTest {
mActivityRule.runOnUiThread(() -> mListView.setItemChecked(0, false));
assertFalse(mListView.isLayoutRequested());
}
-
+ private boolean checkResult = false;
@MediumTest
@Test
public void testSetItemChecked_multipleModeDifferentValue() throws Throwable {
@@ -773,8 +773,15 @@ public class AbsListViewTest {
mActivityRule.runOnUiThread(() -> mListView.setItemChecked(0, false));
mInstrumentation.waitForIdleSync();
assertFalse(mListView.isLayoutRequested());
- mActivityRule.runOnUiThread(() -> mListView.setItemChecked(0, true));
- assertTrue(mListView.isLayoutRequested());
+ checkResult = false;
+ mActivityRule.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ mListView.setItemChecked(0, true);
+ checkResult = mListView.isLayoutRequested();
+ }
+ });
+ assertTrue(checkResult);
}
@MediumTest
@@ -786,8 +793,15 @@ public class AbsListViewTest {
mActivityRule.runOnUiThread(() -> mListView.setItemChecked(0, false));
mInstrumentation.waitForIdleSync();
assertFalse(mListView.isLayoutRequested());
- mActivityRule.runOnUiThread(() -> mListView.setItemChecked(0, true));
- assertTrue(mListView.isLayoutRequested());
+ checkResult = false;
+ mActivityRule.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ mListView.setItemChecked(0, true);
+ checkResult = mListView.isLayoutRequested();
+ }
+ });
+ assertTrue(checkResult);
}
@LargeTest