146 Commits

Author SHA1 Message Date
Jeff Sharkey
fe9a53bc45 Consistent dump() permission checking.
This change introduces new methods on DumpUtils that can check if the
caller has DUMP and/or PACKAGE_USAGE_STATS access.  It then moves all
existing dump() methods to use these checks so that we emit
consistent error messages.

Test: cts-tradefed run commandAndExit cts-dev -m CtsSecurityTestCases -t android.security.cts.ServicePermissionsTest
Bug: 32806790
Change-Id: Iaff6b9506818ee082b1e169c89ebe1001b3bfeca
2017-04-02 22:29:07 -06:00
Chris Thornton
2411a2c38e Clean up dead objects when detected in the SoundTriggerHelper
If an app has died while being connected to the sound trigger helper/the
binder goes away, we should stop and unload the model since there's no
way to get a handle on it again (without reloading the same UUID at some
point).

Test: Force stop the SoundTriggerTestApp while it has a model started,
trigger the sound model, then watch it get unloaded when the helper
notices that the binder is dead.

Change-Id: Iddfaaa03482d56e71f23e5982d4bd579f386b51d
2017-03-22 21:28:31 -07:00
jackqdyulei
455e90add2 Add BatterySaverPolicy for power save mode
The BatterySaverPolicy is designed to consolidate all battery saver
knobs into a central location. Usually it is consistent to
mLowPowerModeEnabled unless it gets different data for specific
service. By adding these knobs, we can effectively tune the battery
saver.

This cl sets up the framework for BatterySaverPolicy and updates
following service to get battery saver data from BatterySaverPolicy

1. GnssLocationProvider
2. VibratorService
3. WindowManagerService
4. BackupManagerService
5. SoundTriggerService
6. NetworkPolicyManagerService

Screen brightness will come in a following cl.

Bug: 34693888
Test: FrameworksServicesTests

Change-Id: I6b040e93391614b44d136a485faa4a332c396e51
2017-03-08 09:20:36 -08:00
Winson Chung
8347163dbb Create a new stack for the assistant activity.
- Add a new stack that is not resized with multiwindow, and
  appears above the fullscreen and docked stacks, but below
  the pinned stack
- Add a method on VoiceInteractionSession to allow the assistant
  to launch activities into this new fullscreen stack.
- Also prevent any activities in the assist stack from the
  fetching of the on screen assist data.

Bug: 30999386
Test: android.server.cts.ActivityManagerAssistantStackTests

Change-Id: I22ab7629b5f758cf1e66d7d1c26648af6bc887c9
2017-02-12 14:52:15 -08:00
Sudheer Shanka
dc589ac82b Update usage of ActivityManagerNative.
- Remove references to ActivityManagerProxy.
- Add isSystemReady to ActivityManager.

Bug: 30977067
Test: cts/hostsidetests/services/activityandwindowmanager/util/run-test android.server.cts
      adb shell am instrument -e class com.android.server.am.ActivityManagerTest,com.android.server.am.TaskStackChangedListenerTest \
          -w com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Change-Id: I07390b6124fb1515821f5c0b37baf6ae74adc8fa
2016-11-14 11:27:12 -08:00
Wale Ogunwale
ac2561e820 Make window token add/remove APIs require displayId
Window tokens can now only be on one display, so we now require clients
that want to add/remove window tokens to specify the display they would
like the token to be created on. This simplifies the token handling code
in WM and will be useful moving forward for clients that want to add
windows to external displays.

Test: Existing tests pass
Change-Id: I6b2d8d58a913b3624f1a9a7bebbb99315613f103
2016-11-02 10:28:45 -07:00
TreeHugger Robot
3916c8f033 Merge "Removed temporary workaround for multi-window assist crash." 2016-10-27 02:09:48 +00:00
TreeHugger Robot
662a134c91 Merge "Synchronized access to mService." 2016-10-20 01:30:38 +00:00
Felipe Leme
e01d95e593 Removed temporary workaround for multi-window assist crash.
BUG: 28348867
Test: manual

Change-Id: I19b8e4cd06ee5f1a3b5818434da6fafbcb3a0550
2016-10-19 16:20:24 -07:00
Felipe Leme
5aaca3a620 Synchronized access to mService.
Test: none
Change-Id: Ibab1211384c1c579fa24be19821c2784faa22b8c
2016-10-19 15:23:08 -07:00
Chris Thornton
b587d8d2c8 Only purge sound models that violate the new primary key constraint if they don't contain identical data. am: d5ff116403 am: 519b7837bb
am: a7f3f1aa91

