dwaan / homebridge-adb

Homebridge script to control remote ADB enabled Android device
MIT License
74 stars 14 forks source link

CheckInput - error #66

Closed halk1982 closed 2 years ago

halk1982 commented 2 years ago

Describe the bug Plugin not able to detect the current running app. Error in Homebridge log is "CheckInput - Error". Tried also the command adb -s your-device-ip shell "dumpsys window windows | grep -E mFocusedApp" and I'm not getting any response back into terminal. Other than this, the device can be controlled normally, meaning switching apps, sleep, wakeup etc. Expected behavior Expected to work as my other two android devices. Both work fine from either the plugin or the command execution from terminal. Log output It is really only one error : CheckInput - Error Let me know if you need something more than this.

Device (please complete the following information): BMAX tablet, model MaxPad I10, Android version 10 Additional context Thank you very much for this amazing plugin Dwaan, I really appreciate your work and effort behind this.

dwaan commented 2 years ago

Hey, can you upload this command output adb -s your-device-ip shell "dumpsys window windows" which app that currently displayed in your screen. Your Android device might have different log type. Most of my Android devices output have "mFocusedApp" in there log to identified current opening app. If I can find the word, I can add to the plugins.

halk1982 commented 2 years ago

Hello Dwann, thank you for the super fast response. I just find out that this one worked just fine (check below):

pi@raspberrypi:~ $ adb -s 192.168.1.85 shell "dumpsys window windows | grep -E mSurface" mAnimationIsEntrance=true mSurface=Surface(name=NavigationBar0)/@0xaf28624 mAnimationIsEntrance=true mSurface=Surface(name=StatusBar)/@0x4db151 mSurface=Surface(name=com.synology.DScam/com.synology.DScam.activities.MainActivity)/@0x59c2d90 mAnimationIsEntrance=true mSurface=Surface(name=com.android.systemui.ImageWallpaper)/@0x86c464a

Here is the output from the command you asked me to run:

For_Dwaan.txt

Let me know if you need something more than this.

dwaan commented 2 years ago

Yes, that should be enough. Just to make sure, are you running com.synology.DScam.activities.MainActivity app in the foreground when running that command?

halk1982 commented 2 years ago

Exactly that was the running app!

App id (or package name) is :

com.Synology.DScam

Thank you so much Dwaan!!

dwaan commented 2 years ago

Oh, one more, can you run 1 or 2 more different apps and send the output of adb -s your-device-ip shell "dumpsys window windows", just want to make sure the exact word will applied to other app or not.

halk1982 commented 2 years ago

Sure thing, there you go.

3 different ones for Home, Settings & Chrome :

For_Dwaan_Home.txt For_Dwaan_Chrome.txt For_Dwaan_Settings.txt

dwaan commented 2 years ago

It seems like there is no consistent way to detect active app based on your outputs. But I found out that I can use this command to produce similar result adb -s IP shell "dumpsys activity activities | grep ' ResumedActivity'". Can you confirm if this produce one line output containing current active app id in your device?

halk1982 commented 2 years ago

Yes it does and works like a charm (check below with several apps open):

homebridge@raspberrypi:/var/lib/homebridge $ adb -s 192.168.1.85 shell "dumpsys activity activities | grep ' ResumedActivity'" ResumedActivity:ActivityRecord{acf4df9 u0 com.android.launcher3/com.android.searchlauncher.SearchLauncher t36} ResumedActivity: ActivityRecord{acf4df9 u0 com.android.launcher3/com.android.searchlauncher.SearchLauncher t36} homebridge@raspberrypi:/var/lib/homebridge $ adb -s 192.168.1.85 shell "dumpsys activity activities | grep ' ResumedActivity'" ResumedActivity:ActivityRecord{c827c0f u0 com.synology.DScam/.activities.MainActivity t84} ResumedActivity: ActivityRecord{c827c0f u0 com.synology.DScam/.activities.MainActivity t84} homebridge@raspberrypi:/var/lib/homebridge $ adb -s 192.168.1.85 shell "dumpsys activity activities | grep ' ResumedActivity'" ResumedActivity:ActivityRecord{1359b75 u0 com.android.chrome/com.google.android.apps.chrome.Main t85} ResumedActivity: ActivityRecord{1359b75 u0 com.android.chrome/com.google.android.apps.chrome.Main t85} homebridge@raspberrypi:/var/lib/homebridge $ adb -s 192.168.1.85 shell "dumpsys activity activities | grep ' ResumedActivity'" ResumedActivity:ActivityRecord{a065697 u0 com.android.settings/.Settings t86} ResumedActivity: ActivityRecord{a065697 u0 com.android.settings/.Settings t86}

halk1982 commented 2 years ago

Hello Dwaan, thank you for this, works great now! However, I now do not have app detection on the other 2 android devices, because of the "dumpsys activity activities | grep ' ResumedActivity'" not a valid command for these devices. Is it possible for you to add an option on every device to select the old or new app detection method ?

dwaan commented 2 years ago

Hello Dwaan, thank you for this, works great now! However, I now do not have app detection on the other 2 android devices, because of the "dumpsys activity activities | grep ' ResumedActivity'" not a valid command for these devices. Is it possible for you to add an option on every device to select the old or new app detection method ?

Ah, thank you for the feedback. Let me get back with another update soon. I was wondering also yesterday if this will break other devices.

halk1982 commented 2 years ago

Hello again Dwaan, just installed 1.4.12. Unfortunately I see no difference, still failing to detect running application on both older android devices (tried also to remove and re-add device to HomeKit) while the brand new one still works great (check below):

Screen Shot 2022-01-11 at 01 22 38

After that, for troubleshooting purpose I rolled back to 1.4.11 and realised the opposite scenario. Older devices worked fine but now the new one was not (check below):

Screen Shot 2022-01-11 at 01 08 24

Is there anything I can do to support you on this ? Thank you again.

dwaan commented 2 years ago

Hi

Thank you for the output, was still trying to figure out the best way to fix it. I released a new version, please try it again, and let me know if it's working now or not.

halk1982 commented 2 years ago

Yes, I do confirm every device app is detected and works like a charm. Can't thank you enough Dwaan, I really appreciate your work.