aboutsummaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorKen Wakasa <kwakasa@google.com>2011-01-09 16:32:58 +0900
committerKen Wakasa <kwakasa@google.com>2011-01-09 16:53:33 +0900
commit90d96615bcb71af7ccbb2318b588aa78c4308e5a (patch)
tree675a69ee4343846acd7e6c135d7c122297cf81ce /native
parent7a42a46069d799c01f1da233d1add2ff974ac834 (diff)
downloadlatinime-90d96615bcb71af7ccbb2318b588aa78c4308e5a.tar.gz
latinime-90d96615bcb71af7ccbb2318b588aa78c4308e5a.tar.xz
latinime-90d96615bcb71af7ccbb2318b588aa78c4308e5a.zip
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
Diffstat (limited to 'native')
-rw-r--r--native/Android.mk2
-rw-r--r--native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp20
2 files changed, 11 insertions, 11 deletions
diff --git a/native/Android.mk b/native/Android.mk
index 38465acf3..a8fe06d50 100644
--- a/native/Android.mk
+++ b/native/Android.mk
@@ -32,7 +32,7 @@ LOCAL_MODULE := libjni_latinime
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 637429298..6e4e97138 100644
--- a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
+++ b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
@@ -50,14 +50,14 @@ static void throwException(JNIEnv *env, const char* ex, const char* fmt, int dat
}
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 @@ static jint latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
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 @@ static jint latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
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 @@ static jint latinime_BinaryDictionary_open(JNIEnv *env, jobject object,
return 0;
}
#endif // USE_MMAP_FOR_DICTIONARY
- env->ReleaseStringUTFChars(apkFileName, apkFileNameChars);
+ env->ReleaseStringUTFChars(sourceDir, sourceDirChars);
if (!dictBuf) {
LOGE("DICT: dictBuf is null");