Merge "Activate the implementation for the new dictionary format."
diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java
index 565b01d..96225f2 100644
--- a/java/src/com/android/inputmethod/latin/CandidateView.java
+++ b/java/src/com/android/inputmethod/latin/CandidateView.java
@@ -193,6 +193,7 @@
 
         public void layoutStrip(SuggestedWords suggestions, int maxWidth, int maxCount) {
             final int size = suggestions.size();
+            if (size == 0) return;
             setupTexts(suggestions, size, mAutoCorrectHighlight);
             mCountInStrip = Math.min(maxCount, size);
             mScaleX = 1.0f;
@@ -244,7 +245,12 @@
             mTexts.clear();
             for (int i = 0; i < count; i++) {
                 final CharSequence suggestion = suggestions.getWord(i);
-                if (suggestion == null) continue;
+                if (suggestion == null) {
+                    // Skip an empty suggestion, but we need to add a place-holder for it in order
+                    // to avoid an exception in the loop in updateSuggestions().
+                    mTexts.add("");
+                    continue;
+                }
 
                 final boolean isAutoCorrect = suggestions.mHasMinimalSuggestion
                         && ((i == 1 && !suggestions.mTypedWordValid)
diff --git a/native/Android.mk b/native/Android.mk
index fc6f196..bc246a9 100644
--- a/native/Android.mk
+++ b/native/Android.mk
@@ -34,6 +34,10 @@
     TARGETING_UNBUNDLED_FROYO := false
 endif
 
+ifeq ($(FLAG_DO_PROFILE), true)
+    TARGETING_UNBUNDLED_FROYO := false
+endif
+
 ifeq ($(TARGETING_UNBUNDLED_FROYO), true)
     LOCAL_NDK_VERSION := 4
     LOCAL_SDK_VERSION := 8
@@ -46,6 +50,7 @@
 ifeq ($(FLAG_DO_PROFILE), true)
     $(warning Making profiling version of native library)
     LOCAL_CFLAGS += -DFLAG_DO_PROFILE
+    LOCAL_SHARED_LIBRARIES := libcutils libutils
 else # FLAG_DO_PROFILE
 ifeq ($(FLAG_DBG), true)
     $(warning Making debug version of native library)
diff --git a/native/src/bigram_dictionary.cpp b/native/src/bigram_dictionary.cpp
index d11aee2..6ed4d09 100644
--- a/native/src/bigram_dictionary.cpp
+++ b/native/src/bigram_dictionary.cpp
@@ -45,8 +45,8 @@
 #ifdef FLAG_DBG
         char s[length + 1];
         for (int i = 0; i <= length; i++) s[i] = word[i];
-#endif
         LOGI("Bigram: Found word = %s, freq = %d :", s, frequency);
+#endif
     }
 
     // Find the right insertion point
diff --git a/native/src/defines.h b/native/src/defines.h
index a516190..bea83b2 100644
--- a/native/src/defines.h
+++ b/native/src/defines.h
@@ -18,8 +18,16 @@
 #ifndef LATINIME_DEFINES_H
 #define LATINIME_DEFINES_H
 
+#if defined(FLAG_DO_PROFILE) || defined(FLAG_DBG)
+#include <cutils/log.h>
+#else
+#define LOGE(fmt, ...)
+#define LOGI(fmt, ...)
+#endif
+
 #ifdef FLAG_DO_PROFILE
 // Profiler
+#include <cutils/log.h>
 #include <time.h>
 #define PROF_BUF_SIZE 100
 static double profile_buf[PROF_BUF_SIZE];
@@ -92,8 +100,7 @@
 #define DEBUG_PROXIMITY_INFO true
 
 #else // FLAG_DBG
-#define LOGE(fmt, ...)
-#define LOGI(fmt, ...)
+
 #define DEBUG_DICT false
 #define DEBUG_DICT_FULL false
 #define DEBUG_SHOW_FOUND_WORD false
diff --git a/native/src/unigram_dictionary.cpp b/native/src/unigram_dictionary.cpp
index 698584e..5e72c76 100644
--- a/native/src/unigram_dictionary.cpp
+++ b/native/src/unigram_dictionary.cpp
@@ -172,8 +172,8 @@
             short unsigned int* w = mOutputChars + j * MAX_WORD_LENGTH;
             char s[MAX_WORD_LENGTH];
             for (int i = 0; i <= MAX_WORD_LENGTH; i++) s[i] = w[i];
-#endif
             LOGI("%s %i", s, mFrequencies[j]);
+#endif
         }
         LOGI("Next letters: ");
         for (int k = 0; k < NEXT_LETTERS_SIZE; k++) {
@@ -301,8 +301,8 @@
 #ifdef FLAG_DBG
         char s[length + 1];
         for (int i = 0; i <= length; i++) s[i] = word[i];
-#endif
         LOGI("Found word = %s, freq = %d", s, frequency);
+#endif
     }
     if (length > MAX_WORD_LENGTH) {
         if (DEBUG_DICT) {
@@ -325,8 +325,8 @@
 #ifdef FLAG_DBG
             char s[length + 1];
             for (int i = 0; i <= length; i++) s[i] = word[i];
-#endif
             LOGI("Added word = %s, freq = %d, %d", s, frequency, S_INT_MAX);
+#endif
         }
         memmove((char*) mFrequencies + (insertAt + 1) * sizeof(mFrequencies[0]),
                (char*) mFrequencies + insertAt * sizeof(mFrequencies[0]),
@@ -809,9 +809,9 @@
                             char s[inputLength + 1];
                             for (int i = 0; i < inputLength; ++i) s[i] = word[i];
                             s[inputLength] = 0;
-#endif
                             LOGI("New missing space word found: %d > %d (%s), %d, %d",
                                     newFreq, maxFreq, s, inputLength, depth);
+#endif
                         }
                         maxFreq = newFreq;
                     }