Commit Graph

2802 Commits

Author SHA1 Message Date
Cassie Wang
34a952cf94 Merge "Ensure calling user is the same as requested user." into sc-dev 2021-07-21 01:03:03 +00:00
TreeHugger Robot
5b6a2aff21 Merge "Stop removing all APP_STANDBY_BUCKET_CHANGED messages." into sc-dev 2021-07-20 23:34:59 +00:00
Kweku Adams
c2f4752a71 Merge "Fix parameter order." into sc-dev 2021-07-20 11:37:09 +00:00
Kweku Adams
63f5d4b699 Stop removing all APP_STANDBY_BUCKET_CHANGED messages.
APP_STANDBY_BUCKET_CHANGED messages are for single apps, so it doesn't
make sense to remove all messages whenever any app's standby bucket
changes.

Bug: 193918191
Test: N/A
Change-Id: I981cd3be3cd381c6d00f06e3da9f8e67f157a26b
Merged-In: I981cd3be3cd381c6d00f06e3da9f8e67f157a26b
2021-07-20 00:14:27 +00:00
Kweku Adams
dbf042c666 Fix parameter order.
AlarmManager.setWindow's parameter order is type -> window start ->
window length. Actually put the values in the correct order.

Bug: 193866265
Test: atest DeviceIdleTest
Test: atest FrameworksMockingServicesTests:DeviceIdleControllerTest
Change-Id: I5c87dad3015859d68aacb6781166432b615327b9
2021-07-19 16:26:54 -07:00
Cassie Wang
3ce6aba403 Ensure calling user is the same as requested user.
This prevents any cross-user requests. Cross-user requests are already
not allowed, but due to a bug elsewhere in the code. This intentionally
handles the case and also throws a SecurityException.

Bug: 193903221
Test: presubmit
Test: manually checked cross-user requests get an exception.
Change-Id: I5bd867b86b972452daa2d8253f3c19f059a8a4b3
2021-07-19 16:17:29 -07:00
Cassie Wang
46db5f1018 Merge "Cache nextPageTokens that a package can use." into sc-dev 2021-07-15 04:14:46 +00:00
TreeHugger Robot
977e2adc14 Merge "Separating alarm history for lower quota" into sc-dev 2021-07-14 20:09:15 +00:00
Kweku Adams
ab7b0e8991 Merge "Restrict all jobs when the device is too hot." into sc-dev 2021-07-14 15:38:19 +00:00
Kweku Adams
b70c941f60 Restrict all jobs when the device is too hot.
Restrict all jobs (and not just connectivity jobs) when the thermal
status is SEVERE+.

Bug: 193269111
Test: atest frameworks/base/services/tests/mockingservicestests/src/com/android/server/job
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/job
Test: atest CtsJobSchedulerTestCases
Change-Id: Id8eed849dfeb26aca1c0743af974c9efadf7fb78
2021-07-13 16:50:54 -07:00
Suprabh Shukla
4e05326a55 Separating alarm history for lower quota
Using a separate container for lower allow-while-idle quota to avoid out
of quota issues. Using the same container means that the lower quota is
out whenever higher quota is used for alarms from the same app.
Lower quota - currently once per 9 minutes - is used in the
following cases:
 - Inexact allow-while-idle alarms. This means the same app can use
 alarms using high quota and low quota simultaneously.
 - When the caller is targeting < S.
 - When the caller is in the power save allowlist, but does not have the
 permission - for exact alarms.

Test: atest CtsAlarmManagerTestCases
Test: atest FrameworkMockingServicesTests:com.android.server.alarm

