Commit Graph

455 Commits

Author SHA1 Message Date
Michael Groover
2e701ddb90 Correct exported state for VoiceInteractionManagerServiceImpl receiver
The VoiceInteractionManagerServiceImpl receiver that listens for
CLOSE_SYSTEM_DIALOGS broadcasts was initially marked as not exported
since this broadcast should be dropped by the platform when sent from
apps. However since this broadcast is still valid to be used in tests,
receivers registering for this broadcast should be marked as exported.
This commit updates the receiver to exported to allow any tests that
send this broadcast to complete successfully.

Bug: 161145287
Test: Build
Change-Id: I2238b2e2d3c3b6ecec155b628ac59e8db6e863b6
2021-11-22 17:40:50 -08:00
Ahaan Ugale
9eacf56797 Merge "Set HotwordDetectionService priority same as VIS." into sc-v2-dev am: a2e3ba4700 am: d3aaca69cf
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16285219

Change-Id: I16ccd53b68b0c9091bba97b559acddb4dfc75e6a
2021-11-18 20:05:56 +00:00
Ahaan Ugale
643eb06ced Set HotwordDetectionService priority same as VIS.
VoiceInteractionService is bound with the BIND_FOREGROUND_SERVICE flag.
Do the same for the HotwordDetectionService now.

Test: manual
Fix: 206812592
Change-Id: Iddd992fe475976ac68b91580c67525f56d534e32
2021-11-17 10:17:54 -08:00
Ytai Ben-Tsvi
78bb22a1c7 Support back-to-back soundtrigger recognitions
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
2021-10-18 16:37:03 +00:00
Michael Groover
73e18d5792 Merge "Add required flag to registerReceiver calls for platform services" 2021-10-05 23:31:26 +00:00
TreeHugger Robot
dddbf380e5 Merge "[NGA v2] Reliable Visible Activity Lookup" into sc-v2-dev am: 80fcbc8fe0 am: 347557e905
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15810445

Change-Id: I4a5b0c551343984de6124a497f7b24dd750c5aca
2021-09-28 18:16:17 +00:00
lpeter
918ea9940f [NGA v2] Reliable Visible Activity Lookup
To enable more voice-oriented in-app user journeys, Google Assistant
needs to access more information regarding the visible activities
via the Voice Interaction Session. Thus, we provide the APIs to receive
the changed visible activities in Voice Interaction Session.

Bug: 178244510
Test: atest CtsVoiceInteractionTestCases
Test: atest CtsVoiceInteractionTestCases --instant
Change-Id: I019d09fee8105ae1eadbc76803f46fd8b1948f6b
2021-09-28 17:06:49 +08:00
Joanne Chung
69d90b08b1 Set interaction boost for voice sessions. am: 02ccd62d0d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15837927

Change-Id: I3273d455ea315bfb66b6072f1a9b69c2e24b31b7
2021-09-27 16:17:15 +00:00
Joanne Chung
aefce65ff8 Set interaction boost for voice sessions. am: 02ccd62d0d am: eafe88a029 am: 7c4f04280c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15837927

Change-Id: Ibc5ac743598ccb26f6ca5148a03f5e08583896ec
2021-09-27 06:33:06 +00:00
Joanne Chung
7c4f04280c Set interaction boost for voice sessions. am: 02ccd62d0d am: eafe88a029
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15837927

Change-Id: Ie46db0533709b14246a2ade286503a66fb314df3
2021-09-27 06:19:02 +00:00
Joanne Chung
02ccd62d0d Set interaction boost for voice sessions.
Bug: 198415915
Test: atest CtsVoiceInteractionTestCases

Change-Id: I8fde3c1ced5a99e98c037a32d97f41835e572a9b
2021-09-27 03:28:13 +00:00
Michael Groover
6f786115cb Add required flag to registerReceiver calls for platform services
Android T adds support to allow a runtime receiver to be registered as
not exported, but to ensure apps can take advantage of this, calls to
receiver should be exported for apps targeting T+ that are registering
for unprotected broadcasts. This commit updates all of the calls under
services/ that are registering receivers for unprotected broadcasts.

