summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/cts/safetycenter/src/android/safetycenter/cts/testing/SafetyCenterEnabledChangedReceiver.kt4
-rw-r--r--tests/cts/safetycenter/src/android/safetycenter/cts/testing/SafetySourceReceiver.kt6
-rw-r--r--tests/cts/safetycenter/src/android/safetycenter/cts/testing/WaitForBroadcastIdle.kt32
3 files changed, 5 insertions, 37 deletions
diff --git a/tests/cts/safetycenter/src/android/safetycenter/cts/testing/SafetyCenterEnabledChangedReceiver.kt b/tests/cts/safetycenter/src/android/safetycenter/cts/testing/SafetyCenterEnabledChangedReceiver.kt
index 6f35e7355..789e6cc67 100644
--- a/tests/cts/safetycenter/src/android/safetycenter/cts/testing/SafetyCenterEnabledChangedReceiver.kt
+++ b/tests/cts/safetycenter/src/android/safetycenter/cts/testing/SafetyCenterEnabledChangedReceiver.kt
@@ -25,7 +25,7 @@ import android.safetycenter.SafetyCenterManager.ACTION_SAFETY_CENTER_ENABLED_CHA
import android.safetycenter.cts.testing.Coroutines.TIMEOUT_LONG
import android.safetycenter.cts.testing.Coroutines.runBlockingWithTimeout
import android.safetycenter.cts.testing.ShellPermissions.callWithShellPermissionIdentity
-import android.safetycenter.cts.testing.WaitForBroadcastIdle.waitForBroadcastIdle
+import com.android.compatibility.common.util.SystemUtil
import java.time.Duration
/** Broadcast receiver used for testing broadcasts sent when the SafetyCenter flag changes. */
@@ -63,7 +63,7 @@ class SafetyCenterEnabledChangedReceiver(private val context: Context) : Broadca
): Boolean {
SafetyCenterFlags.isEnabled = value
if (timeout < TIMEOUT_LONG) {
- context.waitForBroadcastIdle()
+ SystemUtil.waitForBroadcasts()
}
return receiveSafetyCenterEnabledChanged(timeout)
}
diff --git a/tests/cts/safetycenter/src/android/safetycenter/cts/testing/SafetySourceReceiver.kt b/tests/cts/safetycenter/src/android/safetycenter/cts/testing/SafetySourceReceiver.kt
index a034ab38a..f0afcf3fc 100644
--- a/tests/cts/safetycenter/src/android/safetycenter/cts/testing/SafetySourceReceiver.kt
+++ b/tests/cts/safetycenter/src/android/safetycenter/cts/testing/SafetySourceReceiver.kt
@@ -37,8 +37,8 @@ import android.safetycenter.cts.testing.SafetyCenterApisWithShellPermissions.ref
import android.safetycenter.cts.testing.SafetySourceIntentHandler.Request
import android.safetycenter.cts.testing.SafetySourceIntentHandler.Response
import android.safetycenter.cts.testing.ShellPermissions.callWithShellPermissionIdentity
-import android.safetycenter.cts.testing.WaitForBroadcastIdle.waitForBroadcastIdle
import androidx.test.core.app.ApplicationProvider
+import com.android.compatibility.common.util.SystemUtil
import java.time.Duration
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -163,7 +163,7 @@ class SafetySourceReceiver : BroadcastReceiver() {
): String {
refreshSafetySourcesWithPermission(refreshReason, safetySourceIds)
if (timeout < TIMEOUT_LONG) {
- getApplicationContext().waitForBroadcastIdle()
+ SystemUtil.waitForBroadcasts()
}
return receiveRefreshSafetySources(timeout)
}
@@ -182,7 +182,7 @@ class SafetySourceReceiver : BroadcastReceiver() {
): Boolean {
SafetyCenterFlags.isEnabled = value
if (timeout < TIMEOUT_LONG) {
- getApplicationContext().waitForBroadcastIdle()
+ SystemUtil.waitForBroadcasts()
}
return receiveSafetyCenterEnabledChanged(timeout)
}
diff --git a/tests/cts/safetycenter/src/android/safetycenter/cts/testing/WaitForBroadcastIdle.kt b/tests/cts/safetycenter/src/android/safetycenter/cts/testing/WaitForBroadcastIdle.kt
deleted file mode 100644
index 06d2bccab..000000000
--- a/tests/cts/safetycenter/src/android/safetycenter/cts/testing/WaitForBroadcastIdle.kt
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.safetycenter.cts.testing
-
-import android.Manifest.permission.DUMP
-import android.app.ActivityManager
-import android.content.Context
-import android.safetycenter.cts.testing.ShellPermissions.callWithShellPermissionIdentity
-
-/** A class that allows waiting for the broadcast queue to be idle. */
-object WaitForBroadcastIdle {
-
- /** Waits for the broadcast queue to be idle. */
- fun Context.waitForBroadcastIdle() {
- val activityManager = getSystemService(ActivityManager::class.java)!!
- callWithShellPermissionIdentity(DUMP) { activityManager.waitForBroadcastIdle() }
- }
-}