summaryrefslogtreecommitdiff
path: root/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java
Commit message (Collapse)AuthorAgeFilesLines
* base: treewide: Disable debug loggingGeorge Zacharia2023-01-121-1/+1
| | | Change-Id: Ic6cfbb8e5f60b69401fc69ca44e2d879b506003d
* Fix permission checking in SoundTriggerServiceYtai Ben-Tsvi2021-06-231-1/+6
| | | | | | | | | | | Result of permission check was erroneously ignored instead of throwing. Fixes: 191597651 Test: Manual verification of basic soundtrigger flows (assistant, now playing) against regression. Requested reporter to repro bug. Change-Id: I73449a156308880dae9ca5d432df3bc5ee747e58
* Reduce severity of SoundTriggerService error messagesYtai Ben-Tsvi2021-03-311-16/+16
| | | | | | | | Errors resulting from misuse by the client are considered warnings. Test: Compiles Bug: 181269159 Change-Id: Ib81397706a137a41f12810b8b63548170ce855bc
* Improve permission enforcement in SoundTriggerServiceYtai Ben-Tsvi2021-03-311-369/+404
| | | | | | | | | | Use a session-based identity mechanism similar to SoundTriggerMiddleware. Clear identity context within service to allow internal calls to originate from this service. Fixes: 184021066 Test: Manual verification of OKG / Now Playing on Sargo Change-Id: Iccda9ef864f82eafbf3473e706bcffe695705953
* add API for ST clients run in battery saver modeNicholas Ambur2021-01-221-6/+9
| | | | | | | | | | | | | | | | | | | | | New system API interface for both SoundTriggerManager and AlwaysOnHotwordDetector to indicate if a recognition should run in battery saver mode or not. Clients supply this information through the existing startRecognition calls, and the client must hold a new privledged permission, SOUND_TRIGGER_RUN_IN_BATTERY_SAVER, to indicate this intention. As a prerequisite, the device PowerManagerService must have the SoundTrigger service enabled in the battery saver mode battery policy. If not enabled, recognition will be paused as if the client did not provide the indication to run in battery saver mode. Bug: 172294448 Test: build with Google search apk using this feature and verify recognition keeps running in battery saver mode Change-Id: Ia43be99290e6fd7c50ff8e4908d6c60ea513b19a
* fix issue with ST listModules checkNicholas Ambur2020-11-181-3/+15
| | | | | | | | | | | | SoundTrigger.listModules call was being passed to the SoundTrigger HAL without SoundTriggerMiddleware checking permissions against the client. Instead, client was checking permissions against the system service UID. Bug: 171342256 Test: verify `dumpsys soundtrigger_middleware` logs listmodules as being called by the SoundTrigger client session Change-Id: Ic4bef05f59ef3d13ab0eed16017275070513ec84
* fix SoundTrigger overwriting session identityNicholas Ambur2020-11-161-16/+2
| | | | | | | | | | SoundTrigger tracks client UID for every session. This CL fixes an issue with client UID being saved twice causing the incorrect client UID to be saved. Bug: 171342256 Test: boot and verify hotword is functional Change-Id: I68bba238293ed5a74f5a3677f21e5122cc444f82
* Clean up on client death in SoundTriggerServiceYtai Ben-Tsvi2020-11-111-10/+47
| | | | | | | | | This change adds tracking of SoundTriggerService client death and frees up resources whenever that happens. Test: Kill Now Playing process and observer recovery. Bug: 171026874 Change-Id: Ie31d0a3ed392b1513b4e81ec3c344f4e79adcf52
* Tighten up Binder.clearCallingIdentity() usage.Jeff Sharkey2020-10-061-2/+2
| | | | | | | | | | | | | | | | | | | | The recently added AndroidFrameworkBinderIdentity Error Prone checker examines code to ensure that any cleared identities are restored to avoid obscure security vulnerabilities. This change is a purely mechanical refactoring that adds the "final" keyword to the cleared identity to ensure that it's not accidentally modified before eventually being cleared. Here's the exact command used to generate this CL: $ find . -name "*.java" -exec sed -Ei \ 's/ (long \w+ = .+?clearCallingIdentity)/ final \1/' \ {} \; Bug: 155703208 Test: make Exempt-From-Owner-Approval: trivial refactoring Change-Id: I832c9d70c3dfcd8d669cf71939d97837becc973a
* Sessionize the SoundTriggerService layer.Ytai Ben-Tsvi2020-09-101-641/+647
| | | | | | | | This changes associates identity information with every SoundTrigerService session. Change-Id: I30c9177f21203c8f3d03d4ff31523137497e760b Bug: 163865561
* Require identity information in SoundTrigger.javaYtai Ben-Tsvi2020-09-101-1/+17
| | | | | | | | | | Deprecate the way to attach to SoundTrigger that doesn't include identity information. Plumb that up to the SoundTriggerService layer, where it is temporarily provided in a backward-compatible way instead of with the actual identity. Change-Id: Icc2bf3b80300bd2b75c81d253986b4e1582737ca Bug: 163865561
* VIS : SoundTriggerService: follow up fix in createAudioRecordForEvent()Eric Laurent2020-08-131-21/+16
| | | | | | | | | | | Follow up fix after commit a82281f6: Let SoundTriggerService.createAudioRecordForEvent() throw exceptions and let the caller act accordingly. Bug: 161375011 Test: Manual sound trigger regression with OK Google and Now Playing Change-Id: I9a3c9085a15248a87f76b682a21d785ac73c9d11
* Merge "VIS : SoundTriggerService: fix fake AudioRecord creation"Eric Laurent2020-08-031-19/+19
|\
| * VIS : SoundTriggerService: fix fake AudioRecord creationEric Laurent2020-07-231-19/+19
| | | | | | | | | | | | | | | | | | Make sure exceptions that can occur when creating the fake AudioRecord instance in SoundTriggerService.createAudioRecordForEvent() are caught. Bug: 161375011 Test: Manual sound trigger regression with OK Google and Now Playing Change-Id: Ie367b9dda6f9e4f3079f5afe2ac92fc98cf8bced
* | Merge "Removed @Deprecated SystemService callback methods that take a userId."Felipe Leme2020-08-031-8/+0
|\ \
| * | Removed @Deprecated SystemService callback methods that take a userId.Felipe Leme2020-08-031-8/+0
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is just a plain refactoring: the removed methods in the changed classes were called by default by the new methods in the superclass (SystemService). Test: m Test: atest NotificationManagerServiceTest BackupManagerServiceRoboTest Fixes: 161943081 Exempt-From-Owner-Approval: refactoring without side-effects Change-Id: Ifd8df592eb4494cc0922b7e0b2ff20187b8a8b3e
* / Fix NullPointerException thrown by loggingRobin Lee2020-07-281-1/+1
|/ | | | | | | | | | | | | When `properties` is null, this propagates a NullPointerException back to the caller instead of cleanly reporting null like it's supposed to. Issue introduced in Iec7ba6fc59912f44341fbe8d7f99193b9ead52f0 from the start of this function and is fixed by just printing `object` instead of `object.toString()`. Test: atest AssistIntentConditionalTest Bug: 158682298 Change-Id: Ic64f6fba65895e9facc9994f5d1a353081ab3253
* fix calling SoundTriggerMiddleware in safeModeNicholas Ambur2020-05-181-5/+8
| | | | | | | | | deleteSoundModel is calling into the SoundTriggerModdleware when safe mode is enabled. Middleware should not be called in this case. Bug: 152354427 Test: atest SoundTriggerServiceTest#testServiceDisabledInSafeMode Change-Id: I1fa13fd32a384b59928a5deb9505dc4a1e757efa
* Check permission for soundtrigger detection serviceEvan Severson2020-05-011-0/+12
| | | | | | | | | | The app which gets bound to use microphone in the background should be holding the CAPTURE_AUDIO_HOTWORD permission. Test: Verify current services still work Verify that app without permission can't be registered Bug: 155438570 Change-Id: I4b53c45bc74df4e91026e13c7e2bfa0f5461df52
* Merge "remove SoundTrigger public member variables" into rvc-devNicholas Ambur2020-03-271-29/+31
|\
| * remove SoundTrigger public member variablesNicholas Ambur2020-03-261-29/+31
| | | | | | | | | | | | | | Bug: 150127026 Test: boot and verify soundtrigger hotword is functional Change-Id: I04061cdb3eba02aac0f08de96f957e2b74c70a12
* | disable SoundTriggerService in safe modeNicholas Ambur2020-03-231-1/+7
|/ | | | | | | | Bug: 150569186 Test: confirm `dumpsys voiceinteraction` shows no active service && confirm `dumpsys soundtrigger_middleware` shows no API calls. Change-Id: I6b5879c662826e86a6f41f3c3aea444f0674f24c
* Use BIND_INCLUDE_CAPABILITIES for SoundTriggerServiceNick Moukhine2020-03-161-1/+3
| | | | | | | | | SoundTriggerService is used by Now Playing to read DSP audio. Now that audio permissions are gated on process capability, we need this flag for system server to pass on its capability during the bind. With the new capability, permissions will no longer be denied. Bug: 150508177 Fixes: 150508177 Test: todo Change-Id: I79a18a9c98e5f36000f329bf15ca5a5f73826ffe
* add version entry to soundtrigger model databaseNicholas Ambur2020-01-131-0/+3
| | | | | | | | Bug:147159435 Test: manual hotword trigger with upgraded database && dumpsys voiceinteraction Change-Id: I45497c1159fe879e1de119a18aac8f7ecc2b0686
* add parameter control to AlwaysOnHotwordDetectorNicholas Ambur2020-01-091-4/+23
| | | | | | | | | | Per-model control to AlwaysOnHotwordDetector interface. Models are selected by keyphrase and locale associated with the AlwaysOnHotwordDetector instance. Bug: 141929369 Test: tested manually with test app Change-Id: Iffeb0954059fa030d8a4fefb934a3e665323be37
* Replace com.android.internal.util.Preconditions.checkNotNull withDaulet Zhanguzin2019-12-301-4/+4
| | | | | | | | | java.util.Objects.requireNonNull Bug: 126528330 Test: Treehugger Change-Id: I902d340cf8025c560d3ae61223e8eba0c6bc5b30
* add SoundTrigger HAL 2.3 per model parameter apisNicholas Ambur2019-12-111-0/+99
| | | | | | | | | | add support for model parameter control APIs with THRESHOLD_FACTOR as the first supported parameter Bug: 141929369 Test: Tested manually with test app and confirmed with GTS test gts-tradefed run gts-dev -m GtsAssistIntentTestCases Change-Id: I06874fcf2ae2ef8796e7c52c4475252e8a026e2c
* Add ability to get soundtrigger props from dspNicholas Ambur2019-08-301-0/+17
| | | | | | | | | exposes sound trigger module properties to privileged system apps with MANAGE_SOUND_TRIGGER permission Bug: 139071862 Test: GTS test confirmed API accessible and providing valid data Change-Id: Iec7ba6fc59912f44341fbe8d7f99193b9ead52f0
* SoundTriggerService: Track model statsBenjamin Schwartz2019-06-111-2/+98
| | | | | | | Bug: 133868565 Test: adb bugreport Test: In bugreport, check DUMPSYS - voiceinteraction Change-Id: I09750de4b3de1088ac6fba5ad08f01a4b1249112
* Limit GetModelState API to generic sound models (ie music detector)mike dooley2019-05-171-7/+4
| | | | | | | | | This limitation is being added to increase privacy protection. Bug: 70619678 Bug: 117213117 Test: built android Change-Id: Ic6ceed60a9687204fc7bf440becaa344a42d8e74
* SoundTrigger Event loggingJason Hsu2019-04-291-0/+198
| | | | | | | | | check bugreport DUMPSYS - voiceinteraction BUG: 128965282 Test: manual Change-Id: If2032e2cc5c0e071f9205e516987462625248b1c Signed-off-by: Jason Hsu <jasonchhsu@google.com>
* Treat getModelState recognition events the same as regular recognitionmike dooley2019-01-241-5/+1
| | | | | | | | | | events. This change should have been part of ag/5933708 Test: manual test with NowPlaying app on p19 device Change-Id: I42ed7c17ebdd2cb75055122b8d45302e28c510b6
* Converting sound trigger v2.2 getModelState to be asynchronousmike dooley2018-11-091-8/+9
| | | | | | | Test: built android with checkbuild flag Change-Id: I4c6f2388c93b6e577113fc7f2cd19242628ee50f Bug-Id: 70206501
* Revert "Revert "Adding getModelState API to sound trigger""Michael Dooley2018-10-231-0/+34
| | | | | | | | This reverts commit 81f71f1c27b7e877babe1f3293ac00256a66980c. Reason for revert: rolling forward with fix Change-Id: Ifc0c53581ac567cb968d91993f453220f8253aec
* Revert "Revert "Revert "Adding getModelState API to sound trigger"""Michael Dooley2018-09-281-34/+0
| | | | | | | | This reverts commit 7999836ee3c0da85b3e8b55d0113d0b9796b3d21. Reason for revert: broke build Change-Id: Id02636908aed26ee0ed38042da1ace0125a6d417
* Revert "Revert "Adding getModelState API to sound trigger""Michael Dooley2018-09-211-0/+34
| | | | | | | | This reverts commit 81f71f1c27b7e877babe1f3293ac00256a66980c. Reason for revert: undoing rollback Change-Id: Ifddfd0c730f03e93788d662a392d538564ce210b
* Merge "Revert "Adding getModelState API to sound trigger""Michael Dooley2018-09-141-34/+0
|\
| * Revert "Adding getModelState API to sound trigger"Michael Dooley2018-09-141-34/+0
| | | | | | | | | | | | | | | | This reverts commit 4f809fe73ee94802ac473b87c0d47a7345244d5a. Reason for revert: fix build breakage Change-Id: I75a54189f96fc21f6cb12dd8a05e513b1bda027c
* | Merge "Adding getModelState API to sound trigger"Michael Dooley2018-09-141-0/+34
|\|
| * Adding getModelState API to sound triggermike dooley2018-09-051-0/+34
| | | | | | | | | | | | Test: built android Bug-Id: 70206501 Change-Id: Ieb83a366d4ddd471186d5089efe0675ea6285454
* | Frameworks: Annotate trivial @GuardedBy in servicesAndreas Gampe2018-09-051-0/+1
|/ | | | | | | | | | | Add @GuardedBy for simple functions that require locks and have a name in one of the frameworks naming styles for locks ("^.*(Locked|LPw|LPr|L[a-zA-Z]|UL|AL|NL)$"). Derived by errorprone. Bug: 73000847 Test: m Change-Id: If70bb03313388af34d547efca20fb5115de95bf1
* Merge "Disable throttling of SoundTrigger" into pi-dev am: 1936031cbePhilip P. Moltmann2018-05-081-1/+2
|\ | | | | | | | | | | am: c7029fe7e0 Change-Id: Ifb78f41f756ac2002d12dc4e5de09dddef02f074
| * Disable throttling of SoundTriggerPhilip P. Moltmann2018-05-071-1/+2
| | | | | | | | | | | | | | | | | | | | | | Currently we don't have a way of throttling sound trigger events without upsettings the DSP. Bug: 78212455, 78310504 Test: Played music while having song detection enabled. Saw songs being detected Change-Id: I3494d608f097532f02e6a588e22d9fe2d06048b1
* | Merge "Simulate handling of event when throttling" into pi-dev am: 0458578642android-build-team Robot2018-05-071-23/+127
|\| | | | | | | | | | | am: 64bc4fab47 Change-Id: I2f87a69a1836cc9b109e78e49b3d0085bfb32b81
| * Simulate handling of event when throttlingPhilip P. Moltmann2018-05-041-23/+127
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When trottling we need to simulate handling of the event as otherwise the DSP gets upset and SoundTriggerService and SoundTriggerHelper get out of sync. (1) Currently the DSP requires to open and release the AudioRecord if a event was detected. Hence If we drop and event we need to do the minimal version of that (2) If a recognitions is set up with !allowMultipleTriggers the other parts assume that as soon as one even is handled no further will be needed. The other parts of the system are not aware of throttling. Hence even when throttled we have to destroy the service when !allowMultipleTriggers. We do this by splitting the ops into three parts. Setup (always executed): Takes care of problem (2) by checking the flag and setting the destroy-once-ops-and-handled flag Execute (not thottled): Send the op to the remote service Drop (Trottled): Do what is needed if the remote service is not involved. This handled issue (1) Test: Caused throttling and saw - AudioRecord started and released - service connection destroyed Bug: 78212455 Change-Id: I0ff81a7b38d07db1365be7ecc44e93cf329b32d5
* | Merge "Remove PendingIntent based soundTrigger"TreeHugger Robot2018-04-251-184/+6
|\ \ | |/ |/|
| * Remove PendingIntent based soundTriggerPhilip P. Moltmann2018-04-051-184/+6
| | | | | | | | | | | | | | | | | | How that we have the SoundTriggerDetectionService we don't need the pending intent based mechanism anymore. Test: Checked that ambient music still detects music Change-Id: If16c59028b31ff7d2e7f4d7f764460ac948ba946 Fixes: 73829108
* | Properly disconnect after skipping an operation.Philip P. Moltmann2018-04-111-16/+15
|/ | | | | | | | | | | | | | | If we skip an operation we used to just return. This lead to the service staying connected, holding the wakelock and consuming power. Hence after we skip an operation we need to check if we can disconnect the service, basically treating skipping an operation similar failing to execute the operation. Fixes: 77766977 Test: Detected music via sound trigger service and triggered dropping of operations Change-Id: Ia837d628193b3a5c2763f4aae666193d624b6d7f
* Throttle number of sound trigger operations / dayPhilip P. Moltmann2018-03-201-1/+102
| | | | | | | | | | | | | | | | | | | | | | | | | It is not clear when the day should start. Further a day might have 25 hours in the case of daylight savings time. Hence a day in this case is the last 24 hours, not a calendar day. Keeping track of the time of each operation might waste memory as we don't need that much precision. Hence keep track how many operations were performed in the last 24 hours in buckets of hours. If the total count reaches a maximum suppress any further operations. The maximum is configurable via global settings. It can be updated by apps that have the appropriate permissions. Hence if the default value turns out to be incorrect, it can be adjusted after release. This does not throttle based on battery state as it is better to completely unload the sound model to not even have a detection event. Test: atest SoundTriggerDetectionServiceTests (separate CL) atest android.provider.SettingsBackupTest Bug: 73829108 Change-Id: Ied8570b60b61b6a055bd2576d1502c1b36424efa
* Add SoundTriggerDetectionServicePhilip P. Moltmann2018-03-201-24/+448
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The service is meant to replace the PendingIntent based API. Once all users of the PendingIntent based API switched the PendingIntent based API will be removed. To have as little as possible impact on the whole SoundTrigger framework the RemoteSoundTriggerDetectionService class implements the same interface as the PendingIntent based class. Hence the exising code has very little change. Further once the old code can be removed the amount of changed (and added) code is limited. The RemoteSoundTriggerDetectionService -> SoundTriggerDetectionService is a vanilla as possible service implementation. The special behaviors are: - The system holds a wakelock while service operations are in progress and the service is bound as foreground. Hence the service can e.g. listen to the microphone. - Service operations have a certain amount of time they are allowed to run. Once every operation is either finished or the the operation exceeded the allotted time, the system calls onStopOperation for each still pending operation. This is a similar model as for the commonly used JobService. Please note that if the time allowed for an operation is 15s and op1 was run as 0si, and op1 was run at 5s, the service is allowed to run until 20s. Hence _both_ onStopOperations will happen at 20s. This is done for ease of implementation but should not give the service more power than calling onStopOperation exactly 15s after each operation is triggered. - If an operation is done before the allotted time is reached, the service can declare the operation as finished manually by calling onOperationFinished. This is a call back into the system, hence a 'client' binder is sent to the service. If the operation is finished by calling this method onStopOperation will not be called. - As the service instance might be killed and restored between operations we add a opaque bundle 'params' to each operations. The users of the API can use this to send data from the start command to the operations. It can also just be set to null. The params are not meant to store changing state in between operations. Such state needs to be persisted using the regular methods (e.g. write it to disk) - A service can be used for multiple recognition sessions. Each recognition is uniquelity defined by its sound model UUID. Hence each operation gets at least tree arguments: Operation ID, sound mode UUID, params - As a small optimization the params are cached inside of the service instance. The time allowed for each operation is in a @SystemAPI global setting, so the service can make sure it finishes the operations before they are stopped. It might take some time to deliver the operations via the binder, hence it is not recommended to try to use every last ms of allotted time. Test: atest SoundTriggerDetectionServiceTest (added in separate CL) atest android.provider.SettingsBackupTest Change-Id: I47f813b7a5138a6f24732197813a605d29f85a93 Fixes: 73829108