示例#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();
                }
            }
        }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void pushFile(String local, String remote) throws java.io.IOException, AdbCommandRejectedException, TimeoutException, SyncException
        public void pushFile(string local, string remote)
        {
            SyncService sync = null;

            try
            {
                string targetFileName = getFileName(local);

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

                sync = syncService;
                if (sync != null)
                {
                    string message = string.Format("Uploading file onto device '{0}'", serialNumber);
                    Log.d(LOG_TAG, message);
                    sync.pushFile(local, remote, 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();
                }
            }
        }