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.telephony.SubscriptionManager; 21 22 import androidx.lifecycle.LifecycleOwner; 23 24 import com.android.settingslib.core.lifecycle.Lifecycle; 25 import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity; 26 27 public class CallsDefaultSubscriptionController extends DefaultSubscriptionController { 28 CallsDefaultSubscriptionController(Context context, String preferenceKey, Lifecycle lifecycle, LifecycleOwner lifecycleOwner)29 public CallsDefaultSubscriptionController(Context context, String preferenceKey, 30 Lifecycle lifecycle, LifecycleOwner lifecycleOwner) { 31 super(context, preferenceKey, lifecycle, lifecycleOwner); 32 } 33 CallsDefaultSubscriptionController(Context context, String preferenceKey)34 public CallsDefaultSubscriptionController(Context context, String preferenceKey) { 35 super(context, preferenceKey); 36 } 37 38 @Override getDefaultSubscriptionId()39 protected int getDefaultSubscriptionId() { 40 int defaultCallSubId = SubscriptionManager.getDefaultVoiceSubscriptionId(); 41 for (SubscriptionInfoEntity subInfo : mSubInfoEntityList) { 42 int subId = subInfo.getSubId(); 43 if (subInfo.isActiveSubscriptionId && subId == defaultCallSubId) { 44 return subId; 45 } 46 } 47 return SubscriptionManager.INVALID_SUBSCRIPTION_ID; 48 } 49 50 @Override setDefaultSubscription(int subscriptionId)51 protected void setDefaultSubscription(int subscriptionId) { 52 mManager.setDefaultVoiceSubscriptionId(subscriptionId); 53 } 54 55 @Override getSummary()56 public CharSequence getSummary() { 57 return MobileNetworkUtils.getPreferredStatus(isRtlMode(), mContext, true, 58 mSubInfoEntityList); 59 } 60 } 61