Haven is for people who need a way to protect their personal spaces and possessions without compromising their own privacy, through an Android app and on-device sensors
captured photos should be in full color!
n8fr8593ce5457a2c
diff --git a/src/main/java/info/guardianproject/phoneypot/sensors/media/MotionAsyncTask.java b/src/main/java/info/guardianproject/phoneypot/sensors/media/MotionAsyncTask.javaindex 03e7711..27756fe 100644--- a/src/main/java/info/guardianproject/phoneypot/sensors/media/MotionAsyncTask.java+++ b/src/main/java/info/guardianproject/phoneypot/sensors/media/MotionAsyncTask.java@@ -7,6 +7,7 @@package info.guardianproject.phoneypot.sensors.media;+import java.io.ByteArrayOutputStream;import java.io.File;import java.io.FileNotFoundException;import java.io.FileOutputStream;@@ -15,7 +16,9 @@ import java.util.ArrayList;import java.util.List;import android.graphics.Bitmap;+import android.graphics.BitmapFactory;import android.graphics.Color;+import android.graphics.ImageFormat;import android.graphics.Rect;import android.graphics.YuvImage;import android.os.Environment;@@ -49,11 +52,13 @@ public class MotionAsyncTask extends Thread {private Bitmap lastBitmap;private Bitmap newBitmap;+ private Bitmap rawBitmap;private boolean hasChanged;public interface MotionListener {public void onProcess(Bitmap oldBitmap,Bitmap newBitmap,+ Bitmap rawBitmap,boolean motionDetected);}@@ -101,6 +106,21 @@ public class MotionAsyncTask extends Thread {lastBitmap = ImageCodec.lumaToBitmapGreyscale(oldPicLuma, width, height);newBitmap = Bitmap.createBitmap(newPic, width, height, Bitmap.Config.RGB_565);++ if (hasChanged) {+ YuvImage image = new YuvImage(rawNewPic, ImageFormat.NV21, width, height, null);+ ByteArrayOutputStream baos = new ByteArrayOutputStream();+ image.compressToJpeg(+ new Rect(0, 0, image.getWidth(), image.getHeight()), 90,+ baos);++ byte[] imageBytes = baos.toByteArray();+ rawBitmap = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);+ }+ else+ {+ rawBitmap = null;+ }}Log.i("MotionAsyncTask", "Finished processing, sending results");@@ -112,6 +132,7 @@ public class MotionAsyncTask extends Thread {listener.onProcess(lastBitmap,newBitmap,+ rawBitmap,hasChanged);}diff --git a/src/main/java/info/guardianproject/phoneypot/sensors/motion/Preview.java b/src/main/java/info/guardianproject/phoneypot/sensors/motion/Preview.javaindex 252c2d0..8754a21 100644--- a/src/main/java/info/guardianproject/phoneypot/sensors/motion/Preview.java+++ b/src/main/java/info/guardianproject/phoneypot/sensors/motion/Preview.java@@ -244,6 +244,7 @@ public class Preview extends SurfaceView implements SurfaceHolder.Callback {task.addListener(new MotionAsyncTask.MotionListener() {public void onProcess(Bitmap oldBitmap, Bitmap newBitmap,+ Bitmap rawBitmap,boolean motionDetected) {if (motionDetected) {@@ -260,24 +261,22 @@ public class Preview extends SurfaceView implements SurfaceHolder.Callback {String ts = new Date().getTime() + ".jpg";- /**File fileImage = new File(fileImageDir, "detected.original." + ts);FileOutputStream stream = new FileOutputStream(fileImage);- newBitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);+ rawBitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);stream.flush();stream.close();+ message.getData().putString("path", fileImage.getAbsolutePath());- message.getData().putString("original", fileImage.getAbsolutePath());- **/-- File fileImage = new File(fileImageDir, "detected.match." + ts);- FileOutputStream stream = new FileOutputStream(fileImage);+ /**+ fileImage = new File(fileImageDir, "detected.match." + ts);+ stream = new FileOutputStream(fileImage);oldBitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);stream.flush();stream.close();message.getData().putString("path", fileImage.getAbsolutePath());-+ **/serviceMessenger.send(message);diff --git a/src/main/java/info/guardianproject/phoneypot/ui/CameraFragment.java b/src/main/java/info/guardianproject/phoneypot/ui/CameraFragment.javaindex cc777b7..b3c82ae 100644--- a/src/main/java/info/guardianproject/phoneypot/ui/CameraFragment.java+++ b/src/main/java/info/guardianproject/phoneypot/ui/CameraFragment.java@@ -68,7 +68,7 @@ public final class CameraFragment extends Fragment {preview.addListener(new MotionAsyncTask.MotionListener() {- public void onProcess(Bitmap oldBitmap, Bitmap newBitmap,+ public void onProcess(Bitmap oldBitmap, Bitmap newBitmap, Bitmap rawBitmap,boolean motionDetected) {int rotation = 0;boolean reflex = false;@@ -78,6 +78,7 @@ public final class CameraFragment extends Fragment {rotation = 270;reflex = true;}+// oldImage.setImageBitmap(ImageCodec.rotate(oldBitmap, rotation, reflex));newImage.setImageBitmap(ImageCodec.rotate(newBitmap, rotation, reflex));}