Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix light sensor crash on older devices that don't have one #766

Merged
merged 1 commit into from Aug 15, 2020

Conversation

dshokouhi
Copy link
Member

@dshokouhi dshokouhi commented Aug 15, 2020

Older android devices that did not have a light sensor was crashing, this now fixes the below crash

08-14 22:15:22.224 5657-5704/? E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-2
    Process: io.homeassistant.companion.android, PID: 5657
    kotlin.TypeCastException: null cannot be cast to non-null type android.hardware.Sensor
        at io.homeassistant.companion.android.sensors.LightSensorManager.getLightSensor(LightSensorManager.kt:51)
        at io.homeassistant.companion.android.sensors.LightSensorManager.getSensorData(LightSensorManager.kt:42)
        at io.homeassistant.companion.android.sensors.SensorManager$DefaultImpls.getEnabledSensorData(SensorManager.kt:71)
        at io.homeassistant.companion.android.sensors.LightSensorManager.getEnabledSensorData(LightSensorManager.kt:12)
        at io.homeassistant.companion.android.sensors.SensorReceiver.updateSensors(SensorReceiver.kt:81)
        at io.homeassistant.companion.android.sensors.SensorReceiver$onReceive$1.invokeSuspend(SensorReceiver.kt:56)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

I noticed this on my fire tablet that's on android 5, will make sure to include it during testing next time :)

@JBassett JBassett merged commit 469be03 into home-assistant:master Aug 15, 2020
@dshokouhi dshokouhi deleted the fix_crash_light_sensor branch August 15, 2020 15:20
@JBassett JBassett added bug Something isn't working patch A tiny change - Bumps patch build number labels Aug 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cla-signed patch A tiny change - Bumps patch build number
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants