aboutsummaryrefslogtreecommitdiffstats
path: root/ddms/libs
diff options
context:
space:
mode:
authorTsu Chiang Chuang <tsu@google.com>2011-11-03 14:05:56 -0700
committerTsu Chiang Chuang <tsu@google.com>2011-11-03 14:17:35 -0700
commit4ba94fc967614fdaa2a085ae142790f257a29ef1 (patch)
tree46feba32f3a580f0c70e5d865a4078f7dfa52eac /ddms/libs
parent9723f9e4da3362b3334ef8e96d280c3887e02bd6 (diff)
downloadsdk-4ba94fc967614fdaa2a085ae142790f257a29ef1.zip
sdk-4ba94fc967614fdaa2a085ae142790f257a29ef1.tar.gz
sdk-4ba94fc967614fdaa2a085ae142790f257a29ef1.tar.bz2
fix for leaky fd, amke sure we close syncservice.
Change-Id: Id639890c3e962dd5993281a0cdd911031aaf7304
Diffstat (limited to 'ddms/libs')
-rw-r--r--ddms/libs/ddmlib/src/com/android/ddmlib/Device.java21
1 files changed, 18 insertions, 3 deletions
diff --git a/ddms/libs/ddmlib/src/com/android/ddmlib/Device.java b/ddms/libs/ddmlib/src/com/android/ddmlib/Device.java
index 72fb945..8f02327 100644
--- a/ddms/libs/ddmlib/src/com/android/ddmlib/Device.java
+++ b/ddms/libs/ddmlib/src/com/android/ddmlib/Device.java
@@ -446,13 +446,14 @@ final class Device implements IDevice {
public void pushFile(String local, String remote)
throws IOException, AdbCommandRejectedException, TimeoutException, SyncException {
+ SyncService sync = null;
try {
String targetFileName = getFileName(local);
Log.d(targetFileName, String.format("Uploading %1$s onto device '%2$s'",
targetFileName, getSerialNumber()));
- SyncService sync = getSyncService();
+ sync = getSyncService();
if (sync != null) {
String message = String.format("Uploading file onto device '%1$s'",
getSerialNumber());
@@ -473,18 +474,23 @@ final class Device implements IDevice {
Log.e(LOG_TAG, String.format("Error during Sync: %1$s", e.getMessage()));
throw e;
+ } finally {
+ if (sync != null) {
+ sync.close();
+ }
}
}
public void pullFile(String remote, String local)
throws IOException, AdbCommandRejectedException, TimeoutException, SyncException {
+ SyncService sync = null;
try {
String targetFileName = getFileName(remote);
Log.d(targetFileName, String.format("Downloading %1$s from device '%2$s'",
targetFileName, getSerialNumber()));
- SyncService sync = getSyncService();
+ sync = getSyncService();
if (sync != null) {
String message = String.format("Downloding file from device '%1$s'",
getSerialNumber());
@@ -505,6 +511,10 @@ final class Device implements IDevice {
Log.e(LOG_TAG, String.format("Error during Sync: %1$s", e.getMessage()));
throw e;
+ } finally {
+ if (sync != null) {
+ sync.close();
+ }
}
}
@@ -528,6 +538,7 @@ final class Device implements IDevice {
public String syncPackageToDevice(String localFilePath)
throws IOException, AdbCommandRejectedException, TimeoutException, SyncException {
+ SyncService sync = null;
try {
String packageFileName = getFileName(localFilePath);
String remoteFilePath = String.format("/data/local/tmp/%1$s", packageFileName); //$NON-NLS-1$
@@ -535,7 +546,7 @@ final class Device implements IDevice {
Log.d(packageFileName, String.format("Uploading %1$s onto device '%2$s'",
packageFileName, getSerialNumber()));
- SyncService sync = getSyncService();
+ sync = getSyncService();
if (sync != null) {
String message = String.format("Uploading file onto device '%1$s'",
getSerialNumber());
@@ -557,6 +568,10 @@ final class Device implements IDevice {
Log.e(LOG_TAG, String.format("Error during Sync: %1$s", e.getMessage()));
throw e;
+ } finally {
+ if (sync != null) {
+ sync.close();
+ }
}
}