Search in sources :

Example 56 with SensorManager

use of android.hardware.SensorManager in project Osmand by osmandapp.

the class DayNightHelper method startSensorIfNeeded.

public void startSensorIfNeeded(StateChangedListener<Boolean> sensorStateListener) {
    this.sensorStateListener = sensorStateListener;
    DayNightMode dayNightMode = pref.get();
    if (listener == null && dayNightMode.isSensor()) {
        SensorManager mSensorManager = (SensorManager) osmandApplication.getSystemService(Context.SENSOR_SERVICE);
        Sensor mLight = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
        List<Sensor> list = mSensorManager.getSensorList(Sensor.TYPE_LIGHT);
        // $NON-NLS-1$
        log.info("Light sensors:" + list.size());
        mSensorManager.registerListener(this, mLight, SensorManager.SENSOR_DELAY_NORMAL);
        listener = this;
    } else if (listener != null && !dayNightMode.isSensor()) {
        stopSensorIfNeeded();
    }
}
Also used : SensorManager(android.hardware.SensorManager) DayNightMode(net.osmand.plus.OsmandSettings.DayNightMode) Sensor(android.hardware.Sensor)

Example 57 with SensorManager

use of android.hardware.SensorManager in project SmartMesh_Android by SmartMeshFoundation.

the class AmbientLightManager method start.

public void start(CameraManager cameraManager) {
    this.cameraManager = cameraManager;
    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    if (FrontLightMode.readPref(sharedPrefs) == FrontLightMode.AUTO) {
        SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
        lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
        if (lightSensor != null) {
            sensorManager.registerListener(this, lightSensor, SensorManager.SENSOR_DELAY_NORMAL);
        }
    }
}
Also used : SensorManager(android.hardware.SensorManager) SharedPreferences(android.content.SharedPreferences)

Example 58 with SensorManager

use of android.hardware.SensorManager in project SmartMesh_Android by SmartMeshFoundation.

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 59 with SensorManager

use of android.hardware.SensorManager in project MDM-Android-Agent by wso2-attic.

the class DeviceInfo method getAllSensors.

/**
 *Returns all the sensors available on the device as a List
 */
public void getAllSensors() {
    SensorManager sm = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
    List<Sensor> list = sm.getSensorList(Sensor.TYPE_ALL);
    if (CommonUtilities.DEBUG_MODE_ENABLED) {
        for (Sensor s : list) {
            Log.d("SENSORS", s.getName());
        }
    }
}
Also used : SensorManager(android.hardware.SensorManager) Sensor(android.hardware.Sensor)

Example 60 with SensorManager

use of android.hardware.SensorManager in project android_packages_apps_Settings by DirtyUnicorns.

the class DoubleTwistPreferenceController method isGestureAvailable.

public static boolean isGestureAvailable(Context context) {
    final Resources resources = context.getResources();
    final String name = resources.getString(R.string.gesture_double_twist_sensor_name);
    final String vendor = resources.getString(R.string.gesture_double_twist_sensor_vendor);
    if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(vendor)) {
        final SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
        for (Sensor s : sensorManager.getSensorList(Sensor.TYPE_ALL)) {
            if (name.equals(s.getName()) && vendor.equals(s.getVendor())) {
                return true;
            }
        }
    }
    return false;
}
Also used : SensorManager(android.hardware.SensorManager) Resources(android.content.res.Resources) Sensor(android.hardware.Sensor)

Aggregations

SensorManager (android.hardware.SensorManager)89 Sensor (android.hardware.Sensor)29 SharedPreferences (android.content.SharedPreferences)12 Resources (android.content.res.Resources)8 PowerManager (android.os.PowerManager)6 ContentResolver (android.content.ContentResolver)5 IntentFilter (android.content.IntentFilter)5 SystemSensorManager (android.hardware.SystemSensorManager)5 IPowerManager (android.os.IPowerManager)5 RemoteException (android.os.RemoteException)5 WindowManager (android.view.WindowManager)5 DisplayManagerInternal (android.hardware.display.DisplayManagerInternal)4 BatteryManagerInternal (android.os.BatteryManagerInternal)4 DreamManagerInternal (android.service.dreams.DreamManagerInternal)4 IVrManager (android.service.vr.IVrManager)4 Display (android.view.Display)4 WindowManagerPolicy (android.view.WindowManagerPolicy)4 LightsManager (com.android.server.lights.LightsManager)4 SuppressLint (android.annotation.SuppressLint)3 Intent (android.content.Intent)3