[automerger skipped] Import translations. DO NOT MERGE ANYWHERE am: 1af94d4c08 -s ours
am skip reason: subject contains skip directive
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/providers/TelephonyProvider/+/13113851
Change-Id: I356e20cf3a9f1553adb4b237bf1e595323193f88
diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/assets/README b/assets/README
index ad6a29c..43b0965 100644
--- a/assets/README
+++ b/assets/README
@@ -10,3 +10,50 @@
DO NOT MANUALLY EDIT THIS FILE
This file defines carrier id and should be single versioned.
+
+===== How to test carrier id locally =====
+
+If you want to make change locally during testing, currently there are two ways:
+
+1. Modify carrierIdentification.db database by SQL command
+
+For example (Insert MCCMNC '12345' and gid1 'test' to carrier id 20000):
+```
+$ adb shell
+device:/ $ su
+device:/ # DB='/data/user_de/0/com.android.providers.telephony/databases/carrierIdentification.db'
+device:/ # sqlite3 $DB "INSERT INTO carrier_id(mccmnc, gid1, carrier_id, carrier_name) VALUES (12345, 'test', 20000, 'test_carrier')"
+device:/ # reboot
+```
+
+2. Override carrier_list.pb
+
+- Modify carrier_list.textpb directly (Note: You should also bump the version
+ number to let TelephonyProvider reload the carrier_list.pb)
+- Generate class file by using the carrier id proto(TelephonyProvider/proto/src/carrierId.proto)
+ (See https://developers.google.com/protocol-buffers/docs/overview#generating)
+- Create a converter by using TextFormat tool to convert textpb to pb
+ (Text Format: https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/TextFormat)
+- Rename file to carrier_list_test.pb and push the output file to
+ /data/user_de/0/com.android.providers.telephony/files/carrier_list_test.pb
+- Reboot the device
+
+Converter example:
+```
+#!/usr/bin/env python3
+from google.protobuf import text_format
+
+# Generated by: protoc -I=./ --python_out=./ ./carrierId.proto
+from carrierId_pb2 import CarrierList
+
+def main():
+ with open("carrier_list.textpb", "r") as rd:
+ carrierList = CarrierList()
+ text_format.Merge(rd.read(), carrierList)
+
+ with open("carrier_list.pb", "wb") as wf:
+ wf.write(carrierList.SerializeToString())
+
+if __name__ == '__main__':
+ main()
+```
diff --git a/assets/latest_carrier_id/carrier_list.pb b/assets/latest_carrier_id/carrier_list.pb
index 2554f6f..6b126ce 100644
--- a/assets/latest_carrier_id/carrier_list.pb
+++ b/assets/latest_carrier_id/carrier_list.pb
Binary files differ
diff --git a/assets/latest_carrier_id/carrier_list.textpb b/assets/latest_carrier_id/carrier_list.textpb
index c76b4fe..79d5852 100644
--- a/assets/latest_carrier_id/carrier_list.textpb
+++ b/assets/latest_carrier_id/carrier_list.textpb
Binary files differ
diff --git a/assets/sdk28_carrier_id/carrier_list.pb b/assets/sdk28_carrier_id/carrier_list.pb
index 700eb89..b672006 100644
--- a/assets/sdk28_carrier_id/carrier_list.pb
+++ b/assets/sdk28_carrier_id/carrier_list.pb
Binary files differ
diff --git a/assets/sdk28_carrier_id/carrier_list.textpb b/assets/sdk28_carrier_id/carrier_list.textpb
index 619d989..131b414 100644
--- a/assets/sdk28_carrier_id/carrier_list.textpb
+++ b/assets/sdk28_carrier_id/carrier_list.textpb
Binary files differ
diff --git a/assets/sdk29_carrier_id/carrier_list.pb b/assets/sdk29_carrier_id/carrier_list.pb
index 3519d2c..be41a43 100644
--- a/assets/sdk29_carrier_id/carrier_list.pb
+++ b/assets/sdk29_carrier_id/carrier_list.pb
Binary files differ
diff --git a/assets/sdk29_carrier_id/carrier_list.textpb b/assets/sdk29_carrier_id/carrier_list.textpb
index b1c6825..b21d6ec 100644
--- a/assets/sdk29_carrier_id/carrier_list.textpb
+++ b/assets/sdk29_carrier_id/carrier_list.textpb
Binary files differ
diff --git a/assets/sdk30_carrier_id/carrier_list.pb b/assets/sdk30_carrier_id/carrier_list.pb
new file mode 100644
index 0000000..2554f6f
--- /dev/null
+++ b/assets/sdk30_carrier_id/carrier_list.pb
Binary files differ
diff --git a/assets/sdk30_carrier_id/carrier_list.textpb b/assets/sdk30_carrier_id/carrier_list.textpb
new file mode 100644
index 0000000..c76b4fe
--- /dev/null
+++ b/assets/sdk30_carrier_id/carrier_list.textpb
Binary files differ
diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml
index 9bcbd19..309a57b 100644
--- a/res/values-ar/strings.xml
+++ b/res/values-ar/strings.xml
@@ -16,6 +16,6 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_label" product="tablet" msgid="9194799012395299737">"إعداد شبكة الجوال"</string>
+ <string name="app_label" product="tablet" msgid="9194799012395299737">"تهيئة شبكة الجوال"</string>
<string name="app_label" product="default" msgid="8338087656149558019">"مساحة تخزين للهاتف والرسائل"</string>
</resources>
diff --git a/res/values-mn/strings.xml b/res/values-mn/strings.xml
index dc13503..1c1c927 100644
--- a/res/values-mn/strings.xml
+++ b/res/values-mn/strings.xml
@@ -17,5 +17,5 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" product="tablet" msgid="9194799012395299737">"Мобайль Сүлжээний Тохируулга"</string>
- <string name="app_label" product="default" msgid="8338087656149558019">"Гар утас болон Мессежийн Санах ой"</string>
+ <string name="app_label" product="default" msgid="8338087656149558019">"Гар утас болон Зурвасын Санах ой"</string>
</resources>
diff --git a/src/com/android/providers/telephony/CarrierIdProvider.java b/src/com/android/providers/telephony/CarrierIdProvider.java
index a3c299f..3e751aa 100644
--- a/src/com/android/providers/telephony/CarrierIdProvider.java
+++ b/src/com/android/providers/telephony/CarrierIdProvider.java
@@ -83,6 +83,9 @@
private static final int VERSION_BITMASK = 0x00FFFFFF;
private static final String OTA_UPDATED_PB_PATH = "misc/carrierid/" + ASSETS_PB_FILE;
private static final String PREF_FILE = CarrierIdProvider.class.getSimpleName();
+ // For testing purposes only.
+ private static final String OVERRIDE_PB_PATH =
+ "/data/user_de/0/com.android.providers.telephony/files/carrier_list_test.pb";
private static final UriMatcher s_urlMatcher = new UriMatcher(UriMatcher.NO_MATCH);
@@ -527,9 +530,14 @@
CarrierIdProto.CarrierList assets = null;
CarrierIdProto.CarrierList ota = null;
InputStream is = null;
+ File testFile = new File(OVERRIDE_PB_PATH);
try {
- is = getContext().getAssets().open(ASSETS_PB_FILE);
+ if (Build.IS_DEBUGGABLE && testFile.exists()) {
+ is = new FileInputStream(testFile);
+ } else {
+ is = getContext().getAssets().open(ASSETS_PB_FILE);
+ }
assets = CarrierIdProto.CarrierList.parseFrom(readInputStreamToByteArray(is));
} catch (IOException ex) {
Log.e(TAG, "read carrier list from assets pb failure: " + ex);
diff --git a/src/com/android/providers/telephony/SmsProvider.java b/src/com/android/providers/telephony/SmsProvider.java
index 81f732b..d378c64 100644
--- a/src/com/android/providers/telephony/SmsProvider.java
+++ b/src/com/android/providers/telephony/SmsProvider.java
@@ -84,7 +84,7 @@
"body", // getDisplayMessageBody
"date", // getTimestampMillis
"status", // getStatusOnIcc
- "index_on_icc", // getIndexOnIcc
+ "index_on_icc", // getIndexOnIcc (1-based index)
"is_status_report", // isStatusReportMessage
"transport_type", // Always "sms".
"type", // depend on getStatusOnIcc
@@ -353,20 +353,42 @@
type = Sms.MESSAGE_TYPE_OUTBOX;
break;
}
+
+ String address = (type == Sms.MESSAGE_TYPE_INBOX)
+ ? message.getDisplayOriginatingAddress()
+ : message.getRecipientAddress();
+
+ int index = message.getIndexOnIcc();
+ if (address == null) {
+ // The status byte of an EF_SMS record may not be correct. try to read other address
+ // type again.
+ Log.e(TAG, "convertIccToSms: EF_SMS(" + index + ")=> address=null, type=" + type
+ + ", status=" + statusOnIcc + "(may not be correct). fallback to other type.");
+ address = (type == Sms.MESSAGE_TYPE_INBOX)
+ ? message.getRecipientAddress()
+ : message.getDisplayOriginatingAddress();
+
+ if (address != null) {
+ // Rely on actual PDU(address) to set type again.
+ type = (type == Sms.MESSAGE_TYPE_INBOX)
+ ? Sms.MESSAGE_TYPE_SENT
+ : Sms.MESSAGE_TYPE_INBOX;
+ Log.d(TAG, "convertIccToSms: new type=" + type + ", address=xxxxxx");
+ } else {
+ Log.e(TAG, "convertIccToSms: no change");
+ }
+ }
+
// N.B.: These calls must appear in the same order as the
// columns appear in ICC_COLUMNS.
Object[] row = new Object[13];
row[0] = message.getServiceCenterAddress();
- row[1] =
- (type == Sms.MESSAGE_TYPE_INBOX)
- ? message.getDisplayOriginatingAddress()
- : message.getRecipientAddress();
-
+ row[1] = address;
row[2] = String.valueOf(message.getMessageClass());
row[3] = message.getDisplayMessageBody();
row[4] = message.getTimestampMillis();
row[5] = statusOnIcc;
- row[6] = message.getIndexOnIcc();
+ row[6] = index;
row[7] = message.isStatusReportMessage();
row[8] = "sms";
row[9] = type;
@@ -380,7 +402,7 @@
* Gets single message from the ICC for a subscription ID.
*
* @param subId the subscription ID.
- * @param messageIndex the message index of the messaage in the ICC.
+ * @param messageIndex the message index of the messaage in the ICC (1-based index).
* @return a cursor containing just one message from the ICC for the subscription ID.
*/
private Cursor getSingleMessageFromIcc(int subId, int messageIndex) {
@@ -393,19 +415,24 @@
// Use phone app permissions to avoid UID mismatch in AppOpsManager.noteOp() call.
long token = Binder.clearCallingIdentity();
try {
+ // getMessagesFromIcc() returns a zero-based list of valid messages in the ICC.
messages = smsManager.getMessagesFromIcc();
} finally {
Binder.restoreCallingIdentity(token);
}
- final SmsMessage message = messages.get(messageIndex);
- if (message == null) {
- throw new IllegalArgumentException(
- "No message in index " + messageIndex + " for subId " + subId);
+ final int count = messages.size();
+ for (int i = 0; i < count; i++) {
+ SmsMessage message = messages.get(i);
+ if (message != null && message.getIndexOnIcc() == messageIndex) {
+ MatrixCursor cursor = new MatrixCursor(ICC_COLUMNS, 1);
+ cursor.addRow(convertIccToSms(message, 0));
+ return cursor;
+ }
}
- MatrixCursor cursor = new MatrixCursor(ICC_COLUMNS, 1);
- cursor.addRow(convertIccToSms(message, 0));
- return cursor;
+
+ throw new IllegalArgumentException(
+ "No message in index " + messageIndex + " for subId " + subId);
}
/**
@@ -424,6 +451,7 @@
// Use phone app permissions to avoid UID mismatch in AppOpsManager.noteOp() call
long token = Binder.clearCallingIdentity();
try {
+ // getMessagesFromIcc() returns a zero-based list of valid messages in the ICC.
messages = smsManager.getMessagesFromIcc();
} finally {
Binder.restoreCallingIdentity(token);
@@ -882,31 +910,62 @@
count = db.delete("sr_pending", where, whereArgs);
break;
+ case SMS_ALL_ICC:
+ case SMS_ALL_ICC_SUBID:
+ {
+ int subId;
+ int deletedCnt;
+ if (match == SMS_ALL_ICC) {
+ subId = SmsManager.getDefaultSmsSubscriptionId();
+ } else {
+ try {
+ subId = Integer.parseInt(url.getPathSegments().get(1));
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException("Wrong path segements, uri= " + url);
+ }
+ }
+ deletedCnt = deleteAllMessagesFromIcc(subId);
+ // Notify changes even failure case since there might be some changes should be
+ // known.
+ getContext()
+ .getContentResolver()
+ .notifyChange(
+ match == SMS_ALL_ICC ? ICC_URI : ICC_SUBID_URI,
+ null,
+ true,
+ UserHandle.USER_ALL);
+ return deletedCnt;
+ }
+
case SMS_ICC:
case SMS_ICC_SUBID:
- int subId;
- int messageIndex;
- boolean success;
- try {
- if (match == SMS_ICC) {
- subId = SmsManager.getDefaultSmsSubscriptionId();
- messageIndex = Integer.parseInt(url.getPathSegments().get(1));
- } else {
- subId = Integer.parseInt(url.getPathSegments().get(1));
- messageIndex = Integer.parseInt(url.getPathSegments().get(2));
+ {
+ int subId;
+ int messageIndex;
+ boolean success;
+ try {
+ if (match == SMS_ICC) {
+ subId = SmsManager.getDefaultSmsSubscriptionId();
+ messageIndex = Integer.parseInt(url.getPathSegments().get(1));
+ } else {
+ subId = Integer.parseInt(url.getPathSegments().get(1));
+ messageIndex = Integer.parseInt(url.getPathSegments().get(2));
+ }
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException("Wrong path segements, uri= " + url);
}
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException("Wrong path segements, uri= " + url);
+ success = deleteMessageFromIcc(subId, messageIndex);
+ // Notify changes even failure case since there might be some changes should be
+ // known.
+ getContext()
+ .getContentResolver()
+ .notifyChange(
+ match == SMS_ICC ? ICC_URI : ICC_SUBID_URI,
+ null,
+ true,
+ UserHandle.USER_ALL);
+ return success ? 1 : 0; // return deleted count
}
- success = deleteMessageFromIcc(subId, messageIndex);
- // Notify changes even failure case since there might be some changes should be
- // known.
- getContext().getContentResolver().notifyChange(
- match == SMS_ICC ? ICC_URI : ICC_SUBID_URI,
- null,
- true,
- UserHandle.USER_ALL);
- return success ? 1 : 0; // return deleted count
default:
throw new IllegalArgumentException("Unknown URL");
@@ -922,7 +981,7 @@
* Deletes the message at index from the ICC for a subscription ID.
*
* @param subId the subscription ID.
- * @param messageIndex the message index of the message in the ICC.
+ * @param messageIndex the message index of the message in the ICC (1-based index).
* @return true for succeess. Otherwise false.
*/
private boolean deleteMessageFromIcc(int subId, int messageIndex) {
@@ -940,6 +999,38 @@
}
}
+ /**
+ * Deletes all the messages from the ICC for a subscription ID.
+ *
+ * @param subId the subscription ID.
+ * @return return deleted messaegs count.
+ */
+ private int deleteAllMessagesFromIcc(int subId) {
+ if (!SubscriptionManager.isValidSubscriptionId(subId)) {
+ throw new IllegalArgumentException("Invalid Subscription ID " + subId);
+ }
+ SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(subId);
+
+ // Use phone app permissions to avoid UID mismatch in AppOpsManager.noteOp() call.
+ long token = Binder.clearCallingIdentity();
+ try {
+ int deletedCnt = 0;
+ int maxIndex = smsManager.getSmsCapacityOnIcc();
+ // messageIndex is 1-based index of the message in the ICC.
+ for (int messageIndex = 1; messageIndex <= maxIndex; messageIndex++) {
+ if (smsManager.deleteMessageFromIcc(messageIndex)) {
+ deletedCnt++;
+ } else {
+ Log.e(TAG, "Fail to delete SMS at index " + messageIndex
+ + " for subId " + subId);
+ }
+ }
+ return deletedCnt;
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
+
@Override
public int update(Uri url, ContentValues values, String where, String[] whereArgs) {
final int callerUid = Binder.getCallingUid();
diff --git a/src/com/android/providers/telephony/TelephonyBackupAgent.java b/src/com/android/providers/telephony/TelephonyBackupAgent.java
index 930a98a..6ce5da1 100644
--- a/src/com/android/providers/telephony/TelephonyBackupAgent.java
+++ b/src/com/android/providers/telephony/TelephonyBackupAgent.java
@@ -1174,9 +1174,9 @@
if (DEBUG) {
Log.d(TAG, "Add mms:\n" + mms);
}
- final long dummyId = System.currentTimeMillis(); // Dummy ID of the msg.
+ final long placeholderId = System.currentTimeMillis(); // Placeholder ID of the msg.
final Uri partUri = Telephony.Mms.CONTENT_URI.buildUpon()
- .appendPath(String.valueOf(dummyId)).appendPath("part").build();
+ .appendPath(String.valueOf(placeholderId)).appendPath("part").build();
final String srcName = String.format(Locale.US, "text.%06d.txt", 0);
{ // Insert SMIL part.
@@ -1184,7 +1184,7 @@
final String smil = TextUtils.isEmpty(mms.smil) ?
String.format(sSmilTextOnly, smilBody) : mms.smil;
final ContentValues values = new ContentValues(7);
- values.put(Telephony.Mms.Part.MSG_ID, dummyId);
+ values.put(Telephony.Mms.Part.MSG_ID, placeholderId);
values.put(Telephony.Mms.Part.SEQ, -1);
values.put(Telephony.Mms.Part.CONTENT_TYPE, ContentType.APP_SMIL);
values.put(Telephony.Mms.Part.NAME, "smil.xml");
@@ -1199,7 +1199,7 @@
{ // Insert body part.
final ContentValues values = new ContentValues(8);
- values.put(Telephony.Mms.Part.MSG_ID, dummyId);
+ values.put(Telephony.Mms.Part.MSG_ID, placeholderId);
values.put(Telephony.Mms.Part.SEQ, 0);
values.put(Telephony.Mms.Part.CONTENT_TYPE, ContentType.TEXT_PLAIN);
values.put(Telephony.Mms.Part.NAME, srcName);
@@ -1221,7 +1221,7 @@
// Insert the attachment parts.
for (ContentValues mmsAttachment : mms.attachments) {
final ContentValues values = new ContentValues(6);
- values.put(Telephony.Mms.Part.MSG_ID, dummyId);
+ values.put(Telephony.Mms.Part.MSG_ID, placeholderId);
values.put(Telephony.Mms.Part.SEQ, 0);
values.put(Telephony.Mms.Part.CONTENT_TYPE,
mmsAttachment.getAsString(MMS_MIME_TYPE));
diff --git a/src/com/android/providers/telephony/TelephonyProvider.java b/src/com/android/providers/telephony/TelephonyProvider.java
index f07ecb3..98bc81e 100644
--- a/src/com/android/providers/telephony/TelephonyProvider.java
+++ b/src/com/android/providers/telephony/TelephonyProvider.java
@@ -774,7 +774,7 @@
confparser.setInput(confreader);
XmlUtils.beginDocument(confparser, "apns");
- // Sanity check. Force internal version and confidential versions to agree
+ // Correctness check. Force internal version and confidential versions to agree
int confversion = Integer.parseInt(confparser.getAttributeValue(null, "version"));
if (publicversion != confversion) {
log("initDatabase: throwing exception due to version mismatch");
@@ -2013,7 +2013,7 @@
int columnIndex = c.getColumnIndex(key);
if (columnIndex != -1) {
String fromCursor = c.getString(columnIndex);
- if (!TextUtils.isEmpty(fromCursor)) {
+ if (fromCursor != null) {
cv.put(key, fromCursor);
}
}
diff --git a/tests/src/com/android/providers/telephony/CarrierIdProviderTest.java b/tests/src/com/android/providers/telephony/CarrierIdProviderTest.java
index ee0e016..921b59c 100644
--- a/tests/src/com/android/providers/telephony/CarrierIdProviderTest.java
+++ b/tests/src/com/android/providers/telephony/CarrierIdProviderTest.java
@@ -58,18 +58,18 @@
private static final String TAG = CarrierIdProviderTest.class.getSimpleName();
- private static final String dummy_mccmnc = "MCCMNC_DUMMY";
- private static final String dummy_gid1 = "GID1_DUMMY";
- private static final String dummy_gid2 = "GID2_DUMMY";
- private static final String dummy_plmn = "PLMN_DUMMY";
- private static final String dummy_imsi_prefix = "IMSI_PREFIX_DUMMY";
- private static final String dummy_spn = "SPN_DUMMY";
- private static final String dummy_apn = "APN_DUMMY";
- private static final String dummy_iccid_prefix = "ICCID_PREFIX_DUMMY";
- private static final String dummy_name = "NAME_DUMMY";
- private static final String dummy_access_rule =
+ private static final String test_mccmnc = "MCCMNC_TEST";
+ private static final String test_gid1 = "GID1_TEST";
+ private static final String test_gid2 = "GID2_TEST";
+ private static final String test_plmn = "PLMN_TEST";
+ private static final String test_imsi_prefix = "IMSI_PREFIX_TEST";
+ private static final String test_spn = "SPN_TEST";
+ private static final String test_apn = "APN_TEST";
+ private static final String test_iccid_prefix = "ICCID_PREFIX_TEST";
+ private static final String test_name = "NAME_TEST";
+ private static final String test_access_rule =
"B9CFCE1C47A6AC713442718F15EF55B00B3A6D1A6D48CB46249FA8EB51465350";
- private static final int dummy_cid = 0;
+ private static final int test_cid = 0;
private MockContextWithProvider mContext;
private MockContentResolver mContentResolver;
@@ -204,7 +204,7 @@
try {
//insert a row with null mnccmnc to break not null constraint
ContentValues contentValues = new ContentValues();
- contentValues.put(CarrierId.All.GID1, dummy_gid1);
+ contentValues.put(CarrierId.All.GID1, test_gid1);
mContentResolver.insert(CarrierId.All.CONTENT_URI, contentValues);
Assert.fail("should throw an exception for null mccmnc");
} catch (SQLException e) {
@@ -227,7 +227,7 @@
int numRowsDeleted = -1;
try {
String whereClause = CarrierId.All.MCCMNC + "=?";
- String[] whereArgs = new String[] { dummy_mccmnc };
+ String[] whereArgs = new String[] { test_mccmnc };
numRowsDeleted = mContentResolver.delete(CarrierId.All.CONTENT_URI,
whereClause, whereArgs);
} catch (Exception e) {
@@ -254,7 +254,7 @@
try {
contentValues.put(CarrierId.CARRIER_ID, 1);
mContentResolver.update(CarrierId.All.CONTENT_URI, contentValues,
- CarrierId.All.MCCMNC + "=?", new String[] { dummy_mccmnc });
+ CarrierId.All.MCCMNC + "=?", new String[] { test_mccmnc });
} catch (Exception e) {
Log.d(TAG, "Error updating values:" + e);
}
@@ -262,7 +262,7 @@
try {
Cursor findEntry = mContentResolver.query(CarrierId.All.CONTENT_URI,
new String[] { CarrierId.CARRIER_ID},
- CarrierId.All.MCCMNC + "=?", new String[] { dummy_mccmnc },
+ CarrierId.All.MCCMNC + "=?", new String[] { test_mccmnc },
null);
findEntry.moveToFirst();
cid = findEntry.getInt(0);
@@ -282,7 +282,7 @@
mContentResolver.insert(CarrierId.All.CONTENT_URI, contentValues);
// insert its MNO
contentValues = new ContentValues();
- contentValues.put(CarrierId.All.MCCMNC, dummy_mccmnc);
+ contentValues.put(CarrierId.All.MCCMNC, test_mccmnc);
contentValues.put(CarrierId.CARRIER_ID, 1);
mContentResolver.insert(CarrierId.All.CONTENT_URI, contentValues);
} catch (Exception e) {
@@ -293,7 +293,7 @@
String[] columns = {CarrierId.CARRIER_ID, CarrierId.All.ICCID_PREFIX};
try {
findEntry = mContentResolver.query(CarrierId.All.CONTENT_URI, columns,
- CarrierId.All.MCCMNC + "=?", new String[] { dummy_mccmnc },
+ CarrierId.All.MCCMNC + "=?", new String[] { test_mccmnc },
null);
} catch (Exception e) {
Log.d(TAG, "Query failed:" + e);
@@ -306,14 +306,14 @@
CarrierId.All.MCCMNC + "=? and "
+ CarrierId.All.GID1 + "=? and "
+ CarrierId.All.ICCID_PREFIX + "=?",
- new String[] { dummy_mccmnc, dummy_gid1, dummy_iccid_prefix }, null);
+ new String[] { test_mccmnc, test_gid1, test_iccid_prefix }, null);
} catch (Exception e) {
Log.d(TAG, "Query failed:" + e);
}
assertEquals(1, findEntry.getCount());
findEntry.moveToFirst();
- assertEquals(dummy_cid, findEntry.getInt(0));
- assertEquals(dummy_iccid_prefix, findEntry.getString(1));
+ assertEquals(test_cid, findEntry.getInt(0));
+ assertEquals(test_iccid_prefix, findEntry.getString(1));
}
@Test
@@ -337,8 +337,8 @@
// update carrier id for subId 1
try {
ContentValues cv = new ContentValues();
- cv.put(CarrierId.CARRIER_ID, dummy_cid);
- cv.put(CarrierId.CARRIER_NAME, dummy_name);
+ cv.put(CarrierId.CARRIER_ID, test_cid);
+ cv.put(CarrierId.CARRIER_NAME, test_name);
when(subscriptionManager.isActiveSubscriptionId(eq(1))).thenReturn(true);
mContext.getContentResolver().update(Uri.withAppendedPath(CarrierId.CONTENT_URI,
"1"), cv, null, null);
@@ -359,8 +359,8 @@
} catch (Exception e) {
Log.d(TAG, "Error query current subscription: " + e);
}
- assertEquals(dummy_cid, carrierId);
- assertEquals(dummy_name, carrierName);
+ assertEquals(test_cid, carrierId);
+ assertEquals(test_name, carrierName);
// query carrier id for subId 2
int count = -1;
@@ -384,8 +384,8 @@
} catch (Exception e) {
Log.d(TAG, "Error query current subscription: " + e);
}
- assertEquals(dummy_cid, carrierId);
- assertEquals(dummy_name, carrierName);
+ assertEquals(test_cid, carrierId);
+ assertEquals(test_name, carrierName);
}
@Test(expected = IllegalArgumentException.class)
@@ -410,8 +410,8 @@
public void testUpdateCurrentSubscription_WrongURI() {
try {
ContentValues cv = new ContentValues();
- cv.put(CarrierId.CARRIER_ID, dummy_cid);
- cv.put(CarrierId.CARRIER_NAME, dummy_name);
+ cv.put(CarrierId.CARRIER_ID, test_cid);
+ cv.put(CarrierId.CARRIER_NAME, test_name);
mContext.getContentResolver().update(CarrierId.CONTENT_URI, cv, null, null);
Assert.fail("should throw an exception for wrong uri");
} catch (IllegalArgumentException ex) {
@@ -421,17 +421,17 @@
private static ContentValues createCarrierInfoInternal() {
ContentValues contentValues = new ContentValues();
- contentValues.put(CarrierId.All.MCCMNC, dummy_mccmnc);
- contentValues.put(CarrierId.All.GID1, dummy_gid1);
- contentValues.put(CarrierId.All.GID2, dummy_gid2);
- contentValues.put(CarrierId.All.PLMN, dummy_plmn);
- contentValues.put(CarrierId.All.IMSI_PREFIX_XPATTERN, dummy_imsi_prefix);
- contentValues.put(CarrierId.All.SPN, dummy_spn);
- contentValues.put(CarrierId.All.APN, dummy_apn);
- contentValues.put(CarrierId.All.ICCID_PREFIX, dummy_iccid_prefix);
- contentValues.put(CarrierId.CARRIER_NAME, dummy_name);
- contentValues.put(CarrierId.CARRIER_ID, dummy_cid);
- contentValues.put(CarrierId.All.PRIVILEGE_ACCESS_RULE, dummy_access_rule);
+ contentValues.put(CarrierId.All.MCCMNC, test_mccmnc);
+ contentValues.put(CarrierId.All.GID1, test_gid1);
+ contentValues.put(CarrierId.All.GID2, test_gid2);
+ contentValues.put(CarrierId.All.PLMN, test_plmn);
+ contentValues.put(CarrierId.All.IMSI_PREFIX_XPATTERN, test_imsi_prefix);
+ contentValues.put(CarrierId.All.SPN, test_spn);
+ contentValues.put(CarrierId.All.APN, test_apn);
+ contentValues.put(CarrierId.All.ICCID_PREFIX, test_iccid_prefix);
+ contentValues.put(CarrierId.CARRIER_NAME, test_name);
+ contentValues.put(CarrierId.CARRIER_ID, test_cid);
+ contentValues.put(CarrierId.All.PRIVILEGE_ACCESS_RULE, test_access_rule);
return contentValues;
}
}
diff --git a/tests/src/com/android/providers/telephony/CarrierProviderTest.java b/tests/src/com/android/providers/telephony/CarrierProviderTest.java
index 5146aa9..eb95fb6 100644
--- a/tests/src/com/android/providers/telephony/CarrierProviderTest.java
+++ b/tests/src/com/android/providers/telephony/CarrierProviderTest.java
@@ -54,16 +54,16 @@
private MockContentResolver mContentResolver;
private CarrierProviderTestable mCarrierProviderTestable;
- public static final int dummy_type = 1;
- public static final String dummy_mnc = "MNC001";
- public static final String dummy_mnc2 = "MNC002";
- public static final String dummy_mcc = "MCC005";
- public static final String dummy_key1 = "PUBKEY1";
- public static final String dummy_key2 = "PUBKEY2";
- public static final String dummy_mvno_type = "100";
- public static final String dummy_mvno_match_data = "101";
- public static final String dummy_key_identifier_data = "key_identifier1";
- public static final long dummy_key_expiration = 1496795015L;
+ public static final int test_type = 1;
+ public static final String test_mnc = "MNC001";
+ public static final String test_mnc2 = "MNC002";
+ public static final String test_mcc = "MCC005";
+ public static final String test_key1 = "PUBKEY1";
+ public static final String test_key2 = "PUBKEY2";
+ public static final String test_mvno_type = "100";
+ public static final String test_mvno_match_data = "101";
+ public static final String test_key_identifier_data = "key_identifier1";
+ public static final long test_key_expiration = 1496795015L;
/**
@@ -144,14 +144,14 @@
public void testInsertCertificates() {
int count = -1;
ContentValues contentValues = new ContentValues();
- contentValues.put(CarrierDatabaseHelper.KEY_TYPE, dummy_type);
- contentValues.put(CarrierDatabaseHelper.MCC, dummy_mcc);
- contentValues.put(CarrierDatabaseHelper.MNC, dummy_mnc);
- contentValues.put(CarrierDatabaseHelper.MVNO_TYPE, dummy_mvno_type);
- contentValues.put(CarrierDatabaseHelper.MVNO_MATCH_DATA, dummy_mvno_match_data);
- contentValues.put(CarrierDatabaseHelper.KEY_IDENTIFIER, dummy_key_identifier_data);
- contentValues.put(CarrierDatabaseHelper.PUBLIC_KEY, dummy_key1.getBytes());
- contentValues.put(CarrierDatabaseHelper.EXPIRATION_TIME, dummy_key_expiration);
+ contentValues.put(CarrierDatabaseHelper.KEY_TYPE, test_type);
+ contentValues.put(CarrierDatabaseHelper.MCC, test_mcc);
+ contentValues.put(CarrierDatabaseHelper.MNC, test_mnc);
+ contentValues.put(CarrierDatabaseHelper.MVNO_TYPE, test_mvno_type);
+ contentValues.put(CarrierDatabaseHelper.MVNO_MATCH_DATA, test_mvno_match_data);
+ contentValues.put(CarrierDatabaseHelper.KEY_IDENTIFIER, test_key_identifier_data);
+ contentValues.put(CarrierDatabaseHelper.PUBLIC_KEY, test_key1.getBytes());
+ contentValues.put(CarrierDatabaseHelper.EXPIRATION_TIME, test_key_expiration);
try {
mContentResolver.insert(CarrierProvider.CONTENT_URI, contentValues);
@@ -180,14 +180,14 @@
public void testUpdateCertificates() {
String key = null;
ContentValues contentValues = new ContentValues();
- contentValues.put(CarrierDatabaseHelper.KEY_TYPE, dummy_type);
- contentValues.put(CarrierDatabaseHelper.MCC, dummy_mcc);
- contentValues.put(CarrierDatabaseHelper.MNC, dummy_mnc);
- contentValues.put(CarrierDatabaseHelper.MVNO_TYPE, dummy_mvno_type);
- contentValues.put(CarrierDatabaseHelper.MVNO_MATCH_DATA, dummy_mvno_match_data);
- contentValues.put(CarrierDatabaseHelper.KEY_IDENTIFIER, dummy_key_identifier_data);
- contentValues.put(CarrierDatabaseHelper.PUBLIC_KEY, dummy_key1.getBytes());
- contentValues.put(CarrierDatabaseHelper.EXPIRATION_TIME, dummy_key_expiration);
+ contentValues.put(CarrierDatabaseHelper.KEY_TYPE, test_type);
+ contentValues.put(CarrierDatabaseHelper.MCC, test_mcc);
+ contentValues.put(CarrierDatabaseHelper.MNC, test_mnc);
+ contentValues.put(CarrierDatabaseHelper.MVNO_TYPE, test_mvno_type);
+ contentValues.put(CarrierDatabaseHelper.MVNO_MATCH_DATA, test_mvno_match_data);
+ contentValues.put(CarrierDatabaseHelper.KEY_IDENTIFIER, test_key_identifier_data);
+ contentValues.put(CarrierDatabaseHelper.PUBLIC_KEY, test_key1.getBytes());
+ contentValues.put(CarrierDatabaseHelper.EXPIRATION_TIME, test_key_expiration);
try {
mContentResolver.insert(CarrierProvider.CONTENT_URI, contentValues);
@@ -197,10 +197,10 @@
try {
ContentValues updatedValues = new ContentValues();
- updatedValues.put(CarrierDatabaseHelper.PUBLIC_KEY, dummy_key2);
+ updatedValues.put(CarrierDatabaseHelper.PUBLIC_KEY, test_key2);
mContentResolver.update(CarrierProvider.CONTENT_URI, updatedValues,
- "mcc=? and mnc=? and key_type=?", new String[] { dummy_mcc, dummy_mnc,
- String.valueOf(dummy_type) });
+ "mcc=? and mnc=? and key_type=?", new String[] { test_mcc, test_mnc,
+ String.valueOf(test_type) });
} catch (Exception e) {
Log.d(TAG, "Error updating values:" + e);
}
@@ -209,13 +209,13 @@
String[] columns ={CarrierDatabaseHelper.PUBLIC_KEY};
Cursor findEntry = mContentResolver.query(CarrierProvider.CONTENT_URI, columns,
"mcc=? and mnc=? and key_type=?",
- new String[] { dummy_mcc, dummy_mnc, String.valueOf(dummy_type) }, null);
+ new String[] { test_mcc, test_mnc, String.valueOf(test_type) }, null);
findEntry.moveToFirst();
key = findEntry.getString(0);
} catch (Exception e) {
Log.d(TAG, "Query failed:" + e);
}
- assertEquals(key, dummy_key2);
+ assertEquals(key, test_key2);
}
/**
@@ -226,22 +226,22 @@
public void testMultipleCertificates() {
int count = -1;
ContentValues contentValues = new ContentValues();
- contentValues.put(CarrierDatabaseHelper.KEY_TYPE, dummy_type);
- contentValues.put(CarrierDatabaseHelper.MCC, dummy_mcc);
- contentValues.put(CarrierDatabaseHelper.MNC, dummy_mnc);
- contentValues.put(CarrierDatabaseHelper.MVNO_TYPE, dummy_mvno_type);
- contentValues.put(CarrierDatabaseHelper.MVNO_MATCH_DATA, dummy_mvno_match_data);
- contentValues.put(CarrierDatabaseHelper.KEY_IDENTIFIER, dummy_key_identifier_data);
- contentValues.put(CarrierDatabaseHelper.PUBLIC_KEY, dummy_key1.getBytes());
+ contentValues.put(CarrierDatabaseHelper.KEY_TYPE, test_type);
+ contentValues.put(CarrierDatabaseHelper.MCC, test_mcc);
+ contentValues.put(CarrierDatabaseHelper.MNC, test_mnc);
+ contentValues.put(CarrierDatabaseHelper.MVNO_TYPE, test_mvno_type);
+ contentValues.put(CarrierDatabaseHelper.MVNO_MATCH_DATA, test_mvno_match_data);
+ contentValues.put(CarrierDatabaseHelper.KEY_IDENTIFIER, test_key_identifier_data);
+ contentValues.put(CarrierDatabaseHelper.PUBLIC_KEY, test_key1.getBytes());
ContentValues contentValuesNew = new ContentValues();
- contentValuesNew.put(CarrierDatabaseHelper.KEY_TYPE, dummy_type);
- contentValuesNew.put(CarrierDatabaseHelper.MCC, dummy_mcc);
- contentValuesNew.put(CarrierDatabaseHelper.MNC, dummy_mnc2);
- contentValuesNew.put(CarrierDatabaseHelper.MVNO_TYPE, dummy_mvno_type);
- contentValuesNew.put(CarrierDatabaseHelper.MVNO_MATCH_DATA, dummy_mvno_match_data);
- contentValues.put(CarrierDatabaseHelper.KEY_IDENTIFIER, dummy_key_identifier_data);
- contentValuesNew.put(CarrierDatabaseHelper.PUBLIC_KEY, dummy_key2.getBytes());
+ contentValuesNew.put(CarrierDatabaseHelper.KEY_TYPE, test_type);
+ contentValuesNew.put(CarrierDatabaseHelper.MCC, test_mcc);
+ contentValuesNew.put(CarrierDatabaseHelper.MNC, test_mnc2);
+ contentValuesNew.put(CarrierDatabaseHelper.MVNO_TYPE, test_mvno_type);
+ contentValuesNew.put(CarrierDatabaseHelper.MVNO_MATCH_DATA, test_mvno_match_data);
+ contentValues.put(CarrierDatabaseHelper.KEY_IDENTIFIER, test_key_identifier_data);
+ contentValuesNew.put(CarrierDatabaseHelper.PUBLIC_KEY, test_key2.getBytes());
try {
mContentResolver.insert(CarrierProvider.CONTENT_URI, contentValues);
@@ -270,12 +270,12 @@
@Test(expected = SQLException.class)
public void testDuplicateFailure() {
ContentValues contentValues = new ContentValues();
- contentValues.put(CarrierDatabaseHelper.KEY_TYPE, dummy_type);
- contentValues.put(CarrierDatabaseHelper.MCC, dummy_mcc);
- contentValues.put(CarrierDatabaseHelper.MNC, dummy_mnc);
- contentValues.put(CarrierDatabaseHelper.MVNO_TYPE, dummy_mvno_type);
- contentValues.put(CarrierDatabaseHelper.MVNO_MATCH_DATA, dummy_mvno_match_data);
- contentValues.put(CarrierDatabaseHelper.PUBLIC_KEY, dummy_key1.getBytes());
+ contentValues.put(CarrierDatabaseHelper.KEY_TYPE, test_type);
+ contentValues.put(CarrierDatabaseHelper.MCC, test_mcc);
+ contentValues.put(CarrierDatabaseHelper.MNC, test_mnc);
+ contentValues.put(CarrierDatabaseHelper.MVNO_TYPE, test_mvno_type);
+ contentValues.put(CarrierDatabaseHelper.MVNO_MATCH_DATA, test_mvno_match_data);
+ contentValues.put(CarrierDatabaseHelper.PUBLIC_KEY, test_key1.getBytes());
try {
mContentResolver.insert(CarrierProvider.CONTENT_URI, contentValues);
@@ -297,14 +297,14 @@
public void testDelete() {
int numRowsDeleted = -1;
ContentValues contentValues = new ContentValues();
- contentValues.put(CarrierDatabaseHelper.KEY_TYPE, dummy_type);
- contentValues.put(CarrierDatabaseHelper.MCC, dummy_mcc);
- contentValues.put(CarrierDatabaseHelper.MNC, dummy_mnc);
- contentValues.put(CarrierDatabaseHelper.MVNO_TYPE, dummy_mvno_type);
- contentValues.put(CarrierDatabaseHelper.MVNO_MATCH_DATA, dummy_mvno_match_data);
- contentValues.put(CarrierDatabaseHelper.KEY_IDENTIFIER, dummy_key_identifier_data);
- contentValues.put(CarrierDatabaseHelper.PUBLIC_KEY, dummy_key1.getBytes());
- contentValues.put(CarrierDatabaseHelper.EXPIRATION_TIME, dummy_key_expiration);
+ contentValues.put(CarrierDatabaseHelper.KEY_TYPE, test_type);
+ contentValues.put(CarrierDatabaseHelper.MCC, test_mcc);
+ contentValues.put(CarrierDatabaseHelper.MNC, test_mnc);
+ contentValues.put(CarrierDatabaseHelper.MVNO_TYPE, test_mvno_type);
+ contentValues.put(CarrierDatabaseHelper.MVNO_MATCH_DATA, test_mvno_match_data);
+ contentValues.put(CarrierDatabaseHelper.KEY_IDENTIFIER, test_key_identifier_data);
+ contentValues.put(CarrierDatabaseHelper.PUBLIC_KEY, test_key1.getBytes());
+ contentValues.put(CarrierDatabaseHelper.EXPIRATION_TIME, test_key_expiration);
try {
mContentResolver.insert(CarrierProvider.CONTENT_URI, contentValues);
@@ -314,7 +314,7 @@
try {
String whereClause = "mcc=? and mnc=?";
- String[] whereArgs = new String[] { dummy_mcc, dummy_mnc };
+ String[] whereArgs = new String[] { test_mcc, test_mnc };
numRowsDeleted = mContentResolver.delete(CarrierProvider.CONTENT_URI, whereClause, whereArgs);
} catch (Exception e) {
Log.d(TAG, "Error updating values:" + e);
diff --git a/tests/src/com/android/providers/telephony/TelephonyBackupAgentTest.java b/tests/src/com/android/providers/telephony/TelephonyBackupAgentTest.java
index a576c44..00bb15e 100644
--- a/tests/src/com/android/providers/telephony/TelephonyBackupAgentTest.java
+++ b/tests/src/com/android/providers/telephony/TelephonyBackupAgentTest.java
@@ -41,7 +41,6 @@
import android.util.ArraySet;
import android.util.JsonReader;
import android.util.JsonWriter;
-import android.util.Log;
import android.util.SparseArray;
import libcore.io.IoUtils;
@@ -835,7 +834,7 @@
private class FakeMmsProvider extends MockContentProvider {
private int nextRow = 0;
private List<ContentValues> mValues;
- private long mDummyMsgId = -1;
+ private long mPlaceholderMsgId = -1;
private long mMsgId = -1;
private String mFilename;
@@ -845,7 +844,7 @@
@Override
public Uri insert(Uri uri, ContentValues values) {
- Uri retUri = Uri.parse("dummy_uri");
+ Uri retUri = Uri.parse("test_uri");
ContentValues modifiedValues = new ContentValues(mValues.get(nextRow++));
if (values.containsKey("read")) {
assertEquals("read: ", modifiedValues.get("read"), values.get("read"));
@@ -855,8 +854,8 @@
}
if (APP_SMIL.equals(values.get(Telephony.Mms.Part.CONTENT_TYPE))) {
// Smil part.
- assertEquals(-1, mDummyMsgId);
- mDummyMsgId = values.getAsLong(Telephony.Mms.Part.MSG_ID);
+ assertEquals(-1, mPlaceholderMsgId);
+ mPlaceholderMsgId = values.getAsLong(Telephony.Mms.Part.MSG_ID);
}
if (IMAGE_JPG.equals(values.get(Telephony.Mms.Part.CONTENT_TYPE))) {
// Image attachment part.
@@ -874,7 +873,7 @@
if (values.get(Telephony.Mms.Part.SEQ) != null) {
// Part of mms.
final Uri expectedUri = Telephony.Mms.CONTENT_URI.buildUpon()
- .appendPath(String.valueOf(mDummyMsgId))
+ .appendPath(String.valueOf(mPlaceholderMsgId))
.appendPath("part")
.build();
assertEquals(expectedUri, uri);
@@ -887,7 +886,7 @@
}
if (values.get(Telephony.Mms.Part.MSG_ID) != null) {
- modifiedValues.put(Telephony.Mms.Part.MSG_ID, mDummyMsgId);
+ modifiedValues.put(Telephony.Mms.Part.MSG_ID, mPlaceholderMsgId);
}
if (values.containsKey("read")) {
assertEquals("read: ", modifiedValues.get("read"), values.get("read"));
@@ -925,7 +924,7 @@
assertEquals(expectedUri, uri);
assertNotSame(-1, mMsgId);
modifiedValues.put(Telephony.Mms.Addr.MSG_ID, mMsgId);
- mDummyMsgId = -1;
+ mPlaceholderMsgId = -1;
}
if (values.containsKey("read")) {
assertEquals("read: ", modifiedValues.get("read"), values.get("read"));
@@ -944,7 +943,7 @@
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
final Uri expectedUri = Telephony.Mms.CONTENT_URI.buildUpon()
- .appendPath(String.valueOf(mDummyMsgId))
+ .appendPath(String.valueOf(mPlaceholderMsgId))
.appendPath("part")
.build();
assertEquals(expectedUri, uri);