Commit Graph

508 Commits

Author SHA1 Message Date
Daniel Kim
4e528edd31 Merge "Disable proximity result for hotword" into tm-qpr-dev 2022-09-26 08:12:46 +00:00
Nicholas Ambur
0cf35e854e Add Logging of the UI Latency for hotword invocation
Log the UI latency with UIActionLatencyReported atom. We plan to
calulate the latency from when the SoundTrigger HAL emits an event to
when the VoiceInteraction system UI view is shown.

Test: device_config put latency_tracker enabled true; verify traces
and latency is logged in WW.
Bug: 247879896

Change-Id: I3edb91691e81f8f23660c0823a6388338fe926ad
2022-09-23 18:13:14 -07:00
Daniel
4dd69f2ebb Disable proximity result for hotword
Introducing a flag to gate the Attention Service usage by Hotword
Detection Service. The Attention Service will be disabled by default.

Bug: 247890608
Test: atest CtsVoiceInteractionTestCases
Change-Id: Ic8a6a11b2a0843a96f135b360f10f7fef5fce274
2022-09-22 22:55:09 +00:00
Daniel Kim
dda0c6d0a5 Revert "Revert "Refactor ProximityUpdateCallbackInternal to inte..."
Revert submission 19600381-revert-17936037-hotword_proximity-ZZIDPDULZP

Test: atest CtsVoiceInteractionTestCases, atest CtsVoiceInteractionTestCases:android.voiceinteraction.cts.AlwaysOnHotwordDetectorTest#testAlwaysOnHotwordDetector_startRecognitionWithData -- --abi x86_64
Reason for revert: Including the fix for broken tests
Reverted Changes:
Ibfc659015:Revert "Refactor ProximityUpdateCallbackInternal t...
I1a03c21d5:Revert "Verify that proximity key is added to the ...
I6b79d9400:Revert "Add proximity state to the HotwordDetected...

Change-Id: Iee6ab086ccc3f27b95ee601d6be11231f300170c
Merged-In: Iee6ab086ccc3f27b95ee601d6be11231f300170c
2022-08-15 22:46:52 +00:00
Daniel Kim
aa972f2c88 Revert^2 "Add proximity state to the HotwordDetectedResult"
Reverting the previous revert commit which was merged to resolve the
broken tests. Adding a fix to the broken tests by surrounding
mAttentionManagerInternal with null checks.

dbe5ad1a72

Test: atest CtsVoiceInteractionTestCases, atest CtsVoiceInteractionTestCases:android.voiceinteraction.cts.AlwaysOnHotwordDetectorTest#testAlwaysOnHotwordDetector_startRecognitionWithData -- --abi x86_64
Change-Id: Ife5fb9220518a32a89494217f56932f290cce5f3
Merged-In: Ife5fb9220518a32a89494217f56932f290cce5f3
2022-08-15 22:45:55 +00:00
Felipe Leme
88f2307219 Fixed VIMS to postpone ASSISTANT rule change on pre-created users.
RoleService should not be calling onRoleHoldersChanged() on
pre-created users, but that behavior cannot be changed because its
implemented by a system app, and pre-created users APIs are hidden.

To test it:

$ adb shell pm create-user --pre-create-only  --guest
Success: created user id 12

$ adb shell pm create-user --guest ElGuesto
Success: created user id 12

$ adb shell cmd user list --all -v
4 users:

0: id=0, name=Driver, type=system.HEADLESS, flags=ADMIN|INITIALIZED|PRIMARY|SYSTEM (running)
1: id=10, name=Driver, type=full.SECONDARY, flags=ADMIN|FULL|INITIALIZED (running) (current)
2: id=11, name=null, type=full.SECONDARY, flags=FULL|INITIALIZED (pre-created)
3: id=12, name=ElGuesto, type=full.GUEST, flags=EPHEMERAL|FULL|GUEST|INITIALIZED (converted)

$ adb shell am switch-user 12

$ adb shell dumpsys voiceinteraction |egrep '(mBound|implementation)'
  mBound=true mService=android.service.voice.IVoiceInteractionService$Stub$Proxy@77da1bc

$ adb shell cmd voiceinteraction show

Test: see bove
Bug: 216141085
Bug: 226201975

Merged-In: I12d9bb32e144ecf91ee4b452affea0dcea546127
Change-Id: I12d9bb32e144ecf91ee4b452affea0dcea546127
(cherry picked from commit 39acca1d72)
2022-08-03 16:03:02 +00:00
lpeter
33694beb37 Add metrics for software and external source detections.
We add more metrics for software detection and
external source detection.

