예제 #1
0
            public bool Initialize()
            {
                bool isInitialized = false;

                try
                {
                    if (TryParseVersion(GetVersion(), out Version initVersion))
                    {
                        if (initVersion < new Version(3, 0))
                        {
                            isInitialized = s_GameSDK.Call <bool>("initialize");
                        }
                        else
                        {
                            isInitialized = s_GameSDK.Call <bool>("initialize", initVersion.ToString());
                        }

                        if (isInitialized)
                        {
                            isInitialized = RegisterListener();
                        }
                        else
                        {
                            GameSDKLog.Debug("GameSDK.initialize() failed!");
                        }
                    }
                }
                catch (Exception)
                {
                    GameSDKLog.Debug("[Exception] GameSDK.initialize() failed!");
                }

                return(isInitialized);
            }
 void onHighTempWarning(int warningLevel)
 {
     GameSDKLog.Debug("Listener: onHighTempWarning(warningLevel={0})", warningLevel);
     if (warningLevel == 0)
         PerformanceWarningEvent(WarningLevel.NoWarning);
     else if (warningLevel == 1)
         PerformanceWarningEvent(WarningLevel.ThrottlingImminent);
     else if (warningLevel == 2)
         PerformanceWarningEvent(WarningLevel.Throttling);
 }
 public string GetVersion()
 {
     string sdkVersion = "";
     try
     {
         sdkVersion = s_GameSDK.Call<string>("getVersion");
     }
     catch (Exception)
     {
         GameSDKLog.Debug("[Exception] GameSDK.getVersion() failed!");
     }
     return sdkVersion;
 }
 public bool SetLevelWithScene(string scene, int cpu, int gpu)
 {
     bool success = false;
     try
     {
         success = s_GameSDK.Call<bool>("setLevelWithScene", scene, cpu, gpu);
         GameSDKLog.Debug("setLevelWithScene({0}, {1}, {2}) -> {3}", scene, cpu, gpu, success);
     }
     catch (Exception)
     {
         GameSDKLog.Debug("[Exception] GameSDK.setLevelWithScene({0}, {1}, {2}) failed!", scene, cpu, gpu);
     }
     return success;
 }
            public int GetMaxGpuPerformanceLevel()
            {
                int maxGpuPerformanceLevel = -1;
                try
                {
                    maxGpuPerformanceLevel = s_GameSDK.Call<int>("getGPULevelMax");
                }
                catch (Exception)
                {
                    GameSDKLog.Debug("[Exception] GameSDK.getCPULevelMax() failed!");
                }

                return maxGpuPerformanceLevel;
            }
 public int SetFreqLevels(int cpu, int gpu)
 {
     int result = 0;
     try
     {
         result = s_GameSDK.Call<int>("setFreqLevels", cpu, gpu);
         GameSDKLog.Debug("setFreqLevels({0}, {1}) -> {2}", cpu, gpu, result);
     }
     catch (Exception x)
     {
         GameSDKLog.Debug("[Exception] GameSDK.setFreqLevels({0}, {1}) failed: {2}", cpu, gpu, x);
     }
     return result;
 }
        public bool SetPerformanceLevel(int cpuLevel, int gpuLevel)
        {
            if (cpuLevel < 0)
                cpuLevel = 0;
            else if (cpuLevel > MaxCpuPerformanceLevel)
                cpuLevel = MaxCpuPerformanceLevel;

            if (gpuLevel < 0)
                gpuLevel = 0;
            else if (gpuLevel > MaxGpuPerformanceLevel)
                gpuLevel = MaxGpuPerformanceLevel;

            if (m_Version == new Version(3, 2) && cpuLevel == 0)
                cpuLevel = 1;

            bool success = false;
            if (m_UseSetFreqLevels)
            {
                int result = m_Api.SetFreqLevels(cpuLevel, gpuLevel);
                success = result == 1;

                if (result == 2)
                {
                    GameSDKLog.Debug($"Thermal Mitigation Logic is working and CPU({cpuLevel})/GPU({gpuLevel}) level change request was not approved.");
                    m_Data.PerformanceLevelControlAvailable = false;
                    m_Data.ChangeFlags |= Feature.PerformanceLevelControl;
                    m_PerformanceLevelControlSystemChange = true;
                }
            }
            else
            {
                success = m_Api.SetLevelWithScene(sceneName, cpuLevel, gpuLevel);
            }

            lock (m_DataLock)
            {
                var oldCpuLevel = m_Data.CpuPerformanceLevel;
                var oldGpuLevel = m_Data.GpuPerformanceLevel;

                m_Data.CpuPerformanceLevel = success ? cpuLevel : Constants.UnknownPerformanceLevel;
                m_Data.GpuPerformanceLevel = success ? gpuLevel : Constants.UnknownPerformanceLevel;

                if (m_Data.CpuPerformanceLevel != oldCpuLevel)
                    m_Data.ChangeFlags |= Feature.CpuPerformanceLevel;
                if (m_Data.GpuPerformanceLevel != oldGpuLevel)
                    m_Data.ChangeFlags |= Feature.GpuPerformanceLevel;
            }
            return success;
        }
