龙岗云视频 v2.7版本的 MD5 值为:9298cfa7a85a45936abaf845b6f6bd5c
以下内容为反编译后的 EzvizAPI.java 源代码,内容仅作参考
package com.videogo.openapi;
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Handler;
import android.os.Process;
import android.os.SystemClock;
import android.text.TextUtils;
import com.ezviz.opensdk.data.DBTable;
import com.ezviz.opensdk.data.EZDatabaseHelper;
import com.ezviz.opensdk.data.EZDatabaseManager;
import com.ezviz.opensdk.data.FileCacheDeviceInfoManager;
import com.ezviz.stream.EZStreamClientManager;
import com.ezviz.stream.JsonUtils;
import com.google.gson.Gson;
import com.hikvision.dxopensdk.constants.DX_HttpConstants;
import com.hikvision.dxopensdk.model.DX_AccountInfo;
import com.hikvision.wifi.UdpClient.UdpClient;
import com.hikvision.wifi.configuration.DeviceDiscoveryListener;
import com.hikvision.wifi.configuration.OneStepWifiConfigurationManager;
import com.umeng.socialize.common.SocializeConstants;
import com.umeng.socialize.net.utils.SocializeProtocolConstants;
import com.videogo.alarm.AlarmLogInfoManager;
import com.videogo.camera.CameraInfoEx;
import com.videogo.camera.CameraManager;
import com.videogo.constant.Config;
import com.videogo.constant.IntentConsts;
import com.videogo.device.DeviceInfoEx;
import com.videogo.device.DeviceManager;
import com.videogo.errorlayer.ErrorInfo;
import com.videogo.errorlayer.ErrorLayer;
import com.videogo.exception.BaseException;
import com.videogo.exception.BaseSdkRuntimeException;
import com.videogo.exception.EZOpenSDKErrorInfo;
import com.videogo.exception.EZOpenSDKErrorMamager;
import com.videogo.exception.ErrorCode;
import com.videogo.main.AppManager;
import com.videogo.main.EZPTZController;
import com.videogo.main.EzvizWebViewActivity;
import com.videogo.main.StreamServerData;
import com.videogo.openapi.EZConstants;
import com.videogo.openapi.EZOpenSDKListener;
import com.videogo.openapi.annotation.HttpParam;
import com.videogo.openapi.annotation.Serializable;
import com.videogo.openapi.bean.BaseInfo;
import com.videogo.openapi.bean.EZAccessToken;
import com.videogo.openapi.bean.EZAccessTokenInternal;
import com.videogo.openapi.bean.EZAddDeviceBySerialInfo;
import com.videogo.openapi.bean.EZAlarmInfo;
import com.videogo.openapi.bean.EZAreaInfo;
import com.videogo.openapi.bean.EZCameraInfo;
import com.videogo.openapi.bean.EZCloudRecordFile;
import com.videogo.openapi.bean.EZDeleteDeviceBySerialReq;
import com.videogo.openapi.bean.EZDetectorInfo;
import com.videogo.openapi.bean.EZDeviceInfo;
import com.videogo.openapi.bean.EZDeviceRecordFile;
import com.videogo.openapi.bean.EZDeviceUpgradeStatus;
import com.videogo.openapi.bean.EZDeviceVersion;
import com.videogo.openapi.bean.EZHiddnsDeviceInfo;
import com.videogo.openapi.bean.EZLeaveMessage;
import com.videogo.openapi.bean.EZOpenToken;
import com.videogo.openapi.bean.EZPlayURLParams;
import com.videogo.openapi.bean.EZProbeDeviceInfo;
import com.videogo.openapi.bean.EZProbeDeviceInfoResult;
import com.videogo.openapi.bean.EZPushAlarmMessage;
import com.videogo.openapi.bean.EZPushBaseMessage;
import com.videogo.openapi.bean.EZPushTransferMessage;
import com.videogo.openapi.bean.EZRecordFile;
import com.videogo.openapi.bean.EZSDKConfiguration;
import com.videogo.openapi.bean.EZServerInfo;
import com.videogo.openapi.bean.EZStorageStatus;
import com.videogo.openapi.bean.EZStreamLimitInfo;
import com.videogo.openapi.bean.EZTransferMessageInfo;
import com.videogo.openapi.bean.EZUserInfo;
import com.videogo.openapi.bean.EZVideoQualityInfo;
import com.videogo.openapi.bean.req.BaseAlarmInfo;
import com.videogo.openapi.bean.req.BaseCameraInfo;
import com.videogo.openapi.bean.req.BaseDeviceInfo;
import com.videogo.openapi.bean.req.BatchGetTokens;
import com.videogo.openapi.bean.req.EZPrivateTicketRequest;
import com.videogo.openapi.bean.req.GetAlarmListReq;
import com.videogo.openapi.bean.req.GetSmsCodeInfo;
import com.videogo.openapi.bean.req.GetStreamServer;
import com.videogo.openapi.bean.req.RegistInfo;
import com.videogo.openapi.bean.req.ResetPassword;
import com.videogo.openapi.bean.req.VerifySmsCodeInfo;
import com.videogo.openapi.bean.resp.CloudFile;
import com.videogo.openapi.bean.resp.ConfigCity;
import com.videogo.openapi.bean.resp.EZDevicePlayInfo;
import com.videogo.openapi.model.ApiResponse;
import com.videogo.openapi.model.BaseResponse;
import com.videogo.openapi.model.EZAlarmDeleteMultipleAlarmsInfo;
import com.videogo.openapi.model.EZAlarmDeleteMultipleAlarmsReq;
import com.videogo.openapi.model.EZAlarmDeleteMultipleAlarmsResp;
import com.videogo.openapi.model.EZDeviceAddDeviceInfo;
import com.videogo.openapi.model.EZDeviceAddDeviceReq;
import com.videogo.openapi.model.EZDeviceAddDeviceResp;
import com.videogo.openapi.model.req.BatchGetTokensReq;
import com.videogo.openapi.model.req.CheckFeatureCodeReq;
import com.videogo.openapi.model.req.DeleteDeviceReq;
import com.videogo.openapi.model.req.GetCameraDetailReq;
import com.videogo.openapi.model.req.GetCameraInfoReq;
import com.videogo.openapi.model.req.GetCameraStatusReq;
import com.videogo.openapi.model.req.GetCloudInfoReq;
import com.videogo.openapi.model.req.GetSecureSmcCodeReq;
import com.videogo.openapi.model.req.GetServersInfoReq;
import com.videogo.openapi.model.req.GetSmsCodeReq;
import com.videogo.openapi.model.req.GetSmsCodeResetReq;
import com.videogo.openapi.model.req.GetUserNameReq;
import com.videogo.openapi.model.req.RegistReq;
import com.videogo.openapi.model.req.SecureValidateReq;
import com.videogo.openapi.model.req.VerifySmsCodeReq;
import com.videogo.openapi.model.req.WebLoginReq;
import com.videogo.openapi.model.resp.BatchGetTokensResp;
import com.videogo.openapi.model.resp.CheckFeatureCodeResp;
import com.videogo.openapi.model.resp.DeleteDeviceResp;
import com.videogo.openapi.model.resp.GetCameraInfoListResp;
import com.videogo.openapi.model.resp.GetCameraInfoResp;
import com.videogo.openapi.model.resp.GetCameraStatusResp;
import com.videogo.openapi.model.resp.GetCloudInfoResp;
import com.videogo.openapi.model.resp.GetServersInfoResp;
import com.videogo.openapi.model.resp.GetSmsCodeResetResp;
import com.videogo.openapi.model.resp.GetSmsCodeResp;
import com.videogo.openapi.model.resp.GetUserNameResp;
import com.videogo.openapi.model.resp.LogoutResp;
import com.videogo.openapi.model.resp.RegistResp;
import com.videogo.openapi.model.resp.ResetPasswordResp;
import com.videogo.openapi.model.resp.SetAlarmReadResp;
import com.videogo.openapi.model.resp.VerifySmsCodeResp;
import com.videogo.remoteplayback.CloudFileEx;
import com.videogo.restful.NameValuePair;
import com.videogo.stream.EZCloudStreamDownload;
import com.videogo.stream.EZStreamDownload;
import com.videogo.stream.EZStreamParamHelp;
import com.videogo.util.CertUpdateHelper;
import com.videogo.util.ConnectionDetector;
import com.videogo.util.DateTimeUtil;
import com.videogo.util.EZOpenSDKConvertUtil;
import com.videogo.util.HttpUtils;
import com.videogo.util.LocalInfo;
import com.videogo.util.LocalValidate;
import com.videogo.util.LogUtil;
import com.videogo.util.MD5Util;
import com.videogo.util.ReflectionUtils;
import com.videogo.util.RestfulUtils;
import com.videogo.util.Utils;
import com.videogo.wificonfig.APWifiConfig;
import com.videogo.wificonfig.ConfigWifiSdkManager;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import java.util.concurrent.locks.ReentrantLock;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import org.greenrobot.greendao.generator.Schema;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@SuppressLint({"MissingPermission"})
public class EzvizAPI {
private static final String API_CODE = "code";
private static final String API_DATA = "data";
private static final String API_MSG = "description";
private static final String API_RESULT = "result";
private static final int API_SUSCCEED = 200;
private static final int MAX_MESSAGE_BATCH_PROC_NUM = 10;
public static final String STR_NATIVE_PARAM_ERROR = "参数错误!";
public static final String TAG = "EzvizAPI";
public static final int USER_TYPE_ENTERPRISE = 1;
public static final int USER_TYPE_HOME = 0;
public static final int USER_TYPE_SUB = 2;
private static ReentrantLock mlock;
private AlarmLogInfoManager mAlarmLogInfoManager;
private String mAppKey;
private AppManager mAppManager;
private LocalInfo mLocalInfo;
private LocalValidate mLocalValidate;
private String mNetType;
private EZNetworkChangeListener mNetworkChangeListener;
private String mPtzControllerCameraId;
private RestfulUtils mRestfulUtils;
public static EZConstants.EZPlatformType platformType = EZConstants.EZPlatformType.EZPlatformTypeNULL;
private static EzvizAPI mEzvizAPI = null;
public static Application mApplication = null;
public static boolean isNetConnect = false;
private static String exterVer = "";
private static boolean isInit = false;
private List<String> mTokenList = null;
private long mBatchTokensTime = 0;
private String mWebUrl = "";
private String mAppPushSecret = "";
private String mThridToken = "";
private int mAreaId = -1;
private OneStepWifiConfigurationManager mOneStepWifiConfigurationManager = null;
private EZPTZController mEZPTZController = null;
private int stub_storage_call_times = 0;
private boolean streamStub = false;
private int mStartUpgrade = 0;
private int mUpgradeProgress = 0;
private Object mWaitObject = new Object();
private int refreshTokenCount = 0;
class C1EZGetCameraInfoBySerialReq {
@Serializable(name = "method")
public String method = "sdk/manage/getSingleDeviceInfo";
@Serializable(name = "params")
public Params params = new Params();
@Serializable
class Params {
@Serializable(name = "accessToken")
public String accessToken;
@Serializable(name = "deviceSerial")
public String deviceSerial;
Params() {
}
}
C1EZGetCameraInfoBySerialReq() {
}
}
public class EZNetworkChangeListener extends BroadcastReceiver {
EZNetworkChangeListener() {
}
@Override
public void onReceive(Context context, Intent intent) {
String str;
String str2;
if ("android.net.conn.CONNECTIVITY_CHANGE".equals(intent.getAction())) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
LogUtil.i(EzvizAPI.TAG, "CONNECTIVITY_ACTION");
DeviceManager.getInstance().clearPreConnect();
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
if (activeNetworkInfo == null) {
EzvizAPI.isNetConnect = false;
return;
}
if (activeNetworkInfo.isConnected()) {
EzvizAPI.isNetConnect = true;
DeviceManager.getInstance().startPreConnect();
if (activeNetworkInfo.getType() == 1) {
str = EzvizAPI.TAG;
str2 = "当前WiFi连接可用 ";
} else {
if (activeNetworkInfo.getType() != 0) {
return;
}
str = EzvizAPI.TAG;
str2 = "当前移动网络连接可用 ";
}
} else {
EzvizAPI.isNetConnect = false;
str = EzvizAPI.TAG;
str2 = "当前没有网络连接,请确保你已经打开网络 ";
}
LogUtil.d(str, str2);
}
}
}
public EzvizAPI(Application application, String str) {
this.mAppManager = null;
this.mAlarmLogInfoManager = null;
this.mLocalInfo = null;
this.mAppKey = "";
this.mRestfulUtils = null;
this.mLocalValidate = null;
mApplication = application;
this.mAppKey = str;
EZDatabaseManager.initializeInstance(new EZDatabaseHelper(application.getApplicationContext()));
HttpUtils.init(application);
this.mLocalInfo = LocalInfo.getInstance();
this.mNetType = Utils.getNetTypeName(application);
if (this.mNetType == null) {
this.mNetType = "UNKNOWN";
}
RestfulUtils.init(application);
this.mRestfulUtils = RestfulUtils.getInstance();
this.mAppManager = AppManager.getInstance();
this.mAlarmLogInfoManager = AlarmLogInfoManager.getInstance();
this.mLocalValidate = new LocalValidate();
mlock = new ReentrantLock();
registerNetReceiver();
}
private String calendar2String(Calendar calendar) {
return new SimpleDateFormat(DateTimeUtil.TIME_FORMAT).format(calendar.getTime());
}
private BaseSdkRuntimeException changeToRuntimeException(BaseException baseException) {
baseException.printStackTrace();
BaseSdkRuntimeException baseSdkRuntimeException = new BaseSdkRuntimeException();
baseSdkRuntimeException.errCode = baseException.getErrorCode();
baseSdkRuntimeException.errMsg = baseException.getErrorInfo().toString();
return baseSdkRuntimeException;
}
public void checkTokenExpire() {
long expire = LocalInfo.getInstance().getEZAccesstoken().getExpire() - System.currentTimeMillis();
LogUtil.d(TAG, "Expire = " + LocalInfo.getInstance().getEZAccesstoken().getExpire());
LogUtil.d(TAG, "currentTimeMillis = " + System.currentTimeMillis());
LogUtil.d(TAG, "currentTimeMillis - Expire = ".concat(String.valueOf(expire)));
if (TextUtils.isEmpty(LocalInfo.getInstance().getEZAccesstoken().getAccessToken()) || TextUtils.isEmpty(LocalInfo.getInstance().getEZAccesstoken().getRefresh_token())) {
return;
}
if (expire > 0 && expire <= 86400000) {
new Thread(new Runnable() {
@Override
public void run() {
try {
EzvizAPI.this.refreshToken();
} catch (BaseException e) {
e.printStackTrace();
}
}
}).start();
} else if (expire <= 0) {
try {
refreshToken();
} catch (BaseException e) {
e.printStackTrace();
}
}
}
private void clearCacheData() {
LogUtil.i(TAG, "Enter clearCacheData: ");
clearVtduTokens();
DeviceManager.getInstance().clearPreConnect();
DeviceManager.getInstance().clearDevice();
CameraManager.getInstance().clearCamera();
this.mAlarmLogInfoManager.clearAlarmListFromNotifier();
this.mAlarmLogInfoManager.clearDeviceOfflineAlarmList();
this.mAlarmLogInfoManager.clearAllOutsideAlarmList();
this.mEZPTZController = null;
this.mAppManager.clearAllStreamServer();
EZStreamClientManager.create(mApplication).clearTokens();
FileCacheDeviceInfoManager.clearDevice();
FileCacheDeviceInfoManager.clearCamera();
}
private String converTime(Calendar calendar) {
return new SimpleDateFormat("yyyyMMdd,HHmmss.").format(calendar.getTime()).replace(',', 'T').replace('.', 'Z');
}
private EZPlayer createPlayer(String str, int i, boolean z) {
LogUtil.d(TAG, "Enter createPlayer, ");
if (TextUtils.isEmpty(str)) {
return null;
}
LogUtil.d(TAG, "Enter createPlayer, deviceSerialOrUrl = " + str + " cameraNo = " + i + " isUrl = " + z);
return z ? Utils.isEZOpenProtocol(str) ? new EZPlayer(new EZStreamParamHelp(Utils.getEZPlayURLParams(str))) : new EZPlayer(str) : new EZPlayer(new EZStreamParamHelp(str, i));
}
private CameraInfoEx getCameraInfoExFromEZPlayInfo(EZDevicePlayInfo eZDevicePlayInfo, int i) {
CameraInfoEx cameraInfoEx = new CameraInfoEx();
cameraInfoEx.setDeviceSN(eZDevicePlayInfo.getDeviceSerial());
cameraInfoEx.setChannelNo(i);
return cameraInfoEx;
}
private String getCommaSeprateStrFromList(List<String> list) {
if (list == null || list.size() <= 0) {
return null;
}
if (list != null) {
LogUtil.i(TAG, " msgIdList size:" + list.size());
if (list.size() == 0) {
return null;
}
}
StringBuilder sb = new StringBuilder();
if (list.size() == 1) {
sb.append(list.get(0));
} else {
sb.append(list.get(0));
for (int i = 1; i < list.size(); i++) {
sb.append(",");
sb.append(list.get(i));
}
}
return sb.toString();
}
private EZSDKConfiguration getEZSDKConfiguration() {
EZSDKConfiguration eZSDKConfiguration = null;
int i = 0;
BaseException e = null;
while (true) {
if (i > 3) {
break;
}
try {
eZSDKConfiguration = getInstance().getConfiguration();
break;
} catch (BaseException e2) {
e = e2;
LogUtil.printErrStackTrace(TAG, e.fillInStackTrace());
i++;
SystemClock.sleep(i * 5);
}
}
if (TextUtils.isEmpty(LocalInfo.getInstance().getPushAddr()) && eZSDKConfiguration == null && e != null) {
throw e;
}
return eZSDKConfiguration;
}
public static String getExterVer() {
return exterVer;
}
public static EzvizAPI getInstance() {
return mEzvizAPI;
}
private EZStreamLimitInfo getStreamLimitInfo() {
int i;
int i2;
int i3;
LogUtil.i(TAG, "Enter getStreamLimitInfo: ");
if (!Config.ENABLE_STUB || !this.streamStub) {
Object post = this.mRestfulUtils.post(new BaseInfo() {
}, "/api/stream/getSwitchInfo", new ApiResponse() {
@Override
public Object parse(String str) {
JSONObject optJSONObject;
if (!parseCode(str) || (optJSONObject = new JSONObject(str).getJSONObject("result").optJSONObject("data")) == null) {
return null;
}
EZStreamLimitInfo eZStreamLimitInfo = new EZStreamLimitInfo();
EZStreamLimitInfo.StreamLimitInfoEntity streamLimitInfoEntity = new EZStreamLimitInfo.StreamLimitInfoEntity();
ReflectionUtils.convJSONToObject(optJSONObject, eZStreamLimitInfo);
JSONObject jSONObject = optJSONObject.getJSONObject("streamLimitInfo");
if (jSONObject != null) {
ReflectionUtils.convJSONToObject(jSONObject, streamLimitInfoEntity);
eZStreamLimitInfo.setStreamLimitInfo(streamLimitInfoEntity);
}
return eZStreamLimitInfo;
}
});
if (post == null) {
return null;
}
EZStreamLimitInfo eZStreamLimitInfo = (EZStreamLimitInfo) post;
LogUtil.d(TAG, "getStreamLimitInfo: " + eZStreamLimitInfo);
return eZStreamLimitInfo;
}
LogUtil.i(TAG, "getStreamLimitInfo: Enable stub !!!");
HashMap hashMap = new HashMap();
Utils.parseTestConfigFile("/sdcard/videogo_test_cfg", hashMap);
String str = (String) hashMap.get("streamType");
String str2 = (String) hashMap.get("limitTime");
String str3 = (String) hashMap.get("streamTimeLimitSwitch");
try {
i = Integer.parseInt(str);
try {
i2 = Integer.parseInt(str2);
try {
i3 = Integer.parseInt(str3);
} catch (NumberFormatException e) {
e = e;
LogUtil.printErrStackTrace(TAG, e.fillInStackTrace());
i3 = 0;
EZStreamLimitInfo eZStreamLimitInfo2 = new EZStreamLimitInfo();
EZStreamLimitInfo.StreamLimitInfoEntity streamLimitInfoEntity = new EZStreamLimitInfo.StreamLimitInfoEntity();
eZStreamLimitInfo2.setStreamType(i);
streamLimitInfoEntity.setLimitTime(i2);
streamLimitInfoEntity.setStreamTimeLimitSwitch(i3);
eZStreamLimitInfo2.setStreamLimitInfo(streamLimitInfoEntity);
LogUtil.i(TAG, "getStreamLimitInfo: ".concat(String.valueOf(eZStreamLimitInfo2)));
return eZStreamLimitInfo2;
}
} catch (NumberFormatException e2) {
e = e2;
i2 = 0;
LogUtil.printErrStackTrace(TAG, e.fillInStackTrace());
i3 = 0;
EZStreamLimitInfo eZStreamLimitInfo22 = new EZStreamLimitInfo();
EZStreamLimitInfo.StreamLimitInfoEntity streamLimitInfoEntity2 = new EZStreamLimitInfo.StreamLimitInfoEntity();
eZStreamLimitInfo22.setStreamType(i);
streamLimitInfoEntity2.setLimitTime(i2);
streamLimitInfoEntity2.setStreamTimeLimitSwitch(i3);
eZStreamLimitInfo22.setStreamLimitInfo(streamLimitInfoEntity2);
LogUtil.i(TAG, "getStreamLimitInfo: ".concat(String.valueOf(eZStreamLimitInfo22)));
return eZStreamLimitInfo22;
}
} catch (NumberFormatException e3) {
e = e3;
i = 0;
}
EZStreamLimitInfo eZStreamLimitInfo222 = new EZStreamLimitInfo();
EZStreamLimitInfo.StreamLimitInfoEntity streamLimitInfoEntity22 = new EZStreamLimitInfo.StreamLimitInfoEntity();
eZStreamLimitInfo222.setStreamType(i);
streamLimitInfoEntity22.setLimitTime(i2);
streamLimitInfoEntity22.setStreamTimeLimitSwitch(i3);
eZStreamLimitInfo222.setStreamLimitInfo(streamLimitInfoEntity22);
LogUtil.i(TAG, "getStreamLimitInfo: ".concat(String.valueOf(eZStreamLimitInfo222)));
return eZStreamLimitInfo222;
}
public static synchronized void init(Application application, String str) {
synchronized (EzvizAPI.class) {
CertUpdateHelper.getInstance().checkCertUpdate();
EzvizAPI ezvizAPI = mEzvizAPI;
if (ezvizAPI == null) {
mEzvizAPI = new EzvizAPI(application, str);
FileCacheDeviceInfoManager.getDeviceCacheDetailInfo();
} else {
if (!str.equalsIgnoreCase(ezvizAPI.mAppKey)) {
getInstance().setAccessToken("");
}
mEzvizAPI.setAppKey(str);
}
}
}
public static synchronized void init(Application application, String str, String str2) {
synchronized (EzvizAPI.class) {
EzvizAPI ezvizAPI = mEzvizAPI;
if (ezvizAPI != null) {
ezvizAPI.setAppKey(str);
return;
}
setLoadLibraryAbsPath(str2);
mEzvizAPI = new EzvizAPI(application, str);
FileCacheDeviceInfoManager.getDeviceCacheDetailInfo();
}
}
private void initParams() {
new Thread(new Runnable() {
@Override
public void run() {
EzvizAPI.this.checkTokenExpire();
new Thread(new Runnable() {
@Override
public void run() {
try {
if (EZStreamClientManager.create(EzvizAPI.mApplication.getApplicationContext()).getLeftTokenCount() == 0) {
LogUtil.d(EzvizAPI.TAG, "no left token, need to set tokens");
List<String> streamTokenList = EzvizAPI.getInstance().getStreamTokenList();
if (streamTokenList == null || streamTokenList.size() <= 0) {
return;
}
EZStreamClientManager.create(EzvizAPI.mApplication.getApplicationContext()).setTokens((String[]) streamTokenList.toArray(new String[streamTokenList.size()]));
}
} catch (BaseException e) {
LogUtil.printErrStackTrace(EzvizAPI.TAG, e.fillInStackTrace());
}
}
}).start();
new Thread(new Runnable() {
@Override
public void run() {
EZOpenSDKErrorMamager.getMamager().getEZOpenSDKErrorInfoList(EZDatabaseManager.getInstance().getErrorTableVersion());
}
}).start();
try {
AppManager.getInstance().getServerInfo();
} catch (BaseException e) {
LogUtil.printErrStackTrace(EzvizAPI.TAG, e.fillInStackTrace());
}
}
}).start();
}
private EZPushAlarmMessage parsePushAlarmMessage(String str) {
EZPushAlarmMessage eZPushAlarmMessage;
Throwable fillInStackTrace;
int parseInt;
Calendar calendar;
String str2;
int parseInt2;
String str3;
String str4;
String[] split = str.split(",", -1);
try {
parseInt = Integer.parseInt(split[0]);
calendar = Calendar.getInstance();
calendar.setTime(new SimpleDateFormat(DateTimeUtil.TIME_FORMAT).parse(split[1]));
str2 = split[2];
Integer.parseInt(split[3]);
parseInt2 = Integer.parseInt(split[4]);
str3 = split[5];
str4 = split[6];
eZPushAlarmMessage = new EZPushAlarmMessage();
} catch (NumberFormatException e) {
e = e;
eZPushAlarmMessage = null;
} catch (ParseException e2) {
e = e2;
eZPushAlarmMessage = null;
}
try {
eZPushAlarmMessage.setMessageType(parseInt);
eZPushAlarmMessage.setMessageTime(calendar);
eZPushAlarmMessage.setDeviceSerial(str2);
eZPushAlarmMessage.setAlarmType(parseInt2);
eZPushAlarmMessage.setPicUrl(str3);
eZPushAlarmMessage.setVideoUrl(str4);
} catch (NumberFormatException e3) {
e = e3;
fillInStackTrace = e.fillInStackTrace();
LogUtil.printErrStackTrace(TAG, fillInStackTrace);
return eZPushAlarmMessage;
} catch (ParseException e4) {
e = e4;
fillInStackTrace = e.fillInStackTrace();
LogUtil.printErrStackTrace(TAG, fillInStackTrace);
return eZPushAlarmMessage;
}
return eZPushAlarmMessage;
}
private EZPushTransferMessage parsePushTransferMessage(String str) {
EZPushTransferMessage eZPushTransferMessage;
String[] split = str.split(",", -1);
try {
int parseInt = Integer.parseInt(split[0]);
String str2 = split[1];
int parseInt2 = Integer.parseInt(split[2]);
eZPushTransferMessage = new EZPushTransferMessage();
try {
eZPushTransferMessage.setMessageType(parseInt);
eZPushTransferMessage.setDeviceSerial(str2);
eZPushTransferMessage.setSubType(parseInt2);
} catch (NumberFormatException e) {
e = e;
LogUtil.printErrStackTrace(TAG, e.fillInStackTrace());
return eZPushTransferMessage;
}
} catch (NumberFormatException e2) {
e = e2;
eZPushTransferMessage = null;
}
return eZPushTransferMessage;
}
public static boolean parserCode(String str) {
JSONObject jSONObject = new JSONObject(str).getJSONObject("result");
int optInt = jSONObject.optInt("code", ErrorCode.ERROR_INNER_WEBRESPONSE_JSONERROR);
String optString = jSONObject.optString("description", "Resp Error:".concat(String.valueOf(optInt)));
if (optInt == 200) {
return true;
}
if (optInt == 400030) {
ErrorInfo errorLayer = ErrorLayer.getErrorLayer(2, ErrorCode.ERROR_INNER_WEBRESPONSE_JSONERROR);
throw new BaseException(BaseResponse.NETWORK_EXCEPTION_ERROR_MSG, errorLayer.errorCode, errorLayer);
}
ErrorInfo errorLayer2 = ErrorLayer.getErrorLayer(1, optInt);
if (errorLayer2.description.length() == 0) {
errorLayer2.description = optString;
}
throw new BaseException(optString, errorLayer2.errorCode, errorLayer2);
}
public static boolean parserTransferApiCode(String str) {
String str2;
int i;
try {
JSONObject jSONObject = new JSONObject(str).getJSONObject("result");
i = jSONObject.optInt("code", ErrorCode.ERROR_INNER_WEBRESPONSE_JSONERROR);
str2 = jSONObject.optString("description", "Resp Error:".concat(String.valueOf(i)));
} catch (JSONException e) {
LogUtil.printErrStackTrace(TAG, e.fillInStackTrace());
str2 = "";
i = ErrorCode.ERROR_INNER_WEBRESPONSE_JSONERROR;
}
if (i == 200) {
return true;
}
if (i == 400030) {
ErrorInfo errorLayer = ErrorLayer.getErrorLayer(2, ErrorCode.ERROR_INNER_WEBRESPONSE_JSONERROR);
throw new BaseException(BaseResponse.NETWORK_EXCEPTION_ERROR_MSG, errorLayer.errorCode, errorLayer);
}
ErrorInfo errorLayer2 = ErrorLayer.getErrorLayer(1, i);
if (errorLayer2.description.length() == 0) {
errorLayer2.description = str2;
}
throw new BaseException(str2, errorLayer2.errorCode, errorLayer2);
}
private void registerNetReceiver() {
if (this.mNetworkChangeListener == null) {
this.mNetworkChangeListener = new EZNetworkChangeListener();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.net.wifi.WIFI_STATE_CHANGED");
intentFilter.addAction("android.net.wifi.STATE_CHANGE");
intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
mApplication.registerReceiver(this.mNetworkChangeListener, intentFilter);
}
}
public static void setExterVer(String str) {
if (TextUtils.isEmpty(str)) {
LogUtil.d(TAG, "exterVer is null");
} else {
LogUtil.d(TAG, "exterVer: " + exterVer);
}
exterVer = str;
}
private static void setLoadLibraryAbsPath(String str) {
UdpClient.setLoadLibraryAbsPath(str);
}
public EZAccessTokenInternal OAuthCode(final String str, final String str2, final String str3) {
LogUtil.i(TAG, "Enter OAuthCode");
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "authCode")
private String oauthCode;
@HttpParam(name = "scope")
private String scope;
@HttpParam(name = "state")
private String state;
@HttpParam(name = "grant_type")
private String grant_type = "auth_code";
@HttpParam(name = "client_id")
private String client_id = EzvizAPI.getInstance().getAppKey();
@HttpParam(name = "bundleId")
private String bundleId = LocalInfo.getInstance().getPackageName();
@HttpParam(name = "redirect_uri")
private String redirect_uri = Schema.DEFAULT_NAME;
{
this.oauthCode = str;
this.scope = str2;
this.state = str3;
}
}, LocalInfo.getInstance().getOAuthServAddr() + "/oauth/code", new ApiResponse() {
@Override
public Object parse(String str4) {
if (!parseCodeHttp(str4)) {
return null;
}
JSONObject optJSONObject = new JSONObject(str4).optJSONObject("data");
LocalInfo.getInstance().getEZAccesstoken().setExpire(Long.parseLong(optJSONObject.optString(SocializeProtocolConstants.PROTOCOL_KEY_EXPIRE_IN)));
LocalInfo.getInstance().getEZAccesstoken().setAccessToken(optJSONObject.optString("access_token"));
LocalInfo.getInstance().getEZAccesstoken().setOpen_id(optJSONObject.optString("openId"));
LocalInfo.getInstance().getEZAccesstoken().setRefresh_token(optJSONObject.optString("refresh_token"));
LocalInfo.getInstance().getEZAccesstoken().setState(optJSONObject.optString("state"));
LocalInfo.getInstance().getEZAccesstoken().setScope(optJSONObject.optString("scope"));
LocalInfo.getInstance().saveEZAccesstoken();
return LocalInfo.getInstance().getEZAccesstoken();
}
}, true);
if (post != null) {
return (EZAccessTokenInternal) post;
}
return null;
}
public boolean addDevice(String str) {
LogUtil.d(TAG, "Enter addDevice");
EZDeviceAddDeviceInfo eZDeviceAddDeviceInfo = new EZDeviceAddDeviceInfo();
if (TextUtils.isEmpty(str)) {
return false;
}
LogUtil.d(TAG, "Enter addDevice,deviceSerial= ".concat(String.valueOf(str)));
eZDeviceAddDeviceInfo.setDeviceSN(str);
this.mRestfulUtils.postData(new EZDeviceAddDeviceReq().buidParams(eZDeviceAddDeviceInfo), EZDeviceAddDeviceReq.URL, new EZDeviceAddDeviceResp());
return true;
}
public boolean addDeviceBySerial(String str, String str2) {
EZAddDeviceBySerialInfo eZAddDeviceBySerialInfo = new EZAddDeviceBySerialInfo();
EZAddDeviceBySerialInfo.Params params = eZAddDeviceBySerialInfo.params;
params.deviceSerial = str;
params.validateCode = str2;
params.accessToken = LocalInfo.getInstance().getEZAccesstoken().getAccessToken();
try {
return parserCode(transferAPI(ReflectionUtils.convObjectToJSON(eZAddDeviceBySerialInfo).toString()));
} catch (JSONException e) {
LogUtil.printErrStackTrace(TAG, e.fillInStackTrace());
return false;
}
}
public boolean addDeviceBySerialNonTransfer(final String str, final String str2) {
LogUtil.i(TAG, "Enter addDeviceBySerialNonTransfer: ");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
if (!TextUtils.isEmpty(str2)) {
return ((Boolean) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceSerial")
private String mDeviceSerial;
@HttpParam(name = DX_HttpConstants.DX_REQ_KEY_VALIDATE_CODE)
private String mVerifyCode;
{
this.mDeviceSerial = str;
this.mVerifyCode = str2;
}
}, "/api/device/addDevice", new BaseResponse() {
@Override
public Object parse(String str3) {
return Boolean.valueOf(parseCode(str3));
}
})).booleanValue();
}
LogUtil.i(TAG, "addDeviceBySerialNonTransfer, invalid parameters deviceCode");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400001));
}
public boolean addSquareDemoViewedCount(final String str) {
Boolean bool = (Boolean) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "squareId")
private String squareId;
{
this.squareId = str;
}
}, "/api/squareDemo/addViewedCount", new ApiResponse() {
@Override
public Object parse(String str2) {
return Boolean.valueOf(parseCode(str2));
}
});
if (bool != null) {
return bool.booleanValue();
}
return false;
}
public String capturePicture(final String str, final int i) {
LogUtil.i(TAG, "Enter capturePicture");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
if (i >= 0) {
return (String) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = DX_HttpConstants.DX_REQ_KEY_CHANNEL_NO)
private int channelNumber;
@HttpParam(name = "deviceSerial")
private String devSerial;
{
this.devSerial = str;
this.channelNumber = i;
}
}, "/api/device/capturePicture", new ApiResponse() {
@Override
public String parse(String str2) {
JSONObject jSONObject;
boolean parseCode = parseCode(str2);
if (parseCode && parseCode && (jSONObject = new JSONObject(str2).getJSONObject("result")) != null) {
return jSONObject.optString("data");
}
return null;
}
});
}
LogUtil.i(TAG, "capturePicture, invalid parameters channelNo");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
public boolean checkFeatureCode() {
Boolean bool = (Boolean) this.mRestfulUtils.postData(new CheckFeatureCodeReq().buidParams(new BaseInfo()), CheckFeatureCodeReq.URL, new CheckFeatureCodeResp());
if (bool != null) {
return bool.booleanValue();
}
return false;
}
public void clearStreamInfoCache() {
DeviceManager.getInstance().clearDevice();
CameraManager.getInstance().clearCamera();
}
public void clearVtduTokens() {
List<String> list = this.mTokenList;
if (list != null) {
list.clear();
}
this.mBatchTokensTime = 0L;
}
public boolean controlPTZ(final String str, final int i, EZConstants.EZPTZCommand eZPTZCommand, EZConstants.EZPTZAction eZPTZAction, final int i2) {
RestfulUtils restfulUtils;
BaseInfo baseInfo;
ApiResponse apiResponse;
String str2;
LogUtil.d(TAG, "Enter controlPTZ");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
if (i < 0) {
LogUtil.e(TAG, "setDeviceEnryptStatusEx, invalid parameters");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
final int command = eZPTZCommand.getCommand();
if (eZPTZAction == EZConstants.EZPTZAction.EZPTZActionSTART) {
restfulUtils = this.mRestfulUtils;
baseInfo = new BaseInfo() {
@HttpParam(name = DX_HttpConstants.DX_REQ_KEY_CHANNEL_NO)
private int channelNo;
@HttpParam(name = "deviceSerial")
private String deviceSerial;
@HttpParam(name = DX_HttpConstants.DX_REQ_KEY_DIRECTION)
private int direction;
@HttpParam(name = "speed")
private int speed;
{
this.direction = command;
this.speed = i2;
this.deviceSerial = str;
this.channelNo = i;
}
};
apiResponse = new ApiResponse() {
@Override
public Object parse(String str3) {
return Boolean.valueOf(EzvizAPI.parserCode(str3));
}
};
str2 = "/api/device/ptz/start";
} else {
restfulUtils = this.mRestfulUtils;
baseInfo = new BaseInfo() {
@HttpParam(name = DX_HttpConstants.DX_REQ_KEY_CHANNEL_NO)
private int channelNo;
@HttpParam(name = "deviceSerial")
private String deviceSerial;
@HttpParam(name = DX_HttpConstants.DX_REQ_KEY_DIRECTION)
private int direction;
{
this.direction = command;
this.deviceSerial = str;
this.channelNo = i;
}
};
apiResponse = new ApiResponse() {
@Override
public Object parse(String str3) {
return Boolean.valueOf(EzvizAPI.parserCode(str3));
}
};
str2 = "/api/device/ptz/stop";
}
Object post = restfulUtils.post(baseInfo, str2, apiResponse);
if (post == null) {
return false;
}
return ((Boolean) post).booleanValue();
}
public void controlVideoFlip(String str, int i, EZConstants.EZPTZDisplayCommand eZPTZDisplayCommand) {
LogUtil.i(TAG, "Enter controlVideoFlip");
if (TextUtils.isEmpty(str)) {
throw new BaseException("", 400002);
}
EZPTZController eZPTZController = this.mEZPTZController;
if (eZPTZController == null || TextUtils.isEmpty(eZPTZController.getDeviceSerial()) || !this.mEZPTZController.getDeviceSerial().equalsIgnoreCase(str) || this.mEZPTZController.getCameraNo() != i) {
this.mEZPTZController = new EZPTZController(str, i);
}
this.mEZPTZController = new EZPTZController(str, i);
int ptzControl = eZPTZDisplayCommand.getCommand() == 4 ? this.mEZPTZController.ptzControl(eZPTZDisplayCommand.getCommand(), "CENTER", 0, 0) : 0;
if (ptzControl != 100) {
throw new BaseException("", ptzControl);
}
}
public EZPlayer createPlayer(EZPlayURLParams eZPlayURLParams) {
if (eZPlayURLParams != null) {
return new EZPlayer(new EZStreamParamHelp(eZPlayURLParams));
}
return null;
}
public EZPlayer createPlayer(String str, int i) {
return createPlayer(str, i, false);
}
public EZPlayer createPlayerWithDeviceSerial(String str, int i, int i2) {
LogUtil.i(TAG, "Enter createPlayerWithDeviceSerial: ");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
ErrorLayer.getErrorLayer(2, localValidatDeviceSerial);
return null;
}
if (i < 0) {
LogUtil.i(TAG, "createPlayerWithDeviceSerial, invalid parameters channelNo");
return null;
}
EZStreamParamHelp eZStreamParamHelp = new EZStreamParamHelp(str, i, false);
eZStreamParamHelp.setForceVtmStream(true);
eZStreamParamHelp.setStreamType(i2);
return new EZPlayer(eZStreamParamHelp);
}
public EZPlayer createPlayerWithUrl(String str) {
return createPlayer(str, 0, true);
}
public EZPlayer createPlayerWithUserId(int i, int i2, int i3) {
return new EZPlayer(i, i2, i3);
}
public byte[] decryptData(byte[] bArr, String str) {
StringBuilder sb = new StringBuilder("Enter decryptData verifyCode = ");
sb.append(TextUtils.isEmpty(str) ? "NULL" : str);
LogUtil.i(TAG, sb.toString());
if (bArr == null || bArr.length <= 48 || !new String(bArr, 16, 32).equals(MD5Util.getMD5String(MD5Util.getMD5String(str)))) {
return null;
}
if (str != null) {
try {
byte[] copyOfRange = Arrays.copyOfRange(bArr, 48, bArr.length);
SecretKeySpec secretKeySpec = new SecretKeySpec(Arrays.copyOf(str.getBytes(), 16), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(2, secretKeySpec, new IvParameterSpec(new byte[]{48, 49, 50, 51, 52, 53, 54, 55, 0, 0, 0, 0, 0, 0, 0, 0}));
return cipher.doFinal(copyOfRange);
} catch (Exception e) {
LogUtil.printErrStackTrace(TAG, e.fillInStackTrace());
}
}
return null;
}
public boolean deleteAlarm(List<String> list) {
if (list == null || list.size() <= 0) {
LogUtil.e(TAG, "Enter deleteAlarm: alarmIdList is null or size is 0");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
LogUtil.d(TAG, "Enter deleteAlarm, alarmIdList size : " + list.size());
EZAlarmDeleteMultipleAlarmsInfo eZAlarmDeleteMultipleAlarmsInfo = new EZAlarmDeleteMultipleAlarmsInfo();
StringBuilder sb = new StringBuilder();
if (list.size() == 1) {
sb.append(list.get(0));
} else {
sb.append(list.get(0));
for (int i = 1; i < list.size(); i++) {
sb.append(",");
sb.append(list.get(i));
}
}
eZAlarmDeleteMultipleAlarmsInfo.setDeleteString(sb.toString());
this.mRestfulUtils.postData(new EZAlarmDeleteMultipleAlarmsReq().buidParams(eZAlarmDeleteMultipleAlarmsInfo), EZAlarmDeleteMultipleAlarmsReq.URL, new EZAlarmDeleteMultipleAlarmsResp());
return true;
}
public boolean deleteDevice(String str) {
BaseDeviceInfo baseDeviceInfo = new BaseDeviceInfo();
baseDeviceInfo.setDeviceId(str);
Boolean bool = (Boolean) this.mRestfulUtils.postData(new DeleteDeviceReq().buidParams(baseDeviceInfo), DeleteDeviceReq.URL, new DeleteDeviceResp());
if (bool != null) {
return bool.booleanValue();
}
return false;
}
public boolean deleteDeviceBySerial(String str) {
EZDeleteDeviceBySerialReq eZDeleteDeviceBySerialReq = new EZDeleteDeviceBySerialReq();
EZDeleteDeviceBySerialReq.Params params = eZDeleteDeviceBySerialReq.params;
params.deviceSerial = str;
params.accessToken = LocalInfo.getInstance().getEZAccesstoken().getAccessToken();
eZDeleteDeviceBySerialReq.params.featureCode = this.mLocalInfo.getHardwareCode();
try {
return parserCode(transferAPI(ReflectionUtils.convObjectToJSON(eZDeleteDeviceBySerialReq).toString()));
} catch (JSONException e) {
LogUtil.printErrStackTrace(TAG, e.fillInStackTrace());
return false;
}
}
public boolean deleteDeviceNonTransfer(final String str) {
LogUtil.i(TAG, "Enter deleteDeviceNonTransfer");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceSerial")
private String mDeviceSerial;
{
this.mDeviceSerial = str;
}
}, "/api/device/deleteDevice", new ApiResponse() {
@Override
public Object parse(String str2) {
return Boolean.valueOf(parseCode(str2));
}
});
if (post == null) {
return false;
}
boolean booleanValue = ((Boolean) post).booleanValue();
if (booleanValue) {
DeviceManager.getInstance().deleteDevice(str);
}
return booleanValue;
}
public boolean deleteLeaveMessages(List<String> list) {
LogUtil.i(TAG, "Enter deleteLeaveMessages");
final String commaSeprateStrFromList = getCommaSeprateStrFromList(list);
if (!TextUtils.isEmpty(commaSeprateStrFromList)) {
return ((Boolean) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "messageId")
private String mMsgIds;
@HttpParam(name = "type")
private String mType = "2";
{
this.mMsgIds = commaSeprateStrFromList;
}
}, "/api/message/leave/operate", new ApiResponse() {
@Override
public Object parse(String str) {
return Boolean.valueOf(parseCode(str));
}
})).booleanValue();
}
LogUtil.i(TAG, "deleteLeaveMessages, invalid parameters msgIdList");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400001));
}
public void downloadCloudFile(String str, int i, EZCloudRecordFile eZCloudRecordFile, String str2, EZOpenSDKListener.EZStreamDownloadCallback eZStreamDownloadCallback) {
EZCloudStreamDownload eZCloudStreamDownload = new EZCloudStreamDownload(str2, eZCloudRecordFile);
eZCloudStreamDownload.setStreamDownloadCallback(eZStreamDownloadCallback);
eZCloudStreamDownload.start();
}
public boolean formatStorage(final String str, final int i) {
LogUtil.i(TAG, "Enter formatStorage");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
if (i >= 0) {
return ((Boolean) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceSerial")
private String mDeviceSerial;
@HttpParam(name = "diskIndex")
private int mDiskIndex;
{
this.mDeviceSerial = str;
this.mDiskIndex = i;
}
}, "/api/device/format/disk", new ApiResponse() {
@Override
public Object parse(String str2) {
return Boolean.valueOf(parseCode(str2));
}
})).booleanValue();
}
LogUtil.i(TAG, "formatStorage, invalid parameters partitionIndex");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
public List<EZAlarmInfo> getAlarmList(String str, final int i, final int i2, Calendar calendar, Calendar calendar2) {
LogUtil.i(TAG, "Enter getAlarmList: ");
if (i < 0 || i2 <= 0) {
LogUtil.i(TAG, "getAlarmListBySerial, invalid parameters page");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
if (calendar != null && calendar2 != null && calendar.after(calendar2)) {
LogUtil.i(TAG, "getAlarmListBySerial, invalid parameters, begin after end time");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
if (TextUtils.isEmpty(str)) {
str = "";
}
final String str2 = str;
final String calendar2String = calendar == null ? "" : calendar2String(calendar);
final String calendar2String2 = calendar2 == null ? "" : calendar2String(calendar2);
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = DX_HttpConstants.DX_REQ_KEY_START_TIME)
private String mBeginTime;
@HttpParam(name = "deviceSerial")
private String mDeviceSerial;
@HttpParam(name = "endTime")
private String mEndTime;
@HttpParam(name = "pageStart")
private int mPageIndex;
@HttpParam(name = "pageSize")
private int mPageSize;
@HttpParam(name = "alarmType")
private int mAlarmType = -1;
@HttpParam(name = "status")
private int mStatus = 2;
{
this.mDeviceSerial = str2;
this.mPageIndex = i;
this.mPageSize = i2;
this.mBeginTime = calendar2String;
this.mEndTime = calendar2String2;
}
}, "/api/alarm/getList", new ApiResponse() {
@Override
public Object parse(String str3) {
if (!parseCode(str3)) {
return null;
}
JSONArray optJSONArray = new JSONObject(str3).getJSONObject("result").optJSONArray("data");
ArrayList arrayList = new ArrayList();
if (optJSONArray != null && optJSONArray.length() > 0) {
int length = optJSONArray.length();
for (int i3 = 0; i3 < length; i3++) {
EZAlarmInfo eZAlarmInfo = new EZAlarmInfo();
ReflectionUtils.convJSONToObject(optJSONArray.getJSONObject(i3), eZAlarmInfo);
arrayList.add(eZAlarmInfo);
}
}
return arrayList;
}
});
if (post == null) {
return null;
}
List<EZAlarmInfo> list = (List) post;
if (list.size() > 0) {
Iterator<EZAlarmInfo> it = list.iterator();
while (it.hasNext()) {
LogUtil.d(TAG, "getAlarmListBySerial returns: " + new Gson().toJson(it.next()));
}
}
return list;
}
public List<EZAlarmInfo> getAlarmList(String str, int i, Calendar calendar, Calendar calendar2, EZConstants.EZAlarmType eZAlarmType, EZConstants.EZAlarmStatus eZAlarmStatus, int i2, int i3) {
if (i2 < 0 || i3 <= 0) {
LogUtil.e(TAG, "getAlarmListBySerial, invalid parameters page ;pageStart= " + i2 + " pageSize = " + i3);
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
if (calendar == null || calendar2 == null || calendar.after(calendar2)) {
LogUtil.i(TAG, "getAlarmListBySerial, invalid parameters, begin and end time");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
GetAlarmListReq getAlarmListReq = new GetAlarmListReq();
getAlarmListReq.setDeviceSerial(str);
getAlarmListReq.setCameraNo(i);
getAlarmListReq.setStartTime(Utils.calendar2String(calendar));
getAlarmListReq.setEndTime(Utils.calendar2String(calendar2));
getAlarmListReq.setStatus(eZAlarmStatus.getAlarmStatus());
getAlarmListReq.setPageStart(i2);
getAlarmListReq.setPageSize(i3);
getAlarmListReq.setAlarmType(eZAlarmType.getTypeId());
Object post = this.mRestfulUtils.post(getAlarmListReq, "/api/alarm/list", new ApiResponse() {
@Override
public Object parse(String str2) {
JSONArray optJSONArray;
int length;
if (!parseCode(str2) || (optJSONArray = new JSONObject(str2).getJSONObject("result").optJSONArray("data")) == null || (length = optJSONArray.length()) <= 0) {
return null;
}
ArrayList arrayList = new ArrayList();
for (int i4 = 0; i4 < length; i4++) {
JSONObject jSONObject = optJSONArray.getJSONObject(i4);
EZAlarmInfo eZAlarmInfo = new EZAlarmInfo();
ReflectionUtils.convJSONToObject(jSONObject, eZAlarmInfo);
arrayList.add(eZAlarmInfo);
}
return arrayList;
}
});
if (post == null) {
return null;
}
List<EZAlarmInfo> list = (List) post;
LogUtil.d(TAG, "getAlarmList EZAlarmInfo:" + list);
return list;
}
public String getAppKey() {
return this.mAppKey;
}
public String getAppNameByPID(Context context, int i) {
for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : ((ActivityManager) context.getSystemService("activity")).getRunningAppProcesses()) {
if (runningAppProcessInfo.pid == i) {
return runningAppProcessInfo.processName;
}
}
return "";
}
public List<EZAreaInfo> getAreaList() {
Object post = this.mRestfulUtils.post(new BaseInfo(0 == true ? 1 : 0) {
}, "/api/area/list", new ApiResponse() {
@Override
public Object parse(String str) {
JSONArray optJSONArray;
if (!parseCode(str) || (optJSONArray = new JSONObject(str).getJSONObject("result").optJSONArray("data")) == null || optJSONArray.length() <= 0) {
return null;
}
ArrayList arrayList = new ArrayList();
int length = optJSONArray.length();
for (int i = 0; i < length; i++) {
EZAreaInfo eZAreaInfo = new EZAreaInfo();
ReflectionUtils.convJSONToObject(optJSONArray.getJSONObject(i), eZAreaInfo);
arrayList.add(eZAreaInfo);
}
return arrayList;
}
});
if (post == null) {
return null;
}
List<EZAreaInfo> list = (List) post;
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
}
}
return list;
}
public void getBatchTokens() {
this.mBatchTokensTime = System.currentTimeMillis();
BatchGetTokens batchGetTokens = new BatchGetTokens();
batchGetTokens.setCount(10);
this.mTokenList = (List) this.mRestfulUtils.postData(new BatchGetTokensReq().buidParams(batchGetTokens), BatchGetTokensReq.URL, new BatchGetTokensResp());
}
public List<EZCameraInfo> getCameraListNewApi(final int i, final int i2) {
LogUtil.i(TAG, "Enter getCameraListNewApi");
if (i < 0 || i2 <= 0) {
LogUtil.i(TAG, "getEZCameraInfoNoTransfer, invalid parameters");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "pageStart")
private int mPageIndex;
@HttpParam(name = "pageSize")
private int mPageSize;
{
this.mPageIndex = i;
this.mPageSize = i2;
}
}, "/api/device/list", new BaseResponse() {
@Override
public Object parse(String str) {
JSONArray jSONArray;
int length;
if (!parseCode(str) || (length = (jSONArray = new JSONObject(str).getJSONArray(GetCameraInfoListResp.CAMERALIST)).length()) <= 0) {
return null;
}
ArrayList arrayList = new ArrayList();
for (int i3 = 0; i3 < length; i3++) {
EZCameraInfo eZCameraInfo = new EZCameraInfo();
ReflectionUtils.convJSONToObject(jSONArray.getJSONObject(i3), eZCameraInfo);
arrayList.add(eZCameraInfo);
}
return arrayList;
}
});
if (post == null) {
return null;
}
List<EZCameraInfo> list = (List) post;
int size = list.size();
for (int i3 = 0; i3 < size; i3++) {
LogUtil.i(TAG, "getCameraListNewApi returns:" + new Gson().toJson(list.get(i3)));
}
return list;
}
public int getCameraStatus(String str) {
BaseCameraInfo baseCameraInfo = new BaseCameraInfo();
baseCameraInfo.setCameraId(str);
return ((Integer) this.mRestfulUtils.postData(new GetCameraStatusReq().buidParams(baseCameraInfo), GetCameraStatusReq.URL, new GetCameraStatusResp())).intValue();
}
public String getCityConfig(final String str) {
return (String) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = RegistReq.CITYKEY)
private String cityKey;
{
this.cityKey = str;
}
}, "/api/traffic/getCityConfig", new ApiResponse() {
@Override
public Object parse(String str2) {
if (parseCode(str2)) {
return new JSONObject(str2).getJSONObject("result").optString("data");
}
return null;
}
});
}
public List<CloudFile> getCloudFileList(final String str, final int i, Calendar calendar, Calendar calendar2, final int i2, final int i3) {
LogUtil.i(TAG, "Enter getCloudFileList: ");
if (TextUtils.isEmpty(str) || i2 < 0 || i3 < 0) {
LogUtil.i(TAG, "getCloudFileList: invalid parameters");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
final String calendar2String = Utils.calendar2String(calendar);
final String calendar2String2 = Utils.calendar2String(calendar2);
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "endTime")
private String endTime;
@HttpParam(name = GetCameraInfoReq.CAMERANO)
private int mCameraNo;
@HttpParam(name = "deviceSerial")
private String mDeviceSerial;
@HttpParam(name = "pageSize")
private int mPageSize;
@HttpParam(name = "pageStart")
private int mPageStart;
@HttpParam(name = DX_HttpConstants.DX_REQ_KEY_START_TIME)
private String startTime;
@HttpParam(name = "version")
private String version = SocializeConstants.PROTOCOL_VERSON;
{
this.mDeviceSerial = str;
this.mCameraNo = i;
this.startTime = calendar2String;
this.endTime = calendar2String2;
this.mPageStart = i2;
this.mPageSize = i3;
}
}, "/api/cloud/list", new ApiResponse() {
@Override
public Object parse(String str2) {
JSONArray optJSONArray;
if (!parseCode(str2) || (optJSONArray = new JSONObject(str2).getJSONObject("result").optJSONArray("data")) == null) {
return null;
}
ArrayList arrayList = new ArrayList();
int length = optJSONArray.length();
for (int i4 = 0; i4 < length; i4++) {
CloudFile cloudFile = new CloudFile();
ReflectionUtils.convJSONToObject(optJSONArray.getJSONObject(i4), cloudFile);
arrayList.add(cloudFile);
}
return arrayList;
}
});
if (post == null) {
return null;
}
List<CloudFile> list = (List) post;
Iterator<CloudFile> it = list.iterator();
while (it.hasNext()) {
LogUtil.d(TAG, "getCloudFileList: " + new Gson().toJson(it.next()));
}
return list;
}
public List<ConfigCity> getConfigCityList(final int i, final int i2) {
return (List) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "pageSize")
private int pageSize;
@HttpParam(name = "pageStart")
private int pageStart;
{
this.pageStart = i;
this.pageSize = i2;
}
}, "/api/traffic/getConfigCityList", new ApiResponse() {
@Override
public Object parse(String str) {
ArrayList arrayList = new ArrayList();
if (!parseCode(str)) {
return null;
}
JSONArray jSONArray = new JSONObject(str).getJSONObject("result").getJSONArray("data");
for (int i3 = 0; i3 < jSONArray.length(); i3++) {
JSONObject optJSONObject = jSONArray.optJSONObject(i3);
ConfigCity configCity = new ConfigCity();
ReflectionUtils.convJSONToObject(optJSONObject, configCity);
arrayList.add(configCity);
}
return arrayList;
}
});
}
public EZSDKConfiguration getConfiguration() {
LogUtil.i(TAG, "Enter getConfiguration: ");
Object post = this.mRestfulUtils.post(new BaseInfo() {
}, "/api/config/info", new ApiResponse() {
@Override
public Object parse(String str) {
JSONObject optJSONObject;
if (!parseCode(str) || (optJSONObject = new JSONObject(str).getJSONObject("result").optJSONObject("data")) == null) {
return null;
}
EZSDKConfiguration eZSDKConfiguration = new EZSDKConfiguration();
ReflectionUtils.convJSONToObject(optJSONObject, eZSDKConfiguration);
JSONObject jSONObject = optJSONObject.getJSONObject("streamLimitInfo");
if (jSONObject != null) {
EZSDKConfiguration.StreamLimitInfoEntity streamLimitInfoEntity = new EZSDKConfiguration.StreamLimitInfoEntity();
ReflectionUtils.convJSONToObject(jSONObject, streamLimitInfoEntity);
eZSDKConfiguration.setStreamLimitInfo(streamLimitInfoEntity);
}
return eZSDKConfiguration;
}
});
if (post == null) {
return null;
}
EZSDKConfiguration eZSDKConfiguration = (EZSDKConfiguration) post;
LogUtil.d(TAG, new Gson().toJson(eZSDKConfiguration));
return eZSDKConfiguration;
}
public List<EZHiddnsDeviceInfo> getDDNSDeviceList(final int i, final int i2) {
LogUtil.i(TAG, "Enter getDDNSDeviceList");
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "pageSize")
private int pagesize;
@HttpParam(name = "pageStart")
private int pagestart;
{
this.pagesize = i;
this.pagestart = i2;
}
}, "/api/lapp/ddns/list", new ApiResponse() {
@Override
public List<EZHiddnsDeviceInfo> parse(String str) {
boolean parseCodeHttp = parseCodeHttp(str);
if (!parseCodeHttp || !parseCodeHttp) {
return null;
}
JSONArray optJSONArray = new JSONObject(str).optJSONArray("data");
ArrayList arrayList = new ArrayList();
if (optJSONArray != null && optJSONArray.length() > 0) {
int length = optJSONArray.length();
for (int i3 = 0; i3 < length; i3++) {
EZHiddnsDeviceInfo eZHiddnsDeviceInfo = new EZHiddnsDeviceInfo();
ReflectionUtils.convJSONToObject(optJSONArray.optJSONObject(i3), eZHiddnsDeviceInfo);
arrayList.add(eZHiddnsDeviceInfo);
}
}
return arrayList;
}
});
if (post == null) {
return null;
}
List<EZHiddnsDeviceInfo> list = (List) post;
if (list.size() > 0) {
Iterator<EZHiddnsDeviceInfo> it = list.iterator();
while (it.hasNext()) {
LogUtil.d(TAG, "getDDNSDeviceList returns: " + new Gson().toJson(it.next()));
}
}
return list;
}
public EZHiddnsDeviceInfo getDDNSWithDeviceSerial(final String str, final String str2) {
LogUtil.i(TAG, "Enter getDDNSWithDeviceSerial");
if (TextUtils.isEmpty(str) && TextUtils.isEmpty(str2)) {
LogUtil.i(TAG, "deviceSerial and domain cannot be empty at the same time");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, ErrorCode.ERROR_CAS_UPGRADE_PU_PARAM_ERR));
}
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
EZHiddnsDeviceInfo eZHiddnsDeviceInfo = (EZHiddnsDeviceInfo) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceSerial")
private String devSerial;
@HttpParam(name = "domain")
private String mDomain;
{
this.devSerial = str;
this.mDomain = str2;
}
}, "/api/lapp/ddns/get", new ApiResponse() {
@Override
public EZHiddnsDeviceInfo parse(String str3) {
JSONObject optJSONObject;
boolean parseCodeHttp = parseCodeHttp(str3);
if (!parseCodeHttp || !parseCodeHttp || (optJSONObject = new JSONObject(str3).optJSONObject("data")) == null) {
return null;
}
EZHiddnsDeviceInfo eZHiddnsDeviceInfo2 = new EZHiddnsDeviceInfo();
ReflectionUtils.convJSONToObject(optJSONObject, eZHiddnsDeviceInfo2);
return eZHiddnsDeviceInfo2;
}
});
if (eZHiddnsDeviceInfo != null) {
LogUtil.d(TAG, "getDDNSWithDeviceSerial returns: " + new Gson().toJson(eZHiddnsDeviceInfo));
}
return eZHiddnsDeviceInfo;
}
public List<EZDetectorInfo> getDetectorList(final String str) {
LogUtil.i(TAG, "Enter getDetectorList: ");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceSerial")
private String devSerial;
{
this.devSerial = str;
}
}, "/api/detector/list", new ApiResponse() {
@Override
public Object parse(String str2) {
JSONArray optJSONArray;
if (!parseCode(str2) || (optJSONArray = new JSONObject(str2).getJSONObject("result").optJSONArray("data")) == null || optJSONArray.length() <= 0) {
return null;
}
ArrayList arrayList = new ArrayList();
int length = optJSONArray.length();
for (int i = 0; i < length; i++) {
EZDetectorInfo eZDetectorInfo = new EZDetectorInfo();
ReflectionUtils.convJSONToObject(optJSONArray.getJSONObject(i), eZDetectorInfo);
arrayList.add(eZDetectorInfo);
}
return arrayList;
}
});
if (post == null) {
return null;
}
List<EZDetectorInfo> list = (List) post;
if (list.size() > 0) {
Iterator<EZDetectorInfo> it = list.iterator();
while (it.hasNext()) {
LogUtil.d(TAG, "getDetectorList: " + new Gson().toJson(it.next()));
}
}
return list;
}
public EZDeviceInfo getDeviceInfo(final String str) {
LogUtil.i(TAG, "Enter getDeviceInfo: ");
try {
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceSerial")
private String deviceSerial;
{
this.deviceSerial = str;
}
}, "/api/sdk/device/info", new ApiResponse() {
@Override
public Object parse(String str2) {
JSONObject optJSONObject;
EZDeviceInfo eZDeviceInfo = null;
if (parseCode(str2) && (optJSONObject = new JSONObject(str2).getJSONObject("result").optJSONObject("data")) != null) {
eZDeviceInfo = new EZDeviceInfo();
ReflectionUtils.convJSONToObject(optJSONObject, eZDeviceInfo);
JSONArray optJSONArray = optJSONObject.optJSONArray(GetCameraInfoResp.CAMERAINFO);
if (optJSONArray != null && optJSONArray.length() > 0) {
ArrayList arrayList = new ArrayList();
int length = optJSONArray.length();
for (int i = 0; i < length; i++) {
EZCameraInfo eZCameraInfo = new EZCameraInfo();
JSONObject jSONObject = optJSONArray.getJSONObject(i);
ReflectionUtils.convJSONToObject(jSONObject, eZCameraInfo);
JSONArray optJSONArray2 = jSONObject.optJSONArray("videoQualityInfos");
if (optJSONArray2 != null && optJSONArray2.length() > 0) {
ArrayList<EZVideoQualityInfo> arrayList2 = new ArrayList<>();
int length2 = optJSONArray2.length();
for (int i2 = 0; i2 < length2; i2++) {
EZVideoQualityInfo eZVideoQualityInfo = new EZVideoQualityInfo();
ReflectionUtils.convJSONToObject(optJSONArray2.getJSONObject(i2), eZVideoQualityInfo);
arrayList2.add(eZVideoQualityInfo);
}
eZCameraInfo.setVideoQualityInfos(arrayList2);
}
arrayList.add(eZCameraInfo);
}
if (arrayList.size() > 0) {
eZDeviceInfo.setCameraInfoList(arrayList);
}
}
JSONArray optJSONArray3 = optJSONObject.optJSONArray("detectorInfo");
if (optJSONArray3 != null && optJSONArray3.length() > 0) {
ArrayList arrayList3 = new ArrayList();
int length3 = optJSONArray3.length();
for (int i3 = 0; i3 < length3; i3++) {
EZDetectorInfo eZDetectorInfo = new EZDetectorInfo();
ReflectionUtils.convJSONToObject(optJSONArray3.getJSONObject(i3), eZDetectorInfo);
arrayList3.add(eZDetectorInfo);
}
if (arrayList3.size() > 0) {
eZDeviceInfo.setDetectorInfoList(arrayList3);
}
}
}
return eZDeviceInfo;
}
});
if (post == null) {
return null;
}
LogUtil.d(TAG, "getDeviceInfo returns: " + new Gson().toJson(post));
return (EZDeviceInfo) post;
} catch (BaseException e) {
throw e;
}
}
public DeviceInfoEx getDeviceInfoEx(final String str, final int i) {
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = GetCameraInfoReq.CAMERANO)
private int cameraNo;
@HttpParam(name = "deviceSerial")
private String deviceSerial;
@HttpParam(name = "version")
private String version = SocializeConstants.PROTOCOL_VERSON;
{
this.deviceSerial = str;
this.cameraNo = i;
}
}, GetCameraDetailReq.URL, new ApiResponse() {
@Override
public Object parse(String str2) {
JSONObject optJSONObject;
JSONObject optJSONObject2;
DeviceInfoEx deviceInfoEx = null;
if (parseCode(str2) && (optJSONObject = new JSONObject(str2).getJSONObject("result").optJSONObject("data")) != null) {
JSONObject optJSONObject3 = optJSONObject.optJSONObject("device");
if (optJSONObject3 != null) {
deviceInfoEx = new DeviceInfoEx();
ReflectionUtils.convJSONToObject(optJSONObject3, deviceInfoEx);
JSONObject optJSONObject4 = optJSONObject3.optJSONObject("belongDevice");
if (optJSONObject4 != null) {
DeviceInfoEx deviceInfoEx2 = new DeviceInfoEx();
ReflectionUtils.convJSONToObject(optJSONObject4, deviceInfoEx2);
deviceInfoEx.setBelongDevice(deviceInfoEx2);
}
}
if (deviceInfoEx != null && (optJSONObject2 = optJSONObject.optJSONObject("camera")) != null) {
CameraInfoEx cameraInfoEx = new CameraInfoEx();
ReflectionUtils.convJSONToObject(optJSONObject2, cameraInfoEx);
JSONArray optJSONArray = optJSONObject2.optJSONArray("videoQualityInfos");
if (optJSONArray != null && optJSONArray.length() > 0) {
ArrayList<EZVideoQualityInfo> arrayList = new ArrayList<>();
int length = optJSONArray.length();
for (int i2 = 0; i2 < length; i2++) {
EZVideoQualityInfo eZVideoQualityInfo = new EZVideoQualityInfo();
ReflectionUtils.convJSONToObject(optJSONArray.getJSONObject(i2), eZVideoQualityInfo);
arrayList.add(eZVideoQualityInfo);
}
cameraInfoEx.videoQualityInfos = arrayList;
}
deviceInfoEx.setCameraInfoEx(cameraInfoEx);
}
}
return deviceInfoEx;
}
});
if (post == null) {
return null;
}
LogUtil.d(TAG, new Gson().toJson(post));
return (DeviceInfoEx) post;
}
public List<EZDeviceInfo> getDeviceList(final int i, final int i2) {
LogUtil.i(TAG, "Enter getDeviceList: ");
if (i < 0 || i2 <= 0) {
LogUtil.i(TAG, "getDeviceList: invalid parameters");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "pageSize")
private int pageSize;
@HttpParam(name = "pageStart")
private int pageStart;
@HttpParam(name = "version")
private String version = SocializeConstants.PROTOCOL_VERSON;
{
this.pageSize = i2;
this.pageStart = i;
}
}, "/api/device/list", new ApiResponse() {
@Override
public Object parse(String str) {
JSONArray jSONArray;
JSONArray jSONArray2;
if (!parseCode(str)) {
return null;
}
JSONArray optJSONArray = new JSONObject(str).getJSONObject("result").optJSONArray("data");
ArrayList arrayList = new ArrayList();
if (optJSONArray != null) {
int length = optJSONArray.length();
int i3 = 0;
while (i3 < length) {
EZDeviceInfo eZDeviceInfo = new EZDeviceInfo();
JSONObject jSONObject = optJSONArray.getJSONObject(i3);
ReflectionUtils.convJSONToObject(jSONObject, eZDeviceInfo);
JSONArray optJSONArray2 = jSONObject.optJSONArray(GetCameraInfoResp.CAMERAINFO);
if (optJSONArray2 == null || optJSONArray2.length() <= 0) {
jSONArray = optJSONArray;
} else {
ArrayList arrayList2 = new ArrayList();
int length2 = optJSONArray2.length();
int i4 = 0;
while (i4 < length2) {
EZCameraInfo eZCameraInfo = new EZCameraInfo();
JSONObject jSONObject2 = optJSONArray2.getJSONObject(i4);
ReflectionUtils.convJSONToObject(jSONObject2, eZCameraInfo);
JSONArray optJSONArray3 = jSONObject2.optJSONArray("videoQualityInfos");
if (optJSONArray3 == null || optJSONArray3.length() <= 0) {
jSONArray2 = optJSONArray;
} else {
ArrayList<EZVideoQualityInfo> arrayList3 = new ArrayList<>();
int length3 = optJSONArray3.length();
int i5 = 0;
while (i5 < length3) {
EZVideoQualityInfo eZVideoQualityInfo = new EZVideoQualityInfo();
ReflectionUtils.convJSONToObject(optJSONArray3.getJSONObject(i5), eZVideoQualityInfo);
arrayList3.add(eZVideoQualityInfo);
i5++;
optJSONArray = optJSONArray;
}
jSONArray2 = optJSONArray;
eZCameraInfo.setVideoQualityInfos(arrayList3);
}
arrayList2.add(eZCameraInfo);
i4++;
optJSONArray = jSONArray2;
}
jSONArray = optJSONArray;
if (arrayList2.size() > 0) {
eZDeviceInfo.setCameraInfoList(arrayList2);
}
}
JSONArray optJSONArray4 = jSONObject.optJSONArray("detectorInfo");
if (optJSONArray4 != null && optJSONArray4.length() > 0) {
ArrayList arrayList4 = new ArrayList();
int length4 = optJSONArray4.length();
for (int i6 = 0; i6 < length4; i6++) {
EZDetectorInfo eZDetectorInfo = new EZDetectorInfo();
ReflectionUtils.convJSONToObject(optJSONArray4.getJSONObject(i6), eZDetectorInfo);
arrayList4.add(eZDetectorInfo);
}
if (arrayList4.size() > 0) {
eZDeviceInfo.setDetectorInfoList(arrayList4);
}
}
arrayList.add(eZDeviceInfo);
i3++;
optJSONArray = jSONArray;
}
}
return arrayList;
}
});
if (post == null) {
return null;
}
List<EZDeviceInfo> list = (List) post;
Iterator<EZDeviceInfo> it = list.iterator();
while (it.hasNext()) {
LogUtil.d(TAG, "getDeviceList: " + new Gson().toJson(it.next()));
}
return list;
}
public EZDevicePlayInfo getDevicePlayInfo(final String str) {
LogUtil.i(TAG, "Enter getDevicePlayInfo: ");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceSerial")
private String mDeviceSerial;
{
this.mDeviceSerial = str;
}
}, "/api/device/sdk/detail", new ApiResponse() {
@Override
public Object parse(String str2) {
JSONObject optJSONObject;
if (!parseCode(str2) || (optJSONObject = new JSONObject(str2).getJSONObject("result").optJSONObject("data")) == null) {
return null;
}
EZDevicePlayInfo eZDevicePlayInfo = new EZDevicePlayInfo();
ReflectionUtils.convJSONToObject(optJSONObject, eZDevicePlayInfo);
return eZDevicePlayInfo;
}
});
if (post == null) {
LogUtil.i(TAG, "getDevicePlayInfo: return: null");
return null;
}
EZDevicePlayInfo eZDevicePlayInfo = (EZDevicePlayInfo) post;
LogUtil.d(TAG, "getDevicePlayInfo: return:" + eZDevicePlayInfo);
return eZDevicePlayInfo;
}
public EZDeviceUpgradeStatus getDeviceUpgradeStatus(final String str) {
LogUtil.i(TAG, "Enter getDeviceUpgradeStatus");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceSerial")
private String mDeviceSerial;
{
this.mDeviceSerial = str;
}
}, "/api/device/upgrade/status", new ApiResponse() {
@Override
public Object parse(String str2) {
JSONObject optJSONObject;
if (!parseCode(str2) || (optJSONObject = new JSONObject(str2).getJSONObject("result").optJSONObject("data")) == null) {
return null;
}
EZDeviceUpgradeStatus eZDeviceUpgradeStatus = new EZDeviceUpgradeStatus();
int optInt = optJSONObject.optInt("upgradeStatus");
eZDeviceUpgradeStatus.setUpgradeProgress(optJSONObject.optInt("upgradeProgress"));
eZDeviceUpgradeStatus.setUpgradeStatus(optInt);
return eZDeviceUpgradeStatus;
}
});
if (post == null) {
return null;
}
EZDeviceUpgradeStatus eZDeviceUpgradeStatus = (EZDeviceUpgradeStatus) post;
LogUtil.d(TAG, "getDeviceUpgradeStatus: " + eZDeviceUpgradeStatus);
return eZDeviceUpgradeStatus;
}
public EZDeviceUpgradeStatus getDeviceUpgradeStatus_stub(String str) {
LogUtil.i(TAG, "Enter getDeviceUpgradeStatus_stub");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
if (!Config.ENABLE_STUB) {
LogUtil.i(TAG, "getDeviceUpgradeStatus_stub: Config.ENABLE_STUB not open");
return null;
}
EZDeviceUpgradeStatus eZDeviceUpgradeStatus = new EZDeviceUpgradeStatus();
if (this.mStartUpgrade == 0) {
eZDeviceUpgradeStatus.setUpgradeStatus(-1);
eZDeviceUpgradeStatus.setUpgradeProgress(0);
return eZDeviceUpgradeStatus;
}
this.mUpgradeProgress += new Random().nextInt(10);
if (this.mUpgradeProgress >= 100) {
eZDeviceUpgradeStatus.setUpgradeProgress(100);
eZDeviceUpgradeStatus.setUpgradeStatus(2);
this.mStartUpgrade = 0;
this.mUpgradeProgress = 0;
} else {
eZDeviceUpgradeStatus.setUpgradeStatus(0);
eZDeviceUpgradeStatus.setUpgradeProgress(this.mUpgradeProgress);
}
return eZDeviceUpgradeStatus;
}
public EZDeviceVersion getDeviceVersion(final String str) {
LogUtil.i(TAG, "Enter getDeviceVersion");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceSerial")
private String devSerial;
{
this.devSerial = str;
}
}, "/api/device/getVersionInfo", new ApiResponse() {
@Override
public Object parse(String str2) {
JSONObject jSONObject;
JSONObject optJSONObject;
if (!parseCode(str2) || (jSONObject = new JSONObject(str2).getJSONObject("result")) == null || (optJSONObject = jSONObject.optJSONObject("data")) == null) {
return null;
}
EZDeviceVersion eZDeviceVersion = new EZDeviceVersion();
ReflectionUtils.convJSONToObject(optJSONObject, eZDeviceVersion);
return eZDeviceVersion;
}
});
if (post == null || !(post instanceof EZDeviceVersion)) {
return null;
}
EZDeviceVersion eZDeviceVersion = (EZDeviceVersion) post;
LogUtil.i(TAG, "getDeviceVersion: " + eZDeviceVersion);
return eZDeviceVersion;
}
public EZAccessToken getEZAccessToken() {
EZAccessToken eZAccessToken = new EZAccessToken();
if (TextUtils.isEmpty(this.mLocalInfo.getEZAccesstoken().getAccessToken())) {
return null;
}
eZAccessToken.setAccessToken(this.mLocalInfo.getEZAccesstoken().getAccessToken());
eZAccessToken.setExpire(this.mLocalInfo.getEZAccesstoken().getExpire());
return eZAccessToken;
}
public EZDeviceInfo getEZBasicDeviceInfo(final String str) {
LogUtil.i(TAG, "Enter getEZBasicDeviceInfo");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceSerial")
private String mDeviceSerial;
{
this.mDeviceSerial = str;
}
}, "/api/device/getBasicDeviceInfo", new ApiResponse() {
@Override
public Object parse(String str2) {
JSONObject optJSONObject;
if (!parseCode(str2) || (optJSONObject = new JSONObject(str2).getJSONObject("result").optJSONObject("data")) == null) {
return null;
}
EZDeviceInfo eZDeviceInfo = new EZDeviceInfo();
ReflectionUtils.convJSONToObject(optJSONObject, eZDeviceInfo);
return eZDeviceInfo;
}
});
if (post == null) {
return null;
}
EZDeviceInfo eZDeviceInfo = (EZDeviceInfo) post;
LogUtil.i(TAG, "getEZBasicDeviceInfo: info:" + eZDeviceInfo);
return eZDeviceInfo;
}
public EZCameraInfo getEZCameraInfoNoTransfer(final String str) {
LogUtil.i(TAG, "Enter getEZCameraInfoNoTransfer");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceSerial")
private String mDeviceSerial;
{
this.mDeviceSerial = str;
}
}, "/api/device/getDeviceInfo", new ApiResponse() {
@Override
public Object parse(String str2) {
JSONArray optJSONArray;
if (!EzvizAPI.parserCode(str2) || (optJSONArray = new JSONObject(str2).getJSONObject("result").optJSONArray("data")) == null || optJSONArray.length() <= 0) {
return null;
}
JSONObject jSONObject = optJSONArray.getJSONObject(0);
EZCameraInfo eZCameraInfo = new EZCameraInfo();
ReflectionUtils.convJSONToObject(jSONObject, eZCameraInfo);
return eZCameraInfo;
}
});
if (post == null) {
return null;
}
EZCameraInfo eZCameraInfo = (EZCameraInfo) post;
LogUtil.i(TAG, " getEZCameraInfoNoTransfer:" + eZCameraInfo);
return eZCameraInfo;
}
public EZUserInfo getEZUserInfo() {
LogUtil.i(TAG, "Enter getEZUserInfo");
EZUserInfo eZUserInfo = (EZUserInfo) this.mRestfulUtils.post(new BaseInfo() {
}, "/api/user/getUserInfo", new ApiResponse() {
@Override
public Object parse(String str) {
JSONObject optJSONObject;
if (!parseCode(str) || (optJSONObject = new JSONObject(str).getJSONObject("result").optJSONObject("data")) == null) {
return null;
}
EZUserInfo eZUserInfo2 = new EZUserInfo();
ReflectionUtils.convJSONToObject(optJSONObject, eZUserInfo2);
return eZUserInfo2;
}
});
LogUtil.i(TAG, "getEZUserInfo:" + eZUserInfo);
return eZUserInfo;
}
public List<EZOpenToken> getEZopenTokenList(String str, int i) {
LogUtil.i(TAG, "Enter getErrorInfo");
ArrayList arrayList = new ArrayList();
arrayList.add(new NameValuePair("accessToken", str));
arrayList.add(new NameValuePair(DX_HttpConstants.DX_REQ_KEY_APPKEY, getInstance().getAppKey()));
arrayList.add(new NameValuePair("region", String.valueOf(i)));
Object postDataDirectUrl = this.mRestfulUtils.postDataDirectUrl(arrayList, "https://open.ys7.com/api/token/ezopen/get", new ApiResponse() {
@Override
public Object parse(String str2) {
if (!paserCodeHttpNoReport(str2)) {
return null;
}
JSONArray optJSONArray = new JSONObject(str2).optJSONArray("data");
ArrayList arrayList2 = new ArrayList();
if (optJSONArray != null && optJSONArray.length() > 0) {
int length = optJSONArray.length();
for (int i2 = 0; i2 < length; i2++) {
EZOpenToken eZOpenToken = new EZOpenToken();
JSONObject optJSONObject = optJSONArray.optJSONObject(i2);
if (optJSONObject != null) {
ReflectionUtils.convJSONToObject(optJSONObject, eZOpenToken);
arrayList2.add(eZOpenToken);
}
}
}
return arrayList2;
}
});
if (postDataDirectUrl != null) {
return (List) postDataDirectUrl;
}
return null;
}
public EZOpenSDKErrorInfo getErrorInfo(final String str) {
LogUtil.i(TAG, "Enter getErrorInfo");
Object postNoRefreshTokenNoReportError = this.mRestfulUtils.postNoRefreshTokenNoReportError(new BaseInfo() {
@HttpParam(name = "detailCode")
private String detailCode;
{
this.detailCode = str;
}
}, "/api/sdk/error/report", new ApiResponse() {
@Override
public Object parse(String str2) {
JSONObject optJSONObject;
if (!paserCodeHttpNoReport(str2) || (optJSONObject = new JSONObject(str2).optJSONObject("data")) == null) {
return null;
}
EZOpenSDKErrorInfo eZOpenSDKErrorInfo = new EZOpenSDKErrorInfo();
ReflectionUtils.convJSONToObject(optJSONObject, eZOpenSDKErrorInfo);
return eZOpenSDKErrorInfo;
}
});
if (postNoRefreshTokenNoReportError != null) {
return (EZOpenSDKErrorInfo) postNoRefreshTokenNoReportError;
}
return null;
}
public List<EZOpenSDKErrorInfo> getErrorList(final String str) {
LogUtil.i(TAG, "Enter getErrorList");
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "time")
private String time;
{
this.time = str;
}
}, "/api/sdk/error/list", new ApiResponse() {
@Override
public Object parse(String str2) {
if (!parseCodeHttp(str2)) {
return null;
}
JSONArray optJSONArray = new JSONObject(str2).optJSONArray("data");
ArrayList arrayList = new ArrayList();
if (optJSONArray != null && optJSONArray.length() > 0) {
int length = optJSONArray.length();
for (int i = 0; i < length; i++) {
EZOpenSDKErrorInfo eZOpenSDKErrorInfo = new EZOpenSDKErrorInfo();
ReflectionUtils.convJSONToObject(optJSONArray.optJSONObject(i), eZOpenSDKErrorInfo);
arrayList.add(eZOpenSDKErrorInfo);
}
}
return arrayList;
}
});
if (post != null) {
return (List) post;
}
return null;
}
public String getHTTPPublicParam(String str) {
if (TextUtils.equals(str, DX_HttpConstants.DX_REQ_KEY_CLIENT_TYPE)) {
return "13";
}
if (TextUtils.equals(str, "featureCode")) {
return LocalInfo.getInstance().getHardwareCode();
}
if (TextUtils.equals(str, "osVersion")) {
return Build.VERSION.RELEASE;
}
if (TextUtils.equals(str, "netType")) {
return getInstance().getNetType();
}
if (TextUtils.equals(str, "sdkVersion")) {
return Config.VERSION;
}
if (TextUtils.equals(str, DX_HttpConstants.DX_REQ_KEY_APPKEY)) {
return getInstance().getAppKey();
}
if (TextUtils.equals(str, "appID")) {
return LocalInfo.getInstance().getPackageName();
}
if (TextUtils.equals(str, "appName")) {
return LocalInfo.getInstance().getAppName();
}
return null;
}
public Map<String, String> getHTTPPublicParam() {
HashMap hashMap = new HashMap();
hashMap.put(DX_HttpConstants.DX_REQ_KEY_CLIENT_TYPE, "13");
hashMap.put("featureCode", LocalInfo.getInstance().getHardwareCode());
hashMap.put("osVersion", Build.VERSION.RELEASE);
hashMap.put("netType", getInstance().getNetType());
hashMap.put("sdkVersion", Config.VERSION);
hashMap.put(DX_HttpConstants.DX_REQ_KEY_APPKEY, getInstance().getAppKey());
hashMap.put("appID", LocalInfo.getInstance().getPackageName());
hashMap.put("appName", LocalInfo.getInstance().getAppName());
return hashMap;
}
public void getLeaveMessageData(Handler handler, EZLeaveMessage eZLeaveMessage, EZOpenSDKListener.EZLeaveMessageFlowCallback eZLeaveMessageFlowCallback) {
EZStreamDownload eZStreamDownload = new EZStreamDownload();
eZStreamDownload.setHandler(handler);
eZStreamDownload.setLeaveMessageFlowCallback(eZLeaveMessageFlowCallback);
eZStreamDownload.start(eZLeaveMessage);
}
public List<EZLeaveMessage> getLeaveMessageList(String str, final int i, final int i2, Calendar calendar, Calendar calendar2) {
LogUtil.i(TAG, "Enter getLeaveMessageList");
if (str == null) {
str = "";
}
final String str2 = str;
if (i < 0 || i2 <= 0) {
LogUtil.i(TAG, "getLeaveMessageList, invalid parameters page");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
if (calendar == null || calendar2 == null) {
LogUtil.i(TAG, "getLeaveMessageList, invalid parameters, begin or end time is null");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400001));
}
if (calendar.after(calendar2)) {
LogUtil.i(TAG, "getLeaveMessageList, invalid parameters, begin after end time");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DateTimeUtil.TIME_FORMAT);
final String format = simpleDateFormat.format(calendar.getTime());
final String format2 = simpleDateFormat.format(calendar2.getTime());
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = DX_HttpConstants.DX_REQ_KEY_START_TIME)
private String mBeginTime;
@HttpParam(name = "deviceSerial")
private String mDeviceSerial;
@HttpParam(name = "endTime")
private String mEndTime;
@HttpParam(name = "pageStart")
private int mPageIndex;
@HttpParam(name = "pageSize")
private int mPageSize;
@HttpParam(name = "status")
private int mStatus = 0;
@HttpParam(name = "contentType")
private int mContentType = 1;
{
this.mDeviceSerial = str2;
this.mPageIndex = i;
this.mPageSize = i2;
this.mBeginTime = format;
this.mEndTime = format2;
}
}, "/api/message/leaves/get", new ApiResponse() {
@Override
public Object parse(String str3) {
JSONArray optJSONArray;
Date date;
ParseException e;
Date date2;
if (!parseCode(str3) || (optJSONArray = new JSONObject(str3).getJSONObject("result").optJSONArray("data")) == null || optJSONArray.length() <= 0) {
return null;
}
ArrayList arrayList = new ArrayList();
int length = optJSONArray.length();
SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat(DateTimeUtil.TIME_FORMAT);
for (int i3 = 0; i3 < length; i3++) {
JSONObject jSONObject = optJSONArray.getJSONObject(i3);
if (jSONObject != null) {
EZLeaveMessage eZLeaveMessage = new EZLeaveMessage();
ReflectionUtils.convJSONToObject(jSONObject, eZLeaveMessage);
Date date3 = new Date();
Date date4 = new Date();
try {
date = simpleDateFormat2.parse(eZLeaveMessage.getInternalCreateTime());
try {
date2 = simpleDateFormat2.parse(eZLeaveMessage.getInternalUpdateTime());
} catch (ParseException e2) {
e = e2;
LogUtil.printErrStackTrace(EzvizAPI.TAG, e.fillInStackTrace());
date2 = date4;
Calendar calendar3 = Calendar.getInstance();
calendar3.setTime(date);
Calendar calendar4 = Calendar.getInstance();
calendar4.setTime(date2);
eZLeaveMessage.setCreateTime(calendar3);
eZLeaveMessage.setUpdateTime(calendar4);
LogUtil.verboseLog(EzvizAPI.TAG, eZLeaveMessage.toString());
arrayList.add(eZLeaveMessage);
}
} catch (ParseException e3) {
date = date3;
e = e3;
}
Calendar calendar32 = Calendar.getInstance();
calendar32.setTime(date);
Calendar calendar42 = Calendar.getInstance();
calendar42.setTime(date2);
eZLeaveMessage.setCreateTime(calendar32);
eZLeaveMessage.setUpdateTime(calendar42);
LogUtil.verboseLog(EzvizAPI.TAG, eZLeaveMessage.toString());
arrayList.add(eZLeaveMessage);
}
}
return arrayList;
}
});
if (post == null) {
return null;
}
StringBuilder sb = new StringBuilder();
List<EZLeaveMessage> list = (List) post;
sb.append(list);
LogUtil.i(TAG, sb.toString());
return list;
}
public String getNetType() {
return this.mNetType;
}
public boolean getOpenEzvizServiceSMSCode(final String str) {
LogUtil.i(TAG, "Enter getOpenEzvizServiceSMSCode");
int localValidateMobileNumber = this.mLocalValidate.localValidateMobileNumber(str);
if (localValidateMobileNumber == 0) {
return ((Boolean) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "phone")
private String phoneNum;
{
this.phoneNum = str;
}
}, "/api/description/openYSService/smsCode", new ApiResponse() {
@Override
public Object parse(String str2) {
return Boolean.valueOf(parseCode(str2));
}
})).booleanValue();
}
LogUtil.i(TAG, "getOpenEzvizServiceSMSCode, invalid parameters");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidateMobileNumber));
}
public String getOpenWebUrl() {
return this.mWebUrl;
}
public String getOriginalServAddr() {
return this.mLocalInfo.getOriginalServAddr();
}
public boolean getRegistSmsCode(final String str, final String str2) {
Boolean bool = (Boolean) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "phone")
private String phone;
@HttpParam(name = "userName")
private String userName;
{
this.phone = str;
this.userName = str2;
}
}, "/api/description/smsCode/regist", new ApiResponse() {
@Override
public Object parse(String str3) {
return Boolean.valueOf(parseCode(str3));
}
});
if (bool != null) {
return bool.booleanValue();
}
return false;
}
public EZServerInfo getServerInfo() {
return (EZServerInfo) this.mRestfulUtils.postData(new GetServersInfoReq().buidParams(new BaseInfo()), GetServersInfoReq.URL, new GetServersInfoResp());
}
public String getServerUrl() {
return this.mLocalInfo.getServAddr();
}
public List<EZHiddnsDeviceInfo> getShareDDNSDeviceList(final int i, final int i2) {
LogUtil.i(TAG, "Enter getShareDDNSDeviceList");
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "pageSize")
private int pagesize;
@HttpParam(name = "pageStart")
private int pagestart;
{
this.pagesize = i;
this.pagestart = i2;
}
}, "/api/lapp/ddns/share/list", new ApiResponse() {
@Override
public List<EZHiddnsDeviceInfo> parse(String str) {
boolean parseCodeHttp = parseCodeHttp(str);
if (!parseCodeHttp || !parseCodeHttp) {
return null;
}
JSONArray optJSONArray = new JSONObject(str).optJSONArray("data");
ArrayList arrayList = new ArrayList();
if (optJSONArray != null && optJSONArray.length() > 0) {
int length = optJSONArray.length();
for (int i3 = 0; i3 < length; i3++) {
EZHiddnsDeviceInfo eZHiddnsDeviceInfo = new EZHiddnsDeviceInfo();
ReflectionUtils.convJSONToObject(optJSONArray.optJSONObject(i3), eZHiddnsDeviceInfo);
arrayList.add(eZHiddnsDeviceInfo);
}
}
return arrayList;
}
});
if (post != null) {
return (List) post;
}
return null;
}
public List<EZDeviceInfo> getSharedDeviceList(final int i, final int i2) {
LogUtil.i(TAG, "Enter getSharedDeviceList: ");
if (i < 0 || i2 <= 0) {
LogUtil.i(TAG, "getSharedDeviceList: invalid parameters");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
if (i == 0) {
DeviceManager.getInstance().clearDevice();
CameraManager.getInstance().clearCamera();
}
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "pageSize")
private int mPageSize;
@HttpParam(name = "pageStart")
private int mPageStart;
@HttpParam(name = "version")
private String mVersion = SocializeConstants.PROTOCOL_VERSON;
{
this.mPageSize = i2;
this.mPageStart = i;
}
}, "/api/device/sharelist", new ApiResponse() {
@Override
public Object parse(String str) {
if (!parseCode(str)) {
return null;
}
JSONArray optJSONArray = new JSONObject(str).getJSONObject("result").optJSONArray("data");
ArrayList arrayList = new ArrayList();
if (optJSONArray != null) {
int length = optJSONArray.length();
for (int i3 = 0; i3 < length; i3++) {
EZDeviceInfo eZDeviceInfo = new EZDeviceInfo();
JSONObject jSONObject = optJSONArray.getJSONObject(i3);
ReflectionUtils.convJSONToObject(jSONObject, eZDeviceInfo);
JSONArray optJSONArray2 = jSONObject.optJSONArray(GetCameraInfoResp.CAMERAINFO);
if (optJSONArray2 != null && optJSONArray2.length() > 0) {
ArrayList arrayList2 = new ArrayList();
int length2 = optJSONArray2.length();
for (int i4 = 0; i4 < length2; i4++) {
EZCameraInfo eZCameraInfo = new EZCameraInfo();
JSONObject jSONObject2 = optJSONArray2.getJSONObject(i4);
ReflectionUtils.convJSONToObject(jSONObject2, eZCameraInfo);
JSONArray optJSONArray3 = jSONObject2.optJSONArray("videoQualityInfos");
if (optJSONArray3 != null && optJSONArray3.length() > 0) {
ArrayList<EZVideoQualityInfo> arrayList3 = new ArrayList<>();
int length3 = optJSONArray3.length();
for (int i5 = 0; i5 < length3; i5++) {
EZVideoQualityInfo eZVideoQualityInfo = new EZVideoQualityInfo();
ReflectionUtils.convJSONToObject(optJSONArray3.getJSONObject(i5), eZVideoQualityInfo);
arrayList3.add(eZVideoQualityInfo);
}
eZCameraInfo.setVideoQualityInfos(arrayList3);
}
arrayList2.add(eZCameraInfo);
}
if (arrayList2.size() > 0) {
eZDeviceInfo.setCameraInfoList(arrayList2);
}
}
arrayList.add(eZDeviceInfo);
}
}
return arrayList;
}
});
if (post == null) {
return null;
}
List<EZDeviceInfo> list = (List) post;
Iterator<EZDeviceInfo> it = list.iterator();
while (it.hasNext()) {
LogUtil.d(TAG, "getDeviceList: " + it.next());
}
return list;
}
public boolean getSingleDeviceInfoByTransfer(String str) {
new EZCameraInfo();
C1EZGetCameraInfoBySerialReq c1EZGetCameraInfoBySerialReq = new C1EZGetCameraInfoBySerialReq();
C1EZGetCameraInfoBySerialReq.Params params = c1EZGetCameraInfoBySerialReq.params;
params.deviceSerial = str;
params.accessToken = this.mLocalInfo.getEZAccesstoken().getAccessToken();
String transferAPI = transferAPI(ReflectionUtils.convObjectToJSON(c1EZGetCameraInfoBySerialReq).toString());
LogUtil.d(TAG, transferAPI);
try {
return parserCode(transferAPI);
} catch (JSONException e) {
LogUtil.printErrStackTrace(TAG, e.fillInStackTrace());
return false;
}
}
public boolean getSmsCode(int i, String str) {
GetSmsCodeInfo getSmsCodeInfo = new GetSmsCodeInfo();
getSmsCodeInfo.setType(i);
getSmsCodeInfo.setSign(str);
Boolean bool = (Boolean) this.mRestfulUtils.postData(new GetSmsCodeReq().buidParams(getSmsCodeInfo), GetSmsCodeReq.URL, new GetSmsCodeResp());
if (bool != null) {
return bool.booleanValue();
}
return false;
}
public boolean getSmsCode(EZConstants.EZSMSType eZSMSType) {
GetSecureSmcCodeReq getSecureSmcCodeReq = new GetSecureSmcCodeReq();
getSecureSmcCodeReq.params.accessToken = LocalInfo.getInstance().getEZAccesstoken().getAccessToken();
return parserTransferApiCode(getInstance().transferAPI(ReflectionUtils.convObjectToJSON(getSecureSmcCodeReq).toString()));
}
public boolean getSmsCodeNonTransfer(final EZConstants.EZSMSType eZSMSType) {
LogUtil.i(TAG, "Enter getSmsCodeNotTransfer");
return ((Boolean) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "type")
private int mType;
{
this.mType = eZSMSType.getSmsType();
}
}, "/api/description/smsCode/get", new ApiResponse() {
@Override
public Object parse(String str) {
return Boolean.valueOf(parseCode(str));
}
})).booleanValue();
}
public boolean getSmsCodeReset(String str) {
GetSmsCodeInfo getSmsCodeInfo = new GetSmsCodeInfo();
getSmsCodeInfo.setPhone(str);
Boolean bool = (Boolean) this.mRestfulUtils.postData(new GetSmsCodeResetReq().buidParams(getSmsCodeInfo), GetSmsCodeResetReq.URL, new GetSmsCodeResetResp());
if (bool != null) {
return bool.booleanValue();
}
return false;
}
public String getSnapshotPath(String str) {
return LocalInfo.getInstance().getFilePath() + "/CameraSnapshot/" + str;
}
public List<EZStorageStatus> getStorageStatus(final String str) {
LogUtil.i(TAG, "Enter getStorageStatus");
this.stub_storage_call_times++;
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceSerial")
private String mDeviceSerial;
{
this.mDeviceSerial = str;
}
}, "/api/device/format/status", new ApiResponse() {
@Override
public Object parse(String str2) {
JSONObject optJSONObject;
ArrayList arrayList = null;
if (parseCode(str2) && (optJSONObject = new JSONObject(str2).optJSONObject("result").optJSONObject("data")) != null) {
JSONArray optJSONArray = optJSONObject.optJSONArray("storageStatus");
if (optJSONArray == null) {
return null;
}
int length = optJSONArray.length();
if (length > 0) {
arrayList = new ArrayList();
for (int i = 0; i < length; i++) {
JSONObject jSONObject = optJSONArray.getJSONObject(i);
EZStorageStatus eZStorageStatus = new EZStorageStatus();
eZStorageStatus.setIndex(jSONObject.optInt("index"));
eZStorageStatus.setName(jSONObject.optString(DBTable.TABLE_OPEN_VERSON.COLUMN_name));
int optInt = jSONObject.optInt("status");
int optInt2 = jSONObject.optInt("formattingRate");
eZStorageStatus.setStatus(optInt);
if (optInt == 3) {
eZStorageStatus.setFormatRate(optInt2);
}
arrayList.add(eZStorageStatus);
}
}
}
return arrayList;
}
});
if (post == null) {
return null;
}
List<EZStorageStatus> list = (List) post;
LogUtil.i(TAG, "getStorageStatus:" + list);
return list;
}
public StreamServerData getStreamServer(int i) {
GetStreamServer getStreamServer = new GetStreamServer();
if (i == -1) {
i = 0;
}
getStreamServer.setISPType(i);
return (StreamServerData) this.mRestfulUtils.postData(new GetCloudInfoReq().buidParams(getStreamServer), GetCloudInfoReq.URL, new GetCloudInfoResp());
}
public List<String> getStreamTokenList() {
BatchGetTokens batchGetTokens = new BatchGetTokens();
batchGetTokens.setCount(100);
return (List) this.mRestfulUtils.postData(new BatchGetTokensReq().buidParams(batchGetTokens), BatchGetTokensReq.URL, new BatchGetTokensResp());
}
public String getTerminalId() {
String md5Crypto = !TextUtils.isEmpty(LocalInfo.getInstance().getHardwareCode()) ? MD5Util.md5Crypto(LocalInfo.getInstance().getHardwareCode()) : null;
if (!TextUtils.isEmpty(md5Crypto)) {
md5Crypto = MD5Util.md5Crypto(md5Crypto);
}
if (!TextUtils.isEmpty(md5Crypto)) {
LogUtil.d(TAG, "getTerminalId: ".concat(String.valueOf(md5Crypto)));
}
return md5Crypto;
}
public String getThridToken() {
return this.mThridToken;
}
public String getTicket(String str, String str2, String str3) {
String str4;
EZPrivateTicketRequest eZPrivateTicketRequest = new EZPrivateTicketRequest();
eZPrivateTicketRequest.setAppKey(this.mAppKey);
eZPrivateTicketRequest.setClientId(str);
eZPrivateTicketRequest.setClientType("1");
eZPrivateTicketRequest.setSessionId(this.mLocalInfo.getEZAccesstoken().getAccessToken());
eZPrivateTicketRequest.setUsername(str2);
if (TextUtils.isEmpty(str3)) {
str3 = this.mAppPushSecret;
}
eZPrivateTicketRequest.setToken(str3);
if (TextUtils.isEmpty(LocalInfo.getInstance().getPushAddr())) {
str4 = "https://push.ys7.com/api/push/start";
} else {
str4 = LocalInfo.getInstance().getPushAddr() + "/api/push/start";
}
Object postDataDirectUrl = this.mRestfulUtils.postDataDirectUrl(eZPrivateTicketRequest.getNVPairList(), str4, new ApiResponse() {
@Override
public Object parse(String str5) {
try {
JSONObject jSONObject = new JSONObject(str5);
if (jSONObject.optInt("status") == 200) {
return jSONObject.optString("ticket");
}
ErrorInfo errorLayer = ErrorLayer.getErrorLayer(2, ErrorCode.ERROR_INNER_WEBRESPONSE_JSONERROR);
LogUtil.e(EzvizAPI.TAG, "JSON解析错误");
throw new BaseException("JSON解析错误", errorLayer);
} catch (JSONException e) {
ErrorInfo errorLayer2 = ErrorLayer.getErrorLayer(2, ErrorCode.ERROR_INNER_WEBRESPONSE_JSONERROR);
LogUtil.printErrStackTrace(EzvizAPI.TAG, e.fillInStackTrace());
throw new BaseException("JSON解析错误", errorLayer2);
}
}
});
if (postDataDirectUrl != null) {
return (String) postDataDirectUrl;
}
return null;
}
public EZTransferMessageInfo getTransferMessageInfo(final String str) {
LogUtil.i(TAG, "Enter getPushTransferMessage: ");
if (TextUtils.isEmpty(str)) {
LogUtil.i(TAG, "getPushTransferMessage: msgId is null");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400001));
}
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "msgSeq")
private String msgSeq;
{
this.msgSeq = str;
}
}, "/api/common/transparent/getMsgDetail", new ApiResponse() {
@Override
public Object parse(String str2) {
JSONObject optJSONObject;
if (!parseCode(str2) || (optJSONObject = new JSONObject(str2).getJSONObject("result").optJSONObject("msgData")) == null) {
return null;
}
EZTransferMessageInfo eZTransferMessageInfo = new EZTransferMessageInfo();
ReflectionUtils.convJSONToObject(optJSONObject, eZTransferMessageInfo);
return eZTransferMessageInfo;
}
});
if (post == null) {
return null;
}
EZTransferMessageInfo eZTransferMessageInfo = (EZTransferMessageInfo) post;
LogUtil.d(TAG, "getPushNoticeMessage: " + eZTransferMessageInfo);
return eZTransferMessageInfo;
}
public List<EZDeviceInfo> getTrustDeviceList(final int i, final int i2) {
LogUtil.i(TAG, "Enter getDeviceList: ");
if (i < 0 || i2 <= 0) {
LogUtil.i(TAG, "getDeviceList: invalid parameters");
ErrorLayer.getErrorLayer(2, 400002);
throw new BaseSdkRuntimeException(STR_NATIVE_PARAM_ERROR);
}
try {
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "pageSize")
private int pageSize;
@HttpParam(name = "pageStart")
private int pageStart;
@HttpParam(name = "version")
private String version = SocializeConstants.PROTOCOL_VERSON;
{
this.pageSize = i2;
this.pageStart = i;
}
}, "/api/lapp/trust/device/list", new ApiResponse() {
@Override
public Object parse(String str) {
JSONArray jSONArray;
JSONArray jSONArray2;
if (!parseCode(str)) {
return null;
}
JSONArray optJSONArray = new JSONObject(str).getJSONObject("result").optJSONArray("data");
ArrayList arrayList = new ArrayList();
if (optJSONArray != null) {
int length = optJSONArray.length();
int i3 = 0;
while (i3 < length) {
EZDeviceInfo eZDeviceInfo = new EZDeviceInfo();
JSONObject jSONObject = optJSONArray.getJSONObject(i3);
ReflectionUtils.convJSONToObject(jSONObject, eZDeviceInfo);
JSONArray optJSONArray2 = jSONObject.optJSONArray(GetCameraInfoResp.CAMERAINFO);
if (optJSONArray2 == null || optJSONArray2.length() <= 0) {
jSONArray = optJSONArray;
} else {
ArrayList arrayList2 = new ArrayList();
int length2 = optJSONArray2.length();
int i4 = 0;
while (i4 < length2) {
EZCameraInfo eZCameraInfo = new EZCameraInfo();
JSONObject jSONObject2 = optJSONArray2.getJSONObject(i4);
ReflectionUtils.convJSONToObject(jSONObject2, eZCameraInfo);
JSONArray optJSONArray3 = jSONObject2.optJSONArray("videoQualityInfos");
if (optJSONArray3 == null || optJSONArray3.length() <= 0) {
jSONArray2 = optJSONArray;
} else {
ArrayList<EZVideoQualityInfo> arrayList3 = new ArrayList<>();
int length3 = optJSONArray3.length();
int i5 = 0;
while (i5 < length3) {
EZVideoQualityInfo eZVideoQualityInfo = new EZVideoQualityInfo();
ReflectionUtils.convJSONToObject(optJSONArray3.getJSONObject(i5), eZVideoQualityInfo);
arrayList3.add(eZVideoQualityInfo);
i5++;
optJSONArray = optJSONArray;
}
jSONArray2 = optJSONArray;
eZCameraInfo.setVideoQualityInfos(arrayList3);
}
arrayList2.add(eZCameraInfo);
i4++;
optJSONArray = jSONArray2;
}
jSONArray = optJSONArray;
if (arrayList2.size() > 0) {
eZDeviceInfo.setCameraInfoList(arrayList2);
}
}
JSONArray optJSONArray4 = jSONObject.optJSONArray("detectorInfo");
if (optJSONArray4 != null && optJSONArray4.length() > 0) {
ArrayList arrayList4 = new ArrayList();
int length4 = optJSONArray4.length();
for (int i6 = 0; i6 < length4; i6++) {
EZDetectorInfo eZDetectorInfo = new EZDetectorInfo();
ReflectionUtils.convJSONToObject(optJSONArray4.getJSONObject(i6), eZDetectorInfo);
arrayList4.add(eZDetectorInfo);
}
if (arrayList4.size() > 0) {
eZDeviceInfo.setDetectorInfoList(arrayList4);
}
}
arrayList.add(eZDeviceInfo);
i3++;
optJSONArray = jSONArray;
}
}
return arrayList;
}
});
if (post == null) {
return null;
}
List<EZDeviceInfo> list = (List) post;
Iterator<EZDeviceInfo> it = list.iterator();
while (it.hasNext()) {
LogUtil.d(TAG, "getDeviceList: " + new Gson().toJson(it.next()));
}
return list;
} catch (BaseException e) {
throw e;
}
}
public int getUnreadMessageCount(final String str, final EZConstants.EZMessageType eZMessageType) {
LogUtil.i(TAG, "Enter getUnreadMessageCount");
if (str == null) {
str = "";
}
int intValue = ((Integer) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceSerial")
private String mSerial;
@HttpParam(name = "type")
private int mType;
{
this.mSerial = str;
this.mType = eZMessageType.getMessageType();
}
}, "/api/message/unreadCount", new ApiResponse() {
@Override
public Object parse(String str2) {
JSONObject optJSONObject;
return Integer.valueOf((!parseCode(str2) || (optJSONObject = new JSONObject(str2).getJSONObject("result").optJSONObject("data")) == null) ? -1 : optJSONObject.optInt("unreadCount", 0));
}
})).intValue();
LogUtil.i(TAG, "getUnreadMessageCount returns. count:" + intValue);
return intValue;
}
public int getUnreadMsgCount(int i) {
return 0;
}
public String getUserCode() {
return this.mLocalInfo.getUserCode();
}
public EZUserInfo getUserInfoNewApi() {
return null;
}
public String getUserName() {
String str = (String) this.mRestfulUtils.postData(new GetUserNameReq().buidParams(new BaseInfo()), GetUserNameReq.URL, new GetUserNameResp());
this.mLocalInfo.setUserName(str);
return str;
}
public int getUserType() {
return 0;
}
public String getVtduToken() {
long j = this.mBatchTokensTime;
if (j > 0 && Math.abs(j - System.currentTimeMillis()) > 86400000) {
clearVtduTokens();
return null;
}
List<String> list = this.mTokenList;
if (list == null || list.size() <= 0) {
return null;
}
return this.mTokenList.remove(0);
}
public void gotoLoginPage(int i) {
gotoLoginPage(true, this.mAreaId, i);
}
public void gotoLoginPage(boolean z, int i, int i2) {
LogUtil.i(TAG, "Enter gotoLoginPage: ");
this.mAreaId = i;
if (z) {
setAccessToken("");
new Thread() {
@Override
public void run() {
EzvizAPI.this.logout();
}
}.start();
}
Intent intent = new Intent(mApplication, (Class<?>) EzvizWebViewActivity.class);
if (i2 < 0) {
i2 = 268435456;
}
intent.setFlags(i2);
intent.putExtra(IntentConsts.EXTRA_WEBVIEW_PARAM, i);
intent.putExtra(IntentConsts.EXTRA_WEBVIEW_ACTION, 0);
mApplication.startActivity(intent);
}
public boolean isAppMainProcess() {
try {
String appNameByPID = getAppNameByPID(mApplication, Process.myPid());
if (TextUtils.isEmpty(appNameByPID)) {
return true;
}
return mApplication.getPackageName().equalsIgnoreCase(appNameByPID);
} catch (Exception e) {
e.printStackTrace();
return true;
}
}
public boolean isLogin() {
if (TextUtils.isEmpty(LocalInfo.getInstance().getEZAccesstoken().getAccessToken())) {
return false;
}
return (platformType == EZConstants.EZPlatformType.EZPlatformTypeGLOBALSDK && TextUtils.isEmpty(LocalInfo.getInstance().getEZAccesstoken().getAreaDomain())) ? false : true;
}
public void logout() {
LogUtil.i(TAG, "Enter logout: ");
try {
logoutAccount();
} catch (BaseException unused) {
}
setAccessToken("");
}
public boolean logoutAccount() {
Boolean bool = (Boolean) this.mRestfulUtils.post(new BaseInfo(), LogoutResp.URL, new LogoutResp());
if (bool != null) {
return bool.booleanValue();
}
return false;
}
public void openChangePasswordPage() {
LogUtil.i(TAG, "Enter openChangePasswordPage");
Intent intent = new Intent(mApplication, (Class<?>) EzvizWebViewActivity.class);
intent.setFlags(268435456);
intent.putExtra(IntentConsts.EXTRA_WEBVIEW_ACTION, 4);
mApplication.startActivity(intent);
}
public void openCloudPage(String str, int i) {
LogUtil.i(TAG, "Enter openCloudPage");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
Intent intent = new Intent(mApplication, (Class<?>) EzvizWebViewActivity.class);
intent.setFlags(268435456);
intent.putExtra(IntentConsts.EXTRA_WEBVIEW_ACTION, 3);
intent.putExtra(EzvizWebViewActivity.EXTRA_DEVICE_SERIAL, str);
intent.putExtra("channel", i);
mApplication.startActivity(intent);
}
public boolean openEzvizService(final String str, final String str2) {
LogUtil.i(TAG, "Enter openEzvizService");
int localValidateMobileNumber = this.mLocalValidate.localValidateMobileNumber(str);
if (localValidateMobileNumber != 0) {
LogUtil.i(TAG, "openEzvizService, invalid parameters");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidateMobileNumber));
}
int localValidateSmsCode = this.mLocalValidate.localValidateSmsCode(str2);
if (localValidateSmsCode == 0) {
return ((Boolean) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "phone")
private String mPhoneNumber;
@HttpParam(name = "smsCode")
private String mSmsCode;
{
this.mPhoneNumber = str;
this.mSmsCode = str2;
}
}, "/api/user/openYSService", new ApiResponse() {
@Override
public Object parse(String str3) {
return Boolean.valueOf(parseCode(str3));
}
})).booleanValue();
}
LogUtil.i(TAG, "getOpenEzvizServiceSMSCode, invalid parameters");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidateSmsCode));
}
public EZPushBaseMessage parsePushMessage(String str) {
int i;
String str2;
String str3;
if (TextUtils.isEmpty(str)) {
str2 = TAG;
str3 = "parsePushMessage: messageStr string is null";
} else {
LogUtil.d(TAG, "parsePushMessage: messageStr = ".concat(String.valueOf(str)));
String[] split = str.split(",", -1);
if (split.length > 1) {
try {
i = Integer.parseInt(split[0]);
} catch (NumberFormatException e) {
LogUtil.printErrStackTrace(TAG, e.fillInStackTrace());
i = -1;
}
if (i == -1) {
return null;
}
if (i == 1) {
if (split.length < 7) {
return null;
}
return parsePushAlarmMessage(str);
}
if (i != 99 || split.length < 7) {
return null;
}
return parsePushTransferMessage(str);
}
str2 = TAG;
str3 = "parsePushMessage: invalid string format";
}
LogUtil.d(str2, str3);
return null;
}
public EZProbeDeviceInfo probeDeviceInfo(final String str) {
LogUtil.i(TAG, "Enter probeDeviceInfo");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceSerial")
private String mDeviceSerial;
{
this.mDeviceSerial = str;
}
}, "/api/device/searchDeviceInfo", new ApiResponse() {
@Override
public Object parse(String str2) {
JSONObject optJSONObject;
if (!parseCode(str2) || (optJSONObject = new JSONObject(str2).getJSONObject("result").optJSONObject("data")) == null) {
return null;
}
EZProbeDeviceInfo eZProbeDeviceInfo = new EZProbeDeviceInfo();
ReflectionUtils.convJSONToObject(optJSONObject, eZProbeDeviceInfo);
return eZProbeDeviceInfo;
}
});
if (post == null) {
return null;
}
EZProbeDeviceInfo eZProbeDeviceInfo = (EZProbeDeviceInfo) post;
LogUtil.i(TAG, eZProbeDeviceInfo.toString());
return eZProbeDeviceInfo;
}
public EZProbeDeviceInfoResult probeDeviceInfo(final String str, final String str2) {
LogUtil.i(TAG, "Enter probeDeviceInfo");
EZProbeDeviceInfoResult eZProbeDeviceInfoResult = new EZProbeDeviceInfoResult();
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
ErrorInfo errorLayer = ErrorLayer.getErrorLayer(2, localValidatDeviceSerial);
eZProbeDeviceInfoResult.setEZProbeDeviceInfo(null);
eZProbeDeviceInfoResult.setBaseException(new BaseException(STR_NATIVE_PARAM_ERROR, errorLayer));
return eZProbeDeviceInfoResult;
}
if (TextUtils.isEmpty(str2)) {
str2 = "";
}
try {
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceSerial")
private String mDeviceSerial;
@HttpParam(name = "model")
private String model;
{
this.mDeviceSerial = str;
this.model = str2;
}
}, "/api/device/searchDeviceInfo", new ApiResponse() {
@Override
public Object parse(String str3) {
BaseException baseException;
EZProbeDeviceInfoResult eZProbeDeviceInfoResult2 = new EZProbeDeviceInfoResult();
if (str3 == null) {
ErrorInfo errorLayer2 = ErrorLayer.getErrorLayer(2, ErrorCode.ERROR_INNER_WEBRESPONSE_JSONERROR);
eZProbeDeviceInfoResult2.setEZProbeDeviceInfo(null);
baseException = new BaseException(BaseResponse.NETWORK_EXCEPTION_ERROR_MSG, errorLayer2.errorCode, errorLayer2);
} else {
try {
JSONObject jSONObject = new JSONObject(new JSONObject(str3).optString("result"));
int optInt = jSONObject.optInt("code");
String optString = jSONObject.optString("description");
if (optInt == 200) {
JSONObject optJSONObject = jSONObject.optJSONObject("data");
if (optJSONObject != null) {
eZProbeDeviceInfoResult2.setEZProbeDeviceInfo((EZProbeDeviceInfo) JsonUtils.fromJson(optJSONObject.toString(), EZProbeDeviceInfo.class));
eZProbeDeviceInfoResult2.setBaseException(null);
return eZProbeDeviceInfoResult2;
}
ErrorInfo errorLayer3 = ErrorLayer.getErrorLayer(2, ErrorCode.ERROR_INNER_WEBRESPONSE_JSONERROR);
eZProbeDeviceInfoResult2.setEZProbeDeviceInfo(null);
eZProbeDeviceInfoResult2.setBaseException(new BaseException(BaseResponse.NETWORK_EXCEPTION_ERROR_MSG, errorLayer3.errorCode, errorLayer3));
return eZProbeDeviceInfoResult2;
}
if (optInt == 400030) {
ErrorInfo errorLayer4 = ErrorLayer.getErrorLayer(2, ErrorCode.ERROR_INNER_WEBRESPONSE_JSONERROR);
eZProbeDeviceInfoResult2.setEZProbeDeviceInfo(null);
eZProbeDeviceInfoResult2.setBaseException(new BaseException(BaseResponse.NETWORK_EXCEPTION_ERROR_MSG, errorLayer4.errorCode, errorLayer4));
return eZProbeDeviceInfoResult2;
}
ErrorInfo errorLayer5 = ErrorLayer.getErrorLayer(1, optInt);
if (TextUtils.isEmpty(errorLayer5.description)) {
errorLayer5.description = optString;
}
eZProbeDeviceInfoResult2.setBaseException(new BaseException(optString, errorLayer5.errorCode, errorLayer5));
JSONObject optJSONObject2 = jSONObject.optJSONObject("data");
if (optJSONObject2 != null) {
eZProbeDeviceInfoResult2.setEZProbeDeviceInfo((EZProbeDeviceInfo) JsonUtils.fromJson(optJSONObject2.toString(), EZProbeDeviceInfo.class));
}
return eZProbeDeviceInfoResult2;
} catch (JSONException e) {
e.printStackTrace();
ErrorInfo errorLayer6 = ErrorLayer.getErrorLayer(2, ErrorCode.ERROR_INNER_WEBRESPONSE_JSONERROR);
eZProbeDeviceInfoResult2.setEZProbeDeviceInfo(null);
baseException = new BaseException(BaseResponse.NETWORK_EXCEPTION_ERROR_MSG, errorLayer6.errorCode, errorLayer6);
}
}
eZProbeDeviceInfoResult2.setBaseException(baseException);
return eZProbeDeviceInfoResult2;
}
});
if (post == null) {
return null;
}
EZProbeDeviceInfoResult eZProbeDeviceInfoResult2 = (EZProbeDeviceInfoResult) post;
LogUtil.i(TAG, eZProbeDeviceInfoResult2.toString());
return eZProbeDeviceInfoResult2;
} catch (BaseException e) {
e.printStackTrace();
eZProbeDeviceInfoResult.setEZProbeDeviceInfo(null);
eZProbeDeviceInfoResult.setBaseException(e);
return eZProbeDeviceInfoResult;
}
}
public void refreshNetwork() {
if (!ConnectionDetector.isNetworkAvailable(mApplication)) {
DeviceManager.getInstance().clearPreConncetInfo();
DeviceManager.getInstance().clearDevicePlayType();
return;
}
LocalInfo localInfo = LocalInfo.getInstance();
Context context = localInfo.getContext();
if (localInfo.getIsLogin()) {
LogUtil.d(TAG, "网络状态改变");
String wifiMacAddress = ConnectionDetector.getWifiMacAddress(context);
if (!TextUtils.equals(wifiMacAddress, this.mAppManager.getWifiMacAddress())) {
this.mAppManager.setWifiMacAddress(wifiMacAddress);
DeviceManager.getInstance().clearPreConncetInfo();
DeviceManager.getInstance().clearDevicePlayType();
new Thread() {
@Override
public void run() {
LogUtil.d(EzvizAPI.TAG, "onReceive start getServerInfo");
try {
EzvizAPI.this.mAppManager.refreshNetInfo();
} catch (BaseException e) {
LogUtil.printErrStackTrace(EzvizAPI.TAG, e.fillInStackTrace());
}
}
}.start();
}
}
setNetType(Utils.getNetTypeName(mApplication));
}
public Boolean refreshToken() {
LogUtil.i(TAG, "Enter refreshToken");
this.refreshTokenCount++;
synchronized (this.mWaitObject) {
if (this.refreshTokenCount > 1) {
this.refreshTokenCount--;
return Boolean.TRUE;
}
if (TextUtils.isEmpty(LocalInfo.getInstance().getEZAccesstoken().getAccessToken()) || TextUtils.isEmpty(LocalInfo.getInstance().getEZAccesstoken().getRefresh_token())) {
return Boolean.FALSE;
}
final String uuid = UUID.randomUUID().toString();
return (Boolean) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "state")
private String state;
@HttpParam(name = "refresh_token")
private String refresh_token = LocalInfo.getInstance().getEZAccesstoken().getRefresh_token();
@HttpParam(name = "client_id")
private String client_id = EzvizAPI.getInstance().getAppKey();
@HttpParam(name = "grant_type")
private String grant_type = "refresh_token";
@HttpParam(name = "open_id")
private String open_id = LocalInfo.getInstance().getEZAccesstoken().getOpen_id();
@HttpParam(name = "bundleId")
private String bundleId = LocalInfo.getInstance().getPackageName();
@HttpParam(name = "scope")
private String scope = LocalInfo.getInstance().getEZAccesstoken().getScope();
{
this.state = uuid;
}
}, LocalInfo.getInstance().getOAuthServAddr() + "/oauth/token/refreshToken", new ApiResponse() {
@Override
public Object parse(String str) {
if (!parseCodeHttp(str)) {
return Boolean.FALSE;
}
JSONObject optJSONObject = new JSONObject(str).optJSONObject("data");
LocalInfo.getInstance().getEZAccesstoken().setExpire(Long.parseLong(optJSONObject.optString(SocializeProtocolConstants.PROTOCOL_KEY_EXPIRE_IN)));
LocalInfo.getInstance().getEZAccesstoken().setAccessToken(optJSONObject.optString("access_token"));
LocalInfo.getInstance().getEZAccesstoken().setOpen_id(optJSONObject.optString("openId"));
LocalInfo.getInstance().getEZAccesstoken().setRefresh_token(optJSONObject.optString("refresh_token"));
LocalInfo.getInstance().getEZAccesstoken().setState(optJSONObject.optString("state"));
LocalInfo.getInstance().getEZAccesstoken().setScope(optJSONObject.optString("scope"));
LocalInfo.getInstance().saveEZAccesstoken();
return Boolean.TRUE;
}
}, true);
}
}
public boolean regist(RegistInfo registInfo) {
Boolean bool = (Boolean) this.mRestfulUtils.postData(new RegistReq().buidParams(registInfo), RegistReq.URL, new RegistResp());
if (bool != null) {
return bool.booleanValue();
}
return false;
}
public void releasePlayer(EZPlayer eZPlayer) {
LogUtil.d(TAG, "Enter releasePlayer, ");
if (eZPlayer == null) {
return;
}
eZPlayer.release();
}
public void releaseSDK() {
EZNetworkChangeListener eZNetworkChangeListener = this.mNetworkChangeListener;
if (eZNetworkChangeListener != null) {
mApplication.unregisterReceiver(eZNetworkChangeListener);
this.mNetworkChangeListener = null;
}
mEzvizAPI = null;
}
public boolean reportData(final int i) {
LogUtil.i(TAG, "Enter reportData: ");
return ((Boolean) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "type")
private int mType;
{
this.mType = i;
}
}, "/api/report/operateData", new ApiResponse() {
@Override
public Object parse(String str) {
return Boolean.valueOf(parseCode(str));
}
})).booleanValue();
}
public boolean resetAccountPassword(String str, String str2, String str3) {
ResetPassword resetPassword = new ResetPassword();
resetPassword.setAccount(str);
resetPassword.setSmsCode(str2);
resetPassword.setNewPassword(str3);
Boolean bool = (Boolean) this.mRestfulUtils.post(resetPassword, ResetPasswordResp.URL, new ResetPasswordResp());
if (bool != null) {
return bool.booleanValue();
}
return false;
}
public EZRecordFile searchRecordFileByAlarmId(final String str, final int i, final String str2) {
LogUtil.i(TAG, "Enter searchRecordFileByAlarmId");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
if (i < 0) {
LogUtil.i(TAG, "searchRecordFileByAlarmId, invalid parameters channelNo");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
EZRecordFile eZRecordFile = (EZRecordFile) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = DX_HttpConstants.DX_REQ_KEY_ALARM_ID)
private String alarmid;
@HttpParam(name = DX_HttpConstants.DX_REQ_KEY_CHANNEL_NO)
private int channelNumber;
@HttpParam(name = "deviceSerial")
private String devSerial;
{
this.devSerial = str;
this.channelNumber = i;
this.alarmid = str2;
}
}, "/api/lapp/video/by/id", new ApiResponse() {
@Override
public EZRecordFile parse(String str3) {
JSONObject optJSONObject;
boolean parseCodeHttp = parseCodeHttp(str3);
if (!parseCodeHttp || !parseCodeHttp || (optJSONObject = new JSONObject(str3).optJSONObject("data")) == null) {
return null;
}
EZRecordFile eZRecordFile2 = new EZRecordFile();
ReflectionUtils.convJSONToObject(optJSONObject, eZRecordFile2);
return eZRecordFile2;
}
});
if (eZRecordFile != null) {
LogUtil.d(TAG, "searchRecordFilesByTime returns: " + new Gson().toJson(eZRecordFile));
}
return eZRecordFile;
}
public List<EZCloudRecordFile> searchRecordFileFromCloud(final String str, final int i, Calendar calendar, Calendar calendar2) {
List<CloudFileEx> list;
StringBuilder sb = new StringBuilder("Enter searchRecordFileFromCloud, deviceSerial:");
sb.append(str);
sb.append(" startTime:");
sb.append(calendar != null ? calendar.getTime() : DX_AccountInfo.PUSH_FACE_DEFENCE_NOT_SUPPORT);
sb.append(" endT:");
sb.append(calendar2 != null ? calendar2.getTime() : DX_AccountInfo.PUSH_FACE_DEFENCE_NOT_SUPPORT);
LogUtil.i(TAG, sb.toString());
ArrayList arrayList = new ArrayList();
final String calendar2String = Utils.calendar2String(calendar);
final String calendar2String2 = Utils.calendar2String(calendar2);
List list2 = null;
loop0: for (int i2 = 0; i2 < 3; i2++) {
try {
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "endTime")
private String endTime;
@HttpParam(name = GetCameraInfoReq.CAMERANO)
private int mCameraNo;
@HttpParam(name = "deviceSerial")
private String mDeviceSerial;
@HttpParam(name = DX_HttpConstants.DX_REQ_KEY_START_TIME)
private String startTime;
@HttpParam(name = "fileType")
private int fileType = 1;
@HttpParam(name = "version")
private String version = SocializeConstants.PROTOCOL_VERSON;
{
this.mDeviceSerial = str;
this.mCameraNo = i;
this.startTime = calendar2String;
this.endTime = calendar2String2;
}
}, "/api/cloud/files/get", new ApiResponse() {
@Override
public Object parse(String str2) {
if (!parseCode(str2)) {
return null;
}
JSONArray optJSONArray = new JSONObject(str2).getJSONObject("result").optJSONArray("data");
ArrayList arrayList2 = new ArrayList();
if (optJSONArray != null) {
int length = optJSONArray.length();
for (int i3 = 0; i3 < length; i3++) {
CloudFileEx cloudFileEx = new CloudFileEx();
ReflectionUtils.convJSONToObject(optJSONArray.getJSONObject(i3), cloudFileEx);
arrayList2.add(cloudFileEx);
}
}
return arrayList2;
}
});
if (post == null) {
break;
}
list = (List) post;
try {
Iterator it = list.iterator();
while (it.hasNext()) {
LogUtil.d(TAG, "searchRecordFileFromCloud: " + new Gson().toJson((CloudFileEx) it.next()));
}
break loop0;
} catch (BaseException e) {
e = e;
list2 = list;
LogUtil.printErrStackTrace(TAG, e.fillInStackTrace());
}
} catch (BaseException e2) {
e = e2;
}
}
list = list2;
if (list != null && list.size() > 0) {
for (CloudFileEx cloudFileEx : list) {
EZCloudRecordFile eZCloudRecordFile = new EZCloudRecordFile();
EZOpenSDKConvertUtil.convertCloudFileEx2EZCloudFile(eZCloudRecordFile, cloudFileEx);
arrayList.add(eZCloudRecordFile);
}
}
return arrayList;
}
public List<EZCloudRecordFile> searchRecordFileFromCloudEx(final String str, final int i, Calendar calendar, Calendar calendar2) {
StringBuilder sb = new StringBuilder("Enter searchRecordFileFromCloud, deviceSerial:");
sb.append(str);
sb.append(" startTime:");
sb.append(calendar != null ? calendar.getTime() : DX_AccountInfo.PUSH_FACE_DEFENCE_NOT_SUPPORT);
sb.append(" endT:");
sb.append(calendar2 != null ? calendar2.getTime() : DX_AccountInfo.PUSH_FACE_DEFENCE_NOT_SUPPORT);
LogUtil.i(TAG, sb.toString());
List<CloudFileEx> list = null;
ArrayList arrayList = new ArrayList();
final String calendar2String = Utils.calendar2String(calendar);
final String calendar2String2 = Utils.calendar2String(calendar2);
int i2 = 0;
while (true) {
if (i2 >= 3) {
break;
}
try {
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "endTime")
private String endTime;
@HttpParam(name = GetCameraInfoReq.CAMERANO)
private int mCameraNo;
@HttpParam(name = "deviceSerial")
private String mDeviceSerial;
@HttpParam(name = DX_HttpConstants.DX_REQ_KEY_START_TIME)
private String startTime;
@HttpParam(name = "fileType")
private int fileType = 1;
@HttpParam(name = "version")
private String version = "3.0";
{
this.mDeviceSerial = str;
this.mCameraNo = i;
this.startTime = calendar2String;
this.endTime = calendar2String2;
}
}, "/api/cloud/files/get", new ApiResponse() {
@Override
public Object parse(String str2) {
if (!parseCode(str2)) {
return null;
}
JSONArray optJSONArray = new JSONObject(str2).getJSONObject("result").optJSONArray("data");
ArrayList arrayList2 = new ArrayList();
if (optJSONArray != null) {
int length = optJSONArray.length();
for (int i3 = 0; i3 < length; i3++) {
CloudFileEx cloudFileEx = new CloudFileEx();
ReflectionUtils.convJSONToObject(optJSONArray.getJSONObject(i3), cloudFileEx);
arrayList2.add(cloudFileEx);
}
}
return arrayList2;
}
});
if (post == null) {
break;
}
list = (List) post;
break;
} catch (BaseException e) {
LogUtil.printErrStackTrace(TAG, e.fillInStackTrace());
i2++;
}
}
if (list != null && list.size() > 0) {
for (CloudFileEx cloudFileEx : list) {
EZCloudRecordFile eZCloudRecordFile = new EZCloudRecordFile();
EZOpenSDKConvertUtil.convertCloudFileEx2EZCloudFile(eZCloudRecordFile, cloudFileEx);
arrayList.add(eZCloudRecordFile);
}
}
return arrayList;
}
public List<EZDeviceRecordFile> searchRecordFileFromDevice(final String str, final int i, Calendar calendar, Calendar calendar2) {
LogUtil.i(TAG, "Enter searchRecordFileFromDevice");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
if (i < 0) {
LogUtil.i(TAG, "cameraNo must be greater than zero");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
final String calendar2String = Utils.calendar2String(calendar);
final String calendar2String2 = Utils.calendar2String(calendar2);
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = GetCameraInfoReq.CAMERANO)
private int cameraNo;
@HttpParam(name = "deviceSerial")
private String deviceSerial;
@HttpParam(name = "endTime")
private String endTime;
@HttpParam(name = DX_HttpConstants.DX_REQ_KEY_START_TIME)
private String startTime;
{
this.deviceSerial = str;
this.cameraNo = i;
this.startTime = calendar2String;
this.endTime = calendar2String2;
}
}, "/api/sdk/device/local/video", new ApiResponse() {
@Override
public Object parse(String str2) {
if (!EzvizAPI.parserCode(str2)) {
return null;
}
JSONArray optJSONArray = new JSONObject(str2).optJSONObject("result").optJSONArray("data");
ArrayList arrayList = new ArrayList();
for (int i2 = 0; i2 < optJSONArray.length(); i2++) {
JSONObject jSONObject = optJSONArray.getJSONObject(i2);
EZDeviceRecordFile eZDeviceRecordFile = new EZDeviceRecordFile();
ReflectionUtils.convJSONToObject(jSONObject, eZDeviceRecordFile);
arrayList.add(eZDeviceRecordFile);
}
return arrayList;
}
});
if (post == null) {
return null;
}
LogUtil.d(TAG, new Gson().toJson(post));
return (List) post;
}
public List<EZRecordFile> searchRecordFilesByTime(final String str, final int i, final long j, final long j2, final int i2) {
LogUtil.i(TAG, "Enter searchRecordFilesByTime");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
if (i < 0) {
LogUtil.i(TAG, "searchRecordFilesByTime, invalid parameters channelNo");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
List<EZRecordFile> list = (List) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = DX_HttpConstants.DX_REQ_KEY_CHANNEL_NO)
private int channelNumber;
@HttpParam(name = "deviceSerial")
private String devSerial;
@HttpParam(name = "endTime")
private long endtime;
@HttpParam(name = "recType")
private int rectype;
@HttpParam(name = DX_HttpConstants.DX_REQ_KEY_START_TIME)
private long starttime;
{
this.devSerial = str;
this.channelNumber = i;
this.starttime = j;
this.endtime = j2;
this.rectype = i2;
}
}, "/api/lapp/video/by/time", new ApiResponse() {
@Override
public List<EZRecordFile> parse(String str2) {
boolean parseCodeHttp = parseCodeHttp(str2);
if (!parseCodeHttp || !parseCodeHttp) {
return null;
}
JSONArray optJSONArray = new JSONObject(str2).optJSONArray("data");
ArrayList arrayList = new ArrayList();
if (optJSONArray != null && optJSONArray.length() > 0) {
int length = optJSONArray.length();
for (int i3 = 0; i3 < length; i3++) {
EZRecordFile eZRecordFile = new EZRecordFile();
ReflectionUtils.convJSONToObject(optJSONArray.optJSONObject(i3), eZRecordFile);
arrayList.add(eZRecordFile);
}
}
return arrayList;
}
});
if (list != null && list.size() > 0) {
Iterator<EZRecordFile> it = list.iterator();
while (it.hasNext()) {
LogUtil.d(TAG, "searchRecordFilesByTime returns: " + new Gson().toJson(it.next()));
}
}
return list;
}
public boolean secureSmsValidate(String str) {
SecureValidateReq secureValidateReq = new SecureValidateReq();
SecureValidateReq.Params params = secureValidateReq.params;
params.smsCode = str;
params.accessToken = LocalInfo.getInstance().getEZAccesstoken().getAccessToken();
return parserTransferApiCode(getInstance().transferAPI(ReflectionUtils.convObjectToJSON(secureValidateReq).toString()));
}
public void setAccessToken(String str) {
LogUtil.d(TAG, "Enter setAccessToken: ");
String accessToken = LocalInfo.getInstance().getEZAccesstoken().getAccessToken();
if (TextUtils.isEmpty(str)) {
LogUtil.e(TAG, "accessToken is null,logout");
this.mLocalInfo.setEZAccessToken(null);
this.mLocalInfo.setUserName("");
this.mAppManager.clearServerInfo();
clearCacheData();
return;
}
this.mLocalInfo.setAccessToken(str);
if (!isInit) {
isInit = true;
initParams();
}
if (TextUtils.equals(accessToken, str)) {
Application application = mApplication;
if (application != null) {
EZStreamClientManager.create(application).clearTokens();
}
} else {
LogUtil.e(TAG, "accessToken is switch");
this.mAppManager.clearServerInfo();
clearCacheData();
initParams();
}
LogUtil.d(TAG, "Exit setAccessToken: ");
}
public boolean setAlarmRead(String str) {
BaseAlarmInfo baseAlarmInfo = new BaseAlarmInfo();
baseAlarmInfo.setAlarmId(str);
Boolean bool = (Boolean) this.mRestfulUtils.post(baseAlarmInfo, SetAlarmReadResp.URL, new SetAlarmReadResp());
if (bool != null) {
return bool.booleanValue();
}
return false;
}
public boolean setAlarmStatus(List<String> list, EZConstants.EZAlarmStatus eZAlarmStatus) {
if (list == null || list.size() <= 0) {
LogUtil.e(TAG, "Enter setAlarmStatus, alarmIdList is null size:");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
LogUtil.d(TAG, "Enter setAlarmStatus, alarmIdList size:" + list.size());
StringBuilder sb = new StringBuilder();
if (list.size() == 1) {
sb.append(list.get(0));
} else {
sb.append(list.get(0));
for (int i = 1; i < list.size(); i++) {
sb.append(",");
sb.append(list.get(i));
}
}
String sb2 = sb.toString();
BaseAlarmInfo baseAlarmInfo = new BaseAlarmInfo();
baseAlarmInfo.setAlarmId(sb2);
Boolean bool = (Boolean) this.mRestfulUtils.post(baseAlarmInfo, SetAlarmReadResp.URL, new SetAlarmReadResp());
if (bool != null) {
return bool.booleanValue();
}
return false;
}
public void setAppKey(String str) {
this.mAppKey = str;
}
public void setAreaDomain(String str) {
this.mLocalInfo.getEZAccesstoken().setAreaDomain(str);
}
public void setDDNSAutomatic(final String str) {
LogUtil.i(TAG, "Enter setDDNSAutomatic");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceSerial")
private String devSerial;
{
this.devSerial = str;
}
}, "/api/lapp/ddns/mode/setAutomatic", new ApiResponse() {
@Override
public Boolean parse(String str2) {
boolean parseCodeHttp = parseCodeHttp(str2);
if (parseCodeHttp && parseCodeHttp) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}
});
}
public void setDDNSManual(final String str, final int i, final int i2) {
LogUtil.i(TAG, "Enter setDDNSManual");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "cmdPort")
private int cmdport;
@HttpParam(name = "deviceSerial")
private String devSerial;
@HttpParam(name = "httpPort")
private int httpport;
{
this.devSerial = str;
this.cmdport = i;
this.httpport = i2;
}
}, "/api/lapp/ddns/mode/setManual", new ApiResponse() {
@Override
public Boolean parse(String str2) {
boolean parseCodeHttp = parseCodeHttp(str2);
if (parseCodeHttp && parseCodeHttp) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}
});
}
public boolean setDefence(final String str, final EZConstants.EZDefenceStatus eZDefenceStatus) {
LogUtil.i(TAG, "Enter setDefence");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "isDefence")
private int bDefence;
@HttpParam(name = "deviceSerial")
private String devSerial;
{
this.devSerial = str;
this.bDefence = eZDefenceStatus.getStatus();
}
}, "/api/device/updateDefence", new ApiResponse() {
@Override
public Object parse(String str2) {
return Boolean.valueOf(parseCode(str2));
}
});
StringBuilder sb = new StringBuilder("setDeviceDefence return ");
Boolean bool = (Boolean) post;
sb.append(bool);
LogUtil.i(TAG, sb.toString());
return bool.booleanValue();
}
public void setDeviceDoamin(final String str, final String str2) {
LogUtil.i(TAG, "Enter setDeviceDoamin");
if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) {
LogUtil.i(TAG, "deviceSerial and domain cannot be empty");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, ErrorCode.ERROR_CAS_UPGRADE_PU_PARAM_ERR));
}
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceSerial")
private String devSerial;
@HttpParam(name = "domain")
private String mDomain;
{
this.devSerial = str;
this.mDomain = str2;
}
}, "/api/lapp/ddns/setDomain", new ApiResponse() {
@Override
public Boolean parse(String str3) {
boolean parseCodeHttp = parseCodeHttp(str3);
if (parseCodeHttp && parseCodeHttp) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}
});
}
public boolean setDeviceEncryptStatus(final String str, final String str2, final boolean z) {
DeviceInfoEx deviceInfoExById;
int localValidateParam;
LogUtil.i(TAG, "Enter setDeviceEnryptStatusEx");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
if (!z && (localValidateParam = this.mLocalValidate.localValidateParam(str2)) != 0) {
LogUtil.i(TAG, "setDeviceEnryptStatusEx, invalid parameters");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidateParam));
}
boolean booleanValue = ((Boolean) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceSerial")
private String mDeviceSerial;
@HttpParam(name = DX_HttpConstants.DX_REQ_KEY_VALIDATE_CODE)
private String mValidateCode;
@HttpParam(name = "isEncrypt")
private int mIsEncrypt = z ? 1 : 0;
{
this.mDeviceSerial = str;
this.mValidateCode = str2;
}
}, "/api/device/encrypt/set", new ApiResponse() {
@Override
public Object parse(String str3) {
return Boolean.valueOf(parseCode(str3));
}
})).booleanValue();
if (booleanValue && (deviceInfoExById = DeviceManager.getInstance().getDeviceInfoExById(str)) != null) {
deviceInfoExById.setIsEncrypt(z ? 1 : 0);
}
return booleanValue;
}
public boolean setDeviceVideoLevel(final String str, final int i, final int i2) {
CameraInfoEx addedCamera;
LogUtil.i(TAG, "Enter setDeviceVideoLevel,");
Object post = this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = GetCameraInfoReq.CAMERANO)
private int mCameraNo;
@HttpParam(name = "deviceSerial")
private String mDeviceSerial;
@HttpParam(name = "videoLevel")
private int mVideoLevel;
@HttpParam(name = "version")
private String version = SocializeConstants.PROTOCOL_VERSON;
{
this.mDeviceSerial = str;
this.mCameraNo = i;
this.mVideoLevel = i2;
}
}, "/api/device/setVideoLevel", new ApiResponse() {
@Override
public Object parse(String str2) {
return Boolean.valueOf(parseCode(str2));
}
});
if (post == null) {
return false;
}
Boolean bool = (Boolean) post;
if (bool.booleanValue() && (addedCamera = CameraManager.getInstance().getAddedCamera(str, i)) != null) {
addedCamera.setVideoLevel(i2);
}
return bool.booleanValue();
}
public boolean setLeaveMessageStatus(List<String> list, EZConstants.EZMessageStatus eZMessageStatus) {
LogUtil.i(TAG, "Enter setLeaveMessageStatus");
final String commaSeprateStrFromList = getCommaSeprateStrFromList(list);
if (!TextUtils.isEmpty(commaSeprateStrFromList)) {
return ((Boolean) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "messageId")
private String mMsgIds;
@HttpParam(name = "type")
private String mType = "1";
{
this.mMsgIds = commaSeprateStrFromList;
}
}, "/api/message/leave/operate", new ApiResponse() {
@Override
public Object parse(String str) {
return Boolean.valueOf(parseCode(str));
}
})).booleanValue();
}
LogUtil.i(TAG, "setLeaveMessageStatus, invalid parameters msgIdList");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400001));
}
public void setNetType(String str) {
this.mNetType = str;
}
public void setServerUrl(String str, String str2) {
this.mLocalInfo.setServAddr(str);
this.mWebUrl = str2;
LocalInfo.getInstance().setAuthServAddr(this.mWebUrl);
}
public void setThridToken(String str) {
this.mThridToken = str;
}
public void setUserCode(String str) {
this.mLocalInfo.setUserCode(str);
}
public void setVparamForLoginPage(String str) {
WebLoginReq.setmVparam(str);
}
public void shareDDNSDeviceList(final String str, final String str2) {
LogUtil.i(TAG, "Enter shareDDNSDeviceList");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = GetSmsCodeResetReq.ACCOUNT)
private String account1;
@HttpParam(name = "deviceSerial")
private String devSerial;
{
this.devSerial = str;
this.account1 = str2;
}
}, "/api/lapp/ddns/share", new ApiResponse() {
@Override
public Boolean parse(String str3) {
boolean parseCodeHttp = parseCodeHttp(str3);
if (parseCodeHttp && parseCodeHttp) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}
});
}
public void startAPConfigWifiWithSsid(String str, String str2, String str3, String str4, APWifiConfig.APConfigCallback aPConfigCallback) {
ConfigWifiSdkManager.startAPConfigWifiWithSsid(str, str2, str3, str4, aPConfigCallback);
}
public void startAPConfigWifiWithSsid(String str, String str2, String str3, String str4, String str5, String str6, boolean z, APWifiConfig.APConfigCallback aPConfigCallback) {
ConfigWifiSdkManager.startAPConfigWifiWithSsid(str, str2, str3, str4, str5, str6, z, aPConfigCallback);
}
public void startConfigWifi(Context context, String str, String str2, String str3, int i, EZOpenSDKListener.EZStartConfigWifiCallback eZStartConfigWifiCallback) {
LogUtil.i(TAG, "Enter startConfigWifi EZConfigWifiCallback");
ConfigWifiSdkManager.startConfigWifi(context, str, str2, str3, i, eZStartConfigWifiCallback);
}
public boolean startConfigWifi(Context context, String str, String str2, DeviceDiscoveryListener deviceDiscoveryListener) {
LogUtil.i(TAG, "Enter startConfigWifi DeviceDiscoveryListener");
ConfigWifiSdkManager.startConfigWifi(context, str, str2, deviceDiscoveryListener);
return true;
}
public void stopAPConfigWifiWithSsid() {
ConfigWifiSdkManager.stopAPConfigWifiWithSsid();
}
public boolean stopConfigWiFi() {
LogUtil.i(TAG, "Enter stopConfigWiFi");
ConfigWifiSdkManager.stopConfigWifi();
return true;
}
public int stopTicketPush(String str, String str2, String str3, String str4) {
String str5;
EZPrivateTicketRequest eZPrivateTicketRequest = new EZPrivateTicketRequest();
eZPrivateTicketRequest.setAppKey(this.mAppKey);
eZPrivateTicketRequest.setClientId(str);
eZPrivateTicketRequest.setClientType("1");
eZPrivateTicketRequest.setSessionId(str3);
eZPrivateTicketRequest.setUsername(str2);
if (TextUtils.isEmpty(str4)) {
str4 = this.mAppPushSecret;
}
eZPrivateTicketRequest.setToken(str4);
if (TextUtils.isEmpty(LocalInfo.getInstance().getPushAddr())) {
str5 = "https://push.ys7.com/api/push/stop";
} else {
str5 = LocalInfo.getInstance().getPushAddr() + "/api/push/stop";
}
Integer num = (Integer) this.mRestfulUtils.postDataDirectUrl(eZPrivateTicketRequest.getNVPairList(), str5, new ApiResponse() {
@Override
public Object parse(String str6) {
try {
int optInt = new JSONObject(str6).optInt("status");
if (optInt == 200) {
return Integer.valueOf(optInt);
}
ErrorInfo errorLayer = ErrorLayer.getErrorLayer(2, ErrorCode.ERROR_INNER_WEBRESPONSE_JSONERROR);
LogUtil.e(EzvizAPI.TAG, "JSON解析错误");
throw new BaseException("JSON解析错误", errorLayer);
} catch (JSONException unused) {
ErrorInfo errorLayer2 = ErrorLayer.getErrorLayer(2, ErrorCode.ERROR_INNER_WEBRESPONSE_JSONERROR);
LogUtil.e(EzvizAPI.TAG, "JSON解析错误");
throw new BaseException("JSON解析错误", errorLayer2);
}
}
});
if (num.intValue() == 200) {
return num.intValue();
}
return -1;
}
public String transferAPI(final String str) {
return (String) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "reqStr")
private String reqStr;
{
this.reqStr = str;
}
}, "/api/transfer", new ApiResponse() {
@Override
public Object parse(String str2) {
return str2;
}
});
}
public boolean updateDeviceName(final String str, final String str2) {
LogUtil.i(TAG, "Enter updateDeviceName");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
if (!TextUtils.isEmpty(str2)) {
return ((Boolean) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceName")
private String devName;
@HttpParam(name = "deviceSerial")
private String devSerial;
{
this.devSerial = str;
this.devName = str2;
}
}, "/api/device/updateDeviceName", new ApiResponse() {
@Override
public Object parse(String str3) {
return Boolean.valueOf(parseCode(str3));
}
})).booleanValue();
}
LogUtil.i(TAG, "updateDeviceName, invalid parameters:deviceName is null");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
public void upgradeDevice(final String str) {
LogUtil.i(TAG, "Enter upgradeDevice");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "deviceSerial")
private String mDeviceSerial;
{
this.mDeviceSerial = str;
}
}, "/api/device/upgrade", new ApiResponse() {
@Override
public Object parse(String str2) {
return Boolean.valueOf(parseCode(str2));
}
});
}
public void upgradeDevice_stub(String str) {
LogUtil.i(TAG, "Enter upgradeDevice_stub");
int localValidatDeviceSerial = this.mLocalValidate.localValidatDeviceSerial(str);
if (localValidatDeviceSerial != 0) {
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, localValidatDeviceSerial));
}
if (Config.ENABLE_STUB) {
this.mStartUpgrade = 1;
} else {
LogUtil.i(TAG, "getDeviceUpgradeStatus_stub: Config.ENABLE_STUB not open");
}
}
public boolean validateSecureSms(final String str) {
LogUtil.i(TAG, "Enter validateSecureSms: ");
if (!TextUtils.isEmpty(str)) {
return ((Boolean) this.mRestfulUtils.post(new BaseInfo() {
@HttpParam(name = "smsCode")
private String mSmsCode;
{
this.mSmsCode = str;
}
}, "/api/description/secureValidate", new ApiResponse() {
@Override
public Object parse(String str2) {
return Boolean.valueOf(parseCode(str2));
}
})).booleanValue();
}
LogUtil.i(TAG, "validateSecureSms: smsCode is null");
throw new BaseException(STR_NATIVE_PARAM_ERROR, ErrorLayer.getErrorLayer(2, 400002));
}
public boolean verifySmsCode(int i, String str, String str2, String str3) {
VerifySmsCodeInfo verifySmsCodeInfo = new VerifySmsCodeInfo();
verifySmsCodeInfo.setType(i);
verifySmsCodeInfo.setUserId(str);
verifySmsCodeInfo.setPhone(str2);
verifySmsCodeInfo.setSmsCode(str3);
Boolean bool = (Boolean) this.mRestfulUtils.postData(new VerifySmsCodeReq().buidParams(verifySmsCodeInfo), VerifySmsCodeReq.URL, new VerifySmsCodeResp());
if (bool != null) {
return bool.booleanValue();
}
return false;
}
}