From 322f3cf49639809adb4df0b8687e5953a9a9afd8 Mon Sep 17 00:00:00 2001 From: Tomasz Wasilczyk Date: Mon, 16 Sep 2024 10:39:26 -0700 Subject: [PATCH 1/3] Add support for ApnSetting.TYPE_OEM_PAID and OEM_PRIVATE Bug: 366194627 Test: m Test: manually add oem_paid APN to telephony.db and verify if shows up in APN editor Flag: com.android.internal.telephony.flags.oem_paid_private Change-Id: Ida8f6f5712f49caa3172119c547b7ee17e41c12e --- .../settings/network/apn/ApnEditor.java | 27 +++++++++++++++++-- .../settings/network/apn/ApnSettings.java | 3 +-- .../android/settings/network/apn/ApnStatus.kt | 4 +-- .../android/settings/network/apn/ApnTypes.kt | 2 ++ 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/com/android/settings/network/apn/ApnEditor.java b/src/com/android/settings/network/apn/ApnEditor.java index d1b2f2fa3fc..dc9741d67bc 100644 --- a/src/com/android/settings/network/apn/ApnEditor.java +++ b/src/com/android/settings/network/apn/ApnEditor.java @@ -198,6 +198,10 @@ public class ApnEditor extends SettingsPreferenceFragment public static final String APN_TYPE_MCX = "mcx"; /** APN type for XCAP */ public static final String APN_TYPE_XCAP = "xcap"; + /** APN type for OEM_PAID networks (Automotive PANS) */ + public static final String APN_TYPE_OEM_PAID = "oem_paid"; + /** APN type for OEM_PRIVATE networks (Automotive PANS) */ + public static final String APN_TYPE_OEM_PRIVATE = "oem_private"; /** Array of all APN types */ public static final String[] APN_TYPES = {APN_TYPE_DEFAULT, APN_TYPE_MMS, @@ -211,6 +215,14 @@ public class ApnEditor extends SettingsPreferenceFragment APN_TYPE_EMERGENCY, APN_TYPE_MCX, APN_TYPE_XCAP, + APN_TYPE_OEM_PAID, + APN_TYPE_OEM_PRIVATE, + }; + + /** Array of APN types that are never user-editable */ + private static final String[] ALWAYS_READ_ONLY_APN_TYPES = new String[] { + APN_TYPE_OEM_PAID, + APN_TYPE_OEM_PRIVATE, }; /** @@ -360,6 +372,18 @@ public class ApnEditor extends SettingsPreferenceFragment } } + /** + * Fetch complete list of read only APN types. + * + * The list primarily comes from carrier config, but is also supplied by APN types which are + * always read only. + */ + static String[] getReadOnlyApnTypes(PersistableBundle b) { + String[] carrierReadOnlyApnTypes = b.getStringArray( + CarrierConfigManager.KEY_READ_ONLY_APN_TYPES_STRING_ARRAY); + return ArrayUtils.concat(String.class, carrierReadOnlyApnTypes, ALWAYS_READ_ONLY_APN_TYPES); + } + /** * Enable ProxySubscriptionMgr with Lifecycle support for all controllers * live within this fragment @@ -1355,8 +1379,7 @@ public class ApnEditor extends SettingsPreferenceFragment if (configManager != null) { final PersistableBundle b = configManager.getConfigForSubId(mSubId); if (b != null) { - mReadOnlyApnTypes = b.getStringArray( - CarrierConfigManager.KEY_READ_ONLY_APN_TYPES_STRING_ARRAY); + mReadOnlyApnTypes = getReadOnlyApnTypes(b); if (!ArrayUtils.isEmpty(mReadOnlyApnTypes)) { Log.d(TAG, "onCreate: read only APN type: " + Arrays.toString(mReadOnlyApnTypes)); diff --git a/src/com/android/settings/network/apn/ApnSettings.java b/src/com/android/settings/network/apn/ApnSettings.java index 2debba1d99a..0e3c3a4362d 100644 --- a/src/com/android/settings/network/apn/ApnSettings.java +++ b/src/com/android/settings/network/apn/ApnSettings.java @@ -135,8 +135,7 @@ public class ApnSettings extends RestrictedSettingsFragment mHideImsApn = b.getBoolean(CarrierConfigManager.KEY_HIDE_IMS_APN_BOOL); mAllowAddingApns = b.getBoolean(CarrierConfigManager.KEY_ALLOW_ADDING_APNS_BOOL); if (mAllowAddingApns) { - final String[] readOnlyApnTypes = b.getStringArray( - CarrierConfigManager.KEY_READ_ONLY_APN_TYPES_STRING_ARRAY); + final String[] readOnlyApnTypes = ApnEditor.getReadOnlyApnTypes(b); // if no apn type can be edited, do not allow adding APNs if (ApnEditor.hasAllApns(readOnlyApnTypes)) { Log.d(TAG, "not allowing adding APN because all APN types are read only"); diff --git a/src/com/android/settings/network/apn/ApnStatus.kt b/src/com/android/settings/network/apn/ApnStatus.kt index 6492d39417d..68588bbd975 100644 --- a/src/com/android/settings/network/apn/ApnStatus.kt +++ b/src/com/android/settings/network/apn/ApnStatus.kt @@ -204,9 +204,7 @@ fun getCarrierCustomizedConfig( CarrierConfigManager.KEY_ALLOW_ADDING_APNS_BOOL ) val customizedConfig = CustomizedConfig( - readOnlyApnTypes = b.getStringArray( - CarrierConfigManager.KEY_READ_ONLY_APN_TYPES_STRING_ARRAY - )?.toList() ?: emptyList(), + readOnlyApnTypes = ApnEditor.getReadOnlyApnTypes(b)?.toList() ?: emptyList(), readOnlyApnFields = b.getStringArray( CarrierConfigManager.KEY_READ_ONLY_APN_FIELDS_STRING_ARRAY )?.toList() ?: emptyList(), diff --git a/src/com/android/settings/network/apn/ApnTypes.kt b/src/com/android/settings/network/apn/ApnTypes.kt index b9bc480cc35..4f84ac7fa70 100644 --- a/src/com/android/settings/network/apn/ApnTypes.kt +++ b/src/com/android/settings/network/apn/ApnTypes.kt @@ -45,6 +45,8 @@ object ApnTypes { ApnSetting.TYPE_VSIM_STRING, ApnSetting.TYPE_BIP_STRING, ApnSetting.TYPE_ENTERPRISE_STRING, + ApnSetting.TYPE_OEM_PAID_STRING, + ApnSetting.TYPE_OEM_PRIVATE_STRING, ) private fun splitToList(apnType: String): List { From 25db7a82f3293e68359dc299855234b2970fb95b Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Thu, 26 Sep 2024 15:21:29 -0700 Subject: [PATCH 2/3] Import translations. DO NOT MERGE ANYWHERE Auto-generated-cl: translation import Change-Id: Ib40695438c333d727d69b10b2bbbf1cf4c66ff23 --- res-product/values-pt-rPT/strings.xml | 2 +- res-product/values-zh-rCN/strings.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/res-product/values-pt-rPT/strings.xml b/res-product/values-pt-rPT/strings.xml index 25f8b74db07..67c7b747795 100644 --- a/res-product/values-pt-rPT/strings.xml +++ b/res-product/values-pt-rPT/strings.xml @@ -266,7 +266,7 @@ "Partilhar a ligação à Internet do telemóvel através de Ethernet" "Partilhar a ligação à Internet do tablet por Ethernet" "Acerca do tablet" - "Acerca do telefone" + "Acerca do telemóvel" "Acerca do dispositivo" "Acerca do dispositivo emulado" "O seu tablet e os dados pessoais são mais vulneráveis a ataques de apps desconhecidas. Ao instalar apps desta fonte, aceita ser responsável por quaisquer danos no tablet ou perdas de dados que possam resultar da utilização do mesmo." diff --git a/res-product/values-zh-rCN/strings.xml b/res-product/values-zh-rCN/strings.xml index c11fa41ef34..873d35ee2ae 100644 --- a/res-product/values-zh-rCN/strings.xml +++ b/res-product/values-zh-rCN/strings.xml @@ -297,8 +297,8 @@ "您的应用目前耗电量正常。如果应用耗电量过高,您的设备会为您提供操作建议。\n\n如果电池电量不足,您可以随时开启省电模式。" "限制不常用的应用的耗电量" "手机充电时,系统不会衡量电池使用情况和屏幕使用时间" - "平板电脑充电时,系统不会衡量电池用量和设备使用时间" - "设备充电时,系统不会衡量电池用量和设备使用时间" + "平板电脑充电时,系统不会衡量电池用量和屏幕使用时间" + "设备充电时,系统不会衡量电池用量和屏幕使用时间" "从存储设备安装证书" "从SD卡安装证书" "移除该账号会从平板电脑中删除所有相关的邮件、联系人以及其他数据。" From ed5e803c87fba644b0c6cb5b54247717217431c4 Mon Sep 17 00:00:00 2001 From: songferngwang Date: Fri, 27 Sep 2024 08:42:08 +0000 Subject: [PATCH 3/3] Hide the enabling mobile data Since the framework behavior was changed after the enabling mobile data dialog was implemented. Bug: 368450590 Test: manully test the dialog. Change-Id: I08e0e1b9643781e52f6a9d4fa2c0eccf0feb7901 --- .../sim/PreferredSimDialogFragment.java | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/com/android/settings/sim/PreferredSimDialogFragment.java b/src/com/android/settings/sim/PreferredSimDialogFragment.java index 96c0eb61a75..aa42f3cb8f8 100644 --- a/src/com/android/settings/sim/PreferredSimDialogFragment.java +++ b/src/com/android/settings/sim/PreferredSimDialogFragment.java @@ -21,10 +21,12 @@ import static android.telephony.SubscriptionManager.PROFILE_CLASS_PROVISIONING; import android.app.Activity; import android.app.Dialog; import android.app.settings.SettingsEnums; +import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; +import android.telephony.TelephonyManager; import android.util.Log; import androidx.annotation.NonNull; @@ -91,8 +93,12 @@ public class PreferredSimDialogFragment extends SimDialogFragment implements } if (dialog == null) { - Log.d(TAG, "Dialog is null."); - dismiss(); + dismiss("Dialog is null."); + return; + } + Context context = getContext(); + if (context == null) { + dismiss("getContext is null."); return; } @@ -100,24 +106,44 @@ public class PreferredSimDialogFragment extends SimDialogFragment implements if (info == null || (info.isEmbedded() && (info.getProfileClass() == PROFILE_CLASS_PROVISIONING || (Flags.oemEnabledSatelliteFlag() && info.isOnlyNonTerrestrialNetwork())))) { - dismiss(); + dismiss("SubscriptionInfo is null or other esim's cases."); return; } Log.d(TAG, "SubscriptionInfo: " + info); + TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class); + if (telephonyManager == null) { + dismiss("TelephonyManager is null."); + return; + } + telephonyManager = telephonyManager.createForSubscriptionId(info.getSubscriptionId()); + if (telephonyManager.isDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER)) { + dismiss("mobile data is on."); + final SimDialogActivity activity = (SimDialogActivity) getActivity(); + if (activity != null) { + activity.finish(); + } + return; + } + final CharSequence simName = - SubscriptionUtil.getUniqueSubscriptionDisplayName(info, getContext()); + SubscriptionUtil.getUniqueSubscriptionDisplayName(info, context); final String title = - getContext().getString( + context.getString( getTitleResId(), simName); final String message = - getContext().getString( + context.getString( R.string.sim_preferred_message, simName); dialog.setTitle(title); dialog.setMessage(message); } + private void dismiss(String log) { + Log.d(TAG, log); + dismiss(); + } + @Override public void updateDialog() { updateDialog((AlertDialog) getDialog());