3518 Commits

Author SHA1 Message Date
Jing Ji
a47c4a9853 Exempt carrier priviledged apps in background app restrictions.
Bug: 200326767
Bug: 203105544
Test: atest FrameworksMockingServicesTests:BackgroundRestrictionTest
Change-Id: I9470a7e9483721e0faf19c95b2e7c6129fd1edc7
2022-02-02 10:08:36 -08:00
Kweku Adams
f3a2227b24 Limit min runtime for downgraded EJs.
All jobs with HIGH or MAX priority should have reduced execution
timeouts, including downgraded expedited jobs.

Bug: 142272435
Test: atest FrameworksMockingServicesTests:JobSchedulerServiceTest
Change-Id: I131206fbfa0b58bedbe912b02e44a90ef1e49596
2022-02-02 17:58:21 +00:00
Kweku Adams
d30c9c9992 Merge "Split allowed time by standby bucket." 2022-02-02 16:33:33 +00:00
Sudheer Shanka
6aa536eb7f Merge changes from topics "fg-threshold-config", "track-bg-state"
* changes:
  Make broadcast response fg threshold state configurable.
  Track broadcast dispatched event only when the app is in the bg.
2022-02-01 18:07:40 +00:00
Kweku Adams
86f4c940c8 Split allowed time by standby bucket.
Make it so that each standby bucket can have a different "allowed time"
per its window size. That way, we can say apps in bucket X can run for Y
minutes total in a Z time period.

Also separating EXEMPTED from ACTIVE so that any changes to ACTIVE quota
don't affect EXEMPTED apps when we don't want it to.

Bug: 143495340
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/job
Test: atest frameworks/base/services/tests/mockingservicestests/src/com/android/server/job
Test: atest CtsJobSchedulerTestCases
Change-Id: I2a3f6da75a328505e4091a314a73c0f9d8bbb050
2022-01-31 21:14:22 +00:00
Sudheer Shanka
918d724386 Make broadcast response fg threshold state configurable.
Bug: 206518114
Test: atest tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
Change-Id: Ic28b25393b8ff7d50164535722567d1a4e34f102
2022-01-31 10:40:16 -08:00
Ray Essick
80ab8b926d enable strict_updatability_linting
now that the directory and lint-baseline.xml are both clean.

Bug: 188851874
Test: build, boot
Change-Id: I15bf770dc7d955a615553cf1cc3494450bcc0c2c
2022-01-30 20:46:26 -08:00
Ray Essick
52d326c2f7 cleanup for strict_updatability_linting
add extra annotations, reset lint-baseline.xml files.
The lint-baseline.xml includes code fixes from 2021/11 that had no xml
regeneration. XML files updated with output from the test make commands.

Bug: 188851874
Test: build
Test: m out/soong/.intermediates/frameworks/base/apex/media/framework/updatable-media/android_common_apex29/lint/lint-baseline.xml
Test: m out/soong/.intermediates/frameworks/base/apex/media/service/service-media-s/android_common_apex29/lint/lint-baseline.xml
Change-Id: Iad4d811d4d04dd9901d7290d1342e3aae2c22499
2022-01-29 11:47:25 -08:00
Sudheer Shanka
cc59c25bd1 Make broadcast response window duration configurable.
Bug: 206518114
Test: atest tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
Change-Id: Ifc6792e969304967af7019483fdd1ec242bd2a83
2022-01-28 07:22:30 +00:00
TreeHugger Robot
ea0002f04d Merge "SystemService post-completed user event: jobs" 2022-01-27 18:49:10 +00:00
Karishma Vakil
fd190e8b9a Merge changes from topic "refresh-api"
* changes:
  [SafetyCenter] Add REASON_REFRESH_SAFETY_SOURCES to System API
  [SafetyCenter] Delete refresh API constants from `android.content.Intent`
