package org.tizen.sdblib;
+import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
* <p/>
* To get a {@link SyncService} object, use {@link Device#getSyncService()}.
*/
-public final class SyncService {
+public final class SyncService implements Closeable {
private final static byte[] ID_OKAY = { 'O', 'K', 'A', 'Y' };
private final static byte[] ID_FAIL = { 'F', 'A', 'I', 'L' };
private final static byte[] ID_DATA = { 'D', 'A', 'T', 'A' };
private final static byte[] ID_DONE = { 'D', 'O', 'N', 'E' };
private final static byte[] ID_SEND = { 'S', 'E', 'N', 'D' };
+ private final static byte[] ID_QUIT = { 'Q', 'U', 'I', 'T' };
private final static NullSyncProgressMonitor sNullSyncProgressMonitor =
new NullSyncProgressMonitor();
public void close() {
if (mChannel != null) {
try {
+ sync_quit();
mChannel.close();
} catch (IOException e) {
// nothing to be done really...
fos.flush();
} catch (IOException e) {
return new SyncResult(RESULT_FILE_WRITE_ERROR, e);
- }
+ }
return new SyncResult(RESULT_OK);
}
return true;
}
+
+ private void sync_quit() {
+ byte[] msg = createReq(ID_QUIT, 0);
+ try {
+ SdbHelper.write(mChannel, msg, -1, SdbPreferences.getTimeOut());
+ }catch (IOException e) {
+ Log.e("sdb", "send quit error");
+ }
+ }
}
//to process size is bigger than integer maximum value