@@ -521,7 +521,7 @@ jobject AML::GetCurrentContext()
521521}
522522
523523jobject g_VibratorObject;
524- jmethodID g_VibrateLongMethod, g_VibratePatternMethod;
524+ jmethodID g_VibrateLongMethod, g_VibratePatternMethod, g_VibrateCancelMethod ;
525525bool g_bVibratorInited = false ;
526526inline 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
582588bool g_bBatteryInited = false ;
583589jstring 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 );
0 commit comments