Search in sources :

Example 41 with SensorManager

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.");
    }
}
Also used : SensorManager(android.hardware.SensorManager)

Aggregations

SensorManager (android.hardware.SensorManager)41 SharedPreferences (android.content.SharedPreferences)7 PowerManager (android.os.PowerManager)6 ContentResolver (android.content.ContentResolver)5 IntentFilter (android.content.IntentFilter)5 Sensor (android.hardware.Sensor)5 SystemSensorManager (android.hardware.SystemSensorManager)5 IPowerManager (android.os.IPowerManager)5 DisplayManagerInternal (android.hardware.display.DisplayManagerInternal)4 BatteryManagerInternal (android.os.BatteryManagerInternal)4 RemoteException (android.os.RemoteException)4 DreamManagerInternal (android.service.dreams.DreamManagerInternal)4 IVrManager (android.service.vr.IVrManager)4 WindowManagerPolicy (android.view.WindowManagerPolicy)4 LightsManager (com.android.server.lights.LightsManager)4 WindowManager (android.view.WindowManager)3 Context (android.content.Context)2 LocationManager (android.location.LocationManager)2 Display (android.view.Display)2 ActivityManager (android.app.ActivityManager)1