Beispiel #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public String syncPackageToDevice(String localFilePath) throws java.io.IOException, AdbCommandRejectedException, TimeoutException, SyncException
        public string syncPackageToDevice(string localFilePath)
        {
            SyncService sync = null;

            try
            {
                string packageFileName = getFileName(localFilePath);
                string remoteFilePath  = string.Format("/data/local/tmp/{0}", packageFileName);                //$NON-NLS-1$

                Log.d(packageFileName, string.Format("Uploading {0} onto device '{1}'", packageFileName, serialNumber));

                sync = syncService;
                if (sync != null)
                {
                    string message = string.Format("Uploading file onto device '{0}'", serialNumber);
                    Log.d(LOG_TAG, message);
                    sync.pushFile(localFilePath, remoteFilePath, SyncService.nullProgressMonitor);
                }
                else
                {
                    throw new IOException("Unable to open sync connection!");
                }
                return(remoteFilePath);
            }
            catch (TimeoutException e)
            {
                Log.e(LOG_TAG, "Error during Sync: timeout.");
                throw e;
            }
            catch (SyncException e)
            {
                Log.e(LOG_TAG, string.Format("Error during Sync: {0}", e.Message));
                throw e;
            }
            catch (IOException e)
            {
                Log.e(LOG_TAG, string.Format("Error during Sync: {0}", e.Message));
                throw e;
            }
            finally
            {
                if (sync != null)
                {
                    sync.close();
                }
            }
        }
Beispiel #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void pullFile(String remote, String local) throws java.io.IOException, AdbCommandRejectedException, TimeoutException, SyncException
        public void pullFile(string remote, string local)
        {
            SyncService sync = null;

            try
            {
                string targetFileName = getFileName(remote);

                Log.d(targetFileName, string.Format("Downloading {0} from device '{1}'", targetFileName, serialNumber));

                sync = syncService;
                if (sync != null)
                {
                    string message = string.Format("Downloding file from device '{0}'", serialNumber);
                    Log.d(LOG_TAG, message);
                    sync.pullFile(remote, local, SyncService.nullProgressMonitor);
                }
                else
                {
                    throw new IOException("Unable to open sync connection!");
                }
            }
            catch (TimeoutException e)
            {
                Log.e(LOG_TAG, "Error during Sync: timeout.");
                throw e;
            }
            catch (SyncException e)
            {
                Log.e(LOG_TAG, string.Format("Error during Sync: {0}", e.Message));
                throw e;
            }
            catch (IOException e)
            {
                Log.e(LOG_TAG, string.Format("Error during Sync: {0}", e.Message));
                throw e;
            }
            finally
            {
                if (sync != null)
                {
                    sync.close();
                }
            }
        }