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 
24 import com.android.settings.core.BasePreferenceController;
25 
26 public class CarrierSettingsVersionPreferenceController extends BasePreferenceController {
27 
28     private int mSubscriptionId;
29     private CarrierConfigManager mManager;
30 
CarrierSettingsVersionPreferenceController(Context context, String preferenceKey)31     public CarrierSettingsVersionPreferenceController(Context context, String preferenceKey) {
32         super(context, preferenceKey);
33         mManager = context.getSystemService(CarrierConfigManager.class);
34         mSubscriptionId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
35     }
36 
init(int subscriptionId)37     public void init(int subscriptionId) {
38         mSubscriptionId = subscriptionId;
39     }
40 
41     @Override
getSummary()42     public CharSequence getSummary() {
43         final PersistableBundle config = mManager.getConfigForSubId(mSubscriptionId);
44         if (config == null) {
45             return null;
46         }
47         return config.getString(CarrierConfigManager.KEY_CARRIER_CONFIG_VERSION_STRING);
48     }
49 
50     @Override
getAvailabilityStatus()51     public int getAvailabilityStatus() {
52         return AVAILABLE;
53     }
54 }
55