Java Code Examples for android.hardware.SensorManager#SENSOR_DELAY_FASTEST

The following examples show how to use android.hardware.SensorManager#SENSOR_DELAY_FASTEST . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Preferences.java    From ShaderEditor with MIT License 6 votes vote down vote up
private static int parseSensorDelay(String s, int preset) {
	if (s == null) {
		return preset;
	}

	switch (s) {
		case "Fastest":
			return SensorManager.SENSOR_DELAY_FASTEST;
		case "Game":
			return SensorManager.SENSOR_DELAY_GAME;
		case "Normal":
			return SensorManager.SENSOR_DELAY_NORMAL;
		case "UI":
			return SensorManager.SENSOR_DELAY_UI;
	}

	return preset;
}
 
Example 2
Source File: PCustomSensorManager.java    From PHONK with GNU General Public License v3.0 5 votes vote down vote up
@PhonkMethod(description = "Set the speed of the sensor 'slow', 'normal', 'fast'", example = "")
@PhonkMethodParam(params = {"speed=['slow', 'normal', 'fast']"})
public void sensorSpeed(String speed) {
    if (speed.equals("slow")) {
        this.speed = SensorManager.SENSOR_DELAY_UI;
    } else if (speed.equals("fast")) {
        this.speed = SensorManager.SENSOR_DELAY_FASTEST;
    } else {
        this.speed = SensorManager.SENSOR_DELAY_NORMAL;
    }
}
 
Example 3
Source File: XSensorManager.java    From XPrivacy with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void before(XParam param) throws Throwable {
	switch (mMethod) {
	case getDefaultSensor:
		if (isRestricted(param))
			param.setResult(null);
		else if (param.args.length > 0 && param.args[0] instanceof Integer)
			if (isRestricted(param, (Integer) param.args[0]))
				param.setResult(null);
		break;

	case getSensorList:
		if (isRestricted(param))
			param.setResult(new ArrayList<Sensor>());
		else if (param.args.length > 0 && param.args[0] instanceof Integer)
			if (isRestricted(param, (Integer) param.args[0]))
				param.setResult(new ArrayList<Sensor>());
		break;

	case registerListener:
		if (param.args.length > 2 && param.args[1] instanceof Sensor && param.args[2] instanceof Integer) {
			int type = ((Sensor) param.args[1]).getType();
			if (type == Sensor.TYPE_GYROSCOPE || type == Sensor.TYPE_GYROSCOPE_UNCALIBRATED) {
				int rateUs = (Integer) param.args[2];

				// http://developer.android.com/guide/topics/sensors/sensors_overview.html
				if (rateUs == SensorManager.SENSOR_DELAY_NORMAL)
					return; // 200,000 us
				else if (rateUs == SensorManager.SENSOR_DELAY_UI)
					return; // 60,000 us
				else if (rateUs == SensorManager.SENSOR_DELAY_GAME)
					return; // 20,000 us
				else if (rateUs == SensorManager.SENSOR_DELAY_FASTEST)
					; // 0 us

				if (rateUs < cMaxRateUs) // 10,000 us
					if (isRestricted(param))
						param.args[2] = cMaxRateUs;
			}
		}
		break;
	}
}