Bug: 161145287
Test: Manually verified code did not trigger logcat message for not
  specifying the necessary flag when calling #registerReceiver
Change-Id: Icaef9d9cf9ed888d124f33c40dbeb1b15df87938
2021-09-21 19:32:19 -07:00
TreeHugger Robot
2964252dad Merge "Remove the isBound() check for HotwordDetectionService." into sc-qpr1-dev am: 75bdd11137 am: c4a0db7832 am: ba064f738c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15768220

Change-Id: Ida389b1e52e647cb7cca70fa7dfe701a893816d3
2021-09-15 15:21:35 +00:00
TreeHugger Robot
ba064f738c Merge "Remove the isBound() check for HotwordDetectionService." into sc-qpr1-dev am: 75bdd11137 am: c4a0db7832
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15768220

Change-Id: Ied173b905d7cfdfb0bc19402d41bef4489eb356d
2021-09-15 15:07:36 +00:00
TreeHugger Robot
87c105f145 Merge "Remove the isBound() check for HotwordDetectionService." into sc-qpr1-dev am: 75bdd11137
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15768220

Change-Id: I06ace5568c30b982ff9e306f41133dc7a0127b58
2021-09-15 11:48:29 +00:00
lpeter
74b69a2516 Remove the isBound() check for HotwordDetectionService.
There will be a race condition (Ex:Create AlwaysOnHotwordDetector
twice quickly) where it will miss unbinding HotwordDetectionService
and clearing HotwordDetectionServiceProvider when using the
isBound() check for HotwordDetectionService.

Because we use "ServiceConnector.Impl" to create the connection,
it is unnecessary to use isBound() function to check if the
HotwordDetectionService should be unbound.

Bug: 195457729
Test: atest CtsVoiceInteractionTestCases
Test: atest CtsVoiceInteractionTestCases --instant
Test: manual - DSP and non-DSP
Change-Id: Ib74e0dc9364af3713007b115f7d170bf6e833810
2021-09-07 10:38:20 +08:00
Ahaan Ugale
0e7131f309 RESTRICT AUTOMERGE Disable the Trusted Hotword requirement
The requirement to use a sandboxed HotwordDetectionService to avoid
incurring the mic indicator will be added back in a future release.
With this change, SoundTrigger events and hotword-source audio do not
incur the mid indicator for any process.

This change adds back the permissions logic from
I3275647d0f9a6e3ce8b97a556f56723b49170c8e, adjusted to account for the
changes from I4fc3b3e8defed59a900fd156273e9e695a322b0c (preflight
permission checks were made to accept soft denials, so simply reusing
enforcePermissionForPreflight does not work anymore - it would pop up a
dialog if the mic sensor is muted).

We preserve the behavior of showing the indicator when the detected
event is delivered from the Trusted Hotword process (no false-positives
here, so we can accurately show it).

Fix: 197034852
Test: manual - dsp and non-dsp; true and false positives; mute mic
 sensor - events aren't delivered and no dialog is shown, hotword still
 works after unmuting; mute mic and restart, unmute after starting reco;
 Trusted and non-Trusted hotwording
Test: atest CameraMicIndicatorsPermissionTest
Test: atest HotwordDetectionServiceBasicTest
Test: atest android.cts.statsdatom.appops.AppOpsTests#testAppOps
Change-Id: I68f2f37b5ce835e7fd8649b382eaee9fc299ec79
2021-08-18 01:01:19 -07:00
Ahaan Ugale
66a8c768f7 Merge "Make Trusted Hotword session permissions follow previous behavior" into sc-dev am: e81ea6bebd am: 5ac631149d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15474471

Change-Id: I522ee4669cfba3140596120a33c4a807baf25446
2021-08-06 20:04:08 +00:00
Ahaan Ugale
e81ea6bebd Merge "Make Trusted Hotword session permissions follow previous behavior" into sc-dev 2021-08-06 19:21:30 +00:00
Ahaan Ugale
3873a09959 Make Trusted Hotword session permissions follow previous behavior
A prior change to the permissions flow for Trusted Hotword
(I80dabaf6ae0e781028dde16ead3321fbff319542) made the system enforce
the required permissions on the APIs the conventional way - by throwing
a SecurityException. But the existing behavior was to silence these
exceptions and instead return error results. This change brings back
the old behavior which exists in the SoundTrigger layer.

