Because the client callbacks from SoundTriggerMiddleware service are
async, if a client quickly stops and starts a model, then receives a
detection event for that model, it is impossible for it to tell
whether the event corresponding to the previous or current session,
and thus is unable to reason about the resulting state of the model.
To mitigate that, we will always wait for an abort event when a model
is stopped before any other operation is attempted. This way the
model state stays synchronized.
Bug: 191935600
Fixes: 226926627
Test: Manual verification of soundtrigger use-cases. Specifically,
quick toggling of Assitant and Now Playing via Settings.
Change-Id: Ia1b91e78aa6981a7b3612ae9213af1b37a333d00
This reverts commit 6e2eb81ac4.
The original commit fixed b/223922855, which resulted from fixing
b/191935600, but created another.
Blocking the stop() call until the event confirming the stop arrives is
a bad idea, since:
- We have to give up the lock when waiting for the event, and thus lose
the atomicity of some of the operations. b/226926627 is an example of
this.
- It turns out some of the forward calls happen from the main thread's
looper, which is also used for callbacks, and we risk deadlocks.
A follow-up commit will address the fix in a better way.
Bug: 191935600
Bug: 226926627
Bug: 223922855
Test: See next commit in the chain.
Change-Id: I2b9987ae93803d3b4f72a1df56c88e284bed43c5
The modelData callback may be nullified before actually being invoked,
e.g. when calling startRecognition() on an already running model, with
a different callback.
Fixes: 225768984
Test: Manual reproduction on the issue and then applying the fix and
verifying that it works.
Change-Id: I089061123c8cf12eef19fdf16bb3a2c106ea2438
Because the client callbacks from SoundTriggerMiddleware service are
async, if a client quickly stops and starts a model, then receives a
detection event for that model, it is impossible for it to tell
whether the event corresponding to the previous or current session,
and thus is unable to reason about the resulting state of the model.
To mitigate that, we will always wait for an abort event when a model
is stopped before any other operation is attempted. This way the
model state stays synchronized.
Fixes: 191935600
Test: Manual verification of soundtrigger use-cases. Specifically,
quick toggling of Assitant and Now Playing via Settings.
Change-Id: I010558e8fa1891922f20dcdb7b0ca04c9500c2e1
This change allows the HAL driver, at its discretion, indicate that
recognition is still active after a success event.
This is achieved by an additional flag added to the event.
The behavior to support this case has already been in place, for the
sake of supporting a FORCED event. This change just generalizes this
behavior to be able to cover SUCCESS as well.
For b/w compat, when the status is FORCED, we override the new flag
with 'true', indicating that recognition is still active.
We do not allow the flag to be set for status codes other than FORCED
or SUCCESS.
Test: atest FrameworksServicesTests:{SoundTriggerMiddlewareImplTest,SoundHw2CompatTest}
Test: Manual verification of sound trigger operation by invoking the
assistant and now playing multiple times.
Bug: 186031938
Change-Id: Ie4edf82607c72ccb0b8d90a828b04c93153ec8f3
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
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
This change plumbs soundtrigger preemptive model unloading, typically
initiated by the STHAL, all the way to SoundTriggerService, where
logic for retry / lazy loading already exists.
Test: Manual verification of existing soundtrigger use-cases.
Change-Id: I49195fbf2ccd6268e7fbc0279ec6fe04c1cc016e
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
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
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
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
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
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
This changes associates identity information with every
SoundTrigerService session.
Change-Id: I30c9177f21203c8f3d03d4ff31523137497e760b
Bug: 163865561
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
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:
a82281f6e71a6689766a
Change-Id: Ib973e22a5f1bd43facca1ed8c282fe444a739249
Merged-In: Ie367b9dda6f9e4f3079f5afe2ac92fc98cf8bced
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
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
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)
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
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
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
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
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
Bug: 150569186
Test: confirm `dumpsys voiceinteraction` shows no active service
&& confirm `dumpsys soundtrigger_middleware` shows no API calls.
Change-Id: I6b5879c662826e86a6f41f3c3aea444f0674f24c
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
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
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
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
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
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
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