Merge "Add more assertions related to LocalServerSocket.accept()" am: 863ff4a2cb
am: a0c574dcc7
Change-Id: I90164b0ee1b7301fd4f99c530fd6f7159aba780c
diff --git a/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java b/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
index b4d7d9d..cbd8fea 100644
--- a/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
+++ b/tests/cts/hostside/app/src/com/android/cts/net/hostside/AbstractRestrictBackgroundNetworkTestCase.java
@@ -29,6 +29,7 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.DetailedState;
@@ -99,6 +100,8 @@
protected WifiManager mWfm;
protected int mUid;
private String mMeteredWifi;
+ private boolean mHasWatch;
+ private String mDeviceIdleConstantsSetting;
@Override
protected void setUp() throws Exception {
@@ -110,7 +113,13 @@
mWfm = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
mUid = getUid(TEST_APP2_PKG);
final int myUid = getUid(mContext.getPackageName());
-
+ mHasWatch = mContext.getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_WATCH);
+ if (mHasWatch) {
+ mDeviceIdleConstantsSetting = "device_idle_constants_watch";
+ } else {
+ mDeviceIdleConstantsSetting = "device_idle_constants";
+ }
Log.i(TAG, "Apps status on " + getName() + ":\n"
+ "\ttest app: uid=" + myUid + ", state=" + getProcessStateByUid(myUid) + "\n"
+ "\tapp2: uid=" + mUid + ", state=" + getProcessStateByUid(mUid));
@@ -726,14 +735,14 @@
}
protected void setPendingIntentWhitelistDuration(int durationMs) throws Exception {
- final String command = String.format(
- "settings put global device_idle_constants %s=%d",
- "notification_whitelist_duration", durationMs);
- executeSilentShellCommand(command);
+ executeSilentShellCommand(String.format(
+ "settings put global %s %s=%d", mDeviceIdleConstantsSetting,
+ "notification_whitelist_duration", durationMs));
}
protected void resetDeviceIdleSettings() throws Exception {
- executeShellCommand("settings delete global device_idle_constants");
+ executeShellCommand(String.format("settings delete global %s",
+ mDeviceIdleConstantsSetting));
}
protected void startForegroundService() throws Exception {
diff --git a/tests/cts/hostside/app/src/com/android/cts/net/hostside/PacketReflector.java b/tests/cts/hostside/app/src/com/android/cts/net/hostside/PacketReflector.java
index dd0f792..a4a2956 100644
--- a/tests/cts/hostside/app/src/com/android/cts/net/hostside/PacketReflector.java
+++ b/tests/cts/hostside/app/src/com/android/cts/net/hostside/PacketReflector.java
@@ -151,6 +151,15 @@
request[hdrLen] = buf[hdrLen]; // Type.
request[hdrLen + 2] = buf[hdrLen + 2]; // Checksum byte 1.
request[hdrLen + 3] = buf[hdrLen + 3]; // Checksum byte 2.
+
+ // Since Linux kernel 4.2, net.ipv6.auto_flowlabels is set by default, and therefore
+ // the request and reply may have different IPv6 flow label: ignore that as well.
+ if (version == 6) {
+ request[1] = (byte)(request[1] & 0xf0 | buf[1] & 0x0f);
+ request[2] = buf[2];
+ request[3] = buf[3];
+ }
+
for (int i = 0; i < len; i++) {
if (buf[i] != request[i]) {
Log.i(TAG, "Received non-matching packet when expecting ping response.");