Android Metrics Design Review : eldar/276723226

Verify the metrics logs manually as below:

Step 1: m statsd_testdrive
Step 2: statsd_testdrive 434
Step 3: run the test
Step 4: We can see the log as below after 1 minutes from Step 2.

hotword_detector_events {
    event: EXTERNAL_SOURCE_DETECTED
}

hotword_detector_events {
    event: ON_DISCONNECTED
}

hotword_detector_events {
    event: START_EXTERNAL_SOURCE_DETECTION
}

Bug: 207717787
Bug: 233704035
Test: build pass
Test: manual. The logs are expected after following test steps
Change-Id: Ib268902d63c580cec9cbd65a3816fd5ba003eaff
(cherry picked from commit 37f8b3ec2b)
2022-06-16 08:54:54 +00:00
Jack Wang
7adc7ef75c Merge "Grant client app visibility with UID from activity record" into tm-dev am: 7a1dd2e61c am: ac7d47c9a8
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18674418

Change-Id: Iabddbfdd1e73f4657a41e6bc6a8575f6e90ad044
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-06 18:43:36 +00:00
Jack Wang
7a1dd2e61c Merge "Grant client app visibility with UID from activity record" into tm-dev 2022-06-06 16:10:48 +00:00
Jack Wang
d2b102f072 Grant client app visibility with UID from activity record
this also fixes an NPE b/234828308

Bug: 226167520
Test: atest android.voiceinteraction.cts
Change-Id: Ibe20fb4da91fa80f8539bb19c90515167bf6e85b
Merged-In: Ibe20fb4da91fa80f8539bb19c90515167bf6e85b
2022-06-06 16:10:29 +00:00
TreeHugger Robot
199d93fd54 Merge "Postpone the request direct actions before onStart" into tm-dev am: 0d84708056 am: cf05c79ea0
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18628126

Change-Id: Ibbfcc51b996298ce0880e4a95dbbb042aedeb75d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-01 04:11:34 +00:00
TreeHugger Robot
0d84708056 Merge "Postpone the request direct actions before onStart" into tm-dev 2022-06-01 03:29:35 +00:00
lpeter
f8342c8db5 Postpone the request direct actions before onStart
By the original design, we register the activity event in the
ActivityManagerService. After getting the activity event, we will
query current visible activities and report them to Assistant.
Assistant will start to get direct actions of those visible
activities. But sometimes they can not get the direct actions
due to the stage of activity lifecycle before onStart().

We will postpone the request direct actions a few times
before onStart().

Bug: 224789902
Test: atest CtsVoiceInteractionTestCases
Change-Id: If7cd52c5ba749523e575c0be5595e8f20704c4f2
2022-05-31 14:59:42 +08:00
TreeHugger Robot
72d9e091c4 Merge "Add support for onReject and onError for external hotword." into tm-dev am: 90579f32b3 am: 5ec4c563ce
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18308197

Change-Id: Ic3ec74aaaa851b3860e7bddcab1decc9a9db34e1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-26 17:46:37 +00:00
TreeHugger Robot
90579f32b3 Merge "Add support for onReject and onError for external hotword." into tm-dev 2022-05-26 17:14:11 +00:00
Jack Wang
adfba5d6e1 Merge "Grant visibility of voice interaction to the client app" into tm-dev am: b92b97dd6d am: 22b5b92afc
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17730109

Change-Id: Iea6c6ceebc9f4c1aa9def20d98d611909cabb182
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-25 00:33:34 +00:00
Jack Wang
4e953590d0 Grant visibility of voice interaction to the client app
There are three event in which a client app is started:
1. When Assistant starts Voice Activity (startVoiceActivity)
2. When Assistant requests for a Direct Actions (requestDirectActions)
3. When the app starts invoice interation session
   (startLocalVoiceInteraction)

Change-Id: I261ccc1a7136a601b5c8c8b766dc03a024cfe93d
Test: atest android.voiceinteraction.cts
2022-05-24 20:27:44 +00:00
Sergey Volnov
be0edce59a Add support for onReject and onError for external hotword.
Bug: 230658902
Test: atest --no-bazel-mode CtsVoiceInteractionTestCases:HotwordDetectionServiceBasicTest
Change-Id: Ic845f06c2e3943f4968067dd23a0520aecce3973
2022-05-24 01:39:21 +01:00
TreeHugger Robot
863abc6c0d Merge "Start to count the init time from calling updateState function" into tm-dev am: 9f4fb486d8 am: dc2a680bea
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18400689

