Commit Graph

213 Commits

Author SHA1 Message Date
James O'Leary
9c9dd98ee0 Encapsulate state & transcription in hints bundle
Continuation of ag/6226654; edits made per Svetoslav's last comments.

Bug: 122740752
Bug: 123080754
Test: blueline-userdebug build completes successfully.

Change-Id: I3e43137eb6e0d8cae77e14d331150d5a05ede07c
2019-02-14 15:24:08 +00:00
Hai Zhang
5cc4ae9538 Fix assistant role for multi-user.
We need to modify settings based on the user passed in.

Bug: 123527682
Test: manual
Change-Id: I998fa61aa4364a028117cd4bb787d934c60661a1
2019-02-08 11:42:34 -08:00
James O'Leary
596708b973 Only selected VoiceInteractionService can call methods
- Extract current code for checking caller into a private method
- Replace occurrences of that code with a call to the private method
- Add method call to setTranscription/clearTranscription/setVoiceState

Test: Verified Milford can't call setTranscription/clearTranscription
when it is no longer the active service.
Bug: b/123412646

Change-Id: I2c428c6c65b62f6a83264286df4f44fb5d1c249e
2019-02-01 02:21:58 -05:00
Philip P. Moltmann
a0f377fbe8 Merge "Set assistant as a role" 2019-01-24 20:51:41 +00:00
Michael Dooley
c89d8db61d Merge "Treat getModelState recognition events the same as regular recognition events." 2019-01-24 16:57:45 +00:00
mike dooley
9b20c1cda4 Treat getModelState recognition events the same as regular recognition
events.

This change should have been part of ag/5933708

Test: manual test with NowPlaying app on p19 device

Change-Id: I42ed7c17ebdd2cb75055122b8d45302e28c510b6
2019-01-24 08:17:13 +01:00
Philip P. Moltmann
5d894505f7 Set assistant as a role
- Register a role observer in VoiceInteractionManagerService. Once the
role is changes map the new role setting onto the old settings.
- As the assistant role is now always set, there is no need to have code
in AssistUtil for the case the assistant setting is not set
- Remove old config option for the default assistant. The default
assistant is not configured via the roles config

Bug: 110557011
Test: - Set, unset and swtiched assistant via the settings UI
        - for voice interaction service
	- for assist activity
      - Booted from freshly wiped device and saw assitant to be set to
        default
Change-Id: I8596f49c6f6496e8b70cf3236aaa7d7557443a93
2019-01-23 13:05:32 -08:00
Matt Casey
4cff16fda9 Voice state + transcription in VoiceInteractionSvc
Voice state as well as voice transcription can be provided by the
VoiceInteractionService. These get proxied to the AssistManager which
can update the system UI to reflect the state & transcription.

Test: TBD
Bug: 122740752
Bug: 123080754
Change-Id: I79cac1d89fe0123bf25a05d551cb4ef40ae1368e
2019-01-23 20:03:05 +00:00
Robin Lee
ba3af56aaa Let low-ram devices override voice recognisers on
The top-level framework overlay already says this should (by default) be
skipped if the device is low-ram (leaving the device able to turn it
back on again without committing to a specific voice recognizer at build
time):
  <feature name="android.software.voice_recognizers" notLowRam="true" />

The form factor-specific overlay for tablets does override this back to
a state where the feature is always enabled regardless of low-ram:
  <feature name="android.software.voice_recognizers" />

But this is probably a mistake as the code before this change ignored
the feature flag anyway in case of a low-ram device, using a hardcoded
check.

Lets Android TVs have voice recognisers working on all devices by
default without needing to set katniss' package as a force override.

Bug: 117630721
Test: flashall ; adb logcat | grep VoiceInteractionService
Change-Id: I7816bebbc363ae0751b097fe1b6cdc2a646b20e0
2019-01-15 08:53:48 +00:00
mike dooley
da48092c9b Make framework treat getModelState recognition events the same
as regular recogntion events

The application will differentiate between DSP and app triggered
regcognition events.

Test: manual test with STTA and NowPlaying app on p19

Bug: 119386757

Change-Id: I4a3eb4da6ee6be35084fec8aaa3c495423d74033
2019-01-08 10:58:23 +01:00
Michael Dooley
91a94d76bf Merge "Fixing getModelState event processing" 2018-12-21 07:05:01 +00:00
mike dooley
23c625677d Fixing getModelState event processing
Test: manual testing with SoundTriggerTestApp

Bug: 119386757

