- mWakelock.acquire();
- Message msg = mBackupHandler.obtainMessage(MSG_RUN_RESTORE);
- msg.obj = new RestoreParams(getTransport(mCurrentTransport), null,
- restoreSet, pkg, token, true);
- mBackupHandler.sendMessage(msg);
+ // This can throw and so *must* happen before the wakelock is acquired
+ String dirName = transport.transportDirName();
+
+ // We can use a synthetic PackageInfo here because:
+ // 1. We know it's valid, since the Package Manager supplied the name
+ // 2. Only the packageName field will be used by the restore code
+ PackageInfo pkg = new PackageInfo();
+ pkg.packageName = packageName;
+
+ mWakelock.acquire();
+ Message msg = mBackupHandler.obtainMessage(MSG_RUN_RESTORE);
+ msg.obj = new RestoreParams(transport, dirName, null,
+ restoreSet, pkg, token, true);
+ mBackupHandler.sendMessage(msg);
+ } catch (RemoteException e) {
+ // Binding to the transport broke; back off and proceed with the installation.
+ Slog.e(TAG, "Unable to contact transport for install-time restore");
+ }