Loading core/java/android/app/backup/BackupTransport.java +19 −0 Original line number Diff line number Diff line Loading @@ -405,6 +405,25 @@ public class BackupTransport { return BackupTransport.TRANSPORT_ERROR; } /** * Tells the transport to cancel the currently-ongoing full backup operation. This * will happen between {@link #performFullBackup()} and {@link #finishBackup()} * if the OS needs to abort the backup operation for any reason, such as a crash in * the application undergoing backup. * * <p>When it receives this call, the transport should discard any partial archive * that it has stored so far. If possible it should also roll back to the previous * known-good archive in its datastore. * * <p>If the transport receives this callback, it will <em>not</em> receive a * call to {@link #finishBackup()}. It needs to tear down any ongoing backup state * here. */ public void cancelFullBackup() { throw new UnsupportedOperationException( "Transport cancelFullBackup() not implemented"); } // ------------------------------------------------------------------------------------ // Full restore interfaces Loading core/java/com/android/internal/backup/LocalTransport.java +26 −8 Original line number Diff line number Diff line Loading @@ -273,11 +273,15 @@ public class LocalTransport extends BackupTransport { @Override public int finishBackup() { if (DEBUG) Log.v(TAG, "finishBackup()"); if (mSocket != null) { if (DEBUG) { Log.v(TAG, "Concluding full backup of " + mFullTargetPackage); if (DEBUG) Log.v(TAG, "finishBackup() of " + mFullTargetPackage); return tearDownFullBackup(); } // ------------------------------------------------------------------------------------ // Full backup handling private int tearDownFullBackup() { if (mSocket != null) { try { mFullBackupOutputStream.flush(); mFullBackupOutputStream.close(); Loading @@ -286,7 +290,7 @@ public class LocalTransport extends BackupTransport { mSocket.close(); } catch (IOException e) { if (DEBUG) { Log.w(TAG, "Exception caught in finishBackup()", e); Log.w(TAG, "Exception caught in tearDownFullBackup()", e); } return TRANSPORT_ERROR; } finally { Loading @@ -296,8 +300,9 @@ public class LocalTransport extends BackupTransport { return TRANSPORT_OK; } // ------------------------------------------------------------------------------------ // Full backup handling private File tarballFile(String pkgName) { return new File(mCurrentSetFullDir, pkgName); } @Override public long requestFullBackupTime() { Loading Loading @@ -329,7 +334,7 @@ public class LocalTransport extends BackupTransport { mFullTargetPackage = targetPackage.packageName; FileOutputStream tarstream; try { File tarball = new File(mCurrentSetFullDir, mFullTargetPackage); File tarball = tarballFile(mFullTargetPackage); tarstream = new FileOutputStream(tarball); } catch (FileNotFoundException e) { return TRANSPORT_ERROR; Loading Loading @@ -368,6 +373,19 @@ public class LocalTransport extends BackupTransport { return TRANSPORT_OK; } // For now we can't roll back, so just tear everything down. @Override public void cancelFullBackup() { if (DEBUG) { Log.i(TAG, "Canceling full backup of " + mFullTargetPackage); } File archive = tarballFile(mFullTargetPackage); tearDownFullBackup(); if (archive.exists()) { archive.delete(); } } // ------------------------------------------------------------------------------------ // Restore handling static final long[] POSSIBLE_SETS = { 2, 3, 4, 5, 6, 7, 8, 9 }; Loading Loading
core/java/android/app/backup/BackupTransport.java +19 −0 Original line number Diff line number Diff line Loading @@ -405,6 +405,25 @@ public class BackupTransport { return BackupTransport.TRANSPORT_ERROR; } /** * Tells the transport to cancel the currently-ongoing full backup operation. This * will happen between {@link #performFullBackup()} and {@link #finishBackup()} * if the OS needs to abort the backup operation for any reason, such as a crash in * the application undergoing backup. * * <p>When it receives this call, the transport should discard any partial archive * that it has stored so far. If possible it should also roll back to the previous * known-good archive in its datastore. * * <p>If the transport receives this callback, it will <em>not</em> receive a * call to {@link #finishBackup()}. It needs to tear down any ongoing backup state * here. */ public void cancelFullBackup() { throw new UnsupportedOperationException( "Transport cancelFullBackup() not implemented"); } // ------------------------------------------------------------------------------------ // Full restore interfaces Loading
core/java/com/android/internal/backup/LocalTransport.java +26 −8 Original line number Diff line number Diff line Loading @@ -273,11 +273,15 @@ public class LocalTransport extends BackupTransport { @Override public int finishBackup() { if (DEBUG) Log.v(TAG, "finishBackup()"); if (mSocket != null) { if (DEBUG) { Log.v(TAG, "Concluding full backup of " + mFullTargetPackage); if (DEBUG) Log.v(TAG, "finishBackup() of " + mFullTargetPackage); return tearDownFullBackup(); } // ------------------------------------------------------------------------------------ // Full backup handling private int tearDownFullBackup() { if (mSocket != null) { try { mFullBackupOutputStream.flush(); mFullBackupOutputStream.close(); Loading @@ -286,7 +290,7 @@ public class LocalTransport extends BackupTransport { mSocket.close(); } catch (IOException e) { if (DEBUG) { Log.w(TAG, "Exception caught in finishBackup()", e); Log.w(TAG, "Exception caught in tearDownFullBackup()", e); } return TRANSPORT_ERROR; } finally { Loading @@ -296,8 +300,9 @@ public class LocalTransport extends BackupTransport { return TRANSPORT_OK; } // ------------------------------------------------------------------------------------ // Full backup handling private File tarballFile(String pkgName) { return new File(mCurrentSetFullDir, pkgName); } @Override public long requestFullBackupTime() { Loading Loading @@ -329,7 +334,7 @@ public class LocalTransport extends BackupTransport { mFullTargetPackage = targetPackage.packageName; FileOutputStream tarstream; try { File tarball = new File(mCurrentSetFullDir, mFullTargetPackage); File tarball = tarballFile(mFullTargetPackage); tarstream = new FileOutputStream(tarball); } catch (FileNotFoundException e) { return TRANSPORT_ERROR; Loading Loading @@ -368,6 +373,19 @@ public class LocalTransport extends BackupTransport { return TRANSPORT_OK; } // For now we can't roll back, so just tear everything down. @Override public void cancelFullBackup() { if (DEBUG) { Log.i(TAG, "Canceling full backup of " + mFullTargetPackage); } File archive = tarballFile(mFullTargetPackage); tearDownFullBackup(); if (archive.exists()) { archive.delete(); } } // ------------------------------------------------------------------------------------ // Restore handling static final long[] POSSIBLE_SETS = { 2, 3, 4, 5, 6, 7, 8, 9 }; Loading