SDKUtil = SDKUtil or BaseClass() local SDKUtil = SDKUtil _G.SDKUtil.BATTERY_MODULE_LEVEL = 100 function SDKUtil.SDKCallBack( data ) local sdk_data = JsonToTable(data) if sdk_data then local module_name = sdk_data["module"] local func_name = sdk_data["func"] local func_data = sdk_data["data"] if module_name == "SDKPlatform" then if func_name == "GetTaDistinctId" then local temp_data = JsonToTable(func_data) if temp_data and temp_data["data"] then ClientConfig.ta_distinct_id = temp_data["data"] end else PlatformMgr:getInstance():SDKCallBack(func_name,func_data) end elseif module_name == "ChatSpeaker" then if func_name == "onResultOfSpeech" then func_data = string.sub(func_data, 1, #func_data - 3) GlobalEventSystem:Fire(ChatModel.ON_RESULT_OF_SPEECH, func_data) elseif func_name == "onErrorOfSpeech" then Message.show(func_data) elseif func_name == "onEndOfSpeech" then GlobalEventSystem:Fire(ChatModel.ON_END_OF_SPEECH, func_data) end elseif module_name == "SDKBudly" then elseif module_name == "SDKIFLYTEK" then elseif module_name == "BatteryModule" then -- if MainUIModel ~= nil then -- MainUIModel:getInstance().battery_level = tonumber(func_data) _G.SDKUtil.BATTERY_MODULE_LEVEL = tonumber(func_data) GlobalEventSystem:Fire(EventName.REFRESH_BATTERY_LEVEL) -- end elseif module_name == "OrientationDidChange" then if ClientConfig.iphone_x_model then if GlobalOpenCheatState then Message.show("OrientationDidChange dir = " .. tonumber(func_data)) end ClientConfig.orientation_did_change = tonumber(func_data) if ClientConfig.orientation_did_change == 3 then ClientConfig.iphone_x_offset_left = 55 ClientConfig.iphone_x_offset_right = 0 elseif ClientConfig.orientation_did_change == 4 then ClientConfig.iphone_x_offset_left = 0 ClientConfig.iphone_x_offset_right = 55 end GlobalEventSystem:Fire(EventName.ORIENTATION_DID_CHANGE) end elseif module_name == "PhonePhoto" then if func_name == "ImageBack" then GlobalEventSystem:Fire(EventName.PHONE_PHOTO_LOADBACK,func_data) end elseif module_name == "common" then if func_name == "ReceiveMemoryWarning" then GameError.Instance:SendErrorToPHP("收到手机运行内存过低警告") LuaResManager.Instance:CheckToClearObjPool() resMgr:CollectAllMemory() end elseif module_name == "SDKSystem" then if func_name == "GetIOSIdfa" then if func_data and func_data ~= "" then G_IOS_IDFA_VALUE = func_data end elseif func_name == "OrientationChanged" then -- if ClientConfig.iphone_x_model then -- if GlobalOpenCheatState then -- Message.show("OrientationChanged value = " .. tonumber(func_data)) -- end -- local value = tonumber(func_data) -- if value and value >= 0 then -- local change_stata = false -- if value > 45 and value < 135 then -- if ClientConfig.orientation_did_change ~= 4 then -- ClientConfig.orientation_did_change = 4 -- ClientConfig.iphone_x_offset_left = 0 -- ClientConfig.iphone_x_offset_right = 55 -- change_stata = true -- end -- elseif value > 225 and value < 315 then -- if ClientConfig.orientation_did_change ~= 3 then -- ClientConfig.orientation_did_change = 3 -- ClientConfig.iphone_x_offset_left = 55 -- ClientConfig.iphone_x_offset_right = 0 -- change_stata = true -- end -- end -- if change_stata then -- GlobalEventSystem:Fire(EventName.ORIENTATION_DID_CHANGE) -- end -- end -- end elseif func_name == "GetSimulatorType" then if func_data and func_data ~= "" then local is_simulator = tonumber(func_data) if is_simulator and is_simulator == 1 then ClientConfig.is_simulator = true -- InitSimulatorSetting() -- local phone_info = SDKUtil.CallStringFunc("SDKSystem","GetPhoneInfo",{}) -- local error_str = "is_simulator = " .. tostring(is_simulator) .. ", phone_info = " .. tostring(phone_info) -- GameError.Instance:SendErrorMsg(error_str) end end end end end end function SDKUtil.CallSDKFunc( module_name, func_name, func_data ) local sdk_data = SDKUtil.GetSDKTable(module_name, func_name, func_data) SDKManager:CallSDKFunc(sdk_data) end function SDKUtil.CallIntFunc( module_name, func_name, func_data ) local sdk_data = SDKUtil.GetSDKTable(module_name, func_name, func_data) return SDKManager:CallIntFunc(sdk_data) end function SDKUtil.CallBoolFunc( module_name, func_name, func_data ) local sdk_data = SDKUtil.GetSDKTable(module_name, func_name, func_data) return SDKManager:CallBoolFunc(sdk_data) end function SDKUtil.CallStringFunc( module_name, func_name, func_data ) local sdk_data = SDKUtil.GetSDKTable(module_name, func_name, func_data) return SDKManager:CallStringFunc(sdk_data) end function SDKUtil.GetSDKTable( module_name, func_name, func_data ) func_data = func_data or {} if func_data == "" then func_data = {} end func_data["module"] = module_name func_data["func"] = func_name return table2json(func_data) end --设置手机系统屏幕明亮度 0-255 function SDKUtil.SetBright( value ) SDKUtil.CallSDKFunc("SystemBright", "SetBright", {bright = value}) end --复制到剪切板 function SDKUtil.Clipboard( value ) SDKUtil.CallSDKFunc("SystemData", "Clipboard", {data = value}) end