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

Commit 1a3a5b53 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[Status Bar] Wifi: Add support for hotspot device types to repo.

This is needed for instant tether.

The device type isn't hooked up to the UI yet because the device type
icon should only be displayed in Quick Settings Internet Tile (not the
status bar) and the Internet Tile isn't yet hooked in to the new
pipeline.

Bug: 265342892
Bug: 293585143
Test: `adb shell am broadcast -a com.android.systemui.demo -e command
network -e wifi show -e hotspot {tablet/laptop/watch/etc}` -> verify
demo repo has hotspot info
Test: atest WifiRepositoryViaTrackerLibTest WifiNetworkModelTest

Change-Id: Ia121ea81717333addd6cf498100c34d3fcae2297
parent 98eb78a6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -374,6 +374,9 @@ object Flags {
    @JvmField val INCOMPATIBLE_CHARGING_BATTERY_ICON =
        unreleasedFlag(614, "incompatible_charging_battery_icon")

    // TODO(b/293585143): Tracking Bug
    val INSTANT_TETHER = unreleasedFlag(615, "instant_tether")

    // 700 - dialer/calls
    // TODO(b/254512734): Tracking Bug
    val ONGOING_CALL_STATUS_BAR_CHIP = releasedFlag(700, "ongoing_call_status_bar_chip")
+17 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import com.android.systemui.demomode.DemoMode.COMMAND_NETWORK
import com.android.systemui.demomode.DemoModeController
import com.android.systemui.statusbar.pipeline.mobile.data.repository.MobileConnectionRepository.Companion.DEFAULT_NUM_LEVELS
import com.android.systemui.statusbar.pipeline.wifi.data.repository.demo.model.FakeWifiEventModel
import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiNetworkModel
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.SharingStarted
@@ -56,12 +57,14 @@ constructor(
        val activity = getString("activity").toActivity()
        val ssid = getString("ssid")
        val validated = getString("fully").toBoolean()
        val hotspotDeviceType = getString("hotspot").toHotspotDeviceType()

        return FakeWifiEventModel.Wifi(
            level = level,
            activity = activity,
            ssid = ssid,
            validated = validated,
            hotspotDeviceType,
        )
    }

@@ -82,6 +85,20 @@ constructor(
            else -> WifiManager.TrafficStateCallback.DATA_ACTIVITY_NONE
        }

    private fun String?.toHotspotDeviceType(): WifiNetworkModel.HotspotDeviceType {
        return when (this) {
            null,
            "none" -> WifiNetworkModel.HotspotDeviceType.NONE
            "unknown" -> WifiNetworkModel.HotspotDeviceType.UNKNOWN
            "phone" -> WifiNetworkModel.HotspotDeviceType.PHONE
            "tablet" -> WifiNetworkModel.HotspotDeviceType.TABLET
            "laptop" -> WifiNetworkModel.HotspotDeviceType.LAPTOP
            "watch" -> WifiNetworkModel.HotspotDeviceType.WATCH
            "auto" -> WifiNetworkModel.HotspotDeviceType.AUTO
            else -> WifiNetworkModel.HotspotDeviceType.INVALID
        }
    }

    companion object {
        const val DEFAULT_CARRIER_MERGED_SUB_ID = 10
    }
+1 −0
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ constructor(
            isValidated = validated ?: true,
            level = level ?: 0,
            ssid = ssid ?: DEMO_NET_SSID,
            hotspotDeviceType = hotspotDeviceType,

            // These fields below aren't supported in demo mode, since they aren't needed to satisfy
            // the interface.
+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.pipeline.wifi.data.repository.demo.model

import android.telephony.Annotation
import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiNetworkModel

/**
 * Model for demo wifi commands, ported from [NetworkControllerImpl]
@@ -29,6 +30,8 @@ sealed interface FakeWifiEventModel {
        @Annotation.DataActivityType val activity: Int,
        val ssid: String?,
        val validated: Boolean?,
        val hotspotDeviceType: WifiNetworkModel.HotspotDeviceType =
            WifiNetworkModel.HotspotDeviceType.NONE,
    ) : FakeWifiEventModel

    data class CarrierMerged(
+2 −0
Original line number Diff line number Diff line
@@ -261,6 +261,8 @@ constructor(
                    isValidated = networkCapabilities.hasCapability(NET_CAPABILITY_VALIDATED),
                    level = wifiManager.calculateSignalLevel(wifiInfo.rssi),
                    wifiInfo.ssid,
                    // This repository doesn't support any hotspot information.
                    WifiNetworkModel.HotspotDeviceType.NONE,
                    wifiInfo.isPasspointAp,
                    wifiInfo.isOsuAp,
                    wifiInfo.passpointProviderFriendlyName
Loading