Change-Id: I5a376cac47bd279ed13116213b2a78ddcdae8eb2
2016-10-19 01:40:52 +00:00
Chris Thornton
d5ff116403 Only purge sound models that violate the new primary key constraint if
they don't contain identical data.

Bug: 32174118
Change-Id: Ied5e4e852337e5f819c7ded53dd941d79087ce73
2016-10-18 15:36:27 -07:00
TreeHugger Robot
4a648f03c9 Merge "Fixed typo on service name." 2016-10-18 02:22:44 +00:00
Felipe Leme
fb96985d9a Fixed typo on service name.
Test: none

Change-Id: Iba9324d0bbd8152594bb92ce66d2b1d1371f559b
2016-10-17 10:22:49 -07:00
Chris Thornton
5bd5cf75e1 Update primary key in VIS sound model database.
The public API for getting at KeyphraseSoundModels is based on the user,
locale, and keyphrase ID. However, the sound model database would allow
multiple models to be registered using the same values, as it has a
primary key on the model UUID. This can potentially lead to a scenario
where multiple models are enrolled for the same user, and the data that
is returned when querying models is arbitrary.

V6 of the sound model database now enforces a primary key over the user
ID, locale and keyphrase ID. When inserting a new model with the same
primary key, the old model will be removed and the new model will be
used instead.

When upgrading from V5 to V6, if there are any models that would violate
the primary key constraint, they are all dropped.

Bug: 32174118
Change-Id: I9597c6a994f01a426625c3be2c53e826f26f5156
2016-10-17 10:12:04 -07:00
Dianne Hackborn
e9563659a5 Fix issue #30929080: Default Assist app is set to None...
...on removing the third pary search app

We weren't taking into account old style assistants when determining
whether something interesting had been removed.

Change-Id: I6b7b09cdf0781622924e10556d678565570dbd05
2016-08-18 17:33:41 -07:00
Adrian Roos
2335bd6787 Assist: Allow disabling the disclosure animation
Change-Id: I6e7ed00f066fda7cc268119e7aa4133010aa69c1
Fixes: 30809067
2016-08-12 12:04:53 -07:00
Chris Thornton
d0a83b89a6 SoundTriggerHelpoer: Send pause events on abort if a model is running.
If the recognition was aborted due to the service state being set to
false, clients were not made aware that the model had been stopped (but
would get a resume event).

Bug: 30233664
Change-Id: I9f663362ff142eadfd5ef727c5f0c941f8e9e89d
2016-07-20 14:43:07 -07:00
Annie Chin
d953ab6fdf Move voice interaction callback list to VoiceInteractionManagerService
Bug: 30005941

Change-Id: I23b3bba8b4525068b0f032d5ca908c0f1d181558
2016-07-07 12:00:03 -07:00
Annie Chin
2045bdd958 Add a null check for mImpl.
Bug: 30005941
Change-Id: I1212aa66be71b7ee0e990596272a33fa7530770f
2016-07-07 10:22:34 -07:00
Annie Chin
d58f07f58a Merge "Add callbacks to VoiceInteractionManagerService" into nyc-mr1-dev 2016-07-06 23:22:10 +00:00
Annie Chin
ecb9f3e9b8 Add callbacks to VoiceInteractionManagerService
Bug: 29582254

Change-Id: I548d01bd1c7e261b2d2e0afd606d964e5553124e
2016-07-01 13:00:09 -07:00
Chris Thornton
174c581877 Prevent NPE when updating models without a vendor UUID
Change-Id: If58cd3ddb0a2afd601af3e3868ab4ff500be53a9
2016-06-14 15:53:14 -07:00
Chris Thornton
6b1a34877d Store the vendor UUID of a KeyphraseSoundModel in the database
Bug:28027337
Change-Id: Ieb1905812f9655aaf5608e92e160d59ff7b3abd9
2016-06-10 13:52:28 -07:00
Svetoslav Ganov
b625e19a87 Properly set default voice interactor
We need to figure out the default voice interactor to give
it default permissions. This happens before the user has
been unlocked and if the voice interactor is not direct
boot aware we fail to find it, hence no permissions are
granted. Now we query the package manager for both direct
boot aware and unaware components. This is fine as we
don't interact with the assistant until the user is
unlocked.

bug:28963642

Change-Id: Ide5471fa1798e868c6e3a4b5e87570a5556e2d3f
2016-06-02 15:25:15 -07:00
Amith Yamasani
f5c37eb3b7 Use correct synchronization lock
This is to fix an incorrect unregister() that was crashing
the system server. The only way it could be happening is
because of incorrect locking. So, hopefully this fixes it.

