void setBackgroundMusicVolumeJNI(float volume) { // void setBackgroundMusicVolume() #if 0 JniMethodInfo methodInfo; if (! getStaticMethodInfo(methodInfo, "setBackgroundMusicVolume", "(F)V")) { return ; } methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, volume); methodInfo.env->DeleteLocalRef(methodInfo.classID); #endif }
bool DeviceUtils::isWifiEnabled() { JniMethodInfo minfo; bool isHave = getStaticMethodInfo(minfo, JAVA_CLS_DEVICE, "isWifiEnabled", "()Z"); if(!isHave){ return false; } jboolean ret = minfo.env->CallStaticBooleanMethod(minfo.classID, minfo.methodID); CCLog("wifiEnabled: %d", ret); minfo.env->DeleteLocalRef(minfo.classID); if(ret){ return true; } return false; }
void preloadEffectJNI( const char *path ) { // void preloadEffect(String) JniMethodInfo methodInfo; if( !getStaticMethodInfo( methodInfo, "preloadEffect", "(Ljava/lang/String;)V" ) ) { LOGE( "error01:%s", __FUNCTION__ ); return; } jstring stringArg = methodInfo.env->NewStringUTF( path ); methodInfo.env->CallStaticVoidMethod( methodInfo.classID, methodInfo.methodID, stringArg ); methodInfo.env->DeleteLocalRef( stringArg ); methodInfo.env->DeleteLocalRef( methodInfo.classID ); }
void playBackgroundMusicJNI(const char *path, bool isLoop) { // void playBackgroundMusic(String,boolean) JniMethodInfo methodInfo; if (! getStaticMethodInfo(methodInfo, "playBackgroundMusic", "(Ljava/lang/String;Z)V")) { return; } jstring stringArg = methodInfo.env->NewStringUTF(path); methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg, isLoop); methodInfo.env->DeleteLocalRef(stringArg); methodInfo.env->DeleteLocalRef(methodInfo.classID); }
long compareDateJNI(const char* startDate) { JniMethodInfo methodInfo; jlong ret = 0; if (! getStaticMethodInfo(methodInfo, "compareDate", "(Ljava/lang/String;)J")) { return ret; } jstring stringArg = methodInfo.env->NewStringUTF(startDate); ret = methodInfo.env->CallStaticLongMethod(methodInfo.classID, methodInfo.methodID, stringArg); methodInfo.env->DeleteLocalRef(methodInfo.classID); return ret; }
void resumeBackgroundMusicJNI() { // void resumeBackgroundMusic() #if 0 JniMethodInfo methodInfo; if (! getStaticMethodInfo(methodInfo, "resumeBackgroundMusic", "()V")) { return; } methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); #endif }
void playFrameVideoJNI(const char* frameImgPath, const char* contentPath, int x, int y, int width, int height) { JniMethodInfo methodInfo; if (! getStaticMethodInfo(methodInfo, "playFrameVideo", "(Ljava/lang/String;Ljava/lang/String;IIII)V")) { return ; } jstring stringArg1 = methodInfo.env->NewStringUTF(frameImgPath); jstring stringArg2 = methodInfo.env->NewStringUTF(contentPath); methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg1, stringArg2, x, y, width, height); methodInfo.env->DeleteLocalRef(stringArg1); methodInfo.env->DeleteLocalRef(stringArg2); methodInfo.env->DeleteLocalRef(methodInfo.classID); }
void stopAllEffectsJNI() { #if 0 // void stopAllEffects() JniMethodInfo methodInfo; if (! getStaticMethodInfo(methodInfo, "stopAllEffects", "()V")) { return ; } methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); #endif }
void resumeEffectJNI(unsigned int nSoundId) { // void resumeEffect(int) #if 0 JniMethodInfo methodInfo; if (! getStaticMethodInfo(methodInfo, "resumeEffect", "(I)V")) { return ; } methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)nSoundId); methodInfo.env->DeleteLocalRef(methodInfo.classID); #endif }
void endJNI() { // void end() #if 0 JniMethodInfo methodInfo; if (! getStaticMethodInfo(methodInfo, "end", "()V")) { return ; } methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); #endif }
void preloadBackgroundMusicJNI( const char *path ) { LOGD( "%s:%s", __FUNCTION__, path ); // void playBackgroundMusic(String,boolean) JniMethodInfo methodInfo; if( !getStaticMethodInfo( methodInfo, "preloadBackgroundMusic", "(Ljava/lang/String;)V" ) ) { LOGE( "error01:%s", __FUNCTION__ ); return; } jstring stringArg = methodInfo.env->NewStringUTF( path ); methodInfo.env->CallStaticVoidMethod( methodInfo.classID, methodInfo.methodID, stringArg ); methodInfo.env->DeleteLocalRef( stringArg ); methodInfo.env->DeleteLocalRef( methodInfo.classID ); }
void unloadEffectJNI(const char* path) { // void unloadEffect(String) JniMethodInfo methodInfo; if (! getStaticMethodInfo(methodInfo, "unloadEffect", "(Ljava/lang/String;)V")) { return ; } jstring stringArg = methodInfo.env->NewStringUTF(path); methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg); methodInfo.env->DeleteLocalRef(stringArg); methodInfo.env->DeleteLocalRef(methodInfo.classID); }
long long getFreeSpaceJNI() { // int getFreeSpace() JniMethodInfo methodInfo; jlong ret = 0; if (! getStaticMethodInfo(methodInfo, "getFreeSpace", "()J")) { return ret; } ret = methodInfo.env->CallStaticLongMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); return ret; }
bool getNetworkStateJNI() { // boolean getNetworkState() JniMethodInfo methodInfo; jboolean ret = false; if (! getStaticMethodInfo(methodInfo, "getNetworkState", "()Z")) { return ret; } ret = methodInfo.env->CallStaticBooleanMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); return ret; }
unsigned int sendLMSCenterJNI() { // int sendLMSCenter() JniMethodInfo methodInfo; int ret = 0; if (! getStaticMethodInfo(methodInfo, "sendLMSCenter", "()I")) { return ret; } ret = methodInfo.env->CallStaticIntMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); return (unsigned int)ret; }
float getEffectsVolumeJNI() { // float getEffectsVolume() JniMethodInfo methodInfo; jfloat ret = -1.0; if (! getStaticMethodInfo(methodInfo, "getEffectsVolume", "()F")) { return ret; } ret = methodInfo.env->CallStaticFloatMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); return ret; }
bool checkSDCardAvailableJNI() { // boolean removeSaveFile() JniMethodInfo methodInfo; jboolean ret = false; if (! getStaticMethodInfo(methodInfo, "checkSDCardAvailable", "()Z")) { return ret; } ret = methodInfo.env->CallStaticBooleanMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); return ret; }
bool isBackgroundMusicPlayingJNI() { // boolean rewindBackgroundMusic() JniMethodInfo methodInfo; jboolean ret = false; if (! getStaticMethodInfo(methodInfo, "isBackgroundMusicPlaying", "()Z")) { return ret; } ret = methodInfo.env->CallStaticBooleanMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); return ret; }
void playBackgroundMusicXPFJNI(const char *path, bool isLoop, const char* szXPFPath, unsigned int dwSeek, unsigned int dwSize) { // void playBackgroundMusicXPF(final String pPath, final boolean isLoop, final String pXPFPath, final int pSeek, final int pLen) JniMethodInfo methodInfo; if (! getStaticMethodInfo(methodInfo, "playBackgroundMusic", "(Ljava/lang/String;ZLjava/lang/String;II)V")) { return; } jstring stringArg = methodInfo.env->NewStringUTF(path); jstring stringXpf = methodInfo.env->NewStringUTF(szXPFPath); methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg, isLoop, stringXpf, (int)dwSeek, (int)dwSize); methodInfo.env->DeleteLocalRef(stringArg); methodInfo.env->DeleteLocalRef(stringXpf); methodInfo.env->DeleteLocalRef(methodInfo.classID); }
float getBackgroundMusicVolumeJNI() { LOGD( "%s", __FUNCTION__ ); // float getBackgroundMusicVolume() JniMethodInfo methodInfo; jfloat ret = -1.0; if( !getStaticMethodInfo( methodInfo, "getBackgroundMusicVolume", "()F" ) ) { LOGE( "error01:%s", __FUNCTION__ ); return ret; } ret = methodInfo.env->CallStaticFloatMethod( methodInfo.classID, methodInfo.methodID ); methodInfo.env->DeleteLocalRef( methodInfo.classID ); return ret; }
bool isBackgroundMusicPlayingJNI() { LOGD( "%s", __FUNCTION__ ); // boolean rewindBackgroundMusic() JniMethodInfo methodInfo; jboolean ret = false; if( !getStaticMethodInfo( methodInfo, "isBackgroundMusicPlaying", "()Z" ) ) { LOGE( "error01:%s", __FUNCTION__ ); return ret; } ret = methodInfo.env->CallStaticBooleanMethod( methodInfo.classID, methodInfo.methodID ); methodInfo.env->DeleteLocalRef( methodInfo.classID ); return ret; }
unsigned int sendMailJNI(const char* text) { // int sendLMSCenter() JniMethodInfo methodInfo; int ret = 0; if (! getStaticMethodInfo(methodInfo, "sendMail", "(Ljava/lang/String;)I")) { return ret; } jstring stringArg = methodInfo.env->NewStringUTF(text); ret = methodInfo.env->CallStaticIntMethod(methodInfo.classID, methodInfo.methodID, stringArg); methodInfo.env->DeleteLocalRef(stringArg); methodInfo.env->DeleteLocalRef(methodInfo.classID); return (unsigned int)ret; }
long long getFileSizeJNI(const char* path) { // int getFileSize() JniMethodInfo methodInfo; jlong ret = 0; if (! getStaticMethodInfo(methodInfo, "getFileSize", "(Ljava/lang/String;)J")) { return ret; } jstring stringArg = methodInfo.env->NewStringUTF(path); ret = methodInfo.env->CallStaticLongMethod(methodInfo.classID, methodInfo.methodID, stringArg); methodInfo.env->DeleteLocalRef(stringArg); methodInfo.env->DeleteLocalRef(methodInfo.classID); return ret; }
bool removeSaveFileJNI(const char* path) { // boolean removeSaveFile() JniMethodInfo methodInfo; jboolean ret = false; if (! getStaticMethodInfo(methodInfo, "removeSaveFile", "(Ljava/lang/String;)Z")) { return ret; } jstring stringArg = methodInfo.env->NewStringUTF(path); ret = methodInfo.env->CallStaticBooleanMethod(methodInfo.classID, methodInfo.methodID, stringArg); methodInfo.env->DeleteLocalRef(stringArg); methodInfo.env->DeleteLocalRef(methodInfo.classID); return ret; }
float getBackgroundMusicVolumeJNI() { // float getBackgroundMusicVolume() #if 0 JniMethodInfo methodInfo; jfloat ret = -1.0; if (! getStaticMethodInfo(methodInfo, "getBackgroundMusicVolume", "()F")) { return ret; } ret = methodInfo.env->CallStaticFloatMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); return ret; #endif }
unsigned int playEffectJNI(const char* path, bool bLoop) { // int playEffect(String) JniMethodInfo methodInfo; int ret = 0; if (! getStaticMethodInfo(methodInfo, "playEffect", "(Ljava/lang/String;Z)I")) { return ret; } jstring stringArg = methodInfo.env->NewStringUTF(path); ret = methodInfo.env->CallStaticIntMethod(methodInfo.classID, methodInfo.methodID, stringArg, bLoop); methodInfo.env->DeleteLocalRef(stringArg); methodInfo.env->DeleteLocalRef(methodInfo.classID); return (unsigned int)ret; }
int getFileDescriptor(const char * filename, off_t & start, off_t & length) { JniMethodInfo methodInfo; if (! getStaticMethodInfo(methodInfo, ASSET_MANAGER_GETTER, "()Landroid/content/res/AssetManager;")) { methodInfo.env->DeleteLocalRef(methodInfo.classID); return FILE_NOT_FOUND; } jobject assetManager = methodInfo.env->CallStaticObjectMethod(methodInfo.classID, methodInfo.methodID); methodInfo.env->DeleteLocalRef(methodInfo.classID); AAssetManager* (*AAssetManager_fromJava)(JNIEnv* env, jobject assetManager); AAssetManager_fromJava = (AAssetManager* (*)(JNIEnv* env, jobject assetManager)) dlsym(s_pAndroidHandle, "AAssetManager_fromJava"); AAssetManager* mgr = AAssetManager_fromJava(methodInfo.env, assetManager); assert(NULL != mgr); AAsset* (*AAssetManager_open)(AAssetManager* mgr, const char* filename, int mode); AAssetManager_open = (AAsset* (*)(AAssetManager* mgr, const char* filename, int mode)) dlsym(s_pAndroidHandle, "AAssetManager_open"); AAsset* Asset = AAssetManager_open(mgr, filename, AASSET_MODE_UNKNOWN); if (NULL == Asset) { LOGD("file not found! Stop preload file: %s", filename); return FILE_NOT_FOUND; } // open asset as file descriptor int (*AAsset_openFileDescriptor)(AAsset* asset, off_t* outStart, off_t* outLength); AAsset_openFileDescriptor = (int (*)(AAsset* asset, off_t* outStart, off_t* outLength)) dlsym(s_pAndroidHandle, "AAsset_openFileDescriptor"); int fd = AAsset_openFileDescriptor(Asset, &start, &length); assert(0 <= fd); void (*AAsset_close)(AAsset* asset); AAsset_close = (void (*)(AAsset* asset)) dlsym(s_pAndroidHandle, "AAsset_close"); AAsset_close(Asset); return fd; }
unsigned int playEffectXPFJNI(const char* path, bool bLoop, const char* szXPFPath, unsigned int dwSeek, unsigned int dwSize) { // int playEffect(String) JniMethodInfo methodInfo; int ret = 0; if (! getStaticMethodInfo(methodInfo, "playEffect", "(Ljava/lang/String;ZLjava/lang/String;II)I")) { return ret; } jstring stringArg = methodInfo.env->NewStringUTF(path); jstring stringXpf = methodInfo.env->NewStringUTF(szXPFPath); ret = methodInfo.env->CallStaticIntMethod(methodInfo.classID, methodInfo.methodID, stringArg, bLoop, stringXpf, (int)dwSeek, (int)dwSize); methodInfo.env->DeleteLocalRef(stringArg); methodInfo.env->DeleteLocalRef(stringXpf); methodInfo.env->DeleteLocalRef(methodInfo.classID); return (unsigned int)ret; }
const char *LoomJni::getWritablePath() { static utString writablePath; loomJniMethodInfo t; if (getStaticMethodInfo(t, "co/theengine/loomdemo/LoomDemo", "getActivityWritablePath", "()Ljava/lang/String;")) { jstring str = (jstring)t.getEnv()->CallStaticObjectMethod(t.classID, t.methodID); writablePath = jstring2string(str); t.getEnv()->DeleteLocalRef(str); lmLog(jniLogGroup, "writable path %s", writablePath.c_str()); return writablePath.c_str(); } return 0; }
const char *LoomJni::getSettingsPath() { static utString path; loomJniMethodInfo t; if (getStaticMethodInfo(t, "co/theengine/loomplayer/LoomPlayer", "getActivitySettingsPath", "()Ljava/lang/String;")) { jstring str = (jstring)t.getEnv()->CallStaticObjectMethod(t.classID, t.methodID); path = jstring2string(str); t.getEnv()->DeleteLocalRef(str); lmLog(jniLogGroup, "settings path %s", path.c_str()); return path.c_str(); } return 0; }