diff options
author | Christopher Tate <ctate@google.com> | 2011-06-07 15:35:45 -0700 |
---|---|---|
committer | Christopher Tate <ctate@google.com> | 2011-06-07 15:35:45 -0700 |
commit | ec5d4a0f9765f1645ab2e28ad2ef3cad247a042b (patch) | |
tree | 6cec225eb6cad8b0e3adb5447a10b151680f4f84 /packages/BackupRestoreConfirmation/src/com/android/backupconfirm | |
parent | 65abc4531f1222ffa04350a3afc6d61fcc77b2a3 (diff) | |
download | frameworks_base-ec5d4a0f9765f1645ab2e28ad2ef3cad247a042b.zip frameworks_base-ec5d4a0f9765f1645ab2e28ad2ef3cad247a042b.tar.gz frameworks_base-ec5d4a0f9765f1645ab2e28ad2ef3cad247a042b.tar.bz2 |
Don't ack/nak backup redundantly at exit
Change-Id: I7293518bc2fe6c66270a7c8aea3bf0c0829754e4
Diffstat (limited to 'packages/BackupRestoreConfirmation/src/com/android/backupconfirm')
-rw-r--r-- | packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java b/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java index 52bfc28..ed413e6 100644 --- a/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java +++ b/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java @@ -60,6 +60,7 @@ public class BackupRestoreConfirmation extends Activity { IBackupManager mBackupManager; FullObserver mObserver; int mToken; + boolean mDidAcknowledge; TextView mStatusView; Button mAllowButton; @@ -70,6 +71,7 @@ public class BackupRestoreConfirmation extends Activity { Context mContext; ObserverHandler(Context context) { mContext = context; + mDidAcknowledge = false; } @Override @@ -157,11 +159,7 @@ public class BackupRestoreConfirmation extends Activity { mAllowButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - try { - mBackupManager.acknowledgeFullBackupOrRestore(mToken, true, mObserver); - } catch (RemoteException e) { - // TODO: bail gracefully if we can't contact the backup manager - } + sendAcknowledgement(mToken, true, mObserver); mAllowButton.setEnabled(false); mDenyButton.setEnabled(false); } @@ -170,11 +168,7 @@ public class BackupRestoreConfirmation extends Activity { mDenyButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - try { - mBackupManager.acknowledgeFullBackupOrRestore(mToken, false, mObserver); - } catch (RemoteException e) { - // TODO: bail gracefully if we can't contact the backup manager - } + sendAcknowledgement(mToken, false, mObserver); mAllowButton.setEnabled(false); mDenyButton.setEnabled(false); } @@ -187,14 +181,21 @@ public class BackupRestoreConfirmation extends Activity { // We explicitly equate departure from the UI with refusal. This includes the // implicit configuration-changed stop/restart cycle. - try { - mBackupManager.acknowledgeFullBackupOrRestore(mToken, false, null); - } catch (RemoteException e) { - // if this fails we'll still time out with no acknowledgment - } + sendAcknowledgement(mToken, false, null); finish(); } + void sendAcknowledgement(int token, boolean allow, IFullBackupRestoreObserver observer) { + if (!mDidAcknowledge) { + mDidAcknowledge = true; + try { + mBackupManager.acknowledgeFullBackupOrRestore(mToken, true, mObserver); + } catch (RemoteException e) { + // TODO: bail gracefully if we can't contact the backup manager + } + } + } + /** * The observer binder for showing backup/restore progress. This binder just bounces * the notifications onto the main thread. |