• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.settings.network
18 
19 import android.content.Context
20 import android.text.BidiFormatter
21 import com.android.settings.R
22 import com.android.settings.Utils
23 import com.android.settings.activityembedding.ActivityEmbeddingUtils
24 import com.android.settings.core.BasePreferenceController
25 import com.android.settings.network.telephony.SimRepository
26 
27 class TopLevelNetworkEntryPreferenceController
28 @JvmOverloads
29 constructor(
30     context: Context,
31     preferenceKey: String,
32     private val simRepository: SimRepository = SimRepository(context),
<lambda>null33     private val isDemoUser: () -> Boolean = { Utils.isDemoUser(context) },
<lambda>null34     private val isEmbeddingActivityEnabled: () -> Boolean = {
35         ActivityEmbeddingUtils.isEmbeddingActivityEnabled(context)
36     },
37 ) : BasePreferenceController(context, preferenceKey) {
38 
getAvailabilityStatusnull39     override fun getAvailabilityStatus(): Int {
40         // TODO(b/281597506): Update the ActivityEmbeddingUtils.isEmbeddingActivityEnabled
41         //                    while getting the new API.
42         return if (isDemoUser() && !isEmbeddingActivityEnabled()) {
43             UNSUPPORTED_ON_DEVICE
44         } else {
45             AVAILABLE
46         }
47     }
48 
getSummarynull49     override fun getSummary(): CharSequence {
50         val summaryResId =
51             if (simRepository.showMobileNetworkPageEntrance()) {
52                 R.string.network_dashboard_summary_mobile
53             } else {
54                 R.string.network_dashboard_summary_no_mobile
55             }
56         return BidiFormatter.getInstance().unicodeWrap(mContext.getString(summaryResId))
57     }
58 }
59