105 Commits

Author SHA1 Message Date
Sergey Volnov
5532c77904 Store hard refences in a static context and pass through only weak
references during the Content Capture Sharing.

Motivation: if the remote app is killed, we don't want a possibility of
system server holding a stroing reference (through a reference chain)
to large objects in that app. Therefore what's send in the binder has to
be a weak reference. And we will store a hard reference to those objects
in the client app's static context.

Storing hard references to objects in system_servier is less critical, because that is not going to be killed.

Bug: 148265162
Test: covered by CTS tests
Change-Id: Ie561aab6019d191cf8659fb350e045089e7781ed
(cherry picked from commit 13f65b29745d306351c666c4f9f4a2d701513fe5)
2020-03-29 12:50:41 +00:00
Mihir Patel
6f33b10ab5 Moving the NO_SESSION_ID constant from ContentCaptureSession to ContentCaptureManager
Bug: 150599209
Test: manual
Change-Id: I3e7b67cf92ddb6405829ec3c6ed2c491b4e77cab
2020-03-27 15:50:43 +00:00
Felipe Leme
339b7149af Improved user callbacks on SystemService:
* Renamed:

  onStartUser() -> onUserStarting()
  onStopUser() -> onUserStopping()
  onSwitchUser() -> onUserSwitching()
  onUnlockUser() -> onUserUnlocking()
  onCleanupUser() -> onUserStopped()
  isSupportedUser() -> isUserSupported()

* Added:

  onUserUnlocked()

Tested on automotive, which uses the callbacks to dump user metrics:

$ adb shell dumpsys car_service --user-metrics
adb shell dumpsys car_service --user-metrics
* User Metrics *
  no users starting
  no users stopping
Last 10 started users
  2020-02-21T19:44:47.101 - user=0 start=2020-02-21 19:44:45.357 unlocking=+885ms unlocked=+1s122ms
  2020-02-21T19:44:56.376 - user=10 start=2020-02-21 19:44:47.380 switch=+209ms unlocking=+8s262ms unlocked=+8s994ms
  2020-02-21T20:00:08.792 - user=11 start=2020-02-21 20:00:04.634 switch(from 10)=+351ms unlocking=+4s44ms unlocked=+4s156ms
Last 10 stopped users
  2020-02-21T20:00:48.323 - user=10 stop=2020-02-21 20:00:16.741 shutdown=+31s581ms

Test: m update-api
Test: atest BackupManagerServiceTest
Test: manual verification (see above)
Fixes: 150001654

Exempt-From-Owner-Approval: approved on master right before rvc split

Merged-In: I8774c57620030b9aa8e7ec039a6a758ad56db368
Change-Id: I8774c57620030b9aa8e7ec039a6a758ad56db368
(cherry picked from commit 58e7458ac7204992c5408eb2d6420d767afc4eb8)
2020-02-24 16:44:52 +00:00
Sergey Volnov
63f5f3a40f After data was successfully copied - mark package as able to receive new
sharing requrests.

Bug: 145205247
Test: this was actually surfaced during CTS tests implementation, when
subsequent test executions failed because of needing a timeout.

Change-Id: I529216d0e9139f165f90bdaab80850c4c047f836
2020-02-13 17:56:45 +00:00
TreeHugger Robot
cceb2c2e61 Merge "Send autofill assist structure data to content capture" 2020-02-07 18:41:58 +00:00
Mihir Patel
4770be2d60 Send autofill assist structure data to content capture
Test: manual
Change-Id: I23339a8f90dbb6c31f473e6163ba0866518cb0a4
Bug: 147232107
2020-02-07 10:40:15 -08:00
Muhammad Qureshi
e2b2432bc6 Use FrameworkStatsLog instead of StatsLog
As part of statsd becoming a Mainline module in R, autogenerated
StatsLog.write() calls are going away and replaced by
*StatsLog.java
that is autogenerated for each module.
This CL replaces some usages of StatsLog with
FrameworkStatsLog.

