wxr
2023-02-21 409c13d0886117d5ee4ff42186d90b19a692b804
AndroidOpenDemo/DeviceAddModule/src/main/java/com/mm/android/deviceaddmodule/openapi/DeviceAddOpenApiManager.java
@@ -1,12 +1,20 @@
package com.mm.android.deviceaddmodule.openapi;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.mm.android.deviceaddmodule.LCDeviceEngine;
import com.mm.android.deviceaddmodule.SeachDeviceService;
import com.mm.android.deviceaddmodule.device_wifi.CurWifiInfo;
import com.mm.android.deviceaddmodule.device_wifi.WifiConfig;
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.BusinessException;
import com.mm.android.deviceaddmodule.mobilecommon.common.LCConfiguration;
import com.mm.android.deviceaddmodule.openapi.data.AddDevicePolicyData;
import com.mm.android.deviceaddmodule.openapi.data.BindDeviceData;
import com.mm.android.deviceaddmodule.openapi.data.DeviceDetailListData;
@@ -19,6 +27,7 @@
import org.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
public class DeviceAddOpenApiManager {
    private static int TIME_OUT = 10 * 1000;
@@ -106,10 +115,34 @@
        HashMap<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("token", bindDeviceData.data.token);
        paramsMap.put("deviceId", bindDeviceData.data.deviceId);
        JsonObject json = HttpSend.execute(paramsMap, CONST.METHOD_BINDDEVICE,DMS_TIME_OUT);
        BindDeviceData.Response response = new BindDeviceData.Response();
        response.parseData(json);
        return response;
    }
    /**
     * 绑定设备
     *
     * @param bindDeviceData
     * @return
     * @throws BusinessException
     */
    public static BindDeviceData.Response hdlUserDeviceBind(BindDeviceData bindDeviceData) throws BusinessException {
        HashMap<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("extDevId", bindDeviceData.data.deviceId);
        paramsMap.put("spk","security.ipcam.imou");
        paramsMap.put("sid","8D00708PAGA01ED");
        paramsMap.put("productBrandldentity",bindDeviceData.data.productBrandldentity);
        paramsMap.put("code", bindDeviceData.data.code);
        JsonObject json = HttpSend.execute(paramsMap, CONST.METHOD_BINDDEVICE,DMS_TIME_OUT);
        BindDeviceData.Response response = new BindDeviceData.Response();
        response.parseData(json);
        Intent intent = new Intent();
        intent.setAction("hdlUserDeviceBind");
        intent.putExtra("data",response.data.toString());
        return response;
    }
@@ -241,9 +274,15 @@
        return  json.get("openid").getAsString();
    }
    public static boolean addPolicy(AddDevicePolicyData req)throws BusinessException{
        String jsonParam = new Gson().toJson(req);
        HttpSend.execute(jsonParam, CONST.ADD_POLICY,TIME_OUT);
        return  true;
    public static boolean addPolicy(AddDevicePolicyData req)throws BusinessException {
//        String jsonParam = new Gson().toJson(req);
//        HttpSend.execute(jsonParam, CONST.ADD_POLICY,TIME_OUT);
//        return  true;
//        final Map<String, Object> map = new Gson().fromJson(new Gson().toJson(req), new TypeToken<Map<String, Object>>() {
//        }.getType());
//
//        JsonObject json = HttpSend.execute(map, CONST.CREATE_SUB_ACCOUNT, TIME_OUT);
        return true;
    }
}