Commit 14b66f68 authored by vince-bourgmayer's avatar vince-bourgmayer
Browse files

use ServiceExceptionHandler in Observer, OMS & Initializer

parent 4f395d94
...@@ -34,6 +34,8 @@ import foundation.e.drive.receivers.ScreenOffReceiver; ...@@ -34,6 +34,8 @@ import foundation.e.drive.receivers.ScreenOffReceiver;
import foundation.e.drive.utils.AppConstants; import foundation.e.drive.utils.AppConstants;
import foundation.e.drive.utils.CommonUtils; import foundation.e.drive.utils.CommonUtils;
import foundation.e.drive.utils.JobUtils; import foundation.e.drive.utils.JobUtils;
import foundation.e.drive.utils.ServiceExceptionHandler;
import static com.owncloud.android.lib.resources.files.FileUtils.PATH_SEPARATOR; import static com.owncloud.android.lib.resources.files.FileUtils.PATH_SEPARATOR;
import static foundation.e.drive.utils.AppConstants.INITIALFOLDERS_NUMBER; import static foundation.e.drive.utils.AppConstants.INITIALFOLDERS_NUMBER;
import static foundation.e.drive.utils.AppConstants.MEDIA_SYNCABLE_CATEGORIES; import static foundation.e.drive.utils.AppConstants.MEDIA_SYNCABLE_CATEGORIES;
...@@ -63,6 +65,9 @@ public class InitializerService extends Service implements OnRemoteOperationList ...@@ -63,6 +65,9 @@ public class InitializerService extends Service implements OnRemoteOperationList
@Override @Override
public int onStartCommand( Intent intent, int flags, int startId ) { public int onStartCommand( Intent intent, int flags, int startId ) {
Log.i(TAG, "onStartCommand(...)"); Log.i(TAG, "onStartCommand(...)");
Thread.setDefaultUncaughtExceptionHandler(new ServiceExceptionHandler(this));
//Get account //Get account
SharedPreferences prefs = this.getSharedPreferences( AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE ); SharedPreferences prefs = this.getSharedPreferences( AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE );
......
...@@ -51,6 +51,7 @@ import static com.owncloud.android.lib.resources.files.FileUtils.PATH_SEPARATOR; ...@@ -51,6 +51,7 @@ import static com.owncloud.android.lib.resources.files.FileUtils.PATH_SEPARATOR;
import static foundation.e.drive.utils.AppConstants.INITIALIZATION_HAS_BEEN_DONE; import static foundation.e.drive.utils.AppConstants.INITIALIZATION_HAS_BEEN_DONE;
import foundation.e.drive.utils.DavClientProvider; import foundation.e.drive.utils.DavClientProvider;
import foundation.e.drive.utils.JobUtils; import foundation.e.drive.utils.JobUtils;
import foundation.e.drive.utils.ServiceExceptionHandler;
/** /**
* @author Vincent Bourgmayer * @author Vincent Bourgmayer
...@@ -75,16 +76,12 @@ public class ObserverService extends Service implements OnRemoteOperationListene ...@@ -75,16 +76,12 @@ public class ObserverService extends Service implements OnRemoteOperationListene
this.mSyncedFolders = null; this.mSyncedFolders = null;
} }
@Override
public void onCreate() {
Log.i(TAG, "onCreate()");
super.onCreate();
}
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
Log.i(TAG, "onStartCommand("+startId+")"); Log.i(TAG, "onStartCommand("+startId+")");
Thread.setDefaultUncaughtExceptionHandler(new ServiceExceptionHandler(this));
SharedPreferences prefs = this.getSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE); SharedPreferences prefs = this.getSharedPreferences(AppConstants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE);
String accountName = prefs.getString(AccountManager.KEY_ACCOUNT_NAME, ""); String accountName = prefs.getString(AccountManager.KEY_ACCOUNT_NAME, "");
String accountType = prefs.getString(AccountManager.KEY_ACCOUNT_TYPE, ""); String accountType = prefs.getString(AccountManager.KEY_ACCOUNT_TYPE, "");
......
...@@ -40,6 +40,7 @@ import foundation.e.drive.operations.UploadFileOperation; ...@@ -40,6 +40,7 @@ import foundation.e.drive.operations.UploadFileOperation;
import foundation.e.drive.utils.AppConstants; import foundation.e.drive.utils.AppConstants;
import foundation.e.drive.utils.CommonUtils; import foundation.e.drive.utils.CommonUtils;
import foundation.e.drive.utils.DavClientProvider; import foundation.e.drive.utils.DavClientProvider;
import foundation.e.drive.utils.ServiceExceptionHandler;
/** /**
* @author Vincent Bourgmayer * @author Vincent Bourgmayer
...@@ -239,6 +240,7 @@ public class OperationManagerService extends Service implements OnRemoteOperatio ...@@ -239,6 +240,7 @@ public class OperationManagerService extends Service implements OnRemoteOperatio
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
Log.i(TAG, "onStartCommand()"); Log.i(TAG, "onStartCommand()");
Thread.setDefaultUncaughtExceptionHandler(new ServiceExceptionHandler(this));
Bundle extras = intent.getExtras(); Bundle extras = intent.getExtras();
Log.d(TAG, "OperationManagerService recieved "+(extras == null ? "null extras": extras.size()+" operations to perform") ); Log.d(TAG, "OperationManagerService recieved "+(extras == null ? "null extras": extras.size()+" operations to perform") );
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
* http://www.gnu.org/licenses/gpl.html * http://www.gnu.org/licenses/gpl.html
*/ */
package foundation.e.drive.utils; package foundation.e.drive.utils;
import android.app.Service;
import android.os.Environment; import android.os.Environment;
import android.util.Log;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
...@@ -20,6 +20,14 @@ import java.lang.Thread.UncaughtExceptionHandler; ...@@ -20,6 +20,14 @@ import java.lang.Thread.UncaughtExceptionHandler;
* @author Vincent Bourgmayer * @author Vincent Bourgmayer
*/ */
public class ServiceExceptionHandler implements UncaughtExceptionHandler{ public class ServiceExceptionHandler implements UncaughtExceptionHandler{
private UncaughtExceptionHandler defaultUEH;
Service service;
public ServiceExceptionHandler(Service service) {
this.service = service;
}
@Override @Override
public void uncaughtException(Thread t, Throwable e) { public void uncaughtException(Thread t, Throwable e) {
e.printStackTrace(); e.printStackTrace();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment