Upload
snapbacklabs
View
357
Download
5
Tags:
Embed Size (px)
Citation preview
Sensor Stack in Lollipop: what's new and
why you should care about itDroidcon Torino 2015
Friday, April 10 speaker: Claudio Capobianco [email protected]
why we do care about sensors
why we do care about sensors
context awareness
why we do care about sensors
context awareness
improve user interaction
why we do care about sensors
context awareness
improve user interaction
wearable
why we do care about sensors
context awareness
improve user interaction
wearable
internet of things
problem power performances
problem energy consumption
what are the main causes of energy consumption in smartphones?
what are the main causes of energy consumption in smartphones?
peripherals ~33%processor(s) ~28%antennas (network) ~23%display ~16%
source: 2014 Snapback S.r.l.
what are the main causes of energy consumption in smartphones?
peripherals ~33%processor(s) ~28%antennas (network) ~23%display ~16%
source: 2014 Snapback S.r.l.
dive into the problem
batching
my app
onSensorChanged()
my app my app my app
onSensorChanged() onSensorChanged() onSensorChanged()
samplingPeriod
my app
batching: new in KitKat (API 19)
FIFO (HW)
maxReportLatencyonSensorChanged()onSensorChanged()
samplingPeriod
register proximity sensor with batching
SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
Sensor proximitySensor =sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
sensorManager.registerListener(mListener,proximitySensor,SensorManager.SENSOR_DELAY_NORMAL, maxLatency);
register proximity sensor with batching
SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
Sensor proximitySensor =sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
sensorManager.registerListener(mListener,proximitySensor,SensorManager.SENSOR_DELAY_NORMAL, maxLatency);
get Sensor Manager
register proximity sensor with batching
SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
Sensor proximitySensor =sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
sensorManager.registerListener(mListener,proximitySensor,SensorManager.SENSOR_DELAY_NORMAL, maxLatency);get proximity sensor
register proximity sensor with batching
SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
Sensor proximitySensor =sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
sensorManager.registerListener(mListener,proximitySensor,SensorManager.SENSOR_DELAY_NORMAL, maxLatency);
register the sensor listener
register proximity sensor with batching
SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
Sensor proximitySensor =sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
sensorManager.registerListener(mListener,proximitySensor,SensorManager.SENSOR_DELAY_NORMAL, maxLatency);
set samplingperiod [μs]
register proximity sensor with batching
SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
Sensor proximitySensor =sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
sensorManager.registerListener(mListener,proximitySensor,SensorManager.SENSOR_DELAY_NORMAL, maxLatency);
set max report latency [μs]
dive into the problem
batching
wake-up and non-wake-up
what happens when the smartphone is suspended?
what happens when the smartphone is suspended?
wake-upsensor
non-wake-upsensor
wake up the SoC and deliver events
events are lost
which are the wake-up sensors?
up to KitKatmost non-wake-up sensors, except proximity sensor and significant motion detectorcontinuous sensing of other sensor only preventing suspend mode with a wake-lock
which are the wake-up sensors?
up to KitKatmost non-wake-up sensors, except proximity sensor and significant motion detectorcontinuous sensing of other sensor only preventing suspend mode with a wake-lock
starting in Lollipopmost sensors can be defined as both wake-up and non-wake-up variantscontinuous sensing is officially supported
which are the wake-up sensors?
register a wake-up and non-wake-up sensor
Sensor wakeUpAccelerometerSensor =sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER, true);
Sensor nonWakeUpProximitySensor =sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY, false);
Sensor wakeUpProximitySensor =sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY, true);
register a wake-up and non-wake-up sensor
Sensor wakeUpAccelerometerSensor =sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER, true);
Sensor nonWakeUpProximitySensor =sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY, false);
Sensor wakeUpProximitySensor =sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY, true);
boolean wakeUp
register a wake-up and non-wake-up sensor
Sensor wakeUpAccelerometerSensor =sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER, true);
Sensor nonWakeUpProximitySensor =sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY, false);
Sensor wakeUpProximitySensor =sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY, true);
get wake-up accelerometer sensor
(if it exists)
register a wake-up and non-wake-up sensor
Sensor wakeUpAccelerometerSensor =sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER, true);
Sensor nonWakeUpProximitySensor =sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY, false);
Sensor wakeUpProximitySensor =sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY, true); get non-wake-up
proximity sensor(if it exists)
register a wake-up and non-wake-up sensor
Sensor wakeUpAccelerometerSensor =sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER, true);
Sensor nonWakeUpProximitySensor =sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY, false);
Sensor wakeUpProximitySensor =sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY, true);
get wake-up proximity sensor (default)
batching + wake-up sensors
batching + wake-up sensorsenablers of a new generation
of applications
a revolution that involves the full stack
hardwaremanufacturer
AOSPcontributors
applicationdevelopers
Claudio Capobianco [email protected]
thank youplease send me your feedback!