| | |
| | | import android.location.Location; |
| | | import android.location.LocationManager; |
| | | import android.os.IBinder; |
| | | import android.os.SystemClock; |
| | | import android.provider.Settings; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | |
| | | import com.hdl.photovoltaic.ui.bean.DeviceTimeBean; |
| | | import com.hdl.photovoltaic.ui.bean.Geolocation; |
| | | import com.hdl.photovoltaic.ui.bean.HouseIdBean; |
| | | import com.hdl.photovoltaic.ui.bean.HouseInfoBean; |
| | | import com.hdl.photovoltaic.ui.bean.LinkBean; |
| | | import com.hdl.photovoltaic.ui.bean.MemberBean; |
| | | import com.hdl.photovoltaic.ui.bean.NotRunBean; |
| | |
| | | import com.hdl.photovoltaic.ui.me.AsRegardsActivity; |
| | | import com.hdl.photovoltaic.ui.me.CPersonalDataActivity; |
| | | import com.hdl.photovoltaic.ui.me.SetActivity; |
| | | import com.hdl.photovoltaic.ui.newC.MessageCenterList; |
| | | import com.hdl.photovoltaic.ui.newC.PowerStationsListEdit; |
| | | import com.hdl.photovoltaic.ui.newC.MessageCenterListActivity; |
| | | import com.hdl.photovoltaic.ui.newC.PowerStationsListActivity; |
| | | 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; |
| | |
| | | import com.hdl.sdk.link.gateway.HDLLinkLocalGateway; |
| | | |
| | | import org.greenrobot.eventbus.EventBus; |
| | | import org.json.JSONArray; |
| | | import org.json.JSONObject; |
| | | |
| | | |
| | |
| | | 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; |
| | | } |
| | |
| | | break; |
| | | //创建电站 |
| | | case HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION: { |
| | | //uin创建电站成功后通知 |
| | | // HdlResidenceLogic.getInstance().getResidenceIdList("","","","","","",1,50,null); |
| | | try { |
| | | String dataJsonStr = getKeyValue("data", data); |
| | | if (!TextUtils.isEmpty(dataJsonStr)) { |
| | | Gson gson = new Gson(); |
| | | HouseIdBean houseIdBean = gson.fromJson(dataJsonStr, HouseIdBean.class); |
| | | HdlResidenceLogic.getInstance().switchHouse(houseIdBean, true); |
| | | } |
| | | HdlLogLogic.print("uin创建电站成功后通知---" + dataJsonStr, true); |
| | | } catch (Exception e) { |
| | | HdlLogLogic.print("uin创建电站成功后通知---" + e.getMessage(), true); |
| | | } |
| | | |
| | | //EventBus事件分发 |
| | | HdlCommonLogic.getInstance().postEventBus(HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL, HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION, getKeyValue("data", data)); |
| | | // HdlCommonLogic.getInstance().postEventBusSticky(HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL, HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION, getKeyValue("data", data)); |
| | | if (callback != null) { |
| | | uniSuccessCallback(type, null, callback); |
| | | } |
| | |
| | | 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) { |
| | | JsonObject jsonObject = new JsonObject(); |
| | | jsonObject.addProperty("localAuthor", isLocalAuthor); |
| | | uniSuccessCallback(mode_type, jsonObject, callback); |
| | | } |
| | | } |
| | | break; |
| | | //获取手机wifi列表 |
| | | case HDLUniMP.UNI_EVENT_REPLY_PHONE_WIFI_LIST: { |
| | | if (callback != null) { |
| | |
| | | break; |
| | | //逆变器以太网获取 |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_ETHERNET_GET: { |
| | | if (callback != null) { |
| | | uniSuccessCallback(type, "", callback); |
| | | } |
| | | //uniGetAndSetNetwork(mode_type, data, TopicApi.DELETING_GATEWAY_ETHERNET_GET, callback); |
| | | uniGetAndSetNetwork(mode_type, data, TopicApi.DELETING_GATEWAY_ETHERNET_GET, callback); |
| | | } |
| | | break; |
| | | |
| | |
| | | case HDLUniMP.UNI_EVENT_REPLY_MINE_SELECTED_POWERSTATION: { |
| | | Intent intent = new Intent(); |
| | | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | intent.setClass(HDLApp.getInstance(), PowerStationsListEdit.class); |
| | | intent.setClass(HDLApp.getInstance(), PowerStationsListActivity.class); |
| | | HDLApp.getInstance().startActivity(intent); |
| | | } |
| | | break; |
| | |
| | | String isShowFault = getKeyValue("isShowFault", getKeyValue("data", data)); |
| | | Intent intent = new Intent(); |
| | | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | intent.setClass(HDLApp.getInstance(), MessageCenterList.class); |
| | | intent.setClass(HDLApp.getInstance(), MessageCenterListActivity.class); |
| | | if (!TextUtils.isEmpty(homeId)) { |
| | | intent.putExtra("homeId", homeId); |
| | | } |
| | |
| | | } 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) { |
| | |
| | | //uni获取图片 |
| | | case HDLUniMP.UNI_EVENT_REPLY_OTHER_GET_SELECTED_IMAGE: { |
| | | |
| | | } |
| | | break; |
| | | } |
| | | } else if (HDLUniMP.UNI_EVENT_REPLY_NO_WORK_MODEL.equals(topic)) { |
| | | //无网模式 |
| | | switch (type) { |
| | | |
| | | case HDLUniMP.UNI_EVENT_REPLY_NO_WORK_MODEL_EXIT: { |
| | | //退出无网模式标识 |
| | | UserConfigManage.getInstance().setNoNetworkFlag(false); |
| | | UserConfigManage.getInstance().Save(); |
| | | } |
| | | break; |
| | | case HDLUniMP.UNI_EVENT_REPLY_NO_WORK_MODEL_DEVICE_INFO: { |
| | | try { |
| | | //进入无网模式逆变器详情页,缓存mac和密码 |
| | | String mac = getKeyValue("mac", getKeyValue("data", data)); |
| | | String password = getKeyValue("password", getKeyValue("data", data)); |
| | | UserConfigManage.getInstance().setNoNetworkDeviceMac(mac); |
| | | UserConfigManage.getInstance().setNoNetworkPassword(password); |
| | | UserConfigManage.getInstance().Save(); |
| | | } catch (Exception ignored) { |
| | | } |
| | | } |
| | | break; |
| | | case HDLUniMP.UNI_EVENT_REPLY_NO_WORK_MODEL_CLEAR_DEVICE_INFO: { |
| | | //无网模式逆变器详情页,清除缓存mac和密码 |
| | | UserConfigManage.getInstance().setNoNetworkDeviceMac(""); |
| | | UserConfigManage.getInstance().setNoNetworkPassword(""); |
| | | UserConfigManage.getInstance().Save(); |
| | | } |
| | | break; |
| | | } |
| | |
| | | //解密负载数据(写密钥给网关一定是明文,因为那时网关还没有密钥) |
| | | 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); |