LiteOsSettingActivity.java 源代码
package liteos.ossetting;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import base.HiActivity;
import bean.MyCamera;
import com.hichip.base.HiLog;
import com.hichip.callback.ICameraIOSessionCallback;
import com.hichip.campro.R;
import com.hichip.content.HiChipDefines;
import com.hichip.control.HiCamera;
import com.xiaomi.mipush.sdk.Constants;
import common.ConstantCommand;
import common.HiDataValue;
import common.TitleView;
import custom.SwitchButton;
import custom.dialog.NiftyDialogBuilder;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import main.MainActivity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.apache.xmlbeans.XmlErrorCodes;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import utils.DialogUtilsCamHiPro;
import utils.HiLogcatUtil;
import utils.HiTools;
import utils.MyToast;
public class LiteOsSettingActivity extends HiActivity implements ICameraIOSessionCallback, RadioGroup.OnCheckedChangeListener, CompoundButton.OnCheckedChangeListener, View.OnClickListener {
private static final int GET_UPDATE_VERSION_DATA = 65536;
private static final int GET_UPDATE_VERSION_NUM = 39321;
private static String LiteOsDownloadUrl = "http://upgrade.hichip.net/goke_update.html";
public static boolean isDebugModel;
private ConstantCommand.HI_P2P_S_AWAKEN_PARAM awakenParam;
private boolean devPowerModeDisEnable;
private boolean isUpdate;
private ConstantCommand.HI_P2P_S_LED_SWITCH ledParams;
LinearLayout ll_plan_video_content;
LinearLayout ll_record_time;
LinearLayout ll_stream;
LinearLayout ll_work_model;
private int mGetStream;
private MyCamera mMyCamera;
private ConstantCommand.HI_P2P_S_POWER_MODE_PARAM powerMode;
RadioButton rb_15;
RadioButton rb_30;
RadioButton rb_60;
RadioButton rb_all_work;
RadioButton rb_defensive_model;
RadioButton rb_first_stream;
RadioButton rb_lite_os;
RadioButton rb_not_disturb;
RadioButton rb_second_stream;
private ConstantCommand.HI_P2P_S_REC_CHANNEL rec_channel;
private ConstantCommand.HI_P2P_S_PLAN_REC_INFO rec_param;
private String redirectAddr;
RadioGroup rg_power_model;
RadioGroup rg_stream_set;
RadioGroup rg_switch_model;
RadioGroup rg_time_set;
RelativeLayout rl_alarmfasdf;
RelativeLayout rl_lan_wake;
RelativeLayout rl_long_wake;
RelativeLayout rl_low_power_open_os;
RelativeLayout rl_open_led_light;
RelativeLayout rl_open_record;
RelativeLayout rl_pir_test;
RelativeLayout rl_power_consumption_setting;
RelativeLayout rl_power_work_model;
RelativeLayout rl_server_setting;
RelativeLayout rl_standby;
RelativeLayout rl_update_test;
RelativeLayout rl_wake_up_record;
SeekBar sb_sensitivity;
SwitchButton sbtn_pir;
SwitchButton sbtn_remote;
SwitchButton sbtn_wlan;
SwitchButton switch_btn_open_close;
SwitchButton switch_led;
SwitchButton switch_low_power_open_os;
SwitchButton switch_record;
TitleView title;
TextView tv1;
TextView tv2;
TextView tv4;
TextView tv_dev_is_in_os;
TextView tv_sensitivity_rate;
private UpdateInfo updateInfo;
private long updateTime;
TextView update_test;
private ConstantCommand.HI_P2P_WAKEUP_MODE_PARAM wakeup_mode_param;
private ConstantCommand.HI_P2P_S_DEVICE_MODE_PARAM work_mode;
private ConstantCommand.HI_P2P_S_DEV_WORK_MODE_PARAM work_mode_params;
private int mPowerSupplyType = 1;
private float alpha = 0.4f;
private boolean isCheck = true;
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message message) {
int i = message.what;
if (i == -1879048189) {
LiteOsSettingActivity.this.handIOCTRL(message);
return;
}
if (i != LiteOsSettingActivity.GET_UPDATE_VERSION_NUM) {
if (i != 65536) {
return;
}
LiteOsSettingActivity.this.showDialogOld();
} else {
if (message.arg1 == 1) {
LiteOsSettingActivity.this.updateInfo = (UpdateInfo) message.obj;
if (LiteOsSettingActivity.this.mMyCamera != null) {
LiteOsSettingActivity.this.mMyCamera.registerIOSessionListener(LiteOsSettingActivity.this);
}
LiteOsSettingActivity.this.handleDeviceInfo();
return;
}
LiteOsSettingActivity liteOsSettingActivity = LiteOsSettingActivity.this;
MyToast.showToast(liteOsSettingActivity, liteOsSettingActivity.getString(R.string.tips_update_system_failed));
LiteOsSettingActivity.this.dismissjuHuaDialog();
}
}
};
private boolean isChec = false;
private List<UpdateInfo> mListUpdataInfo = new ArrayList();
@Override
public void receiveSessionState(HiCamera hiCamera, int i) {
}
@Override
protected int setLayoutId() {
return R.layout.activity_lite_os_setting;
}
@Override
protected void init(Bundle bundle) {
getIntentData();
initView();
initData();
setListeners();
}
private void setListeners() {
this.rl_standby.setOnClickListener(this);
this.update_test.setOnClickListener(this);
this.rl_server_setting.setOnClickListener(this);
this.rl_power_consumption_setting.setOnClickListener(this);
this.rl_pir_test.setOnClickListener(this);
this.sbtn_pir.setOnCheckedChangeListener(this);
this.sbtn_wlan.setOnCheckedChangeListener(this);
this.sbtn_remote.setOnCheckedChangeListener(this);
this.switch_record.setOnCheckedChangeListener(this);
this.rg_power_model.setOnCheckedChangeListener(this);
this.rg_switch_model.setOnCheckedChangeListener(this);
this.switch_btn_open_close.setOnCheckedChangeListener(this);
this.sb_sensitivity.setMax(585);
this.sb_sensitivity.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
LiteOsSettingActivity.this.tv_sensitivity_rate.setText((i + 15) + "");
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
if (LiteOsSettingActivity.this.rec_param == null) {
return;
}
LiteOsSettingActivity.this.rec_param.u32FileLen = seekBar.getProgress() + 15;
LiteOsSettingActivity.this.showjuHuaDialog();
LiteOsSettingActivity.this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_SET_PLAN_REC_INFO, LiteOsSettingActivity.this.rec_param.parseContent());
}
});
}
@Override
public void onResume() {
super.onResume();
MyCamera myCamera = this.mMyCamera;
if (myCamera != null) {
myCamera.registerIOSessionListener(this);
}
}
@Override
public void onPause() {
super.onPause();
MyCamera myCamera = this.mMyCamera;
if (myCamera != null) {
myCamera.unregisterIOSessionListener(this);
}
}
private void initData() {
if (this.mMyCamera.appGetCommandFunction(ConstantCommand.HI_P2P_GET_DEVICE_WORKING_MODE)) {
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_GET_DEVICE_WORKING_MODE, new byte[0]);
} else {
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_GET_POWER_MODE, new byte[0]);
}
if (this.mMyCamera.appGetCommandFunction(ConstantCommand.HI_P2P_GET_REC_CHN)) {
this.ll_stream.setVisibility(0);
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_GET_REC_CHN, new byte[0]);
}
if (isDebugModel) {
if (this.mMyCamera.appGetCommandFunction(ConstantCommand.HI_P2P_GET_DEV_WORK_MODE)) {
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_GET_DEV_WORK_MODE, new byte[0]);
}
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_GET_AWAKEN_PARAM, new byte[0]);
Log.i("tedu", "--发咯 获取唤醒模式参数--");
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_GET_AWAKEN_MODE_PARAM, new byte[0]);
}
}
private void initView() {
if (this.mMyCamera.appGetCommandFunction(ConstantCommand.HI_P2P_GET_POWER_MODE) || this.mMyCamera.appGetCommandFunction(ConstantCommand.HI_P2P_GET_DEVICE_WORKING_MODE)) {
this.rl_power_work_model.setVisibility(0);
}
if (this.mMyCamera.appGetCommandFunction(ConstantCommand.HI_P2P_GET_PLAN_REC_INFO)) {
this.rl_open_record.setAlpha(this.alpha);
this.rl_open_record.setVisibility(0);
}
if (this.mMyCamera.appGetCommandFunction(ConstantCommand.HI_P2P_GET_LED_SWITCH)) {
this.rl_open_led_light.setVisibility(0);
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_GET_LED_SWITCH, new byte[0]);
}
this.title.setTitle(getString(R.string.low_power_setting));
this.title.setButton(0);
this.title.setNavigationBarButtonListener(new TitleView.NavigationBarButtonListener() {
@Override
public void OnNavigationButtonClick(int i) {
if (i != 0) {
return;
}
LiteOsSettingActivity.this.finish();
}
});
if (isDebugModel) {
this.rl_wake_up_record.setVisibility(0);
this.tv1.setVisibility(0);
this.tv2.setVisibility(0);
this.tv4.setVisibility(0);
this.rl_wake_up_record.setVisibility(0);
this.rl_standby.setVisibility(0);
this.rl_server_setting.setVisibility(0);
this.rl_lan_wake.setVisibility(0);
this.rl_long_wake.setVisibility(0);
this.rl_update_test.setVisibility(0);
this.ll_work_model.setVisibility(0);
this.rl_alarmfasdf.setVisibility(0);
this.rl_pir_test.setVisibility(0);
if (this.mMyCamera.appGetCommandFunction(ConstantCommand.HI_P2P_GET_L_DTIM)) {
this.rl_power_consumption_setting.setVisibility(0);
}
}
boolean appGetCommandFunction = this.mMyCamera.appGetCommandFunction(65595);
this.devPowerModeDisEnable = appGetCommandFunction;
if (appGetCommandFunction) {
this.rl_power_work_model.setAlpha(this.alpha);
this.rb_lite_os.setEnabled(false);
this.rb_all_work.setEnabled(false);
this.switch_record.setEnabled(false);
}
}
private void getIntentData() {
String stringExtra = getIntent().getStringExtra(HiDataValue.EXTRAS_KEY_UID);
if (!TextUtils.isEmpty(stringExtra)) {
Iterator<MyCamera> it = HiDataValue.CameraList.iterator();
while (true) {
if (!it.hasNext()) {
break;
}
MyCamera next = it.next();
if (next.getUid().equalsIgnoreCase(stringExtra)) {
this.mMyCamera = next;
break;
}
}
}
if (HiTools.cameraWhetherNull(this.mMyCamera, this)) {
}
}
@Override
public void receiveIOCtrlData(HiCamera hiCamera, int i, byte[] bArr, int i2) {
if (hiCamera != this.mMyCamera) {
return;
}
Bundle bundle = new Bundle();
bundle.putByteArray("data", bArr);
Message obtainMessage = this.mHandler.obtainMessage();
obtainMessage.what = HiDataValue.HANDLE_MESSAGE_RECEIVE_IOCTRL;
obtainMessage.obj = hiCamera;
obtainMessage.arg1 = i;
obtainMessage.arg2 = i2;
obtainMessage.setData(bundle);
this.mHandler.sendMessage(obtainMessage);
}
public void handIOCTRL(Message message) {
if (message.arg2 == 0) {
byte[] byteArray = message.getData().getByteArray("data");
switch (message.arg1) {
case ConstantCommand.HI_P2P_GET_POWER_MODE:
dismissjuHuaDialog();
this.powerMode = new ConstantCommand.HI_P2P_S_POWER_MODE_PARAM(byteArray);
Log.i("tedu", "--电源模式--:" + this.powerMode.u32PowerMode);
this.mPowerSupplyType = this.powerMode.u32PowerType;
Log.i("tedu", "--电源供电类型--:" + this.powerMode.u32PowerType);
if (this.powerMode.u32PowerMode == 1) {
this.rb_all_work.setChecked(true);
this.rl_open_record.setAlpha(1.0f);
if (this.mMyCamera.appGetCommandFunction(ConstantCommand.HI_P2P_GET_PLAN_REC_INFO)) {
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_GET_PLAN_REC_INFO, new byte[0]);
return;
} else {
this.ll_record_time.setVisibility(8);
return;
}
}
if (this.powerMode.u32PowerMode == 0) {
this.rb_lite_os.setChecked(true);
this.rl_open_record.setAlpha(this.alpha);
return;
}
return;
case ConstantCommand.HI_P2P_SET_POWER_MODE:
dismissjuHuaDialog();
ConstantCommand.HI_P2P_S_POWER_MODE_PARAM hi_p2p_s_power_mode_param = this.powerMode;
if (hi_p2p_s_power_mode_param != null && hi_p2p_s_power_mode_param.u32PowerMode == 1) {
this.rl_open_record.setAlpha(1.0f);
if (this.mMyCamera.appGetCommandFunction(ConstantCommand.HI_P2P_GET_PLAN_REC_INFO)) {
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_GET_PLAN_REC_INFO, new byte[0]);
return;
} else {
this.ll_record_time.setVisibility(8);
return;
}
}
return;
case ConstantCommand.HI_P2P_GET_DEV_WORK_MODE:
this.work_mode = new ConstantCommand.HI_P2P_S_DEVICE_MODE_PARAM(byteArray);
Log.i("tedu", "--work_mode--:" + this.work_mode.u32DeviceMode);
if (this.work_mode.u32DeviceMode == 1) {
this.rb_defensive_model.setChecked(true);
return;
} else {
if (this.work_mode.u32DeviceMode == 0) {
this.rb_not_disturb.setChecked(true);
return;
}
return;
}
case ConstantCommand.HI_P2P_SET_DEV_WORK_MODE:
dismissjuHuaDialog();
MyToast.showToast(this, getString(R.string.switch_success));
return;
case ConstantCommand.HI_P2P_SET_AWAKEN_PARAM:
dismissjuHuaDialog();
return;
case ConstantCommand.HI_P2P_GET_AWAKEN_PARAM:
this.awakenParam = new ConstantCommand.HI_P2P_S_AWAKEN_PARAM(byteArray);
Log.i("tedu", "-无操作待机时长-:" + this.awakenParam.u32Dormancy);
Log.i("tedu", "-唤醒时是否开启录像-:" + this.awakenParam.u32RecEnable);
Log.i("tedu", "-第几码流-:" + this.awakenParam.u32RecChannel);
Log.i("tedu", "-文件格式-:" + this.awakenParam.u32FileFormat);
this.switch_btn_open_close.setChecked(this.awakenParam.u32RecEnable == 1);
if (this.awakenParam.u32Dormancy == 60) {
this.rb_60.setChecked(true);
} else if (this.awakenParam.u32Dormancy == 30) {
this.rb_30.setChecked(true);
} else if (this.awakenParam.u32Dormancy == 15) {
this.rb_15.setChecked(true);
}
this.rg_time_set.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
if (i == R.id.rb_15) {
LiteOsSettingActivity.this.awakenParam.u32Dormancy = 15;
} else if (i == R.id.rb_30) {
LiteOsSettingActivity.this.awakenParam.u32Dormancy = 30;
} else if (i == R.id.rb_60) {
LiteOsSettingActivity.this.awakenParam.u32Dormancy = 60;
}
LiteOsSettingActivity.this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_SET_AWAKEN_PARAM, LiteOsSettingActivity.this.awakenParam.parseContent());
}
});
return;
case ConstantCommand.HI_P2P_GET_AWAKEN_MODE_PARAM:
this.wakeup_mode_param = new ConstantCommand.HI_P2P_WAKEUP_MODE_PARAM(byteArray);
Log.i("tedu", "-PIR报警唤醒设备-:" + this.wakeup_mode_param.u32WPirEnable);
Log.i("tedu", "-局域网唤醒设备-:" + this.wakeup_mode_param.u32WLanEnable);
Log.i("tedu", "-远程唤醒设备-:" + this.wakeup_mode_param.u32WWanEnable);
this.sbtn_pir.setChecked(this.wakeup_mode_param.u32WPirEnable == 1);
this.sbtn_wlan.setChecked(this.wakeup_mode_param.u32WLanEnable == 1);
this.sbtn_remote.setChecked(this.wakeup_mode_param.u32WWanEnable == 1);
return;
case ConstantCommand.HI_P2P_SET_AWAKEN_MODE_PARAM:
dismissjuHuaDialog();
return;
case ConstantCommand.HI_P2P_SET_PLAN_REC_INFO:
dismissjuHuaDialog();
return;
case ConstantCommand.HI_P2P_GET_PLAN_REC_INFO:
this.rec_param = new ConstantCommand.HI_P2P_S_PLAN_REC_INFO(byteArray);
Log.e("===44==receive", this.rec_param.u32FileLen + "");
this.sb_sensitivity.setProgress(this.rec_param.u32FileLen - 15);
this.tv_sensitivity_rate.setText(this.rec_param.u32FileLen + "");
if (this.rec_param.u32Enable == 1) {
showViewContent();
}
this.switch_record.setOnCheckedChangeListener(null);
this.switch_record.setChecked(this.rec_param.u32Enable == 1);
this.switch_record.setOnCheckedChangeListener(this);
return;
case ConstantCommand.HI_P2P_SET_REC_CHN:
dismissjuHuaDialog();
this.mMyCamera.isSystemState = 1;
startActivity(new Intent(this, (Class<?>) MainActivity.class));
return;
case ConstantCommand.HI_P2P_GET_REC_CHN:
ConstantCommand.HI_P2P_S_REC_CHANNEL hi_p2p_s_rec_channel = new ConstantCommand.HI_P2P_S_REC_CHANNEL(byteArray);
this.rec_channel = hi_p2p_s_rec_channel;
this.mGetStream = hi_p2p_s_rec_channel.u32RecChn;
if (this.rec_channel.u32RecChn == 1) {
this.rb_second_stream.setChecked(true);
} else if (this.rec_channel.u32RecChn == 0) {
this.rb_first_stream.setChecked(true);
}
this.rg_stream_set.setOnCheckedChangeListener(this);
return;
case ConstantCommand.HI_P2P_GET_LED_SWITCH:
ConstantCommand.HI_P2P_S_LED_SWITCH hi_p2p_s_led_switch = new ConstantCommand.HI_P2P_S_LED_SWITCH(byteArray);
this.ledParams = hi_p2p_s_led_switch;
if (hi_p2p_s_led_switch.u8LedSwitch == 0) {
this.switch_led.setChecked(true);
}
this.switch_led.setOnCheckedChangeListener(this);
return;
case ConstantCommand.HI_P2P_GET_DEVICE_WORKING_MODE:
dismissjuHuaDialog();
if (byteArray == null) {
return;
}
this.work_mode_params = new ConstantCommand.HI_P2P_S_DEV_WORK_MODE_PARAM(byteArray);
HiLogcatUtil.i("--HI_P2P_GET_DEVICE_WORKING_MODE--:" + this.work_mode_params.toString());
this.switch_low_power_open_os.setChecked(this.work_mode_params.u32LowPowerSwitch == 1);
this.switch_low_power_open_os.setOnCheckedChangeListener(this);
if (this.work_mode_params.u32ManualWorkMode == 1) {
if (this.work_mode_params.u32LowPowerSwitch == 1 && this.work_mode_params.u32RealWorkMode == 0) {
if (this.tv_dev_is_in_os.getVisibility() != 0) {
this.tv_dev_is_in_os.setVisibility(0);
}
} else if (this.tv_dev_is_in_os.getVisibility() == 0) {
this.tv_dev_is_in_os.setVisibility(8);
}
this.rb_all_work.setChecked(true);
this.rl_open_record.setAlpha(1.0f);
if (this.rl_low_power_open_os.getVisibility() != 0) {
this.rl_low_power_open_os.setVisibility(0);
}
if (this.mMyCamera.appGetCommandFunction(ConstantCommand.HI_P2P_GET_PLAN_REC_INFO)) {
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_GET_PLAN_REC_INFO, new byte[0]);
return;
} else {
this.ll_record_time.setVisibility(8);
return;
}
}
if (this.work_mode_params.u32ManualWorkMode == 0) {
this.rb_lite_os.setChecked(true);
this.rl_open_record.setAlpha(this.alpha);
if (this.rl_low_power_open_os.getVisibility() == 0) {
this.rl_low_power_open_os.setVisibility(8);
return;
}
return;
}
return;
case ConstantCommand.HI_P2P_SET_DEVICE_WORKING_MODE:
dismissjuHuaDialog();
if (this.work_mode_params.u32ManualWorkMode == 1) {
if (this.work_mode_params.u32LowPowerSwitch == 1 && this.work_mode_params.u32RealWorkMode == 0) {
if (this.tv_dev_is_in_os.getVisibility() != 0) {
this.tv_dev_is_in_os.setVisibility(0);
}
} else if (this.tv_dev_is_in_os.getVisibility() == 0) {
this.tv_dev_is_in_os.setVisibility(8);
}
this.rl_open_record.setAlpha(1.0f);
if (this.mMyCamera.appGetCommandFunction(ConstantCommand.HI_P2P_GET_PLAN_REC_INFO)) {
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_GET_PLAN_REC_INFO, new byte[0]);
} else {
this.ll_record_time.setVisibility(8);
}
if (this.rl_low_power_open_os.getVisibility() != 0) {
this.rl_low_power_open_os.setVisibility(0);
return;
}
return;
}
return;
default:
return;
}
}
switch (message.arg1) {
case ConstantCommand.HI_P2P_GET_POWER_MODE:
case ConstantCommand.HI_P2P_SET_POWER_MODE:
case ConstantCommand.HI_P2P_SET_DEV_WORK_MODE:
case ConstantCommand.HI_P2P_SET_PLAN_REC_INFO:
case ConstantCommand.HI_P2P_SET_REC_CHN:
case ConstantCommand.HI_P2P_GET_DEVICE_WORKING_MODE:
case ConstantCommand.HI_P2P_SET_DEVICE_WORKING_MODE:
dismissjuHuaDialog();
return;
case ConstantCommand.HI_P2P_GET_AWAKEN_MODE_PARAM:
MyToast.showToast(this, "获取报警唤醒模式参数失败!");
return;
default:
return;
}
}
public void lambda$onCheckedChanged$0$LiteOsSettingActivity(NiftyDialogBuilder niftyDialogBuilder, View view) {
niftyDialogBuilder.dismiss();
this.isCheck = false;
this.rb_lite_os.setChecked(true);
}
public void lambda$onCheckedChanged$1$LiteOsSettingActivity(NiftyDialogBuilder niftyDialogBuilder, View view) {
niftyDialogBuilder.dismiss();
ConstantCommand.HI_P2P_S_POWER_MODE_PARAM hi_p2p_s_power_mode_param = this.powerMode;
if (hi_p2p_s_power_mode_param != null) {
hi_p2p_s_power_mode_param.u32PowerMode = 1;
showjuHuaDialog();
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_SET_POWER_MODE, this.powerMode.parseContent());
}
ConstantCommand.HI_P2P_S_DEV_WORK_MODE_PARAM hi_p2p_s_dev_work_mode_param = this.work_mode_params;
if (hi_p2p_s_dev_work_mode_param != null) {
hi_p2p_s_dev_work_mode_param.u32ManualWorkMode = 1;
this.work_mode_params.u32RealWorkMode = 1;
showjuHuaDialog();
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_SET_DEVICE_WORKING_MODE, this.work_mode_params.parseContent());
}
}
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
switch (i) {
case R.id.rb_all_work:
boolean z = this.isChec;
if (!z) {
this.isChec = !z;
return;
}
final NiftyDialogBuilder niftyDialogBuilder = NiftyDialogBuilder.getInstance(this);
niftyDialogBuilder.withMessageLayoutHWrapW(HiTools.dip2px(this, 260.0f));
niftyDialogBuilder.withTitle(getString(R.string.tip_reminder)).withMessage(getString(R.string.tip_switch_lite));
niftyDialogBuilder.withButton1Text(getString(R.string.cancel)).withButton2Text(getString(R.string.all_right));
niftyDialogBuilder.isCancelableOnTouchOutside(false);
niftyDialogBuilder.setButton1Click(new View.OnClickListener() {
@Override
public final void onClick(View view) {
LiteOsSettingActivity.this.lambda$onCheckedChanged$0$LiteOsSettingActivity(niftyDialogBuilder, view);
}
});
niftyDialogBuilder.setButton2Click(new View.OnClickListener() {
@Override
public final void onClick(View view) {
LiteOsSettingActivity.this.lambda$onCheckedChanged$1$LiteOsSettingActivity(niftyDialogBuilder, view);
}
});
niftyDialogBuilder.show();
return;
case R.id.rb_defensive_model:
this.work_mode.u32DeviceMode = 1;
showjuHuaDialog();
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_SET_DEV_WORK_MODE, this.work_mode.parseContent());
return;
case R.id.rb_first_stream:
if (this.mGetStream != 0) {
setRec_channel(0);
return;
}
return;
case R.id.rb_lite_os:
boolean z2 = this.isChec;
if (!z2) {
this.isChec = !z2;
return;
}
if (!this.isCheck) {
this.isCheck = true;
return;
}
ConstantCommand.HI_P2P_S_POWER_MODE_PARAM hi_p2p_s_power_mode_param = this.powerMode;
if (hi_p2p_s_power_mode_param != null) {
hi_p2p_s_power_mode_param.u32PowerMode = 0;
showjuHuaDialog();
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_SET_POWER_MODE, this.powerMode.parseContent());
}
ConstantCommand.HI_P2P_S_DEV_WORK_MODE_PARAM hi_p2p_s_dev_work_mode_param = this.work_mode_params;
if (hi_p2p_s_dev_work_mode_param != null) {
hi_p2p_s_dev_work_mode_param.u32ManualWorkMode = 0;
this.work_mode_params.u32RealWorkMode = 0;
showjuHuaDialog();
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_SET_DEVICE_WORKING_MODE, this.work_mode_params.parseContent());
if (this.rl_low_power_open_os.getVisibility() == 0) {
this.rl_low_power_open_os.setVisibility(8);
}
if (this.tv_dev_is_in_os.getVisibility() == 0) {
this.tv_dev_is_in_os.setVisibility(8);
}
}
if (this.switch_record.isChecked()) {
disMissViewContent();
}
this.switch_record.setOnCheckedChangeListener(null);
this.switch_record.setChecked(false);
this.switch_record.setOnCheckedChangeListener(this);
this.rl_open_record.setAlpha(this.alpha);
return;
case R.id.rb_not_disturb:
this.work_mode.u32DeviceMode = 0;
showjuHuaDialog();
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_SET_DEV_WORK_MODE, this.work_mode.parseContent());
return;
case R.id.rb_second_stream:
if (this.mGetStream != 1) {
setRec_channel(1);
return;
}
return;
default:
return;
}
}
private void setLed(boolean z) {
if (z) {
this.ledParams.u8LedSwitch = 0;
} else {
this.ledParams.u8LedSwitch = 1;
}
Log.e("TAG", this.ledParams.u8LedSwitch + "");
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_SET_LED_SWITCH, this.ledParams.parseContent());
}
private void setRec_channel(final int i) {
final NiftyDialogBuilder niftyDialogBuilder = NiftyDialogBuilder.getInstance(this);
niftyDialogBuilder.withMessageLayoutHWrapW(HiTools.dip2px(this, 260.0f));
niftyDialogBuilder.withTitle(getString(R.string.tip_reminder)).withMessage(getString(R.string.liteos_modify_stream_restart));
niftyDialogBuilder.withButton1Text(getString(R.string.cancel)).withButton2Text(getString(R.string.all_right));
niftyDialogBuilder.isCancelableOnTouchOutside(false);
niftyDialogBuilder.setButton1Click(new View.OnClickListener() {
@Override
public final void onClick(View view) {
LiteOsSettingActivity.this.lambda$setRec_channel$2$LiteOsSettingActivity(niftyDialogBuilder, view);
}
});
niftyDialogBuilder.setButton2Click(new View.OnClickListener() {
@Override
public final void onClick(View view) {
LiteOsSettingActivity.this.lambda$setRec_channel$3$LiteOsSettingActivity(niftyDialogBuilder, i, view);
}
});
niftyDialogBuilder.show();
}
public void lambda$setRec_channel$2$LiteOsSettingActivity(NiftyDialogBuilder niftyDialogBuilder, View view) {
niftyDialogBuilder.dismiss();
int i = this.mGetStream;
if (i == 1) {
this.rb_second_stream.setChecked(true);
} else if (i == 0) {
this.rb_first_stream.setChecked(true);
}
}
public void lambda$setRec_channel$3$LiteOsSettingActivity(NiftyDialogBuilder niftyDialogBuilder, int i, View view) {
niftyDialogBuilder.dismiss();
this.rec_channel.u32RecChn = i;
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_SET_REC_CHN, this.rec_channel.parseContent());
showjuHuaDialog();
}
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
int id = compoundButton.getId();
if (id == R.id.switch_btn_open_close) {
this.awakenParam.u32RecEnable = z ? 1 : 0;
showjuHuaDialog();
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_SET_AWAKEN_PARAM, this.awakenParam.parseContent());
return;
}
switch (id) {
case R.id.sbtn_pir:
showjuHuaDialog();
this.wakeup_mode_param.u32WPirEnable = z ? 1 : 0;
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_SET_AWAKEN_MODE_PARAM, this.wakeup_mode_param.parseContent());
return;
case R.id.sbtn_remote:
showjuHuaDialog();
this.wakeup_mode_param.u32WWanEnable = z ? 1 : 0;
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_SET_AWAKEN_MODE_PARAM, this.wakeup_mode_param.parseContent());
return;
case R.id.sbtn_wlan:
showjuHuaDialog();
this.wakeup_mode_param.u32WLanEnable = z ? 1 : 0;
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_SET_AWAKEN_MODE_PARAM, this.wakeup_mode_param.parseContent());
return;
default:
switch (id) {
case R.id.switch_led:
setLed(this.switch_led.isChecked());
return;
case R.id.switch_low_power_open_os:
setLowPowerOpenOS(this.switch_low_power_open_os.isChecked());
return;
case R.id.switch_record:
if (this.rl_open_record.getAlpha() != 1.0f) {
this.switch_record.setChecked(false);
MyToast.showToast(this, getString(R.string.open_all_work_first));
return;
}
if (z) {
showViewContent();
} else {
disMissViewContent();
}
Log.e("==setRecordStatus", "onCheckedChanged: ");
ConstantCommand.HI_P2P_S_PLAN_REC_INFO hi_p2p_s_plan_rec_info = this.rec_param;
if (hi_p2p_s_plan_rec_info == null) {
return;
}
hi_p2p_s_plan_rec_info.u32Enable = z ? 1 : 0;
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_SET_PLAN_REC_INFO, this.rec_param.parseContent());
return;
default:
return;
}
}
}
private void setLowPowerOpenOS(boolean z) {
ConstantCommand.HI_P2P_S_DEV_WORK_MODE_PARAM hi_p2p_s_dev_work_mode_param = this.work_mode_params;
if (hi_p2p_s_dev_work_mode_param == null) {
return;
}
if (z) {
hi_p2p_s_dev_work_mode_param.u32LowPowerSwitch = 1;
} else {
hi_p2p_s_dev_work_mode_param.u32RealWorkMode = 1;
this.work_mode_params.u32LowPowerSwitch = 0;
}
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_SET_DEVICE_WORKING_MODE, this.work_mode_params.parseContent());
}
@Override
public void onClick(View view) {
Intent intent = new Intent();
switch (view.getId()) {
case R.id.rl_pir_test:
intent.setClass(this, PirTestActivity.class);
intent.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
startActivity(intent);
return;
case R.id.rl_power_consumption_setting:
intent.setClass(this, PowerSettingActivity.class);
intent.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
startActivity(intent);
return;
case R.id.rl_server_setting:
intent.setClass(this, ServerSettingActivity.class);
intent.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
startActivity(intent);
return;
case R.id.update_test:
showjuHuaDialog();
checkUpdate();
return;
default:
return;
}
}
private void checkUpdate() {
new ThreadHttpResqust().start();
}
public class ThreadHttpResqust extends Thread {
public ThreadHttpResqust() {
}
@Override
public void run() {
try {
HttpResponse execute = new DefaultHttpClient().execute(new HttpGet(LiteOsSettingActivity.LiteOsDownloadUrl));
if (execute.getStatusLine().getStatusCode() == 200) {
String entityUtils = EntityUtils.toString(execute.getEntity());
HiLog.v("result:" + entityUtils);
try {
JSONArray jSONArray = new JSONObject(entityUtils).getJSONArray(XmlErrorCodes.LIST);
for (int i = 0; i < jSONArray.length(); i++) {
JSONObject jSONObject = jSONArray.getJSONObject(i);
LiteOsSettingActivity.this.mListUpdataInfo.add(new UpdateInfo(jSONObject.getString("url"), jSONObject.getString("ver")));
}
} catch (JSONException e) {
e.printStackTrace();
}
if (LiteOsSettingActivity.this.mListUpdataInfo.size() > 0) {
Message message = new Message();
message.what = LiteOsSettingActivity.GET_UPDATE_VERSION_NUM;
message.arg1 = 1;
LiteOsSettingActivity.this.mHandler.sendMessage(message);
return;
}
}
Message message2 = new Message();
message2.what = LiteOsSettingActivity.GET_UPDATE_VERSION_NUM;
message2.arg1 = 0;
LiteOsSettingActivity.this.mHandler.sendMessage(message2);
} catch (Exception unused) {
Message message3 = new Message();
message3.what = LiteOsSettingActivity.GET_UPDATE_VERSION_NUM;
message3.arg1 = 0;
LiteOsSettingActivity.this.mHandler.sendMessage(message3);
}
}
}
private static String getString(byte[] bArr) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < bArr.length && bArr[i] != 0; i++) {
sb.append((char) bArr[i]);
}
return sb.toString();
}
public void handleDeviceInfo() {
String string = getString(this.mMyCamera.getDeciveInfo().aszSystemSoftVersion);
if (string.isEmpty() || string.length() < 3) {
return;
}
String substring = string.substring(3, string.length());
for (UpdateInfo updateInfo : this.mListUpdataInfo) {
HiLog.v("version:" + substring);
String[] split = updateInfo.ver.split("\\.");
String[] split2 = substring.split("\\.");
if (split.length == split2.length && split2.length == 5) {
int i = 0;
while (true) {
if (i >= split.length) {
break;
}
if (i == split.length - 1) {
String[] split3 = split[i].split(Constants.ACCEPT_TIME_SEPARATOR_SERVER);
String[] split4 = split2[i].split(Constants.ACCEPT_TIME_SEPARATOR_SERVER);
HiLog.v("last_new_array:" + split3.length + " last_old_array:" + split4.length);
if ((split3.length >= 1 ? Integer.parseInt(split3[0]) : 0) > (split4.length >= 1 ? Integer.parseInt(split4[0]) : 0)) {
this.updateInfo = updateInfo;
this.isUpdate = true;
}
} else if (!split2[i].equals(split[i])) {
this.isUpdate = false;
break;
}
i++;
}
}
if (this.isUpdate) {
break;
}
}
if (!this.isUpdate || this.updateInfo == null) {
return;
}
this.redirectAddr = this.updateInfo.url + this.updateInfo.ver + ".exe";
new ThreadCheckRedirect().start();
}
public class ThreadCheckRedirect extends Thread {
static final boolean $assertionsDisabled = false;
private ThreadCheckRedirect() {
}
@Override
public void run() {
Message message;
Socket socket;
int i = 80;
Socket socket2 = null;
String str = null;
socket2 = null;
try {
try {
socket = new Socket();
} catch (IOException e) {
e = e;
}
} catch (Throwable th) {
th = th;
}
try {
socket.setReuseAddress(true);
Matcher matcher = Pattern.compile("(?<=//|)((\\w)+\\.)+\\w+(:\\d{0,5})?").matcher(LiteOsSettingActivity.this.updateInfo.url);
if (matcher.find()) {
str = matcher.group();
System.out.println("host2:" + str);
}
if (str.contains(Constants.COLON_SEPARATOR)) {
String[] split = str.split(Constants.COLON_SEPARATOR);
str = split[0];
int parseInt = Integer.parseInt(split[1]);
System.out.println("---00port: " + split[0]);
System.out.println("---port: " + parseInt);
i = parseInt;
}
socket.connect(new InetSocketAddress(str, i));
DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream());
String str2 = (((((("GET /" + LiteOsSettingActivity.this.updateInfo.ver + ".exe HTTP/1.1\r\n") + "Accept: */*\r\n") + "Accept-Language: zh-cn\r\n") + "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n") + "Host: " + str + "\r\n") + "Connection: Keep-Alive\r\n") + "\r\n";
System.out.println("sendhead:" + str2);
dataOutputStream.write(str2.getBytes());
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
while (true) {
String readLine = bufferedReader.readLine();
System.out.println("in.readLine:" + readLine);
if (readLine.contains("HTTP/")) {
if (!readLine.contains("302") && !readLine.contains("301")) {
break;
} else {
System.out.println("------------ 301 302 Found----------------");
}
}
if (readLine.contains("Location:")) {
String trim = readLine.substring(9).trim();
System.out.println("1------------ newhttp----------------:" + trim);
LiteOsSettingActivity.this.redirectAddr = readLine.substring(9).trim();
break;
}
}
dataOutputStream.close();
bufferedReader.close();
try {
socket.close();
} catch (IOException unused) {
}
message = new Message();
} catch (IOException e2) {
e = e2;
socket2 = socket;
e.printStackTrace();
if (socket2 != null) {
try {
socket2.close();
} catch (IOException unused2) {
}
}
message = new Message();
message.what = 65536;
message.arg1 = 1;
LiteOsSettingActivity.this.mHandler.sendMessage(message);
} catch (Throwable th2) {
th = th2;
socket2 = socket;
if (socket2 != null) {
try {
socket2.close();
} catch (IOException unused3) {
}
}
Message message2 = new Message();
message2.what = 65536;
message2.arg1 = 1;
LiteOsSettingActivity.this.mHandler.sendMessage(message2);
throw th;
}
message.what = 65536;
message.arg1 = 1;
LiteOsSettingActivity.this.mHandler.sendMessage(message);
}
}
public void showDialogOld() {
dismissjuHuaDialog();
new DialogUtilsCamHiPro(this).title(getText(R.string.tips_warning)).message(getText(R.string.tip_system_update_old)).sureText(getString(R.string.sure)).cancelText(getString(R.string.cancel)).setSureOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
LiteOsSettingActivity.this.lambda$showDialogOld$4$LiteOsSettingActivity(view);
}
}).build().show();
}
public void lambda$showDialogOld$4$LiteOsSettingActivity(View view) {
if (System.currentTimeMillis() - this.updateTime <= 180000) {
return;
}
String str = this.redirectAddr;
byte[] bArr = new byte[128];
byte[] bytes = str.getBytes();
System.arraycopy(bytes, 0, bArr, 0, bytes.length <= 128 ? bytes.length : 128);
HiLog.v("dl:" + str);
this.updateTime = System.currentTimeMillis();
MyCamera myCamera = this.mMyCamera;
if (myCamera != null) {
myCamera.registerIOSessionListener(this);
}
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_SET_DOWNLOAD_TEST, HiChipDefines.HI_P2P_S_SET_DOWNLOAD.parseContent(0, bArr));
}
public class UpdateInfo {
String url;
String ver;
public UpdateInfo(String str, String str2) {
this.url = str;
this.ver = str2;
}
}
private void disMissViewContent() {
this.ll_plan_video_content.setPivotY(0.0f);
AnimatorSet animatorSet = new AnimatorSet();
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(this.ll_plan_video_content, "ScaleY", 1.0f, 0.0f);
ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(this.ll_plan_video_content, "Alpha", 1.0f, 0.0f);
animatorSet.setDuration(350L);
animatorSet.setInterpolator(new AccelerateInterpolator());
animatorSet.playTogether(ofFloat, ofFloat2);
animatorSet.start();
this.ll_plan_video_content.setVisibility(8);
}
private void showViewContent() {
if (this.ll_plan_video_content.getVisibility() == 0) {
return;
}
this.ll_plan_video_content.setVisibility(0);
this.ll_plan_video_content.setPivotY(0.0f);
AnimatorSet animatorSet = new AnimatorSet();
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(this.ll_plan_video_content, "ScaleY", 0.0f, 1.0f);
ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(this.ll_plan_video_content, "Alpha", 0.0f, 1.0f);
animatorSet.setDuration(350L);
animatorSet.setInterpolator(new AccelerateInterpolator());
animatorSet.playTogether(ofFloat, ofFloat2);
animatorSet.start();
}
}