| | |
| | | import android.content.pm.PackageManager; |
| | | import android.location.Location; |
| | | import android.location.LocationManager; |
| | | import android.net.wifi.ScanResult; |
| | | import android.os.IBinder; |
| | | import android.os.SystemClock; |
| | | import android.provider.Settings; |
| | |
| | | import com.hdl.photovoltaic.uni.HDLUniMP; |
| | | import com.hdl.photovoltaic.uni.HDLUniMPSDKManager; |
| | | import com.hdl.photovoltaic.utils.NetworkUtils; |
| | | import com.hdl.photovoltaic.utils.PermissionUtils; |
| | | import com.hdl.photovoltaic.utils.WifiUtils; |
| | | import com.hdl.sdk.link.common.exception.HDLLinkException; |
| | | import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; |
| | |
| | | String type = getKeyValue("type", data);//小类 |
| | | String logTag = getKeyValue("logTag", data);//标记uni指令 |
| | | String mode_type = "大类-" + topic + "---" + "小类-" + type;//用来打印的 |
| | | HdlLogLogic.print(logTag + ":" + "uni---发送---" + mode_type + "\r\n" + data, true); |
| | | HdlLogLogic.print(logTag + ":" + "uni---发送---" + mode_type + "---" + data, true); |
| | | if (HDLUniMP.UNI_EVENT_REPLY_USER_MODEL.equals(topic)) { |
| | | //用户模块 |
| | | switch (type) { |
| | |
| | | jsonObject.addProperty("appKey", AppConfigManage.getAppKey()); |
| | | jsonObject.addProperty("appSecret", AppConfigManage.getAppSecret()); |
| | | uniSuccessCallback(mode_type, jsonObject, callback); |
| | | HdlLogLogic.print("获取用户本地缓存信息---->>>" + jsonObject.toString()); |
| | | HdlLogLogic.print("获取用户本地缓存信息----" + jsonObject.toString()); |
| | | } |
| | | break; |
| | | } |
| | |
| | | WifiUtils wifiUtils = WifiUtils.getInstance(); |
| | | //wifi模块 |
| | | switch (type) { |
| | | //获取位置权限 |
| | | case HDLUniMP.UNI_EVENT_REPLY_AUTHORIZATION_GET: { |
| | | boolean isLocalAuthor = PermissionUtils.checkPermission(HDLApp.getInstance(), Manifest.permission.ACCESS_FINE_LOCATION); |
| | | if (callback != null) { |
| | | uniSuccessCallback(mode_type, isLocalAuthor, callback); |
| | | } |
| | | } |
| | | break; |
| | | //获取手机wifi列表 |
| | | case HDLUniMP.UNI_EVENT_REPLY_PHONE_WIFI_LIST: { |
| | | if (callback != null) { |
| | |
| | | } else if (HDLUniMP.UNI_EVENT_REPLY_OTHER_MODEL.equals(topic)) { |
| | | //其它模块 |
| | | switch (type) { |
| | | |
| | | //获取温度单位 |
| | | case HDLUniMP.UNI_EVENT_REPLY_OTHER_UNIT: { |
| | | uniSuccessCallback(mode_type, UserConfigManage.getInstance().getTemperature_unit(), callback); |
| | |
| | | break; |
| | | //uni通知原生退出登录 |
| | | case HDLUniMP.UNI_EVENT_REPLY_OTHER_LOGOUT: { |
| | | HdlLogLogic.print("uni通知原生退出登录---", true); |
| | | HDLLinkPMUser.getInstance().logout(0); |
| | | } |
| | | break; |
| | |
| | | String json = HdlESLocalJsonLogic.getInstance().readHdlESLocalJson(fileName + ".json", deviceModel); |
| | | if (TextUtils.isEmpty(json)) { |
| | | //本地没有缓存 |
| | | HdlESLocalJsonLogic.getInstance().getHdlESLocalJson(fileName, deviceType, deviceModel, new CloudCallBeak<String>() { |
| | | HdlESLocalJsonLogic.getInstance().getHdlESLocalJson(fileName, deviceType, deviceModel, false, new CloudCallBeak<String>() { |
| | | @Override |
| | | public void onSuccess(String obj) { |
| | | // if (callback != null) { |
| | |
| | | if (callback != null) { |
| | | uniSuccessCallback(type, null, callback); |
| | | } |
| | | List<GatewayBean> list = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId); |
| | | List<GatewayBean> list = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId, null); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | GatewayBean gatewayBean = list.get(i); |
| | | HdlDeviceLogic.getInstance().initializeInverter(gatewayBean.getDevice_mac(), null); |
| | |
| | | //解密负载数据(写密钥给网关一定是明文,因为那时网关还没有密钥) |
| | | TcpClient.getInstance().sendDataToLinkGateway(mac, false, TopicApi, jsonArray, "", new HDLLinkCallBack() { |
| | | @Override |
| | | public void onSuccess(String msg) { |
| | | public void onSuccess(String s) { |
| | | if (callback != null) { |
| | | uniSuccessCallback(type, msg, callback); |
| | | try { |
| | | if (s.startsWith("{")) { |
| | | uniSuccessCallback(type, new Gson().fromJson(s, JsonObject.class), callback); |
| | | } else if (s.startsWith("[")) { |
| | | uniSuccessCallback(type, new Gson().fromJson(s, JsonArray.class), callback); |
| | | } else { |
| | | uniSuccessCallback(type, s, callback); |
| | | } |
| | | } catch (Exception e) { |
| | | uniSuccessCallback(type, s, callback); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | UserConfigManage.getInstance().setBingEmail(cUserInfo.getMemberEmail()); |
| | | UserConfigManage.getInstance().setUserImageUrl(cUserInfo.getMemberHeadIcon()); |
| | | UserConfigManage.getInstance().Save(); |
| | | HdlLogLogic.print("头像路径---->>>" + cUserInfo.getMemberHeadIcon()); |
| | | HdlLogLogic.print("头像路径----" + cUserInfo.getMemberHeadIcon()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | */ |
| | | private void uniGetCurrentHomeLocalAndCloudGatewayList(String type, Object data, DCUniMPJSCallback callback) { |
| | | String homeId = getKeyValue("homeId", getKeyValue("data", data)); |
| | | // UserConfigManage.getInstance().setHomeId(homeId); |
| | | HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(homeId, new CloudCallBeak<List<GatewayBean>>() { |
| | | @Override |
| | | public void onSuccess(List<GatewayBean> list) { |
| | |
| | | uniCallBackBaseBean.setData(obj); |
| | | if (callback != null) { |
| | | callback.invoke(getJSONObject(uniCallBackBaseBean)); |
| | | // callback.invoke(uniCallBackBaseBean); |
| | | HdlLogLogic.print("回复---uni---" + type + "---" + new Gson().toJson(uniCallBackBaseBean), true); |
| | | HdlLogLogic.print("回复---uni---" + type + "---" + getJSONObject(uniCallBackBaseBean).toString(), true); |
| | | } |
| | | } catch (Exception e) { |
| | | HdlLogLogic.print("回复---uni---" + type + "---" + e.getMessage(), true); |