From 516ba5a225b2c533e24e3c29c8e2eee48e677d44 Mon Sep 17 00:00:00 2001 From: Branden Archer Date: Sun, 27 Dec 2015 20:34:02 -0500 Subject: [PATCH 1/3] Allow volume control to adjust playback volume The AudioTrack for playing audio from the child device was sending audio to the voice call stream. It is more appropriate to use the music stream. In addition, suggest that the activity control the music stream's volume with the hardware controls. --- src/protect/babymonitor/ListenActivity.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/protect/babymonitor/ListenActivity.java b/src/protect/babymonitor/ListenActivity.java index f2e5b9e..0e1b66e 100644 --- a/src/protect/babymonitor/ListenActivity.java +++ b/src/protect/babymonitor/ListenActivity.java @@ -50,7 +50,7 @@ public class ListenActivity extends Activity int audioEncoding = AudioFormat.ENCODING_PCM_16BIT; int bufferSize = AudioTrack.getMinBufferSize(frequency, channelConfiguration, audioEncoding); - final AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_VOICE_CALL, + final AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, frequency, channelConfiguration, audioEncoding, @@ -63,6 +63,8 @@ public class ListenActivity extends Activity Thread playThread = new Thread(audioPlayer); playThread.start(); + setVolumeControlStream(AudioManager.STREAM_MUSIC); + InputStream is = socket.getInputStream(); int read = 0; From 7f604c47cecfbff27854f5daac6b81beb1e988d3 Mon Sep 17 00:00:00 2001 From: Branden Archer Date: Sun, 27 Dec 2015 20:41:01 -0500 Subject: [PATCH 2/3] Prevent child device from sleeping if listening If the screen turns off, the child device will be unable to record from the microphone. Keep the screen on in the monitor activity to keep microphone on. --- res/layout/activity_monitor.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/res/layout/activity_monitor.xml b/res/layout/activity_monitor.xml index 566286e..07625b9 100644 --- a/res/layout/activity_monitor.xml +++ b/res/layout/activity_monitor.xml @@ -8,6 +8,7 @@ android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" + android:keepScreenOn="true" tools:context="protect.babymonitor.MonitorActivity" > Date: Sun, 27 Dec 2015 20:48:00 -0500 Subject: [PATCH 3/3] Prevent screen rotation or resize from destroying activities If the screen is rotated by default Android destroys the activity and recreates it. This causes issues if a child and parent are already paired, as the connection is lost. To prevent Android from destroying the Activity, instead invoke a configuration change on an orientation or resize. --- AndroidManifest.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index a03df26..271c6b7 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -18,6 +18,7 @@ @@ -27,16 +28,19 @@