public void setSensorSleepWindow(long millis) {
   try {
     sensorManager.setSensorConfig(
         sensorType, PullSensorConfig.POST_SENSE_SLEEP_LENGTH_MILLIS, millis);
   } catch (ESException e) {
     e.printStackTrace();
   }
 }
 public void setSensorSampleWindow(long millis) {
   try {
     sensorManager.setSensorConfig(
         sensorType, PullSensorConfig.SENSE_WINDOW_LENGTH_MILLIS, millis);
   } catch (ESException e) {
     e.printStackTrace();
   }
 }
 public String getSensorName() {
   try {
     return SensorUtils.getSensorName(sensorType);
   } catch (ESException e) {
     e.printStackTrace();
     return null;
   }
 }
 public ExampleSensorConfigUpdater(int sensor) {
   this.sensorType = sensor;
   try {
     sensorManager = ESSensorManager.getSensorManager(ApplicationContext.getContext());
   } catch (ESException e) {
     e.printStackTrace();
   }
 }
 public int getSensorSleepWindow() {
   try {
     Long sampleWindow =
         (Long)
             sensorManager.getSensorConfigValue(
                 sensorType, PullSensorConfig.POST_SENSE_SLEEP_LENGTH_MILLIS);
     return (int) (sampleWindow / 1000);
   } catch (ESException e) {
     e.printStackTrace();
     return 0;
   }
 }
  public void run() {
    synchronized (syncObject) {
      while (true) {
        try {
          try {

            if ((state == PAUSED) || (state == STOPPED)) {
              if (state == PAUSED) {
                syncObject.wait(pauseTime);
              } else if (state == STOPPED) {
                syncObject.wait();
              }
              state = RUNNING;
              continue;
            }

            // SENSE
            // sense() is a blocking call and returns when
            // the sensing is complete, the sensorConfig object
            // will have the sampling window, cycle information
            if (GlobalConfig.shouldLog()) {
              Log.d(
                  getLogTag(),
                  "Pulling from: " + SensorUtils.getSensorName(sensor.getSensorType()));
            }

            SensorData sensorData = getCurrentSensorData(false);
            // publish sensed data
            publishData(sensorData);

            // SLEEP
            long samplingInterval =
                (Long) sensor.getSensorConfig(PullSensorConfig.POST_SENSE_SLEEP_LENGTH_MILLIS);
            syncObject.wait(samplingInterval);
          } catch (InterruptedException exp) {
            // ignore
          }
        } catch (ESException e) {
          e.printStackTrace();
          try {
            Thread.sleep(30000);
          } catch (Exception exp) {
            exp.printStackTrace();
          }
        }
      }
    }
  }