BackupRestoreConfirmation.java revision 728a1c4d5ed3b808172013a7f5bb5065d1e964f6
14a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate/* 24a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * Copyright (C) 2011 The Android Open Source Project 34a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * 44a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * Licensed under the Apache License, Version 2.0 (the "License"); 54a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * you may not use this file except in compliance with the License. 64a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * You may obtain a copy of the License at 74a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * 84a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * http://www.apache.org/licenses/LICENSE-2.0 94a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * 104a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * Unless required by applicable law or agreed to in writing, software 114a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * distributed under the License is distributed on an "AS IS" BASIS, 124a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 134a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * See the License for the specific language governing permissions and 144a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * limitations under the License. 154a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate */ 164a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 174a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tatepackage com.android.backupconfirm; 184a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 194a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tateimport android.app.Activity; 204a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tateimport android.app.backup.FullBackup; 214a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tateimport android.app.backup.IBackupManager; 224a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tateimport android.app.backup.IFullBackupRestoreObserver; 234a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tateimport android.content.Context; 244a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tateimport android.content.Intent; 254a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tateimport android.os.Bundle; 264a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tateimport android.os.Handler; 274a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tateimport android.os.Message; 284a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tateimport android.os.RemoteException; 294a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tateimport android.os.ServiceManager; 304a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tateimport android.util.Slog; 314a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tateimport android.view.View; 324a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tateimport android.widget.Button; 334a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tateimport android.widget.TextView; 344a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tateimport android.widget.Toast; 354a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 364a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate/** 374a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * Confirm with the user that a requested full backup/restore operation is legitimate. 384a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * Any attempt to perform a full backup/restore will launch this UI and wait for a 394a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * designated timeout interval (nominally 30 seconds) for the user to confirm. If the 404a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * user fails to respond within the timeout period, or explicitly refuses the operation 414a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * within the UI presented here, no data will be transferred off the device. 424a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * 434a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * Note that the fully scoped name of this class is baked into the backup manager service. 444a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * 454a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * @hide 464a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate */ 474a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tatepublic class BackupRestoreConfirmation extends Activity { 484a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate static final String TAG = "BackupRestoreConfirmation"; 494a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate static final boolean DEBUG = true; 504a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 514a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate static final int MSG_START_BACKUP = 1; 524a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate static final int MSG_BACKUP_PACKAGE = 2; 534a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate static final int MSG_END_BACKUP = 3; 544a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate static final int MSG_START_RESTORE = 11; 554a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate static final int MSG_RESTORE_PACKAGE = 12; 564a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate static final int MSG_END_RESTORE = 13; 574a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate static final int MSG_TIMEOUT = 100; 584a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 594a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate Handler mHandler; 604a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate IBackupManager mBackupManager; 614a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate FullObserver mObserver; 624a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate int mToken; 63ec5d4a0f9765f1645ab2e28ad2ef3cad247a042bChristopher Tate boolean mDidAcknowledge; 644a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 654a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate TextView mStatusView; 66728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate TextView mCurPassword; 67728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate TextView mEncPassword; 684a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate Button mAllowButton; 694a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate Button mDenyButton; 704a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 714a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate // Handler for dealing with observer callbacks on the main thread 724a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate class ObserverHandler extends Handler { 734a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate Context mContext; 744a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate ObserverHandler(Context context) { 754a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mContext = context; 76ec5d4a0f9765f1645ab2e28ad2ef3cad247a042bChristopher Tate mDidAcknowledge = false; 774a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 784a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 794a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate @Override 804a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate public void handleMessage(Message msg) { 814a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate switch (msg.what) { 824a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate case MSG_START_BACKUP: { 83dc92c82b4180e8067f1acd00a7db7935afce00ffChristopher Tate Toast.makeText(mContext, "!!! Backup starting !!!", Toast.LENGTH_LONG).show(); 844a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 854a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate break; 864a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 874a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate case MSG_BACKUP_PACKAGE: { 884a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate String name = (String) msg.obj; 894a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mStatusView.setText(name); 904a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 914a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate break; 924a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 934a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate case MSG_END_BACKUP: { 94dc92c82b4180e8067f1acd00a7db7935afce00ffChristopher Tate Toast.makeText(mContext, "!!! Backup ended !!!", Toast.LENGTH_SHORT).show(); 95dc92c82b4180e8067f1acd00a7db7935afce00ffChristopher Tate finish(); 964a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 974a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate break; 984a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 994a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate case MSG_START_RESTORE: { 100dc92c82b4180e8067f1acd00a7db7935afce00ffChristopher Tate Toast.makeText(mContext, "!!! Restore starting !!!", Toast.LENGTH_LONG).show(); 1014a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 1024a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate break; 1034a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 1044a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate case MSG_RESTORE_PACKAGE: { 10575a99709accef8cf221fd436d646727e7c8dd1f1Christopher Tate String name = (String) msg.obj; 10675a99709accef8cf221fd436d646727e7c8dd1f1Christopher Tate mStatusView.setText(name); 1074a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 1084a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate break; 1094a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 1104a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate case MSG_END_RESTORE: { 111dc92c82b4180e8067f1acd00a7db7935afce00ffChristopher Tate Toast.makeText(mContext, "!!! Restore ended !!!", Toast.LENGTH_SHORT).show(); 112dc92c82b4180e8067f1acd00a7db7935afce00ffChristopher Tate finish(); 1134a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 1144a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate break; 1154a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 1164a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate case MSG_TIMEOUT: { 117dc92c82b4180e8067f1acd00a7db7935afce00ffChristopher Tate Toast.makeText(mContext, "!!! TIMED OUT !!!", Toast.LENGTH_LONG).show(); 1184a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 1194a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate break; 1204a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 1214a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 1224a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 1234a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 1244a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate @Override 1254a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate public void onCreate(Bundle icicle) { 1264a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate super.onCreate(icicle); 1274a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 1284a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate final Intent intent = getIntent(); 1294a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate final String action = intent.getAction(); 1304a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 1312efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate final int layoutId; 1324a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate if (action.equals(FullBackup.FULL_BACKUP_INTENT_ACTION)) { 1334a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate layoutId = R.layout.confirm_backup; 1344a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } else if (action.equals(FullBackup.FULL_RESTORE_INTENT_ACTION)) { 1354a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate layoutId = R.layout.confirm_restore; 1364a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } else { 1374a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate Slog.w(TAG, "Backup/restore confirmation activity launched with invalid action!"); 1384a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate finish(); 1394a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate return; 1404a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 1414a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 1424a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mToken = intent.getIntExtra(FullBackup.CONF_TOKEN_INTENT_EXTRA, -1); 1434a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate if (mToken < 0) { 1444a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate Slog.e(TAG, "Backup/restore confirmation requested but no token passed!"); 1454a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate finish(); 1464a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate return; 1474a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 1484a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 1494a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mBackupManager = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE)); 1504a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 1514a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mHandler = new ObserverHandler(getApplicationContext()); 1524a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mObserver = new FullObserver(); 1534a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 1544a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate setContentView(layoutId); 1554a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 1564a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate // Same resource IDs for each layout variant (backup / restore) 1574a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mStatusView = (TextView) findViewById(R.id.package_name); 1584a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mAllowButton = (Button) findViewById(R.id.button_allow); 1594a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mDenyButton = (Button) findViewById(R.id.button_deny); 1604a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 161728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate mCurPassword = (TextView) findViewById(R.id.password); 162728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate mEncPassword = (TextView) findViewById(R.id.enc_password); 163728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate TextView curPwDesc = (TextView) findViewById(R.id.password_desc); 164728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate 165728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate // We vary the password prompt depending on whether one is predefined 166728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate if (!haveBackupPassword()) { 167728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate curPwDesc.setVisibility(View.GONE); 168728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate mCurPassword.setVisibility(View.GONE); 169728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate if (layoutId == R.layout.confirm_backup) { 170728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate TextView encPwDesc = (TextView) findViewById(R.id.enc_password_desc); 171728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate encPwDesc.setText(R.string.backup_enc_password_optional); 1722efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate } 1732efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate } 1742efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate 1754a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mAllowButton.setOnClickListener(new View.OnClickListener() { 1764a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate @Override 1774a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate public void onClick(View v) { 178ec5d4a0f9765f1645ab2e28ad2ef3cad247a042bChristopher Tate sendAcknowledgement(mToken, true, mObserver); 1794a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mAllowButton.setEnabled(false); 1804a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mDenyButton.setEnabled(false); 1814a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 1824a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate }); 1834a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 1844a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mDenyButton.setOnClickListener(new View.OnClickListener() { 1854a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate @Override 1864a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate public void onClick(View v) { 187ec5d4a0f9765f1645ab2e28ad2ef3cad247a042bChristopher Tate sendAcknowledgement(mToken, false, mObserver); 1884a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mAllowButton.setEnabled(false); 1894a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mDenyButton.setEnabled(false); 1904a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 1914a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate }); 1924a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 1934a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 1944a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate @Override 1954a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate public void onStop() { 1964a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate super.onStop(); 1974a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 1984a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate // We explicitly equate departure from the UI with refusal. This includes the 1994a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate // implicit configuration-changed stop/restart cycle. 200ec5d4a0f9765f1645ab2e28ad2ef3cad247a042bChristopher Tate sendAcknowledgement(mToken, false, null); 2014a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate finish(); 2024a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 2034a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 204ec5d4a0f9765f1645ab2e28ad2ef3cad247a042bChristopher Tate void sendAcknowledgement(int token, boolean allow, IFullBackupRestoreObserver observer) { 205ec5d4a0f9765f1645ab2e28ad2ef3cad247a042bChristopher Tate if (!mDidAcknowledge) { 206ec5d4a0f9765f1645ab2e28ad2ef3cad247a042bChristopher Tate mDidAcknowledge = true; 2072efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate 208ec5d4a0f9765f1645ab2e28ad2ef3cad247a042bChristopher Tate try { 209728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate mBackupManager.acknowledgeFullBackupOrRestore(mToken, 210728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate allow, 211728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate String.valueOf(mCurPassword.getText()), 212728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate String.valueOf(mEncPassword.getText()), 213728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate mObserver); 214ec5d4a0f9765f1645ab2e28ad2ef3cad247a042bChristopher Tate } catch (RemoteException e) { 215ec5d4a0f9765f1645ab2e28ad2ef3cad247a042bChristopher Tate // TODO: bail gracefully if we can't contact the backup manager 216ec5d4a0f9765f1645ab2e28ad2ef3cad247a042bChristopher Tate } 217ec5d4a0f9765f1645ab2e28ad2ef3cad247a042bChristopher Tate } 218ec5d4a0f9765f1645ab2e28ad2ef3cad247a042bChristopher Tate } 219ec5d4a0f9765f1645ab2e28ad2ef3cad247a042bChristopher Tate 220728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate boolean haveBackupPassword() { 221728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate try { 222728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate return mBackupManager.hasBackupPassword(); 223728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate } catch (RemoteException e) { 224728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate return true; // in the failure case, assume we need one 225728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate } 226728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate } 227728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate 2284a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate /** 2294a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * The observer binder for showing backup/restore progress. This binder just bounces 2304a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate * the notifications onto the main thread. 2314a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate */ 2324a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate class FullObserver extends IFullBackupRestoreObserver.Stub { 2334a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate // 2344a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate // IFullBackupRestoreObserver implementation 2354a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate // 2364a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate @Override 2374a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate public void onStartBackup() throws RemoteException { 2384a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mHandler.sendEmptyMessage(MSG_START_BACKUP); 2394a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 2404a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 2414a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate @Override 2424a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate public void onBackupPackage(String name) throws RemoteException { 2434a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mHandler.sendMessage(mHandler.obtainMessage(MSG_BACKUP_PACKAGE, name)); 2444a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 2454a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 2464a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate @Override 2474a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate public void onEndBackup() throws RemoteException { 2484a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mHandler.sendEmptyMessage(MSG_END_BACKUP); 2494a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 2504a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 2514a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate @Override 2524a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate public void onStartRestore() throws RemoteException { 2534a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mHandler.sendEmptyMessage(MSG_START_RESTORE); 2544a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 2554a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 2564a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate @Override 2574a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate public void onRestorePackage(String name) throws RemoteException { 2584a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mHandler.sendMessage(mHandler.obtainMessage(MSG_RESTORE_PACKAGE, name)); 2594a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 2604a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 2614a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate @Override 2624a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate public void onEndRestore() throws RemoteException { 2634a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mHandler.sendEmptyMessage(MSG_END_RESTORE); 2644a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 2654a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate 2664a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate @Override 2674a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate public void onTimeout() throws RemoteException { 2684a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate mHandler.sendEmptyMessage(MSG_TIMEOUT); 2694a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 2704a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate } 2714a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate} 272