摄像头

This commit is contained in:
Long-PC\Long
2019-07-18 21:10:29 +08:00
parent 4de0e77972
commit 656790e86b
107 changed files with 852 additions and 10414 deletions
-9
View File
@@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="EMTMF_0101_1608016">
<CLASSES>
<root url="jar://$PROJECT_DIR$/iFish7/libs/EMTMF_0101_1608016.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
+13
View File
@@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="SoundWaveSender-v2.0.2">
<CLASSES>
<root url="file://$USER_HOME$/.android/build-cache/4050fe18f111fa218f0b47e060f233fd501763d4/output/res" />
<root url="jar://$USER_HOME$/.android/build-cache/4050fe18f111fa218f0b47e060f233fd501763d4/output/jars/classes.jar!/" />
<root url="jar://$USER_HOME$/.android/build-cache/4050fe18f111fa218f0b47e060f233fd501763d4/output/jars/libs/EMTMFSDK_0101_160914.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.github.jwkj/SoundWaveSender/v2.0.2/e5510e3e5052a1eed8a3f3b182e09e8368e9fd2f/SoundWaveSender-v2.0.2-sources.jar!/" />
</SOURCES>
</library>
</component>
-9
View File
@@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="alicloud-android-ut-5.4.0">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.aliyun.ams/alicloud-android-ut/5.4.0/d0dc04a92cf401c8d222195cee892d6bafe15314/alicloud-android-ut-5.4.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
+9
View File
@@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="alicloud-android-ut-5.4.1">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.aliyun.ams/alicloud-android-ut/5.4.1/fb4feeb72d291cd71a404b9a72dd6895af6cbed8/alicloud-android-ut-5.4.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
+11
View File
@@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="converter-gson-2.0.0">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.retrofit2/converter-gson/2.0.0/49eb3ad545e7701234e4dd83db8dc1344b577f23/converter-gson-2.0.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.retrofit2/converter-gson/2.0.0/446f26737894df0d696b5b4fc5f473abcdaf7dde/converter-gson-2.0.0-sources.jar!/" />
</SOURCES>
</library>
</component>
+11
View File
@@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="gson-2.7">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.7/751f548c85fa49f330cecbb1875893f971b33c4e/gson-2.7.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.7/bbb63ca253b483da8ee53a50374593923e3de2e2/gson-2.7-sources.jar!/" />
</SOURCES>
</library>
</component>
-9
View File
@@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="javabase64">
<CLASSES>
<root url="jar://$PROJECT_DIR$/p2PCore/libs/javabase64.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
+12
View File
@@ -0,0 +1,12 @@
<component name="libraryTable">
<library name="libhttp-0.4.6.3">
<CLASSES>
<root url="jar://$USER_HOME$/.android/build-cache/81bb1e81ce531aeaac2645ff6c3818d15e86e716/output/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.android/build-cache/81bb1e81ce531aeaac2645ff6c3818d15e86e716/output/res" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.libhttp/libhttp/0.4.6.3/8369dc49daa7e0be35e281034b120af313a68f24/libhttp-0.4.6.3-sources.jar!/" />
</SOURCES>
</library>
</component>
+12
View File
@@ -0,0 +1,12 @@
<component name="libraryTable">
<library name="libhttp-v0.5.0">
<CLASSES>
<root url="file://$USER_HOME$/.android/build-cache/58450a43aace51ec322f59d7215b04262a3161fa/output/res" />
<root url="jar://$USER_HOME$/.android/build-cache/58450a43aace51ec322f59d7215b04262a3161fa/output/jars/classes.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.libhttp/libhttp/v0.5.0/bcc0a4f12c828a8370ec4e892f8753091bf1f160/libhttp-v0.5.0-sources.jar!/" />
</SOURCES>
</library>
</component>
@@ -1,11 +1,11 @@
<component name="libraryTable">
<library name="gson-2.4">
<library name="logging-interceptor-3.8.1">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.4/695b63d702f505b9b916e02272e3b6381bade7f/gson-2.4.jar!/" />
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/logging-interceptor/3.8.1/feab46062803513d6a8307c74b0084265855de1a/logging-interceptor-3.8.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.4/b98251e078d1809f889324fe90dbc4996919c02a/gson-2.4-sources.jar!/" />
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/logging-interceptor/3.8.1/346af70dd5d5493ad6e2c6ed3a944449e6709786/logging-interceptor-3.8.1-sources.jar!/" />
</SOURCES>
</library>
</component>
+11
View File
@@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="okhttp-3.3.0">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/3.3.0/2b802460eea20f8f2ad9c08c74e0f14718e88aa9/okhttp-3.3.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/3.3.0/ce902532a348a685692095f86d14800314078813/okhttp-3.3.0-sources.jar!/" />
</SOURCES>
</library>
</component>
+11
View File
@@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="okhttp-3.8.1">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/3.8.1/4d060ca3190df0eda4dc13415532a12e15ca5f11/okhttp-3.8.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/3.8.1/fc70ffa234e7e77741867d38b341d162ec1ec01e/okhttp-3.8.1-sources.jar!/" />
</SOURCES>
</library>
</component>
+11
View File
@@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="okio-1.13.0">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.okio/okio/1.13.0/a9283170b7305c8d92d25aff02a6ab7e45d06cbe/okio-1.13.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.okio/okio/1.13.0/f4c91e12121af963e3ef76e81c82aa75ba6e8533/okio-1.13.0-sources.jar!/" />
</SOURCES>
</library>
</component>
+11
View File
@@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="okio-1.8.0">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.okio/okio/1.8.0/5ea7af56cc7c567ed9856d99efb30740e9b17ff/okio-1.8.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.okio/okio/1.8.0/3a5f5ed555660472caab77ad3acdf157db97f838/okio-1.8.0-sources.jar!/" />
</SOURCES>
</library>
</component>
+14
View File
@@ -0,0 +1,14 @@
<component name="libraryTable">
<library name="p2p-core-0.4.4">
<CLASSES>
<root url="file://$USER_HOME$/.android/build-cache/0c5edad20f8fca1b212e021a2556133989ae759e/output/res" />
<root url="jar://$USER_HOME$/.android/build-cache/0c5edad20f8fca1b212e021a2556133989ae759e/output/jars/libs/Baidu_Mtj_3.7.5.4.jar!/" />
<root url="jar://$USER_HOME$/.android/build-cache/0c5edad20f8fca1b212e021a2556133989ae759e/output/jars/libs/org.apache.http.legacy.jar!/" />
<root url="jar://$USER_HOME$/.android/build-cache/0c5edad20f8fca1b212e021a2556133989ae759e/output/jars/classes.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.p2p.core/p2p-core/0.4.4/2c0bc721496df8555d49877e63db75d339d23c56/p2p-core-0.4.4-sources.jar!/" />
</SOURCES>
</library>
</component>
+11
View File
@@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="reactive-streams-1.0.0">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.reactivestreams/reactive-streams/1.0.0/14b8c877d98005ba3941c9257cfe09f6ed0e0d74/reactive-streams-1.0.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.reactivestreams/reactive-streams/1.0.0/5be7bd3f38e43c8fc83699bbb5328c62adb95bbf/reactive-streams-1.0.0-sources.jar!/" />
</SOURCES>
</library>
</component>
+11
View File
@@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="retrofit2-rxjava2-adapter-1.0.0">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.jakewharton.retrofit/retrofit2-rxjava2-adapter/1.0.0/e117362a2103f8ec01091ebd2f40aca4e1ada599/retrofit2-rxjava2-adapter-1.0.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.jakewharton.retrofit/retrofit2-rxjava2-adapter/1.0.0/7c4445a9e74b30d72c2dc78165a3b68ec26c800c/retrofit2-rxjava2-adapter-1.0.0-sources.jar!/" />
</SOURCES>
</library>
</component>
+11
View File
@@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="retrofit-2.1.0">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.retrofit2/retrofit/2.1.0/2de7cd8b95b7021b1d597f049bcb422055119f2c/retrofit-2.1.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.retrofit2/retrofit/2.1.0/3564ebef90ac75e61ed65ab9af0f422ce92d4afa/retrofit-2.1.0-sources.jar!/" />
</SOURCES>
</library>
</component>
+12
View File
@@ -0,0 +1,12 @@
<component name="libraryTable">
<library name="rxandroid-2.0.1">
<CLASSES>
<root url="jar://$USER_HOME$/.android/build-cache/e1ae9ca298c27ee12fe7c4f59cafe36df8a587e2/output/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.android/build-cache/e1ae9ca298c27ee12fe7c4f59cafe36df8a587e2/output/res" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/io.reactivex.rxjava2/rxandroid/2.0.1/67244b35fe87c5899f87151f8b63981b7c9b37db/rxandroid-2.0.1-sources.jar!/" />
</SOURCES>
</library>
</component>
+11
View File
@@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="rxjava-2.0.1">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/io.reactivex.rxjava2/rxjava/2.0.1/57f850a6b317e5582f1dbaff10a9e7d7e1fcdcfb/rxjava-2.0.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/io.reactivex.rxjava2/rxjava/2.0.1/194434fed571c2038f2d78baad1acd0d86394c3b/rxjava-2.0.1-sources.jar!/" />
</SOURCES>
</library>
</component>
+12
View File
@@ -0,0 +1,12 @@
<component name="libraryTable">
<library name="udpsender-v2.0.1">
<CLASSES>
<root url="file://$USER_HOME$/.android/build-cache/825e75b49abe0c63dec1213870f87d39fd7af6c1/output/res" />
<root url="jar://$USER_HOME$/.android/build-cache/825e75b49abe0c63dec1213870f87d39fd7af6c1/output/jars/classes.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.jwkj/udpsender/v2.0.1/56c72cbfc273ef764d897803cb56fc2774debd14/udpsender-v2.0.1-sources.jar!/" />
</SOURCES>
</library>
</component>
Binary file not shown.
@@ -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<BaseBean<Camera>>() {
private int result;
@Override
public void success(BaseBean<Camera> 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();
}
}
}
@@ -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;
}
}
@@ -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);
}
@@ -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;
}
}
@@ -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;
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-24
View File
@@ -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+'
}
@@ -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 = "";
}
@@ -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 = "";
}
@@ -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 {
}
@@ -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 {
}
@@ -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 {
}
@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.p2p_core" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="21" />
</manifest>
@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.p2p_core" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="21" />
</manifest>
@@ -1 +0,0 @@
#Mon Jun 10 20:47:20 CST 2019
@@ -1,2 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="output$Generated" generated="true"><source path="C:\Users\Administrator\.android\build-cache\7f60ceede3a1b85b8bcc39101a275f97d5327a9b\output\res"/></dataSet><dataSet config="debug$Generated" generated="true"><source path="C:\beifen\ifish\ifish\p2PCore\build\intermediates\bundles\debug\res"/></dataSet><dataSet config="main$Generated" generated="true"><source path="C:\beifen\ifish\ifish\p2PCore\src\androidTest\res"/><source path="C:\beifen\ifish\ifish\p2PCore\build\generated\res\rs\androidTest\debug"/><source path="C:\beifen\ifish\ifish\p2PCore\build\generated\res\resValues\androidTest\debug"/></dataSet><dataSet config="output" from-dependency="true" generated-set="output$Generated"><source path="C:\Users\Administrator\.android\build-cache\7f60ceede3a1b85b8bcc39101a275f97d5327a9b\output\res"/></dataSet><dataSet config="debug" from-dependency="true" generated-set="debug$Generated"><source path="C:\beifen\ifish\ifish\p2PCore\build\intermediates\bundles\debug\res"/></dataSet><dataSet config="main" generated-set="main$Generated"><source path="C:\beifen\ifish\ifish\p2PCore\src\androidTest\res"/><source path="C:\beifen\ifish\ifish\p2PCore\build\generated\res\rs\androidTest\debug"/><source path="C:\beifen\ifish\ifish\p2PCore\build\generated\res\resValues\androidTest\debug"/></dataSet><mergedItems/></merger>
@@ -1,2 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main"><source path="C:\beifen\ifish\ifish\p2PCore\src\main\assets"/><source path="C:\beifen\ifish\ifish\p2PCore\build\generated\assets\shaders\debug"/></dataSet><dataSet config="debug"><source path="C:\beifen\ifish\ifish\p2PCore\src\debug\assets"/></dataSet></merger>
@@ -1 +0,0 @@
#Mon Jun 10 20:47:20 CST 2019
@@ -1,2 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="output$Generated" generated="true"><source path="C:\Users\Administrator\.android\build-cache\7f60ceede3a1b85b8bcc39101a275f97d5327a9b\output\res"/></dataSet><dataSet config="main$Generated" generated="true"><source path="C:\beifen\ifish\ifish\p2PCore\src\main\res"/><source path="C:\beifen\ifish\ifish\p2PCore\build\generated\res\rs\debug"/><source path="C:\beifen\ifish\ifish\p2PCore\build\generated\res\resValues\debug"/></dataSet><dataSet config="debug$Generated" generated="true"><source path="C:\beifen\ifish\ifish\p2PCore\src\debug\res"/></dataSet><dataSet config="output" from-dependency="true" generated-set="output$Generated"><source path="C:\Users\Administrator\.android\build-cache\7f60ceede3a1b85b8bcc39101a275f97d5327a9b\output\res"/></dataSet><dataSet config="main" generated-set="main$Generated"><source path="C:\beifen\ifish\ifish\p2PCore\src\main\res"/><source path="C:\beifen\ifish\ifish\p2PCore\build\generated\res\rs\debug"/><source path="C:\beifen\ifish\ifish\p2PCore\build\generated\res\resValues\debug"/></dataSet><dataSet config="debug" generated-set="debug$Generated"><source path="C:\beifen\ifish\ifish\p2PCore\src\debug\res"/></dataSet><mergedItems/></merger>
@@ -1,2 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main"><source path="C:\beifen\ifish\ifish\p2PCore\src\main\shaders"/></dataSet><dataSet config="debug"><source path="C:\beifen\ifish\ifish\p2PCore\src\debug\shaders"/></dataSet></merger>
@@ -1,2 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main"><source path="C:\beifen\ifish\ifish\p2PCore\src\main\assets"/><source path="C:\beifen\ifish\ifish\p2PCore\build\generated\assets\shaders\release"/></dataSet><dataSet config="release"><source path="C:\beifen\ifish\ifish\p2PCore\src\release\assets"/></dataSet></merger>
@@ -1,2 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main"><source path="C:\beifen\ifish\ifish\p2PCore\src\main\shaders"/></dataSet><dataSet config="release"><source path="C:\beifen\ifish\ifish\p2PCore\src\release\shaders"/></dataSet></merger>
@@ -1 +0,0 @@
#Mon Jun 10 20:47:20 CST 2019
@@ -1,2 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main$Generated" generated="true"><source path="C:\beifen\ifish\ifish\p2PCore\src\main\res"/><source path="C:\beifen\ifish\ifish\p2PCore\build\generated\res\rs\debug"/><source path="C:\beifen\ifish\ifish\p2PCore\build\generated\res\resValues\debug"/></dataSet><dataSet config="debug$Generated" generated="true"><source path="C:\beifen\ifish\ifish\p2PCore\src\debug\res"/></dataSet><dataSet config="main" generated-set="main$Generated"><source path="C:\beifen\ifish\ifish\p2PCore\src\main\res"/><source path="C:\beifen\ifish\ifish\p2PCore\build\generated\res\rs\debug"/><source path="C:\beifen\ifish\ifish\p2PCore\build\generated\res\resValues\debug"/></dataSet><dataSet config="debug" generated-set="debug$Generated"><source path="C:\beifen\ifish\ifish\p2PCore\src\debug\res"/></dataSet><mergedItems/></merger>
@@ -1 +0,0 @@
#Mon Jun 10 20:47:12 CST 2019
@@ -1,2 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main$Generated" generated="true"><source path="C:\beifen\ifish\ifish\p2PCore\src\main\res"/><source path="C:\beifen\ifish\ifish\p2PCore\build\generated\res\rs\release"/><source path="C:\beifen\ifish\ifish\p2PCore\build\generated\res\resValues\release"/></dataSet><dataSet config="release$Generated" generated="true"><source path="C:\beifen\ifish\ifish\p2PCore\src\release\res"/></dataSet><dataSet config="main" generated-set="main$Generated"><source path="C:\beifen\ifish\ifish\p2PCore\src\main\res"/><source path="C:\beifen\ifish\ifish\p2PCore\build\generated\res\rs\release"/><source path="C:\beifen\ifish\ifish\p2PCore\build\generated\res\resValues\release"/></dataSet><dataSet config="release" generated-set="release$Generated"><source path="C:\beifen\ifish\ifish\p2PCore\src\release\res"/></dataSet><mergedItems/></merger>
@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.p2p_core.test" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="21" />
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:functionalTest="false"
android:handleProfiling="false"
android:label="Tests for com.example.p2p_core.test"
android:targetPackage="com.example.p2p_core.test" />
<application>
<uses-library android:name="android.test.runner" />
</application>
</manifest>
@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.p2p_core" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="21" />
</manifest>
@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.p2p_core" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="21" />
</manifest>
Binary file not shown.
Binary file not shown.
Binary file not shown.
-102
View File
@@ -1,102 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":p2PCore" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":p2PCore" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
<option name="PROJECT_TYPE" value="1" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-annotations-23.4.0" level="project" />
<orderEntry type="library" exported="" name="javabase64" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.4.0" level="project" />
<orderEntry type="library" exported="" name="org.apache.http.legacy-android-25" level="project" />
</component>
</module>
-6
View File
@@ -1,6 +0,0 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.p2p_core">
</manifest>
@@ -1,7 +0,0 @@
package com.p2p.core;
public abstract class BaseCallActivity extends BaseCoreActivity{
}
@@ -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<Integer, Integer> activity_stack = new HashMap<Integer, Integer>();
public HomeWatcher mHomeWatcher;
private void onStackChange() {
Set<Integer> 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<Integer> 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();
}
@@ -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);
}
@@ -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()<this.getCurrentWidth(s)&&this.getHeight()<this.getCurrentHeight())
// {
// this.changeNormalSize();
// }
onTouchPointerUp(event);
break;
}
}catch(Exception e){
e.printStackTrace();
};
return false;
}
/**
* 多点松开
*/
void onTouchPointerUp(MotionEvent event){
mafterLenght= getDistance(event);// 获取两点的距离
float mgapLenght = mafterLenght - mbeforeLenght;// 变化的长度
if(mgapLenght>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<Void, Integer, Void> {
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]);
}
});
}
}
}
@@ -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();
}
@@ -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();
}
@@ -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;
}
}
-29
View File
@@ -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);
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -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);
}
@@ -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<int[]> 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<int[]> 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);
}
@@ -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;
}
}
@@ -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==1type等于其它值时,通过npc和ipc来判断
//scale0 代表43 1 代表169
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);
*/
}
}
@@ -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<ViewConfiguration> sConfigurations =
new SparseArray<ViewConfiguration>(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;
}
}
@@ -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";
}
}
@@ -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;
}
}
@@ -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<SAlarmRecord> alarmRecords=new ArrayList<SAlarmRecord>();
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<o.serverReceiveTime){
return 1;
}else{
return 0;
}
}
@Override
public boolean equals(Object arg0) {
// TODO Auto-generated method stub
SAlarmRecord o=(SAlarmRecord)arg0;
if(this.messgeId.endsWith(o.messgeId)){
return true;
}else{
return false;
}
}
}
}
@@ -1,33 +0,0 @@
package com.p2p.core.network;
import org.json.JSONObject;
import android.util.Log;
import com.p2p.core.utils.MyUtils;
public class GetAccountInfoResult {
public String email;
public String countryCode;
public String phone;
public String error_code;
public GetAccountInfoResult(JSONObject json){
init(json);
}
private void init(JSONObject json){
try{
error_code = json.getString("error_code");
email = json.getString("Email");
countryCode = json.getString("CountryCode");
phone = json.getString("PhoneNO");
}catch(Exception e){
if(!MyUtils.isNumeric(error_code)){
Log.e("my","GetAccountInfoResult json解析错误");
error_code = String.valueOf(NetManager.JSON_PARSE_ERROR);
}
}
}
}
@@ -1,98 +0,0 @@
package com.p2p.core.network;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.json.JSONObject;
import android.util.Log;
import com.p2p.core.utils.MyUtils;
public class GetAlarmRecordListResult {
public String error_code;
public List<GXAlarmRecord> datas = new ArrayList<GXAlarmRecord>();
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<o.serverTime){
return 1;
}else{
return 0;
}
}
@Override
public boolean equals(Object arg0) {
// TODO Auto-generated method stub
GXAlarmRecord o = (GXAlarmRecord) arg0;
if(this.index.equals(o.index)){
return true;
}else{
return false;
}
}
}
}
@@ -1,49 +0,0 @@
package com.p2p.core.network;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONObject;
import android.util.Log;
import com.p2p.core.utils.MyUtils;
public class GetBindDeviceAccountResult {
public String error_code;
public List<String> contactIds = new ArrayList<String>();
public List<String> flags = new ArrayList<String>();
public List<String> phones = new ArrayList<String>();
public List<String> country_codes = new ArrayList<String>();
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<list.length;i++){
String[] datas = list[i].split(":");
country_codes.add(datas[0]);
phones.add(datas[1]);
flags.add(datas[2]);
String contactId = "";
try{
contactId = "0"+String.valueOf((Integer.parseInt(datas[3])&0x7fffffff));
}catch(Exception e){
}
contactIds.add(contactId);
}
}catch(Exception e){
if(!MyUtils.isNumeric(error_code)){
Log.e("my","GetAccountInfoResult json解析错误");
error_code = String.valueOf(NetManager.JSON_PARSE_ERROR);
}
}
}
}
@@ -1,42 +0,0 @@
package com.p2p.core.network;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONObject;
import android.util.Log;
import com.p2p.core.utils.MyUtils;
public class GetDeviceListResult {
public String error_code;
public String bindFlag;
public List<String> contactIds = new ArrayList<String>();
public List<String> flags = new ArrayList<String>();
public List<String> nikeNames = new ArrayList<String>();
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<list.length;i++){
String[] datas = list[i].split(":");
contactIds.add(datas[0]);
flags.add(datas[1]);
nikeNames.add(datas[2]);
}
}catch(Exception e){
if(!MyUtils.isNumeric(error_code)){
Log.e("my","GetAccountInfoResult json解析错误");
error_code = String.valueOf(NetManager.JSON_PARSE_ERROR);
}
}
}
}
@@ -1,35 +0,0 @@
package com.p2p.core.network;
import org.json.JSONObject;
import android.util.Log;
import com.p2p.core.utils.MyUtils;
public class GetStartInfoResult {
public String error_code;
public String Index;
public String ImageSrc;
public String pictrue_Link;
public String Preview ;//是否预览(1:预览,其他值:非预览)
public GetStartInfoResult(JSONObject json){
init(json);
}
public void init(JSONObject json){
try{
error_code=json.getString("error_code");
Index=json.getString("Index");
ImageSrc=json.getString("ImageSrc");
pictrue_Link=json.getString("Link");;
Preview=json.getString("Preview");
}catch(Exception e){
if(!MyUtils.isNumeric(error_code)){
Log.e("my","GetAccountInfoResult json解析错误");
error_code = String.valueOf(NetManager.JSON_PARSE_ERROR);
}
}
}
}
@@ -1,53 +0,0 @@
package com.p2p.core.network;
import android.util.Log;
import com.p2p.core.utils.MyUtils;
import org.json.JSONObject;
import java.io.Serializable;
public class LoginResult implements Serializable {
public String contactId;
public String rCode1;
public String rCode2;
public String phone;
public String email;
public String sessionId;
public String countryCode;
public String error_code;
public LoginResult(JSONObject json){
init(json);
}
private void init(JSONObject json){
try{
error_code = json.getString("error_code");
contactId = json.getString("UserID");
rCode1 = json.getString("P2PVerifyCode1");
rCode2 = json.getString("P2PVerifyCode2");
phone = json.getString("PhoneNO");
email = json.getString("Email");
sessionId = json.getString("SessionID");
countryCode = json.getString("CountryCode");
try{
contactId = "0"+String.valueOf((Integer.parseInt(contactId)&0x7fffffff));
}catch(Exception e){
}
}catch(Exception e){
contactId = "";
rCode1 = "";
rCode2 = "";
phone = "";
email = "";
sessionId = "";
countryCode = "";
if(!MyUtils.isNumeric(error_code)){
Log.e("my","LoginResult json解析错误");
error_code = String.valueOf(NetManager.JSON_PARSE_ERROR);
}
}
}
}
@@ -1,28 +0,0 @@
package com.p2p.core.network;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import org.json.JSONException;
import org.json.JSONObject;
import android.util.Log;
public class MallUrlResult {
public String error_code;
public String store_link;
public MallUrlResult(JSONObject json){
init(json);
}
public void init(JSONObject json){
try {
error_code=json.getString("error_code");
store_link=json.optString("StoreLink");
Log.e("mall_url", "link="+store_link);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
@@ -1,28 +0,0 @@
package com.p2p.core.network;
import org.json.JSONObject;
import android.util.Log;
import com.p2p.core.utils.MyUtils;
public class ModifyLoginPasswordResult {
public String error_code;
public String sessionId;
public ModifyLoginPasswordResult(JSONObject json){
init(json);
}
private void init(JSONObject json){
try{
error_code = json.getString("error_code");
sessionId = json.getString("SessionID");
}catch(Exception e){
if(!MyUtils.isNumeric(error_code)){
Log.e("my","ModifyLoginPasswordResult json解析错误");
error_code = String.valueOf(NetManager.JSON_PARSE_ERROR);
}
}
}
}
@@ -1,798 +0,0 @@
package com.p2p.core.network;
import android.content.Context;
import android.util.Log;
import com.p2p.core.utils.MD5;
import com.p2p.core.utils.MyUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class NetManager {
// private static final String SERVER1 = "http://cloudlinks.cn:90/";
// private static final String SERVER2 = "http://cloudlinks.cn:90/";
// private static final String SERVER3 = "http://cloudlinks.cn:90/";
// private static final String SERVER4 = "http://cloudlinks.cn:90/";
// private static final String SERVER1 = "http://cloudlinks.cn/";
// private static final String SERVER2 = "http://gwelltimes.com/";
// private static final String SERVER3 = "http://2cu.co/";
// private static final String SERVER4 = "http://cloud-links.net/";
// private static final String SERVER1 = "http://api1.cloudlinks.cn/";
// private static final String SERVER2 = "http://api2.cloudlinks.cn/";
// private static final String SERVER3 = "http://api3.cloud-links.net/";
// private static final String SERVER4 = "http://api4.cloud-links.net/";
//2017年1月16日 17:42:33更新
private static final String SERVER1 = "http://api1.cloudlinks.cn/";
private static final String SERVER2 = "http://api2.cloudlinks.cn/";
private static final String SERVER3 = "http://api3.cloud-links.net/";
private static final String SERVER4 = "http://api4.cloud-links.net/";
// private static final String SERVER1 = "http://videoipcamera.cn/";
// private static final String SERVER2 = "http://videoipcamera.com/";
// private static final String SERVER3 = "http://videoipcamera.cn/";
// private static final String SERVER4 = "http://videoipcamera.com/";
// private static final String SERVER1 = "http://192.168.1.222/";
// private static final String SERVER2 = "http://192.168.1.222/";
// private static final String SERVER3 = "http://192.168.1.222/";
// private static final String SERVER4 = "http://192.168.1.222/";
// private static final String SERVER1 = "http://gxyaj.cn/";
// private static final String SERVER2 = "http://gxyaj.cn/";
// private static final String SERVER3 = "http://gxyaj.cn/";
// private static final String SERVER4 = "http://gxyaj.cn/";
// private static final String SERVER1 = "http://c-telphone.cn/";
// private static final String SERVER2 = "http://c-telphone.com/";
private static String CURRENT_SERVER;
private static String LOGIN_URL = CURRENT_SERVER + "Users/LoginCheck.ashx";
private static String GETPHONE_CODE_URL = CURRENT_SERVER
+ "Users/PhoneCheckCode.ashx";
private static String VERIFY_CODE_URL = CURRENT_SERVER
+ "Users/PhoneVerifyCodeCheck.ashx";
private static String REGISTER_URL = CURRENT_SERVER
+ "Users/RegisterCheck.ashx";
private static String ACCOUNT_INFO_URL = CURRENT_SERVER
+ "Users/UpdateSafeSet.ashx";
private static String ALARM_RECORD_LIST_URL = CURRENT_SERVER
+ "Alarm/AlarmRecordEx.ashx";
private static String EXIT_APPLICATION_URL = CURRENT_SERVER
+ "Users/Logout.ashx";
private static String MODIFY_LOGIN_PASSWORD_URL = CURRENT_SERVER
+ "Users/ModifyPwd.ashx";
private static String BIND_DEVICE_ACCOUNT = CURRENT_SERVER
+ "Account/Bind/BindAccountEx.ashx";
private static String SEARCH_BIND_DEVICE_ACCOUNT = CURRENT_SERVER
+ "Account/Bind/SearchBindAccountEx.ashx";
private static String REMOVE_BIND_DEVICE_ACCOUNT = CURRENT_SERVER
+ "Account/Bind/RemoveBindEx.ashx";
private static String DEVICE_LIST_URL = CURRENT_SERVER
+ "Account/Bind/SearchBindDev.ashx";
private static String MODIFY_NIKE_NAME = CURRENT_SERVER
+ "Account/Bind/ModifyNickname.ashx";
private static String ALARM_MSSAGE_URL="http://192.168.1.222/"
+ "Alarm/AlarmRecordEx.ashx";
private static String SYSTEM_MESSAGE_URL="http://cloudlinks.cn/"+
"business/seller/recommendinfo.ashx";
private static String LOGO_URL="http://cloudlinks.cn/"+
"AppInfo/getappstartinfo.ashx";
private static String MALL_URL="http://cloudlinks.cn/"+
"AppInfo/getstorelinks.ashx";
private static String STORE_ID_URL="http://cloudlinks.cn/"+
"AppInfo/SetStoreID.ashx";
public static final int LOGIN_SUCCESS = 0;
public static final int LOGIN_USER_UNEXIST = 2;
public static final int LOGIN_PWD_ERROR = 3;
public static final int GET_PHONE_CODE_SUCCESS = 0;
public static final int GET_PHONE_CODE_PHONE_USED = 6;
public static final int GET_PHONE_CODE_PHONE_FORMAT_ERROR = 9;
public static final int GET_PHONE_CODE_TOO_TIMES = 27;
public static final int VERIFY_CODE_SUCCESS = 0;
public static final int VERIFY_CODE_ERROR = 18;
public static final int VERIFY_CODE_TIME_OUT = 21;
public static final int REGISTER_SUCCESS = 0;
public static final int REGISTER_EMAIL_FORMAT_ERROR = 4;
public static final int REGISTER_PHONE_USED = 6;
public static final int REGISTER_EMAIL_USED = 7;
public static final int REGISTER_PHONE_CODE_ERROR = 18;
public static final int REGISTER_PHONE_FORMAT_ERROR = 9;
public static final int REGISTER_PASSWORD_NO_MATCH = 10;
public static final int GET_ACCOUNT_SUCCESS = 0;
public static final int SET_ACCOUNT_SUCCESS = 0;
public static final int SET_ACCOUNT_PWD_ERROR = 3;
public static final int SET_ACCOUNT_EMAIL_FORMAT_ERROR = 4;
public static final int SET_ACCOUNT_EMAIL_USED = 7;
public static final int MODIFY_LOGIN_PWD_SUCCESS = 0;
public static final int MODIFY_LOGIN_PWD_INCONSISTENCE = 10;
public static final int MODIFY_LOGIN_PWD_OLD_PWD_ERROR = 11;
public static final int GET_DEVICE_LIST_SUCCESS = 0;
public static final int GET_DEVICE_LIST_EMPTY = 13;
public static final int GET_BIND_DEVICE_ACCOUNT_SUCCESS = 0;
public static final int MODIFY_BIND_DEVICE_ACCOUNT_SUCCESS = 0;
public static final int GET_ALARM_RECORD_SUCCESS = 0;
public static final int GET_ALARM_RECORD_EMPTY = 13;
public static final int GET_SYSTEM_MESSAGE_SUCCESS=0;
public static final int GET_START_LOGO_INFO=0;
public static final int SESSION_ID_ERROR = 23;
public static final int UNKNOWN_ERROR = 999;
public static final int CONNECT_CHANGE = 998;
public static final int JSON_PARSE_ERROR = 997;
private static int reconnect_count = 0;
private static String[] servers = new String[4];
private static boolean isInit = false;
private static NetManager manager = null;
private NetManager() {
};
private Context mContext;
public synchronized static NetManager getInstance(Context context) {
if (null == manager) {
synchronized (NetManager.class) {
manager = new NetManager();
manager.mContext = context;
}
}
return manager;
}
private void initServer() {
Log.e("my", "initNetServer");
randomServer();
reconnect_count = 0;
CURRENT_SERVER = servers[0];
isInit = true;
}
private void randomServer() {
Random random = new Random();
if(MyUtils.isZh(mContext)){
int value = random.nextInt(2);
if(value==0){
servers[0] = SERVER1;
servers[1] = SERVER2;
}else{
servers[0] = SERVER2;
servers[1] = SERVER1;
}
value = random.nextInt(2);
if(value==0){
servers[2] = SERVER3;
servers[3] = SERVER4;
}else{
servers[2] = SERVER4;
servers[3] = SERVER3;
}
}else{
int value = random.nextInt(2);
if(value==0){
servers[0] = SERVER3;
servers[1] = SERVER4;
}else{
servers[0] = SERVER4;
servers[1] = SERVER3;
}
value = random.nextInt(2);
if(value==0){
servers[2] = SERVER1;
servers[3] = SERVER2;
}else{
servers[2] = SERVER2;
servers[3] = SERVER1;
}
}
CURRENT_SERVER = servers[0];
}
private static void updateUrl(String server) {
LOGIN_URL = server + "Users/LoginCheck.ashx";
GETPHONE_CODE_URL = server + "Users/PhoneCheckCode.ashx";
VERIFY_CODE_URL = server + "Users/PhoneVerifyCodeCheck.ashx";
REGISTER_URL = server + "Users/RegisterCheck.ashx";
ACCOUNT_INFO_URL = server + "Users/UpdateSafeSet.ashx";
ALARM_RECORD_LIST_URL = server + "Alarm/AlarmRecordEx.ashx";
EXIT_APPLICATION_URL = server + "Users/Logout.ashx";
MODIFY_LOGIN_PASSWORD_URL = server + "Users/ModifyPwd.ashx";
BIND_DEVICE_ACCOUNT = server + "Account/Bind/BindAccountEx.ashx";
SEARCH_BIND_DEVICE_ACCOUNT = server + "Account/Bind/SearchBindAccountEx.ashx";
REMOVE_BIND_DEVICE_ACCOUNT = server + "Account/Bind/RemoveBindEx.ashx";
DEVICE_LIST_URL = server + "Account/Bind/SearchBindDev.ashx";
MODIFY_NIKE_NAME = server + "Account/Bind/ModifyNickname.ashx";
ALARM_MSSAGE_URL="http://192.168.1.222/"+"Alarm/AlarmRecordEx.ashx";
}
public String doPost(List<NameValuePair> 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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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<NameValuePair> params = new ArrayList<NameValuePair>();
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;
}
}
@@ -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);
}
}
}
}
@@ -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);
}
}
}
}
@@ -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<SystemMessage> systemMessages=new ArrayList<SystemMessage>();
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<o.time){
return 1;
}else{
return 0;
}
}
@Override
public boolean equals(Object arg0) {
// TODO Auto-generated method stub
SystemMessage o=(SystemMessage) arg0;
if(this.msgId.endsWith(o.msgId)){
return true;
}else{
return false;
}
}
}
}
@@ -1,213 +0,0 @@
package com.p2p.core.update;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import com.p2p.core.utils.MyUtils;
public class UpdateManager {
// private static final String UPDATE_URL = "http://www.gwelltimes.com/upg/android/";
private static final String UPDATE_URL = "http://upg1.cloudlinks.cn/upg/android/";
//private static final String WEISUO = "http://www.gwelltimes.com/upg/30/00/";
// private static final String UPDATE_URL = "http://c-telphone.com/upg/android/";
// private static final String UPDATE_URL = "http://gxyaj.cn/upg/android/";
public static final int HANDLE_MSG_DOWNING = 0X11;
public static final int HANDLE_MSG_DOWN_SUCCESS = 0X12;
public static final int HANDLE_MSG_DOWN_FAULT = 0X13;
private boolean isDowning = false;
private String version_server;
private static UpdateManager manager = null;
private int download_state;
private UpdateManager(){};
public synchronized static UpdateManager getInstance(){
if(null==manager){
synchronized(UpdateManager.class){
manager = new UpdateManager();
}
}
return manager;
}
public boolean getIsDowning(){
return isDowning;
}
public void cancelDown(){
isDowning = false;
}
public boolean checkUpdate(String AppId){
boolean haveNewVersion = false;
if(AppId==null||AppId.length()<=0){
AppId="0517401";
}
try{
//获取当前版本信息
String version = MyUtils.getVersion();
String[] version_parse = version.split("\\.");
String url = UPDATE_URL+version_parse[0]+"/"+version_parse[1]+"/latestversion.asp?AppId="+AppId+"&version="+version;
//解析服务器版本
version_server = version;
URL update_url = new URL(url);
HttpURLConnection connection = (HttpURLConnection) update_url.openConnection();
BufferedInputStream bis = new BufferedInputStream(connection.getInputStream());
byte[] buffer = new byte[128];
int n;
while((n=bis.read(buffer, 0, buffer.length))!=-1){
version_server = new String(buffer);
}
bis.close();
connection.disconnect();
//当前版本与服务器版本比较
String[] vaersion_server_parse = version_server.split("\\.");
int version_count = Integer.parseInt((version_parse[2]+version_parse[3]).trim());
int version_count_server = Integer.parseInt((vaersion_server_parse[2]+vaersion_server_parse[3]).trim());
if(version_count<version_count_server){
haveNewVersion = true;
}else{
haveNewVersion = false;
}
}catch(Exception e){
haveNewVersion = false;
}
return haveNewVersion;
}
public String getUpdateDescription(){
String description = "";
BufferedInputStream bis = null;
try{
String[] version_parse = MyUtils.getVersion().split("\\.");
String url = UPDATE_URL+version_parse[0]+"/"+version_parse[1]+"/des_html.asp";
URL update_url = new URL(url);
HttpURLConnection connection = (HttpURLConnection) update_url.openConnection();
bis = new BufferedInputStream(connection.getInputStream());
StringBuffer desBuffer = new StringBuffer();
byte[] buffer = new byte[1024];
int n;
while((n=bis.read(buffer, 0, buffer.length))!=-1){
desBuffer.append(new String(buffer,"utf-8"));
}
bis.close();
connection.disconnect();
description = desBuffer.toString();
}catch (Exception e){
e.printStackTrace();
}finally{
try {
if(bis!=null){bis.close();}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
description = description.trim();
return description;
}
public String getUpdateDescription_en(){
String description = "";
BufferedInputStream bis = null;
try{
String[] version_parse = MyUtils.getVersion().split("\\.");
String url = UPDATE_URL+version_parse[0]+"/"+version_parse[1]+"/des_html_en.asp";
URL update_url = new URL(url);
HttpURLConnection connection = (HttpURLConnection) update_url.openConnection();
bis = new BufferedInputStream(connection.getInputStream());
StringBuffer desBuffer = new StringBuffer();
byte[] buffer = new byte[1024];
int n;
while((n=bis.read(buffer, 0, buffer.length))!=-1){
desBuffer.append(new String(buffer,"utf-8"));
}
bis.close();
connection.disconnect();
description = desBuffer.toString();
}catch (Exception e){
e.printStackTrace();
}finally{
try {
if(bis!=null){bis.close();}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
description = description.trim();
return description;
}
public void downloadApk(Handler handler,String filePath,String fileName){
boolean isSuccess = true;
int progress = 0;
try {
if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
String savePath = Environment.getExternalStorageDirectory()+"/"+filePath;
File dirfile = new File(savePath);
if(!dirfile.exists()){
dirfile.mkdirs();
}
File apkfile = new File(savePath+"/"+fileName);
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(apkfile));
String[] version_server_parse = version_server.split("\\.");
String[] version_parse = MyUtils.getVersion().split("\\.");
URL down_url = new URL(UPDATE_URL+"/"+version_parse[0]+"/"+version_parse[1]+"/"+version_server.trim()+".apk");
HttpURLConnection connection = (HttpURLConnection) down_url.openConnection();
BufferedInputStream bis = new BufferedInputStream(connection.getInputStream());
int fileLength = connection.getContentLength();
int downLength = 0;
int n;
byte[] buffer = new byte[1024];
isDowning = true;
while((n=bis.read(buffer, 0, buffer.length))!=-1){
if(!isDowning){
isSuccess = false;
break;
}
bos.write(buffer, 0, n);
downLength +=n;
progress = (int) (((float) downLength / fileLength) * 100);
Message msg = new Message();
msg.what = HANDLE_MSG_DOWNING;
msg.arg1 = progress;
handler.sendMessage(msg);
}
bis.close();
bos.close();
isDowning = false;
connection.disconnect();
}
} catch (Exception e) {
// TODO Auto-generated catch block
isDowning = false;
isSuccess = false;
e.printStackTrace();
}
Message msg = new Message();
msg.arg1 = progress;
if(isSuccess){
msg.what = HANDLE_MSG_DOWN_SUCCESS;
}else{
msg.what = HANDLE_MSG_DOWN_FAULT;
}
handler.sendMessage(msg);
}
}
@@ -1,70 +0,0 @@
package com.p2p.core.utils;
import java.io.UnsupportedEncodingException;
import java.security.GeneralSecurityException;
import java.security.InvalidKeyException;
import java.security.SecureRandom;
import java.util.Arrays;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.SecretKeySpec;
import android.util.Log;
public class DES {
static byte[] key=new byte[]{(byte) 0x9c, (byte) 0xae, 0x6a, 0x5a, (byte) 0xe1,(byte) 0xfc,(byte) 0xb0, (byte) 0x82};
public static byte[] des(byte[] str,int type)
throws Exception {
if (type == 0) {
return desEncrypt(str,key);
} else {
return desDecrypt(str,key);
}
}
public static byte[] desEncrypt(byte[] source, byte rawKeyData[])
throws GeneralSecurityException, UnsupportedEncodingException {
SecretKeySpec key = new SecretKeySpec(rawKeyData, "DES");
// Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
Cipher cipher = Cipher.getInstance("DES/ECB/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] ss=cipher.doFinal(source);
return ss;
}
public static byte[] desDecrypt(byte[] data, byte rawKeyData[])
throws GeneralSecurityException, UnsupportedEncodingException {
SecretKeySpec key = new SecretKeySpec(rawKeyData, "DES");
// Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
Cipher cipher = Cipher.getInstance("DES/ECB/NoPadding");
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] ss=cipher.doFinal(data);
return ss;
}
public static String bytesToHexString(byte[] src){
StringBuilder stringBuilder = new StringBuilder("");
stringBuilder.append("[");
if (src == null || src.length <= 0) {
return null;
}
for (int i = 0; i < src.length; i++) {
int v = src[i] & 0xFF;
String hv = Integer.toHexString(v);
if (hv.length() < 2) {
stringBuilder.append(0);
}
stringBuilder.append(hv);
if(i!=src.length-1){
stringBuilder.append(", ");
}
}
stringBuilder.append("]");
return stringBuilder.toString();
}
}
@@ -1,24 +0,0 @@
package com.p2p.core.utils;
public class DelayThread extends Thread{
int delayTime;
OnRunListener onRunListener;
public DelayThread(int delayTime,OnRunListener onRunListener){
this.delayTime = delayTime;
this.onRunListener = onRunListener;
}
public void run(){
try {
Thread.sleep(delayTime);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
onRunListener.run();
}
public static interface OnRunListener{
public void run();
}
}
@@ -1,73 +0,0 @@
package com.p2p.core.utils;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.util.Log;
public class HomeWatcher {
static final String TAG = "hg";
private Context mContext;
private IntentFilter mFilter;
private OnHomePressedListener mListener;
private InnerRecevier mRecevier;
private boolean isRegister;
public HomeWatcher(Context context) {
isRegister = false;
mContext = context;
mFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
}
public void setOnHomePressedListener(OnHomePressedListener listener) {
mListener = listener;
mRecevier = new InnerRecevier();
}
public void startWatch() {
if (mRecevier != null) {
if(!isRegister){
mContext.registerReceiver(mRecevier, mFilter);
isRegister = true;
}
}
}
public void stopWatch() {
if (mRecevier != null) {
if(isRegister){
mContext.unregisterReceiver(mRecevier);
isRegister = false;
}
}
}
class InnerRecevier extends BroadcastReceiver {
final String SYSTEM_DIALOG_REASON_KEY = "reason";
final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions";
final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";
final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey";
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) {
String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY);
if (reason != null) {
Log.e(TAG, "action:" + action + ",reason:" + reason);
if (mListener != null) {
if (reason.equals(SYSTEM_DIALOG_REASON_HOME_KEY)) {
// home键
mListener.onHomePressed();
} else if (reason
.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) {
// 长按home键
mListener.onHomeLongPressed();
}
}
}
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More