Commit Graph

339 Commits

Author SHA1 Message Date
TreeHugger Robot
ecd46961ba Merge "Use the PersistableBundle instead of the Bundle" into sc-dev am: 20e5c931b5
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13917726

Change-Id: I20c50141818d4b32d001ba4fe16c209927eec542
2021-03-24 01:19:01 +00:00
lpeter
58f920e023 Use the PersistableBundle instead of the Bundle
It will be more secure to use PersistableBundle
instead of Bundle for passing the configrations
data from VoiceInteractor to HotwordDetectionService.

Bug: 176938300
Test: Test: atest CtsVoiceInteractionTestCases
Test: atest CtsVoiceInteractionTestCases --instant
Change-Id: I19a412cca5e2cd5f9f79a112a9d7da8fd3a00a38
2021-03-23 12:32:25 +08:00
TreeHugger Robot
4c2e705bfd Merge "Validate HotwordDetectionService to be in the isolated process." into sc-dev am: f1ce6c68c9
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13885355

Change-Id: I71cdfe1d66731121cfdff41516138b2fc3ef21a3
2021-03-22 13:19:46 +00:00
TreeHugger Robot
f1ce6c68c9 Merge "Validate HotwordDetectionService to be in the isolated process." into sc-dev 2021-03-22 07:03:44 +00:00
Nicolò Mazzucato
89ae2cd60b Merge "Always call onHandleAssist with AssistState containing at least activity id" into sc-dev am: 11bc52ed42
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13872931

Change-Id: Icba2342b5f3236f1c7ec5a04cc31b66583f87d34
2021-03-19 14:01:38 +00:00
lpeter
91e9a97d1d Validate HotwordDetectionService to be in the isolated process.
Bug: 176938459
Test: atest CtsVoiceInteractionTestCases
Test: atest CtsVoiceInteractionTestCases --instant
Change-Id: I5cdbada18ecd56397337377fba7ff2d6309ecf0f
2021-03-19 18:29:55 +08:00
Nicolo' Mazzucato
bbc1459cf0 Always call onHandleAssist with AssistState containing at least activity id
With this change, even if clients are not requesting any assist
data (e.g. VoiceInteractionSession.showSession is called with 0
as flags), Activity's `onHandleAssist(AssistState)` is always
called with non-null ActivityId. If no other data were requested,
AssistContent, AssistData and AssistStructure inside
VoiceInteractionSession.AssistState are null.

The previous behaviour was that if no assistData were requested,
Activity's `onHandleAssist` would not have been called.

This new behaviour saves time to clients interested only in ActivityIds,
because no activities methods need to be called (to get AssistData and
AssistContent).

We are not adding a new flag "SHOW_WITH_ACTIVITY_ID" because this
ActivityId is always non-null in ActivityState, and it's cheap to get it.

Bug: 178020517
Test: atest CtsAssistTestCases
Test: atest CtsVoiceInteractionTestCases
Change-Id: Icb46a928c8508a4bd355622df78f9371c21fd0e6
2021-03-18 20:14:36 +00:00
TreeHugger Robot
8bbdbef937 Merge "Only allow preinstalled application to be able to call setHotwordDetectionServiceConfig" into sc-dev am: 3be701e767
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13877206

Change-Id: I9b397efbc045fe63cee660019276aef998431356
2021-03-18 08:55:26 +00:00
lpeter
b787d41387 Only allow preinstalled application to be able to call setHotwordDetectionServiceConfig
We added a new permission "MANAGE_HOTWORD_DETECTION" to allow
the application that held this permission to be able to use
setHotwordDetectionServiceConfig functions.

In order to avoid the feature leakage, we submit the change
about Shell in internal branch.

Bug: 178346114
Test: atest CtsVoiceInteractionTestCases
Test: atest PermissionPolicyTest
Change-Id: I8829c3c389fb5fe4b06ffcf21870db50fa2ede4b
2021-03-17 19:37:16 +08:00
TreeHugger Robot
97fd95556c Merge "Implement passing the model data to the trusted process" into sc-dev am: 98dfc2a69c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13764805

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Id6165e1ab62493cb0d33007629e2de3840ca718b
2021-03-12 04:31:40 +00:00
lpeter
9a75f1c529 Implement passing the model data to the trusted process
In this patch, we change the behavior to trigger the hotword
detection service when the interactor application calls the
new "createAlwaysOnHotwordDetector" function. The system will
also pass the read-only data(Ex : model data) back to hotword
detection service by using the share memory when the service
is initialized.

