Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c38516e authored by Christopher Tate's avatar Christopher Tate
Browse files

Don't hang installs if the transport disappears

Bug 12991308

Change-Id: Ie5d3d27fe565dd4014976f5333e37b5707acb707
parent 3651cb7b
Loading
Loading
Loading
Loading
+19 −10
Original line number Original line Diff line number Diff line
@@ -5803,19 +5803,25 @@ public class BackupManagerService extends IBackupManager.Stub {
            return;
            return;
        }
        }


        boolean skip = false;

        long restoreSet = getAvailableRestoreToken(packageName);
        long restoreSet = getAvailableRestoreToken(packageName);
        if (DEBUG) Slog.v(TAG, "restoreAtInstall pkg=" + packageName
        if (DEBUG) Slog.v(TAG, "restoreAtInstall pkg=" + packageName
                + " token=" + Integer.toHexString(token)
                + " token=" + Integer.toHexString(token)
                + " restoreSet=" + Long.toHexString(restoreSet));
                + " restoreSet=" + Long.toHexString(restoreSet));
        if (restoreSet == 0) {
            if (MORE_DEBUG) Slog.i(TAG, "No restore set");
            skip = true;
        }


        if (mAutoRestore && mProvisioned && restoreSet != 0) {
        // Do we have a transport to fetch data for us?
        // Do we have a transport to fetch data for us?
        IBackupTransport transport = getTransport(mCurrentTransport);
        IBackupTransport transport = getTransport(mCurrentTransport);
        if (transport == null) {
        if (transport == null) {
                if (DEBUG) Slog.w(TAG, "No transport for install-time restore");
            if (DEBUG) Slog.w(TAG, "No transport");
                return;
            skip = true;
        }
        }


        if (!skip && mAutoRestore && mProvisioned) {
            try {
            try {
                // okay, we're going to attempt a restore of this package from this restore set.
                // okay, we're going to attempt a restore of this package from this restore set.
                // The eventual message back into the Package Manager to run the post-install
                // The eventual message back into the Package Manager to run the post-install
@@ -5837,12 +5843,15 @@ public class BackupManagerService extends IBackupManager.Stub {
                mBackupHandler.sendMessage(msg);
                mBackupHandler.sendMessage(msg);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                // Binding to the transport broke; back off and proceed with the installation.
                // Binding to the transport broke; back off and proceed with the installation.
                Slog.e(TAG, "Unable to contact transport for install-time restore");
                Slog.e(TAG, "Unable to contact transport");
                skip = true;
            }
            }
        } else {
        }

        if (skip) {
            // Auto-restore disabled or no way to attempt a restore; just tell the Package
            // Auto-restore disabled or no way to attempt a restore; just tell the Package
            // Manager to proceed with the post-install handling for this package.
            // Manager to proceed with the post-install handling for this package.
            if (DEBUG) Slog.v(TAG, "No restore set -- skipping restore");
            if (DEBUG) Slog.v(TAG, "Skipping");
            try {
            try {
                mPackageManagerBinder.finishPackageInstall(token);
                mPackageManagerBinder.finishPackageInstall(token);
            } catch (RemoteException e) { /* can't happen */ }
            } catch (RemoteException e) { /* can't happen */ }