Contacts: "non-existent account type".
Providing a "non-existent account type" instead of
an exception when there is no default account on the phone.
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index 0424cf5..777315e 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -1610,7 +1610,7 @@
case GROUPS: {
boolean markAsDirty = shouldMarkGroupAsDirty(uri);
- final boolean permanently =
+ final boolean permanently =
readBooleanQueryParameter(uri, RawContacts.DELETE_PERMANENTLY, false);
int numDeletes = 0;
Cursor c = mDb.query(Tables.GROUPS, new String[]{Groups._ID},
@@ -2904,10 +2904,8 @@
return accounts[0];
}
} catch (Throwable e) {
- throw new RuntimeException("Cannot determine the default account "
- + "for contacts compatibility", e);
+ Log.e(TAG, "Cannot determine the default account for contacts compatibility", e);
}
- throw new RuntimeException("Cannot determine the default account "
- + "for contacts compatibility");
+ return null;
}
}
diff --git a/src/com/android/providers/contacts/LegacyApiSupport.java b/src/com/android/providers/contacts/LegacyApiSupport.java
index 9be5760..e9e6c1d 100644
--- a/src/com/android/providers/contacts/LegacyApiSupport.java
+++ b/src/com/android/providers/contacts/LegacyApiSupport.java
@@ -58,6 +58,8 @@
private static final String TAG = "ContactsProviderV1";
+ private static final String NON_EXISTENT_ACCOUNT_TYPE = "android.INVALID_ACCOUNT_TYPE";
+
private static final UriMatcher sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
private static final int PEOPLE = 1;
@@ -466,6 +468,12 @@
private void ensureDefaultAccount() {
if (mAccount == null) {
mAccount = mContactsProvider.getDefaultAccount();
+ if (mAccount == null) {
+
+ // This fall-through account will not match any data in the database, which
+ // is the expected behavior
+ mAccount = new Account("", NON_EXISTENT_ACCOUNT_TYPE);
+ }
}
}