Loading AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -818,6 +818,10 @@ android:permission="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS" android:theme="@style/Theme.AlertDialog.SimConfirmDialog"/> <activity android:name=".network.telephony.EuiccRacConnectivityDialogActivity" android:exported="false" android:theme="@style/Theme.AlertDialog.SimConfirmDialog"/> <activity android:name="Settings$TetherSettingsActivity" android:label="@string/tether_settings_title_all" Loading res/layout/sim_warning_dialog_wifi_connectivity.xml 0 → 100644 +52 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2024 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. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <ImageView android:src="@drawable/ic_warning_24dp" android:contentDescription="@null" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="16dp" android:gravity="center" android:tint="?android:attr/textColorSecondary"/> <TextView android:id="@+id/title" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingEnd="24dp" android:paddingTop="16dp" android:paddingLeft="24dp" android:gravity="center" style="?android:attr/textAppearanceLarge"/> <TextView android:id="@+id/msg" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingEnd="24dp" android:paddingTop="16dp" android:paddingStart="24dp" android:paddingBottom="32dp" android:gravity="center" android:textAppearance="@style/TextAppearance.DialogMessage" android:visibility="gone"/> </LinearLayout> res/values/strings.xml +10 −0 Original line number Diff line number Diff line Loading @@ -11701,6 +11701,16 @@ <!-- Body text of error message indicating the device could not erase the SIM due to an error. [CHAR_LIMIT=NONE] --> <string name="erase_sim_fail_text">Something went wrong and this eSIM wasn\'t erased.\n\nRestart your device and try again.</string> <!-- Strings for to use Wi-Fi before deleting eUICC subscriptions --> <!-- Title on confirmation dialog asking the user to have Wi-Fi. [CHAR_LIMIT=NONE] --> <string name="wifi_warning_dialog_title">Connect to Wi\u2011Fi before erasing</string> <!-- Body text in confirmation dialog indicating why having Wi-Fi is recommended. [CHAR_LIMIT=NONE] --> <string name="wifi_warning_dialog_text">This makes it easier to use your eSIM again in the future without needing to contact your carrier</string> <!-- Button label to continue with erasing [CHAR_LIMIT=20] --> <string name="wifi_warning_continue_button">Erase anyway</string> <!-- Button label to return to settings [CHAR_LIMIT=20] --> <string name="wifi_warning_return_button">OK</string> <!-- Title for Network connection request Dialog [CHAR LIMIT=60] --> <string name="network_connection_request_dialog_title">Connect to device</string> <!-- Summary for Network connection request Dialog [CHAR LIMIT=NONE] --> src/com/android/settings/network/SubscriptionUtil.java +29 −1 Original line number Diff line number Diff line Loading @@ -17,13 +17,15 @@ package com.android.settings.network; import static android.telephony.SubscriptionManager.INVALID_SIM_SLOT_INDEX; import static android.telephony.UiccSlotInfo.CARD_STATE_INFO_PRESENT; import static android.telephony.SubscriptionManager.PROFILE_CLASS_PROVISIONING; import static android.telephony.UiccSlotInfo.CARD_STATE_INFO_PRESENT; import static com.android.internal.util.CollectionUtils.emptyIfNull; import android.content.Context; import android.content.SharedPreferences; import android.net.ConnectivityManager; import android.net.NetworkCapabilities; import android.os.ParcelUuid; import android.provider.Settings; import android.telephony.PhoneNumberUtils; Loading Loading @@ -560,6 +562,7 @@ public class SubscriptionUtil { Log.i(TAG, "Unable to delete subscription due to invalid subscription ID."); return; } // TODO(b/325693582): Add verification if carrier is RAC and logic for new dialog context.startActivity(DeleteEuiccSubscriptionDialogActivity.getIntent(context, subId)); } Loading Loading @@ -832,4 +835,29 @@ public class SubscriptionUtil { } return true; } /** * Returns {@code true} if device is connected to Wi-Fi or mobile data provided by a different * subId. * * @param context context * @param targetSubId subscription that is going to be deleted */ @VisibleForTesting static boolean isConnectedToWifiOrDifferentSubId(@NonNull Context context, int targetSubId) { ConnectivityManager connectivityManager = context.getSystemService(ConnectivityManager.class); NetworkCapabilities capabilities = connectivityManager.getNetworkCapabilities(connectivityManager.getActiveNetwork()); if (capabilities != null) { if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) { // Connected to WiFi return true; } else if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) { return targetSubId != SubscriptionManager.getActiveDataSubscriptionId(); } } return false; } } src/com/android/settings/network/telephony/EuiccRacConnectivityDialogActivity.java 0 → 100644 +95 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.content.Intent; import android.os.Bundle; import android.telephony.SubscriptionManager; import android.util.Log; import androidx.annotation.NonNull; import com.android.settings.R; /** This dialog activity advise the user to have connectivity if the eSIM uses a RAC. */ public class EuiccRacConnectivityDialogActivity extends SubscriptionActionDialogActivity implements WarningDialogFragment.OnConfirmListener { private static final String TAG = "EuiccRacConnectivityDialogActivity"; // Dialog tags private static final int DIALOG_TAG_ERASE_ANYWAY_CONFIRMATION = 1; private int mSubId; /** * Returns an intent of EuiccRacConnectivityDialogActivity. * * @param context The context used to start the EuiccRacConnectivityDialogActivity. * @param subId The subscription ID of the subscription needs to be deleted. If the subscription * belongs to a group of subscriptions, all subscriptions from the group will be deleted. */ @NonNull public static Intent getIntent(@NonNull Context context, int subId) { Intent intent = new Intent(context, EuiccRacConnectivityDialogActivity.class); intent.putExtra(ARG_SUB_ID, subId); return intent; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); mSubId = intent.getIntExtra(ARG_SUB_ID, SubscriptionManager.INVALID_SUBSCRIPTION_ID); if (savedInstanceState == null) { showConnectivityWarningDialog(); } } @Override public void onConfirm(int tag, boolean confirmed) { if (!confirmed) { finish(); return; } switch (tag) { case DIALOG_TAG_ERASE_ANYWAY_CONFIRMATION: finish(); Log.i(TAG, "Show dialogue activity that handles deleting eSIM profiles"); startActivity(DeleteEuiccSubscriptionDialogActivity.getIntent(this, mSubId)); break; default: Log.e(TAG, "Unrecognized confirmation dialog tag: " + tag); break; } } /* Displays warning to have connectivity because subscription is RAC dialog. */ private void showConnectivityWarningDialog() { WarningDialogFragment.show( this, WarningDialogFragment.OnConfirmListener.class, DIALOG_TAG_ERASE_ANYWAY_CONFIRMATION, getString(R.string.wifi_warning_dialog_title), getString(R.string.wifi_warning_dialog_text), getString(R.string.wifi_warning_continue_button), getString(R.string.wifi_warning_return_button)); } } Loading
AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -818,6 +818,10 @@ android:permission="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS" android:theme="@style/Theme.AlertDialog.SimConfirmDialog"/> <activity android:name=".network.telephony.EuiccRacConnectivityDialogActivity" android:exported="false" android:theme="@style/Theme.AlertDialog.SimConfirmDialog"/> <activity android:name="Settings$TetherSettingsActivity" android:label="@string/tether_settings_title_all" Loading
res/layout/sim_warning_dialog_wifi_connectivity.xml 0 → 100644 +52 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2024 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. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <ImageView android:src="@drawable/ic_warning_24dp" android:contentDescription="@null" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="16dp" android:gravity="center" android:tint="?android:attr/textColorSecondary"/> <TextView android:id="@+id/title" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingEnd="24dp" android:paddingTop="16dp" android:paddingLeft="24dp" android:gravity="center" style="?android:attr/textAppearanceLarge"/> <TextView android:id="@+id/msg" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingEnd="24dp" android:paddingTop="16dp" android:paddingStart="24dp" android:paddingBottom="32dp" android:gravity="center" android:textAppearance="@style/TextAppearance.DialogMessage" android:visibility="gone"/> </LinearLayout>
res/values/strings.xml +10 −0 Original line number Diff line number Diff line Loading @@ -11701,6 +11701,16 @@ <!-- Body text of error message indicating the device could not erase the SIM due to an error. [CHAR_LIMIT=NONE] --> <string name="erase_sim_fail_text">Something went wrong and this eSIM wasn\'t erased.\n\nRestart your device and try again.</string> <!-- Strings for to use Wi-Fi before deleting eUICC subscriptions --> <!-- Title on confirmation dialog asking the user to have Wi-Fi. [CHAR_LIMIT=NONE] --> <string name="wifi_warning_dialog_title">Connect to Wi\u2011Fi before erasing</string> <!-- Body text in confirmation dialog indicating why having Wi-Fi is recommended. [CHAR_LIMIT=NONE] --> <string name="wifi_warning_dialog_text">This makes it easier to use your eSIM again in the future without needing to contact your carrier</string> <!-- Button label to continue with erasing [CHAR_LIMIT=20] --> <string name="wifi_warning_continue_button">Erase anyway</string> <!-- Button label to return to settings [CHAR_LIMIT=20] --> <string name="wifi_warning_return_button">OK</string> <!-- Title for Network connection request Dialog [CHAR LIMIT=60] --> <string name="network_connection_request_dialog_title">Connect to device</string> <!-- Summary for Network connection request Dialog [CHAR LIMIT=NONE] -->
src/com/android/settings/network/SubscriptionUtil.java +29 −1 Original line number Diff line number Diff line Loading @@ -17,13 +17,15 @@ package com.android.settings.network; import static android.telephony.SubscriptionManager.INVALID_SIM_SLOT_INDEX; import static android.telephony.UiccSlotInfo.CARD_STATE_INFO_PRESENT; import static android.telephony.SubscriptionManager.PROFILE_CLASS_PROVISIONING; import static android.telephony.UiccSlotInfo.CARD_STATE_INFO_PRESENT; import static com.android.internal.util.CollectionUtils.emptyIfNull; import android.content.Context; import android.content.SharedPreferences; import android.net.ConnectivityManager; import android.net.NetworkCapabilities; import android.os.ParcelUuid; import android.provider.Settings; import android.telephony.PhoneNumberUtils; Loading Loading @@ -560,6 +562,7 @@ public class SubscriptionUtil { Log.i(TAG, "Unable to delete subscription due to invalid subscription ID."); return; } // TODO(b/325693582): Add verification if carrier is RAC and logic for new dialog context.startActivity(DeleteEuiccSubscriptionDialogActivity.getIntent(context, subId)); } Loading Loading @@ -832,4 +835,29 @@ public class SubscriptionUtil { } return true; } /** * Returns {@code true} if device is connected to Wi-Fi or mobile data provided by a different * subId. * * @param context context * @param targetSubId subscription that is going to be deleted */ @VisibleForTesting static boolean isConnectedToWifiOrDifferentSubId(@NonNull Context context, int targetSubId) { ConnectivityManager connectivityManager = context.getSystemService(ConnectivityManager.class); NetworkCapabilities capabilities = connectivityManager.getNetworkCapabilities(connectivityManager.getActiveNetwork()); if (capabilities != null) { if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) { // Connected to WiFi return true; } else if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) { return targetSubId != SubscriptionManager.getActiveDataSubscriptionId(); } } return false; } }
src/com/android/settings/network/telephony/EuiccRacConnectivityDialogActivity.java 0 → 100644 +95 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.content.Intent; import android.os.Bundle; import android.telephony.SubscriptionManager; import android.util.Log; import androidx.annotation.NonNull; import com.android.settings.R; /** This dialog activity advise the user to have connectivity if the eSIM uses a RAC. */ public class EuiccRacConnectivityDialogActivity extends SubscriptionActionDialogActivity implements WarningDialogFragment.OnConfirmListener { private static final String TAG = "EuiccRacConnectivityDialogActivity"; // Dialog tags private static final int DIALOG_TAG_ERASE_ANYWAY_CONFIRMATION = 1; private int mSubId; /** * Returns an intent of EuiccRacConnectivityDialogActivity. * * @param context The context used to start the EuiccRacConnectivityDialogActivity. * @param subId The subscription ID of the subscription needs to be deleted. If the subscription * belongs to a group of subscriptions, all subscriptions from the group will be deleted. */ @NonNull public static Intent getIntent(@NonNull Context context, int subId) { Intent intent = new Intent(context, EuiccRacConnectivityDialogActivity.class); intent.putExtra(ARG_SUB_ID, subId); return intent; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); mSubId = intent.getIntExtra(ARG_SUB_ID, SubscriptionManager.INVALID_SUBSCRIPTION_ID); if (savedInstanceState == null) { showConnectivityWarningDialog(); } } @Override public void onConfirm(int tag, boolean confirmed) { if (!confirmed) { finish(); return; } switch (tag) { case DIALOG_TAG_ERASE_ANYWAY_CONFIRMATION: finish(); Log.i(TAG, "Show dialogue activity that handles deleting eSIM profiles"); startActivity(DeleteEuiccSubscriptionDialogActivity.getIntent(this, mSubId)); break; default: Log.e(TAG, "Unrecognized confirmation dialog tag: " + tag); break; } } /* Displays warning to have connectivity because subscription is RAC dialog. */ private void showConnectivityWarningDialog() { WarningDialogFragment.show( this, WarningDialogFragment.OnConfirmListener.class, DIALOG_TAG_ERASE_ANYWAY_CONFIRMATION, getString(R.string.wifi_warning_dialog_title), getString(R.string.wifi_warning_dialog_text), getString(R.string.wifi_warning_continue_button), getString(R.string.wifi_warning_return_button)); } }