Bug: 145952197
Test: m
Change-Id: Iaa2db34a7be4c3215f62cc36661ba8ac81656baa
2020-02-03 09:17:40 -08:00
Sergey Volnov
439294404f Got rid of cancellation signals in the Content Capture Data Sharing
Motivation: if the Content Capture service want's to end the session, it
can close the read-fd, while not have finished reading, and that would
result in an exception in the system server, that can later be
propagated to the caller as an error.

Similarly, timeout of the sharing session can be reflected as an error
with a specific error code.

Test: built Android locally and perfomed a manual test.
Bug: 145203958
Change-Id: Iaeb45e0ab68da9fe30dce1ae4eab2354ef56d827
2020-01-29 15:31:00 +00:00
Sergey Volnov
7c78ce6e4d Made DataShareCallbackDelegate a static class not storing a hard
reference to its parent.

This is to prevent occasional data leaks caused by GC not cleaning up
parent resources.

Bug: 148265162
Test: built Android and performed an E2E test
Change-Id: Ie2b948fa2e5f457f2f44883cfb5995287a704bb5
2020-01-28 13:36:53 +00:00
Sergey Volnov
97e66d0206 Merge "Changed ContentCaptureManagerService to have a static TAG var for logging" 2020-01-27 15:25:09 +00:00
Sergey Volnov
ed8ce564b3 Merge "Use cancellation signals for timeouts and cancel-by-CCService operations" 2020-01-27 15:24:41 +00:00
Sergey Volnov
ac90cd8bf9 Merge "Implement data sharing API for Content Capture." 2020-01-24 22:05:27 +00:00
Sergey Volnov
ad82c0baca Changed ContentCaptureManagerService to have a static TAG var for logging
Bug: 148265162
Test: built Android
Change-Id: I7eecb1c463e16219c413b7d0f7f13a8da17377a6
2020-01-24 17:06:39 +00:00
Sergey Volnov
d7e9844445 Use cancellation signals for timeouts and cancel-by-CCService operations
Bug: 148264965
Test: built Android + manually tested
Change-Id: I95f7ec2bb96b8b6d6ead106877f9d7128e3ec209
2020-01-24 16:57:35 +00:00
Sergey Volnov
6e049014a7 Implement data sharing API for Content Capture.
This API allows any whitelisted caller app supply data to Content
Capture Service. CDD suggests to not use standard "binding" mechanisms,
so this is a guaranteed-writeonly way of sharing data.

Test: build Android locally, manual E2E test
Bug: 145203958

Change-Id: If2219acd6aa48f199e4dadd6f18ceb55c258e1d0
2020-01-24 14:58:43 +00:00
Makoto Onuki
c8815900d2 Clean up SystemService as a preparation to make @SystemApi
Bug: 146145144
Test: Boot + treehugger
Test: atest CtsAutoFillServiceTestCases (with some unrelated failures)
Test: atest CtsContentCaptureServiceTestCases CtsVoiceInteractionTestCases (all passed)

Change-Id: I89265c3c46262cd3251153f85df6f4aea37520f1
2020-01-10 16:19:37 -08:00
Jiyong Park
bae2e90796 Add filegroups for services.* libraries
... in preparation for creating a stub library from services.jar

Bug: 139391334
Test: m
Change-Id: Ifd6cfc77acf2284804a2f64011c2733b5c222369
2019-11-17 14:05:08 +09:00
Adam He
ffa36ff8fa Prevent content capture sessions starting if a non-default service
requests it on an activity not in its own UID.

Fixes: 142284417
Test: manual verification
Change-Id: I9e217e0087e2e7741a2713c25ca26264eae618e7
2019-10-15 12:52:28 -07:00
Felipe Leme
987655d049 Improved AbstractMasterSystemService to handle supported user types.
Also changed AutofillManagerService and ContentCaptureManagerService to take advantage of these methods.

Test: manual verification
Test: atest CtsAutoFillServiceTestCases CtsContentCaptureServiceTestCases # on phone and Automotive

Bug: 133242016

