summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/telephony/TelephonyProvider.java
diff options
context:
space:
mode:
authorWink Saville <wink@google.com>2014-06-09 21:04:39 -0700
committerWink Saville <wink@google.com>2014-06-11 15:13:46 -0700
commite84c0a8cf610ed6172b6319244c908856ac4c4a9 (patch)
tree90707963121e97881b0a8b7f6ff6643eb02516c8 /src/com/android/providers/telephony/TelephonyProvider.java
parentdb8b1cd5ef2b56203c41c29eacf273102d9842ed (diff)
downloadandroid_packages_providers_TelephonyProvider-e84c0a8cf610ed6172b6319244c908856ac4c4a9.tar.gz
android_packages_providers_TelephonyProvider-e84c0a8cf610ed6172b6319244c908856ac4c4a9.tar.bz2
android_packages_providers_TelephonyProvider-e84c0a8cf610ed6172b6319244c908856ac4c4a9.zip
Merge kwd to master.
Add support for MSIM, specifically a table for managing subscriptions. Change-Id: Idb607c0aa32f80fe4fe1539aedea7a221e9e7f04
Diffstat (limited to 'src/com/android/providers/telephony/TelephonyProvider.java')
-rw-r--r--src/com/android/providers/telephony/TelephonyProvider.java363
1 files changed, 319 insertions, 44 deletions
diff --git a/src/com/android/providers/telephony/TelephonyProvider.java b/src/com/android/providers/telephony/TelephonyProvider.java
index b67aac0..d145e1d 100644
--- a/src/com/android/providers/telephony/TelephonyProvider.java
+++ b/src/com/android/providers/telephony/TelephonyProvider.java
@@ -33,6 +33,8 @@ import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import android.os.Environment;
import android.provider.Telephony;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
import android.util.Log;
import android.util.Xml;
@@ -54,17 +56,27 @@ public class TelephonyProvider extends ContentProvider
{
private static final String DATABASE_NAME = "telephony.db";
private static final boolean DBG = true;
+ private static final boolean VDBG = false;
- private static final int DATABASE_VERSION = 8 << 16;
+ private static final int DATABASE_VERSION = 9 << 16;
+ private static final int URL_UNKNOWN = 0;
private static final int URL_TELEPHONY = 1;
private static final int URL_CURRENT = 2;
private static final int URL_ID = 3;
private static final int URL_RESTOREAPN = 4;
private static final int URL_PREFERAPN = 5;
private static final int URL_PREFERAPN_NO_UPDATE = 6;
+ private static final int URL_SIMINFO = 7;
+ private static final int URL_TELEPHONY_USING_SUBID = 8;
+ private static final int URL_CURRENT_USING_SUBID = 9;
+ private static final int URL_RESTOREAPN_USING_SUBID = 10;
+ private static final int URL_PREFERAPN_USING_SUBID = 11;
+ private static final int URL_PREFERAPN_NO_UPDATE_USING_SUBID = 12;
+ private static final int URL_SIMINFO_USING_SUBID = 13;
private static final String TAG = "TelephonyProvider";
private static final String CARRIERS_TABLE = "carriers";
+ private static final String SIMINFO_TABLE = "siminfo";
private static final String PREF_FILE = "preferred-apn";
private static final String COLUMN_APN_ID = "apn_id";
@@ -84,6 +96,16 @@ public class TelephonyProvider extends ContentProvider
s_urlMatcher.addURI("telephony", "carriers/preferapn", URL_PREFERAPN);
s_urlMatcher.addURI("telephony", "carriers/preferapn_no_update", URL_PREFERAPN_NO_UPDATE);
+ s_urlMatcher.addURI("telephony", "siminfo", URL_SIMINFO);
+
+ s_urlMatcher.addURI("telephony", "carriers/subId/*", URL_TELEPHONY_USING_SUBID);
+ s_urlMatcher.addURI("telephony", "carriers/current/subId/*", URL_CURRENT_USING_SUBID);
+ s_urlMatcher.addURI("telephony", "carriers/restore/subId/*", URL_RESTOREAPN_USING_SUBID);
+ s_urlMatcher.addURI("telephony", "carriers/preferapn/subId/*", URL_PREFERAPN_USING_SUBID);
+ s_urlMatcher.addURI("telephony", "carriers/preferapn_no_update/subId/*",
+ URL_PREFERAPN_NO_UPDATE_USING_SUBID);
+
+
s_currentNullMap = new ContentValues(1);
s_currentNullMap.put("current", (Long) null);
@@ -114,7 +136,7 @@ public class TelephonyProvider extends ContentProvider
int publicversion = Integer.parseInt(parser.getAttributeValue(null, "version"));
return DATABASE_VERSION | publicversion;
} catch (Exception e) {
- Log.e(TAG, "Can't get version of APN database", e);
+ loge("Can't get version of APN database" + e);
return DATABASE_VERSION;
} finally {
parser.close();
@@ -123,6 +145,17 @@ public class TelephonyProvider extends ContentProvider
@Override
public void onCreate(SQLiteDatabase db) {
+ db.execSQL("CREATE TABLE " + SIMINFO_TABLE + "("
+ + "_id INTEGER PRIMARY KEY AUTOINCREMENT,"
+ + SubscriptionManager.ICC_ID + " TEXT NOT NULL,"
+ + SubscriptionManager.SIM_ID + " INTEGER DEFAULT " + SubscriptionManager.SIM_NOT_INSERTED + ","
+ + SubscriptionManager.DISPLAY_NAME + " TEXT,"
+ + SubscriptionManager.NAME_SOURCE + " INTEGER DEFAULT " + SubscriptionManager.DEFAULT_SOURCE + ","
+ + SubscriptionManager.COLOR + " INTEGER DEFAULT " + SubscriptionManager.COLOR_DEFAULT + ","
+ + SubscriptionManager.NUMBER + " TEXT,"
+ + SubscriptionManager.DISPLAY_NUMBER_FORMAT + " INTEGER NOT NULL DEFAULT " + SubscriptionManager.DISLPAY_NUMBER_DEFAULT + ","
+ + SubscriptionManager.DATA_ROAMING + " INTEGER DEFAULT " + SubscriptionManager.DATA_ROAMING_DEFAULT
+ + ");");
// Set up the database schema
db.execSQL("CREATE TABLE " + CARRIERS_TABLE +
"(_id INTEGER PRIMARY KEY," +
@@ -147,7 +180,10 @@ public class TelephonyProvider extends ContentProvider
"carrier_enabled BOOLEAN," +
"bearer INTEGER," +
"mvno_type TEXT," +
- "mvno_match_data TEXT);");
+ "mvno_match_data TEXT," +
+ "sub_id LONG DEFAULT -1);");
+ /* FIXME Currenlty sub_id is column is not used for query purpose.
+ This would be modified to more appropriate default value later. */
initDatabase(db);
}
@@ -162,7 +198,7 @@ public class TelephonyProvider extends ContentProvider
publicversion = Integer.parseInt(parser.getAttributeValue(null, "version"));
loadApns(db, parser);
} catch (Exception e) {
- Log.e(TAG, "Got exception while loading APN database.", e);
+ loge("Got exception while loading APN database." + e);
} finally {
parser.close();
}
@@ -190,7 +226,7 @@ public class TelephonyProvider extends ContentProvider
// It's ok if the file isn't found. It means there isn't a confidential file
// Log.e(TAG, "File not found: '" + confFile.getAbsolutePath() + "'");
} catch (Exception e) {
- Log.e(TAG, "Exception while parsing '" + confFile.getAbsolutePath() + "'", e);
+ loge("Exception while parsing '" + confFile.getAbsolutePath() + "'" + e);
} finally {
try { if (confreader != null) confreader.close(); } catch (IOException e) { }
}
@@ -241,6 +277,11 @@ public class TelephonyProvider extends ContentProvider
" ADD COLUMN mvno_match_data TEXT DEFAULT '';");
oldVersion = 8 << 16 | 6;
}
+ if (oldVersion < (9 << 16 | 6)) {
+ db.execSQL("ALTER TABLE " + CARRIERS_TABLE +
+ " ADD COLUMN sub_id LONG DEFAULT -1;");
+ oldVersion = 9 << 16 | 6;
+ }
}
/**
@@ -350,11 +391,11 @@ public class TelephonyProvider extends ContentProvider
}
db.setTransactionSuccessful();
} catch (XmlPullParserException e) {
- Log.e(TAG, "Got XmlPullParserException while loading apns.", e);
+ loge("Got XmlPullParserException while loading apns." + e);
} catch (IOException e) {
- Log.e(TAG, "Got IOException while loading apns.", e);
+ loge("Got IOException while loading apns." + e);
} catch (SQLException e) {
- Log.e(TAG, "Got SQLException while loading apns.", e);
+ loge("Got SQLException while loading apns." + e);
} finally {
db.endTransaction();
}
@@ -394,33 +435,65 @@ public class TelephonyProvider extends ContentProvider
return true;
}
- private void setPreferredApnId(Long id) {
- SharedPreferences sp = getContext().getSharedPreferences(PREF_FILE, Context.MODE_PRIVATE);
+ private void setPreferredApnId(Long id, long subId) {
+ SharedPreferences sp = getContext().getSharedPreferences(
+ PREF_FILE + subId, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.putLong(COLUMN_APN_ID, id != null ? id.longValue() : -1);
editor.apply();
}
- private long getPreferredApnId() {
- SharedPreferences sp = getContext().getSharedPreferences(PREF_FILE, Context.MODE_PRIVATE);
+ private long getPreferredApnId(long subId) {
+ SharedPreferences sp = getContext().getSharedPreferences(
+ PREF_FILE + subId, Context.MODE_PRIVATE);
return sp.getLong(COLUMN_APN_ID, -1);
}
@Override
public Cursor query(Uri url, String[] projectionIn, String selection,
String[] selectionArgs, String sort) {
+ TelephonyManager mTelephonyManager =
+ (TelephonyManager)getContext().getSystemService(Context.TELEPHONY_SERVICE);
+ long subId = SubscriptionManager.getDefaultSubId();
+ String subIdString;
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setStrict(true); // a little protection from injection attacks
qb.setTables("carriers");
int match = s_urlMatcher.match(url);
switch (match) {
+ case URL_TELEPHONY_USING_SUBID: {
+ subIdString = url.getLastPathSegment();
+ try {
+ subId = Long.parseLong(subIdString);
+ } catch (NumberFormatException e) {
+ loge("NumberFormatException" + e);
+ return null;
+ }
+ if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
+ qb.appendWhere("numeric = " + mTelephonyManager.getSimOperator(subId));
+ // FIXME alter the selection to pass subId
+ // selection = selection + "and subId = "
+ }
+ //intentional fall through from above case
// do nothing
case URL_TELEPHONY: {
break;
}
-
+ case URL_CURRENT_USING_SUBID: {
+ subIdString = url.getLastPathSegment();
+ try {
+ subId = Long.parseLong(subIdString);
+ } catch (NumberFormatException e) {
+ loge("NumberFormatException" + e);
+ return null;
+ }
+ if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
+ // FIXME alter the selection to pass subId
+ // selection = selection + "and subId = "
+ }
+ //intentional fall through from above case
case URL_CURRENT: {
qb.appendWhere("current IS NOT NULL");
// do not ignore the selection since MMS may use it.
@@ -433,9 +506,26 @@ public class TelephonyProvider extends ContentProvider
break;
}
+ case URL_PREFERAPN_USING_SUBID:
+ case URL_PREFERAPN_NO_UPDATE_USING_SUBID: {
+ subIdString = url.getLastPathSegment();
+ try {
+ subId = Long.parseLong(subIdString);
+ } catch (NumberFormatException e) {
+ loge("NumberFormatException" + e);
+ return null;
+ }
+ if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
+ }
+ //intentional fall through from above case
case URL_PREFERAPN:
case URL_PREFERAPN_NO_UPDATE: {
- qb.appendWhere("_id = " + getPreferredApnId());
+ qb.appendWhere("_id = " + getPreferredApnId(subId));
+ break;
+ }
+
+ case URL_SIMINFO: {
+ qb.setTables(SIMINFO_TABLE);
break;
}
@@ -444,22 +534,24 @@ public class TelephonyProvider extends ContentProvider
}
}
- if (projectionIn != null) {
- for (String column : projectionIn) {
- if (Telephony.Carriers.TYPE.equals(column) ||
- Telephony.Carriers.MMSC.equals(column) ||
- Telephony.Carriers.MMSPROXY.equals(column) ||
- Telephony.Carriers.MMSPORT.equals(column) ||
- Telephony.Carriers.APN.equals(column)) {
- // noop
- } else {
- checkPermission();
- break;
+ if (match != URL_SIMINFO) {
+ if (projectionIn != null) {
+ for (String column : projectionIn) {
+ if (Telephony.Carriers.TYPE.equals(column) ||
+ Telephony.Carriers.MMSC.equals(column) ||
+ Telephony.Carriers.MMSPROXY.equals(column) ||
+ Telephony.Carriers.MMSPORT.equals(column) ||
+ Telephony.Carriers.APN.equals(column)) {
+ // noop
+ } else {
+ checkPermission();
+ break;
+ }
}
+ } else {
+ // null returns all columns, so need permission check
+ checkPermission();
}
- } else {
- // null returns all columns, so need permission check
- checkPermission();
}
SQLiteDatabase db = mOpenHelper.getReadableDatabase();
@@ -467,7 +559,7 @@ public class TelephonyProvider extends ContentProvider
try {
ret = qb.query(db, projectionIn, selection, selectionArgs, null, null, sort);
} catch (SQLException e) {
- Log.e(TAG, "got exception when querying: " + e);
+ loge("got exception when querying: " + e);
}
if (ret != null)
ret.setNotificationUri(getContext().getContentResolver(), url);
@@ -479,11 +571,14 @@ public class TelephonyProvider extends ContentProvider
{
switch (s_urlMatcher.match(url)) {
case URL_TELEPHONY:
+ case URL_TELEPHONY_USING_SUBID:
return "vnd.android.cursor.dir/telephony-carrier";
case URL_ID:
return "vnd.android.cursor.item/telephony-carrier";
+ case URL_PREFERAPN_USING_SUBID:
+ case URL_PREFERAPN_NO_UPDATE_USING_SUBID:
case URL_PREFERAPN:
case URL_PREFERAPN_NO_UPDATE:
return "vnd.android.cursor.item/telephony-carrier";
@@ -497,6 +592,7 @@ public class TelephonyProvider extends ContentProvider
public Uri insert(Uri url, ContentValues initialValues)
{
Uri result = null;
+ long subId = SubscriptionManager.getDefaultSubId();
checkPermission();
@@ -505,6 +601,19 @@ public class TelephonyProvider extends ContentProvider
boolean notify = false;
switch (match)
{
+ case URL_TELEPHONY_USING_SUBID:
+ {
+ String subIdString = url.getLastPathSegment();
+ try {
+ subId = Long.parseLong(subIdString);
+ } catch (NumberFormatException e) {
+ loge("NumberFormatException" + e);
+ return result;
+ }
+ if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
+ }
+ //intentional fall through from above case
+
case URL_TELEPHONY:
{
ContentValues values;
@@ -565,6 +674,10 @@ public class TelephonyProvider extends ContentProvider
values.put(Telephony.Carriers.MVNO_MATCH_DATA, "");
}
+ if (!values.containsKey(Telephony.Carriers.SUB_ID)) {
+ values.put(Telephony.Carriers.SUB_ID, subId);
+ }
+
long rowID = db.insert(CARRIERS_TABLE, null, values);
if (rowID > 0)
{
@@ -572,10 +685,24 @@ public class TelephonyProvider extends ContentProvider
notify = true;
}
- if (false) Log.d(TAG, "inserted " + values.toString() + " rowID = " + rowID);
+ if (VDBG) log("inserted " + values.toString() + " rowID = " + rowID);
break;
}
+ case URL_CURRENT_USING_SUBID:
+ {
+ String subIdString = url.getLastPathSegment();
+ try {
+ subId = Long.parseLong(subIdString);
+ } catch (NumberFormatException e) {
+ loge("NumberFormatException" + e);
+ return result;
+ }
+ if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
+ // FIXME use subId in the query
+ }
+ //intentional fall through from above case
+
case URL_CURRENT:
{
// null out the previous operator
@@ -587,27 +714,45 @@ public class TelephonyProvider extends ContentProvider
if (updated > 0)
{
- if (false) {
- Log.d(TAG, "Setting numeric '" + numeric + "' to be the current operator");
- }
+ if (VDBG) log("Setting numeric '" + numeric + "' to be the current operator");
}
else
{
- Log.e(TAG, "Failed setting numeric '" + numeric + "' to the current operator");
+ loge("Failed setting numeric '" + numeric + "' to the current operator");
}
break;
}
+ case URL_PREFERAPN_USING_SUBID:
+ case URL_PREFERAPN_NO_UPDATE_USING_SUBID:
+ {
+ String subIdString = url.getLastPathSegment();
+ try {
+ subId = Long.parseLong(subIdString);
+ } catch (NumberFormatException e) {
+ loge("NumberFormatException" + e);
+ return result;
+ }
+ if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
+ }
+ //intentional fall through from above case
+
case URL_PREFERAPN:
case URL_PREFERAPN_NO_UPDATE:
{
if (initialValues != null) {
if(initialValues.containsKey(COLUMN_APN_ID)) {
- setPreferredApnId(initialValues.getAsLong(COLUMN_APN_ID));
+ setPreferredApnId(initialValues.getAsLong(COLUMN_APN_ID), subId);
}
}
break;
}
+
+ case URL_SIMINFO: {
+ long id = db.insert(SIMINFO_TABLE, null, initialValues);
+ result = ContentUris.withAppendedId(SubscriptionManager.CONTENT_URI, id);
+ break;
+ }
}
if (notify) {
@@ -621,6 +766,7 @@ public class TelephonyProvider extends ContentProvider
public int delete(Uri url, String where, String[] whereArgs)
{
int count = 0;
+ long subId = SubscriptionManager.getDefaultSubId();
checkPermission();
@@ -628,12 +774,39 @@ public class TelephonyProvider extends ContentProvider
int match = s_urlMatcher.match(url);
switch (match)
{
+ case URL_TELEPHONY_USING_SUBID:
+ {
+ String subIdString = url.getLastPathSegment();
+ try {
+ subId = Long.parseLong(subIdString);
+ } catch (NumberFormatException e) {
+ loge("NumberFormatException" + e);
+ throw new IllegalArgumentException("Invalid subId " + url);
+ }
+ if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
+ // FIXME use subId in query
+ }
+ //intentional fall through from above case
+
case URL_TELEPHONY:
{
count = db.delete(CARRIERS_TABLE, where, whereArgs);
break;
}
+ case URL_CURRENT_USING_SUBID: {
+ String subIdString = url.getLastPathSegment();
+ try {
+ subId = Long.parseLong(subIdString);
+ } catch (NumberFormatException e) {
+ loge("NumberFormatException" + e);
+ throw new IllegalArgumentException("Invalid subId " + url);
+ }
+ if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
+ // FIXME use subId in query
+ }
+ //intentional fall through from above case
+
case URL_CURRENT:
{
count = db.delete(CARRIERS_TABLE, where, whereArgs);
@@ -647,17 +820,46 @@ public class TelephonyProvider extends ContentProvider
break;
}
+ case URL_RESTOREAPN_USING_SUBID: {
+ String subIdString = url.getLastPathSegment();
+ try {
+ subId = Long.parseLong(subIdString);
+ } catch (NumberFormatException e) {
+ loge("NumberFormatException" + e);
+ throw new IllegalArgumentException("Invalid subId " + url);
+ }
+ if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
+ // FIXME use subId in query
+ }
case URL_RESTOREAPN: {
count = 1;
- restoreDefaultAPN();
+ restoreDefaultAPN(subId);
break;
}
+ case URL_PREFERAPN_USING_SUBID:
+ case URL_PREFERAPN_NO_UPDATE_USING_SUBID: {
+ String subIdString = url.getLastPathSegment();
+ try {
+ subId = Long.parseLong(subIdString);
+ } catch (NumberFormatException e) {
+ loge("NumberFormatException" + e);
+ throw new IllegalArgumentException("Invalid subId " + url);
+ }
+ if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
+ }
+ //intentional fall through from above case
+
case URL_PREFERAPN:
case URL_PREFERAPN_NO_UPDATE:
{
- setPreferredApnId((long)-1);
- if (match == URL_PREFERAPN) count = 1;
+ setPreferredApnId((long)-1, subId);
+ if ((match == URL_PREFERAPN) || (match == URL_PREFERAPN_USING_SUBID)) count = 1;
+ break;
+ }
+
+ case URL_SIMINFO: {
+ count = db.delete(SIMINFO_TABLE, where, whereArgs);
break;
}
@@ -677,6 +879,8 @@ public class TelephonyProvider extends ContentProvider
public int update(Uri url, ContentValues values, String where, String[] whereArgs)
{
int count = 0;
+ int uriType = URL_UNKNOWN;
+ long subId = SubscriptionManager.getDefaultSubId();
checkPermission();
@@ -684,12 +888,40 @@ public class TelephonyProvider extends ContentProvider
int match = s_urlMatcher.match(url);
switch (match)
{
+ case URL_TELEPHONY_USING_SUBID:
+ {
+ String subIdString = url.getLastPathSegment();
+ try {
+ subId = Long.parseLong(subIdString);
+ } catch (NumberFormatException e) {
+ loge("NumberFormatException" + e);
+ throw new IllegalArgumentException("Invalid subId " + url);
+ }
+ if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
+ //FIXME use subId in the query
+ }
+ //intentional fall through from above case
+
case URL_TELEPHONY:
{
count = db.update(CARRIERS_TABLE, values, where, whereArgs);
break;
}
+ case URL_CURRENT_USING_SUBID:
+ {
+ String subIdString = url.getLastPathSegment();
+ try {
+ subId = Long.parseLong(subIdString);
+ } catch (NumberFormatException e) {
+ loge("NumberFormatException" + e);
+ throw new IllegalArgumentException("Invalid subId " + url);
+ }
+ if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
+ //FIXME use subId in the query
+ }
+ //intentional fall through from above case
+
case URL_CURRENT:
{
count = db.update(CARRIERS_TABLE, values, where, whereArgs);
@@ -707,25 +939,55 @@ public class TelephonyProvider extends ContentProvider
break;
}
+ case URL_PREFERAPN_USING_SUBID:
+ case URL_PREFERAPN_NO_UPDATE_USING_SUBID:
+ {
+ String subIdString = url.getLastPathSegment();
+ try {
+ subId = Long.parseLong(subIdString);
+ } catch (NumberFormatException e) {
+ loge("NumberFormatException" + e);
+ throw new IllegalArgumentException("Invalid subId " + url);
+ }
+ if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
+ }
+
case URL_PREFERAPN:
case URL_PREFERAPN_NO_UPDATE:
{
if (values != null) {
if (values.containsKey(COLUMN_APN_ID)) {
- setPreferredApnId(values.getAsLong(COLUMN_APN_ID));
- if (match == URL_PREFERAPN) count = 1;
+ setPreferredApnId(values.getAsLong(COLUMN_APN_ID), subId);
+ if ((match == URL_PREFERAPN) ||
+ (match == URL_PREFERAPN_USING_SUBID)) {
+ count = 1;
+ }
}
}
break;
}
+ case URL_SIMINFO: {
+ count = db.update(SIMINFO_TABLE, values, where, whereArgs);
+ uriType = URL_SIMINFO;
+ break;
+ }
+
default: {
throw new UnsupportedOperationException("Cannot update that URL: " + url);
}
}
if (count > 0) {
- getContext().getContentResolver().notifyChange(Telephony.Carriers.CONTENT_URI, null);
+ switch (uriType) {
+ case URL_SIMINFO:
+ getContext().getContentResolver().notifyChange(
+ SubscriptionManager.CONTENT_URI, null);
+ break;
+ default:
+ getContext().getContentResolver().notifyChange(
+ Telephony.Carriers.CONTENT_URI, null);
+ }
}
return count;
@@ -738,15 +1000,28 @@ public class TelephonyProvider extends ContentProvider
private DatabaseHelper mOpenHelper;
- private void restoreDefaultAPN() {
+ private void restoreDefaultAPN(long subId) {
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
try {
db.delete(CARRIERS_TABLE, null, null);
} catch (SQLException e) {
- Log.e(TAG, "got exception when deleting to restore: " + e);
+ loge("got exception when deleting to restore: " + e);
}
- setPreferredApnId((long)-1);
+ setPreferredApnId((long)-1, subId);
mOpenHelper.initDatabase(db);
}
+
+ /**
+ * Log with debug
+ *
+ * @param s is string log
+ */
+ private static void log(String s) {
+ Log.d(TAG, s);
+ }
+
+ private static void loge(String s) {
+ Log.e(TAG, s);
+ }
}