From 1a2ad39b5562c3f0ae104b00a6abaceeeb115b4f Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Sat, 26 Jan 2019 20:47:06 -0800 Subject: [PATCH] Foreground Service Location tests Create multiple foreground services and make sure the process state reflects which FG service type is running. Also fix an existing test with hardcoded proc state. Bug: 111453223 Test: atest CtsAppTestCases atest CtsHostsideNetworkTests Change-Id: I309083d13452df58f6dc8e7089328acf260a2ed0 --- .../hostside/AbstractRestrictBackgroundNetworkTestCase.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 ec5a877757..c6e80a22a8 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 @@ -92,7 +92,8 @@ abstract class AbstractRestrictBackgroundNetworkTestCase extends Instrumentation private static final String NETWORK_STATUS_SEPARATOR = "\\|"; private static final int SECOND_IN_MS = 1000; static final int NETWORK_TIMEOUT_MS = 15 * SECOND_IN_MS; - private static final int PROCESS_STATE_FOREGROUND_SERVICE = 3; + private static int PROCESS_STATE_FOREGROUND_SERVICE; + private static final int PROCESS_STATE_TOP = 2; private static final String KEY_NETWORK_STATE_OBSERVER = TEST_PKG + ".observer"; @@ -131,6 +132,8 @@ abstract class AbstractRestrictBackgroundNetworkTestCase extends Instrumentation protected void setUp() throws Exception { super.setUp(); + PROCESS_STATE_FOREGROUND_SERVICE = (Integer) ActivityManager.class + .getDeclaredField("PROCESS_STATE_FOREGROUND_SERVICE").get(null); mInstrumentation = getInstrumentation(); mContext = mInstrumentation.getContext(); mCm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);