OSDN Git Service

When parsing extras, use best type when none provided.
authorJeff Sharkey <jsharkey@android.com>
Fri, 18 Sep 2009 08:27:41 +0000 (01:27 -0700)
committerJeff Sharkey <jsharkey@android.com>
Fri, 18 Sep 2009 08:27:41 +0000 (01:27 -0700)
When the caller doesn't pass any type, use the best for the
selected ContactsSource, instead of TYPE_CUSTOM.

Indirectly helps http://b/2129074

src/com/android/contacts/model/EntityModifier.java

index 003e641..0d8ede9 100644 (file)
@@ -517,8 +517,10 @@ public class EntityModifier {
         final boolean validValue = (value != null && TextUtils.isGraphic(value));
         if (!validValue || !canInsert) return;
 
-        // Find exact type, or otherwise best type
-        final int typeValue = extras.getInt(typeExtra, BaseTypes.TYPE_CUSTOM);
+        // Find exact type when requested, otherwise best available type
+        final boolean hasType = extras.containsKey(typeExtra);
+        final int typeValue = extras.getInt(typeExtra, hasType ? BaseTypes.TYPE_CUSTOM
+                : Integer.MIN_VALUE);
         final EditType editType = EntityModifier.getBestValidType(state, kind, true, typeValue);
 
         // Create data row and fill with value