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

Commit 5df38498 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[Pod] Move AirplaneModeRepository & impl into a pod.

Bug: 307607958
Flag: EXEMPT refactor
Test: m SystemUI-application
Test: build SystemUIGoogle in studio, verify AirplaneTableLogs are still
logged
Test: atest AirplaneModeRepositoryImplTest (& run that same test via
studio)

Change-Id: I4fb76a3b8423e1c581e958a5793f55900a2f2b09
parent fcbb8081
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ java_library {
        "com.android.systemui.retail-impl",
        "com.android.systemui.retail.data-api",
        "com.android.systemui.retail.domain-api",
        "com.android.systemui.statusbar.pipeline.airplane.data.repository-api",
        "com.android.systemui.statusbar.pipeline.airplane.shared-api",
        "com.android.systemui.util.kotlin",
        "com.android.systemui.util.settings-api",
@@ -88,6 +89,7 @@ java_library {
    static_libs: [
        "com.android.systemui.pods-api-aosp-handheld",
        "com.android.systemui.retail-impl",
        "com.android.systemui.statusbar.pipeline.airplane.data.repository-impl",
        "com.android.systemui.statusbar.pipeline.airplane.shared-impl",
        "com.android.systemui.util.time-impl",
    ],
+3 −3
Original line number Diff line number Diff line
@@ -19,10 +19,10 @@ package com.android.systemui.statusbar.pipeline.airplane.data.repository
import kotlinx.coroutines.flow.StateFlow

/** Provides data related to airplane mode. */
interface AirplaneModeRepository {
public interface AirplaneModeRepository {
    /** Observable for whether the device is currently in airplane mode. */
    val isAirplaneMode: StateFlow<Boolean>
    public val isAirplaneMode: StateFlow<Boolean>

    /** Sets airplane mode state. */
    suspend fun setIsAirplaneMode(isEnabled: Boolean)
    public suspend fun setIsAirplaneMode(isEnabled: Boolean)
}
+54 −0
Original line number Diff line number Diff line
//
// Copyright (C) 2025 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 {
    default_applicable_licenses: ["frameworks_base_packages_SystemUI_license"],
}

java_library {
    name: "com.android.systemui.statusbar.pipeline.airplane.data.repository-api",
    srcs: [
        "*.kt",
    ],
    static_libs: [
        "kotlinx_coroutines",
    ],
    defaults: [
        "SystemUI_pod_defaults_api",
    ],
}

java_library {
    name: "com.android.systemui.statusbar.pipeline.airplane.data.repository-impl",
    srcs: [
        "impl/*.kt",
    ],
    libs: [
        "com.android.systemui.dagger-api",
        "com.android.systemui.log.table-api",
        "com.android.systemui.statusbar.pipeline.airplane.shared-api",
        "com.android.systemui.util.kotlin",
        "com.android.systemui.util.settings-api",
        "dagger2",
        "kotlinx_coroutines",
    ],
    static_libs: [
        "com.android.systemui.statusbar.pipeline.airplane.data.repository-api",
    ],
    defaults: [
        "SystemUI_pod_defaults_impl",
    ],
}
+5 −4
Original line number Diff line number Diff line
@@ -14,13 +14,14 @@
 * limitations under the License.
 */

package com.android.systemui.statusbar.pipeline.airplane.data.repository
package com.android.systemui.statusbar.pipeline.airplane.data.repository.impl

import com.android.systemui.statusbar.pipeline.airplane.data.repository.impl.AirplaneModeRepositoryImpl
import com.android.systemui.statusbar.pipeline.airplane.data.repository.AirplaneModeRepository
import dagger.Binds
import dagger.Module

@Module
interface AirplaneModeDataLayerModule {
    @Binds fun airplaneModeRepository(impl: AirplaneModeRepositoryImpl): AirplaneModeRepository
public interface AirplaneModeDataLayerModule {
    @Binds
    public fun airplaneModeRepository(impl: AirplaneModeRepositoryImpl): AirplaneModeRepository
}
+4 −3
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ import kotlinx.coroutines.withContext

@SysUISingleton
@Suppress("EXPERIMENTAL_IS_NOT_ENABLED")
class AirplaneModeRepositoryImpl
public class AirplaneModeRepositoryImpl
@Inject
constructor(
    private val connectivityManager: ConnectivityManager,
@@ -51,7 +51,7 @@ constructor(
    @Background scope: CoroutineScope,
) : AirplaneModeRepository {
    // TODO(b/254848912): Replace this with a generic SettingObserver coroutine once we have it.
    override val isAirplaneMode: StateFlow<Boolean> =
    public override val isAirplaneMode: StateFlow<Boolean> =
        conflatedCallbackFlow {
                val observer =
                    object : SettingObserver(globalSettings, bgHandler, Global.AIRPLANE_MODE_ON) {
@@ -74,6 +74,7 @@ constructor(
                initialValue = false,
            )

    override suspend fun setIsAirplaneMode(isEnabled: Boolean) =
    public override suspend fun setIsAirplaneMode(isEnabled: Boolean) {
        withContext(backgroundContext) { connectivityManager.setAirplaneMode(isEnabled) }
    }
}
Loading