@Override
public void onCreate() {
super.onCreate();
- Log_OC.i(TAG, "mPendingUploads size:" + mPendingUploads.size());
+ Log_OC.d(TAG, "Creating service");
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
HandlerThread thread = new HandlerThread("FileUploaderThread", Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
}
/**
+ * Service clean up
+ */
+ @Override
+ public void onDestroy() {
+ Log_OC.v(TAG, "Destroying service" );
+ mBinder = null;
+ mServiceHandler = null;
+ mServiceLooper.quit();
+ mServiceLooper = null;
+ mNotificationManager = null;
+ super.onDestroy();
+ }
+
+
+ /**
* Entry point to add one or several files to the queue of uploads.
*
* New uploads are added calling to startService(), resulting in a call to
*/
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
+ Log_OC.d(TAG, "Starting command with id " + startId);
+
if (!intent.hasExtra(KEY_ACCOUNT) || !intent.hasExtra(KEY_UPLOAD_TYPE)
|| !(intent.hasExtra(KEY_LOCAL_FILE) || intent.hasExtra(KEY_FILE))) {
Log_OC.e(TAG, "Not enough information provided in intent");
if (uploadType == UPLOAD_SINGLE_FILE) {
if (intent.hasExtra(KEY_FILE)) {
- files = new OCFile[] { intent.getParcelableExtra(KEY_FILE) };
+ files = new OCFile[] { (OCFile) intent.getParcelableExtra(KEY_FILE) };
} else {
localPaths = new String[] { intent.getStringExtra(KEY_LOCAL_FILE) };
*
* If 'file' is a directory, returns 'true' if some of its descendant files is uploading or waiting to upload.
*
- * @param account Owncloud account where the remote file will be stored.
- * @param file A file that could be in the queue of pending uploads
+ * @param account ownCloud account where the remote file will be stored.
+ * @param file A file that could be in the queue of pending uploads
*/
public boolean isUploading(Account account, OCFile file) {
if (account == null || file == null)
*
* @param listener Object to notify about progress of transfer.
* @param account ownCloud account holding the file of interest.
- * @param file {@link OCfile} of interest for listener.
+ * @param file {@link OCFile} of interest for listener.
*/
public void addDatatransferProgressListener (OnDatatransferProgressListener listener, Account account, OCFile file) {
if (account == null || file == null || listener == null) return;
*
* @param listener Object to notify about progress of transfer.
* @param account ownCloud account holding the file of interest.
- * @param file {@link OCfile} of interest for listener.
+ * @param file {@link OCFile} of interest for listener.
*/
public void removeDatatransferProgressListener (OnDatatransferProgressListener listener, Account account, OCFile file) {
if (account == null || file == null || listener == null) return;
mService.uploadFile(it.next());
}
}
+ Log_OC.d(TAG, "Stopping command after id " + msg.arg1);
mService.stopSelf(msg.arg1);
}
}