5
0
Эх сурвалжийг харах

Gives the user the ability to find out whether the service is being shutdown in order to avoid executing nodes after calling shutdown on it.

Pedro Liberal Fernandez 11 жил өмнө
parent
commit
d964f2c0ab

+ 6 - 0
android_10/src/org/ros/android/NodeMainExecutorService.java

@@ -75,6 +75,7 @@ public class NodeMainExecutorService extends Service implements NodeMainExecutor
   private final IBinder binder;
   private final ListenerGroup<NodeMainExecutorServiceListener> listeners;
 
+  private boolean isShuttingDown;
   private Handler handler;
   private WakeLock wakeLock;
   private WifiLock wifiLock;
@@ -174,6 +175,7 @@ public class NodeMainExecutorService extends Service implements NodeMainExecutor
   }
 
   public void forceShutdown() {
+    isShuttingDown = true;
     signalOnShutdown();
     nodeMainExecutor.addListener(new NodeMainExecutorListener() {
       @Override
@@ -185,6 +187,10 @@ public class NodeMainExecutorService extends Service implements NodeMainExecutor
     nodeMainExecutor.shutdown();
   }
 
+  public boolean isShuttingDown() {
+    return isShuttingDown;
+  }
+
   public void addNodeMainExecutorServiceListener(final NodeMainExecutorServiceListener listener) {
     listeners.add(listener);
   }