Bug 697641, part 1: Export Android Sensor Manager API to Gecko. r=cjones

This commit is contained in:
Sinker Li
2012-02-01 22:47:51 -08:00
parent d5599b9343
commit fe8d0d714a
3 changed files with 62 additions and 0 deletions

View File

@@ -679,6 +679,42 @@ public class GeckoAppShell
});
}
/*
* Keep these values consistent with |SensorType| in Hal.h
*/
private static final int SENSOR_ORIENTATION = 1;
private static final int SENSOR_ACCELERATION = 2;
private static final int SENSOR_PROXIMITY = 3;
private static Sensor gProximitySensor = null;
public static void enableSensor(int aSensortype) {
SensorManager sm = (SensorManager)
GeckoApp.surfaceView.getContext().
getSystemService(Context.SENSOR_SERVICE);
switch(aSensortype) {
case SENSOR_PROXIMITY:
if(gProximitySensor == null)
gProximitySensor = sm.getDefaultSensor(Sensor.TYPE_PROXIMITY);
sm.registerListener(GeckoApp.surfaceView, gProximitySensor,
SensorManager.SENSOR_DELAY_GAME);
break;
}
}
public static void disableSensor(int aSensortype) {
SensorManager sm = (SensorManager)
GeckoApp.surfaceView.getContext().
getSystemService(Context.SENSOR_SERVICE);
switch(aSensortype) {
case SENSOR_PROXIMITY:
sm.unregisterListener(GeckoApp.surfaceView, gProximitySensor);
break;
}
}
public static void moveTaskToBack() {
GeckoApp.mAppContext.moveTaskToBack(true);
}