So the interactor application can use the new function with
share memory to pass the model data back to hotword detection
service.

Bug: 176938619
Test: atest CtsVoiceInteractionTestCases
Change-Id: I753988691725c9d962be25c92d60ec66a3812394
2021-03-09 20:20:27 +08:00
Ytai Ben-Tsvi
7139d464cf Adopt "resourcesAvailable" naming instead of "tryAgain"
Test: Compiles
Bug: 178722883
Change-Id: I13c983ae34d33f616677280eb856c17fb5c69ed8
2021-03-05 12:41:40 -08:00
Ytai Ben-Tsvi
72695ffa6e Support preemptive model unloading
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
2021-03-05 12:41:28 -08:00
Sergey Volnov
54e2ec28d5 Merge "Refactor audio flows so that server streams audio to the client." into sc-dev 2021-03-01 20:12:22 +00:00
Sergey Volnov
1d87cf0604 Refactor audio flows so that server streams audio to the client.
This way server has control over when to stop recording (in case clients
time out or don't start consuming bytes) AND it solves the attribution
problem (Voice Interaction Service would only get the capture session upon a positive
trigger, so would be "blamed" then).

Test: atest CtsVoiceInteractionTestCases
Bug: 168305377
Change-Id: If5bead87e88cfc9e31393029df5389afb6922183
2021-03-01 11:09:08 +00:00
Ahaan Ugale
3a1cef2e92 VIMS: Use the new recognizer config resource for init.
When initializing or resetting the recognizer setting, the configured
package is preferred over other available recognizers.

Bug: 175480455
Test: manual - unset recognizer, reboot, and check the setting
Test: atest CtsAssistTestCases CtsVoiceInteractionTestCases \
  CtsVoiceSettingsTestCases
Change-Id: I2fc225eba56bc787b267262d9917e718035c6047
2021-02-25 22:12:49 +00:00
Ahaan Ugale
1537ad4281 VIMS: Don't set recognizer when assistant changes.
Decoupling recognizer from assistant allows it to be provided by a
different package.
The recognizer is now set only on initializing the user or when
packages are modified.

There should be no change to how the assistant or interactor is set.

Bug: 167597525
Test: manual - set/unset assistant, reboot.
Test: atest CtsVoiceInteractionTestCases
Change-Id: I42bd1ab768070d444a1f6e3e78571cae8288a8ba
2021-02-20 04:30:22 +00:00
Ahaan Ugale
de203c37c3 VIMS: Decouple recognizer init from interactor in PackageMonitor.
On package modification, set the recognizer independently of the
interactor.
This will allow keeping the default recognizer provider a different
package from the interactor.
There should be no change to how the interactor is set.

Bug: 167597525
Test: manual
Test: atest CtsVoiceInteractionTestCases
Change-Id: Ib24f077365cbb0850c61196c2825737db1c1c090
2021-02-20 02:49:18 +00:00
Ahaan Ugale
50cabe923d VIMS: Decouple recognizer from interactor in initForUser().
When initializing settings for a user, set the recognizer independently
of the interactor.
This will allow the default recognizer to be provided by a different
package from the interactor.
There should be no change to how the interactor is set.

Bug: 167597525
Test: manual
Test: atest CtsVoiceInteractionTestCases
Change-Id: I2da8f72c768b27df21534e265a3d1fb6919c7140
2021-02-20 02:49:01 +00:00
TreeHugger Robot
f3421c57d4 Merge "VIMS: Helper method for InteractionService query." into sc-dev 2021-02-10 01:20:26 +00:00
Charles Chen
b80fdde45f Remove addWindowTokenWithOptions
Since WindowContext won't add WindowToken from the client side,
addWindowTokenWithOption is no more needed. Also remove the logic
to invoke removeWindowToken from the client side.

Bug: 159767464
Bug: 153369119
Test: atest WindowManagerServiceTests WindowManagerPermissionTests
Change-Id: Ib0c948dca223cf8d056865ce3a0d4adaef07d247
2021-02-06 15:47:08 +08:00
lpeter
fd652d522c Get the HotwordDetectionService from the xml metadata
Bug: 178171920
Test: atest CtsVoiceInteractionTestCases
Merged-In: Ic19ae8b0ad8b646836fca7417e68b9b36429d5f0
Change-Id: I2a97491c7bbfd3a04ec3d9488beb158287d22e10
2021-02-05 23:28:13 +08:00
Ahaan Ugale
79593fb955 VIMS: Helper method for InteractionService query.
Code is duplicated in a couple of places.

Bug: 178410946
Test: atest
Change-Id: I1385a03a098ed7fdee7254c4752df6cbaae4a7a2
2021-02-03 11:16:20 -08:00
Ahaan Ugale
8b3b3b9403 VIMS: Clarify NonNullability of PackageMonitor#onPackageModified.
Bug: 178410946
Test: builds
Change-Id: I767e0f7f4ed1ae8c7f0a74afb5114a85a679d86a
2021-01-29 08:41:46 +00:00
lpeter
205ee1efed Create basic behavior of HotwordDetectionService
Create the HotwordDetectionService to help to verify the audio data.
The VoiceInteractor app will implement the HotwordDetectionService
and create the validation algorithm to increase the hotword accuracy.

The HotwordDetectionService will be triggered by VoiceInteractor app
from the VoiceInteractionService after the VoiceInteractionService
is ready.

The VoiceInteractionManagerService will check if we need to bind the
HotwordDetectionService.

After receiving the audio data from the DSP, the
VoiceInteractionManagerService will pass the audio data to the
HotwordDetectionService, then the HotwordDetectionService will verify
the audio data and send the result back.

If the hotword is valid, then the VoiceInteractionManagerService will
inform the VoiceInteractionService. The VoiceInteractor app will show
the UI.

Local test:
1.Make sure the original hotword function to work well manually.
2.Add the additional test code and check the log to make sure the
basic flow of hotword detection service runs well manually.

Bug: 175738546
Test: Manually
Test: atest CtsVoiceInteractionTestCases
Change-Id: Idb662bab37bb9691da24c9c2910a2c3dafedcadd
2021-01-26 00:58:37 +00:00
Ahaan Ugale
61732f5f69 VIMS: Simplify findAvailInteractor() by getting metadata in initial pm query.
Also reorders the conditional blocks for readability.

Currently, available interactors are queried and one of them is selected, then the
metadata for it is retrieved through the VoiceInteractionServiceInfo constructor.

With this change, both things are done in a single step. That might mean we retrieve some
unneeded data (the metadata for the packages that aren't selected), but optimizing it
isn't important since there's usually just one interactor.

Bug: 178410946
Test: atest CtsVoiceInteractionTestCases
Change-Id: I9a0d859f12d043f47f33a307609dbcf9de759e7e
2021-01-25 13:39:27 -08:00
Ahaan Ugale
ba37dbb352 VIMS cleanup: set package on pm query instead of filtering results.
Bug: 178410946
Test: atest CtsVoiceInteractionTestCases
Change-Id: I8ab1824aba534857e2978861d001a74837de281d
2021-01-25 13:39:21 -08:00
Ahaan Ugale
54a505d46f VoiceInteraction: Remove MATCH_DEBUG_TRIAGED_MISSING from PM queries.
MATCH_DEBUG_TRIAGED_MISSING is the deprecated equivalent to MATCH_DIRECT_BOOT_AUTO.
Not needed since we use MATCH_DIRECT_BOOT_AWARE and MATCH_DIRECT_BOOT_UNAWARE (see
comments on ag/1101955).

Bug: 178410946
Test: atest CtsVoiceInteractionTestCases
Change-Id: I2093b163bb18e43c4f868715d60bc4b637fced6c
2021-01-25 13:39:02 -08:00
Ahaan Ugale
cc6f2a78e4 VIMS: Remove useless field mCurUserUnlocked.
It's never set to true and is only used for logging anyway.

Bug: 178410946
Test: atest CtsVoiceInteractionTestCases
Change-Id: Ie4370c2e9ddd305daad90f1393897e30a2dee8ac
2021-01-25 13:38:53 -08: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
547308d671 Merge "Don't change the voice interactor setting if it's explicitly unset." 2020-12-16 18:37:56 +00:00
Ahaan Ugale
c962a1acd6 Don't change the voice interactor setting if it's explicitly unset.
Test: manual (currently requires hardcoding the assistant role due to b/175747251)
Test: atest CtsAssistTestCases CtsVoiceInteractionTestCases CtsVoiceSettingsTestCases
Bug: 167261484

Change-Id: Ibc2c1675f8b026f2915c3faf55e8ff3c52e1ee32
2020-12-16 16:58:35 +00: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
Hai Zhang
2bad176fc2 Move DefaultPermissionGrantPolicy out of PermissionManagerService.
DefaultPermissionGrantPolicy should be migrated to role in the future,
however it requires exposing a lot of APIs, including
set*PackagesProvider() and grantPermissionsTo*(), which would soon be
deprecated once we finish migration to role. On the other hand, the
benefits of making DefaultPermissionGrantPolicy updatable is
negligible. So we should keep DefaultPermissionGrantPolicy in the
platform.

Since we are making permission updatable, and package is a different
thing from permission, we are creating a new internal service call
LegacyPermissionManagerService to host it. We need this new internal
service instead of directly exposing DefaultPermissionGrantPolicy,
because there are system APIs on the framework PermissionManager class
that needs an AIDL interface, and a small amount of the AIDL methods
there are not DefaultPermissionGrantPolicy but still should remain in
platform. For now, the AIDL methods are delegated to
LegacyPermissionManagerInternal via PermissionManagerService, but
later we will create its own AIDL for LegacyPermissionManagerService
and make the AIDL calls directly, without involving
PermissionManagerService.

So we are exposing a new LegacyPermissionManagerInternal on
LocalServices, and replacing the usages of the previous
PermissionManagerServiceInternal.

LegacyPermissionManagerInternal is also made available in
PackageManagerService to facilitate calling
DefaultPermissionGrantPolicy grantDefaultPermissions().

The system browser permission granting is moved into the browser
role's behavior, to avoid exposing it to RoleManagerService.

Bug: 158736025
Test: presubmit
Change-Id: Ic78f7775eaf0b1d7b5b940ccb03f7afc38437ef4
2020-12-04 23:22:38 -08:00
TreeHugger Robot
203346d3f5 Merge "fix issue with ST listModules check" 2020-11-19 01:34:16 +00: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
Adam Bookatz
961f737505 Merge "Move UserManagerInternal out of android.os" 2020-11-18 17:38:06 +00:00
Adam Bookatz
e5140cc83b Move UserManagerInternal out of android.os
Moving this class out of android.os will reportedly
greatly reduce ART overhead.

Test: compiles
Test: atest FrameworksServicesTests FrameworksCoreTests
Bug: 165817914
Exempt-From-Owner-Approval: no-op refactoring
Change-Id: I1f3e77120979e2f336e5f42e4ec6e459d6492083
2020-11-17 20:43:46 +00: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
Nicholas Ambur
cf2c264736 fix return behavior of deleteKeyphraseSoundModel
When deleting an enrolled keyphrase sound model that is not actively
started, the model is never removed from the framework database, and an
incorrect value is returned.

Test: gts-tradefed run gts -m GtsAssistIntentTestCases \
-t com.google.android.assist.gts.KeyphraseModelManagerTest \
\#testUpdateAndRemoveKeyphraseSoundModel
Bug: 169628490

Change-Id: I469fe1fd05e386095ec646e1506fcb191b93c46f
2020-10-14 16:47:52 -07:00
Jeff Sharkey
b93712f623 Tighten up Binder.clearCallingIdentity() usage.
This is a third CL in a chain that adjusts existing malformed code
to follow AndroidFrameworkBinderIdentity best-practices.

Specifically, if a thread clears an identity they need to restore it
to avoid obscure security vulnerabilities.  In addition, the relevant
"try" block must start immediately after the identity is cleared to
ensure that its restored if/when any exceptions are thrown.

Bug: 155703208
Test: make
Exempt-From-Owner-Approval: trivial refactoring
Change-Id: I74cb958b68d55a647547aae21baff6ddc364859b
2020-10-07 21:24:05 -06: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
10c9b09f25 Sessionize VoiceInteractionManagerService
This change associates an identity with every
VoiceInteractionManagerService session.

Change-Id: I6c87c2976a4409b8dda4480234d794db91cee374
Bug: 163865561
2020-09-10 13:27:08 -07: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