111
hxb
2022-11-24 0a3e07f10937484145f33c7560607b4b2353cb81
AndroidOpenDemo/DeviceAddModule/src/main/java/com/mm/android/deviceaddmodule/openapi/DeviceAddOpenApiManager.java
@@ -3,6 +3,7 @@
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.device_wifi.CurWifiInfo;
import com.mm.android.deviceaddmodule.device_wifi.WifiConfig;
@@ -19,6 +20,7 @@
import org.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
public class DeviceAddOpenApiManager {
    private static int TIME_OUT = 10 * 1000;
@@ -106,6 +108,24 @@
        HashMap<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("token", bindDeviceData.data.token);
        paramsMap.put("deviceId", bindDeviceData.data.deviceId);
        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);
        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("deviceId", bindDeviceData.data.deviceId);
        paramsMap.put("spk","security.ipcam.imou");
        paramsMap.put("code", bindDeviceData.data.code);
        JsonObject json = HttpSend.execute(paramsMap, CONST.METHOD_BINDDEVICE,DMS_TIME_OUT);
        BindDeviceData.Response response = new BindDeviceData.Response();
@@ -241,9 +261,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, String>>() {
        }.getType());
        JsonObject json = HttpSend.execute(map, CONST.CREATE_SUB_ACCOUNT, TIME_OUT);
        return true;
    }
}