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

Commit c295a443 authored by Christopher Tate's avatar Christopher Tate Committed by Android (Google) Code Review
Browse files

Merge "Always call finishBackup() if performFullBackup() succeeded" into lmp-dev

parents c0844bef a176d221
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -331,6 +331,10 @@ public class BackupTransport {
     * its datastore, if appropriate, and close the socket that had been provided in
     * {@link #performFullBackup(PackageInfo, ParcelFileDescriptor)}.
     *
     * <p class="note">If the transport returns TRANSPORT_OK from this method, then the
     * OS will always provide a matching call to {@link #finishBackup()} even if sending
     * data via {@link #sendBackupData(int)} failed at some point.
     *
     * @param targetPackage The package whose data is to follow.
     * @param socket The socket file descriptor through which the data will be provided.
     *    If the transport returns {@link #TRANSPORT_PACKAGE_REJECTED} here, it must still
+18 −7
Original line number Diff line number Diff line
@@ -3535,19 +3535,30 @@ public class BackupManagerService extends IBackupManager.Stub {
                                }
                            } while (nRead > 0 && result == BackupTransport.TRANSPORT_OK);

                            // Done -- how did it turn out?
                            // In all cases we need to give the transport its finish callback
                            int finishResult = transport.finishBackup();

                            // If we were otherwise in a good state, now interpret the final
                            // result based on what finishBackup() returned.  If we're in a
                            // failure case already, preserve that result and ignore whatever
                            // finishBackup() reported.
                            if (result == BackupTransport.TRANSPORT_OK) {
                                result = transport.finishBackup();
                            } else {
                                Slog.w(TAG, "Error backing up " + target.packageName);
                                result = finishResult;
                            }

                            if (result != BackupTransport.TRANSPORT_OK) {
                                Slog.e(TAG, "Error " + result
                                        + " backing up " + target.packageName);
                            }
                        } else if (result == BackupTransport.TRANSPORT_PACKAGE_REJECTED) {
                        }

                        if (result == BackupTransport.TRANSPORT_PACKAGE_REJECTED) {
                            if (DEBUG) {
                                Slog.i(TAG, "Transport rejected backup of " + target.packageName
                                        + ", skipping");
                            }
                            // do nothing, clean up, and continue looping
                        } else {
                        } else if (result != BackupTransport.TRANSPORT_OK) {
                            if (DEBUG) {
                                Slog.i(TAG, "Transport failed; aborting backup");
                                return;