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

Deleted VolumeDynamicSeries. Renamed BluetoothService. Deleted warnings.

Luca Bonato49c41d70bd14
diff --git a/src/me/ziccard/secureit/MonitorActivity.java b/src/me/ziccard/secureit/MonitorActivity.java
index 6aff642..df94dd6 100644
--- a/src/me/ziccard/secureit/MonitorActivity.java
+++ b/src/me/ziccard/secureit/MonitorActivity.java
@@ -4,7 +4,7 @@ import me.ziccard.secureit.fragment.AccelerometerFragment;
import me.ziccard.secureit.fragment.CameraFragment;
import me.ziccard.secureit.fragment.EmptyFragment;
import me.ziccard.secureit.fragment.MicrophoneFragment;
-import me.ziccard.secureit.service.BluetoothService;
+import me.ziccard.secureit.service.UploadService;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
@@ -61,7 +61,7 @@ public class MonitorActivity extends FragmentActivity {
/**
* Binding to the bluetooth service
*/
- startService(new Intent(this, BluetoothService.class));
+ startService(new Intent(this, UploadService.class));
}
class MonitorAdapter extends FragmentPagerAdapter {
@@ -141,7 +141,7 @@ public class MonitorActivity extends FragmentActivity {
getApplicationContext(), StartActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
- stopService(new Intent(this, BluetoothService.class));
+ stopService(new Intent(this, UploadService.class));
preferences.unsetAccessToken();
preferences.unsetDelegatedAccessToken();
preferences.unsetPhoneId();
diff --git a/src/me/ziccard/secureit/Preview.java b/src/me/ziccard/secureit/Preview.java
index 29e2d08..7760a0d 100644
--- a/src/me/ziccard/secureit/Preview.java
+++ b/src/me/ziccard/secureit/Preview.java
@@ -10,7 +10,7 @@ import java.util.List;
import me.ziccard.secureit.async.MotionAsyncTask;
import me.ziccard.secureit.async.MotionAsyncTask.MotionListener;
import me.ziccard.secureit.motiondetection.LuminanceMotionDetector;
-import me.ziccard.secureit.service.BluetoothService;
+import me.ziccard.secureit.service.UploadService;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -139,7 +139,7 @@ public class Preview extends SurfaceView implements SurfaceHolder.Callback {
* We bind to the alert service
*/
context.bindService(new Intent(context,
- BluetoothService.class), mConnection, Context.BIND_ABOVE_CLIENT);
+ UploadService.class), mConnection, Context.BIND_ABOVE_CLIENT);
/*
* The Surface has been created, acquire the camera and tell it where
@@ -256,7 +256,7 @@ public class Preview extends SurfaceView implements SurfaceHolder.Callback {
Log.i("MotionListener", "Motion detected");
if (serviceMessenger!=null) {
Message message = new Message();
- message.what = BluetoothService.CAMERA_MESSAGE;
+ message.what = UploadService.CAMERA_MESSAGE;
try {
serviceMessenger.send(message);
} catch (RemoteException e) {
diff --git a/src/me/ziccard/secureit/StartActivity.java b/src/me/ziccard/secureit/StartActivity.java
index 897b179..733bf69 100644
--- a/src/me/ziccard/secureit/StartActivity.java
+++ b/src/me/ziccard/secureit/StartActivity.java
@@ -2,22 +2,13 @@ package me.ziccard.secureit;
import java.io.File;
-import me.ziccard.secureit.async.AudioRecorderTask;
-import me.ziccard.secureit.async.MicrophoneTaskFactory;
-import me.ziccard.secureit.async.BluetoothServerTask;
-import me.ziccard.secureit.async.MicrophoneTaskFactory.RecordLimitExceeded;
-import me.ziccard.secureit.async.BluetoothServerTask.NoBluetoothException;
import me.ziccard.secureit.async.upload.AuthenticatorTask;
import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
-import android.content.ComponentName;
-import android.content.Context;
import android.content.Intent;
-import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.util.Log;
-import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
diff --git a/src/me/ziccard/secureit/VolumeDynamicSeries.java b/src/me/ziccard/secureit/VolumeDynamicSeries.java
deleted file mode 100644
index 7615f65..0000000
--- a/src/me/ziccard/secureit/VolumeDynamicSeries.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package me.ziccard.secureit;
-
-import android.util.Log;
-
-import com.androidplot.series.XYSeries;
-
-public class VolumeDynamicSeries implements XYSeries{
-
- @SuppressWarnings("unused")
- private int seriesIndex;
- private String title;
- short[] data = new short[0];
-
- public VolumeDynamicSeries(int seriesIndex, String title) {
- this.seriesIndex = seriesIndex;
- this.title = title;
- }
-
- synchronized public void updateData(short[] data) {
- this.data = data;
- }
-
- public String getTitle() {
- return title;
- }
-
- public int size() {
- return data.length;
- }
-
- public Number getX(int index) {
- if (index >= data.length) {
- throw new IllegalArgumentException();
- }
- return index;
- }
-
- public Number getY(int index) {
- if (index >= data.length) {
- throw new IllegalArgumentException();
- }
- double val = 0.0;
- if (data[index]!=0) {
- Log.i("VolumDynamicSeries", "Non zero value");
- val = 20*Math.log10(Math.abs(data[index])/1);
- }
- //Log.i("LOGGGARTI", ""+val);
- return val;
- }
-}
diff --git a/src/me/ziccard/secureit/async/BluetoothServerTask.java b/src/me/ziccard/secureit/async/BluetoothServerTask.java
index 2ce31f3..bfb0e5f 100644
--- a/src/me/ziccard/secureit/async/BluetoothServerTask.java
+++ b/src/me/ziccard/secureit/async/BluetoothServerTask.java
@@ -8,7 +8,6 @@ import java.util.Date;
import me.ziccard.secureit.async.upload.DelegatedPositionUploaderTask;
import me.ziccard.secureit.bluetooth.ObjectBluetoothSocket;
import me.ziccard.secureit.config.Remote;
-import me.ziccard.secureit.messages.BluetoothMessage;
import me.ziccard.secureit.messages.HelloMessage;
import me.ziccard.secureit.messages.KeyRequest;
import me.ziccard.secureit.messages.KeyResponse;
@@ -20,7 +19,6 @@ import android.bluetooth.BluetoothSocket;
import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
-import android.location.LocationProvider;
import android.util.Log;
public class BluetoothServerTask extends Thread {
@@ -118,7 +116,6 @@ public class BluetoothServerTask extends Thread {
//Sending key request
ObjectOutputStream ostream = socket.getOutputStream();
- Date timestamp = new Date();
MessageBuilder builder = new MessageBuilder();
builder.setLat(lastKnownLocation.getLatitude());
builder.setLng(lastKnownLocation.getLongitude());
diff --git a/src/me/ziccard/secureit/async/upload/BluetoothPeriodicPositionUploaderTask.java b/src/me/ziccard/secureit/async/upload/BluetoothPeriodicPositionUploaderTask.java
index abd15d9..7be561e 100644
--- a/src/me/ziccard/secureit/async/upload/BluetoothPeriodicPositionUploaderTask.java
+++ b/src/me/ziccard/secureit/async/upload/BluetoothPeriodicPositionUploaderTask.java
@@ -2,23 +2,14 @@ package me.ziccard.secureit.async.upload;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.security.NoSuchAlgorithmException;
-import java.security.spec.AlgorithmParameterSpec;
import java.util.ArrayList;
import java.util.Date;
-import javax.crypto.Cipher;
-import javax.crypto.NoSuchPaddingException;
-import javax.crypto.spec.IvParameterSpec;
-import javax.crypto.spec.SecretKeySpec;
-
import me.ziccard.secureit.SecureItPreferences;
import me.ziccard.secureit.bluetooth.ObjectBluetoothSocket;
import me.ziccard.secureit.config.Remote;
import me.ziccard.secureit.messages.BluetoothMessage;
-import me.ziccard.secureit.messages.HelloMessage;
import me.ziccard.secureit.messages.KeyRequest;
-import me.ziccard.secureit.messages.KeyResponse;
import me.ziccard.secureit.messages.MessageBuilder;
import me.ziccard.secureit.messages.MessageType;
import android.bluetooth.BluetoothAdapter;
@@ -29,13 +20,11 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.AsyncTask;
-import android.util.Base64;
import android.util.Log;
import android.widget.Toast;
public class BluetoothPeriodicPositionUploaderTask extends AsyncTask<Void, Void, Void> {
- @SuppressWarnings("unused")
private Context context;
/**
diff --git a/src/me/ziccard/secureit/fragment/AccelerometerFragment.java b/src/me/ziccard/secureit/fragment/AccelerometerFragment.java
index 9e74668..8c27a7a 100644
--- a/src/me/ziccard/secureit/fragment/AccelerometerFragment.java
+++ b/src/me/ziccard/secureit/fragment/AccelerometerFragment.java
@@ -2,7 +2,7 @@ package me.ziccard.secureit.fragment;
import me.ziccard.secureit.R;
import me.ziccard.secureit.SecureItPreferences;
-import me.ziccard.secureit.service.BluetoothService;
+import me.ziccard.secureit.service.UploadService;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
@@ -114,7 +114,7 @@ public class AccelerometerFragment extends Fragment implements SensorEventListen
accelerometerText.setVisibility(View.VISIBLE);
Message message = new Message();
- message.what = BluetoothService.ACCELEROMETER_MESSAGE;
+ message.what = UploadService.ACCELEROMETER_MESSAGE;
try {
if (serviceMessenger != null) {
@@ -159,7 +159,7 @@ public class AccelerometerFragment extends Fragment implements SensorEventListen
}
getActivity().bindService(new Intent(getActivity(),
- BluetoothService.class), mConnection, Context.BIND_ABOVE_CLIENT);
+ UploadService.class), mConnection, Context.BIND_ABOVE_CLIENT);
}
@Override
diff --git a/src/me/ziccard/secureit/fragment/MicrophoneFragment.java b/src/me/ziccard/secureit/fragment/MicrophoneFragment.java
index 4013849..980ce96 100644
--- a/src/me/ziccard/secureit/fragment/MicrophoneFragment.java
+++ b/src/me/ziccard/secureit/fragment/MicrophoneFragment.java
@@ -17,7 +17,7 @@ import me.ziccard.secureit.SecureItPreferences;
import me.ziccard.secureit.async.MicSamplerTask;
import me.ziccard.secureit.async.MicrophoneTaskFactory;
import me.ziccard.secureit.async.MicrophoneTaskFactory.RecordLimitExceeded;
-import me.ziccard.secureit.service.BluetoothService;
+import me.ziccard.secureit.service.UploadService;
import android.view.LayoutInflater;
import android.view.View;
@@ -86,7 +86,7 @@ public final class MicrophoneFragment extends Fragment implements MicSamplerTask
}
getActivity().bindService(new Intent(getActivity(),
- BluetoothService.class), mConnection, Context.BIND_ABOVE_CLIENT);
+ UploadService.class), mConnection, Context.BIND_ABOVE_CLIENT);
try {
microphone = MicrophoneTaskFactory.makeSampler(getActivity());
@@ -168,7 +168,7 @@ public final class MicrophoneFragment extends Fragment implements MicSamplerTask
if (averageDB > NOISE_THRESHOLD) {
Message message = new Message();
- message.what = BluetoothService.MICROPHONE_MESSAGE;
+ message.what = UploadService.MICROPHONE_MESSAGE;
try {
serviceMessenger.send(message);
} catch (RemoteException e) {
diff --git a/src/me/ziccard/secureit/opengl/AccelerometerGLRenderer.java b/src/me/ziccard/secureit/opengl/AccelerometerGLRenderer.java
index 73204a2..b5d38e5 100644
--- a/src/me/ziccard/secureit/opengl/AccelerometerGLRenderer.java
+++ b/src/me/ziccard/secureit/opengl/AccelerometerGLRenderer.java
@@ -14,7 +14,6 @@ import android.hardware.SensorManager;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import android.opengl.Matrix;
-import android.os.SystemClock;
/**
@@ -490,9 +489,7 @@ public class AccelerometerGLRenderer implements GLSurfaceView.Renderer
angle_y -= .18;
}
}
-
- float offsetX = 0.0F;
- float offsetY = 0.0F;
+
float angleInDegreesX = (angle_x)/(SensorManager.GRAVITY_EARTH*2)*180;
float angleInDegreesY = (angle_y)/(SensorManager.GRAVITY_EARTH*2)*180;
diff --git a/src/me/ziccard/secureit/service/BluetoothService.java b/src/me/ziccard/secureit/service/UploadService.java
similarity index 91%
rename from src/me/ziccard/secureit/service/BluetoothService.java
rename to src/me/ziccard/secureit/service/UploadService.java
index 4594e31..1bb6704 100644
--- a/src/me/ziccard/secureit/service/BluetoothService.java
+++ b/src/me/ziccard/secureit/service/UploadService.java
@@ -1,11 +1,5 @@
package me.ziccard.secureit.service;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.ArrayList;
-import java.util.Date;
-
import me.ziccard.secureit.MonitorActivity;
import me.ziccard.secureit.R;
import me.ziccard.secureit.SecureItPreferences;
@@ -16,24 +10,13 @@ import me.ziccard.secureit.async.BluetoothServerTask.NoBluetoothException;
import me.ziccard.secureit.async.upload.BluetoothPeriodicPositionUploaderTask;
import me.ziccard.secureit.async.upload.ImagesUploaderTask;
import me.ziccard.secureit.async.upload.PeriodicPositionUploaderTask;
-import me.ziccard.secureit.bluetooth.ObjectBluetoothSocket;
-import me.ziccard.secureit.config.Remote;
-import me.ziccard.secureit.messages.BluetoothMessage;
-import me.ziccard.secureit.messages.HelloMessage;
-import me.ziccard.secureit.messages.KeyRequest;
-import me.ziccard.secureit.messages.KeyResponse;
import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothSocket;
-import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
@@ -46,7 +29,7 @@ import android.util.Log;
import android.widget.Toast;
@SuppressLint("HandlerLeak")
-public class BluetoothService extends Service {
+public class UploadService extends Service {
/**
* Task used to upload position, is periodic, when we close the app