102 Commits

Author SHA1 Message Date
Dianne Hackborn
4870e9d5eb More work on device idle mode and other power stuff.
Add idle mode support to the alarm manager.  Introduce
a new concept of flags associated with alarms to tell
the alarm manager how to treat the alarm -- they allow
everything from the alarm that will bring us out of idle
mode, to alarms that are allowed when idle or should
also bring us out of idle.  The standalone boolean is
now also a flag.

(Note there is currently no protection from user space
setting the flags however it wants; I will be working
on that in a follow-up change.)

When in idle mode, the alarm manager pushes all alarms
that shouldn't execute during that time over to a
separate list that is not executed until out of idle.
To help with this, I reworked a bit how Alarm objects
are managed, so that when rebatching or moving between
lists we don't have to allocated new objects but can
just use the same existing instance.

Also tweaked the sync manager to deal with idle mode,
which currently just means doing the same thing as when
low on storage -- turning off sync.

Add new ACTION_CHARGING and ACTION_DISCHARGING broadcasts
that apps can listen for to know when the device is actively
charging and discharging.  These are better than the old
POWER_CONNECTED and POWER_DISCONNECTED ones because we only
report charging when we actually see that there is enough
power being provided to charge the battery (and will report
discharging if there is not enough power).

The job controller uses these new actions for scheduling
jobs that want to run while plugged in.  Removed the
"stable charging" stuff while doing so, since the new
charging state serves as an even better signal for that.

Introduced two new process states: FOREGROUND_SERVICE and
TOP_SLEEPING.  This will allow us to treat foreground services
specially (such as still allowing network access to them for
background music playback) while not mixing them together with
whatever happens to be the top activity while the device is
asleep.

Also some other small cleanup here and there.

Change-Id: I7a9808b578bad6f50deb8e1baf919298512a0d3a
2015-04-09 14:05:17 -07:00
Dianne Hackborn
d59a5d59df Various fixes and improvements...
Issue #19912529: VI: VoiceInteractor callback ClassCastException

Fix to use correct argument.

Issue #19912636: VI: Documentation for VoiceInteractionSession.onBackPressed

Added documentation.

Issue #19912703: VI: VoiceInteractionSession NPE on Abort Request

Maybe fix this -- don't crash if there is no active session.

Issue #19953731: VI: Add value index to...
...android.app.VoiceInteractor.PickOptionRequest.Option

There is now an optional index integer that can be associated with
every Option object.

Issue #19912635: VI: Behavior of startActivity when in voice...
...interaction is unexpected

We now forcibly finish the current voice interaction task whenever
another activity takes focus from it.

Issue #20066569: Add API to request heap dumps

New ActivityManager API to set the pss limit to generate heap
dumps.

Also added app ops for assist receiving structure and screenshot
data, so that we can track when it does these things.

Change-Id: I688d4ff8f0bd0b8b9e3390a32375b4bb7875c1a1
2015-04-04 17:36:05 -07:00
Jorim Jaggi
0b68ff4512 Add flag to voice interactor for supporting assist gesture
Add an additional flag to the voice-interaction-service declaration
so it can indicate whether it is able to handle the assist gesture.
Use that information in SystemUI so it only starts the voice
interaction session if the service is able to support it.

Change-Id: I62b035ce4f4cf06ee6e7eb0ddc4bf5edbc0e6737
2015-04-03 11:12:13 -07:00
Jorim Jaggi
225d3b5449 Add more internal API's for assist
- When starting a voice interaction session from SysUI, a callback
can be passed to know when voice interaction has successfully started
- Add a new window type for the voice interaction starting window,
which resides behind the voice interaction layer.
- SystemUI now also inspects the voice interaction service to get the
logo asset for the starting window.
- Make VoiceInteractionSession window fullscreen, to accomodate for
the visuals.

Change-Id: If8c3c445e8b39841f48e8d153e6d1ba81e447286
2015-04-03 11:12:03 -07:00
Jorim Jaggi
25e12abc5b Add ability to start voice interaction session directly
Add internal API's for SystemUI to start a voice interaction session
directly, without using an intent.

