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

Commit df1d0ff4 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 20858

* changes:
  Don't let bmgr leave a restore session hanging on error
parents 29d85df0 0e0b4ae5
Loading
Loading
Loading
Loading
+10 −8
Original line number Original line Diff line number Diff line
@@ -315,8 +315,7 @@ public final class Bmgr {
                for (RestoreSet s : sets) {
                for (RestoreSet s : sets) {
                    if (s.token == token) {
                    if (s.token == token) {
                        System.out.println("Scheduling restore: " + s.name);
                        System.out.println("Scheduling restore: " + s.name);
                        mRestore.performRestore(token, observer);
                        didRestore = (mRestore.performRestore(token, observer) == 0);
                        didRestore = true;
                        break;
                        break;
                    }
                    }
                }
                }
@@ -330,7 +329,9 @@ public final class Bmgr {
                }
                }
            }
            }


            // now wait for it to be done
            // if we kicked off a restore successfully, we have to wait for it
            // to complete before we can shut down the restore session safely
            if (didRestore) {
                synchronized (observer) {
                synchronized (observer) {
                    while (!observer.done) {
                    while (!observer.done) {
                        try {
                        try {
@@ -339,6 +340,7 @@ public final class Bmgr {
                        }
                        }
                    }
                    }
                }
                }
            }


            // once the restore has finished, close down the session and we're done
            // once the restore has finished, close down the session and we're done
            mRestore.endRestoreSession();
            mRestore.endRestoreSession();
+5 −0
Original line number Original line Diff line number Diff line
@@ -40,6 +40,8 @@ interface IRestoreSession {
     * Restore the given set onto the device, replacing the current data of any app
     * Restore the given set onto the device, replacing the current data of any app
     * contained in the restore set with the data previously backed up.
     * contained in the restore set with the data previously backed up.
     *
     *
     * @return Zero on success; nonzero on error.  The observer will only receive
     *   progress callbacks if this method returned zero.
     * @param token The token from {@link getAvailableRestoreSets()} corresponding to
     * @param token The token from {@link getAvailableRestoreSets()} corresponding to
     *   the restore set that should be used.
     *   the restore set that should be used.
     * @param observer If non-null, this binder points to an object that will receive
     * @param observer If non-null, this binder points to an object that will receive
@@ -50,6 +52,9 @@ interface IRestoreSession {
    /**
    /**
     * End this restore session.  After this method is called, the IRestoreSession binder
     * End this restore session.  After this method is called, the IRestoreSession binder
     * is no longer valid.
     * is no longer valid.
     *
     * <p><b>Note:</b> The caller <i>must</i> invoke this method to end the restore session,
     *   even if {@link getAvailableRestoreSets} or {@link performRestore} failed.
     */
     */
    void endRestoreSession();
    void endRestoreSession();
}
}
+2 −0
Original line number Original line Diff line number Diff line
@@ -1725,6 +1725,8 @@ class BackupManagerService extends IBackupManager.Stub {
                    return 0;
                    return 0;
                }
                }
            }
            }

            Log.w(TAG, "Restore token " + Long.toHexString(token) + " not found");
            return -1;
            return -1;
        }
        }