Change-Id: I2c2960d169b119cb35345315638eeae28460896c
2018-12-20 16:48:53 +01:00
Dianne Hackborn
3d7ab61b02 Fix issue #121104681: Force stopping AGSA causes system to revert to its default impl
If you have a legacy assist app (launched through ACTION_ASSIST, not
implementing a VoiceInteractionService) then we kept the Google app
as the current speech recognizer.  Thus if you force stopped the
Google app, we saw that as one of the active parts of the interactor
or recognizer and reset all of the state.

Now we handle the "only recognizer" case separately, only resettting
the recognizer state in that case.

Bug: 121104681
Test: manual
Change-Id: Icc007bdf2352548d58be997fae77d9e5aba842f3
2018-12-17 11:45:32 -08:00
mike dooley
b2ab04aefd Converting sound trigger v2.2 getModelState to be asynchronous
Test: built android with checkbuild flag

Change-Id: I4c6f2388c93b6e577113fc7f2cd19242628ee50f
Bug-Id: 70206501
2018-11-09 08:36:15 +01:00
Michael Dooley
291751e510 Revert "Revert "Adding getModelState API to sound trigger""
This reverts commit 81f71f1c27.

Reason for revert: rolling forward with fix

Change-Id: Ifc0c53581ac567cb968d91993f453220f8253aec
2018-10-23 07:44:51 +02:00
Michael Dooley
be93d52505 Revert "Revert "Revert "Adding getModelState API to sound trigger"""
This reverts commit 7999836ee3.

Reason for revert: broke build

Change-Id: Id02636908aed26ee0ed38042da1ace0125a6d417
2018-09-28 07:30:28 +00:00
Michael Dooley
7999836ee3 Revert "Revert "Adding getModelState API to sound trigger""
This reverts commit 81f71f1c27.

Reason for revert: undoing rollback

Change-Id: Ifddfd0c730f03e93788d662a392d538564ce210b
2018-09-21 12:13:01 +00:00
Yuzhou Jia
35339498ef Merge "Make Changes to VoiceInteraction API for supporting System checking an assistant voice action availability on AAE." 2018-09-20 01:02:44 +00:00
jiayuzhou
21a353b701 Make Changes to VoiceInteraction API for supporting System checking
an assistant voice action availability on AAE.

Test: build and test on AAE.
Bug: 110587280

Change-Id: If37036e0dbe021fee9c95caf7e450330ca24ae32
2018-09-19 10:21:59 -07:00
Michael Dooley
c106550132 Merge "Revert "Adding getModelState API to sound trigger"" 2018-09-14 16:21:17 +00:00
Michael Dooley
81f71f1c27 Revert "Adding getModelState API to sound trigger"
This reverts commit 4f809fe73e.

Reason for revert: fix build breakage

Change-Id: I75a54189f96fc21f6cb12dd8a05e513b1bda027c
2018-09-14 16:09:18 +00:00
Michael Dooley
a707ba1cb0 Merge "Adding getModelState API to sound trigger" 2018-09-14 12:32:09 +00:00
Andreas Gampe
8ce7ed95a0 Frameworks: Annotate trivial @GuardedBy in services
Add @GuardedBy for simple functions that require locks and have a name in
one of the frameworks naming styles for locks ("^.*(Locked|LPw|LPr|L[a-zA-Z]|UL|AL|NL)$").

Derived by errorprone.

Bug: 73000847
Test: m
Change-Id: If70bb03313388af34d547efca20fb5115de95bf1
2018-09-05 17:02:08 -07:00
mike dooley
4f809fe73e Adding getModelState API to sound trigger
Test: built android
Bug-Id: 70206501
Change-Id: Ieb83a366d4ddd471186d5089efe0675ea6285454
2018-09-05 15:58:27 +02:00
Wale Ogunwale
6d50dcc8af Moved URI grants code out of ActivityManagerService to its own service (13/n)
Allows for other services like window manager to call uri grants without
holding AM service lock.

Bug: 80414790
Test: Existing tests pass.
Change-Id: Ie5b4ddb19a2cedff09332dbeb56bcd9292fd18ac
2018-07-23 16:37:46 -07:00
Wale Ogunwale
f673393b93 Moved more stuff from ActivityManagerService to ActivityTaskManagerService (11/n)
Moved more stuff related to activities out of the current service to the new one.

