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
first major update and refactoring for phoneypot
n8fr8de7710dde276
diff --git a/build.gradle b/build.gradleindex 2da36f4..b916d9f 100644--- a/build.gradle+++ b/build.gradle@@ -1,19 +1,25 @@buildscript {+ repositories {+ jcenter()+ }dependencies {- classpath 'com.android.tools.build:gradle:1.1.0'+ classpath 'com.android.tools.build:gradle:2.2.3'++ // NOTE: Do not place your application dependencies here; they belong+ // in the individual module build.gradle files}+}apply plugin: 'com.android.application'repositories {- maven { url "http://dl.bintray.com/populov/maven" }- mavenCentral()+ jcenter()}android {- compileSdkVersion 16- buildToolsVersion "21.1.2"+ compileSdkVersion 25+ buildToolsVersion "25"packagingOptions {exclude 'META-INF/LICENSE.txt'@@ -23,10 +29,10 @@ android {defaultConfig {applicationId "me.ziccard.secureit"minSdkVersion 10- targetSdkVersion 15+ targetSdkVersion 25compileOptions {- sourceCompatibility JavaVersion.VERSION_1_5- targetCompatibility JavaVersion.VERSION_1_5+ sourceCompatibility JavaVersion.VERSION_1_7+ targetCompatibility JavaVersion.VERSION_1_7}}@@ -39,10 +45,6 @@ android {}dependencies {- compile 'com.android.support:support-v4:18.0.0'- compile "com.androidplot:androidplot-core:0.6.1"- compile 'org.apache.httpcomponents:httpclient:4.2.3'- compile 'org.apache.httpcomponents:httpcore:4.2.3'- compile 'org.apache.httpcomponents:httpmime:4.2.3'- compile 'com.viewpagerindicator:library:2.4.1@aar'+ compile 'com.android.support:support-v4:25.0.0'+}diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.propertiesindex 0c71e76..1081cc3 100644--- a/gradle/wrapper/gradle-wrapper.properties+++ b/gradle/wrapper/gradle-wrapper.properties@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOMEdistributionPath=wrapper/distszipStoreBase=GRADLE_USER_HOMEzipStorePath=wrapper/dists-distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip+distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zipdiff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xmlindex 6f83f0b..9a38e50 100644--- a/src/main/AndroidManifest.xml+++ b/src/main/AndroidManifest.xml@@ -1,5 +1,5 @@<manifest xmlns:android="http://schemas.android.com/apk/res/android"- package="me.ziccard.secureit"+ package="me.ziccard.phoneypot"android:versionCode="1"android:versionName="1.0" >@@ -26,19 +26,18 @@android:label="@string/app_name"android:theme="@style/AppTheme" ><activity- android:name=".StartActivity"+ android:name="me.ziccard.info.guardianproject.phoneypot.StartActivity"android:label="@string/title_activity_start" ><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity>- <activity android:label="@string/app_name" android:name=".MonitorFragment"/>- <activity+ <activityandroid:label="@string/app_name"- android:name=".MonitorActivity"+ android:name="me.ziccard.info.guardianproject.phoneypot.MonitorActivity"android:launchMode="singleTop"android:screenOrientation="portrait"/>- <service android:name=".service.UploadService"/>+ <service android:name="me.ziccard.info.guardianproject.phoneypot.service.MonitorService"/></application></manifest>diff --git a/src/main/java/me/ziccard/phoneypot/MonitorActivity.java b/src/main/java/me/ziccard/phoneypot/MonitorActivity.javanew file mode 100644index 0000000..343701f--- /dev/null+++ b/src/main/java/me/ziccard/phoneypot/MonitorActivity.java@@ -0,0 +1,114 @@+/*+ * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato+ * Licensed under the MIT license.+ */+++package me.ziccard.phoneypot;++import me.ziccard.phoneypot.service.MonitorService;+import android.app.AlertDialog;+import android.content.DialogInterface;+import android.content.Intent;+import android.content.res.Configuration;+import android.os.Bundle;+import android.support.v4.app.FragmentActivity;+import android.text.InputType;+import android.view.Menu;+import android.view.MenuItem;+import android.widget.EditText;+import android.widget.Toast;++public class MonitorActivity extends FragmentActivity {++ private SecureItPreferences preferences = null;++ private static final String[] CONTENT = new String[] { "Accel.", "Camera",+ "Mic."};+ @Override+ protected void onCreate(Bundle savedInstanceState) {+ super.onCreate(savedInstanceState);++ preferences = new SecureItPreferences(getApplicationContext());++ setContentView(R.layout.layout_running);++ /**+ * starting the alert srevice+ */+ startService(new Intent(this, MonitorService.class));+ }++++ @Override+ public boolean onCreateOptionsMenu(Menu menu) {+ getMenuInflater().inflate(R.menu.monitor_activity, menu);+ return true;+ }++ @Override+ public boolean onOptionsItemSelected (MenuItem item) {+ switch (item.getItemId()){+ case R.id.menu_settings:+ createUnlockDialog();+ break;+ }+ return true;+ }++ /**+ * Closes the monitor activity and unset session properties+ */+ private void close() {+ Intent intent = new Intent(+ getApplicationContext(), StartActivity.class);+ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);+ startActivity(intent);+ stopService(new Intent(this, MonitorService.class));+ preferences.unsetAccessToken();+ preferences.unsetDelegatedAccessToken();+ preferences.unsetPhoneId();++ }++ /**+ * When user closes the activity+ */+ @Override+ public void onBackPressed() {+ createUnlockDialog();+ }++ /**+ * Shows a dialog prompting the unlock code+ */+ private void createUnlockDialog() {+ final AlertDialog.Builder builder = new AlertDialog.Builder(this);+ builder.setTitle("Stop monitoring?");+ final EditText input = new EditText(this);+ input.setHint("Unlock code");+ input.setInputType(InputType.TYPE_CLASS_NUMBER);+ input.setRawInputType(Configuration.KEYBOARD_12KEY);+ builder.setView(input);++ builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {+ public void onClick(DialogInterface dialog, int whichButton) {+ if (input.getText().toString().equals(preferences.getUnlockCode())) {+ dialog.dismiss();+ close();+ } else {+ dialog.dismiss();+ Toast.makeText(+ getApplicationContext(),+ "Wrong unlock code",+ Toast.LENGTH_SHORT).show();+ }+ }+ });++ builder.show();+++ }+}diff --git a/src/main/java/me/ziccard/secureit/Preview.java b/src/main/java/me/ziccard/phoneypot/Preview.javasimilarity index 95%rename from src/main/java/me/ziccard/secureit/Preview.javarename to src/main/java/me/ziccard/phoneypot/Preview.javaindex 73b8dfe..107beb5 100644--- a/src/main/java/me/ziccard/secureit/Preview.java+++ b/src/main/java/me/ziccard/phoneypot/Preview.java@@ -4,7 +4,7 @@*/-package me.ziccard.secureit;+package me.ziccard.phoneypot;import java.io.File;import java.io.FileNotFoundException;@@ -13,10 +13,10 @@ import java.io.IOException;import java.util.ArrayList;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.UploadService;+import me.ziccard.phoneypot.async.MotionAsyncTask;+import me.ziccard.phoneypot.async.MotionAsyncTask.MotionListener;+import me.ziccard.phoneypot.motiondetection.LuminanceMotionDetector;+import me.ziccard.phoneypot.service.MonitorService;import android.content.ComponentName;import android.content.Context;import android.content.Intent;@@ -145,7 +145,7 @@ public class Preview extends SurfaceView implements SurfaceHolder.Callback {* We bind to the alert service*/context.bindService(new Intent(context,- UploadService.class), mConnection, Context.BIND_ABOVE_CLIENT);+ MonitorService.class), mConnection, Context.BIND_ABOVE_CLIENT);/** The Surface has been created, acquire the camera and tell it where@@ -262,7 +262,7 @@ public class Preview extends SurfaceView implements SurfaceHolder.Callback {Log.i("MotionListener", "Motion detected");if (serviceMessenger!=null) {Message message = new Message();- message.what = UploadService.CAMERA_MESSAGE;+ message.what = MonitorService.CAMERA_MESSAGE;try {serviceMessenger.send(message);} catch (RemoteException e) {diff --git a/src/main/java/me/ziccard/secureit/SecureItPreferences.java b/src/main/java/me/ziccard/phoneypot/SecureItPreferences.javasimilarity index 82%rename from src/main/java/me/ziccard/secureit/SecureItPreferences.javarename to src/main/java/me/ziccard/phoneypot/SecureItPreferences.javaindex 15478a9..9cfc328 100644--- a/src/main/java/me/ziccard/secureit/SecureItPreferences.java+++ b/src/main/java/me/ziccard/phoneypot/SecureItPreferences.java@@ -4,7 +4,7 @@*/-package me.ziccard.secureit;+package me.ziccard.phoneypot;import android.app.Activity;import android.content.Context;@@ -34,8 +34,6 @@ public class SecureItPreferences {private static final String MICROPHONE_SENSITIVITY="microphone_sensitivity";private static final String SMS_ACTIVE="sms_active";private static final String SMS_NUMBER="sms_number";- private static final String REMOTE_ACTIVE="remote_active";- private static final String REMOTE_EMAIL="remote_email";private static final String UNLOCK_CODE="unlock_code";private static final String ACCESS_TOKEN="access_token";@@ -44,15 +42,11 @@ public class SecureItPreferences {private static final String PHONE_ID="phone_id";private static final String DIR_PATH = "/secureit";-- private static final String IMAGE_PATH = DIR_PATH+"/secureit";- private static final int MAX_IMAGES = 10;-- private static final String AUDIO_PATH = DIR_PATH+"/SecureIt_Audio";- private static final long AUDIO_LENGTH = 10000;-++ private Context context;public SecureItPreferences(Context context) {+ this.context = context;this.appSharedPrefs = context.getSharedPreferences(APP_SHARED_PREFS, Activity.MODE_PRIVATE);this.prefsEditor = appSharedPrefs.edit();}@@ -146,20 +140,7 @@ public class SecureItPreferences {public String getSmsNumber() {return appSharedPrefs.getString(SMS_NUMBER, "");}-- public void activateRemote(boolean active) {- prefsEditor.putBoolean(REMOTE_ACTIVE, active);- prefsEditor.commit();- }-- public boolean getRemoteActivation() {- return appSharedPrefs.getBoolean(REMOTE_ACTIVE, true);- }-- public void setRemoteEmail(String email) {- prefsEditor.putString(REMOTE_EMAIL, email);- prefsEditor.commit();- }+public void setUnlockCode(String unlockCode) {prefsEditor.putString(UNLOCK_CODE, unlockCode);@@ -169,11 +150,7 @@ public class SecureItPreferences {public String getUnlockCode() {return appSharedPrefs.getString(UNLOCK_CODE, "");}-- public String getRemoteEmail() {- return appSharedPrefs.getString(REMOTE_EMAIL, "");- }-+public void setAccessToken(String accessToken) {prefsEditor.putString(ACCESS_TOKEN, accessToken);prefsEditor.commit();@@ -199,15 +176,7 @@ public class SecureItPreferences {public void unsetDelegatedAccessToken() {prefsEditor.remove(DELEGATED_ACCESS_TOKEN);}-- public String getImagePath() {- return IMAGE_PATH;- }-- public int getMaxImages() {- return MAX_IMAGES;- }-+public void setPhoneId(String phoneId) {prefsEditor.putString(PHONE_ID, phoneId);prefsEditor.commit();@@ -225,16 +194,28 @@ public class SecureItPreferences {return DIR_PATH;}- public String getAudioPath() {- return AUDIO_PATH;+ public String getSMSText() {+ return context.getString(R.string.intrusion_detected);}-- public long getAudioLenght() {- return AUDIO_LENGTH;++ public String getImagePath ()+ {+ return "/phoneypot";}-- public String getSMSText() {- return "WARNING: SecureIt has detected an intrusion.\n"+- "PhoneId: "+getPhoneId();++ public int getMaxImages ()+ {+ return 10;+ }++ public String getAudioPath ()+ {+ return "/phoneypot";++ }++ public int getAudioLength ()+ {+ return 5000;}}diff --git a/src/main/java/me/ziccard/secureit/StartActivity.java b/src/main/java/me/ziccard/phoneypot/StartActivity.javasimilarity index 53%rename from src/main/java/me/ziccard/secureit/StartActivity.javarename to src/main/java/me/ziccard/phoneypot/StartActivity.javaindex 7ad2fe7..974f70f 100644--- a/src/main/java/me/ziccard/secureit/StartActivity.java+++ b/src/main/java/me/ziccard/phoneypot/StartActivity.java@@ -4,26 +4,30 @@*/-package me.ziccard.secureit;+package me.ziccard.phoneypot;import java.io.File;-import me.ziccard.secureit.async.upload.AuthenticatorTask;+import android.Manifest;+import android.app.AlertDialog;+import android.content.DialogInterface;+import android.content.res.Configuration;import android.os.Bundle;import android.os.Environment;import android.app.Activity;import android.content.Intent;import android.content.pm.PackageManager;+import android.support.v4.app.ActivityCompat;+import android.support.v4.content.ContextCompat;+import android.text.InputType;import android.util.Log;import android.view.View;import android.widget.Button;import android.widget.CheckBox;import android.widget.CompoundButton;import android.widget.EditText;-import android.widget.RelativeLayout;import android.widget.CompoundButton.OnCheckedChangeListener;import android.widget.Spinner;-import android.widget.Toast;public class StartActivity extends Activity {@@ -45,11 +49,7 @@ public class StartActivity extends Activity {/*** Checkboxes for enabled app options*/- final CheckBox accelerometerCheck = (CheckBox) this.findViewById(R.id.accelerometer_check);- final CheckBox cameraCheck = (CheckBox) this.findViewById(R.id.camera_check);- final CheckBox microphoneCheck = (CheckBox) this.findViewById(R.id.microphone_check);final CheckBox smsCheck = (CheckBox) this.findViewById(R.id.sms_check);- final CheckBox remoteCheck = (CheckBox) this.findViewById(R.id.remote_check);/** Detecting if the device has a front camera@@ -69,17 +69,8 @@ public class StartActivity extends Activity {* Detecting if the device has the flash* and configuring properly the check box*/- final CheckBox flashCheck = (CheckBox) findViewById(R.id.flash_check);- if (!pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) {- flashCheck.setEnabled(false);- }-- final RelativeLayout accelerometerOptions = (RelativeLayout) this.findViewById(R.id.accelerometer_options);- final RelativeLayout cameraOptions = (RelativeLayout) this.findViewById(R.id.camera_options);- final RelativeLayout microphoneOptions = (RelativeLayout) this.findViewById(R.id.microphone_options);- final RelativeLayout smsOptions = (RelativeLayout) this.findViewById(R.id.sms_options);- final RelativeLayout remoteOptions = (RelativeLayout) this.findViewById(R.id.remote_options);-++final Spinner accelerometerSensitivity = (Spinner)this.findViewById(R.id.accelerometer_sensitivity_spinner);final Spinner cameraSensitivity = (Spinner)@@ -89,97 +80,38 @@ public class StartActivity extends Activity {final EditText phoneNumber = (EditText)this.findViewById(R.id.phone_number);- final EditText email = (EditText)- this.findViewById(R.id.email);- final EditText password = (EditText)- this.findViewById(R.id.password);-- final EditText unlockCode = (EditText)- this.findViewById(R.id.unlock_code);--+final Button startButton = (Button) this.findViewById(R.id.start_button);-- accelerometerCheck.setOnCheckedChangeListener(new OnCheckedChangeListener() {-- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {- if (isChecked) {- accelerometerOptions.setVisibility(View.VISIBLE);- } else {- accelerometerOptions.setVisibility(View.GONE);- }- }- });- cameraCheck.setOnCheckedChangeListener(new OnCheckedChangeListener() {-- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {- if (isChecked) {- cameraOptions.setVisibility(View.VISIBLE);- } else {- cameraOptions.setVisibility(View.GONE);- }- }- });- microphoneCheck.setOnCheckedChangeListener(new OnCheckedChangeListener() {-- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {- if (isChecked) {- microphoneOptions.setVisibility(View.VISIBLE);- } else {- microphoneOptions.setVisibility(View.GONE);- }- }- });++smsCheck.setOnCheckedChangeListener(new OnCheckedChangeListener() {public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {if (isChecked) {- smsOptions.setVisibility(View.VISIBLE);- } else {- smsOptions.setVisibility(View.GONE);- }- }- });- remoteCheck.setOnCheckedChangeListener(new OnCheckedChangeListener() {-- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {- if (isChecked) {- remoteOptions.setVisibility(View.VISIBLE);- } else {- remoteOptions.setVisibility(View.GONE);- }+ askForPermission(Manifest.permission.SEND_SMS,6);+ }}});startButton.setOnClickListener(new View.OnClickListener() {public void onClick(View v) {-- if (accelerometerCheck.isChecked()) {+preferences.activateAccelerometer(true);preferences.setAccelerometerSensitivity((String)accelerometerSensitivity.getSelectedItem());- } else {- preferences.activateAccelerometer(false);- }- if (cameraCheck.isChecked()) {+preferences.activateCamera(true);- preferences.activateFlash(- flashCheck.isChecked());preferences.setCamera((String)selectCameraSpinner.getSelectedItem());preferences.setCameraSensitivity((String)cameraSensitivity.getSelectedItem());- } else {- preferences.activateCamera(false);- }- if (microphoneCheck.isChecked()) {++preferences.activateMicrophone(true);preferences.setMicrophoneSensitivity((String)microphoneSensitivity.getSelectedItem());- } else {- preferences.activateMicrophone(false);- }+if (smsCheck.isChecked() && !phoneNumber.getText().toString().equals("")) {Log.i("StartActivity", "Send message alert is active");preferences.activateSms(true);@@ -188,42 +120,27 @@ public class StartActivity extends Activity {} else {preferences.activateSms(false);}- if (remoteCheck.isChecked()) {- preferences.activateRemote(true);- preferences.setRemoteEmail(- email.getText().toString());- } else {- preferences.activateRemote(false);- }-- if (!unlockCode.getText().toString().equals("")) {- preferences.setUnlockCode(unlockCode.getText().toString());- } else {- /*- * We cannot start without an unlock code- */- Toast.makeText(StartActivity.this, "Empty unlock code", Toast.LENGTH_LONG).show();- return;- }-- if (preferences.getRemoteActivation() &&- preferences.getRemoteEmail() != null &&- !password.getText().toString().equals("")) {-- /*- * Authentication is set so we need to authenticate- */- AuthenticatorTask task = new AuthenticatorTask(StartActivity.this,- preferences.getRemoteEmail(),- password.getText().toString());- task.execute();- } else {- Intent intent = new Intent(- StartActivity.this,- MonitorActivity.class);-- StartActivity.this.startActivity(intent);- }++ AlertDialog.Builder alert = new AlertDialog.Builder(StartActivity.this);+ final EditText input = new EditText(StartActivity.this);+ input.setInputType(InputType.TYPE_CLASS_NUMBER);+ input.setRawInputType(Configuration.KEYBOARD_12KEY);+ alert.setView(input);+ alert.setTitle(R.string.unlock_title);+ alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {+ public void onClick(DialogInterface dialog, int whichButton) {++ preferences.setUnlockCode(input.getText().toString());+ startMonitoring();+ }+ });+ alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {+ public void onClick(DialogInterface dialog, int whichButton) {+++ }+ });+ alert.show();}});@@ -231,7 +148,6 @@ public class StartActivity extends Activity {* Loads preferences and sets view*/if (preferences.getAccelerometerActivation()) {- accelerometerCheck.setChecked(true);String sensitivity = preferences.getAccelerometerSensitivity();if (sensitivity.equals(SecureItPreferences.LOW))accelerometerSensitivity.setSelection(0);@@ -241,7 +157,6 @@ public class StartActivity extends Activity {accelerometerSensitivity.setSelection(2);}if (preferences.getCameraActivation()) {- cameraCheck.setChecked(true);String sensitivity = preferences.getCameraSensitivity();if (sensitivity.equals(SecureItPreferences.LOW))cameraSensitivity.setSelection(0);@@ -249,7 +164,6 @@ public class StartActivity extends Activity {cameraSensitivity.setSelection(1);else if (sensitivity.equals(SecureItPreferences.HIGH))cameraSensitivity.setSelection(2);- flashCheck.setChecked(preferences.getFlashActivation());String camera = preferences.getCamera();if (camera.equals(SecureItPreferences.FRONT))selectCameraSpinner.setSelection(0);@@ -257,7 +171,6 @@ public class StartActivity extends Activity {selectCameraSpinner.setSelection(1);}if (preferences.getMicrophoneActivation()) {- microphoneCheck.setChecked(true);String sensitivity = preferences.getMicrophoneSensitivity();if (sensitivity.equals(SecureItPreferences.LOW))microphoneSensitivity.setSelection(0);@@ -270,9 +183,69 @@ public class StartActivity extends Activity {smsCheck.setChecked(true);phoneNumber.setText(preferences.getSmsNumber());}- if (preferences.getRemoteActivation()) {- remoteCheck.setChecked(true);- email.setText(preferences.getRemoteEmail());- }++ askForPermission(Manifest.permission.ACCESS_FINE_LOCATION, 1);++ }++ @Override+ public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);++ switch (requestCode) {+ //Location+ case 1:+ askForPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE,2);+ break;+ case 2:+ askForPermission(Manifest.permission.CAMERA,3);++ break;+ case 3:+ askForPermission(Manifest.permission.BLUETOOTH_ADMIN,4);++ break;+ //Call+ case 4:+ askForPermission(Manifest.permission.ACCESS_NETWORK_STATE,5);++ break;++ case 5:+ askForPermission(Manifest.permission.SEND_SMS,6);++ break;+ }++ }+++ private void askForPermission(String permission, Integer requestCode) {+ if (ContextCompat.checkSelfPermission(StartActivity.this, permission) != PackageManager.PERMISSION_GRANTED) {++ // Should we show an explanation?+ if (ActivityCompat.shouldShowRequestPermissionRationale(StartActivity.this, permission)) {++ //This is called if user has denied the permission before+ //In this case I am just asking the permission again+ ActivityCompat.requestPermissions(StartActivity.this, new String[]{permission}, requestCode);++ } else {++ ActivityCompat.requestPermissions(StartActivity.this, new String[]{permission}, requestCode);+ }+ } else {+ }+ }++ private void startMonitoring ()+ {++ Intent intent = new Intent(+ StartActivity.this,+ MonitorActivity.class);++ StartActivity.this.startActivity(intent);}+}diff --git a/src/main/java/me/ziccard/secureit/async/AudioRecorderTask.java b/src/main/java/me/ziccard/phoneypot/async/AudioRecorderTask.javasimilarity index 84%rename from src/main/java/me/ziccard/secureit/async/AudioRecorderTask.javarename to src/main/java/me/ziccard/phoneypot/async/AudioRecorderTask.javaindex e03b179..a3aad2b 100644--- a/src/main/java/me/ziccard/secureit/async/AudioRecorderTask.java+++ b/src/main/java/me/ziccard/phoneypot/async/AudioRecorderTask.java@@ -4,21 +4,9 @@*/-package me.ziccard.secureit.async;+package me.ziccard.phoneypot.async;-import java.io.BufferedReader;-import java.io.File;-import java.io.InputStreamReader;-import org.apache.http.HttpException;-import org.apache.http.HttpResponse;-import org.apache.http.client.HttpClient;-import org.apache.http.client.methods.HttpPost;-import org.apache.http.entity.mime.HttpMultipartMode;-import org.apache.http.entity.mime.MultipartEntity;-import org.apache.http.entity.mime.content.FileBody;-import org.apache.http.impl.client.DefaultHttpClient;-import me.ziccard.secureit.SecureItPreferences;-import me.ziccard.secureit.config.Remote;+import me.ziccard.phoneypot.SecureItPreferences;import android.content.ContentValues;import android.content.Context;import android.media.MediaRecorder;@@ -119,7 +107,7 @@ public class AudioRecorderTask extends Thread {Log.i("AudioRecorderTask", "Start recording");recorder.start();try {- Thread.sleep(prefs.getAudioLenght());+ Thread.sleep(prefs.getAudioLength());} catch (InterruptedException e) {e.printStackTrace();}@@ -135,6 +123,7 @@ public class AudioRecorderTask extends Thread {* Uploading the audio*/Log.i("AudioRecorderTask", "Trying to upload");+ /**HttpClient httpclient = new DefaultHttpClient();HttpPost request = new HttpPost(Remote.HOST+@@ -145,17 +134,12 @@ public class AudioRecorderTask extends Thread {"URI: "+Remote.HOST+Remote.PHONES+"/"+phoneId+Remote.UPLOAD_AUDIO);- /*- * Getting the audio from the file system- */+MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);File audio = new File(audioPath);reqEntity.addPart("audio", new FileBody(audio, "audio/mp3"));request.setEntity(reqEntity);-- /*- * Authentication token- */+request.setHeader("access_token", accessToken);try {@@ -175,7 +159,9 @@ public class AudioRecorderTask extends Thread {}} catch (Exception e) {Log.e("DataUploaderTask", "Error uploading audio: "+audioPath);- }+ }++ **/}}diff --git a/src/main/java/me/ziccard/secureit/async/MicSamplerTask.java b/src/main/java/me/ziccard/phoneypot/async/MicSamplerTask.javasimilarity index 96%rename from src/main/java/me/ziccard/secureit/async/MicSamplerTask.javarename to src/main/java/me/ziccard/phoneypot/async/MicSamplerTask.javaindex c6296df..aa87150 100644--- a/src/main/java/me/ziccard/secureit/async/MicSamplerTask.java+++ b/src/main/java/me/ziccard/phoneypot/async/MicSamplerTask.java@@ -4,11 +4,11 @@*/-package me.ziccard.secureit.async;+package me.ziccard.phoneypot.async;import java.io.IOException;-import me.ziccard.secureit.codec.AudioCodec;+import me.ziccard.phoneypot.codec.AudioCodec;import android.os.AsyncTask;import android.util.Log;diff --git a/src/main/java/me/ziccard/secureit/async/MicrophoneTaskFactory.java b/src/main/java/me/ziccard/phoneypot/async/MicrophoneTaskFactory.javasimilarity index 97%rename from src/main/java/me/ziccard/secureit/async/MicrophoneTaskFactory.javarename to src/main/java/me/ziccard/phoneypot/async/MicrophoneTaskFactory.javaindex 66d0cfb..aa60256 100644--- a/src/main/java/me/ziccard/secureit/async/MicrophoneTaskFactory.java+++ b/src/main/java/me/ziccard/phoneypot/async/MicrophoneTaskFactory.java@@ -4,7 +4,7 @@*/-package me.ziccard.secureit.async;+package me.ziccard.phoneypot.async;import android.content.Context;diff --git a/src/main/java/me/ziccard/secureit/async/MotionAsyncTask.java b/src/main/java/me/ziccard/phoneypot/async/MotionAsyncTask.javasimilarity index 92%rename from src/main/java/me/ziccard/secureit/async/MotionAsyncTask.javarename to src/main/java/me/ziccard/phoneypot/async/MotionAsyncTask.javaindex eb48e3e..a48c143 100644--- a/src/main/java/me/ziccard/secureit/async/MotionAsyncTask.java+++ b/src/main/java/me/ziccard/phoneypot/async/MotionAsyncTask.java@@ -4,14 +4,14 @@*/-package me.ziccard.secureit.async;+package me.ziccard.phoneypot.async;import java.util.ArrayList;import java.util.List;-import me.ziccard.secureit.codec.ImageCodec;-import me.ziccard.secureit.motiondetection.IMotionDetector;-import me.ziccard.secureit.motiondetection.LuminanceMotionDetector;+import me.ziccard.phoneypot.codec.ImageCodec;+import me.ziccard.phoneypot.motiondetection.IMotionDetector;+import me.ziccard.phoneypot.motiondetection.LuminanceMotionDetector;import android.graphics.Bitmap;import android.graphics.Color;diff --git a/src/main/java/me/ziccard/secureit/codec/AudioCodec.java b/src/main/java/me/ziccard/phoneypot/codec/AudioCodec.javasimilarity index 98%rename from src/main/java/me/ziccard/secureit/codec/AudioCodec.javarename to src/main/java/me/ziccard/phoneypot/codec/AudioCodec.javaindex 71dfde0..e3ad80b 100644--- a/src/main/java/me/ziccard/secureit/codec/AudioCodec.java+++ b/src/main/java/me/ziccard/phoneypot/codec/AudioCodec.java@@ -4,7 +4,7 @@*/-package me.ziccard.secureit.codec;+package me.ziccard.phoneypot.codec;import java.io.IOException;import java.util.Arrays;diff --git a/src/main/java/me/ziccard/secureit/codec/ImageCodec.java b/src/main/java/me/ziccard/phoneypot/codec/ImageCodec.javasimilarity index 98%rename from src/main/java/me/ziccard/secureit/codec/ImageCodec.javarename to src/main/java/me/ziccard/phoneypot/codec/ImageCodec.javaindex d9bb88b..e66de93 100644--- a/src/main/java/me/ziccard/secureit/codec/ImageCodec.java+++ b/src/main/java/me/ziccard/phoneypot/codec/ImageCodec.java@@ -4,7 +4,7 @@*/-package me.ziccard.secureit.codec;+package me.ziccard.phoneypot.codec;import java.io.ByteArrayOutputStream;diff --git a/src/main/java/me/ziccard/secureit/motiondetection/IMotionDetector.java b/src/main/java/me/ziccard/phoneypot/motiondetection/IMotionDetector.javasimilarity index 92%rename from src/main/java/me/ziccard/secureit/motiondetection/IMotionDetector.javarename to src/main/java/me/ziccard/phoneypot/motiondetection/IMotionDetector.javaindex cfa4826..a73b190 100644--- a/src/main/java/me/ziccard/secureit/motiondetection/IMotionDetector.java+++ b/src/main/java/me/ziccard/phoneypot/motiondetection/IMotionDetector.java@@ -4,7 +4,7 @@*/-package me.ziccard.secureit.motiondetection;+package me.ziccard.phoneypot.motiondetection;import java.util.List;diff --git a/src/main/java/me/ziccard/secureit/motiondetection/LuminanceMotionDetector.java b/src/main/java/me/ziccard/phoneypot/motiondetection/LuminanceMotionDetector.javasimilarity index 97%rename from src/main/java/me/ziccard/secureit/motiondetection/LuminanceMotionDetector.javarename to src/main/java/me/ziccard/phoneypot/motiondetection/LuminanceMotionDetector.javaindex 3c651f0..0da75ab 100644--- a/src/main/java/me/ziccard/secureit/motiondetection/LuminanceMotionDetector.java+++ b/src/main/java/me/ziccard/phoneypot/motiondetection/LuminanceMotionDetector.java@@ -4,7 +4,7 @@*/-package me.ziccard.secureit.motiondetection;+package me.ziccard.phoneypot.motiondetection;import java.util.ArrayList;import java.util.List;diff --git a/src/main/java/me/ziccard/secureit/service/UploadService.java b/src/main/java/me/ziccard/phoneypot/service/MonitorService.javasimilarity index 57%rename from src/main/java/me/ziccard/secureit/service/UploadService.javarename to src/main/java/me/ziccard/phoneypot/service/MonitorService.javaindex 2a2b9ab..573551f 100644--- a/src/main/java/me/ziccard/secureit/service/UploadService.java+++ b/src/main/java/me/ziccard/phoneypot/service/MonitorService.java@@ -4,38 +4,28 @@*/-package me.ziccard.secureit.service;+package me.ziccard.phoneypot.service;++import me.ziccard.phoneypot.MonitorActivity;+import me.ziccard.phoneypot.R;+import me.ziccard.phoneypot.SecureItPreferences;-import me.ziccard.secureit.MonitorActivity;-import me.ziccard.secureit.R;-import me.ziccard.secureit.SecureItPreferences;-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.BluetoothPeriodicPositionUploaderTask;-import me.ziccard.secureit.async.upload.ImagesUploaderTask;-import me.ziccard.secureit.async.upload.PeriodicPositionUploaderTask;import android.annotation.SuppressLint;import android.app.Notification;import android.app.NotificationManager;import android.app.PendingIntent;import android.app.Service;-import android.content.Context;import android.content.Intent;-import android.net.ConnectivityManager;-import android.net.NetworkInfo;import android.os.AsyncTask;import android.os.Handler;import android.os.IBinder;import android.os.Message;import android.os.Messenger;import android.telephony.SmsManager;-import android.util.Log;import android.widget.Toast;@SuppressLint("HandlerLeak")-public class UploadService extends Service {+public class MonitorService extends Service {/*** Task used to upload position, is periodic, when we close the app@@ -96,15 +86,7 @@ public class UploadService extends Service {manager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);prefs = new SecureItPreferences(this);- try {- new BluetoothServerTask(this).start();- } catch (NoBluetoothException e) {- Log.i("UploadService", "Background bluetooth server not started");- CharSequence text = "Background bluetooth server not started";- int duration = Toast.LENGTH_SHORT;- Toast toast = Toast.makeText(this, text, duration);- toast.show();- }+showNotification();}@@ -158,8 +140,8 @@ public class UploadService extends Service {PendingIntent contentIntent = PendingIntent.getActivity(this, 0,toLaunch, PendingIntent.FLAG_UPDATE_CURRENT);- notification.setLatestEventInfo(this, "SecureService",- text, contentIntent);+// notification.setLatestEventInfo(this, "SecureService",+ // text, contentIntent);// Send the notification.// We use a string id because it is a unique number. We use it later to cancel.@@ -181,70 +163,7 @@ public class UploadService extends Service {*/already_alerted = true;- /*- * If remote communication with SecureIt back-end is required we- * need to check the type of connectivity- */- if (prefs.getRemoteActivation()) {- ConnectivityManager cm = (ConnectivityManager)this.getSystemService(Context.CONNECTIVITY_SERVICE);- boolean isConnected = false;- boolean isWifi = false;- NetworkInfo activeNetwork = cm.getActiveNetworkInfo();- if (activeNetwork != null) {- isConnected = activeNetwork.isConnectedOrConnecting();- isWifi = activeNetwork.getType() == ConnectivityManager.TYPE_WIFI;- }-- // Phone is connected- if (isConnected) {-- int connectivityType = ImagesUploaderTask.NO_CONNECTIVITY;-- // through wireless- if (isWifi) {- CharSequence text = "WIFI: sending a lot of data";- int duration = Toast.LENGTH_SHORT;- Toast toast = Toast.makeText(this, text, duration);- toast.show();- connectivityType = ImagesUploaderTask.WIFI_CONNECTIVITY;-- // through 3G- } else {- CharSequence text = "3G: sending a little of data";- int duration = Toast.LENGTH_SHORT;- Toast toast = Toast.makeText(this, text, duration);- toast.show();- connectivityType = ImagesUploaderTask.MOBILE_CONNECTIVITY;- }-- /*- * Image uploader task according to connectivity type- */- (new ImagesUploaderTask(this, connectivityType)).execute();- /*- * Audio recorder and uploader task- */- try {- MicrophoneTaskFactory.makeRecorder(this).start();- } catch (RecordLimitExceeded e) {- Log.e("UploadService", "An audio is being uploaded");- }- /*- * Periodic position uploader task- */- positionTask = new PeriodicPositionUploaderTask(this);- positionTask.execute();-- } else {- CharSequence text = "NO CONNECTIVITY: sending a bluetooth alert";- int duration = Toast.LENGTH_SHORT;- Toast toast = Toast.makeText(this, text, duration);- toast.show();-- positionTask = new BluetoothPeriodicPositionUploaderTask(this);- positionTask.execute();- }- }+/** If SMS mode is on we send an SMS alert to the specified* numberdiff --git a/src/main/java/me/ziccard/secureit/MicrophoneVolumePicker.java b/src/main/java/me/ziccard/secureit/MicrophoneVolumePicker.javadeleted file mode 100644index 9cac399..0000000--- a/src/main/java/me/ziccard/secureit/MicrophoneVolumePicker.java+++ /dev/null@@ -1,190 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit;--import android.content.Context;-import android.graphics.Canvas;-import android.graphics.Color;-import android.graphics.Paint;-import android.graphics.Rect;-import android.util.Log;-import android.view.View;--public class MicrophoneVolumePicker extends View {- Paint paint = new Paint();-- final int GREEN = 8453888; // 80FF00- final int ORANGE = 16744448; // FF8000- final int RED = 14549506; // DE0202-- private boolean _isMono = false;-- // margini dal bordo- final int PADDING_TOP = 30;- final int PADDING_LEFT = 30;- final int PADDING_RIGHT = 30;- final int PADDING_BOTTOM = 30;-- // DRAWING AREAS- private int _canvasWidth; // in android canvas.getWidth()- private int _canvasHeight; // in android canvas.getHeight()-- // area disponibile per il disegno- private int _drawableAreaHeight;- private int _drawableAreaWidth;-- // noise & cliping value- final int FULL_SCALE = 120;- int NOISE_THRESHOLD = 50;- final int CLIPPING_THRESHOLD = 70;-- // ogetto canvas- // private var _canvas:Shape;-- // fattore di decellerazione- final double FACTOR = 0.05;-- // valori visualizzati- private double _microfoneLeftValue;- private double _microfoneRightValue;-- // read values- private double microfoneReadLeftValue;- private double microfoneReadRightValue;-- public MicrophoneVolumePicker(Context context) {- super(context);- this.paint.setTextSize(19f);- }-- public void setNoiseThreshold(double noiseThreshold) {- this.NOISE_THRESHOLD = (int)noiseThreshold;- }-- /**- * Sets the read decibels values (for stereo)- */- public void setValues(double leftValue, double rightValue) {- microfoneReadLeftValue = leftValue;- microfoneReadRightValue = rightValue;- }-- @Override- public void onDraw(Canvas canvas) {-- Log.i("MicrophoneVolumePicker", "Creating view");-- _canvasWidth = canvas.getWidth();- _canvasHeight = canvas.getHeight();-- Log.i("MicrophoneVolumePicker", "CanvasWidth: " + _canvasWidth- + " CanvasHeight: " + _canvasHeight);-- _drawableAreaHeight = _canvasHeight - PADDING_TOP - PADDING_BOTTOM;- _drawableAreaWidth = _canvasWidth - PADDING_LEFT - PADDING_RIGHT;-- if (_isMono)- _microfoneLeftValue = _microfoneRightValue;-- _microfoneLeftValue = microfoneReadLeftValue;- _microfoneRightValue = microfoneReadRightValue;-- // DECELLAROZIONE PER SMOOTHING DEI DATI IN INGRESSO- _microfoneLeftValue = ((microfoneReadLeftValue < _microfoneLeftValue) ?- // SE VALORE RILEVATO E' MINORE APPLICA DECELLERAZIONE- ((microfoneReadLeftValue * FACTOR) + (_microfoneLeftValue * (1 - FACTOR)))- :- // ALTRIMENTI VAI AL VALORE APPENA RILEVATO- microfoneReadLeftValue);- _microfoneRightValue = ((microfoneReadRightValue < _microfoneRightValue) ? ((microfoneReadRightValue * FACTOR) + (_microfoneRightValue * (1 - FACTOR)))- : microfoneReadRightValue);-- // QUI EVENTUALI PROCEDURE DI QUANTIZZAZIONE E NORMALIZZAZIONE- // NELL'INTERVALLO 0-120 del segnale-- int colomnWidth = 40;- // DRAW LEFT CHANNEL- int originX = PADDING_LEFT + _drawableAreaWidth / 2 - 50;- drawVolumeRect(canvas, originX, colomnWidth, _microfoneLeftValue);-- // DRAWING RIGHT CHANNEL- originX = PADDING_LEFT + _drawableAreaWidth / 2 + 50;- drawVolumeRect(canvas, originX, colomnWidth, _microfoneRightValue);-- // draw plot- drawPlot(canvas, colomnWidth);-- }-- private void drawVolumeRect(Canvas canvas,- int originX,- int width,- double value) {-- double oneDbHeight = _drawableAreaHeight/((double)FULL_SCALE);-- int top = 0;- int bottom = 0;- // draws red rectangle: when sampled audio is greater than clipping threshold- if (value > CLIPPING_THRESHOLD) {- paint.setColor(Color.RED);- // determines the starting y-point for red area- bottom = PADDING_TOP + ((int)(oneDbHeight*(FULL_SCALE - CLIPPING_THRESHOLD)));- // determines the ending y-point for red area- top = PADDING_TOP + ((int)(oneDbHeight*(FULL_SCALE - value)));-- canvas.drawRect(new Rect(originX, top, originX + width, bottom), paint);-- }- // draws orange rectangle: when sampled audio is greater than noise threshold- if (value > NOISE_THRESHOLD) {- paint.setColor(Color.rgb(0xFF, 0x80, 0x00));- // determines the starting y-point for orange area- bottom = PADDING_TOP + ((int)(oneDbHeight*(FULL_SCALE - NOISE_THRESHOLD)));- // determines the ending y-point for orange area:- // if the sampled value is lower than clipping threshold then the value is the- // ending point otherwise the starting point of the red area is the ending point- top = PADDING_TOP + ((int)(oneDbHeight*(FULL_SCALE - Math.min(value, CLIPPING_THRESHOLD))));-- canvas.drawRect(new Rect(originX, top, originX + width, bottom), paint);- }-- // draws green rectangle: there must be something under noise threshold- paint.setColor(Color.GREEN);- bottom = PADDING_TOP + ((int)(oneDbHeight*FULL_SCALE));- top = PADDING_TOP + ((int)(oneDbHeight*(FULL_SCALE - Math.min(value, NOISE_THRESHOLD))));-- canvas.drawRect(new Rect(originX, top, originX + width, bottom), paint);-- }-- private void drawPlot(Canvas canvas, int width) {- float step = 10*(_drawableAreaHeight/((float)FULL_SCALE));- float lineLevel = PADDING_TOP + _drawableAreaHeight;- float left = PADDING_LEFT + _drawableAreaWidth/2 - 60;- float right = PADDING_LEFT + _drawableAreaWidth/2 + 100;- for (int i=0; i< FULL_SCALE/10 + 1; i++) {- paint.setColor(Color.BLACK);- if (i*10 == NOISE_THRESHOLD || i*10 == CLIPPING_THRESHOLD) {- paint.setStrokeWidth(3.0f);- canvas.drawLine(left, lineLevel, right, lineLevel, paint);- paint.setStrokeWidth(0);- } else {- canvas.drawLine(left, lineLevel, right, lineLevel, paint);- }- if (i%2 == 0) {- paint.setTextAlign(Paint.Align.RIGHT);- canvas.drawText(Integer.toString(i*10), left - 10, lineLevel, paint);- } else {- paint.setTextAlign(Paint.Align.LEFT);- canvas.drawText(Integer.toString(i*10), right + 10, lineLevel, paint);- }- lineLevel = lineLevel - step;- }- }--}\ No newline at end of filediff --git a/src/main/java/me/ziccard/secureit/MonitorActivity.java b/src/main/java/me/ziccard/secureit/MonitorActivity.javadeleted file mode 100644index b1159b8..0000000--- a/src/main/java/me/ziccard/secureit/MonitorActivity.java+++ /dev/null@@ -1,195 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit;--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.UploadService;-import android.app.AlertDialog;-import android.content.DialogInterface;-import android.content.Intent;-import android.os.Bundle;-import android.support.v4.app.Fragment;-import android.support.v4.app.FragmentActivity;-import android.support.v4.app.FragmentManager;-import android.support.v4.app.FragmentPagerAdapter;-import android.support.v4.view.ViewPager;-import android.text.InputType;-import android.util.Log;-import android.view.Menu;-import android.view.MenuItem;-import android.widget.EditText;-import android.widget.Toast;--import com.viewpagerindicator.TitlePageIndicator;-import com.viewpagerindicator.TitlePageIndicator.IndicatorStyle;--public class MonitorActivity extends FragmentActivity {-- private SecureItPreferences preferences = null;-- private static final String[] CONTENT = new String[] { "Accel.", "Camera",- "Mic."};- @Override- protected void onCreate(Bundle savedInstanceState) {- super.onCreate(savedInstanceState);-- preferences = new SecureItPreferences(getApplicationContext());-- setContentView(R.layout.activity_monitor);-- FragmentPagerAdapter adapter = new MonitorAdapter(- getSupportFragmentManager());-- ViewPager pager = (ViewPager)findViewById(R.id.pager);- pager.setAdapter(adapter);-- TitlePageIndicator indicator = (TitlePageIndicator)findViewById(R.id.indicator);- indicator.setViewPager(pager);- final float density = getResources().getDisplayMetrics().density;- indicator.setBackgroundColor(0x18FF0000);- indicator.setFooterColor(0xFFAA2222);- indicator.setFooterLineHeight(1 * density); //1dp- indicator.setFooterIndicatorHeight(3 * density); //3dp- indicator.setFooterIndicatorStyle(IndicatorStyle.Underline);- indicator.setTextColor(0xAA000000);- indicator.setSelectedColor(0xFF000000);- indicator.setSelectedBold(true);-- pager.setCurrentItem(1);-- /**- * Binding to the bluetooth service- */- startService(new Intent(this, UploadService.class));- }-- class MonitorAdapter extends FragmentPagerAdapter {-- private Fragment accelerometerFragment;-- private Fragment cameraFragment;-- private Fragment microphoneFragment;-- public MonitorAdapter(FragmentManager fm) {- super(fm);- }-- @Override- public Fragment getItem(int position) {- switch(position) {- case 0:- if (preferences.getAccelerometerActivation()) {- if (accelerometerFragment == null)- accelerometerFragment = new AccelerometerFragment();- return accelerometerFragment;- } else- return EmptyFragment.newInstance(CONTENT[0]);-- case 1:- if (preferences.getCameraActivation()) {- if (cameraFragment == null)- cameraFragment = new CameraFragment();- return cameraFragment;- } else- return EmptyFragment.newInstance(CONTENT[1]);- case 2:- if (preferences.getMicrophoneActivation()) {- if (microphoneFragment == null)- microphoneFragment = new MicrophoneFragment();- return microphoneFragment;- } else- return EmptyFragment.newInstance(CONTENT[2]);- }- return null;- }-- @Override- public CharSequence getPageTitle(int position) {- return CONTENT[position % CONTENT.length].toUpperCase();- }--- @Override- public int getCount() {- return CONTENT.length;- }- }-- @Override- public boolean onCreateOptionsMenu(Menu menu) {- getMenuInflater().inflate(R.menu.monitor_activity, menu);- return true;- }-- @Override- public boolean onOptionsItemSelected (MenuItem item) {- switch (item.getItemId()){- case R.id.menu_settings:- createUnlockDialog();- break;- }- return true;- }-- /**- * Closes the monitor activity and unset session properties- */- private void close() {- Intent intent = new Intent(- getApplicationContext(), StartActivity.class);- intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);- startActivity(intent);- stopService(new Intent(this, UploadService.class));- preferences.unsetAccessToken();- preferences.unsetDelegatedAccessToken();- preferences.unsetPhoneId();-- }-- /**- * When user closes the activity- */- @Override- public void onBackPressed() {- createUnlockDialog();- }-- /**- * Shows a dialog prompting the unlock code- */- private void createUnlockDialog() {- final AlertDialog.Builder builder = new AlertDialog.Builder(this);- builder.setTitle("Stop monitoring?");- final EditText input = new EditText(this);- input.setHint("Unlock code");- input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);- builder.setView(input);-- builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {- public void onClick(DialogInterface dialog, int whichButton) {- if (input.getText().toString().equals(preferences.getUnlockCode())) {- Log.i("MonitorActivity", "INPUT "+input.getText().toString());- Log.i("MonitorActivity", "STORED "+preferences.getUnlockCode());- dialog.dismiss();- close();- } else {- dialog.dismiss();- Toast.makeText(- getApplicationContext(),- "Wrong unlock code",- Toast.LENGTH_SHORT).show();- }- }- });-- builder.show();- }-}diff --git a/src/main/java/me/ziccard/secureit/async/BluetoothServerTask.java b/src/main/java/me/ziccard/secureit/async/BluetoothServerTask.javadeleted file mode 100644index 5659642..0000000--- a/src/main/java/me/ziccard/secureit/async/BluetoothServerTask.java+++ /dev/null@@ -1,153 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.async;--import java.io.IOException;-import java.io.ObjectInputStream;-import java.io.ObjectOutputStream;-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.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;-import android.bluetooth.BluetoothServerSocket;-import android.bluetooth.BluetoothSocket;-import android.content.Context;-import android.location.Location;-import android.location.LocationManager;-import android.util.Log;--public class BluetoothServerTask extends Thread {-- public class NoBluetoothException extends Exception {-- private static final long serialVersionUID = 4817843408138269806L;-- }-- private final BluetoothServerSocket mmServerSocket;-- private BluetoothAdapter mBluetoothAdapter;-- private Context context;-- public BluetoothServerTask(Context context) throws NoBluetoothException {-- Log.i("BluetoothServerTask", "Created");- mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();- if (mBluetoothAdapter == null) {- // Device does not support Bluetooth- throw new NoBluetoothException();-- }- this.context = context;- Log.i("BluetoothServerTask", "Got adapter");- // Use a temporary object that is later assigned to mmServerSocket,- // because mmServerSocket is final- BluetoothServerSocket tmp = null;- try {- // MY_UUID is the app's UUID string, also used by the client code- tmp = mBluetoothAdapter.listenUsingInsecureRfcommWithServiceRecord(- Remote.BLUETOOTH_NAME,- Remote.BLUETOOTH_UUID);- Log.i("BluetoothServerTask", "Created insecure server socket");- } catch (IOException e) {- throw new NoBluetoothException();- }- mmServerSocket = tmp;- }-- public void run() {- ObjectBluetoothSocket socket = null;- // Keep listening until exception occurs or a socket is returned- while (true) {- try {- Log.i("BluetoothServerTask", "Waiting for a connection");-- BluetoothSocket tmp = mmServerSocket.accept();-- socket = new ObjectBluetoothSocket(tmp);- Log.i("BluetoothServerTask", "Server creted a socket");-- } catch (IOException e) {- Log.i("AcceptException", e.getStackTrace().toString());- e.printStackTrace();- break;- }- // If a connection was accepted- if (socket != null) {- // Do work to manage the connection (in a separate thread)- manageConnectedSocket(socket);- }- }- }-- /** Will cancel the listening socket, and cause the thread to finish */- public void cancel() {- try {- mmServerSocket.close();- } catch (IOException e) { }- }-- /**- * Manage the new connection- */- public void manageConnectedSocket(final ObjectBluetoothSocket socket) {- Log.i("BluetoothServerTask", "Connection accepted");- (new Thread() {- @Override- public void run() {- try {- //Receiving first hello message- ObjectInputStream instream = socket.getInputStream();- HelloMessage message = (HelloMessage) instream.readObject();- Log.i("BluetoothServerTask", "Received message "+message.getType().toString());-- /*- * Get last known location- */- LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);- String locationProvider = LocationManager.NETWORK_PROVIDER;- Location lastKnownLocation = locationManager.getLastKnownLocation(locationProvider);-- //Sending key request- ObjectOutputStream ostream = socket.getOutputStream();- MessageBuilder builder = new MessageBuilder();- builder.setLat(lastKnownLocation.getLatitude());- builder.setLng(lastKnownLocation.getLongitude());- builder.setTimestamp(new Date());-- KeyRequest keyRequest = (KeyRequest) builder.buildMessage(MessageType.KEY_REQUEST);- ostream.writeObject(keyRequest);- Log.i("BluetoothServerTask", "Sent message " + keyRequest.getType().toString());-- //Receiving key response- KeyResponse keyResponse = (KeyResponse) instream.readObject();- Log.i("BluetoothServerTask", "Received message "+keyResponse.getType().toString());-- ostream.writeObject(new String("STOP"));-- new DelegatedPositionUploaderTask(- message.getPhoneId(),- keyRequest.getLat(),- keyRequest.getLng(),- keyResponse.getAccessKey()).execute();-- socket.close();- } catch (Exception e) {- Log.d("BLUETOOTH_COMMS", e.getMessage());- }- }- }).start();- }-}\ No newline at end of filediff --git a/src/main/java/me/ziccard/secureit/async/upload/AuthenticatorTask.java b/src/main/java/me/ziccard/secureit/async/upload/AuthenticatorTask.javadeleted file mode 100644index 260fa4b..0000000--- a/src/main/java/me/ziccard/secureit/async/upload/AuthenticatorTask.java+++ /dev/null@@ -1,233 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.async.upload;--import java.io.BufferedReader;-import java.io.IOException;-import java.io.InputStreamReader;-import java.util.ArrayList;-import java.util.List;-import me.ziccard.secureit.MonitorActivity;-import me.ziccard.secureit.SecureItPreferences;-import me.ziccard.secureit.config.Remote;-import org.apache.http.HttpResponse;-import org.apache.http.HttpStatus;-import org.apache.http.NameValuePair;-import org.apache.http.client.ClientProtocolException;-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.json.JSONException;-import org.json.JSONObject;-import org.json.JSONTokener;-import android.app.Activity;-import android.app.AlertDialog;-import android.app.ProgressDialog;-import android.content.Context;-import android.content.DialogInterface;-import android.content.Intent;-import android.os.AsyncTask;-import android.os.Build;-import android.telephony.TelephonyManager;-import android.util.Log;--public class AuthenticatorTask extends AsyncTask<Void, Void, Void>{-- /**- * Reference activity- */- private Activity activity;-- /**- * Username- */- private String username;-- /**- * Password- */- private String password;-- /**- * Progress dialog- */- private ProgressDialog dialog;-- /**- * Authentication token- */- private String accessToken;-- /**- * Delegated authentication token- */- private String delegatedAccessToken;-- /**- * True iff authentication has failed- */- private Boolean authenticationFailure = false;-- /**- * Manager to get device infos- */- private TelephonyManager manager;-- public AuthenticatorTask(Activity activity, String username, String password) {- this.activity = activity;- this.username = username;- this.password = password;- this.manager = (TelephonyManager) activity.- getSystemService(Context.TELEPHONY_SERVICE);- }-- /**- * Shows an authentication failure dialog- */- public void showFailureDialog() {- AlertDialog.Builder builder = new AlertDialog.Builder(activity);- builder.setMessage("Authentication failed")- .setCancelable(false)- .setPositiveButton("Ok", new DialogInterface.OnClickListener() {-- public void onClick(DialogInterface dialog, int which) {- // TODO Auto-generated method stub-- }- });- AlertDialog alertDialog = builder.create();- alertDialog.show();- }-- @Override- protected void onPreExecute() {- dialog = new ProgressDialog(activity);- dialog.setCancelable(false);- dialog.setTitle("Authenticating");- dialog.setMessage("Trying to authenticate");- dialog.show();- }-- @Override- protected Void doInBackground(Void... params) {- /*- * PHASE1: Authenticate- */- HttpClient httpclient = new DefaultHttpClient();- HttpPost httppost = new HttpPost(Remote.HOST+Remote.ACCESS_TOKEN);- HttpResponse response = null;- try {- // Add your data- List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);- nameValuePairs.add(new BasicNameValuePair("email", username));- nameValuePairs.add(new BasicNameValuePair("password", password));- httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));-- // Execute HTTP Post Request-- response = httpclient.execute(httppost);-- if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {- authenticationFailure = true;- return null;- }- //accessToken = org.apache.http.util.EntityUtils.toString(response.getEntity());- //Log.i("AuthenticatorTask", accessToken);-- } catch (ClientProtocolException e) {- authenticationFailure = true;- e.printStackTrace();- } catch (IOException e) {- authenticationFailure = true;- e.printStackTrace();- }-- try {- if (response != null) {-- /*- * Retrieving access token from response- */- BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));- StringBuilder builder = new StringBuilder();- for (String line = null; (line = reader.readLine()) != null;) {- builder.append(line).append("\n");- }-- Log.i("AuthenticatorToken", "FIRST RESPONSE:\n"+builder.toString());-- JSONTokener tokener = new JSONTokener(builder.toString());- JSONObject finalResult = new JSONObject(tokener);- accessToken = finalResult.getString("access_token");- delegatedAccessToken = finalResult.getString("delegated_access_token");-- /*- * PHASE2: Register phone- */- httppost = new HttpPost(Remote.HOST+Remote.PHONES);--- List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);- nameValuePairs.add(new BasicNameValuePair("id",- manager.getDeviceId()));- nameValuePairs.add(new BasicNameValuePair("model",- Build.MANUFACTURER+" "+Build.PRODUCT));- nameValuePairs.add(new BasicNameValuePair("version", "VERSION"));- httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));-- httppost.addHeader("access_token", accessToken);-- // Execute HTTP Post Request- response = httpclient.execute(httppost);--- if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {- authenticationFailure = true;- return null;- }- //accessToken = org.apache.http.util.EntityUtils.toString(response.getEntity());- Log.i("AuthenticatorTask", accessToken);-- /*- * Storing access token- */- SecureItPreferences prefs = new SecureItPreferences(activity);- prefs.setAccessToken(accessToken);- prefs.setDelegatedAccessToken(delegatedAccessToken);- prefs.setPhoneId(manager.getDeviceId());- }-- } catch (ClientProtocolException e) {- authenticationFailure = true;- e.printStackTrace();- } catch (IOException e) {- authenticationFailure = true;- e.printStackTrace();- } catch (JSONException e) {- authenticationFailure = true;- e.printStackTrace();- }- return null;-- }-- @Override- protected void onPostExecute(Void result) {- super.onPostExecute(result);- dialog.dismiss();- if (!authenticationFailure) {- Intent intent = new Intent(- activity,- MonitorActivity.class);- activity.startActivity(intent);- } else {- showFailureDialog();- }- }-}diff --git a/src/main/java/me/ziccard/secureit/async/upload/BluetoothPeriodicPositionUploaderTask.java b/src/main/java/me/ziccard/secureit/async/upload/BluetoothPeriodicPositionUploaderTask.javadeleted file mode 100644index 49a1ae1..0000000--- a/src/main/java/me/ziccard/secureit/async/upload/BluetoothPeriodicPositionUploaderTask.java+++ /dev/null@@ -1,198 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.async.upload;--import java.io.ObjectInputStream;-import java.io.ObjectOutputStream;-import java.util.ArrayList;-import java.util.Date;--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.KeyRequest;-import me.ziccard.secureit.messages.MessageBuilder;-import me.ziccard.secureit.messages.MessageType;-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.os.AsyncTask;-import android.util.Log;-import android.widget.Toast;--public class BluetoothPeriodicPositionUploaderTask extends AsyncTask<Void, Void, Void> {-- private Context context;-- /**- * Boolean true iff last thread iterations position has been sent- */- private boolean dataSent = false;-- private SecureItPreferences prefs;-- /**- * Adapter for bluetooth services- */- private BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();-- /**- * Creates a BroadcastReceiver for ACTION_FOUND and ACTION_DISCOVERY_FINISHED- */- private final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {-- private ArrayList<BluetoothDevice> devices = new ArrayList<BluetoothDevice>();-- @Override- public void onReceive(Context context, Intent intent) {- String action = intent.getAction();- // When discovery finds a device- if (BluetoothDevice.ACTION_FOUND.equals(action)) {- // Get the BluetoothDevice object from the Intent- BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);- devices.add(device);-- Log.i("BluetoothPeriodicPositionUploaderTask", "Discovered "+device.getName());- CharSequence text = "Discovered "+device.getName();- int duration = Toast.LENGTH_SHORT;- Toast toast = Toast.makeText(context, text, duration);- toast.show();-- return;- }- // When ending the discovery- if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {- for (BluetoothDevice device : devices){- Log.i("DISCOVERY", "FINISHED");- try {- BluetoothSocket tmp = null;- tmp = device.createInsecureRfcommSocketToServiceRecord(Remote.BLUETOOTH_UUID);-- if (tmp != null) {-- Log.i("BluetoothPeriodicPositionUploaderTask", "Trying to connect to " + device.getName());-- adapter.cancelDiscovery();- tmp.connect();-- Log.i("BluetoothPeriodicPositionUploaderTask", "Connected to " + device.getName());-- ObjectBluetoothSocket socket = new ObjectBluetoothSocket(tmp);-- MessageBuilder builder = new MessageBuilder();- builder.setPhoneId(phoneId);- builder.setTimestamp(new Date());- //Sending hello message- BluetoothMessage message = builder.buildMessage(MessageType.HELLO);- ObjectOutputStream ostream = socket.getOutputStream();- ostream.writeObject(message);- Log.i("BluetoothPeriodicPositionUploaderTask", "Sent message " + message.getType().toString());-- //Receiving key request- ObjectInputStream instream = socket.getInputStream();- KeyRequest keyRequestMessage = (KeyRequest) instream.readObject();- Log.i("BluetoothPeriodicPositionUploaderTask", "Received message "+keyRequestMessage.getType().toString());-- builder.setLat(keyRequestMessage.getLat());- builder.setLng(keyRequestMessage.getLng());- builder.setTimestamp(keyRequestMessage.getTimestamp());- builder.setPassword(delegatedAccessToken);-- Log.i("BluetoothPeriodicPositionUploaderTask",delegatedAccessToken);-- message = builder.buildMessage(MessageType.KEY_RESPONSE);- ostream.writeObject(message);- Log.i("BluetoothPeriodicPositionUploaderTask", "Sent message " + message.getType().toString());-- //Reading last object- instream.readObject();-- socket.close();-- CharSequence text = "Bluetooth message sent";- int duration = Toast.LENGTH_SHORT;- Toast toast = Toast.makeText(context, text, duration);- toast.show();-- dataSent = true;- }- } catch (Exception e) {- e.printStackTrace();- }- }- context.unregisterReceiver(broadcastReceiver);- }- }- };-- /**- * ID of the phone sending data- */- private String phoneId = null;-- /**- * Access token of the phone sending data- */- private String delegatedAccessToken = null;-- /**- * Constructor- * @param context- * @param lat- * @param lng- */- public BluetoothPeriodicPositionUploaderTask(Context context) {- this.context = context;- prefs = new SecureItPreferences(context);- this.phoneId = prefs.getPhoneId();- this.delegatedAccessToken = prefs.getDelegatedAccessToken();-- Log.i("BluetoothPeriodicPositionUploaderTask", "Created");- }-- @Override- protected void onCancelled () {- Log.i("BluetoothPeriodicPositionUploaderTask", "Task stopped");- }-- @Override- protected Void doInBackground(Void... params) {-- while(true) {-- this.context.registerReceiver(broadcastReceiver,- new IntentFilter(BluetoothDevice.ACTION_FOUND));-- this.context.registerReceiver(broadcastReceiver,- new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED));-- Boolean runningBluetooth = adapter.startDiscovery();-- if (!runningBluetooth) {- Log.i("BluetoothPeriodicPositionUploaderTask", "Bluetooth is off");- } else {- Log.i("BluetoothPeriodicPositionUploaderTask", "Started discovery");- }-- if (isCancelled()) {- return null;- }-- try {- if (dataSent) Thread.sleep(3600*1000);- else Thread.sleep(60*1000);- } catch (InterruptedException e) {- return null;- }- }- }-}\ No newline at end of filediff --git a/src/main/java/me/ziccard/secureit/async/upload/DelegatedPositionUploaderTask.java b/src/main/java/me/ziccard/secureit/async/upload/DelegatedPositionUploaderTask.javadeleted file mode 100644index f8dba34..0000000--- a/src/main/java/me/ziccard/secureit/async/upload/DelegatedPositionUploaderTask.java+++ /dev/null@@ -1,110 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.async.upload;--import java.io.BufferedReader;-import java.io.InputStreamReader;-import java.util.ArrayList;-import java.util.List;-import me.ziccard.secureit.config.Remote;-import org.apache.http.HttpException;-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 android.os.AsyncTask;-import android.util.Log;--public class DelegatedPositionUploaderTask extends AsyncTask<Void, Void, Void> {-- /**- * Latitude of the last position to be uploaded- */- protected double lat;-- /**- * Longitude of the last position to be uploaded- */- protected double lng;-- /**- * ID of the phone sending data- */- private String phoneId = null;-- /**- * Access token of the phone sending data- */- private String accessKey = null;-- /**- * Constructor- * @param context- * @param lat- * @param lng- */- public DelegatedPositionUploaderTask(String phoneId, double lat, double lng, String accessKey) {-- this.lat = lat;- this.lng = lng;- this.phoneId = phoneId;- this.accessKey = accessKey;-- }-- @Override- protected Void doInBackground(Void... params) {-- while(true) {-- Log.i("DelegatedPositionUploaderTask", "Started");-- HttpClient client = new DefaultHttpClient();-- /*- * Send the last- * detected position to /phone/phoneId/position [POST]- */- HttpPost request = new HttpPost(- Remote.HOST+- Remote.PHONES+"/"+phoneId+- Remote.DELEGATED_UPLOAD_POSITION);-- /*- * Adding latitude and longitude- */- List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);- nameValuePairs.add(new BasicNameValuePair("lat", ""+lat));- nameValuePairs.add(new BasicNameValuePair("long", ""+lng));- nameValuePairs.add(new BasicNameValuePair("access_key", accessKey));- try {- request.setEntity(new UrlEncodedFormEntity(nameValuePairs));--- HttpResponse response = client.execute(request);-- BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));- StringBuilder builder = new StringBuilder();- for (String line = null; (line = reader.readLine()) != null;) {- builder.append(line).append("\n");- }-- Log.i("PeriodicPositionUploaderTask", "Response:\n"+builder.toString());-- if (response.getStatusLine().getStatusCode() != 200) {- throw new HttpException();- }-- } catch (Exception e) {- Log.e("DelegatedPositionUploaderTask", "Error uploading delegated location");- }- }- }-}\ No newline at end of filediff --git a/src/main/java/me/ziccard/secureit/async/upload/ImagesUploaderTask.java b/src/main/java/me/ziccard/secureit/async/upload/ImagesUploaderTask.javadeleted file mode 100644index 048ad04..0000000--- a/src/main/java/me/ziccard/secureit/async/upload/ImagesUploaderTask.java+++ /dev/null@@ -1,153 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.async.upload;--import java.io.BufferedReader;-import java.io.File;-import java.io.InputStreamReader;--import me.ziccard.secureit.SecureItPreferences;-import me.ziccard.secureit.config.Remote;-import org.apache.http.HttpException;-import org.apache.http.HttpResponse;-import org.apache.http.client.HttpClient;-import org.apache.http.client.methods.HttpPost;-import org.apache.http.entity.mime.HttpMultipartMode;-import org.apache.http.entity.mime.MultipartEntity;-import org.apache.http.entity.mime.content.FileBody;-import org.apache.http.impl.client.DefaultHttpClient;-import android.content.Context;-import android.os.AsyncTask;-import android.os.Environment;-import android.util.Log;--public class ImagesUploaderTask extends AsyncTask<Void, Void, Void> {-- @SuppressWarnings("unused")- private Context context;-- private SecureItPreferences prefs;-- public static final int WIFI_CONNECTIVITY = 0;-- public static final int MOBILE_CONNECTIVITY = 1;-- public static final int NO_CONNECTIVITY = 2;-- /**- * ID of the phone sending data- */- private String phoneId = null;-- /**- * Access token of the phone sending data- */- private String accessToken = null;-- /**- * Private connectivity type- */- private int connectivityType;-- /**- * Constructor- * @param phoneId- * @param accessToken- */- public ImagesUploaderTask(Context context, int connectivityType) {- this.context = context;- prefs = new SecureItPreferences(context);-- this.phoneId = prefs.getPhoneId();- this.accessToken = prefs.getAccessToken();- this.connectivityType = connectivityType;- }--- @Override- protected Void doInBackground(Void... params) {- HttpClient client = new DefaultHttpClient();-- Log.i("ImagesUploaderTask","Started");-- int imagesToUpload = 0;-- /*- * If we are using mobile connectivity we upload half of the images- * stored- */- if (connectivityType == WIFI_CONNECTIVITY) {- imagesToUpload = prefs.getMaxImages();- }- if (connectivityType == MOBILE_CONNECTIVITY) {- imagesToUpload = prefs.getMaxImages() / 2;- }- if (connectivityType == NO_CONNECTIVITY) {- imagesToUpload = 0;- }-- for (int imageCount = 0; imageCount < imagesToUpload; imageCount++) {-- String path = Environment.getExternalStorageDirectory().getPath() +- prefs.getImagePath() +- imageCount +- ".jpg";-- HttpPost request = new HttpPost(- Remote.HOST+- Remote.PHONES+"/"+phoneId+- Remote.UPLOAD_IMAGES);-- Log.i("ImagesUploaderTask", "Uploading image "+path);-- /*- * Get image from filesystem- */- File image = new File(path);-- //Only if the image exists we upload it- if (image.exists()) {-- Log.i("ImagesUploaderTask", "Image exists");-- /*- * Getting the image from the file system- */- MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);- reqEntity.addPart("image", new FileBody(image, "image/jpeg"));- request.setEntity(reqEntity);-- /*- * Setting the access token- */- request.setHeader("access_token", accessToken);-- try {- HttpResponse response = client.execute(request);-- BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));- StringBuilder builder = new StringBuilder();- for (String line = null; (line = reader.readLine()) != null;) {- builder.append(line).append("\n");- }-- Log.i("ImagesRecorderTask", "Response:\n"+builder.toString());-- if (response.getStatusLine().getStatusCode() != 200) {- throw new HttpException();- }- } catch (Exception e) {- Log.e("ImageUploaderTask", "Error uploading image: "+path);- }- //otherwise no other image exists- } else {- return null;- }- }- return null;- }-}diff --git a/src/main/java/me/ziccard/secureit/async/upload/PeriodicPositionUploaderTask.java b/src/main/java/me/ziccard/secureit/async/upload/PeriodicPositionUploaderTask.javadeleted file mode 100644index 770e2cb..0000000--- a/src/main/java/me/ziccard/secureit/async/upload/PeriodicPositionUploaderTask.java+++ /dev/null@@ -1,212 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.async.upload;--import java.io.BufferedReader;-import java.io.InputStreamReader;-import java.util.ArrayList;-import java.util.List;-import me.ziccard.secureit.SecureItPreferences;-import me.ziccard.secureit.config.Remote;-import org.apache.http.HttpException;-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 android.content.Context;-import android.location.Location;-import android.location.LocationListener;-import android.location.LocationManager;-import android.net.ConnectivityManager;-import android.net.NetworkInfo;-import android.os.AsyncTask;-import android.os.Bundle;-import android.util.Log;--public class PeriodicPositionUploaderTask extends AsyncTask<Void, Void, Void> implements LocationListener {-- private static final double INVALID_VALUE = Double.MAX_VALUE;-- /**- * In case 3G and WIFI are turned off we start the upload- * using bluetooth- */- private BluetoothPeriodicPositionUploaderTask bluetoothTask;-- /**- * Context to retrieve shared preferences- */- private Context context;-- /**- * Boolean true iff last thread iterations position has been sent- */- private boolean dataSent = false;-- private SecureItPreferences prefs;-- /**- * Latitude of the last position to be uploaded- */- protected double lat = INVALID_VALUE;-- /**- * Longitude of the last position to be uploaded- */- protected double lng = INVALID_VALUE;-- /**- * Manager to retrieve location- */- private LocationManager locationManager = null;-- /**- * ID of the phone sending data- */- private String phoneId = null;-- /**- * Access token of the phone sending data- */- private String accessToken = null;-- /**- * Constructor- * @param context- * @param lat- * @param lng- */- public PeriodicPositionUploaderTask(Context context) {- this.context = context;- locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);-- if (locationManager.getAllProviders().contains(LocationManager.NETWORK_PROVIDER))- locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);- if (locationManager.getAllProviders().contains(LocationManager.GPS_PROVIDER))- locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);-- prefs = new SecureItPreferences(context);-- this.phoneId = prefs.getPhoneId();- this.accessToken = prefs.getAccessToken();- }-- @Override- protected void onCancelled () {- if (bluetoothTask != null) bluetoothTask.cancel(true);- else locationManager.removeUpdates(this);- }-- @Override- protected Void doInBackground(Void... params) {-- while(true) {-- Log.i("PeriodicPositionUploaderTask", "Started");-- if (isCancelled()) {- return null;- }-- HttpClient client = new DefaultHttpClient();-- /*- * Send the last- * detected position to /phone/phoneId/position [POST]- */- HttpPost request = new HttpPost(- Remote.HOST+- Remote.PHONES+"/"+phoneId+- Remote.UPLOAD_POSITION);-- /*- * Adding latitude and longitude- */- List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);- nameValuePairs.add(new BasicNameValuePair("lat", ""+lat));- nameValuePairs.add(new BasicNameValuePair("long", ""+lng));- try {- request.setEntity(new UrlEncodedFormEntity(nameValuePairs));-- /*- * Access token- */- request.setHeader("access_token", accessToken);-- /*- * We send position only if Gps/Network fixed- */-- if (lat != Double.MAX_VALUE && lng != Double.MAX_VALUE) {- dataSent = true;- HttpResponse response = client.execute(request);-- BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));- StringBuilder builder = new StringBuilder();- for (String line = null; (line = reader.readLine()) != null;) {- builder.append(line).append("\n");- }-- Log.i("PeriodicPositionUploaderTask", "Response:\n"+builder.toString());-- if (response.getStatusLine().getStatusCode() != 200) {- throw new HttpException();- }- } else {- Log.i("PeriodicPositionUploaderTask", "We have no position data yet");- dataSent = false;- }- } catch (Exception e) {- Log.e("DataUploaderTask", "Error uploading location");- /*- * We check if we still have connectivity, if this is not true- * we start BluetoothPeriodicPositionUploader- */- ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);- NetworkInfo activeNetwork = cm.getActiveNetworkInfo();- boolean isConnected = activeNetwork.isConnectedOrConnecting();- if (!isConnected) {- bluetoothTask = new BluetoothPeriodicPositionUploaderTask(context);- bluetoothTask.execute();- locationManager.removeUpdates(this);- return null;- }- }-- try {- if (dataSent) Thread.sleep(3600*1000);- else Thread.sleep(60*1000);- } catch (InterruptedException e) {- return null;- }- }- }-- public void onLocationChanged(Location location) {- lat = location.getLatitude();- lng = location.getLongitude();- }-- public void onProviderDisabled(String provider) {- // Nothing interesting to do-- }-- public void onProviderEnabled(String provider) {- // Nothing interesting to do-- }-- public void onStatusChanged(String provider, int status, Bundle extras) {- // Nothing interesting to do-- }-}\ No newline at end of filediff --git a/src/main/java/me/ziccard/secureit/bluetooth/ObjectBluetoothSocket.java b/src/main/java/me/ziccard/secureit/bluetooth/ObjectBluetoothSocket.javadeleted file mode 100644index 95b61d2..0000000--- a/src/main/java/me/ziccard/secureit/bluetooth/ObjectBluetoothSocket.java+++ /dev/null@@ -1,57 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.bluetooth;--import java.io.IOException;-import java.io.ObjectInputStream;-import java.io.ObjectOutputStream;--import android.bluetooth.BluetoothSocket;--public class ObjectBluetoothSocket {-- /**- * Original byte oriented socket- */- private BluetoothSocket socket;-- /**- * Object output stream associated with socket- */- private ObjectOutputStream outputStream;-- /**- * Object input stream associated with socket- */- private ObjectInputStream inputStream;-- public ObjectBluetoothSocket(BluetoothSocket socket) throws IOException {- this.socket = socket;- this.outputStream = new ObjectOutputStream(this.socket.getOutputStream());- this.inputStream = new ObjectInputStream(this.socket.getInputStream());- }-- public ObjectInputStream getInputStream() {- return inputStream;- }-- public ObjectOutputStream getOutputStream() {- return outputStream;- }-- public void close() throws IOException {- outputStream.close();- inputStream.close();- socket.close();- }-- public void connect() throws IOException {- socket.connect();- }---}diff --git a/src/main/java/me/ziccard/secureit/config/Remote.java b/src/main/java/me/ziccard/secureit/config/Remote.javadeleted file mode 100644index a665e4b..0000000--- a/src/main/java/me/ziccard/secureit/config/Remote.java+++ /dev/null@@ -1,31 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.config;--import java.util.UUID;--public class Remote {-- public static final String HOST = "http://10.192.6.90:9000/";-- public static final String ACCESS_TOKEN = "users/accesstoken";-- public static final String PHONES = "api/phones";-- public static final String UPLOAD_IMAGES = "/image";-- public static final String UPLOAD_AUDIO = "/audio";-- public static final String UPLOAD_POSITION = "/position";-- public static final String DELEGATED_UPLOAD_POSITION = "/position/delegated";-- public static final String BLUETOOTH_NAME = "me.ziccard.secureit";-- public static final UUID BLUETOOTH_UUID =- UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");-}diff --git a/src/main/java/me/ziccard/secureit/fragment/AccelerometerFragment.java b/src/main/java/me/ziccard/secureit/fragment/AccelerometerFragment.javadeleted file mode 100644index b216350..0000000--- a/src/main/java/me/ziccard/secureit/fragment/AccelerometerFragment.java+++ /dev/null@@ -1,221 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.fragment;--import me.ziccard.secureit.R;-import me.ziccard.secureit.SecureItPreferences;-import me.ziccard.secureit.service.UploadService;-import android.app.Activity;-import android.content.ComponentName;-import android.content.Context;-import android.content.Intent;-import android.content.ServiceConnection;-import android.hardware.Sensor;-import android.hardware.SensorEvent;-import android.hardware.SensorEventListener;-import android.hardware.SensorManager;-import android.os.Bundle;-import android.os.IBinder;-import android.os.Message;-import android.os.Messenger;-import android.os.RemoteException;-import android.support.v4.app.Fragment;-import android.util.Log;-import android.view.LayoutInflater;-import android.view.View;-import android.view.ViewGroup;-import android.widget.FrameLayout;-import android.widget.TextView;-import me.ziccard.secureit.opengl.AccelerometerGLSurfaceView;--public class AccelerometerFragment extends Fragment implements SensorEventListener {-- // For shake motion detection.- private SensorManager sensorMgr;-- /**- * Accelerometer sensor- */- private Sensor accelerometer;-- /**- * OpenGL view to show accelerometer informations- */- private AccelerometerGLSurfaceView view;-- /**- * Last update of the accelerometer- */- private long lastUpdate = -1;-- /**- * Current accelerometer values- */- private float accel_values[];-- /**- * Last accelerometer values- */- private float last_accel_values[];-- /**- * Data field used to retrieve application prefences- */- private SecureItPreferences prefs;-- /**- * Shake threshold- */- private static int SHAKE_THRESHOLD = 2300;-- /**- * Text showing accelerometer values- */- private TextView accelerometerText;- private int maxAlertPeriod = 30;- private int remainingAlertPeriod = 0;- private boolean alert = false;--- public void onAccuracyChanged(Sensor sensor, int accuracy) {- // Safe not to implement-- }-- public void onSensorChanged(SensorEvent event) {- long curTime = System.currentTimeMillis();- // only allow one update every 100ms.- if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {- if ((curTime - lastUpdate) > 100) {- long diffTime = (curTime - lastUpdate);- lastUpdate = curTime;-- accel_values = event.values.clone();-- if (alert && remainingAlertPeriod > 0) {- remainingAlertPeriod = remainingAlertPeriod - 1;- } else {- accelerometerText.setVisibility(View.INVISIBLE);- alert = false;- }-- view.renderer.setPosition(-accel_values[0], accel_values[1], accel_values[2]);-- if (last_accel_values != null) {- float speed = Math.abs(- accel_values[0]+accel_values[1]+accel_values[2] -- last_accel_values[0]+last_accel_values[1]+last_accel_values[2])- / diffTime * 10000;- if (speed > SHAKE_THRESHOLD) {- /*- * Send Alert- */-- alert = true;- remainingAlertPeriod = maxAlertPeriod;- accelerometerText.setVisibility(View.VISIBLE);-- Message message = new Message();- message.what = UploadService.ACCELEROMETER_MESSAGE;-- try {- if (serviceMessenger != null) {- serviceMessenger.send(message);- }- } catch (RemoteException e) {- // TODO Auto-generated catch block- e.printStackTrace();- }- }- }- last_accel_values = accel_values.clone();- }- }- }-- @Override- public View onCreateView(LayoutInflater inflater, ViewGroup container,- Bundle savedInstanceState) {-- return inflater.inflate(R.layout.accelerometer_fragment, container, false);-- }-- @Override- public void onCreate(Bundle savedInstanceState) {- super.onCreate(savedInstanceState);- prefs = new SecureItPreferences(getActivity());-- /*- * Set sensitivity value- */- if (prefs.getAccelerometerSensitivity().equals("Medium")) {- SHAKE_THRESHOLD = 2700;- Log.i("AccelerometerFragment", "Sensitivity set to 2700");- } else if (prefs.getAccelerometerSensitivity().equals("Low")) {- SHAKE_THRESHOLD = 3100;- Log.i("AccelerometerFragment", "Sensitivity set to 3100");- } else {- SHAKE_THRESHOLD = 2300;- Log.i("AccelerometerFragment", "Sensitivity set to 2300");- }-- getActivity().bindService(new Intent(getActivity(),- UploadService.class), mConnection, Context.BIND_ABOVE_CLIENT);- }-- @Override- public void onPause() {- super.onPause();- //sensorMgr.unregisterListener(this);- }-- @Override- public void onDestroy() {- super.onDestroy();- sensorMgr.unregisterListener(this);- getActivity().unbindService(mConnection);- Log.i("AccelerometerFragment", "Fragment destroyed");- }-- @Override- public void onResume() {- super.onResume();-- view = new AccelerometerGLSurfaceView(this.getActivity());- ((FrameLayout) getActivity().findViewById(R.id.opengl)).addView(view);-- accelerometerText = (TextView) getActivity().findViewById(R.id.accelerometer_text);-- sensorMgr = (SensorManager) getActivity().getSystemService(Activity.SENSOR_SERVICE);- accelerometer = (Sensor) sensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);-- if (accelerometer == null) {- Log.i("AccelerometerFrament", "Warning: no accelerometer");- } else {- sensorMgr.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_NORMAL);- }- }-- private Messenger serviceMessenger = null;-- private ServiceConnection mConnection = new ServiceConnection() {-- public void onServiceConnected(ComponentName className,- IBinder service) {- Log.i("AccelerometerFragment", "SERVICE CONNECTED");- // We've bound to LocalService, cast the IBinder and get LocalService instance- serviceMessenger = new Messenger(service);- }-- public void onServiceDisconnected(ComponentName arg0) {- Log.i("AccelerometerFragment", "SERVICE DISCONNECTED");- serviceMessenger = null;- }- };--}diff --git a/src/main/java/me/ziccard/secureit/fragment/CameraFragment.java b/src/main/java/me/ziccard/secureit/fragment/CameraFragment.javadeleted file mode 100644index 48e9834..0000000--- a/src/main/java/me/ziccard/secureit/fragment/CameraFragment.java+++ /dev/null@@ -1,83 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.fragment;--import me.ziccard.secureit.Preview;-import me.ziccard.secureit.R;-import me.ziccard.secureit.async.MotionAsyncTask.MotionListener;-import me.ziccard.secureit.codec.ImageCodec;-import android.os.Bundle;-import android.graphics.Bitmap;-import android.support.v4.app.Fragment;-import android.hardware.Camera;-import android.hardware.SensorEvent;-import android.view.LayoutInflater;-import android.view.View;-import android.view.ViewGroup;-import android.widget.ImageView;-import android.widget.FrameLayout;--public final class CameraFragment extends Fragment {-- private Preview preview;-- private ImageView oldImage;- private ImageView newImage;-- @Override- public View onCreateView(LayoutInflater inflater, ViewGroup container,- Bundle savedInstanceState) {-- return inflater.inflate(R.layout.camera_fragment, container, false);-- }-- @Override- public void onCreate(Bundle savedInstanceState) {- super.onCreate(savedInstanceState);- }-- @Override- public void onPause() {- super.onPause();- }-- @Override- public void onResume() {- super.onResume();-- if (preview == null) {- //Uncomment to see the camera- preview = new Preview(getActivity());- ((FrameLayout) getActivity().findViewById(R.id.preview)).addView(preview);-- oldImage = (ImageView) getActivity().findViewById(R.id.old_image);- newImage = (ImageView) getActivity().findViewById(R.id.new_image);-- preview.addListener(new MotionListener() {-- public void onProcess(Bitmap oldBitmap, Bitmap newBitmap,- boolean motionDetected) {- int rotation = 0;- boolean reflex = false;- if (preview.getCameraFacing() == Camera.CameraInfo.CAMERA_FACING_BACK) {- rotation = 90;- } else {- rotation = 270;- reflex = true;- }- oldImage.setImageBitmap(ImageCodec.rotate(oldBitmap, rotation, reflex));- newImage.setImageBitmap(ImageCodec.rotate(newBitmap, rotation, reflex));- }- });- }- }-- public void onSensorChanged(SensorEvent event) {-- }-}\ No newline at end of filediff --git a/src/main/java/me/ziccard/secureit/fragment/EmptyFragment.java b/src/main/java/me/ziccard/secureit/fragment/EmptyFragment.javadeleted file mode 100644index 64d5410..0000000--- a/src/main/java/me/ziccard/secureit/fragment/EmptyFragment.java+++ /dev/null@@ -1,75 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.fragment;--import me.ziccard.secureit.R;-import android.os.Bundle;-import android.support.v4.app.Fragment;-import android.view.Gravity;-import android.view.LayoutInflater;-import android.view.View;-import android.view.ViewGroup;-import android.widget.RelativeLayout;-import android.widget.TextView;-import android.widget.LinearLayout.LayoutParams;--public final class EmptyFragment extends Fragment {-- private static final String CONTENT = "fragment_content";-- public static EmptyFragment newInstance(String content) {- EmptyFragment fragment = new EmptyFragment();--- fragment.mContent = "Service "+content+" disabled";- return fragment;- }-- private String mContent = "???";-- @Override- public void onCreate(Bundle savedInstanceState) {- super.onCreate(savedInstanceState);- }-- @Override- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {-- if ((savedInstanceState != null) && savedInstanceState.containsKey(CONTENT)) {- mContent = savedInstanceState.getString(CONTENT);- }-- TextView text = new TextView(getActivity());- text.setGravity(Gravity.CENTER);- text.setText(mContent);- text.setTextSize(20 * getResources().getDisplayMetrics().density);-- RelativeLayout layout = new RelativeLayout(getActivity());- layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));- layout.setGravity(Gravity.CENTER);-- RelativeLayout alert = new RelativeLayout(getActivity());- RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);- params.leftMargin = 20;- params.rightMargin = 20;- params.addRule(RelativeLayout.CENTER_HORIZONTAL);- params.addRule(RelativeLayout.CENTER_IN_PARENT);- alert.setLayoutParams(params);- alert.setBackgroundResource(R.drawable.red_back);- alert.setPadding(30, 0, 30, 0);- alert.addView(text);- layout.addView(alert);-- return layout;- }-- @Override- public void onSaveInstanceState(Bundle outState) {- super.onSaveInstanceState(outState);- outState.putString("CONTENT", mContent);- }-}\ No newline at end of filediff --git a/src/main/java/me/ziccard/secureit/fragment/MicrophoneFragment.java b/src/main/java/me/ziccard/secureit/fragment/MicrophoneFragment.javadeleted file mode 100644index 90836df..0000000--- a/src/main/java/me/ziccard/secureit/fragment/MicrophoneFragment.java+++ /dev/null@@ -1,190 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.fragment;--import android.content.ComponentName;-import android.content.Context;-import android.content.Intent;-import android.content.ServiceConnection;-import android.os.Bundle;-import android.os.IBinder;-import android.os.Message;-import android.os.Messenger;-import android.os.RemoteException;-import android.support.v4.app.Fragment;-import android.util.Log;-import me.ziccard.secureit.MicrophoneVolumePicker;-import me.ziccard.secureit.R;-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.UploadService;--import android.view.LayoutInflater;-import android.view.View;-import android.view.ViewGroup;-import android.widget.LinearLayout;-import android.widget.TextView;--public final class MicrophoneFragment extends Fragment implements MicSamplerTask.MicListener {--- private MicSamplerTask microphone;-- private TextView microphoneText;-- /**- * View for microphone data- */- private MicrophoneVolumePicker picker;-- /**- * Object used to fetch application dependencies- */- private SecureItPreferences prefs;-- /**- * Threshold for the decibels sampled- */- private double NOISE_THRESHOLD = 60.0;-- /**- * Messenger used to communicate with alert service- */- private Messenger serviceMessenger = null;-- private ServiceConnection mConnection = new ServiceConnection() {-- public void onServiceConnected(ComponentName className,- IBinder service) {- Log.i("MicrophoneFragment", "SERVICE CONNECTED");- // We've bound to LocalService, cast the IBinder and get LocalService instance- serviceMessenger = new Messenger(service);- }-- public void onServiceDisconnected(ComponentName arg0) {- Log.i("MicrophoneFragment", "SERVICE DISCONNECTED");- serviceMessenger = null;- }- };-- @Override- public View onCreateView(LayoutInflater inflater, ViewGroup container,- Bundle savedInstanceState) {-- return inflater.inflate(R.layout.microphone_fragment, container, false);- }-- @Override- public void onCreate(Bundle savedInstanceState) {- super.onCreate(savedInstanceState);- prefs = new SecureItPreferences(getActivity());-- if (prefs.getMicrophoneSensitivity().equals("High")) {- NOISE_THRESHOLD = 30.0;- } else if (prefs.getMicrophoneSensitivity().equals("Medium")) {- NOISE_THRESHOLD = 40.0;- }-- getActivity().bindService(new Intent(getActivity(),- UploadService.class), mConnection, Context.BIND_ABOVE_CLIENT);-- try {- microphone = MicrophoneTaskFactory.makeSampler(getActivity());- microphone.setMicListener(this);- microphone.execute();- } catch (RecordLimitExceeded e) {- // TODO Auto-generated catch block- e.printStackTrace();- }- }-- @Override- public void onPause() {- super.onPause();- }-- @Override- public void onResume() {- super.onResume();-- Log.i("MicrophoneFragment", "Resumed");-- microphoneText = (TextView) getActivity().findViewById(R.id.microphone);-- LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(- LinearLayout.LayoutParams.MATCH_PARENT,- LinearLayout.LayoutParams.WRAP_CONTENT);-- LinearLayout layout = (LinearLayout) getActivity().findViewById(R.id.linear_layout);- if (layout.getChildCount() == 1) {- picker = new MicrophoneVolumePicker(this.getActivity());- picker.setNoiseThreshold(NOISE_THRESHOLD);- layout.addView(picker, params);- }--// if (microphone == null || microphone.isCancelled()) {-//-// }- }-- @Override- public void onDestroy() {- super.onDestroy();- Log.i("MicrophoneFramgnet", "Fragment destroyed");- getActivity().unbindService(mConnection);- microphone.cancel(true);- }--- public void onSignalReceived(short[] signal) {-- /*- * We do and average of the 512 samples- */- int total = 0;- int count = 0;- for (short peak : signal) {- //Log.i("MicrophoneFragment", "Sampled values are: "+peak);- if (peak != 0) {- total+=Math.abs(peak);- count++;- }- }- Log.i("MicrophoneFragment", "Total value: "+total);- int average = 0;- if (count > 0) average = total/count;- /*- * We compute a value in decibels- */- double averageDB = 0.0;- if (average!=0) {- averageDB = 20*Math.log10(Math.abs(average)/1);- }-- microphoneText.setText("Sampled DBs: "+averageDB);-- picker.setValues(averageDB, averageDB);- picker.invalidate();-- if (averageDB > NOISE_THRESHOLD) {- Message message = new Message();- message.what = UploadService.MICROPHONE_MESSAGE;- try {- if (serviceMessenger != null)- serviceMessenger.send(message);- } catch (RemoteException e) {- // Cannot happen- }- }- }-- public void onMicError() {- Log.e("MicrophoneActivity", "Microphone is not ready");- }-}\ No newline at end of filediff --git a/src/main/java/me/ziccard/secureit/messages/BluetoothMessage.java b/src/main/java/me/ziccard/secureit/messages/BluetoothMessage.javadeleted file mode 100644index 9c47fda..0000000--- a/src/main/java/me/ziccard/secureit/messages/BluetoothMessage.java+++ /dev/null@@ -1,15 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.messages;--import java.io.Serializable;--public interface BluetoothMessage extends Serializable {-- public MessageType getType();--}diff --git a/src/main/java/me/ziccard/secureit/messages/BluetoothMessageData.java b/src/main/java/me/ziccard/secureit/messages/BluetoothMessageData.javadeleted file mode 100644index 75ff5ab..0000000--- a/src/main/java/me/ziccard/secureit/messages/BluetoothMessageData.java+++ /dev/null@@ -1,19 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.messages;--import java.util.Date;--public class BluetoothMessageData {-- protected Date timestamp;-- public Date getTimestamp() {- return timestamp;- }--}diff --git a/src/main/java/me/ziccard/secureit/messages/HelloMessage.java b/src/main/java/me/ziccard/secureit/messages/HelloMessage.javadeleted file mode 100644index 734c392..0000000--- a/src/main/java/me/ziccard/secureit/messages/HelloMessage.java+++ /dev/null@@ -1,42 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.messages;--import java.util.Date;--public class HelloMessage extends BluetoothMessageData implements BluetoothMessage {-- /**- *- */- private static final long serialVersionUID = 4363335604763136855L;-- /**- * Id of the phone delegating an alert- */- private String phoneId;-- /**- * Constructor- */- public HelloMessage(String phoneId, Date timestamp) {- this.phoneId = phoneId;- this.timestamp = timestamp;- }-- /**- * phoneId getter- */- public String getPhoneId() {- return phoneId;- }-- public MessageType getType() {- return MessageType.HELLO;- }--}diff --git a/src/main/java/me/ziccard/secureit/messages/KeyRequest.java b/src/main/java/me/ziccard/secureit/messages/KeyRequest.javadeleted file mode 100644index c79c943..0000000--- a/src/main/java/me/ziccard/secureit/messages/KeyRequest.java+++ /dev/null@@ -1,39 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.messages;--import java.util.Date;--public class KeyRequest extends BluetoothMessageData implements BluetoothMessage {-- private double lat;- private double lng;-- public KeyRequest(double lat, double lng, Date timestamp) {- this.lat = lat;- this.lng = lng;- this.timestamp = timestamp;- }-- public double getLat() {- return lat;- }-- public double getLng() {- return lng;- }-- /**- *- */- private static final long serialVersionUID = -5241265795662117718L;-- public MessageType getType() {- return MessageType.KEY_REQUEST;- }--}diff --git a/src/main/java/me/ziccard/secureit/messages/KeyResponse.java b/src/main/java/me/ziccard/secureit/messages/KeyResponse.javadeleted file mode 100644index 42e1e53..0000000--- a/src/main/java/me/ziccard/secureit/messages/KeyResponse.java+++ /dev/null@@ -1,32 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.messages;--import java.util.Date;--public class KeyResponse extends BluetoothMessageData implements BluetoothMessage {-- /**- *- */- private static final long serialVersionUID = -4625933882220755290L;-- public KeyResponse(String accessKey, Date timestamp) {- this.accessKey = accessKey;- this.timestamp = timestamp;- }-- private String accessKey;-- public String getAccessKey() {- return accessKey;- }-- public MessageType getType() {- return MessageType.KEY_RESPONSE;- }-}diff --git a/src/main/java/me/ziccard/secureit/messages/MessageBuilder.java b/src/main/java/me/ziccard/secureit/messages/MessageBuilder.javadeleted file mode 100644index 207a158..0000000--- a/src/main/java/me/ziccard/secureit/messages/MessageBuilder.java+++ /dev/null@@ -1,98 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.messages;--import java.security.spec.AlgorithmParameterSpec;-import java.util.Date;--import javax.crypto.Cipher;-import javax.crypto.spec.IvParameterSpec;-import javax.crypto.spec.SecretKeySpec;--import android.util.Base64;--public class MessageBuilder {-- /**- * Phone Id- */- private String phoneId;-- /**- * Latitude value- */- private double lat;-- /**- * Longitude value- */- private double lng;-- /**- * Timestamp- */- private Date timestamp;-- /**- * Password used to encrypt KeyResponse- */- private String password;-- public void setPhoneId(String phoneId) {- this.phoneId = phoneId;- }-- public void setLat(double lat) {- this.lat = lat;- }-- public void setLng(double lng) {- this.lng = lng;- }-- public void setTimestamp(Date timestamp) {- this.timestamp = timestamp;- }-- public void setPassword(String password) {- this.password = password;- }-- /**- * Constructor- * @param type- * @return- */- public BluetoothMessage buildMessage(MessageType type) {- switch (type) {- case HELLO:- return new HelloMessage(phoneId, new Date());- case KEY_REQUEST:- return new KeyRequest(lat, lng, new Date());- case KEY_RESPONSE:- String accessKey = "{\"lat\": \"" + lat + "\"," +- "\"long\": \"" + lng + "\"," +- "\"timestamp\": \"" + timestamp + "\"}";-- SecretKeySpec key = new SecretKeySpec(password.getBytes(), "AES");- AlgorithmParameterSpec paramSpec = new IvParameterSpec(password.substring(0, 16).getBytes());- Cipher cipher;- try {- cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");- cipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);- byte[] ecrypted = cipher.doFinal(accessKey.getBytes());- accessKey = Base64.encodeToString(ecrypted, Base64.DEFAULT);- } catch (Exception e) {-- e.printStackTrace();- }- return new KeyResponse(accessKey, new Date());- default:- return new HelloMessage(phoneId, new Date());- }- }-}diff --git a/src/main/java/me/ziccard/secureit/messages/MessageType.java b/src/main/java/me/ziccard/secureit/messages/MessageType.javadeleted file mode 100644index ff6c4a2..0000000--- a/src/main/java/me/ziccard/secureit/messages/MessageType.java+++ /dev/null@@ -1,15 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.messages;--public enum MessageType {-- HELLO,- KEY_REQUEST,- KEY_RESPONSE--}diff --git a/src/main/java/me/ziccard/secureit/opengl/AccelerometerGLRenderer.java b/src/main/java/me/ziccard/secureit/opengl/AccelerometerGLRenderer.javadeleted file mode 100644index 6809c51..0000000--- a/src/main/java/me/ziccard/secureit/opengl/AccelerometerGLRenderer.java+++ /dev/null@@ -1,620 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.opengl;--import java.nio.ByteBuffer;-import java.nio.ByteOrder;-import java.nio.FloatBuffer;--import javax.microedition.khronos.egl.EGLConfig;-import javax.microedition.khronos.opengles.GL10;--import me.ziccard.secureit.R;--import android.content.Context;-import android.hardware.SensorManager;-import android.opengl.GLES20;-import android.opengl.GLSurfaceView;-import android.opengl.Matrix;---/**- * This class implements our custom renderer. Note that the GL10 parameter passed in is unused for OpenGL ES 2.0- * renderers -- the static class GLES20 is used instead.- */-public class AccelerometerGLRenderer implements GLSurfaceView.Renderer-{-- /**- * Angles of the accelerometer- */- float angle_x;- float angle_y;- float angle_z;--- float angleToGoX;- float angleToGoY;- float angleToGoZ;-- static final float THRESHOLD = 0.1F;-- static final float SMOOTH = 0.1F;-- public void setPosition(float angleX, float angleY, float angleZ) {-- if(Math.abs(angleX-angle_x) > THRESHOLD)- angleToGoX = angleX;- if(Math.abs(angleY-angle_y)> THRESHOLD)- angleToGoY = angleY;- }-- private final Context mActivityContext;-- /**- * Store the model matrix. This matrix is used to move models from object space (where each model can be thought- * of being located at the center of the universe) to world space.- */- private float[] mModelMatrix = new float[16];-- /**- * Store the view matrix. This can be thought of as our camera. This matrix transforms world space to eye space;- * it positions things relative to our eye.- */- private float[] mViewMatrix = new float[16];-- /** Store the projection matrix. This is used to project the scene onto a 2D viewport. */- private float[] mProjectionMatrix = new float[16];-- /** Allocate storage for the final combined matrix. This will be passed into the shader program. */- private float[] mMVPMatrix = new float[16];-- /**- * Stores a copy of the model matrix specifically for the light position.- */- private float[] mLightModelMatrix = new float[16];-- /** Store our model data in a float buffer. */- private final FloatBuffer mCubePositions;- private final FloatBuffer mCubeColors;- private final FloatBuffer mCubeNormals;- private final FloatBuffer mCubeTextureCoordinates;-- /** This will be used to pass in the transformation matrix. */- private int mMVPMatrixHandle;-- /** This will be used to pass in the modelview matrix. */- private int mMVMatrixHandle;-- /** This will be used to pass in the light position. */- private int mLightPosHandle;-- /** This will be used to pass in the texture. */- private int mTextureUniformHandle;-- /** This will be used to pass in model position information. */- private int mPositionHandle;-- /** This will be used to pass in model color information. */- private int mColorHandle;-- /** This will be used to pass in model normal information. */- private int mNormalHandle;-- /** This will be used to pass in model texture coordinate information. */- private int mTextureCoordinateHandle;-- /** How many bytes per float. */- private final int mBytesPerFloat = 4;-- /** Size of the position data in elements. */- private final int mPositionDataSize = 3;-- /** Size of the color data in elements. */- private final int mColorDataSize = 4;-- /** Size of the normal data in elements. */- private final int mNormalDataSize = 3;-- /** Size of the texture coordinate data in elements. */- private final int mTextureCoordinateDataSize = 2;-- /** Used to hold a light centered on the origin in model space. We need a 4th coordinate so we can get translations to work when- * we multiply this by our transformation matrices. */- private final float[] mLightPosInModelSpace = new float[] {0.0f, 0.0f, 0.0f, 1.0f};-- /** Used to hold the current position of the light in world space (after transformation via model matrix). */- private final float[] mLightPosInWorldSpace = new float[4];-- /** Used to hold the transformed position of the light in eye space (after transformation via modelview matrix) */- private final float[] mLightPosInEyeSpace = new float[4];-- /** This is a handle to our cube shading program. */- private int mProgramHandle;-- /** This is a handle to our light point program. */- private int mPointProgramHandle;-- /** This is a handle to our texture data. */- private int mTextureDataHandle;-- /**- * Initialize the model data.- */- public AccelerometerGLRenderer(final Context activityContext)- {- mActivityContext = activityContext;-- // Define points for a cube.-- // X, Y, Z- final float[] cubePositionData =- {- // In OpenGL counter-clockwise winding is default. This means that when we look at a triangle,- // if the points are counter-clockwise we are looking at the "front". If not we are looking at- // the back. OpenGL has an optimization where all back-facing triangles are culled, since they- // usually represent the backside of an object and aren't visible anyways.-- // Front face- -1.0f, 1.5f, 1.0f,- -1.0f, -1.5f, 1.0f,- 1.0f, 1.5f, 1.0f,- -1.0f, -1.5f, 1.0f,- 1.0f, -1.5f, 1.0f,- 1.0f, 1.5f, 1.0f,-- // Right face- 1.0f, 1.5f, 1.0f,- 1.0f, -1.5f, 1.0f,- 1.0f, 1.5f, 0.9f,- 1.0f, -1.5f, 1.0f,- 1.0f, -1.5f, 0.9f,- 1.0f, 1.5f, 0.9f,-- // Back face- 1.0f, 1.5f, 0.9f,- 1.0f, -1.5f, 0.9f,- -1.0f, 1.5f, 0.9f,- 1.0f, -1.5f, 0.9f,- -1.0f, -1.5f, 0.9f,- -1.0f, 1.5f, 0.9f,-- // Left face- -1.0f, 1.5f, 0.9f,- -1.0f, -1.5f, 0.9f,- -1.0f, 1.5f, 1.0f,- -1.0f, -1.5f, 0.9f,- -1.0f, -1.5f, 1.0f,- -1.0f, 1.5f, 1.0f,-- // Top face- -1.0f, 1.5f, 0.9f,- -1.0f, 1.5f, 1.0f,- 1.0f, 1.5f, 0.9f,- -1.0f, 1.5f, 1.0f,- 1.0f, 1.5f, 1.0f,- 1.0f, 1.5f, 0.9f,-- // Bottom face- 1.0f, -1.5f, 0.9f,- 1.0f, -1.5f, 1.0f,- -1.0f, -1.5f, 0.9f,- 1.0f, -1.5f, 1.0f,- -1.0f, -1.5f, 1.0f,- -1.0f, -1.5f, 0.9f,- };-- // R, G, B, A- final float[] cubeColorData =- {- // Front face (red)- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,-- // Right face (green)- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,-- // Back face (blue)- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,-- // Left face (yellow)- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,-- // Top face (cyan)- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,-- // Bottom face (magenta)- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f,- 0.8f, 0.8f, 0.8f, 0.8f- };-- // X, Y, Z- // The normal is used in light calculations and is a vector which points- // orthogonal to the plane of the surface. For a cube model, the normals- // should be orthogonal to the points of each face.- final float[] cubeNormalData =- {- // Front face- 0.0f, 0.0f, 1.0f,- 0.0f, 0.0f, 1.0f,- 0.0f, 0.0f, 1.0f,- 0.0f, 0.0f, 1.0f,- 0.0f, 0.0f, 1.0f,- 0.0f, 0.0f, 1.0f,-- // Right face- 1.0f, 0.0f, 0.0f,- 1.0f, 0.0f, 0.0f,- 1.0f, 0.0f, 0.0f,- 1.0f, 0.0f, 0.0f,- 1.0f, 0.0f, 0.0f,- 1.0f, 0.0f, 0.0f,-- // Back face- 0.0f, 0.0f, -1.0f,- 0.0f, 0.0f, -1.0f,- 0.0f, 0.0f, -1.0f,- 0.0f, 0.0f, -1.0f,- 0.0f, 0.0f, -1.0f,- 0.0f, 0.0f, -1.0f,-- // Left face- -1.0f, 0.0f, 0.0f,- -1.0f, 0.0f, 0.0f,- -1.0f, 0.0f, 0.0f,- -1.0f, 0.0f, 0.0f,- -1.0f, 0.0f, 0.0f,- -1.0f, 0.0f, 0.0f,-- // Top face- 0.0f, 1.0f, 0.0f,- 0.0f, 1.0f, 0.0f,- 0.0f, 1.0f, 0.0f,- 0.0f, 1.0f, 0.0f,- 0.0f, 1.0f, 0.0f,- 0.0f, 1.0f, 0.0f,-- // Bottom face- 0.0f, -1.0f, 0.0f,- 0.0f, -1.0f, 0.0f,- 0.0f, -1.0f, 0.0f,- 0.0f, -1.0f, 0.0f,- 0.0f, -1.0f, 0.0f,- 0.0f, -1.0f, 0.0f- };-- // S, T (or X, Y)- // Texture coordinate data.- // Because images have a Y axis pointing downward (values increase as you move down the image) while- // OpenGL has a Y axis pointing upward, we adjust for that here by flipping the Y axis.- // What's more is that the texture coordinates are the same for every face.- final float[] cubeTextureCoordinateData =- {- // Front face- 0.0f, 0.0f,- 0.0f, 1.0f,- 1.0f, 0.0f,- 0.0f, 1.0f,- 1.0f, 1.0f,- 1.0f, 0.0f,-- // Right face- 0.0f, 0.0f,- 0.0f, 1.0f,- 1.0f, 0.0f,- 0.0f, 1.0f,- 1.0f, 1.0f,- 1.0f, 0.0f,-- // Back face- 0.0f, 0.0f,- 0.0f, 1.0f,- 1.0f, 0.0f,- 0.0f, 1.0f,- 1.0f, 1.0f,- 1.0f, 0.0f,-- // Left face- 0.0f, 0.0f,- 0.0f, 1.0f,- 1.0f, 0.0f,- 0.0f, 1.0f,- 1.0f, 1.0f,- 1.0f, 0.0f,-- // Top face- 0.0f, 0.0f,- 0.0f, 1.0f,- 1.0f, 0.0f,- 0.0f, 1.0f,- 1.0f, 1.0f,- 1.0f, 0.0f,-- // Bottom face- 0.0f, 0.0f,- 0.0f, 1.0f,- 1.0f, 0.0f,- 0.0f, 1.0f,- 1.0f, 1.0f,- 1.0f, 0.0f- };-- // Initialize the buffers.- mCubePositions = ByteBuffer.allocateDirect(cubePositionData.length * mBytesPerFloat)- .order(ByteOrder.nativeOrder()).asFloatBuffer();- mCubePositions.put(cubePositionData).position(0);-- mCubeColors = ByteBuffer.allocateDirect(cubeColorData.length * mBytesPerFloat)- .order(ByteOrder.nativeOrder()).asFloatBuffer();- mCubeColors.put(cubeColorData).position(0);-- mCubeNormals = ByteBuffer.allocateDirect(cubeNormalData.length * mBytesPerFloat)- .order(ByteOrder.nativeOrder()).asFloatBuffer();- mCubeNormals.put(cubeNormalData).position(0);-- mCubeTextureCoordinates = ByteBuffer.allocateDirect(cubeTextureCoordinateData.length * mBytesPerFloat)- .order(ByteOrder.nativeOrder()).asFloatBuffer();- mCubeTextureCoordinates.put(cubeTextureCoordinateData).position(0);- }-- protected String getVertexShader()- {- return RawResourceReader.readTextFileFromRawResource(mActivityContext, R.raw.per_pixel_vertex_shader);- }-- protected String getFragmentShader()- {- return RawResourceReader.readTextFileFromRawResource(mActivityContext, R.raw.per_pixel_fragment_shader);- }-- public void onSurfaceCreated(GL10 glUnused, EGLConfig config)- {- // Set the background clear color to black.- GLES20.glClearColor(0.906f, 0.906f, 0.906f, 1.0f);-- // Use culling to remove back faces.- GLES20.glEnable(GLES20.GL_CULL_FACE);-- // Enable depth testing- GLES20.glEnable(GLES20.GL_DEPTH_TEST);-- // The below glEnable() call is a holdover from OpenGL ES 1, and is not needed in OpenGL ES 2.- // Enable texture mapping- // GLES20.glEnable(GLES20.GL_TEXTURE_2D);-- // Position the eye in front of the origin.- final float eyeX = 0.0f;- final float eyeY = 0.0f;- final float eyeZ = -0.5f;-- // We are looking toward the distance- final float lookX = 0.0f;- final float lookY = 0.0f;- final float lookZ = -5.0f;-- // Set our up vector. This is where our head would be pointing were we holding the camera.- final float upX = 0.0f;- final float upY = 1.0f;- final float upZ = 0.0f;-- // Set the view matrix. This matrix can be said to represent the camera position.- // NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination of a model and- // view matrix. In OpenGL 2, we can keep track of these matrices separately if we choose.- Matrix.setLookAtM(mViewMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);-- final String vertexShader = getVertexShader();- final String fragmentShader = getFragmentShader();-- final int vertexShaderHandle = ShaderHelper.compileShader(GLES20.GL_VERTEX_SHADER, vertexShader);- final int fragmentShaderHandle = ShaderHelper.compileShader(GLES20.GL_FRAGMENT_SHADER, fragmentShader);-- mProgramHandle = ShaderHelper.createAndLinkProgram(vertexShaderHandle, fragmentShaderHandle,- new String[] {"a_Position", "a_Color", "a_Normal", "a_TexCoordinate"});-- // Define a simple shader program for our point.- final String pointVertexShader = RawResourceReader.readTextFileFromRawResource(mActivityContext, R.raw.per_pixel_vertex_shader);- final String pointFragmentShader = RawResourceReader.readTextFileFromRawResource(mActivityContext, R.raw.per_pixel_fragment_shader);-- final int pointVertexShaderHandle = ShaderHelper.compileShader(GLES20.GL_VERTEX_SHADER, pointVertexShader);- final int pointFragmentShaderHandle = ShaderHelper.compileShader(GLES20.GL_FRAGMENT_SHADER, pointFragmentShader);- mPointProgramHandle = ShaderHelper.createAndLinkProgram(pointVertexShaderHandle, pointFragmentShaderHandle,- new String[] {"a_Position"});-- // Load the texture- mTextureDataHandle = TextureHelper.loadTexture(mActivityContext, R.drawable.fronttx);- }-- public void onSurfaceChanged(GL10 glUnused, int width, int height)- {- // Set the OpenGL viewport to the same size as the surface.- GLES20.glViewport(0, 0, width, height);-- // Create a new perspective projection matrix. The height will stay the same- // while the width will vary as per aspect ratio.- final float ratio = (float) width / height;- final float left = -ratio;- final float right = ratio;- final float bottom = -1.0f;- final float top = 1.0f;- final float near = 1.0f;- final float far = 10.0f;-- Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far);- }-- public void onDrawFrame(GL10 glUnused)- {-- GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);-- if(Math.abs(angle_x -angleToGoX) > .4){- if(angle_x < angleToGoX){- angle_x += .18;- }- else{- angle_x -= .18;- }- }- if(Math.abs(angle_y -angleToGoY) > .4){- if(angle_y < angleToGoY){- angle_y += .18;- }- else{- angle_y -= .18;- }- }-- float angleInDegreesX = (angle_x)/(SensorManager.GRAVITY_EARTH*2)*180;- float angleInDegreesY = (angle_y)/(SensorManager.GRAVITY_EARTH*2)*180;-- // Set our per-vertex lighting program.- GLES20.glUseProgram(mProgramHandle);-- // Set program handles for cube drawing.- mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_MVPMatrix");- mMVMatrixHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_MVMatrix");- mLightPosHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_LightPos");- mTextureUniformHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_Texture");- mPositionHandle = GLES20.glGetAttribLocation(mProgramHandle, "a_Position");- mColorHandle = GLES20.glGetAttribLocation(mProgramHandle, "a_Color");- mNormalHandle = GLES20.glGetAttribLocation(mProgramHandle, "a_Normal");- mTextureCoordinateHandle = GLES20.glGetAttribLocation(mProgramHandle, "a_TexCoordinate");-- // Set the active texture unit to texture unit 0.- GLES20.glActiveTexture(GLES20.GL_TEXTURE0);-- // Bind the texture to this unit.- GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataHandle);-- // Tell the texture uniform sampler to use this texture in the shader by binding to texture unit 0.- GLES20.glUniform1i(mTextureUniformHandle, 0);-- // Calculate position of the light. Rotate and then push into the distance.- Matrix.setIdentityM(mLightModelMatrix, 0);- //Ruota il punto di luce su un piano- //Matrix.rotateM(mLightModelMatrix, 0, angleInDegrees, 0.0f, 1.0f, 0.0f);- Matrix.translateM(mLightModelMatrix, 0, 0.0f, 0.0f, 2.0f);-- Matrix.multiplyMV(mLightPosInWorldSpace, 0, mLightModelMatrix, 0, mLightPosInModelSpace, 0);- Matrix.multiplyMV(mLightPosInEyeSpace, 0, mViewMatrix, 0, mLightPosInWorldSpace, 0);-- Matrix.setIdentityM(mModelMatrix, 0);- Matrix.translateM(mModelMatrix, 0, 0.0f, 0.0f, -4.0f);- Matrix.rotateM(mModelMatrix, 0, angleInDegreesY, 1.0f, 0.0f, 0.0f);- Matrix.rotateM(mModelMatrix, 0, angleInDegreesX, 0.0f, 1.0f, 0.0f);- drawCube();-- // Draw a point to indicate the light.- GLES20.glUseProgram(mPointProgramHandle);- drawLight();- }-- /**- * Draws a cube.- */- private void drawCube()- {- // Pass in the position information- mCubePositions.position(0);- GLES20.glVertexAttribPointer(mPositionHandle, mPositionDataSize, GLES20.GL_FLOAT, false,- 0, mCubePositions);-- GLES20.glEnableVertexAttribArray(mPositionHandle);-- // Pass in the color information- mCubeColors.position(0);- GLES20.glVertexAttribPointer(mColorHandle, mColorDataSize, GLES20.GL_FLOAT, false,- 0, mCubeColors);-- GLES20.glEnableVertexAttribArray(mColorHandle);-- // Pass in the normal information- mCubeNormals.position(0);- GLES20.glVertexAttribPointer(mNormalHandle, mNormalDataSize, GLES20.GL_FLOAT, false,- 0, mCubeNormals);-- GLES20.glEnableVertexAttribArray(mNormalHandle);-- // Pass in the texture coordinate information- mCubeTextureCoordinates.position(0);- GLES20.glVertexAttribPointer(mTextureCoordinateHandle, mTextureCoordinateDataSize, GLES20.GL_FLOAT, false,- 0, mCubeTextureCoordinates);-- GLES20.glEnableVertexAttribArray(mTextureCoordinateHandle);-- // This multiplies the view matrix by the model matrix, and stores the result in the MVP matrix- // (which currently contains model * view).- Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0);-- // Pass in the modelview matrix.- GLES20.glUniformMatrix4fv(mMVMatrixHandle, 1, false, mMVPMatrix, 0);-- // This multiplies the modelview matrix by the projection matrix, and stores the result in the MVP matrix- // (which now contains model * view * projection).- Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);-- // Pass in the combined matrix.- GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);-- // Pass in the light position in eye space.- GLES20.glUniform3f(mLightPosHandle, mLightPosInEyeSpace[0], mLightPosInEyeSpace[1], mLightPosInEyeSpace[2]);-- // Draw the cube.- GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 36);- }-- /**- * Draws a point representing the position of the light.- */- private void drawLight()- {- final int pointMVPMatrixHandle = GLES20.glGetUniformLocation(mPointProgramHandle, "u_MVPMatrix");- final int pointPositionHandle = GLES20.glGetAttribLocation(mPointProgramHandle, "a_Position");-- // Pass in the position.- GLES20.glVertexAttrib3f(pointPositionHandle, mLightPosInModelSpace[0], mLightPosInModelSpace[1], mLightPosInModelSpace[2]);-- // Since we are not using a buffer object, disable vertex arrays for this attribute.- GLES20.glDisableVertexAttribArray(pointPositionHandle);-- // Pass in the transformation matrix.- Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mLightModelMatrix, 0);- Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);- GLES20.glUniformMatrix4fv(pointMVPMatrixHandle, 1, false, mMVPMatrix, 0);-- // Draw the point.- // GLES20.glDrawArrays(GLES20.GL_POINTS, 0, 1);- }-}\ No newline at end of filediff --git a/src/main/java/me/ziccard/secureit/opengl/AccelerometerGLSurfaceView.java b/src/main/java/me/ziccard/secureit/opengl/AccelerometerGLSurfaceView.javadeleted file mode 100644index 1976a4b..0000000--- a/src/main/java/me/ziccard/secureit/opengl/AccelerometerGLSurfaceView.java+++ /dev/null@@ -1,27 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.opengl;--import android.content.Context;-import android.opengl.GLSurfaceView;--public class AccelerometerGLSurfaceView extends GLSurfaceView {-- public AccelerometerGLRenderer renderer;-- public AccelerometerGLSurfaceView(Context context){- super(context);-- // Create an OpenGL ES 2.0 context- setEGLContextClientVersion(2);-- renderer = new AccelerometerGLRenderer(context);-- // Set the Renderer for drawing on the GLSurfaceView- setRenderer(renderer);- }-}diff --git a/src/main/java/me/ziccard/secureit/opengl/RawResourceReader.java b/src/main/java/me/ziccard/secureit/opengl/RawResourceReader.javadeleted file mode 100644index 4484bc0..0000000--- a/src/main/java/me/ziccard/secureit/opengl/RawResourceReader.java+++ /dev/null@@ -1,46 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.opengl;--import java.io.BufferedReader;-import java.io.IOException;-import java.io.InputStream;-import java.io.InputStreamReader;--import android.content.Context;--public class RawResourceReader-{- public static String readTextFileFromRawResource(final Context context,- final int resourceId)- {- final InputStream inputStream = context.getResources().openRawResource(- resourceId);- final InputStreamReader inputStreamReader = new InputStreamReader(- inputStream);- final BufferedReader bufferedReader = new BufferedReader(- inputStreamReader);-- String nextLine;- final StringBuilder body = new StringBuilder();-- try- {- while ((nextLine = bufferedReader.readLine()) != null)- {- body.append(nextLine);- body.append('\n');- }- }- catch (IOException e)- {- return null;- }-- return body.toString();- }-}diff --git a/src/main/java/me/ziccard/secureit/opengl/ShaderHelper.java b/src/main/java/me/ziccard/secureit/opengl/ShaderHelper.javadeleted file mode 100644index 24a30e4..0000000--- a/src/main/java/me/ziccard/secureit/opengl/ShaderHelper.java+++ /dev/null@@ -1,109 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.opengl;--import android.opengl.GLES20;-import android.util.Log;--public class ShaderHelper-{- private static final String TAG = "ShaderHelper";-- /**- * Helper function to compile a shader.- *- * @param shaderType The shader type.- * @param shaderSource The shader source code.- * @return An OpenGL handle to the shader.- */- public static int compileShader(final int shaderType, final String shaderSource)- {- int shaderHandle = GLES20.glCreateShader(shaderType);-- if (shaderHandle != 0)- {- // Pass in the shader source.- GLES20.glShaderSource(shaderHandle, shaderSource);-- // Compile the shader.- GLES20.glCompileShader(shaderHandle);-- // Get the compilation status.- final int[] compileStatus = new int[1];- GLES20.glGetShaderiv(shaderHandle, GLES20.GL_COMPILE_STATUS, compileStatus, 0);-- // If the compilation failed, delete the shader.- if (compileStatus[0] == 0)- {- Log.e(TAG, "Error compiling shader: " + GLES20.glGetShaderInfoLog(shaderHandle));- GLES20.glDeleteShader(shaderHandle);- shaderHandle = 0;- }- }-- if (shaderHandle == 0)- {- throw new RuntimeException("Error creating shader.");- }-- return shaderHandle;- }-- /**- * Helper function to compile and link a program.- *- * @param vertexShaderHandle An OpenGL handle to an already-compiled vertex shader.- * @param fragmentShaderHandle An OpenGL handle to an already-compiled fragment shader.- * @param attributes Attributes that need to be bound to the program.- * @return An OpenGL handle to the program.- */- public static int createAndLinkProgram(final int vertexShaderHandle, final int fragmentShaderHandle, final String[] attributes)- {- int programHandle = GLES20.glCreateProgram();-- if (programHandle != 0)- {- // Bind the vertex shader to the program.- GLES20.glAttachShader(programHandle, vertexShaderHandle);-- // Bind the fragment shader to the program.- GLES20.glAttachShader(programHandle, fragmentShaderHandle);-- // Bind attributes- if (attributes != null)- {- final int size = attributes.length;- for (int i = 0; i < size; i++)- {- GLES20.glBindAttribLocation(programHandle, i, attributes[i]);- }- }-- // Link the two shaders together into a program.- GLES20.glLinkProgram(programHandle);-- // Get the link status.- final int[] linkStatus = new int[1];- GLES20.glGetProgramiv(programHandle, GLES20.GL_LINK_STATUS, linkStatus, 0);-- // If the link failed, delete the program.- if (linkStatus[0] == 0)- {- Log.e(TAG, "Error compiling program: " + GLES20.glGetProgramInfoLog(programHandle));- GLES20.glDeleteProgram(programHandle);- programHandle = 0;- }- }-- if (programHandle == 0)- {- throw new RuntimeException("Error creating program.");- }-- return programHandle;- }-}diff --git a/src/main/java/me/ziccard/secureit/opengl/TextureHelper.java b/src/main/java/me/ziccard/secureit/opengl/TextureHelper.javadeleted file mode 100644index 6f8286d..0000000--- a/src/main/java/me/ziccard/secureit/opengl/TextureHelper.java+++ /dev/null@@ -1,52 +0,0 @@-/*- * Copyright (c) 2013-2015 Marco Ziccardi, Luca Bonato- * Licensed under the MIT license.- */---package me.ziccard.secureit.opengl;--import android.content.Context;-import android.graphics.Bitmap;-import android.graphics.BitmapFactory;-import android.opengl.GLES20;-import android.opengl.GLUtils;--public class TextureHelper-{- public static int loadTexture(final Context context, final int resourceId)- {- final int[] textureHandle = new int[1];-- GLES20.glGenTextures(1, textureHandle, 0);-- if (textureHandle[0] != 0)- {- final BitmapFactory.Options options = new BitmapFactory.Options();- options.inScaled = false; // No pre-scaling-- // Read in the resource- final Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resourceId, options);-- // Bind to the texture in OpenGL- GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle[0]);-- // Set filtering- GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);- GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);-- // Load the bitmap into the bound texture.- GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);-- // Recycle the bitmap, since its data has been loaded into OpenGL.- bitmap.recycle();- }-- if (textureHandle[0] == 0)- {- throw new RuntimeException("Error loading texture.");- }-- return textureHandle[0];- }-}diff --git a/src/main/res/layout/activity_monitor.xml b/src/main/res/layout/activity_monitor.xmldeleted file mode 100644index fa79d4d..0000000--- a/src/main/res/layout/activity_monitor.xml+++ /dev/null@@ -1,21 +0,0 @@-<?xml version="1.0" encoding="utf-8"?>-<LinearLayout- xmlns:android="http://schemas.android.com/apk/res/android"- android:orientation="vertical"- android:layout_width="fill_parent"- android:layout_height="fill_parent">-- <com.viewpagerindicator.TitlePageIndicator- android:id="@+id/indicator"- android:padding="10dip"- android:layout_height="wrap_content"- android:layout_width="fill_parent"- />- <android.support.v4.view.ViewPager- android:id="@+id/pager"- android:layout_width="fill_parent"- android:layout_height="0dp"- android:layout_weight="1"- />--</LinearLayout>\ No newline at end of filediff --git a/src/main/res/layout/activity_start.xml b/src/main/res/layout/activity_start.xmlindex 3fc324f..3f21d45 100644--- a/src/main/res/layout/activity_start.xml+++ b/src/main/res/layout/activity_start.xml@@ -3,29 +3,14 @@android:layout_width="fill_parent"android:layout_height="fill_parent">-<RelativeLayout+<LinearLayout+ android:orientation="vertical"android:layout_width="match_parent"- android:layout_height="match_parent" >+ android:layout_height="match_parent"+ android:padding="6sp"+ >- <CheckBox- android:id="@+id/accelerometer_check"- android:text="@string/accelerometer_label"- android:layout_width="wrap_content"- android:layout_height="wrap_content"- android:layout_centerHorizontal="true"- tools:context=".StartActivity" />-- <RelativeLayout- android:background="@drawable/back"- android:layout_below="@id/accelerometer_check"- android:id="@+id/accelerometer_options"- android:layout_width="match_parent"- android:layout_height="wrap_content"- android:visibility="gone"- android:paddingLeft="30dp"- android:paddingRight="30dp"- android:layout_marginLeft="20dp"- android:layout_marginRight="20dp">+<TextViewandroid:id="@+id/accelerometer_prompt"android:text="@string/accelerometer_prompt"@@ -43,36 +28,7 @@android:layout_height="wrap_content"android:layout_centerHorizontal="true"/>-- </RelativeLayout>- <CheckBox- android:id="@+id/camera_check"- android:text="@string/camera_label"- android:layout_width="wrap_content"- android:layout_height="wrap_content"- android:layout_centerHorizontal="true"- tools:context=".StartActivity"- android:layout_below="@id/accelerometer_options"/>- <RelativeLayout- android:background="@drawable/back"- android:layout_below="@id/camera_check"- android:id="@+id/camera_options"- android:layout_width="match_parent"- android:layout_height="wrap_content"- android:visibility="gone"- android:paddingLeft="30dp"- android:paddingRight="30dp"- android:layout_marginLeft="20dp"- android:layout_marginRight="20dp">- <CheckBox- android:id="@+id/flash_check"- android:text="@string/flash_label"- android:layout_width="wrap_content"- android:layout_height="wrap_content"- android:layout_centerHorizontal="true"- tools:context=".StartActivity"- /><TextViewandroid:id="@+id/camera_prompt"android:text="@string/camera_prompt"@@ -80,7 +36,6 @@android:layout_width="wrap_content"android:layout_height="wrap_content"android:paddingTop="10dp"- android:layout_below="@id/flash_check"/><Spinnerandroid:id="@+id/camera_spinner"@@ -90,11 +45,10 @@android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerHorizontal="true"- android:layout_below="@id/flash_check"/><TextViewandroid:id="@+id/camera_sensitivity_prompt"- android:text="@string/accelerometer_prompt"+ android:text="@string/camera_sensitivity"android:layout_alignParentLeft="true"android:layout_width="wrap_content"android:layout_height="wrap_content"@@ -104,7 +58,7 @@<Spinnerandroid:id="@+id/camera_sensitivity_spinner"android:layout_alignParentRight="true"- android:layout_below="@id/camera_spinner"+ android:layout_below="@id/camera_sensitivity_prompt"android:prompt="@string/accelerometer_prompt"android:entries="@array/accelerometer_sensitivity"android:layout_width="wrap_content"@@ -112,30 +66,9 @@android:layout_centerHorizontal="true"/>- </RelativeLayout>- <CheckBox- android:id="@+id/microphone_check"- android:text="@string/microphone_label"- android:layout_width="wrap_content"- android:layout_height="wrap_content"- android:layout_centerHorizontal="true"- tools:context=".StartActivity"- android:layout_below="@id/camera_options" />-- <RelativeLayout- android:background="@drawable/back"- android:layout_below="@id/microphone_check"- android:id="@+id/microphone_options"- android:layout_width="match_parent"- android:layout_height="wrap_content"- android:visibility="gone"- android:paddingLeft="30dp"- android:paddingRight="30dp"- android:layout_marginLeft="20dp"- android:layout_marginRight="20dp">- <TextView+ <TextViewandroid:id="@+id/microphone_prompt"- android:text="@string/accelerometer_prompt"+ android:text="@string/microphone_sensitivity"android:layout_alignParentLeft="true"android:layout_width="wrap_content"android:layout_height="wrap_content"@@ -144,35 +77,22 @@<Spinnerandroid:id="@+id/microphone_sensitivity_spinner"android:layout_alignParentRight="true"- android:prompt="@string/accelerometer_prompt"+ android:prompt="@string/microphone_sensitivity"android:entries="@array/accelerometer_sensitivity"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerHorizontal="true"/>- </RelativeLayout>-+<CheckBoxandroid:id="@+id/sms_check"android:text="@string/sms_label"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerHorizontal="true"- tools:context=".StartActivity"- android:layout_below="@id/microphone_options" />+ tools:context=".StartActivity" />- <RelativeLayout- android:background="@drawable/back"- android:layout_below="@id/sms_check"- android:id="@+id/sms_options"- android:layout_width="match_parent"- android:layout_height="wrap_content"- android:visibility="gone"- android:paddingLeft="30dp"- android:paddingRight="30dp"- android:layout_marginLeft="20dp"- android:layout_marginRight="20dp"><EditTextandroid:id="@+id/phone_number"android:hint="@string/sms_hint"@@ -182,82 +102,15 @@android:layout_height="wrap_content"android:paddingTop="10dp"/>-- </RelativeLayout>-- <CheckBox- android:id="@+id/remote_check"- android:text="@string/remote_label"- android:layout_width="wrap_content"- android:layout_height="wrap_content"- android:layout_centerHorizontal="true"- tools:context=".StartActivity"- android:layout_below="@id/sms_options" />- <RelativeLayout- android:background="@drawable/back"- android:layout_below="@id/remote_check"- android:id="@+id/remote_options"- android:layout_width="match_parent"- android:layout_height="wrap_content"- android:visibility="gone"- android:paddingLeft="30dp"- android:paddingRight="30dp"- android:layout_marginLeft="20dp"- android:layout_marginRight="20dp">- <EditText- android:id="@+id/email"- android:hint="@string/email_hint"- android:inputType="textEmailAddress"- android:layout_centerHorizontal="true"- android:layout_width="fill_parent"- android:layout_height="wrap_content"- android:paddingTop="10dp"- />- <EditText- android:id="@+id/password"- android:layout_below="@id/email"- android:hint="@string/password_hint"- android:inputType="textPassword"- android:layout_centerHorizontal="true"- android:layout_width="fill_parent"- android:layout_height="wrap_content"- android:paddingTop="10dp"- />-- </RelativeLayout>-- <RelativeLayout- android:background="@drawable/back"- android:layout_below="@id/remote_options"- android:id="@+id/unlock_options"- android:layout_width="match_parent"- android:layout_height="wrap_content"- android:paddingLeft="30dp"- android:paddingRight="30dp"- android:layout_marginTop="10dp"- android:layout_marginLeft="20dp"- android:layout_marginRight="20dp">- <EditText- android:id="@+id/unlock_code"- android:hint="@string/unlock_code_hint"- android:inputType="textPassword"- android:layout_centerHorizontal="true"- android:layout_width="fill_parent"- android:layout_height="wrap_content"- android:paddingTop="10dp"- />-- </RelativeLayout>-+<Buttonandroid:id="@+id/start_button"android:text="@string/start_button"- android:layout_below="@id/unlock_options"- android:layout_width="wrap_content"+ android:layout_width="200dp"android:layout_height="wrap_content"android:layout_centerHorizontal="true"/>-</RelativeLayout>+</LinearLayout></ScrollView>\ No newline at end of filediff --git a/src/main/res/layout/layout_running.xml b/src/main/res/layout/layout_running.xmlnew file mode 100644index 0000000..a598b11--- /dev/null+++ b/src/main/res/layout/layout_running.xml@@ -0,0 +1,15 @@+<?xml version="1.0" encoding="utf-8"?>+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"+ android:orientation="vertical" android:layout_width="match_parent"+ android:layout_height="match_parent"+ android:gravity="center_vertical"+ >++ <TextView+ android:layout_width="wrap_content"+ android:layout_height="wrap_content"+ android:textAppearance="?android:attr/textAppearanceLarge"+ android:text="Monitoring..."+ android:id="@+id/textView"+ android:layout_gravity="center_horizontal|center_vertical" />+</LinearLayout>\ No newline at end of filediff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xmlindex 433d69c..790466d 100644--- a/src/main/res/values/strings.xml+++ b/src/main/res/values/strings.xml@@ -1,18 +1,24 @@<resources>- <string name="app_name">SecureIt</string>+ <string name="app_name">PhoneyPot</string><string name="menu_stop">Stop</string>- <string name="title_activity_start">SecureIt</string>-- <string name="accelerometer_label">- Use accelerometer to detect motion- </string>+ <string name="title_activity_start">PhoneyPot</string>+<string name="accelerometer_prompt">- Set sensitivity+ Set movement & vibration sensitivity</string>-++ <string name="microphone_sensitivity">+ Set microphone sensitivity+ </string>++ <string name="camera_sensitivity">+ Set camera motion sensitivity+ </string>++<string name="microphone_label">Use microphone to detect any sound</string>@@ -28,28 +34,15 @@<string name="sms_label">Send an SMS as alert</string>-- <string name="remote_label">- Send alert data to SecureIt- </string>-+<string name="sms_hint">Phone</string>-- <string name="email_hint">- </string>-- <string name="password_hint">- Password- </string>-+<string name="unlock_code_hint">Code to stop the app</string>--+<string name="start_button">Start</string>@@ -67,13 +60,12 @@<item>Front</item><item>Back</item></array>++ <string name="unlock_title">Set Unlock Pin</string>- <string name="secure_service_started">- Home security deamon started- </string>+ <string name="secure_service_started">Phoneypot monitoring activated</string>- <string name="secure_service_stopped">- Home security deamon stopped- </string>+ <string name="secure_service_stopped">Phoneypot monitoring deactivated</string>+ <string name="intrusion_detected">An intrusion was detected.</string></resources>\ No newline at end of file