Also removes permissions checks for a couple of APIs to again be
consistent with the old behavior (and the current behavior in the
SoundTrigger layer).

Fix: 193116894
Test: manual - remove permission and reboot / remove permission after
 boot, stop/start reco
Test: atest HotwordDetectionServiceBasicTest
Change-Id: I56391260fd4375a04233eb3261bacec8696bda99
2021-08-06 02:19:30 +00:00
Ahaan Ugale
966437f651 Merge "Send the HotwordDetectionService UID to AudioPolicy" into sc-dev am: 298c5093dc am: 1c1a014258
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15465671

Change-Id: I5cf12c4a699fbc06aa39b48f710e9fceca6d6746
2021-08-05 19:49:38 +00:00
Ahaan Ugale
3ac246c432 Send the HotwordDetectionService UID to AudioPolicy
This change follows the pattern of how the IME UID is set.

The UID is stored in AudioService and re-sent there if the audio server
dies.

Fix: 194368677
Test: manual - hotword works when another app is using the mic and in
 Auto projection mode; also after restarting the process or killing
 audio server
Test: atest HotwordDetectionServiceBasicTest
Change-Id: I325cb33d17387e62302967b261b6fe61086d8893
2021-08-04 21:29:21 -07:00
Joanne Chung
519fd25544 Merge "Bug fix: fix System crash due to NullPointerException." into sc-dev am: 6791ed0112 am: 9aa7694408
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15234896

Change-Id: Id4ce45b30e682b57ce63db7432efbe2c84c50a29
2021-08-03 13:29:23 +00:00
Joanne Chung
223060d6f4 Bug fix: fix System crash due to NullPointerException.
If the voice interaction doesn't set RecognitionService, it may cause
NPE when it tries to get recognizer name. We don't need recognizer
name since Android 12, we delete it directly. To avoid the app does
not set RecognitionService then updating the app to earlier platform
that may cause boot loop. We add a warning log and set empty service
for voiceinteraction to let app aware the problem. Also logging and
unset the voiceinteraction service if the app try to update the app
without recognition service.

Bug: 170742278
Test: Use sample VoiceInteractionService without a RecognitionService
The system doesn't crash when choosing the sample app as the default
assistant app from Settings. And make sure the VoiceInteractionService
is unset.
Test: Install sample VoiceInteractionService with a RecognitionService
and then update it without a RecognitionService. Make sure the voice
interaction service is unset.

Change-Id: I79ab3d6449984ead0be28a94adaad57ab24d1fb9
2021-08-03 07:34:05 +00:00
Ahaan Ugale
6329f0d195 Merge "Hotword: Treat preflight soft denial as granted." into sc-dev am: a13d80321e am: e8c8941937
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15421452

Change-Id: I5c3f653d6bfdc86319f231818622c3c09671e01b
2021-07-30 23:04:30 +00:00
Ahaan Ugale
bf0b40550b Hotword: Treat preflight soft denial as granted.
In preflight we should accept soft denials as they can become grants at
the time of delivery.
Realigns permissions code in VoiceInteraction with that in SoundTrigger,
which was fixed in I4fc3b3e8defed59a900fd156273e9e695a322b0c.

Fix: 194137739
Test: manual - no errors for starting recognition when mic access is
 blocked. data delivery is still blocked
Test: atest HotwordDetectionServiceBasicTest
Change-Id: I49d504a30b4d04f157990580838757a3f17861cc
2021-07-29 11:18:34 -07:00
Ahaan Ugale
7916020e2b Merge changes I212ad58c,Idf5dd82d into sc-dev am: 0e3d3b90ec am: 9c1d1a05fe
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15360457

Change-Id: Ia0d660886263d62272b81315aa1cea05b70324f0
2021-07-24 07:23:39 +00:00
Ahaan Ugale
acccd67afc Merge "Add null pointer check for callback in HotwordDetectionConnection." into sc-dev am: f569f09b5a am: 75aba256b2
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15327988