Bug: 80414790
Fixes: 110988007
Test: Existing tests pass.
Change-Id: Iceed1da8a7441a26d11efebc6d9f692fd053bc7f
2018-06-29 23:51:01 +00:00
Wale Ogunwale
9e4f3e077f Introduced WindowProcessController/Listener (10/n)
One heavy dependence between the current AMS service and activities
is process management which is heavy affected by activities and their
current state. We introduce WindowProcessController and WindowProcessListener
objects as a structured way for the process changes in AM package to
be communicated to the WM package and WindowProcessListner for activity
changes in the WM package to the communicated back to the AM package.
The ProcessRecord object in AM will own the WindowProcessController object
and also implement the WindowProcessListener.

Test: Existing tests pass
Test: go/wm-smoke-auto
Bug: 80414790
Change-Id: I9e96e841b0f95e99a597cb4629fa5d2fe45760b6
2018-06-22 14:26:24 -07:00
Wale Ogunwale
a6191b4fa1 Moved more stuff from ActivityManagerService to ActivityTaskManagerService (9/n)
Moved more stuff related to activities out of the current service to the new one.

Test: Existing tests pass
Test: go/wm-smoke-auto
Bug: 80414790
Change-Id: I16863dd977bf09136cc23b0ab3aa197c613879ea
2018-06-21 15:11:21 -07:00
Wale Ogunwale
d0412b339b Switched ActivityRecord.service to ActivityTaskManagerService (5/n)
Objects that contain or represent activities like ActivityRecord can
no longer rely on ActivityManagerService as it is going to be in a
different package.

Test: Existing tests pass
Test: go/wm-smoke-auto
Bug: 80414790
Change-Id: I7eabc9b80e494367d79ff7452c88ba82ff216bcd
2018-06-17 18:11:42 -07:00
Wale Ogunwale
6767eaee94 Split internal interface activities from current AM interface (3/n)
3rd step in unifying the window hierarchy that is currently split
within AM and WM packages. We separate the the internal interface used
to communicate within system server dealing with activities and their
containers (tasks, stack, display) from the rest of AM internal
interface.

Test: Existing tests pass
Test: go/wm-smoke-auto
Bug: 80414790
Change-Id: Idad77721c1fe10621b9be5dced42a0a11f0183e5
2018-06-15 08:43:22 -07:00
Wale Ogunwale
04d9cb5f40 Moved some activities implementation to ActivityTaskManagerService (2/n)
Second step in unifying the window hierarchy that is currently split
within AM and WM packages. We move some of the API implementation for
activities from ActivityManagerService.java to
ActivityTaskManagerService.java.

Test: Existing tests pass
Test: go/wm-smoke-auto
Bug: 80414790

Change-Id: I23dcd924493d8ad1e0b6e3a55386fd72b0146605
2018-06-12 13:38:39 -07:00
Wale Ogunwale
65ebd955e1 Split interfaces and service for activities from current AM interfaces (1/n)
First step in unifying the window hierarchy that is currently split
within AM and WM packages. We separate the interfaces and service dealing
with activities and their containers (tasks, stack, display) from the
rest of AM interfaces and services. This will allow us to move the new
interfaces and services to WM when the internal states are cleaned-up.

Test: Existing tests pass
Test: go/wm-smoke-auto
Bug: 80414790
Change-Id: Ide9b3f89123b768cdbd3e3878113c7a8021187f3
2018-06-06 18:26:21 -07:00
mike dooley
82aaf21a54 Merge "Fixing a couple crashes in the SoundTriggerTestApp" into pi-dev am: 67890e0e1d
am: bbea1f436f

Change-Id: I4899434b32a6f2685fdbfe3d25a854917832f25d
2018-05-10 00:23:16 -07:00
TreeHugger Robot
67890e0e1d Merge "Fixing a couple crashes in the SoundTriggerTestApp" into pi-dev 2018-05-10 06:57:32 +00:00
Philip P. Moltmann
7108c33e3b Merge "Disable throttling of SoundTrigger" into pi-dev am: 1936031cbe
am: c7029fe7e0

Change-Id: Ifb78f41f756ac2002d12dc4e5de09dddef02f074
2018-05-08 12:31:31 -07:00
android-build-team Robot
cffc7c5b90 Merge "Simulate handling of event when throttling" into pi-dev am: 0458578642
am: 64bc4fab47

Change-Id: I2f87a69a1836cc9b109e78e49b3d0085bfb32b81
2018-05-07 18:03:42 -07:00
Philip P. Moltmann
3d1683be84 Disable throttling of SoundTrigger
Currently we don't have a way of throttling sound trigger events without
upsettings the DSP.

