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

Commit b831b144 authored by Brian Attwell's avatar Brian Attwell
Browse files

Don't crash QuickContacts because of null uri

When composeQuickContactActivity() is passed a null uri, then
startActivity throws the following exception:

    ActivityNotFoundException: No Activity found to handle Intent
    { act=android.provider.action.QUICK_CONTACT flg=0x20000000 (has extras) }

I can't reproduce this. So lets just fix the crash.

Inside contact list fragments, ignore clicks on views bound to null uris.
We don't need to change Dialer. It already handles these cases.

Note that we can't fix this by checking for null URIs inside
ContactEntryListFragment. One of the Dialer subclasses of
ContactEntryListFragment requires null URIs.

Bug: 17807956
Change-Id: I41dd878b23b8cc3e9b8ad49e12675a4da9ced466
parent c62cc793
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -128,6 +128,9 @@ public class ContactPickerFragment extends ContactEntryListFragment<ContactEntry
        } else {
            uri = ((ContactListAdapter)getAdapter()).getContactUri(position);
        }
        if (uri == null) {
            return;
        }
        if (mEditMode) {
            editContact(uri);
        } else  if (mShortcutRequested) {
+6 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.contacts.list;
import android.content.Context;
import android.content.CursorLoader;
import android.content.Intent;
import android.net.Uri;
import android.provider.ContactsContract.Contacts;
import android.text.TextUtils;
import android.util.Log;
@@ -86,7 +87,11 @@ public class DefaultContactBrowseListFragment extends ContactBrowseListFragment

    @Override
    protected void onItemClick(int position, long id) {
        viewContact(getAdapter().getContactUri(position));
        final Uri uri = getAdapter().getContactUri(position);
        if (uri == null) {
            return;
        }
        viewContact(uri);
    }

    @Override
+3 −0
Original line number Diff line number Diff line
@@ -45,6 +45,9 @@ public class EmailAddressPickerFragment extends ContactEntryListFragment<Contact
    @Override
    protected void onItemClick(int position, long id) {
        EmailAddressListAdapter adapter = (EmailAddressListAdapter)getAdapter();
        if (getAdapter().getItem(position) == null) {
            return;
        }
        pickEmailAddress(adapter.getDataUri(position));
    }

+3 −0
Original line number Diff line number Diff line
@@ -46,6 +46,9 @@ public class PostalAddressPickerFragment

    @Override
    protected void onItemClick(int position, long id) {
        if (getAdapter().getItem(position) == null) {
            return;
        }
        if (!isLegacyCompatibilityMode()) {
            PostalAddressListAdapter adapter = (PostalAddressListAdapter)getAdapter();
            pickPostalAddress(adapter.getDataUri(position));