Commit Graph

279 Commits

Author SHA1 Message Date
felipeal
755578ac28 Added command / binder method to temporarily disable VoiceInteraction.
It will be used by Automotive when the display is off.

Test: adb shell cmd voiceinteraction disable true && \
      adb shell cmd voiceinteraction show
Test: atest CtsVoiceInteractionTestCases CtsAssistTestCases
Bug: 154011437

Change-Id: Ia87b0544b242c356c4f9180e250e2df54279803f
2020-06-04 23:05:14 +00:00
felipeal
b6ebc24b86 Initial implementation of 'cmd voiceinteraction'.
Test: adb shell cmd voiceinteraction help
Test: adb shell cmd voiceinteraction show

Bug: 154011437

Change-Id: I671fca55c050370e04bdae5604f0f7ae705ccadc
2020-05-27 13:05:37 -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
Nicholas Ambur
64fb254c63 fix enrollment application permission check
Remove check associated with enrollment application UID, and allow
enrollment applications holding the KEYPHRASE_ENROLLMENT_APPLICATION
privledged permission to enroll.

Bug: 151405284
Test: Confirm enrollment from both enrollment application and active
voiceinteraction service. Confirm enrollment can still occurr after
system user switch.

Change-Id: I8686f705fe5405523004eef5de834282a7382464
2020-03-20 14:55:35 -07:00
Hui Yu
7ab1ea2ac3 Merge "Use BIND_INCLUDE_CAPABILITIES for SoundTriggerService" into rvc-dev 2020-03-17 19:40:29 +00: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
Nicholas Ambur
666b309c9f Merge "reduce excessive soundtrigger logging" into rvc-dev 2020-03-11 17:48:50 +00:00
Nicholas Ambur
c04b49fd2e lazy load enrollment application UID in VIMS
Enrollment application services are only avaiable for package manager
to query after the system on-boot-completed status. Lazy loading the
KeyphraseEnrollmentInfo class until first client access ensures all
packages are loaded prior to query.

Bug: 151095585
Test: erase userdata and boot device; ensure no enrollment application
crashes when boot device for first time; dump enrollment database with
`dumpsys voiceinteraction` and confirm model is present in database.

Change-Id: I6009d5834fff8848a17e5edef9d39395b1586318
2020-03-10 20:24:48 +00:00
Nicholas Ambur
3f82874bc9 reduce excessive soundtrigger logging
Bug: 151095585
Test: build and boot smoke test
Change-Id: I3216cfd837a4c688b19f3bb87021983153601350
2020-03-10 00:57:13 +00:00
Nicholas Ambur
1ec50c8f2f remove client token passing active VI service
Previous implementation relied on client to pass a token which the
service used to verify if it was the active service. This is seen to be
a security concern as there is no way to verify how the client obtained
the token. Instead, a check is done to confirm the caller's UID matches
the UID of the active service.

In the case of voice model enrollment, KeyphraseEnrollmentInfo class is
leveraged. A client is allowed to enroll if it is the active voice
interaction service or if it is a voice model enrollment application
bundled with the system image.

All previous manifest permision checks still apply.

Bug: 148159858
Test: gts-tradefed run gts-dev -m GtsAssistIntentTestCases -t \
com.google.android.assist.gts.KeyphraseModelManagerTest \
\#testShouldEnrollOnlyWhenActiveService

Merged-In: Ie2c4653d365770a9123a22bc69822518b4ccc568
Change-Id: Ie2c4653d365770a9123a22bc69822518b4ccc568
(cherry picked from commit c6f4118f9e)
2020-02-25 01:20:05 +00:00
Felipe Leme
339b7149af Improved user callbacks on SystemService:
* Renamed:

  onStartUser() -> onUserStarting()
  onStopUser() -> onUserStopping()
  onSwitchUser() -> onUserSwitching()
  onUnlockUser() -> onUserUnlocking()
  onCleanupUser() -> onUserStopped()
  isSupportedUser() -> isUserSupported()

* Added:

  onUserUnlocked()

Tested on automotive, which uses the callbacks to dump user metrics:

$ adb shell dumpsys car_service --user-metrics
adb shell dumpsys car_service --user-metrics
* User Metrics *
  no users starting
  no users stopping
Last 10 started users
  2020-02-21T19:44:47.101 - user=0 start=2020-02-21 19:44:45.357 unlocking=+885ms unlocked=+1s122ms
  2020-02-21T19:44:56.376 - user=10 start=2020-02-21 19:44:47.380 switch=+209ms unlocking=+8s262ms unlocked=+8s994ms
  2020-02-21T20:00:08.792 - user=11 start=2020-02-21 20:00:04.634 switch(from 10)=+351ms unlocking=+4s44ms unlocked=+4s156ms
Last 10 stopped users
  2020-02-21T20:00:48.323 - user=10 stop=2020-02-21 20:00:16.741 shutdown=+31s581ms

Test: m update-api
Test: atest BackupManagerServiceTest
Test: manual verification (see above)
Fixes: 150001654

