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

Commit 7cd20ff0 authored by Evan Laird's avatar Evan Laird
Browse files

Revert^2 "[Satellite] DeviceBasedSatelliteBindableIcon"

1cad7854

Original commit message:
[Satellite] DeviceBasedSatelliteBindableIcon

This icon and binder implement the OEM satellite icon view for
status bar.

Also adds try/catch blocks for the registration of the satellite
callbacks, since they throw for nonprovisioned devices.

Test: manual; existing unit tests
Test: DeviceBasedSatelliteRepositoryImplTest
Bug: 311417356
Flag: ACONFIG com.android.internal.telephony.flags.oem_enabled_satellite_flag DEVELOPMENT

Change-Id: I65b12637a74aeee9a910b9cf8b3e7aca899017bc
parent 4b67ed2d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@
        <item><xliff:g id="id">@string/status_bar_screen_record</xliff:g></item>
        <item><xliff:g id="id">@string/status_bar_cast</xliff:g></item>
        <item><xliff:g id="id">@string/status_bar_ethernet</xliff:g></item>
        <item><xliff:g id="id">@string/status_bar_oem_satellite</xliff:g></item>
        <item><xliff:g id="id">@string/status_bar_wifi</xliff:g></item>
        <item><xliff:g id="id">@string/status_bar_hotspot</xliff:g></item>
        <item><xliff:g id="id">@string/status_bar_mobile</xliff:g></item>
@@ -102,6 +103,7 @@
    <string translatable="false" name="status_bar_call_strength">call_strength</string>
    <string translatable="false" name="status_bar_sensors_off">sensors_off</string>
    <string translatable="false" name="status_bar_screen_record">screen_record</string>
    <string translatable="false" name="status_bar_oem_satellite">satellite</string>

    <!-- Flag indicating whether the surface flinger has limited
         alpha compositing functionality in hardware.  If set, the window
+1 −0
Original line number Diff line number Diff line
@@ -3198,6 +3198,7 @@
  <java-symbol type="string" name="status_bar_camera" />
  <java-symbol type="string" name="status_bar_sensors_off" />
  <java-symbol type="string" name="status_bar_screen_record" />
  <java-symbol type="string" name="status_bar_oem_satellite" />

  <!-- Locale picker -->
  <java-symbol type="id" name="locale_search_menu" />
+4 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.pipeline.icons.shared

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.statusbar.pipeline.icons.shared.model.BindableIcon
import com.android.systemui.statusbar.pipeline.satellite.ui.DeviceBasedSatelliteBindableIcon
import javax.inject.Inject

/**
@@ -39,10 +40,11 @@ class BindableIconsRegistryImpl
@Inject
constructor(
    /** Bindables go here */
    oemSatellite: DeviceBasedSatelliteBindableIcon
) : BindableIconsRegistry {
    /**
     * Adding the injected bindables to this list will get them registered with
     * StatusBarIconController
     */
    override val bindableIcons: List<BindableIcon> = listOf()
    override val bindableIcons: List<BindableIcon> = listOf(oemSatellite)
}
+19 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.pipeline.satellite.data.prod
import android.os.OutcomeReceiver
import android.telephony.satellite.NtnSignalStrengthCallback
import android.telephony.satellite.SatelliteManager
import android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_SUCCESS
import android.telephony.satellite.SatelliteModemStateCallback
import androidx.annotation.VisibleForTesting
import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
@@ -188,9 +189,17 @@ constructor(
                    trySend(SatelliteConnectionState.fromModemState(state))
                }

                var registered = false

                try {
                    val res =
                        sm.registerForSatelliteModemStateChanged(bgDispatcher.asExecutor(), cb)
                    registered = res == SATELLITE_RESULT_SUCCESS
                } catch (e: Exception) {
                    // Logging is in next commit
                }

                awaitClose { sm.unregisterForSatelliteModemStateChanged(cb) }
                awaitClose { if (registered) sm.unregisterForSatelliteModemStateChanged(cb) }
            }
            .flowOn(bgDispatcher)

@@ -204,9 +213,15 @@ constructor(
                    trySend(signalStrength.level)
                }

                var registered = false
                try {
                    sm.registerForNtnSignalStrengthChanged(bgDispatcher.asExecutor(), cb)
                    registered = true
                } catch (e: Exception) {
                    // Logging is in next commit
                }

                awaitClose { sm.unregisterForNtnSignalStrengthChanged(cb) }
                awaitClose { if (registered) sm.unregisterForNtnSignalStrengthChanged(cb) }
            }
            .flowOn(bgDispatcher)

+46 −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.ui

import android.content.Context
import com.android.internal.telephony.flags.Flags.oemEnabledSatelliteFlag
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.statusbar.pipeline.icons.shared.model.BindableIcon
import com.android.systemui.statusbar.pipeline.icons.shared.model.ModernStatusBarViewCreator
import com.android.systemui.statusbar.pipeline.satellite.ui.binder.DeviceBasedSatelliteIconBinder
import com.android.systemui.statusbar.pipeline.satellite.ui.viewmodel.DeviceBasedSatelliteViewModel
import com.android.systemui.statusbar.pipeline.shared.ui.view.SingleBindableStatusBarIconView
import javax.inject.Inject

@SysUISingleton
class DeviceBasedSatelliteBindableIcon
@Inject
constructor(
    context: Context,
    viewModel: DeviceBasedSatelliteViewModel,
) : BindableIcon {
    override val slot: String =
        context.getString(com.android.internal.R.string.status_bar_oem_satellite)

    override val initializer = ModernStatusBarViewCreator { context ->
        SingleBindableStatusBarIconView.createView(context).also { view ->
            view.initView(slot) { DeviceBasedSatelliteIconBinder.bind(view, viewModel) }
        }
    }

    override val shouldBindIcon: Boolean = oemEnabledSatelliteFlag()
}
Loading