Loading java/src/com/android/inputmethod/latin/NativeUtils.java 0 → 100644 +32 −0 Original line number Diff line number Diff line /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.inputmethod.latin; public class NativeUtils { static { JniUtils.loadNativeLibrary(); } private NativeUtils() { // This utility class is not publicly instantiable. } /** * This method just calls up libm's powf() directly. */ public static native float powf(float x, float y); } java/src/com/android/inputmethod/latin/UserHistoryForgettingCurveUtils.java +2 −2 Original line number Diff line number Diff line Loading @@ -211,8 +211,8 @@ public class UserHistoryForgettingCurveUtils { } for (int j = 0; j < ELAPSED_TIME_MAX; ++j) { final float elapsedHours = j * ELAPSED_TIME_INTERVAL_HOURS; final double freq = initialFreq * Math.pow(initialFreq, elapsedHours / HALF_LIFE_HOURS); final float freq = initialFreq * NativeUtils.powf(initialFreq, elapsedHours / HALF_LIFE_HOURS); final int intFreq = Math.min(FC_FREQ_MAX, Math.max(0, (int)freq)); SCORE_TABLE[i][j] = intFreq; } Loading native/jni/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function LATIN_IME_JNI_SRC_FILES := \ com_android_inputmethod_keyboard_ProximityInfo.cpp \ com_android_inputmethod_latin_BinaryDictionary.cpp \ com_android_inputmethod_latin_NativeUtils.cpp \ jni_common.cpp LATIN_IME_CORE_SRC_FILES := \ Loading native/jni/com_android_inputmethod_latin_NativeUtils.cpp 0 → 100644 +40 −0 Original line number Diff line number Diff line /* ** ** Copyright 2012, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ #include "com_android_inputmethod_latin_NativeUtils.h" #include "jni.h" #include "jni_common.h" #include <math.h> namespace latinime { static float latinime_NativeUtils_powf(float x, float y) { return powf(x, y); } static JNINativeMethod sMethods[] = { {"powf", "(FF)F", (void*)latinime_NativeUtils_powf} }; int register_NativeUtils(JNIEnv *env) { const char* const kClassPathName = "com/android/inputmethod/latin/NativeUtils"; return registerNativeMethods(env, kClassPathName, sMethods, sizeof(sMethods) / sizeof(sMethods[0])); } } // namespace latinime native/jni/com_android_inputmethod_latin_NativeUtils.h 0 → 100644 +29 −0 Original line number Diff line number Diff line /* ** ** Copyright 2012, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ #ifndef _COM_ANDROID_INPUTMETHOD_LATIN_NATIVEUTILS_H #define _COM_ANDROID_INPUTMETHOD_LATIN_NATIVEUTILS_H #include "jni.h" namespace latinime { int register_NativeUtils(JNIEnv *env); } #endif // _COM_ANDROID_INPUTMETHOD_LATIN_NATIVEUTILS_H Loading
java/src/com/android/inputmethod/latin/NativeUtils.java 0 → 100644 +32 −0 Original line number Diff line number Diff line /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.inputmethod.latin; public class NativeUtils { static { JniUtils.loadNativeLibrary(); } private NativeUtils() { // This utility class is not publicly instantiable. } /** * This method just calls up libm's powf() directly. */ public static native float powf(float x, float y); }
java/src/com/android/inputmethod/latin/UserHistoryForgettingCurveUtils.java +2 −2 Original line number Diff line number Diff line Loading @@ -211,8 +211,8 @@ public class UserHistoryForgettingCurveUtils { } for (int j = 0; j < ELAPSED_TIME_MAX; ++j) { final float elapsedHours = j * ELAPSED_TIME_INTERVAL_HOURS; final double freq = initialFreq * Math.pow(initialFreq, elapsedHours / HALF_LIFE_HOURS); final float freq = initialFreq * NativeUtils.powf(initialFreq, elapsedHours / HALF_LIFE_HOURS); final int intFreq = Math.min(FC_FREQ_MAX, Math.max(0, (int)freq)); SCORE_TABLE[i][j] = intFreq; } Loading
native/jni/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function LATIN_IME_JNI_SRC_FILES := \ com_android_inputmethod_keyboard_ProximityInfo.cpp \ com_android_inputmethod_latin_BinaryDictionary.cpp \ com_android_inputmethod_latin_NativeUtils.cpp \ jni_common.cpp LATIN_IME_CORE_SRC_FILES := \ Loading
native/jni/com_android_inputmethod_latin_NativeUtils.cpp 0 → 100644 +40 −0 Original line number Diff line number Diff line /* ** ** Copyright 2012, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ #include "com_android_inputmethod_latin_NativeUtils.h" #include "jni.h" #include "jni_common.h" #include <math.h> namespace latinime { static float latinime_NativeUtils_powf(float x, float y) { return powf(x, y); } static JNINativeMethod sMethods[] = { {"powf", "(FF)F", (void*)latinime_NativeUtils_powf} }; int register_NativeUtils(JNIEnv *env) { const char* const kClassPathName = "com/android/inputmethod/latin/NativeUtils"; return registerNativeMethods(env, kClassPathName, sMethods, sizeof(sMethods) / sizeof(sMethods[0])); } } // namespace latinime
native/jni/com_android_inputmethod_latin_NativeUtils.h 0 → 100644 +29 −0 Original line number Diff line number Diff line /* ** ** Copyright 2012, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ #ifndef _COM_ANDROID_INPUTMETHOD_LATIN_NATIVEUTILS_H #define _COM_ANDROID_INPUTMETHOD_LATIN_NATIVEUTILS_H #include "jni.h" namespace latinime { int register_NativeUtils(JNIEnv *env); } #endif // _COM_ANDROID_INPUTMETHOD_LATIN_NATIVEUTILS_H