Commit Graph

438 Commits

Author SHA1 Message Date
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
Sergey Volnov
56686819a8 Merge "Implement preriodic trusted process restarting for hotword detectors." into sc-dev 2021-06-22 13:33:08 +00:00
Sergey Volnov
1b2b909a16 Implement preriodic trusted process restarting for hotword detectors.
Bug: 188892570
Test: 1) adb shell cmd voiceinteraction restart-detection
2) Tried locally with restarting every 30 seconds, verified everything
works
3) adb shell ps | grep <test_package_name> - shows:

u0_a221       3328  1026 14501612 69208 0                   0 R com.google.th
u0_i9002      9049  1026 14448104 53860 0                   0 S com.google.th:com.google.th.SampleHotwordDetectionService:hotword_detector_3

Change-Id: I9f08943212c20b83da35c18df56460eaedbbf8f0
2021-06-22 12:43:08 +01:00
TreeHugger Robot
3e3e618310 Merge "Improved implementation of VoiceInteractionManagerService.setDisabled()" into sc-dev am: 50bbe88967 am: 8458a57ec6
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14940217

Change-Id: I674ad35ba1e0b86d8cff12ee99260c9fefab858c
2021-06-15 22:10:51 +00:00
TreeHugger Robot
50bbe88967 Merge "Improved implementation of VoiceInteractionManagerService.setDisabled()" into sc-dev 2021-06-15 21:45:38 +00:00
Felipe Leme
07848e302b Improved implementation of VoiceInteractionManagerService.setDisabled()
This method is called by CarService when the system goes into suspend
state and the initial implementation completely disabled the service
(and unbound system server from it), which had 2 drawbacks:
- It adds extra work when the system resumes as it has to rebind.
- It can cause memory leaks if the service implementation doesn't
  handle it well.

This CL changes how the API is implemented: rather than disabling the
service, it just ignores new sessions.

To test it:

1. Disable

$ adb shell cmd voiceinteraction disable true

2. Start a session

$ adb shell cmd voiceinteraction show

3. Check logcat

I VoiceInteractionManager: showSessionForActiveService(): ignored while temporarily disabled

Bug: 190051449
Test: manual verification (see above)

Change-Id: Idbc4881b92d9254fb07ea5af1370ea600fc10b80
2021-06-15 11:31:36 -07:00
Ahaan Ugale
3fdfdaf765 Merge "Allow HotwordDetectionService access to audioflinger." into sc-dev am: a8a6a45f68 am: 42b7c85907
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14671365

Change-Id: I994da7b38be7af9f58bf07685adb0f60072d4bf8
2021-06-14 05:31:58 +00:00
Ahaan Ugale
a8a6a45f68 Merge "Allow HotwordDetectionService access to audioflinger." into sc-dev 2021-06-14 05:05:08 +00:00
Ahaan Ugale
23c84d2896 Merge "Grant HotwordDetectionService RECORD_AUDIO and CAPTURE_AUDIO_HOTWORD." into sc-dev am: 40069e8943 am: 1eea819631
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14427323

Change-Id: I23dbb652f411f736d8380ecbd95f148f36ec8e89
2021-06-10 18:22:37 +00:00
Ahaan Ugale
40069e8943 Merge "Grant HotwordDetectionService RECORD_AUDIO and CAPTURE_AUDIO_HOTWORD." into sc-dev 2021-06-10 17:53:56 +00:00
TreeHugger Robot
a68c88e681 Merge "Hotword: Propagate the DSP DetectedResult." into sc-dev am: dfbde545f3 am: accafd4628
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14427823

Change-Id: Icbd4f765b3030a5d832452dc9fadcff6413687b0
2021-06-09 23:03:54 +00:00
TreeHugger Robot
dfbde545f3 Merge "Hotword: Propagate the DSP DetectedResult." into sc-dev 2021-06-09 22:32:37 +00:00
TreeHugger Robot
c36d77961f Merge "Called onError() when HotwordDetectionService process died" into sc-dev am: 97be319829 am: cbdeae3a3e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14879196

Change-Id: Icca54c9a1a498dcf3d50c3f4d0b43104ac63f1a1
2021-06-09 11:56:59 +00:00
Ahaan Ugale
603ea83bd7 Hotword: Propagate the DSP DetectedResult.
Fix: 190572818
Test: atest CtsVoiceInteractionTestCases
Change-Id: I8a109f6540cf8c342b827464ccc2beabd99d1b9c
2021-06-08 23:33:47 -07:00
Ahaan Ugale
5fc6910227 Grant HotwordDetectionService RECORD_AUDIO and CAPTURE_AUDIO_HOTWORD.
HotwordDetectionService is an isolated service which ordinarily cannot
hold permissions. An isolated service has its own uid separate from the
owning package.
To allow it to access mic audio, we dynamically override the permissions
check based on the currently bound HotwordDetectionService.

Bug: 190011174
Test: manual - sample app can read audio (with a few other wip changes)
Test: atest CtsVoiceInteractionTestCases
Change-Id: I5abc809546184ef13cb9eb009f916afae6bdf1af
2021-06-08 14:26:04 -07:00
lpeter
568efb06b8 Called onError() when HotwordDetectionService process died
Bug: 189887779
Test: atest CtsVoiceInteractionTestCases
Test: atest CtsVoiceInteractionTestCases --instant
Change-Id: I98659f4c4553b6c9da31829016419871756d34c9
2021-06-08 23:27:09 +08:00
Ahaan Ugale
a64d628182 Allow HotwordDetectionService access to audioflinger.
HotwordDetectionService is an isolated service which ordinarily cannot
access audioflinger due to selinux restrictions on isolated processes.
To bypass those restrictions, the audioflinger binder is passed from
the system server to the HotwordDetectionService. This follows the
existing pattern of providing access to the ContentCapture service.

In T we *may* instead solve this at the selinux layer. For now, this
simpler approach is used.

Bug: 190011174
Test: manual - sample app can read audio (with a few other wip changes)
Test: atest CtsVoiceInteractionTestCases
Change-Id: I5493a5c3addf68f2ae80d64b6971a8576484eb8e
2021-06-04 07:20:27 +00:00
Sergey Volnov
fdd8f55445 Merge "Hotword: Add onStopDetection() for software detectors." into sc-dev am: 76660ef721 am: 20a30b3855 am: ac235e9a60
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14718524

Change-Id: I8d4a47536d42264f72854390c5d48f47964d97a8
2021-05-25 22:39:36 +00:00