use of android.hardware.SensorManager in project android_frameworks_base by crdroidandroid.
the class GestureLauncherService method registerCameraLaunchGesture.
/**
* Registers for the camera launch gesture.
*/
private void registerCameraLaunchGesture(Resources resources) {
if (mRegistered) {
return;
}
mCameraGestureOnTimeMs = SystemClock.elapsedRealtime();
mCameraGestureLastEventTime = mCameraGestureOnTimeMs;
SensorManager sensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
int cameraLaunchGestureId = resources.getInteger(com.android.internal.R.integer.config_cameraLaunchGestureSensorType);
if (cameraLaunchGestureId != -1) {
mRegistered = false;
String sensorName = resources.getString(com.android.internal.R.string.config_cameraLaunchGestureSensorStringType);
mCameraLaunchSensor = sensorManager.getDefaultSensor(cameraLaunchGestureId, true);
// makes the code more robust.
if (mCameraLaunchSensor != null) {
if (sensorName.equals(mCameraLaunchSensor.getStringType())) {
mRegistered = sensorManager.registerListener(mGestureListener, mCameraLaunchSensor, 0);
} else {
String message = String.format("Wrong configuration. Sensor type and sensor " + "string type don't match: %s in resources, %s in the sensor.", sensorName, mCameraLaunchSensor.getStringType());
throw new RuntimeException(message);
}
}
if (DBG)
Slog.d(TAG, "Camera launch sensor registered: " + mRegistered);
} else {
if (DBG)
Slog.d(TAG, "Camera launch sensor is not specified.");
}
}
Aggregations