Bug: 190788800
Change-Id: Iba46fdd36dc04843e9256827b0754d21cfff89c9
2021-07-13 16:19:23 -07:00
Xiaoyu Jin
d4ce296d90 Merge "Register callback to statsD for AppSearchStorageInfo" into sc-dev 2021-07-10 01:20:18 +00:00
Xiaoyu Jin
57bd208139 Register callback to statsD for AppSearchStorageInfo
Bug: b/173532925, b/193254235
Test: statsd_testdrive 10116
      atom {
        app_search_storage_info {
          user: 0
          total_storage_size_bytes: 3929088
          document_storage_info {
            num_alive_documents: 1116
            num_deleted_documents: 4933
            num_expired_documents: 0
            document_store_size_bytes: 3637760
            document_log_size_bytes: 2928640
            key_mapper_size_bytes: 49152
            document_id_mapper_size_bytes: 49152
            score_cache_size_bytes: 122880
            filter_cache_size_bytes: 73728
            corpus_mapper_size_bytes: 20480
            corpus_score_cache_size_bytes: 4096
            namespace_id_mapper_size_bytes: 20480
            num_namespaces: 21
          }
          schema_store_storage_info {
            schema_store_size_bytes: 39424
            num_schema_types: 4
            num_total_sections: 9
            num_schema_types_sections_exhausted: 0
          }
          index_storage_info {
            index_size_bytes: 248320
            lite_index_lexicon_size_bytes: 155648
            lite_index_hit_buffer_size_bytes: 262144
            main_index_lexicon_size_bytes: 0
            main_index_storage_size_bytes: 0
            main_index_block_size_bytes: 4096
            num_blocks: 1
            min_free_fraction: 0.99999905
          }
        }
      }
      appsearch cts tests

Change-Id: I009c0932e36afb467c93013215d1e67dfae5a28a
2021-07-09 17:05:23 -07:00
Terry Wang
878a0d7c8f Merge "Add check for optimize after each mutation operation." into sc-dev 2021-07-09 22:47:24 +00:00
Terry Wang
da0e9a9b37 Add check for optimize after each mutation operation.
Optimize is an important job for AppSearch to work properly.
It could collect garbage and release resources. Without it, the garbage
resource will last forever and the device's space will be fulled up by
zombie documents.

The algorithm to trigger optimize is:
1: Query garbage resource info after a batch of mutation operations.
2: Only trigger optimize if there are enough resource could be released.

The behavior exists in AppSearch Jetpack for a while and working properly
for our Jetpack dogfooders.

Bug: 175255572
Test: FrameworkOptimizeStrategyTest
Test: AppSearchConfigTest
Test: AppSearchImplTest
Change-Id: Ib7ae475cc035d1b69969df1e22ac409895e0e3fa
2021-07-09 12:09:10 -07:00
Tej Singh
7961d27429 Cleanup appsearch platform logger
Test: TH
Bug: 192684294
Change-Id: I8e6828b9cbcbd30d06370ad19f2d36290298da25
2021-07-08 14:45:36 -07:00
Tej Singh
6f5306d6e7 Merge "Cleanup AcitivityManagerConstants and AppSearch" into sc-dev 2021-07-07 17:04:41 +00:00
Tej Singh
77b3d5db92 Cleanup AcitivityManagerConstants and AppSearch
Test: TH
Bug: 192684294
Change-Id: Iaf4d7893214297408f609ce58573846f2b6adf5e
2021-07-02 15:01:11 -07:00
Alexander Dorokhine
e55cf2579c Cache nextPageTokens that a package can use.
A user-package can only manipulate their own nextPageTokens (i.e.
advance or invalidate it) otherwise some other package could affect the
search results of a package. Because we check at the user-package level,
this still allows a package to manipulate nextPageTokens that were
returned for different databases. This isn't recommended, but not a
security risk since it's the package's own data.

Note that manipulating nextPageTokens isn't available through
AppSearch's public API. This would be if someone were circumventing the
normal AppSearchSession.