예제 #8
0
        override public void Start()
        {
            if (m_Api.Initialize())
            {
                if (TryParseVersion(m_Api.GetVersion(), out m_Version))
                {
                    if (m_Version >= new Version(3, 0))
                    {
                        initialized = true;
                        m_UseHighPrecisionSkinTemp = true;
                        MaxCpuPerformanceLevel     = m_Api.GetMaxCpuPerformanceLevel();
                        MaxGpuPerformanceLevel     = m_Api.GetMaxGpuPerformanceLevel();
                        GameSDKLog.Debug("MaxCpuPerformanceLevel: " + MaxCpuPerformanceLevel + " MaxGpuPerformanceLevel:" + MaxGpuPerformanceLevel);
                        m_MainTemperature = m_SkinTemp;
                    }
                    else if (m_Version >= new Version(2, 0))
                    {
                        initialized = true;
                        m_UseHighPrecisionSkinTemp = true;
                    }
                    else if (m_Version >= new Version(1, 6))
                    {
                        initialized = true;
                        m_UseHighPrecisionSkinTemp = false;
                    }
                    else if (m_Version >= new Version(1, 5))
                    {
                        m_MaxTempLevel             = 6.0f;
                        m_MinTempLevel             = 0.0f;
                        initialized                = true;
                        m_MainTemperature          = m_PSTLevel;
                        m_SkinTemp                 = null;
                        m_UseHighPrecisionSkinTemp = false;
                    }
                    else
                    {
                        m_Api.Terminate();
                        initialized = false;
                    }
                }

                m_Data.PerformanceLevelControlAvailable = true;
            }

            if (initialized)
            {
                ImmediateUpdateTemperature();
            }
        }
            public void UnregisterListener()
            {
                bool success = true;
                try
                {
                    GameSDKLog.Debug("setListener(null)");
                    success = s_GameSDK.Call<bool>("setListener", (Object)null);
                }
                catch (Exception)
                {
                    success = false;
                }

                if (!success)
                    GameSDKLog.Debug("setListener(null) failed!");
            }
        public void ApplicationResume()
        {
            //We need to re-initialize because some Android onForegroundchange() APIs do not detect the change (e.g. bixby)
            if (!m_Api.Initialize())
                GameSDKLog.Debug("Resume: reinitialization failed!");

            lock (m_DataLock)
            {
                m_Data.CpuPerformanceLevel = Constants.UnknownPerformanceLevel;
                m_Data.GpuPerformanceLevel = Constants.UnknownPerformanceLevel;
                m_Data.ChangeFlags |= Feature.CpuPerformanceLevel;
                m_Data.ChangeFlags |= Feature.GpuPerformanceLevel;
            }

            ImmediateUpdateTemperature();
        }
            public bool RegisterListener()
            {
                bool success = false;
                try
                {
                    success = s_GameSDK.Call<bool>("setListener", this);
                }
                catch (Exception)
                {
                    success = false;
                }

                if (!success)
                    GameSDKLog.Debug("failed to register listener");

                return success;
            }
 public int GetSkinTempLevel()
 {
     int currentTempLevel = -1;
     try
     {
         currentTempLevel = AndroidJNI.CallIntMethod(s_GameSDKRawObjectID, s_GetSkinTempLevelID, s_NoArgs);
         if (AndroidJNI.ExceptionOccurred() != IntPtr.Zero)
         {
             AndroidJNI.ExceptionDescribe();
             AndroidJNI.ExceptionClear();
         }
     }
     catch (Exception)
     {
         GameSDKLog.Debug("[Exception] GameSDK.getSkinTempLevel() failed!");
     }
     return currentTempLevel;
 }
 public double GetHighPrecisionSkinTempLevel()
 {
     double currentTempLevel = -1.0;
     try
     {
         currentTempLevel = AndroidJNI.CallDoubleMethod(s_GameSDKRawObjectID, s_GetHighPrecisionSkinTempLevelID, s_NoArgs);
         if (AndroidJNI.ExceptionOccurred() != IntPtr.Zero)
         {
             AndroidJNI.ExceptionDescribe();
             AndroidJNI.ExceptionClear();
         }
     }
     catch (Exception)
     {
         GameSDKLog.Debug("[Exception] GameSDK.getHighPrecisionSkinTempLevel() failed!");
     }
     return currentTempLevel;
 }
