Bug 697641, part 1: Export Android Sensor Manager API to Gecko. r=cjones
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user