Search in sources :

Example 26 with SensorManager

use of android.hardware.SensorManager in project platform_frameworks_base by android.

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)

Example 27 with SensorManager

use of android.hardware.SensorManager in project SharedPreferenceInspector by PrashamTrivedi.

the class DemoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo);
    SharedPreferences defualtPref = PreferenceManager.getDefaultSharedPreferences(this);
    defualtPref.edit().putString("Test", "Done").apply();
    SharedPreferences anotherPref = getSharedPreferences("Prasham", MODE_PRIVATE);
    anotherPref.edit().putString("Test", "Love you life").apply();
    anotherPref.edit().putInt("Test Int", 1138).apply();
    anotherPref.edit().putFloat("Test Float", 11.38F).apply();
    anotherPref.edit().putLong("Test Long", 113834).apply();
    anotherPref.edit().putBoolean("Test Boolean", true).apply();
    SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    ShakeDetector sd = new ShakeDetector(this);
    sd.start(sensorManager);
}
Also used : SensorManager(android.hardware.SensorManager) SharedPreferences(android.content.SharedPreferences) ShakeDetector(com.squareup.seismic.ShakeDetector)

Example 28 with SensorManager

use of android.hardware.SensorManager in project zxingfragmentlib by mitoyarzun.

the class AmbientLightManager method stop.

public void stop() {
    if (lightSensor != null) {
        SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
        sensorManager.unregisterListener(this);
        cameraManager = null;
        lightSensor = null;
    }
}
Also used : SensorManager(android.hardware.SensorManager)

Example 29 with SensorManager

use of android.hardware.SensorManager in project android_frameworks_base by AOSPA.

the class GestureLauncherService method unregisterCameraLaunchGesture.

private void unregisterCameraLaunchGesture() {
    if (mRegistered) {
        mRegistered = false;
        mCameraGestureOnTimeMs = 0L;
        mCameraGestureLastEventTime = 0L;
        mCameraGestureSensor1LastOnTimeMs = 0;
        mCameraGestureSensor2LastOnTimeMs = 0;
        mCameraLaunchLastEventExtra = 0;
        SensorManager sensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
        sensorManager.unregisterListener(mGestureListener);
    }
}
Also used : SensorManager(android.hardware.SensorManager)

Example 30 with SensorManager

use of android.hardware.SensorManager in project android_frameworks_base by AOSPA.

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