Bug: 78212455, 78310504
Test: Played music while having song detection enabled. Saw songs being
      detected

Change-Id: I3494d608f097532f02e6a588e22d9fe2d06048b1
2018-05-07 16:02:44 -07:00
Philip P. Moltmann
a5b4403a1f Simulate handling of event when throttling
When trottling we need to simulate handling of the event as otherwise
the DSP gets upset and SoundTriggerService and SoundTriggerHelper get
out of sync.

(1) Currently the DSP requires to open and release the AudioRecord if
a event was detected. Hence If we drop and event we need to do the
minimal version of that

(2) If a recognitions is set up with !allowMultipleTriggers the other
parts assume that as soon as one even is handled no further will be
needed. The other parts of the system are not aware of throttling.
Hence even when throttled we have to destroy the service when
!allowMultipleTriggers.

We do this by splitting the ops into three parts.

Setup (always executed): Takes care of problem (2) by checking the flag
and setting the destroy-once-ops-and-handled flag

Execute (not thottled): Send the op to the remote service

Drop (Trottled): Do what is needed if the remote service is not
involved. This handled issue (1)

Test: Caused throttling and saw - AudioRecord started and released
                                - service connection destroyed
Bug: 78212455

Change-Id: I0ff81a7b38d07db1365be7ecc44e93cf329b32d5
2018-05-04 13:59:45 -07:00
TreeHugger Robot
63b534768e Merge "Remove PendingIntent based soundTrigger" 2018-04-25 21:29:06 +00:00
mike dooley
cabbb11c01 Fixing a couple crashes in the SoundTriggerTestApp
Bug: 78269975
Test: built and ran the SoundTriggerTestApp
Change-Id: I966550a3d64e9f6a66c40e062a89f39b897aaea2
2018-04-19 15:57:06 +02:00
Philip P. Moltmann
09dd8c47d8 Properly disconnect after skipping an operation.
If we skip an operation we used to just return. This lead to the service
staying connected, holding the wakelock and consuming power.

Hence after we skip an operation we need to check if we can disconnect
the service, basically treating skipping an operation similar failing
to execute the operation.

Fixes: 77766977
Test: Detected music via sound trigger service and triggered dropping of
operations

Change-Id: Ia837d628193b3a5c2763f4aae666193d624b6d7f
2018-04-11 09:23:19 -07:00
Philip P. Moltmann
19402f557b Remove PendingIntent based soundTrigger
How that we have the SoundTriggerDetectionService we don't need the
pending intent based mechanism anymore.

Test: Checked that ambient music still detects music
Change-Id: If16c59028b31ff7d2e7f4d7f764460ac948ba946
Fixes: 73829108
2018-04-05 16:32:59 -07:00
Philip P. Moltmann
7e25b3d915 Throttle number of sound trigger operations / day
It is not clear when the day should start. Further a day might have
25 hours in the case of daylight savings time.
Hence a day in this case is the last 24 hours, not a calendar day.

Keeping track of the time of each operation might waste memory as we
don't need that much precision.

Hence keep track how many operations were performed in the last 24
hours in buckets of hours. If the total count reaches a maximum suppress
any further operations.

The maximum is configurable via global settings. It can be updated
by apps that have the appropriate permissions. Hence if the default
value turns out to be incorrect, it can be adjusted after release.

This does not throttle based on battery state as it is better to
completely unload the sound model to not even have a detection event.

Test: atest SoundTriggerDetectionServiceTests (separate CL)
      atest android.provider.SettingsBackupTest
Bug: 73829108
Change-Id: Ied8570b60b61b6a055bd2576d1502c1b36424efa
2018-03-20 13:57:14 -07:00
Philip P. Moltmann
18e3eb8168 Add SoundTriggerDetectionService
The service is meant to replace the PendingIntent based API. Once all
users of the PendingIntent based API switched the PendingIntent based API
will be removed.

To have as little as possible impact on the whole SoundTrigger framework
the RemoteSoundTriggerDetectionService class implements the same
interface as the PendingIntent based class. Hence the exising code has
very little change. Further once the old code can be removed the amount
of changed (and added) code is limited.

The RemoteSoundTriggerDetectionService -> SoundTriggerDetectionService
is a vanilla as possible service implementation. The special behaviors
are:
- The system holds a wakelock while service operations are in progress
and the service is bound as foreground. Hence the service can e.g.
listen to the microphone.
- Service operations have a certain amount of time they are allowed to
run. Once every operation is either finished or the the operation
exceeded the allotted time, the system calls onStopOperation for each
still pending operation. This is a similar model as for the commonly
used JobService.
  Please note that if the time allowed for an operation is 15s and
