Dialer: fix the runtime exception issue for smartsearch.

Device will throw runtime exception when accountName
or accountType is null.

Add a default value for the two columns.

Change-Id: I70a6dfad001c1cd4fc018fe1054108c3539f6276
CRs-Fixed: 1068330
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6d94d8e..48d49af 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1161,4 +1161,6 @@
     <string name="alert_call_over_wifi">Calls will be made over Wi-Fi.</string>
     <string name="alert_call_no_cellular_coverage">No cellular network available. Connect to available Wi-Fi to make calls.</string>
     <string name="alert_user_connect_to_wifi_for_call">Connect to Wi-Fi to make calls.</string>
+    <string name="missing_account_type">(No type)</string>
+    <string name="missing_account_name">(No name)</string>
 </resources>
diff --git a/src/com/android/dialer/database/DialerDatabaseHelper.java b/src/com/android/dialer/database/DialerDatabaseHelper.java
index 1d3de31..2d9b8aa 100644
--- a/src/com/android/dialer/database/DialerDatabaseHelper.java
+++ b/src/com/android/dialer/database/DialerDatabaseHelper.java
@@ -943,10 +943,24 @@
                 insert.bindLong(12, updatedContactCursor.getInt(PhoneQuery.PHONE_IS_PRIMARY));
                 insert.bindLong(13, updatedContactCursor.getInt(PhoneQuery.PHONE_CARRIER_PRESENCE));
                 insert.bindLong(14, currentMillis);
-                insert.bindString(15, updatedContactCursor
-                        .getString(PhoneQuery.PHONE_ACCOUNT_TYPE));
-                insert.bindString(16, updatedContactCursor
-                        .getString(PhoneQuery.PHONE_ACCOUNT_NAME));
+
+                final String accountType = updatedContactCursor.getString(
+                        PhoneQuery.PHONE_ACCOUNT_TYPE);
+                if (accountType == null) {
+                    insert.bindString(15, mContext.getResources().getString(
+                            R.string.missing_account_type));
+                } else {
+                    insert.bindString(15, accountType);
+                }
+
+                final String accountName = updatedContactCursor.getString(
+                        PhoneQuery.PHONE_ACCOUNT_NAME);
+                if (accountName == null) {
+                    insert.bindString(16, mContext.getResources().getString(
+                            R.string.missing_account_name));
+                } else {
+                    insert.bindString(16, accountName);
+                }
                 insert.executeInsert();
                 final String contactPhoneNumber =
                         updatedContactCursor.getString(PhoneQuery.PHONE_NUMBER);