Bug: 28813750
Change-Id: Ie3c47ffa3024a0c533e12db0d2d021df8fc0367a
2016-05-23 17:21:08 -07:00
Amith Yamasani
4f128e4d96 Fix multi-window assiststructure trashing
When multiple activities within the same process
try to handle requests for AssistStructure, the
singleton mLastAssistStructure tends to trash
the old structure when a second window's request
comes in.

This change passes in a sessionId so that the
cache is only cleared if the session id changes.

Bug: 28348867
Change-Id: I07efcd933db7e48aefd25a1c95493b71bbcffe4b
2016-05-10 12:17:51 -07:00
Amith Yamasani
02c80c63d4 Workaround for assist crash with multiwindow
Temporarily disable multiwindow assist until
Bug: 28348867
is fixed correctly.

Change-Id: Ia9d0fb5d4412e87aada90e8dcffe829b61221c6c
2016-05-09 12:46:23 -07:00
Chris Thornton
f967da9052 VIMS should only stop the keyphrases it started.
When the VIMS changes the implementation or has its implementation force
stopped, it used to stop all the recognitions that were in the
SoundTriggerService (without letting those clients know that they've
been stopped). Instead, the VIMS should just unload the keyphrases that
it loaded, so the other clients are not perturbed.

Bug:28518547
Change-Id: Ia70e8576f43cb8a8521c947ff7fc56f63cfbad54
2016-05-02 19:22:57 -07:00
Chris Thornton
37f9776ab9 Remove the STH tracking if a model has been aborted.
The STH just needs to log the fact that a model has been stopped when it
is aborted. We also need to allow models to be stopped even if the
service is unavailable.

Bug:28474708
Change-Id: I2d618ae9c7c87311223f7d75b8ded7678252d11c
2016-05-02 19:07:33 -07:00
Chris Thornton
56056038f7 Keep STH state in sync with HAL
During stopAllRecognitions(), the internal state of a sound model was
being cleared (which made it look like the model was being unloaded).
However, the model was still loaded, so subsequent calls to load a 'new'
model would break.

Bug:28432002

Change-Id: I7090bf52704c6e46e3bb6d495d8fe4b8a1d9e2ad
2016-04-30 12:06:49 -07:00
Amith Yamasani
50bbb66d60 Fix a regression in assist when context is disabled
Fixes: 28293783
 CTS: DisableContextTest#testContextAndScreenshotOff failure

When assist context is disabled, make sure that the handleAssist() is
still called with no data.

Change-Id: I569dd9f6de503e62fb04c590214df0f2ce3aa4f3
2016-04-22 15:43:21 -07:00
TreeHugger Robot
2be4c463bc Merge "Throw better exception when startVoiceActivity fails" into nyc-dev 2016-04-21 00:46:32 +00:00
Amith Yamasani
37f9de996e Reinitialize voice interaction service on unlock
Fixes the incomplete initialization on FBE devices when
voice interaction service is not available before unlock.

Change-Id: I397237e4554453d29da643aee59384e289fa3654
Fixes: 28183380
2016-04-19 17:20:51 -07:00
Amith Yamasani
4244978621 Throw better exception when startVoiceActivity fails
Introduced new error codes so that Instrumentation can
include the correct message in the exception.

Bug: 28216630
Change-Id: I93ee77153cdad11fa208c74c28c6790db27c9753
2016-04-19 11:45:51 -07:00
Chris Thornton
41e04a4525 Use .equals() to compare two UUIDs in SoundTriggerHelper, rather than ==
Also refactors ModelData::clearState to clear a bit more of the state.

Bug:28251543
Change-Id: I18d7ccd90a6a9ee8bc8743d9a92c48f17d87c842
2016-04-18 17:58:37 -07:00
Narayan Kamath
a09b4d2a61 Remove unnecessary allocation+unboxing of objects.
Transforming String->int can be done with 0 allocations
using Integer.parseInt.

bug: 28078871
Change-Id: I8d9f322d7154728849dde61ef282046032858d60
2016-04-18 09:55:59 +01:00
Arunesh Mishra
59623ee337 Merge "SoundTriggerHelper: Add ability to manage multiple voice models." into nyc-dev 2016-04-14 20:00:00 +00:00
Arunesh Mishra
fac2515695 SoundTriggerHelper: Add ability to manage multiple voice models.
This CL adds the ability in STH to manage multiple voice models indexed by
keyphrase ID, which is an integer.