2022-01-27 16:56:22 +00:00
Jing Ji
354efbc368 Merge changes from topic "bg_app_restrictions"
* changes:
  Expose the bg restriction exemption list as an internal API.
  Add an action button to the notification for bg battery abusive apps
  Exempt certain app behaviors for their background battery usage
  Add tracking on abusive broadcast and service binding requests
  Add exemption cases for app background restrictions
  Monitor long-running foreground services
  Post notification on abusive background current drain
  Allow limited alarms/jobs when background restricted
  Cap the LRU position of broadcast receivers in bg restricted apps
  Add a tracker on background current drains for each uid
  Add background restriction levels definition and its controller
2022-01-27 05:57:18 +00:00
Adam Bookatz
d6e625de2e SystemService post-completed user event: jobs
Use the new onUser completed event for JobSchedulerService.

This delays handling aspects of the user starting/unlock events
(which are important, but not urgent) until a little later.
In particular, it delays the intial job scheduling until a little after
the user has started, instead of immediately.

Test: manual
Bug: 197344658
Change-Id: I78ea7f7822ee466ce34dfc0b9f602fa1a4ceb7c3
2022-01-26 10:16:57 -08:00
Jing Ji
8bca883bf2 Expose the bg restriction exemption list as an internal API.
To share the same exemption policy with task manager.

Bug: 200326767
Bug: 203105544
Test: atest FrameworksMockingServicesTests:BackgroundRestrictionTest
Change-Id: I01c70b501e37f13c516d439533e95061ed4a9ebe
2022-01-25 15:23:28 -08:00
Kevin Jeon
f4f174422a Annotate dump methods with @NeverCompile [1/5]
This change annotates dump/debug methods in services.odex that are
larger than 10000 bytes with NeverCompile so that they will not be
compiled. This results in an overall ~1% decrease in the size of
services.odex.

Bug: 215417388
Test: Build and check that these methods are not called during boot or
      app startup.
Change-Id: I0b8d62c68a6a79c07f2a8a533bf69aee100f0877
2022-01-25 23:03:05 +00:00
Jing Ji
b5f28a5ee6 Allow limited alarms/jobs when background restricted
When app is background restricted, allow alarms/jobs but they'll be
under the quota control of restricted standby bucket.

This behavior is gated by a feature flag now.

Bug: 200326767
Test: atest CtsJobSchedulerTestCases
Test: atest CtsAlarmManagerTestCases
Test: atest FrameworksMockingServicesTests
Change-Id: I154656c19954a306e8ae05dc50ea708c4de2a739
2022-01-25 14:33:21 -08:00
Jing Ji
f0201257ee Merge "Tweak the restricted standby bucket timeout again." 2022-01-25 17:07:49 +00:00
Karishma Vakil
04d0971b07 [SafetyCenter] Add REASON_REFRESH_SAFETY_SOURCES to System API
Test: Will be tested in use in SafetyCenterManager refresh API
Bug: 210431135
Change-Id: Ide16d6c2d18f211840e06e923aa0e92abc4f5a90
2022-01-25 10:08:23 +00:00
Jing Ji
1507931e89 Add background restriction levels definition and its controller
This CL adds the definition of background app restriction levels.

The existing various system background app restriction features will
be mapped into the levels here, including app standby buckets,
background restrictions (forced-app-standby) etc. Future CLs may
apply restrictions to background apps accordingly.

BYPASS_INCLUSIVE_LANGUAGE_REASON=Legacy API name

Bug: 200326767
Test: atest FrameworksMockingServicesTests:BackgroundRestrictionTest
Change-Id: Icf82031c572e7b8e82e6528402e9df4de5b7a675
2022-01-24 18:34:48 -08:00
Kweku Adams
24f779dcf0 Merge "Deferring low and min priority jobs when quota is low." 2022-01-24 22:55:21 +00:00
Kweku Adams
2f3e7488cb Merge "Fix Doze FGS job handling." 2022-01-24 22:53:18 +00:00
Jing Ji
8ab4456078 Tweak the restricted standby bucket timeout again.
Extend the timeout to the restricted standby bucket.