Change-Id: I6e58e79592faca842ada3ddd1c0d6fd9dcdb7e49
2021-07-24 01:38:12 +00:00
lpeter
d28177c7e7 Provide the way to enable/disable debug mode for logging egressed data
Currently we provide the Shell command to enable/disable one debug mode
that we will log the HotwordDetectedResult and HotwordRejectedResult if
the debug mode is wnable. But we will reset the debug mode after one
hour from last enable.

Bug: 194339253
Test: Use the Shell command and check the log
Change-Id: I212ad58c7550b297babed50249a08db6f0e24b3a
2021-07-24 04:09:34 +08:00
lpeter
2d28217de6 Set the Debug flag to false
Set the Debug flag to false, but we also reserve some logs
for clarifying the issue.

Bug: 177502877
Test: atest CtsVoiceInteractionTestCases
Test: atest CtsVoiceInteractionTestCases --instant
Change-Id: Idf5dd82d8db27bb682b473eb4584e8b230073d08
2021-07-23 14:46:29 +08:00
lpeter
aa80f8e7d5 Add null pointer check for callback in HotwordDetectionConnection.
Bug: 194090728
Test: atest CtsVoiceInteractionTestCases
Test: atest CtsVoiceInteractionTestCases --instant
Change-Id: I5b9f8320ddbcfc947f9a0b810b6f71c8a4fc9ff4
2021-07-23 13:16:17 +08:00
TreeHugger Robot
56685c88b0 Merge "Reset HotwordDetectionConnection when VoiceInteractionService crashes" into sc-dev am: a687e13ff3 am: 955c0a799c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15269082

Change-Id: Ie7859fd24ee48136b8f36e773586772f75760ddd
2021-07-17 02:09:01 +00:00
lpeter
5a485126d8 Reset HotwordDetectionConnection when VoiceInteractionService crashes
I use the command "adb shell kill <pid>" and "adb shell am crash
<package>" to test, it works well.

Bug: 193421614
Test: manual test
Test: atest CtsVoiceInteractionTestCases
Test: atest CtsVoiceInteractionTestCases --instant
Change-Id: I53206f07801b0fac588cb23fa2b91cac561547ed
2021-07-16 18:46:56 +08:00
Ahaan Ugale
878ceb38cd Merge "Check/note ops when delivering HotwordDetectedResult" into sc-dev am: e360fc69a7 am: 19c940f607
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15241921

Change-Id: I8d9e9d472412c113c349e6ba630949f1fd11abe3
2021-07-12 18:10:18 +00:00
Ahaan Ugale
c5e855a9d9 Check/note ops when delivering HotwordDetectedResult
This is partially a followup of
I80dabaf6ae0e781028dde16ead3321fbff319542 which removed these operations
from the SoundTrigger layer when the HotwordDetectionService is used.

Also fixes a race condition where the DSP event can go directly to the
Interactor if the DetectionService isn't connected.

Bug: 186164881
Test: atest HotwordDetectionServiceBasicTest
Test: manual - DSP and non-DSP
Change-Id: Iee3b00c6c08597ad1993fae677e9f8ae2f60744c
2021-07-12 17:42:24 +00:00
Ahaan Ugale
fad26b4dec Merge "Re-init HotwordDetectionSrvc when audioserver dies" into sc-dev am: 8fd0ab207a am: ebfc830bde
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15187469

Change-Id: Ib1971b7542d6955c5ac3ec04bec344984c0740bd
2021-07-03 09:31:10 +00:00
Ahaan Ugale
8fd0ab207a Merge "Re-init HotwordDetectionSrvc when audioserver dies" into sc-dev 2021-07-03 08:50:06 +00:00
TreeHugger Robot
3a6d3e8b23 Merge "Init HotwordDetectionSrvc identity earlier" into sc-dev am: aa2c737e51 am: bf00a4312b
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15187288