Exempt-From-Owner-Approval: approved on master right before rvc split

Merged-In: I8774c57620030b9aa8e7ec039a6a758ad56db368
Change-Id: I8774c57620030b9aa8e7ec039a6a758ad56db368
(cherry picked from commit 58e7458ac7)
2020-02-24 16:44:52 +00:00
Philip P. Moltmann
ee29509ecd Revert "Revert "Activity start: Send featureId from context->AppOpsManager""
This reverts commit e7421e92d9.

Exempt-From-Owner-Approval: revert-revert and only piping anyway
Test: 1:1 revert-revert
Bug: 136595429
Change-Id: I44e5fa2019f5604c6e2c08bdd1967129c64a90a7
2020-02-12 18:51:53 +00:00
Philip P. Moltmann
e7421e92d9 Revert "Activity start: Send featureId from context->AppOpsManager"
Revert "Adjust monkey to changed internal APIs"

Revert "Test featureId is correctly used in startActivity"

Revert submission 10111030-activityStarter_featureId

Reason for revert: presubmit test breakage
Reverted Changes:
Ic7056b492: Activity start: Send featureId from context->AppOp...
I8e2a07da7: Adjust monkey to changed internal APIs
I7a6af6fb1: Test featureId is correctly used in startActivity

Change-Id: I48c55a962c990b22ea49e923baa7c73b121d179b
2020-02-10 16:14:12 +00:00
Philip P. Moltmann
9c5226fe36 Activity start: Send featureId from context->AppOpsManager
The expected usage pattern for noteOp is to get the
Context#getOpPackageName() and Context#getFeatureId() in the calling app
and the call

noteOp(callingPackageName, Binder.getCallingUid(), callingFeatureId)

As the featureId parameter is new this parameter has to been piped all
through from the ...Manager classes running in the app all way deep into
the bowels of the system server.

There is a special featureId==null for the "default" feature. This is
used in two cases:
- In case the system server (packageName == null || packageName ==
  "android") makes a call
- In the case there is no caller. In this case I left annotations in the
  code to make clear that the default feature is used

Raw binder interfaces (defined in AIDL files) are not supposed to be
used by apps. Still historically this has happened and we ended up with
@UnsupportedAppUsage tags in these files. Also AIDL does not support
two methods with the same name but different parameters. I.e. in the
case when I had to add a paramater to a method tagged as UnsupportedAppUsage I
- created a new method ...WithFeature with the additional paramter
- set a maxTargetSDK for the old method and mention the public API to
  use in the deprecation method
This is really not pretty. Once there is no more app using the old
internal API this hack can be removed.

Additionally this change removed all internal calls to
AppOpsService.noteOperation and AppOpsService.checkOperation and
replaces them with the public API equivalent. This sometimes means to
move the resolution of the mAppOpsManager to be lazy.

Exempt-From-Owner-Approval:: Just piping through arguments
Bug: 136595429
Test: atest --test-mapping frameworks/base/services/core/java/com/android/server/am/
      atest CtsAppOpsTestCases added test to cover activity start
      atest WmTests
Change-Id: Ic7056b492cb1c9a79158e6c2b4864898a0eb5b2a
2020-02-08 22:53:43 +00:00
Nicholas Ambur
f771e6c9f6 async enrollment support AlwaysOnHotwordDetector
Added ability for AlwaysOnHotwordDetector to support async enrollment
performed outside of support detected through KeyphraseEnrollmentInfo.

Bug: 147159435
Test: tested enrollment and availability is updated when enrolling
outside of KeyphraseEnrollmentInfo

Change-Id: Ia5d71e90c062ac100d4c6df760acf0d41920853e
2020-01-22 16:40:18 -08:00
Nicholas Ambur
ef84fc4843 add KeyphraseModelManager
Exposes a set of @SystemApi's allowing the active VoiceInteractionService
to enroll voice models.

Bug: 147159435
Test: manual tested enrollment and unenrollment via bundled
hotwordenrollment application and test app.

Change-Id: I94ef3550df236486401a0a6f9de9d874b9bf9b46
2020-01-22 16:40:13 -08: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
9e3ec9af07 Merge "add version entry to soundtrigger model database" 2020-01-14 00:47:20 +00: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
Makoto Onuki
2b0a51b664 Merge "Clean up SystemService as a preparation to make @SystemApi" 2020-01-13 15:54:42 +00:00
Makoto Onuki
c8815900d2 Clean up SystemService as a preparation to make @SystemApi
Bug: 146145144
Test: Boot + treehugger
Test: atest CtsAutoFillServiceTestCases (with some unrelated failures)
Test: atest CtsContentCaptureServiceTestCases CtsVoiceInteractionTestCases (all passed)

Change-Id: I89265c3c46262cd3251153f85df6f4aea37520f1
2020-01-10 16:19:37 -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
Felipe Leme
e87735bdab Improved dump on services that implement isSupported(UserInfo).
Test: adb shell dumpsys voiceinteraction
Test: adb shell dumpsys autofill

Bug: 146349941

