Commit Graph

91 Commits

Author SHA1 Message Date
Ytai Ben-Tsvi
b2d3d3aba5 Fix permission checking in SoundTriggerService
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
2021-06-23 08:14:26 -07:00
Ytai Ben-Tsvi
60a49f1b3b Reduce severity of SoundTriggerService error messages
Errors resulting from misuse by the client are considered warnings.

Test: Compiles
Bug: 181269159
Change-Id: Ib81397706a137a41f12810b8b63548170ce855bc
2021-03-31 14:27:06 -07:00
Ytai Ben-Tsvi
def517ec04 Improve permission enforcement in SoundTriggerService
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
2021-03-31 14:24:54 -07:00
Nicholas Ambur
28cc6364d6 add API for ST clients run in battery saver mode
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
2021-01-22 18:24:39 -08:00
Treehugger Robot
93b8b32e8b Merge "Add ytai and elaurent to SoundTriggerService OWNERS" am: c1fca8e84e am: 619b06b95f am: 3133db8b96
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1527771

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Iee1f63773d57627867156ab7704ce9a69a7aeabf
2020-12-14 22:55:09 +00:00
Ytai Ben-Tsvi
16ed896ea5 Add ytai and elaurent to SoundTriggerService OWNERS
Test: n/a
Change-Id: I5c0366f0be49e9d42860694af22550f026f75cbf
2020-12-14 11:33:51 -08:00
Ytai Ben-Tsvi
5bc8f0e178 Reset mServiceDisabled when service dies
When we don't reset the state, if the service died while it was
disabled, future attempts to load models would fail.

Fixes: 171953855
Test: Verified basic sound trigger cases as well as recovery from
      STHAL and audioserver crashes.
Change-Id: I32929123aa936cbee3101ec0ef65c52dd28b240b
2020-12-08 10:48:14 -08:00
Nicholas Ambur
5b96c01506 fix issue with ST listModules check
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
2020-11-18 15:08:53 -08:00
Nicholas Ambur
e835b9847e fix SoundTrigger overwriting session identity
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
2020-11-16 17:47:32 -08:00
Ytai Ben-Tsvi
3559e8693e Clean up on client death in SoundTriggerService
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
2020-11-11 10:12:59 -08:00
Jeff Sharkey
2d2e07e2ff Tighten up Binder.clearCallingIdentity() usage.
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
2020-10-06 11:18:09 -06:00
Ytai Ben-Tsvi
7558017301 Sessionize the SoundTriggerService layer.
This changes associates identity information with every
SoundTrigerService session.

Change-Id: I30c9177f21203c8f3d03d4ff31523137497e760b
Bug: 163865561
2020-09-10 13:27:08 -07:00
Ytai Ben-Tsvi
c79176dc64 Require identity information in SoundTrigger.java
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
2020-09-10 13:27:08 -07:00
Eric Laurent
4db6ccaaa3 Merge "VIS : SoundTriggerService: fix fake AudioRecord creation" into rvc-qpr-dev 2020-09-10 15:04:47 +00:00
Eric Laurent
cbc302a86e VIS : SoundTriggerService: fix fake AudioRecord creation
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
Squashed commit of:
  a82281f6e7
  1a6689766a

Change-Id: Ib973e22a5f1bd43facca1ed8c282fe444a739249
Merged-In: Ie367b9dda6f9e4f3079f5afe2ac92fc98cf8bced
2020-08-14 18:41:08 +00:00
Eric Laurent
1a6689766a VIS : SoundTriggerService: follow up fix in createAudioRecordForEvent()
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
2020-08-13 15:58:42 -07:00
Eric Laurent
e14b11bef2 Merge "VIS : SoundTriggerService: fix fake AudioRecord creation" 2020-08-03 23:55:49 +00:00
Felipe Leme
46a0354076 Merge "Removed @Deprecated SystemService callback methods that take a userId." 2020-08-03 15:23:25 +00:00
Felipe Leme
837f8c1e8a Removed @Deprecated SystemService callback methods that take a userId.
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
2020-08-03 07:24:26 +00:00
Robin Lee
f6ef97cd1d Fix NullPointerException thrown by logging
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
(cherry picked from commit 935906e180)
2020-07-28 19:42:55 +00:00
Robin Lee
935906e180 Fix NullPointerException thrown by logging
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
2020-07-28 03:03:41 +02:00
Eric Laurent
a82281f6e7 VIS : SoundTriggerService: fix fake AudioRecord creation
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
2020-07-23 15:21:35 -07:00
Nicholas Ambur
dc1ea7ce04 fix calling SoundTriggerMiddleware in safeMode
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
2020-05-18 10:11:02 -07:00
Evan Severson
b07f0599bb Check permission for soundtrigger detection service
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
2020-05-01 11:04:12 -07:00
Eric Laurent
a9fd7bc05c SoundTriggerHelper: improve in call behavior
Fix 3 issues in SoundTriggerHelper when a call is active:
1) Do not actually load a sound model when recognition start is requested
but disabled because of and active call or any other reason. Previously
we were loading the sound model even if actual start was deferred until
enabled.
2) Allow to start recognition while disabled: the recognition start
request is stored as pending and will be executed when enabled again.
3) Process call state change with enough delay when call ends to allow
time for the HAL to process the call disconnect notification before re
enabling pending recognitions.

