Skip to content

armgit / haven

Public Imported from GitHub
0

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

more work on file deletion and blocking of gallery indexing added ".nomedia" to phoneypot folder so that the Gallery app won't try to suck these in

n8fr8734f2752dfd8
diff --git a/src/main/java/info/guardianproject/phoneypot/MonitorActivity.java b/src/main/java/info/guardianproject/phoneypot/MonitorActivity.java
index 7d17fb5..975f838 100644
--- a/src/main/java/info/guardianproject/phoneypot/MonitorActivity.java
+++ b/src/main/java/info/guardianproject/phoneypot/MonitorActivity.java
@@ -14,10 +14,12 @@ import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.CountDownTimer;
+import android.os.Environment;
import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.FragmentActivity;
import android.text.InputType;
+import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -27,6 +29,10 @@ import android.widget.Toast;
import org.w3c.dom.Text;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
import info.guardianproject.phoneypot.service.MonitorService;
public class MonitorActivity extends FragmentActivity {
@@ -129,6 +135,17 @@ public class MonitorActivity extends FragmentActivity {
private void initMonitor ()
{
+ //ensure folder exists and will not be scanned by the gallery app
+
+ try {
+ File fileImageDir = new File(Environment.getExternalStorageDirectory(), preferences.getImagePath());
+ fileImageDir.mkdirs();
+ new FileOutputStream(new File(fileImageDir, ".nomedia")).write(0);
+ }
+ catch (IOException e){
+ Log.e("Monitor","unable to init media storage directory",e);
+ }
+
//Do something after 100ms
startService(new Intent(MonitorActivity.this, MonitorService.class));
diff --git a/src/main/java/info/guardianproject/phoneypot/sensors/media/MotionAsyncTask.java b/src/main/java/info/guardianproject/phoneypot/sensors/media/MotionAsyncTask.java
index 4e1df97..03e7711 100644
--- a/src/main/java/info/guardianproject/phoneypot/sensors/media/MotionAsyncTask.java
+++ b/src/main/java/info/guardianproject/phoneypot/sensors/media/MotionAsyncTask.java
@@ -10,6 +10,7 @@ package info.guardianproject.phoneypot.sensors.media;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
@@ -97,7 +98,7 @@ public class MotionAsyncTask extends Thread {
newPic[changedPixel] = Color.RED;
}
}
-
+
lastBitmap = ImageCodec.lumaToBitmapGreyscale(oldPicLuma, width, height);
newBitmap = Bitmap.createBitmap(newPic, width, height, Bitmap.Config.RGB_565);
}
@@ -118,32 +119,5 @@ public class MotionAsyncTask extends Thread {
});
}
- private void saveImage ()
- {
-/**
- *
- try {
- YuvImage image = new YuvImage(data, parameters.getPreviewFormat(),
- size.width, size.height, null);
-
- imageCount = (imageCount + 1)%(prefs.getMaxImages());
-
- File file = new File(
- Environment.getExternalStorageDirectory().getPath() +
- prefs.getImagePath() +
- imageCount +
- ".jpg");
- FileOutputStream filecon = new FileOutputStream(file);
-
- image.compressToJpeg(
- new Rect(0, 0, image.getWidth(), image.getHeight()), 90,
- filecon);
-
- } catch (FileNotFoundException e) {
- Toast toast = Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG);
- toast.show();
- }
- */
- }
}
diff --git a/src/main/java/info/guardianproject/phoneypot/sensors/motion/Preview.java b/src/main/java/info/guardianproject/phoneypot/sensors/motion/Preview.java
index d45eb07..498e871 100644
--- a/src/main/java/info/guardianproject/phoneypot/sensors/motion/Preview.java
+++ b/src/main/java/info/guardianproject/phoneypot/sensors/motion/Preview.java
@@ -255,6 +255,8 @@ public class Preview extends SurfaceView implements SurfaceHolder.Callback {
fileImageDir.mkdirs();
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);
@@ -262,9 +264,10 @@ public class Preview extends SurfaceView implements SurfaceHolder.Callback {
stream.close();
message.getData().putString("original", fileImage.getAbsolutePath());
+ **/
- fileImage = new File(fileImageDir, "detected.match." + ts);
- stream = new FileOutputStream(fileImage);
+ File fileImage = new File(fileImageDir, "detected.match." + ts);
+ FileOutputStream stream = new FileOutputStream(fileImage);
oldBitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
stream.flush();
stream.close();