Merge branch 'master' into develop
[pub/Android/ownCloud.git] / src / com / owncloud / android / services / OperationsService.java
index a47385b..581a686 100644 (file)
@@ -144,6 +144,8 @@ public class OperationsService extends Service {
     @Override
     public void onCreate() {
         super.onCreate();
+        Log_OC.d(TAG, "Creating service");
+
         /// First worker thread for most of operations 
         HandlerThread thread = new HandlerThread("Operations thread", Process.THREAD_PRIORITY_BACKGROUND);
         thread.start();
@@ -165,7 +167,9 @@ public class OperationsService extends Service {
      */
     @Override
     public int onStartCommand(Intent intent, int flags, int startId) {
-        // WIP: for the moment, only SYNC_FOLDER and CANCEL_SYNC_FOLDER is expected here;
+        Log_OC.d(TAG, "Starting command with id " + startId);
+
+        // WIP: for the moment, only SYNC_FOLDER is expected here;
         // the rest of the operations are requested through the Binder
         if (ACTION_SYNC_FOLDER.equals(intent.getAction())) {
 
@@ -198,7 +202,7 @@ public class OperationsService extends Service {
 
     @Override
     public void onDestroy() {
-        //Log_OC.wtf(TAG, "onDestroy init" );
+        Log_OC.v(TAG, "Destroying service" );
         // Saving cookies
         try {
             OwnCloudClientManagerFactory.getDefaultSingleton().
@@ -215,10 +219,16 @@ public class OperationsService extends Service {
             e.printStackTrace();
         }
         
-        //Log_OC.wtf(TAG, "Clear mUndispatchedFinisiedOperations" );
         mUndispatchedFinishedOperations.clear();
-        
-        //Log_OC.wtf(TAG, "onDestroy end" );
+
+        mOperationsBinder = null;
+
+        mOperationsHandler.getLooper().quit();
+        mOperationsHandler = null;
+
+        mSyncFolderHandler.getLooper().quit();
+        mSyncFolderHandler = null;
+
         super.onDestroy();
     }
 
@@ -403,6 +413,7 @@ public class OperationsService extends Service {
         @Override
         public void handleMessage(Message msg) {
             nextOperation();
+            Log_OC.d(TAG, "Stopping after command with id " + msg.arg1);
             mService.stopSelf(msg.arg1);
         }