diff --git a/.idea/libraries/EMTMF_0101_1608016.xml b/.idea/libraries/EMTMF_0101_1608016.xml
deleted file mode 100644
index 2c99b73d7..000000000
--- a/.idea/libraries/EMTMF_0101_1608016.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/SoundWaveSender_v2_0_2.xml b/.idea/libraries/SoundWaveSender_v2_0_2.xml
new file mode 100644
index 000000000..5d768fc21
--- /dev/null
+++ b/.idea/libraries/SoundWaveSender_v2_0_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/alicloud_android_ut_5_4_0.xml b/.idea/libraries/alicloud_android_ut_5_4_0.xml
deleted file mode 100644
index ff7c98865..000000000
--- a/.idea/libraries/alicloud_android_ut_5_4_0.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/alicloud_android_ut_5_4_1.xml b/.idea/libraries/alicloud_android_ut_5_4_1.xml
new file mode 100644
index 000000000..560286aff
--- /dev/null
+++ b/.idea/libraries/alicloud_android_ut_5_4_1.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/converter_gson_2_0_0.xml b/.idea/libraries/converter_gson_2_0_0.xml
new file mode 100644
index 000000000..a1f7f2afb
--- /dev/null
+++ b/.idea/libraries/converter_gson_2_0_0.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/gson_2_7.xml b/.idea/libraries/gson_2_7.xml
new file mode 100644
index 000000000..22607550e
--- /dev/null
+++ b/.idea/libraries/gson_2_7.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/javabase64.xml b/.idea/libraries/javabase64.xml
deleted file mode 100644
index 14a59434c..000000000
--- a/.idea/libraries/javabase64.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/libhttp_0_4_6_3.xml b/.idea/libraries/libhttp_0_4_6_3.xml
new file mode 100644
index 000000000..d1cc3e658
--- /dev/null
+++ b/.idea/libraries/libhttp_0_4_6_3.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/libhttp_v0_5_0.xml b/.idea/libraries/libhttp_v0_5_0.xml
new file mode 100644
index 000000000..25e7a01f1
--- /dev/null
+++ b/.idea/libraries/libhttp_v0_5_0.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/gson_2_4.xml b/.idea/libraries/logging_interceptor_3_8_1.xml
similarity index 54%
rename from .idea/libraries/gson_2_4.xml
rename to .idea/libraries/logging_interceptor_3_8_1.xml
index dbc0d4d5d..ff3e22095 100644
--- a/.idea/libraries/gson_2_4.xml
+++ b/.idea/libraries/logging_interceptor_3_8_1.xml
@@ -1,11 +1,11 @@
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/okhttp_3_3_0.xml b/.idea/libraries/okhttp_3_3_0.xml
new file mode 100644
index 000000000..bce0736ce
--- /dev/null
+++ b/.idea/libraries/okhttp_3_3_0.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/okhttp_3_8_1.xml b/.idea/libraries/okhttp_3_8_1.xml
new file mode 100644
index 000000000..1c52fa2da
--- /dev/null
+++ b/.idea/libraries/okhttp_3_8_1.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/okio_1_13_0.xml b/.idea/libraries/okio_1_13_0.xml
new file mode 100644
index 000000000..a855abb67
--- /dev/null
+++ b/.idea/libraries/okio_1_13_0.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/okio_1_8_0.xml b/.idea/libraries/okio_1_8_0.xml
new file mode 100644
index 000000000..3422c1a90
--- /dev/null
+++ b/.idea/libraries/okio_1_8_0.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/p2p_core_0_4_4.xml b/.idea/libraries/p2p_core_0_4_4.xml
new file mode 100644
index 000000000..59b128885
--- /dev/null
+++ b/.idea/libraries/p2p_core_0_4_4.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/reactive_streams_1_0_0.xml b/.idea/libraries/reactive_streams_1_0_0.xml
new file mode 100644
index 000000000..e0378bb16
--- /dev/null
+++ b/.idea/libraries/reactive_streams_1_0_0.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/retrofit2_rxjava2_adapter_1_0_0.xml b/.idea/libraries/retrofit2_rxjava2_adapter_1_0_0.xml
new file mode 100644
index 000000000..e7292a3fc
--- /dev/null
+++ b/.idea/libraries/retrofit2_rxjava2_adapter_1_0_0.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/retrofit_2_1_0.xml b/.idea/libraries/retrofit_2_1_0.xml
new file mode 100644
index 000000000..cc9bd6983
--- /dev/null
+++ b/.idea/libraries/retrofit_2_1_0.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/rxandroid_2_0_1.xml b/.idea/libraries/rxandroid_2_0_1.xml
new file mode 100644
index 000000000..051803770
--- /dev/null
+++ b/.idea/libraries/rxandroid_2_0_1.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/rxjava_2_0_1.xml b/.idea/libraries/rxjava_2_0_1.xml
new file mode 100644
index 000000000..73bb1b576
--- /dev/null
+++ b/.idea/libraries/rxjava_2_0_1.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/udpsender_v2_0_1.xml b/.idea/libraries/udpsender_v2_0_1.xml
new file mode 100644
index 000000000..da1721681
--- /dev/null
+++ b/.idea/libraries/udpsender_v2_0_1.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/iFish7/libs/EMTMF_0101_1608016.jar b/iFish7/libs/EMTMF_0101_1608016.jar
deleted file mode 100644
index 5caf13075..000000000
Binary files a/iFish7/libs/EMTMF_0101_1608016.jar and /dev/null differ
diff --git a/iFish7/src/main/java/com/ifish/activity/WaveCameraActivity.java b/iFish7/src/main/java/com/ifish/activity/WaveCameraActivity.java
new file mode 100644
index 000000000..f2aa9be28
--- /dev/null
+++ b/iFish7/src/main/java/com/ifish/activity/WaveCameraActivity.java
@@ -0,0 +1,395 @@
+/**
+ * @Title: WaitCameraActivity.java
+ * @Package com.ifish.activity
+ * @Description: TODO
+ * @author Jacky dada
+ * @date 2016-6-28 上午10:35:53
+ */
+package com.ifish.activity;
+
+import android.content.Context;
+import android.content.Intent;
+import android.media.AudioManager;
+import android.net.wifi.WifiManager;
+import android.os.Bundle;
+import android.os.CountDownTimer;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.view.View;
+
+import com.ifish.basebean.BaseBean;
+import com.ifish.basebean.FinishWaitActivity;
+import com.ifish.basebean.RefreshCamera;
+import com.ifish.baseclass.BaseActivity;
+import com.ifish.baseclass.BaseGradeMonitorActivity;
+import com.ifish.geewe.Camera;
+import com.ifish.geewe.Constants;
+import com.ifish.geewe.UDPHelper;
+import com.ifish.utils.Commons;
+import com.ifish.utils.Commons.LoginSPKey;
+import com.ifish.utils.Commons.NetWork;
+import com.ifish.utils.Commons.Text;
+import com.ifish.utils.HttpListener;
+import com.ifish.utils.HttpManager;
+import com.ifish.utils.L;
+import com.ifish.utils.SPUtil;
+import com.ifish.utils.ToastUtil;
+import com.lsemtmf.genersdk.tools.emtmf.EMTMFSDK;
+import com.lsemtmf.genersdk.tools.emtmf.EMTMFSDKListener;
+import com.mediatek.elian.ElianNative;
+import com.p2p.core.P2PHandler;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import de.greenrobot.event.EventBus;
+
+/**
+ * @ClassName: WaitCameraActivity
+ * @Description: 绑定摄像头等待界面
+ * @author Jacky dada
+ * @date 2016-6-28 上午10:35:53
+ */
+public class WaitCameraActivity extends BaseActivity {
+ private WifiManager.MulticastLock lock;
+ private String ssid="", pwd="";
+ private byte type;
+ private ElianNative elain;
+ private long TimeOut=110 * 1000;//110S超时时间
+ public Handler myhandler = new Handler();
+ private boolean isReceive = false;
+ private boolean isSendWifiStop = true;
+ private boolean isTimerCancel = true;
+ private boolean isFinish = false;//返回键退出
+ private Timer mTimer;
+ private int time;
+ public UDPHelper mHelper;
+ private Camera mCamera;
+ private HttpManager hm=HttpManager.getInstance();
+ private Camera userCamera;
+ private SPUtil sp;
+ private EMTMFSDK waveSDK;
+ private EMTMFSDKListener waveSDKListener;
+ private CountDownTimer waveTimer;
+ private String FinishTips="绑定中,请稍候操作...";
+ static {
+ System.loadLibrary("elianjni");//加载空中发包动态库
+ }
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.waitcamera_activity);
+ init();
+ initListener();
+ initSoundWaveSDK();
+ startWaveTimer();
+ setAudio();
+ }
+ private void initListener(){
+ findViewById(R.id.view_goback).setOnClickListener(this);
+ findViewById(R.id.view_explain).setOnClickListener(this);
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()){
+ case R.id.view_goback:{
+ ToastUtil.show(WaitCameraActivity.this,FinishTips);
+ break;
+ }
+ case R.id.view_explain:{
+ ToastUtil.show(WaitCameraActivity.this,FinishTips);
+ break;
+ }
+ }
+ }
+
+
+ private void setAudio() {//给手机调大媒体音量到75% 确保摄像头能听到声波
+ AudioManager audiomanage = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
+ int streamMaxVolume = audiomanage.getStreamMaxVolume(AudioManager.STREAM_MUSIC);//得到当前手机最大媒体音量,然后乘以75% 并设置给手机
+ streamMaxVolume=(int) (streamMaxVolume*0.75);
+ audiomanage.setStreamVolume(AudioManager.STREAM_MUSIC,streamMaxVolume, 0);
+ }
+ private void initSoundWaveSDK() {//初始化声波sdk
+ waveSDK = EMTMFSDK.getInstance(WaitCameraActivity.this);
+ waveSDK.initSDK(WaitCameraActivity.this, "gwelltimes", "gwelltimes", "gm8135s-8136", "11625ae8060111e6b5123e1d05defe78");//初始化声波sdk
+ waveSDK.startConnectTimeOutListener(getApplicationContext());//在听到设备播放接收成功后可以出发调用此方法,对设备连接失败的超时进行限制
+ waveSDKListener = new EMTMFSDKListener() {
+ public void didEndOfPlay() {//声波发送大约5秒后会结束,然后会调用此方法。在这里间隔2秒后继续发送下一次声波 无限循环,直到收到cameraId或者用户主动退出Activity为止
+ startWaveTimer();
+ }
+ };
+ waveSDK.setListener(waveSDKListener);//设置监听
+ }
+ private void startWaveTimer(){
+ if (waveTimer==null) {
+ waveTimer = new CountDownTimer(1900, 1900) {//延迟2秒发送声波,没有收到空中发包得到的cameraId则不停止计时器
+ public void onTick(long millisUntilFinished) {}
+ public void onFinish() {
+ waveSDK.sendWifiSet(WaitCameraActivity.this, ssid, pwd);//发送合成的声波
+ }
+ };
+ }
+ waveTimer.start();
+ }
+ private void stopWaveTimer(){
+ if (waveTimer!=null) {
+ waveTimer.cancel();
+ }
+ }
+ private void init() {
+ WifiManager manager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
+ lock = manager.createMulticastLock("localWifi");
+ ssid = getIntent().getStringExtra("ssidname");
+ pwd = getIntent().getStringExtra("wifiPwd");
+ type = getIntent().getByteExtra("type", (byte) -1);
+ excuteTimer();
+ lock.acquire();
+ mHelper = new UDPHelper(9988);
+ listen();
+ myhandler.postDelayed(mrunnable, TimeOut);
+ mHelper.StartListen();
+ sp = SPUtil.getInstance(WaitCameraActivity.this);
+ }
+ private void excuteTimer() {
+ mTimer = new Timer();
+ TimerTask mTask = new TimerTask() {
+ @Override
+ public void run() {
+ if (time < 3) {
+ sendWifiHandler.sendEmptyMessage(0);
+ } else {
+ sendWifiHandler.sendEmptyMessage(1);
+ }
+ }
+ };
+ mTimer.schedule(mTask, 500, 30 * 1000);
+ isTimerCancel = false;
+ }
+ private Handler sendWifiHandler = new Handler(new Handler.Callback() {
+ @Override
+ public boolean handleMessage(Message arg0) {
+ switch (arg0.what) {
+ case 0:
+ time++;
+ sendWifi();
+ L.i("第" + time + "次发包时间:" + getTime());
+ break;
+ case 1:
+ cancleTimer();
+ L.i("第" + time + "次停止计时器时间:" + getTime());
+ break;
+ case 2:
+ stopSendWifi();
+ L.i( "第" + time + "次停止发包时间:" + getTime());
+ break;
+
+ default:
+ break;
+ }
+ return false;
+ }
+ });
+ /**
+ * 发包 20秒后停止
+ */
+ private void sendWifi() {
+ if (elain == null) {
+ elain = new ElianNative();
+ }
+ if (null != ssid && !"".equals(ssid)) {
+ elain.InitSmartConnection(null, 1, 1);
+ elain.StartSmartConnection(ssid, pwd, "", type);
+ Log.e("wifi_mesg", "ssidname=" + ssid + "--" + "wifipwd=" + pwd
+ + "--" + "type=" + type);
+ isSendWifiStop = false;
+ }
+ sendWifiHandler.postDelayed(stopRunnable, 20 * 1000);
+ }
+
+ public Runnable stopRunnable = new Runnable() {
+ @Override
+ public void run() {
+ sendWifiHandler.sendEmptyMessage(2);
+ }
+ };
+
+ /**
+ * 停止发包
+ */
+ private void stopSendWifi() {
+ if (elain != null) {
+ elain.StopSmartConnection();
+ isSendWifiStop = true;
+ }
+ }
+ private void cancleTimer() {
+ if (mTimer != null) {
+ mTimer.cancel();
+ isTimerCancel = true;
+ }
+ }
+ private String getTime() {
+ String time = new SimpleDateFormat("HH:mm.ss").format(new Date());
+ return time;
+ }
+ public Runnable mrunnable = new Runnable() {
+
+ @Override
+ public void run() {
+ if (!isReceive) {
+ stopWaveTimer();//停止计时器
+ waveSDK.stopSend();//停止发送声波
+ ToastUtil.show(WaitCameraActivity.this, "设置WiFi超时");
+ Intent it = new Intent();
+ it.setAction(Constants.Action.RADAR_SET_WIFI_FAILED);
+ sendBroadcast(it);
+ // 跳转
+ finish();
+ EventBus.getDefault().post(new FinishWaitActivity());//让上一个界面显示输入框
+ }
+ }
+ };
+ void listen() {
+ mHelper.setCallBack(new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case UDPHelper.HANDLER_MESSAGE_BIND_ERROR:
+ ToastUtil.show(WaitCameraActivity.this, "端口被占用");
+ finish();
+ EventBus.getDefault().post(new FinishWaitActivity());//让上一个界面显示输入框
+ break;
+ case UDPHelper.HANDLER_MESSAGE_RECEIVE_MSG:
+ stopWaveTimer();//停止计时器
+ waveSDK.stopSend();//停止发送声波
+ isFinish=true;
+ isReceive = true;
+ mHelper.StopListen();
+ Bundle bundle = msg.getData();
+ String contactId = bundle.getString("contactId");//摄像头id
+ String ipFlag = bundle.getString("ipFlag");//ip 地址
+ mCamera = new Camera(contactId);
+ mCamera.ip=ipFlag;
+ String entryPassword = P2PHandler.getInstance().EntryPassword(HttpManager.Camera_psw);//转换密码
+ P2PHandler.getInstance().setInitPassword(mCamera.ip, entryPassword, HttpManager.Camera_psw, HttpManager.Camera_psw);//根据摄像头ip设置摄像头密码
+ EventBus.getDefault().post(mCamera);
+ //发送请求,摄像头id与用户关联
+ hm.bindCamera(new HttpListener>() {
+ private int result;
+ @Override
+ public void success(BaseBean baseBean) {
+ result = baseBean.result;
+ if (result==NetWork.Success) {
+ userCamera = baseBean.data;
+ }
+ }
+
+ @Override
+ public void finish() {
+ cameraHandler.sendEmptyMessage(result);
+ }
+
+ @Override
+ public void error(Exception e, String msg) {
+ result=NetWork.ERROR;
+ }
+ }, mCamera.cameraId, Commons.USER.getUserId());
+
+ break;
+ }
+ cancleTimer();
+ }
+
+ });
+ }
+ Handler cameraHandler = new Handler(){
+ private boolean isSameName=false;
+
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case NetWork.Success:
+ if (Commons.CAMERA.size()!=0) {
+ for (int i = 0; i < Commons.CAMERA.size(); i++) {
+ if (userCamera.cameraId.equals(Commons.CAMERA.get(i).cameraId)) {//相同的设备
+ isSameName=true;
+ Commons.CameraPosition=i;
+ sp.putInt(LoginSPKey.Camera_Position, i);
+ break;
+ }
+ }
+ }
+ if (!isSameName) {
+ Commons.CAMERA.add(userCamera);
+ Commons.CameraPosition=Commons.CAMERA.size()-1;
+ sp.putInt(LoginSPKey.Camera_Position, Commons.CAMERA.size()-1);
+ }
+ Commons.HAVE_CAMERA=true;
+ Commons.IS_CAMERA=true;
+ EventBus.getDefault().post(new RefreshCamera());
+ sp.putBoolean(LoginSPKey.IS_CAMERA, Commons.IS_CAMERA);
+ ToastUtil.show(WaitCameraActivity.this, "绑定摄像头成功");
+ Intent i=new Intent(WaitCameraActivity.this,MonitorActivity.class);
+ i.putExtra(BaseGradeMonitorActivity.BINDCAMERA,true);//绑定摄像头增加经验
+ startActivity(i);
+ Intent it = new Intent();
+ it.setAction(Constants.Action.RADAR_SET_WIFI_SUCCESS);
+ sendBroadcast(it);//发送上一个页面成功的广播 退出Activity
+ break;
+ case NetWork.Fail:
+ EventBus.getDefault().post(new FinishWaitActivity());//让上一个界面显示输入框
+ ToastUtil.show(WaitCameraActivity.this, "绑定摄像头失败 请重试");
+ break;
+ case NetWork.ERROR:
+ EventBus.getDefault().post(new FinishWaitActivity());//让上一个界面显示输入框
+ ToastUtil.show(getApplicationContext(), Text.ERROR);
+ break;
+ default:
+ EventBus.getDefault().post(new FinishWaitActivity());//让上一个界面显示输入框
+ ToastUtil.show(getApplicationContext(), Text.ServerException);
+ break;
+ }
+ finish();//销毁界面
+ }
+ };
+ @Override
+ public void onBackPressed() {
+// if (!isFinish) {
+// EventBus.getDefault().post(new FinishWaitActivity());//让上一个界面显示输入框
+// finish();
+// }else{
+//
+// }
+ ToastUtil.show(WaitCameraActivity.this,FinishTips);
+ }
+ @Override
+ protected void onPause() {
+ super.onPause();
+ if (!isSendWifiStop) {
+ stopSendWifi();
+ }
+ try {
+ if (lock.isHeld()) {
+ lock.release();
+ }
+ } catch (Exception e) {
+ }
+ }
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ stopWaveTimer();//停止计时器
+ waveSDK.stopSend();//停止发送声波
+ waveSDK.exitEMTFSDK(WaitCameraActivity.this);//释放声波sdk资源
+ myhandler.removeCallbacks(mrunnable);
+ sendWifiHandler.removeCallbacks(stopRunnable);
+ mHelper.StopListen();
+ if (!isTimerCancel) {
+ cancleTimer();
+ }
+ }
+}
diff --git a/iFish7/src/main/java/com/ifish/esptouch/EspAES.java b/iFish7/src/main/java/com/ifish/esptouch/EspAES.java
new file mode 100644
index 000000000..b89f476c8
--- /dev/null
+++ b/iFish7/src/main/java/com/ifish/esptouch/EspAES.java
@@ -0,0 +1,104 @@
+package com.espressif.iot.esptouch.util;
+
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+
+public class EspAES {
+ private static final String TRANSFORMATION_DEFAULT = "AES/ECB/PKCS5Padding";
+
+ private final byte[] mKey;
+ private final byte[] mIV;
+ private final String mTransformation;
+ private Cipher mEncryptCipher;
+ private Cipher mDecryptCipher;
+
+ public EspAES(byte[] key) {
+ this(key, null, TRANSFORMATION_DEFAULT);
+ }
+
+ public EspAES(byte[] key, String transformation) {
+ this(key, null, transformation);
+ }
+
+ public EspAES(byte[] key, byte[] iv) {
+ this(key, iv, TRANSFORMATION_DEFAULT);
+ }
+
+ public EspAES(byte[] key, byte[] iv, String transformation) {
+ mKey = key;
+ mIV = iv;
+ mTransformation = transformation;
+
+ mEncryptCipher = createEncryptCipher();
+ mDecryptCipher = createDecryptCipher();
+ }
+
+ private Cipher createEncryptCipher() {
+ try {
+ Cipher cipher = Cipher.getInstance(mTransformation);
+
+ SecretKeySpec secretKeySpec = new SecretKeySpec(mKey, "AES");
+ if (mIV == null) {
+ cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);
+ } else {
+ IvParameterSpec parameterSpec = new IvParameterSpec(mIV);
+ cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, parameterSpec);
+ }
+
+ return cipher;
+ } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException
+ e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ private Cipher createDecryptCipher() {
+ try {
+ Cipher cipher = Cipher.getInstance(mTransformation);
+
+ SecretKeySpec secretKeySpec = new SecretKeySpec(mKey, "AES");
+ if (mIV == null) {
+ cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);
+ } else {
+ IvParameterSpec parameterSpec = new IvParameterSpec(mIV);
+ cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, parameterSpec);
+ }
+
+ return cipher;
+ } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException
+ e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ public byte[] encrypt(byte[] content) {
+ try {
+ return mEncryptCipher.doFinal(content);
+ } catch (BadPaddingException | IllegalBlockSizeException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public byte[] decrypt(byte[] content) {
+ try {
+ return mDecryptCipher.doFinal(content);
+ } catch (BadPaddingException | IllegalBlockSizeException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+}
diff --git a/iFish7/src/main/java/com/ifish/esptouch/IEsptouchListener.java b/iFish7/src/main/java/com/ifish/esptouch/IEsptouchListener.java
new file mode 100644
index 000000000..4c9d992c4
--- /dev/null
+++ b/iFish7/src/main/java/com/ifish/esptouch/IEsptouchListener.java
@@ -0,0 +1,11 @@
+package com.espressif.iot.esptouch;
+
+public interface IEsptouchListener {
+ /**
+ * when new esptouch result is added, the listener will call
+ * onEsptouchResultAdded callback
+ *
+ * @param result the Esptouch result
+ */
+ void onEsptouchResultAdded(IEsptouchResult result);
+}
diff --git a/iFish7/src/main/java/com/ifish/esptouch/TouchData.java b/iFish7/src/main/java/com/ifish/esptouch/TouchData.java
new file mode 100644
index 000000000..f96afaf07
--- /dev/null
+++ b/iFish7/src/main/java/com/ifish/esptouch/TouchData.java
@@ -0,0 +1,22 @@
+package com.espressif.iot.esptouch.protocol;
+
+import com.espressif.iot.esptouch.util.ByteUtil;
+
+public class TouchData {
+ private final byte[] mData;
+
+ public TouchData(String string) {
+ mData = ByteUtil.getBytesByString(string);
+ }
+
+ public TouchData(byte[] data) {
+ if (data == null) {
+ throw new NullPointerException("data can't be null");
+ }
+ mData = data;
+ }
+
+ public byte[] getData() {
+ return mData;
+ }
+}
diff --git a/iFish7/src/main/java/com/ifish/esptouch/TouchNetUtil.java b/iFish7/src/main/java/com/ifish/esptouch/TouchNetUtil.java
new file mode 100644
index 000000000..e9bcf9237
--- /dev/null
+++ b/iFish7/src/main/java/com/ifish/esptouch/TouchNetUtil.java
@@ -0,0 +1,123 @@
+package com.espressif.iot.esptouch.util;
+
+import android.content.Context;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+public class TouchNetUtil {
+
+ /**
+ * get the local ip address by Android System
+ *
+ * @param context the context
+ * @return the local ip addr allocated by Ap
+ */
+ public static InetAddress getLocalInetAddress(Context context) {
+ WifiManager wm = (WifiManager) context
+ .getSystemService(Context.WIFI_SERVICE);
+ WifiInfo wifiInfo = wm.getConnectionInfo();
+ int localAddrInt = wifiInfo.getIpAddress();
+ String localAddrStr = __formatString(localAddrInt);
+ InetAddress localInetAddr = null;
+ try {
+ localInetAddr = InetAddress.getByName(localAddrStr);
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ }
+ return localInetAddr;
+ }
+
+ private static String __formatString(int value) {
+ String strValue = "";
+ byte[] ary = __intToByteArray(value);
+ for (int i = ary.length - 1; i >= 0; i--) {
+ strValue += (ary[i] & 0xFF);
+ if (i > 0) {
+ strValue += ".";
+ }
+ }
+ return strValue;
+ }
+
+ private static byte[] __intToByteArray(int value) {
+ byte[] b = new byte[4];
+ for (int i = 0; i < 4; i++) {
+ int offset = (b.length - 1 - i) * 8;
+ b[i] = (byte) ((value >>> offset) & 0xFF);
+ }
+ return b;
+ }
+
+ /**
+ * parse InetAddress
+ *
+ * @param inetAddrBytes
+ * @return
+ */
+ public static InetAddress parseInetAddr(byte[] inetAddrBytes, int offset,
+ int count) {
+ InetAddress inetAddress = null;
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < count; i++) {
+ sb.append(Integer.toString(inetAddrBytes[offset + i] & 0xff));
+ if (i != count - 1) {
+ sb.append('.');
+ }
+ }
+ try {
+ inetAddress = InetAddress.getByName(sb.toString());
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ }
+ return inetAddress;
+ }
+
+ /**
+ * parse bssid
+ *
+ * @param bssid the bssid like aa:bb:cc:dd:ee:ff
+ * @return byte converted from bssid
+ */
+ public static byte[] parseBssid2bytes(String bssid) {
+ String bssidSplits[] = bssid.split(":");
+ byte[] result = new byte[bssidSplits.length];
+ for (int i = 0; i < bssidSplits.length; i++) {
+ result[i] = (byte) Integer.parseInt(bssidSplits[i], 16);
+ }
+ return result;
+ }
+
+ public static byte[] getOriginalSsidBytes(WifiInfo info) {
+ try {
+ Method method = info.getClass().getMethod("getWifiSsid");
+ if (method == null) {
+ return null;
+ }
+ method.setAccessible(true);
+ Object wifiSsid = method.invoke(info);
+ if (wifiSsid == null) {
+ return null;
+ }
+ method = wifiSsid.getClass().getMethod("getOctets");
+ if (method == null) {
+ return null;
+ }
+ method.setAccessible(true);
+ return (byte[]) method.invoke(wifiSsid);
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+}
diff --git a/iFish7/src/main/jniLibs/armeabi-v7a/libSDL.so b/iFish7/src/main/jniLibs/armeabi-v7a/libSDL.so
deleted file mode 100644
index 9be9c9d69..000000000
Binary files a/iFish7/src/main/jniLibs/armeabi-v7a/libSDL.so and /dev/null differ
diff --git a/iFish7/src/main/jniLibs/armeabi-v7a/libelianjni.so b/iFish7/src/main/jniLibs/armeabi-v7a/libelianjni.so
deleted file mode 100644
index 93da5de46..000000000
Binary files a/iFish7/src/main/jniLibs/armeabi-v7a/libelianjni.so and /dev/null differ
diff --git a/iFish7/src/main/jniLibs/armeabi-v7a/liblarksmarkemtmfJNI.so b/iFish7/src/main/jniLibs/armeabi-v7a/liblarksmarkemtmfJNI.so
deleted file mode 100644
index e5b70f6c5..000000000
Binary files a/iFish7/src/main/jniLibs/armeabi-v7a/liblarksmarkemtmfJNI.so and /dev/null differ
diff --git a/iFish7/src/main/jniLibs/armeabi-v7a/liblocSDK6a.so b/iFish7/src/main/jniLibs/armeabi-v7a/liblocSDK6a.so
deleted file mode 100644
index 56278b236..000000000
Binary files a/iFish7/src/main/jniLibs/armeabi-v7a/liblocSDK6a.so and /dev/null differ
diff --git a/iFish7/src/main/jniLibs/armeabi-v7a/libmediaplayer.so b/iFish7/src/main/jniLibs/armeabi-v7a/libmediaplayer.so
deleted file mode 100644
index 77f51841b..000000000
Binary files a/iFish7/src/main/jniLibs/armeabi-v7a/libmediaplayer.so and /dev/null differ
diff --git a/iFish7/src/main/jniLibs/armeabi/libSDL.so b/iFish7/src/main/jniLibs/armeabi/libSDL.so
deleted file mode 100644
index 9be9c9d69..000000000
Binary files a/iFish7/src/main/jniLibs/armeabi/libSDL.so and /dev/null differ
diff --git a/iFish7/src/main/jniLibs/armeabi/libmediaplayer.so b/iFish7/src/main/jniLibs/armeabi/libmediaplayer.so
deleted file mode 100644
index 77f51841b..000000000
Binary files a/iFish7/src/main/jniLibs/armeabi/libmediaplayer.so and /dev/null differ
diff --git a/p2PCore/build.gradle b/p2PCore/build.gradle
deleted file mode 100644
index f54b0d072..000000000
--- a/p2PCore/build.gradle
+++ /dev/null
@@ -1,24 +0,0 @@
-apply plugin: 'com.android.library'
-
-android {
- useLibrary 'org.apache.http.legacy'
- compileSdkVersion rootProject.ext.compileSdkVersion
- buildToolsVersion rootProject.ext.buildToolsVersion
-
- defaultConfig {
- minSdkVersion rootProject.ext.minSdkVersion
- targetSdkVersion rootProject.ext.targetSdkVersion
- }
-
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
- }
- }
-}
-
-dependencies {
- compile files('libs/javabase64.jar')
- compile 'com.android.support:support-v4:23+'
-}
diff --git a/p2PCore/build/generated/source/buildConfig/androidTest/debug/com/example/p2p_core/test/BuildConfig.java b/p2PCore/build/generated/source/buildConfig/androidTest/debug/com/example/p2p_core/test/BuildConfig.java
deleted file mode 100644
index b6e1a3a6f..000000000
--- a/p2PCore/build/generated/source/buildConfig/androidTest/debug/com/example/p2p_core/test/BuildConfig.java
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * Automatically generated file. DO NOT MODIFY
- */
-package com.example.p2p_core.test;
-
-public final class BuildConfig {
- public static final boolean DEBUG = Boolean.parseBoolean("true");
- public static final String APPLICATION_ID = "com.example.p2p_core.test";
- public static final String BUILD_TYPE = "debug";
- public static final String FLAVOR = "";
- public static final int VERSION_CODE = -1;
- public static final String VERSION_NAME = "";
-}
diff --git a/p2PCore/build/generated/source/buildConfig/debug/com/example/p2p_core/BuildConfig.java b/p2PCore/build/generated/source/buildConfig/debug/com/example/p2p_core/BuildConfig.java
deleted file mode 100644
index d811fd183..000000000
--- a/p2PCore/build/generated/source/buildConfig/debug/com/example/p2p_core/BuildConfig.java
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * Automatically generated file. DO NOT MODIFY
- */
-package com.example.p2p_core;
-
-public final class BuildConfig {
- public static final boolean DEBUG = Boolean.parseBoolean("true");
- public static final String APPLICATION_ID = "com.example.p2p_core";
- public static final String BUILD_TYPE = "debug";
- public static final String FLAVOR = "";
- public static final int VERSION_CODE = -1;
- public static final String VERSION_NAME = "";
-}
diff --git a/p2PCore/build/generated/source/r/androidTest/debug/android/support/v4/R.java b/p2PCore/build/generated/source/r/androidTest/debug/android/support/v4/R.java
deleted file mode 100644
index 4ce195487..000000000
--- a/p2PCore/build/generated/source/r/androidTest/debug/android/support/v4/R.java
+++ /dev/null
@@ -1,10 +0,0 @@
-/* AUTO-GENERATED FILE. DO NOT MODIFY.
- *
- * This class was automatically generated by the
- * gradle plugin from the resource data it found. It
- * should not be modified by hand.
- */
-package android.support.v4;
-
-public final class R {
-}
diff --git a/p2PCore/build/generated/source/r/androidTest/debug/com/example/p2p_core/R.java b/p2PCore/build/generated/source/r/androidTest/debug/com/example/p2p_core/R.java
deleted file mode 100644
index f287fbf8f..000000000
--- a/p2PCore/build/generated/source/r/androidTest/debug/com/example/p2p_core/R.java
+++ /dev/null
@@ -1,10 +0,0 @@
-/* AUTO-GENERATED FILE. DO NOT MODIFY.
- *
- * This class was automatically generated by the
- * gradle plugin from the resource data it found. It
- * should not be modified by hand.
- */
-package com.example.p2p_core;
-
-public final class R {
-}
diff --git a/p2PCore/build/generated/source/r/debug/android/support/v4/R.java b/p2PCore/build/generated/source/r/debug/android/support/v4/R.java
deleted file mode 100644
index 4ce195487..000000000
--- a/p2PCore/build/generated/source/r/debug/android/support/v4/R.java
+++ /dev/null
@@ -1,10 +0,0 @@
-/* AUTO-GENERATED FILE. DO NOT MODIFY.
- *
- * This class was automatically generated by the
- * gradle plugin from the resource data it found. It
- * should not be modified by hand.
- */
-package android.support.v4;
-
-public final class R {
-}
diff --git a/p2PCore/build/intermediates/bundles/debug/AndroidManifest.xml b/p2PCore/build/intermediates/bundles/debug/AndroidManifest.xml
deleted file mode 100644
index 44720a37c..000000000
--- a/p2PCore/build/intermediates/bundles/debug/AndroidManifest.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/p2PCore/build/intermediates/bundles/default/AndroidManifest.xml b/p2PCore/build/intermediates/bundles/default/AndroidManifest.xml
deleted file mode 100644
index 44720a37c..000000000
--- a/p2PCore/build/intermediates/bundles/default/AndroidManifest.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/p2PCore/build/intermediates/incremental/compileDebugAidl/dependency.store b/p2PCore/build/intermediates/incremental/compileDebugAidl/dependency.store
deleted file mode 100644
index 8b8400dcf..000000000
Binary files a/p2PCore/build/intermediates/incremental/compileDebugAidl/dependency.store and /dev/null differ
diff --git a/p2PCore/build/intermediates/incremental/compileDebugAndroidTestAidl/dependency.store b/p2PCore/build/intermediates/incremental/compileDebugAndroidTestAidl/dependency.store
deleted file mode 100644
index 8b8400dcf..000000000
Binary files a/p2PCore/build/intermediates/incremental/compileDebugAndroidTestAidl/dependency.store and /dev/null differ
diff --git a/p2PCore/build/intermediates/incremental/compileReleaseAidl/dependency.store b/p2PCore/build/intermediates/incremental/compileReleaseAidl/dependency.store
deleted file mode 100644
index 8b8400dcf..000000000
Binary files a/p2PCore/build/intermediates/incremental/compileReleaseAidl/dependency.store and /dev/null differ
diff --git a/p2PCore/build/intermediates/incremental/mergeDebugAndroidTestResources/compile-file-map.properties b/p2PCore/build/intermediates/incremental/mergeDebugAndroidTestResources/compile-file-map.properties
deleted file mode 100644
index 7105eb8bc..000000000
--- a/p2PCore/build/intermediates/incremental/mergeDebugAndroidTestResources/compile-file-map.properties
+++ /dev/null
@@ -1 +0,0 @@
-#Mon Jun 10 20:47:20 CST 2019
diff --git a/p2PCore/build/intermediates/incremental/mergeDebugAndroidTestResources/merger.xml b/p2PCore/build/intermediates/incremental/mergeDebugAndroidTestResources/merger.xml
deleted file mode 100644
index 6ef5037b6..000000000
--- a/p2PCore/build/intermediates/incremental/mergeDebugAndroidTestResources/merger.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/p2PCore/build/intermediates/incremental/mergeDebugAssets/merger.xml b/p2PCore/build/intermediates/incremental/mergeDebugAssets/merger.xml
deleted file mode 100644
index 3b96724ee..000000000
--- a/p2PCore/build/intermediates/incremental/mergeDebugAssets/merger.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/p2PCore/build/intermediates/incremental/mergeDebugResources/compile-file-map.properties b/p2PCore/build/intermediates/incremental/mergeDebugResources/compile-file-map.properties
deleted file mode 100644
index 7105eb8bc..000000000
--- a/p2PCore/build/intermediates/incremental/mergeDebugResources/compile-file-map.properties
+++ /dev/null
@@ -1 +0,0 @@
-#Mon Jun 10 20:47:20 CST 2019
diff --git a/p2PCore/build/intermediates/incremental/mergeDebugResources/merger.xml b/p2PCore/build/intermediates/incremental/mergeDebugResources/merger.xml
deleted file mode 100644
index 413ba0488..000000000
--- a/p2PCore/build/intermediates/incremental/mergeDebugResources/merger.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/p2PCore/build/intermediates/incremental/mergeDebugShaders/merger.xml b/p2PCore/build/intermediates/incremental/mergeDebugShaders/merger.xml
deleted file mode 100644
index 1808bc156..000000000
--- a/p2PCore/build/intermediates/incremental/mergeDebugShaders/merger.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/p2PCore/build/intermediates/incremental/mergeReleaseAssets/merger.xml b/p2PCore/build/intermediates/incremental/mergeReleaseAssets/merger.xml
deleted file mode 100644
index 2b76365b4..000000000
--- a/p2PCore/build/intermediates/incremental/mergeReleaseAssets/merger.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/p2PCore/build/intermediates/incremental/mergeReleaseShaders/merger.xml b/p2PCore/build/intermediates/incremental/mergeReleaseShaders/merger.xml
deleted file mode 100644
index 31760a4a3..000000000
--- a/p2PCore/build/intermediates/incremental/mergeReleaseShaders/merger.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/p2PCore/build/intermediates/incremental/packageDebugResources/compile-file-map.properties b/p2PCore/build/intermediates/incremental/packageDebugResources/compile-file-map.properties
deleted file mode 100644
index 7105eb8bc..000000000
--- a/p2PCore/build/intermediates/incremental/packageDebugResources/compile-file-map.properties
+++ /dev/null
@@ -1 +0,0 @@
-#Mon Jun 10 20:47:20 CST 2019
diff --git a/p2PCore/build/intermediates/incremental/packageDebugResources/merger.xml b/p2PCore/build/intermediates/incremental/packageDebugResources/merger.xml
deleted file mode 100644
index e915772c8..000000000
--- a/p2PCore/build/intermediates/incremental/packageDebugResources/merger.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/p2PCore/build/intermediates/incremental/packageReleaseResources/compile-file-map.properties b/p2PCore/build/intermediates/incremental/packageReleaseResources/compile-file-map.properties
deleted file mode 100644
index 5225ca789..000000000
--- a/p2PCore/build/intermediates/incremental/packageReleaseResources/compile-file-map.properties
+++ /dev/null
@@ -1 +0,0 @@
-#Mon Jun 10 20:47:12 CST 2019
diff --git a/p2PCore/build/intermediates/incremental/packageReleaseResources/merger.xml b/p2PCore/build/intermediates/incremental/packageReleaseResources/merger.xml
deleted file mode 100644
index e4cccbc51..000000000
--- a/p2PCore/build/intermediates/incremental/packageReleaseResources/merger.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/p2PCore/build/intermediates/manifest/androidTest/debug/AndroidManifest.xml b/p2PCore/build/intermediates/manifest/androidTest/debug/AndroidManifest.xml
deleted file mode 100644
index a0b7ee716..000000000
--- a/p2PCore/build/intermediates/manifest/androidTest/debug/AndroidManifest.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/p2PCore/build/intermediates/manifests/aapt/debug/AndroidManifest.xml b/p2PCore/build/intermediates/manifests/aapt/debug/AndroidManifest.xml
deleted file mode 100644
index 44720a37c..000000000
--- a/p2PCore/build/intermediates/manifests/aapt/debug/AndroidManifest.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/p2PCore/build/intermediates/manifests/aapt/release/AndroidManifest.xml b/p2PCore/build/intermediates/manifests/aapt/release/AndroidManifest.xml
deleted file mode 100644
index 44720a37c..000000000
--- a/p2PCore/build/intermediates/manifests/aapt/release/AndroidManifest.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/p2PCore/build/intermediates/res/resources-debug-androidTest.ap_ b/p2PCore/build/intermediates/res/resources-debug-androidTest.ap_
deleted file mode 100644
index cb24bf983..000000000
Binary files a/p2PCore/build/intermediates/res/resources-debug-androidTest.ap_ and /dev/null differ
diff --git a/p2PCore/build/outputs/aar/p2PCore-debug.aar b/p2PCore/build/outputs/aar/p2PCore-debug.aar
deleted file mode 100644
index 10d288fce..000000000
Binary files a/p2PCore/build/outputs/aar/p2PCore-debug.aar and /dev/null differ
diff --git a/p2PCore/build/outputs/aar/p2PCore-release.aar b/p2PCore/build/outputs/aar/p2PCore-release.aar
deleted file mode 100644
index 826288a96..000000000
Binary files a/p2PCore/build/outputs/aar/p2PCore-release.aar and /dev/null differ
diff --git a/p2PCore/libs/javabase64.jar b/p2PCore/libs/javabase64.jar
deleted file mode 100644
index b152c8921..000000000
Binary files a/p2PCore/libs/javabase64.jar and /dev/null differ
diff --git a/p2PCore/p2PCore.iml b/p2PCore/p2PCore.iml
deleted file mode 100644
index 9aeac6257..000000000
--- a/p2PCore/p2PCore.iml
+++ /dev/null
@@ -1,102 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- generateDebugSources
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/p2PCore/src/main/AndroidManifest.xml b/p2PCore/src/main/AndroidManifest.xml
deleted file mode 100644
index 7499200ea..000000000
--- a/p2PCore/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/p2PCore/src/main/java/com/p2p/core/BaseCallActivity.java b/p2PCore/src/main/java/com/p2p/core/BaseCallActivity.java
deleted file mode 100644
index 14d5adb22..000000000
--- a/p2PCore/src/main/java/com/p2p/core/BaseCallActivity.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.p2p.core;
-
-
-public abstract class BaseCallActivity extends BaseCoreActivity{
-
-
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/BaseCoreActivity.java b/p2PCore/src/main/java/com/p2p/core/BaseCoreActivity.java
deleted file mode 100644
index 7d1d28013..000000000
--- a/p2PCore/src/main/java/com/p2p/core/BaseCoreActivity.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package com.p2p.core;
-
-import java.util.HashMap;
-import java.util.Set;
-
-import android.support.v4.app.FragmentActivity;
-import android.util.Log;
-
-import com.p2p.core.global.Constants;
-import com.p2p.core.utils.HomeWatcher;
-import com.p2p.core.utils.OnHomePressedListener;
-
-public abstract class BaseCoreActivity extends FragmentActivity implements
- OnHomePressedListener {
- private boolean isGoExit = false;
- protected static HashMap activity_stack = new HashMap();
- public HomeWatcher mHomeWatcher;
-
- private void onStackChange() {
- Set keys = activity_stack.keySet();
- int start = 0;
- int stop = 0;
- for (Integer key : keys) {
- int status = activity_stack.get(key);
- if (status == Constants.ActivityStatus.STATUS_START) {
- start++;
- } else if (status == Constants.ActivityStatus.STATUS_STOP) {
- stop++;
- }
- }
-
- if (activity_stack.size() > 0 && start == 0) {
- if (!isGoExit) {
- onGoBack();
- }
- } else if (activity_stack.size() > 0 && start > 0) {
- onGoFront();
- }
- Log.e("my", "stack size:" + activity_stack.size() + " start:"
- + start + " stop:" + stop);
- }
-
- @Override
- public void onStop() {
- // TODO Auto-generated method stub
- super.onStop();
- if (mHomeWatcher != null) {
- mHomeWatcher.stopWatch();
- mHomeWatcher = null;
- }
- activity_stack.put(getActivityInfo(),
- Constants.ActivityStatus.STATUS_STOP);
- onStackChange();
- }
-
- // 应用程序是否在前台运行
- protected boolean isOnFront() {
- Set keys = activity_stack.keySet();
- int start = 0;
- int stop = 0;
- for (Integer key : keys) {
- int status = activity_stack.get(key);
- if (status == Constants.ActivityStatus.STATUS_START) {
- start++;
- } else if (status == Constants.ActivityStatus.STATUS_STOP) {
- stop++;
- }
- }
-
- if (activity_stack.size() > 0 && start == 0) {
- return false;
- } else {
- return true;
- }
- }
-
- @Override
- protected void onStart() {
- // TODO Auto-generated method stub
- super.onStart();
- mHomeWatcher = new HomeWatcher(this);
- mHomeWatcher.setOnHomePressedListener(this);
- mHomeWatcher.startWatch();
- activity_stack.put(getActivityInfo(),
- Constants.ActivityStatus.STATUS_START);
- onStackChange();
- }
-
- @Override
- protected void onDestroy() {
- // TODO Auto-generated method stub
- super.onDestroy();
- activity_stack.remove(getActivityInfo());
- onStackChange();
- }
-
- // 每个继承的activity必须返回不同的值
- public abstract int getActivityInfo();
-
- protected void isGoExit(boolean isGoExit) {
- this.isGoExit = isGoExit;
- }
-
- // Home键按下时回调
- @Override
- public void onHomePressed() {
- // TODO Auto-generated method stub
-
- }
-
- // Home键长按下时回调
- @Override
- public void onHomeLongPressed() {
- // TODO Auto-generated method stub
-
- }
- // 进入后台
- protected abstract void onGoBack();
-
- // 进入前台
- protected abstract void onGoFront();
-
- // 退出应用
- protected abstract void onExit();
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/BaseMonitorActivity.java b/p2PCore/src/main/java/com/p2p/core/BaseMonitorActivity.java
deleted file mode 100644
index 12bdf0e35..000000000
--- a/p2PCore/src/main/java/com/p2p/core/BaseMonitorActivity.java
+++ /dev/null
@@ -1,290 +0,0 @@
-package com.p2p.core;
-
-import android.app.Activity;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.view.MotionEvent;
-import android.view.inputmethod.InputMethodManager;
-
-import com.p2p.core.global.Constants;
-import com.p2p.core.utils.MyUtils;
-
-import java.io.IOException;
-
-public abstract class BaseMonitorActivity extends BaseCoreActivity {
- private final int MSG_SHOW_CAPTURERESULT = 0x00002;
- public static int mVideoFrameRate = 15;
- private final int MINX = 50;
- private final int MINY = 25;
- private final int USR_CMD_OPTION_PTZ_TURN_LEFT = 0;
- private final int USR_CMD_OPTION_PTZ_TURN_RIGHT = 1;
- private final int USR_CMD_OPTION_PTZ_TURN_UP = 2;
- private final int USR_CMD_OPTION_PTZ_TURN_DOWN = 3;
- public P2PView pView;
- boolean isBaseRegFilter = false;
- public boolean isFullScreen = false;
- public boolean isLand = true;// 是否全屏
- private int PrePoint=-1;
- public static String contactId;
- public static String password;
-
- private Handler mHandler = new Handler(new Handler.Callback() {
- @Override
- public boolean handleMessage(Message msg) {
- switch (msg.what) {
- case MSG_SHOW_CAPTURERESULT:
- if (msg.arg1 == 1) {
- onCaptureScreenResult(true,PrePoint);
- } else {
- onCaptureScreenResult(false,PrePoint);
- }
- break;
- default:
- break;
- }
- return false;
- }
- });
-
- protected void onCreate(Bundle savedInstanceState) {
- // TODO Auto-generated method stub
- super.onCreate(savedInstanceState);
-
- baseRegFilter();
- MediaPlayer.getInstance().setCaptureListener(
- new CaptureListener(mHandler));
- L.i(this.getClass().getName()+"----------------onCreate");
- }
- /**
- *
- * @Description: 隐藏输入法
- * @author Jacky dada
- * @param
- * @date 2015-9-4 下午6:23:11
- */
- protected void hideKeyboard() {
- InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
- try {
- imm.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
- } catch (Exception e) {
- // 这里可能会报空指针错误
- }
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- L.i(this.getClass().getName()+"----------------onStart");
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- L.i(this.getClass().getName()+"----------------onResume");
- }
-
- @Override
- protected void onRestart() {
- super.onRestart();
- L.i(this.getClass().getName()+"----------------onRestart");
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- L.i(this.getClass().getName()+"----------------onPause");
- }
-
- @Override
- public void onStop() {
- super.onStop();
- L.i(this.getClass().getName()+"----------------onStop");
- }
-
-
- public void initP2PView(int type) {
- pView.setCallBack();
- pView.setGestureDetector(new GestureDetector(this,
- new GestureListener(), null, true));
- pView.setDeviceType(type);
- }
-
- public void initScaleView(Activity activity, int windowWidth,
- int windowHeight) {
- pView.setmActivity(activity);
- pView.setScreen_W(windowHeight);
- pView.setScreen_H(windowWidth);
- pView.initScaleView();
- }
-
- private void baseRegFilter() {
- IntentFilter filter = new IntentFilter();
- filter.addAction(Constants.P2P_WINDOW.Action.P2P_WINDOW_READY_TO_START);
- this.registerReceiver(baseReceiver, filter);
- isBaseRegFilter = true;
- }
-
- public void setMute(boolean bool) {
- try {
- MediaPlayer.getInstance()._SetMute(bool);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
-
- public void setIsLand(boolean isLan) {
- this.isLand = isLan;
- }
-
- private BroadcastReceiver baseReceiver = new BroadcastReceiver() {
-
- @Override
- public void onReceive(Context arg0, Intent intent) {
- if (intent.getAction().equals(
- Constants.P2P_WINDOW.Action.P2P_WINDOW_READY_TO_START)) {
- final MediaPlayer mPlayer = MediaPlayer.getInstance();
- new Thread(new Runnable() {
- @Override
- public void run() {
- MediaPlayer.nativeInit(mPlayer);
- try {
- mPlayer.setDisplay(pView);
- } catch (IOException e) {
- e.printStackTrace();
- }
- mPlayer.start(mVideoFrameRate);
- setMute(true);
- }
- }).start();
- }
- }
- };
-
- private class GestureListener extends
- GestureDetector.SimpleOnGestureListener {
- @Override
- public boolean onSingleTapConfirmed(MotionEvent e) {
- onP2PViewSingleTap();
- return super.onSingleTapConfirmed(e);
- }
-
- @Override
- public boolean onSingleTapUp(MotionEvent e) {
- return super.onSingleTapUp(e);
- }
-
- @Override
- public boolean onDoubleTap(MotionEvent e) {
- if (isLand) {
- if (!isFullScreen) {
- isFullScreen = true;
- pView.fullScreen();
- } else {
- isFullScreen = false;
- pView.halfScreen();
- }
- }
-
- return super.onDoubleTap(e);
- }
-
-
- @Override
- public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
- float velocityY) {
- int id = -1;
- float distance = 0;
- boolean ishorizontal = false;
- if ((Math.abs(e2.getX() - e1.getX())) > (Math.abs(e2.getY()
- - e1.getY()))) {
- ishorizontal = true;
- }
-
- if (ishorizontal) {
- distance = e2.getX() - e1.getX();
- if (Math.abs(distance) > MyUtils.dip2px(
- BaseMonitorActivity.this, MINX)) {
- if (distance > 0) {
- id = USR_CMD_OPTION_PTZ_TURN_RIGHT;
- } else {
- id = USR_CMD_OPTION_PTZ_TURN_LEFT;
- }
- }
- } else {
- distance = e2.getY() - e1.getY();
- if (Math.abs(distance) > MyUtils.dip2px(
- BaseMonitorActivity.this, MINY)) {
- if (distance > 0) {
- id = USR_CMD_OPTION_PTZ_TURN_UP;
- } else {
- id = USR_CMD_OPTION_PTZ_TURN_DOWN;
- }
- }
- }
-
- if (id != -1) {
- MediaPlayer.getInstance().native_p2p_control(id);
-// if(id==USR_CMD_OPTION_PTZ_TURN_UP){
-// P2PHandler.getInstance().controlCamera(contactId, password,MyUtils.btop);
-// }else if(id==USR_CMD_OPTION_PTZ_TURN_DOWN){
-// P2PHandler.getInstance().controlCamera(contactId, password,MyUtils.bbottom);
-// }else if(id==USR_CMD_OPTION_PTZ_TURN_LEFT){
-// P2PHandler.getInstance().controlCamera(contactId, password,MyUtils.bleft);
-// }else if(id==USR_CMD_OPTION_PTZ_TURN_RIGHT){
-// P2PHandler.getInstance().controlCamera(contactId, password,MyUtils.bright);
-// }
- } else {
- }
-
- return true;
- }
- }
-
- private class CaptureListener implements MediaPlayer.ICapture {
- Handler mSubHandler;
-
- public CaptureListener(Handler handler) {
- mSubHandler = handler;
- }
-
- @Override
- public void vCaptureResult(int result) {
- Message msg = new Message();
- msg.what = MSG_SHOW_CAPTURERESULT;
- msg.arg1 = result;
- mSubHandler.sendMessage(msg);
- }
- }
-
- /**
- * -1是普通截图,0~4是预置位截图
- * @param prePoint
- */
- public void captureScreen(int prePoint) {
- this.PrePoint=prePoint;
- try {
- MediaPlayer.getInstance()._CaptureScreen();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- L.i(this.getClass().getName()+"----------------onDestroy");
- if (isBaseRegFilter) {
- this.unregisterReceiver(baseReceiver);
- isBaseRegFilter = false;
- }
- }
-
- protected abstract void onP2PViewSingleTap();
- protected abstract void onCaptureScreenResult(boolean isSuccess,int prePoint);
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/BaseP2PView.java b/p2PCore/src/main/java/com/p2p/core/BaseP2PView.java
deleted file mode 100644
index be6001ed1..000000000
--- a/p2PCore/src/main/java/com/p2p/core/BaseP2PView.java
+++ /dev/null
@@ -1,401 +0,0 @@
-package com.p2p.core;
-
-import com.p2p.core.global.Constants;
-import com.p2p.core.utils.MyUtils;
-
-import android.app.Activity;
-import android.content.Context;
-import android.os.AsyncTask;
-import android.util.AttributeSet;
-import android.util.FloatMath;
-import android.util.Log;
-import android.view.MotionEvent;
-import android.view.SurfaceView;
-import android.view.animation.ScaleAnimation;
-
-public abstract class BaseP2PView extends SurfaceView {
- public static String contactId;
- public static String password;
-
- public BaseP2PView(Context context) {
- super(context);
- }
-
- public BaseP2PView(Context context, AttributeSet attrs) {
- super(context, attrs);
- // TODO Auto-generated constructor stub
- }
-
- protected abstract int getCurrentWidth();
-
- protected abstract int getCurrentHeight();
-
- // protected abstract void setSize(int width, int height);
- protected abstract void setVideoScale(int x, int y, float scale);
-
- protected abstract boolean MovePicture(int moveX, int moveY);
-
- protected abstract void StopMoving();
-
- protected abstract void changeNormalSize();
-
- private Activity mActivity;
- private int screen_W, screen_H;// 可见屏幕的宽高度
- private int current_Top, current_Right, current_Bottom, current_Left;
- private int start_Top = -1, start_Right = -1, start_Bottom = -1,
- start_Left = -1;// 初始化默认位置.
-
- private int start_x, start_y, current_x, current_y;// 触摸位置
-
- private float beforeLenght, afterLenght;// 两触点距离
-
- private float mbeforeLenght, mafterLenght;// 两触点距离
-
- private float scale_temp;// 缩放比例
-
- private int iTouchUp = 0;
-
- /**
- * 模式 NONE:无 DRAG:拖拽. ZOOM:缩放
- *
- * @author zhangjia
- *
- */
- public enum MODE {
- NONE, DRAG, ZOOM
-
- };
-
- public MODE mode = MODE.NONE;// 默认模式
-
- private boolean isControl_V = false;// 垂直监控
-
- private boolean isControl_H = false;// 水平监控
-
- private ScaleAnimation scaleAnimation;// 缩放动画
-
- private boolean isScaleAnim = false;// 缩放动画
-
- private MyAsyncTask myAsyncTask;// 异步动画
-
- public void setmActivity(Activity mActivity) {
- this.mActivity = mActivity;
- }
-
- /** 可见屏幕高度 **/
- public void setScreen_H(int screen_H) {
- this.screen_H = screen_H;
- }
-
- /** 可见屏幕宽度 **/
- public void setScreen_W(int screen_W) {
- this.screen_W = screen_W;
- }
-
- public int getMaxWidth() {
- return this.getCurrentWidth() * 3;
- }
-
- public int getMaxHeight() {
- return this.getCurrentHeight() * 3;
- }
-
- public int getMinWidth() {
- return this.getCurrentWidth() / 2;
- }
-
- public int getMinHeight() {
- return this.getCurrentHeight() / 2;
- }
-
- @Override
- protected void onLayout(boolean changed, int left, int top, int right,
- int bottom) {
- super.onLayout(changed, left, top, right, bottom);
- if (start_Top == -1) {
- start_Top = top;
- start_Left = left;
- start_Bottom = bottom;
- start_Right = right;
- }
-
- }
- public int getStartBottonm(){
- return start_Bottom;
- }
-
- /***
- * touch 事件
- */
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- try{
- /** 处理单点、多点触摸 **/
- switch (event.getAction() & MotionEvent.ACTION_MASK) {
- case MotionEvent.ACTION_DOWN:
- onTouchDown(event);
- break;
- // 多点触摸
- case MotionEvent.ACTION_POINTER_DOWN:
- onPointerDown(event);
- break;
-
- case MotionEvent.ACTION_MOVE:
- return onTouchMove(event);
- case MotionEvent.ACTION_UP:
- mode = MODE.NONE;
- iTouchUp = 1;
- break;
-
- // 多点松开
- case MotionEvent.ACTION_POINTER_UP:
- mode = MODE.NONE;
- /** 执行缩放还原 **/
- // if
- // (this.getWidth()0){
- P2PHandler.getInstance().setZoom(Constants.ZOOM.ZOOM_BIG);
- }else{
- P2PHandler.getInstance().setZoom(Constants.ZOOM.ZOOM_SMALL);
- }
- beforeLenght=afterLenght;
-
- }
- /** 按下 **/
- void onTouchDown(MotionEvent event) {
- mode = MODE.DRAG;
-
- current_x = (int) event.getRawX();
- current_y = (int) event.getRawY();
-
- start_x = (int) event.getRawX();
- start_y = (int) event.getRawY();
-
- }
-
- /** 两个手指 只能放大缩小 **/
- void onPointerDown(MotionEvent event) {
- if (event.getPointerCount() == 2) {
- mode = MODE.ZOOM;
- beforeLenght =getDistance(event);// 获取两点的距离
- mbeforeLenght=getDistance(event);
- }
- }
-
- /** 移动的处理 **/
- boolean onTouchMove(MotionEvent event) {
- int left = 0, top = 0, right = 0, bottom = 0;
- if (mode == MODE.DRAG) {
- current_x = (int) event.getRawX();
- current_y = (int) event.getRawY();
- int moveX = current_x - start_x;
- int moveY = current_y - start_y;
-
- start_x = current_x;
- start_y = current_y;
-
- if (moveX != 0 || moveY != 0) {
- return this.MovePicture(moveX, moveY);
- } else if (iTouchUp == 1) {
- this.StopMoving();
- iTouchUp = 0;
- return false;
- }
-
- }
- /** 处理缩放 **/
- else if (mode == MODE.ZOOM) {
-
- afterLenght = getDistance(event);// 获取两点的距离
-
- float gapLenght = afterLenght - beforeLenght;// 变化的长度
-
- if (Math.abs(gapLenght) > 5f) {
- scale_temp = afterLenght / beforeLenght;// 求的缩放的比例
-
- int x, y;
- x = getCenterX(event);
- y = getCenterY(event);
- //this.setScale(scale_temp);
- beforeLenght = afterLenght;
- if(P2PView.SUPPORT_ZOOM_FOCUS==false){
- this.setVideoScale(x, y, scale_temp);
- }
- }
- }
-
- return true;
- }
-
- /** 获取两点的距离 **/
- float getDistance(MotionEvent event) {
- float x = event.getX(0) - event.getX(1);
- float y = event.getY(0) - event.getY(1);
- return (float)Math.sqrt(x * x + y * y);
- }
-
- int getCenterX(MotionEvent event) {
- // Log.e("Gview","x0" + (int)event.getX(0) + " x1" + (int)event.getX(1)
- // +" y0 "+ (int)event.getY(0) + " y1 "+ (int)event.getY(1) );
- return (int) ((event.getX(0) + event.getX(1)) / 2);
- }
-
- int getCenterY(MotionEvent event) {
- return (int) ((event.getY(0) + event.getY(1)) / 2);
- }
-
- /** 实现处理拖动 **/
- private void setPosition(int left, int top, int right, int bottom) {
- this.layout(left, top, right, bottom);
- }
-
- /** 处理缩放 **/
- void setScale(float scale) {
-
- // this.setSize(int x, int y, float scale);
-
- // �Ŵ�
- int disX = (int) (this.getWidth() * Math.abs(1 - scale)) / 2;
- int disY = (int) (this.getHeight() * Math.abs(1 - scale)) / 2;
-
- // this.setSize( (int)(100*scale), (int)(100*scale));
-
- if (scale > 1 && this.getWidth() <= this.getMaxWidth()) {
- // this.setSize(this.getWidth()+disX, this.getHeight()+disY);
- if (this.getHeight() > screen_H) {
- isControl_V = true;
- } else {
- isControl_V = false;
- }
-
- if (this.getWidth() > screen_W) {
- isControl_H = true;
- } else {
- isControl_H = false;
- }
-
- } else if (scale < 1 && this.getWidth() >= this.getMinWidth()) {
- if ((this.getWidth() - disX) <= screen_W) {
- isControl_H = false;
- }
-
- if ((this.getHeight() - disY) <= screen_H) {
- isControl_V = false;
- }
-
- if (isControl_H || isControl_V) {
- // this.setSize(this.getWidth()-disX, this.getHeight()-disY);
- } else {
- // this.setSize(this.getWidth()-disX, this.getHeight()-disY);
- isScaleAnim = true;// �������Ŷ���
- }
-
- }
-
- }
-
- /***
- * 缩放动画处理
- */
- public void doScaleAnim() {
- myAsyncTask = new MyAsyncTask(screen_W, this.getWidth(),
- this.getHeight());
- myAsyncTask.setLTRB(this.getLeft(), this.getTop(), this.getRight(),
- this.getBottom());
- myAsyncTask.execute();
- isScaleAnim = false;// 关闭动画
- }
-
- /***
- * 回缩动画執行
- */
- class MyAsyncTask extends AsyncTask {
- private int screen_W, current_Width, current_Height;
-
- private int left, top, right, bottom;
-
- private float scale_WH;// 宽高的比例
-
- /** 当前的位置属性 **/
- public void setLTRB(int left, int top, int right, int bottom) {
- this.left = left;
- this.top = top;
- this.right = right;
- this.bottom = bottom;
- }
-
- private float STEP = 8f;// 步伐
-
- private float step_H, step_V;// 水平步伐,垂直步伐
-
- public MyAsyncTask(int screen_W, int current_Width, int current_Height) {
- super();
- this.screen_W = screen_W;
- this.current_Width = current_Width;
- this.current_Height = current_Height;
- scale_WH = (float) current_Height / current_Width;
- step_H = STEP;
- step_V = scale_WH * STEP;
- }
-
- @Override
- protected Void doInBackground(Void... params) {
-
- while (current_Width <= screen_W) {
-
- left -= step_H;
- top -= step_V;
- right += step_H;
- bottom += step_V;
-
- current_Width += 2 * step_H;
-
- left = Math.max(left, start_Left);
- top = Math.max(top, start_Top);
- right = Math.min(right, start_Right);
- bottom = Math.min(bottom, start_Bottom);
- Log.e("jj", "top=" + top + ",bottom=" + bottom + ",left="
- + left + ",right=" + right);
- onProgressUpdate(new Integer[] { left, top, right, bottom });
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- return null;
- }
-
- @Override
- protected void onProgressUpdate(final Integer... values) {
- super.onProgressUpdate(values);
- mActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- // MovePicture(values[0], values[1], values[2], values[3]);
- // setSize(values[2] - values[0], values[3] - values[1]);
- }
- });
-
- }
-
- }
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/BasePlayBackActivity.java b/p2PCore/src/main/java/com/p2p/core/BasePlayBackActivity.java
deleted file mode 100644
index 933b3d495..000000000
--- a/p2PCore/src/main/java/com/p2p/core/BasePlayBackActivity.java
+++ /dev/null
@@ -1,140 +0,0 @@
-package com.p2p.core;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.Bundle;
-import android.view.MotionEvent;
-
-import com.p2p.core.global.Constants;
-
-import java.io.IOException;
-
-public abstract class BasePlayBackActivity extends BaseCoreActivity{
- private static int mVideoFrameRate = 15;
- public P2PView pView;
- boolean isBaseRegFilter = false;
- boolean isFullScreen = false;
-
- private static final int PAUSE = 2;
- private static final int START = 3;
- private static final int JUMP = 4;
- private static final int NEXT = 5;
- private static final int PREVIOUS = 6;
- private static final int NAMEPLAY = 7;
-
- protected void onCreate(Bundle savedInstanceState) {
- // TODO Auto-generated method stub
- super.onCreate(savedInstanceState);
-
- baseRegFilter();
- }
-
- public void baseRegFilter(){
- IntentFilter filter = new IntentFilter();
- filter.addAction(Constants.P2P_WINDOW.Action.P2P_WINDOW_READY_TO_START);
- this.registerReceiver(baseReceiver, filter);
- isBaseRegFilter = true;
- }
-
- private BroadcastReceiver baseReceiver = new BroadcastReceiver(){
-
- @Override
- public void onReceive(Context arg0, Intent intent) {
- if(intent.getAction().equals(Constants.P2P_WINDOW.Action.P2P_WINDOW_READY_TO_START)){
- final MediaPlayer mPlayer = MediaPlayer.getInstance();
- new Thread(new Runnable() {
- @Override
- public void run() {
- MediaPlayer.nativeInit(mPlayer);
- try {
- mPlayer.setDisplay(pView);
-
- } catch (IOException e) {
- e.printStackTrace();
- }
- mPlayer.start(mVideoFrameRate);
- }
- }).start();
- }
- }
- };
-
- public void initP2PView(int type){
- pView.setCallBack();
- pView.setGestureDetector(new GestureDetector(this, new GestureListener(), null, true));
- pView.setDeviceType(type);
- }
-
- private class GestureListener extends GestureDetector.SimpleOnGestureListener {
- @Override
- public boolean onSingleTapConfirmed(MotionEvent e) {
- onP2PViewSingleTap();
- return super.onSingleTapConfirmed(e);
- }
-
-
- @Override
- public boolean onSingleTapUp(MotionEvent e) {
- return super.onSingleTapUp(e);
- }
-
- @Override
- public boolean onDoubleTap(MotionEvent e) {
- if(!isFullScreen){
- isFullScreen = true;
- pView.fullScreen();
- }else{
- isFullScreen = false;
- pView.halfScreen();
- }
- return super.onDoubleTap(e);
- }
-
- @Override
- public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
-
- return super.onFling(e1, e2, velocityX, velocityY);
- }
- }
-
- @Override
- public void onDestroy(){
- super.onDestroy();
- if(isBaseRegFilter){
- this.unregisterReceiver(baseReceiver);
- isBaseRegFilter = false;
- }
- }
-
- public void pausePlayBack(){
- MediaPlayer.iRecFilePlayingControl(PAUSE,0,"test".getBytes());
- }
-
- public void startPlayBack(){
- MediaPlayer.iRecFilePlayingControl(START,0,"test".getBytes());
- }
-
- public boolean previous(String filename){
- if(MediaPlayer.iRecFilePlayingControl(NAMEPLAY,0,filename.getBytes())==0){
- return false;
- }else{
- return true;
- }
- }
-
- public boolean next(String filename){
- if(MediaPlayer.iRecFilePlayingControl(NAMEPLAY,0,filename.getBytes())==0){
- return false;
- }else{
- return true;
- }
- }
-
- public void jump(int value){
- MediaPlayer.iRecFilePlayingControl(JUMP,value,"test".getBytes());
- }
-
- protected abstract void onP2PViewSingleTap();
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/BaseVideoActivity.java b/p2PCore/src/main/java/com/p2p/core/BaseVideoActivity.java
deleted file mode 100644
index 244d95676..000000000
--- a/p2PCore/src/main/java/com/p2p/core/BaseVideoActivity.java
+++ /dev/null
@@ -1,187 +0,0 @@
-package com.p2p.core;
-
-import java.io.IOException;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.MotionEvent;
-//import android.widget.RelativeLayout;
-import android.widget.LinearLayout.LayoutParams;
-
-import com.p2p.core.global.Constants;
-import com.p2p.core.utils.MyUtils;
-
-public abstract class BaseVideoActivity extends BaseCoreActivity {
- public static int mVideoFrameRate = 15;
- private final int MINX = 50;
- private final int MINY = 25;
- private final int USR_CMD_OPTION_PTZ_TURN_LEFT = 0;
- private final int USR_CMD_OPTION_PTZ_TURN_RIGHT = 1;
- private final int USR_CMD_OPTION_PTZ_TURN_UP = 2;
- private final int USR_CMD_OPTION_PTZ_TURN_DOWN = 3;
- public P2PView pView;
- boolean isBaseRegFilter = false;
- boolean isFullScreen = false;
-
- protected void onCreate(Bundle savedInstanceState) {
- // TODO Auto-generated method stub
- super.onCreate(savedInstanceState);
-
- baseRegFilter();
- }
-
- public void baseRegFilter() {
- IntentFilter filter = new IntentFilter();
- filter.addAction(Constants.P2P_WINDOW.Action.P2P_WINDOW_READY_TO_START);
- this.registerReceiver(baseReceiver, filter);
- isBaseRegFilter = true;
- }
-
- private BroadcastReceiver baseReceiver = new BroadcastReceiver() {
-
- @Override
- public void onReceive(Context arg0, Intent intent) {
- if (intent.getAction().equals(
- Constants.P2P_WINDOW.Action.P2P_WINDOW_READY_TO_START)) {
- final MediaPlayer mPlayer = MediaPlayer.getInstance();
- new Thread(new Runnable() {
- @Override
- public void run() {
- MediaPlayer.nativeInit(mPlayer);
- try {
- mPlayer.setDisplay(pView);
-
- } catch (IOException e) {
- e.printStackTrace();
- }
- mPlayer.start(mVideoFrameRate);
- }
- }).start();
- }
- }
- };
-
- public void initP2PView(int type) {
- pView.setCallBack();
- pView.setGestureDetector(new GestureDetector(this,
- new GestureListener(), null, true));
- pView.setDeviceType(type);
- }
-
- private class GestureListener extends
- GestureDetector.SimpleOnGestureListener {
- @Override
- public boolean onSingleTapConfirmed(MotionEvent e) {
- onP2PViewSingleTap();
- return super.onSingleTapConfirmed(e);
- }
-
- @Override
- public boolean onSingleTapUp(MotionEvent e) {
- return super.onSingleTapUp(e);
- }
-
- @Override
- public boolean onDoubleTap(MotionEvent e) {
- if (!isFullScreen) {
- isFullScreen = true;
- pView.fullScreen();
- } else {
- isFullScreen = false;
- pView.halfScreen();
- }
- return super.onDoubleTap(e);
- }
-
- @Override
- public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
- float velocityY) {
- // int id = -1;
- // float distance = 0;
- // boolean ishorizontal = false;
- // if ((Math.abs(e2.getX()- e1.getX())) > (Math.abs(e2.getY()-
- // e1.getY()))) {
- // ishorizontal = true;
- // }
- //
- // if (ishorizontal) {
- // distance = e2.getX() - e1.getX();
- // if (Math.abs(distance) > MyUtils.dip2px(BaseVideoActivity.this,
- // MINX)) {
- // if (distance > 0) {
- // id = USR_CMD_OPTION_PTZ_TURN_RIGHT;
- // }
- // else {
- // id = USR_CMD_OPTION_PTZ_TURN_LEFT;
- // }
- // }
- // }
- // else {
- // distance = e2.getY() - e1.getY();
- // if (Math.abs(distance) > MyUtils.dip2px(BaseVideoActivity.this,
- // MINY)) {
- // if (distance > 0) {
- // id = USR_CMD_OPTION_PTZ_TURN_UP;
- // }
- // else {
- // id = USR_CMD_OPTION_PTZ_TURN_DOWN;
- // }
- // }
- // }
- //
- // if (id != -1) {
- // MediaPlayer.getInstance().native_p2p_control(id);
- // } else {
- // }
-
- return true;
- }
- }
-
- public void fillCameraData(byte[] data, int length, int PreviewWidth,
- int PreviewHeight, int isYUV) {
- MediaPlayer.getInstance()._FillVideoRawFrame(data, data.length,
- PreviewWidth, PreviewHeight, isYUV);
- }
-
- public void setMute(boolean bool) {
- try {
- MediaPlayer.getInstance()._SetMute(bool);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public boolean closeLocalCamera() {
- if (MediaPlayer.iLocalVideoControl(1) == 1) {
- return true;
- } else {
- return false;
- }
- }
-
- public boolean openLocalCamera() {
- if (MediaPlayer.iLocalVideoControl(0) == 1) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- if (isBaseRegFilter) {
- this.unregisterReceiver(baseReceiver);
- isBaseRegFilter = false;
- }
- }
-
- protected abstract void onP2PViewSingleTap();
-
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/GestureDetector.java b/p2PCore/src/main/java/com/p2p/core/GestureDetector.java
deleted file mode 100644
index 08db6d66a..000000000
--- a/p2PCore/src/main/java/com/p2p/core/GestureDetector.java
+++ /dev/null
@@ -1,460 +0,0 @@
-/**
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.p2p.core;
-
-import android.content.Context;
-import android.os.Build;
-import android.os.Handler;
-import android.os.Message;
-import android.view.MotionEvent;
-import android.view.VelocityTracker;
-
-public class GestureDetector {
-
- public interface OnGestureListener {
- boolean onDown(MotionEvent e);
- void onShowPress(MotionEvent e);
- boolean onSingleTapUp(MotionEvent e);
- boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY);
- void onLongPress(MotionEvent e);
- boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY);
- }
-
- public interface OnDoubleTapListener {
- boolean onSingleTapConfirmed(MotionEvent e);
- boolean onDoubleTap(MotionEvent e);
- boolean onDoubleTapEvent(MotionEvent e);
- }
-
-
- public static class SimpleOnGestureListener implements OnGestureListener, OnDoubleTapListener {
- public boolean onSingleTapUp(MotionEvent e) {
- return false;
- }
-
- public void onLongPress(MotionEvent e) {
- }
-
- public boolean onScroll(MotionEvent e1, MotionEvent e2,
- float distanceX, float distanceY) {
- return false;
- }
-
- public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
- float velocityY) {
- return false;
- }
-
- public void onShowPress(MotionEvent e) {
- }
-
- public boolean onDown(MotionEvent e) {
- return false;
- }
-
- public boolean onDoubleTap(MotionEvent e) {
- return false;
- }
-
- public boolean onDoubleTapEvent(MotionEvent e) {
- return false;
- }
-
- public boolean onSingleTapConfirmed(MotionEvent e) {
- return false;
- }
- }
-
- // TODO: ViewConfiguration
- private int mBiggerTouchSlopSquare = 20 * 20;
-
- private int mTouchSlopSquare;
- private int mDoubleTapSlopSquare;
- private int mMinimumFlingVelocity;
- private int mMaximumFlingVelocity;
-
- private static final int LONGPRESS_TIMEOUT = ViewConfiguration.getLongPressTimeout();
- private static final int TAP_TIMEOUT = ViewConfiguration.getTapTimeout();
- private static final int DOUBLE_TAP_TIMEOUT = ViewConfiguration.getDoubleTapTimeout();
-
- // constants for Message.what used by GestureHandler below
- private static final int SHOW_PRESS = 1;
- private static final int LONG_PRESS = 2;
- private static final int TAP = 3;
-
- private final Handler mHandler;
- private final OnGestureListener mListener;
- private OnDoubleTapListener mDoubleTapListener;
-
- private boolean mStillDown;
- private boolean mInLongPress;
- private boolean mAlwaysInTapRegion;
- private boolean mAlwaysInBiggerTapRegion;
-
- private MotionEvent mCurrentDownEvent;
- private MotionEvent mPreviousUpEvent;
-
- /***
- * True when the user is still touching for the second tap (down, move, and
- * up events). Can only be true if there is a double tap listener attached.
- */
- private boolean mIsDoubleTapping;
-
- private float mLastMotionY;
- private float mLastMotionX;
-
- private boolean mIsLongpressEnabled;
-
- /***
- * True if we are at a target API level of >= Froyo or the developer can
- * explicitly set it. If true, input events with > 1 pointer will be ignored
- * so we can work side by side with multitouch gesture detectors.
- */
- private boolean mIgnoreMultitouch;
-
- /***
- * Determines speed during touch scrolling
- */
- private VelocityTracker mVelocityTracker;
-
- private class GestureHandler extends Handler {
- GestureHandler() {
- super();
- }
-
- GestureHandler(Handler handler) {
- super(handler.getLooper());
- }
-
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case SHOW_PRESS:
- mListener.onShowPress(mCurrentDownEvent);
- break;
-
- case LONG_PRESS:
- dispatchLongPress();
- break;
-
- case TAP:
- // If the user's finger is still down, do not count it as a tap
- if (mDoubleTapListener != null && !mStillDown) {
- mDoubleTapListener.onSingleTapConfirmed(mCurrentDownEvent);
- }
- break;
-
- default:
- throw new RuntimeException("Unknown message " + msg); //never
- }
- }
- }
-
- @Deprecated
- public GestureDetector(OnGestureListener listener, Handler handler) {
- this(null, listener, handler);
- }
-
- @Deprecated
- public GestureDetector(OnGestureListener listener) {
- this(null, listener, null);
- }
-
- public GestureDetector(Context context, OnGestureListener listener) {
- this(context, listener, null);
- }
-
- public GestureDetector(Context context, OnGestureListener listener, Handler handler) {
- this(context, listener, handler, context != null &&
- context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.FROYO);
- }
-
- public GestureDetector(Context context, OnGestureListener listener, Handler handler,
- boolean ignoreMultitouch) {
- if (handler != null) {
- mHandler = new GestureHandler(handler);
- } else {
- mHandler = new GestureHandler();
- }
- mListener = listener;
- if (listener instanceof OnDoubleTapListener) {
- setOnDoubleTapListener((OnDoubleTapListener) listener);
- }
- init(context, ignoreMultitouch);
- }
-
- @SuppressWarnings("deprecation")
- private void init(Context context, boolean ignoreMultitouch) {
- if (mListener == null) {
- throw new NullPointerException("OnGestureListener must not be null");
- }
- mIsLongpressEnabled = true;
- mIgnoreMultitouch = ignoreMultitouch;
-
- // Fallback to support pre-donuts releases
- int touchSlop, doubleTapSlop;
- if (context == null) {
- //noinspection deprecation
- touchSlop = ViewConfiguration.getTouchSlop();
- doubleTapSlop = ViewConfiguration.getDoubleTapSlop();
- //noinspection deprecation
- mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
- mMaximumFlingVelocity = ViewConfiguration.getMaximumFlingVelocity();
- } else {
- final ViewConfiguration configuration = ViewConfiguration.get(context);
- touchSlop = configuration.getScaledTouchSlop();
- doubleTapSlop = configuration.getScaledDoubleTapSlop();
- mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
- mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity();
- }
- mTouchSlopSquare = touchSlop * touchSlop;
- mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop;
- }
-
- /***
- * Sets the listener which will be called for double-tap and related
- * gestures.
- *
- * @param onDoubleTapListener the listener invoked for all the callbacks, or
- * null to stop listening for double-tap gestures.
- */
- public void setOnDoubleTapListener(OnDoubleTapListener onDoubleTapListener) {
- mDoubleTapListener = onDoubleTapListener;
- }
-
- /***
- * Set whether longpress is enabled, if this is enabled when a user
- * presses and holds down you get a longpress event and nothing further.
- * If it's disabled the user can press and hold down and then later
- * moved their finger and you will get scroll events. By default
- * longpress is enabled.
- *
- * @param isLongpressEnabled whether longpress should be enabled.
- */
- public void setIsLongpressEnabled(boolean isLongpressEnabled) {
- mIsLongpressEnabled = isLongpressEnabled;
- }
-
- /***
- * @return true if longpress is enabled, else false.
- */
- public boolean isLongpressEnabled() {
- return mIsLongpressEnabled;
- }
-
- /***
- * Analyzes the given motion event and if applicable triggers the
- * appropriate callbacks on the {@link OnGestureListener} supplied.
- *
- * @param ev The current motion event.
- * @return true if the {@link OnGestureListener} consumed the event,
- * else false.
- */
- public boolean onTouchEvent(MotionEvent ev) {
- final int action = ev.getAction();
- final float y = ev.getY();
- final float x = ev.getX();
-
- if (mVelocityTracker == null) {
- mVelocityTracker = VelocityTracker.obtain();
- }
- mVelocityTracker.addMovement(ev);
-
- boolean handled = false;
-
- switch (action & MotionEvent.ACTION_MASK) {
- case MotionEvent.ACTION_POINTER_DOWN:
- if (mIgnoreMultitouch) {
- // Multitouch event - abort.
- cancel();
- if(this.mOnZoomInListener!=null){
- this.mOnZoomInListener.onZoom(ev);
- }
- }
- break;
-
- case MotionEvent.ACTION_POINTER_UP:
- // Ending a multitouch gesture and going back to 1 finger
- if (mIgnoreMultitouch && ev.getPointerCount() == 2) {
- int index = (((action & MotionEvent.ACTION_POINTER_INDEX_MASK)
- >> MotionEvent.ACTION_POINTER_INDEX_SHIFT) == 0) ? 1 : 0;
- mLastMotionX = ev.getX(index);
- mLastMotionY = ev.getY(index);
- mVelocityTracker.recycle();
- mVelocityTracker = VelocityTracker.obtain();
- }
- break;
-
- case MotionEvent.ACTION_DOWN:
- if (mDoubleTapListener != null) {
- boolean hadTapMessage = mHandler.hasMessages(TAP);
- if (hadTapMessage) mHandler.removeMessages(TAP);
- if ((mCurrentDownEvent != null) && (mPreviousUpEvent != null) && hadTapMessage &&
- isConsideredDoubleTap(mCurrentDownEvent, mPreviousUpEvent, ev)) {
- // This is a second tap
- mIsDoubleTapping = true;
- // Give a callback with the first tap of the double-tap
- handled |= mDoubleTapListener.onDoubleTap(mCurrentDownEvent);
- // Give a callback with down event of the double-tap
- handled |= mDoubleTapListener.onDoubleTapEvent(ev);
- } else {
- // This is a first tap
- mHandler.sendEmptyMessageDelayed(TAP, DOUBLE_TAP_TIMEOUT);
- }
- }
-
- mLastMotionX = x;
- mLastMotionY = y;
- if (mCurrentDownEvent != null) {
- mCurrentDownEvent.recycle();
- }
- mCurrentDownEvent = MotionEvent.obtain(ev);
- mAlwaysInTapRegion = true;
- mAlwaysInBiggerTapRegion = true;
- mStillDown = true;
- mInLongPress = false;
-
- if (mIsLongpressEnabled) {
- mHandler.removeMessages(LONG_PRESS);
- mHandler.sendEmptyMessageAtTime(LONG_PRESS, mCurrentDownEvent.getDownTime()
- + TAP_TIMEOUT + LONGPRESS_TIMEOUT);
- }
- mHandler.sendEmptyMessageAtTime(SHOW_PRESS, mCurrentDownEvent.getDownTime() + TAP_TIMEOUT);
- handled |= mListener.onDown(ev);
- break;
-
- case MotionEvent.ACTION_MOVE:
- if (mInLongPress || (mIgnoreMultitouch && ev.getPointerCount() > 1)) {
- if(this.mOnZoomInListener!=null){
- this.mOnZoomInListener.onZoom(ev);
- }
- break;
- }
- final float scrollX = mLastMotionX - x;
- final float scrollY = mLastMotionY - y;
- if (mIsDoubleTapping) {
- // Give the move events of the double-tap
- handled |= mDoubleTapListener.onDoubleTapEvent(ev);
- } else if (mAlwaysInTapRegion) {
- final int deltaX = (int) (x - mCurrentDownEvent.getX());
- final int deltaY = (int) (y - mCurrentDownEvent.getY());
- int distance = (deltaX * deltaX) + (deltaY * deltaY);
- if (distance > mTouchSlopSquare) {
- handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY);
- mLastMotionX = x;
- mLastMotionY = y;
- mAlwaysInTapRegion = false;
- mHandler.removeMessages(TAP);
- mHandler.removeMessages(SHOW_PRESS);
- mHandler.removeMessages(LONG_PRESS);
- }
- if (distance > mBiggerTouchSlopSquare) {
- mAlwaysInBiggerTapRegion = false;
- }
- } else if ((Math.abs(scrollX) >= 1) || (Math.abs(scrollY) >= 1)) {
- handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY);
- mLastMotionX = x;
- mLastMotionY = y;
- }
- break;
-
- case MotionEvent.ACTION_UP:
- mStillDown = false;
- MotionEvent currentUpEvent = MotionEvent.obtain(ev);
- if (mIsDoubleTapping) {
- // Finally, give the up event of the double-tap
- handled |= mDoubleTapListener.onDoubleTapEvent(ev);
- } else if (mInLongPress) {
- mHandler.removeMessages(TAP);
- mInLongPress = false;
- } else if (mAlwaysInTapRegion) {
- handled = mListener.onSingleTapUp(ev);
- } else {
-
- // A fling must travel the minimum tap distance
- final VelocityTracker velocityTracker = mVelocityTracker;
- velocityTracker.computeCurrentVelocity(1000, mMaximumFlingVelocity);
- final float velocityY = velocityTracker.getYVelocity();
- final float velocityX = velocityTracker.getXVelocity();
-
- if ((Math.abs(velocityY) > mMinimumFlingVelocity)
- || (Math.abs(velocityX) > mMinimumFlingVelocity)){
- handled = mListener.onFling(mCurrentDownEvent, ev, velocityX, velocityY);
- }
- }
- if (mPreviousUpEvent != null) {
- mPreviousUpEvent.recycle();
- }
- // Hold the event we obtained above - listeners may have changed the original.
- mPreviousUpEvent = currentUpEvent;
- mVelocityTracker.recycle();
- mVelocityTracker = null;
- mIsDoubleTapping = false;
- mHandler.removeMessages(SHOW_PRESS);
- mHandler.removeMessages(LONG_PRESS);
- break;
- case MotionEvent.ACTION_CANCEL:
- cancel();
- }
- return handled;
- }
-
- private void cancel() {
- mHandler.removeMessages(SHOW_PRESS);
- mHandler.removeMessages(LONG_PRESS);
- mHandler.removeMessages(TAP);
- mVelocityTracker.recycle();
- mVelocityTracker = null;
- mIsDoubleTapping = false;
- mStillDown = false;
- if (mInLongPress) {
- mInLongPress = false;
- }
- }
-
- private boolean isConsideredDoubleTap(MotionEvent firstDown, MotionEvent firstUp,
- MotionEvent secondDown) {
- if (!mAlwaysInBiggerTapRegion) {
- return false;
- }
-
- if (secondDown.getEventTime() - firstUp.getEventTime() > DOUBLE_TAP_TIMEOUT) {
- return false;
- }
-
- int deltaX = (int) firstDown.getX() - (int) secondDown.getX();
- int deltaY = (int) firstDown.getY() - (int) secondDown.getY();
- return (deltaX * deltaX + deltaY * deltaY < mDoubleTapSlopSquare);
- }
-
- private void dispatchLongPress() {
- mHandler.removeMessages(TAP);
- mInLongPress = true;
- mListener.onLongPress(mCurrentDownEvent);
- }
-
-
- public interface OnZoomInListener{
- public void onZoom(MotionEvent event);
- }
-
- public OnZoomInListener mOnZoomInListener;
-
- public void setOnZoomInListener(OnZoomInListener listener){
- this.mOnZoomInListener = listener;
- }
-}
-
diff --git a/p2PCore/src/main/java/com/p2p/core/L.java b/p2PCore/src/main/java/com/p2p/core/L.java
deleted file mode 100644
index d2b2cb746..000000000
--- a/p2PCore/src/main/java/com/p2p/core/L.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
-* @Title: LogCat.java
-* @Package com.ifish.utils
-* @Description: TODO
-* @author Jacky dada
-* @date 2015-10-19 下午8:11:26
- */
-package com.p2p.core;
-
-import android.util.Log;
-
-/**
- * @ClassName: LogCat
- * @Description: 打印工具栏
- * @author Jacky dada
- * @date 2015-10-19 下午8:11:26
- */
-public class L {
- private static String TAG="iFish7";
- public static void i(String msg) {
- Log.i(TAG, msg);
- }
- public static void d(String msg) {
- Log.d(TAG, msg);
- }
- public static void e(String msg) {
- Log.e(TAG, msg);
- }
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/MediaPlayer.java b/p2PCore/src/main/java/com/p2p/core/MediaPlayer.java
deleted file mode 100644
index b446745c3..000000000
--- a/p2PCore/src/main/java/com/p2p/core/MediaPlayer.java
+++ /dev/null
@@ -1,2001 +0,0 @@
-package com.p2p.core;
-
-import android.media.AudioFormat;
-import android.media.AudioManager;
-import android.media.AudioRecord;
-import android.media.AudioTrack;
-import android.media.MediaRecorder;
-import android.os.Build;
-import android.util.Log;
-import android.view.Surface;
-import android.view.SurfaceView;
-import android.widget.SeekBar;
-
-import com.p2p.core.P2PInterface.IP2P;
-import com.p2p.core.P2PInterface.ISetting;
-import com.p2p.core.global.Constants;
-import com.p2p.core.utils.DES;
-import com.p2p.core.utils.MyUtils;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import javax.microedition.khronos.egl.EGL10;
-import javax.microedition.khronos.egl.EGLConfig;
-import javax.microedition.khronos.egl.EGLContext;
-import javax.microedition.khronos.egl.EGLDisplay;
-import javax.microedition.khronos.egl.EGLSurface;
-
-public class MediaPlayer {
- private static MediaPlayer manager = null;
- private static IP2P p2pInterface = null;
- private static ISetting settingInterface = null;
-
- public MediaPlayer() {
- native_setup(new WeakReference(this));
- }
-
- public static MediaPlayer getInstance() {
- if (manager == null) {
- manager = new MediaPlayer();
- }
- return manager;
- }
-
- public static boolean isMute = true;
- public static boolean isSendAudio = false;
-
- private final static String TAG = "2cu";
- private boolean mScreenOnWhilePlaying;
- private static ICapture mCapture = null;
-
- private static AudioRecord mAudioRecord = null;
- private static int mCpuVersion = 0;
- private int mNativeContext; // accessed by native methods
- private Surface mSurface;
-
- static {
- System.loadLibrary("SDL");
- // System.loadLibrary("mp4v2");//被注释且应用包中没有MP4v2SO库时,setReceveAVData(boolean)不可用
- mCpuVersion = MyUtils.getCPUVesion();
- System.loadLibrary("mediaplayer");
- native_init(mCpuVersion);
- }
-
- public void setCaptureListener(ICapture captureLister) {
- mCapture = captureLister;
- }
-
- public void setP2PInterface(IP2P p2pInterface) {
- this.p2pInterface = p2pInterface;
- }
-
- public void setSettingInterface(ISetting settingInterface) {
- this.settingInterface = settingInterface;
- }
-
- public void setIsSendAudio(boolean bool) {
- this.isSendAudio = bool;
- }
-
- public static int getConvertAckResult(int result) {
- if (result == 0) {
- return Constants.ACK_RET_TYPE.ACK_SUCCESS;
- } else if (result == 1) {
- return Constants.ACK_RET_TYPE.ACK_PWD_ERROR;
- } else if (result == 2) {
- return Constants.ACK_RET_TYPE.ACK_NET_ERROR;
- } else if (result == 4) {
- return Constants.ACK_RET_TYPE.ACK_INSUFFICIENT_PERMISSIONS;
- } else {
- return result;
- }
- }
-
- private static void postEventFromNative(Object mediaplayer_ref, int what,
- int iDesID, int arg1, int arg2, String msgStr) {
- if (p2pInterface == null || settingInterface == null) {
- return;
- }
- int reason_code = 0;
- // 截获字串
- if (msgStr.equals("pw_incrrect")) {
- reason_code = 0;
- } else if (msgStr.equals("busy")) {
- reason_code = 1;
- } else if (msgStr.equals("none")) {
- reason_code = 2;
- } else if (msgStr.equals("id_disabled")) {
- reason_code = 3;
- } else if (msgStr.equals("id_overdate")) {
- reason_code = 4;
- } else if (msgStr.equals("id_inactived")) {
- reason_code = 5;
- } else if (msgStr.equals("offline")) {
- reason_code = 6;
- } else if (msgStr.equals("powerdown")) {
- reason_code = 7;
- } else if (msgStr.equals("nohelper")) {
- reason_code = 8;
- } else if (msgStr.equals("hungup")) {
- reason_code = 9;
- } else if (msgStr.equals("timeout")) {
- reason_code = 10;
- } else if (msgStr.equals("nobody")) {
- reason_code = 11;
- } else if (msgStr.equals("internal_error")) {
- reason_code = 12;
- } else if (msgStr.equals("conn_fail")) {
- reason_code = 13;
- } else if (msgStr.equals("not_support")) {
- reason_code = 14;
- } else if (msgStr.equals("noframe")) {
- reason_code = 15;
- }
-
- switch (what) {
- case 1:
- String threeNumber = "";
- if (arg2 > 0) {
- threeNumber = String.valueOf(arg2);
- } else {
- threeNumber = "0" + String.valueOf((0 - arg2));
- }
- if (arg1 == 1) {
- // 鍛煎叆
- p2pInterface.vCalling(false, threeNumber,
- Integer.parseInt(msgStr));
- } else {
- // 鍛煎嚭
- p2pInterface.vCalling(true, threeNumber,
- Integer.parseInt(msgStr));
- }
- break;
- case 2:
- Log.e("leleTestvReject", "iDesID="+iDesID+"reason_code="+reason_code);
- p2pInterface.vReject(reason_code);
- break;
- case 3:
- p2pInterface.vAccept(arg1, arg2);
- break;
- case 4:
- p2pInterface.vConnectReady();
- break;
- case 5:
- if (mCapture != null) {
- mCapture.vCaptureResult(arg1);
- }
- break;
- case 6:
- // remote 绾跨▼ack鍥炶皟
- if (arg1 < Constants.MsgSection.MSG_ID_SET_REMOTE_DEFENCE
- && arg1 >= (Constants.MsgSection.MSG_ID_SET_REMOTE_DEFENCE - 1000)) {
- settingInterface
- .ACK_vRetSetRemoteDefence(String.valueOf(iDesID), arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_SET_REMOTE_RECORD
- && arg1 >= (Constants.MsgSection.MSG_ID_SET_REMOTE_RECORD - 1000)) {
- settingInterface.ACK_vRetSetRemoteRecord(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_SETTING_DEVICE_TIME
- && arg1 >= (Constants.MsgSection.MSG_ID_SETTING_DEVICE_TIME - 1000)) {
- settingInterface.ACK_vRetSetDeviceTime(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_GETTING_DEVICE_TIME
- && arg1 >= (Constants.MsgSection.MSG_ID_GETTING_DEVICE_TIME - 1000)) {
- settingInterface.ACK_vRetGetDeviceTime(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_GETTING_NPC_SETTINGS
- && arg1 >= (Constants.MsgSection.MSG_ID_GETTING_NPC_SETTINGS - 1000)) {
- settingInterface.ACK_vRetGetNpcSettings(String.valueOf(iDesID),
- arg1, getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_VIDEO_FORMAT
- && arg1 >= (Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_VIDEO_FORMAT - 1000)) {
- settingInterface.ACK_vRetSetNpcSettingsVideoFormat(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_VIDEO_VOLUME
- && arg1 >= (Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_VIDEO_VOLUME - 1000)) {
- settingInterface.ACK_vRetSetNpcSettingsVideoVolume(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_BUZZER
- && arg1 >= (Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_BUZZER - 1000)) {
- settingInterface.ACK_vRetSetNpcSettingsBuzzer(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_MOTION
- && arg1 >= (Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_MOTION - 1000)) {
- settingInterface.ACK_vRetSetNpcSettingsMotion(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_RECORD_TYPE
- && arg1 >= (Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_RECORD_TYPE - 1000)) {
- settingInterface.ACK_vRetSetNpcSettingsRecordType(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_RECORD_TIME
- && arg1 >= (Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_RECORD_TIME - 1000)) {
- settingInterface.ACK_vRetSetNpcSettingsRecordTime(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_RECORD_PLAN_TIME
- && arg1 >= (Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_RECORD_PLAN_TIME - 1000)) {
- settingInterface.ACK_vRetSetNpcSettingsRecordPlanTime(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_NET_TYPE
- && arg1 >= (Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_NET_TYPE - 1000)) {
- settingInterface.ACK_vRetSetNpcSettingsNetType(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_SETTING_ALARM_EMAIL
- && arg1 >= (Constants.MsgSection.MSG_ID_SETTING_ALARM_EMAIL - 1000)) {
- settingInterface.ACK_vRetSetAlarmEmail(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_GETTING_ALARM_EMAIL
- && arg1 >= (Constants.MsgSection.MSG_ID_GETTING_ALARM_EMAIL - 1000)) {
- settingInterface.ACK_vRetGetAlarmEmail(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_SETTING_ALARM_BIND_ID
- && arg1 >= (Constants.MsgSection.MSG_ID_SETTING_ALARM_BIND_ID - 1000)) {
- settingInterface.ACK_vRetSetAlarmBindId(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_GETTING_ALARM_BIND_ID
- && arg1 >= (Constants.MsgSection.MSG_ID_GETTING_ALARM_BIND_ID - 1000)) {
- settingInterface.ACK_vRetGetAlarmBindId(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_SETTING_INIT_PASSWORD
- && arg1 >= (Constants.MsgSection.MSG_ID_SETTING_INIT_PASSWORD - 1000)) {
- settingInterface.ACK_vRetSetInitPassword(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_SETTING_DEVICE_PASSWORD
- && arg1 >= (Constants.MsgSection.MSG_ID_SETTING_DEVICE_PASSWORD - 1000)) {
- settingInterface.ACK_vRetSetDevicePassword(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_CHECK_DEVICE_PASSWORD
- && arg1 >= (Constants.MsgSection.MSG_ID_CHECK_DEVICE_PASSWORD - 1000)) {
- settingInterface.ACK_vRetCheckDevicePassword(arg1,
- getConvertAckResult(arg2));
- Log.e("ACK_vRetCheckDevicePassword", "iDesID=" + iDesID + "---"
- + "result=" + getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_SETTING_DEFENCEAREA
- && arg1 >= (Constants.MsgSection.MSG_ID_SETTING_DEFENCEAREA - 1000)) {
- settingInterface.ACK_vRetSetDefenceArea(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_GETTING_DEFENCEAREA
- && arg1 >= (Constants.MsgSection.MSG_ID_GETTING_DEFENCEAREA - 1000)) {
- settingInterface.ACK_vRetGetDefenceArea(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_SETTING_WIFI
- && arg1 >= (Constants.MsgSection.MSG_ID_SETTING_WIFI - 1000)) {
- settingInterface.ACK_vRetSetWifi(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_GETTING_WIFI_LIST
- && arg1 >= (Constants.MsgSection.MSG_ID_GETTING_WIFI_LIST - 1000)) {
- settingInterface.ACK_vRetGetWifiList(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_GETTING_RECORD_FILE_LIST
- && arg1 >= (Constants.MsgSection.MSG_ID_GETTING_RECORD_FILE_LIST - 1000)) {
- settingInterface.ACK_vRetGetRecordFileList(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_SEND_MESSAGE
- && arg1 >= (Constants.MsgSection.MSG_ID_SEND_MESSAGE - 1000)) {
- settingInterface.ACK_vRetMessage(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_SEND_CUSTOM_CMD
- && arg1 >= (Constants.MsgSection.MSG_ID_SEND_CUSTOM_CMD - 1000)) {
- settingInterface.ACK_vRetCustomCmd(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_CHECK_DEVICE_UPDATE
- && arg1 >= (Constants.MsgSection.MSG_ID_CHECK_DEVICE_UPDATE - 1000)) {
- settingInterface.ACK_vRetCheckDeviceUpdate(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_CANCEL_DEVICE_UPDATE
- && arg1 >= (Constants.MsgSection.MSG_ID_CANCEL_DEVICE_UPDATE - 1000)) {
- settingInterface.ACK_vRetCancelDeviceUpdate(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_DO_DEVICE_UPDATE
- && arg1 >= (Constants.MsgSection.MSG_ID_DO_DEVICE_UPDATE - 1000)) {
- settingInterface.ACK_vRetDoDeviceUpdate(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_GET_DEFENCE_STATE
- && arg1 >= (Constants.MsgSection.MSG_ID_GET_DEFENCE_STATE - 1000)) {
- settingInterface
- .ACK_vRetGetDefenceStates(String.valueOf(iDesID), arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_GET_DEVICE_VERSION
- && arg1 >= (Constants.MsgSection.MSG_ID_GET_DEVICE_VERSION - 1000)) {
- settingInterface.ACK_vRetGetDeviceVersion(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MSG_ID_CLEAR_DEFENCE_GROUP
- && arg1 >= (Constants.MsgSection.MSG_ID_CLEAR_DEFENCE_GROUP - 1000)) {
- settingInterface.ACK_vRetClearDefenceAreaState(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MESG_ID_STTING_PIC_REVERSE
- && arg1 >= (Constants.MsgSection.MESG_ID_STTING_PIC_REVERSE - 1000)) {
- settingInterface.ACK_vRetSetImageReverse(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MESG_ID_STTING_IR_ALARM_EN
- && arg1 >= (Constants.MsgSection.MESG_ID_STTING_IR_ALARM_EN - 1000)) {
- settingInterface.ACK_vRetSetInfraredSwitch(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MESG_STTING_ID_EXTLINE_ALARM_IN_EN
- && arg1 >= (Constants.MsgSection.MESG_STTING_ID_EXTLINE_ALARM_IN_EN - 1000)) {
- settingInterface.ACK_vRetSetWiredAlarmInput(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MESG_STTING_ID_EXTLINE_ALARM_OUT_EN
- && arg1 >= (Constants.MsgSection.MESG_STTING_ID_EXTLINE_ALARM_OUT_EN - 1000)) {
- settingInterface.ACK_vRetSetWiredAlarmOut(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MESG_STTING_ID_SECUPGDEV
- && arg1 >= (Constants.MsgSection.MESG_STTING_ID_SECUPGDEV - 1000)) {
- settingInterface.ACK_vRetSetAutomaticUpgrade(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MESG_STTING_ID_GUEST_PASSWD
- && arg1 >= (Constants.MsgSection.MESG_STTING_ID_GUEST_PASSWD - 1000)) {
- settingInterface.ACK_VRetSetVisitorDevicePassword(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MESG_STTING_ID_TIMEZONE
- && arg1 >= (Constants.MsgSection.MESG_STTING_ID_TIMEZONE - 1000)) {
- settingInterface.ACK_vRetSetTimeZone(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MESG_GET_SD_CARD_CAPACITY
- && arg1 >= (Constants.MsgSection.MESG_GET_SD_CARD_CAPACITY - 1000)) {
- settingInterface.ACK_vRetGetSDCard(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MESG_SD_CARD_FORMAT
- && arg1 >= (Constants.MsgSection.MESG_SD_CARD_FORMAT - 1000)) {
- settingInterface.ACK_vRetSdFormat(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MESG_GET_DEFENCE_AREA_SWITCH
- && arg1 >= (Constants.MsgSection.MESG_GET_DEFENCE_AREA_SWITCH - 1000)) {
- settingInterface.ACK_vRetGetSensorSwitchs(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MESG_SET_DEFENCE_AREA_SWITCH
- && arg1 >= (Constants.MsgSection.MESG_SET_DEFENCE_AREA_SWITCH - 1000)) {
- settingInterface.ACK_vRetSetSensorSwitchs(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MESG_SET_LAMP
- && arg1 >= (Constants.MsgSection.MESG_SET_LAMP - 1000)) {
- settingInterface.vACK_RecvSetLAMPStatus(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MESG_GET_ALARM_CENTER_PARAMETER
- && arg1 >= (Constants.MsgSection.MESG_GET_ALARM_CENTER_PARAMETER - 1000)) {
- settingInterface.ACK_vRetGetAlarmCenter(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MESG_SET_ALARM_CENTER_PARAMETER
- && arg1 >= (Constants.MsgSection.MESG_SET_ALARM_CENTER_PARAMETER - 1000)) {
- settingInterface.ACK_vRetSetAlarmCenter(arg1,
- getConvertAckResult(arg2));
- } else if (arg1 < Constants.MsgSection.MESG_TYPE_GET_LAN_IPC_LIST
- && arg1 >= (Constants.MsgSection.MESG_TYPE_GET_LAN_IPC_LIST - 1000)) {
- settingInterface.ACK_VRetGetNvrIpcList(arg1,
- getConvertAckResult(arg2));
- }
- // //message ack鍥炶皟
- // if(arg1>=4000&&arg1<6000){
- // if(getConvertAckResult(arg2)==Constants.SettingConfig.ACK_SUCCESS){
- // Log.e("my","msg success");
- // if(MainActivity.msgHeap.get(arg1+"")!=null){
- // Intent i = new Intent();
- // i.setAction(Constants.Action.SUCCESS_MSG);
- // i.putExtra("msgId", arg1);
- // MyApp.app.sendBroadcast(i);
- // }
- // }else
- // if(getConvertAckResult(arg2)==Constants.SettingConfig.ACK_NET_ERROR){
- // Log.e("my","msg fault");
- // if(MainActivity.msgHeap.get(arg1+"")!=null){
- // Intent i = new Intent();
- // i.setAction(Constants.Action.FAULT_MSG);
- // i.putExtra("msgId", arg1);
- // MyApp.app.sendBroadcast(i);
- // }
- // }
- // }
- //
- // //search playback list ack鍥炶皟
- // if((arg2==2 || arg2==1)&&arg1>=6000&&arg1<8000){
- // Log.e("my","search fault");
- // Intent i = new Intent();
- // i.putExtra("errorCode", getConvertAckResult(arg2));
- // i.setAction(Constants.Action.PLAYBACK_SEARCH_FAULT);
- // MyApp.app.sendBroadcast(i);
- // }
- //
-
- break;
- case 7:
-
- break;
- case 8:
- p2pInterface.vChangeVideoMask(arg1);
- break;
- case 9:
- p2pInterface.vRetRTSPNotify(arg2, msgStr);
- break;
- default:
- p2pInterface.vRetPostFromeNative(what, iDesID, arg1, arg2, msgStr);
- break;
- }
-
- }
-
- static int iAudioDataInputNs = 0;
- static long AudioTrackPTSBegin = 0;
- static boolean fgdoPlayInit = true;
- static boolean fgdoRecordInit = true;
-
- public static void openAudioTrack() {
- Log.i(TAG, "openAudioTrack");
- try {
- int maxjitter = AudioTrack.getMinBufferSize(8000,
- AudioFormat.CHANNEL_OUT_MONO,
- AudioFormat.ENCODING_PCM_16BIT);
- if (Build.MODEL.equals("HTC One X")) {
- mAudioTrack = new AudioTrack(AudioManager.STREAM_VOICE_CALL,
- 8000, AudioFormat.CHANNEL_OUT_MONO,
- AudioFormat.ENCODING_PCM_16BIT, maxjitter * 2,
- AudioTrack.MODE_STREAM);
- } else {
- mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, 8000,
- AudioFormat.CHANNEL_OUT_MONO,
- AudioFormat.ENCODING_PCM_16BIT, maxjitter * 2,
- AudioTrack.MODE_STREAM);
- }
-
- Log.i(TAG, "Audio Track min buffer size:" + maxjitter); // 870
- // frames--
- // 108.75mS
- iAudioDataInputNs = 0;
- AudioTrackPTSBegin = System.currentTimeMillis();
- mAudioTrack.play();
- fgdoPlayInit = true;
- } catch (Exception e) {
- Log.e("test", "error");
- }
- }
-
- public static void openAudioRecord() {
- Log.i(TAG, "openAudioRecord");
- int samp_rate = 8000;
- int min = AudioRecord.getMinBufferSize(samp_rate,
- AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT);
-
- mAudioRecord = new AudioRecord(MediaRecorder.AudioSource.CAMCORDER,
- samp_rate, AudioFormat.CHANNEL_IN_MONO,
- AudioFormat.ENCODING_PCM_16BIT, min);
- try {
- mAudioRecord.startRecording();
- } catch (Exception e) {
- Log.e("dxserror",
- "AudioRecord staart error,Maybe user inhibit AudioRecord");
- mAudioRecord = null;
- fgdoRecordInit = false;
- }
-
- fgdoRecordInit = true;
- }
-
- private static int setAudioBuffer(byte[] buffer, int buffer_size, int[] iPTS) {
- int readNum = 0;
- if (mAudioRecord == null) {
- readNum = 0;
- } else {
- // Set priority, only do once
- if (fgdoRecordInit == true) {
- try {
- android.os.Process
- .setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
- } catch (Exception e) {
- // DoLog("Set play thread priority failed: " +
- }
- fgdoRecordInit = false;
- }
-
- readNum = mAudioRecord.read(buffer, 0, buffer_size);
- // Log.e("my",readNum+"");
- iPTS[0] = (int) (System.currentTimeMillis() - AudioTrackPTSBegin - (readNum / 16));
- // iAudioRecordPTS += readNum/16 ; ///time mS
- }
- return readNum;
- }
-
- private static void getAudioBuffer(byte[] buffer, int buffer_size,
- int[] iPTS) {
- int i;
- int iTime1;
-
- i = mAudioTrack.getPlaybackHeadPosition();
- iTime1 = (int) (System.currentTimeMillis() - AudioTrackPTSBegin);
-
- iPTS[0] = iTime1 + (iAudioDataInputNs - i) / 8; // /PTS mS
-
- if (mAudioTrack != null) {
- if (fgdoPlayInit == true) {
- try {
- android.os.Process
- .setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
- } catch (Exception e) {
-
- }
- fgdoPlayInit = false;
- }
- int result = mAudioTrack.write(buffer, 0, 320);
-
- iAudioDataInputNs += (buffer_size / 2);
- }
-
- }
-
- public static void RecvAVData(byte[] AudioBuffer, int AudioLen,
- int AudioFrames, long AudioPTS, byte[] VideoBuffer, int VideoLen,
- long VideoPTS) {
- p2pInterface.vRecvAudioVideoData(AudioBuffer, AudioLen, AudioFrames,
- AudioPTS, VideoBuffer, VideoLen, VideoPTS);
- }
-
- public native void setAVFilePath(String filename);
-
- public native int stopRecoder();
-
- public native int startRecoder();
-
- public void setDisplay(SurfaceView sh) throws IOException {
- _setVideoSurface(sh);
- }
-
- public void init(int width, int height, int fullScreenSize)
- throws IllegalStateException {
- _InitSession(width, height, fullScreenSize);
- }
-
- public void start(int iFrameRate) throws IllegalStateException {
- openAudioRecord();
- _StartSending(iFrameRate);
- }
-
- public void stop() throws IllegalStateException {
- _StopSession();
-
- if (mAudioTrack != null) {
- mAudioTrack.flush();
- mAudioTrack.stop();
-
- mAudioTrack.release();
- mAudioTrack = null;
- }
- if (mAudioRecord != null) {
- mAudioRecord.stop();
-
- mAudioRecord.release();
- mAudioRecord = null;
- }
- }
-
- public void pause() throws IllegalStateException {
- _PauseSession();
- }
-
- public void setScreenOnWhilePlaying(boolean screenOn) {
- if (mScreenOnWhilePlaying != screenOn) {
- mScreenOnWhilePlaying = screenOn;
- }
- }
-
- private native void _setVideoSurface(SurfaceView surface)
- throws IOException;
-
- public native void _SetMute(boolean isMute) throws IOException;
-
- public native void _CaptureScreen() throws IOException;
-
- public native void _SetRecvAVDataEnable(boolean fgRecv);
-
- private native void _InitSession(int width, int height, int fullScreenSize)
- throws IllegalStateException;
-
- public native void _StartPlaying(int width, int height, int callType)
- throws IOException, IllegalStateException;
-
- private native void _StartSending(int iFrameRate)
- throws IllegalStateException;
-
- private native void _PauseSession() throws IllegalStateException;
-
- private native void _StopSession() throws IllegalStateException;
-
- /**
- * Checks whether the MediaPlayer is playing.
- *
- * @return true if currently playing, false otherwise
- */
- public native boolean _isPlaying();
-
- /**
- * H264 ENCODER
- */
- public native int _FillVideoRawFrame(byte[] in, int insize, int width,
- int height, int isYUV);
-
- /**
- * AMR ENCODER
- */
-
- /**
- * P2P connect
- */
-
- private static native final void native_init(int cpuVersion)
- throws RuntimeException;
-
- private native final void native_setup(Object mediaplayer_this);
-
- public native int native_p2p_connect(int uID, int password, int code1,
- int code2, byte[] szMesg, int[] iCustomerID);
-
- public native int native_p2p_call(long id, int bMonitor, int password,
- int iFileIndex, int VideoTrans, byte[] filename, byte[] szMesg,
- String ipdress,long headerID);
-
- public native void native_p2p_accpet();
-
- public native void native_p2p_hungup();
-
- public native void native_p2p_control(int control);
-
- public native void native_p2p_disconnect();
-
- // SDL function
- public static native void nativeInit(Object classObj);
-
- public static native void nativeQuit();
-
- public static native void nativePause();
-
- public static native void nativeResume();
-
- public static native void onNativeResize(int x, int y, int format);
-
- public static native void onNativeKeyDown(int keycode);
-
- public static native void onNativeKeyUp(int keycode);
-
- public static native void onNativeTouch(int touchDevId,
- int pointerFingerId, int action, float x, float y, float p);
-
- public static native void onNativeAccel(float x, float y, float z);
-
- public static native void nativeRunAudioThread();
-
- /**
- * Releases resources associated with this MediaPlayer object. It is
- * considered good practice to call this method when you're done using the
- * MediaPlayer.
- */
-
- public void release() {
- // stayAwake(false);
- // updateSurfaceScreenOn();
- // _release();
- }
-
- /**
- * Resets the MediaPlayer to its uninitialized state. After calling this
- * method, you will have to initialize it again by setting the data source
- * and calling prepare().
- */
- public void reset() {
- // stayAwake(false);
- // _reset();
- }
-
- // @Override
-
- public interface IFFMpegPlayer {
- public void onPlay();
-
- public void onStop();
-
- public void onRelease();
-
- public void onError(String msg, Exception e);
- }
-
- public interface ICapture {
- public void vCaptureResult(int result);
- }
-
- // yi add
- public static native void nativeInitPlayBack();
-
- /**
- * +++++++++++++++++++++++SDL++++++++++++++++++++++*************************
- * ************88
- */
- private static EGLContext mEGLContext;
- private static EGLSurface mEGLSurface;
- private static EGLDisplay mEGLDisplay;
- private static EGLConfig mEGLConfig;
- private static int mGLMajor, mGLMinor;
- private static EGL10 mEgl;
-
- // Audio
- private static Thread mAudioThread;
- private static AudioTrack mAudioTrack;
- private static Object buf;
-
- /**
- * ++++++++++++++++For native callback function+++++++++++++++++++++++++
- */
- public static void testFunction(int sb1, int sb2) {
-
- }
-
- public static boolean createGLContext(int majorVersion, int minorVersion) {
- Log.e(TAG, "createGLContext");
- return initEGL(majorVersion, minorVersion);
- }
-
- public static void flipBuffers() {
- // Log.e(TAG, "flipBuffers");
- flipEGL();
- }
-
- public static Object audioInit(int sampleRate, boolean is16Bit,
- boolean isStereo, int desiredFrames) {
- return null;
- }
-
- public static void audioWriteShortBuffer(short[] buffer) {
-
- }
-
- public static void audioWriteByteBuffer(byte[] buffer) {
- }
-
- public static void audioQuit() {
- Log.i(TAG, "++ audioQuit");
- if (mAudioThread != null) {
- try {
- mAudioThread.join();
- } catch (Exception e) {
- Log.v(TAG, "Problem stopping audio thread: " + e);
- }
- mAudioThread = null;
-
- // Log.v("SDL", "Finished waiting for audio thread");
- }
-
- if (mAudioTrack != null) {
- mAudioTrack.stop();
- mAudioTrack.release();
- mAudioTrack = null;
- }
-
- Log.i(TAG, "-- audioQuit");
- }
-
- /**
- * ----------------For native callback function-------------------------
- */
-
- public static void audioStartThread() {
-
- }
-
- // EGL functions
- public static boolean initEGL(int majorVersion, int minorVersion) {
- Log.i(TAG, "++ initEGL");
- Log.i("surface", "initEGL");
- if (mEGLDisplay == null) {
- // Log.v("SDL", "Starting up OpenGL ES " + majorVersion + "." +
- // minorVersion);
-
- try {
- if (mEgl == null) {
- mEgl = (EGL10) EGLContext.getEGL();
- }
-
- EGLDisplay dpy = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
-
- int[] version = new int[2];
- mEgl.eglInitialize(dpy, version);
-
- int EGL_OPENGL_ES_BIT = 1;
- int EGL_OPENGL_ES2_BIT = 4;
- int renderableType = 0;
-
- if (majorVersion == 2) {
- renderableType = EGL_OPENGL_ES2_BIT;
- } else if (majorVersion == 1) {
- renderableType = EGL_OPENGL_ES_BIT;
- }
- int[] configSpec = {
- // EGL10.EGL_DEPTH_SIZE, 16,
- EGL10.EGL_RENDERABLE_TYPE, renderableType,
- EGL10.EGL_NONE };
- EGLConfig[] configs = new EGLConfig[1];
- int[] num_config = new int[1];
- if (!mEgl.eglChooseConfig(dpy, configSpec, configs, 1,
- num_config) || num_config[0] == 0) {
- Log.e(TAG, "No EGL config available");
- return false;
- }
- EGLConfig config = configs[0];
-
- /*
- * int EGL_CONTEXT_CLIENT_VERSION=0x3098; int contextAttrs[] =
- * new int[] { EGL_CONTEXT_CLIENT_VERSION, majorVersion,
- * EGL10.EGL_NONE }; EGLContext ctx = egl.eglCreateContext(dpy,
- * config, EGL10.EGL_NO_CONTEXT, contextAttrs);
- *
- * if (ctx == EGL10.EGL_NO_CONTEXT) { Log.e("SDL",
- * "Couldn't create context"); return false; }
- * SDLActivity.mEGLContext = ctx;
- */
- mEGLDisplay = dpy;
- mEGLConfig = config;
- mGLMajor = majorVersion;
- mGLMinor = minorVersion;
-
- Log.i("SDL", "majorVersion " + majorVersion);
- Log.i("SDL", "minorVersion " + minorVersion);
-
- createEGLSurface();
- } catch (Exception e) {
- Log.v(TAG, e + "");
- for (StackTraceElement s : e.getStackTrace()) {
- Log.v(TAG, s.toString());
- }
- }
- } else
- createEGLSurface();
-
- Log.i(TAG, "-- initEGL");
- return true;
- }
-
- static long timeStart = 0;
- static int frame = 0;
- private static Object showView = null;
-
- public static void setEglView(Object view) {
- Log.e(TAG, "surfaceView.hashcode-->" + view.hashCode());
- showView = view;
- }
-
- // EGL buffer flip
- public static void flipEGL() {
- if (frame == 0) {
- // timeStart = Calendar.getInstance().getTimeInMillis(); //shengming
- }
-
- try {
- mEgl.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface,
- mEGLContext);
- mEgl.eglWaitNative(EGL10.EGL_CORE_NATIVE_ENGINE, null);
- // drawing here
- mEgl.eglWaitGL();
- mEgl.eglSwapBuffers(mEGLDisplay, mEGLSurface);
- } catch (Exception e) {
- Log.v(TAG, "flipEGL(): " + e);
- for (StackTraceElement s : e.getStackTrace()) {
- Log.v(TAG, s.toString());
- }
- }
-
- /*
- * frame++;
- *
- * if (frame == 25) { frame = 0; Log.e(TAG, "duration time is: " +
- * (Calendar.getInstance().getTimeInMillis() - timeStart)); }
- */
- }
-
- public static boolean createEGLContext() {
- Log.i(TAG, "createEGLContext");
- int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
- int contextAttrs[] = new int[] { EGL_CONTEXT_CLIENT_VERSION, mGLMajor,
- EGL10.EGL_NONE };
- mEGLContext = mEgl.eglCreateContext(mEGLDisplay, mEGLConfig,
- EGL10.EGL_NO_CONTEXT, contextAttrs);
- if (mEGLContext == EGL10.EGL_NO_CONTEXT) {
- Log.e(TAG, "Couldn't create context");
- return false;
- }
- return true;
- }
-
- public static boolean createEGLSurface() {
- Log.i(TAG, "createEGLSurface");
- if (mEGLDisplay != null && mEGLConfig != null) {
- if (mEGLContext == null)
- createEGLContext();
-
- Log.v(TAG, "Creating new EGL Surface");
- EGLSurface surface = mEgl.eglCreateWindowSurface(mEGLDisplay,
- mEGLConfig, showView, null);
- if (surface == EGL10.EGL_NO_SURFACE) {
- Log.e(TAG, "Couldn't create surface");
- return false;
- }
-
- if (!mEgl
- .eglMakeCurrent(mEGLDisplay, surface, surface, mEGLContext)) {
- Log.e(TAG, "Old EGL Context doesnt work, trying with a new one");
- createEGLContext();
- if (!mEgl.eglMakeCurrent(mEGLDisplay, surface, surface,
- mEGLContext)) {
- Log.e(TAG, "Failed making EGL Context current");
- return false;
- }
- }
- mEGLSurface = surface;
- return true;
- }
-
- return false;
- }
-
- public static void ReleaseOpenGL() {
- // 棣栧厛瑙i櫎display,surface绛夐〉闈㈠拰鎺ュ彛鐨勯偊瀹�
- mEgl.eglMakeCurrent(EGL10.EGL_NO_DISPLAY, EGL10.EGL_NO_SURFACE,
- EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
-
- // 鎺ョ潃鍒犻櫎鍚勪釜椤甸潰
- if (mEGLContext != null) {
- mEgl.eglDestroyContext(mEGLDisplay, mEGLContext);
- mEGLContext = null;
- }
-
- if (mEGLSurface != null) {
- mEgl.eglDestroySurface(mEGLDisplay, mEGLSurface);
- mEGLSurface = null;
- }
-
- if (mEGLDisplay != null) {
- mEgl.eglTerminate(mEGLDisplay);
- mEGLDisplay = null;
- }
- Log.i(TAG, "ReleaseOpenGL");
- }
-
- /**
- * +++++++++++++++++++++++SDL++++++++++++++++++++++
- ************************************************/
-
- public static native int iSetNPCSettings(int iNPCID, int iPassword,
- int iMsgID, int iSettingID, int iSettingValue);
-
- public static native int iGetNPCSettings(int iNPCID, int iPassword,
- int iMsgID);
-
- public static void vRetNPCSettings(int iSrcID, int iCount,
- int[] iSettingID, int[] iValue, int iResult) {
- if (iResult == 1) {
- Log.e("my", "鑾峰彇");
- for (int i = 0; i < iCount; i++) {
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_REMOTE_DEFENCE) {
- settingInterface.vRetGetRemoteDefenceResult("" + iSrcID,
- iValue[i]);
- if (settingInterface == null) {
- Log.e("settingInterface", "settingInterface is null"
- + "iSrcID=" + iSrcID);
- }
- continue;
- }
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_BUZZER) {
- settingInterface.vRetGetBuzzerResult(iValue[i]);
- continue;
- }
-
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_REMOTE_RECORD) {
- settingInterface.vRetGetRemoteRecordResult(iValue[i]);
- continue;
- }
-
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_MOTION_DECT) {
- settingInterface.vRetGetMotionResult(iValue[i]);
- continue;
- }
-
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_VIDEO_FORMAT) {
- settingInterface.vRetGetVideoFormatResult(iValue[i]);
- continue;
- }
-
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_RECORD_TYPE) {
- settingInterface.vRetGetRecordTypeResult(iValue[i]);
- continue;
- }
-
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_RECORD_TIME) {
- settingInterface.vRetGetRecordTimeResult(iValue[i]);
- continue;
- }
-
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_NET_TYPE) {
- /*
- * iValue[i]>>16 鏈夌嚎锛� wifi:2 閮芥湁锛�
- */
- settingInterface.vRetGetNetTypeResult(iValue[i] & 0xffff);
- continue;
- }
-
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_VOLUME) {
- settingInterface.vRetGetVideoVolumeResult(iValue[i]);
- continue;
- }
-
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_RECORD_PLAN_TIME) {
- int time = iValue[i];
- settingInterface.vRetGetRecordPlanTimeResult(MyUtils
- .convertPlanTime(time));
- continue;
- }
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_IMAGE_REVERSE) {
- settingInterface.vRetGetImageReverseResult(iValue[i]);
- continue;
- }
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_IR_ALARM_EN) {
- settingInterface.vRetGetInfraredSwitch(iValue[i]);
- continue;
- }
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_EXTLINE_ALARM_IN_EN) {
- settingInterface.vRetGetWiredAlarmInput(iValue[i]);
- continue;
- }
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_EXTLINE_ALARM_OUT_EN) {
- settingInterface.vRetGetWiredAlarmOut(iValue[i]);
- continue;
- }
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_SECUPGDEV) {
- settingInterface.vRetGetAutomaticUpgrade(iValue[i]);
- continue;
- }
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_TIMEZONE) {
- settingInterface.vRetGetTimeZone(iValue[i]);
- continue;
- }
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.STTING_ID_GET_AUDIO_DEVICE_TYPE) {
- settingInterface.vRetGetAudioDeviceType(iValue[i]);
- continue;
- }
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_PRERECORD) {
- settingInterface.vRetGetPreRecord(iValue[i]);
- continue;
- }
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_LAMP) {
- settingInterface.vRecvGetLAMPStatus(iValue[i]);
- continue;
- }
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_GUEST_PASSWD) {
- // settingInterface.vRetNPCVistorPwd(iValue[i]);不再使用21返回访客密码
- int k = -1;
- for (int j = 0; j < iCount; j++) {
- if (iSettingID[j] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_VISITORPWD) {
- k = iValue[j];
- break;
- }
- }
- settingInterface.vRetNPCVistorPwd(k);
- continue;
- }
- if (iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_FOCUS_ZOOM) {
- settingInterface.vRetFocusZoom(iValue[i]);
- continue;
- }
-
- if(iSettingID[i] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_CHECK_AP_MODE_SURPPORT){
- settingInterface.vRetAPModeSurpport(String.valueOf(iSrcID), iValue[i]);
- continue;
- }
-
- }
- } else {
- if (iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_VIDEO_FORMAT) {
- settingInterface.vRetSetVideoFormatResult(iResult);
- } else if (iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_VOLUME) {
- settingInterface.vRetSetVolumeResult(iResult);
- } else if (iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_BUZZER) {
- settingInterface.vRetSetBuzzerResult(iResult);
- } else if (iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_RECORD_TYPE) {
- settingInterface.vRetSetRecordTypeResult(iResult);
- } else if (iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_MOTION_DECT) {
- settingInterface.vRetSetMotionResult(iResult);
- } else if (iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_RECORD_TIME) {
- settingInterface.vRetSetRecordTimeResult(iResult);
- } else if (iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_RECORD_PLAN_TIME) {
- settingInterface.vRetSetRecordPlanTimeResult(iResult);
- } else if (iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_REMOTE_DEFENCE) {
- if (settingInterface != null) {
- settingInterface.vRetSetRemoteDefenceResult(String.valueOf(iSrcID),iResult);
- }
- } else if (iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_DEVICE_PWD) {
- settingInterface.vRetSetDevicePasswordResult(iResult);
- } else if (iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_NET_TYPE) {
- settingInterface.vRetSetNetTypeResult(iResult);
- } else if (iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_REMOTE_RECORD) {
- settingInterface.vRetSetRemoteRecordResult(iResult);
- } else if (iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_IMAGE_REVERSE) {
- settingInterface.vRetSetImageReverse(iResult);
- } else if (iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_IR_ALARM_EN) {
- settingInterface.vRetSetInfraredSwitch(iResult);
- } else if (iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_EXTLINE_ALARM_IN_EN) {
- settingInterface.vRetSetWiredAlarmInput(iResult);
- } else if (iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_EXTLINE_ALARM_OUT_EN) {
- settingInterface.vRetSetWiredAlarmOut(iResult);
- } else if (iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_SECUPGDEV) {
- settingInterface.vRetSetAutomaticUpgrade(iResult);
- } else if (iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_GUEST_PASSWD) {
- settingInterface.vRetSetVisitorDevicePassword(iResult);
- } else if (iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_TIMEZONE) {
- settingInterface.vRetSetTimeZone(iResult);
- } else if (iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_PRERECORD) {
- settingInterface.vRetSetPreRecord(iResult);
- } else if (iSettingID[0] == 34) {
- settingInterface.vRecvSetLAMPStatus(iResult);
- }else if(iSettingID[0] == Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_SET_WIFI_WORK_MODE){
- settingInterface.vRetSetWifiMode(String.valueOf(iSrcID), iResult);
- }
- }
-
- }
-
- public static void vRetFriendsStatus(final int iFriendsCount,
- final int[] iIDArray, final byte[] bStatus, final byte[] bType) {
- String[] threeNumbers = new String[iFriendsCount];
- int[] status = new int[iFriendsCount];
- int[] types = new int[iFriendsCount];
-
- for (int i = 0; i < iFriendsCount; i++) {
- int id = iIDArray[i] & 0x7FFFFFFF;
- int state = bStatus[i] & 0x0f;
- int type = bType[i] & 0x0f;
-
- status[i] = state;
- types[i] = type;
- if ((iIDArray[i] & 0x80000000) != 0) {
- threeNumbers[i] = "0" + id;
- } else {
- threeNumbers[i] = "" + id;
- }
-
- }
-
- settingInterface.vRetGetFriendStatus(iFriendsCount, threeNumbers,
- status, types);
- }
-
- public static void vRetMessage(int srcID, int iLen, byte[] cString) {
- /* ***********************************
- * ***********************************
- * ***********************************
- * ***********************************
- * ***********************************
- * **********************************
- */
- int id = srcID & 0x7FFFFFFF;
-
- if (id == 10000) {
- settingInterface.vRetSysMessage(new String(cString));
- return;
- }
- settingInterface.vRetMessage("0" + String.valueOf(id), new String(
- cString));
- }
-
- public static native int iGetFriendsStatus(int[] data, int iFriendNS);
-
- public static native int iSendMesgToFriend(int iDesID, int iMesgID,
- byte[] data, int datasize);
-
- public static native int iGetRecFiles(int iNPCID, int iPassword,
- int iMesgID, int iStartDateTime, int iEndDateTime);
-
- public static void vRetRecordFilesList(int id, int count, byte[] bytes) {
- String name = new String(bytes);
- String[] names = name.split("\\|");
- String[] names_moveEndNull = new String[count];
- System.arraycopy(names, 0, names_moveEndNull, 0, count);
- settingInterface.vRetGetRecordFiles(names_moveEndNull,(byte)-1,(byte)-1);
- }
-
- public static native int iRecFilePlayingControl(int iCommand, int iParm,
- byte[] filename);
-
- public static native int iLocalVideoControl(int iCommand);
-
- public static void vRetPlayingStatus(int iStatus) {
- p2pInterface.vRetPlayBackStatus(iStatus);
- }
-
- public static void vRetPlayingPos(int iLength, int iCurrentSec) {
- p2pInterface.vRetPlayBackPos(iLength, iCurrentSec);
- }
-
- public static void vRetPlayingSize(int iWidth, int iHeight) {
- p2pInterface.vRetPlaySize(iWidth, iHeight);
- }
-
- public static void vRetPlayingNumber(int iNumber) {
- p2pInterface.vRetPlayNumber(iNumber);
- }
-
- public static native int iSetNPCDateTime(int iNpcID, int iPassword,
- int iMesgID, int iTime);
-
- public static native int iGetNPCDateTime(int iNpcID, int iPassword,
- int iMesgID);
-
- public static native int iGetNPCEmail(int iNpcID, int iPassword, int iMesgID);
-
- public static native int iSetNPCEmail(int iNpcID, int iPassword,
- int iMesgID, byte[] data, int iLen);
-
- public static void vRetEmail(int srcID, int iLen, byte[] cString, int result) {
- byte option = (byte) ((result >> 0) & (0x1));
- if (option == 1) {
- // 鑾峰彇鎴愬姛
- String email = new String(cString);
- // settingInterface.vRetAlarmEmailResult(result, email);
- } else {
- // settingInterface.vRetAlarmEmailResult(result, "");
- }
- }
-
- public static native int iGetNPCWifiList(int iNpcID, int iPassword,
- int iMesgID);
-
- /*
- * @param data1 Wifi Name
- *
- * @param data2 Wifi password
- */
- public static native int iSetNPCWifi(int iNpcID, int iPassword,
- int iMesgID, int iType, byte[] data1, int iLen1, byte[] data2,
- int iLen2);
-
- public static native int iGetNPCIpConfig(int iNpcID, int iPassword,
- int iMesgID, int iType, byte[] data1, int iLen1, byte[] data2,
- int iLen2);
-
- public static void vRetNPCWifiList(int srcID, int iCurrentId, int iCount,
- int[] iType, int[] iStrength, byte[] cString, int iResult) {
-
- String strbuffer = "--";
- for (int j = 0; j < cString.length; j++) {
- if (cString[j] == 0) {
- Log.e("wifidata", strbuffer);
- strbuffer = "--";
- }
- strbuffer = strbuffer + " " + cString[j];
- }
- // for(int i=0;i data = new ArrayList();
- int[] status_key = new int[8];
- status_key[0] = (key >> 0) & 0x1;
- status_key[1] = (key >> 1) & 0x1;
- status_key[2] = (key >> 2) & 0x1;
- status_key[3] = (key >> 3) & 0x1;
- status_key[4] = (key >> 4) & 0x1;
- status_key[5] = (key >> 5) & 0x1;
- status_key[6] = (key >> 6) & 0x1;
- status_key[7] = (key >> 7) & 0x1;
- Log.e("area", status_key[0] + " " + status_key[1] + " "
- + status_key[2] + " " + status_key[3] + " " + status_key[4]
- + " " + status_key[5] + " " + status_key[6] + " "
- + status_key[7] + " ");
- data.add(0, status_key);
- for (int i = 0; i < iCount; i++) {
- byte b = bData[i];
- int[] status = new int[8];
- status[0] = (b >> 0) & 0x1;
- status[1] = (b >> 1) & 0x1;
- status[2] = (b >> 2) & 0x1;
- status[3] = (b >> 3) & 0x1;
- status[4] = (b >> 4) & 0x1;
- status[5] = (b >> 5) & 0x1;
- status[6] = (b >> 6) & 0x1;
- status[7] = (b >> 7) & 0x1;
- Log.e("area", status[0] + " " + status[1] + " " + status[2]
- + " " + status[3] + " " + status[4] + " " + status[5]
- + " " + status[6] + " " + status[7] + " ");
- data.add(i + 1, status);
- }
-
- settingInterface.vRetDefenceAreaResult(iResult, data, 0, 0);
- } else {
- int group = bData[0];
- int item = bData[4];
- settingInterface.vRetDefenceAreaResult(iResult, null, group, item);
- }
-
- }
-
- public static native int iGetBindAlarmId(int iNpcID, int iPassword,
- int iMesgID);
-
- public static native int iSetBindAlarmId(int iNpcID, int iPassword,
- int iMesgID, int iCount, int[] iData);
-
- public static void vRetBindAlarmId(int srcID, int iMaxCount, int iCount,
- int[] iData, int iResult) {
- if (iResult == 1) {
- if (iCount == 1 && iData[0] == 0) {
- settingInterface.vRetBindAlarmIdResult(srcID, iResult,
- iMaxCount, new String[0]);
- } else {
- String[] new_data = new String[iData.length];
- for (int i = 0; i < iData.length; i++) {
- new_data[i] = "0" + iData[i];
- }
- settingInterface.vRetBindAlarmIdResult(srcID, iResult,
- iMaxCount, new_data);
- }
- } else {
- settingInterface.vRetBindAlarmIdResult(srcID, iResult, 0, null);
- }
-
- }
-
- public static void vRetDeviceNotSupport(int iNpcId) {
- Log.e("my", "device not support:" + iNpcId);
- settingInterface.vRetDeviceNotSupport();
- }
-
- public static native void ChangeScreenSize(int windowWidth,
- int windowHeight, int isFullScreen);
-
- public static native int ZoomView(int x, int y, float fScale);
-
- public static native int MoveView(int DetaX, int DetaY);
-
- public static native int iSetInitPassword(int iNpcID, int iPassword,
- int iMesgID, int iNewPassword, int AppID);
-
- public static void vRetInitPassword(int iNpcId, int iResult) {
- settingInterface.vRetSetInitPasswordResult(iResult);
- }
-
- public static void vRetAlarm(int iSrcId, int iType,
- int isSupportExternAlarm, int iGroup, int iItem) {
- boolean bool = false;
- boolean isSupportDelete = false;
- if ((isSupportExternAlarm & 0x1) == 1) {
- bool = true;
- } else {
- bool = false;
- }
- Log.e("dxsAlarmActivity", "iSrcId-->" + iSrcId + "iType-->" + iType
- + "--isSupportExternAlarm-->" + isSupportExternAlarm);
- if (((isSupportExternAlarm >> 2) & (0x1)) == 1) {
- isSupportDelete = true;
- } else {
- isSupportDelete = false;
- }
- if (iGroup > 8) {
- isSupportExternAlarm = 0;
- }
-
- p2pInterface.vAllarming(String.valueOf(iSrcId), iType, bool, iGroup,
- iItem, isSupportDelete);
- }
-
- /* ***********************************************************************
- * SDK
- * ***********************************************************************
- */
-
- // 璁剧疆璁惧鏃堕棿鍥炶皟
- public static void vRetNPCTime(int iTime, int result) {
- if (result == 1) {
- // 鑾峰彇鎴愬姛
- settingInterface.vRetGetDeviceTimeResult(MyUtils
- .convertDeviceTime(iTime));
- } else {
- settingInterface.vRetSetDeviceTimeResult(result);
- }
- }
-
- public static native int iSendCmdToFriend(int iDesID, int iPassword,
- int iMesgID, byte[] data, int datasize);
-
- // 鑷畾涔夊懡浠�
- public static void vRetCustomCmd(int srcID, int iLen, byte[] cString) {
- int id = srcID & 0x7FFFFFFF;
- settingInterface.vRetCustomCmd(id, iLen, cString);
- }
-
- public static native int iSetVideoMode(int type);
-
- public static native void checkDeviceUpdate(int iNpcID, int iPassword,
- int iMesgID);
-
- public static void vRetCheckDeviceUpdate(int iSrcID, int result,
- int iCurVersion, int iUpgVersion) {
- int a = iCurVersion & 0xff;
- int b = (iCurVersion >> 8) & 0xff;
- int c = (iCurVersion >> 16) & 0xff;
- int d = (iCurVersion >> 24) & 0xff;
-
- String cur_version = d + "." + c + "." + b + "." + a;
-
- int e = iUpgVersion & 0xff;
- int f = (iUpgVersion >> 8) & 0xff;
- int g = (iUpgVersion >> 16) & 0xff;
- int h = (iUpgVersion >> 24) & 0xff;
-
- String upg_version = h + "." + g + "." + f + "." + e;
- String contactId = String.valueOf(iSrcID);
- settingInterface.vRetCheckDeviceUpdate(contactId, result, cur_version,
- upg_version);
- }
-
- public static native void doDeviceUpdate(int iNpcID, int iPassword,
- int iMesgID);
-
- public static void vRetDoDeviceUpdate(int iSrcID, int result, int value) {
-
- settingInterface.vRetDoDeviceUpdate(String.valueOf(iSrcID), result,
- value);
- }
-
- public static native void cancelDeviceUpdate(int iNpcID, int iPassword,
- int iMesgID);
-
- public static void vRetCancelDeviceUpdate(int iSrcID, int result) {
-
- settingInterface.vRetCancelDeviceUpdate(result);
- }
-
- public static native int iSendCtlCmd(int iCmd, int iOption);
-
- public static native void getDeviceVersion(int iNpcID, int iPassword,
- int iMesgID);
-
- public static void vRetGetDeviceVersion(int iSrcID, int result,
- int iCurVersion, int iUbootVersion, int iKernelVersion,
- int iRootfsVersion) {
- int a = iCurVersion & 0xff;
- int b = (iCurVersion >> 8) & 0xff;
- int c = (iCurVersion >> 16) & 0xff;
- int d = (iCurVersion >> 24) & 0xff;
-
- String cur_version = d + "." + c + "." + b + "." + a;
- settingInterface.vRetGetDeviceVersion(result, cur_version,
- iUbootVersion, iKernelVersion, iRootfsVersion);
- }
-
- public static native void setBindFlag(int flag);
-
- public static void vGXNotifyFlag(int flag) {
- p2pInterface.vGXNotifyFlag(flag);
- }
-
- public static native int iClearAlarmCodeGroup(int iNpcID, int iPassword,
- int iMesgID, int iGroup);
-
- public static void vRetClearAlarmCodeGroup(int iSrcID, int result) {
- settingInterface.vRetClearDefenceAreaState(result);
- }
-
- public static native int iExtendedCmd(int iTargetID, int iPassword,
- int iMesgID, byte[] data, int datasize);
-
- public static final int MESG_TYPE_GET_DISK_INFO = 80;
- public static final int MESG_TYPE_FORMAT_DISK = 81;
- public static final int MESG_SDCARD_NO_EXIST = 82;
- public static final int MESG_SET_GPIO_INFO = 96;
- public static final int MESG_TYPE_RET_DEFENCE_SWITCH_STATE = 84;
-
- public static final int MESG_TYPE_GET_ALARM_TYPE_MOTOR_PRESET_POS = 89;// 预置位
- public static final int MESG_TYPE_SET_MOTOR_PRESET_POS = 87;// 预置位
- public static final int MESG_TYPE_LOOK_MOTOR_PRESET_POS = 88;// 返回预置位
- public static final int MESG_TYPE_RET_ALARM_TYPE_MOTOR_PRESET_POS = 91;// 返回设置于获取预置位
- public static final int IP_CONFIG = 105;// 返回IP信息
-
- public static final int MESG_GET_ALARM_CENTER_PARAMETER = 102;
- public static final int MESG_DELETE_ALARMDEVICEID = 128;// 删除设备绑定报警推送ID
-
- public static final int MESG_TYPE_RET_LAN_IPC_LIST = 130;// 返回NVR的ipc列表
-
- public static final int MESG_CONTROL_CAMERA = 131;
- public static final int MESG_TYPE_FISHEYE_SETTING = 149;// 鱼眼设置
- public static final int MESG_TYPE_FISHEYE_MEMBERLIST = 215;// 鱼眼获取列表
- public static final int MESG_TYPE_DEVIECE_NOT_SUPPORT_RET = 255;
- public static final int MESG_TYPE_RET_DEVICE_LANGUAGE = 213;
-
- public static void vRetExtenedCmd(int iSrcID, byte[] data, int datasize) {
- Log.e("vRetExtenedCmd", "vRetExtenedCmd-->" + Arrays.toString(data));
- int option = 0;
- if (data[0] < 0) {
- option = data[0] + 256;
- } else {
- option = data[0];
- }
- if (option == MESG_TYPE_GET_DISK_INFO) {
- if (data[1] == MESG_SDCARD_NO_EXIST) {
- settingInterface.vRetGetSdCard(0, 0, 0, 0);
- } else {
- int DiskCount;
- int DiskID;
- long TotalSpace, FreeSpace;
- DiskCount = data[2] + data[3] * 256;
- Log.e("2cu", "---" + DiskCount);
- DiskID = data[4];
- Log.e("diskid", "DiskID" + DiskID);
-
- long[] longData = new long[8];
- longData[0] = 0xFF & data[5];
- longData[0] <<= 0;
- longData[1] = 0xFF & data[6];
- longData[1] <<= 8;
- longData[2] = 0xFF & data[7];
- longData[2] <<= 16;
- longData[3] = 0xFF & data[8];
- longData[3] <<= 24;
- longData[4] = 0xFF & data[9];
- longData[4] <<= 32;
- longData[5] = 0xFF & data[10];
- longData[5] <<= 40;
- longData[6] = 0xFF & data[11];
- longData[6] <<= 48;
- longData[7] = 0xFF & data[12];
- longData[7] <<= 56;
-
- TotalSpace = longData[0] + longData[1] + longData[2]
- + longData[3] + longData[4] + longData[5] + longData[6]
- + longData[7];
- TotalSpace = TotalSpace / 1024 / 1024; // MB
-
- longData[0] = 0xFF & data[13];
- longData[0] <<= 0;
- longData[1] = 0xFF & data[14];
- longData[1] <<= 8;
- longData[2] = 0xFF & data[15];
- longData[2] <<= 16;
- longData[3] = 0xFF & data[16];
- longData[3] <<= 24;
- longData[4] = 0xFF & data[17];
- longData[4] <<= 32;
- longData[5] = 0xFF & data[18];
- longData[5] <<= 40;
- longData[6] = 0xFF & data[19];
- longData[6] <<= 48;
- longData[7] = 0xFF & data[20];
- longData[7] <<= 56;
-
- FreeSpace = longData[0] + longData[1] + longData[2]
- + longData[3] + longData[4] + longData[5] + longData[6]
- + longData[7];
- FreeSpace = FreeSpace / 1024 / 1024; // MB
-
- Log.e("2cu", "TotalSpace=" + TotalSpace);
- Log.e("2cu", "FreeSpace=" + FreeSpace);
-
- settingInterface.vRetGetSdCard((int) TotalSpace,
- (int) FreeSpace, DiskID, 1);
-
- if (DiskCount > 1) {
- DiskID = data[21];
- Log.e("diskid", "DiskID" + DiskID);
- longData[0] = 0xFF & data[22];
- longData[0] <<= 0;
- longData[1] = 0xFF & data[23];
- longData[1] <<= 8;
- longData[2] = 0xFF & data[24];
- longData[2] <<= 16;
- longData[3] = 0xFF & data[25];
- longData[3] <<= 24;
- longData[4] = 0xFF & data[26];
- longData[4] <<= 32;
- longData[5] = 0xFF & data[27];
- longData[5] <<= 40;
- longData[6] = 0xFF & data[28];
- longData[6] <<= 48;
- longData[7] = 0xFF & data[29];
- longData[7] <<= 56;
-
- TotalSpace = longData[0] + longData[1] + longData[2]
- + longData[3] + longData[4] + longData[5]
- + longData[6] + longData[7];
- TotalSpace = TotalSpace / 1024 / 1024; // MB
-
- longData[0] = 0xFF & data[30];
- longData[0] <<= 0;
- longData[1] = 0xFF & data[31];
- longData[1] <<= 8;
- longData[2] = 0xFF & data[32];
- longData[2] <<= 16;
- longData[3] = 0xFF & data[33];
- longData[3] <<= 24;
- longData[4] = 0xFF & data[34];
- longData[4] <<= 32;
- longData[5] = 0xFF & data[35];
- longData[5] <<= 40;
- longData[6] = 0xFF & data[36];
- longData[6] <<= 48;
- longData[7] = 0xFF & data[37];
- longData[7] <<= 56;
-
- FreeSpace = longData[0] + longData[1] + longData[2]
- + longData[3] + longData[4] + longData[5]
- + longData[6] + longData[7];
- FreeSpace = FreeSpace / 1024 / 1024; // MB
-
- Log.e("2cu", "TotalSpace=" + TotalSpace);
- Log.e("2cu", "FreeSpace=" + FreeSpace);
- settingInterface.VRetGetUsb((int) TotalSpace,
- (int) FreeSpace, DiskID, 1);
- }
-
- }
-
- } else if (option == MESG_TYPE_FORMAT_DISK) {
- settingInterface.vRetSdFormat(data[1]);
- } else if (option == MESG_SET_GPIO_INFO) {
- int result = -1;
- if (data[1] < 0) {
- result = (data[1] + 256);
- } else {
- result = data[1];
- }
- settingInterface.vRetSetGPIO(result);
- } else if (option == MESG_TYPE_RET_DEFENCE_SWITCH_STATE) {
- if (data[1] == 1) {
- ArrayList sensors = new ArrayList();
- for (int i = 4; i < data.length; i++) {
- if (data[i] < 0) {
- String sensor = Integer.toBinaryString(data[i] + 256);
- int[] sensor_switchs = new int[8];
- ArrayList list = new ArrayList();
- if (sensor.length() < 8) {
- for (int k = 0; k < 8 - sensor.length(); k++) {
- list.add(0);
- }
- }
- for (int j = 0; j < sensor.length(); j++) {
- list.add(Integer.parseInt(sensor
- .substring(j, j + 1)));
- }
- Log.e("length", "list_size" + list.size());
- String s = "";
- for (int k = 0; k < list.size(); k++) {
- sensor_switchs[k] = list.get(k);
- s = s + sensor_switchs[k];
- }
- Log.e("length", s);
- // Log.e("length",
- // "sensor="+sensor+"length="+sensor.length());
- // int [] sensor_switchs=new int[8];
- // if(sensor.length()<8){
- // for(int k=0;k<8-sensor.length();k++){
- // sensor_switchs[k]=0;
- // }
- // }
- // for(int j=8-sensor.length();j<8;j++){
- // sensor_switchs[j]=Integer.parseInt(sensor.substring(j,
- // j+1));
- // }
- sensors.add(sensor_switchs);
- } else {
- String sensor = Integer.toBinaryString(data[i]);
- int[] sensor_switchs = new int[8];
- ArrayList list = new ArrayList();
- if (sensor.length() < 8) {
- for (int k = 0; k < 8 - sensor.length(); k++) {
- list.add(0);
- }
- }
- for (int j = 0; j < sensor.length(); j++) {
- list.add(Integer.parseInt(sensor
- .substring(j, j + 1)));
- }
- Log.e("length", "list_size" + list.size());
- String s = "";
- for (int k = 0; k < list.size(); k++) {
- sensor_switchs[k] = list.get(k);
- s = s + sensor_switchs[k];
- }
- Log.e("length", s);
- // Log.e("length",
- // "sensor="+sensor+"length="+sensor.length());
- // int [] sensor_switchs=new int[8];
- // if(sensor.length()<8){
- // for(int k=0;k<8-sensor.length();k++){
- // sensor_switchs[k]=0;
- // }
- // }
- // for(int j=8-sensor.length();j<8;j++){
- // sensor_switchs[j]=Integer.parseInt(sensor.substring(j,
- // j+1));
- // }
- sensors.add(sensor_switchs);
- }
- }
- settingInterface.vRetGetSensorSwitchs(1, sensors);
- } else if (data[1] == 0) {
- settingInterface.vRetSetSensorSwitchs(0);
- } else if (data[1] == 41) {
- settingInterface.vRetGetSensorSwitchs(41,
- new ArrayList());
- } else if (data[1] == 88) {
- settingInterface.vRetSetSensorSwitchs(88);
- }
- } else if (option == MESG_TYPE_RET_ALARM_TYPE_MOTOR_PRESET_POS) {
- settingInterface.vRetAlarmPresetMotorPos(data);
- } else if (option == MESG_TYPE_LOOK_MOTOR_PRESET_POS) {
- settingInterface.vRetPresetMotorPos(data);
- } else if (option == IP_CONFIG) {
- settingInterface.vRetIpConfig(data);
- } else if (option == MESG_GET_ALARM_CENTER_PARAMETER) {
- Log.e("sddata", "---");
- if (data[1] == 1) {
- int[] newdata = new int[data.length];
- for (int i = 2; i < data.length; i++) {
- if (data[i] < 0) {
- newdata[i] = data[i] + 256;
- } else {
- newdata[i] = data[i];
- }
- Log.e("sddate", "newdata[i]=" + newdata[i]);
- }
- for (int j = 0; j < data.length; j++) {
- Log.e("sddate", "data[j]" + data[j] + "---" + data.length);
- }
- int state = data[4];
- int ipdress1 = (data[8] + 256) % 256;
- int ipdress2 = (data[9] + 256) % 256;
- int ipdress3 = (data[10] + 256) % 256;
- int ipdress4 = (data[11] + 256) % 256;
- String ipdress = ipdress4 + "." + ipdress3 + "." + ipdress2
- + "." + ipdress1;
- Log.e("ipdress", ipdress);
- int port = newdata[12] | newdata[13] << 8 | newdata[14] << 16
- | newdata[15] << 24;
- String userId;
- // if(newdata.length>=24){
- // long
- // user_Id=newdata[16]|newdata[17]<<8|newdata[18]<<16|newdata[19]<<24|newdata[20]<<32|newdata[21]<<40|newdata[22]<<48|newdata[23]<<56;
- // userId="0x"+Long.toHexString(user_Id).toString().toUpperCase();
- // }else{
- int user_Id = newdata[16] | newdata[17] << 8
- | newdata[18] << 16 | newdata[19] << 24;
- userId = "0x"
- + Integer.toHexString(user_Id).toString().toUpperCase();
- // }
- Log.e("alarm_center", "userId=" + userId);
- Log.e("sddata", "state=" + state + " " + "ipdress=" + ipdress
- + " " + "port" + port + " " + "userId" + userId);
- settingInterface.vRetGetAlarmCenter(1, state, ipdress, port,
- userId);
- } else if (data[1] == 0) {
- settingInterface.vRetSetAlarmCenter(data[1]);
- } else {
- settingInterface.vRetSetAlarmCenter(data[1]);
- }
- } else if (option == MESG_DELETE_ALARMDEVICEID) {
- settingInterface.vRetDeleteDeviceAlarmID(data[1]);
- } else if (option == MESG_TYPE_RET_DEVICE_LANGUAGE) {
- int result = data[1];
- int languegecount = data[4];
- int curlanguege = data[5];
- int[] langueges = new int[languegecount];
- for (int i = 0; i < langueges.length; i++) {
- if (data.length > i + 6) {
- langueges[i] = data[i + 6];
- }
- }
- Log.e("languege", "result=" + result + "--" + "languegecount="
- + languegecount + "--" + "curlanguege=" + curlanguege
- + "--" + "--" + "langueges_length=" + langueges.length);
- settingInterface.vRetDeviceLanguege(result, languegecount,
- curlanguege, langueges);
- } else if (option == MESG_TYPE_FISHEYE_SETTING) {
- settingInterface.vRetFishEyeData(iSrcID, data, datasize);
- } else if (option == MESG_TYPE_FISHEYE_MEMBERLIST) {
- data[1] = 45;// 由于鱼眼获取用户列表结构改变,复用之前的广播
- settingInterface.vRetFishEyeData(iSrcID, data, datasize);
- } else if (option == MESG_TYPE_RET_LAN_IPC_LIST) {
- int result = -1;
- if (data[1] < 0) {
- result = (data[1] + 256);
- } else {
- result = data[1];
- }
- byte[] list_data = new byte[data.length - 6];
- int number = data[2] | data[3] << 8
- | data[4] << 16 | data[5] << 24;
- System.arraycopy(data, 6, list_data, 0, list_data.length);
- String s_list = "";
- try {
- s_list = new String(list_data, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- String[] ipc_list = s_list.split(",");
- String[] list=new String[number];
- for(int i=0;i"+srcID+"--boption-->"+boption+"--emailaddress-->"+emailaddress+"--port-->"+port+"--server-->"+server+"--user-->"+user+"--Entry-->"+Entry);
- }
-
- public static native int SetRobortEmailNew(int iNpcID, int iPassword,
- int iMesgID, byte boption, String emailaddress, int port,
- String server, String user, byte[] pwd, String subject,
- String content, byte Entry, byte reserve1, int reserve2, int pwdlen);
-
- public static void vRetAlarmWithTime(int iSrcId, int iType,
- int isSupportExternAlarm, int iGroup, int iItem, int capNums,
- byte[] Times, byte[] alarmCapDirs, byte[] vedioPaths) {
- String TimeTemp = new String(Times);
- Log.e("dxsTest", "TimeTemp-->" + TimeTemp);
- String Time = TimeTemp.replace("-", "");
- String alarmCapDir = new String(alarmCapDirs);
- String vedioPath = new String(vedioPaths);
- String filename = "G" + MyUtils.compleInteger(iGroup, 2)
- + MyUtils.compleInteger(iItem, 2) + Time
- + MyUtils.compleInteger(capNums, 2);
- alarmCapDir = alarmCapDir + filename;
- p2pInterface.vAllarmingWitghTime(String.valueOf(iSrcId), iType,
- isSupportExternAlarm, iGroup, iItem, capNums, Time,
- alarmCapDir, vedioPath);
- }
-
- public static native int native_rtsp_call(long id, String rstp);
-
- public static native int SetScreenShotPath(String path, String name);
-
- public static native int SendUserData(int cmd, int option, byte[] data,
- int datalength);
-
- public static native int EntryPwd(String password);
-
- public static native int GetAllarmImage(int id, int password,
- String filename, String LocalName);
-
- public static void RetGetAllarmImage(int id, byte[] filename, int errorcode) {
- String file = new String(filename);
- settingInterface.vRetGetAllarmImage(id, file, errorcode);
- }
-
- public static native int GetFileProgress();
-
- public static native void CancelGetRemoteFile();
-
- public static native String RTSPEntry(String pwd);
-
- public static native String HTTPDecrypt(String userID, String pwd,
- int backLen);
-
- public static native String HTTPEncrypt(String userID, String pwd,
- int backLen);
-
- public static native byte[] P2PEntryPassword(int pwd);
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/P2PHandler.java b/p2PCore/src/main/java/com/p2p/core/P2PHandler.java
deleted file mode 100644
index db38586c2..000000000
--- a/p2PCore/src/main/java/com/p2p/core/P2PHandler.java
+++ /dev/null
@@ -1,1983 +0,0 @@
-package com.p2p.core;
-
-import android.content.Context;
-import android.os.Handler;
-import android.util.Log;
-
-import com.p2p.core.P2PInterface.IP2P;
-import com.p2p.core.P2PInterface.ISetting;
-import com.p2p.core.global.Config;
-import com.p2p.core.global.Constants;
-import com.p2p.core.utils.DES;
-import com.p2p.core.utils.MyUtils;
-import com.p2p.core.utils.RtspThread;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.sql.Timestamp;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
-
-/**
- * P2P交互帮助类 在此类中包装需要与设备通信的数据,通过JNI传给设备
- */
-public class P2PHandler {
- String TAG = "SDK";
-
- private static int MSG_ID_SETTING_DEVICE_TIME = Constants.MsgSection.MSG_ID_SETTING_DEVICE_TIME;
- private static int MSG_ID_GETTING_DEVICE_TIME = Constants.MsgSection.MSG_ID_GETTING_DEVICE_TIME;
-
- private static int MSG_ID_GETTING_NPC_SETTINGS = Constants.MsgSection.MSG_ID_GETTING_NPC_SETTINGS;
- private static int MSG_ID_SET_REMOTE_DEFENCE = Constants.MsgSection.MSG_ID_SET_REMOTE_DEFENCE;
- private static int MSG_ID_SET_REMOTE_RECORD = Constants.MsgSection.MSG_ID_SET_REMOTE_RECORD;
- private static int MSG_ID_SETTING_NPC_SETTINGS_VIDEO_FORMAT = Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_VIDEO_FORMAT;
- private static int MSG_ID_SETTING_NPC_SETTINGS_VIDEO_VOLUME = Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_VIDEO_VOLUME;
- private static int MSG_ID_SETTING_NPC_SETTINGS_BUZZER = Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_BUZZER;
- private static int MSG_ID_SETTING_NPC_SETTINGS_MOTION = Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_MOTION;
- private static int MSG_ID_SETTING_NPC_SETTINGS_RECORD_TYPE = Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_RECORD_TYPE;
- private static int MSG_ID_SETTING_NPC_SETTINGS_RECORD_TIME = Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_RECORD_TIME;
- private static int MSG_ID_SETTING_NPC_SETTINGS_RECORD_PLAN_TIME = Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_RECORD_PLAN_TIME;
- private static int MSG_ID_SETTING_NPC_SETTINGS_NET_TYPE = Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_NET_TYPE;
-
- private static int MSG_ID_SETTING_ALARM_EMAIL = (int) (Constants.MsgSection.MSG_ID_SETTING_ALARM_EMAIL + Math
- .random() * 999);
- private static int MSG_ID_GETTING_ALARM_EMAIL = (int) (Constants.MsgSection.MSG_ID_GETTING_ALARM_EMAIL + Math
- .random() * 999);
-
- private static int MSG_ID_SETTING_ALARM_BIND_ID = Constants.MsgSection.MSG_ID_SETTING_ALARM_BIND_ID;
- private static int MSG_ID_GETTING_ALARM_BIND_ID = Constants.MsgSection.MSG_ID_GETTING_ALARM_BIND_ID;
-
- private static int MSG_ID_SETTING_INIT_PASSWORD = Constants.MsgSection.MSG_ID_SETTING_INIT_PASSWORD;
- private static int MSG_ID_SETTING_DEVICE_PASSWORD = Constants.MsgSection.MSG_ID_SETTING_DEVICE_PASSWORD;
- private static int MSG_ID_CHECK_DEVICE_PASSWORD = Constants.MsgSection.MSG_ID_CHECK_DEVICE_PASSWORD;
-
- private static int MSG_ID_SETTING_DEFENCEAREA = Constants.MsgSection.MSG_ID_SETTING_DEFENCEAREA;
- private static int MSG_ID_GETTING_DEFENCEAREA = Constants.MsgSection.MSG_ID_GETTING_DEFENCEAREA;
-
- private static int MSG_ID_SETTING_WIFI = Constants.MsgSection.MSG_ID_SETTING_WIFI;
- private static int MSG_ID_GETTING_WIFI_LIST = Constants.MsgSection.MSG_ID_GETTING_WIFI_LIST;
-
- private static int MSG_ID_GETTING_RECORD_FILE_LIST = Constants.MsgSection.MSG_ID_GETTING_RECORD_FILE_LIST;
- private static int MSG_ID_SEND_MESSAGE = Constants.MsgSection.MSG_ID_SEND_MESSAGE;
- private static int MSG_ID_SEND_CUSTOM_CMD = Constants.MsgSection.MSG_ID_SEND_CUSTOM_CMD;
- private static int MSG_ID_CHECK_DEVICE_UPDATE = Constants.MsgSection.MSG_ID_CHECK_DEVICE_UPDATE;
- private static int MSG_ID_CANCEL_DEVICE_UPDATE = Constants.MsgSection.MSG_ID_CANCEL_DEVICE_UPDATE;
- private static int MSG_ID_DO_DEVICE_UPDATE = Constants.MsgSection.MSG_ID_DO_DEVICE_UPDATE;
- private static int MSG_ID_GET_DEFENCE_STATE = Constants.MsgSection.MSG_ID_GET_DEFENCE_STATE;
- private static int MSG_ID_GET_DEVICE_VERSION = Constants.MsgSection.MSG_ID_GET_DEVICE_VERSION;
- private static int MSG_ID_CLEAR_DEFENCE_GROUP = Constants.MsgSection.MSG_ID_CLEAR_DEFENCE_GROUP;
- private static int MESG_ID_STTING_PIC_REVERSE = Constants.MsgSection.MESG_ID_STTING_PIC_REVERSE;
- private static int MESG_ID_STTING_IR_ALARM_EN = Constants.MsgSection.MESG_ID_STTING_IR_ALARM_EN;
- private static int MESG_STTING_ID_EXTLINE_ALARM_IN_EN = Constants.MsgSection.MESG_STTING_ID_EXTLINE_ALARM_IN_EN;
- private static int MESG_STTING_ID_EXTLINE_ALARM_OUT_EN = Constants.MsgSection.MESG_STTING_ID_EXTLINE_ALARM_OUT_EN;
- private static int MESG_STTING_ID_SECUPGDEV = Constants.MsgSection.MESG_STTING_ID_SECUPGDEV;
- private static int MESG_STTING_ID_GUEST_PASSWD = Constants.MsgSection.MESG_STTING_ID_GUEST_PASSWD;
- private static int MESG_STTING_ID_TIMEZONE = Constants.MsgSection.MESG_STTING_ID_TIMEZONE;
- private static int MESG_GET_SD_CARD_CAPACITY = Constants.MsgSection.MESG_GET_SD_CARD_CAPACITY;
- private static int MESG_SD_CARD_FORMAT = Constants.MsgSection.MESG_SD_CARD_FORMAT;
- private static int MESG_SET_GPIO = Constants.MsgSection.MESG_SET_GPIO;
- private static int MESG_SET_GPI1_0 = Constants.MsgSection.MESG_SET_GPI1_0;
- private static int MESG_SET_PRE_RECORD = Constants.MsgSection.MESG_SET_PRE_RECORD;
- private static int MESG_GET_DEFENCE_AREA_SWITCH = Constants.MsgSection.MESG_GET_DEFENCE_AREA_SWITCH;
- private static int MESG_SET_DEFENCE_AREA_SWITCH = Constants.MsgSection.MESG_SET_DEFENCE_AREA_SWITCH;
- private static int MESG_SET_LAMP = Constants.MsgSection.MESG_SET_LAMP;
- private static int MESG_GET_LAMP = Constants.MsgSection.MESG_GET_LAMP;
- private static int SET_USER_DEFINE_MESG = Constants.MsgSection.SET_USER_DEFINE_MESG;
- private static int MESG_PRESET_MOTOR_POS = Constants.MsgSection.MESG_PRESET_MOTOR_POS;
- private static int MESG_GET_PRESET_MOTOR_POS = Constants.MsgSection.MESG_GET_PRESET_MOTOR_POS;
- private static int MESG_SET_PRESET_MOTOR_POS = Constants.MsgSection.MESG_SET_PRESET_MOTOR_POS;
- private static int MESG_GET_ALARM_CENTER_PARAMETER = Constants.MsgSection.MESG_GET_ALARM_CENTER_PARAMETER;
- private static int MESG_SET_ALARM_CENTER_PARAMETER = Constants.MsgSection.MESG_SET_ALARM_CENTER_PARAMETER;
- private static int MESG_DELETE_ALARMID = Constants.MsgSection.MESG_DELETE_DEVICEALARMID;
- private static int MESG_SET_SYSTEM_MESSAGE_INDEX = Constants.MsgSection.MESG_SET_SYSTEM_MESSAGE_INDEX;
- private static int CONTROL_CAMERA = Constants.MsgSection.CONTROL_CAMERA;
- private static int MESG_SET_RECEIVE_DOOBELL = Constants.MsgSection.MESG_SET_RECEIVE_DOOBELL;
- private static int MESG_GET_LANGUEGE = Constants.MsgSection.MESG_GET_LANGUEGE;
- private static int MESG_SET_LANGUEGE = Constants.MsgSection.MESG_SET_LANGUEGE;
- private static int MESG_TYPE_GET_LAN_IPC_LIST = Constants.MsgSection.MESG_TYPE_GET_LAN_IPC_LIST;
- private static int MESG_TYPE_SET_AP_MODE_CHANGE = Constants.MsgSection.MESG_TYPE_SET_AP_MODE_CHANGE;
- private static P2PHandler manager = null;
-
- private static int IP_CONFIG = Constants.MsgSection.IP_CONFIG;
-
- private P2PHandler() {
- }
-
- ;
-
- public synchronized static P2PHandler getInstance() {
- if (null == manager) {
- synchronized (P2PHandler.class) {
- manager = new P2PHandler();
- }
- }
- return manager;
- }
-
- /**
- * 初始化
- */
- public void p2pInit(Context context, IP2P p2pListener,
- ISetting settingListener) {
- // new MediaPlayer();
- MediaPlayer.getInstance().setP2PInterface(p2pListener);
- MediaPlayer.getInstance().setSettingInterface(settingListener);
- }
-
- /**
- * p2p连接
- */
- public boolean p2pConnect(String activeUser, int codeStr1, int codeStr2) {
- // final String cHostName="|6sci.com|6sci.com.cn";
- // final String cHostName =
- // "|cloudlinks.cn|2cu.co|gwelltimes.com|cloud-links.net";
-// final String cHostName = "|p2p1.cloudlinks.cn|p2p3.cloud-links.net|p2p2.cloudlinks.cn|p2p4.cloud-links.net";
- //2017年1月16日 17:42:33更新
- final String cHostName = "|p2p1.cloudlinks.cn|p2p3.cloud-links.net|p2p2.cloudlinks.cn|p2p4.cloud-links.net|p2p5.cloudlinks.cn|p2p6.cloudlinks.cn|p2p7.cloudlinks.cn|p2p8.cloudlinks.cn|p2p9.cloudlinks.cn|p2p10.cloudlinks.cn";
- // final String cHostName = "|videoipcamera.cn|videoipcamera.com";
- // if (MediaPlayer.getInstance().native_p2p_connect(
- // Integer.parseInt(activeUser)|0x80000000, 886976412, codeStr1,
- // codeStr2,cHostName.getBytes() ) == 1) {
- // return true;
- // } else {
- // return false;
- // }
- int connect;
- int[] customers = Config.AppConfig.CustomerIDs;
- int[] customer_ids = new int[10];
- if (customers.length < 10) {
- for (int i = 0; i < customers.length; i++) {
- customer_ids[i] = customers[i];
- }
- for (int j = customers.length; j < 10; j++) {
- customer_ids[j] = 0;
- }
- } else {
- customer_ids = customers;
- }
- if (activeUser.equals("517401")) {
- connect = MediaPlayer.getInstance().native_p2p_connect(
- Integer.parseInt(activeUser), 886976412, codeStr1,
- codeStr2, cHostName.getBytes(), customer_ids);
- } else {
- connect = MediaPlayer.getInstance().native_p2p_connect(
- Integer.parseInt(activeUser) | 0x80000000, 886976412,
- codeStr1, codeStr2, cHostName.getBytes(), customer_ids);
- }
- if (connect == 1) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * p2p断开
- */
- public void p2pDisconnect() {
- Log.e("leleTest", "p2pDisconnect");
- MediaPlayer.getInstance().native_p2p_disconnect();
- Log.e("leleTest", "p2pDisconnect after");
- }
-
- /**
- * 获取WIFI列表
- */
- public void getWifiList(String contactId, String password) {
- Log.e(TAG, "P2PHANDLER:getWifiList");
- if (this.MSG_ID_GETTING_WIFI_LIST >= (Constants.MsgSection.MSG_ID_GETTING_WIFI_LIST)) {
- this.MSG_ID_GETTING_WIFI_LIST = Constants.MsgSection.MSG_ID_GETTING_WIFI_LIST - 1000;
- }
-
- MediaPlayer.iGetNPCWifiList(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MSG_ID_GETTING_WIFI_LIST);
- this.MSG_ID_GETTING_WIFI_LIST++;
- }
-
- /**
- * 设置WIFI
- */
- public void setWifi(String contactId, String password, int type,
- String name, String wifiPassword) {
- Log.e(TAG, "P2PHANDLER:setWifi");
- String s = null;
- byte[] bt;
- try {
- bt = name.getBytes("UTF-8");
- for (int i = 0; i < bt.length; i++) {
- s = s + " " + bt[i];
- }
- Log.e("setwifiname", "--" + s);
- } catch (UnsupportedEncodingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- if (this.MSG_ID_SETTING_WIFI >= (Constants.MsgSection.MSG_ID_SETTING_WIFI)) {
- this.MSG_ID_SETTING_WIFI = Constants.MsgSection.MSG_ID_SETTING_WIFI - 1000;
- }
-
- MediaPlayer.iSetNPCWifi(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MSG_ID_SETTING_WIFI, type,
- name.getBytes(), name.length(), wifiPassword.getBytes(),
- wifiPassword.length());
- this.MSG_ID_SETTING_WIFI++;
- }
-
- /**
- * 获取NPC各种设置
- */
- public void getNpcSettings(String contactId, String password) {
- Log.e(TAG, "P2PHANDLER:getNpcSettings");
-
- int iPassword = Integer.MAX_VALUE;
- try {
- iPassword = Integer.parseInt(password);
- } catch (Exception e) {
- iPassword = Integer.MAX_VALUE;
- }
-
- if (this.MSG_ID_GETTING_NPC_SETTINGS >= (Constants.MsgSection.MSG_ID_GETTING_NPC_SETTINGS)) {
- this.MSG_ID_GETTING_NPC_SETTINGS = Constants.MsgSection.MSG_ID_GETTING_NPC_SETTINGS - 1000;
- }
-
- MediaPlayer.iGetNPCSettings(Integer.parseInt(contactId), iPassword,
- this.MSG_ID_GETTING_NPC_SETTINGS);
- this.MSG_ID_GETTING_NPC_SETTINGS++;
- }
-
- /**
- * 获取布放状态
- */
- public void getDefenceStates(String contactId, String password) {
- Log.e(TAG, "P2PHANDLER:getDefenceStates");
- int iPassword = Integer.MAX_VALUE;
- try {
- iPassword = Integer.parseInt(password);
- } catch (Exception e) {
- iPassword = Integer.MAX_VALUE;
- }
- Log.e("defence", Integer.parseInt(contactId) + "--" + iPassword
- + "---------------");
- if (this.MSG_ID_GET_DEFENCE_STATE >= (Constants.MsgSection.MSG_ID_GET_DEFENCE_STATE)) {
- this.MSG_ID_GET_DEFENCE_STATE = Constants.MsgSection.MSG_ID_GET_DEFENCE_STATE - 1000;
- }
-
- MediaPlayer.iGetNPCSettings(Integer.parseInt(contactId), iPassword,
- this.MSG_ID_GET_DEFENCE_STATE);
- this.MSG_ID_GET_DEFENCE_STATE++;
- }
-
- /**
- * 检查密码
- */
- public void checkPassword(String contactId, String password) {
- Log.e(TAG, "P2PHANDLER:checkPassword");
- if (this.MSG_ID_CHECK_DEVICE_PASSWORD >= (Constants.MsgSection.MSG_ID_CHECK_DEVICE_PASSWORD)) {
- this.MSG_ID_CHECK_DEVICE_PASSWORD = Constants.MsgSection.MSG_ID_CHECK_DEVICE_PASSWORD - 1000;
- }
-
- MediaPlayer.iGetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MSG_ID_CHECK_DEVICE_PASSWORD);
- this.MSG_ID_CHECK_DEVICE_PASSWORD++;
- }
-
- /**
- * 获取防区设置
- */
- public void getDefenceArea(String contactId, String password) {
- Log.e(TAG, "P2PHANDLER:getDefenceArea");
- if (this.MSG_ID_GETTING_DEFENCEAREA >= (Constants.MsgSection.MSG_ID_GETTING_DEFENCEAREA)) {
- this.MSG_ID_GETTING_DEFENCEAREA = Constants.MsgSection.MSG_ID_GETTING_DEFENCEAREA - 1000;
- }
-
- MediaPlayer.iGetAlarmCodeStatus(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MSG_ID_GETTING_DEFENCEAREA);
- this.MSG_ID_GETTING_DEFENCEAREA++;
- }
-
- /**
- * 设置远程布防
- */
- public void setRemoteDefence(String contactId, String password, int value) {
- Log.e(TAG, "P2PHANDLER:setRemoteDefence");
- if (this.MSG_ID_SET_REMOTE_DEFENCE >= (Constants.MsgSection.MSG_ID_SET_REMOTE_DEFENCE)) {
- this.MSG_ID_SET_REMOTE_DEFENCE = Constants.MsgSection.MSG_ID_SET_REMOTE_DEFENCE - 1000;
- }
- MediaPlayer.iSetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MSG_ID_SET_REMOTE_DEFENCE,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_REMOTE_DEFENCE,
- value);
- this.MSG_ID_SET_REMOTE_DEFENCE++;
- }
-
- // public void SetSystemMessageIndex(int iSystemMessageType,
- // int iSystemMessageIndex) {
- // MediaPlayer.SetSystemMessageIndex(iSystemMessageType,
- // iSystemMessageIndex);
- // }
-
- public void vSendWiFiCmd(int iType, byte[] SSID, int iSSIDLen,
- byte[] Password, int iPasswordLen) {
- MediaPlayer.vSendWiFiCmd(iType, SSID, iSSIDLen, Password, iPasswordLen);
- }
-
- /**
- * 设置远程录像
- */
- public void setRemoteRecord(String contactId, String password, int value) {
- Log.e(TAG, "P2PHANDLER:setRemoteRecord");
- if (this.MSG_ID_SET_REMOTE_RECORD >= (Constants.MsgSection.MSG_ID_SET_REMOTE_RECORD)) {
- this.MSG_ID_SET_REMOTE_RECORD = Constants.MsgSection.MSG_ID_SET_REMOTE_RECORD - 1000;
- }
- MediaPlayer
- .iSetNPCSettings(
- Integer.parseInt(contactId),
- Integer.parseInt(password),
- this.MSG_ID_SET_REMOTE_RECORD,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_REMOTE_RECORD,
- value);
- this.MSG_ID_SET_REMOTE_RECORD++;
- }
-
- /**
- * 设置设备时间
- */
- public void setDeviceTime(String contactId, String password, String time) {
- Log.e(TAG, "P2PHANDLER:setDeviceTime");
- if (this.MSG_ID_SETTING_DEVICE_TIME >= (Constants.MsgSection.MSG_ID_SETTING_DEVICE_TIME)) {
- this.MSG_ID_SETTING_DEVICE_TIME = Constants.MsgSection.MSG_ID_SETTING_DEVICE_TIME - 1000;
- }
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm");
- Date date = null;
- try {
- date = df.parse(time);
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(date);
- int parseTime = 0;
-
- if (null != date) {
-
- if (time.substring(11, 13).equals("12")) {
- parseTime = ((calendar.get(Calendar.YEAR) - 2000) << 24)
- | (((calendar.get(Calendar.MONTH) + 1) << 18))
- | (calendar.get(Calendar.DAY_OF_MONTH) << 12)
- | (12 << 6) | (calendar.get(Calendar.MINUTE) << 0);
- } else {
- parseTime = ((calendar.get(Calendar.YEAR) - 2000) << 24)
- | (((calendar.get(Calendar.MONTH) + 1) << 18))
- | (calendar.get(Calendar.DAY_OF_MONTH) << 12)
- | (calendar.get(Calendar.HOUR_OF_DAY) << 6)
- | (calendar.get(Calendar.MINUTE) << 0);
- }
-
- }
- MediaPlayer.iSetNPCDateTime(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MSG_ID_SETTING_DEVICE_TIME,
- parseTime);
- this.MSG_ID_SETTING_DEVICE_TIME++;
- }
-
- /**
- * 获取设备时间
- */
- public void getDeviceTime(String contactId, String password) {
- Log.e(TAG, "P2PHANDLER:getDeviceTime");
- if (this.MSG_ID_GETTING_DEVICE_TIME >= (Constants.MsgSection.MSG_ID_GETTING_DEVICE_TIME)) {
- this.MSG_ID_GETTING_DEVICE_TIME = Constants.MsgSection.MSG_ID_GETTING_DEVICE_TIME - 1000;
- }
-
- MediaPlayer.iGetNPCDateTime(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MSG_ID_GETTING_DEVICE_TIME);
- this.MSG_ID_GETTING_DEVICE_TIME++;
- }
-
- /**
- * 设置设备音量
- */
- public void setVideoVolume(String contactId, String password, int value) {
- Log.e(TAG, "P2PHANDLER:setVideoVolume");
- if (this.MSG_ID_SETTING_NPC_SETTINGS_VIDEO_VOLUME >= (Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_VIDEO_VOLUME)) {
- this.MSG_ID_SETTING_NPC_SETTINGS_VIDEO_VOLUME = Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_VIDEO_VOLUME - 1000;
- }
-
- MediaPlayer.iSetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(password),
- this.MSG_ID_SETTING_NPC_SETTINGS_VIDEO_VOLUME,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_VOLUME, value);
- this.MSG_ID_SETTING_NPC_SETTINGS_VIDEO_VOLUME++;
- }
-
- /**
- * 设置视频格式
- */
- public void setVideoFormat(String contactId, String password, int value) {
- Log.e(TAG, "P2PHANDLER:setVideoFormat");
- if (this.MSG_ID_SETTING_NPC_SETTINGS_VIDEO_FORMAT >= (Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_VIDEO_FORMAT)) {
- this.MSG_ID_SETTING_NPC_SETTINGS_VIDEO_FORMAT = Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_VIDEO_FORMAT - 1000;
- }
-
- MediaPlayer.iSetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(password),
- this.MSG_ID_SETTING_NPC_SETTINGS_VIDEO_FORMAT,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_VIDEO_FORMAT, value);
- this.MSG_ID_SETTING_NPC_SETTINGS_VIDEO_FORMAT++;
- }
-
- /**
- * 设置录像类型
- */
- public void setRecordType(String contactId, String password, int type) {
- Log.e(TAG, "P2PHANDLER:setRecordType");
- if (this.MSG_ID_SETTING_NPC_SETTINGS_RECORD_TYPE >= (Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_RECORD_TYPE)) {
- this.MSG_ID_SETTING_NPC_SETTINGS_RECORD_TYPE = Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_RECORD_TYPE - 1000;
- }
-
- MediaPlayer.iSetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(password),
- this.MSG_ID_SETTING_NPC_SETTINGS_RECORD_TYPE,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_RECORD_TYPE, type);
- this.MSG_ID_SETTING_NPC_SETTINGS_RECORD_TYPE++;
- }
-
- /**
- * 设置录像时间
- */
- public void setRecordTime(String contactId, String password, int time) {
- Log.e(TAG, "P2PHANDLER:setRecordTime");
- if (this.MSG_ID_SETTING_NPC_SETTINGS_RECORD_TIME >= (Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_RECORD_TIME)) {
- this.MSG_ID_SETTING_NPC_SETTINGS_RECORD_TIME = Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_RECORD_TIME - 1000;
- }
-
- MediaPlayer.iSetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(password),
- this.MSG_ID_SETTING_NPC_SETTINGS_RECORD_TIME,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_RECORD_TIME, time);
- this.MSG_ID_SETTING_NPC_SETTINGS_RECORD_TIME++;
- }
-
- /**
- * 设置录像计划时间
- */
- public void setRecordPlanTime(String contactId, String password, String time) {
- Log.e(TAG, "P2PHANDLER:setRecordPlanTime");
- if (this.MSG_ID_SETTING_NPC_SETTINGS_RECORD_PLAN_TIME >= (Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_RECORD_PLAN_TIME)) {
- this.MSG_ID_SETTING_NPC_SETTINGS_RECORD_PLAN_TIME = Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_RECORD_PLAN_TIME - 1000;
- }
-
- int iTime = MyUtils.convertPlanTime(time);
- MediaPlayer.iSetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(password),
- this.MSG_ID_SETTING_NPC_SETTINGS_RECORD_PLAN_TIME,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_RECORD_PLAN_TIME,
- iTime);
- this.MSG_ID_SETTING_NPC_SETTINGS_RECORD_PLAN_TIME++;
- }
-
- /**
- * 设置防区状态
- */
- public void setDefenceAreaState(String contactId, String password,
- int group, int item, int type) {
- Log.e(TAG, "P2PHANDLER:setDefenceAreaState");
- if (this.MSG_ID_SETTING_DEFENCEAREA >= (Constants.MsgSection.MSG_ID_SETTING_DEFENCEAREA)) {
- this.MSG_ID_SETTING_DEFENCEAREA = Constants.MsgSection.MSG_ID_SETTING_DEFENCEAREA - 1000;
- }
-
- MediaPlayer.iSetAlarmCodeStatus(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MSG_ID_SETTING_DEFENCEAREA, 1,
- type, new int[] { group }, new int[] { item });
- this.MSG_ID_SETTING_DEFENCEAREA++;
- }
-
- /**
- * 清空防区状态
- */
- public void clearDefenceAreaState(String contactId, String password,
- int group) {
- Log.e(TAG, "P2PHANDLER:setDefenceAreaState");
- if (this.MSG_ID_CLEAR_DEFENCE_GROUP >= (Constants.MsgSection.MSG_ID_CLEAR_DEFENCE_GROUP)) {
- this.MSG_ID_CLEAR_DEFENCE_GROUP = Constants.MsgSection.MSG_ID_CLEAR_DEFENCE_GROUP - 1000;
- }
-
- MediaPlayer.iClearAlarmCodeGroup(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MSG_ID_CLEAR_DEFENCE_GROUP,
- group);
-
- this.MSG_ID_CLEAR_DEFENCE_GROUP++;
- }
-
- /**
- * 设置网络类型
- */
- public void setNetType(String contactId, String password, int type) {
- Log.e(TAG, "P2PHANDLER:setNetType");
- if (this.MSG_ID_SETTING_NPC_SETTINGS_NET_TYPE >= (Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_NET_TYPE)) {
- this.MSG_ID_SETTING_NPC_SETTINGS_NET_TYPE = Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_NET_TYPE - 1000;
- }
-
- MediaPlayer.iSetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(password),
- this.MSG_ID_SETTING_NPC_SETTINGS_NET_TYPE,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_NET_TYPE, type);
- this.MSG_ID_SETTING_NPC_SETTINGS_NET_TYPE++;
- }
-
- /**
- * 设置绑定报警ID
- */
- public void setBindAlarmId(String contactId, String password, int count,
- String[] datas) {
- Log.e(TAG, "P2PHANDLER:setBindAlarmId");
- if (this.MSG_ID_SETTING_ALARM_BIND_ID >= (Constants.MsgSection.MSG_ID_SETTING_ALARM_BIND_ID)) {
- this.MSG_ID_SETTING_ALARM_BIND_ID = Constants.MsgSection.MSG_ID_SETTING_ALARM_BIND_ID - 1000;
- }
- int[] iData = new int[datas.length];
- try {
-
- for (int i = 0; i < datas.length; i++) {
- iData[i] = Integer.parseInt(datas[i]);
- }
- } catch (Exception e) {
- iData = new int[] { 0 };
- count = 1;
- }
- MediaPlayer.iSetBindAlarmId(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MSG_ID_SETTING_ALARM_BIND_ID,
- count, iData);
- this.MSG_ID_SETTING_ALARM_BIND_ID++;
- }
-
- /**
- * 获取绑定报警ID
- */
- public void getBindAlarmId(String contactId, String password) {
- Log.e(TAG, "P2PHANDLER:getBindAlarmId");
- if (this.MSG_ID_GETTING_ALARM_BIND_ID >= (Constants.MsgSection.MSG_ID_GETTING_ALARM_BIND_ID)) {
- this.MSG_ID_GETTING_ALARM_BIND_ID = Constants.MsgSection.MSG_ID_GETTING_ALARM_BIND_ID - 1000;
- }
-
- MediaPlayer.iGetBindAlarmId(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MSG_ID_GETTING_ALARM_BIND_ID);
- this.MSG_ID_GETTING_ALARM_BIND_ID++;
- }
-
- /**
- * 设置报警邮箱
- */
- public void setAlarmEmail(String contactId, String password, String email) {
- Log.e(TAG, "P2PHANDLER:setAlarmEmail");
- if (this.MSG_ID_SETTING_ALARM_EMAIL >= (Constants.MsgSection.MSG_ID_SETTING_ALARM_EMAIL)) {
- this.MSG_ID_SETTING_ALARM_EMAIL = Constants.MsgSection.MSG_ID_SETTING_ALARM_EMAIL - 1000;
- }
-
- MediaPlayer.iSetNPCEmail(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MSG_ID_SETTING_ALARM_EMAIL,
- email.getBytes(), email.length());
- this.MSG_ID_SETTING_ALARM_EMAIL++;
- }
-
- /**
- * 设置报警邮箱带SMTP参数(添加##结束标记并用0补齐8的整数位)
- *
- * @param contactId
- * @param password
- * @param boption
- * 操作标记
- * @param emailaddress
- * 收件人邮箱地址
- * @param port
- * 发件人的邮局SMTP端口参数
- * @param server
- * 发件人的邮局SMTP服务参数
- * @param user
- * 发件人邮箱
- * @param pwd
- * 发件人邮箱密码
- * @param subject
- * 发件主题
- * @param content
- * 发件邮件内容
- */
- public void setAlarmEmailWithSMTP(String contactId, String password,
- byte boption, String emailaddress, int port, String server,
- String user, String pwd, String subject, String content,
- byte Entry, byte reserve1, int reserve2) {
- Log.e(TAG, "P2PHANDLER:setAlarmEmail");
- if (this.MSG_ID_SETTING_ALARM_EMAIL >= (Constants.MsgSection.MSG_ID_SETTING_ALARM_EMAIL)) {
- this.MSG_ID_SETTING_ALARM_EMAIL = Constants.MsgSection.MSG_ID_SETTING_ALARM_EMAIL - 1000;
- }
- String pwds = pwd + "##";
- int m = pwds.length();
- int k = 8 - m % 8;
- for (int i = 0; i < k; i++) {
- pwds = pwds + "0";
- }
- byte[] ppp = null;
- try {
- ppp = DES.des(pwds.getBytes(), 0);
- } catch (Exception e) {
- ppp = new byte[] { 0 };
- e.printStackTrace();
- }
- Log.e("alarm_email", "contactId=" + contactId + "--" + "password="
- + Integer.parseInt(password) + "--" + "boption=" + boption
- + "--" + "emailaddress=" + emailaddress + "--" + "port=" + port
- + "--" + "server=" + server + "--" + "user=" + user + "--"
- + "ppp=" + ppp + "--" + "subject=" + subject + "--"
- + "content=" + content + "--" + "Entry=" + Entry + "--"
- + "reserve1=" + reserve1 + "--" + "reserve2=" + reserve1);
- MediaPlayer.SetRobortEmailNew(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MSG_ID_SETTING_ALARM_EMAIL,
- boption, emailaddress, port, server, user, ppp, subject,
- content, Entry, (byte) reserve1, reserve2, ppp.length);
- this.MSG_ID_SETTING_ALARM_EMAIL++;
- }
-
- /**
- * 获取报警邮箱
- */
- public void getAlarmEmail(String contactId, String password) {
- Log.e(TAG, "P2PHANDLER:getAlarmEmail");
- if (this.MSG_ID_GETTING_ALARM_EMAIL >= (Constants.MsgSection.MSG_ID_GETTING_ALARM_EMAIL)) {
- this.MSG_ID_GETTING_ALARM_EMAIL = Constants.MsgSection.MSG_ID_GETTING_ALARM_EMAIL - 1000;
- }
-
- MediaPlayer.iGetNPCEmail(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MSG_ID_GETTING_ALARM_EMAIL);
- this.MSG_ID_GETTING_ALARM_EMAIL++;
- }
-
- /**
- * 设置蜂鸣器
- */
- public void setBuzzer(String contactId, String password, int value) {
- Log.e(TAG, "P2PHANDLER:setBuzzer");
- if (this.MSG_ID_SETTING_NPC_SETTINGS_BUZZER >= (Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_BUZZER)) {
- this.MSG_ID_SETTING_NPC_SETTINGS_BUZZER = Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_BUZZER - 1000;
- }
-
- MediaPlayer.iSetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(password),
- this.MSG_ID_SETTING_NPC_SETTINGS_BUZZER,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_BUZZER, value);
- this.MSG_ID_SETTING_NPC_SETTINGS_BUZZER++;
- }
-
- /**
- * 设置移动侦测
- */
- public void setMotion(String contactId, String password, int value) {
- Log.e(TAG, "P2PHANDLER:setMotion");
- if (this.MSG_ID_SETTING_NPC_SETTINGS_MOTION >= (Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_MOTION)) {
- this.MSG_ID_SETTING_NPC_SETTINGS_MOTION = Constants.MsgSection.MSG_ID_SETTING_NPC_SETTINGS_MOTION - 1000;
- }
-
- MediaPlayer.iSetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(password),
- this.MSG_ID_SETTING_NPC_SETTINGS_MOTION,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_MOTION_DECT, value);
- this.MSG_ID_SETTING_NPC_SETTINGS_MOTION++;
- }
-
- /**
- * 设置初始密码
- */
- public void setInitPassword(String contactId, String password) {
- Log.e(TAG, "P2PHANDLER:setInitPassword");
- if (this.MSG_ID_SETTING_INIT_PASSWORD >= (Constants.MsgSection.MSG_ID_SETTING_INIT_PASSWORD)) {
- this.MSG_ID_SETTING_INIT_PASSWORD = Constants.MsgSection.MSG_ID_SETTING_INIT_PASSWORD - 1000;
- }
-
- MediaPlayer.iSetInitPassword(Integer.parseInt(contactId), 0,
- this.MSG_ID_SETTING_INIT_PASSWORD, Integer.parseInt(password),Integer.parseInt(contactId));
- this.MSG_ID_SETTING_INIT_PASSWORD++;
- }
-
- /**
- * 设置设备密码
- */
- public void setDevicePassword(String contactId, String oldPassword,
- String newPassword) {
- Log.e(TAG, "P2PHANDLER:setDevicePassword");
- if (this.MSG_ID_SETTING_DEVICE_PASSWORD >= (Constants.MsgSection.MSG_ID_SETTING_DEVICE_PASSWORD)) {
- this.MSG_ID_SETTING_DEVICE_PASSWORD = Constants.MsgSection.MSG_ID_SETTING_DEVICE_PASSWORD - 1000;
- }
-
- MediaPlayer.iSetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(oldPassword),
- this.MSG_ID_SETTING_DEVICE_PASSWORD,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_DEVICE_PWD,
- Integer.parseInt(newPassword));
- this.MSG_ID_SETTING_DEVICE_PASSWORD++;
- }
-
- /**
- * 设置访客密码
- */
- public void setDeviceVisitorPassword(String contactId, String oldPassword,
- String visitorPassword) {
- Log.e(TAG, "P2PHANDLER:setDevicePassword");
- if (this.MESG_STTING_ID_GUEST_PASSWD >= (Constants.MsgSection.MESG_STTING_ID_GUEST_PASSWD)) {
- this.MESG_STTING_ID_GUEST_PASSWD = Constants.MsgSection.MESG_STTING_ID_GUEST_PASSWD - 1000;
- }
-
- MediaPlayer.iSetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(oldPassword),
- this.MESG_STTING_ID_GUEST_PASSWD,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_GUEST_PASSWD,
- Integer.parseInt(visitorPassword));
- MediaPlayer.iSetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(oldPassword),
- this.MESG_STTING_ID_GUEST_PASSWD,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_VISITORPWD,
- Integer.parseInt(visitorPassword));
- this.MESG_STTING_ID_GUEST_PASSWD++;
- }
-
- /**
- * 获取好友状态
- */
-
- public void getFriendStatus(String[] contactIds) {
- Log.e(TAG, "P2PHANDLER:getFriendStatus");
- int[] friends = new int[contactIds.length];
- for (int i = 0; i < contactIds.length; i++) {
- if (contactIds[i].substring(0, 1).equals("0")) {
- friends[i] = Integer.parseInt(contactIds[i]) | 0x80000000;
- } else {
- friends[i] = Integer.parseInt(contactIds[i]);
- }
- }
- MediaPlayer.iGetFriendsStatus(friends, friends.length);
- }
-
- /**
- * 获取录像列表
- */
-
- public void getRecordFiles(String contactId, String password,
- int timeInterval) {
- Log.e(TAG, "P2PHANDLER:getRecordFiles");
- if (this.MSG_ID_GETTING_RECORD_FILE_LIST >= (Constants.MsgSection.MSG_ID_GETTING_RECORD_FILE_LIST)) {
- this.MSG_ID_GETTING_RECORD_FILE_LIST = Constants.MsgSection.MSG_ID_GETTING_RECORD_FILE_LIST - 1000;
- }
- Timestamp now = new Timestamp(System.currentTimeMillis());
- int i_start;
- if (now.getDate() < timeInterval) {
- i_start = ((now.getYear() - 100) << 24)
- | (((now.getMonth()) << 18))
- | ((timeInterval - now.getDate()) << 12)
- | ((now.getHours()) << 6) | ((now.getMinutes()) << 0);
- } else {
- i_start = ((now.getYear() - 100) << 24)
- | (((now.getMonth() + 1) << 18))
- | ((now.getDate() - timeInterval) << 12)
- | ((now.getHours()) << 6) | ((now.getMinutes()) << 0);
- }
- int i_end = ((now.getYear() - 100) << 24)
- | (((now.getMonth() + 1) << 18)) | ((now.getDate()) << 12)
- | ((now.getHours()) << 6) | ((now.getMinutes()) << 0);
- Log.e("timestamp", "year" + now.getYear() + "month" + now.getMonth()
- + "hour" + now.getHours());
- Log.e("timestamp", "i_start=" + i_start + "i_end=" + i_end);
- MediaPlayer.iGetRecFiles(Integer.parseInt(contactId),
- Integer.parseInt(password),
- this.MSG_ID_GETTING_RECORD_FILE_LIST, i_start, i_end);
- this.MSG_ID_GETTING_RECORD_FILE_LIST++;
- }
-
- /**
- * 获取录像列表
- */
-
- public void getRecordFiles(String contactId, String password, Date start,
- Date end) {
- Log.e(TAG, "P2PHANDLER:getRecordFiles");
- if (this.MSG_ID_GETTING_RECORD_FILE_LIST >= (Constants.MsgSection.MSG_ID_GETTING_RECORD_FILE_LIST)) {
- this.MSG_ID_GETTING_RECORD_FILE_LIST = Constants.MsgSection.MSG_ID_GETTING_RECORD_FILE_LIST - 1000;
- }
-
- int i_start = ((start.getYear() - 100) << 24)
- | (((start.getMonth() + 1) << 18)) | ((start.getDate()) << 12)
- | ((start.getHours()) << 6) | ((start.getMinutes()) << 0);
- int i_end = ((end.getYear() - 100) << 24)
- | (((end.getMonth() + 1) << 18)) | ((end.getDate()) << 12)
- | ((end.getHours()) << 6) | ((end.getMinutes()) << 0);
- Log.e("timestamp", "i_start=" + i_start + "i_end=" + i_end);
- MediaPlayer.iGetRecFiles(Integer.parseInt(contactId),
- Integer.parseInt(password),
- this.MSG_ID_GETTING_RECORD_FILE_LIST, i_start, i_end);
- this.MSG_ID_GETTING_RECORD_FILE_LIST++;
- }
-
- /**
- * 发送端消息
- */
- public String sendMessage(String contactId, String msg) {
- Log.e(TAG, "P2PHANDLER:sendMessage");
- if (this.MSG_ID_SEND_MESSAGE >= (Constants.MsgSection.MSG_ID_SEND_MESSAGE)) {
- this.MSG_ID_SEND_MESSAGE = Constants.MsgSection.MSG_ID_SEND_MESSAGE - 1000;
- }
- int iId = Integer.parseInt(contactId) | 0x80000000;
- MediaPlayer.iSendMesgToFriend(iId, this.MSG_ID_SEND_MESSAGE,
- msg.getBytes(), msg.getBytes().length);
- this.MSG_ID_SEND_MESSAGE++;
- return String.valueOf(this.MSG_ID_SEND_MESSAGE - 1);
- }
-
- /**
- * 发送自定义命令
- */
- public String sendCustomCmd(String contactId, String password, String msg) {
- Log.e(TAG, "P2PHANDLER:sendCustomCmd");
- if (this.MSG_ID_SEND_CUSTOM_CMD >= (Constants.MsgSection.MSG_ID_SEND_CUSTOM_CMD)) {
- this.MSG_ID_SEND_CUSTOM_CMD = Constants.MsgSection.MSG_ID_SEND_CUSTOM_CMD - 1000;
- }
- int iId = Integer.parseInt(contactId);
- MediaPlayer.iSendCmdToFriend(iId, Integer.parseInt(password),
- this.MSG_ID_SEND_CUSTOM_CMD, msg.getBytes(),
- msg.getBytes().length);
- this.MSG_ID_SEND_CUSTOM_CMD++;
- return String.valueOf(this.MSG_ID_SEND_CUSTOM_CMD - 1);
- }
-
- /**
- * 打开音频设备并准备播放
- *
- * @param callType
- * 监控类型
- */
- public void openAudioAndStartPlaying(int callType) {
- try {
- MediaPlayer.getInstance().openAudioTrack();
- MediaPlayer.getInstance()._StartPlaying(
- Constants.P2P_WINDOW.P2P_SURFACE_START_PLAYING_WIDTH,
- Constants.P2P_WINDOW.P2P_SURFACE_START_PLAYING_HEIGHT,
- callType);
- } catch (IllegalStateException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * 挂断p2p
- */
- public synchronized void reject() {
- synchronized (P2PHandler.this) {
- MediaPlayer.getInstance().native_p2p_hungup();
- }
-
- }
-
- /**
- * 接听
- */
- public void accept() {
- MediaPlayer.getInstance().native_p2p_accpet();
- }
-
- /**
- * RTSP
- */
- public void RTSPConnect(final String contactId, final String password,
- final boolean isOutCall, final int callType, final String callId,
- final String ipFlag, final String pushMsg, String ipAddress,
- int VideoMode, Handler rtspHandler,String headerID) {
- new RtspThread(ipAddress, rtspHandler, contactId, password, isOutCall,
- callType, callId, ipFlag, pushMsg, VideoMode,headerID).start();
-
- }
-
- /**
- * 呼叫(监控)
- * @param contactId APPID
- * @param password 密码
- * @param isOutCall
- * @param callType
- * @param callId 呼叫ID
- * @param ipFlag IP标记
- * @param pushMsg 附带消息
- * @param VideoMode 视屏分辨率
- * @param headerID 头像截图命名ID
- * @return
- */
-
- public boolean call(final String contactId, final String password,
- final boolean isOutCall, final int callType, final String callId,
- final String ipFlag, final String pushMsg, int VideoMode,String headerID) {
- boolean result = false;
- long headerId=Long.parseLong(headerID);
- byte[] byt = new byte[8];
- try {
- if (isOutCall) {
- String parseNum = callId;
- if (parseNum.contains("+")) {
- boolean isPhone = false;
- for (int i = 0; i < regionCode.length; i++) {
- int cLength = String.valueOf(regionCode[i]).length();
- parseNum = parseNum.replace("+", "");
- String hight = parseNum.substring(0, cLength);
- String low = parseNum.substring(cLength,
- parseNum.length());
- if (Integer.parseInt(hight) == regionCode[i]) {
- long num = (Long.parseLong(hight) << 48 | Long
- .parseLong(low));
- parseNum = String.valueOf(num);
- isPhone = true;
- break;
- }
- }
-
- if (!isPhone) {
- return result;
- }
- }
-
- long id = Long.parseLong(parseNum);
- if (parseNum.charAt(0) == '0') {
- id = 0 - id;
- }
-
- int pwd = 0;
-
- int isMonitor = 0;
- if (callType == Constants.P2P_TYPE.P2P_TYPE_MONITOR) {
- isMonitor = 1;
- pwd = Integer.parseInt(password);
- }
-
- int x = 0;
- if (null != ipFlag && !ipFlag.equals("")
- && MyUtils.isNumeric(ipFlag)) {
- x = MediaPlayer.getInstance().native_p2p_call(
- Integer.parseInt(ipFlag), isMonitor, pwd, -1,
- VideoMode, byt, pushMsg.getBytes("utf-8"), "gwell",headerId);
- } else {
- x = MediaPlayer.getInstance().native_p2p_call(id,
- isMonitor, pwd, -1, VideoMode, byt,
- pushMsg.getBytes("utf-8"), "gwell",headerId);
- }
-
- if (x == 1) {
- result = true;
- Log.i("tag", "p2p call success");
- } else {
- Log.e("tag", "p2p call fail");
- }
-
- }
- } catch (Exception e) {
- result = false;
- e.printStackTrace();
- }
- return result;
-
- // new DelayThread(1000, new DelayThread.OnRunListener() {
- //
- // @Override
- // public void run() {
- // // TODO Auto-generated method stub
- // try {
- // synchronized (P2PHandler.this) {
- // call_alter(contactId, password, isOutCall, callType,
- // callId, ipFlag, pushMsg);
- // }
- // } catch (UnsupportedEncodingException e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- //
- // }
- // }).start();
- }
-
- private static int[] regionCode = { 1264, 1268, 1242, 1246, 1441, 1284,
- 1345, 1767, 1809, 1473, 1876, 1664, 1787, 1869, 1758, 1784, 1868,
- 1649, 1340, 1671, 1670, 210, 211, 212, 213, 214, 215, 216, 217,
- 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230,
- 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243,
- 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256,
- 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269,
- 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 350, 351, 352,
- 353, 354, 355, 356, 357, 358, 359, 370, 371, 372, 373, 374, 375,
- 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388,
- 389, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 500, 501,
- 502, 503, 504, 505, 506, 507, 508, 509, 590, 591, 592, 593, 594,
- 595, 596, 597, 598, 599, 670, 671, 672, 673, 674, 675, 676, 677,
- 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690,
- 691, 692, 693, 694, 695, 696, 697, 698, 699, 800, 801, 802, 803,
- 804, 805, 806, 807, 808, 809, 850, 851, 852, 853, 854, 855, 856,
- 857, 858, 859, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879,
- 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 960, 961, 962,
- 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975,
- 976, 977, 978, 979, 990, 991, 992, 993, 994, 995, 996, 997, 998,
- 999, 20, 27, 28, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, 47, 48, 49, 51, 52, 53, 54, 55, 56, 57, 58, 60, 61,
- 62, 63, 64, 65, 66, 81, 82, 83, 84, 86, 90, 91, 92, 93, 94, 95, 98,
- 1, 7 };
-
- private void call_alter(String threeNumber, String password,
- boolean isOutCall, int callType, String callId, String ipFlag,
- String pushMsg, int VideoMode,String headerID) throws UnsupportedEncodingException {
- byte[] byt = new byte[8];
- long headerId=Long.parseLong(headerID);
- if (isOutCall) {
- String parseNum = callId;
- if (parseNum.contains("+")) {
- boolean isPhone = false;
- try {
- for (int i = 0; i < regionCode.length; i++) {
- int cLength = String.valueOf(regionCode[i]).length();
- parseNum = parseNum.replace("+", "");
- String hight = parseNum.substring(0, cLength);
- String low = parseNum.substring(cLength,
- parseNum.length());
- if (Integer.parseInt(hight) == regionCode[i]) {
- long num = (Long.parseLong(hight) << 48 | Long
- .parseLong(low));
- parseNum = String.valueOf(num);
- isPhone = true;
- break;
- }
- }
- } catch (Exception e) {
- // onCallResult(Constants.P2P_CALL.CALL_RESULT.CALL_PHONE_FORMAT_ERROR);
- }
-
- if (!isPhone) {
- // onCallResult(Constants.P2P_CALL.CALL_RESULT.CALL_PHONE_FORMAT_ERROR);
- return;
- }
- }
-
- long id = Long.parseLong(parseNum);
- if (parseNum.charAt(0) == '0') {
- id = 0 - id;
- }
-
- int pwd = 0;
-
- int isMonitor = 0;
- if (callType == Constants.P2P_TYPE.P2P_TYPE_MONITOR) {
- isMonitor = 1;
- if (MyUtils.isNumeric(password)) {
- pwd = Integer.parseInt(password);
- }
- }
-
- int result = 0;
- if (null != ipFlag && !ipFlag.equals("")
- && MyUtils.isNumeric(ipFlag)) {
- result = MediaPlayer.getInstance().native_p2p_call(
- Integer.parseInt(ipFlag), isMonitor, pwd, -1,
- VideoMode, byt, pushMsg.getBytes("utf-8"), "gwell",headerId);
- } else {
- result = MediaPlayer.getInstance().native_p2p_call(id,
- isMonitor, pwd, -1, VideoMode, byt,
- pushMsg.getBytes("utf-8"), "gwell",headerId);
- }
-
- if (result == 1) {
- Log.i("tag", "p2p call success");
- } else {
- Log.e("tag", "p2p call fail");
- }
- }
- }
-
- /**
- * 录像回放连接
- */
- public void playbackConnect(String contactId, String password,
- String filename, int recordFilePosition, int VideoMode) {
- byte[] byt = filename.getBytes();
- MediaPlayer.getInstance().native_p2p_call(Integer.parseInt(contactId),
- Constants.P2P_TYPE.P2P_TYPE_PLAYBACK,
- Integer.parseInt(password), recordFilePosition, VideoMode, byt,
- "".getBytes(), "gwell",Integer.parseInt(contactId));
- }
-
- /**
- * 设置视频模式
- */
-
- public int setVideoMode(int type) {
- Log.e("dxsMode","type----->"+type);
- return MediaPlayer.getInstance().iSetVideoMode(type);
- }
-
- public void checkDeviceUpdate(String contactId, String password) {
-
- Log.e(TAG, "P2PHANDLER:checkDeviceUpdate");
- if (this.MSG_ID_CHECK_DEVICE_UPDATE >= (Constants.MsgSection.MSG_ID_CHECK_DEVICE_UPDATE)) {
- this.MSG_ID_CHECK_DEVICE_UPDATE = Constants.MsgSection.MSG_ID_CHECK_DEVICE_UPDATE - 1000;
- }
-
- MediaPlayer.getInstance().checkDeviceUpdate(
- Integer.parseInt(contactId), Integer.parseInt(password),
- this.MSG_ID_CHECK_DEVICE_UPDATE);
- this.MSG_ID_CHECK_DEVICE_UPDATE++;
- }
-
-
- /**
- * 设备固件更新
- *
- * @param contactId
- * @param password
- */
- public void doDeviceUpdate(String contactId, String password) {
-
- Log.e(TAG, "P2PHANDLER:doDeviceUpdate");
- if (this.MSG_ID_DO_DEVICE_UPDATE >= (Constants.MsgSection.MSG_ID_DO_DEVICE_UPDATE)) {
- this.MSG_ID_DO_DEVICE_UPDATE = Constants.MsgSection.MSG_ID_DO_DEVICE_UPDATE - 1000;
- }
-
- MediaPlayer.getInstance().doDeviceUpdate(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MSG_ID_DO_DEVICE_UPDATE);
- this.MSG_ID_DO_DEVICE_UPDATE++;
-
- }
-
- /**
- * 取消设备固件更新
- *
- * @param contactId
- * @param password
- */
- public void cancelDeviceUpdate(String contactId, String password) {
-
- Log.e(TAG, "P2PHANDLER:cancelDeviceUpdate");
- if (this.MSG_ID_CANCEL_DEVICE_UPDATE >= (Constants.MsgSection.MSG_ID_CANCEL_DEVICE_UPDATE)) {
- this.MSG_ID_CANCEL_DEVICE_UPDATE = Constants.MsgSection.MSG_ID_CANCEL_DEVICE_UPDATE - 1000;
- }
-
- MediaPlayer.getInstance().cancelDeviceUpdate(
- Integer.parseInt(contactId), Integer.parseInt(password),
- this.MSG_ID_CANCEL_DEVICE_UPDATE);
- this.MSG_ID_CANCEL_DEVICE_UPDATE++;
-
- }
-
- /**
- * 获得固件版本
- *
- * @param contactId
- * @param password
- */
- public void getDeviceVersion(String contactId, String password) {
-
- Log.e(TAG, "P2PHANDLER:getDeviceVersion");
- if (this.MSG_ID_GET_DEVICE_VERSION >= (Constants.MsgSection.MSG_ID_GET_DEVICE_VERSION)) {
- this.MSG_ID_GET_DEVICE_VERSION = Constants.MsgSection.MSG_ID_GET_DEVICE_VERSION - 1000;
- }
-
- MediaPlayer.getInstance().getDeviceVersion(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MSG_ID_GET_DEVICE_VERSION);
- this.MSG_ID_GET_DEVICE_VERSION++;
- }
-
- public boolean sendCtlCmd(int cmd, int option) {
- if (MediaPlayer.iSendCtlCmd(cmd, option) == 1) {
- return true;
- } else {
- return false;
- }
- }
-
- public void setBindFlag(int flag) {
- MediaPlayer.setBindFlag(flag);
- }
-
- /**
- * 设置是否接收音视频数据在高端2CU中单独设置无效
- *
- * @param fgEn
- */
- public void setRecvAVDataEnable(boolean fgEn) {
- MediaPlayer.getInstance()._SetRecvAVDataEnable(fgEn);
- }
-
- public void setImageReverse(String contactId, String password, int value) {
- Log.e(TAG, "P2PHANDLER:setImageReverse");
- if ((this.MESG_ID_STTING_PIC_REVERSE) >= (Constants.MsgSection.MESG_ID_STTING_PIC_REVERSE)) {
- this.MESG_ID_STTING_PIC_REVERSE = Constants.MsgSection.MESG_ID_STTING_PIC_REVERSE - 1000;
- }
- MediaPlayer
- .iSetNPCSettings(
- Integer.parseInt(contactId),
- Integer.parseInt(password),
- this.MESG_ID_STTING_PIC_REVERSE,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_IMAGE_REVERSE,
- value);
- this.MESG_ID_STTING_PIC_REVERSE++;
- }
-
- public void setInfraredSwitch(String contactId, String password, int value) {
- if ((this.MESG_ID_STTING_IR_ALARM_EN) >= (Constants.MsgSection.MESG_ID_STTING_IR_ALARM_EN)) {
- this.MESG_ID_STTING_IR_ALARM_EN = Constants.MsgSection.MESG_ID_STTING_IR_ALARM_EN - 1000;
- }
- MediaPlayer.iSetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MESG_ID_STTING_IR_ALARM_EN,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_IR_ALARM_EN,
- value);
- this.MESG_ID_STTING_IR_ALARM_EN++;
- }
-
- public void setWiredAlarmInput(String contactId, String password, int value) {
- if ((this.MESG_STTING_ID_EXTLINE_ALARM_IN_EN) >= (Constants.MsgSection.MESG_STTING_ID_EXTLINE_ALARM_IN_EN)) {
- this.MESG_STTING_ID_EXTLINE_ALARM_IN_EN = Constants.MsgSection.MESG_STTING_ID_EXTLINE_ALARM_IN_EN - 1000;
- }
- MediaPlayer
- .iSetNPCSettings(
- Integer.parseInt(contactId),
- Integer.parseInt(password),
- this.MESG_STTING_ID_EXTLINE_ALARM_IN_EN,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_EXTLINE_ALARM_IN_EN,
- value);
- this.MESG_STTING_ID_EXTLINE_ALARM_IN_EN++;
- }
-
- public void setWiredAlarmOut(String contactId, String password, int value) {
- if ((this.MESG_STTING_ID_EXTLINE_ALARM_OUT_EN) >= (Constants.MsgSection.MESG_STTING_ID_EXTLINE_ALARM_OUT_EN)) {
- this.MESG_STTING_ID_EXTLINE_ALARM_OUT_EN = Constants.MsgSection.MESG_STTING_ID_EXTLINE_ALARM_OUT_EN - 1000;
- }
- MediaPlayer
- .iSetNPCSettings(
- Integer.parseInt(contactId),
- Integer.parseInt(password),
- this.MESG_STTING_ID_EXTLINE_ALARM_OUT_EN,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_EXTLINE_ALARM_OUT_EN,
- value);
- this.MESG_STTING_ID_EXTLINE_ALARM_OUT_EN++;
- }
-
- public void setAutomaticUpgrade(String contactId, String password, int value) {
- if ((this.MESG_STTING_ID_SECUPGDEV) >= (Constants.MsgSection.MESG_STTING_ID_SECUPGDEV)) {
- this.MESG_STTING_ID_SECUPGDEV = Constants.MsgSection.MESG_STTING_ID_SECUPGDEV - 1000;
- }
- MediaPlayer.iSetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MESG_STTING_ID_SECUPGDEV,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_SECUPGDEV, value);
- this.MESG_STTING_ID_SECUPGDEV++;
- }
-
- /**
- * 设置时区
- *
- * @param contactId
- * @param password
- * @param value
- */
- public void setTimeZone(String contactId, String password, int value) {
- if ((this.MESG_STTING_ID_TIMEZONE) >= (Constants.MsgSection.MESG_STTING_ID_TIMEZONE)) {
- this.MESG_STTING_ID_TIMEZONE = Constants.MsgSection.MESG_STTING_ID_TIMEZONE - 1000;
- }
- MediaPlayer.iSetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MESG_STTING_ID_TIMEZONE,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_TIMEZONE, value);
- this.MESG_STTING_ID_TIMEZONE++;
- }
-
- public void getSdCardCapacity(String contactId, String password, String data) {
- if ((this.MESG_GET_SD_CARD_CAPACITY) >= (Constants.MsgSection.MESG_GET_SD_CARD_CAPACITY)) {
- this.MESG_GET_SD_CARD_CAPACITY = Constants.MsgSection.MESG_GET_SD_CARD_CAPACITY - 1000;
- }
- byte[] datas = new byte[16];
- datas[0] = 80;
- datas[1] = 0;
- datas[2] = 0;
- datas[3] = 0;
- MediaPlayer.iExtendedCmd(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MESG_GET_SD_CARD_CAPACITY,
- datas, 4);
- this.MESG_GET_SD_CARD_CAPACITY++;
- }
-
- /**
- * SD卡格式化
- *
- * @param contactId
- * @param password
- * @param SDcardID
- */
- public void setSdFormat(String contactId, String password, int SDcardID) {
- if ((this.MESG_SD_CARD_FORMAT) >= (Constants.MsgSection.MESG_SD_CARD_FORMAT)) {
- this.MESG_SD_CARD_FORMAT = Constants.MsgSection.MESG_SD_CARD_FORMAT - 1000;
- }
- byte[] datas = new byte[16];
- datas[0] = 81;
- datas[1] = 0;
- datas[2] = 0;
- datas[3] = 0;
- datas[4] = (byte) SDcardID;
- Log.e("id", "id:" + datas[4]);
- MediaPlayer.iExtendedCmd(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MESG_SD_CARD_FORMAT, datas, 5);
- this.MESG_SD_CARD_FORMAT++;
- }
-
- public void setGPIO(String contactId, String password, int group, int pin) {
- if ((this.MESG_SET_GPIO) >= (Constants.MsgSection.MESG_SET_GPIO)) {
- this.MESG_SET_GPIO = Constants.MsgSection.MESG_SET_GPIO - 1000;
- }
- byte[] datas = new byte[37];
- datas[0] = 95;
- datas[1] = 0;
- datas[2] = (byte) group;
- datas[3] = (byte) pin;
- datas[4] = 5;
- datas[5] = (byte) (-15 & 0xFF);
- datas[6] = (byte) (-15 >> 8 & 0xFF);
- datas[7] = (byte) (-15 >> 16 & 0xFF);
- datas[8] = (byte) (-15 >> 24 & 0xFF);
- datas[9] = (byte) (1000 & 0xFF);
- datas[10] = (byte) (1000 >> 8 & 0xFF);
- datas[11] = (byte) (1000 >> 16 & 0xFF);
- datas[12] = (byte) (1000 >> 24 & 0xFF);
- datas[13] = (byte) (-1000 & 0xFF);
- datas[14] = (byte) (-1000 >> 8 & 0xFF);
- datas[15] = (byte) (-1000 >> 16 & 0xFF);
- datas[16] = (byte) (-1000 >> 24 & 0xFF);
- datas[17] = (byte) (1000 & 0xFF);
- datas[18] = (byte) (1000 >> 8 & 0xFF);
- datas[19] = (byte) (1000 >> 16 & 0xFF);
- datas[20] = (byte) (1000 >> 24 & 0xFF);
- datas[21] = (byte) (-1000 & 0xFF);
- datas[22] = (byte) (-1000 >> 8 & 0xFF);
- datas[23] = (byte) (-1000 >> 16 & 0xFF);
- datas[24] = (byte) (-1000 >> 24 & 0xFF);
- for (int i = 25; i < datas.length; i++) {
- datas[i] = 0;
- }
- String s = "";
- for (int j = 0; j < datas.length; j++) {
- s = s + " " + datas[j];
- }
- Log.e("GPIO", "GPIO" + s + " " + "length=" + datas.length);
- MediaPlayer.iExtendedCmd(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MESG_SET_GPIO, datas,
- datas.length);
- this.MESG_SET_GPIO++;
- }
-
- public void setGPIO1_0(String contactId, String password) {
- if ((this.MESG_SET_GPI1_0) >= (Constants.MsgSection.MESG_SET_GPI1_0)) {
- this.MESG_SET_GPI1_0 = Constants.MsgSection.MESG_SET_GPI1_0 - 1000;
- }
- byte[] datas = new byte[37];
- datas[0] = 95;
- datas[1] = 0;
- datas[2] = 1;
- datas[3] = 0;
- datas[4] = 3;
- datas[5] = (byte) (-15 & 0xFF);
- datas[6] = (byte) (-15 >> 8 & 0xFF);
- datas[7] = (byte) (-15 >> 16 & 0xFF);
- datas[8] = (byte) (-15 >> 24 & 0xFF);
- datas[9] = (byte) (6000 & 0xFF);
- datas[10] = (byte) (6000 >> 8 & 0xFF);
- datas[11] = (byte) (6000 >> 16 & 0xFF);
- datas[12] = (byte) (6000 >> 24 & 0xFF);
- datas[13] = (byte) (-6000 & 0xFF);
- datas[14] = (byte) (-6000 >> 8 & 0xFF);
- datas[15] = (byte) (-6000 >> 16 & 0xFF);
- datas[16] = (byte) (-6000 >> 24 & 0xFF);
- for (int i = 17; i < datas.length; i++) {
- datas[i] = 0;
- }
- String s = "";
- for (int j = 0; j < datas.length; j++) {
- s = s + " " + datas[j];
- }
- Log.e("GPIO", "GPIO" + s + " " + "length=" + datas.length);
- MediaPlayer.iExtendedCmd(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MESG_SET_GPI1_0, datas,
- datas.length);
- this.MESG_SET_GPI1_0++;
- }
-
- /**
- * 设置预录像
- *
- * @param contactId
- * @param password
- * @param value
- */
- public void setPreRecord(String contactId, String password, int value) {
- if ((this.MESG_SET_PRE_RECORD) >= (Constants.MsgSection.MESG_SET_PRE_RECORD)) {
- this.MESG_SET_PRE_RECORD = Constants.MsgSection.MESG_SET_PRE_RECORD - 1000;
- }
- MediaPlayer.iSetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MESG_SET_PRE_RECORD,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_PRERECORD, value);
- this.MESG_SET_PRE_RECORD++;
- }
-
- /**
- * 获得防区报警开关状态,需要设备配置
- *
- * @param contactId
- * @param password
- */
- public void getDefenceAreaAlarmSwitch(String contactId, String password) {
- if ((this.MESG_GET_DEFENCE_AREA_SWITCH) >= (Constants.MsgSection.MESG_GET_DEFENCE_AREA_SWITCH)) {
- this.MESG_GET_DEFENCE_AREA_SWITCH = Constants.MsgSection.MESG_GET_DEFENCE_AREA_SWITCH - 1000;
- }
- byte[] datas = new byte[12];
- datas[0] = 82;
- datas[1] = 0;
- datas[2] = 8;
- datas[3] = 0;
- datas[4] = 0;
- datas[5] = 0;
- datas[6] = 0;
- datas[7] = 0;
- datas[8] = 0;
- datas[9] = 0;
- datas[10] = 0;
- datas[11] = 0;
- MediaPlayer.iExtendedCmd(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MESG_GET_DEFENCE_AREA_SWITCH,
- datas, datas.length);
- this.MESG_GET_DEFENCE_AREA_SWITCH++;
- }
-
- /**
- * 设置防区报警开关
- *
- * @param contactId
- * @param password
- * @param state
- * 开关状态
- * @param group
- * 防区
- * @param item
- * 通道
- */
- public void setDefenceAreaAlarmSwitch(String contactId, String password,
- int state, int group, int item) {
- if ((this.MESG_SET_DEFENCE_AREA_SWITCH) >= (Constants.MsgSection.MESG_SET_DEFENCE_AREA_SWITCH)) {
- this.MESG_SET_DEFENCE_AREA_SWITCH = Constants.MsgSection.MESG_SET_DEFENCE_AREA_SWITCH - 1000;
- }
- byte[] datas = new byte[12];
- datas[0] = 83;
- datas[1] = 0;
- datas[2] = (byte) state;
- datas[3] = 1;
- datas[4] = (byte) (group & 0xFF);
- datas[5] = (byte) (group >> 8 & 0xFF);
- datas[6] = (byte) (group >> 16 & 0xFF);
- datas[7] = (byte) (group >> 24 & 0xFF);
- datas[8] = (byte) (item & 0xFF);
- datas[9] = (byte) (item >> 8 & 0xFF);
- datas[10] = (byte) (item >> 16 & 0xFF);
- datas[11] = (byte) (item >> 24 & 0xFF);
- MediaPlayer.iExtendedCmd(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MESG_SET_DEFENCE_AREA_SWITCH,
- datas, datas.length);
- this.MESG_SET_DEFENCE_AREA_SWITCH++;
- }
-
- /**
- * 获得灯的状态
- *
- * @param contactId
- * @param password
- */
- public void vgetLampStatus(String contactId, String password) {
- if (this.MESG_GET_LAMP >= (Constants.MsgSection.MESG_GET_LAMP)) {
- this.MESG_GET_LAMP = Constants.MsgSection.MESG_GET_LAMP - 1000;
- }
- MediaPlayer.iGetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MESG_GET_LAMP);
- this.MESG_GET_LAMP++;
- }
-
- /**
- * 设置灯的状态
- *
- * @param contactId
- * @param password
- */
- public void vsetLampStatus(String contactId, String password, int LampStatus) {
- if (this.MESG_SET_LAMP >= (Constants.MsgSection.MESG_SET_LAMP)) {
- this.MESG_SET_LAMP = Constants.MsgSection.MESG_SET_LAMP - 1000;
- }
- MediaPlayer.iSetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MESG_SET_LAMP, 34, LampStatus);
- this.MESG_SET_LAMP++;
- }
-
- /**
- * 自定义串口消息
- *
- * @param contactId
- * @param password
- * @param dataBuffer
- * 用户输入的串口消息
- * @param len
- * 消息长度
- * @param appID
- */
- public void vSendDataToURAT(String contactId, String password,
- byte[] dataBuffer, int len, boolean appID) {
- if (this.SET_USER_DEFINE_MESG >= (Constants.MsgSection.SET_USER_DEFINE_MESG)) {
- this.SET_USER_DEFINE_MESG = Constants.MsgSection.SET_USER_DEFINE_MESG - 1000;
- }
- int iId = Integer.parseInt(contactId);
- String fgMesg = "";
- if (appID) {
- fgMesg = "IPC1";
- } else {
- fgMesg = "IPC2";
- }
- byte[] fgme = null;
- fgme = fgMesg.getBytes();
- int lens = fgme.length;
- byte[] datas = new byte[fgme.length + dataBuffer.length];
- System.arraycopy(fgme, 0, datas, 0, fgme.length);
- System.arraycopy(dataBuffer, 0, datas, fgme.length, dataBuffer.length);
- MediaPlayer.iSendCmdToFriend(iId, Integer.parseInt(password),
- this.SET_USER_DEFINE_MESG, datas, datas.length);
- this.SET_USER_DEFINE_MESG++;
- }
-
- /**
- * 获取报警类型或防区通道对应的摄像头预置位置
- *
- * @param contactId
- * @param password
- * @param data
- */
- public void sMesgGetAlarmPresetMotorPos(String contactId, String password,
- byte[] data) {
- if ((this.MESG_GET_PRESET_MOTOR_POS) >= (Constants.MsgSection.MESG_GET_PRESET_MOTOR_POS)) {
- this.MESG_GET_PRESET_MOTOR_POS = Constants.MsgSection.MESG_GET_PRESET_MOTOR_POS - 1000;
- }
-
- MediaPlayer.iExtendedCmd(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MESG_GET_PRESET_MOTOR_POS,
- data, 7);
-
- this.MESG_GET_PRESET_MOTOR_POS++;
- }
-
- /**
- * 设置报警类型或防区通道对应的摄像头预置位置
- *
- * @param contactId
- * @param password
- * @param data
- */
- public void sMesgSetAlarmPresetMotorPos(String contactId, String password,
- byte[] data) {
- if ((this.MESG_SET_PRESET_MOTOR_POS) >= (Constants.MsgSection.MESG_SET_PRESET_MOTOR_POS)) {
- this.MESG_SET_PRESET_MOTOR_POS = Constants.MsgSection.MESG_SET_PRESET_MOTOR_POS - 1000;
- }
-
- MediaPlayer.iExtendedCmd(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MESG_SET_PRESET_MOTOR_POS,
- data, 7);
-
- this.MESG_SET_PRESET_MOTOR_POS++;
- }
-
- /**
- * 设置/查看摄像头预置位置
- *
- * @param contactId
- * @param password
- * @param data
- */
- public void sMesgPresetMotorPos(String contactId, String password,
- byte[] data) {
- if ((this.MESG_PRESET_MOTOR_POS) >= (Constants.MsgSection.MESG_PRESET_MOTOR_POS)) {
- this.MESG_PRESET_MOTOR_POS = Constants.MsgSection.MESG_PRESET_MOTOR_POS - 1000;
- }
- MediaPlayer
- .iExtendedCmd(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MESG_PRESET_MOTOR_POS,
- data, 7);
- this.MESG_PRESET_MOTOR_POS++;
- }
-
- /**
- * 获取设备IP相关信息
- *
- * @param contactId
- * @param password
- * @param data
- */
- public void sIpConfig(String contactId, String password, byte[] data) {
- if ((this.IP_CONFIG) >= (Constants.MsgSection.IP_CONFIG)) {
- this.IP_CONFIG = Constants.MsgSection.IP_CONFIG - 1000;
- }
- MediaPlayer.iExtendedCmd(Integer.parseInt(contactId),
- Integer.parseInt(password), this.IP_CONFIG, data, 8);
- this.IP_CONFIG++;
- }
-
- public void getAlarmCenterParameters(String contactId, String password) {
- if ((this.MESG_GET_ALARM_CENTER_PARAMETER) >= (Constants.MsgSection.MESG_GET_ALARM_CENTER_PARAMETER)) {
- this.MESG_GET_ALARM_CENTER_PARAMETER = Constants.MsgSection.MESG_GET_ALARM_CENTER_PARAMETER - 1000;
- }
- byte[] datas = new byte[20];
- datas[0] = 100;
- datas[1] = 0;
- datas[2] = 0;
- datas[3] = 20;
- for (int i = 4; i < datas.length; i++) {
- datas[i] = 0;
- }
- String s = "";
- for (int j = 0; j < datas.length; j++) {
- s = s + " " + datas[j];
- }
- Log.e("alarm_center", s + "lenght=" + datas.length);
- Log.e("alarmcenter", "MESG_GET_ALARM_CENTER_PARAMETER="
- + this.MESG_GET_ALARM_CENTER_PARAMETER + " " + "length="
- + datas.length);
- MediaPlayer.iExtendedCmd(Integer.parseInt(contactId),
- Integer.parseInt(password),
- this.MESG_GET_ALARM_CENTER_PARAMETER, datas, datas.length);
- this.MESG_GET_ALARM_CENTER_PARAMETER++;
- }
-
- /**
- * 设置报警中心参数
- *
- * @param contactId
- * @param password
- * @param port
- * @param ipdress
- * @param userId
- * @param state
- */
- public void setAlarmCenterParameters(String contactId, String password,
- int port, String ipdress, String userId, int state) {
- if ((this.MESG_SET_ALARM_CENTER_PARAMETER) >= (Constants.MsgSection.MESG_SET_ALARM_CENTER_PARAMETER)) {
- this.MESG_SET_ALARM_CENTER_PARAMETER = Constants.MsgSection.MESG_SET_ALARM_CENTER_PARAMETER - 1000;
- }
- byte[] datas = new byte[20];
- datas[0] = 101;
- datas[1] = 0;
- datas[2] = 0;
- datas[3] = 20;
- datas[4] = (byte) state;
- datas[5] = 0;
- datas[6] = 0;
- datas[7] = 0;
- Log.e("ipdesss_length", ipdress);
- String[] ipdesss = ipdress.split("\\.");
- Log.e("ipdesss_length", "lenght=" + ipdesss.length);
- int[] ips = { Integer.parseInt(ipdesss[0]),
- Integer.parseInt(ipdesss[1]), Integer.parseInt(ipdesss[2]),
- Integer.parseInt(ipdesss[3]) };
- int user_id2 = Integer.parseInt(userId, 16);
- datas[8] = (byte) (ips[3]);
- datas[9] = (byte) (ips[2]);
- datas[10] = (byte) (ips[1]);
- datas[11] = (byte) ips[0];
- datas[12] = (byte) (port & 0xFF);
- datas[13] = (byte) (port >> 8 & 0xFF);
- datas[14] = (byte) (port >> 16 & 0xFF);
- datas[15] = (byte) (port >> 24 & 0xFF);
- datas[16] = (byte) (user_id2 & 0xFF);
- datas[17] = (byte) (user_id2 >> 8 & 0xFF);
- datas[18] = (byte) (user_id2 >> 16 & 0xFF);
- datas[19] = (byte) (user_id2 >> 24 & 0xFF);
- // datas[20]=(byte)(user_id2>>32&0xFF);
- // datas[21]=(byte)(user_id2>>40&0xFF);
- // datas[22]=(byte)(user_id2>>48&0xFF);
- // datas[23]=(byte)(user_id2>>56&0xFF);
-
- for (int i = 0; i < datas.length; i++) {
- Log.e("alarm_center", "datas[i]" + datas[i]);
- }
- Log.e("alarmcenter", "MESG_SET_ALARM_CENTER_PARAMETER="
- + this.MESG_SET_ALARM_CENTER_PARAMETER + " " + "length="
- + datas.length);
- MediaPlayer.iExtendedCmd(Integer.parseInt(contactId),
- Integer.parseInt(password),
- this.MESG_SET_ALARM_CENTER_PARAMETER, datas, datas.length);
- this.MESG_SET_ALARM_CENTER_PARAMETER++;
- }
-
- public void DeleteDeviceAlarmId(String contactId) {
- if ((this.MESG_DELETE_ALARMID) >= (Constants.MsgSection.MESG_DELETE_DEVICEALARMID)) {
- this.MESG_DELETE_ALARMID = Constants.MsgSection.MESG_DELETE_DEVICEALARMID - 1000;
- }
- byte[] datas = new byte[16];
- datas[0] = 127;
- datas[3] = 16;
- datas[8] = 1;
- MediaPlayer.iExtendedCmd(Integer.parseInt(contactId), 0,
- this.MESG_DELETE_ALARMID, datas, datas.length);
- Log.e("vRetExtenedCmd", "datas-->" + Arrays.toString(datas));
- this.MESG_DELETE_ALARMID++;
- }
-
- public void setSystemMessageIndex(int iSystemMessageType,
- int iSystemMessageIndex) {
- if ((this.MESG_SET_SYSTEM_MESSAGE_INDEX) >= (Constants.MsgSection.MESG_SET_SYSTEM_MESSAGE_INDEX)) {
- this.MESG_SET_SYSTEM_MESSAGE_INDEX = Constants.MsgSection.MESG_SET_SYSTEM_MESSAGE_INDEX - 1000;
- }
-
- MediaPlayer.SetSystemMessageIndex(iSystemMessageType,
- iSystemMessageIndex);
- this.MESG_SET_SYSTEM_MESSAGE_INDEX++;
- }
-
- /**
- * 自定义截图路径
- *
- * @param path
- * 路径(必须省略sdcard路径)~/11/22/33/10234.jpg时 path=/11/22/33
- * @param name
- * name=1023.jpg
- * @return 创建文件夹是否成功 0成功 !0失败
- */
- public int setScreenShotpath(String path, String name) {
- return MediaPlayer.getInstance().SetScreenShotPath(path, name);
- }
-
- public void controlCamera(String contactId, String password, byte[] data) {
- if (this.CONTROL_CAMERA >= (Constants.MsgSection.CONTROL_CAMERA)) {
- this.CONTROL_CAMERA = Constants.MsgSection.CONTROL_CAMERA - 1000;
- }
- byte[] sendData = new byte[68];
- for (int i = 0; i < data.length; i++) {
- sendData[i] = data[i];
- }
- if (data.length < 68) {
- for (int j = data.length; j < sendData.length; j++) {
- sendData[j] = 0;
- }
- }
- Log.e("control_camera", "contactId=" + contactId + "--" + "password="
- + password + "--" + Arrays.toString(sendData));
- int iId = Integer.parseInt(contactId);
- MediaPlayer.iExtendedCmd(iId, Integer.parseInt(password),
- this.CONTROL_CAMERA, sendData, sendData.length);
- this.CONTROL_CAMERA++;
-
- }
-
- /**
- * 收到门铃
- */
- public void setReceiveDoorBell(String contactId) {
- Log.e(TAG, "P2PHANDLER:setRemoteDefence");
- if (this.MESG_SET_RECEIVE_DOOBELL >= (Constants.MsgSection.MESG_SET_RECEIVE_DOOBELL)) {
- this.MESG_SET_RECEIVE_DOOBELL = Constants.MsgSection.MESG_SET_RECEIVE_DOOBELL - 1000;
- }
- byte[] datas = new byte[16];
- datas[0] = 127;
- datas[3] = 16;
- datas[8] = 3;
- datas[12] = 1;
-
- MediaPlayer.iExtendedCmd(Integer.parseInt(contactId), 0,
- this.MESG_SET_RECEIVE_DOOBELL, datas, datas.length);
- Log.e("vRetExtenedCmd", "datas-->" + Arrays.toString(datas));
- this.MESG_SET_RECEIVE_DOOBELL++;
- }
-
- public void getDeviceLanguage(String contactId, String password) {
- if ((this.MESG_GET_LANGUEGE) >= (Constants.MsgSection.MESG_GET_LANGUEGE)) {
- this.MESG_GET_LANGUEGE = Constants.MsgSection.MESG_GET_LANGUEGE - 1000;
- }
- byte[] datas = new byte[7];
- datas[0] = (byte) 211;
- MediaPlayer.iExtendedCmd(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MESG_GET_LANGUEGE, datas,
- datas.length);
- this.MESG_GET_LANGUEGE++;
- }
-
- public void setDevieceLanguege(String contactId, String password,
- int curLanguege) {
- if ((this.MESG_SET_LANGUEGE) >= (Constants.MsgSection.MESG_SET_LANGUEGE)) {
- this.MESG_SET_LANGUEGE = Constants.MsgSection.MESG_SET_LANGUEGE - 1000;
- }
- byte[] datas = new byte[7];
- datas[0] = (byte) 212;
- datas[5] = (byte) curLanguege;
- MediaPlayer.iExtendedCmd(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MESG_SET_LANGUEGE, datas,
- datas.length);
- this.MESG_SET_LANGUEGE++;
- }
-
- public void setFocus(byte state) {
- byte[] data = new byte[5];
- data[0] = (byte) state;
- MediaPlayer.SendUserData(9, 1, data, data.length);
- Log.e("ptz", "focus--" + Arrays.toString(data));
- }
-
- public void setZoom(byte state) {
- byte[] data = new byte[5];
- data[0] = (byte) state;
- MediaPlayer.SendUserData(9, 2, data, data.length);
- Log.e("ptz", "zoom--" + Arrays.toString(data));
- }
-
- public String EntryPassword(String password) {
- if (MyUtils.isNumeric(password) && password.length() < 10) {
- return password;
- } else {
- return String.valueOf(MediaPlayer.EntryPwd(password));
- }
- }
-
- /**
- * 获取报警图像
- *
- * @param id设备ID
- * @param password密码
- * @param filename
- * 图片文件名完整路径
- * @param localName
- * 存放文件名完整路径
- * @return
- */
- public int GetAllarmImage(String id, String password, String filename,
- String localName) {
- return MediaPlayer.GetAllarmImage(Integer.parseInt(id),
- Integer.parseInt(password), filename, localName);
- }
-
- /**
- * 获取图片的进度
- *
- * @return
- */
- public int GetAllarmImageProgress() {
- return MediaPlayer.GetFileProgress();
- }
-
- /**
- * 取消获取图片
- */
- public void CancelGetAllarmImage() {
- MediaPlayer.CancelGetRemoteFile();
- }
-
- public static byte[] intToByte2(int i) {
- byte[] targets = new byte[2];
- targets[0] = (byte) (i & 0xFF);
- targets[1] = (byte) (i >> 8 & 0xFF);
- return targets;
- }
-
- public static byte[] intToByte4(int i) {
- byte[] targets = new byte[4];
- targets[0] = (byte) (i & 0xFF);
- targets[1] = (byte) (i >> 8 & 0xFF);
- targets[2] = (byte) (i >> 16 & 0xFF);
- targets[3] = (byte) (i >> 24 & 0xFF);
- return targets;
- }
-
- public void setFishEye(int contactId, int password, int msgId, byte[] datas) {
- MediaPlayer.iExtendedCmd(contactId, password, msgId, datas,
- datas.length);
- }
-
- public void getNvrIpcList(String nvrId, String password) {
- if (this.MESG_TYPE_GET_LAN_IPC_LIST >= (Constants.MsgSection.MESG_TYPE_GET_LAN_IPC_LIST)) {
- this.MESG_TYPE_GET_LAN_IPC_LIST = Constants.MsgSection.MESG_TYPE_GET_LAN_IPC_LIST - 1000;
- }
- byte[] data = new byte[20];
- data[0] = (byte) 129;
- MediaPlayer.iExtendedCmd(Integer.parseInt(nvrId),
- Integer.parseInt(password), this.MESG_TYPE_GET_LAN_IPC_LIST,
- data, data.length);
- Log.e("nvr_list", "nvrId=" + nvrId + "--" + "password=" + password
- + "data=" + Arrays.toString(data));
- this.MESG_TYPE_GET_LAN_IPC_LIST++;
-
- }
-
- /**
- * 兼容RTSP密码加密
- *
- * @param password
- * @return
- */
- public String RTSPPwd(String password) {
- if (password != null && password.length() > 0) {
- return MediaPlayer.RTSPEntry(password);
- } else {
- return "error";
- }
- }
-
- /**
- * 服务器保存的设备密码的解密函数(应用场景:从服务器获取设备列表)
- *
- * @param userID用户ID
- * @param password密文
- * @param backLen返回的字符串缓冲区长度,建议比预估的值稍大
- * @return 返回的error可能是错误 也可能是缓冲区长度不足
- */
- public String HTTPDecrypt(String userID, String password, int backLen) {
- if (password != null && password.length() > 0) {
- return MediaPlayer.HTTPDecrypt(userID, password, backLen);
- } else {
- return "error";
- }
- }
-
- /**
- * 服务器保存的设备密码的加密函数(应用场景:上传设备列表到服务器)
- *
- * @param userID登陆账号关联的ID
- * @param password明文
- * @param backLen返回的字符串缓冲区长度,建议比预估的值稍大
- * @return 返回的error可能是错误 也可能是缓冲区长度不足
- */
- public String HTTPEncrypt(String userID, String password, int backLen) {
- if (password != null && password.length() > 0) {
- return MediaPlayer.HTTPEncrypt(userID, password, backLen);
- } else {
- return "error";
- }
- }
-
- /**
- * 密码加密,用于P2P
- *
- * @param pwd
- * @return
- */
- public byte[] P2PEntryPassword(int pwd) {
- return MediaPlayer.P2PEntryPassword(pwd);
- }
-
- /**
- * 设置AP模式切換 1切換
- */
- public void setAPModeChange(String contactId, String password, int value) {
- if (this.MESG_TYPE_SET_AP_MODE_CHANGE >= (Constants.MsgSection.MESG_TYPE_SET_AP_MODE_CHANGE)) {
- this.MESG_TYPE_SET_AP_MODE_CHANGE = Constants.MsgSection.MESG_TYPE_SET_AP_MODE_CHANGE - 1000;
- }
- MediaPlayer.iSetNPCSettings(Integer.parseInt(contactId),
- Integer.parseInt(password), this.MESG_TYPE_SET_AP_MODE_CHANGE,
- Constants.P2P_SETTING.SETTING_TYPE.SETTING_ID_SET_WIFI_WORK_MODE,
- value);
- this.MESG_TYPE_SET_AP_MODE_CHANGE++;
- }
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/P2PInterface/IP2P.java b/p2PCore/src/main/java/com/p2p/core/P2PInterface/IP2P.java
deleted file mode 100644
index 07f8504db..000000000
--- a/p2PCore/src/main/java/com/p2p/core/P2PInterface/IP2P.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.p2p.core.P2PInterface;
-
-public interface IP2P {
- public void vCalling(boolean isOutCall, String threeNumber, int type);
-
- public void vReject(int reason_code);
-
- public void vAccept(int type,int state);
-
- public void vConnectReady();
-
- public void vAllarming(String srcId, int type, boolean isSupportExternAlarm, int iGroup, int iItem,boolean isSurpportDelete);
-
- public void vChangeVideoMask(int state);
-
- public void vRetPlayBackPos(int length, int currentPos);
-
- public void vRetPlayBackStatus(int state);
-
- public void vGXNotifyFlag(int flag);
-
- public void vRetPlaySize(int iWidth, int iHeight);
-
- public void vRetPlayNumber(int iNumber);
-
- public void vRecvAudioVideoData(byte[] AudioBuffer, int AudioLen, int AudioFrames, long AudioPTS,
- byte[] VideoBuffer, int VideoLen, long VideoPTS);
- public void vAllarmingWitghTime(String srcId, int type, int option, int iGroup, int iItem,int imagecounts,String imagePath,String alarmCapDir,String VideoPath);
- public void vRetNewSystemMessage(int iSystemMessageType,int iSystemMessageIndex);
- public void vRetRTSPNotify(int arg2,String msg);
- public void vRetPostFromeNative(int what,int iDesID, int arg1, int arg2, String msgStr);
-
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/P2PInterface/ISetting.java b/p2PCore/src/main/java/com/p2p/core/P2PInterface/ISetting.java
deleted file mode 100644
index ca517bec6..000000000
--- a/p2PCore/src/main/java/com/p2p/core/P2PInterface/ISetting.java
+++ /dev/null
@@ -1,276 +0,0 @@
-package com.p2p.core.P2PInterface;
-
-import java.util.ArrayList;
-
-public interface ISetting {
- // ACK 回调函数
-
- public void ACK_vRetSetDeviceTime(int msgId, int result);
-
- public void ACK_vRetGetDeviceTime(int msgId, int result);
-
- public void ACK_vRetGetNpcSettings(String contactId, int msgId, int result);
-
- public void ACK_vRetSetRemoteDefence(String contactId, int msgId, int result);
-
- public void ACK_vRetSetRemoteRecord(int msgId, int result);
-
- public void ACK_vRetSetNpcSettingsVideoFormat(int msgId, int result);
-
- public void ACK_vRetSetNpcSettingsVideoVolume(int msgId, int result);
-
- public void ACK_vRetSetNpcSettingsBuzzer(int msgId, int result);
-
- public void ACK_vRetSetNpcSettingsMotion(int msgId, int result);
-
- public void ACK_vRetSetNpcSettingsRecordType(int msgId, int result);
-
- public void ACK_vRetSetNpcSettingsRecordTime(int msgId, int result);
-
- public void ACK_vRetSetNpcSettingsRecordPlanTime(int msgId, int result);
-
- public void ACK_vRetSetNpcSettingsNetType(int msgId, int result);
-
- public void ACK_vRetSetAlarmEmail(int msgId, int result);
-
- public void ACK_vRetGetAlarmEmail(int msgId, int result);
-
- public void ACK_vRetSetAlarmBindId(int srcID, int result);
-
- public void ACK_vRetGetAlarmBindId(int srcID, int result);
-
- public void ACK_vRetSetInitPassword(int msgId, int result);
-
- public void ACK_vRetSetDevicePassword(int msgId, int result);
-
- public void ACK_vRetCheckDevicePassword(int msgId, int result);
-
- public void ACK_vRetSetWifi(int msgId, int result);
-
- public void ACK_vRetGetWifiList(int msgId, int result);
-
- public void ACK_vRetSetDefenceArea(int msgId, int result);
-
- public void ACK_vRetGetDefenceArea(int msgId, int result);
-
- public void ACK_vRetGetRecordFileList(int msgId, int result);
-
- public void ACK_vRetMessage(int msgId, int result);
-
- public void ACK_vRetCustomCmd(int msgId, int result);
-
- public void ACK_vRetGetDeviceVersion(int msgId, int result);
-
- public void ACK_vRetCheckDeviceUpdate(int msgId, int result);
-
- public void ACK_vRetDoDeviceUpdate(int msgId, int result);
-
- public void ACK_vRetCancelDeviceUpdate(int msgId, int result);
-
- public void ACK_vRetClearDefenceAreaState(int msgId, int result);
-
- public void ACK_vRetGetDefenceStates(String contactId, int msgId, int result);
-
- public void ACK_vRetSetImageReverse(int msgId, int result);
-
- public void ACK_vRetSetInfraredSwitch(int msgId, int result);
-
- public void ACK_vRetSetWiredAlarmInput(int msgId, int state);
-
- public void ACK_vRetSetWiredAlarmOut(int msgId, int state);
-
- public void ACK_vRetSetAutomaticUpgrade(int msgId, int state);
-
- public void ACK_VRetSetVisitorDevicePassword(int msgId, int state);
-
- public void ACK_vRetSetTimeZone(int msgId, int state);
-
- public void ACK_vRetGetSDCard(int msgId, int state);
-
- public void ACK_vRetSdFormat(int msgId, int state);
-
- public void ACK_vRetSetGPIO(int msgId, int state);
-
- public void ACK_vRetSetGPIO1_0(int msgId, int state);
-
- public void ACK_vRetSetPreRecord(int msgId, int state);
-
- public void ACK_vRetGetSensorSwitchs(int msgId, int state);
-
- public void ACK_vRetSetSensorSwitchs(int msgId, int state);
-
- public void ACK_vRetGetAlarmCenter(int msgId,int state);
-
- public void ACK_vRetSetAlarmCenter(int msgId,int state);
-
- public void ACK_VRetGetNvrIpcList(int msgId,int state);
-
- // 设置结果回调
- public void vRetGetRemoteDefenceResult(String contactId, int state);
-
- public void vRetGetRemoteRecordResult(int state);
-
- public void vRetGetBuzzerResult(int state);
-
- public void vRetGetMotionResult(int state);
-
- public void vRetGetVideoFormatResult(int type);
-
- public void vRetGetRecordTypeResult(int type);
-
- public void vRetGetRecordTimeResult(int time);
-
- public void vRetGetNetTypeResult(int type);
-
- public void vRetGetVideoVolumeResult(int value);
-
- public void vRetGetRecordPlanTimeResult(String time);
-
- public void vRetGetImageReverseResult(int type);
-
- public void vRetGetInfraredSwitch(int state);
-
- public void vRetGetWiredAlarmInput(int state);
-
- public void vRetGetWiredAlarmOut(int state);
-
- public void vRetGetAutomaticUpgrade(int state);
-
- public void vRetGetTimeZone(int state);
-
- public void vRetGetAudioDeviceType(int type);
-
- public void vRetGetPreRecord(int state);
-
- public void vRetGetSensorSwitchs(int result, ArrayList data);
-
- public void vRetSetRemoteDefenceResult(String contactId,int result);
-
- public void vRetSetRemoteRecordResult(int result);
-
- public void vRetSetBuzzerResult(int result);
-
- public void vRetSetMotionResult(int result);
-
- public void vRetSetVideoFormatResult(int result);
-
- public void vRetSetRecordTypeResult(int result);
-
- public void vRetSetRecordTimeResult(int result);
-
- public void vRetSetNetTypeResult(int result);
-
- public void vRetSetVolumeResult(int result);
-
- public void vRetSetRecordPlanTimeResult(int result);
-
- public void vRetSetDeviceTimeResult(int result);
-
- public void vRetGetDeviceTimeResult(String time);
-
- public void vRetAlarmEmailResult(int result, String email);
-
- public void vRetAlarmEmailResultWithSMTP(int result, String email,
- int smtpport, byte Entry,String[] SmptMessage,byte reserve);
-
- public void vRetWifiResult(int result, int currentId, int count,
- int[] types, int[] strengths, String[] names);
-
- public void vRetDefenceAreaResult(int result, ArrayList data,
- int group, int item);
-
- public void vRetBindAlarmIdResult(int srcID, int result, int maxCount,
- String[] data);
-
- public void vRetSetInitPasswordResult(int result);
-
- public void vRetSetDevicePasswordResult(int result);
-
- public void vRetGetFriendStatus(int count, String[] contactIds,
- int[] status, int[] types);
-
- public void vRetGetRecordFiles(String[] names,byte option0,byte option1);
-
- public void vRetMessage(String contactId, String msg);
-
- public void vRetSysMessage(String msg);
-
- public void vRetCustomCmd(int contactId,int len, byte[] cmd);
-
- public void vRetGetDeviceVersion(int result, String cur_version,
- int iUbootVersion, int iKernelVersion, int iRootfsVersion);
-
- public void vRetCheckDeviceUpdate(String contactId,int result, String cur_version,
- String upg_version);
-
- public void vRetDoDeviceUpdate(String contactId,int result, int value);
-
- public void vRetCancelDeviceUpdate(int result);
-
- public void vRetDeviceNotSupport();
-
- public void vRetClearDefenceAreaState(int result);
-
- public void vRetSetImageReverse(int result);
-
- public void vRetSetInfraredSwitch(int result);
-
- public void vRetSetWiredAlarmInput(int state);
-
- public void vRetSetWiredAlarmOut(int state);
-
- public void vRetSetAutomaticUpgrade(int state);
-
- public void vRetSetVisitorDevicePassword(int result);
-
- public void vRetSetTimeZone(int result);
-
- public void vRetGetSdCard(int result1, int result2, int SDcardID, int state);
-
- public void VRetGetUsb(int result1, int result2, int SDcardID, int state);
-
- public void vRetSdFormat(int result);
-
- public void vRetSetGPIO(int result);
-
- public void vRetSetPreRecord(int result);
-
- public void vRetSetSensorSwitchs(int result);
-
- public void vRecvSetLAMPStatus(int result);
-
- public void vACK_RecvSetLAMPStatus(int result, int value);
-
- public void vRecvGetLAMPStatus(int result);
-
- public void vRetPresetMotorPos(byte[] result);
-
- public void vRetDefenceSwitchStatus(int result);
-
- public void vRetDefenceSwitchStatusResult(byte[] result);
-
- public void vRetAlarmPresetMotorPos(byte[] result);
-
- public void vRetIpConfig(byte[] result);
-
- public void vRetGetAlarmCenter(int result,int state,String ipdress,int port,String userId);
-
- public void vRetSetAlarmCenter(int result);
-
- public void vRetDeviceNotSupportAlarmCenter();
-
- public void vRetNPCVistorPwd(int pwd);
-
- public void vRetDeleteDeviceAlarmID(int result);
-
- public void vRetDeviceLanguege(int result,int languegecount,int curlanguege,int[] langueges);
-
- public void vRetFocusZoom(int result);
- public void vRetGetAllarmImage(int id,String filename,int errorCode);
- public void vRetFishEyeData(int iSrcID, byte[] data, int datasize);
- public void vRetGetNvrIpcList(String contactId,String[]date,int number);
-
- public void vRetSetWifiMode(String id,int result);
- public void vRetAPModeSurpport(String id,int result);
-
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/P2PValue.java b/p2PCore/src/main/java/com/p2p/core/P2PValue.java
deleted file mode 100644
index 8bbdcbf76..000000000
--- a/p2PCore/src/main/java/com/p2p/core/P2PValue.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.p2p.core;
-
-public class P2PValue {
- public static class AlarmType{
- public static final int EXTERNAL_ALARM = 1;
- public static final int MOTION_DECT_ALARM = 2;
- public static final int EMERGENCY_ALARM = 3;
- public static final int EXT_LINE_ALARM = 5;
- public static final int LOW_VOL_ALARM = 6;
- public static final int PIR_ALARM = 7;
- public static final int DEFENCE=8;
- public static final int NO_DEFENCE=9;
- public static final int BATTERY_LOW_ALARM=10;
- public static final int ALARM_TYPE_DOORBELL_PUSH=13;
- public static final int RECORD_FAILED_ALARM=15;
- public static final int ALARM_TYPE_KEEP_SILENT=39;//39 silent
- public static final int ALARM_TYPE_SMOKE_ALARM=40;//40smoke
- public static final int ALARM_TYPE_GAS_ALARM=41;//41gas
- public static final int ALARM_TYPE_DOOR_MAGNET=42;//42door magnet
- public static final int ALARM_TYPE_TEMPTATURE=43;//43temprature
- public static final int ALARM_TYPE_HUMIDITY=44;//44humidity
- public static final int ALARM_TYPE_PIR_ALARM=45;//45pir
-
- }
-
- public static class DeviceType{
- public static final int UNKNOWN = 0;
-
- public static final int NPC = 2;
- public static final int PHONE = 3;
- public static final int PC = 4;
- public static final int DOORBELL = 5;
- public static final int IPC = 7;
- public static final int NVR=11;
- public static final int ROBOT = 999;
- }
-
- public static class VideoMode{//、高清(HD)、标清(SD)、普清(LD)
- public static final int VIDEO_MODE_SD = 5;
- public static final int VIDEO_MODE_LD = 6;
- public static final int VIDEO_MODE_HD = 7;
- }
-
- public static class UpdateState{
- public static final int STATE_UPDATING = 1;
- public static final int STATE_UPDATE_SUCCESS = 65;
- }
- public static class DeviceMode{
- public static final int GERNERY_MODE=0;
- public static final int AP_MODE=1;
- }
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/P2PView.java b/p2PCore/src/main/java/com/p2p/core/P2PView.java
deleted file mode 100644
index f53a05cd5..000000000
--- a/p2PCore/src/main/java/com/p2p/core/P2PView.java
+++ /dev/null
@@ -1,398 +0,0 @@
-package com.p2p.core;
-
-import android.R.bool;
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.PixelFormat;
-import android.util.AttributeSet;
-import android.util.DisplayMetrics;
-import android.util.Log;
-import android.view.MotionEvent;
-import android.view.SurfaceHolder;
-import android.widget.RelativeLayout;
-
-import com.p2p.core.GestureDetector.OnZoomInListener;
-import com.p2p.core.global.Constants;
-
-public class P2PView extends BaseP2PView {
- static final String TAG = "p2p";
- Context mContext;
- MediaPlayer mPlayer;
- private int mWidth, mHeight;
- boolean isInitScreen = false;
- protected GestureDetector mGestureDetector;
- int deviceType;
- int mWindowWidth, mWindowHeight;
- public int fgFullScreen = 0;
- boolean isInitScale;
- static final boolean SUPPORT_ZOOM =true;
- static final boolean SUPPORT_ZOOM_FOCUS=true;
- public static int type=0;
- public static int scale=0;
- public static String contactId;
- public static String password;
- public P2PView(Context context) {
- super(context);
- this.mContext = context;
- mPlayer = MediaPlayer.getInstance();
- Log.e("leleTest", "P2PView--");
-
- }
-
- public P2PView(Context context, AttributeSet attrs) {
- super(context, attrs);
- // TODO Auto-generated constructor stub
- this.mContext = context;
- mPlayer = MediaPlayer.getInstance();
- Log.e("leleTest", "P2PView++");
- DisplayMetrics dm = new DisplayMetrics();
- dm = getResources().getDisplayMetrics();
- mWindowWidth = dm.widthPixels;
- mWindowHeight = dm.heightPixels;
- }
-
- public void initScaleView() {
- isInitScale = true;
- }
-
- private void vSetWindow() {
- DisplayMetrics dm = new DisplayMetrics();
- dm = getResources().getDisplayMetrics();
- mWindowWidth = dm.widthPixels;
- mWindowHeight = dm.heightPixels;
-
- Log.e("my", "xWidth:" + mWindowWidth + " xHeight:" + mWindowHeight);
- mWidth = mWindowWidth;
- mHeight = mWindowHeight;
- //如果type==1,type等于其它值时,通过npc和ipc来判断
- //scale:0 代表4:3 1 代表16:9
- if (fgFullScreen == 0) {
- if(type==1){
- if (scale==0) {
- int Rate, Rate2;
- Rate = mWidth * 1024 / mHeight;
- Rate2 = 4 * 1024 / 3;
- if (Rate > Rate2) {
- mWidth = mHeight * 4 / 3;
- } else {
- mHeight = mWidth * 3 / 4;
- }
-
- // fullScreen();//为何要全屏
- } else {
- int Rate, Rate2;
- Rate = mWidth * 1024 / mHeight;
- Rate2 = 16 * 1024 / 9;
- if (Rate > Rate2) {
- mWidth = mHeight * 16 / 9;
- } else {
- mHeight = mWidth * 9 / 16;
- }
- }
- }else{
- if (deviceType == P2PValue.DeviceType.NPC) {
- int Rate, Rate2;
- Rate = mWidth * 1024 / mHeight;
- Rate2 = 4 * 1024 / 3;
- if (Rate > Rate2) {
- mWidth = mHeight * 4 / 3;
- } else {
- mHeight = mWidth * 3 / 4;
- }
-
- // fullScreen();//为何要全屏
- } else {
- int Rate, Rate2;
- Rate = mWidth * 1024 / mHeight;
- Rate2 = 16 * 1024 / 9;
- if (Rate > Rate2) {
- mWidth = mHeight * 16 / 9;
- } else {
- mHeight = mWidth * 9 / 16;
- }
- }
- }
- }
-
- RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
- layoutParams.width = mWidth;
- layoutParams.height = mHeight;
- // layoutParams.leftMargin = (mWindowWidth - mWidth) / 2;
- // layoutParams.topMargin = (mWindowHeight - mHeight) / 2;
- setLayoutParams(layoutParams);
- mPlayer.ChangeScreenSize(mWidth, mHeight, fgFullScreen);
- Log.e("dxslayout","mWidth---"+mWidth+"mHeight---"+mHeight);
- }
-
- public void updateScreenOrientation() {
- vSetWindow();
- }
-
- public void setCallBack() {
- MediaPlayer.setEglView(this);
- getHolder().addCallback(mSHCallback);
- }
-
- public void setGestureDetector(GestureDetector gestureDetector) {
- mGestureDetector = gestureDetector;
- }
-
- public void setDeviceType(int type) {
- this.deviceType = type;
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
-
- Log.d(TAG, "onTouchEvent");
- if (SUPPORT_ZOOM) {
- if (!(super.onTouchEvent(event))) {
- if (mGestureDetector != null) {
- mGestureDetector.setOnZoomInListener(zoomInListener);
- mGestureDetector.onTouchEvent(event);
- }
- }
- } else {
- if (mGestureDetector != null) {
- mGestureDetector.setOnZoomInListener(zoomInListener);
- mGestureDetector.onTouchEvent(event);
- }
- }
-
- return true;
- }
-
- public OnZoomInListener zoomInListener = new OnZoomInListener() {
-
- @Override
- public void onZoom(MotionEvent event) {
- // TODO Auto-generated method stub
- if (SUPPORT_ZOOM) {
- mode = MODE.ZOOM;
- touchSuper(event);
- }
- }
-
- };
-
- public void touchSuper(MotionEvent event) {
- super.onTouchEvent(event);
- }
-
- public void fullScreen() {
-
- fgFullScreen = 1;
- vSetWindow();
- }
-
- public void halfScreen() {
- fgFullScreen = 0;
- vSetWindow();
- }
-
- SurfaceHolder.Callback mSHCallback = new SurfaceHolder.Callback() {
- public void surfaceChanged(SurfaceHolder holder, int format, int w,
- int h) {
- // startVideo();
- Log.v(TAG, "surfaceChanged()");
- int sdlFormat = 0x85151002; // SDL_PIXELFORMAT_RGB565 by default
- switch (format) {
- case PixelFormat.A_8:
- Log.v(TAG, "pixel format A_8");
- break;
- case PixelFormat.LA_88:
- Log.v(TAG, "pixel format LA_88");
- break;
- case PixelFormat.L_8:
- Log.v(TAG, "pixel format L_8");
- break;
- case PixelFormat.RGBA_4444:
- Log.v(TAG, "pixel format RGBA_4444");
- sdlFormat = 0x85421002; // SDL_PIXELFORMAT_RGBA4444
- break;
- case PixelFormat.RGBA_5551:
- Log.v(TAG, "pixel format RGBA_5551");
- sdlFormat = 0x85441002; // SDL_PIXELFORMAT_RGBA5551
- break;
- case PixelFormat.RGBA_8888:
- Log.v(TAG, "pixel format RGBA_8888");
- sdlFormat = 0x86462004; // SDL_PIXELFORMAT_RGBA8888
- break;
- case PixelFormat.RGBX_8888:
- Log.v(TAG, "pixel format RGBX_8888");
- sdlFormat = 0x86262004; // SDL_PIXELFORMAT_RGBX8888
- break;
- case PixelFormat.RGB_332:
- Log.v(TAG, "pixel format RGB_332");
- sdlFormat = 0x84110801; // SDL_PIXELFORMAT_RGB332
- break;
- case PixelFormat.RGB_565:
- Log.v(TAG, "pixel format RGB_565");
- sdlFormat = 0x85151002; // SDL_PIXELFORMAT_RGB565
- break;
- case PixelFormat.RGB_888:
- Log.v(TAG, "pixel format RGB_888");
- // Not sure this is right, maybe SDL_PIXELFORMAT_RGB24 instead?
- sdlFormat = 0x86161804; // SDL_PIXELFORMAT_RGB888
- break;
- default:
- Log.v(TAG, "pixel format unknown " + format);
- break;
- }
- mPlayer.onNativeResize(w, h, sdlFormat);
- Log.e("surface", w + ":" + h);
- mWidth = w;
- mHeight = h;
-
-
- if (fgFullScreen == 0) {
- if(type==1){
- if (scale ==0) {
- int Rate, Rate2;
- Rate = mWidth * 1024 / mHeight;
- Rate2 = 4 * 1024 / 3;
- if (Rate > Rate2) {
- mWidth = mHeight * 4 / 3;
- } else {
- mHeight = mWidth * 3 / 4;
- }
- } else {
- int Rate, Rate2;
- Rate = mWidth * 1024 / mHeight;
- Rate2 = 16 * 1024 / 9;
- if (Rate > Rate2) {
- mWidth = mHeight * 16 / 9;
- } else {
- mHeight = mWidth * 9 / 16;
- }
- }
- }else{
- if (deviceType == P2PValue.DeviceType.NPC) {
- int Rate, Rate2;
- Rate = mWidth * 1024 / mHeight;
- Rate2 = 4 * 1024 / 3;
- if (Rate > Rate2) {
- mWidth = mHeight * 4 / 3;
- } else {
- mHeight = mWidth * 3 / 4;
- }
- } else {
- int Rate, Rate2;
- Rate = mWidth * 1024 / mHeight;
- Rate2 = 16 * 1024 / 9;
- if (Rate > Rate2) {
- mWidth = mHeight * 16 / 9;
- } else {
- mHeight = mWidth * 9 / 16;
- }
- }
- }
- }
-
- RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
- layoutParams.width = mWidth;
- layoutParams.height = mHeight;
- // layoutParams.leftMargin = (mWindowWidth - mWidth) / 2;
- // layoutParams.topMargin = (mWindowHeight - mHeight) / 2;
- setLayoutParams(layoutParams);
- sendStartBrod();
- }
-
- public void surfaceCreated(SurfaceHolder holder) {
- Log.v(TAG, "surfaceCreated()");
- holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
- holder.setKeepScreenOn(true);
-
- }
-
- public void surfaceDestroyed(SurfaceHolder holder) {
- Log.e(TAG, "surfaceDestroyed");
- type=1;
- scale=1;
- release();
- }
- };
- public void sendStartBrod(){
- if(!isInitScreen){
- isInitScreen=true;
- mPlayer.init(mWidth, mHeight, mWindowWidth);
- Intent start = new Intent();
- start.setAction(Constants.P2P_WINDOW.Action.P2P_WINDOW_READY_TO_START);
- mContext.sendBroadcast(start);
- }
-
- }
- public synchronized void release() {
- if (mPlayer != null) {
- // mPlayer.native_p2p_hungup();
- Log.e("leleTest", "release");
- mPlayer.stop();
- mPlayer.release();
- mPlayer = null;
- }
- isInitScreen=false;
- MediaPlayer.ReleaseOpenGL();
- }
-
- @Override
- protected int getCurrentWidth() {
- // TODO Auto-generated method stub
- return mWindowWidth;
- }
-
- public int getmHeight(){
- return mHeight;
- }
-
- @Override
- protected int getCurrentHeight() {
- // TODO Auto-generated method stub
- return mWindowHeight;
- }
-
- @Override
- protected void setVideoScale(int x, int y, float scale) {
- // TODO Auto-generated method stub
-
- RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
-
- y = mHeight - (layoutParams.topMargin + y);
-
- // Log.e("Gview","zoom" + x + ":" + y+" "+scale);
-
- mPlayer.ZoomView(x, y, scale);
-
- }
-
- @Override
- protected boolean MovePicture(int left, int top) {
- // TODO Auto-generated method stub
-
- if (mPlayer.MoveView(left, 0 - top) == 0) {
- return false;
- }
- return true;
-
- }
-
- @Override
- protected void StopMoving() {
- // TODO Auto-generated method stub
-
- mPlayer.MoveView(0, 0);
-
- }
-
- @Override
- public void changeNormalSize() {
- /*
- * LayoutParams layoutParams = (LayoutParams) getLayoutParams();
- * layoutParams.width = mFixWidth; layoutParams.height = mFixHeight;
- * layoutParams.leftMargin = (mWindowWidth - mFixWidth) / 2;
- * layoutParams.topMargin = (mWindowHeight - mFixHeight) / 2;
- * setLayoutParams(layoutParams); mPlayer.ChangeScreenSize(mFixWidth,
- * mFixHeight, 0);
- */
- }
-
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/ViewConfiguration.java b/p2PCore/src/main/java/com/p2p/core/ViewConfiguration.java
deleted file mode 100644
index 7847c841b..000000000
--- a/p2PCore/src/main/java/com/p2p/core/ViewConfiguration.java
+++ /dev/null
@@ -1,488 +0,0 @@
-/**
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.p2p.core;
-
-import android.content.Context;
-import android.util.DisplayMetrics;
-import android.util.SparseArray;
-
-/***
- * Contains methods to standard constants used in the UI for timeouts, sizes, and distances.
- */
-public class ViewConfiguration {
- /***
- * Defines the width of the horizontal scrollbar and the height of the vertical scrollbar in
- * pixels
- */
- private static final int SCROLL_BAR_SIZE = 10;
-
- /***
- * Duration of the fade when scrollbars fade away in milliseconds
- */
- private static final int SCROLL_BAR_FADE_DURATION = 250;
-
- /***
- * Default delay before the scrollbars fade in milliseconds
- */
- private static final int SCROLL_BAR_DEFAULT_DELAY = 300;
-
- /***
- * Defines the length of the fading edges in pixels
- */
- private static final int FADING_EDGE_LENGTH = 12;
-
- /***
- * Defines the duration in milliseconds of the pressed state in child
- * components.
- */
- private static final int PRESSED_STATE_DURATION = 125;
-
- /***
- * Defines the duration in milliseconds before a press turns into
- * a long press
- */
- private static final int LONG_PRESS_TIMEOUT = 500;
-
- /***
- * Defines the duration in milliseconds a user needs to hold down the
- * appropriate button to bring up the global actions dialog (power off,
- * lock screen, etc).
- */
- private static final int GLOBAL_ACTIONS_KEY_TIMEOUT = 500;
-
- /***
- * Defines the duration in milliseconds we will wait to see if a touch event
- * is a tap or a scroll. If the user does not move within this interval, it is
- * considered to be a tap.
- */
- private static final int TAP_TIMEOUT = 115;
-
- /***
- * Defines the duration in milliseconds we will wait to see if a touch event
- * is a jump tap. If the user does not complete the jump tap within this interval, it is
- * considered to be a tap.
- */
- private static final int JUMP_TAP_TIMEOUT = 500;
-
- /***
- * Defines the duration in milliseconds between the first tap's up event and
- * the second tap's down event for an interaction to be considered a
- * double-tap.
- */
- private static final int DOUBLE_TAP_TIMEOUT = 300;
-
- /***
- * Defines the duration in milliseconds we want to display zoom controls in response
- * to a user panning within an application.
- */
- private static final int ZOOM_CONTROLS_TIMEOUT = 3000;
-
- /***
- * Inset in pixels to look for touchable content when the user touches the edge of the screen
- */
- private static final int EDGE_SLOP = 12;
-
- /***
- * Distance a touch can wander before we think the user is scrolling in pixels
- */
- private static final int TOUCH_SLOP = 16;
-
- /***
- * Distance a touch can wander before we think the user is attempting a paged scroll
- * (in dips)
- */
- private static final int PAGING_TOUCH_SLOP = TOUCH_SLOP * 2;
-
- /***
- * Distance between the first touch and second touch to still be considered a double tap
- */
- private static final int DOUBLE_TAP_SLOP = 100;
-
- /***
- * Distance a touch needs to be outside of a window's bounds for it to
- * count as outside for purposes of dismissing the window.
- */
- private static final int WINDOW_TOUCH_SLOP = 16;
-
- /***
- * Minimum velocity to initiate a fling, as measured in pixels per second
- */
- private static final int MINIMUM_FLING_VELOCITY = 50;
-
- /***
- * Maximum velocity to initiate a fling, as measured in pixels per second
- */
- private static final int MAXIMUM_FLING_VELOCITY = 4000;
-
- /***
- * The maximum size of View's drawing cache, expressed in bytes. This size
- * should be at least equal to the size of the screen in ARGB888 format.
- */
- @Deprecated
- private static final int MAXIMUM_DRAWING_CACHE_SIZE = 320 * 480 * 4; // HVGA screen, ARGB8888
-
- /***
- * The coefficient of friction applied to flings/scrolls.
- */
- private static float SCROLL_FRICTION = 0.015f;
-
- private final int mEdgeSlop;
- private final int mFadingEdgeLength;
- private final int mMinimumFlingVelocity;
- private final int mMaximumFlingVelocity;
- private final int mScrollbarSize;
- private final int mTouchSlop;
- private final int mPagingTouchSlop;
- private final int mDoubleTapSlop;
- private final int mWindowTouchSlop;
- private final int mMaximumDrawingCacheSize;
-
- private static final SparseArray sConfigurations =
- new SparseArray(2);
-
- /***
- * @deprecated Use {@link android.view.ViewConfiguration#get(android.content.Context)} instead.
- */
- @Deprecated
- public ViewConfiguration() {
- mEdgeSlop = EDGE_SLOP;
- mFadingEdgeLength = FADING_EDGE_LENGTH;
- mMinimumFlingVelocity = MINIMUM_FLING_VELOCITY;
- mMaximumFlingVelocity = MAXIMUM_FLING_VELOCITY;
- mScrollbarSize = SCROLL_BAR_SIZE;
- mTouchSlop = TOUCH_SLOP;
- mPagingTouchSlop = PAGING_TOUCH_SLOP;
- mDoubleTapSlop = DOUBLE_TAP_SLOP;
- mWindowTouchSlop = WINDOW_TOUCH_SLOP;
- //noinspection deprecation
- mMaximumDrawingCacheSize = MAXIMUM_DRAWING_CACHE_SIZE;
- }
-
- /***
- * Creates a new configuration for the specified context. The configuration depends on
- * various parameters of the context, like the dimension of the display or the density
- * of the display.
- *
- * @param context The application context used to initialize this view configuration.
- *
- * @see #get(android.content.Context)
- * @see android.util.DisplayMetrics
- */
- private ViewConfiguration(Context context) {
- final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
- final float density = metrics.density;
-
- mEdgeSlop = (int) (density * EDGE_SLOP + 0.5f);
- mFadingEdgeLength = (int) (density * FADING_EDGE_LENGTH + 0.5f);
- mMinimumFlingVelocity = (int) (density * MINIMUM_FLING_VELOCITY + 0.5f);
- mMaximumFlingVelocity = (int) (density * MAXIMUM_FLING_VELOCITY + 0.5f);
- mScrollbarSize = (int) (density * SCROLL_BAR_SIZE + 0.5f);
- mTouchSlop = (int) (density * TOUCH_SLOP + 0.5f);
- mPagingTouchSlop = (int) (density * PAGING_TOUCH_SLOP + 0.5f);
- mDoubleTapSlop = (int) (density * DOUBLE_TAP_SLOP + 0.5f);
- mWindowTouchSlop = (int) (density * WINDOW_TOUCH_SLOP + 0.5f);
-
- // Size of the screen in bytes, in ARGB_8888 format
- mMaximumDrawingCacheSize = 4 * metrics.widthPixels * metrics.heightPixels;
- }
-
- /***
- * Returns a configuration for the specified context. The configuration depends on
- * various parameters of the context, like the dimension of the display or the
- * density of the display.
- *
- * @param context The application context used to initialize the view configuration.
- */
- public static ViewConfiguration get(Context context) {
- final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
- final int density = (int) (100.0f * metrics.density);
-
- ViewConfiguration configuration = sConfigurations.get(density);
- if (configuration == null) {
- configuration = new ViewConfiguration(context);
- sConfigurations.put(density, configuration);
- }
-
- return configuration;
- }
-
- /***
- * @return The width of the horizontal scrollbar and the height of the vertical
- * scrollbar in pixels
- *
- * @deprecated Use {@link #getScaledScrollBarSize()} instead.
- */
- @Deprecated
- public static int getScrollBarSize() {
- return SCROLL_BAR_SIZE;
- }
-
- /***
- * @return The width of the horizontal scrollbar and the height of the vertical
- * scrollbar in pixels
- */
- public int getScaledScrollBarSize() {
- return mScrollbarSize;
- }
-
- /***
- * @return Duration of the fade when scrollbars fade away in milliseconds
- */
- public static int getScrollBarFadeDuration() {
- return SCROLL_BAR_FADE_DURATION;
- }
-
- /***
- * @return Default delay before the scrollbars fade in milliseconds
- */
- public static int getScrollDefaultDelay() {
- return SCROLL_BAR_DEFAULT_DELAY;
- }
-
- /***
- * @return the length of the fading edges in pixels
- *
- * @deprecated Use {@link #getScaledFadingEdgeLength()} instead.
- */
- @Deprecated
- public static int getFadingEdgeLength() {
- return FADING_EDGE_LENGTH;
- }
-
- /***
- * @return the length of the fading edges in pixels
- */
- public int getScaledFadingEdgeLength() {
- return mFadingEdgeLength;
- }
-
- /***
- * @return the duration in milliseconds of the pressed state in child
- * components.
- */
- public static int getPressedStateDuration() {
- return PRESSED_STATE_DURATION;
- }
-
- /***
- * @return the duration in milliseconds before a press turns into
- * a long press
- */
- public static int getLongPressTimeout() {
- return LONG_PRESS_TIMEOUT;
- }
-
- /***
- * @return the duration in milliseconds we will wait to see if a touch event
- * is a tap or a scroll. If the user does not move within this interval, it is
- * considered to be a tap.
- */
- public static int getTapTimeout() {
- return TAP_TIMEOUT;
- }
-
- /***
- * @return the duration in milliseconds we will wait to see if a touch event
- * is a jump tap. If the user does not move within this interval, it is
- * considered to be a tap.
- */
- public static int getJumpTapTimeout() {
- return JUMP_TAP_TIMEOUT;
- }
-
- /***
- * @return the duration in milliseconds between the first tap's up event and
- * the second tap's down event for an interaction to be considered a
- * double-tap.
- */
- public static int getDoubleTapTimeout() {
- return DOUBLE_TAP_TIMEOUT;
- }
-
- /***
- * @return Inset in pixels to look for touchable content when the user touches the edge of the
- * screen
- *
- * @deprecated Use {@link #getScaledEdgeSlop()} instead.
- */
- @Deprecated
- public static int getEdgeSlop() {
- return EDGE_SLOP;
- }
-
- /***
- * @return Inset in pixels to look for touchable content when the user touches the edge of the
- * screen
- */
- public int getScaledEdgeSlop() {
- return mEdgeSlop;
- }
-
- /***
- * @return Distance a touch can wander before we think the user is scrolling in pixels
- *
- * @deprecated Use {@link #getScaledTouchSlop()} instead.
- */
- @Deprecated
- public static int getTouchSlop() {
- return TOUCH_SLOP;
- }
-
- /***
- * @return Distance a touch can wander before we think the user is scrolling in pixels
- */
- public int getScaledTouchSlop() {
- return mTouchSlop;
- }
-
- /***
- * @return Distance a touch can wander before we think the user is scrolling a full page
- * in dips
- */
- public int getScaledPagingTouchSlop() {
- return mPagingTouchSlop;
- }
-
- /***
- * @return Distance between the first touch and second touch to still be
- * considered a double tap
- * @deprecated Use {@link #getScaledDoubleTapSlop()} instead.
- * @hide The only client of this should be GestureDetector, which needs this
- * for clients that still use its deprecated constructor.
- */
- @Deprecated
- public static int getDoubleTapSlop() {
- return DOUBLE_TAP_SLOP;
- }
-
- /***
- * @return Distance between the first touch and second touch to still be
- * considered a double tap
- */
- public int getScaledDoubleTapSlop() {
- return mDoubleTapSlop;
- }
-
- /***
- * @return Distance a touch must be outside the bounds of a window for it
- * to be counted as outside the window for purposes of dismissing that
- * window.
- *
- * @deprecated Use {@link #getScaledWindowTouchSlop()} instead.
- */
- @Deprecated
- public static int getWindowTouchSlop() {
- return WINDOW_TOUCH_SLOP;
- }
-
- /***
- * @return Distance a touch must be outside the bounds of a window for it
- * to be counted as outside the window for purposes of dismissing that
- * window.
- */
- public int getScaledWindowTouchSlop() {
- return mWindowTouchSlop;
- }
-
- /***
- * @return Minimum velocity to initiate a fling, as measured in pixels per second.
- *
- * @deprecated Use {@link #getScaledMinimumFlingVelocity()} instead.
- */
- @Deprecated
- public static int getMinimumFlingVelocity() {
- return MINIMUM_FLING_VELOCITY;
- }
-
- /***
- * @return Minimum velocity to initiate a fling, as measured in pixels per second.
- */
- public int getScaledMinimumFlingVelocity() {
- return mMinimumFlingVelocity;
- }
-
- /***
- * @return Maximum velocity to initiate a fling, as measured in pixels per second.
- *
- * @deprecated Use {@link #getScaledMaximumFlingVelocity()} instead.
- */
- @Deprecated
- public static int getMaximumFlingVelocity() {
- return MAXIMUM_FLING_VELOCITY;
- }
-
- /***
- * @return Maximum velocity to initiate a fling, as measured in pixels per second.
- */
- public int getScaledMaximumFlingVelocity() {
- return mMaximumFlingVelocity;
- }
-
- /***
- * The maximum drawing cache size expressed in bytes.
- *
- * @return the maximum size of View's drawing cache expressed in bytes
- *
- * @deprecated Use {@link #getScaledMaximumDrawingCacheSize()} instead.
- */
- @Deprecated
- public static int getMaximumDrawingCacheSize() {
- //noinspection deprecation
- return MAXIMUM_DRAWING_CACHE_SIZE;
- }
-
- /***
- * The maximum drawing cache size expressed in bytes.
- *
- * @return the maximum size of View's drawing cache expressed in bytes
- */
- public int getScaledMaximumDrawingCacheSize() {
- return mMaximumDrawingCacheSize;
- }
-
- /***
- * The amount of time that the zoom controls should be
- * displayed on the screen expressed in milliseconds.
- *
- * @return the time the zoom controls should be visible expressed
- * in milliseconds.
- */
- public static long getZoomControlsTimeout() {
- return ZOOM_CONTROLS_TIMEOUT;
- }
-
- /***
- * The amount of time a user needs to press the relevant key to bring up
- * the global actions dialog.
- *
- * @return how long a user needs to press the relevant key to bring up
- * the global actions dialog.
- */
- public static long getGlobalActionKeyTimeout() {
- return GLOBAL_ACTIONS_KEY_TIMEOUT;
- }
-
- /***
- * The amount of friction applied to scrolls and flings.
- *
- * @return A scalar dimensionless value representing the coefficient of
- * friction.
- */
- public static float getScrollFriction() {
- return SCROLL_FRICTION;
- }
-}
-
diff --git a/p2PCore/src/main/java/com/p2p/core/global/Config.java b/p2PCore/src/main/java/com/p2p/core/global/Config.java
deleted file mode 100644
index e07fc14c8..000000000
--- a/p2PCore/src/main/java/com/p2p/core/global/Config.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.p2p.core.global;
-
-/**
- * Created by dxs on 2015/9/6.
- */
-public class Config {
-
- public static class AppConfig{
- public static final String VERSION="00.46.00.08";
- public static int [] CustomerIDs={0};
- public static String store_id="1";
- }
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/global/Constants.java b/p2PCore/src/main/java/com/p2p/core/global/Constants.java
deleted file mode 100644
index 3251155cd..000000000
--- a/p2PCore/src/main/java/com/p2p/core/global/Constants.java
+++ /dev/null
@@ -1,202 +0,0 @@
-package com.p2p.core.global;
-
-public class Constants {
- public static class SettingConfig{
- public static final int ACK_PWD_ERROR = 9999;
- public static final int ACK_NET_ERROR = 9998;
- public static final int ACK_SUCCESS = 9997;
- }
-
- public static class MsgSection{
-
-
- public static int MSG_ID_SETTING_DEVICE_TIME = 1000;
- public static int MSG_ID_GETTING_DEVICE_TIME = 2000;
-
- public static int MSG_ID_GETTING_NPC_SETTINGS = 3000;
- public static int MSG_ID_SET_REMOTE_DEFENCE = 4000;
- public static int MSG_ID_SET_REMOTE_RECORD = 5000;
- public static int MSG_ID_SETTING_NPC_SETTINGS_VIDEO_FORMAT = 6000;
- public static int MSG_ID_SETTING_NPC_SETTINGS_VIDEO_VOLUME = 7000;
- public static int MSG_ID_SETTING_NPC_SETTINGS_BUZZER = 8000;
- public static int MSG_ID_SETTING_NPC_SETTINGS_MOTION = 9000;
- public static int MSG_ID_SETTING_NPC_SETTINGS_RECORD_TYPE = 10000;
- public static int MSG_ID_SETTING_NPC_SETTINGS_RECORD_TIME = 11000;
- public static int MSG_ID_SETTING_NPC_SETTINGS_RECORD_PLAN_TIME = 12000;
- public static int MSG_ID_SETTING_NPC_SETTINGS_NET_TYPE = 13000;
-
- public static int MSG_ID_SETTING_ALARM_EMAIL = 14000;
- public static int MSG_ID_GETTING_ALARM_EMAIL = 15000;
-
- public static int MSG_ID_SETTING_ALARM_BIND_ID = 16000;
- public static int MSG_ID_GETTING_ALARM_BIND_ID = 17000;
-
- public static int MSG_ID_SETTING_INIT_PASSWORD = 18000;
- public static int MSG_ID_SETTING_DEVICE_PASSWORD = 19000;
- public static int MSG_ID_CHECK_DEVICE_PASSWORD = 20000;
-
- public static int MSG_ID_SETTING_DEFENCEAREA = 21000;
- public static int MSG_ID_GETTING_DEFENCEAREA = 22000;
-
- public static int MSG_ID_SETTING_WIFI = 23000;
- public static int MSG_ID_GETTING_WIFI_LIST = 24000;
-
- public static int MSG_ID_GETTING_RECORD_FILE_LIST = 25000;
- public static int MSG_ID_SEND_MESSAGE = 26000;
- public static int MSG_ID_SEND_CUSTOM_CMD = 27000;
-
-
- public static int MSG_ID_CHECK_DEVICE_UPDATE = 28000;
- public static int MSG_ID_CANCEL_DEVICE_UPDATE = 29000;
- public static int MSG_ID_DO_DEVICE_UPDATE = 30000;
- public static int MSG_ID_GET_DEFENCE_STATE = 31000;
- public static int MSG_ID_GET_DEVICE_VERSION = 32000;
-
- public static int MSG_ID_CLEAR_DEFENCE_GROUP = 33000;
-
- public static int MESG_ID_STTING_PIC_REVERSE=34000;
- public static int MESG_ID_STTING_IR_ALARM_EN=35000;
- public static int MESG_STTING_ID_EXTLINE_ALARM_IN_EN=36000;
- public static int MESG_STTING_ID_EXTLINE_ALARM_OUT_EN=37000;
- public static int MESG_STTING_ID_SECUPGDEV=38000;
- public static int MESG_STTING_ID_GUEST_PASSWD=39000;
- public static int MESG_STTING_ID_TIMEZONE=40000;
- public static int MESG_GET_SD_CARD_CAPACITY=41000;
- public static int MESG_SD_CARD_FORMAT=42000;
- public static int MESG_SET_GPIO=43000;
- public static int MESG_SET_GPI1_0=44000;
- public static int MESG_SET_PRE_RECORD=45000;
- public static int MESG_GET_DEFENCE_AREA_SWITCH=46000;
- public static int MESG_SET_DEFENCE_AREA_SWITCH=47000;
- public static int MESG_GET_PRESET_MOTOR_POS = 48000;
- public static int MESG_SET_PRESET_MOTOR_POS = 49000;
- public static int MESG_PRESET_MOTOR_POS = 50000;
- public static int IP_CONFIG = 51000;
- public static int MESG_GET_ALARM_CENTER_PARAMETER=52000;
- public static int MESG_SET_ALARM_CENTER_PARAMETER=53000;
- public static int MESG_DELETE_DEVICEALARMID=54000;
- public static int MESG_SET_SYSTEM_MESSAGE_INDEX=55000;
- public static int CONTROL_CAMERA=56000;
- public static int MESG_SET_RECEIVE_DOOBELL=57000;
- public static int MESG_GET_LANGUEGE=58000;
- public static int MESG_SET_LANGUEGE=59000;
- public static int MESG_SET_LAMP=60000;
- public static int MESG_GET_LAMP=61000;
- public static int SET_USER_DEFINE_MESG=62000;
- public static int MESG_TYPE_GET_LAN_IPC_LIST=63000;
- public static int MESG_TYPE_SET_AP_MODE_CHANGE=64000;
-
- //fisheye jump over the last int 58000,startwith 100000
- public static int MSG_ID_FISHEYE_SETTING_WORKMODE_DEFULT =101000;
- public static int MSG_ID_FISHEYE_SETTING_IPC_WORKMODE =102000;
- public static int MSG_ID_FISHEYE_SETTING_SENSOR_WORKMODE =103000;
- public static int MSG_ID_FISHEYE_SETTING_SCHEDULE_WORKMODE =104000;
- public static int MSG_ID_FISHEYE_DELETE_SCHEDULE =105000;
- public static int MSG_ID_FISHEYE_GET_CURRENTWORKMODE =106000;
- public static int MSG_ID_FISHEYE_GET_SENSORWORKMODE =107000;
- public static int MSG_ID_FISHEYE_WORKMODE_SCHEDULE =108000;
- public static int MSG_ID_FISHEYE_SETTING_ALL_SENSOR_SWITCH =109000;
- public static int MSG_ID_FISHEYE_GET_ALL_SENSOR_SWITCH =110000;
- public static int MSG_ID_FISHEYE_SET_LOW_VOL_TIMEINTERVAL =111000;
- public static int MSG_ID_FISHEYE_GET_LOW_VOL_TIMEINTERVAL =112000;
-
- //第二次添加
- public static int MSG_ID_FISHEYE_DELETE_ONE_CONTROLER =113000;
- public static int MSG_ID_FISHEYE_DELETE_ONE_SENSOR =114000;
- public static int MSG_ID_FISHEYE_CHANGE_CONTROLER_NAME =115000;
- public static int MSG_ID_FISHEYE_CHANGE_SENSOR_NAME =116000;
- public static int MSG_ID_FISHEYE_INTO_LEARN_STATE =117000;
- public static int MSG_ID_FISHEYE_TURN_SENSOR =118000;
- public static int MSG_ID_FISHEYE_SHARE_TO_MEMBER =119000;
- public static int MSG_ID_FISHEYE_GOT_SHARE_MESG =120000;
- public static int MSG_ID_FISHEYE_DEV_RECV_MEMBER_FEEDBACK =121000;
- public static int MSG_ID_FISHEYE_ADMIN_DELETE_ONE_MEMBER =122000;
- public static int MSG_ID_FISHEYE_DELETE_DEV =123000;
- public static int MSG_ID_FISHEYE_GET_MEMBER_LIST =124000;
- public static int MSG_ID_FISHEYE_SET_SPECIAL_ALARM =125000;
- public static int MSG_ID_FISHEYE_GET_ALL_SPECIAL_ALARM =126000;
- public static int MSG_ID_FISHEYE_GET_LAMP_STATE =127000;
- public static int MSG_ID_FISHEYE_KEEP_CLIENT_STATE =128000;
- }
-
- public static class ACK_RET_TYPE{
- public static final int ACK_PWD_ERROR = 9999;
- public static final int ACK_NET_ERROR = 9998;
- public static final int ACK_SUCCESS = 9997;
- public static final int ACK_INSUFFICIENT_PERMISSIONS=9996;
- }
-
- public static class P2P_SETTING{
-
- public static class SETTING_TYPE{
- public static final int SETTING_REMOTE_DEFENCE = 0;
- public static final int SETTING_BUZZER = 1;
- public static final int SETTING_MOTION_DECT = 2;
- public static final int SETTING_RECORD_TYPE = 3;
- public static final int SETTING_REMOTE_RECORD = 4;
- public static final int SETTING_RECORD_PLAN_TIME= 5;
- public static final int SETTING_VIDEO_FORMAT = 8;
- public static final int SETTING_DEVICE_PWD = 9;
- public static final int SETTING_ALARM_ID = 10;
-
- public static final int SETTING_RECORD_TIME = 11;
-
- public static final int SETTING_NET_TYPE = 13;
- public static final int SETTING_VOLUME = 14;
-
- public static final int SETTING_ID_SECUPGDEV=16;
- public static final int SETTING_ID_IR_ALARM_EN=17;
- public static final int SETTING_ID_EXTLINE_ALARM_IN_EN=18;
- public static final int SETTING_ID_EXTLINE_ALARM_OUT_EN=19;
- public static final int SETTING_ID_TIMEZONE=20;
- public static final int SETTING_ID_GUEST_PASSWD=21;
- public static final int SETTING_IMAGE_REVERSE=24;
- public static final int SETTING_ID_PRERECORD =25;
- public static final int STTING_ID_GET_AUDIO_DEVICE_TYPE=27;
- public static final int SETTING_ID_LAMP=34;
- public static final int SETTING_ID_VISITORPWD=37;//返回访客密码
- public static final int SETTING_ID_FOCUS_ZOOM=38;
- public static final int SETTING_ID_SET_WIFI_WORK_MODE=39;//切换AP模式工作模式1为切换模式
- public static final int SETTING_ID_CHECK_AP_MODE_SURPPORT=40;//AP模式支持 2当前模式 1支持 0不支持
- }
-
- public static final int DEFENCE_AREA_TYPE_LEARN = 0;
- public static final int DEFENCE_AREA_TYPE_CLEAR = 1;
- }
-
- public static class P2P_TYPE{
- public static final int P2P_TYPE_CALL = 0;
- public static final int P2P_TYPE_MONITOR = 1;
- public static final int P2P_TYPE_PLAYBACK = 2;
- public static final int P2P_TYPE_RTSP = 3;
- }
-
- public static class P2P_CALL{
- public static class CALL_RESULT{
- public static final int CALL_SUCCESS = 0;
- public static final int CALL_PHONE_FORMAT_ERROR = 1;
- }
- }
-
- public static class P2P_WINDOW{
- public static final int P2P_SURFACE_START_PLAYING_WIDTH = 320;
- public static final int P2P_SURFACE_START_PLAYING_HEIGHT = 240;
-
- public static class Action{
- public static final String P2P_WINDOW_READY_TO_START = "com.p2p.core.P2P_WINDOW_READY_TO_START";
- }
- }
- public static class ActivityStatus{
- public static final int STATUS_START = 0;
- public static final int STATUS_STOP = 1;
- }
- public static class ZOOM{
- public static final byte ZOOM_BIG=0x5;
- public static final byte ZOOM_SMALL=0x15;
- }
- public static class SystemMessgeType{
- public static final int MALL_NEW=1;
- }
-
-
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/network/AlarmRecordResult.java b/p2PCore/src/main/java/com/p2p/core/network/AlarmRecordResult.java
deleted file mode 100644
index a62362626..000000000
--- a/p2PCore/src/main/java/com/p2p/core/network/AlarmRecordResult.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package com.p2p.core.network;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import android.util.Log;
-
-import com.p2p.core.utils.MyUtils;
-
-public class AlarmRecordResult implements Serializable {
- public String error_code;
- public String Surplus;
- public List alarmRecords=new ArrayList();
- public AlarmRecordResult(JSONObject json){
- init(json);
- }
- private void init(JSONObject json){
- try {
- error_code=json.getString("error_code");
- Surplus=json.getString("Surplus");
- String RL=json.getString("RL");
- String[] list=RL.split(";");
- for(String str:list){
- if(str.equals("")){
- continue;
- }
- String[] data=str.split("&");
- SAlarmRecord ar=new SAlarmRecord();
- ar.messgeId=data[0];
- ar.sourceId=data[1];
- String dTime=data[2];
- ar.alarmTime=MyUtils.convertTimeStringToInterval(dTime);
- ar.pictureUrl=data[3];
- ar.alarmType=Integer.parseInt(data[4]);
- ar.defenceArea=Integer.parseInt(data[5]);
- ar.channel=Integer.parseInt(data[6]);
- String sTime=data[7];
- ar.serverReceiveTime=MyUtils.convertTimeStringToInterval(sTime);
- alarmRecords.add(ar);
- }
- } catch (Exception e) {
- if(!MyUtils.isNumeric(error_code)){
- Log.e("my","GetAccountInfoResult json解析错误");
- error_code = String.valueOf(NetManager.JSON_PARSE_ERROR);
- }
- }
- }
- public static class SAlarmRecord implements Serializable,Comparable{
- public String messgeId;
- public String sourceId;
- public long alarmTime;
- public String pictureUrl;
- public int alarmType;
- public int defenceArea;
- public int channel;
- public long serverReceiveTime;
- @Override
- public int compareTo(Object arg0) {
- // TODO Auto-generated method stub
- SAlarmRecord o=(SAlarmRecord) arg0;
- if(this.serverReceiveTime>o.serverReceiveTime){
- return -1;
- }else if(this.serverReceiveTime datas = new ArrayList();
-
- public GetAlarmRecordListResult(JSONObject json){
- init(json);
- }
-
- private void init(JSONObject json){
- try{
- error_code = json.getString("error_code");
- String RL = json.getString("RL");
- String[] list = RL.split(";");
- for(String str : list){
- if(str.equals("")){
- continue;
- }
-
- String[] data = str.split("&");
- GXAlarmRecord gxar = new GXAlarmRecord();
- gxar.index = data[0];
- gxar.sendContactId = data[1];
-
- String dTime = data[2];
- gxar.deviceTime = MyUtils.convertTimeStringToInterval(dTime);
- gxar.imageUrl = data[3];
- gxar.type = Integer.parseInt(data[4]);
- gxar.group = Integer.parseInt(data[5]);
- gxar.item = Integer.parseInt(data[6]);
-
- String sTime = data[7];
- gxar.serverTime = MyUtils.convertTimeStringToInterval(sTime);
-
- datas.add(gxar);
- }
-
- Collections.sort(datas);
- }catch(Exception e){
- if(!MyUtils.isNumeric(error_code)){
- Log.e("my","GetAccountInfoResult json解析错误");
- error_code = String.valueOf(NetManager.JSON_PARSE_ERROR);
- }
-
- }
- }
-
-
- public static class GXAlarmRecord implements Serializable,Comparable{
- public String index;
- public String sendContactId;
- public long deviceTime;
- public long serverTime;
- public String imageUrl;
- public int type;
- public int item;
- public int group;
-
- @Override
- public int compareTo(Object arg0) {
- // TODO Auto-generated method stub
- GXAlarmRecord o = (GXAlarmRecord) arg0;
- if(this.serverTime>o.serverTime){
- return -1;
- }else if(this.serverTime contactIds = new ArrayList();
- public List flags = new ArrayList();
- public List phones = new ArrayList();
- public List country_codes = new ArrayList();
-
- public GetBindDeviceAccountResult(JSONObject json){
- init(json);
- }
-
- private void init(JSONObject json){
- try{
- error_code = json.getString("error_code");
- String RL = json.getString("RL");
- String[] list = RL.split(",");
- for(int i=0;i contactIds = new ArrayList();
- public List flags = new ArrayList();
- public List nikeNames = new ArrayList();
- public GetDeviceListResult(JSONObject json){
- init(json);
- }
-
- private void init(JSONObject json){
- try{
- error_code = json.getString("error_code");
- bindFlag = json.getString("BindFlag");
- String RL = json.getString("RL");
- String[] list = RL.split(",");
- for(int i=0;i params, String url)
- throws Exception {
- if (!isInit) {
- initServer();
- }
- updateUrl(CURRENT_SERVER);
- Log.e("my", "current-server:" + CURRENT_SERVER);
- String result = null;
- // 新建HttpPost对象
- HttpPost httpPost = new HttpPost(url);
- // 设置字符集
- HttpEntity entity = new UrlEncodedFormEntity(params, HTTP.UTF_8);
- // 设置参数实体
- httpPost.setEntity(entity);
- // 获取HttpClient对象
- HttpClient httpClient = new DefaultHttpClient();
- // 连接超时
- httpClient.getParams().setParameter(
- CoreConnectionPNames.CONNECTION_TIMEOUT, 10000);
- // 请求超时
- httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT,
- 10000);
- try {
- HttpResponse httpResp = httpClient.execute(httpPost);
- int http_code;
- if ((http_code = httpResp.getStatusLine().getStatusCode()) == 200) {
- result = EntityUtils.toString(httpResp.getEntity(), "UTF-8");
- Log.e("my", "original http:" + result);
- } else {
- Log.e("my", "HttpPost方式请求失败:" + http_code);
- // result = "{\"error_code\":998}";
- throw new Exception();
- }
- try {
- JSONObject jObject = new JSONObject(result);
- int error_code = jObject.getInt("error_code");
- if (error_code == 1 || error_code == 29 || error_code == 999) {
- throw new Exception();
- }
- } catch (Exception e) {
- throw new Exception();
- }
- randomServer();
- reconnect_count = 0;
-
- } catch (Exception e) {
- reconnect_count++;
- if (reconnect_count <= 3) {
- CURRENT_SERVER = servers[reconnect_count];
- Log.e("my", "更换服务器:" + CURRENT_SERVER);
- result = "{\"error_code\":998}";
- } else {
- randomServer();
- reconnect_count = 0;
- result = "{\"error_code\":999}";
- }
- }
-
- return result;
- }
-
- public JSONObject getAccountInfo(String contactId, String sessionId) {
- JSONObject jObject = null;
-
- List params = new ArrayList();
- try {
- params.add(new BasicNameValuePair("Opion", "GetParam"));
- params.add(new BasicNameValuePair("UserID", String.valueOf(Integer.parseInt(contactId)|0x80000000)));
- params.add(new BasicNameValuePair("SessionID", sessionId));
- jObject = new JSONObject(doPost(params, ACCOUNT_INFO_URL));
- Log.e("my", jObject.toString());
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return jObject;
- }
-
- public JSONObject getDeviceList(String phone, String sessionId) {
- JSONObject jObject = null;
-
- List params = new ArrayList();
- params.add(new BasicNameValuePair("Account", phone));
- params.add(new BasicNameValuePair("SessionID", sessionId));
- try {
- jObject = new JSONObject(doPost(params, DEVICE_LIST_URL));
- Log.e("my", jObject.toString());
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return jObject;
- }
-
- public JSONObject getBindDeviceAccountList(String phone,String sessionId,String deviceId){
- JSONObject jObject = null;
-
- List params = new ArrayList();
- params.add(new BasicNameValuePair("Account", phone));
- params.add(new BasicNameValuePair("SessionID", sessionId));
- params.add(new BasicNameValuePair("DevID", deviceId));
- try {
- jObject = new JSONObject(doPost(params, SEARCH_BIND_DEVICE_ACCOUNT));
- Log.e("my", jObject.toString());
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return jObject;
- }
-
- public JSONObject getAlarmRecordList(String contactId, String sessionId,String index,int pageSize,int option) {
- JSONObject jObject = null;
-
- List params = new ArrayList();
- params.add(new BasicNameValuePair("UserID", String.valueOf(Integer.parseInt(contactId)|0x80000000)));
- params.add(new BasicNameValuePair("SessionID", sessionId));
- params.add(new BasicNameValuePair("MsgIndex", index));
- params.add(new BasicNameValuePair("PageSize", String.valueOf(pageSize)));
- params.add(new BasicNameValuePair("Option", String.valueOf(option)));
- try {
- jObject = new JSONObject(doPost(params, ALARM_RECORD_LIST_URL));
- Log.e("my", jObject.toString());
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return jObject;
- }
-
- public JSONObject modifyLoginPassword(String contactId, String sessionId,
- String oldPwd, String newPwd, String rePwd) {
- JSONObject jObject = null;
-
- List params = new ArrayList();
- MD5 md = new MD5();
- params.add(new BasicNameValuePair("UserID", String.valueOf(Integer.parseInt(contactId)|0x80000000)));
- params.add(new BasicNameValuePair("SessionID", sessionId));
- params.add(new BasicNameValuePair("OldPwd", md.getMD5ofStr(oldPwd)));
- params.add(new BasicNameValuePair("Pwd", md.getMD5ofStr(newPwd)));
- params.add(new BasicNameValuePair("RePwd", md.getMD5ofStr(rePwd)));
- try {
- jObject = new JSONObject(doPost(params, MODIFY_LOGIN_PASSWORD_URL));
- Log.e("my", jObject.toString());
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return jObject;
- }
-
- /*
- * flag 0:绑定手机和邮箱,1:绑定手机,2:绑定邮箱
- */
- public int setAccountInfo(String contactId, String phone, String email,
- String countryCode, String sessionId, String password, String flag,
- String phoneCheckCode) {
- int result = UNKNOWN_ERROR;
-
- List params = new ArrayList();
- MD5 md = new MD5();
- params.add(new BasicNameValuePair("Opion", "SetParam"));
- params.add(new BasicNameValuePair("UserID", String.valueOf(Integer.parseInt(contactId)|0x80000000)));
- params.add(new BasicNameValuePair("SessionID", sessionId));
- params.add(new BasicNameValuePair("Email", email));
- params.add(new BasicNameValuePair("CountryCode", countryCode));
- params.add(new BasicNameValuePair("PhoneNO", phone));
-
- params.add(new BasicNameValuePair("UserPwd", md.getMD5ofStr(password)));
- params.add(new BasicNameValuePair("BindFlag", flag));
- params.add(new BasicNameValuePair("PhoneCheckCode", phoneCheckCode));
- try {
- JSONObject jObject = new JSONObject(
- doPost(params, ACCOUNT_INFO_URL));
- Log.e("my", jObject.toString());
- result = jObject.getInt("error_code");
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return result;
- }
-
- public int setBindDeviceAccount(String phone,String sessionId, String deviceId, String account,String flag,String name) {
- int result = UNKNOWN_ERROR;
-
- List params = new ArrayList();
- MD5 md = new MD5();
- params.add(new BasicNameValuePair("Account", phone));
- params.add(new BasicNameValuePair("SessionID", sessionId));
- params.add(new BasicNameValuePair("DevID", deviceId));
- params.add(new BasicNameValuePair("BindAccount", account));
- params.add(new BasicNameValuePair("Level", flag));
- params.add(new BasicNameValuePair("NickName", name));
- try {
- JSONObject jObject = new JSONObject(
- doPost(params, BIND_DEVICE_ACCOUNT));
- Log.e("my", jObject.toString());
- result = jObject.getInt("error_code");
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return result;
- }
-
- public int modifyNikeName(String phone,String sessionId, String deviceId, String name) {
- int result = UNKNOWN_ERROR;
-
- List params = new ArrayList();
- MD5 md = new MD5();
- params.add(new BasicNameValuePair("Account", phone));
- params.add(new BasicNameValuePair("SessionID", sessionId));
- params.add(new BasicNameValuePair("DevID", deviceId));
- params.add(new BasicNameValuePair("NickName", name));
- try {
- JSONObject jObject = new JSONObject(
- doPost(params, MODIFY_NIKE_NAME));
- Log.e("my", jObject.toString());
- result = jObject.getInt("error_code");
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return result;
- }
-
- public int deleteBindDeviceAccount(String phone,String sessionId, String deviceId, String account) {
- int result = UNKNOWN_ERROR;
-
- List params = new ArrayList();
- MD5 md = new MD5();
- params.add(new BasicNameValuePair("Account", phone));
- params.add(new BasicNameValuePair("SessionID", sessionId));
- params.add(new BasicNameValuePair("DevID", deviceId));
- params.add(new BasicNameValuePair("BindAccount", account));
- try {
- JSONObject jObject = new JSONObject(
- doPost(params, REMOVE_BIND_DEVICE_ACCOUNT));
- Log.e("my", jObject.toString());
- result = jObject.getInt("error_code");
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return result;
- }
-
- public JSONObject login(String username, String password) {
- if(MyUtils.isNumeric(username)){
- username = String.valueOf((Integer.parseInt(username)|0x80000000));
- }
- JSONObject jObject = null;
- List params = new ArrayList();
- MD5 md = new MD5();
- params.add(new BasicNameValuePair("User", username));
- params.add(new BasicNameValuePair("Pwd", md.getMD5ofStr(password)));
- params.add(new BasicNameValuePair("VersionFlag", "1"));
- params.add(new BasicNameValuePair("AppOS", "3"));
- params.add(new BasicNameValuePair("AppVersion", MyUtils
- .getBitProcessingVersion()));
- try {
- jObject = new JSONObject(doPost(params, LOGIN_URL));
- Log.e("my", jObject.toString());
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return jObject;
- }
- public JSONObject login(String username, String password,String sellerId) {
- if(MyUtils.isNumeric(username)){
- username = String.valueOf((Integer.parseInt(username)|0x80000000));
- }
- JSONObject jObject = null;
- List params = new ArrayList();
- MD5 md = new MD5();
- params.add(new BasicNameValuePair("User", username));
- params.add(new BasicNameValuePair("Pwd", md.getMD5ofStr(password)));
- params.add(new BasicNameValuePair("VersionFlag", "1"));
- params.add(new BasicNameValuePair("AppOS", "3"));
- params.add(new BasicNameValuePair("AppVersion", MyUtils
- .getBitProcessingVersion()));
- params.add(new BasicNameValuePair("StoreID",sellerId));
- try {
- jObject = new JSONObject(doPost(params, LOGIN_URL));
- Log.e("my", jObject.toString());
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return jObject;
- }
- public JSONObject getAlarmMessage(String username,String sessionId,int pageSize,int option){
- JSONObject jObject = null;
- List params = new ArrayList();
- params.add(new BasicNameValuePair("UserID", String.valueOf(Integer.parseInt(username)|0x80000000)));
- params.add(new BasicNameValuePair("SessionID", sessionId));
- params.add(new BasicNameValuePair("pageSize", String.valueOf(pageSize)));
- params.add(new BasicNameValuePair("Option", String.valueOf(option)));
- try {
- jObject = new JSONObject(doPost(params, ALARM_MSSAGE_URL));
- Log.e("my", jObject.toString());
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return jObject;
- }
- public int getPhoneCode(String CountryCode, String PhoneNO) {
- int result = UNKNOWN_ERROR;
-
- List params = new ArrayList();
- params.add(new BasicNameValuePair("CountryCode", CountryCode));
- params.add(new BasicNameValuePair("PhoneNO", PhoneNO));
- params.add(new BasicNameValuePair("AppVersion", MyUtils
- .getBitProcessingVersion()));
- try {
- JSONObject jObject = new JSONObject(doPost(params,
- GETPHONE_CODE_URL));
- Log.e("my", jObject.toString());
- result = jObject.getInt("error_code");
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return result;
-
- }
-
- public int verifyPhoneCode(String CountryCode, String PhoneNO,
- String VerifyCode) {
- int result = UNKNOWN_ERROR;
- List params = new ArrayList();
- params.add(new BasicNameValuePair("CountryCode", CountryCode));
- params.add(new BasicNameValuePair("PhoneNO", PhoneNO));
- params.add(new BasicNameValuePair("VerifyCode", VerifyCode));
- try {
- JSONObject jObject = new JSONObject(doPost(params, VERIFY_CODE_URL));
- Log.e("my", jObject.toString());
- result = jObject.getInt("error_code");
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return result;
- }
-
- public JSONObject register(String VersionFlag, String Email, String CountryCode,
- String PhoneNO, String password, String rePassword,
- String VerifyCode, String IgnoreSafeWarning) {
- JSONObject jObject = null;
- MD5 md = new MD5();
- List params = new ArrayList();
- params.add(new BasicNameValuePair("VersionFlag", VersionFlag));
- params.add(new BasicNameValuePair("Email", Email));
- params.add(new BasicNameValuePair("CountryCode", CountryCode));
- params.add(new BasicNameValuePair("PhoneNO", PhoneNO));
- params.add(new BasicNameValuePair("Pwd", md.getMD5ofStr(password)));
- params.add(new BasicNameValuePair("RePwd", md.getMD5ofStr(rePassword)));
- params.add(new BasicNameValuePair("VerifyCode", VerifyCode));
- params.add(new BasicNameValuePair("IgnoreSafeWarning",
- IgnoreSafeWarning));
-
- try {
- jObject = new JSONObject(doPost(params, REGISTER_URL));
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return jObject;
-
- }
-
- public int exit_application(String contactId, String sessionId) {
- int result = UNKNOWN_ERROR;
- List params = new ArrayList();
- params.add(new BasicNameValuePair("UserID", String.valueOf((Integer
- .parseInt(contactId) | 0x80000000))));
- params.add(new BasicNameValuePair("SessionID", sessionId));
- try {
- JSONObject jObject = new JSONObject(doPost(params,
- EXIT_APPLICATION_URL));
- result = jObject.getInt("error_code");
- Log.e("my", jObject.toString());
-
- } catch (Exception e) {
- e.printStackTrace();
- Log.e("my", "exit error");
- }
- return result;
- }
- public JSONObject getSystemMessage(String username,String sessionId,String SellerID,int PageSize,int Option){
- JSONObject jObject=null;
- List params = new ArrayList();
- params.add(new BasicNameValuePair("UserID", String.valueOf(Integer.parseInt(username)|0x80000000)));
- params.add(new BasicNameValuePair("SessionID", sessionId));
- params.add(new BasicNameValuePair("StoreID", SellerID));
- params.add(new BasicNameValuePair("Option", String.valueOf(Option)));
- params.add(new BasicNameValuePair("PageSize",String.valueOf(PageSize)));
- try {
- jObject=new JSONObject(doPost(params,SYSTEM_MESSAGE_URL));
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return jObject;
- }
- public JSONObject getSystemMessageByMsgId(String username,String sessionId,String SellerID,String MsgIndex,int PageSize,int Option){
- JSONObject jObject=null;
- List params = new ArrayList();
- params.add(new BasicNameValuePair("UserID", String.valueOf(Integer.parseInt(username)|0x80000000)));
- params.add(new BasicNameValuePair("SessionID", sessionId));
- params.add(new BasicNameValuePair("StoreID", SellerID));
- params.add(new BasicNameValuePair("Index", MsgIndex));
- params.add(new BasicNameValuePair("Option", String.valueOf(Option)));
- params.add(new BasicNameValuePair("PageSize",String.valueOf(PageSize)));
- try {
- jObject=new JSONObject(doPost(params,SYSTEM_MESSAGE_URL));
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return jObject;
- }
- public JSONObject getLogoStartInfo(String username,String sessionId,String SellerID){
- JSONObject jObject=null;
- List params = new ArrayList();
- params.add(new BasicNameValuePair("UserID", String.valueOf(Integer.parseInt(username)|0x80000000)));
- params.add(new BasicNameValuePair("SessionID", sessionId));
- params.add(new BasicNameValuePair("StoreID", SellerID));
- try {
- jObject=new JSONObject(doPost(params,LOGO_URL));
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return jObject;
- }
- public JSONObject getMallUrl(String username,String sessionId,String SellerID){
- JSONObject jObject=null;
- List params = new ArrayList();
- params.add(new BasicNameValuePair("UserID", String.valueOf(Integer.parseInt(username)|0x80000000)));
- params.add(new BasicNameValuePair("SessionID", sessionId));
- params.add(new BasicNameValuePair("StoreID", SellerID));
- try {
- jObject=new JSONObject(doPost(params,MALL_URL));
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return jObject;
- }
- public JSONObject setStoreId(String username,String sessionId,String SellerID){
- JSONObject jObject=null;
- List params = new ArrayList();
- params.add(new BasicNameValuePair("UserID", String.valueOf(Integer.parseInt(username)|0x80000000)));
- params.add(new BasicNameValuePair("SessionID", sessionId));
- params.add(new BasicNameValuePair("StoreID", SellerID));
- try {
- jObject=new JSONObject(doPost(params,STORE_ID_URL));
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return jObject;
- }
- public static RegisterResult createRegisterResult(
- JSONObject jObject) {
- RegisterResult result = null;
- result = new RegisterResult(jObject);
- return result;
- }
-
- public static GetAccountInfoResult createGetAccountInfoResult(
- JSONObject jObject) {
- GetAccountInfoResult result = null;
- result = new GetAccountInfoResult(jObject);
- return result;
- }
-
- public static ModifyLoginPasswordResult createModifyLoginPasswordResult(
- JSONObject jObject) {
- ModifyLoginPasswordResult result = null;
- result = new ModifyLoginPasswordResult(jObject);
- return result;
- }
-
- public static LoginResult createLoginResult(JSONObject jObject) {
- LoginResult result = null;
- result = new LoginResult(jObject);
- return result;
- }
- public static AlarmRecordResult getAlarmRecords(JSONObject jObject){
- AlarmRecordResult result=null;
- result=new AlarmRecordResult(jObject);
- return result;
- }
- public static GetDeviceListResult createGetDeviceListResult(JSONObject jObject) {
- GetDeviceListResult result = null;
- result = new GetDeviceListResult(jObject);
- return result;
- }
-
- public static GetBindDeviceAccountResult createGetBindDeviceAccountResult(JSONObject jObject) {
- GetBindDeviceAccountResult result = null;
- result = new GetBindDeviceAccountResult(jObject);
- return result;
- }
-
- public static GetAlarmRecordListResult createGetAlarmRecordListResult(JSONObject jObject) {
- GetAlarmRecordListResult result = null;
- result = new GetAlarmRecordListResult(jObject);
- return result;
- }
- public static SystemMessageResult GetSystemMessageResult(JSONObject jObject){
- SystemMessageResult result=null;
- result=new SystemMessageResult(jObject);
- return result;
- }
- public static GetStartInfoResult createGetStartInfoResult(JSONObject jObject){
- GetStartInfoResult result=null;
- result=new GetStartInfoResult(jObject);
- return result;
- }
- public static MallUrlResult getMallUrlResult(JSONObject jObject){
- MallUrlResult result=null;
- result=new MallUrlResult(jObject);
- return result;
- }
- public static SetStoreIdResult setStoreIdResult(JSONObject jObject){
- SetStoreIdResult result=null;
- result=new SetStoreIdResult(jObject);
- return result;
- }
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/network/RegisterResult.java b/p2PCore/src/main/java/com/p2p/core/network/RegisterResult.java
deleted file mode 100644
index bc49e01a5..000000000
--- a/p2PCore/src/main/java/com/p2p/core/network/RegisterResult.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.p2p.core.network;
-
-import org.json.JSONObject;
-
-import android.util.Log;
-
-import com.p2p.core.utils.MyUtils;
-
-public class RegisterResult {
- public String contactId;
- public String error_code;
- public RegisterResult(JSONObject json){
- init(json);
- }
- private void init(JSONObject json){
- try{
- error_code = json.getString("error_code");
- contactId = json.getString("UserID");
- }catch(Exception e){
- if(!MyUtils.isNumeric(error_code)){
- Log.e("my","RegisterResult json解析错误");
- error_code = String.valueOf(NetManager.JSON_PARSE_ERROR);
- }
- }
- }
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/network/SetStoreIdResult.java b/p2PCore/src/main/java/com/p2p/core/network/SetStoreIdResult.java
deleted file mode 100644
index 4ef36ecde..000000000
--- a/p2PCore/src/main/java/com/p2p/core/network/SetStoreIdResult.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.p2p.core.network;
-
-import org.json.JSONObject;
-
-import android.util.Log;
-
-import com.p2p.core.utils.MyUtils;
-
-public class SetStoreIdResult {
- public String error_code;
- public SetStoreIdResult(JSONObject json){
- innit(json);
- }
- public void innit(JSONObject json){
- try{
- error_code = json.getString("error_code");
- }catch(Exception e){
- if(!MyUtils.isNumeric(error_code)){
- Log.e("my","GetAccountInfoResult json解析错误");
- error_code = String.valueOf(NetManager.JSON_PARSE_ERROR);
- }
-
- }
- }
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/network/SystemMessageResult.java b/p2PCore/src/main/java/com/p2p/core/network/SystemMessageResult.java
deleted file mode 100644
index 8d199ad8e..000000000
--- a/p2PCore/src/main/java/com/p2p/core/network/SystemMessageResult.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package com.p2p.core.network;
-
-
-import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-
-import android.util.Log;
-
-import com.p2p.core.utils.MyUtils;
-
-public class SystemMessageResult implements Serializable {
- public String error_code;
- public String RecordCount;
- public String Surplus;
- public String RecommendFlag;
- public List systemMessages=new ArrayList();
- public SystemMessageResult(JSONObject json) {
- // TODO Auto-generated constructor stub
- init(json);
- }
- public void init(JSONObject json){
- try {
- error_code=json.getString("error_code");
- Log.e("error_code", "error_code="+error_code+"++++++++++++");
- RecordCount=json.getString("RecordCount");
- Surplus=json.getString("Surplus");
- RecommendFlag=json.getString("RecommendFlag");
- String RL=json.getString("RL");
- String [] list=RL.split(";");
- for(String mesg:list){
- if(mesg.equals("")){
- continue;
- }
- String [] data=mesg.split(",");
- SystemMessage s=new SystemMessage();
- s.msgId=data[0];
- s.title=data[1];
- s.content=data[2];
- s.picture_url=data[3];
- s.picture_in_url=data[4];
- String sTime=data[6];
- s.time=MyUtils.convertTimeStringToInterval(sTime);
- systemMessages.add(s);
- }
- } catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public static class SystemMessage implements Serializable,Comparable{
- public String msgId;
- public String title;
- public String content;
- public long time;
- public String picture_url;
- public String picture_in_url;
- @Override
- public int compareTo(Object arg0) {
- // TODO Auto-generated method stub
- SystemMessage o=(SystemMessage) arg0;
- if(this.time>o.time){
- return -1;
- }else if(this.time>> (32 - s));
- a += b;
- return a;
- }
-
- private long GG(long a, long b, long c, long d, long x, long s,
- long ac) {
- a += G (b, c, d) + x + ac;
- a = ((int) a << s) | ((int) a >>> (32 - s));
- a += b;
- return a;
- }
- private long HH(long a, long b, long c, long d, long x, long s,
- long ac) {
- a += H (b, c, d) + x + ac;
- a = ((int) a << s) | ((int) a >>> (32 - s));
- a += b;
- return a;
- }
- private long II(long a, long b, long c, long d, long x, long s,
- long ac) {
- a += I (b, c, d) + x + ac;
- a = ((int) a << s) | ((int) a >>> (32 - s));
- a += b;
- return a;
- }
- /*
- md5Update��MD5���������̣�inbuf��Ҫ�任���ֽڴ���inputlen�dz��ȣ����
- ������getMD5ofStr���ã�����֮ǰ��Ҫ����md5init����˰�����Ƴ�private��
- */
- private void md5Update(byte[] inbuf, int inputLen) {
-
- int i, index, partLen;
- byte[] block = new byte[64];
- index = (int)(count[0] >>> 3) & 0x3F;
- // /* Update number of bits */
- if ((count[0] += (inputLen << 3)) < (inputLen << 3))
- count[1]++;
- count[1] += (inputLen >>> 29);
-
- partLen = 64 - index;
-
- // Transform as many times as possible.
- if (inputLen >= partLen) {
- md5Memcpy(buffer, inbuf, index, 0, partLen);
- md5Transform(buffer);
-
- for (i = partLen; i + 63 < inputLen; i += 64) {
-
- md5Memcpy(block, inbuf, 0, i, 64);
- md5Transform (block);
- }
- index = 0;
-
- } else
-
- i = 0;
-
- ///* Buffer remaining input */
- md5Memcpy(buffer, inbuf, index, i, inputLen - i);
-
- }
-
- /*
- md5Final������������
- */
- private void md5Final () {
- byte[] bits = new byte[8];
- int index, padLen;
-
- ///* Save number of bits */
- Encode (bits, count, 8);
-
- ///* Pad out to 56 mod 64.
- index = (int)(count[0] >>> 3) & 0x3f;
- padLen = (index < 56) ? (56 - index) : (120 - index);
- md5Update (PADDING, padLen);
-
- ///* Append length (before padding) */
- md5Update(bits, 8);
-
- ///* Store state in digest */
- Encode (digest, state, 16);
-
- }
-
- /* md5Memcpy��һ���ڲ�ʹ�õ�byte����Ŀ鿽�������input��inpos��ʼ��len���ȵ�
-���������� �ֽڿ�����output��outposλ�ÿ�ʼ
- */
-
- private void md5Memcpy (byte[] output, byte[] input,
- int outpos, int inpos, int len)
- {
- int i;
-
- for (i = 0; i < len; i++)
- output[outpos + i] = input[inpos + i];
- }
-
- /*
- md5Transform��MD5���ı任������md5Update���ã�block�Ƿֿ��ԭʼ�ֽ�
- */
- private void md5Transform (byte block[]) {
- long a = state[0], b = state[1], c = state[2], d = state[3];
- long[] x = new long[16];
-
- Decode (x, block, 64);
-
- /* Round 1 */
- a = FF (a, b, c, d, x[0], S11, 0xd76aa478L); /* 1 */
- d = FF (d, a, b, c, x[1], S12, 0xe8c7b756L); /* 2 */
- c = FF (c, d, a, b, x[2], S13, 0x242070dbL); /* 3 */
- b = FF (b, c, d, a, x[3], S14, 0xc1bdceeeL); /* 4 */
- a = FF (a, b, c, d, x[4], S11, 0xf57c0fafL); /* 5 */
- d = FF (d, a, b, c, x[5], S12, 0x4787c62aL); /* 6 */
- c = FF (c, d, a, b, x[6], S13, 0xa8304613L); /* 7 */
- b = FF (b, c, d, a, x[7], S14, 0xfd469501L); /* 8 */
- a = FF (a, b, c, d, x[8], S11, 0x698098d8L); /* 9 */
- d = FF (d, a, b, c, x[9], S12, 0x8b44f7afL); /* 10 */
- c = FF (c, d, a, b, x[10], S13, 0xffff5bb1L); /* 11 */
- b = FF (b, c, d, a, x[11], S14, 0x895cd7beL); /* 12 */
- a = FF (a, b, c, d, x[12], S11, 0x6b901122L); /* 13 */
- d = FF (d, a, b, c, x[13], S12, 0xfd987193L); /* 14 */
- c = FF (c, d, a, b, x[14], S13, 0xa679438eL); /* 15 */
- b = FF (b, c, d, a, x[15], S14, 0x49b40821L); /* 16 */
-
- /* Round 2 */
- a = GG (a, b, c, d, x[1], S21, 0xf61e2562L); /* 17 */
- d = GG (d, a, b, c, x[6], S22, 0xc040b340L); /* 18 */
- c = GG (c, d, a, b, x[11], S23, 0x265e5a51L); /* 19 */
- b = GG (b, c, d, a, x[0], S24, 0xe9b6c7aaL); /* 20 */
- a = GG (a, b, c, d, x[5], S21, 0xd62f105dL); /* 21 */
- d = GG (d, a, b, c, x[10], S22, 0x2441453L); /* 22 */
- c = GG (c, d, a, b, x[15], S23, 0xd8a1e681L); /* 23 */
- b = GG (b, c, d, a, x[4], S24, 0xe7d3fbc8L); /* 24 */
- a = GG (a, b, c, d, x[9], S21, 0x21e1cde6L); /* 25 */
- d = GG (d, a, b, c, x[14], S22, 0xc33707d6L); /* 26 */
- c = GG (c, d, a, b, x[3], S23, 0xf4d50d87L); /* 27 */
- b = GG (b, c, d, a, x[8], S24, 0x455a14edL); /* 28 */
- a = GG (a, b, c, d, x[13], S21, 0xa9e3e905L); /* 29 */
- d = GG (d, a, b, c, x[2], S22, 0xfcefa3f8L); /* 30 */
- c = GG (c, d, a, b, x[7], S23, 0x676f02d9L); /* 31 */
- b = GG (b, c, d, a, x[12], S24, 0x8d2a4c8aL); /* 32 */
-
- /* Round 3 */
- a = HH (a, b, c, d, x[5], S31, 0xfffa3942L); /* 33 */
- d = HH (d, a, b, c, x[8], S32, 0x8771f681L); /* 34 */
- c = HH (c, d, a, b, x[11], S33, 0x6d9d6122L); /* 35 */
- b = HH (b, c, d, a, x[14], S34, 0xfde5380cL); /* 36 */
- a = HH (a, b, c, d, x[1], S31, 0xa4beea44L); /* 37 */
- d = HH (d, a, b, c, x[4], S32, 0x4bdecfa9L); /* 38 */
- c = HH (c, d, a, b, x[7], S33, 0xf6bb4b60L); /* 39 */
- b = HH (b, c, d, a, x[10], S34, 0xbebfbc70L); /* 40 */
- a = HH (a, b, c, d, x[13], S31, 0x289b7ec6L); /* 41 */
- d = HH (d, a, b, c, x[0], S32, 0xeaa127faL); /* 42 */
- c = HH (c, d, a, b, x[3], S33, 0xd4ef3085L); /* 43 */
- b = HH (b, c, d, a, x[6], S34, 0x4881d05L); /* 44 */
- a = HH (a, b, c, d, x[9], S31, 0xd9d4d039L); /* 45 */
- d = HH (d, a, b, c, x[12], S32, 0xe6db99e5L); /* 46 */
- c = HH (c, d, a, b, x[15], S33, 0x1fa27cf8L); /* 47 */
- b = HH (b, c, d, a, x[2], S34, 0xc4ac5665L); /* 48 */
-
- /* Round 4 */
- a = II (a, b, c, d, x[0], S41, 0xf4292244L); /* 49 */
- d = II (d, a, b, c, x[7], S42, 0x432aff97L); /* 50 */
- c = II (c, d, a, b, x[14], S43, 0xab9423a7L); /* 51 */
- b = II (b, c, d, a, x[5], S44, 0xfc93a039L); /* 52 */
- a = II (a, b, c, d, x[12], S41, 0x655b59c3L); /* 53 */
- d = II (d, a, b, c, x[3], S42, 0x8f0ccc92L); /* 54 */
- c = II (c, d, a, b, x[10], S43, 0xffeff47dL); /* 55 */
- b = II (b, c, d, a, x[1], S44, 0x85845dd1L); /* 56 */
- a = II (a, b, c, d, x[8], S41, 0x6fa87e4fL); /* 57 */
- d = II (d, a, b, c, x[15], S42, 0xfe2ce6e0L); /* 58 */
- c = II (c, d, a, b, x[6], S43, 0xa3014314L); /* 59 */
- b = II (b, c, d, a, x[13], S44, 0x4e0811a1L); /* 60 */
- a = II (a, b, c, d, x[4], S41, 0xf7537e82L); /* 61 */
- d = II (d, a, b, c, x[11], S42, 0xbd3af235L); /* 62 */
- c = II (c, d, a, b, x[2], S43, 0x2ad7d2bbL); /* 63 */
- b = II (b, c, d, a, x[9], S44, 0xeb86d391L); /* 64 */
-
- state[0] += a;
- state[1] += b;
- state[2] += c;
- state[3] += d;
-
- }
-
- /*Encode��long���鰴˳����byte���飬��Ϊjava��long������64bit�ģ�
- ֻ���32bit������ӦԭʼCʵ�ֵ���;
- */
- private void Encode (byte[] output, long[] input, int len) {
- int i, j;
-
- for (i = 0, j = 0; j < len; i++, j += 4) {
- output[j] = (byte)(input[i] & 0xffL);
- output[j + 1] = (byte)((input[i] >>> 8) & 0xffL);
- output[j + 2] = (byte)((input[i] >>> 16) & 0xffL);
- output[j + 3] = (byte)((input[i] >>> 24) & 0xffL);
- }
- }
-
- /*Decode��byte���鰴˳��ϳɳ�long���飬��Ϊjava��long������64bit�ģ�
- ֻ�ϳɵ�32bit����32bit���㣬����ӦԭʼCʵ�ֵ���;
- */
- private void Decode (long[] output, byte[] input, int len) {
- int i, j;
-
-
- for (i = 0, j = 0; j < len; i++, j += 4)
- output[i] = b2iu(input[j]) |
- (b2iu(input[j + 1]) << 8) |
- (b2iu(input[j + 2]) << 16) |
- (b2iu(input[j + 3]) << 24);
-
- return;
- }
-
- /*
- b2iu����д��һ����byte���ղ�������ŵ�ԭ��ģ���λ��������Ϊjavaû��unsigned����
- */
- public static long b2iu(byte b) {
- return b < 0 ? b & 0x7F + 128 : b;
- }
-
- /*byteHEX()��������һ��byte���͵���ת����ʮ����Ƶ�ASCII��ʾ��
- ����Ϊjava�е�byte��toString��ʵ����һ�㣬������û��C�����е�
- sprintf(outbuf,"%02X",ib)
- */
- public static String byteHEX(byte ib) {
- char[] Digit = { '0','1','2','3','4','5','6','7','8','9',
- 'A','B','C','D','E','F' };
- char [] ob = new char[2];
- ob[0] = Digit[(ib >>> 4) & 0X0F];
- ob[1] = Digit[ib & 0X0F];
- String s = new String(ob);
- return s;
- }
-}
\ No newline at end of file
diff --git a/p2PCore/src/main/java/com/p2p/core/utils/MyUtils.java b/p2PCore/src/main/java/com/p2p/core/utils/MyUtils.java
deleted file mode 100644
index 6b48f4832..000000000
--- a/p2PCore/src/main/java/com/p2p/core/utils/MyUtils.java
+++ /dev/null
@@ -1,288 +0,0 @@
-package com.p2p.core.utils;
-
-import android.content.Context;
-import android.os.Build;
-import android.util.Log;
-
-import com.p2p.core.global.Config;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import java.io.InputStream;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.regex.Pattern;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-public class MyUtils {
- /*
- * 是否是纯数字字串
- */
- public static boolean isNumeric(String str) {
- if (null == str) {
- return false;
- }
- Pattern pattern = Pattern.compile("[0-9]*");
- return pattern.matcher(str).matches();
- }
-
- /*
- * 获取CPU版本
- */
- public static int getCPUVesion() {
- int version = 0;
- String verString = Build.CPU_ABI;
- Log.i("cpuversion", "verString" + verString);
- try {
- String ver = verString.substring(9, 10);
- if (isNumeric(ver)) {
- version = Integer.parseInt(ver);
- Log.i("cpuversion", "version" + version);
- }
- } catch (Exception e) {
- }
- return version;
- }
-
- public static boolean isZh(Context context) {
- Locale locale = context.getResources().getConfiguration().locale;
- String language = locale.getLanguage();
- if (language.endsWith("zh"))
- return true;
- else
- return false;
- }
-
- public static String convertPlanTime(int time) {
- int minute_to = (time & 0xff);
- int minute_from = ((time >> 8) & 0xff);
- int hour_to = ((time >> 16) & 0xff);
- int hour_from = ((time >> 24) & 0xff);
- StringBuilder sb = new StringBuilder();
- if (hour_from < 10) {
- sb.append("0" + hour_from + ":");
- } else {
- sb.append(hour_from + ":");
- }
- if (minute_from < 10) {
- sb.append("0" + minute_from + "-");
- } else {
- sb.append(minute_from + "-");
- }
-
- if (hour_to < 10) {
- sb.append("0" + hour_to + ":");
- } else {
- sb.append(hour_to + ":");
- }
-
- if (minute_to < 10) {
- sb.append("0" + minute_to);
- } else {
- sb.append("" + minute_to);
- }
- return sb.toString();
- }
-
- public static int convertPlanTime(String time) {
- int iRet = 0;
- try {
- String[] times = time.split("-");
- String[] time_from = times[0].split(":");
- String[] time_to = times[1].split(":");
-
- iRet = ((Integer.parseInt(time_from[0]) << 24)
- | (Integer.parseInt(time_to[0]) << 16)
- | (Integer.parseInt(time_from[1]) << 8) | (Integer
- .parseInt(time_to[1]) << 0));
- return iRet;
- } catch (Exception e) {
- return iRet;
- }
-
- }
-
- public static int dip2px(Context context, int dipValue) {
- final float scale = context.getResources().getDisplayMetrics().density;
- return (int) (dipValue * scale + 0.5f);
- }
-
- public static String convertDeviceTime(int iTime) {
- int year = (2000 + ((iTime >> 24)));
- int month = (iTime >> 18) & 0x3f;
- int day = (iTime >> 12) & 0x3f;
- int hour = (iTime >> 6) & 0x3f;
- int minute = (iTime >> 0) & 0x3f;
-
- StringBuilder sb = new StringBuilder();
- sb.append(year + "-");
-
- if (month < 10) {
- sb.append("0" + month + "-");
- } else {
- sb.append(month + "-");
- }
-
- if (day < 10) {
- sb.append("0" + day + " ");
- } else {
- sb.append(day + " ");
- }
-
- if (hour < 10) {
- sb.append("0" + hour + ":");
- } else {
- sb.append(hour + ":");
- }
-
- if (minute < 10) {
- sb.append("0" + minute);
- } else {
- sb.append("" + minute);
- }
- return sb.toString();
- }
-
- public static String getBitProcessingVersion() {
- try {
- String[] parseVerson = getVersion().split("\\.");
- int a = Integer.parseInt(parseVerson[0]) << 24;
- int b = Integer.parseInt(parseVerson[1]) << 16;
- int c = Integer.parseInt(parseVerson[2]) << 8;
- int d = Integer.parseInt(parseVerson[3]);
- return String.valueOf((a | b | c | d));
- } catch (Exception e) {
- return "9999";
- }
- }
-
- public static String getVersion() {
- String version = "";
- InputStream input = MyUtils.class.getClassLoader().getResourceAsStream(
- "version.xml");
- try {
- HashMap data = parseXml(input);
- // 获取当前版本信息
- version = data.get("version");
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- if (version.equals("")) {
- return Config.AppConfig.VERSION;
- }
- return version;
- }
-
- public static long convertTimeStringToInterval(String time) {
- long interval = 0;
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
- Date d;
- try {
-
- d = sdf.parse(time);
- interval = d.getTime();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return interval;
- }
-
- /*
- * 读取version.xml版本信息
- */
- private static HashMap parseXml(InputStream input)
- throws Exception {
- HashMap hashMap = new HashMap();
-
- // 实例化一个文档构建器工厂
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- // 通过文档构建器工厂获取一个文档构建器
- DocumentBuilder builder = factory.newDocumentBuilder();
- // 通过文档通过文档构建器构建一个文档实例
- Document document = builder.parse(input);
- // 获取XML文件根节点
- Element root = document.getDocumentElement();
- // 获得所有子节点
- NodeList childNodes = root.getChildNodes();
- for (int j = 0; j < childNodes.getLength(); j++) {
- // 遍历子节点
- Node childNode = (Node) childNodes.item(j);
- if (childNode.getNodeType() == Node.ELEMENT_NODE) {
- Element childElement = (Element) childNode;
- // 版本号
- if ("version".equals(childElement.getNodeName())) {
- hashMap.put("version", childElement.getFirstChild()
- .getNodeValue());
- }
- }
- }
- return hashMap;
- }
-
- /**
- * 将int数值转换为占四个字节的byte数组,本方法适用于(高位在前,低位在后)的顺序
- */
- public static byte[] intToBytes2(int value) {
- byte[] src = new byte[4];
- src[3] = (byte) (value & 0xFF);
- src[2] = (byte) ((value >> 8) & 0xFF);
- src[1] = (byte) ((value >> 16) & 0xFF);
- src[0] = (byte) ((value >> 24) & 0xFF);
-
- return src;
- }
-
- public static byte[] btop = { (byte) 130, 1, 7, 0, (byte) 0xff, 0x01, 0x00,
- 0x08, 0x00, (byte) 0xff, 0x08 };// 上
- public static byte[] bbottom = { (byte) 130, 1, 7, 0, (byte) 0xff, 0x01,
- 0x00, 0x10, 0x00, (byte) 0xff, 0x10 };// 下
- public static byte[] bleft = { (byte) 130, 1, 7, 0, (byte) 0xff, 0x01,
- 0x00, 0x04, (byte) 0xff, 0x00, 0x04 };// 左
- public static byte[] bright = { (byte) 130, 1, 7, 0, (byte) 0xff, 0x01,
- 0x00, 0x02, (byte) 0xff, 0x00, 0x02, };// 右
-
- public static byte[] zoom_small = { (byte) 130, 1, 7, 0, (byte) 0xff, 0x01,
- 0x00, 0x20, 0x00, 0x00, 0x21 };// 变倍短
- public static byte[] zoom_big = { (byte) 130, 1, 7, 0, (byte) 0xff, 0x01,
- 0x00, 0x40, 0x00, 0x00, 0x41 };// 变倍长
- public static byte[] focus_small = { (byte) 130, 1, 7, 0, (byte) 0xff,
- 0x01, 0x00, (byte) 0x80, 0x00, 0x00, (byte) 0x81 };// 聚焦近
- public static byte[] focus_big = { (byte) 130, 1, 7, 0, (byte) 0xff, 0x01,
- 0x01, 0x00, 0x00, 0x00, 0x02 };// 聚焦远
- public static byte[] aperture_smal = { (byte) 130, 1, 7, 0, (byte) 0xff,
- 0x01, 0x02, 0x00, 0x00, 0x00, 0x03 };// 光圈小
- public static byte[] aperture_big = { (byte) 130, 1, 7, 0, (byte) 0xff,
- 0x01, 0x04, 0x00, 0x00, 0x00, 0x05 };// 光圈大
-
- public static int bytesToInt(byte[] src, int offset) {
- int value;
- value = (int) ((src[offset] & 0xFF) | ((src[offset + 1] & 0xFF) << 8)
- | ((src[offset + 2] & 0xFF) << 16) | ((src[offset + 3] & 0xFF) << 24));
- return value;
- }
- /**
- * 临时格式化数字
- * @param src
- * @param len
- * @return
- */
- public static String compleInteger(int src, int len) {
-
- if (src < 10) {
- return "0" + src;
- } else {
- return String.valueOf(src);
- }
-
- }
-
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/utils/OnHomePressedListener.java b/p2PCore/src/main/java/com/p2p/core/utils/OnHomePressedListener.java
deleted file mode 100644
index 6718ebea9..000000000
--- a/p2PCore/src/main/java/com/p2p/core/utils/OnHomePressedListener.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.p2p.core.utils;
-
-public interface OnHomePressedListener {
- public void onHomePressed();
-
- public void onHomeLongPressed();
-}
diff --git a/p2PCore/src/main/java/com/p2p/core/utils/RtspThread.java b/p2PCore/src/main/java/com/p2p/core/utils/RtspThread.java
deleted file mode 100644
index 22d6c0930..000000000
--- a/p2PCore/src/main/java/com/p2p/core/utils/RtspThread.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package com.p2p.core.utils;
-
-import android.os.Handler;
-
-import com.p2p.core.MediaPlayer;
-import com.p2p.core.global.Config.AppConfig;
-
-import java.io.UnsupportedEncodingException;
-
-/**
- * Created by dxs on 2015/10/9.
- */
-public class RtspThread extends Thread {
- private String ipAddress;
- private Handler rtspHandler;
- private long id;
- private String password;
- private boolean isOutCall;
- private int callType;
- private String callId;
- private String ipFlag;
- private String pushMes;
- private int connectTime=3;
- private int VideoMode;
- private long HeaderID;//头像图片使用的标记ID,一般与设备ID相同
-
- public RtspThread(String ipAddress, Handler rtspHandler, String contactId, String password, boolean isOutCall, int callType, String callId, String ipFlag, String pushMes,int VideoMode,String HeaderID) {
- this.ipAddress = ipAddress;
- this.rtspHandler = rtspHandler;
- this.password = password;
- this.isOutCall = isOutCall;
- this.callType = callType;
- this.callId = callId;
- this.ipFlag = ipFlag;
- this.pushMes = pushMes;
- this.VideoMode=VideoMode;
- this.HeaderID=Long.parseLong(HeaderID);
-
- this.id = Long.parseLong(callId);
- if (callId.charAt(0) == '0') {
- this.id = 0 - id;
- }
- connectTime=3;
- }
-
- @Override
- public void run() {
-
- int ret= 0;
- try {
- ret = MediaPlayer.getInstance().native_p2p_call(id, callType, 0, -1, VideoMode,new byte[8], pushMes.getBytes("utf-8"), ipAddress,HeaderID);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
-// ret=MediaPlayer.getInstance().native_rtsp_call(id,ipAddress);
-// while(connectTime>0) {
-// if (ret != 0) {
-// break;
-// } else {
-// try {
-// Log.e("error","rtsp第"+connectTime+"次连接");
-// ret = MediaPlayer.getInstance().native_p2p_call(id, callType, Integer.parseInt(password), -1, new byte[8], pushMes.getBytes("utf-8"), ipAddress);
-// } catch (UnsupportedEncodingException e) {
-// e.printStackTrace();
-// }
-//
-// try {
-// sleep(1000);
-// } catch (InterruptedException e) {
-// e.printStackTrace();
-// }
-// }
-// connectTime--;
-// }
- if(ret==0){
- rtspHandler.sendEmptyMessage(0);
- }else{
- rtspHandler.sendEmptyMessage(1);
- }
-
-
- }
-}
diff --git a/p2PCore/src/main/java/com/p2p/shake/ShakeData.java b/p2PCore/src/main/java/com/p2p/shake/ShakeData.java
deleted file mode 100644
index 1da16aa13..000000000
--- a/p2PCore/src/main/java/com/p2p/shake/ShakeData.java
+++ /dev/null
@@ -1,226 +0,0 @@
-package com.p2p.shake;
-
-import android.R.array;
-import android.util.Log;
-
-import com.p2p.core.global.Config;
-
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-
-public class ShakeData {
- public static class Cmd {
- public static final int GET_DEVICE_LIST = 1;
- public static final int RECEIVE_DEVICE_LIST = 2;
- public static final int NO_ASSOCIATED_DATA_PACKET = 9999;
-
- public static int[] getCmds() {
- return new int[] { 1, 2 };
- }
- }
-
- public static final int DEFAULT_LEFT_LENGTH = 28;
- public static final int DEFAULT_RIGHT_COUNT = 0;
- public static final int DEFAULT_STRING_PARAMETER_LENGTH = 64;
- public static int[] iCustomer = Config.AppConfig.CustomerIDs;
- // left 512 data
- private int cmd;
- private int error_code;
- private int leftlength;
- private int rightCount;
- private int id;
- private int type;
- private int flag;
-
- // right 512 data
- private String name;
-
- public static byte[] getBytes(ShakeData data) {
- if (data.getLeftlength() == 0) {
- data.setLeftlength(DEFAULT_LEFT_LENGTH);
- }
-
- if (data.getRightCount() == 0) {
- data.setRightCount(DEFAULT_RIGHT_COUNT);
- }
-
- byte[] bytes;
- ByteBuffer buffer = ByteBuffer.allocate(1024);
- buffer.putInt(data.getCmd());
- buffer.putInt(data.getError_code());
- buffer.putInt(data.getLeftlength());
- buffer.putInt(data.getRightCount());
- buffer.putInt(data.getId());
- buffer.putInt(data.getType());
- buffer.putInt(data.getFlag());
-
- // putString(buffer,data.getName(),0);
-
- bytes = buffer.array();
- buffer.clear();
- return bytes;
- }
-
- public static ShakeData getShakeData(ByteBuffer buffer) {
- ShakeData data = new ShakeData();
- try {
- boolean isTrue = false;
- for (Integer cmd : Cmd.getCmds()) {
- if (buffer.getInt(0) == cmd) {
- isTrue = true;
- break;
- }
- }
-
- if (!isTrue) {
- throw new Exception();
- }
-
- data.setCmd(buffer.getInt(0));
- data.setError_code(buffer.getInt(4));
- data.setLeftlength(buffer.getInt(8));
- data.setRightCount(buffer.getInt(12));
- data.setId(buffer.getInt(16));
- data.setType(buffer.getInt(20));
- data.setFlag(buffer.getInt(24));
-
-// boolean isCustomID = false;
-// for (int i = 0; i < iCustomer.length; i++) {
-// int customerID = iCustomer[i];
-// if (customerID != 0) {
-// if ((buffer.getInt(12) & 0x01) != 0
-// && buffer.getInt(17 * 4) == customerID) {
-// isCustomID = true;
-// }
-// } else {
-// isCustomID = true;
-// }
-// }
-// if (!isCustomID) {
-// data.setCmd(Cmd.NO_ASSOCIATED_DATA_PACKET);
-// }
- boolean isCustomID=false;
- for(int i=0;i= (DEFAULT_STRING_PARAMETER_LENGTH - 1)) {
- break;
- }
- buffer.put((position + i), bytes[i]);
- }
-
- buffer.put((index + DEFAULT_STRING_PARAMETER_LENGTH), (byte) 0);
- return index + DEFAULT_STRING_PARAMETER_LENGTH;
- }
-
- public static String getString(ByteBuffer buffer, int index) {
- String data = "";
- byte[] bytes = buffer.array();
- int position = 512 + index * DEFAULT_STRING_PARAMETER_LENGTH;
- for (int i = 0; i < DEFAULT_STRING_PARAMETER_LENGTH; i++) {
- if (bytes[position + i] == 0) {
- System.out.println(position + ":" + (position + i));
- data = new String(bytes, position, i);
- break;
- }
- }
- return data;
- }
-
- public int getCmd() {
- return cmd;
- }
-
- public void setCmd(int cmd) {
- this.cmd = cmd;
- }
-
- public int getLeftlength() {
- return leftlength;
- }
-
- public void setLeftlength(int leftlength) {
- this.leftlength = leftlength;
- }
-
- public int getRightCount() {
- return rightCount;
- }
-
- public void setRightCount(int rightCount) {
- this.rightCount = rightCount;
- }
-
- public int getError_code() {
- return error_code;
- }
-
- public void setError_code(int error_code) {
- this.error_code = error_code;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getType() {
- return type;
- }
-
- public void setType(int type) {
- this.type = type;
- }
-
- public int getFlag() {
- return flag;
- }
-
- public void setFlag(int flag) {
- this.flag = flag;
- }
-
-}
diff --git a/p2PCore/src/main/java/com/p2p/shake/ShakeManager.java b/p2PCore/src/main/java/com/p2p/shake/ShakeManager.java
deleted file mode 100644
index 309bf3d0f..000000000
--- a/p2PCore/src/main/java/com/p2p/shake/ShakeManager.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package com.p2p.shake;
-
-import java.net.InetAddress;
-
-import android.os.Handler;
-
-public class ShakeManager {
- public static final int HANDLE_ID_SEARCH_END = 0x11;
- public static final int HANDLE_ID_RECEIVE_DEVICE_INFO = 0x12;
- public static final int HANDLE_ID_APDEVICE_END = 0x13;
- public static final int HANDLE_ID_ONEAPDEVICE = 0x14;
-
- private static ShakeManager manager = null;
- private ShakeThread shakeThread;
- private ShakeManager(){};
- private long searchTime = 10000;
- private InetAddress host;
- public synchronized static ShakeManager getInstance(){
- if(null==manager){
- synchronized(ShakeManager.class){
- manager = new ShakeManager();
- }
- }
- return manager;
- }
-
- public Handler handler;
-
- public void setHandler(Handler handler){
- this.handler = handler;
- }
-
- public void setSearchTime(long time){
- this.searchTime = time;
- }
-
- public void setInetAddress(InetAddress host){
- this.host = host;
- }
-
- public boolean shaking(){
- if(null==shakeThread){
- shakeThread = new ShakeThread(handler);
- shakeThread.setHandler(handler);
- shakeThread.setSearchTime(searchTime);
- shakeThread.setInetAddress(host);
- shakeThread.start();
- return true;
- }else{
- return false;
- }
- }
-
- public void stopShaking(){
- if(null!=shakeThread){
- shakeThread.killThread();
- shakeThread = null;
- }
- }
-
- public boolean isShaking(){
- if(null!=shakeThread){
- return true;
- }else{
- return false;
- }
- }
-
-}
diff --git a/p2PCore/src/main/java/com/p2p/shake/ShakeThread.java b/p2PCore/src/main/java/com/p2p/shake/ShakeThread.java
deleted file mode 100644
index d50f49247..000000000
--- a/p2PCore/src/main/java/com/p2p/shake/ShakeThread.java
+++ /dev/null
@@ -1,244 +0,0 @@
-package com.p2p.shake;
-
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.util.Log;
-
-import java.io.IOException;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.nio.ByteBuffer;
-import java.nio.channels.DatagramChannel;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.Selector;
-import java.util.Set;
-
-public class ShakeThread extends Thread {
- public static final int DEFAULT_PORT = 8899;
- public static final int RECEIVE_IPC_INFO = 0;
- public static final int CLOSE_SERVER = 999;
- public int SEND_TIMES;
-
- private int port;
- private boolean isRun;
-
- private DatagramSocket server;
- private DatagramSocket broadcast;
- private Selector selector;
- private DatagramChannel channel;
- private Handler handler;
-
- private InetAddress host;
- public ShakeThread(Handler handler) {
- this.port = DEFAULT_PORT;
- this.SEND_TIMES = 10;
- }
-
- public void setSearchTime(long time) {
- SEND_TIMES = (int) (time / 1000);
- }
-
- public void setInetAddress(InetAddress host) {
- this.host = host;
- }
-
- public void setHandler(Handler handler) {
- this.handler = handler;
- }
-
- @Override
- public void run() {
- isRun = true;
- try {
- selector = Selector.open();
- channel = DatagramChannel.open();
- channel.configureBlocking(false);
- server = channel.socket();
- server.bind(new InetSocketAddress(port));
- channel.register(selector, SelectionKey.OP_READ);
-
- ByteBuffer receiveBuffer = ByteBuffer.allocate(1024);
-
- new Thread() {
- @Override
- public void run() {
- try {
- int times = 0;
- broadcast = new DatagramSocket();
- broadcast.setBroadcast(true);
- while (times < SEND_TIMES) {
- if (!isRun) {
- return;
- }
- times++;
- Log.e("my", "shake thread send broadcast.");
-
- ShakeData data = new ShakeData();
- data.setCmd(ShakeData.Cmd.GET_DEVICE_LIST);
- // data.setName("hello");
- // data.setLeftlength(ShakeData.DEFAULT_LEFT_LENGTH);
- // data.setRightlength(0);
- // data.setError_code(0);
- // data.setFlag(1);
- // data.setId(11126);
-
- // data.setType(1);
- // Log.e("my","************************************");
- // byte[] b = ShakeData.getBytes(data);
- // int m = 0;
- // String mmm = "";
- // for(int i=512;i 0) {
- Set keys = selector.selectedKeys();
- for (SelectionKey key : keys) {
- keys.remove(key);
- if (key.isReadable()) {
- DatagramChannel dc = (DatagramChannel) key.channel();
- InetSocketAddress client = (InetSocketAddress) dc.receive(receiveBuffer);
- key.interestOps(SelectionKey.OP_READ);
- receiveBuffer.flip();
- // Log.e("my",client.getAddress().toString());
- // if(!client.getAddress().toString().equals("/192.168.1.87")){
- // Log.e("my","************************************");
- // byte[] b = receiveBuffer.array();
- // int m = 0;
- // String mmm = "";
- // for(int i=0;i