summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Greenwalt <rgreenwalt@google.com>2013-07-16 12:06:09 -0700
committerThe Android Automerger <android-build@google.com>2013-07-18 11:24:56 -0700
commita34a64d2b1df270331cfe9817f59e875b3298aca (patch)
tree85450b32dd583a4436ff301f0a233fa418bf7e9e
parent4fbe5af45e16abcc22ef48f688de4b8e0ff5afc5 (diff)
downloadbase-android-4.3_r2.1.tar.gz
Add gservices updater for carrier provisioning urlandroid-4.3_r2.1
bug:9623159 Change-Id: I36697ed341353b7a3dbec5afe20241102e76f6f1
-rw-r--r--core/java/android/net/ConnectivityManager.java12
-rw-r--r--core/java/android/net/IConnectivityManager.aidl2
-rw-r--r--core/res/AndroidManifest.xml6
-rw-r--r--services/java/com/android/server/ConnectivityService.java126
-rw-r--r--services/java/com/android/server/updates/CarrierProvisioningUrlsInstallReceiver.java24
5 files changed, 163 insertions, 7 deletions
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index 6487c9267e9e..697bde99a2d1 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -1358,4 +1358,16 @@ public class ConnectivityManager {
}
return timeOutMs;
}
+
+ /**
+ * Get the carrier provisioning url.
+ * {@hide}
+ */
+ public String getMobileProvisioningUrl() {
+ try {
+ return mService.getMobileProvisioningUrl();
+ } catch (RemoteException e) {
+ }
+ return null;
+ }
}
diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl
index 3dbe078313ac..4600c1a4dc27 100644
--- a/core/java/android/net/IConnectivityManager.aidl
+++ b/core/java/android/net/IConnectivityManager.aidl
@@ -134,4 +134,6 @@ interface IConnectivityManager
int findConnectionTypeForIface(in String iface);
int checkMobileProvisioning(boolean sendNotification, int suggestedTimeOutMs, in ResultReceiver resultReceiver);
+
+ String getMobileProvisioningUrl();
}
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 4aa540a1dc00..4bff536acc6b 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -2384,6 +2384,12 @@
</intent-filter>
</receiver>
+ <receiver android:name="com.android.server.updates.CarrierProvisioningUrlsInstallReceiver" >
+ <intent-filter>
+ <action android:name="android.intent.action.UPDATE_CARRIER_PROVISIONING_URLS" />
+ </intent-filter>
+ </receiver>
+
<receiver android:name="com.android.server.updates.TZInfoInstallReceiver" >
<intent-filter>
<action android:name="android.intent.action.UPDATE_TZINFO" />
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index ca5fc181dcfa..54bcdcbb27d2 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -42,6 +42,7 @@ import android.content.ContextWrapper;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.net.CaptivePortalTracker;
@@ -97,6 +98,7 @@ import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Slog;
import android.util.SparseIntArray;
+import android.util.Xml;
import com.android.internal.R;
import com.android.internal.net.LegacyVpnInfo;
@@ -106,6 +108,7 @@ import com.android.internal.telephony.DctConstants;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.util.IndentingPrintWriter;
+import com.android.internal.util.XmlUtils;
import com.android.server.am.BatteryStatsService;
import com.android.server.connectivity.Nat464Xlat;
import com.android.server.connectivity.Tethering;
@@ -117,7 +120,13 @@ import com.google.android.collect.Sets;
import dalvik.system.DexClassLoader;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.File;
import java.io.FileDescriptor;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Constructor;
@@ -3600,10 +3609,9 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
case ConnectivityManager.CMP_RESULT_CODE_REDIRECTED: {
log("CheckMp.onComplete: warm sim");
- String url = getProvisioningUrl();
+ String url = getMobileProvisioningUrl();
if (TextUtils.isEmpty(url)) {
- url = mContext.getResources()
- .getString(R.string.mobile_redirected_provisioning_url);
+ url = getMobileRedirectedProvisioningUrl();
}
if (TextUtils.isEmpty(url) == false) {
log("CheckMp.onComplete: warm sim (redirected), url=" + url);
@@ -3615,7 +3623,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
case ConnectivityManager.CMP_RESULT_CODE_NO_DNS:
case ConnectivityManager.CMP_RESULT_CODE_NO_TCP_CONNECTION: {
- String url = getProvisioningUrl();
+ String url = getMobileProvisioningUrl();
if (TextUtils.isEmpty(url) == false) {
log("CheckMp.onComplete: warm sim (no dns/tcp), url=" + url);
setNotificationVisible(true, ni, url);
@@ -3989,10 +3997,114 @@ public class ConnectivityService extends IConnectivityManager.Stub {
log("setNotificationVisible: X visible=" + visible + " ni=" + networkInfo + " url=" + url);
}
- private String getProvisioningUrl() {
- String url = mContext.getResources().getString(R.string.mobile_provisioning_url);
- log("getProvisioningUrl: mobile_provisioning_url=" + url);
+ /** Location to an updatable file listing carrier provisioning urls.
+ * An example:
+ *
+ * <?xml version="1.0" encoding="utf-8"?>
+ * <provisioningUrls>
+ * <provisioningUrl mcc="310" mnc="4">http://myserver.com/foo?mdn=%3$s&amp;iccid=%1$s&amp;imei=%2$s</provisioningUrl>
+ * <redirectedUrl mcc="310" mnc="4">http://www.google.com</redirectedUrl>
+ * </provisioningUrls>
+ */
+ private static final String PROVISIONING_URL_PATH =
+ "/data/misc/radio/provisioning_urls.xml";
+ private final File mProvisioningUrlFile = new File(PROVISIONING_URL_PATH);
+
+ /** XML tag for root element. */
+ private static final String TAG_PROVISIONING_URLS = "provisioningUrls";
+ /** XML tag for individual url */
+ private static final String TAG_PROVISIONING_URL = "provisioningUrl";
+ /** XML tag for redirected url */
+ private static final String TAG_REDIRECTED_URL = "redirectedUrl";
+ /** XML attribute for mcc */
+ private static final String ATTR_MCC = "mcc";
+ /** XML attribute for mnc */
+ private static final String ATTR_MNC = "mnc";
+
+ private static final int REDIRECTED_PROVISIONING = 1;
+ private static final int PROVISIONING = 2;
+
+ private String getProvisioningUrlBaseFromFile(int type) {
+ FileReader fileReader = null;
+ XmlPullParser parser = null;
+ Configuration config = mContext.getResources().getConfiguration();
+ String tagType;
+
+ switch (type) {
+ case PROVISIONING:
+ tagType = TAG_PROVISIONING_URL;
+ break;
+ case REDIRECTED_PROVISIONING:
+ tagType = TAG_REDIRECTED_URL;
+ break;
+ default:
+ throw new RuntimeException("getProvisioningUrlBaseFromFile: Unexpected parameter " +
+ type);
+ }
+
+ try {
+ fileReader = new FileReader(mProvisioningUrlFile);
+ parser = Xml.newPullParser();
+ parser.setInput(fileReader);
+ XmlUtils.beginDocument(parser, TAG_PROVISIONING_URLS);
+
+ while (true) {
+ XmlUtils.nextElement(parser);
+
+ String element = parser.getName();
+ if (element == null) break;
+ if (element.equals(tagType)) {
+ String mcc = parser.getAttributeValue(null, ATTR_MCC);
+ try {
+ if (mcc != null && Integer.parseInt(mcc) == config.mcc) {
+ String mnc = parser.getAttributeValue(null, ATTR_MNC);
+ if (mnc != null && Integer.parseInt(mnc) == config.mnc) {
+ parser.next();
+ if (parser.getEventType() == XmlPullParser.TEXT) {
+ return parser.getText();
+ }
+ }
+ }
+ } catch (NumberFormatException e) {
+ loge("NumberFormatException in getProvisioningUrlBaseFromFile: " + e);
+ }
+ }
+ }
+ return null;
+ } catch (FileNotFoundException e) {
+ loge("Carrier Provisioning Urls file not found");
+ } catch (XmlPullParserException e) {
+ loge("Xml parser exception reading Carrier Provisioning Urls file: " + e);
+ } catch (IOException e) {
+ loge("I/O exception reading Carrier Provisioning Urls file: " + e);
+ } finally {
+ if (fileReader != null) {
+ try {
+ fileReader.close();
+ } catch (IOException e) {}
+ }
+ }
+ return null;
+ }
+
+ private String getMobileRedirectedProvisioningUrl() {
+ String url = getProvisioningUrlBaseFromFile(REDIRECTED_PROVISIONING);
+ if (TextUtils.isEmpty(url)) {
+ url = mContext.getResources().getString(R.string.mobile_redirected_provisioning_url);
+ }
+ return url;
+ }
+
+ public String getMobileProvisioningUrl() {
+ enforceConnectivityInternalPermission();
+ String url = getProvisioningUrlBaseFromFile(PROVISIONING);
+ if (TextUtils.isEmpty(url)) {
+ url = mContext.getResources().getString(R.string.mobile_provisioning_url);
+ log("getProvisioningUrl: mobile_provisioining_url from resource =" + url);
+ } else {
+ log("getProvisioningUrl: mobile_provisioning_url from File =" + url);
+ }
// populate the iccid, imei and phone number in the provisioning url.
if (!TextUtils.isEmpty(url)) {
String phoneNumber = mTelephonyManager.getLine1Number();
diff --git a/services/java/com/android/server/updates/CarrierProvisioningUrlsInstallReceiver.java b/services/java/com/android/server/updates/CarrierProvisioningUrlsInstallReceiver.java
new file mode 100644
index 000000000000..b53fb650c627
--- /dev/null
+++ b/services/java/com/android/server/updates/CarrierProvisioningUrlsInstallReceiver.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.updates;
+
+public class CarrierProvisioningUrlsInstallReceiver extends ConfigUpdateInstallReceiver {
+
+ public CarrierProvisioningUrlsInstallReceiver() {
+ super("/data/misc/radio/", "provisioning_urls.xml", "metadata/", "version");
+ }
+}