Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 382114ec authored by Jay Shrauner's avatar Jay Shrauner Committed by Android Git Automerger
Browse files

am e033c37e: am 12d9fbf8: Merge "Fix NPE in DialerDatabaseHelper for null...

am e033c37e: am 12d9fbf8: Merge "Fix NPE in DialerDatabaseHelper for null phone numbers" into klp-dev

* commit 'e033c37e':
  Fix NPE in DialerDatabaseHelper for null phone numbers
parents c31ed856 e033c37e
Loading
Loading
Loading
Loading
+23 −6
Original line number Original line Diff line number Diff line
@@ -628,10 +628,26 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper {


            updatedContactCursor.moveToPosition(-1);
            updatedContactCursor.moveToPosition(-1);
            while (updatedContactCursor.moveToNext()) {
            while (updatedContactCursor.moveToNext()) {
                insert.bindLong(1, updatedContactCursor.getLong(PhoneQuery.PHONE_ID));
                insert.clearBindings();
                insert.bindString(2, updatedContactCursor.getString(PhoneQuery.PHONE_NUMBER));

                insert.bindLong(3, updatedContactCursor.getLong(PhoneQuery.PHONE_CONTACT_ID));
                // Handle string columns which can possibly be null first. In the case of certain
                insert.bindString(4, updatedContactCursor.getString(PhoneQuery.PHONE_LOOKUP_KEY));
                // null columns (due to malformed rows possibly inserted by third-party apps
                // or sync adapters), skip the phone number row.
                final String number = updatedContactCursor.getString(PhoneQuery.PHONE_NUMBER);
                if (TextUtils.isEmpty(number)) {
                    continue;
                } else {
                    insert.bindString(2, number);
                }

                final String lookupKey = updatedContactCursor.getString(
                        PhoneQuery.PHONE_LOOKUP_KEY);
                if (TextUtils.isEmpty(lookupKey)) {
                    continue;
                } else {
                    insert.bindString(4, lookupKey);
                }

                final String displayName = updatedContactCursor.getString(
                final String displayName = updatedContactCursor.getString(
                        PhoneQuery.PHONE_DISPLAY_NAME);
                        PhoneQuery.PHONE_DISPLAY_NAME);
                if (displayName == null) {
                if (displayName == null) {
@@ -639,6 +655,9 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper {
                } else {
                } else {
                    insert.bindString(5, displayName);
                    insert.bindString(5, displayName);
                }
                }

                insert.bindLong(1, updatedContactCursor.getLong(PhoneQuery.PHONE_ID));
                insert.bindLong(3, updatedContactCursor.getLong(PhoneQuery.PHONE_CONTACT_ID));
                insert.bindLong(6, updatedContactCursor.getLong(PhoneQuery.PHONE_PHOTO_ID));
                insert.bindLong(6, updatedContactCursor.getLong(PhoneQuery.PHONE_PHOTO_ID));
                insert.bindLong(7, updatedContactCursor.getLong(PhoneQuery.PHONE_LAST_TIME_USED));
                insert.bindLong(7, updatedContactCursor.getLong(PhoneQuery.PHONE_LAST_TIME_USED));
                insert.bindLong(8, updatedContactCursor.getInt(PhoneQuery.PHONE_TIMES_USED));
                insert.bindLong(8, updatedContactCursor.getInt(PhoneQuery.PHONE_TIMES_USED));
@@ -648,8 +667,6 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper {
                insert.bindLong(12, updatedContactCursor.getInt(PhoneQuery.PHONE_IS_PRIMARY));
                insert.bindLong(12, updatedContactCursor.getInt(PhoneQuery.PHONE_IS_PRIMARY));
                insert.bindLong(13, currentMillis);
                insert.bindLong(13, currentMillis);
                insert.executeInsert();
                insert.executeInsert();
                insert.clearBindings();

                final String contactPhoneNumber =
                final String contactPhoneNumber =
                        updatedContactCursor.getString(PhoneQuery.PHONE_NUMBER);
                        updatedContactCursor.getString(PhoneQuery.PHONE_NUMBER);
                final ArrayList<String> numberPrefixes =
                final ArrayList<String> numberPrefixes =