Also remove assumption on valid model handle values.

Test: repro steps in b/152723355
Bug: 152723355
Change-Id: Id46ae8c285426ed2ace8a6d80478fecb98f4ec33
2020-04-06 13:58:50 -07:00
Nicholas Ambur
95ee3d7ad5 Merge "remove SoundTrigger public member variables" into rvc-dev 2020-03-27 20:54:22 +00:00
Nicholas Ambur
1e43767f10 remove SoundTrigger public member variables
Bug: 150127026
Test: boot and verify soundtrigger hotword is functional

Change-Id: I04061cdb3eba02aac0f08de96f957e2b74c70a12
2020-03-26 19:44:31 +00:00
Nicholas Ambur
78a22682fb disable SoundTriggerService in safe mode
Bug: 150569186
Test: confirm `dumpsys voiceinteraction` shows no active service
&& confirm `dumpsys soundtrigger_middleware` shows no API calls.

Change-Id: I6b5879c662826e86a6f41f3c3aea444f0674f24c
2020-03-23 15:42:21 -07:00
Nick Moukhine
67b5e387b5 Use BIND_INCLUDE_CAPABILITIES for SoundTriggerService
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
2020-03-16 19:31:49 +00:00
Ytai Ben-tsvi
49f7e6bfdf Merge "Correctly set the recognition state in response to GET_STATE" 2020-01-15 19:54:32 +00:00
Ytai Ben-Tsvi
8672d25e8a Correctly set the recognition state in response to GET_STATE
A forced recognition does not stop recognition.
SoundTriggerHelper had a bug where it assumed that it does, and so
future interactions would assume the wrong state and would eventually
erroneously use the underlying layers.

Bug: 147568295
Change-Id: I5ae69a8b292fda6aadc6011c4bf5cbc4d263a1ca
2020-01-14 16:54:15 -08:00
Nicholas Ambur
d3ec82fbc4 add version entry to soundtrigger model database
Bug:147159435
Test: manual hotword trigger with upgraded database
&& dumpsys voiceinteraction

Change-Id: I45497c1159fe879e1de119a18aac8f7ecc2b0686
2020-01-13 12:23:56 -08:00
Nicholas Ambur
f94db1c822 add parameter control to AlwaysOnHotwordDetector
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
2020-01-09 18:18:47 -08:00
Daulet Zhanguzin
e789eeee79 Replace com.android.internal.util.Preconditions.checkNotNull with
java.util.Objects.requireNonNull

Bug: 126528330

Test: Treehugger
Change-Id: I902d340cf8025c560d3ae61223e8eba0c6bc5b30
2019-12-30 14:01:53 +00:00
Nicholas Ambur
a0be6be387 add SoundTrigger HAL 2.3 per model parameter apis
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
2019-12-11 19:16:48 -08:00
Eric Laurent
d4718e182d Merge "SoundTriggerHelper: fix state after audioserver death" into qt-qpr1-dev am: e5a3106cc5
am: e34b12d69b

Change-Id: Ie5d8451abfc732b45b9d803a6a901313479c0aa3
2019-09-19 12:03:09 -07:00
Eric Laurent
2fedc55920 SoundTriggerHelper: fix state after audioserver death
Make sure mRecognitionRequested is reset when a failure
condition disables all recognitions: A stale value would
prevent from registering call and power state listeners
and properly update the states.