Make the assist gesture use that ability, if available.

Change-Id: I88ce3c7514714eb45666884847193585a07417a9
2015-04-03 11:11:51 -07:00
Dianne Hackborn
27eac1d58f Add ability to get a screenshot for assist.
New flag you pass in to startSession() to say you want it,
new callback on VoiceInteractionSession to receive it.

Change-Id: I61fdcfdee41a60d46036a2ef16681a9b4181115a
2015-03-17 16:45:51 -07:00
Dianne Hackborn
3d07c94c39 Add new voice request for picking from a list.
Also add API for voice interaction service to control
whether the system should hold a wake lock while it is
working with an activity (and actually *do* hold a wake
lock while doing so, duh!).

And while in there, clean up the launching wake lock to
correctly give blame to the app that is launching.

Change-Id: I7cc4d566b80f59fe0a9ac51ae9bbb7188a01f433
2015-03-16 11:29:12 -07:00
Dianne Hackborn
a83ce1dd2a More work on collecting assist data.
Optimize parceling of AssistData (which is now renamed to
AssistStructure) by pooling duplicated class name strings.

Change text associated with a view node to a CharSequence,
so styling information comes along.

Include global text attributes -- size, colors, etc.

Introduce a new AssistContent structure, which allows us
to propagate information about the intent and data the
activity is looking at.  This further allows us to propagate
permission grants, so the assistant can dig in to that data.
The default implementation propagates the base intent of an
activity, so if for example you bring up the assistant while
doing a share the assistant itself has the same information
and access that was given to the share activity (so it could
for example share it in another way if it wanted to).

Did some optimization of loading PersistableBundle from xml,
to avoid duplicating hash maps and such.

Changed how we dispatch ACTION_ASSIST to no longer include
the more detailed AssistStructure (and new AssistContent)
data when launching; now the example code that intercepts
that needs to be sure to ask for assist data when it starts
its session.  This is more like it will finally be, and allows
us to get to the UI more quickly.

Change-Id: I88420a55761bf48d34ce3013e81bd96a0e087637
2015-03-12 17:07:51 -07:00
Dianne Hackborn
ffeecb1bfb Rework voice interaction session lifecycle.
We now have a formal concept of the session being shown and
hidden, with it being able to continue running while hidden
as long as there is enough RAM.

This changes the flow that a VoiceInteractionSession will
see: onCreate() is when it is first created, onCreateContentView()
is when its UI first needs to be built, onShow() is called each
time it needs to be shown and has the arguments given when the
show request was made (which has been renamed from startSession to
showSession), and then onHide() will be called when the UI is
no longer shown.

The methods show() and hide() now allow a VoiceInteractionSession
subclass to control when it is shown and hidden, working with the
shown state being maintained by the system.

Change-Id: Ic4a430ec7e8bf76a5441fd0425e2932806170fcc
2015-02-25 17:36:17 -08:00
Dianne Hackborn
ae6688b096 Update voice interaction layer for new UI design.
Can switch from a pure overlay at the top of the screen,
to interactive mode with the voice UI drawing at the bottom
and pushing its target activity up like an IME.

Add mechanism to get assist data to the voice interaction UI.

Add some basic visualization of the assist data, outlining
where on the screen we have text.

Add a test ACTION_ASSIST handler, which can propagate the
assist data it gets to the voice interaction session so
you can see what kind of data we are getting from different
apps.

Change-Id: I18312fe1601d7926d1fb96a817638d60f6263771
2015-02-13 11:27:57 -08:00
Dianne Hackborn
4e106cedfe Bring back voice interaction APIs.
Change-Id: I6039d7c0b188ac342441c56f7d19994b9a80ba17
2015-01-21 15:07:20 -08:00
Dianne Hackborn
c0e4aaad1e Issue #17551667: Voice interaction service should be disabled...
...by default on Svelte devices

Also make sure the voice_recognizers feature is not enabled on
low-ram devices, with a new facility for platform feature
declarations to say they should be ignored on low ram devices.

