Merge "Add support for ApnSetting.TYPE_OEM_PAID and OEM_PRIVATE" into main
diff --git a/src/com/android/settings/network/apn/ApnEditor.java b/src/com/android/settings/network/apn/ApnEditor.java
index d1b2f2f..dc9741d 100644
--- a/src/com/android/settings/network/apn/ApnEditor.java
+++ b/src/com/android/settings/network/apn/ApnEditor.java
@@ -198,6 +198,10 @@
     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 @@
             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,
     };
 
     /**
@@ -361,6 +373,18 @@
     }
 
     /**
+     * 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 @@
         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 2debba1..0e3c3a4 100644
--- a/src/com/android/settings/network/apn/ApnSettings.java
+++ b/src/com/android/settings/network/apn/ApnSettings.java
@@ -135,8 +135,7 @@
         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 6492d39..68588bb 100644
--- a/src/com/android/settings/network/apn/ApnStatus.kt
+++ b/src/com/android/settings/network/apn/ApnStatus.kt
@@ -204,9 +204,7 @@
         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 b9bc480..4f84ac7 100644
--- a/src/com/android/settings/network/apn/ApnTypes.kt
+++ b/src/com/android/settings/network/apn/ApnTypes.kt
@@ -45,6 +45,8 @@
         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<String> {