audiosource icon indicating copy to clipboard operation
audiosource copied to clipboard

Fix AudioRecord & Notification permission issues, remove extra indents

Open barlin41k opened this issue 4 months ago • 4 comments

  • RecordService
    • handling SecurityException and check RECORD_AUDIO permission for AudioRecord initialization
    • check POST_NOTIFICATIONS permission before showing notifications
    • minor >= warning fix
  • RecordThread
    • remove extra indents

barlin41k avatar Sep 07 '25 13:09 barlin41k

Hi @barlin41k,

Thanks for the PR, but I'm not sure what issue it addresses.

Permissions are checked in MainActivity.java even before starting the service, so it shouldn't be necessary to check them again (unless I'm missing something).

Best regards,

gdzx avatar Oct 01 '25 22:10 gdzx

Hi @barlin41k,

Thanks for the PR, but I'm not sure what issue it addresses.

Permissions are checked in MainActivity.java even before starting the service, so it shouldn't be necessary to check them again (unless I'm missing something).

Best regards,

Hi @gdzx,

You're right, the required permissions already checks in MainActivity.java, so I ended up duplicating that logic.

That said, I think try/catch around AudioRecord is still useful because if the user revokes the permission after service has started, it would just crash. The POST_NOTIFICATIONS checks around notify don't really add any value, since calling notify() is safe without the permission. Those can definitely removed.

Best regards,

barlin41k avatar Oct 02 '25 12:10 barlin41k

If the user revokes the permission after service has started, it would just crash.

I don't think this is addressed by your change either, since after the service is started, the same AudioRecord instance is kept in the RecordThread (so it won't pass through your try / catch again).

There is a lot that could be improved in the handling of permissions (like having some UI that can ask the user to grant them, whereas currently the app just doesn't work), but I don't think this PR really improves the situation, sorry.

gdzx avatar Oct 02 '25 19:10 gdzx