Change-Id: I833c04b12e0e566dd682ed20adb0985c677a696f
2014-11-14 11:05:08 -08:00
Sandeep Siddhartha
45c00b5877 Don't unload the sound model on stopRecognition
This helps us in majority of the scenarios where the sound model doesn't
change across start/stop calls.

Bug: 17954633
Change-Id: Ibff817bb69bc69d2bb3a2603460fed596688b892
2014-11-12 09:57:27 -08:00
Sandeep Siddhartha
8cf8f71644 Fix issues with multiple languages and multi-users
For multi-user the issue was looking into the user ID of the current
process instead of the active user. The current process was the system
process and the call to UserManager was returning a user handle that
wasn't of any use while trying to map sound models to a user.

For language, the issue was that we were incorrectly just looking up the
model based on the keyphrase id, however we should have also taken the
enrolled model's locale into account.

Explicitly document that for model management the string representation of locales
is a BCP47 language tag.

Remove debug logging.

Bug: 16798166
Bug: 17462570
Bug: 17463511
Change-Id: Ieffb3e218de63f6e7f40af9705dced481a35b0ad
2014-09-15 19:59:09 -07:00
Eric Laurent
2475e38c10 SoundTriggerHelper: handle media server death
Retry to attach sound trigger module when startRecognition() is called.

Bug: 17373746.
Change-Id: I5b2f806b6cab47741d345be1cde73a84f5a62590
2014-09-09 17:26:00 -07:00
Dianne Hackborn
d7c0395d26 Hide the interaction part of VoiceInteractionService.
Also the ability to start voice activities is turned off,
though for testing purposes it can be turned back on with a system
property.

Change-Id: I867704d32c53beeb851ceea9b45c28bf5c01ef61
2014-09-02 10:29:28 -07:00
Jeff Hao
1b012d302b Add sample profiling option to am.
Also bundles all profiling options into a class.

Bug: 17040932
Change-Id: I85d675ee1494bdc7308caffdf94145d27c996e9d
2014-08-26 15:54:25 -07:00
Sandeep Siddhartha
efe0f9c7f2 Turn off hotword when in power save mode
Bug: 15705459
Change-Id: Ifa8b80223affffdc00da467c2066bc6370c85af1
2014-08-22 18:35:49 -07:00
Dianne Hackborn
16ec0808b5 Make sure we initialize to enable the default voice interaction service.
We weren't taking care of the case of an upgrade to L.  The main
change here is that the voice interaction service setting now has
an empty string when the user has explicitly said they don't want
one, so when it is null we will initialize it to its default.

Change-Id: Icdd30b4f09498f8928cea759a64628bd43bc5d0e
2014-08-15 18:34:10 -07:00
Sandeep Siddhartha
a31413a325 Fix delete clause for sound model DB
Since UUIDs contain '-'s they need to be wrapped within quotes

Bug: 16985919
Change-Id: I624a512ca7fc2494a7737b5465c94a9e161dec88
2014-08-13 10:52:17 -07:00
Sandeep Siddhartha
6df952ec22 Add debugging info to VIS via dump()
Change-Id: I9e8f4536de309256db835b30d94765bfc27d4e80
2014-08-11 09:38:38 -07:00
Dianne Hackborn
a351ab9698 Fix issues 16739817 and 16709247 in voice interaction service.
Issue #16739817 VIS doesn't start for non-primary user(s)
Issue #16709247 GSA is not the default voice interaction agent

These are both fixed by getting rid of the existing code for applying
the default voice recognizer, moving it in to the voice interaction
manager service, and extending it to also set up the default voice
interaction service.

Change-Id: If8d5936c28aebfa7eff77c8d99241c3a2ffdb0a4
2014-08-09 13:31:59 -07:00
Sandeep Siddhartha
6b8556d2e3 Dump the state of SoundTriggerHelper for bugreports
Change-Id: I01a17d969fbd22c6bcbb161e3542ca14a3f8c7c8
2014-08-07 12:10:48 -07:00
Sandeep Siddhartha
cb4e81c7fe Handle microphone contention/Phone calls while recognition is active
Internally we pause the recognition when:
 - a phone call is active/off-hook/ringing
 - or some other application grabs the microphone