Change-Id: Ic5ba9900635284f1dadf59aded5bc01c4d5b25f2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-19 09:31:49 +00:00
lpeter
8de8268420 Start to count the init time from calling updateState function
Bug: 233011234
Test: atest HotwordDetectionServiceBasicTest
Change-Id: Ie2e426cb6f6168a2a704dd934d949047436e7826
2022-05-19 11:03:40 +08:00
TreeHugger Robot
0c0231e1c6 Merge "Inform Assistant when security exception occurs during onDetected" into tm-dev am: d5cd970e0c am: 16d458b618
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18179574

Change-Id: Ic514a20d9c5a948110e3af82757efd21d92f3ea1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-13 08:50:09 +00:00
TreeHugger Robot
d5cd970e0c Merge "Inform Assistant when security exception occurs during onDetected" into tm-dev 2022-05-13 03:19:48 +00:00
Peter Li
e6bbe4660e Inform Assistant when security exception occurs during onDetected
By the behavior, the interactor of assistant needs to call the
startRecognition function again after hotword event is triggered.
Otherwise it will not receive the result of detection.

Currently when security exception occurs during onDetected, we
won't inform the interactor of assistant about the hotword event.
It will cause the interactor still to wait the hotword event and
doesn't call startRecognition function again.

After syncing with assistant, we should use onError() callback
to inform interactor.

The behavior of onError() in the interactor:
For both of DSP and Software, assistant will call startRecognition
function.

The behavior of onRejected() in the interactor:
Only for DSP, assistant will call startRecognition function.
For Software, assistant doesn't expect to get onRejected()

Bug: 230738063
Test: atest HotwordDetectionServiceBasicTest
Change-Id: I3083fd5a4a78ad9d2f35acd7fa1a4f2036cf64de
Merged-In: Ideb210d4364d4c48c747d66268d77a2f5b017186
2022-05-12 09:50:08 +00:00
Joanne Chung
4dc13e47d8 Merge "Fix Assistant breaks after stopping the app." into tm-dev am: 4c41912939 am: 7031a7817e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17651837

Change-Id: I7c014e9f2366e97a57e647f5bdeb3562cb15c9d4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-04 05:29:03 +00:00
Joanne Chung
4c41912939 Merge "Fix Assistant breaks after stopping the app." into tm-dev 2022-05-04 04:08:18 +00:00
Joanne Chung
8edc50d8bf Fix Assistant breaks after stopping the app.
Android 13 introduces a feature that allows users to kill foreground
services that will break the home screen mic function. The root cause
is because we don't handle the binding die case. Ideally we should
migrate the force stop, package update cases to onBindingDied but we
would like to minimize the risk before release. From the fgs task
manager description, we can check new REASON_USER_REQUESTED reason on
ApplicationExitInfo, we only handle this case to rebind the service
to minimize the scope.

Bug: 225166047
Test: atest CtsVoiceInteractionTestCases
Test: manual. The function still works after adb shell cmd activity
stop-app com.google.android.googlequicksearchbox

Change-Id: Ia8395fc6f7b6df36b158f0578d57d948748a43b3
2022-05-03 21:09:51 +08:00
Ahaan Ugale
f51a7392ec Merge "RESTRICT AUTOMERGE Disable the Trusted Hotword requirement" into tm-qpr-dev 2022-05-02 23:37:44 +00:00
Ahaan Ugale
2fd599b2bb 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 mic 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: 228092460
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
(cherry picked from commit 3f961f24f4)
2022-05-02 23:36:58 +00:00
Ahaan Ugale
44e14e72b6 Merge "Allow IVoiceInteractionSessionListener to listen for window vis changes" into tm-dev 2022-04-27 17:03:31 +00:00
Winson Chung
06fb230d6d Allow IVoiceInteractionSessionListener to listen for window vis changes
- The listener currently tracks session shown/hidden, but doesn't track
  the visibility of the session window which can change on the client
  side without the server knowing. In some cases, it's useful for SysUI
  to be able to track the visibility of the session window to show/hide
  bars appropriately.

Bug: 222308557
Test: Manual, launch the assistant and verify the calls are made
Change-Id: I9b4bb27c9497b2a828616caf72eaf345b072c294
2022-04-23 05:56:27 +00:00
Peter Li
f11f969973 Extend the timeout of update state
Bug: 207717787
Change-Id: Iaeea0917ce4aa363cd5889379580aa77c05b43bf
Test: atest HotwordDetectionServiceBasicTest
2022-04-19 17:37:19 +08:00
TreeHugger Robot
5e1904c323 Merge "Add and update some hotword detection metrics" into tm-dev 2022-04-12 23:11:32 +00:00
lpeter
ee5e2a7a3f Add and update some hotword detection metrics
We use "DETECT_EXCEPTION" in three different places, it is difficult
to distinguish what is realy happening. We use different metrics values
to replace them. And we also add a new metrics value to log onRejected
when the trusted process is restarted.

