am 04311337: am cad5d8e3: am c72280d2: am 49e29575: am 21cf95e7: Don\'t allow clients to update or insert _data column data
* commit '04311337ec83020caf58747d680eaccee3ab9b99':
diff --git a/src/com/android/providers/telephony/TelephonyProvider.java b/src/com/android/providers/telephony/TelephonyProvider.java
old mode 100755
new mode 100644
index 7ec2aed..b7cc7a9
--- a/src/com/android/providers/telephony/TelephonyProvider.java
+++ b/src/com/android/providers/telephony/TelephonyProvider.java
@@ -26,6 +26,7 @@
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.database.Cursor;
+import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteQueryBuilder;
@@ -56,7 +57,7 @@
private static final String DATABASE_NAME = "telephony.db";
private static final boolean DBG = true;
- private static final int DATABASE_VERSION = 7 << 16;
+ private static final int DATABASE_VERSION = 8 << 16;
private static final int URL_TELEPHONY = 1;
private static final int URL_CURRENT = 2;
private static final int URL_ID = 3;
@@ -147,7 +148,9 @@
"protocol TEXT," +
"roaming_protocol TEXT," +
"carrier_enabled BOOLEAN," +
- "bearer INTEGER);");
+ "bearer INTEGER," +
+ "mvno_type TEXT," +
+ "mvno_match_data TEXT);");
initDatabase(db);
}
@@ -167,7 +170,7 @@
parser.close();
}
- // Read external APNS data (partner-provided)
+ // Read external APNS data (partner-provided)
XmlPullParser confparser = null;
// Environment.getRootDirectory() is a fancy way of saying ANDROID_ROOT or "/system".
File confFile = new File(Environment.getRootDirectory(), PARTNER_APNS_PATH);
@@ -225,13 +228,22 @@
oldVersion = 6 << 16 | 6;
}
if (oldVersion < (7 << 16 | 6)) {
- // Add protcol fields to the APN. The XML file does not change.
+ // Add carrier_enabled, bearer fields to the APN. The XML file does not change.
db.execSQL("ALTER TABLE " + CARRIERS_TABLE +
" ADD COLUMN carrier_enabled BOOLEAN DEFAULT 1;");
db.execSQL("ALTER TABLE " + CARRIERS_TABLE +
" ADD COLUMN bearer INTEGER DEFAULT 0;");
oldVersion = 7 << 16 | 6;
}
+ if (oldVersion < (8 << 16 | 6)) {
+ // Add mvno_type, mvno_match_data fields to the APN.
+ // The XML file does not change.
+ db.execSQL("ALTER TABLE " + CARRIERS_TABLE +
+ " ADD COLUMN mvno_type TEXT DEFAULT '';");
+ db.execSQL("ALTER TABLE " + CARRIERS_TABLE +
+ " ADD COLUMN mvno_match_data TEXT DEFAULT '';");
+ oldVersion = 8 << 16 | 6;
+ }
}
/**
@@ -307,6 +319,15 @@
if (bearer != null) {
map.put(Telephony.Carriers.BEARER, Integer.parseInt(bearer));
}
+
+ String mvno_type = parser.getAttributeValue(null, "mvno_type");
+ if (mvno_type != null) {
+ String mvno_match_data = parser.getAttributeValue(null, "mvno_match_data");
+ if (mvno_match_data != null) {
+ map.put(Telephony.Carriers.MVNO_TYPE, mvno_type);
+ map.put(Telephony.Carriers.MVNO_MATCH_DATA, mvno_match_data);
+ }
+ }
return map;
}
@@ -320,19 +341,25 @@
private void loadApns(SQLiteDatabase db, XmlPullParser parser) {
if (parser != null) {
try {
- while (true) {
- XmlUtils.nextElement(parser);
+ db.beginTransaction();
+ XmlUtils.nextElement(parser);
+ while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
ContentValues row = getRow(parser);
- if (row != null) {
- insertAddingDefaults(db, CARRIERS_TABLE, row);
- } else {
- break; // do we really want to skip the rest of the file?
+ if (row == null) {
+ throw new XmlPullParserException("Expected 'apn' tag", parser, null);
}
+ insertAddingDefaults(db, CARRIERS_TABLE, row);
+ XmlUtils.nextElement(parser);
}
- } catch (XmlPullParserException e) {
- Log.e(TAG, "Got execption while getting perferred time zone.", e);
+ db.setTransactionSuccessful();
+ } catch (XmlPullParserException e) {
+ Log.e(TAG, "Got XmlPullParserException while loading apns.", e);
} catch (IOException e) {
- Log.e(TAG, "Got execption while getting perferred time zone.", e);
+ Log.e(TAG, "Got IOException while loading apns.", e);
+ } catch (SQLException e) {
+ Log.e(TAG, "Got SQLException while loading apns.", e);
+ } finally {
+ db.endTransaction();
}
}
}
@@ -354,6 +381,12 @@
if (row.containsKey(Telephony.Carriers.BEARER) == false) {
row.put(Telephony.Carriers.BEARER, 0);
}
+ if (row.containsKey(Telephony.Carriers.MVNO_TYPE) == false) {
+ row.put(Telephony.Carriers.MVNO_TYPE, "");
+ }
+ if (row.containsKey(Telephony.Carriers.MVNO_MATCH_DATA) == false) {
+ row.put(Telephony.Carriers.MVNO_MATCH_DATA, "");
+ }
db.insert(CARRIERS_TABLE, null, row);
}
}
@@ -463,8 +496,14 @@
}
SQLiteDatabase db = mOpenHelper.getReadableDatabase();
- Cursor ret = qb.query(db, projectionIn, selection, selectionArgs, null, null, sort);
- ret.setNotificationUri(getContext().getContentResolver(), url);
+ Cursor ret = null;
+ try {
+ ret = qb.query(db, projectionIn, selection, selectionArgs, null, null, sort);
+ } catch (SQLException e) {
+ Log.e(TAG, "got exception when querying: " + e);
+ }
+ if (ret != null)
+ ret.setNotificationUri(getContext().getContentResolver(), url);
return ret;
}
@@ -552,6 +591,12 @@
if (!values.containsKey(Telephony.Carriers.BEARER)) {
values.put(Telephony.Carriers.BEARER, 0);
}
+ if (!values.containsKey(Telephony.Carriers.MVNO_TYPE)) {
+ values.put(Telephony.Carriers.MVNO_TYPE, "");
+ }
+ if (!values.containsKey(Telephony.Carriers.MVNO_MATCH_DATA)) {
+ values.put(Telephony.Carriers.MVNO_MATCH_DATA, "");
+ }
long rowID = db.insert(CARRIERS_TABLE, null, values);
if (rowID > 0)
@@ -729,7 +774,11 @@
private void restoreDefaultAPN() {
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
- db.delete(CARRIERS_TABLE, null, null);
+ try {
+ db.delete(CARRIERS_TABLE, null, null);
+ } catch (SQLException e) {
+ Log.e(TAG, "got exception when deleting to restore: " + e);
+ }
setPreferredApnId((long)-1);
mOpenHelper.initDatabase(db);
}