Merge "CtsHostsideNetworkTests: Add more logging when the test fails." into oc-mr1-dev am: 26e6bf91be
am: 09bab7b5c3
Change-Id: Ia1f48086e6e32923458778f187c7f8c9dfaf34ca
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 aadf239..caf25ce 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
@@ -143,6 +143,7 @@
Log.i(TAG, "Apps status on " + getName() + ":\n"
+ "\ttest app: uid=" + mMyUid + ", state=" + getProcessStateByUid(mMyUid) + "\n"
+ "\tapp2: uid=" + mUid + ", state=" + getProcessStateByUid(mUid));
+ executeShellCommand("settings get global app_idle_constants");
}
@Override
@@ -390,6 +391,8 @@
timeoutMs = Math.min(timeoutMs*2, NETWORK_TIMEOUT_MS);
}
dumpAllNetworkRules();
+ Log.d(TAG, "Usagestats dump: " + getUsageStatsDump());
+ executeShellCommand("settings get global app_idle_constants");
fail("Invalid state for expectAvailable=" + expectAvailable + " after " + maxTries
+ " attempts.\nLast error: " + error);
}
@@ -867,16 +870,8 @@
protected void setAppIdle(boolean enabled) throws Exception {
Log.i(TAG, "Setting app idle to " + enabled);
- final String beforeStats = getUsageStatsDump();
executeSilentShellCommand("am set-inactive " + TEST_APP2_PKG + " " + enabled );
- try {
- assertAppIdle(enabled); // Sanity check
- } catch (Throwable e) {
- final String afterStats = getUsageStatsDump();
- Log.d(TAG, "UsageStats before:\n" + beforeStats);
- Log.d(TAG, "UsageStats after:\n" + afterStats);
- throw e;
- }
+ assertAppIdle(enabled); // Sanity check
}
private String getUsageStatsDump() throws Exception {
@@ -891,7 +886,7 @@
&& !str.contains(TEST_PKG) && !str.contains(TEST_APP2_PKG)) {
continue;
}
- if (str.contains("config=")) {
+ if (str.trim().startsWith("config=") || str.trim().startsWith("time=")) {
continue;
}
sb.append(str).append('\n');
@@ -900,7 +895,13 @@
}
protected void assertAppIdle(boolean enabled) throws Exception {
- assertDelayedShellCommand("am get-inactive " + TEST_APP2_PKG, 15, 2, "Idle=" + enabled);
+ try {
+ assertDelayedShellCommand("am get-inactive " + TEST_APP2_PKG, 15, 2, "Idle=" + enabled);
+ } catch (Throwable e) {
+ Log.d(TAG, "UsageStats dump:\n" + getUsageStatsDump());
+ executeShellCommand("settings get global app_idle_constants");
+ throw e;
+ }
}
/**