Change-Id: Ibc3001515081ba0efc72b3651f900a4e4f630faa
2019-12-17 13:26:48 -08: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
Philip Cuadra
50dd58571f Merge "Bind voice interactor as top-app when it is being used" into qt-qpr1-dev am: 6183d81af6
am: 1c4b22d3cd

Change-Id: I88f95f30d8430ab9285c8d4a80a4cf8a7d6593bc
2019-09-05 13:44:32 -07:00
TreeHugger Robot
6183d81af6 Merge "Bind voice interactor as top-app when it is being used" into qt-qpr1-dev 2019-09-05 19:41:09 +00:00
TreeHugger Robot
d8c549a0e9 Merge "Add ability to get soundtrigger props from dsp" 2019-09-04 23:59:05 +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
TreeHugger Robot
a68d535199 Merge "Defined a more generic way to let services "opt-out" from certain user types." 2019-08-22 20:59:41 +00:00
Hai Zhang
bfa2eb9a8d Merge "Fix legacy role holder resolution for assistant, dialer and SMS." into qt-qpr1-dev am: d4c175c156
am: 9d15770e4f

Change-Id: I59dedef6e000648c284190624fc938dd581a9743
2019-08-22 12:58:10 -07:00
Hai Zhang
dbffb693a5 Fix legacy role holder resolution for assistant, dialer and SMS.
The legacy settings for them can actually remain null and it was
handled specially to use the system default instead. If the legacy
role holders aren't resolved correctly, role implementation will do a
fallback grant which overrides permission state, whereas if they are
resolved correctly the normal fix up won't do an override.

Fixes: 139752137
Test: manual
Change-Id: I5cc301c3b7b459bdfaece0117bcacd984d1cb78f
2019-08-22 05:08:22 +00:00
Felipe Leme
501a514ba7 Defined a more generic way to let services "opt-out" from certain user types.
SystemService now defines a isSupported(UserInfo), which is used by SystemServiceManager to
skip the service for the unsupported types.

Also added a new argument to SystemService.onSwitch() to indicate which user is
being switched from.

Finally, also fixed VoiceInteractionManagerService so it doesn't start for headless user 0.

Test: manual verification
Test: atest CtsVoiceInteractionTestCases CtsAssistTestCases # on automotive and walleye

Bug: 133242016
Bug: 137878080

Change-Id: Ife4bd875f412f85cccf9c9fd03115abd238d7eab
2019-08-21 15:15:30 -07:00
Philip Cuadra
1e84d67493 Bind voice interactor as top-app when it is being used
When voice interactor is being used, it should run as the top app to
handle processing as quickly as possible.  This is similar to what IME
does when IME is shown.

Bug 139756725
Test: invoke assistant, confirm :interactor becomes top-app and then
goes back to foreground after use.

Change-Id: Id13b47dcb4de6658eede13a650e6ef631f649f4f
2019-08-21 17:06:43 +00:00
Felipe Leme
e5434c301b Initial implementation of system service optimizations for different type of users.
On R, we want to optimize boot time by not starting system services for some types of users,
like a headless system user (which is the case for Automotive)

As a "guinea pig", it optimizes VoiceInteractionService for headless system user, so the 3rd-party app
service is not bound for user 0 (and hence its process is not launched).

This change improves boot time on Automotive in about 100ms.

Test: atest CtsVoiceInteractionTestCases CtsAssistTestCases # on walleye and Automotive
Test: manual verification on logcat

Bug: 133242016
Fixes: 137878080

Change-Id: Ib0a902855e32691a1d00bfa77ee82c8e2430977c
2019-08-13 10:10:53 -07:00
Eric Laurent
6139a86809 Merge "SoundTriggerHelper: fix power save mode listener" into qt-r1-dev am: 8b3386567f
am: 72cd844e57

Change-Id: I53d7dbc8d28ba2362caab5bb11ebe9532be20044
2019-07-22 18:38:57 -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
Todd Kennedy
583378df9c Move providers to permission manager
Bug: 135279435
Test: atest PermissionUpdateListenerTest
Test: atest android.content.pm.cts.PackageManagerTest
Test: atest android.permission2.cts.RestrictedPermissionsTest
Test: atest TeleServiceTests
Test: atest DataConnectionTest
Change-Id: Ife563589929b2662c60e1a0ab0ec8f6a2d7e4c12
2019-07-16 13:09:33 -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
TreeHugger Robot
b13d88af52 Merge "Revert "Offload role manager work to background thread"" into qt-dev 2019-06-03 21:48:24 +00:00
Hai Zhang
c00c31e97e Revert "Offload role manager work to background thread"
This reverts commit f105c93c4a.

Reason for revert: b/132974796#23 the offloaded thread will be holding a lock for a noticeable period of time and cause contention.

Bug: 132974796
Change-Id: Ic81a2e3ee7226266c8f97b606fc1a2834240f689
2019-06-03 18:50:55 +00:00
Michael Dooley
58ac2ae2cb Merge "Limit GetModelState API to generic sound models (ie music detector)" into qt-dev 2019-05-24 05:37:10 +00:00