Bug: 187972715
Test: AppSearchImplTest
Change-Id: I67a22f3ae171ea2886eb89dcf493286a8421408d
2021-07-02 14:50:05 -07:00
Alexander Dorokhine
733537f1a6 Merge "Add ability to enforce limits on docs per package and size of doc." into sc-dev 2021-07-02 01:46:27 +00:00
TreeHugger Robot
e1f4e0f0eb Merge "Change the logic to check car idleness" into sc-dev 2021-07-01 22:24:34 +00:00
Alexander Dorokhine
5a26c6b39c Merge "Move libicing.so out of /usr/lib, into the appsearch apex." into sc-dev 2021-07-01 21:29:56 +00:00
Alexander Dorokhine
5e4a11cd10 Add ability to enforce limits on docs per package and size of doc.
This is needed to prevent abuse of our service and to share icing
docids in framework, which are the resource we are most likely to
run out of.

Without this change, an app could use the platform backend to index
a very high number of documents and exhaust the docid limit, thereby
preventing any other app from using AppSearch.

Bug: 170371356
Test: New testcases added to AppSearchImplTest
Change-Id: I03ade35072bc69b84f8fcefed72b3c3bc2b8ee68
2021-07-01 13:22:08 -07:00
Eric Jeong
919b3ad3d8 Change the logic to check car idleness
- Following the change of device idleness checking, car idleness
tracker considers screen on to determine idleness.
- The condition to get idle in automotive is 1) garage mode is started,
or 2) screen is off and idle is triggered.
- If idleness is forced or garage mode is running, it is considered idle
by car idleness tracker, regardless of screen on/off.

Bug: 182492612
Test: atest android.jobscheduler.cts.IdleConstraintTest
Change-Id: I15e78157c6b1539086e9b39354e5da51186c6535
2021-06-30 15:57:58 -07:00
TreeHugger Robot
d1d3358be9 Merge "Allow power-allowlisted apps to schedule alarm-clocks" into sc-dev 2021-06-30 06:13:59 +00:00
TreeHugger Robot
12ded20343 Merge "Exempt default_input_method from BG-FGS-start restriction." into sc-dev 2021-06-30 03:03:32 +00:00
TreeHugger Robot
4260ce4100 Merge "Improve javadocs for repeating alarms" into sc-dev 2021-06-30 00:55:07 +00:00
Suprabh Shukla
94f5840bed Improve javadocs for repeating alarms
Specifically, mentioning that the alarm count can only be included with
the alarm if the supplied pending intent is mutable.

Test: make offline-sdk-docs

Fixes: 178413211
Change-Id: I2914bceebeed8b52b0de11d70960aa33e6837b13
2021-06-29 17:34:14 -07:00
Paul Duffin
56dc119776 Merge "Enable appsearch to perform its own hidden API processing" into sc-dev 2021-06-29 22:37:46 +00:00
Suprabh Shukla
96da2e8fae Allow power-allowlisted apps to schedule alarm-clocks
They can already use a lot of APIs to perform work in the background
and it simplifies the logic handling permission state changes and the
return value of canScheduleExactAlarms.

The major changes in behavior are:
1. Allowlisted apps can schedule unlimited alarm-clock alarms. This
should be the same as pre-S behavior.
2. If they happen to get the permission revoked, due to whatever reason:
user revocation, deny list, or app update, their alarm-clock alarms will
stay safe like their other exact alarms.
3. The API canScheduleExactAlarms is now true to its name: It returns
true even if the app is allowlisted.

Test: atest CtsAlarmManagerTestCases:ExactAlarmsTest
atest FrameworksMockingServicesTests:AlarmManagerServiceTest

BYPASS_INCLUSIVE_LANGUAGE_REASON=Existing APIs

