aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTsu Chiang Chuang <tsu@google.com>2011-11-03 14:57:14 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-11-03 14:57:14 -0700
commit28fe4f4f0a12747ab71ea69049d64b93c6f5ad7f (patch)
tree679e522441fab14b3c5d5138740204b502459529
parent27ed098e750ee9463dfa7a36cef68d219de9eb50 (diff)
parent4ba94fc967614fdaa2a085ae142790f257a29ef1 (diff)
downloadsdk-28fe4f4f0a12747ab71ea69049d64b93c6f5ad7f.zip
sdk-28fe4f4f0a12747ab71ea69049d64b93c6f5ad7f.tar.gz
sdk-28fe4f4f0a12747ab71ea69049d64b93c6f5ad7f.tar.bz2
Merge "fix for leaky fd, amke sure we close syncservice."
-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();
+ }
}
}