1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.systemui.smartspace.ui.viewmodel
18 
19 import com.android.systemui.power.domain.interactor.PowerInteractor
20 import dagger.assisted.Assisted
21 import dagger.assisted.AssistedFactory
22 import dagger.assisted.AssistedInject
23 import kotlinx.coroutines.flow.Flow
24 import kotlinx.coroutines.flow.filter
25 
26 class SmartspaceViewModel
27 @AssistedInject
28 constructor(
29     powerInteractor: PowerInteractor,
30     @Assisted val surfaceName: String,
31 ) {
32 
33     /** Screen on/off state */
34     val isAwake: Flow<Boolean> =
<lambda>null35         powerInteractor.isAwake.filter { surfaceName != SURFACE_WEATHER_VIEW }
36 
37     @AssistedFactory
38     interface Factory {
createnull39         fun create(surfaceName: String): SmartspaceViewModel
40     }
41 
42     companion object {
43         const val SURFACE_DATE_VIEW = "date_view"
44         const val SURFACE_WEATHER_VIEW = "weather_view"
45         const val SURFACE_GENERAL_VIEW = "general_view"
46     }
47 }
48