CATROID-1412 Fix loudness sensor being always 0#5167
CATROID-1412 Fix loudness sensor being always 0#5167urkat merged 16 commits intoCatrobat:developfrom
Conversation
|
Red phase. Add a regression test that captures the loudness recorder target path and proves that the current A small test seam is introduced in |
|
Green phase. Switch the loudness sensor from This keeps the regression test green and restores working loudness readings on a real device. |
catroid/src/test/java/org/catrobat/catroid/formulaeditor/SensorLoudnessTest.java
Fixed
Show fixed
Hide fixed
There was a problem hiding this comment.
Pull request overview
Fixes the loudness sensor returning 0 by replacing the recorder output from /dev/null with a real file under the app’s cache directory, and adds a regression test to ensure the recorder path is cache-backed.
Changes:
- Add
SensorLoudnessTestto assert the loudness recorder no longer targets/dev/nulland uses the sound recorder cache directory. - Update
SensorLoudnessto create itsSoundRecorderwith a cache-file output path (via a small test seam/factory). - Centralize the default loudness recording file path (
Constants.SOUND_RECORDER_CACHE_DIRECTORY/loudness_sensor.m4a).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
catroid/src/test/java/org/catrobat/catroid/formulaeditor/SensorLoudnessTest.java |
Adds a Robolectric regression test verifying the recorder path selection. |
catroid/src/main/java/org/catrobat/catroid/formulaeditor/SensorLoudness.java |
Switches loudness recording target from /dev/null to a cache-backed file and introduces a factory seam for testing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
catroid/src/main/java/org/catrobat/catroid/formulaeditor/SensorLoudness.java
Outdated
Show resolved
Hide resolved
|
@wslany The SensorLoudness fix itself looks good to me, and the added tests are helpful. This likely stayed unnoticed before because SensorLoudness was using Could You Please add explicit loudness/sensor cleanup when the dialog is dismissed or stopped, then this looks good to me. |
|
@wslany LGTM! |
|
Thanks @harshsomankar123-tech , it was a good catch. I added a regression test for |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Here's a screen recording with sound of an on-device test of the build: https://photos.app.goo.gl/z1ywpYWsDRW78VLa9 --- I tested:
|
dorianpercic
left a comment
There was a problem hiding this comment.
Thanks for the PR! :)
I think we should implement source code files in Kotlin, since otherwise we need a refactoring ticket again.
catroid/src/main/java/org/catrobat/catroid/formulaeditor/SensorLoudness.kt
Fixed
Show fixed
Hide fixed
catroid/src/main/java/org/catrobat/catroid/formulaeditor/SensorLoudness.kt
Fixed
Show fixed
Hide fixed
catroid/src/main/java/org/catrobat/catroid/ui/dialogs/FormulaEditorComputeDialog.kt
Fixed
Show fixed
Hide fixed
catroid/src/main/java/org/catrobat/catroid/ui/dialogs/FormulaEditorComputeDialog.kt
Fixed
Show fixed
Hide fixed
I rewrote the touched loudness-related Java files and their dedicated tests to Kotlin in a red/green sequence:
Verification:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
catroid/src/test/java/org/catrobat/catroid/ui/dialogs/FormulaEditorComputeDialogTest.kt
Show resolved
Hide resolved
catroid/src/main/java/org/catrobat/catroid/formulaeditor/SensorLoudness.kt
Outdated
Show resolved
Hide resolved
catroid/src/main/java/org/catrobat/catroid/formulaeditor/SensorLoudness.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I've also tested the latest head on my phone once more: loudness sensor works everywhere, Other sensors also work in the formula editor compute dialog. |
|



Summary
This PR fixes the loudness sensor returning
0by replacing its/dev/nullrecorder target with a real cache-backed recording file.https://catrobat.atlassian.net/browse/CATROID-1412
There are several red -> green commits which are only meant to make reviewing easier. The PR should be squashed when merged.
Red phase
The first commit adds a regression test for the loudness recorder setup and a small test seam in
SensorLoudnessso the chosen recorder path can be inspected in a unit test.In the red state, the test fails because
SensorLoudnessstill creates its recorder with/dev/null.Green phase
The second commit changes the default loudness recorder target to a file inside
Constants.SOUND_RECORDER_CACHE_DIRECTORY.This keeps the test green and avoids the
/dev/nullsetup that appears to breakMediaRecorder.getMaxAmplitude()on current Android/device combinations.Verification
SensorLoudnessTestfails before the fixSensorLoudnessTestpasses after the fixYour checklist for this pull request
Please review the contributing guidelines and wiki pages of this repository.