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' };
public void close() {
if (mChannel != null) {
try {
+ sync_quit();
mChannel.close();
} catch (IOException e) {
// nothing to be done really...
// check we have the proper data back
if (checkResult(pullResult, ID_DATA) == false &&
checkResult(pullResult, ID_DONE) == false) {
- sync_quit();
return new SyncResult(RESULT_CONNECTION_ERROR);
}
} catch (UnsupportedEncodingException e) {
fos.flush();
} catch (IOException e) {
return new SyncResult(RESULT_FILE_WRITE_ERROR, e);
- } finally {
- sync_quit();
}
return new SyncResult(RESULT_OK);
byte[] remotePathContent = remotePath.getBytes(SdbHelper.UTF_ENCODING);
if (remotePathContent.length > REMOTE_PATH_MAX_LENGTH) {
- sync_quit();
return new SyncResult(RESULT_REMOTE_PATH_LENGTH);
}
// this shouldn't happen but still...
if (f.exists() == false) {
- sync_quit();
return new SyncResult(RESULT_NO_LOCAL_FILE);
}
while (true) {
// check if we're canceled
if (monitor.isCanceled() == true) {
- sync_quit();
return new SyncResult(RESULT_CANCELED);
}
// output the result?
String message = new String(mBuffer, 0, len);
Log.e("sdb", "transfer error: " + message);
- sync_quit();
return new SyncResult(RESULT_UNKNOWN_ERROR, message);
}
} catch (IOException e) {
return new SyncResult(RESULT_CONNECTION_ERROR, e);
}
- sync_quit();
+
return new SyncResult(RESULT_OK);
}