예제 #14
0
            public bool Initialize()
            {
                bool isInitialized = false;

                try
                {
                    Version initVersion;
                    if (TryParseVersion(GetVersion(), out initVersion))
                    {
                        if (initVersion < new Version(3, 0))
                        {
                            isInitialized = s_GameSDK.Call <bool>("initialize");
                        }
                        else
                        {
                            // There is a critical bug which can lead to overheated devices in GameSDK 3.1 so we will not initialize GameSDK or Adaptive Performance
                            if (initVersion == new Version(3, 1))
                            {
                                GameSDKLog.Debug("GameSDK 3.1 is not supported and will not be initialized, Adaptive Performance will not be used.");
                            }
                            else
                            {
                                isInitialized = s_GameSDK.Call <bool>("initialize", initVersion.ToString());
                            }
                        }

                        if (isInitialized)
                        {
                            isInitialized = RegisterListener();
                        }
                        else
                        {
                            GameSDKLog.Debug("GameSDK.initialize() failed!");
                        }
                    }
                }
                catch (Exception)
                {
                    GameSDKLog.Debug("[Exception] GameSDK.initialize() failed!");
                }

                return(isInitialized);
            }
            public double GetGpuFrameTime()
            {
                double gpuFrameTime = -1.0;
                try
                {
                    gpuFrameTime = AndroidJNI.CallDoubleMethod(s_GameSDKRawObjectID, s_GetGpuFrameTimeID, s_NoArgs);
                    if (AndroidJNI.ExceptionOccurred() != IntPtr.Zero)
                    {
                        AndroidJNI.ExceptionDescribe();
                        AndroidJNI.ExceptionClear();
                    }
                }
                catch (Exception)
                {
                    GameSDKLog.Debug("[Exception] GameSDK.getGpuFrameTime() failed!");
                }

                return gpuFrameTime;
            }
            public void Terminate()
            {
                UnregisterListener();

                bool success = true;

                try
                {
                    var packageName = Application.identifier;
                    GameSDKLog.Debug("GameSDK.finalize({0})", packageName);
                    success = s_GameSDK.Call<bool>("finalize", packageName);
                }
                catch (Exception)
                {
                    success = false;
                }

                if (!success)
                    GameSDKLog.Debug("GameSDK.finalize() failed!");
            }
            public bool Initialize()
            {
                bool isInitialized = false;

                try
                {
                    isInitialized = s_GameSDK.Call <bool>("initialize");
                    if (isInitialized)
                    {
                        isInitialized = RegisterListener();
                    }
                    else
                    {
                        GameSDKLog.Debug("GameSDK.initialize() failed!");
                    }
                }
                catch (Exception)
                {
                    GameSDKLog.Debug("[Exception] GameSDK.initialize() failed!");
                }

                return(isInitialized);
            }
예제 #18
0
 void onReleasedByTimeout()
 {
     GameSDKLog.Debug("Listener: onReleasedByTimeout()");
     PerformanceLevelTimeoutEvent();
 }
예제 #19
0
 void onRefreshRateChanged()
 {
     GameSDKLog.Debug("Listener: onRefreshRateChanged()");
     // Not used in 1.x.x. Available in 2.0.0 but the callback is needed to avoid that Samsung GameSDK is correctly calling other callbacks on VRR enabled devices.
 }