Merge "Use JobScheduler's storage-not-low constraint." into sc-dev
This commit is contained in:
@@ -193,12 +193,6 @@ public class SyncManager {
|
||||
*/
|
||||
private static final int SYNC_MONITOR_PROGRESS_THRESHOLD_BYTES = 10; // 10 bytes
|
||||
|
||||
/**
|
||||
* If a previously scheduled sync becomes ready and we are low on storage, it gets
|
||||
* pushed back for this amount of time.
|
||||
*/
|
||||
private static final long SYNC_DELAY_ON_LOW_STORAGE = 60*60*1000; // 1 hour
|
||||
|
||||
/**
|
||||
* If a sync becomes ready and it conflicts with an already running sync, it gets
|
||||
* pushed back for this amount of time.
|
||||
@@ -242,7 +236,6 @@ public class SyncManager {
|
||||
|
||||
volatile private PowerManager.WakeLock mSyncManagerWakeLock;
|
||||
volatile private boolean mDataConnectionIsConnected = false;
|
||||
volatile private boolean mStorageIsLow = false;
|
||||
private volatile int mNextJobIdOffset = 0;
|
||||
|
||||
private final NotificationManager mNotificationMgr;
|
||||
@@ -312,31 +305,6 @@ public class SyncManager {
|
||||
return pendingSyncs;
|
||||
}
|
||||
|
||||
private final BroadcastReceiver mStorageIntentReceiver =
|
||||
new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (Intent.ACTION_DEVICE_STORAGE_LOW.equals(action)) {
|
||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
||||
Slog.v(TAG, "Internal storage is low.");
|
||||
}
|
||||
mStorageIsLow = true;
|
||||
cancelActiveSync(
|
||||
SyncStorageEngine.EndPoint.USER_ALL_PROVIDER_ALL_ACCOUNTS_ALL,
|
||||
null /* any sync */,
|
||||
"storage low");
|
||||
} else if (Intent.ACTION_DEVICE_STORAGE_OK.equals(action)) {
|
||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
||||
Slog.v(TAG, "Internal storage is ok.");
|
||||
}
|
||||
mStorageIsLow = false;
|
||||
rescheduleSyncs(EndPoint.USER_ALL_PROVIDER_ALL_ACCOUNTS_ALL,
|
||||
"storage ok");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final BroadcastReceiver mAccountsUpdatedReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
@@ -650,10 +618,6 @@ public class SyncManager {
|
||||
IntentFilter intentFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||
context.registerReceiver(mConnectivityIntentReceiver, intentFilter);
|
||||
|
||||
intentFilter = new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW);
|
||||
intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK);
|
||||
context.registerReceiver(mStorageIntentReceiver, intentFilter);
|
||||
|
||||
intentFilter = new IntentFilter(Intent.ACTION_SHUTDOWN);
|
||||
intentFilter.setPriority(100);
|
||||
context.registerReceiver(mShutdownIntentReceiver, intentFilter);
|
||||
@@ -1654,6 +1618,7 @@ public class SyncManager {
|
||||
new ComponentName(mContext, SyncJobService.class))
|
||||
.setExtras(syncOperation.toJobInfoExtras())
|
||||
.setRequiredNetworkType(networkType)
|
||||
.setRequiresStorageNotLow(true)
|
||||
.setPersisted(true)
|
||||
.setPriority(priority)
|
||||
.setFlags(jobFlags);
|
||||
@@ -2201,7 +2166,9 @@ public class SyncManager {
|
||||
}
|
||||
pw.println();
|
||||
}
|
||||
pw.print("Memory low: "); pw.println(mStorageIsLow);
|
||||
Intent storageLowIntent =
|
||||
mContext.registerReceiver(null, new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW));
|
||||
pw.print("Storage low: "); pw.println(storageLowIntent != null);
|
||||
pw.print("Clock valid: "); pw.println(mSyncStorageEngine.isClockValid());
|
||||
|
||||
final AccountAndUser[] accounts = AccountManagerService.getSingleton().getAllAccounts();
|
||||
@@ -3188,11 +3155,6 @@ public class SyncManager {
|
||||
|
||||
SyncJobService.markSyncStarted(op.jobId);
|
||||
|
||||
if (mStorageIsLow) {
|
||||
deferSyncH(op, SYNC_DELAY_ON_LOW_STORAGE, "storage low");
|
||||
return;
|
||||
}
|
||||
|
||||
if (op.isPeriodic) {
|
||||
// Don't allow this periodic to run if a previous instance failed and is currently
|
||||
// scheduled according to some backoff criteria.
|
||||
|
||||
Reference in New Issue
Block a user