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

Commit 47f79bb4 authored by Daniel Lehmann's avatar Daniel Lehmann Committed by Android (Google) Code Review
Browse files

Merge "Replace try-catch code by proper type checking. Saves an exception for each blob."

parents 3a18eb93 156add95
Loading
Loading
Loading
Loading
+12 −19
Original line number Original line Diff line number Diff line
@@ -2113,29 +2113,22 @@ public final class ContactsContract {
                            Data.DATA_VERSION);
                            Data.DATA_VERSION);
                    for (String key : DATA_KEYS) {
                    for (String key : DATA_KEYS) {
                        final int columnIndex = cursor.getColumnIndexOrThrow(key);
                        final int columnIndex = cursor.getColumnIndexOrThrow(key);
                        if (cursor.isNull(columnIndex)) {
                        switch (cursor.getType(columnIndex)) {
                            case Cursor.FIELD_TYPE_NULL:
                                // don't put anything
                                // don't put anything
                        } else {
                                break;
                            try {
                            case Cursor.FIELD_TYPE_INTEGER:
                            case Cursor.FIELD_TYPE_FLOAT:
                            case Cursor.FIELD_TYPE_STRING:
                                cv.put(key, cursor.getString(columnIndex));
                                cv.put(key, cursor.getString(columnIndex));
                            } catch (SQLiteException e) {
                                break;
                            case Cursor.FIELD_TYPE_BLOB:
                                cv.put(key, cursor.getBlob(columnIndex));
                                cv.put(key, cursor.getBlob(columnIndex));
                                break;
                            default:
                                throw new IllegalStateException("Invalid or unhandled data type");
                        }
                        }
                    }
                    }
                        // TODO: go back to this version of the code when bug
                        // http://b/issue?id=2306370 is fixed.
//                        if (cursor.isNull(columnIndex)) {
//                            // don't put anything
//                        } else if (cursor.isLong(columnIndex)) {
//                            values.put(key, cursor.getLong(columnIndex));
//                        } else if (cursor.isFloat(columnIndex)) {
//                            values.put(key, cursor.getFloat(columnIndex));
//                        } else if (cursor.isString(columnIndex)) {
//                            values.put(key, cursor.getString(columnIndex));
//                        } else if (cursor.isBlob(columnIndex)) {
//                            values.put(key, cursor.getBlob(columnIndex));
//                        }
                    }
                    contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv);
                    contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv);
                } while (cursor.moveToNext());
                } while (cursor.moveToNext());