Also:
- In isRecognitionAllowed(), read current call and power
states directly from services if listeners are not registered.
- Also add missing null checks on mModule at various places.

Bug: 139268184
Test: repro steps in the bug
Change-Id: I763130b4d491a1a6a9e0756c7a18943e406ce73e
2019-09-12 01:37:15 +00:00
Nicholas Ambur
1aa4b4b779 Add ability to get soundtrigger props from dsp
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
2019-08-30 10:10:18 -07:00
Eric Laurent
80565fbf36 SoundTriggerHelper: fix power save mode listener
When stopping a recognition, do not unregister power save mode
listener if no recognition is active any more but only if no recognition
is requested. Otherwise recognitions suspended due to power save mode will
never resume.

Bug: 136978230
Test: Activate power save mode, plug USB and verify OK G works.
Change-Id: I426e11447fcde5c578ae2f64aa1fe18ef00fba0f
2019-07-19 12:06:24 -07:00
Benjamin Schwartz
9e7a0158fc SoundTriggerService: Track model stats
Bug: 133868565
Test: adb bugreport
Test: In bugreport, check DUMPSYS - voiceinteraction
Change-Id: I09750de4b3de1088ac6fba5ad08f01a4b1249112
2019-06-11 13:20:41 -07:00
mike dooley
baa22c7a8f Limit GetModelState API to generic sound models (ie music detector)
This limitation is being added to increase privacy protection.

Bug: 70619678
Bug: 117213117
Test: built android
Change-Id: Ic6ceed60a9687204fc7bf440becaa344a42d8e74
2019-05-17 07:26:11 +00:00
Jason Hsu
1363f581dc SoundTrigger Event logging
check bugreport DUMPSYS - voiceinteraction

BUG: 128965282
Test: manual
Change-Id: If2032e2cc5c0e071f9205e516987462625248b1c
Signed-off-by: Jason Hsu <jasonchhsu@google.com>
2019-04-29 12:14:41 +08:00
rago
f96269ab4d Enabling HW detection while phone ringing
Updated logic to allow HotWord detection while phone is ringing (still
not off-hook).

Test: Manual Testing
Bug: 124762676
Change-Id: Idce6d39a5589aee6d5baa4e5bcd8d98b3e13b239
2019-03-26 10:34:04 -07:00
mike dooley
9b20c1cda4 Treat getModelState recognition events the same as regular recognition
events.

This change should have been part of ag/5933708

Test: manual test with NowPlaying app on p19 device

Change-Id: I42ed7c17ebdd2cb75055122b8d45302e28c510b6
2019-01-24 08:17:13 +01:00
mike dooley
da48092c9b Make framework treat getModelState recognition events the same
as regular recogntion events

The application will differentiate between DSP and app triggered
regcognition events.

Test: manual test with STTA and NowPlaying app on p19

Bug: 119386757

Change-Id: I4a3eb4da6ee6be35084fec8aaa3c495423d74033
2019-01-08 10:58:23 +01:00
mike dooley
23c625677d Fixing getModelState event processing
Test: manual testing with SoundTriggerTestApp

Bug: 119386757

Change-Id: I2c2960d169b119cb35345315638eeae28460896c
2018-12-20 16:48:53 +01:00
mike dooley
b2ab04aefd Converting sound trigger v2.2 getModelState to be asynchronous
Test: built android with checkbuild flag

Change-Id: I4c6f2388c93b6e577113fc7f2cd19242628ee50f
Bug-Id: 70206501
2018-11-09 08:36:15 +01:00
Michael Dooley
291751e510 Revert "Revert "Adding getModelState API to sound trigger""
This reverts commit 81f71f1c27.

Reason for revert: rolling forward with fix

Change-Id: Ifc0c53581ac567cb968d91993f453220f8253aec
2018-10-23 07:44:51 +02:00
Michael Dooley
be93d52505 Revert "Revert "Revert "Adding getModelState API to sound trigger"""
This reverts commit 7999836ee3.

Reason for revert: broke build

Change-Id: Id02636908aed26ee0ed38042da1ace0125a6d417
2018-09-28 07:30:28 +00:00
Michael Dooley
7999836ee3 Revert "Revert "Adding getModelState API to sound trigger""
This reverts commit 81f71f1c27.

Reason for revert: undoing rollback

Change-Id: Ifddfd0c730f03e93788d662a392d538564ce210b
2018-09-21 12:13:01 +00:00