Snap for 6864616 from f56e6480e7f82d68da84b8484331a088f7c1481c to rvc-qpr1-release
Change-Id: I77c38f661cec111c6f65c2d8a8eb01065575cc4f
diff --git a/src/com/android/providers/telephony/TelephonyBackupAgent.java b/src/com/android/providers/telephony/TelephonyBackupAgent.java
index 6fa4bf9..930a98a 100644
--- a/src/com/android/providers/telephony/TelephonyBackupAgent.java
+++ b/src/com/android/providers/telephony/TelephonyBackupAgent.java
@@ -691,12 +691,16 @@
private SmsProviderQuery mSmsProviderQuery = new SmsProviderQuery() {
@Override
public boolean doesSmsExist(ContentValues smsValues) {
- final String where = String.format(Locale.US, "%s = %d and %s = %s",
+ // The SMS body might contain '\0' characters (U+0000) such as in the case of
+ // http://b/160801497 . SQLite does not allow '\0' in String literals, but as of SQLite
+ // version 3.32.2 2020-06-04, it does allow them as selectionArgs; therefore, we're
+ // using the latter approach here.
+ final String selection = String.format(Locale.US, "%s=%d AND %s=?",
Telephony.Sms.DATE, smsValues.getAsLong(Telephony.Sms.DATE),
- Telephony.Sms.BODY,
- DatabaseUtils.sqlEscapeString(smsValues.getAsString(Telephony.Sms.BODY)));
+ Telephony.Sms.BODY);
+ String[] selectionArgs = new String[] { smsValues.getAsString(Telephony.Sms.BODY)};
try (Cursor cursor = mContentResolver.query(Telephony.Sms.CONTENT_URI, PROJECTION_ID,
- where, null, null)) {
+ selection, selectionArgs, null)) {
return cursor != null && cursor.getCount() > 0;
}
}