Bug: 28104190
Change-Id: I8e10cca05ed8b4b8414cae7fffc26c132d4b7cbd
2016-04-14 12:12:27 -07:00
Amith Yamasani
e8222e551f Multi-window assist callback
Introducing a new callback in VoiceInteractionSession to
provide assist data for additional activities in the
foreground in a multiwindow setup.

PIP, docked windows and free-form windows (top-most)
will be queried for assist data and passed through the
new API to the Voice Interaction service.

Bug: 27718385

Change-Id: Ib4427c304611b75c2078dcb54f1f7e47ae7d9cfa
2016-04-13 17:12:29 -07:00
Arunesh Mishra
78ab7cf301 SoundTriggerHelper re-design.
This CL redesigns and cleans up a lot of the core logic in STH.

Major changes include:
   - Adds Tron logging based counters.
   - Common startRecognition(), stopRecognition() and updateRecognition()
     routines that work on both Keyphrase and Generic sound models.
   - Common streamlined logic for when recognition is aborted, requested and
     paused due to phone call/power save etc, for both keyphrase and generic
     models.
   - Special handling of the singleton nature of keyphrase models in
     startRecognition().
   - Moves all Keyphrase model state to the common ModelData structure.
   - Adds Recognition pause/resume() for generic sound models so that they react
     to power save, call state, recognition aborted due to service unavailable
     etc.
Bug: 27972641

Change-Id: I96a7f567d2a4973facec556892a163ca74176bbf
2016-04-08 13:22:38 -07:00
Ryan Bavetta
6e3eeadee2 Merge "Fix unsynchronized access to model hashmap" into nyc-dev 2016-03-09 00:05:33 +00:00
Ryan Bavetta
79655ebf7e Fix unsynchronized access to model hashmap
BUG:27529749
Change-Id: I5b7cd59d8b45858896e6014b8fe95c1cc3c77869
2016-03-08 20:14:04 +00:00
Joe Onorato
3973b1a75d Turn down the logging a little bit.
Change-Id: I810b9bd58412d2b38d8ce4497baa71047125b92f
2016-03-04 12:21:30 -08:00
Arunesh Mishra
f47f173b06 Fix AlwaysOnHotwordDetector recognition event bug.
Parcelables don't work well with inheritance. So changed the
IRecognitionStatusCallback to have onKeyphraseDetected() and
onGenericSoundTriggerDetected() for those respective events.

Made corresponding changes to AlwaysOnHotwordDetector and SoundTriggerDetector.

Bug: 27250528
Change-Id: Ic08a431e7cc4248c688b05c865348170246de576
2016-02-24 12:57:01 -08:00
Arunesh Mishra
2d1de78a4c Unload logic for generic and keyphrase sound models.
When delete is called, now the STH unloads the corresponding models.

Fix bug with keyphrase where a delete call didn't unload (or stop)
the keyphrase model.

Bug: 27279380
Change-Id: Ia34f713d2aecef4102c0f0ccc57b8d2e5febe4bb
2016-02-22 15:19:44 -08:00
Arunesh Mishra
933da8150c Fix minor bugs:
- Fix issue when multiple starts cause multiple spurious loads to be sent to
   the native layer.
 - Fix scrolling issue in the native app.

Bug: 27222043
Change-Id: Iddf36a8b68637f478dc23b001ecbde352db3a5f0
2016-02-19 15:06:27 -08:00
Arunesh Mishra
3fff7f5634 SoundTriggerHelper changes for GenericSoundModels.
- Refactoring SoundTriggerHelper to handle generic sound models.
     - Ability to store multiple models, callback and state information.
     - Separate out initialization to be done per voice model, per any model
     and per generic model.
 - Minor change to the API exposed -- removing the Handler from the
   createSoundTriggerDetector call.
 - Added callback processing for onRecognitionEvent().
 - Added logic for stopAll().
 - Changes to the SoundTriggerTestApp to start/stop recognition.
     - Multiple models (3).
     - Ability to start/stop/load/unload individual models.

Bug: 22860713
Bug: 27222043
Change-Id: Ie5d811babb956bead653fb560a43f1e549ed11bd
2016-02-17 14:24:03 -08:00
Arunesh Mishra
55a9b0089c Fix moduleProperties in SoundTriggerInternal.
Change-Id: Ie7ea74ca39894f78875768dbc3e504b32f262fe6
2016-02-01 14:14:06 -08:00
Arunesh Mishra
c722ec4105 Fix SoundTriggerModel uses to GenericSoundModel.
Change-Id: I30308b39536864d7b9640367861730e3b1b12129
2016-01-27 13:37:27 -08:00