Commit Graph

126 Commits

Author SHA1 Message Date
TreeHugger Robot
9145f4a488 Merge "Ensure we clear mPackagesWithShareRequests when a remote exception happens at write() or start()." into sc-qpr1-dev am: 7207d8d032
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16174880

Change-Id: If8fdbfe1c02a4b9cb0122c18d4d2a11d531c7e21
2021-11-03 11:49:10 +00:00
Sergey Volnov
063fe636ba Ensure we clear mPackagesWithShareRequests when a remote exception
happens at write() or start().

Bug: 203784652
Test: atest CtsContentCaptureServiceTestCases
Change-Id: I35d8c8056dc126c44f03b74a04090861224a9407
(cherry picked from commit 39d8062aec)
2021-11-02 18:18:08 +00:00
Joanne Chung
4fc5c86bb9 Rebind ContentCaptureService when the binderDied.
If the ContentCaptureService has package dependency with other
package, if the package is updating, ContentCaptureService will also
be killed.

In the normal case, if the service will be reconnected but in this
case the binding is cleared without any notification to the
ContentCaptureManagerService. The bug is in the core platform infra.
In the Content Capture code, we only see the binderDied.

This change is a short term solution in S, we will rebind the service
when the binderDied. To avoid crash loop, we only bind the service
with limit rebind counts.

Bug: 199609306
Test: manual. Add addPackageDependency to package and update the
package. Make sure the state is not zombie.

Change-Id: I09a4cf6281a5a259a9a759ca640d6f075726e562
2021-11-02 07:56:10 +00:00
Jieru Shi
570adf55c8 Add logging for remote service died for CCAPI.
Test: manual
Bug: 201480600
Change-Id: I91ecee33681449d5360660e8bcb330bba929813f
2021-09-30 22:15:51 -07:00
Adam He
d9e69e2b50 Content Capture change to send window token on creating session.
Bug: 189477723
Test: atest CtsContentCaptureTestCases
Change-Id: I70a0be583faae1a18c61e70c72a3d2a8e9e46438
2021-09-22 17:06:50 +00:00
Sergey Volnov
eacb8c8aee Fix content capture not being usable from hotword detector.
Bug: 194534612
Test: local repro
Change-Id: I58e5c68ea486b4da2f82b9d89440f86a8d507727
2021-07-27 12:38:31 +01:00
Alex Mang
e1d8be7afe Switch over RemoteCallbackList to handle callbacks.
Increases complexity, but given the limited # of apps a user has, this shouldn't be a big problem.

Bug: 162609730
Tested: atest WhitelistTest, Manually on device
Change-Id: I4504b7eb7b503a95d663c375f481c997022d23fe
2021-03-18 11:17:54 -07:00
Alex Mang
d77366e4f2 Merge "Propagate ContentCaptureManager allowlist update to activities" into sc-dev 2021-03-04 02:26:25 +00:00
Joanne Chung
af76755ff7 Update ContentCaptureContext to have a token information
In order to support auto translation, we need to give information to
content capture service to let the app can use this information to
find the Activity which needed to be translated.

It's not safe to provide an activity token to the client app directly
even if it is a privilege app. They can use this activity token to
access many activity/windows related functions. We create a new token
for use for content capture and translation. This token will be used
get the target Activity for translation new APIs.

This change focuses on the Content capture API change, the API change
about translation will be done in the next change,

Bug: 177789967
Test: manual. Make sure cc service can get the information.
Test: atest android.view.contentcapture.ContentCaptureContextTest
Test: atest CtsContentCaptureServiceTestCases

Change-Id: Ife8096a8bd1e71ce4e686d95043e347222ad7ee6
2021-03-02 06:47:48 +00:00
Alex Mang
842dd79ec5 Propagate ContentCaptureManager allowlist update to activities
Ref Doc: go/propagate-ccm-allowlist

BYPASS_INCLUSIVE_LANGUAGE_REASON=logging existing function call name
Tested: manually on device
Bug: 177345035
Bug: 165025636

Change-Id: I46c41a1e3e8a91a08889f5505e5bc1510776e253
2021-03-01 22:26:02 -08:00
kholoud mohamed
28913aa2f9 Add testAPIs in ContentCaptureManager
Added the following static testAPIs to replace
the usage of adb commands in cts/gts tests:
* resetTemporaryService
* setTemporaryService
* setDefaultServiceEnabled
These APIs are static because by default ContentCaptureManager
isn't available until it's enabled using these APIs.

