Merge "refactor data/voice roaming states"
diff --git a/src/com/android/providers/telephony/TelephonyProvider.java b/src/com/android/providers/telephony/TelephonyProvider.java
index 3d791de..fffd78c 100644
--- a/src/com/android/providers/telephony/TelephonyProvider.java
+++ b/src/com/android/providers/telephony/TelephonyProvider.java
@@ -388,6 +388,7 @@
s_urlMatcher.addURI("telephony", "carriers/preferapnset", URL_PREFERAPNSET);
s_urlMatcher.addURI("telephony", "siminfo", URL_SIMINFO);
+ s_urlMatcher.addURI("telephony", "siminfo/#", URL_SIMINFO_USING_SUBID);
s_urlMatcher.addURI("telephony", "carriers/subId/*", URL_TELEPHONY_USING_SUBID);
s_urlMatcher.addURI("telephony", "carriers/current/subId/*", URL_CURRENT_USING_SUBID);
@@ -3243,6 +3244,24 @@
break;
}
+ case URL_SIMINFO_USING_SUBID:
+ String subIdString = url.getLastPathSegment();
+ try {
+ subId = Integer.parseInt(subIdString);
+ } catch (NumberFormatException e) {
+ loge("NumberFormatException" + e);
+ throw new IllegalArgumentException("Invalid subId " + url);
+ }
+ if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
+ if (where != null || whereArgs != null) {
+ throw new UnsupportedOperationException(
+ "Cannot update URL " + url + " with a where clause");
+ }
+ count = db.update(SIMINFO_TABLE, values, _ID + "=?",
+ new String[] { subIdString});
+ uriType = URL_SIMINFO_USING_SUBID;
+ break;
+
case URL_SIMINFO: {
count = db.update(SIMINFO_TABLE, values, where, whereArgs);
uriType = URL_SIMINFO;
@@ -3255,10 +3274,27 @@
}
if (count > 0) {
+ Uri wfcNotifyUri = SubscriptionManager.WFC_ENABLED_CONTENT_URI;
+ Uri enhanced4GNotifyUri = SubscriptionManager.ENHANCED_4G_ENABLED_CONTENT_URI;
switch (uriType) {
+ case URL_SIMINFO_USING_SUBID:
+ wfcNotifyUri = Uri.withAppendedPath(
+ SubscriptionManager.WFC_ENABLED_CONTENT_URI, "" + subId);
+ enhanced4GNotifyUri = Uri.withAppendedPath(
+ SubscriptionManager.ENHANCED_4G_ENABLED_CONTENT_URI, "" + subId);
+ // intentional fall through from above case
case URL_SIMINFO:
getContext().getContentResolver().notifyChange(
SubscriptionManager.CONTENT_URI, null, true, UserHandle.USER_ALL);
+ // notify observers on specific user settings changes.
+ if (values.containsKey(SubscriptionManager.WFC_IMS_ENABLED)) {
+ getContext().getContentResolver().notifyChange(
+ wfcNotifyUri, null, true, UserHandle.USER_ALL);
+ }
+ if (values.containsKey(SubscriptionManager.ENHANCED_4G_MODE_ENABLED)) {
+ getContext().getContentResolver().notifyChange(
+ enhanced4GNotifyUri, null, true, UserHandle.USER_ALL);
+ }
break;
default:
getContext().getContentResolver().notifyChange(
diff --git a/tests/AndroidTest.xml b/tests/AndroidTest.xml
index 129f4d9..ad703de 100644
--- a/tests/AndroidTest.xml
+++ b/tests/AndroidTest.xml
@@ -22,7 +22,7 @@
<option name="test-tag" value="TelephonyProviderTests" />
<test class="com.android.tradefed.testtype.InstrumentationTest" >
<option name="package" value="com.android.providers.telephony.tests" />
- <option name="runner" value="android.test.InstrumentationTestRunner" />
+ <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
<option name="hidden-api-checks" value="false"/>
</test>
</configuration>
diff --git a/tests/src/com/android/providers/telephony/TelephonyProviderTest.java b/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
index 465b5b1..715f3dd 100644
--- a/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
+++ b/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
@@ -73,6 +73,8 @@
private int notifyChangeCount;
private int notifyChangeRestoreCount;
+ private int notifyWfcCount;
+ private int notifyWfcCountWithTestSubId;
private static final String TEST_SUBID = "1";
private static final String TEST_OPERATOR = "123456";
@@ -88,6 +90,8 @@
// Used to test the preferred apn
private static final Uri URL_PREFERAPN_USING_SUBID = Uri.parse(
"content://telephony/carriers/preferapn/subId/" + TEST_SUBID);
+ private static final Uri URL_WFC_ENABLED_USING_SUBID = Uri.parse(
+ "content://telephony/siminfo/" + TEST_SUBID);
private static final String COLUMN_APN_ID = "apn_id";
@@ -119,6 +123,10 @@
notifyChangeCount++;
if (URL_RESTOREAPN_USING_SUBID.equals(uri)) {
notifyChangeRestoreCount++;
+ } else if (SubscriptionManager.WFC_ENABLED_CONTENT_URI.equals(uri)) {
+ notifyWfcCount++;
+ } else if (URL_WFC_ENABLED_USING_SUBID.equals(uri)) {
+ notifyWfcCountWithTestSubId++;
}
}
};
@@ -1382,4 +1390,53 @@
assertEquals(0, cursor.getCount());
assertEquals(3, notifyChangeRestoreCount);
}
+
+ /**
+ * Test changes to siminfo/WFC_IMS_ENABLED and simInfo/ENHANCED_4G
+ */
+ @Test
+ @SmallTest
+ public void testUpdateWfcEnabled() {
+ // insert test contentValues
+ ContentValues contentValues = new ContentValues();
+ final int insertSubId = 1;
+ final String insertDisplayName = "exampleDisplayName";
+ final String insertCarrierName = "exampleCarrierName";
+ final String insertIccId = "exampleIccId";
+ final String insertCardId = "exampleCardId";
+ contentValues.put(SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID, insertSubId);
+ contentValues.put(SubscriptionManager.DISPLAY_NAME, insertDisplayName);
+ contentValues.put(SubscriptionManager.CARRIER_NAME, insertCarrierName);
+ contentValues.put(SubscriptionManager.ICC_ID, insertIccId);
+ contentValues.put(SubscriptionManager.CARD_ID, insertCardId);
+
+ Log.d(TAG, "testSimTable Inserting wfc contentValues: " + contentValues);
+ mContentResolver.insert(SubscriptionManager.CONTENT_URI, contentValues);
+ assertEquals(0, notifyWfcCount);
+
+ // update wfc_enabled
+ ContentValues values = new ContentValues();
+ values.put(SubscriptionManager.WFC_IMS_ENABLED, true);
+ final String selection = SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID + "=?";
+ final String[] selectionArgs = { "" + insertSubId };
+ mContentResolver.update(SubscriptionManager.CONTENT_URI, values, selection, selectionArgs);
+ assertEquals(1, notifyWfcCount);
+ assertEquals(0, notifyWfcCountWithTestSubId);
+
+ // update other fields
+ values = new ContentValues();
+ values.put(SubscriptionManager.DISPLAY_NAME, "exampleDisplayNameNew");
+ mContentResolver.update(SubscriptionManager.CONTENT_URI, values, selection, selectionArgs);
+ // expect no change on wfc count
+ assertEquals(1, notifyWfcCount);
+ assertEquals(0, notifyWfcCountWithTestSubId);
+
+ // update WFC using subId
+ values = new ContentValues();
+ values.put(SubscriptionManager.WFC_IMS_ENABLED, false);
+ mContentResolver.update(SubscriptionManager.getUriForSubscriptionId(insertSubId),
+ values, null, null);
+ assertEquals(1, notifyWfcCount);
+ assertEquals(0, notifyWfcCountWithTestSubId);
+ }
}