Bug: 200326767
Test: atest AppStandbyControllerTests
Test: atest CtsJobSchedulerTestCases
Change-Id: I36b42c476940cf21e79f1ed09caba9b0376a467c
2022-01-24 14:46:29 -08:00
Kweku Adams
514337c716 Fix Doze FGS job handling.
While in Doze, jobs of apps the Foreground Service proc state or higher
are only exempted if they're expedited or have the
important-while-foreground bit set. We were accidentally considering all
uidActive jobs as exempt, letting the device exit the Doze maintenance
window early, and then stopping the uidActive app's jobs if they weren't
exempted or had the important-while-foreground bit set. This meant that
if only the app running a foreground service had jobs to run and the app
didn't ask for the jobs to be exempted from Doze, the maintenance window
would last for 30 seconds and the jobs would be stopped, but if there
were other background jobs to be run, the maintenance window could last
for the full time (10 minutes or whatever it would be). Fixing the
inconsistency so that we don't exit a maintenance window early when
there are non-exempt jobs running.

Bug: 216150579
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/job
Test: atest frameworks/base/services/tests/mockingservicestests/src/com/android/server/job
Test: atest CtsJobSchedulerTestCases
Change-Id: I07de57b364c9fee995eca020153622ba85d17c96
2022-01-24 21:03:17 +00:00
Karishma Vakil
dd839b26e4 [SafetyCenter] Delete refresh API constants from android.content.Intent
* Suggested by API council to move them to
`android.safetycenter.SafetyCenterManager`

Test: Will be tested in use in SafetyCenterManager refresh API
Bug: 215555855
Change-Id: I4f84ae5a9037b4938f0ba7feb151c50149362fdd
2022-01-24 12:55:06 +00:00
Jing Ji
acda8c6591 Merge "Tweak the restricted standby bucket timeout" 2022-01-23 04:43:02 +00:00
Jing Ji
70acdbf5fa Tweak the restricted standby bucket timeout
Shorten the timeout to the restricted standby bucket, and extend
the minimum required time to the restricted standby bucket.

Bug: 200326767
Test: atest AppStandbyControllerTests
Test: atest CtsJobSchedulerTestCases
Change-Id: I03f16d407942bdab4602361ecac430be9d5d9dcf
2022-01-22 18:39:24 -08:00
Kweku Adams
6765e85033 Deferring low and min priority jobs when quota is low.
Make sure there is some minimum amount of quota available for higher
priority jobs before we start running lower priority jobs.

Bug: 205714315
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/job
Test: atest frameworks/base/services/tests/mockingservicestests/src/com/android/server/job
Test: atest CtsJobSchedulerTestCases
Change-Id: I87919e08684fe1012bfc66d7fae928d04f575637
2022-01-21 22:19:02 +00:00
TreeHugger Robot
cde7c73941 Merge "Declare size outside the loop." 2022-01-21 16:14:04 +00:00
Oliver Woodman
60103fcfb6 MediaSession2Service: Doc notification permission
Test: Javadoc only
Bug: 209461524

Change-Id: I3a0041d6bebcedd0528801fdd37d94230a273479
2022-01-20 17:17:17 +00:00
TreeHugger Robot
ce65b04d56 Merge "Revert "Revert "Migrate unsafe parcel APIs in framework-minus-apex""" 2022-01-20 11:33:39 +00:00
Sudheer Shanka
9d6b131a0b Declare size outside the loop.
Bug: 206518483
Change-Id: Ibeb5b287c549d6641000987acbd36c297df8b8e6
Test: treehugger
2022-01-19 23:21:13 +00:00
Sudheer Shanka
b016336ebe Add a separate device_config key for slice-pinned events.
Bug: 206518483
Test: manual
Change-Id: I6f9929c09c156c5781039dfc177f1f9c5e181d0f
2022-01-19 22:27:40 +00:00
Sudheer Shanka
e21748a999 Merge "Add a knob to change the impact of the notification-seen event." 2022-01-19 22:21:01 +00:00
Bernardo Rufino
1a5cb387d6 Revert "Revert "Migrate unsafe parcel APIs in framework-minus-apex""
This reverts commit 331be9a6431d6489f8d1e1b80cb510d0ee073c50.

