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

Commit 43455184 authored by Evan Millar's avatar Evan Millar
Browse files

Handle IM entries with missing protocol field.

Fix bc_triaged bug http://b/issue?id=2174637
Dr. No approval from Tim Sullivan

Change-Id: Ia91c39e91a54e3c58ec94d1c5064a9572519f036
parent cee3b66d
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -229,6 +229,11 @@ public class ContactsUtils {
     */
    public static Intent buildImIntent(ContentValues values) {
        final boolean isEmail = Email.CONTENT_ITEM_TYPE.equals(values.getAsString(Data.MIMETYPE));

        if (!isEmail && !isProtocolValid(values)) {
            return null;
        }

        final int protocol = isEmail ? Im.PROTOCOL_GOOGLE_TALK : values.getAsInteger(Im.PROTOCOL);

        String host = values.getAsString(Im.CUSTOM_PROTOCOL);
@@ -248,6 +253,19 @@ public class ContactsUtils {
        }
    }

    private static boolean isProtocolValid(ContentValues values) {
        String protocolString = values.getAsString(Im.PROTOCOL);
        if (protocolString == null) {
            return false;
        }
        try {
            Integer.valueOf(protocolString);
        } catch (NumberFormatException e) {
            return false;
        }
        return true;
    }

    public static Intent getPhotoPickIntent() {
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
        intent.setType("image/*");
+35 −20
Original line number Diff line number Diff line
@@ -750,6 +750,7 @@ public class QuickContactWindow implements Window.Callback,
            } else if (Im.CONTENT_ITEM_TYPE.equals(mimeType)) {
                final boolean isEmail = Email.CONTENT_ITEM_TYPE.equals(
                        getAsString(cursor, Data.MIMETYPE));
                if (isEmail || isProtocolValid(cursor)) {
                    final int protocol = isEmail ? Im.PROTOCOL_GOOGLE_TALK :
                            getAsInt(cursor, Im.PROTOCOL);

@@ -774,6 +775,7 @@ public class QuickContactWindow implements Window.Callback,
                        mIntent = new Intent(Intent.ACTION_SENDTO, imUri);
                    }
                }
            }

            if (mIntent == null) {
                // Otherwise fall back to default VIEW action
@@ -784,6 +786,19 @@ public class QuickContactWindow implements Window.Callback,
            mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        }

        private boolean isProtocolValid(Cursor cursor) {
            final int columnIndex = cursor.getColumnIndex(Im.PROTOCOL);
            if (cursor.isNull(columnIndex)) {
                return false;
            }
            try {
                Integer.valueOf(cursor.getString(columnIndex));
            } catch (NumberFormatException e) {
                return false;
            }
            return true;
        }

        /** {@inheritDoc} */
        public CharSequence getHeader() {
            return mHeader;