Commit Graph

399 Commits

Author SHA1 Message Date
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
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
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
8fd0ab207a Merge "Re-init HotwordDetectionSrvc when audioserver dies" into sc-dev 2021-07-03 08:50:06 +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
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
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
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
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
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
a8a6a45f68 Merge "Allow HotwordDetectionService access to audioflinger." into sc-dev 2021-06-14 05:05:08 +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
dfbde545f3 Merge "Hotword: Propagate the DSP DetectedResult." into sc-dev 2021-06-09 22:32:37 +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
Ahaan Ugale
31f241cc63 Hotword: Add onStopDetection() for software detectors.
For DSP-based detection, stopRecognition() disables detection at the
sound trigger layer. For software detection, the HotwordDetectionService
must be notified so it can stop detection.

Bug: 189236104
CTS-Coverage-Bug: 183425641
Test: atest CtsVoiceInteractionTestCases
Change-Id: I220d2255e5e500c22723f6e2fbc34860a529f216
2021-05-25 18:59:29 +00:00
TreeHugger Robot
6572539f65 Merge "Check "BIND_HOTWORD_DETECTION_SERVICE" permission before binding HotwordDetectionService" into sc-dev 2021-05-25 13:24:35 +00:00
lpeter
e66524d14f Check "BIND_HOTWORD_DETECTION_SERVICE" permission before binding HotwordDetectionService
Bug: 187914415
Test: atest CtsVoiceInteractionTestCases
Test: atest CtsVoiceInteractionTestCases --instant
Change-Id: I4ccd8fd5b153f28fa4b1463f7412bb8067cc4ffd
2021-05-21 10:49:56 +08:00
Evan Severson
11b564feb1 Show sensor usage dialog for assistant
The problem is that the assistant doesn't draw its own
UI in some cases so even though it's in the background the user
considers it as a foreground app. We can check if the app trying to
access the microphone currently has a voice interaction session which
should be a good indicator that the user intends to user the app.

Test: Use the assistant, observe dialog
Bug: 178243539
Change-Id: Ie17f6e47a002e75467cce23fd74f5fcbc92aa577
2021-05-18 14:02:04 -07:00
TreeHugger Robot
c0f1de7c5c Merge "API review : use a range of numbers for OEM errors" into sc-dev 2021-05-13 18:17:52 +00:00
Ahaan Ugale
d579a8ee6e Nullability fixes for HotwordDetectionService APIs.
* Make the Hotword*Result payloads NonNull. HotwordDetectedResult on the
  VoiceInteraction side is still @Nullable since the EventPayload is
  used for other result types too.
* Remove @NonNull for a primitive return type.

Bug: 184962614
Test: atest CtsVoiceInteractionTestCases
Change-Id: Ib57368dab442f80805233864dc8fd86249f677cf
2021-05-12 13:06:31 -07:00
lpeter
f79009a5d7 API review : use a range of numbers for OEM errors
By API review feedback, it would be better to use a range
of numbers for OEM errors instead of just defining
CUSTOM_ERROR_1 / CUSTOM_ERROR_2 in HotwordDetectionService.

Bug: 184962614
Test: atest CtsVoiceInteractionTestCases
Test: atest CtsVoiceInteractionTestCases --instant
Change-Id: Id1e3a29e37ef566a1d8e30c703b7f2c4ae138f82
2021-05-12 17:39:00 +08:00
lpeter
044ca5adfa Close audio source after getting callback from HotwordDetectionService
Due to the file descriptor of audio source was closed before
the attempt to parcel the file descriptor when passing the
file descriptor to the HotwordDetectionService.

It will cause the exception below:
java.lang.RuntimeException: Bad file descriptor

It would be better to close audio source when getting
callback from HotwordDetectionService

Bug: 185569471
Test: atest CtsVoiceInteractionTestCases
Test: atest CtsVoiceInteractionTestCases --instant
Change-Id: I10774fd29d559b5d2bedc21b0ebb2ef849a1b7c6
2021-05-04 16:22:09 +08:00
Ahaan Ugale
35f28d1bb2 Leverage new Audio history sharing for HotwordDetectionService.
The Audio Framework now supports sharing audio history, so
VoiceInteractionManagerService no longer needs to handle audio streams
itself.
See I5beba6c1e489148a14ba86165b8ef2fdc78c802a.

Bug: 168305377
Test: atest CtsVoiceInteractionTestCases
Test: manual
Change-Id: Ia7c5830aa5af6c015ae26619e0a90967ddff74e5
2021-04-26 07:50:01 +00:00
TreeHugger Robot
3346694817 Merge "Add TestApi to trigger the onDetect function of HotwordDetectionService" into sc-dev 2021-04-20 09:23:33 +00:00
Sergey Volnov
f421bf17fc Allow HotwordDetectionService to obtain ContentCaptureManager.
This would allow pushing data into sandboxed ContentCaptureService.