Android Metrics Design Review : eldar/276723226

Bug: 207717787
Test: build pass
Change-Id: Ib631bac3e5d6663c7eb64f54516b86b7fd9b8144
2022-04-12 18:27:12 +08:00
Ytai Ben-Tsvi
f3e7be0058 Wait for an abort event when stopping a model
Because the client callbacks from SoundTriggerMiddleware service are
async, if a client quickly stops and starts a model, then receives a
detection event for that model, it is impossible for it to tell
whether the event corresponding to the previous or current session,
and thus is unable to reason about the resulting state of the model.

To mitigate that, we will always wait for an abort event when a model
is stopped before any other operation is attempted. This way the
model state stays synchronized.

Bug: 191935600
Fixes: 226926627
Test: Manual verification of soundtrigger use-cases. Specifically,
      quick toggling of Assitant and Now Playing via Settings.
Change-Id: Ia1b91e78aa6981a7b3612ae9213af1b37a333d00
2022-04-11 11:55:20 -07:00
Ytai Ben-Tsvi
64c62ca506 Revert "Wait for an abort event when stopping a model"
This reverts commit 6e2eb81ac4.

The original commit fixed b/223922855, which resulted from fixing
b/191935600, but created another.
Blocking the stop() call until the event confirming the stop arrives is
a bad idea, since:
- We have to give up the lock when waiting for the event, and thus lose
  the atomicity of some of the operations. b/226926627 is an example of
  this.
- It turns out some of the forward calls happen from the main thread's
  looper, which is also used for callbacks, and we risk deadlocks.

A follow-up commit will address the fix in a better way.

Bug: 191935600
Bug: 226926627
Bug: 223922855
Test: See next commit in the chain.
Change-Id: I2b9987ae93803d3b4f72a1df56c88e284bed43c5
2022-04-11 11:32:44 -07:00
Joanne Chung
b9fe1923d9 Fix finishTranslation doesn't work if start Activity in the same task
If the app starts a new Activity in the same task then the
finishTranslation() is called, the finish translation doesn't work
because our logic is to check if task top Activity is our expected
translation Activity. In this case, the top Activity is the new
Activity, the original Activity is paused in the same task. To fix
the problem, we get all non-finishing Activities in the task and
check if the target Activity in this task.

Bug: 202570916
Test: atest UiTranslationManagerTest
Test: atest CtsVoiceInteractionTestCases
Test: atest CtsAssistTestCases

Change-Id: I2471e04b894890777e13dd45c290f059dbe5f487
2022-04-08 20:34:08 +08:00
Joanne Chung
b6e44763bd Allow to update restart period dynamically.
We use a flag to control the restart period time, the value is static
and set in class level that means if we update the device config, we
should reboot the device to get the updated value.

This change reads the value in the constructor, so the value will be
updated when the voice interaction app updates no need to reboot.
Ideally it's good to listen the value change dynamically but it
increases the complexity here, we provide a workable and safe change
now.

Bug: 224618257
Test: update the package and the value is expected by command:
adb shell dumpsys voiceinteraction | grep RESTART_PERIOD_SECONDS

Change-Id: Id7d5f2d4f17de1f36baf6509598a82d6d73c5b53
2022-04-06 10:58:11 +08:00
Oscar Azucena
3ae3376064 Added logic to reset assistant UIDs on audio crash
On native audioserver recovery the assistant UIDs will reset to an empty
list, followed by adding the current role or setting holder for
assistant. Also added a settings lock around the update assistant
method. Added remove assistant UID for reset hotword detection
connection.

Bug: 222584963
Bug: 222777782
Test: atest VoiceInteractionTest
Test: atest AudioManagerTest
Test: atest HotwordDetectionServiceBasicTest
Test: kill audio server and verify assistant UIDs is not increasing
	unbounded.
Test: adb shell cmd voiceinteraction restart-detection, verify assistant
	UIDs list is not increasing unbounded.
Change-Id: I475bfee1f0bcd56a750e4fef8aa8a2b93fe090fc
2022-03-24 04:37:55 +00:00
Ytai Ben-Tsvi
d2185bf42c Check for null callback
The modelData callback may be nullified before actually being invoked,
e.g. when calling startRecognition() on an already running model, with
a different callback.