Bug: 191716678
Bug: 190625528
Change-Id: I420694455f50aac10cf49cd43ff3b98575d86e9f
2021-06-29 15:32:29 -07:00
Hui Yu
20a8ef3c7f Exempt default_input_method from BG-FGS-start restriction.
Bug: 191702190
Test: atest android.app.cts.ActivityManagerFgsBgStartTest#testFgsStartInputMethod
Change-Id: I3bbe6da7afa8e3f2fce3a7c7d5bc40c3c7fd7758
2021-06-29 13:14:43 -07:00
Jing Ji
160fb766f1 Merge "Revert "Kill process if it's cached & idle and in forced-app-standby mode"" into sc-dev 2021-06-29 19:17:17 +00:00
Alexander Dorokhine
24da2e6b35 Move libicing.so out of /usr/lib, into the appsearch apex.
Bug: 169826971
Test: Presubmit
Change-Id: Ibe5dd5014c5a70cb5b0fcf3eb33db9911047bdc8
2021-06-28 19:44:58 -07:00
Paul Duffin
6a87d217c7 Enable appsearch to perform its own hidden API processing
Previously, the hidden API encoding of the appsearch boot dex jars,
i.e. those dex jars that appsearch contributes to the bootclasspath
were done as part of the monolithic hidden API processing. This change
causes the encoding to be done by the appsearch's
bootclasspath_fragment.

This change involves the following:
* Addition of the fragments property to the appsearch's
  bootclasspath_fragment module to list all the other
  bootclasspath_fragment modules on which this depends.
* Addition of the additional_stubs property to add stubs for APIs that
  are not provided by another bootclasspath_fragment.

The build automatically checks that the hidden API flags which are
computed by appsearch and encoded into its boot dex jars match those
that are generated by the monolithic processing so this is guaranteed
to be safe.

Bug: 179354495
Test: m com.android.appsearch
      - ensure that the generated APEX is byte-for-byte identical
        before and after these changes.
      m out/soong/hiddenapi/hiddenapi-flags.csv
      - make sure that they are not changed by this.
Change-Id: I8e5a60d64d3e147535e11a4ad30404f9888f53d2
2021-06-29 02:17:11 +01:00
Jing Ji
453601681d Revert "Kill process if it's cached & idle and in forced-app-standby mode"
This reverts commit 6cf25139a0.

Reason for revert: It results in thrashing the system in some cases

Bug: 192082833
Bug: 152573287
Test: atest FrameworksMockingServicesTests
Test: atest FrameworksServicesTests
Change-Id: I0ca09655b7911857cded5da74169b0c3bd332bda
2021-06-28 16:30:33 -07:00
Kweku Adams
881da35724 Merge "Fix pending job sorting." into sc-dev 2021-06-28 16:29:42 +00:00
Alexander Dorokhine
e665d39fd4 Merge "Port appsearch-service to the system_server_current sdk." into sc-dev 2021-06-28 16:27:55 +00:00
Kweku Adams
a309167072 Avoid unnecessary work.
Only requested-expedited-jobs could have their run-in-bg constraint
change (because of EJ quota) without a corresponding call coming through
the ForceAppStandbyListener. Restrict job evaluation to requested-EJ
jobs to avoid making unnecessary/redundant calls for regular jobs.

Bug: 192105110
Test: atest frameworks/base/services/tests/mockingservicestests/src/com/android/server/job
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/job
Test: atest CtsJobSchedulerTestCases
Change-Id: I9acc45e109c32fb77c79df4fe126a9b1845163ff
2021-06-25 16:43:45 -07:00
Alexander Dorokhine
9da0fe5179 Port appsearch-service to the system_server_current sdk.
The hidden APIs have already been fixed, so this CL mostly changes
build rules.

Bug: 181787682
Bug: 146218515
Test: Presubmit
Change-Id: I5d68d68ce8f39753f62c5e3680216877b7d7f819
2021-06-24 22:58:46 -07:00
Kweku Adams
2700aba1c5 Fix pending job sorting.
We want to always run an app's expedited jobs before its own regular
jobs. This means that we order an app's EJs before its regular jobs. In
order to satisfy the transitivity constraint, we must also order one
app's EJs ahead of a differing app's jobs iff we had to order the first
app's EJ ahead of a job that was earlier than the second app's jobs.

The current sorting system fails the transitivity requirement.

Test case: regJob1 enqueued at t1 for UID A, regJob2 enqueued at t2 for
UID B, EJ3 enqueued at t3 for UID A. Because we expedite EJs, EJ3 is
ordered before regJob1. Because we sort jobs of differing apps by enqueue
time, regJob1 comes before regJob2 and regJob2 comes before EJ3. This
violates transitivity.

