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
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index ebf1dbd..fa9e03a 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -492,13 +492,9 @@
                     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:
diff --git a/src/com/android/contacts/list/PhoneNumberListAdapter.java b/src/com/android/contacts/list/PhoneNumberListAdapter.java
index cac89b1..a86e082 100644
--- a/src/com/android/contacts/list/PhoneNumberListAdapter.java
+++ b/src/com/android/contacts/list/PhoneNumberListAdapter.java
@@ -90,15 +90,6 @@
                     + "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 @@
             }
 
             loader.setProjection(PHONES_PROJECTION);
-            configureSelection(loader, directoryId, filter);
+            configureSelection(loader, directoryId, getFilter());
         }
 
         loader.setUri(uri);
@@ -145,9 +136,6 @@
         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 @@
                 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]));