Remove unnecessary DeleteLocalRef (?) and clean up checking code

This commit is contained in:
folecr 2013-07-19 16:32:38 -07:00
parent 210cf68cab
commit f3141826b2
1 changed files with 16 additions and 13 deletions

View File

@ -17,28 +17,31 @@ namespace CocosDenshion {
#define METHOD_NAME "getDeviceModel"
bool is_buggy_device(void) {
bool buggydevice = false;
JniMethodInfo methodInfo;
jstring jstr;
if (JniHelper::getStaticMethodInfo(methodInfo, CLASS_NAME, METHOD_NAME, "()Ljava/lang/String;"))
{
jstr = (jstring)methodInfo.env->CallStaticObjectMethod(methodInfo.classID, methodInfo.methodID);
}
methodInfo.env->DeleteLocalRef(methodInfo.classID);
if (JniHelper::getStaticMethodInfo(methodInfo,
CLASS_NAME,
METHOD_NAME,
"()Ljava/lang/String;")) {
jstr = (jstring)methodInfo.env->CallStaticObjectMethod(methodInfo.classID,
methodInfo.methodID);
}
const char* deviceModel = methodInfo.env->GetStringUTFChars(jstr, NULL);
LOGD("%s", deviceModel);
if (NULL == deviceModel) {
return false;
}
LOGD("deviceModel = %s", deviceModel);
methodInfo.env->ReleaseStringUTFChars(jstr, deviceModel);
methodInfo.env->DeleteLocalRef(jstr);
if (strcmp(I9100_MODEL, deviceModel) == 0) {
LOGD("i9100 model\nSwitch to OpenSLES");
buggydevice = true;
return true;
}
methodInfo.env->ReleaseStringUTFChars(jstr, deviceModel);
methodInfo.env->DeleteLocalRef(jstr);
return buggydevice;
return false;
}
std::string getFullPathWithoutAssetsPrefix(const char* pszFilename) {