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

Commit c1a02736 authored by Evan Laird's avatar Evan Laird
Browse files

[Satellite] Initial data and domain layers for OEM satellite

Add DeviceBasedSatelliteRepository and DeviceBasedSatelliteInteractor,
which define our data model for device-based (OEM) satellite UI.

Note that there is no callback for determining satellite availability,
and we use a polling method, defaulting to checks every hour while calls
are unavailable.

This change also introduces a MobileIconsInteractor.icons flow, which
allows us to make decisions across the aggregate of all mobile
connections.

Test: DeviceBasedSatelliteRepositoryImplTest
Test: DeviceBasedSatelliteInteractorTest
Bug: 311417356
Flag: ACONFIG com.android.internal.telephony.flags.oem_enabled_satellite_flag DEVELOPMENT

Change-Id: Ia4b79ae0bd05525df76d9dc0179e74a57298b740
parent 38fa3c93
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -68,6 +68,8 @@ class FakeMobileIconsInteractor(

    override val isSingleCarrier = MutableStateFlow(true)

    override val icons: MutableStateFlow<List<MobileIconInteractor>> = MutableStateFlow(emptyList())

    private val _defaultMobileIconMapping = MutableStateFlow(TEST_MAPPING)
    override val defaultMobileIconMapping = _defaultMobileIconMapping

@@ -80,8 +82,12 @@ class FakeMobileIconsInteractor(
    override val isForceHidden = MutableStateFlow(false)

    /** Always returns a new fake interactor */
    override fun getMobileConnectionInteractorForSubId(subId: Int): MobileIconInteractor {
        return FakeMobileIconInteractor(tableLogBuffer).also { interactorCache[subId] = it }
    override fun getMobileConnectionInteractorForSubId(subId: Int): FakeMobileIconInteractor {
        return FakeMobileIconInteractor(tableLogBuffer).also {
            interactorCache[subId] = it
            // Also update the icons
            icons.value = interactorCache.values.toList()
        }
    }

    /**
+7 −0
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ import android.telecom.TelecomManager;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.satellite.SatelliteManager;
import android.view.Choreographer;
import android.view.CrossWindowBlurListeners;
import android.view.IWindowManager;
@@ -712,4 +713,10 @@ public class FrameworkServicesModule {
                ServiceManager.getService(Context.URI_GRANTS_SERVICE)
        );
    }

    @Provides
    @Singleton
    static Optional<SatelliteManager> provideSatelliteManager(Context context) {
        return Optional.ofNullable(context.getSystemService(SatelliteManager.class));
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ import com.android.systemui.statusbar.pipeline.mobile.util.MobileMappingsProxy
import com.android.systemui.statusbar.pipeline.mobile.util.MobileMappingsProxyImpl
import com.android.systemui.statusbar.pipeline.mobile.util.SubscriptionManagerProxy
import com.android.systemui.statusbar.pipeline.mobile.util.SubscriptionManagerProxyImpl
import com.android.systemui.statusbar.pipeline.satellite.data.DeviceBasedSatelliteRepository
import com.android.systemui.statusbar.pipeline.satellite.data.prod.DeviceBasedSatelliteRepositoryImpl
import com.android.systemui.statusbar.pipeline.shared.data.repository.ConnectivityRepository
import com.android.systemui.statusbar.pipeline.shared.data.repository.ConnectivityRepositoryImpl
import com.android.systemui.statusbar.pipeline.shared.ui.binder.CollapsedStatusBarViewBinder
@@ -83,6 +85,11 @@ abstract class StatusBarPipelineModule {
    @Binds
    abstract fun connectivityRepository(impl: ConnectivityRepositoryImpl): ConnectivityRepository

    @Binds
    abstract fun deviceBasedSatelliteRepository(
        impl: DeviceBasedSatelliteRepositoryImpl
    ): DeviceBasedSatelliteRepository

    @Binds abstract fun wifiRepository(impl: WifiRepositorySwitcher): WifiRepository

    @Binds abstract fun wifiInteractor(impl: WifiInteractorImpl): WifiInteractor
+13 −0
Original line number Diff line number Diff line
@@ -71,6 +71,12 @@ interface MobileIconsInteractor {
    /** List of subscriptions, potentially filtered for CBRS */
    val filteredSubscriptions: Flow<List<SubscriptionModel>>

    /**
     * The current list of [MobileIconInteractor]s associated with the current list of
     * [filteredSubscriptions]
     */
    val icons: StateFlow<List<MobileIconInteractor>>

    /** True if the active mobile data subscription has data enabled */
    val activeDataConnectionHasDataEnabled: StateFlow<Boolean>

@@ -259,6 +265,13 @@ constructor(
        }
    }

    override val icons =
        filteredSubscriptions
            .mapLatest { subs ->
                subs.map { getMobileConnectionInteractorForSubId(it.subscriptionId) }
            }
            .stateIn(scope, SharingStarted.WhileSubscribed(), emptyList())

    /**
     * Copied from the old pipeline. We maintain a 2s period of time where we will keep the
     * validated bit from the old active network (A) while data is changing to the new one (B).
+37 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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 com.android.systemui.statusbar.pipeline.satellite.data

import com.android.systemui.statusbar.pipeline.satellite.shared.model.SatelliteConnectionState
import kotlinx.coroutines.flow.Flow

/**
 * Device-based satellite refers to the capability of a device to connect directly to a satellite
 * network. This is in contrast to carrier-based satellite connectivity, which is a property of a
 * given mobile data subscription.
 */
interface DeviceBasedSatelliteRepository {
    /** See [SatelliteConnectionState] for available states */
    val connectionState: Flow<SatelliteConnectionState>

    /** 0-4 level (similar to wifi and mobile) */
    // @IntRange(from = 0, to = 4)
    val signalStrength: Flow<Int>

    /** Clients must observe this property, as device-based satellite is location-dependent */
    val isSatelliteAllowedForCurrentLocation: Flow<Boolean>
}
Loading