adding-retrys #4

Closed
pi wants to merge 0 commits from adding-retrys into child-monitor-multiple-clients
Owner

added editable retries and correct error handleing

added editable retries and correct error handleing
pi changed target branch from master to child-monitor-multiple-clients 2025-11-11 01:54:56 +01:00
pi added 246 commits 2025-11-11 01:54:56 +01:00
The StartActivity is the first activity which will be launched
in the baby monitor, and in the future will list the two main
options: become a monitor or a listener.
This commit adds the shell of the MonitorActivity. This activity
will register its service on the local network, wait for a connection,
then send audio data.
When the MonitorActivity is started it will create a ServerSocket.
The assigned port is then advertised over mDNS for a
"ProtectBabyMonitor" service.

Eventually, when something connects to the ServerSocket audio
data will be streamed out.
If a client connects to the advertised ProtectBabyMonitor service,
attempt to service the connection.

For now, simply close the connection instead of sending data.
While connected, send packets of audio data to connected clients.
If the send buffer size is large and the receiver is unable
to keep up, then audio samples will collect on the monitor
and lag will accumulate. As only the most recent sample is
important, reduce the send buffer size to the minimum
AudioRecord buffer size.
This is the stub of the DiscoverActivity, which is responsible for
discovering all available ProtectBabyMonitor services on the
local network.
Attempt to discover any providers of the ProtectBabyMonitor
service on the local network, resolving any which are found.
For now nothing is done with the information on found
providers.
This activity will eventually receive audio from the MonitorActivity
of another Android device and play it.
If any ProtectBabyMonitor services are found on the network, clicking
on one will start a ListenActivity with information on the service.
When connected to a ProtectBabyMonitor service, accept
audio over the network. However, for now, discard the audio
instead of playing it.
This thread will be used for playing audio samples. The samples
will be provided by a blocking queue.

It is assumed that the configuration of the passed AudioTrack and
the samples from the blocking queue are compatible.
Whenever a sample is received from the socket, pass it to
the AudioPlayer thread via a blocking queue. The AudioPlayer
thread will then play the sample and wait for more input.
The "monitor" and "connect to monitor" descriptions may
have been confusing. Changing the terminology to refer to
a child and parent device.
When mDNS returns the service name, any spaces are replaced
with \\032. Change this back into a space
It may not have been obvious that the labels were clickable before.
Improve layout and appearance of application
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.
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.
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.
Improve usability - volume control, survive screen rotation, screen stays on
This will eventually be called in multiple places
Previously an IOException would prevent the AudioRecord
from being cleaned up.
Previously the monitor activity would only support one connection,
after which the activity would need to be restarted. With this change,
if a connection is established with a parent device but is eventually
disconnected the child device will begin advertising again.

Note that because the child device can only support one connection
at a time currently, after the connection is established it will
now stop advertising. When a connection is lost and advertising
starts again, it may end up advertising as another service. E.g.
  ProtectBabyMonitor (2)
instead of
  ProtectBabyMonitor
If the connection to the child was intentionally severed, do not
post a "disconnected" message, as the activity is likely closing.
If the child device disconnects unexpectedly, alert the
user, in case they were not expecting the disconnect.

The audio file being played is originally from here:
https://freesound.org/people/pan14/sounds/263655/
These methods are not needed outside of this class
Better recovery from connection disconnects
Create NEWS
Update versionName to be 0.1 for initial release
The previous approach was to list buttons in a TableLayout.
However, this approach does not work well if there are more
items than can fit on the screen.

To allow scrolling of items, and also a better presentation
of said items, use a ListView.
Use a ListView to store discovered child devices
The additional thread to feed the AudioTrack was unnecessary.
Because the AudioTrack API is blocking when data is written,
and internally it buffers data, writing the data as soon
as it is received from the network leads to better playback
performance. It is also much simpler.
The original buffer sized used was 1/2 what was intended.
byteBufferSize is already defined to be bufferSize*2
Some implementations of mDNS on Android display a space as
  \\032
and some display it as
  \032

Attempt to convert both types to a " " before displaying it
Improve audio
Create AUTHORS file
Update NEWS
Later, the parent will be able to use this information to pair
with the child device, as an alternative to using mDNS
On some networks or some mDNS implementations child discovery may not
work well. As an alternative, allow a parent to connect to a device
directly with an IP Address and port.
If mDNS fails to locate the child device, allow the parent device
to enter an IP address and port to connect.
Allow parent to enter child's address and port to connect
Added Japanese translation
Prepare 0.2 release
The source of the app icon was Icons4Android. Mentioning WPZOOM instead was a typo.
Correct source of app icon in README.md
Improvements to README.md
README: add Transifex info
Convert project from ant to gradle
Add support for FindBugs
It turns out that the min SDK the application will support is
16, as the NsdManager is available only at SDK 16 and above.
These are only available in SDK 17
This is to support SDK 16 and below
Reduce min SDK to 16
Updated README with SDK 16
Add google maven repository, to allow importing compatibility libs
TODO: Change icon color/details for connected vs. disconnected status
Update the SDK version to match the version in gradle.
Implement Persistent Notification
The version name and code were not brought over
from the AndroidManafest.xml file. Previously they
were for v0.2.
Update for v0.3
Add privacy policy
onCreate is already running on the UI thread, no need
to create a separate runnable.
Notification updates
Create CONTRIBUTING.md
The aapt2 tool, new to Android Studio 3, creates an APK which fails
to install on Android 5 and below if it contains the following bug:

  https://issuetracker.google.com/issues/64434571

Build tools 27.0.1 has a mitigation. Avoiding aapt2 also avoids hitting
the bug.
Workaround install crash on Android 5 and below
Translations contributed by Alexander Muro on Transifex
Add German translations
The settings menu was present in the Child Device view, but
did not do anything when selected.
Remove unused settings menu
Transifex config file and translation updates
Add Dutch translations
Update privacy policy
Update translation instructions in README
Mention hiatus in README
string in ptbr
ptbr translation
It doesn't change any functionality, only the format and
settings according to the recommendations of Android Studio
This moves the model of the historic volume to its own class (VolumeHistory),
and extracts the listening out of the ListenActivity to the ListenService.
Move listening to ListenService
Same motivation as for the parent device:
The monitor activity will be quickly destroyed,
unless it is connected to a foreground service.

By moving the thread and audio listener to a service,
this should be avoided.
The socket is closed in another thread to stop the transmission.
That causes an exception, but that is the expected behaviour, so
do not log it.
Move Monitor Mode for Child to its own Service
This way we can handle the IOException in the same place
as in the java version, without throwing passing unchecked exceptions
Modernize the Stack Kotlin Edition
Undo an unintentional change done in f6a429e.
The brightness was calculated from the normalized volume, but when factoring
the norm out in the history, that norm was dropped.
- Setters are rather java-esque, and ...
- callbacks in the Android ecosystem are usually more
  called on<EventName> than <EventName>Callback.
Remove setters, and rename callbacks for onSomething
Normalize volume for brightness
No more translations please
Delete unsupported .tx/config for Transifex
pi closed this pull request 2025-11-11 01:56:58 +01:00

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: pi/babyphone#4