Loading packages/LocalTransport/src/com/android/localtransport/LocalTransport.java +13 −7 Original line number Original line Diff line number Diff line Loading @@ -95,7 +95,6 @@ public class LocalTransport extends BackupTransport { private long mFullBackupSize; private long mFullBackupSize; private FileInputStream mCurFullRestoreStream; private FileInputStream mCurFullRestoreStream; private FileOutputStream mFullRestoreSocketStream; private byte[] mFullRestoreBuffer; private byte[] mFullRestoreBuffer; private final LocalTransportParameters mParameters; private final LocalTransportParameters mParameters; Loading Loading @@ -195,6 +194,15 @@ public class LocalTransport extends BackupTransport { @Override @Override public int performBackup(PackageInfo packageInfo, ParcelFileDescriptor data, int flags) { public int performBackup(PackageInfo packageInfo, ParcelFileDescriptor data, int flags) { try { return performBackupInternal(packageInfo, data, flags); } finally { IoUtils.closeQuietly(data); } } private int performBackupInternal( PackageInfo packageInfo, ParcelFileDescriptor data, int flags) { boolean isIncremental = (flags & FLAG_INCREMENTAL) != 0; boolean isIncremental = (flags & FLAG_INCREMENTAL) != 0; boolean isNonIncremental = (flags & FLAG_NON_INCREMENTAL) != 0; boolean isNonIncremental = (flags & FLAG_NON_INCREMENTAL) != 0; Loading Loading @@ -750,7 +758,6 @@ public class LocalTransport extends BackupTransport { private void resetFullRestoreState() { private void resetFullRestoreState() { IoUtils.closeQuietly(mCurFullRestoreStream); IoUtils.closeQuietly(mCurFullRestoreStream); mCurFullRestoreStream = null; mCurFullRestoreStream = null; mFullRestoreSocketStream = null; mFullRestoreBuffer = null; mFullRestoreBuffer = null; } } Loading Loading @@ -795,10 +802,11 @@ public class LocalTransport extends BackupTransport { Log.e(TAG, "Unable to read archive for " + name); Log.e(TAG, "Unable to read archive for " + name); return TRANSPORT_PACKAGE_REJECTED; return TRANSPORT_PACKAGE_REJECTED; } } mFullRestoreSocketStream = new FileOutputStream(socket.getFileDescriptor()); mFullRestoreBuffer = new byte[2*1024]; mFullRestoreBuffer = new byte[2*1024]; } } FileOutputStream stream = new FileOutputStream(socket.getFileDescriptor()); int nRead; int nRead; try { try { nRead = mCurFullRestoreStream.read(mFullRestoreBuffer); nRead = mCurFullRestoreStream.read(mFullRestoreBuffer); Loading @@ -815,14 +823,12 @@ public class LocalTransport extends BackupTransport { if (DEBUG) { if (DEBUG) { Log.i(TAG, " delivering restore chunk: " + nRead); Log.i(TAG, " delivering restore chunk: " + nRead); } } mFullRestoreSocketStream.write(mFullRestoreBuffer, 0, nRead); stream.write(mFullRestoreBuffer, 0, nRead); } } } catch (IOException e) { } catch (IOException e) { return TRANSPORT_ERROR; // Hard error accessing the file; shouldn't happen return TRANSPORT_ERROR; // Hard error accessing the file; shouldn't happen } finally { } finally { // Most transports will need to explicitly close 'socket' here, but this transport IoUtils.closeQuietly(socket); // is in the same process as the caller so it can leave it up to the backup manager // to manage both socket fds. } } return nRead; return nRead; Loading Loading
packages/LocalTransport/src/com/android/localtransport/LocalTransport.java +13 −7 Original line number Original line Diff line number Diff line Loading @@ -95,7 +95,6 @@ public class LocalTransport extends BackupTransport { private long mFullBackupSize; private long mFullBackupSize; private FileInputStream mCurFullRestoreStream; private FileInputStream mCurFullRestoreStream; private FileOutputStream mFullRestoreSocketStream; private byte[] mFullRestoreBuffer; private byte[] mFullRestoreBuffer; private final LocalTransportParameters mParameters; private final LocalTransportParameters mParameters; Loading Loading @@ -195,6 +194,15 @@ public class LocalTransport extends BackupTransport { @Override @Override public int performBackup(PackageInfo packageInfo, ParcelFileDescriptor data, int flags) { public int performBackup(PackageInfo packageInfo, ParcelFileDescriptor data, int flags) { try { return performBackupInternal(packageInfo, data, flags); } finally { IoUtils.closeQuietly(data); } } private int performBackupInternal( PackageInfo packageInfo, ParcelFileDescriptor data, int flags) { boolean isIncremental = (flags & FLAG_INCREMENTAL) != 0; boolean isIncremental = (flags & FLAG_INCREMENTAL) != 0; boolean isNonIncremental = (flags & FLAG_NON_INCREMENTAL) != 0; boolean isNonIncremental = (flags & FLAG_NON_INCREMENTAL) != 0; Loading Loading @@ -750,7 +758,6 @@ public class LocalTransport extends BackupTransport { private void resetFullRestoreState() { private void resetFullRestoreState() { IoUtils.closeQuietly(mCurFullRestoreStream); IoUtils.closeQuietly(mCurFullRestoreStream); mCurFullRestoreStream = null; mCurFullRestoreStream = null; mFullRestoreSocketStream = null; mFullRestoreBuffer = null; mFullRestoreBuffer = null; } } Loading Loading @@ -795,10 +802,11 @@ public class LocalTransport extends BackupTransport { Log.e(TAG, "Unable to read archive for " + name); Log.e(TAG, "Unable to read archive for " + name); return TRANSPORT_PACKAGE_REJECTED; return TRANSPORT_PACKAGE_REJECTED; } } mFullRestoreSocketStream = new FileOutputStream(socket.getFileDescriptor()); mFullRestoreBuffer = new byte[2*1024]; mFullRestoreBuffer = new byte[2*1024]; } } FileOutputStream stream = new FileOutputStream(socket.getFileDescriptor()); int nRead; int nRead; try { try { nRead = mCurFullRestoreStream.read(mFullRestoreBuffer); nRead = mCurFullRestoreStream.read(mFullRestoreBuffer); Loading @@ -815,14 +823,12 @@ public class LocalTransport extends BackupTransport { if (DEBUG) { if (DEBUG) { Log.i(TAG, " delivering restore chunk: " + nRead); Log.i(TAG, " delivering restore chunk: " + nRead); } } mFullRestoreSocketStream.write(mFullRestoreBuffer, 0, nRead); stream.write(mFullRestoreBuffer, 0, nRead); } } } catch (IOException e) { } catch (IOException e) { return TRANSPORT_ERROR; // Hard error accessing the file; shouldn't happen return TRANSPORT_ERROR; // Hard error accessing the file; shouldn't happen } finally { } finally { // Most transports will need to explicitly close 'socket' here, but this transport IoUtils.closeQuietly(socket); // is in the same process as the caller so it can leave it up to the backup manager // to manage both socket fds. } } return nRead; return nRead; Loading