Skip to content

Commit e516c0e

Browse files
committed
Add missing vibrateCancel method
1 parent 7405bc0 commit e516c0e

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

aml.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ jobject AML::GetCurrentContext()
521521
}
522522

523523
jobject g_VibratorObject;
524-
jmethodID g_VibrateLongMethod, g_VibratePatternMethod;
524+
jmethodID g_VibrateLongMethod, g_VibratePatternMethod, g_VibrateCancelMethod;
525525
bool g_bVibratorInited = false;
526526
inline bool InitVibroJNI(JNIEnv* env)
527527
{
@@ -543,6 +543,7 @@ inline bool InitVibroJNI(JNIEnv* env)
543543
g_VibratorObject = env->NewGlobalRef(localVibrateObject);
544544
g_VibrateLongMethod = env->GetMethodID(vibratorCls, "vibrate", "(J)V");
545545
g_VibratePatternMethod = env->GetMethodID(vibratorCls, "vibrate", "([JI)V");
546+
g_VibrateCancelMethod = env->GetMethodID(vibratorCls, "cancel", "()V");
546547

547548
env->DeleteLocalRef(vibratorFieldStr);
548549
env->DeleteLocalRef(vibratorCls);
@@ -578,6 +579,11 @@ void AML::DoVibro(jlong* pattern, int patternItems)
578579
env->DeleteLocalRef(patternArray);
579580
}
580581
}
582+
void AML::CancelVibro()
583+
{
584+
JNIEnv* env = GetCurrentJNI();
585+
if(env) env->CallVoidMethod(g_VibratorObject, g_VibrateCancelMethod);
586+
}
581587

582588
bool g_bBatteryInited = false;
583589
jstring g_pLevelStr;
@@ -607,6 +613,8 @@ float AML::GetBatteryLevel()
607613
jstring scaleStr = env->NewStringUTF("scale");
608614
g_fCachedScale = (float)env->CallIntMethod(g_BatteryIntent, g_GetLevelMethod, scaleStr, -1);
609615
env->DeleteLocalRef(scaleStr);
616+
617+
g_bBatteryInited = true;
610618
}
611619

612620
jint level = env->CallIntMethod(g_BatteryIntent, g_GetLevelMethod, g_pLevelStr, -1);

include/aml.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class AML : public IAML
9595
jobject GetCurrentContext();
9696
void DoVibro(int msTime);
9797
void DoVibro(jlong* pattern, int patternItems);
98+
void CancelVibro();
9899
float GetBatteryLevel();
99100
};
100101

mod/iaml.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ class IAML
187187
virtual jobject GetCurrentContext();
188188
virtual void DoVibro(int msTime); // Pretty strong feedback... If you need a small vibro, do it for like ~20ms, it's gonna be enough
189189
virtual void DoVibro(jlong* pattern, int patternItems); // Patterns might give you more control
190+
virtual void CancelVibro();
190191
virtual float GetBatteryLevel(); // returns a float from 0.0 to 100.0
191192

192193

0 commit comments

Comments
 (0)