2013-07-14 05:59:30 +08:00
|
|
|
#include "ccdandroidUtils.h"
|
|
|
|
#include "cocos2d.h"
|
|
|
|
|
|
|
|
#include <jni.h>
|
|
|
|
#include <android/log.h>
|
|
|
|
#include "jni/JniHelper.h"
|
|
|
|
|
|
|
|
USING_NS_CC;
|
|
|
|
|
|
|
|
namespace CocosDenshion {
|
|
|
|
namespace android {
|
|
|
|
|
|
|
|
#define I9100_MODEL "GT-I9100"
|
|
|
|
#define LOG_TAG "Device Model"
|
|
|
|
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
|
|
|
|
#define CLASS_NAME "org/cocos2dx/lib/Cocos2dxHelper"
|
|
|
|
#define METHOD_NAME "getDeviceModel"
|
|
|
|
|
|
|
|
bool is_buggy_device(void) {
|
|
|
|
JniMethodInfo methodInfo;
|
|
|
|
jstring jstr;
|
2013-07-20 07:32:38 +08:00
|
|
|
if (JniHelper::getStaticMethodInfo(methodInfo,
|
|
|
|
CLASS_NAME,
|
|
|
|
METHOD_NAME,
|
|
|
|
"()Ljava/lang/String;")) {
|
|
|
|
jstr = (jstring)methodInfo.env->CallStaticObjectMethod(methodInfo.classID,
|
|
|
|
methodInfo.methodID);
|
|
|
|
}
|
2013-07-14 05:59:30 +08:00
|
|
|
|
|
|
|
const char* deviceModel = methodInfo.env->GetStringUTFChars(jstr, NULL);
|
2013-07-20 07:32:38 +08:00
|
|
|
if (NULL == deviceModel) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
LOGD("deviceModel = %s", deviceModel);
|
|
|
|
methodInfo.env->ReleaseStringUTFChars(jstr, deviceModel);
|
|
|
|
methodInfo.env->DeleteLocalRef(jstr);
|
2013-07-14 05:59:30 +08:00
|
|
|
|
|
|
|
if (strcmp(I9100_MODEL, deviceModel) == 0) {
|
|
|
|
LOGD("i9100 model\nSwitch to OpenSLES");
|
2013-07-20 07:32:38 +08:00
|
|
|
return true;
|
2013-07-14 05:59:30 +08:00
|
|
|
}
|
|
|
|
|
2013-07-20 07:32:38 +08:00
|
|
|
return false;
|
2013-07-14 05:59:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string getFullPathWithoutAssetsPrefix(const char* pszFilename) {
|
|
|
|
// Changing file path to full path
|
2013-07-25 07:57:15 +08:00
|
|
|
std::string fullPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(pszFilename);
|
2013-07-14 05:59:30 +08:00
|
|
|
// Removing `assets` since it isn't needed for the API of playing sound.
|
|
|
|
size_t pos = fullPath.find("assets/");
|
|
|
|
if (pos == 0)
|
|
|
|
{
|
|
|
|
fullPath = fullPath.substr(strlen("assets/"));
|
|
|
|
}
|
|
|
|
return fullPath;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|