diff --git a/res/values/strings.xml b/res/values/strings.xml
index eb8f75b4d62..e51910dec00 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -11420,4 +11420,9 @@
Shift gesture detection region above keyboard
+
+ Convert to eSIM
+
+ Transfer eSIM to another device
+
diff --git a/res/xml/mobile_network_settings.xml b/res/xml/mobile_network_settings.xml
index 22434b1ddc2..1ce7d27537b 100644
--- a/res/xml/mobile_network_settings.xml
+++ b/res/xml/mobile_network_settings.xml
@@ -250,6 +250,18 @@
settings:controller="com.android.settings.network.telephony.NrAdvancedCallingPreferenceController"/>
+
+
+
+
mSubscriptionInfoEntityList = new ArrayList<>();
+ private SubscriptionInfoEntity mSubscriptionInfoEntity;
+
+ public ConvertToEsimPreferenceController(Context context, String key, Lifecycle lifecycle,
+ LifecycleOwner lifecycleOwner, int subId) {
+ super(context, key);
+ mSubId = subId;
+ mMobileNetworkRepository = MobileNetworkRepository.createBySubId(context, this, mSubId);
+ mLifecycleOwner = lifecycleOwner;
+ if (lifecycle != null) {
+ lifecycle.addObserver(this);
+ }
+ }
+
+ public void init(int subId, SubscriptionInfoEntity subInfoEntity) {
+ mSubId = subId;
+ mSubscriptionInfoEntity = subInfoEntity;
+ }
+
+ @OnLifecycleEvent(ON_START)
+ public void onStart() {
+ mMobileNetworkRepository.addRegister(mLifecycleOwner);
+ }
+
+ @OnLifecycleEvent(ON_STOP)
+ public void onStop() {
+ mMobileNetworkRepository.removeRegister();
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(getPreferenceKey());
+ }
+
+ @Override
+ public int getAvailabilityStatus(int subId) {
+ return CONDITIONALLY_UNAVAILABLE;
+ // TODO(b/262195754): Need the intent to enabled the feature.
+// return mSubscriptionInfoEntity != null && mSubscriptionInfoEntity.isActiveSubscriptionId
+// && !mSubscriptionInfoEntity.isEmbedded ? AVAILABLE
+// : CONDITIONALLY_UNAVAILABLE;
+ }
+
+ @VisibleForTesting
+ void update() {
+ if (mPreference == null) {
+ return;
+ }
+ mPreference.setVisible(getAvailabilityStatus(mSubId) == AVAILABLE);
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
+ return false;
+ }
+ // Send intent to launch LPA
+ return true;
+ }
+
+ @VisibleForTesting
+ public void setSubscriptionInfoEntity(SubscriptionInfoEntity subscriptionInfoEntity) {
+ mSubscriptionInfoEntity = subscriptionInfoEntity;
+ }
+
+ @Override
+ public void onAirplaneModeChanged(boolean airplaneModeEnabled) {
+ }
+
+ @Override
+ public void onAvailableSubInfoChanged(List subInfoEntityList) {
+ }
+
+ @Override
+ public void onActiveSubInfoChanged(List subInfoEntityList) {
+ // TODO(b/262195754): Need the intent to enabled the feature.
+// if (DataServiceUtils.shouldUpdateEntityList(mSubscriptionInfoEntityList,
+// subInfoEntityList)) {
+// mSubscriptionInfoEntityList = subInfoEntityList;
+// mSubscriptionInfoEntityList.forEach(entity -> {
+// if (Integer.parseInt(entity.subId) == mSubId) {
+// mSubscriptionInfoEntity = entity;
+// update();
+// }
+// });
+// }
+ }
+
+ @Override
+ public void onAllUiccInfoChanged(List uiccInfoEntityList) {
+ }
+
+ @Override
+ public void onAllMobileNetworkInfoChanged(
+ List mobileNetworkInfoEntityList) {
+ }
+}
diff --git a/src/com/android/settings/network/telephony/MobileDataPreferenceController.java b/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
index 8543770dc0d..1f17d5e854f 100644
--- a/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
+++ b/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
@@ -26,10 +26,10 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
+import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.OnLifecycleEvent;
-import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
index 60f35cd1290..8bc12242fd0 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
@@ -80,6 +80,7 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings impleme
private static final String KEY_CALLS_PREF = "calls_preference";
private static final String KEY_SMS_PREF = "sms_preference";
private static final String KEY_MOBILE_DATA_PREF = "mobile_data_enable";
+ private static final String KEY_CONVERT_TO_ESIM_PREF = "convert_to_esim";
//String keys for preference lookup
private static final String BUTTON_CDMA_SYSTEM_SELECT_KEY = "cdma_system_select_key";
@@ -178,6 +179,8 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings impleme
new SmsDefaultSubscriptionController(context, KEY_SMS_PREF, getSettingsLifecycle(),
this),
new MobileDataPreferenceController(context, KEY_MOBILE_DATA_PREF,
+ getSettingsLifecycle(), this, mSubId),
+ new ConvertToEsimPreferenceController(context, KEY_CONVERT_TO_ESIM_PREF,
getSettingsLifecycle(), this, mSubId));
}
@@ -286,6 +289,8 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings impleme
.addListener(videoCallingPreferenceController);
use(ContactDiscoveryPreferenceController.class).init(getParentFragmentManager(), mSubId);
use(NrAdvancedCallingPreferenceController.class).init(mSubId);
+ use(TransferEsimPreferenceController.class).init(mSubId, mSubscriptionInfoEntity);
+ use(ConvertToEsimPreferenceController.class).init(mSubId, mSubscriptionInfoEntity);
}
@Override
diff --git a/src/com/android/settings/network/telephony/TransferEsimPreferenceController.java b/src/com/android/settings/network/telephony/TransferEsimPreferenceController.java
new file mode 100644
index 00000000000..82e9fb6cf00
--- /dev/null
+++ b/src/com/android/settings/network/telephony/TransferEsimPreferenceController.java
@@ -0,0 +1,70 @@
+/**
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.network.telephony;
+
+import android.content.Context;
+import android.text.TextUtils;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity;
+
+public class TransferEsimPreferenceController extends TelephonyBasePreferenceController {
+
+ private Preference mPreference;
+ private SubscriptionInfoEntity mSubscriptionInfoEntity;
+
+ public TransferEsimPreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ public void init(int subId, SubscriptionInfoEntity subInfoEntity) {
+ mSubId = subId;
+ mSubscriptionInfoEntity = subInfoEntity;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(getPreferenceKey());
+ }
+
+ @Override
+ public int getAvailabilityStatus(int subId) {
+ return CONDITIONALLY_UNAVAILABLE;
+ // TODO(b/262195754): Need the intent to enabled the feature.
+// return mSubscriptionInfoEntity != null && mSubscriptionInfoEntity.isActiveSubscriptionId
+// && mSubscriptionInfoEntity.isEmbedded ? AVAILABLE
+// : CONDITIONALLY_UNAVAILABLE;
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
+ return false;
+ }
+ // Send intent to launch LPA
+ return true;
+ }
+
+ @VisibleForTesting
+ public void setSubscriptionInfoEntity(SubscriptionInfoEntity subscriptionInfoEntity) {
+ mSubscriptionInfoEntity = subscriptionInfoEntity;
+ }
+}