/** {@hide} */
  public SystemSensorManager(Looper mainLooper) {
    mMainLooper = mainLooper;

    synchronized (sListeners) {
      if (!sSensorModuleInitialized) {
        sSensorModuleInitialized = true;

        nativeClassInit();

        // initialize the sensor list
        sensors_module_init();
        final ArrayList<Sensor> fullList = sFullSensorsList;
        int i = 0;
        do {
          Sensor sensor = new Sensor();
          i = sensors_module_get_next_sensor(sensor, i);

          if (i >= 0) {
            // Log.d(TAG, "found sensor: " + sensor.getName() +
            //        ", handle=" + sensor.getHandle());
            fullList.add(sensor);
            sHandleToSensor.append(sensor.getHandle(), sensor);
          }
        } while (i > 0);

        sPool = new SensorEventPool(sFullSensorsList.size() * 2);
        sSensorThread = new SensorThread();
      }
    }
  }
 private boolean disableSensorLocked(Sensor sensor) {
   for (ListenerDelegate i : sListeners) {
     if (i.hasSensor(sensor)) {
       // not an error, it's just that this sensor is still in use
       return true;
     }
   }
   String name = sensor.getName();
   int handle = sensor.getHandle();
   return sensors_enable_sensor(sQueue, name, handle, SENSOR_DISABLE);
 }
 private boolean enableSensorLocked(Sensor sensor, int delay) {
   boolean result = false;
   for (ListenerDelegate i : sListeners) {
     if (i.hasSensor(sensor)) {
       String name = sensor.getName();
       int handle = sensor.getHandle();
       result = sensors_enable_sensor(sQueue, name, handle, delay);
       break;
     }
   }
   return result;
 }
 boolean hasSensor(Sensor sensor) {
   return mSensors.get(sensor.getHandle());
 }
 int removeSensor(Sensor sensor) {
   mSensors.delete(sensor.getHandle());
   mSensorList.remove(sensor);
   return mSensors.size();
 }
 void addSensor(Sensor sensor) {
   mSensors.put(sensor.getHandle(), true);
   mSensorList.add(sensor);
 }