Loading packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java +16 −15 Original line number Original line Diff line number Diff line Loading @@ -60,6 +60,7 @@ public class BackupRestoreConfirmation extends Activity { IBackupManager mBackupManager; IBackupManager mBackupManager; FullObserver mObserver; FullObserver mObserver; int mToken; int mToken; boolean mDidAcknowledge; TextView mStatusView; TextView mStatusView; Button mAllowButton; Button mAllowButton; Loading @@ -70,6 +71,7 @@ public class BackupRestoreConfirmation extends Activity { Context mContext; Context mContext; ObserverHandler(Context context) { ObserverHandler(Context context) { mContext = context; mContext = context; mDidAcknowledge = false; } } @Override @Override Loading Loading @@ -157,11 +159,7 @@ public class BackupRestoreConfirmation extends Activity { mAllowButton.setOnClickListener(new View.OnClickListener() { mAllowButton.setOnClickListener(new View.OnClickListener() { @Override @Override public void onClick(View v) { public void onClick(View v) { try { sendAcknowledgement(mToken, true, mObserver); mBackupManager.acknowledgeFullBackupOrRestore(mToken, true, mObserver); } catch (RemoteException e) { // TODO: bail gracefully if we can't contact the backup manager } mAllowButton.setEnabled(false); mAllowButton.setEnabled(false); mDenyButton.setEnabled(false); mDenyButton.setEnabled(false); } } Loading @@ -170,11 +168,7 @@ public class BackupRestoreConfirmation extends Activity { mDenyButton.setOnClickListener(new View.OnClickListener() { mDenyButton.setOnClickListener(new View.OnClickListener() { @Override @Override public void onClick(View v) { public void onClick(View v) { try { sendAcknowledgement(mToken, false, mObserver); mBackupManager.acknowledgeFullBackupOrRestore(mToken, false, mObserver); } catch (RemoteException e) { // TODO: bail gracefully if we can't contact the backup manager } mAllowButton.setEnabled(false); mAllowButton.setEnabled(false); mDenyButton.setEnabled(false); mDenyButton.setEnabled(false); } } Loading @@ -187,12 +181,19 @@ public class BackupRestoreConfirmation extends Activity { // We explicitly equate departure from the UI with refusal. This includes the // We explicitly equate departure from the UI with refusal. This includes the // implicit configuration-changed stop/restart cycle. // implicit configuration-changed stop/restart cycle. sendAcknowledgement(mToken, false, null); finish(); } void sendAcknowledgement(int token, boolean allow, IFullBackupRestoreObserver observer) { if (!mDidAcknowledge) { mDidAcknowledge = true; try { try { mBackupManager.acknowledgeFullBackupOrRestore(mToken, false, null); mBackupManager.acknowledgeFullBackupOrRestore(mToken, true, mObserver); } catch (RemoteException e) { } catch (RemoteException e) { // if this fails we'll still time out with no acknowledgment // TODO: bail gracefully if we can't contact the backup manager } } } finish(); } } /** /** Loading Loading
packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java +16 −15 Original line number Original line Diff line number Diff line Loading @@ -60,6 +60,7 @@ public class BackupRestoreConfirmation extends Activity { IBackupManager mBackupManager; IBackupManager mBackupManager; FullObserver mObserver; FullObserver mObserver; int mToken; int mToken; boolean mDidAcknowledge; TextView mStatusView; TextView mStatusView; Button mAllowButton; Button mAllowButton; Loading @@ -70,6 +71,7 @@ public class BackupRestoreConfirmation extends Activity { Context mContext; Context mContext; ObserverHandler(Context context) { ObserverHandler(Context context) { mContext = context; mContext = context; mDidAcknowledge = false; } } @Override @Override Loading Loading @@ -157,11 +159,7 @@ public class BackupRestoreConfirmation extends Activity { mAllowButton.setOnClickListener(new View.OnClickListener() { mAllowButton.setOnClickListener(new View.OnClickListener() { @Override @Override public void onClick(View v) { public void onClick(View v) { try { sendAcknowledgement(mToken, true, mObserver); mBackupManager.acknowledgeFullBackupOrRestore(mToken, true, mObserver); } catch (RemoteException e) { // TODO: bail gracefully if we can't contact the backup manager } mAllowButton.setEnabled(false); mAllowButton.setEnabled(false); mDenyButton.setEnabled(false); mDenyButton.setEnabled(false); } } Loading @@ -170,11 +168,7 @@ public class BackupRestoreConfirmation extends Activity { mDenyButton.setOnClickListener(new View.OnClickListener() { mDenyButton.setOnClickListener(new View.OnClickListener() { @Override @Override public void onClick(View v) { public void onClick(View v) { try { sendAcknowledgement(mToken, false, mObserver); mBackupManager.acknowledgeFullBackupOrRestore(mToken, false, mObserver); } catch (RemoteException e) { // TODO: bail gracefully if we can't contact the backup manager } mAllowButton.setEnabled(false); mAllowButton.setEnabled(false); mDenyButton.setEnabled(false); mDenyButton.setEnabled(false); } } Loading @@ -187,12 +181,19 @@ public class BackupRestoreConfirmation extends Activity { // We explicitly equate departure from the UI with refusal. This includes the // We explicitly equate departure from the UI with refusal. This includes the // implicit configuration-changed stop/restart cycle. // implicit configuration-changed stop/restart cycle. sendAcknowledgement(mToken, false, null); finish(); } void sendAcknowledgement(int token, boolean allow, IFullBackupRestoreObserver observer) { if (!mDidAcknowledge) { mDidAcknowledge = true; try { try { mBackupManager.acknowledgeFullBackupOrRestore(mToken, false, null); mBackupManager.acknowledgeFullBackupOrRestore(mToken, true, mObserver); } catch (RemoteException e) { } catch (RemoteException e) { // if this fails we'll still time out with no acknowledgment // TODO: bail gracefully if we can't contact the backup manager } } } finish(); } } /** /** Loading