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
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 9f19f11..e12dfb0 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -2368,6 +2368,24 @@
         public static final String TETHER_SUPPORTED = "tether_supported";
 
         /**
+         * Used to require DUN APN on the device or not - defaults to a build config value
+         * which defaults to false
+         * @hide
+         */
+        public static final String TETHER_DUN_REQUIRED = "tether_dun_required";
+
+        /**
+         * Used to hold a gservices-provisioned apn value for DUN.  If set, or the
+         * corresponding build config values are set it will override the APN DB
+         * values.
+         * Consists of a comma seperated list of strings:
+         * "name,apn,proxy,port,username,password,server,mmsc,mmsproxy,mmsport,mcc,mnc,auth,type"
+         * note that empty fields can be ommitted: "name,apn,,,,,,,,,310,260,,DUN"
+         * @hide
+         */
+        public static final String TETHER_DUN_APN = "tether_dun_apn";
+
+        /**
          * No longer supported.
          */
         public static final String PARENTAL_CONTROL_ENABLED = "parental_control_enabled";
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 64f05fe..088ab44 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -91,8 +91,18 @@
     <string-array translatable="false" name="config_tether_upstream_regexs">
     </string-array>
 
-    <!-- Boolean indicating if we require the use of DUN on mobile for tethering -->
-    <bool translatable="false" name="config_tether_dun_required">true</bool>
+    <!-- Boolean indicating if we require the use of DUN on mobile for tethering.
+         Note that this defaults to false so that if you move to a carrier that
+         hasn't configured anything tethering will still work.  If you'd rather
+         make the device untetherable on unconfigured devices, set to true -->
+    <bool translatable="false" name="config_tether_dun_required">false</bool>
+
+    <!-- String containing the apn value for tethering.  May be overriden by secure settings
+         TETHER_DUN_APN.  Value is a comma separated series of strings:
+         "name,apn,proxy,port,username,password,server,mmsc,mmsproxy,mmsport,mcc,mnc,auth,type"
+         note that empty fields can be ommitted: "name,apn,,,,,,,,,310,260,,DUN" -->
+    <string translatable="false" name="config_tether_apndata"></string>
+
 
     <!-- Flag indicating whether the keyguard should be bypassed when
          the slider is open.  This can be set or unset depending how easily