You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Joaquim Rego (JIRA)" <ji...@apache.org> on 2016/05/26 14:15:13 UTC

[jira] [Comment Edited] (CB-9082) Accelerometer not working on moto G 2

    [ https://issues.apache.org/jira/browse/CB-9082?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15302124#comment-15302124 ] 

Joaquim Rego edited comment on CB-9082 at 5/26/16 2:14 PM:
-----------------------------------------------------------

I've found the exact same issue.

The problem happens when the device doesn't report accuracy changes - while in CB-9339, the default accuracy was set to medium, thus apparently solving the problem, when we stop watching acceleration, the accuracy is set to unreliable... the next time you start it again, it will already be set to unreliable and it won't report any acceleration.

{code}
private void stop() {
        stopTimeout();
        if (this.status != AccelListener.STOPPED) {
            this.sensorManager.unregisterListener(this);
        }
        this.setStatus(AccelListener.STOPPED);
        this.accuracy = SensorManager.SENSOR_STATUS_UNRELIABLE;
}
{code}


I think this can be fixed either by:

# *Don't reset acceleration on stop*: This would change the behavior when the device reports accuracy, because upon restart, app will use the same accuracy as the last onAccuracyChanged, and that may be inconsistent with real accuracy (until a new onAccuracyChanged is triggered). I don't know if this can actually happen, given that in my experience, when the device reports accuracy, it will do it immediately after registering the acceleration listener - of course that's not documented, and unsafer to assume...
# *Always set acceleration to medium before starting*: Similar drawbacks as the 1st solution - when reporting, we may be setting a value higher than the current value and it will only be fixed when the 1st onAccuracyChange is triggered. So, it won't change the stop behavior, but we would end up with 2 lines for a behavior similar to option 1;
# *Reset acceleration on stop only if onAccuracyChanged was triggered*: the most reliable option, given that it keeps the same behavior when device triggers accuracy changes - have a flag for when onAccuracyChanged is triggered and reset or don't reset accordingly (if it doesn't trigger accuracy, don't reset; if it does reset).


was (Author: joaquim.rego):
I've found the exact same issue.

The problem happens when the device doesn't report accuracy changes - while in CB-9339, the default accuracy was set to medium, thus apparently solving the problem, when we stop watching acceleration, the accuracy is set to unreliable... the next time you start it again, it will already be set to unreliable and it won't report any acceleration.

{code}
private void stop() {
        stopTimeout();
        if (this.status != AccelListener.STOPPED) {
            this.sensorManager.unregisterListener(this);
        }
        this.setStatus(AccelListener.STOPPED);
        this.accuracy = SensorManager.SENSOR_STATUS_UNRELIABLE;
}
{code}


I think this can be fixed either by:

# *Don't reset acceleration on stop*: This would change the behavior when the device reports accuracy, because upon restart, app will use the same accuracy as the last onAccuracyChanged, and that may be inconsistent with real accuracy (until a new onAccuracyChanged is triggered). I don't know if this can actually happen, given that in my experience, when the device reports accuracy, it will do it immediately after registering the acceleration listener - of course that's not documented, and unsafer to assume...

# *Always set acceleration to medium before starting*: Similar drawbacks as the 1st solution - when reporting, we may be setting a value higher than the current value and it will only be fixed when the 1st onAccuracyChange is triggered. So, it won't change the stop behavior, but we would end up with 2 lines for a behavior similar to option 1;

# *Reset acceleration on stop only if onAccuracyChanged was triggered*: the most reliable option, given that it keeps the same behavior when device triggers accuracy changes - have a flag for when onAccuracyChanged is triggered and reset or don't reset accordingly (if it doesn't trigger accuracy, don't reset; if it does reset).

> Accelerometer not working on moto G 2
> -------------------------------------
>
>                 Key: CB-9082
>                 URL: https://issues.apache.org/jira/browse/CB-9082
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin Device Motion
>         Environment: Android
>            Reporter: thiago ramires kairala
>
> Accelerometer doesn't work on moto g 2 but works on any other device



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org