summaryrefslogtreecommitdiff
path: root/media/java/android/media/RingtoneManager.java
AgeCommit message (Collapse)Author
2021-07-02Add context in AudioManager.hasHapticChannels.jiabin
A context will be required for resolving a Uri. Using the context in AudioService may not always work and it may cause not oneway binder call issue. In that case, using the context in RingtoneManager could help. In AudioManager, caching a static context so that it can be used when there is not context provided. Test: atest RingtoneManagerTest Bug: 187842281 Change-Id: Ia2f514cb8f821926cf3d353cf912a44aeb584ab6
2021-06-14Fix inconsistency in ringtone listakansha.shukla
Sometimes when ringtone from external storage gets same _id as any ringtone of internal volume, getRingtonePosition(..) matches with the internal one firstly, and the ringtone shown is wrong. Solution is to match the URI of ringtone instead of the _ID so that correct ringtone is chosen. Bug: 172878342 Change-Id: I8fc3e936fe89308d4697eda42088e4fd533ce47c Merged-In: I8fc3e936fe89308d4697eda42088e4fd533ce47c
2020-10-29Add maxTargetSdk restriction to unused APIs.Mathew Inwood
These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. This is a resubmit of ag/12929664 with some APIs excluded that caused test failures; see bugs 171886397, 171888296, 171864568. APIs excluded: Landroid/bluetooth/le/ScanRecord;->parseFromBytes([B)Landroid/bluetooth/le/ScanRecord; Landroid/os/Process;->myPpid()I Landroid/os/SharedMemory;->getFd()I Landroid/hardware/input/InputManager;->INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH:I Bug: 170729553 Test: Treehugger Change-Id: I8285daa8530260251ecad6f3f38f98e263629ca7
2020-10-28Revert "Add maxTargetSdk restriction to unused APIs."Hongwei Wang
This reverts commit 72f07d6a8a32db4a0dedd7682a0b3385be2b9cd6. Reason for revert: Droidcop-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?testMethod=testAppZygotePreload&testClass=android.app.cts.ServiceTest&atpConfigName=suite%2Ftest-mapping-presubmit-retry_cloud-tf&testModule=CtsAppTestCases&fkbb=6936597&lkbb=6936969&lkgb=6936551&testResults=true&branch=git_master&target=cf_x86_phone-userdebug>, bug b/171886397 Bug: 171886397 Change-Id: Ibe0f0430a3451477c1ee8ef56a596e91ea1e7672
2020-10-27Add maxTargetSdk restriction to unused APIs.Mathew Inwood
These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. Bug: 170729553 Test: Treehugger Change-Id: I4c8fd0006f950de9955242e93968fb0996ceb372
2020-09-29Use the try catch to deal with the StaleDataException.guofei.xue
When test the monkey, the mCursor is not null and the mCursor is Closed. So that the mCursor cannot call the method of moveToPosition. Otherwise it will lead to StaleDataException. In order to prevent the android.database.StaleDataException and IllegalStateException, use the try catch to deal with the StaleDataException and IllegalStateException. Test:Perform the monkey test, and See if this android.database.StaleDataException will happen again when call the method of android.media.RingtoneManager#getRingtoneUri. Bug: 169292273 Change-Id: I577c41c6a4b0025ce562a2dc495a6f28b103cfaa
2020-09-18Ringtone uri should add type querywan.li
When only DisplayName is used to query the default ringtone, the query may be incorrect, because other types of ringtones may contain resources with the same name. It should not happen that other types of ringtone uri are set as the default ringtone of the current type by mistake. Test: manual set all types of default ringtones to use the audio with the same DisplayName as the preset value. See if all types of ringtones are selected in RingtonePickerActivity. Bug: 168431815 Change-Id: Iec46c80b1da929cacc0e04fd9641955ce6e8cfcf
2020-02-19Merge "RingtoneManager: Don't crash if the ringtone doesn't have a numerical ↵Automerger Merge Worker
ID" am: ff78aab391 am: 0396aae65b am: ac23b2292d Change-Id: Id6d7ff358769c86fab311b5b1161e8916169212e
2020-02-14RingtoneManager: Don't crash if the ringtone doesn't have a numerical IDScott Warner
When changing the notification sound for some apps with app-provided sounds, the notification URI doesn't have a numerical ID. For example, Outlook's email notification URI has the id 'new_email' Test: m, outlook doesn't crash anymore, test google calendar Change-Id: Ibf0c6f2f13e1c76ce02784165b97b92e8f7e432c
2020-01-09Use new UnsupportedAppUsage annotation.Artur Satayev
Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library. Bug: 145132366 Test: m && diff unsupportedappusage_index.csv Change-Id: I4bc8c9482e4bb1af21363f951affff7ee3fefeab Merged-In: I4bc8c9482e4bb1af21363f951affff7ee3fefeab
2019-12-18Use new UnsupportedAppUsage annotation.Artur Satayev
Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library. Bug: 145132366 Test: m && diff unsupportedappusage_index.csv Change-Id: I4bc8c9482e4bb1af21363f951affff7ee3fefeab
2019-12-18Shuffling to prepare for MediaProvider APEX.Jeff Sharkey
An upcoming change will move MediaStore to be within the recently created MediaProvider APEX. This means that MediaStore will need to be fully built against @SystemApi, and so this CL adjusts APIs to support a clean transition: -- Listing of "recent" storage volumes and scan paths for "internal" storage is now handled by StorageManager directly, so that partners retain control over what is deemed recent. -- StorageVolume now returns the MediaStore volume name and the filesystem directory where its contents are presented to apps. -- Conversion of legacy thumbnail "kind" values to dimensions now happens directly inside MediaStore. -- PendingParams and PendingSession are completely removed. -- Contributed media APIs are completely removed. -- Media for demo users is now surfaced as a unique StorageVolume. -- Migrate most MediaStore APIs to accept ContentResolver, which supports easy usage of ContentResolver.wrap(). Bug: 144247087, 137890034 Test: atest --test-mapping packages/providers/MediaProvider Exempt-From-Owner-Approval: in-place refactoring Change-Id: I445528b2779bb37b9f2558e67a3cfc9f60412092
2019-10-18Move default ringtone configuration to framework.Jeff Sharkey
This ensures that partners have a place to customize the default ringtone configuration, such as adding support for per-SIM ringtones which aren't officially supported by Android yet. Bug: 141596983, 141518853, 141594113, 141595768, 141809410 Test: atest --test-mapping packages/providers/MediaProvider Change-Id: Ibe5b41c09ca40caadfcbb81162b996173fe8509b
2019-10-11Finish deprecating legacy MediaScanner.Jeff Sharkey
We switched completely over to using ModernMediaScanner in Android Q, and this legacy code is no longer being used. Clean it up, but leave enough remnants behind to begrudgingly keep reflecting apps working. Bug: 128243527 Test: atest --test-mapping packages/providers/MediaProvider Change-Id: Ib2bc341fafcd4c2e049c864a35fbe651d013f6fd
2019-05-16Compare ringtones using IDs.Jeff Sharkey
Comparing by constructing full Uris doesn't work when one of the values has been canonicalized. Bug: 132816653 Test: atest android.media.cts.RingtoneManagerTest#testAccessMethods Change-Id: Id4b26820e76ec3d1d56ba6cf3c76375dafcf92c0
2019-05-06Call MediaStore#scanFile directly in RingtoneManagerWinson
Reproduced the failing case, even without thread pool changes. Since RingtoneManager was blocking on the call anyways, changing it to use the synchronous scanFile method directly should be fine. Bug: 131882699 Test: manual add MP3 with RingtonePickerActivity Change-Id: I53b49ed17403cda93ecfefb6985133b161a96983
2019-04-17Canonicalize default ringtones.Jeff Sharkey
Bug: 130445562 Test: atest --test-mapping packages/providers/MediaProvider Change-Id: Ia4dee2f5596147ac50b2393fccb8516cc43b0102
2019-04-16Canonicalize ringtones before returning.Jeff Sharkey
Bug: 130475623 Test: none Change-Id: I6408800290077dfc7d0252a9b23443c3a70d4563
2019-03-26Unify media permissions enforcement in framework.Jeff Sharkey
This opens the door to the same consistent logic being shared by anyone across the OS who wants to enforce storage permissions. Bug: 126788266 Test: atest --test-mapping packages/apps/MediaProvider Exempted-From-Owner-Approval: Trivial permissions refactoring Change-Id: I3107425f8dafa6ba05918bb67c3c0cb5d3899657
2019-03-20Add API in RingtoneManager to query if files contain haptic channels.jiabin
The query will go to AudioService in case the app itself does not have the permission to access the files. Test: test with files (not) containing haptic channels. Bug: 128012181 Change-Id: I0a3410161e9718197276dc9d6abecada81cf0ee4
2019-03-17Fix synthetic RingtoneManager column.Jeff Sharkey
It was querying a column that didn't exist internally; instead it needs to fake that value for its clients. Bug: 128349496 Test: atest android.media.cts.RingtoneTest Change-Id: I7c3738cdb21ac5c92df55a8622b24f5c6a118154
2018-12-21Make RingtoneManager and Ringtone class support VolumeShaperYiwen Chen
Bug: 120789399 Test: When finish the whole change, flash into a dev phone to test first. Change-Id: I4620fac5f1c34d37b3b33565cebbea2c091a5d08
2018-11-30RingtoneManager: add @Nullable to openDefaultRingtoneUri().Dongwon Kang
Bug: 120072398 Test: make update-api Change-Id: I9fd43ac80f643fe81b4ed16d84b4253f19899c1c
2018-10-26Move away from deprecated "_data" column.Jeff Sharkey
As part of the new privacy work in Q, apps no longer have access to raw filesystem paths, since they may live outside of the current sandbox. Instead, we need to use CR.openFileDescriptor(). Bug: 111960973 Test: builds, boots Change-Id: I6e52a7dcb39850d9835183c44f5f638a5bf77202
2018-10-10Add RingtoneManager.openDefaultRingtoneUri()Dongwon Kang
This enables a way for client to open ringtone cache from DE storage area before user is unlocked. Test: RingtoneManagerTest and MediaPlayer2Test Bug: 112767549 Change-Id: Ica929f079dbc14f8541d92b5c9b9a0db502d3d64
2018-08-17Add @UnsupportedAppUsage annotationsMathew Inwood
For packages: android.media.tv android.media.soundtrigger android.media.session android.media.projection android.media.midi android.media.effect.effects android.media.effect android.media.browse android.media.audiopolicy android.media.audiofx android.media This is an automatically generated CL. See go/UnsupportedAppUsage for more details. Exempted-From-Owner-Approval: Mechanical changes to the codebase which have been approved by Android API council and announced on android-eng@ Bug: 110868826 Test: m Change-Id: I3bd40136d7fc948f66eca6b2d139c15e39c5a248
2018-05-24Merge "Use correct filename when adding to ringtone" am: daff857ffdDaisuke Teranishi
am: 24062f05d3 Change-Id: Id9d89491c5604b1611b22f215827f55de98f8ac2
2018-05-24Use correct filename when adding to ringtoneDaisuke Teranishi
If the title of the music file includes "/", it's recognized as a directory separator. Use correct filename to select the file properly. Bug: 80202253 Test: Add mp3 which title includes "/" to ringtone Change-Id: I9bb05f6fe2d7d4dbbdf4f67db7ac6fde04707979
2018-01-31Use sendfile() and splice() to speed up copying.Jeff Sharkey
There are several places across the OS where Java code is simply copying data between two points, which requires bringing that data out into userspace before going back into the kernel. (That's pretty lame.) The patches for the recent Meltdown/Spectre security issues have made this overhead even worse, so it's finally time to move this copying directly into the kernel. This change adds a couple new FileUtils.copy() methods which inspect the given streams/FDs, and attempt to do as much optimization as possible before falling back to a slower userspace-based copy. Benchmarks are showing typical improvements of 44% for 32KB files, 50% for 32MB files, and 35% for 32MB pipes. Plenty of tests are included, and there's a simple kill-switch that can be used to enable/disable the feature if it starts causing any trouble. (A future CL will enable the optimizations.) Test: bit FrameworksCoreTests:android.os.FileUtilsTest Test: vogar --mode app_process --benchmark frameworks/base/core/tests/benchmarks/src/android/os/FileUtilsBenchmark.java Bug: 71932978 Change-Id: I52518d529da5d961610998b9f61399064d8025cd
2017-05-09Allow ogg files to be selected as ringtonesChristine Franks
Bug: 37891455 Test: manual - open custom phone ringtone picker in settings, navigate to an .ogg file, and it should be selectable; select it and it should add itself to the list of available ringtones, and play its sample correctly. Change-Id: I33b1ff07d0b43646c807ba0994efa4f6d8d95cae
2017-02-23Don't copy ringtones when profile sync goes offRobin Lee
Experimentally, it makes more sense to more people to have the parent setting as an overlay not a concrete thing. Test: make cts -j30 && cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.ManagedProfileTest#testRingtoneSyncAutoDisableRingtone' </dev/null 2>&1 Bug: 34730524 Change-Id: I5f804713def9e54921b90e4f5cea742ba8aaa685
2017-01-24[SettingsProvider] Auto disable ringtone syncAndre Lago
Disable the SYNC_PARENT_SOUNDS setting if a work profile ringtone is set Test: cts-tradefed --test com.android.cts.devicepolicy.ManagedProfileTest Bug: 30658854 Change-Id: I172f5396b47f03ac8afa365db0ec90f3a2dd0e29
2017-01-05[RingtoneManager] Option for cursor to list parent soundsAndre Lago
Modify RingtoneManager.getCursor so that the cursor returned also retrieves the parent profile's ringtones, adding the parent's id to those ringtones Test: manual (use ringtone picker in associated CL) Bug: 30658854 Change-Id: I3b52b0dc41a5a3ff1a71a89fd8a0d33023021aba
2017-01-05[RingtoneManager] API to delete custom ringtonesAndre Lago
Given a Uri, if it is a media file in one of the external ringtone storages, this API deletes its file and database entry. Test: manual - associated CL Bug: 30658854 Change-Id: I987bd18577960f9a2b02ce37a4a2d5d033d7a969
2017-01-05[RingtoneManager] API to add custom ringtonesAndre Lago
So far, the only way for users to add custom ringtones was to either use a 3rd party app or copy files to a specific directory in the storage, and there was no API to make it easier to add custom ringtones. This CL creates a hidden API in RingtoneManager that allows adding any audio file as a custom ringtone, by copying that file into the ringtone storage and asking MediaScanner to scan that file. This API is not intended to be used by existing apps, but an associated CL uses it in RingtonePickerActivity Test: make && vendor/google/tools/flashall, plus manual testing with associated CL Bug: 30658854 Change-Id: I2b291847c5430e1fc2c3fc6a351b6111a49fcbf3
2016-11-30Stream types are for volume controlJean-Michel Trivi
Deprecate methods where stream types are not used for volume control operations. Add a warning in the logs about the use of stream types to encourage migration to audio attributes. Since STREAM_ACCESSIBILITY is added in O for the volume of a11y audio, throw an exception when trying to use it for playback. Test: make offline-sdk-docs Bug: 30955183 Change-Id: I7fcf79f1de68f217a9b19561aa1325ade169dfcf
2016-09-29Merge "[RingtoneManager] Remove user id from internal Uri"TreeHugger Robot
2016-09-29[RingtoneManager] Remove user id from internal UriAndre Lago
Prevent system ringtones from leaking with user id's on them Test: manual Change-Id: Ia4492c75211f9637e075450763f201bf24c5bf03
2016-09-26Media: check Settings.AUTHORITY without userIdRobin Lee
Otherwise we'll miss a trick and not take the settings provider shortcut for playing work ringtones. Bug: 30658854 Change-Id: I378cabe0ba426a2c91919b3df33a525d41fe3d0d
2016-08-18[media] Separate ringtones for managed profilesAndre Lago
Separate the default system ringtone settings for managed profiles, which previously used the same default ringtones as the personal profile they belong to Bug: 30658854 Change-Id: I22c69c7b8d31c7c424f5e00a3d9febac98b93d74
2016-03-09Resolve ringtone Uris using Context user.Jeff Sharkey
The Context passed in has already been tied strongly to a specific user, so resolve Settings based on that user. Bug: 27568161 Change-Id: I1365c25f97c4177afe592d7c9f410eab777110e7
2016-03-05Ask RingtonePlayer to open data for caching.Jeff Sharkey
When setting default ringtones, RingtoneManager now caches the selected media for playback before the device is unlocked. However, this API hasn't historically required the caller to hold storage permissions. To keep this working, we attempt to delegate ringtone access over through RingtonePlayer, which is what we do for playback. However, because we're caching the real ringtone bits now, we need to be much more careful about the PFDs we're willing to return. This change requires that they be in external storage, and that they have the ringtone/alarm/notification bit set. Bug: 27366059 Change-Id: I59c2adc1d1250a3eac281f190f35a7cb3119967b
2016-02-24Don't try caching null ringtones.Jeff Sharkey
Bug: 27330629 Change-Id: Id09d10d6f4a3a20782480647c68a5c94ef69e7b3
2016-02-23Offer to cache ringtones in system DE storage.Jeff Sharkey
Ringtones often live on shared media, which is now encrypted with CE keys and not available until after the user is unlocked. To improve the user experience while locked, cache the default ringtone, notification sound, and alarm sound in a DE storage area. Bug: 26730753 Change-Id: Ie6ad7790af4c87dd25759df3ed017e3b91a2fb87
2015-07-22RingtoneManager: query results depend on caller permissionJean-Michel Trivi
When querying for ringtones, only look for ringtones on external storage when the caller has READ_EXTERNAL_STORAGE. Document this behavior in the javadoc of the affected methods. Bug 22545684 Change-Id: Iae9c9a4ccaf635da8af2ac289b6b4df1b16c5d11
2015-05-20Extra for ACTION_RINGTONE_PICKER for AudioAttributes flagsJean-Michel Trivi
Add EXTRA_RINGTONE_AUDIO_ATTRIBUTES_FLAGS to allow specifying AudioAttributes flags that will be used when playing the Ringtone. Bug 19407114 Change-Id: I56a77d7308b21afc0766356e1b6a2d76dca21221
2013-11-20Remove unused imports from frameworks/base.John Spurlock
Change-Id: Ia1f99bd2c1105b0b0f70aa614f1f4a67b2840906
2013-04-29Fix javadoc errors for @deprecated tags with no explanatory commentMike Lockwood
Change-Id: I38a31facf7d4a9cd13645516f25b4305df65c618
2013-04-29Remove obsolete OMA-DRM supportMike Lockwood
Change-Id: Ic6008d4c9f8b9cd9fd4efec070260227af70559c
2012-04-27Migrate ringtone playback to SystemUI.Jeff Sharkey
Introduce IRingtonePlayer, which handles playback for both Ringtone objects and Notifications. SystemUI now hosts this player, which it registers with AudioService. It also keeps MediaPlayer instances warm, and cleans them up after stop() or Binder death. Move both Ringtone and NotificationManagerService to play back audio through this new interface. Bug: 6376128, 6350773 Change-Id: I1dcb86d16ee3c4f07cdb2248d33dcff4ead3609a