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

Commit 53d303dc authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Phone: don't crash when unsupported filter is set

- Unsupported filters, such as FILTER_TYPE_STARRED, could be applied
with deprecated public intents, such as LIST_STARRED_ACTION.

- Don't crash when these are set.  Just treat them as the all filter.
Besides, some of these are 100% valid and there's no reason the
app should crash.  (e.g. FILTER_TYPE_WITH_PHONE_NUMBERS_ONLY)

- Also, make PeopleActivity not set a filter for LIST_FREQUENT_ACTION,
LIST_STREQUENT_ACTION and LIST_STREQUENT_ACTION.  Just showing the favorites
tab should be enough.  (These are all public, but deprecated intents.)

Bug 5265438

Change-Id: I6c6d0ec3279f174907844706ef3527f10bf47bbd
parent e050438f
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -492,13 +492,9 @@ public class PeopleActivity extends ContactsActivity
                    tabToOpen = TabState.ALL;
                    break;

                // TODO: handle FREQUENT and STREQUENT according to the spec
                case ContactsRequest.ACTION_FREQUENT:
                case ContactsRequest.ACTION_STREQUENT:
                    // For now they are treated the same as STARRED
                case ContactsRequest.ACTION_STARRED:
                    filter = ContactListFilter.createFilterWithType(
                            ContactListFilter.FILTER_TYPE_STARRED);
                    tabToOpen = TabState.FAVORITES;
                    break;
                case ContactsRequest.ACTION_VIEW_CONTACT:
+10 −25
Original line number Diff line number Diff line
@@ -90,15 +90,6 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter {
                    + "directoryId: " + directoryId + ")");
        }

        final ContactListFilter filter = getFilter();
        if (filter != null &&
                (filter.filterType != ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS &&
                filter.filterType != ContactListFilter.FILTER_TYPE_ACCOUNT &&
                filter.filterType != ContactListFilter.FILTER_TYPE_CUSTOM)) {
            throw new IllegalArgumentException("Unexpected filter type came " +
                    "(type: " + filter.filterType + ", toString: " + filter + ")");
        }

        if (isSearchMode()) {
            String query = getQueryString();
            Builder builder = Phone.CONTENT_FILTER_URI.buildUpon();
@@ -122,7 +113,7 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter {
            }

            loader.setProjection(PHONES_PROJECTION);
            configureSelection(loader, directoryId, filter);
            configureSelection(loader, directoryId, getFilter());
        }

        loader.setUri(uri);
@@ -145,9 +136,6 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter {
        final List<String> selectionArgs = new ArrayList<String>();

        switch (filter.filterType) {
            case ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS: {
                break;
            }
            case ContactListFilter.FILTER_TYPE_CUSTOM: {
                selection.append(Contacts.IN_VISIBLE_GROUP + "=1");
                selection.append(" AND " + Contacts.HAS_PHONE_NUMBER + "=1");
@@ -169,20 +157,17 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter {
                selection.append(")");
                break;
            }
            case ContactListFilter.FILTER_TYPE_GROUP: {
                selection.append(Data.MIMETYPE + "=?"
                        + " AND " + GroupMembership.GROUP_ROW_ID + "=?");
                selectionArgs.add(GroupMembership.CONTENT_ITEM_TYPE);
                selectionArgs.add(String.valueOf(filter.groupId));
                break;
            }

            case ContactListFilter.FILTER_TYPE_SINGLE_CONTACT:
            case ContactListFilter.FILTER_TYPE_STARRED:
            case ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS:
            case ContactListFilter.FILTER_TYPE_DEFAULT:
                break; // No selection needed.
            case ContactListFilter.FILTER_TYPE_WITH_PHONE_NUMBERS_ONLY:
                break; // This adapter is always "phone only", so no selection needed either.
            default:
                throw new IllegalArgumentException("Unexpected filter type came " +
                        "(type: " + filter.filterType + ", toString: " + filter + ")");
                Log.w(TAG, "Unsupported filter type came " +
                        "(type: " + filter.filterType + ", toString: " + filter + ")" +
                        " showing all contacts.");
                // No selection.
                break;
        }
        loader.setSelection(selection.toString());
        loader.setSelectionArgs(selectionArgs.toArray(new String[0]));