Skip to content

armgit / haven

Public Imported from GitHub
0

Haven is for people who need a way to protect their personal spaces and possessions without compromising their own privacy, through an Android app and on-device sensors

handle crashes from the media record better

n8fr8b6ba321f0153
diff --git a/src/main/java/info/guardianproject/phoneypot/sensors/media/AudioRecorderTask.java b/src/main/java/info/guardianproject/phoneypot/sensors/media/AudioRecorderTask.java
index 3eaf6ef..431fb91 100644
--- a/src/main/java/info/guardianproject/phoneypot/sensors/media/AudioRecorderTask.java
+++ b/src/main/java/info/guardianproject/phoneypot/sensors/media/AudioRecorderTask.java
@@ -103,24 +103,31 @@ public class AudioRecorderTask extends Thread {
e.printStackTrace();
return;
}
-
- Log.i("AudioRecorderTask", "Start recording");
- recorder.start();
+
try {
- Thread.sleep(prefs.getAudioLength());
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- recorder.stop();
- Log.i("AudioRecorderTask", "Stopped recording");
- recorder.release();
- recording = false;
+ Log.i("AudioRecorderTask", "Start recording");
+ recorder.start();
+ try {
+ Thread.sleep(prefs.getAudioLength());
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ recorder.stop();
+ Log.i("AudioRecorderTask", "Stopped recording");
+ recorder.release();
+
+ recording = false;
- MicrophoneTaskFactory.restartSampling();
+ MicrophoneTaskFactory.restartSampling();
- if (mListener != null)
- mListener.recordingComplete(audioPath.toString());
+ if (mListener != null)
+ mListener.recordingComplete(audioPath.toString());
+ }
+ catch (IllegalStateException ise)
+ {
+ Log.w("AudioRecorderTask","error with media recorder");
+ }
}