• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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.statusbar.pipeline.mobile.data.model
18 
19 import android.net.NetworkCapabilities
20 import com.android.systemui.log.table.Diffable
21 import com.android.systemui.log.table.TableRowLogger
22 
23 /** Provides information about a mobile network connection */
24 data class MobileConnectivityModel(
25     /** Whether mobile is the connected transport see [NetworkCapabilities.TRANSPORT_CELLULAR] */
26     val isConnected: Boolean = false,
27     /** Whether the mobile transport is validated [NetworkCapabilities.NET_CAPABILITY_VALIDATED] */
28     val isValidated: Boolean = false,
29 ) : Diffable<MobileConnectivityModel> {
30     // TODO(b/267767715): Can we implement [logDiffs] and [logFull] generically for data classes?
logDiffsnull31     override fun logDiffs(prevVal: MobileConnectivityModel, row: TableRowLogger) {
32         if (prevVal.isConnected != isConnected) {
33             row.logChange(COL_IS_CONNECTED, isConnected)
34         }
35         if (prevVal.isValidated != isValidated) {
36             row.logChange(COL_IS_VALIDATED, isValidated)
37         }
38     }
39 
logFullnull40     override fun logFull(row: TableRowLogger) {
41         row.logChange(COL_IS_CONNECTED, isConnected)
42         row.logChange(COL_IS_VALIDATED, isValidated)
43     }
44 
45     companion object {
46         private const val COL_IS_CONNECTED = "isConnected"
47         private const val COL_IS_VALIDATED = "isValidated"
48     }
49 }
50