Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b3b4c2c authored by Evan Laird's avatar Evan Laird
Browse files

[Sat] DeviceBasedSatelliteRepo MIN_UPTIME and logging

1. Changed MIN_UPTIME to 5s instead of 60s. Looks like tests were being
   done before this 1 minute had passed. 60s was likely too conservative
   of a time to wait for checking satellite support. Going with 5s for
   now so we don't _immediately_ start asking the system once we boot
   up.

2. Tweaked the logging a bit, so we will know exactly how long we've
   delayed for, and added a missing log field name to the check for
   satellite available for location.

Test: DeviceBasedSatelliteInteractorTest
Test: manual via logcat
Bug: 322203863
Flag: ACONFIG com.android.internal.telephony.flags.oem_enabled_satellite_flag DEVELOPMENT
Change-Id: I6f093581f062d442d63b5d7a3eb469006867039f
parent e3b7288b
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -153,7 +153,14 @@ constructor(
        if (satelliteManager != null) {
            // First, check that satellite is supported on this device
            scope.launch {
                ensureMinUptime(systemClock, MIN_UPTIME)
                val waitTime = ensureMinUptime(systemClock, MIN_UPTIME)
                if (waitTime > 0) {
                    logBuffer.i({ long1 = waitTime }) {
                        "Waiting $long1 ms before checking for satellite support"
                    }
                    delay(waitTime)
                }

                satelliteSupport.value = satelliteManager.checkSatelliteSupported()

                logBuffer.i(
@@ -260,7 +267,7 @@ constructor(
                    }

                    override fun onResult(allowed: Boolean) {
                        logBuffer.i { allowed.toString() }
                        logBuffer.i { "isSatelliteAllowedForCurrentLocation: $allowed" }
                        isSatelliteAllowedForCurrentLocation.value = allowed
                    }
                }
@@ -309,19 +316,14 @@ constructor(
        // TTL for satellite polling is one hour
        const val POLLING_INTERVAL_MS: Long = 1000 * 60 * 60

        // Let the system boot up and stabilize before we check for system support
        const val MIN_UPTIME: Long = 1000 * 60
        // Let the system boot up (5s) and stabilize before we check for system support
        const val MIN_UPTIME: Long = 1000 * 5

        private const val TAG = "DeviceBasedSatelliteRepo"

        /** If our process hasn't been up for at least MIN_UPTIME, delay until we reach that time */
        private suspend fun ensureMinUptime(clock: SystemClock, uptime: Long) {
            val timeTilMinUptime =
        /** Calculates how long we have to wait to reach MIN_UPTIME */
        private fun ensureMinUptime(clock: SystemClock, uptime: Long): Long =
            uptime - (clock.uptimeMillis() - android.os.Process.getStartUptimeMillis())
            if (timeTilMinUptime > 0) {
                delay(timeTilMinUptime)
            }
        }

        /** A couple of convenience logging methods rather than a whole class */
        private fun LogBuffer.i(