Reintroducing ag/16366278 since it seems unrelated to b/214053959 (more details on b/214053959#comment55).

Original commit message:

Migrate unsafe parcel APIs in framework-minus-apex

Migrate the following unsafe parcel APIs in framework-minus-apex:
* Parcel.readSerializable()
* Parcel.readArrayList()
* Parcel.readList()
* Parcel.readParcelable()
* Parcel.readParcelableList()
* Parcel.readSparseArray()

This CL was generated by applying lint fixes that infer the expected
type from the caller code and provide that as the type parameter
(ag/16365240).

A few observations:
* In some classes we couldn't migrate because the class also belonged to
another build module whose min SDK wasn't current (as is the case for
framework-minus-apex), hence I suppressed the lint check
(since I'll eventually submit the lint check to the tree).
* In some cases, I needed to do the cast in
https://stackoverflow.com/a/1080525/5765705 to make the compiler happy
since there isn't another way of providing a class of type
Class<MyClassWithGenerics<T>>.
* In the readSerializable() case, the new API also requires the class
loader, that was inferred to by InferredClass.class.getClassLoader().
* Note that automatic formatting and import rely on running hooked up
to the IDE, which wasn't the case here.

Bug: 195622897
Change-Id: I272432e6e082a973f7a50492ec35d79c2b577c93
Test: TH passes
2022-01-19 11:13:18 +00:00
Karishma Vakil
80ecc67235 [SafetyCenter] Add reason code for ACTION_REFRESH_SAFETY_SOURCES to place an app on temp allowlist to start a fg service.
* See BroadcastOptions#setTemporaryAppAllowlist(long duration, @TempAllowListType int type, @ReasonCode int reasonCode, @Nullable String reason)

Test: Will be added once the constant is used in SafetyCenterService
Bug: 210431135
Change-Id: I466d4e9cfa722b04343121f09e0cb52f99580581
2022-01-18 11:42:44 +00:00
Kweku Adams
bfb0de3010 Merge "Satisfy charging constraint earlier for top apps." 2022-01-14 20:35:34 +00:00
Kweku Adams
9bbddb7302 Satisfy charging constraint earlier for top apps.
Several releases ago, we delayed the CHARGING broadcast to ~15 minutes
after the device was plugged in. This means that any job that specifies
a charging constraint won't have the constraint satisfied until 15 minutes
after the device is plugged in. If such a job's setting is explicitly set
by the user and the user plugs in their device while the app is on top,
they will see that the work doesn't start immediately. This would be
confusing for the user. We now the top app's charging constraint jobs
as satisfied when the device is plugged in to avoid this confusion. If
any TOP app's charging constraint jobs start while the app is on top,
the job will be allowed to continue running after the user leaves the
app as long as the device is plugged in. Any jobs that didn't start will
be treated regularly and will have to wait for the CHARGING broadcast.

Bug: 198624541
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/job
Test: atest frameworks/base/services/tests/mockingservicestests/src/com/android/server/job
Test: atest CtsJobSchedulerTestCases
Change-Id: I914176d7bf9fd4a8998c05d411483bd4607589f2
2022-01-14 16:45:02 +00:00
Etienne Ruffieux
83335e4890 Merge "Added SystemApi annotation to REASON_BLUETOOTH_BROADCAST" am: 77b596f2bf am: e1e07765ba am: 6198337c7a am: 1f6d26d5cb
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1946687

Change-Id: Iba33aecaa4ee7e4fd207db7b64e23214cc131cfb
2022-01-14 09:43:21 +00:00
Etienne Ruffieux
77b596f2bf Merge "Added SystemApi annotation to REASON_BLUETOOTH_BROADCAST" 2022-01-14 08:43:13 +00:00
Sudheer Shanka
6fce6e66ed Add a knob to change the impact of the notification-seen event.
Currently, notification-seen event will promote an app to
Working set bucket. This change adds a knob to allow changing
the bucket that the app gets promoted to on a notification-seen
event.

This change also updates AppStandbyController logic to allow
setting timeouts for buckets other than Active and Working set.

Bug: 206518483
Test: atest --test-mapping apex/jobscheduler/service/java/com/android/server/usage/TEST_MAPPING
Change-Id: Ic818c3871a34107b86b97c983285214beea220a5
2022-01-14 03:47:32 +00:00
Etienne Ruffieux
7363fc0a38 Added SystemApi annotation to REASON_BLUETOOTH_BROADCAST
As Android Bluetooth becomes a mainline module, we need to
remove all hidden API usages. BluetoothManagerService is
using REASON_BLUETOOTH_BROADCAST so we have to make it
accessible to the Bluetooth module.

Tag: #feature
Bug: 211851706
Test: make
Change-Id: I99ade4673836c068b2e643ce5e56d9ad0454233f
2022-01-13 18:43:50 +00:00
TreeHugger Robot
a39fb4cde0 Merge "Revert "Make MediaParser depend on the latest Exo version"" 2022-01-13 03:12:39 +00:00
TreeHugger Robot
f434a1e931 Merge "Combine battery trackers." 2022-01-13 00:39:09 +00:00
Ashwini Oruganti
776b439703 Merge "Revert "Migrate unsafe parcel APIs in framework-minus-apex"" 2022-01-12 23:07:08 +00:00
Bernardo Rufino
331be9a643 Revert "Migrate unsafe parcel APIs in framework-minus-apex"
This reverts commit 90bb3709dc75f7e44914222114752de5bce133d4.

Reason for revert: b/214053959

Change-Id: Ic271bab1d3eaf677a5989dda9deb944ee2ad6850
2022-01-12 17:44:44 +00:00
Kweku Adams
b32b6aed4e Combine battery trackers.
Combine the separate Controller battery/charging trackers into one so
that JobScheduler only has to receive the battery change broadcasts once
to update all of the state. This also makes testing easier since the
test can be sure that once the battery sequence is updated, all of JS
has processed the battery state change.

Bug: 141645789
Bug: 213277873
Test: atest --rerun-until-failure 25 CtsJobSchedulerTestCases:android.jobscheduler.cts.JobThrottlingTest#testRestrictingStopReason_Quota
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/job
Test: atest frameworks/base/services/tests/mockingservicestests/src/com/android/server/job
Test: atest CtsJobSchedulerTestCases
Change-Id: I7151798f17c177eb5e86a6ec51c2d545768a4fcd
2022-01-12 15:45:18 +00:00
Santiago Seifert
91effa2ad2 Revert "Make MediaParser depend on the latest Exo version"
Revert "Update cts to depend on new ExoPlayer version"

Revert submission 16527581-update_exoplayer_version

Reason for revert: b/213856810
Reverted Changes:
I231cf3512:Update cts to depend on new ExoPlayer version
I26f7159a7:Make MediaParser depend on the latest Exo version
Id69a309ce:Update MediaParser's ExoPlayer version

Change-Id: I84fbc379ec4868d1a81a3abcabb61ccaa919972c
2022-01-12 11:32:14 +00:00
Treehugger Robot
18f92370b5 Merge "Pruning departed users from OWNERS" am: b77890ae5e am: ebeefc7ebe am: af5c498c7b am: ff7e7e6844
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1946368

Change-Id: I33888e43836ea9d98aa57cebc82656f4604233c9
2022-01-12 11:25:22 +00:00
TreeHugger Robot
6df6d02ad2 Merge "media: don't reuse ParceledListSlices" 2022-01-12 04:55:39 +00:00
Ray Essick
1feb6240ca Pruning departed users from OWNERS
Bug: 206221953
Test: n
Change-Id: I48f21abae63d418e27224db2ecf0cbc177ff4f17
2022-01-11 20:33:22 -08:00