Java Code Examples for android.hardware.Sensor#isWakeUpSensor()
The following examples show how to use
android.hardware.Sensor#isWakeUpSensor() .
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: DeviceSensor.java From Sensor-Data-Logger with Apache License 2.0 | 6 votes |
public DeviceSensor(Sensor sensor) { name = sensor.getName(); vendor = sensor.getVendor(); version = sensor.getVersion(); type = sensor.getType(); resolution = sensor.getResolution(); power = sensor.getPower(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { stringType = sensor.getStringType(); } else { stringType = "SENSOR_TYPE_" + type; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { reportingMode = sensor.getReportingMode(); isWakeUpSensor = sensor.isWakeUpSensor(); } else { reportingMode = 0; isWakeUpSensor = sensor.getName().toLowerCase().contains("wake_up"); } }
Example 2
Source File: Sensors.java From batteryhub with Apache License 2.0 | 6 votes |
private static SensorDetails extractSensorDetails(Sensor sensor) { SensorDetails details = null; if ((details = sensorsMap.get(sensor.getName())) == null) { details = new SensorDetails(); sensorsMap.put(sensor.getName(), details); } details.codeType = sensor.getType(); details.fifoMaxEventCount = sensor.getFifoMaxEventCount(); details.fifoReservedEventCount = sensor.getFifoReservedEventCount(); getAttributesNewVersion(sensor, details); details.isWakeUpSensor = sensor.isWakeUpSensor(); details.maxDelay = sensor.getMaxDelay(); details.maximumRange = sensor.getMaximumRange(); details.minDelay = sensor.getMinDelay(); details.name = sensor.getName(); details.power = sensor.getPower(); details.reportingMode = sensor.getReportingMode(); details.resolution = sensor.getResolution(); details.stringType = sensor.getStringType(); details.vendor = sensor.getVendor(); details.version = sensor.getVersion(); return details; }
Example 3
Source File: WindowOrientationListener.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * Creates a new WindowOrientationListener. * * @param context for the WindowOrientationListener. * @param handler Provides the Looper for receiving sensor updates. * @param rate at which sensor events are processed (see also * {@link android.hardware.SensorManager SensorManager}). Use the default * value of {@link android.hardware.SensorManager#SENSOR_DELAY_NORMAL * SENSOR_DELAY_NORMAL} for simple screen orientation change detection. * * This constructor is private since no one uses it. */ private WindowOrientationListener(Context context, Handler handler, int rate) { mHandler = handler; mSensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE); mRate = rate; List<Sensor> l = mSensorManager.getSensorList(Sensor.TYPE_DEVICE_ORIENTATION); Sensor wakeUpDeviceOrientationSensor = null; Sensor nonWakeUpDeviceOrientationSensor = null; /** * Prefer the wakeup form of the sensor if implemented. * It's OK to look for just two types of this sensor and use * the last found. Typical devices will only have one sensor of * this type. */ for (Sensor s : l) { if (s.isWakeUpSensor()) { wakeUpDeviceOrientationSensor = s; } else { nonWakeUpDeviceOrientationSensor = s; } } if (wakeUpDeviceOrientationSensor != null) { mSensor = wakeUpDeviceOrientationSensor; } else { mSensor = nonWakeUpDeviceOrientationSensor; } if (mSensor != null) { mOrientationJudge = new OrientationSensorJudge(); } if (mOrientationJudge == null) { mSensor = mSensorManager.getDefaultSensor(USE_GRAVITY_SENSOR ? Sensor.TYPE_GRAVITY : Sensor.TYPE_ACCELEROMETER); if (mSensor != null) { // Create listener only if sensors do exist mOrientationJudge = new AccelSensorJudge(context); } } }
Example 4
Source File: SensorMetricsCollector.java From Battery-Metrics with MIT License | 4 votes |
static boolean isWakeupSensor(Sensor sensor) { return Build.VERSION.SDK_INT >= 21 && sensor.isWakeUpSensor(); }