Skip to content

Commit

Permalink
[hybris-adaptors] Select 1st sensor variant for each sensor type. JB#…
Browse files Browse the repository at this point in the history
…39550

The advent of virtual sensor variants means it is likely that several
sensors are listed by android hal for each sensor type. Looks like at
least Sony Xperia X lists primary sensors (that have wakeup capabilities
like we expect) before secondary sensors. As sensorfwd uses the last
entry listed for each sensor type, it means we get inverse wakeup from
suspend behavior from what we want: The proximity sensor does not wake
up the device, but something like ambient light sensor would - if it
were left active in suspend.

Probably this sensor selection should mimic what android java side does
when choosing default sensor for type, but that has dependencies to
sensors api versions etc.

Choose the 1st sensor listed for each type in assumption that it will be
the best fit for our purposes in case of having several virtual sensor
variants.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Aug 31, 2017
1 parent 47f52bf commit 818be65
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions core/hybrisadaptor.cpp
Expand Up @@ -119,11 +119,29 @@ void HybrisManager::init()
sensorsCount = module->get_sensors_list(module, &sensorList);

for (int i = 0 ; i < sensorsCount ; i++) {
bool use = true;
// Assumption: The primary sensor variants that we want to
// use are listed before the secondary ones that we want
// to ignore -> Use the 1st entry found for each sensor type.
if( sensorMap.contains(sensorList[i].type) ) {
use = false;
}

// some devices have compass and compass raw,
// ignore compass raw. compass has range 360
if (sensorList[i].type != SENSOR_TYPE_ORIENTATION
|| sensorList[i].maxRange == 360)
sensorMap.insert(sensorList[i].type, i);
if (sensorList[i].type == SENSOR_TYPE_ORIENTATION &&
sensorList[i].maxRange != 360) {
use = false;
}

sensordLogW() << Q_FUNC_INFO
<< (use ? "SELECT" : "IGNORE")
<< "type:" << sensorList[i].type
<< "name:" << (sensorList[i].name ?: "n/a");

if (use) {
sensorMap.insert(sensorList[i].type, i);
}
}
}

Expand Down

0 comments on commit 818be65

Please sign in to comment.