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

Commit 764a940b authored by Chienyuan's avatar Chienyuan
Browse files

MAP: Throw exception for illegal ID column

MAP may get IllegalStateException when query ID of MMS
The exception may be caused by below reasons:

1. the Mms._ID column doesn't exist.
2. the column value is null
3. cursor is moved to an illegal row
4. the column type is not an integral
5. the integer value is outside the range [Long.MIN_VALUE, Long.MAX_VALUE]

Bug: 144585524
Test: manual
Change-Id: I97cb66942b6981d32c2d48682d2edece6aafd086
parent 43f697c1
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -1410,7 +1410,11 @@ public class BluetoothMapContentObserver {
            try {
                if (c != null && c.moveToFirst()) {
                    do {
                        long id = c.getLong(c.getColumnIndex(Sms._ID));
                        int idIndex = c.getColumnIndexOrThrow(Sms._ID);
                        if (c.isNull(idIndex)) {
                            throw new IllegalStateException("ID is null");
                        }
                        long id = c.getLong(idIndex);
                        int type = c.getInt(c.getColumnIndex(Sms.TYPE));
                        int threadId = c.getInt(c.getColumnIndex(Sms.THREAD_ID));
                        int read = c.getInt(c.getColumnIndex(Sms.READ));
@@ -1526,8 +1530,6 @@ public class BluetoothMapContentObserver {
                        }
                    } while (c.moveToNext());
                }
            } catch (IllegalStateException e) {
                Log.w(TAG, e);
            } finally {
                if (c != null) {
                    c.close();
@@ -1568,7 +1570,11 @@ public class BluetoothMapContentObserver {
            try {
                if (c != null && c.moveToFirst()) {
                    do {
                        long id = c.getLong(c.getColumnIndex(Mms._ID));
                        int idIndex = c.getColumnIndexOrThrow(Mms._ID);
                        if (c.isNull(idIndex)) {
                            throw new IllegalStateException("ID is null");
                        }
                        long id = c.getLong(idIndex);
                        int type = c.getInt(c.getColumnIndex(Mms.MESSAGE_BOX));
                        int mtype = c.getInt(c.getColumnIndex(Mms.MESSAGE_TYPE));
                        int threadId = c.getInt(c.getColumnIndex(Mms.THREAD_ID));
@@ -1697,8 +1703,6 @@ public class BluetoothMapContentObserver {
                    } while (c.moveToNext());

                }
            } catch (IllegalStateException e) {
                Log.w(TAG, e);
            } finally {
                if (c != null) {
                    c.close();