final Object mAgentConnectLock = new Object();
IBackupAgent mConnectedAgent;
volatile boolean mConnecting;
- volatile boolean mBackupOrRestoreInProgress = false;
volatile long mLastBackupPass;
volatile long mNextBackupPass;
// Persistently track the need to do a full init
static final String INIT_SENTINEL_FILE_NAME = "_need_init_";
HashSet<String> mPendingInits = new HashSet<String>(); // transport names
- volatile boolean mInitInProgress = false;
// ----- Asynchronous backup/restore handler thread -----
IBackupTransport transport = getTransport(mCurrentTransport);
if (transport == null) {
Log.v(TAG, "Backup requested but no transport available");
- synchronized (mQueueLock) {
- mBackupOrRestoreInProgress = false;
- }
mWakelock.release();
break;
}
(new PerformBackupTask(transport, queue, oldJournal)).run();
} else {
Log.v(TAG, "Backup requested but nothing pending");
- synchronized (mQueueLock) {
- mBackupOrRestoreInProgress = false;
- }
mWakelock.release();
}
}
// can't really do more than bail here
}
} else {
- // Don't run backups now if we're disabled, not yet
- // fully set up, in the middle of a backup already,
- // or racing with an initialize pass.
- if (mEnabled && mProvisioned
- && !mBackupOrRestoreInProgress && !mInitInProgress) {
+ // Don't run backups now if we're disabled or not yet
+ // fully set up.
+ if (mEnabled && mProvisioned) {
if (DEBUG) Log.v(TAG, "Running a backup pass");
- mBackupOrRestoreInProgress = true;
// Acquire the wakelock and pass it to the backup thread. it will
// be released once backup concludes.
Message msg = mBackupHandler.obtainMessage(MSG_RUN_BACKUP);
mBackupHandler.sendMessage(msg);
} else {
- Log.w(TAG, "Backup pass but e=" + mEnabled + " p=" + mProvisioned
- + " b=" + mBackupOrRestoreInProgress + " i=" + mInitInProgress);
+ Log.w(TAG, "Backup pass but e=" + mEnabled + " p=" + mProvisioned);
}
}
}
if (RUN_INITIALIZE_ACTION.equals(intent.getAction())) {
synchronized (mQueueLock) {
if (DEBUG) Log.v(TAG, "Running a device init");
- mInitInProgress = true;
// Acquire the wakelock and pass it to the init thread. it will
// be released once init concludes.
if (status == BackupConstants.TRANSPORT_NOT_INITIALIZED) {
// The backend reports that our dataset has been wiped. We need to
// reset all of our bookkeeping and instead run a new backup pass for
- // everything. This must come after mBackupOrRestoreInProgress is cleared.
+ // everything.
EventLog.writeEvent(EventLogTags.BACKUP_RESET, mTransport.transportDirName());
resetBackupState(mStateDir);
}
Log.e(TAG, "Unable to remove backup journal file " + mJournal);
}
- // Only once we're entirely finished do we indicate our completion
- // and release the wakelock
- synchronized (mQueueLock) {
- mBackupOrRestoreInProgress = false;
- }
-
+ // Only once we're entirely finished do we release the wakelock
if (status == BackupConstants.TRANSPORT_NOT_INITIALIZED) {
- // This must come after mBackupOrRestoreInProgress is cleared.
backupNow();
}
}
// done; we can finally release the wakelock
- synchronized (mQueueLock) {
- mBackupOrRestoreInProgress = false;
- }
mWakelock.release();
}
}
}
// Last but not least, release the cpu
- synchronized (mQueueLock) {
- mBackupOrRestoreInProgress = false;
- }
mWakelock.release();
}
}
} catch (Exception e) {
Log.e(TAG, "Unexpected error performing init", e);
} finally {
- // Done; indicate that we're finished and release the wakelock
- synchronized (mQueueLock) {
- mInitInProgress = false;
- }
+ // Done; release the wakelock
mWakelock.release();
}
}
}
synchronized (mQueueLock) {
- if (mBackupOrRestoreInProgress) {
- Log.e(TAG, "Backup pass in progress, restore aborted");
- return -1;
- }
-
for (int i = 0; i < mRestoreSets.length; i++) {
if (token == mRestoreSets[i].token) {
long oldId = Binder.clearCallingIdentity();
- // Suppress backups until the restore operation is finished
- mBackupOrRestoreInProgress = true;
mWakelock.acquire();
Message msg = mBackupHandler.obtainMessage(MSG_RUN_RESTORE);
msg.obj = new RestoreParams(mRestoreTransport, observer, token);
synchronized (mQueueLock) {
pw.println("Backup Manager is " + (mEnabled ? "enabled" : "disabled")
+ " / " + (!mProvisioned ? "not " : "") + "provisioned / "
- + (!mBackupOrRestoreInProgress ? "not " : "") + "in progress / "
- + (this.mPendingInits.size() == 0 ? "not " : "") + "pending init / "
- + (!mInitInProgress ? "not " : "") + "initializing");
+ + (this.mPendingInits.size() == 0 ? "not " : "") + "pending init");
pw.println("Last backup pass: " + mLastBackupPass
+ " (now = " + System.currentTimeMillis() + ')');
pw.println(" next scheduled: " + mNextBackupPass);