• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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.telephony;
18 
19 import android.content.Context;
20 import android.os.PersistableBundle;
21 import android.telephony.CarrierConfigManager;
22 import android.telephony.SubscriptionManager;
23 import android.text.TextUtils;
24 
25 import com.android.settings.core.BasePreferenceController;
26 
27 public class CarrierSettingsVersionPreferenceController extends BasePreferenceController {
28 
29     private int mSubscriptionId;
30     private CarrierConfigManager mManager;
31 
CarrierSettingsVersionPreferenceController(Context context, String preferenceKey)32     public CarrierSettingsVersionPreferenceController(Context context, String preferenceKey) {
33         super(context, preferenceKey);
34         mManager = context.getSystemService(CarrierConfigManager.class);
35         mSubscriptionId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
36     }
37 
init(int subscriptionId)38     public void init(int subscriptionId) {
39         mSubscriptionId = subscriptionId;
40     }
41 
42     @Override
getSummary()43     public CharSequence getSummary() {
44         final PersistableBundle config = mManager.getConfigForSubId(mSubscriptionId);
45         if (config == null) {
46             return null;
47         }
48         return config.getString(CarrierConfigManager.KEY_CARRIER_CONFIG_VERSION_STRING);
49     }
50 
51     @Override
getAvailabilityStatus()52     public int getAvailabilityStatus() {
53         return TextUtils.isEmpty(getSummary()) ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
54     }
55 }
56