summaryrefslogtreecommitdiff
path: root/cmds/requestsync
diff options
context:
space:
mode:
authorMakoto Onuki <omakoto@google.com>2018-03-28 14:42:42 -0700
committerMakoto Onuki <omakoto@google.com>2018-03-29 14:53:02 -0700
commit75ad2496ebd8162771687510dfe40b5316cb38bc (patch)
tree304a8849055ac733e93287ce529777ea44621096 /cmds/requestsync
parent2011f2333d1b9d0930223dbb3587a40e2d1b80bb (diff)
AppStandby exemption: sync requested by FG apps
Bug: 72443754 Fix: 72443754 Test: atest ${ANDROID_BUILD_TOP}/frameworks/base/services/tests/servicestests/src/com/android/server/content/SyncOperationTest.java Test: Manual test with contacts sync: Precondition: Put the contacts sync in RARE bucket. adb shell dumpsys deviceidle tempwhitelist -r com.google.android.syncadapters.contacts adb shell am make-uid-idle com.google.android.syncadapters.contacts adb shell am set-standby-bucket com.google.android.syncadapters.contacts 40 Test 1: Toggle contacts sync from the Settings -> Account - Make sure a sync happens. Test 2: Mutate a contact on the WEB - Sync is scheduled, but won't run because it has no network access. - am set-standby-bucket com.google.android.syncadapters.contacts 30 - Sync run runs. Test 3. adb shell requestsync -n ACCOUNT -t com.google -a com.android.contacts - Sync is scheduled but won't run. Test 4. adb shell requestsync -n ACCOUNT -t com.google -a com.android.contacts -f - Sync is scheduled but it still won't run. Test 5. adb shell requestsync -n ACCOUNT -t com.google -a com.android.contacts -F - Sync now runs Change-Id: I1eb972ed321d2a1a782ae23ccb806671926d3e6b
Diffstat (limited to 'cmds/requestsync')
-rw-r--r--cmds/requestsync/src/com/android/commands/requestsync/RequestSync.java23
1 files changed, 13 insertions, 10 deletions
diff --git a/cmds/requestsync/src/com/android/commands/requestsync/RequestSync.java b/cmds/requestsync/src/com/android/commands/requestsync/RequestSync.java
index b76d6694ca2d..37b7acfaf5e6 100644
--- a/cmds/requestsync/src/com/android/commands/requestsync/RequestSync.java
+++ b/cmds/requestsync/src/com/android/commands/requestsync/RequestSync.java
@@ -29,23 +29,21 @@ public class RequestSync {
private String[] mArgs;
private int mNextArg;
private String mCurArgData;
- private boolean mIsForegroundRequest;
+
+ private int mExemptionFlag = ContentResolver.SYNC_EXEMPTION_NONE;
enum Operation {
REQUEST_SYNC {
@Override
void invoke(RequestSync caller) {
- if (caller.mIsForegroundRequest) {
- caller.mExtras.putBoolean(
- ContentResolver.SYNC_VIRTUAL_EXTRAS_FORCE_FG_SYNC, true);
- } else {
- caller.mExtras.putBoolean(
- ContentResolver.SYNC_VIRTUAL_EXTRAS_FORCE_BG_SYNC, true);
+ final int flag = caller.mExemptionFlag;
+ caller.mExtras.putInt(ContentResolver.SYNC_VIRTUAL_EXTRAS_EXEMPTION_FLAG, flag);
+ if (flag == ContentResolver.SYNC_EXEMPTION_NONE) {
System.out.println(
"Making a sync request as a background app.\n"
+ "Note: request may be throttled by App Standby.\n"
+ "To override this behavior and run a sync immediately,"
- + " pass a -f option.\n");
+ + " pass a -f or -F option (use -h for help).\n");
}
final SyncRequest request =
new SyncRequest.Builder()
@@ -213,7 +211,10 @@ public class RequestSync {
mExtras.putBoolean(key, Boolean.valueOf(value));
} else if (opt.equals("-f") || opt.equals("--foreground")) {
- mIsForegroundRequest = true;
+ mExemptionFlag = ContentResolver.SYNC_EXEMPTION_ACTIVE;
+
+ } else if (opt.equals("-F") || opt.equals("--top")) {
+ mExemptionFlag = ContentResolver.SYNC_EXEMPTION_ACTIVE_WITH_TEMP;
} else {
System.err.println("Error: Unknown option: " + opt);
@@ -293,7 +294,9 @@ public class RequestSync {
" -a|--authority <AUTHORITY>\n" +
" App-standby related options\n" +
"\n" +
- " -f|--foreground (Exempt a sync from app standby)\n" +
+ " -f|--foreground (cause WORKING_SET, FREQUENT sync adapters" +
+ " to run immediately)\n" +
+ " -F|--top (cause even RARE sync adapters to run immediately)\n" +
" ContentResolver extra options:\n" +
" --is|--ignore-settings: Add SYNC_EXTRAS_IGNORE_SETTINGS\n" +
" --ib|--ignore-backoff: Add SYNC_EXTRAS_IGNORE_BACKOFF\n" +