we auto-resume when the condition that caused us to pause reverses.

Both these events are notified to the client via callbacks so that they can choose to display on their UI,
that the recognition is paused for some reason.

Bug: 16515468
Bug: 16740806
Bug: 16514535
Change-Id: Ib274d68522c8cf37d42402c875b16159957657f0
2014-08-07 11:53:02 -07:00
Sandeep Siddhartha
256e1a6267 Handle same keyphrase for multiple users
Also notify the VIS of a change after finishing the change

Bug: 16816191
Change-Id: I6c96595819cd07182c3825c522d9bae559bb6814
2014-08-07 10:50:18 -07:00
Eric Laurent
d3b8223377 SoundTrigger API update.
Add sound model update callback.
Add native service state change callback.
Add vendor UUID in sound model description.
Add coarse confidence level in recognition event.
Add capture format in recognition event.

Bug: 12378680.

Change-Id: Id63437819ec7b9a4a69e1ff6185b747e20cad95e
2014-08-04 16:35:27 -07:00
Sandeep Siddhartha
5e33fb057c Stop recognition when shutting down VIS
Bug: 16629417
Change-Id: I9c98d7e6d487d3eaff604df401c320f8554589f9
2014-08-01 18:18:08 -07:00
Sandeep Siddhartha
2c0273e50a Add a flag for multiple triggers with same recognition session
Also annotate the flags with @IntDef to make things clearer and safer

Add more debug logging

Revert to start/stop being synchronous since telephony and microphone will
need to be handled internally.

Bug: 16731586
Bug: 16514535
Bug: 16549061
Change-Id: I83695d52e9547269c95d443e4d921c9238b7401e
2014-08-01 17:46:27 -07:00
Sandeep Siddhartha
299efbe1fb Don't unload sound model in start recognition unless the model changes
This helps in start -> detected -> start again scenarios

Change-Id: I6d8d55e469e0623b9eb07595df8897ad4942aa11
2014-07-31 09:39:47 -07:00
Sandeep Siddhartha
1ed12ddb8c Make startRecognition async
- This is needed for telephony and audio integration which should happen via async callbacks
that'll end up starting/stopping recognition.

e.g. if a startRecognition happens when in a phone call - the onDetectionStarted will get called once the phone
call ends.

For now the transient stoppages due to internal reasons will not be propagated back to the client.

Bug: 16514535
Bug: 16515468
Change-Id: I1b2b8edd28f5c5e67c453f66c23e1a67a626114e
2014-07-30 11:43:41 -07:00
Sandeep Siddhartha
8ef360f348 Notify VIS of shutdown before switching implementations
This lets the implementation cleanup before it's destroyed.

Bug: 16629417
Change-Id: Ia717d461677e9ca8fa66f02c030aacad1597692d
2014-07-29 17:23:40 -07:00
Sandeep Siddhartha
2e14dd46e1 Use keyphrase id from the recognition event
Bug: 16516658
Change-Id: I8be773eec39e1c4c57d106e03a443cbfc5c6dc5d
2014-07-29 13:37:34 -07:00
Sandeep Siddhartha
6817337118 Read the keyphrase ID from the recognition event
Bug: 16516658
Change-Id: Ibeee81c9543aa1091bb075066cfc2269107f13c0
2014-07-29 11:24:51 -07:00
Sandeep Siddhartha
39c12fab49 Use blob (shared memory) for large data in sound model/recognition event/config
Also add a missing null check in writeBlob

Bug: 16516353
Change-Id: Ie702f8daae541cab7c2cee6e13d49e7fc84c84e1
2014-07-28 11:10:32 -07:00
Sandeep Siddhartha
452a642430 Fix various bugs with model management
- Tie the sound model and keyphrase for simplicity
  We won't support multiple keyphrases in a single model out of the box.
  The db schema will need to be changed by the OEM wishing to add multiple hotwords.
  This is because we currently have no way to test the flow and make sure that things work well with multiple keyphrases
  and also the framework only reads the metadata for one keyphrase.

