diff options
author | android-build-prod (mdb) <android-build-team-robot@google.com> | 2019-10-10 18:31:26 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-10-10 18:31:26 +0000 |
commit | f6fd7454c9d1706d18c33a3638f6db447aab1bfd (patch) | |
tree | ccfb7838e1b8c1e390fabe0d88251776c83ab3b6 | |
parent | 90914c424e8d0562b1a3834ecf815484c5a47888 (diff) | |
parent | d77c849d8bceda98c16ec3424ffe0ccf0b3f49ed (diff) | |
download | cts-nougat-cts-release.tar.gz |
Merge "Snap for 5905527 from 8719ff4006e7327f53fa603dc331af7ab75b95ab to nougat-cts-release" into nougat-cts-releaseandroid-cts-7.0_r33nougat-cts-release
12 files changed, 115 insertions, 17 deletions
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml index 8ea0e9c672f..c6a3991251d 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="7.0_r32"> + android:versionName="7.0_r33"> <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="24"/> @@ -1322,6 +1322,7 @@ <!-- KeyChain is only installed on communication-oriented devices inheriting core.mk --> <meta-data android:name="test_excluded_features" android:value="android.hardware.type.watch:android.hardware.type.television:android.software.leanback" /> + <meta-data android:name="test_required_features" android:value="android.software.device_admin" /> </activity> <activity android:name=".p2p.GoNegRequesterTestListActivity" diff --git a/apps/CtsVerifier/res/layout/js_charging.xml b/apps/CtsVerifier/res/layout/js_charging.xml index e0986babb96..d6a20c6f6c4 100644 --- a/apps/CtsVerifier/res/layout/js_charging.xml +++ b/apps/CtsVerifier/res/layout/js_charging.xml @@ -16,6 +16,7 @@ android:text="@string/js_test_description" android:layout_margin="@dimen/js_padding"/> <TextView + android:id="@+id/charger_prompt" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="@dimen/js_padding" @@ -70,12 +71,14 @@ android:textSize="16dp"/> </LinearLayout> <TextView + android:id="@+id/unplug_prompt" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="@dimen/js_padding" android:text="@string/js_charging_description_2" android:textStyle="bold"/> <LinearLayout + android:id="@+id/unplug_test_description" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="@dimen/js_padding" diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml index 0a882f1a483..16d93b5a1c3 100755 --- a/apps/CtsVerifier/res/values/strings.xml +++ b/apps/CtsVerifier/res/values/strings.xml @@ -1692,6 +1692,7 @@ You should be prompted to select credentials; choose the ones you just installed Verify that the notification is badged (see sample badge below). Then mark this test accordingly. </string> <string name="provisioning_byod_notification_title">This is a notification</string> + <string name="provisioning_byod_notification_public_title">Contents hidden by policy</string> <string name="provisioning_byod_disallow_apps_control">Disallow apps control</string> <string name="provisioning_byod_disallow_apps_control_info"> @@ -2457,11 +2458,11 @@ You should be prompted to select credentials; choose the ones you just installed <string name="js_charging_off_test">Device not charging will not execute a job with a charging constraint.</string> <string name="js_charging_on_test">Device when charging will execute a job with a charging constraint.</string> <string name="js_charging_description_2">After the above test has passed, remove the charger to continue. If the above failed, you can simply fail this test.</string> - <string name="js_charging_description_3">Device is plugged in. Please wait while it get\s into stable charging state.</string> - <string name="js_charging_description_4">There seems to be a problem with your charger. Pleasy try again.</string> + <string name="js_charging_description_3">Device is plugged in. Please wait while it gets into stable charging state.</string> + <string name="js_charging_description_4">There seems to be a problem with your charger. Please try again.</string> <string name="js_connectivity_test">Connectivity Constraints</string> - <string name="js_connectivity_instructions">Verify the behaviour of the JobScheduler API for when the device has no access to data connectivity. Simply follow the on-screen instructions.</string> + <string name="js_connectivity_instructions">Verify the behavior of the JobScheduler API for when the device has no access to data connectivity. Simply follow the on-screen instructions.</string> <string name="js_connectivity_description_1">Disable WiFi and Cellular data to begin.</string> <string name="js_unmetered_connectivity_test">Device with no connectivity will not execute a job with an unmetered connectivity constraint.</string> <string name="js_any_connectivity_test">Device with no connectivity will not execute a job with an unmetered connectivity constraint.</string> diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/jobscheduler/ChargingConstraintTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/jobscheduler/ChargingConstraintTestActivity.java index 4b70b894640..f2908b4e8a0 100644 --- a/apps/CtsVerifier/src/com/android/cts/verifier/jobscheduler/ChargingConstraintTestActivity.java +++ b/apps/CtsVerifier/src/com/android/cts/verifier/jobscheduler/ChargingConstraintTestActivity.java @@ -66,6 +66,14 @@ public class ChargingConstraintTestActivity extends ConstraintTestActivity { mStartButton.setEnabled(true); } + if (!deviceHasBattery()) { + // This device has hardwired power, so do not prompt about connecting + // or disconnecting the charger, and ignore the "no power" test. + findViewById(R.id.charger_prompt).setVisibility(View.GONE); + findViewById(R.id.unplug_prompt).setVisibility(View.GONE); + findViewById(R.id.unplug_test_description).setVisibility(View.GONE); + } + hideWaitingForStableChargingViews(); mTestState = STATE_NOT_RUNNING; @@ -88,6 +96,12 @@ public class ChargingConstraintTestActivity extends ConstraintTestActivity { unregisterReceiver(mChargingChangedReceiver); } + private boolean deviceHasBattery() { + final Intent batteryInfo = registerReceiver(null, + new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); + return batteryInfo.getBooleanExtra(BatteryManager.EXTRA_PRESENT, true); + } + private boolean isDevicePluggedIn() { IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); Intent batteryStatus = registerReceiver(null, ifilter); @@ -117,8 +131,11 @@ public class ChargingConstraintTestActivity extends ConstraintTestActivity { new TestDevicePluggedInConstraint().execute(); } } else if (BatteryManager.ACTION_DISCHARGING.equals(intent.getAction())) { - if (mTestState == STATE_ON_CHARGING_TEST_PASSED) { - new TestDeviceUnpluggedConstraint().execute(); + // ignore this [spurious!] broadcast on non-battery devices + if (deviceHasBattery()) { + if (mTestState == STATE_ON_CHARGING_TEST_PASSED) { + new TestDeviceUnpluggedConstraint().execute(); + } } } else if (Intent.ACTION_POWER_CONNECTED.equals(intent.getAction())) { if (mTestState == STATE_WAITING_TO_START_ON_CHARGING_TEST) { diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java index b4f9724a3c2..d6781125cc7 100644 --- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java +++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java @@ -175,9 +175,17 @@ public class ByodHelperActivity extends LocationListenerActivity .setContentTitle(getString(R.string.provisioning_byod_notification_title)) .setVisibility(visibility) .setAutoCancel(true) + .setPublicVersion(createPublicVersionNotification()) .build(); mNotificationManager.notify(NOTIFICATION_ID, notification); } + private Notification createPublicVersionNotification() { + return new Notification.Builder(this) + .setSmallIcon(R.drawable.icon) + .setContentTitle(getString(R.string.provisioning_byod_notification_public_title)) + .setAutoCancel(true) + .build(); + } @Override diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java index a4686aac77e..297485841d6 100644 --- a/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java +++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/DirectBootHostTest.java @@ -220,11 +220,25 @@ public class DirectBootHostTest extends DeviceTestCase implements IAbiReceiver, if (featureList.contains("feature:android.hardware.type.watch\n") || featureList.contains("feature:android.hardware.type.television\n")) { return false; + } else if (!hasSecureLockScreen(featureList)) { + // skip if device doesn't have secure lock screen + return false; } else { return true; } } + /* + * Device that don't report android.software.device_admin doesn't have secure lock screen + * because device with secure lock screen MUST report android.software.device_admin . + * + * https://source.android.com/compatibility/7.0/android-7.0-cdd.html#3_9_device_administration + * + */ + private boolean hasSecureLockScreen(final String featureList) { + return featureList.contains("feature:android.software.device_admin\n"); + } + private void waitForBootCompleted() throws Exception { for (int i = 0; i < 45; i++) { if (isBootCompleted()) { diff --git a/hostsidetests/net/app/Android.mk b/hostsidetests/net/app/Android.mk index 9519ec5242f..443ea71b1cc 100644 --- a/hostsidetests/net/app/Android.mk +++ b/hostsidetests/net/app/Android.mk @@ -19,10 +19,13 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := tests -LOCAL_SDK_VERSION := current +#LOCAL_SDK_VERSION := current +LOCAL_PRIVATE_PLATFORM_APIS := true LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil ctstestrunner ub-uiautomator \ CtsHostsideNetworkTestsAidl +LOCAL_JAVA_LIBRARIES := android.test.runner + LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_PACKAGE_NAME := CtsHostsideNetworkTestsApp diff --git a/hostsidetests/net/app/src/com/android/cts/net/hostside/VpnTest.java b/hostsidetests/net/app/src/com/android/cts/net/hostside/VpnTest.java index 12fe625370b..9635b28031e 100755 --- a/hostsidetests/net/app/src/com/android/cts/net/hostside/VpnTest.java +++ b/hostsidetests/net/app/src/com/android/cts/net/hostside/VpnTest.java @@ -29,6 +29,7 @@ import android.net.NetworkRequest; import android.net.VpnService; import android.os.ParcelFileDescriptor; import android.os.Process; +import android.os.SystemProperties; import android.support.test.uiautomator.UiDevice; import android.support.test.uiautomator.UiObject; import android.support.test.uiautomator.UiObjectNotFoundException; @@ -525,6 +526,14 @@ public class VpnTest extends InstrumentationTestCase { public void testDefault() throws Exception { if (!supportedHardware()) return; + // If adb TCP port opened, this test may running by adb over network. + // All of socket would be destroyed in this test. So this test don't + // support adb over network, see b/119382723. + if (SystemProperties.getInt("persist.adb.tcp.port", -1) > -1 + || SystemProperties.getInt("service.adb.tcp.port", -1) > -1) { + Log.i(TAG, "adb is running over the network, so skip this test"); + return; + } FileDescriptor fd = openSocketFdInOtherApp(TEST_HOST, 80, TIMEOUT_MS); @@ -542,6 +551,7 @@ public class VpnTest extends InstrumentationTestCase { FileDescriptor fd = openSocketFdInOtherApp(TEST_HOST, 80, TIMEOUT_MS); + // Shell app must not be put in here or it would kill the ADB-over-network use case String allowedApps = mRemoteSocketFactoryClient.getPackageName() + "," + mPackageName; startVpn(new String[] {"192.0.2.2/32", "2001:db8:1:2::ffe/128"}, new String[] {"192.0.2.0/24", "2001:db8::/32"}, @@ -559,6 +569,12 @@ public class VpnTest extends InstrumentationTestCase { FileDescriptor remoteFd = openSocketFdInOtherApp(TEST_HOST, 80, TIMEOUT_MS); String disallowedApps = mRemoteSocketFactoryClient.getPackageName() + "," + mPackageName; + // If adb TCP port opened, this test may running by adb over TCP. + // Add com.android.shell appllication into blacklist to exclude adb socket for VPN test, + // see b/119382723. + // Note: The test don't support running adb over network for root device + disallowedApps = disallowedApps + ",com.android.shell"; + Log.i(TAG, "Append shell app to disallowedApps: " + disallowedApps); startVpn(new String[] {"192.0.2.2/32", "2001:db8:1:2::ffe/128"}, new String[] {"192.0.2.0/24", "2001:db8::/32"}, "", disallowedApps); diff --git a/tests/tests/net/jni/NativeMultinetworkJni.c b/tests/tests/net/jni/NativeMultinetworkJni.c index ad56b510c32..4531f822eb9 100644 --- a/tests/tests/net/jni/NativeMultinetworkJni.c +++ b/tests/tests/net/jni/NativeMultinetworkJni.c @@ -177,13 +177,17 @@ JNIEXPORT jint Java_android_net_cts_MultinetworkApiTest_runDatagramCheck( setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &timeo, sizeof(timeo)); // For reference see: - // https://tools.ietf.org/html/draft-tsvwg-quic-protocol-01#section-6.1 - uint8_t quic_packet[] = { - 0x0c, // public flags: 64bit conn ID, 8bit sequence number + // https://tools.ietf.org/html/draft-tsvwg-quic-protocol#section-6.1 + uint8_t quic_packet[1200] = { + 0x0d, // public flags: + // - version present (0x01), + // - 64bit connection ID (0x0c), + // - 1 byte packet number (0x00) 0, 0, 0, 0, 0, 0, 0, 0, // 64bit connection ID - 0x01, // sequence number + 0xaa, 0xda, 0xca, 0xaa, // reserved-space version number + 1, // 1 byte packet number 0x00, // private flags - 0x07, // type: regular frame type "PING" + 0x07, // PING frame (cuz why not) }; arc4random_buf(quic_packet + 1, 8); // random connection ID @@ -211,7 +215,7 @@ JNIEXPORT jint Java_android_net_cts_MultinetworkApiTest_runDatagramCheck( i + 1, MAX_RETRIES, rcvd, errnum); } } - if (rcvd < sent) { + if (rcvd < 9) { ALOGD("QUIC UDP %s: sent=%zd but rcvd=%zd, errno=%d", kPort, sent, rcvd, errnum); if (rcvd <= 0) { ALOGD("Does this network block UDP port %s?", kPort); @@ -227,8 +231,7 @@ JNIEXPORT jint Java_android_net_cts_MultinetworkApiTest_runDatagramCheck( return -EPROTO; } - // TODO: log, and compare to the IP address encoded in the - // response, since this should be a public reset packet. + // TODO: Replace this quick 'n' dirty test with proper QUIC-capable code. close(fd); return 0; diff --git a/tests/tests/text/src/android/text/format/cts/TimeTest.java b/tests/tests/text/src/android/text/format/cts/TimeTest.java index f4f444c409b..1a590a5f784 100644 --- a/tests/tests/text/src/android/text/format/cts/TimeTest.java +++ b/tests/tests/text/src/android/text/format/cts/TimeTest.java @@ -2717,6 +2717,12 @@ public class TimeTest extends AndroidTestCase { Fields.assertTimeEquals(expected, t); } + public void test_bug118835133() { + Time t = new Time("Asia/Singapore"); + Fields.set(t, 2018, 9, 30, 12, 48, 32, 0 /* isDst */, 0, 0, 0); + // With http://b/118835133 toMillis() returns -1. + assertEquals(1540874912000L, t.toMillis(true /* ignoreDst */)); + } private static void assertNormalizeResult(boolean normalizeArgument, Time toNormalize, Time expectedTime, long expectedTimeMillis) { long actualTimeMillis = toNormalize.normalize(normalizeArgument /* ignore isDst */); diff --git a/tests/tests/webkit/src/android/webkit/cts/ServiceWorkerClientTest.java b/tests/tests/webkit/src/android/webkit/cts/ServiceWorkerClientTest.java index a77d648f069..9a703ebe5c3 100644 --- a/tests/tests/webkit/src/android/webkit/cts/ServiceWorkerClientTest.java +++ b/tests/tests/webkit/src/android/webkit/cts/ServiceWorkerClientTest.java @@ -55,13 +55,22 @@ public class ServiceWorkerClientTest extends ActivityInstrumentationTestCase2<We + " <script>\n" + " navigator.serviceWorker.register('sw.js').then(function(reg) {\n" + " " + JS_INTERFACE_NAME + ".registrationSuccess();\n" - + " }).catch(function(err) { \n" + + " }).catch(function(err) {\n" + " console.error(err);\n" + " });\n" + " </script>\n" + " </body>\n" + "</html>\n"; private static final String SW_RAW_HTML = "fetch('fetch.html');"; + private static final String SW_UNREGISTER_RAW_JS = + "navigator.serviceWorker.getRegistration().then(function(r) {" + + " r.unregister().then(function(success) {" + + " if (success) " + JS_INTERFACE_NAME + ".unregisterSuccess();" + + " else console.error('unregister() was not successful');" + + " });" + + "}).catch(function(err) {" + + " console.error(err);" + + "});"; private JavascriptStatusReceiver mJavascriptStatusReceiver; private WebViewOnUiThread mOnUiThread; @@ -165,17 +174,34 @@ public class ServiceWorkerClientTest extends ActivityInstrumentationTestCase2<We assertEquals(2, requests.size()); assertEquals(SW_URL, requests.get(0).getUrl().toString()); assertEquals(FETCH_URL, requests.get(1).getUrl().toString()); + + // Clean-up, make sure to unregister the Service Worker. + mOnUiThread.evaluateJavascript(SW_UNREGISTER_RAW_JS, null); + Callable<Boolean> unregisterSuccess = new Callable<Boolean>() { + @Override + public Boolean call() { + return mJavascriptStatusReceiver.mUnregisterSuccess; + } + }; + PollingCheck.check("JS could not unregister Service Worker", POLLING_TIMEOUT, + unregisterSuccess); } // Object added to the page via AddJavascriptInterface() that is used by the test Javascript to // notify back to Java if the Service Worker registration was successful. public final static class JavascriptStatusReceiver { public volatile boolean mRegistrationSuccess = false; + public volatile boolean mUnregisterSuccess = false; @JavascriptInterface public void registrationSuccess() { mRegistrationSuccess = true; } + + @JavascriptInterface + public void unregisterSuccess() { + mUnregisterSuccess = true; + } } } diff --git a/tools/cts-tradefed/Android.mk b/tools/cts-tradefed/Android.mk index 47caabec7b2..ad62c7b36f2 100644 --- a/tools/cts-tradefed/Android.mk +++ b/tools/cts-tradefed/Android.mk @@ -25,7 +25,7 @@ LOCAL_SUITE_BUILD_NUMBER := $(BUILD_NUMBER_FROM_FILE) LOCAL_SUITE_TARGET_ARCH := $(TARGET_ARCH) LOCAL_SUITE_NAME := CTS LOCAL_SUITE_FULLNAME := "Compatibility Test Suite" -LOCAL_SUITE_VERSION := 7.0_r32 +LOCAL_SUITE_VERSION := 7.0_r33 LOCAL_MODULE := cts-tradefed |