Clean up: Update variable names to comply with spec of ApplicationInfo.

ApplicationInfo.sourceDir may or may not be apk file name.  It can be a directory as well.
The spec just says it's "Full path to the location of this package".

Also, added error handling in loadDictionary().

Change-Id: I5e64d0aba4b1ec7634f4b3ac5537e7a774433ece
diff --git a/native/Android.mk b/native/Android.mk
index 38465ac..a8fe06d 100644
--- a/native/Android.mk
+++ b/native/Android.mk
@@ -32,7 +32,7 @@
 LOCAL_MODULE_TAGS := user
 
 ifeq ($(FLAG_DBG), true)
-    $(warning "Making debug build.")
+    $(warning Making debug version of native library)
     LOCAL_CFLAGS += -DFLAG_DBG
     LOCAL_SHARED_LIBRARIES := libcutils libutils
 endif
diff --git a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
index 6374292..6e4e971 100644
--- a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
+++ b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
@@ -50,14 +50,14 @@
 }
 
 static jint latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
-        jstring apkFileName, jlong dictOffset, jlong dictSize,
+        jstring sourceDir, jlong dictOffset, jlong dictSize,
         jint typedLetterMultiplier, jint fullWordMultiplier, jint maxWordLength, jint maxWords,
         jint maxAlternatives) {
     PROF_OPEN;
     PROF_START(66);
-    const char *apkFileNameChars = env->GetStringUTFChars(apkFileName, NULL);
-    if (apkFileNameChars == NULL) {
-        LOGE("DICT: Can't get apk file name");
+    const char *sourceDirChars = env->GetStringUTFChars(sourceDir, NULL);
+    if (sourceDirChars == NULL) {
+        LOGE("DICT: Can't get sourceDir string");
         return 0;
     }
     int fd = 0;
@@ -65,9 +65,9 @@
     int adjust = 0;
 #ifdef USE_MMAP_FOR_DICTIONARY
     /* mmap version */
-    fd = open(apkFileNameChars, O_RDONLY);
+    fd = open(sourceDirChars, O_RDONLY);
     if (fd < 0) {
-        LOGE("DICT: Can't open apk file. errno=%d", errno);
+        LOGE("DICT: Can't open sourceDir. sourceDirChars=%s errno=%d", sourceDirChars, errno);
         return 0;
     }
     int pagesize = getpagesize();
@@ -76,16 +76,16 @@
     int adjDictSize = dictSize + adjust;
     dictBuf = mmap(NULL, sizeof(char) * adjDictSize, PROT_READ, MAP_PRIVATE, fd, adjDictOffset);
     if (dictBuf == MAP_FAILED) {
-        LOGE("DICT: Can't mmap dictionary file. errno=%d", errno);
+        LOGE("DICT: Can't mmap dictionary. errno=%d", errno);
         return 0;
     }
     dictBuf = (void *)((char *)dictBuf + adjust);
 #else // USE_MMAP_FOR_DICTIONARY
     /* malloc version */
     FILE *file = NULL;
-    file = fopen(apkFileNameChars, "rb");
+    file = fopen(sourceDirChars, "rb");
     if (file == NULL) {
-        LOGE("DICT: Can't fopen apk file. errno=%d", errno);
+        LOGE("DICT: Can't fopen sourceDir. sourceDirChars=%s errno=%d", sourceDirChars, errno);
         return 0;
     }
     dictBuf = malloc(sizeof(char) * dictSize);
@@ -109,7 +109,7 @@
         return 0;
     }
 #endif // USE_MMAP_FOR_DICTIONARY
-    env->ReleaseStringUTFChars(apkFileName, apkFileNameChars);
+    env->ReleaseStringUTFChars(sourceDir, sourceDirChars);
 
     if (!dictBuf) {
         LOGE("DICT: dictBuf is null");