OSDN Git Service

Tweak exemption for sync requests made by FG apps
authorMakoto Onuki <omakoto@google.com>
Tue, 22 May 2018 23:02:17 +0000 (16:02 -0700)
committerMakoto Onuki <omakoto@google.com>
Wed, 23 May 2018 21:50:05 +0000 (14:50 -0700)
commitd5f25d2cd882c89965b6538082556d9469f72288
tree35933c6e4705b547df7e96cff84f38139d7d475f
parentfab8e71697c3ab47ad3e53864b22542a9a34fa2f
Tweak exemption for sync requests made by FG apps

Exemption given to a sync request made by a foreground app (including
PROCESS_STATE_IMPORTANT_FOREGROUND).
At the schedule time, we promote the sync adapter app for a higher bucket:
- If the device is not dozing (so the sync will start right away)
  promote to ACTIVE for 1 hour.
- If the device is dozing (so the sync *won't* start right away),
promote to WORKING_SET for 4 hours, so it'll get a higher chance to be started once the
device comes out of doze.
- When the sync actually starts, we promote the sync adapter app to ACTIVE for 10 minutes,
so it can schedule and start more syncs without getting throttled, even when the first
operation was canceled and now we're retrying.

Test: atest cts/tests/tests/syncmanager/
Test: Manual test with "requestsync -f" and "am set-standby-bucket", while checking
"dumpsys usagestats"
Test: settings put global app_idle_constants \
  exempted_sync_scheduled_nd_duration=1,exempted_sync_scheduled_d_duration=2,exempted_sync_start_duration=3
  and check "dumpsys usagestats" and make sure the constants are properly updated.
Fixes: 72443754

Change-Id: I233d8e4be85769150830bac798abc04810f4cc7b
cmds/requestsync/src/com/android/commands/requestsync/RequestSync.java
core/java/android/app/usage/UsageStatsManager.java
core/java/android/app/usage/UsageStatsManagerInternal.java
core/java/android/content/ContentResolver.java
services/core/java/com/android/server/content/ContentService.java
services/core/java/com/android/server/content/SyncManager.java
services/core/java/com/android/server/content/SyncOperation.java
services/core/java/com/android/server/content/SyncStorageEngine.java
services/tests/servicestests/src/com/android/server/usage/AppStandbyControllerTests.java
services/usage/java/com/android/server/usage/AppStandbyController.java
services/usage/java/com/android/server/usage/UsageStatsService.java