Blame view

ios/cocos2d/cocos/platform/android/CCEnhanceAPI-android.cpp 2.76 KB
520389e3   xiaoyu   接入cocos源码,编译未通过,继续修改
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
  /****************************************************************************
   * 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
  ****************************************************************************/
  #include "platform/android/jni/JniHelper.h"
  #include "platform/android/CCEnhanceAPI-android.h"
  #include <android/log.h>
  #include <jni.h>
  
  #define  LOG_TAG    "CCEnhanceAPI_android Debug"
  #define  LOGD(...)  __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
  
  #define CLASS_NAME "org.cocos2dx.lib.Cocos2dxHelper"
  
  // 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.
  // Fixed, at least, in NDK 12b
  //#ifdef __aarch64__
  //extern "C" size_t __ctype_get_mb_cur_max(void) {
  //    return (size_t) sizeof(wchar_t);
  //}
  //#endif
  
  NS_CC_BEGIN
  
  EnhanceAPI::EnhanceAPI()
  {
  }
  
  EnhanceAPI::~EnhanceAPI()
  {
  }
  
  int EnhanceAPI::setResolutionPercent(int n)
  {
      JniMethodInfo t;
      int ret = -1;
      if(JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setResolutionPercent", "(I)I"))
      {
          ret = t.env->CallStaticIntMethod(t.classID, t.methodID, n);
          t.env->DeleteLocalRef(t.classID);
      }
      return ret;
  }
  
  int EnhanceAPI::setFPS(int fps)
  {
      JniMethodInfo t;
      int ret = -1;
      if(JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setFPS", "(I)I"))
      {
          ret = t.env->CallStaticIntMethod(t.classID, t.methodID, fps);
          t.env->DeleteLocalRef(t.classID);
      }
      return ret;
  }
  
  int EnhanceAPI::fastLoading(int sec)
  {
      JniMethodInfo t;
      int ret = -1;
      if(JniHelper::getStaticMethodInfo(t, CLASS_NAME, "fastLoading", "(I)I"))
      {
          ret = t.env->CallStaticIntMethod(t.classID, t.methodID, sec);
          t.env->DeleteLocalRef(t.classID);
      }
      return ret;
  }
  
  int EnhanceAPI::getTemperature()
  {
      JniMethodInfo t;
      int ret = -1;
      if(JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getTemperature", "()I"))
      {
          ret = t.env->CallStaticIntMethod(t.classID, t.methodID);
          t.env->DeleteLocalRef(t.classID);
      }
      return ret;
  }
  
  int EnhanceAPI::setLowPowerMode(bool enable)
  {
      JniMethodInfo t;
      int ret = -1;
      if(JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setLowPowerMode", "(Z)I"))
      {
          ret = t.env->CallStaticIntMethod(t.classID, t.methodID, enable);
          t.env->DeleteLocalRef(t.classID);
      }
      return ret;
  }
  NS_CC_END