Fixes: 225768984
Test: Manual reproduction on the issue and then applying the fix and
      verifying that it works.
Change-Id: I089061123c8cf12eef19fdf16bb3a2c106ea2438
2022-03-21 15:10:04 -07:00
Ytai Ben-tsvi
9197321f90 Merge changes from topics "presubmit-am-396588a7c76a4caab06560123f7aa31f", "presubmit-am-5d32ede90d0f47cea969e97e31951f5a", "presubmit-am-fe95e604ee2242fe949cc5ad13c15af1" into tm-dev
* changes:
  Wait for an abort event when stopping a model
  Generate an abort event when stopping
  Extract some event utilities
2022-03-18 20:56:24 +00:00
Ytai Ben-Tsvi
6e2eb81ac4 Wait for an abort event when stopping a model
Because the client callbacks from SoundTriggerMiddleware service are
async, if a client quickly stops and starts a model, then receives a
detection event for that model, it is impossible for it to tell
whether the event corresponding to the previous or current session,
and thus is unable to reason about the resulting state of the model.

To mitigate that, we will always wait for an abort event when a model
is stopped before any other operation is attempted. This way the
model state stays synchronized.

Fixes: 191935600
Test: Manual verification of soundtrigger use-cases. Specifically,
      quick toggling of Assitant and Now Playing via Settings.


Change-Id: I010558e8fa1891922f20dcdb7b0ca04c9500c2e1
2022-03-17 14:07:06 -07:00
Peter Li
95e2fcd838 Update hotword detection metrics.
Bug: 215630960
Change-Id: I93512c8e6c7e2f3fff1fb38c974e763489a8e00d
Test: build & boot pass.
2022-03-17 08:51:33 +00:00
Joanne Chung
46e6944804 Use flag to control the restart period value.
Bug: 224618257
Test: adb shell cmd device_config get/put voice_interaction \
restart_period_in_seconds works fine
Test: the value is expected by command: adb shell dumpsys \
voiceinteraction | grep RESTART_PERIOD_SECONDS

Change-Id: Icd8d19c2a482d0d6b9bf0432e2176ca10f3bd2eb
2022-03-15 12:10:14 +00:00
Ahaan Ugale
b8cd0a4286 Trusted Hotword: Disable periodic restarts.
Mitigates quality risk that may arise due to mismanaged state around the
restarts (either on the platform or application side).

Restarts will be flag-controlled and ramped back up later.

Bug: 224618257
Test: manual
Change-Id: I3b17b47fab4120b42d75443b213be3c1ef5491aa
2022-03-15 15:57:57 +08:00
Joanne Chung
e4b76fc200 Add hotword detection metrics.
Bug: 207717787
Test: build & boot pass.
Test: manual. Both trust and no-trust still work.
Test: manual. In nornal case, log with expected values, see bug for
details. Log expected value for some error cases (not all are tested)
by local changes.

Change-Id: Iaa778616eca4cfad83a94297d9cd6116bb9577e7
2022-03-10 09:06:18 +00:00
Joanne Chung
70bbc8e6a1 Merge "Add HotwordMetricsLogger for statistics logging." into tm-dev 2022-03-08 15:59:58 +00:00
Joanne Chung
e13c17d233 Add HotwordMetricsLogger for statistics logging.
This change only provide a utilility class to help hotword dection
metrics logging. The log writing will on the follow up changes.

Bug: 207717787
Test: build pass can boot success
Change-Id: If436aae1b4ebdb06c7bd5a1c0b8d6df4e94488cd
2022-03-08 09:37:01 +00:00
Sergey Volnov
6db1879a19 Limit HotwordDetection process number to 10
Bug: 216095923
Test: existing CTS tests
Change-Id: I73d12ad84e2dce108dcc923c6ad400a2a1bdddd6
(cherry picked from commit bef5d91b67)
2022-03-07 10:58:47 +00:00
TreeHugger Robot
16a227c1a4 Merge "Add getPackageName to VoiceInteractor" 2022-02-12 02:29:50 +00:00
Lee Campbell
99589ebc0f Add getPackageName to VoiceInteractor
Adds a new API to VoiceInteractor to allow apps to query
the package name of the Voice Interactor associated with
this the current voice interaction

BUG: 192061561
CTS-Coverage-Bug: 218687104
Test: Manual validation from personal and work profiles

Change-Id: If381c38498535bf94d13c0b5ad5f6c4fa5495117
2022-02-11 16:42:38 +00:00