home-assistant / android

:iphone: Home Assistant Companion for Android
https://companion.home-assistant.io/
Apache License 2.0
2.26k stars 628 forks source link

Value data in android intent cannot be read #3824

Closed Maaaciek1 closed 1 year ago

Maaaciek1 commented 1 year ago

Home Assistant Android app version(s): 2023.8.2

Android version(s): 10 QP1A.190711.020 MIUI Global 12.0.6

Device model(s): Xiaomi Redmi Note 8 Pro

Home Assistant version: 2023.8.4

Last working Home Assistant release (if known): ---

Description of problem: Notify for mi band app on Android used to send me value of my mi band battery, which I used as a sensor in Home Assistant. Since upgrading Companion app to 2023.8.2 (I'm not sure it is a cause, though) the sensor is unavailable. Value data in android intent is empty. Tasker can read the value data, so I assume that Notify for mi band app is correctly sending the intent. In attached logs you can see that key value is java.lang.Integer instead of expected String. Perhaps it is related to #3685?

Companion App Logs:

08-26 15:33:59.449  3416  3416 D SensorReceiver: Received intent: com.mc.miband.batteryStatGot
08-26 15:33:59.453  3416  3416 D LastUpdate: Last update is com.mc.miband.batteryStatGot
08-26 15:33:59.462  3416  3416 W Bundle  : Key value expected String but value was a java.lang.Integer.  The default value <null> was returned.
08-26 15:33:59.463  3416  3416 W Bundle  : Attempt to cast generated internal exception:
08-26 15:33:59.463  3416  3416 W Bundle  : java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
08-26 15:33:59.463  3416  3416 W Bundle  :  at android.os.BaseBundle.getString(BaseBundle.java:1172)
08-26 15:33:59.463  3416  3416 W Bundle  :  at io.homeassistant.companion.android.common.sensors.SensorReceiverBase.onReceive(SensorReceiverBase.kt:119)
08-26 15:33:59.463  3416  3416 W Bundle  :  at io.homeassistant.companion.android.sensors.Hilt_SensorReceiver.onReceive(Hilt_SensorReceiver.java:26)
08-26 15:33:59.463  3416  3416 W Bundle  :  at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1556)
08-26 15:33:59.463  3416  3416 W Bundle  :  at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2)
08-26 15:33:59.463  3416  3416 W Bundle  :  at android.os.Handler.handleCallback(Handler.java:914)
08-26 15:33:59.463  3416  3416 W Bundle  :  at android.os.Handler.dispatchMessage(Handler.java:100)
08-26 15:33:59.463  3416  3416 W Bundle  :  at android.os.Looper.loop(Looper.java:224)
08-26 15:33:59.463  3416  3416 W Bundle  :  at android.app.ActivityThread.main(ActivityThread.java:7551)
08-26 15:33:59.463  3416  3416 W Bundle  :  at java.lang.reflect.Method.invoke(Native Method)
08-26 15:33:59.463  3416  3416 W Bundle  :  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
08-26 15:33:59.463  3416  3416 W Bundle  :  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995)
08-26 15:33:59.463  3416  3416 D SensorReceiver: Event data: {value=, intent=com.mc.miband.batteryStatGot}

Screenshot or video of problem: 1

dshokouhi commented 1 year ago

Perhaps it is related to #3685?

no seems like its related to #3698

Will do a partial revert as it seems the non-deprecated method won't work for us as we need to account for different types of values