| | |
| | | package cn.com.basic.face.fragment; |
| | | |
| | | import android.app.AlarmManager; |
| | | import android.content.Context; |
| | | import android.net.wifi.WifiManager; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.os.Environment; |
| | | import android.os.SystemClock; |
| | | import android.text.format.Formatter; |
| | | import android.util.Log; |
| | | import android.view.SurfaceHolder; |
| | | import android.view.SurfaceView; |
| | | import android.view.View; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.ProgressBar; |
| | | import android.widget.RadioButton; |
| | | import android.widget.RadioGroup; |
| | | import android.widget.RelativeLayout; |
| | |
| | | import cn.com.basic.face.base.MainActivity; |
| | | import cn.com.basic.face.discern.common.CommonVariables; |
| | | import cn.com.basic.face.service.DeviceMng; |
| | | import cn.com.basic.face.thread.StartCameraThread; |
| | | import cn.com.basic.face.util.RtspFaceNative; |
| | | |
| | | import cn.com.basic.face.service.SurveillanceMng; |
| | | import cn.com.basic.face.util.SurveillancePhotoEmulateThread; |
| | | import cn.com.basic.face.thread.SurveillancePhotoEmulateThread; |
| | | import cn.com.basic.face.widget.surveilance.SurveillanceBottomAttendanceListView; |
| | | import cn.com.basic.face.widget.surveilance.SurveillanceBottomVisitorListView; |
| | | |
| | | import com.facebook.common.file.FileUtils; |
| | | import com.lidroid.xutils.view.annotation.ViewInject; |
| | | import com.lidroid.xutils.view.annotation.event.OnClick; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.DataOutputStream; |
| | | import java.io.File; |
| | | import java.io.FileReader; |
| | | import java.net.InetAddress; |
| | | import java.net.NetworkInterface; |
| | | import java.net.SocketException; |
| | |
| | | @ViewInject(R.id.fragment_surveillance_bottom_linear_layout) |
| | | private LinearLayout fragment_surveillance_bottom_linear_layout; |
| | | |
| | | StartCameraThread startEnterCameraThread = null; |
| | | StartCameraThread startExitCameraThread = null; |
| | | |
| | | static boolean useNative = false; |
| | | |
| | |
| | | useNative = false; |
| | | } |
| | | if (useNative) { |
| | | try{ |
| | | Calendar c = Calendar.getInstance(); |
| | | c.set(2017, 4, 1, 12, 34, 56); |
| | | AlarmManager am = (AlarmManager) MainActivity.getInstance().getSystemService(Context.ALARM_SERVICE); |
| | | |
| | | //am.setTime(c.getTimeInMillis()); |
| | | //Process su = Runtime.getRuntime().exec("su"); |
| | | //DataOutputStream outputStream = new DataOutputStream(su.getOutputStream()); |
| | | |
| | | //outputStream.writeBytes("busybox ifconfig wlan0 down\n"); |
| | | //outputStream.flush(); |
| | | //Thread.sleep(5000); |
| | | // outputStream.writeBytes("busybox ifconfig wlan0 hw ether f4:8b:32:62:4f:89\n"); |
| | | // outputStream.flush(); |
| | | |
| | | //outputStream.writeBytes("exit\n"); |
| | | //outputStream.flush(); |
| | | //su.waitFor(); |
| | | /* |
| | | busybox ifconfig wlan0 hw ether AC:83:F3:42:19:CE |
| | | |
| | | |
| | | */ |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | System.loadLibrary("cvface_api"); |
| | | System.loadLibrary("opencv_java3"); |
| | | System.loadLibrary("protobuf-lite"); |
| | |
| | | } |
| | | } catch (SocketException ex) {} |
| | | |
| | | try{ |
| | | //Process su = Runtime.getRuntime().exec("su"); |
| | | //DataOutputStream outputStream = new DataOutputStream(su.getOutputStream()); |
| | | |
| | | //outputStream.writeBytes("busybox ifconfig wlan0 down\n"); |
| | | //outputStream.flush(); |
| | | //Thread.sleep(5000); |
| | | // outputStream.writeBytes("busybox ifconfig wlan0 hw ether f4:8b:32:62:4f:89\n"); |
| | | // outputStream.flush(); |
| | | |
| | | //outputStream.writeBytes("exit\n"); |
| | | //outputStream.flush(); |
| | | //su.waitFor(); |
| | | /* |
| | | busybox ifconfig wlan0 hw ether AC:83:F3:42:19:CE |
| | | |
| | | |
| | | */ |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | // outputStream.writeBytes("busybox ifconfig wlan0 hw ether 00:e0:2c:31:1a:ba\n"); |
| | | /* |
| | | sysctl kernel.sched_is_big_little=1 |
| | | sysctl net.core.rmem_max=40000000 |
| | | */ |
| | | RtspFaceNative.setLocalIP(ipAddress); |
| | | System.out.println("ipaddr="+ipAddress); |
| | | } |
| | |
| | | if (CommonVariables.FACE_SERVER) { |
| | | fragment_supervisory_enter_camera_relative_layout.addView(MainActivity.getInstance().mPreview); |
| | | fragment_supervisory_enter_camera_relative_layout.addView(MainActivity.getInstance().mDraw); |
| | | //fragment_supervisory_exit_camera_relative_layout.setVisibility(View.GONE); |
| | | //fragment_surveillance_bottom_linear_layout.setVisibility(View.GONE); |
| | | } |
| | | fragment_supervisory_enter_camera.getHolder().addCallback(new SurfaceHolder.Callback() { |
| | | public void surfaceCreated(SurfaceHolder holder) { |
| | | new SurveillancePhotoEmulateThread().start(); |
| | | if (CommonVariables.EMULATOR) { |
| | | new SurveillancePhotoEmulateThread().start(); |
| | | } |
| | | if (useNative) { |
| | | RtspFaceNative.setSurface(Integer.parseInt(CommonVariables.Camera.IN), fragment_supervisory_enter_camera.getHolder().getSurface()); |
| | | RtspFaceNative.createPlayer(Integer.parseInt(CommonVariables.Camera.IN), DeviceMng.getInstance().getCamera1Address()); |
| | | RtspFaceNative.setFaceCallback(Integer.parseInt(CommonVariables.Camera.IN), "cn/com/basic/face/util/RtspFaceNative", "faceCallBack"); |
| | | synchronized (MainActivity.getInstance()) { |
| | | startEnterCameraThread = new StartCameraThread(Integer.parseInt(CommonVariables.Camera.IN), fragment_supervisory_enter_camera.getHolder().getSurface()); |
| | | startEnterCameraThread.start(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {} |
| | | public void surfaceDestroyed(SurfaceHolder holder) { |
| | | System.out.println("surfaceDestroyed"); |
| | | } |
| | | public void surfaceDestroyed(SurfaceHolder holder) { } |
| | | }); |
| | | fragment_supervisory_exit_camera.getHolder().addCallback(new SurfaceHolder.Callback() { |
| | | public void surfaceCreated(SurfaceHolder holder) { |
| | | if (useNative) { |
| | | RtspFaceNative.setSurface(Integer.parseInt(CommonVariables.Camera.OUT), fragment_supervisory_exit_camera.getHolder().getSurface()); |
| | | RtspFaceNative.createPlayer(Integer.parseInt(CommonVariables.Camera.OUT), DeviceMng.getInstance().getCamera2Address()); |
| | | RtspFaceNative.setFaceCallback(Integer.parseInt(CommonVariables.Camera.OUT), "cn/com/basic/face/util/RtspFaceNative", "faceCallBack"); |
| | | synchronized (MainActivity.getInstance()) { |
| | | startEnterCameraThread = new StartCameraThread(Integer.parseInt(CommonVariables.Camera.OUT), fragment_supervisory_exit_camera.getHolder().getSurface()); |
| | | startEnterCameraThread.start(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { |
| | | System.out.print("width="+width+",height="+height); |
| | | // if (useNative) { |
| | | // RtspFaceNative.setSurface(Integer.parseInt(CommonVariables.Camera.IN), fragment_supervisory_enter_camera.getHolder().getSurface()); |
| | | // RtspFaceNative.createPlayer(Integer.parseInt(CommonVariables.Camera.IN), DeviceMng.getInstance().getCamera1Address()); |
| | | // RtspFaceNative.setFaceCallback(Integer.parseInt(CommonVariables.Camera.IN), "cn/com/basic/face/util/RtspFaceNative", "faceCallBack"); |
| | | // } |
| | | } |
| | | public void surfaceDestroyed(SurfaceHolder holder) { |
| | | System.out.println("surfaceDestroyed"); |
| | | } |
| | | public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { } |
| | | public void surfaceDestroyed(SurfaceHolder holder) { } |
| | | }); |
| | | new SurveillanceMng.SurveillanceListThread().start(); |
| | | } |
| | |
| | | // reloadBottomList(); |
| | | } |
| | | }); |
| | | setupUI(getView()); |
| | | } |
| | | |
| | | @Override |