Change-Id: I21147287d3c92efe7146cc9888a342175a470793
2021-07-03 05:11:50 +00:00
Ahaan Ugale
bb8885f631 Re-init HotwordDetectionSrvc when audioserver dies
We do this instead of simply sending over the new binder to avoid race
conditions with audio reading in the service.

Fix: 190011174
Test: manual - kill audio server, also do this twice in quick
 succession; dsp and non-dsp
Test: atest CtsVoiceInteractionTestCases
Change-Id: Iabee9549512cc09d2305de5b0e965b9315134fb0
2021-07-02 21:51:23 -07:00
TreeHugger Robot
aa2c737e51 Merge "Init HotwordDetectionSrvc identity earlier" into sc-dev 2021-07-03 04:41:08 +00:00
Ahaan Ugale
cb8ebd1151 Init HotwordDetectionSrvc identity earlier
Grants mic access to the process as soon as it comes up, instead of
waiting for the initialization status callback.

Bug: 190011174
Test: manual - dsp and non-dsp; restarting while invoking the hotword
Test: atest CtsVoiceInteractionTestCases
Change-Id: I54e0b42868f663ae1c9edd9bcf4aaee2a13b827a
2021-07-02 19:06:06 -07:00
TreeHugger Robot
e32a777158 Merge "Logging the number of bits egressing from the hotword trusted process" into sc-dev am: 023fa14302 am: 840ed7bb10
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15126534

Change-Id: I774bfed14b1f4cd43a895121cdd0d95d7add09c7
2021-07-02 08:19:18 +00:00
TreeHugger Robot
023fa14302 Merge "Logging the number of bits egressing from the hotword trusted process" into sc-dev 2021-07-02 07:48:25 +00:00
lpeter
53de9e92d7 Logging the number of bits egressing from the hotword trusted process
Bug: 192331590
Test: atest CtsVoiceInteractionTestCases
Test: atest CtsVoiceInteractionTestCases --instant
Change-Id: I08329643d94655f762787a7a49567e19bbbfbe9c
2021-07-02 12:20:27 +08:00
Ahaan Ugale
fb75c5c19b Merge "HotwordDetectionSrvc: Handle SoundTrigger permissions in VIMS" into sc-dev am: b0ef72e5d5 am: 9cb98b5bd8 am: 7670a06819
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15108252

Change-Id: I46dd9383eab8f948145a2de5b689993de4c3cf2c
2021-06-30 15:16:08 +00:00
Ahaan Ugale
b0ef72e5d5 Merge "HotwordDetectionSrvc: Handle SoundTrigger permissions in VIMS" into sc-dev 2021-06-30 14:27:12 +00:00
Ahaan Ugale
ba966c1461 HotwordDetectionSrvc: Handle SoundTrigger permissions in VIMS
This allows properly checking/noting against the voice interactor or
HotwordDetectionService as needed. Otherwise,
SoundTriggerMiddlewarePermission notes ops for data delivery to the
interactor, even if the data only reaches the HotwordDetectionService.

This is accomplished with a decorator for permission checks, that wraps
the real implementation. A proxy that serves as the remote Binder object
is also needed, to allow this decoration pattern.

The list of sessions stored in VIMS is removed for simplicity. It
currently serves no purpose (used only in dump() but doesn't implement
it so it's a no-op there).

DataDelivery checks will be addressed in a followup change.

Bug: 186164881
Test: manual - permissions are checked appropriately
Test: atest CtsVoiceInteractionTestCases
Change-Id: I80dabaf6ae0e781028dde16ead3321fbff319542
2021-06-29 19:13:13 -07:00
Ytai Ben-tsvi
e5ba7447bb Merge "Fix permission checking in SoundTriggerService" into sc-dev am: 7461a5576b am: 30d571456c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15081290

Change-Id: I05983c00ad5472aec618a148ab80f30f0da06b7d
2021-06-24 07:23:30 +00:00
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
Sergey Volnov
90a6e6bacc Merge "Implement preriodic trusted process restarting for hotword detectors." into sc-dev am: 56686819a8 am: 952946bf67
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14679832

Change-Id: I6abb7134f755e00bd63b5bb73b61de5e51af465d
2021-06-22 13:53:17 +00:00