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

Commit fa69bf1a authored by Evan Laird's avatar Evan Laird Committed by Android (Google) Code Review
Browse files

Merge changes I0f6eafdb,I6f093581 into main

* changes:
  [Sat] Fix check for all mobile connections OOS
  [Sat] DeviceBasedSatelliteRepo MIN_UPTIME and logging
parents 1cb072a3 3d109f63
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(
@@ -259,7 +266,7 @@ constructor(
                    }

                    override fun onResult(allowed: Boolean) {
                        logBuffer.i { allowed.toString() }
                        logBuffer.i { "isSatelliteAllowedForCurrentLocation: $allowed" }
                        isSatelliteAllowedForCurrentLocation.value = allowed
                    }
                }
@@ -308,19 +315,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(
+1 −1
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ constructor(
            } else {
                flowOf(false)
            }
            .stateIn(scope, SharingStarted.WhileSubscribed(), false)
            .stateIn(scope, SharingStarted.WhileSubscribed(), true)
}

/**
+27 −6
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.statusbar.pipeline.satellite.domain.interactor

import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import androidx.test.filters.SmallTest
import com.android.internal.telephony.flags.Flags.FLAG_OEM_ENABLED_SATELLITE_FLAG
import com.android.systemui.SysuiTestCase
@@ -49,8 +51,6 @@ class DeviceBasedSatelliteInteractorTest : SysuiTestCase() {

    @Before
    fun setUp() {
        mSetFlagsRule.enableFlags(FLAG_OEM_ENABLED_SATELLITE_FLAG)

        underTest =
            DeviceBasedSatelliteInteractor(
                repo,
@@ -60,6 +60,7 @@ class DeviceBasedSatelliteInteractorTest : SysuiTestCase() {
    }

    @Test
    @EnableFlags(FLAG_OEM_ENABLED_SATELLITE_FLAG)
    fun isSatelliteAllowed_falseWhenNotAllowed() =
        testScope.runTest {
            val latest by collectLastValue(underTest.isSatelliteAllowed)
@@ -72,6 +73,7 @@ class DeviceBasedSatelliteInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(FLAG_OEM_ENABLED_SATELLITE_FLAG)
    fun isSatelliteAllowed_trueWhenAllowed() =
        testScope.runTest {
            val latest by collectLastValue(underTest.isSatelliteAllowed)
@@ -84,10 +86,10 @@ class DeviceBasedSatelliteInteractorTest : SysuiTestCase() {
        }

    @Test
    @DisableFlags(FLAG_OEM_ENABLED_SATELLITE_FLAG)
    fun isSatelliteAllowed_offWhenFlagIsOff() =
        testScope.runTest {
            // GIVEN feature is disabled
            mSetFlagsRule.disableFlags(FLAG_OEM_ENABLED_SATELLITE_FLAG)

            // Remake the interactor so the flag is read
            underTest =
@@ -107,6 +109,7 @@ class DeviceBasedSatelliteInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(FLAG_OEM_ENABLED_SATELLITE_FLAG)
    fun connectionState_matchesRepositoryValue() =
        testScope.runTest {
            val latest by collectLastValue(underTest.connectionState)
@@ -129,10 +132,10 @@ class DeviceBasedSatelliteInteractorTest : SysuiTestCase() {
        }

    @Test
    @DisableFlags(FLAG_OEM_ENABLED_SATELLITE_FLAG)
    fun connectionState_offWhenFeatureIsDisabled() =
        testScope.runTest {
            // GIVEN the flag is disabled
            mSetFlagsRule.disableFlags(FLAG_OEM_ENABLED_SATELLITE_FLAG)

            // Remake the interactor so the flag is read
            underTest =
@@ -164,6 +167,7 @@ class DeviceBasedSatelliteInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(FLAG_OEM_ENABLED_SATELLITE_FLAG)
    fun signalStrength_matchesRepo() =
        testScope.runTest {
            val latest by collectLastValue(underTest.signalStrength)
@@ -182,10 +186,10 @@ class DeviceBasedSatelliteInteractorTest : SysuiTestCase() {
        }

    @Test
    @DisableFlags(FLAG_OEM_ENABLED_SATELLITE_FLAG)
    fun signalStrength_zeroWhenDisabled() =
        testScope.runTest {
            // GIVEN the flag is enabled
            mSetFlagsRule.disableFlags(FLAG_OEM_ENABLED_SATELLITE_FLAG)

            // Remake the interactor so the flag is read
            underTest =
@@ -212,6 +216,19 @@ class DeviceBasedSatelliteInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(FLAG_OEM_ENABLED_SATELLITE_FLAG)
    fun areAllConnectionsOutOfService_noConnections_yes() =
        testScope.runTest {
            val latest by collectLastValue(underTest.areAllConnectionsOutOfService)

            // GIVEN, 0 connections

            // THEN the value is propagated to this interactor
            assertThat(latest).isTrue()
        }

    @Test
    @EnableFlags(FLAG_OEM_ENABLED_SATELLITE_FLAG)
    fun areAllConnectionsOutOfService_twoConnectionsOos_yes() =
        testScope.runTest {
            val latest by collectLastValue(underTest.areAllConnectionsOutOfService)
@@ -229,6 +246,7 @@ class DeviceBasedSatelliteInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(FLAG_OEM_ENABLED_SATELLITE_FLAG)
    fun areAllConnectionsOutOfService_oneConnectionOos_yes() =
        testScope.runTest {
            val latest by collectLastValue(underTest.areAllConnectionsOutOfService)
@@ -244,6 +262,7 @@ class DeviceBasedSatelliteInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(FLAG_OEM_ENABLED_SATELLITE_FLAG)
    fun areAllConnectionsOutOfService_oneConnectionInService_no() =
        testScope.runTest {
            val latest by collectLastValue(underTest.areAllConnectionsOutOfService)
@@ -259,6 +278,7 @@ class DeviceBasedSatelliteInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(FLAG_OEM_ENABLED_SATELLITE_FLAG)
    fun areAllConnectionsOutOfService_twoConnectionsOneInService_no() =
        testScope.runTest {
            val latest by collectLastValue(underTest.areAllConnectionsOutOfService)
@@ -276,6 +296,7 @@ class DeviceBasedSatelliteInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(FLAG_OEM_ENABLED_SATELLITE_FLAG)
    fun areAllConnectionsOutOfService_twoConnectionsInService_no() =
        testScope.runTest {
            val latest by collectLastValue(underTest.areAllConnectionsOutOfService)
@@ -293,10 +314,10 @@ class DeviceBasedSatelliteInteractorTest : SysuiTestCase() {
        }

    @Test
    @DisableFlags(FLAG_OEM_ENABLED_SATELLITE_FLAG)
    fun areAllConnectionsOutOfService_falseWhenFlagIsOff() =
        testScope.runTest {
            // GIVEN the flag is disabled
            mSetFlagsRule.disableFlags(FLAG_OEM_ENABLED_SATELLITE_FLAG)

            // Remake the interactor so the flag is read
            underTest =