- Make the delete/update operations atomic

- Make the flow of data from Enrollment -> VIMS; the large sound model doesn't cross the process boundary any other time.
  This is achieved by passing they key around, instead of the model themselves.

- Add a specific delete operation in DatabaseHelper rather than relying on emptying the keyphrases to delete.

Bug: 16555803
Bug: 16516353
Change-Id: I1e0cce137517502a669e431ca7e9f9f755598328
2014-07-25 17:11:34 -07:00
Sandeep Siddhartha
f63bc523ea Make hotword availability a callback
This helps us make the list sound models operation an async one, it also helps us
with the case where a detector is invalidated, so the client doesn't have to keep checking the
state.

Synchronize DatabaseHelper methods on its instance so that other VoiceInteractionManagerService
calls aren't blocked on db writes/reads.
It's still possible for the list operation to be blocked on update and vice-versa

Change-Id: Ib8ec4ac5056b62d443038560ce31d0641b4627b0
2014-07-22 17:11:52 -07:00
Sandeep Siddhartha
6daae96226 AlwaysOnHotwordDetector needs to reflect enrollment changes
Add a callback for when any sound model change happens. This helps the VIS
to re-check the availability and either enroll the user, or start/stop recognition.

Also shut down any active recognition when VIS dies, or a different hotword detector instance is obtained from VIS.

Change-Id: I03f94e78c6ee307afe822a84aebc7e74c64de7b4
2014-07-22 09:16:18 -07:00
Sandeep Siddhartha
110f569b47 Fix synchronization issues in AlwaysOnHotwordDetector
- Remove unnecessary recognition status from AlwaysOnHotwordDetector

- Remove unnecessary recognition started callback from IRecognitionStatusCallback

- Fix a bug around the fact that we weren't picking up enrollment at runtime because
we were storing the availability at instantiation time.

- Handle 0-length arrays in SoundTrigger classes while parceling/unparceling

- Fix issue in SoundTrigger helper where we were not comparing binders for start/stop calls

- Unload the previous model when starting a new recognition

- Add more debug logging

Change-Id: Icc56d7f3dd1ffa49a8cfeea49080e3ab4d342c32
2014-07-20 16:53:09 -07:00
Sandeep Siddhartha
055897208d Move sound trigger calls to VoiceInteractionManagerService
- This ensures that any data being loaded on the DSP comes from the framework

Change-Id: Ie15f0994850ba8f298ca07c49fe0b89e066d9e2b
2014-07-20 11:22:55 -07:00
Sandeep Siddhartha
7444c906fa Test hotword flow
- Also fix a few StrictMode violations in DatabaseHelper

Change-Id: I93f27407dae34cc0dca5e9f891d4ca718d6010a5
2014-07-17 18:44:12 -07:00
Sandeep Siddhartha
f8cf71d753 Support model deletion
the updateKeyphrase call is also used to clear out a sound model currently,
this happens when the sound model passed in has no keyphrases.

We can revisit if we need another deleteSoundModel method

- Also fix an issue with the way we were writing keyphrase to the DB
  and when updating keyphrase, we actually addOrUpdate

Change-Id: Ib7250c2fdafef6bc40387912a79366c334d73292
2014-07-17 11:01:25 -07:00
Dianne Hackborn
fee756ff91 Implement issue #16330060: Inform ActivityManager about WebView...
...state changes.

Add a new API to tell the activity manager about a new dependency
one process has on another package.  Start using it already for
when apps is Context.createPackageContext() to load code from another
app.

Also do some work on getting the monitoring of proc/uid states
in shape so it can be used by unundled code, along with an
AppImportanceMonitor class for doing so.

Some small fixes and additions to VoiceInteractionService.

Improve handling of unaccounted/overcounted battery use so that
they aren't shown to the user unless they are significant.

