Merge "Don't mix "current dataset" tokens for different backup transports" into oc-dev
am: 70a2316ec7
Change-Id: Ifc4be7cab333d1956b3b6543e846489f686981ed
This commit is contained in:
@@ -2387,7 +2387,7 @@ public class BackupManagerService {
|
||||
|
||||
long token = mAncestralToken;
|
||||
synchronized (mQueueLock) {
|
||||
if (mEverStoredApps.contains(packageName)) {
|
||||
if (mCurrentToken != 0 && mEverStoredApps.contains(packageName)) {
|
||||
if (MORE_DEBUG) {
|
||||
Slog.i(TAG, "App in ever-stored, so using current token");
|
||||
}
|
||||
@@ -10464,8 +10464,7 @@ if (MORE_DEBUG) Slog.v(TAG, " + got " + nRead + "; now wanting " + (size - soF
|
||||
final long oldId = Binder.clearCallingIdentity();
|
||||
try {
|
||||
String prevTransport = mTransportManager.selectTransport(transport);
|
||||
Settings.Secure.putString(mContext.getContentResolver(),
|
||||
Settings.Secure.BACKUP_TRANSPORT, transport);
|
||||
updateStateForTransport(transport);
|
||||
Slog.v(TAG, "selectBackupTransport() set " + mTransportManager.getCurrentTransportName()
|
||||
+ " returning " + prevTransport);
|
||||
return prevTransport;
|
||||
@@ -10488,9 +10487,7 @@ if (MORE_DEBUG) Slog.v(TAG, " + got " + nRead + "; now wanting " + (size - soF
|
||||
@Override
|
||||
public void onSuccess(String transportName) {
|
||||
mTransportManager.selectTransport(transportName);
|
||||
Settings.Secure.putString(mContext.getContentResolver(),
|
||||
Settings.Secure.BACKUP_TRANSPORT,
|
||||
mTransportManager.getCurrentTransportName());
|
||||
updateStateForTransport(mTransportManager.getCurrentTransportName());
|
||||
Slog.v(TAG, "Transport successfully selected: " + transport.flattenToShortString());
|
||||
try {
|
||||
listener.onSuccess(transportName);
|
||||
@@ -10513,6 +10510,28 @@ if (MORE_DEBUG) Slog.v(TAG, " + got " + nRead + "; now wanting " + (size - soF
|
||||
Binder.restoreCallingIdentity(oldId);
|
||||
}
|
||||
|
||||
private void updateStateForTransport(String newTransportName) {
|
||||
// Publish the name change
|
||||
Settings.Secure.putString(mContext.getContentResolver(),
|
||||
Settings.Secure.BACKUP_TRANSPORT, newTransportName);
|
||||
|
||||
// And update our current-dataset bookkeeping
|
||||
IBackupTransport transport = mTransportManager.getTransportBinder(newTransportName);
|
||||
if (transport != null) {
|
||||
try {
|
||||
mCurrentToken = transport.getCurrentRestoreSet();
|
||||
} catch (Exception e) {
|
||||
// Oops. We can't know the current dataset token, so reset and figure it out
|
||||
// when we do the next k/v backup operation on this transport.
|
||||
mCurrentToken = 0;
|
||||
}
|
||||
} else {
|
||||
// The named transport isn't bound at this particular moment, so we can't
|
||||
// know yet what its current dataset token is. Reset as above.
|
||||
mCurrentToken = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Supply the configuration Intent for the given transport. If the name is not one
|
||||
// of the available transports, or if the transport does not supply any configuration
|
||||
// UI, the method returns null.
|
||||
|
||||
@@ -182,13 +182,13 @@ class TransportManager {
|
||||
|
||||
String[] getBoundTransportNames() {
|
||||
synchronized (mTransportLock) {
|
||||
return mBoundTransports.keySet().toArray(new String[0]);
|
||||
return mBoundTransports.keySet().toArray(new String[mBoundTransports.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
ComponentName[] getAllTransportCompenents() {
|
||||
synchronized (mTransportLock) {
|
||||
return mValidTransports.keySet().toArray(new ComponentName[0]);
|
||||
return mValidTransports.keySet().toArray(new ComponentName[mValidTransports.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user