Test: Confirmed that the APIs are accessible in CTS tests.
Bug: 180328483
Change-Id: I0a94d90b509e1d2f695556955d85d27acab19ae9
2021-03-01 15:43:20 +00:00
Jeff Sharkey
4b5b0174d0 Merge changes from topic "sep11" am: c0b288133a am: 69e6f07347 am: 741c0a78cc am: da7478b570 am: 487d394296
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1426195

Change-Id: Id01f468b43fd5b2aada78608010625b392c1b647
2020-09-15 21:01:48 +00:00
Jeff Sharkey
9b37625b9b Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

Test: none
Bug: 168334533
Exempt-From-Owner-Approval: docs updates
Change-Id: Ia37d0180a2d687fa788eea854f7d89ad5faab593
2020-09-14 10:00:14 -06:00
Jeff Sharkey
05e513d1c5 Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

Test: none
Bug: 168334533
Exempt-From-Owner-Approval: docs updates
Change-Id: I8aa4186f44957fc69aebceeeff1e6584b4eebd5a
2020-09-14 10:00:12 -06:00
Jeff Sharkey
4172f8a62c Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

Test: none
Bug: 168334533
Exempt-From-Owner-Approval: docs updates
Change-Id: If75259aab72329f9f8b0e1972a96370ca5134e2c
2020-09-14 10:00:10 -06:00
Felipe Leme
7a907dbe46 Refactored user switch workflow to decouple UserInfo from TargetUser.
UserController calls SystemServiceManager on some stages of the user
switch lifecycle, and SystemServiceManager calls the respective
callbacks in the SystemService objects it manage.

Prior to Android 11, these callbacks would take a @UserIdInt userid,
but now they take a TargetUser (which in turns contains a Userinfo).
So, currently, UserController calls SystemServiceManager passing the
userid, and SystemServiceManager gets the UserInfo from
UserManagerService. That works fine most of the time, but there might
be some race conditions when a user is removed that can crash the
system when such user is stopped (because UserManagerService doesn't
have its UserInfo anymore).

This CL fixes this issue by refactoring the user switch workflow so:

- TargetUser doesn't hold a reference to the UserInfo anymore, but
  offer the methods needed by SystemService implementations.
- SystemServiceManager keeps track of the TargetUser objects used in
  the callbacks.

Test: manual verification

Fixes: 159831354

Change-Id: If68ab1b5e247c7389c8cac16432d8b8809507e86
2020-08-13 16:56:34 -07:00
Yara Hassan
be678673b3 Catch RemoteExceptions in DataShareCallbackDelegate
Catch the RemoteExceptions thrown in DataShareCallback's accept() and
reject() methods, as throwing an exception could result in the
ContentCaptureService crashing.

Bug: 159213080
Fixes: 159213080
Test: ran cts tests
Change-Id: I4ce8f15c835fba665a0657c7b3ed898f4e091b19
2020-06-19 15:01:45 +01:00
Yara Hassan
faf50e11cb Add westworld logging for CCAPI data share
Bug: 158295023
Fixes: 158295023
Test: ran cts tests
Change-Id: I8309404452a45291650735be9da76a8b08c6dcb6
2020-06-16 16:23:48 +00:00
Yara Hassan
cf146dfa39 Handle sender's crash in Data Share API
Implement IBinder.DeathRecipient in DataShareCallbackDelegate to listen
to the client's death and send an error to the CC service.

Test: CTS test
Bug: 157141129
Fixes: 157141129
Change-Id: I30f08f8ed741988ebcf585d74168d4dda03663a8
2020-05-29 14:36:22 -07:00
TreeHugger Robot
219daf9eef Merge "Close a file descriptor that's a copy of the one that the receiver receives." into rvc-dev 2020-05-29 19:01:30 +00:00
Sergey Volnov
3b3445d5e5 Close a file descriptor that's a copy of the one that the receiver
receives.

That is to give ability to the receiving end to close the stream and by
that cancel the copy operation.

Test: CTS in a parallel commit
Bug: 157141129
Change-Id: I1da1a47d7f8a7a5208644cf6e1266a3a2a724c17
2020-05-29 18:19:04 +01:00
Sergey Volnov
da8e520a89 Add BIND_INCLUDE_CAPABILITIES flag to ContentCaptureService
Bug: 153621002
Test: built Android
Change-Id: Ieedcd7ad888ef69e47f6f7c6df63a514eee75781
2020-05-28 16:17:04 +01:00
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 13f65b2974)
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 58e7458ac7)
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
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