Change-Id: I3e7f9d65a6ef1e8e6ec886a41b35733e463a6389
2019-08-26 10:51:03 -07:00
Adam He
420947c4cc Metrics for content capture.
Bug: 119613670
Test: statsd_testdrive & manual test
Change-Id: If43465ccee7454a7ebf9e15caa23fce7bae33cfe
2019-05-14 11:33:33 -07:00
Felipe Leme
5654efd4cb Merge "Renamed UserDataRemovalRequest to DataRemovalRequest." 2019-05-09 00:17:10 +00:00
Felipe Leme
4439ee663f Renamed UserDataRemovalRequest to DataRemovalRequest.
Test: m update-api
Test: atest CtsContentCaptureServiceTestCases

Bug: 130726495

Change-Id: I691b9de40863421395e910f6e28186d8a91b08f2
2019-05-08 10:36:36 -07:00
Felipe Leme
6916eda7c2 Merge "Disable existing ContentCapture sessions if service changes their whitelist status." into qt-dev am: d97db54da4
am: a182f9c95f

Change-Id: I6463bd892ce0f0e67449988e40e0b2ac40598bea
2019-05-08 10:22:42 -07:00
Felipe Leme
0a3bec5860 Disable existing ContentCapture sessions if service changes their whitelist status.
Test: atest CtsContentCaptureServiceTestCases:CustomViewActivityTest
Test: atest CtsContentCaptureServiceTestCases # sanity check

Fixes: 130802293

Change-Id: Ia94016382192912668c4ac1ce580a0b95c76f35c
2019-05-06 16:09:05 -07:00
Adam He
bfd799ad8a Merge "Propogate disabled state to content capture session after changing user restrictions or on ccm.setContentCaptureEnabled()." into qt-dev am: 9f590ef1a9
am: e82f16f82c

Change-Id: I795acfb113c76eb30cea34138410eaff560cfcf7
2019-05-02 16:00:24 -07:00
Matt Pape
55a51bf8d3 Merge "Migrate usage of single property lister to multi prop listener." into qt-dev am: 8e24abad64
am: 554e191d4b

Change-Id: Ibc55770e1e02ed4fb8a44c6f765ec080395068bf
2019-05-01 20:38:19 -07:00
TreeHugger Robot
9f590ef1a9 Merge "Propogate disabled state to content capture session after changing user restrictions or on ccm.setContentCaptureEnabled()." into qt-dev 2019-05-01 23:50:58 +00:00
Matt Pape
15769e2ffa Migrate usage of single property lister to multi prop listener.
Test: atest CtsViewTestCases:TextClassificationManagerTest
      atest FrameworksCoreTests:TextClassificationManagerTest
      atest ExtServicesUnitTests:AssistantSettingsTest
      atest SystemUITests:SmartReplyConstantsTest
      atest FrameworksServicesTests:AutofillManagerServiceTest
      atest FrameworksUiServicesTests:NotificationManagerServiceTest
Bug: 128902955
Change-Id: I00e524b615b3bd03b6b40535410ff7eb2ef6f8ee
2019-04-30 16:35:16 +00:00
Adam He
6c0afca46a Propogate disabled state to content capture session after changing user
restrictions or on ccm.setContentCaptureEnabled().

Bug: 124127364
Test: # manual verification
Change-Id: Ic9688f33f8b9153ab967e5842f939a18fe85412e
2019-04-26 15:22:00 -07:00
Felipe Leme
cbf7f26baa Fixed content capture whitelist for specific activities.
Test: manual verification (it cannot be fully verified using the current CTS setup)
Test: atest CtsContentCaptureServiceTestCases:android.contentcaptureservice.cts.WhitelistTest
Test: atest FrameworksCoreTests:android.content.ContentCaptureOptionsTest
Test: atest CtsContentCaptureServiceTestCases # sanity check
Test: m update-api

