From 78f838255ac28e38dc4a2b0e7cd497ed156ecb1b Mon Sep 17 00:00:00 2001 From: Rayan Osseiran Date: Wed, 19 Apr 2023 17:04:23 -0700 Subject: [PATCH] Add missing fields to ApnSetting#toContentValues - ApnSetting#toContentValues is missing important fields for connectivity and identifying carriers. Added the mcc,mnc and the MVNO match data. Bug: 264916634 Test: atest CtsTelephonyTestCases Test: Validated no issues on local device (C10). Change-Id: I71d58247ccc4fe577eec93243fb16399ebbef993 --- telephony/java/android/telephony/data/ApnSetting.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/telephony/java/android/telephony/data/ApnSetting.java b/telephony/java/android/telephony/data/ApnSetting.java index 1ce85ba93d95e..8be074d5e9321 100644 --- a/telephony/java/android/telephony/data/ApnSetting.java +++ b/telephony/java/android/telephony/data/ApnSetting.java @@ -1337,6 +1337,14 @@ public class ApnSetting implements Parcelable { public ContentValues toContentValues() { ContentValues apnValue = new ContentValues(); apnValue.put(Telephony.Carriers.NUMERIC, nullToEmpty(mOperatorNumeric)); + // If the APN is editable, the user may be able to set an invalid numeric. The numeric must + // always be 5 or 6 characters (depending on the length of the MNC), so skip if it is + // potentially invalid. + if (!TextUtils.isEmpty(mOperatorNumeric) + && (mOperatorNumeric.length() == 5 || mOperatorNumeric.length() == 6)) { + apnValue.put(Telephony.Carriers.MCC, mOperatorNumeric.substring(0, 3)); + apnValue.put(Telephony.Carriers.MNC, mOperatorNumeric.substring(3)); + } apnValue.put(Telephony.Carriers.NAME, nullToEmpty(mEntryName)); apnValue.put(Telephony.Carriers.APN, nullToEmpty(mApnName)); apnValue.put(Telephony.Carriers.PROXY, nullToEmpty(mProxyAddress)); @@ -1356,6 +1364,7 @@ public class ApnSetting implements Parcelable { getProtocolStringFromInt(mRoamingProtocol)); apnValue.put(Telephony.Carriers.CARRIER_ENABLED, mCarrierEnabled); apnValue.put(Telephony.Carriers.MVNO_TYPE, getMvnoTypeStringFromInt(mMvnoType)); + apnValue.put(Telephony.Carriers.MVNO_MATCH_DATA, nullToEmpty(mMvnoMatchData)); apnValue.put(Telephony.Carriers.NETWORK_TYPE_BITMASK, mNetworkTypeBitmask); apnValue.put(Telephony.Carriers.LINGERING_NETWORK_TYPE_BITMASK, mLingeringNetworkTypeBitmask);