The new sorting system will order a later EJ ahead of a differing app's
jobs iff the first app has a regular job that is earlier than the
differing app's first regular job.

Bug: 191592712
Test: atest FrameworksMockingServicesTests:JobSchedulerServiceTest
Test: atest CtsJobSchedulerTestCases
Change-Id: I5391a4f35269d7d43eefc1954788f9df160b1d22
2021-06-24 12:25:33 -07:00
Cassie Wang
f98a5efba1 Merge "Prevent instant apps from using AppSearch." into sc-dev 2021-06-24 02:36:40 +00:00
Cassie Wang
8417a0f253 Prevent instant apps from using AppSearch.
Bug: 181875256
Test: atest -m -c --rebuild-module-info CtsAppSearchHostTestCases
CtsAppSearchTestCases FrameworksCoreTests:android.app.appsearch
FrameworksServicesTests:com.android.server.appsearch

Change-Id: I50fa222f51a9d10395bd6b5815580170561d96d0
2021-06-23 14:15:27 -07:00
Alexander Dorokhine
9a8625df25 Sync framework from jetpack.
Changes included:
* 131d852: Remove usages of hidden APIs in the CTS tests.
* c984c24: Change AppSearchSchema and PropertyConfig #toString()

Bug: 146218515
Bug: 179680545
Test: Presubmit
Change-Id: Ibcef982cfea95ede2ae8e6075a052a83b44298c4
2021-06-23 13:14:01 -07:00
Alexander Dorokhine
4e229f4471 Merge "Update framework from jetpack." into sc-dev 2021-06-23 17:12:36 +00:00
TreeHugger Robot
41e40c69f2 Merge "Tighten up Doze alarm timing." into sc-dev 2021-06-22 22:53:03 +00:00
Alexander Dorokhine
bb978dfe38 Update framework from jetpack.
Changes included:
* 79f2ffe: Fixes required for export.
* e1ca63a: Implement empty schema shouldn't have a version number.
* 8b76be4: Refactor VisibilityStore from a no-op implementation into an interface.
* 47ba533: Remove the max repeatable length limit for GenericDocument
* 52ca287: Add GetSchemaResponse cts test.
* 56585f5: Change PutDocumentsRequestTest to be a cts test.

Bug: 183050495
Bug: 180058203
Bug: 191592792
Bug: 189161227
Bug: 183239766
Test: Presubmit
Change-Id: I30f51a18d697d3a5e43d2c63549ab19a36bbe99e
2021-06-22 12:32:15 -07:00
Alexander Dorokhine
27b63bb150 Merge "Update framework from jetpack." into sc-dev 2021-06-22 17:30:26 +00:00
Suprabh Shukla
a7807022fe canScheduleExactAlarms returns true for older apps
Callers that don't target S can schedule exact alarms so should get a
return value of true when they call canScheduleExactAlarm.

Test: atest FrameworksMockingServicesTests:AlarmManagerServiceTest

Bug: 191328951
Change-Id: I1cd1d0fb3d3d922360494552e653ed540bfe5227
2021-06-21 18:09:35 -07:00
Kweku Adams
aa8f6da7d4 Merge "Allow bucket elevation for timed-out restricted apps." into sc-dev 2021-06-21 20:20:17 +00:00
Alexander Dorokhine
f9d86a4aeb Update framework from jetpack.
Included changes:
* a8c984: Add more tests for logging
* 501a51: Remove some deprecated TODOs.
* 639f25: Add SchemaMigrationStats.
* 0b8885: Use consistent terminology for 3p and system access.
* 064c36: Add a CTS test for snippeting window sizes and max match counts.

Bug: 173532925
Bug: 187879464
Bug: 180058203
Test: Presubmit
Change-Id: I878fd6c7a42cccb237898392aac8c615830eb564
2021-06-18 14:28:34 -07:00