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.settings.network.telephony; 18 19 import android.content.Context; 20 import android.text.TextUtils; 21 22 import androidx.annotation.VisibleForTesting; 23 import androidx.preference.Preference; 24 import androidx.preference.PreferenceScreen; 25 26 import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity; 27 28 public class TransferEsimPreferenceController extends TelephonyBasePreferenceController { 29 30 private Preference mPreference; 31 private SubscriptionInfoEntity mSubscriptionInfoEntity; 32 TransferEsimPreferenceController(Context context, String key)33 public TransferEsimPreferenceController(Context context, String key) { 34 super(context, key); 35 } 36 init(int subId, SubscriptionInfoEntity subInfoEntity)37 public void init(int subId, SubscriptionInfoEntity subInfoEntity) { 38 mSubId = subId; 39 mSubscriptionInfoEntity = subInfoEntity; 40 } 41 42 @Override displayPreference(PreferenceScreen screen)43 public void displayPreference(PreferenceScreen screen) { 44 super.displayPreference(screen); 45 mPreference = screen.findPreference(getPreferenceKey()); 46 } 47 48 @Override getAvailabilityStatus(int subId)49 public int getAvailabilityStatus(int subId) { 50 return CONDITIONALLY_UNAVAILABLE; 51 // TODO(b/262195754): Need the intent to enabled the feature. 52 // return mSubscriptionInfoEntity != null && mSubscriptionInfoEntity.isActiveSubscriptionId 53 // && mSubscriptionInfoEntity.isEmbedded ? AVAILABLE 54 // : CONDITIONALLY_UNAVAILABLE; 55 } 56 57 @Override handlePreferenceTreeClick(Preference preference)58 public boolean handlePreferenceTreeClick(Preference preference) { 59 if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) { 60 return false; 61 } 62 // Send intent to launch LPA 63 return true; 64 } 65 66 @VisibleForTesting setSubscriptionInfoEntity(SubscriptionInfoEntity subscriptionInfoEntity)67 public void setSubscriptionInfoEntity(SubscriptionInfoEntity subscriptionInfoEntity) { 68 mSubscriptionInfoEntity = subscriptionInfoEntity; 69 } 70 } 71