Lines Matching refs:Sensor
34 * Sensor manager implementation that communicates with the built-in
41 private static native int nativeGetNextSensor(Sensor sensor, int next);
45 private static final ArrayList<Sensor> sFullSensorsList = new ArrayList<Sensor>();
46 private static final SparseArray<Sensor> sHandleToSensor = new SparseArray<Sensor>();
68 // initialize the sensor list
69 final ArrayList<Sensor> fullList = sFullSensorsList;
72 Sensor sensor = new Sensor();
73 i = nativeGetNextSensor(sensor, i);
75 //Log.d(TAG, "found sensor: " + sensor.getName() +
76 // ", handle=" + sensor.getHandle());
77 fullList.add(sensor);
78 sHandleToSensor.append(sensor.getHandle(), sensor);
88 protected List<Sensor> getFullSensorList() {
95 protected boolean registerListenerImpl(SensorEventListener listener, Sensor sensor,
97 if (listener == null || sensor == null) {
98 Log.e(TAG, "sensor or listener is null");
102 if (sensor.getReportingMode() == Sensor.REPORTING_MODE_ONE_SHOT) {
120 if (!queue.addSensor(sensor, delayUs, maxBatchReportLatencyUs, reservedFlags)) {
127 return queue.addSensor(sensor, delayUs, maxBatchReportLatencyUs, reservedFlags);
134 protected void unregisterListenerImpl(SensorEventListener listener, Sensor sensor) {
136 if (sensor != null && sensor.getReportingMode() == Sensor.REPORTING_MODE_ONE_SHOT) {
144 if (sensor == null) {
147 result = queue.removeSensor(sensor, true);
159 protected boolean requestTriggerSensorImpl(TriggerEventListener listener, Sensor sensor) {
160 if (sensor == null) throw new IllegalArgumentException("sensor cannot be null");
162 if (sensor.getReportingMode() != Sensor.REPORTING_MODE_ONE_SHOT) return false;
168 if (!queue.addSensor(sensor, 0, 0, 0)) {
175 return queue.addSensor(sensor, 0, 0, 0);
182 protected boolean cancelTriggerSensorImpl(TriggerEventListener listener, Sensor sensor,
184 if (sensor != null && sensor.getReportingMode() != Sensor.REPORTING_MODE_ONE_SHOT) {
191 if (sensor == null) {
194 result = queue.removeSensor(sensor, disable);
220 * BaseEventQueue is the communication channel with the sensor service,
251 Sensor sensor, int delayUs, int maxBatchReportLatencyUs, int reservedFlags) {
253 int handle = sensor.getHandle();
258 addSensorEvent(sensor);
259 if (enableSensor(sensor, delayUs, maxBatchReportLatencyUs, reservedFlags) != 0) {
262 maxBatchReportLatencyUs > 0 && enableSensor(sensor, delayUs, 0, 0) != 0) {
263 removeSensor(sensor, false);
274 Sensor sensor = sHandleToSensor.get(handle);
275 if (sensor != null) {
276 disableSensor(sensor);
278 removeSensorEvent(sensor);
287 public boolean removeSensor(Sensor sensor, boolean disable) {
288 final int handle = sensor.getHandle();
290 if (disable) disableSensor(sensor);
291 mActiveSensors.put(sensor.getHandle(), false);
292 removeSensorEvent(sensor);
331 Sensor sensor, int rateUs, int maxBatchReportLatencyUs, int reservedFlags) {
333 if (sensor == null) throw new NullPointerException();
334 return nativeEnableSensor(nSensorEventQueue, sensor.getHandle(), rateUs,
338 private int disableSensor(Sensor sensor) {
340 if (sensor == null) throw new NullPointerException();
341 return nativeDisableSensor(nSensorEventQueue, sensor.getHandle());
347 protected abstract void addSensorEvent(Sensor sensor);
348 protected abstract void removeSensorEvent(Sensor sensor);
362 public void addSensorEvent(Sensor sensor) {
363 SensorEvent t = new SensorEvent(Sensor.getMaxLengthValuesArray(sensor,
366 mSensorsEvents.put(sensor.getHandle(), t);
371 public void removeSensorEvent(Sensor sensor) {
373 mSensorsEvents.delete(sensor.getHandle());
382 final Sensor sensor = sHandleToSensor.get(handle);
397 t.sensor = sensor;
403 mListener.onAccuracyChanged(t.sensor, t.accuracy);
411 final Sensor sensor = sHandleToSensor.get(handle);
412 ((SensorEventListener2)mListener).onFlushCompleted(sensor);
429 public void addSensorEvent(Sensor sensor) {
430 TriggerEvent t = new TriggerEvent(Sensor.getMaxLengthValuesArray(sensor,
433 mTriggerEvents.put(sensor.getHandle(), t);
438 public void removeSensorEvent(Sensor sensor) {
440 mTriggerEvents.delete(sensor.getHandle());
449 final Sensor sensor = sHandleToSensor.get(handle);
455 Log.e(TAG, "Error: Trigger Event is null for Sensor: " + sensor);
462 t.sensor = sensor;
464 // A trigger sensor is auto disabled. So just clean up and don't call native
466 mManager.cancelTriggerSensorImpl(mListener, sensor, false);