op1 was run as 0si, and op1 was run at 5s, the service is allowed to run
until 20s. Hence _both_ onStopOperations will happen at 20s. This is
done for ease of implementation but should not give the service more
power than calling onStopOperation exactly 15s after each operation is
triggered.
- If an operation is done before the allotted time is reached, the
service can declare the operation as finished manually by calling
onOperationFinished. This is a call back into the system, hence a
'client' binder is sent to the service. If the operation is finished
by calling this method onStopOperation will not be called.
- As the service instance might be killed and restored between
operations we add a opaque bundle 'params' to each operations. The users
of the API can use this to send data from the start command to the
operations. It can also just be set to null. The params are not meant to
store changing state in between operations. Such state needs to be
persisted using the regular methods (e.g. write it to disk)
- A service can be used for multiple recognition sessions. Each
recognition is uniquelity defined by its sound model UUID. Hence each
operation gets at least tree arguments: Operation ID, sound mode UUID, params
- As a small optimization the params are cached inside of the service
instance.

The time allowed for each operation is in a @SystemAPI global setting,
so the service can make sure it finishes the operations before they are
stopped. It might take some time to deliver the operations via the
binder, hence it is not recommended to try to use every last ms of
allotted time.

Test: atest SoundTriggerDetectionServiceTest (added in separate CL)
      atest android.provider.SettingsBackupTest
Change-Id: I47f813b7a5138a6f24732197813a605d29f85a93
Fixes: 73829108
2018-03-20 13:57:14 -07:00
Hall Liu
017afff112 Merge "Check for location access on TelephonyRegistry" am: 31230bb193 am: f581580fdb
am: 9b31dd86da

Change-Id: Icd2feab82a9350fa2b6539617863ad91a44e5208
2018-02-22 00:43:12 +00:00
Hall Liu
5fb337ff85 Check for location access on TelephonyRegistry
When sending outbound callbacks on CELL_INFO and CELL_LOCATION, check to
make sure that the user has authorized us and the receiving app to get
information on their location.

Bug: 69637693
Test: manual: telephony testapp
Change-Id: Iacfc894428b11a7ec973567d7a797eedb281355f
2018-02-06 14:01:47 -08:00
Fyodor Kupolov
ab781c254f Offload switchUser calls to worker threads
Some switchUser callbacks can block ActivityManager thread for 100+ ms.
The work can be done on a worker thread instead.

Test: Manual create/switch to user
Bug: 37579992
Change-Id: I45034fa8c8bdf457bcc3737c8064057fbfaf32f5
2017-12-19 16:44:26 -08:00
Winson Chung
bccd4b5b8e Fix deadlock when fetching active voice interaction service component.
- Notify AM whenever the active voice interaction service changes and
  dependency on VoiceInteractionManagerService from AM.

Bug: 70616466
Test: android.server.am.ActivityManagerAssistantStackTests
Change-Id: Ifd3dcbf0b6afc7b3e8a1d9d29bacd5b04af2a15d
2017-12-13 11:08:39 -08:00
Chris Thornton
ae5fb99096 Fix deadlock in SoundTriggerService using intent API.
The callback of the SoundTriggerService using the intent API used to try
and grab the same lock that other calls to the STS were using when they
accessed the SoundTriggerHelper.

This happens because most functions in the STH grab the STH's lock,
including the one that handles the recognition events. The recognition
event callback in the STS would then try to grab the STS lock, while
implicitly holding the STH one.

However, a concurrent call to the STS from outside could first grab the
STS lock, then call into the STH which may need the STH lock, resulting
in a deadlock.

By removing the requirement that the STS callback grab the main STS
lock, this condition is avoided.

Bug: 70346433
Test: On device
Change-Id: I44571fba786a82a17423d45f503be9537b476a01
2017-12-07 18:39:06 -08:00
Dianne Hackborn
08bd3ea8ca Fix issue #68002319: Allow current VoiceInteractionService to avoid...
...activity launch delays.

Activity manager now has a new private mechanism for other services
to report which apps are allowed to bypass the launch delay restriction,
which voice interaction service uses.

Test: manual

Bug: 68002319
Change-Id: I44e9b67411b5106b81e8363dc22d4e54caeb83c1
2017-11-22 13:59:17 -08:00