2015-05-15 14:29:22 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Samsung API for cocos
|
|
|
|
* Developed by Game Engine part
|
|
|
|
*
|
|
|
|
* Copyright 2015 by Mobile Solution Lab, MSG, SRC-NJ.
|
|
|
|
* Wang Ying
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This software is the confidential and proprietary information of
|
|
|
|
* Samsung Electronics, Inc. ("Confidential Information"). You
|
|
|
|
* Shall not disclose such Confidential Information and shall use
|
|
|
|
* it only in accordance with the terms of the license agreement
|
|
|
|
* you entered into with Samsung
|
2021-12-25 10:04:45 +08:00
|
|
|
****************************************************************************/
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "platform/android/jni/JniHelper.h"
|
|
|
|
#include "platform/android/CCEnhanceAPI-android.h"
|
2015-05-15 14:29:22 +08:00
|
|
|
#include <android/log.h>
|
|
|
|
#include <jni.h>
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
#define LOG_TAG "CCEnhanceAPI_android Debug"
|
|
|
|
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
|
2015-05-15 14:29:22 +08:00
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
#define CLASS_NAME "org.axys1.lib.AxysHelper"
|
2015-05-15 14:29:22 +08:00
|
|
|
|
|
|
|
// FIXME: using ndk-r10c will cause the next function could not be found. It may be a bug of ndk-r10c.
|
|
|
|
// Here is the workaround method to fix the problem.
|
2016-07-12 05:07:11 +08:00
|
|
|
// Fixed, at least, in NDK 12b
|
|
|
|
//#ifdef __aarch64__
|
2021-12-25 10:04:45 +08:00
|
|
|
// extern "C" size_t __ctype_get_mb_cur_max(void) {
|
2016-07-12 05:07:11 +08:00
|
|
|
// return (size_t) sizeof(wchar_t);
|
|
|
|
//}
|
|
|
|
//#endif
|
2015-05-15 14:29:22 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_BEGIN
|
2015-05-15 14:29:22 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
EnhanceAPI::EnhanceAPI() {}
|
2015-05-15 14:29:22 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
EnhanceAPI::~EnhanceAPI() {}
|
2015-05-15 14:29:22 +08:00
|
|
|
|
|
|
|
int EnhanceAPI::setResolutionPercent(int n)
|
|
|
|
{
|
|
|
|
JniMethodInfo t;
|
2015-08-14 21:17:51 +08:00
|
|
|
int ret = -1;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setResolutionPercent", "(I)I"))
|
2015-05-15 14:29:22 +08:00
|
|
|
{
|
|
|
|
ret = t.env->CallStaticIntMethod(t.classID, t.methodID, n);
|
2015-10-24 20:26:59 +08:00
|
|
|
t.env->DeleteLocalRef(t.classID);
|
2015-05-15 14:29:22 +08:00
|
|
|
}
|
2015-08-14 21:17:51 +08:00
|
|
|
return ret;
|
2015-05-15 14:29:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int EnhanceAPI::setFPS(int fps)
|
|
|
|
{
|
|
|
|
JniMethodInfo t;
|
2015-08-14 21:17:51 +08:00
|
|
|
int ret = -1;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setFPS", "(I)I"))
|
2015-05-15 14:29:22 +08:00
|
|
|
{
|
|
|
|
ret = t.env->CallStaticIntMethod(t.classID, t.methodID, fps);
|
2015-10-24 20:26:59 +08:00
|
|
|
t.env->DeleteLocalRef(t.classID);
|
2015-05-15 14:29:22 +08:00
|
|
|
}
|
2015-08-14 21:17:51 +08:00
|
|
|
return ret;
|
2015-05-15 14:29:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int EnhanceAPI::fastLoading(int sec)
|
|
|
|
{
|
|
|
|
JniMethodInfo t;
|
2015-08-14 21:17:51 +08:00
|
|
|
int ret = -1;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "fastLoading", "(I)I"))
|
2015-05-15 14:29:22 +08:00
|
|
|
{
|
|
|
|
ret = t.env->CallStaticIntMethod(t.classID, t.methodID, sec);
|
2015-10-24 20:26:59 +08:00
|
|
|
t.env->DeleteLocalRef(t.classID);
|
2015-05-15 14:29:22 +08:00
|
|
|
}
|
2015-08-14 21:17:51 +08:00
|
|
|
return ret;
|
2015-05-15 14:29:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int EnhanceAPI::getTemperature()
|
|
|
|
{
|
|
|
|
JniMethodInfo t;
|
2015-08-14 21:17:51 +08:00
|
|
|
int ret = -1;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getTemperature", "()I"))
|
2015-05-15 14:29:22 +08:00
|
|
|
{
|
|
|
|
ret = t.env->CallStaticIntMethod(t.classID, t.methodID);
|
2015-10-24 20:26:59 +08:00
|
|
|
t.env->DeleteLocalRef(t.classID);
|
2015-05-15 14:29:22 +08:00
|
|
|
}
|
2015-08-14 21:17:51 +08:00
|
|
|
return ret;
|
2015-05-15 14:29:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int EnhanceAPI::setLowPowerMode(bool enable)
|
|
|
|
{
|
|
|
|
JniMethodInfo t;
|
2015-08-14 21:17:51 +08:00
|
|
|
int ret = -1;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setLowPowerMode", "(Z)I"))
|
2015-05-15 14:29:22 +08:00
|
|
|
{
|
|
|
|
ret = t.env->CallStaticIntMethod(t.classID, t.methodID, enable);
|
2015-10-24 20:26:59 +08:00
|
|
|
t.env->DeleteLocalRef(t.classID);
|
2015-05-15 14:29:22 +08:00
|
|
|
}
|
2015-08-14 21:17:51 +08:00
|
|
|
return ret;
|
2015-05-15 14:29:22 +08:00
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_END
|