use of android.hardware.Sensor in project AndEngine by nicolasgramlich.
the class Engine method unregisterSelfAsSensorListener.
private void unregisterSelfAsSensorListener(final SensorManager pSensorManager, final int pType) {
final Sensor sensor = pSensorManager.getSensorList(pType).get(0);
pSensorManager.unregisterListener(this, sensor);
}
use of android.hardware.Sensor in project sensey by nisrulz.
the class SensorUtils method testSensor.
private static Sensor testSensor(int type) {
Sensor sensor = mock(Sensor.class);
when(sensor.getType()).thenReturn(type);
return sensor;
}
use of android.hardware.Sensor in project robolectric by robolectric.
the class ShadowSensorManagerTest method registerListener.
private SensorEventListener registerListener() {
SensorEventListener listener = new TestSensorEventListener();
Sensor sensor = sensorManager.getDefaultSensor(SensorManager.SENSOR_ACCELEROMETER);
sensorManager.registerListener(listener, sensor, SensorManager.SENSOR_DELAY_NORMAL);
return listener;
}
use of android.hardware.Sensor in project platform_frameworks_base by android.
the class SensorPowerCalculator method calculateApp.
@Override
public void calculateApp(BatterySipper app, BatteryStats.Uid u, long rawRealtimeUs, long rawUptimeUs, int statsType) {
// Process Sensor usage
final SparseArray<? extends BatteryStats.Uid.Sensor> sensorStats = u.getSensorStats();
final int NSE = sensorStats.size();
for (int ise = 0; ise < NSE; ise++) {
final BatteryStats.Uid.Sensor sensor = sensorStats.valueAt(ise);
final int sensorHandle = sensorStats.keyAt(ise);
final BatteryStats.Timer timer = sensor.getSensorTime();
final long sensorTime = timer.getTotalTimeLocked(rawRealtimeUs, statsType) / 1000;
switch(sensorHandle) {
case BatteryStats.Uid.Sensor.GPS:
app.gpsTimeMs = sensorTime;
app.gpsPowerMah = (app.gpsTimeMs * mGpsPowerOn) / (1000 * 60 * 60);
break;
default:
final int sensorsCount = mSensors.size();
for (int i = 0; i < sensorsCount; i++) {
final Sensor s = mSensors.get(i);
if (s.getHandle() == sensorHandle) {
app.sensorPowerMah += (sensorTime * s.getPower()) / (1000 * 60 * 60);
break;
}
}
break;
}
}
}
use of android.hardware.Sensor in project JieCaoVideoPlayer by lipangit.
the class ApiActivity method onResume.
@Override
protected void onResume() {
super.onResume();
Sensor accelerometerSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mSensorManager.registerListener(mSensorEventListener, accelerometerSensor, SensorManager.SENSOR_DELAY_NORMAL);
}
Aggregations