Skip to content

Query MediaStore for media file URI for setting ringtone #4389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: release/4.0
Choose a base branch
from

Conversation

TranceLove
Copy link
Collaborator

Description

With reference to #4367, by inspecting the ringtone settings of a device

settings get system notification_sound

It becomes known that ringtone requires a content URI to the selected audio file on the device.

This PR tries to create that URI by querying the MediaStore. Therefore there is a prerequisite that even the audio file is visible in Amaze, it must also be visible to the MediaStore too, that refreshing the MediaStore is required.

Had attempted to do this for end user in code, but only worked on Android 14 or above, so gave up and not reinvent the wheel instead.

Issue tracker

Fixes #4367

Automatic tests

  • Added test cases

Manual tests

  • Done

Device:

  • Pixel 4 emulator running Android 9
  • Pixel 7 emulator running Android 14
  1. Make sure the audio file exists in MediaStore. Some apps like Musicolet can help refresh the MediaStore
  2. Open settings -> Sound
  3. Change ringtone
  4. Choose Amaze when app selection pops up
  5. Choose the audio file
  6. Ringtone name should shown equal to filename without extension, and no Toast pops up
  7. Call the device
  8. Device should ring without crashing any app

Build tasks success

Successfully running following tasks on local:

  • ./gradlew assembledebug
  • ./gradlew spotlessCheck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using to select ringtone won't work and is irreversible
1 participant