From c017d9adf33ee239845bdd59918a21bc7ee3770a Mon Sep 17 00:00:00 2001 From: Sudheer Shanka Date: Mon, 14 Jun 2021 18:58:27 +0000 Subject: [PATCH] Avoid waiting unnecessarily if there is no data to return. Bug: 189790442 Test: atest ./tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java Change-Id: I091991aac8eb11319bd60dc8f07124ace1ad52f1 Merged-In: I091991aac8eb11319bd60dc8f07124ace1ad52f1 --- .../hostside/AbstractRestrictBackgroundNetworkTestCase.java | 4 ++++ 1 file changed, 4 insertions(+) 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 f9454ad052..5b95eea332 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 @@ -126,6 +126,8 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase { private static final String KEY_NETWORK_STATE_OBSERVER = TEST_PKG + ".observer"; private static final String KEY_SKIP_VALIDATION_CHECKS = TEST_PKG + ".skip_validation_checks"; + private static final String EMPTY_STRING = ""; + protected static final int TYPE_COMPONENT_ACTIVTIY = 0; protected static final int TYPE_COMPONENT_FOREGROUND_SERVICE = 1; protected static final int TYPE_EXPEDITED_JOB = 2; @@ -229,6 +231,8 @@ public abstract class AbstractRestrictBackgroundNetworkTestCase { final String resultData = getResultData(); if (resultData == null) { Log.e(TAG, "Received null data from ordered intent"); + // Offer an empty string so that the code waiting for the result can return. + result.offer(EMPTY_STRING); return; } result.offer(resultData);