diff options
author | Robert Greenwalt <robdroid@android.com> | 2010-06-03 18:57:26 -0700 |
---|---|---|
committer | Robert Greenwalt <robdroid@android.com> | 2010-06-04 11:13:34 -0700 |
commit | 77b32ddbbeeb13a07b16f23af705567c75a8e3df (patch) | |
tree | 6a284450b6ea308c982d7adcc89bc86c8d59947c /telephony | |
parent | 6a297118724f31b1063b74f52295d459ec4f58dc (diff) | |
download | frameworks_base-77b32ddbbeeb13a07b16f23af705567c75a8e3df.zip frameworks_base-77b32ddbbeeb13a07b16f23af705567c75a8e3df.tar.gz frameworks_base-77b32ddbbeeb13a07b16f23af705567c75a8e3df.tar.bz2 |
Make the DUN apn data secure.
Rather than come out of the user-modifiable APN DB, the DUN APN data will
come first from a built-in resource and then potentially overriden by a secure
setting (which is gservices upgradable).
Also made the "require-dun" setting secure-setting overridable.
bug:2736390
Change-Id: I1e4644c3839f06c977b83797641f3948785146a2
Diffstat (limited to 'telephony')
-rw-r--r-- | telephony/java/com/android/internal/telephony/gsm/ApnSetting.java | 29 | ||||
-rw-r--r-- | telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java | 23 |
2 files changed, 52 insertions, 0 deletions
diff --git a/telephony/java/com/android/internal/telephony/gsm/ApnSetting.java b/telephony/java/com/android/internal/telephony/gsm/ApnSetting.java index 4cbfc87..05527af 100644 --- a/telephony/java/com/android/internal/telephony/gsm/ApnSetting.java +++ b/telephony/java/com/android/internal/telephony/gsm/ApnSetting.java @@ -55,6 +55,35 @@ public class ApnSetting { this.types = types; } + // data[0] = name + // data[1] = apn + // data[2] = proxy + // data[3] = port + // data[4] = username + // data[5] = password + // data[6] = server + // data[7] = mmsc + // data[8] = mmsproxy + // data[9] = mmsport + // data[10] = mcc + // data[11] = mnc + // data[12] = auth + // data[13] = first type... + public static ApnSetting fromString(String data) { + if (data == null) return null; + String[] a = data.split("\\s*,\\s*"); + if (a.length < 14) return null; + int authType = 0; + try { + authType = Integer.parseInt(a[12]); + } catch (Exception e) { + } + String[] typeArray = new String[a.length - 13]; + System.arraycopy(a, 13, typeArray, 0, a.length - 13); + return new ApnSetting(-1,a[10]+a[11],a[0],a[1],a[2],a[3],a[7],a[8], + a[9],a[4],a[5],authType,typeArray); + } + public String toString() { StringBuilder sb = new StringBuilder(); sb.append(carrier) diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java index cbfb550..627d94d 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java @@ -49,6 +49,7 @@ import android.text.TextUtils; import android.util.EventLog; import android.util.Log; +import com.android.internal.R; import com.android.internal.telephony.DataCallState; import com.android.internal.telephony.DataConnection; import com.android.internal.telephony.DataConnectionTracker; @@ -366,6 +367,10 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { @Override protected boolean isApnTypeAvailable(String type) { + if (type.equals(Phone.APN_TYPE_DUN)) { + return (fetchDunApn() != null); + } + if (allApns != null) { for (ApnSetting apn : allApns) { if (apn.canHandleType(type)) { @@ -1303,6 +1308,17 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { } } + private ApnSetting fetchDunApn() { + Context c = phone.getContext(); + String apnData = Settings.Secure.getString(c.getContentResolver(), + Settings.Secure.TETHER_DUN_APN); + ApnSetting dunSetting = ApnSetting.fromString(apnData); + if (dunSetting != null) return dunSetting; + + apnData = c.getResources().getString(R.string.config_tether_apndata); + return ApnSetting.fromString(apnData); + } + /** * * @return waitingApns list to be used to create PDP @@ -1310,6 +1326,13 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { */ private ArrayList<ApnSetting> buildWaitingApns() { ArrayList<ApnSetting> apnList = new ArrayList<ApnSetting>(); + + if (mRequestedApnType.equals(Phone.APN_TYPE_DUN)) { + ApnSetting dun = fetchDunApn(); + if (dun != null) apnList.add(dun); + return apnList; + } + String operator = mGsmPhone.mSIMRecords.getSIMOperatorNumeric(); if (mRequestedApnType.equals(Phone.APN_TYPE_DEFAULT)) { |