Change-Id: I22dd79a73f4e70103d3f8964494aebc8a31f971c
2014-07-16 22:50:31 -07:00
Sandeep Siddhartha
2883ba6975 Plumb the database code to read/update sound models
Change-Id: I135131b042481462f905bdb69ea8544e2561d177
2014-07-16 22:10:45 -07:00
Sandeep Siddhartha
8ecaf5f5cf Hook in startRecogniton call
Add required info to the sound model database: users & recognition modes

Change-Id: I6e12cbc6342a2767c0e3d8328c0a3be899ac9952
2014-07-15 18:36:09 -07:00
Sandeep
d701820031 Always on hotword changes
Add model management API skeleton to VoiceInteractionManagerService
Add an "interactor" for all always-on APIs

- The VoiceInteractionService will get an interactor for the given
  keyphrase and locale.
- It can then check the availability and call methods to start and
  stop recognition on this interactor.

- Add a common class to deal with SoundTrigger APIs

- Cleanup the keyphrase representation:
  We now have separate representations for the keyphrase metadata and
  a keyphrase being used for recognition.
  This'll also help us to handle custom keyphrases in the
  future easily.
  This also ensures that for use within the framework,
  we rely on the ID of the KeyphraseInfo rather than comparing the
  text everytime.

Add a callback for the AlwaysOnHotwordDetector

This callback should be passed in by the VoiceInteractionService and is used to notify it
of recognition events.

Change-Id: I26252298773024f53a10cdd2af4404a4e6d74aae
2014-07-10 18:32:37 -07:00
Eric Laurent
013f66b92d SoundTrigger: update API
class Keyphrase: replaced number of users by list of user IDs.
class RecognitionEvent: added capture preamble duration.
class KeyphraseRecognitionEvent: add keyphrase ID and explicit list of
user ID/confidence level pairs.
startRecognition(): takes a RecognitionConfig specifying the list of
keyphrases to listen to as well as for each keyphrase the recognition mode,
users and min confidence levels for each user.

Bug: 12378680.
Change-Id: I57036cc83b5d9e90512b8bb3f951af3a4a74c0ce
2014-07-08 11:48:44 -07:00
Sandeep Siddhartha
d4233c68fc Initial code for listing/storing sound models
- We use a DB to store and persist the sound models.
- This'll be used by SoundTriggerModelManager, a service that lists,
  deletes and registers new models. This'll be used by the enrollment
  client to enroll and unenroll users.

- This needs the unique identifiers for sound model & keyphrases to be
  present in the respective data structures

This is very early stage so please point out any concerns.

Change-Id: I82962895bf326167458f20e6ba995295551de025
2014-07-08 09:36:51 -07:00
Dianne Hackborn
6ea0d0a259 Fix cleanup of voice sessions.
They would leave active voice activities lingering around.

Change-Id: I5b6716ab303636ebdf2f13c3172552a73dae3bb1
2014-07-07 11:28:29 -07:00
Dianne Hackborn
e30e02f5d9 Add system layer for voice interaction services.
New window layer that voice interaction service windows
go in to.  Includes a new voice-specific content rectangle
that voice activities are placed in to.

Add specific animations for this layer, sliding down from
the top (though this can be customized by the voice interaction
service).

Also add the concept of activities running for voice interaction
services for purposes of adjusting the animation used for them,
again sliding from the top, but not (yet?) customizable by the
voice interaction service.

Change-Id: Ic9e0e8c843c2e2972d6abb4087dce0019326155d
2014-05-28 17:16:51 -07:00
Dianne Hackborn
c03c9167c2 Further work on voice interaction services.
This makes VoiceInteractionSession a more first-class
concept.  Now the flow is that a VoiceInteractionService
calls startSession() when it wants to begin a session.
This will result in a new VoiceInteractionSession via the
VoiceInteractionSessionService containing it, and the
session at that point an decide what to do.  It can now
show UI, and it is what has access to the startVoiceActivity
API.

Change-Id: Ie2b85b3020ef1206d3f44b335b128d064e8f9935
2014-05-05 11:18:08 -07:00