Bug: 168305377
CTS-Coverage-Bug: 183425641
Test: atest CtsVoiceInteractionTestCases
Change-Id: I798b4f525a5707d4c97ae525ed69bd3864cb261d
2021-04-19 14:23:40 +01:00
lpeter
afef0beebf Add TestApi to trigger the onDetect function of HotwordDetectionService
Bug: 184685043
Test: atest CtsVoiceInteractionTestCases
Test: atest CtsVoiceInteractionTestCases --instant
Change-Id: I531c1229de908c64e29f1976bd2fd1e70e545853
2021-04-19 14:22:38 +08:00
lpeter
f08559cf43 Set correct audio source when creating mic audio record
Bug: 185223459
Test: atest CtsVoiceInteractionTestCases
Test: atest CtsVoiceInteractionTestCases --instant
Change-Id: Iad79066eb66ecb02497be926a467b3726e467a5c
2021-04-14 21:25:16 +08:00
Bhalchandra Gajare
ab5fedc682 AudioAttributes: update setHotwordMode to setHotwordModeEnabled
Update setHotwordMode to setHotwordModeEnabled and set/clear the hotword
mode based on the boolean flag passed to setHotwordModeEnabled. This is
to meet the API requirements. Also update the references to this API.

BUG: 180419637
Test: Able to setHotwordModeEnabled from AGSA application. Confirmed
HAL receives the flag and audioSource correctly in open_input_stream.

Change-Id: Ia01e8b5f3edaeafc9617846efc247635005456a8
2021-04-09 02:29:42 -07:00
Peter Li
2fa9e7823e Merge "Implement timeout mechanism when HotwordDetectionService initializes" into sc-dev 2021-04-09 04:25:46 +00:00
lpeter
9c9f5aa6a1 Implement timeout mechanism when HotwordDetectionService initializes
Bug: 183684347
Test: atest CtsVoiceInteractionTestCases
Test: atest CtsVoiceInteractionTestCases --instant
Change-Id: I77d29491b055ee2a45aa088df4c1cd54e604c259
2021-04-07 12:23:42 +08:00
Nicholas Ambur
ff66bbffac rm permission from getActiveServiceComponentName
remove the ACCESS_VOICE_INTERACTION_SERVICE permission from
VoiceInteractionManagerService.getActiveServiceComponentName

Test: build and verify no stability impact
Bug: 173122149
Change-Id: I9e42b7b6e205ec352b3cfbac51022dd7594d1d0f
2021-04-06 13:14:42 -07:00
Ytai Ben-Tsvi
60a49f1b3b Reduce severity of SoundTriggerService error messages
Errors resulting from misuse by the client are considered warnings.

Test: Compiles
Bug: 181269159
Change-Id: Ib81397706a137a41f12810b8b63548170ce855bc
2021-03-31 14:27:06 -07:00
Ytai Ben-Tsvi
def517ec04 Improve permission enforcement in SoundTriggerService
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
2021-03-31 14:24:54 -07:00
lpeter
6f2a263810 Add callback to report HotwordDetectionService status
Bug: 182788844
Test: Test: atest CtsVoiceInteractionTestCases
Test: atest CtsVoiceInteractionTestCases --instant
Change-Id: I12f0a265fc4fce0bbfe0983f39b4dcd947e3cf64
2021-03-29 17:41:24 +08:00
Ahaan Ugale
5395b1a47f Merge "Unset default reco if selectableAsDefault=false." into sc-dev 2021-03-26 19:27:58 +00:00
Sergey Volnov
baceb11e71 Introduce the concept of software and external hotword.
Follow-up: implement circular buffer and integrate with the flows.

Bug: 182788844
Bug: 168305377
CTS-Coverage-Bug: 183425641
Test: atest CtsVoiceInteractionTestCases
Change-Id: I654a06afb27bb961bfb547a6636e08eb72a031fc
2021-03-26 00:10:44 -07:00
TreeHugger Robot
d5dc9e47a4 Merge "Unhide api for setHotwordDetectionServiceConfig" into sc-dev 2021-03-25 03:49:32 +00:00
Ahaan Ugale
50261c6ae9 Unset default reco if selectableAsDefault=false.
A non selectableAsDefault recognition service can still become the
default if no other services are available.

Bug: 180964085
Test: non selectableAsDefault reco is unset at boot and replaced
Test: selectableAsDefault recos aren't affected
Test: system default reco still works
Change-Id: I429e6e457bc81ef0642ca90ccd9eb47eb10fbab8
2021-03-25 03:05:28 +00:00
Nicolò Mazzucato
745af612b6 Merge "Fix onHandleAssist behaviour when showSession is called with flags = 0" into sc-dev 2021-03-24 10:11:30 +00:00