Loading app/src/main/java/foundation/e/drive/utils/CommonUtils.java +16 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ package foundation.e.drive.utils; import android.accounts.Account; import android.accounts.AccountManager; import android.app.Service; import android.content.ContentResolver; import android.content.Context; import android.media.MediaScannerConnection; Loading Loading @@ -39,6 +40,21 @@ import static foundation.e.drive.utils.AppConstants.SETTINGSYNC_PROVIDER_AUTHORI public abstract class CommonUtils { final private static String TAG = CommonUtils.class.getSimpleName(); /** * Set ServiceUncaughtExceptionHandler to be the MainThread Exception Handler * Or update the service which use it * @param service current service */ public static void setServiceUnCaughtExceptionHandler(Service service){ Thread.UncaughtExceptionHandler defaultUEH = Thread.getDefaultUncaughtExceptionHandler(); if(defaultUEH.getClass().getSimpleName().equals(ServiceExceptionHandler.class.getSimpleName())){ Log.d("ObserverService", "ServiceExceptionHandler already set!"); ((ServiceExceptionHandler) defaultUEH).setService(service); }else{ Thread.setDefaultUncaughtExceptionHandler(new ServiceExceptionHandler(service)); } } /** * Unregister from screeOffReceiver component Loading app/src/main/java/foundation/e/drive/utils/ServiceExceptionHandler.java +10 −0 Original line number Diff line number Diff line Loading @@ -23,8 +23,18 @@ import java.lang.Thread.UncaughtExceptionHandler; public class ServiceExceptionHandler implements UncaughtExceptionHandler{ private UncaughtExceptionHandler defaultUEH; Service service; /** * Update the service which use this handler * @param service current running service */ public void setService(Service service) { this.service = service; } public ServiceExceptionHandler(Service service) { this.service = service; defaultUEH = Thread.getDefaultUncaughtExceptionHandler(); Loading Loading
app/src/main/java/foundation/e/drive/utils/CommonUtils.java +16 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ package foundation.e.drive.utils; import android.accounts.Account; import android.accounts.AccountManager; import android.app.Service; import android.content.ContentResolver; import android.content.Context; import android.media.MediaScannerConnection; Loading Loading @@ -39,6 +40,21 @@ import static foundation.e.drive.utils.AppConstants.SETTINGSYNC_PROVIDER_AUTHORI public abstract class CommonUtils { final private static String TAG = CommonUtils.class.getSimpleName(); /** * Set ServiceUncaughtExceptionHandler to be the MainThread Exception Handler * Or update the service which use it * @param service current service */ public static void setServiceUnCaughtExceptionHandler(Service service){ Thread.UncaughtExceptionHandler defaultUEH = Thread.getDefaultUncaughtExceptionHandler(); if(defaultUEH.getClass().getSimpleName().equals(ServiceExceptionHandler.class.getSimpleName())){ Log.d("ObserverService", "ServiceExceptionHandler already set!"); ((ServiceExceptionHandler) defaultUEH).setService(service); }else{ Thread.setDefaultUncaughtExceptionHandler(new ServiceExceptionHandler(service)); } } /** * Unregister from screeOffReceiver component Loading
app/src/main/java/foundation/e/drive/utils/ServiceExceptionHandler.java +10 −0 Original line number Diff line number Diff line Loading @@ -23,8 +23,18 @@ import java.lang.Thread.UncaughtExceptionHandler; public class ServiceExceptionHandler implements UncaughtExceptionHandler{ private UncaughtExceptionHandler defaultUEH; Service service; /** * Update the service which use this handler * @param service current running service */ public void setService(Service service) { this.service = service; } public ServiceExceptionHandler(Service service) { this.service = service; defaultUEH = Thread.getDefaultUncaughtExceptionHandler(); Loading