Fixes: 130573023
Merged-In: I2c76a01bd98c4154c4c59099f1368232d2dba80d
Change-Id: I2c76a01bd98c4154c4c59099f1368232d2dba80d
2019-04-19 20:25:45 -07:00
Felipe Leme
41e9eb0aed Fixed content capture whitelist for specific activities.
Test: manual verification (it cannot be fully verified using the current CTS setup)
Test: atest CtsContentCaptureServiceTestCases:android.contentcaptureservice.cts.WhitelistTest
Test: atest FrameworksCoreTests:android.content.ContentCaptureOptionsTest
Test: atest CtsContentCaptureServiceTestCases # sanity check
Test: m update-api

Fixes: 130573023
Change-Id: I2c76a01bd98c4154c4c59099f1368232d2dba80d
2019-04-19 19:47:36 -07:00
Felipe Leme
ab08d1de64 Merge "Remove ContentCaptureServerSession when app died." into qt-dev am: 094b9acb0d
am: 11c6dfd0af

Change-Id: I4963ae27992e59b801c51304a181093d2a1b9735
2019-04-18 14:02:09 -07:00
Felipe Leme
6334116065 Remove ContentCaptureServerSession when app died.
Test: manual verification
Test: atest CtsContentCaptureServiceTestCases:android.contentcaptureservice.cts.AppKilledTest

Fixes: 119524920

Change-Id: I324aa7d83721ba078752dda2f91b32d788ce304f
2019-04-16 16:19:37 -07:00
Felipe Leme
ef1c0b36ab DO NOT MERGE - Removed ContentCapture support from standard SDK toolkit.
Test: atest CtsContentCaptureServiceTestCases
Test: m update-api
Test: make ds-docs

Fixes: 129982633

Change-Id: I5a0fa4231d0222638830c1abd8015d9f2635996a
2019-04-15 09:36:25 -07:00
Robert Berry
835123dba2 Add system captions manager service
This service connects to a remote system captions manager service. This
service is responsible for enabling system captions when the user
requests them. As the system binds to it, this service will be
persistent.

Cherry pick from ag/6761232

Bug: 128925852
Test: Manual. I created an implementation of the service.
Merged-In: Iafde1bb68f4754d8167624f47c6833d43c0ec336
Change-Id: Iafde1bb68f4754d8167624f47c6833d43c0ec336
2019-04-07 15:09:06 +00:00
Robert Berry
e14120edf2 Add system captions manager service
This service connects to a remote system captions manager service. This
service is responsible for enabling system captions when the user
requests them. As the system binds to it, this service will be
persistent.

Bug: 128925852
Test: Manual. I created an implementation of the service.
Change-Id: Iafde1bb68f4754d8167624f47c6833d43c0ec336
2019-04-03 20:41:03 -04:00
Felipe Leme
afbba9fb36 Checks package name belongs to called UID on some content capture methods.
Also refactored how the SecurityException is thrown back to the caller app.

Bug: 122959591
Test: manual verification
Test: atest CtsContentCaptureServiceTestCases # sanity check (minus usual flakiness)

Change-Id: I4d2a68e61dc1c801d80734a30f4bbe6fdae8555d
2019-03-28 19:31:52 -07:00
Felipe Leme
a8d33c24f8 Implemented ContentCaptureConditions APIs.
Test: atest ContentCaptureConditionTest \
       CustomViewActivityTest#testContentCaptureConditions \
       CustomViewActivityTest#testContentCaptureConditions_otherPackage
Test: atest CtsContentCaptureServiceTestCases # sanity check (minus usual flakiness)

Fixes: 129266058

Change-Id: I199c3ae99fa6b407da64562a71d8d7581ebf80e6
2019-03-28 18:48:31 -07:00
Felipe Leme
080542019a Refactored ContentCapture sessions to use an int id.
This is an internal change that will save memory:
- ids themselves are smaller (one int vs ~20 chars string)
- can be mapped with SparseArrays
- parcel objects will be smaller

Test: atest CtsContentCaptureServiceTestCases \
  FrameworksCoreTests:android.view.contentcapture.ContentCaptureEventTest \
  FrameworksCoreTests:android.view.contentcapture.ContentCaptureSessionTest

Fixes: 121197119

Change-Id: I4b4367bd7238400ade385c2bcc4b0595ed0b1c7b
2019-03-28 13:50:06 -07:00
Felipe Leme
9bee9440db Fixed ContentCapture and AugmentedAutofill methods that should not hold the main lock...
...otherwise they could ANR the ActivityManagerService and crash the system

Test: manual verification
Test: atest AugmentedLoginActivityTest
Test: atest CtsContentCaptureServiceTestCases # sanity check (minus usual flakiness)

Fixes: 129410913
Bug: 126266412

Change-Id: I4b0b0c389dd2c34928c6fffeec2854518a5e7da1
2019-03-27 17:11:08 -07:00
Adam He
59e96e1464 Reset the whitelist helper for augmented autofill and content capture
when service changes.

Fixes: 128911798
Test: atest CtsContentCaptureServiceTestCases
Test: atest
android.autofillservice.cts.augmented.AugmentedLoginActivityTest

Change-Id: If63b1d1419637764557c87b4e960d6ef32160594
2019-03-26 15:55:39 -07:00
Michal Karpinski
322df0bb74 Modify AbstractRemoteService#mBindInstantServiceAllowed to #mBindingFlags
in order to support multiple binding flags

And supply BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS for RemoteFillService.

Test: atest CtsAutoFillServiceTestCases
Test: atest AutofillManagerServiceTest
Bug: 126267782
Change-Id: Id5262d6a4e0fde0ad874020f783cfbf72fe201f4
2019-03-26 11:07:33 +00:00
TreeHugger Robot
1987dfa035 Merge "Added a "lite" flag on ContentCaptureOptions." 2019-03-23 04:33:21 +00:00
Felipe Leme
6430cbc869 Restricts ContentCapture and AugmentedAutofill when using temporary services.
Test: manual verification
Test: atest CtsContentCaptureServiceTestCases AugmentedLoginActivityTest

Fixes: 120514763

Change-Id: Icb4bfab566ecb041ff77655651b1f6c51551303f
2019-03-22 16:24:36 -07:00
TreeHugger Robot
4f3f18dec3 Merge "Fixed Content Capture workflow when service package is updated." 2019-03-22 23:00:01 +00:00
Felipe Leme
2f28843249 Fixed Content Capture workflow when service package is updated.
The workflow already handles the case where the service dies and the framework re-establishes
the binder connection, but that didn't work when it died because the package was being updated.

This CL fixes this scenario by gracefully pausing the existing sessions before the package is
updated, then resuming them afterwards.

Test: manual verification
Test: atest CtsContentCaptureServiceTestCases # sanity check minus flakiness

Bug: 126266412
Fixes: 129072171

Change-Id: Ibc6b723c7bc08b4f920436f365d6006bc8fac7b6
2019-03-21 18:15:05 -07:00
Felipe Leme
5001b3bb44 Added a "lite" flag on ContentCaptureOptions.
It will be used to let activities from the ContentCapture service package to use
the ContentCaptureManager APIs (such as isContentCaptureFeatureEnabled()), without
triggering content capture per se.

Bug: 122958583
Test: manual verification
Test: atest CtsContentCaptureServiceTestCases # sanity check

Change-Id: I0305fa9f3adb68e6faff80afcb965ae4643f2992
2019-03-21 10:13:49 -07:00
Felipe Leme
f8b8778468 New method ContentCaptureManager.getServiceSettingsComponentName()
Test: manual verification

Test: atest CtsContentCaptureServiceTestCases # sanity check

Bug: 119264902

Change-Id: I3f387386652dad7b187ae04b29f16512ff444ca1
2019-03-20 14:58:53 -07:00
TreeHugger Robot
d766168cda Merge "New autofill cmds to enable / disable / check default augmented service." 2019-03-20 20:42:06 +00:00
Felipe Leme
a5d5e2db8f Added manifest metadata to define the content capture settings activity.
Test: m update-api
Test: mmm frameworks/base/:doc-comment-check-docs
Test: adb shell dumpsys content_capture
Test: CtsContentCaptureServiceTestCases

Bug: 119264902

Change-Id: I656c50d9a45f68312898c8857572d5fe3f55c193
2019-03-20 08:36:24 -07:00