Android 11 support (my attempts)

More
2 years 3 months ago - 2 years 3 months ago #2207 by RoyN
Android 11 support (my attempts) was created by RoyN
TL/DR: Android 11+ boxes require different ADB treatment and it may be impssible to use ADB as a means for their control...

Hi,

A while back I realized that my TV box was not going to work with myServer (in its currrent state) because it was running Android 11, and the ADB authentication scheme has changed...

I was working on trying to get it up and running now, and I've run into a myServer question/issue...  I'll document my steps on this thread so others can hopefully get it working once it works for me.

What I've done so far
on the Android Box:
- Enable WIFI Debugging (as opposed to just ADB) on the Android
- Allow ADB debugging on the connected network (tick remember this network)
- Select "Pair with code" and make note of the IP, Port & 6 digit pin. Close the dialog box.
- Make note of the IP/Port that ADB is using (this may be different from the Port you noted above.  It will be the same IP, however). (We'll call this PORTADB)

On myServer
- Access terminal (ssh or web terminal or equivalent)
- Download the updated ADB tools for Arm (raspberry pi) from:  github.com/lzhiyong/android-sdk-tools/releases
- unzip and replace the folder /home/allonis/applications/platform-tools with the folder from the archive (I renamed my old platform-tools to keep as a backup)
- run "adb kill-server" 
- run "adb pair IP:PORT" (then enter the pin code when requested - the Pin, IP and Port are the ones you got on the Android Box above).
- run "adb connect IP:PORTADB
- run "adb devices" to confirm the box is correctly connected.

- go into the AndroidTV Driver, Driver Test, then AddDevice, and customize the command to add the correct IP, Port, etc for the device

At this point i'm pretty much stuck...  Even after adding the device as above I dont seem to be able to make it work.  I get some errors such as:

1
1/04/2024 20:45:47.45 · DEBUG · AndroidTV.doCommand - Cmd=[7~SendKey~Back] Client=[dashboard-fx-x1vs]
11/04/2024 20:45:47.45 · ERROR · AndroidTV.doCommand - Error in doCommand - Object reference not set to an instance of an object.
11/04/2024 20:45:49.45 · DEBUG · Server.doCommand - AV|{{active_androidtv_{{clientname}}}}~SendKey~Back from dashboard-fx-x1vs
11/04/2024 20:45:49.45 · DEBUG · Server.doCommand - AV|7~SendKey~Back
11/04/2024 20:45:49.45 · DEBUG · AndroidTV.doCommand - Cmd=[7~SendKey~Back] Client=[dashboard-fx-x1vs]
11/04/2024 20:45:49.45 · ERROR · AndroidTV.doCommand - Error in doCommand - Object reference not set to an instance of an object


Apart from this there are several issues which seem to be widespread about Android 11... Namely the Wifi adb doesnt persist after a reboot (or randomly in my experience).  Also, every time the unit is rebooted, reconnects to wifi, or has its Wifi ADB put back on, the ADB port updates to another random number... 

So this is where I'm stuck... I wonder if others have attacked this issue differently?

One thing that comes to mind is using a IRUsb device from Video-Storm... its pretty cheap and I remember I used it to integrate a Shield with a Control4 project once... I just checked and it seems to allow IP control without the ADB hassles...  www.video-storm.com/manuals/IrUSB_protocol.pdf is the protocol info... Would this be possible to be supported in myServer to connect to Android devices that are Android 11+?

EDIT: It's slightly more expensive than I remember (around $75) but is an option I'd consider if supported in myServer.

EDIT2: possible solution to get the changing port here:  stackoverflow.com/a/72987868 Android 11 still seems like a pain in the A##
Last edit: 2 years 3 months ago by RoyN.

Please Log in to join the conversation.

More
2 years 3 months ago #2213 by bowlingbeeg
Replied by bowlingbeeg on topic Android 11 support (my attempts)
I haven't tried connecting to an Android 11 but I will say that I have one of the IrUSB devices that I used in the past with my 2019 Shield Pro and it was excellent. Much more stable and faster than the adb connection. But yes, it is a little pricey.

Please Log in to join the conversation.

More
2 years 3 months ago #2216 by davep
Replied by davep on topic Android 11 support (my attempts)
I've made some changes to the AndroidTV driver I'd like you to test.

First, from the myServer controller make sure that the version of ADB that is installed supports the ADB Pair command. If ADB Pair returns "unknown command pair" then you'll need a newer ADB.

For anyone wanting to do this on an Allonis PI the steps are:

Download this arm64 version from  github.com/lzhiyong/android-sdk-tools/re...s-static-aarch64.zip .
Unzip this to the /usr/lib/android-sdk/platform-tools folder replacing the files that are there. You'll need sudo for this.

wget  github.com/lzhiyong/android-sdk-tools/re...s-static-aarch64.zip
unzip android-sdk-tools-static-aarch64.zip
sudo cp platform-tools/* /usr/lib/android-sdk/platform-tools

Then ADB pair should work.

On the Android device make sure you enable Wireless debugging and click on ."Pair device with pairing code"
Note the IP Address & Port shown in the Pair with device dialog.

From the myServer controller's terminal window issue the command
adb pair ip Address and port from above.
for example: adb pair 192.168.0.124:45361

When prompted to "Enter pairing code" type in the pairing code as displayed on the Android device.
You should get a "Successfully paired to" message displaying a pairing guid like [guid=adb-R5CRC3LT5RK-jtXDDE]

Now from the Android driver in the Dashboard you will need to manually add a new AndroidTV device.
Select AddDevice from the command builder:

Make sure to select IP Port 0, and set the MAC Address field to the value of the quid from above. Your command should look something like.
AndroidTV|AddDevice~New ATV~192.168.0.124~0~AndroidTV~0~~adb-R5CRC3LT5RK-jtXDDE~Unknown

Execute the command to add the device.

When the AndroidTV device is using port 0 that will trigger additional logic in the driver to automatically go out and find the current adb port on the device and use that.
Once it finds the port it will connect to it.

Now, my experience with my Samsung phone is that each time the phone is restarted it will not automatically enabled wireless adb debugging. You'll have to remember to go back in and re-enable when your Android device restarts. Also, another added feature is that it will assign a new adb port every time it gets enabled. The driver has logic in it to catch the old port becoming invalid and going out and finding the new one.

This has been working fine here using my Samsung Galaxy phone as the test device.

Once it is connected then all the normal adb commands will work.

Lots of steps but the bulk of them only need to happen once.

Let us know how this works for you.
 
The following user(s) said Thank You: RoyN

Please Log in to join the conversation.

More
2 years 3 months ago #2222 by RoyN
Replied by RoyN on topic Android 11 support (my attempts)
Apparently it works!! Nice! This may fix issues for users with some Shields that had new android...

As for myself, I dont want to be re-enabling ADB often, and my tv box shuts down randomly... so I'll probably try using another tv box such as a Mi Box I have... Thanks anyways for working on this! I'm sure it will be useful for others.

As for the IrUSB yes, it is really fast, and faster than other experiences I had with ADB. Could be something to look into supporting at a later date.

Please Log in to join the conversation.

More
2 years 3 months ago #2232 by RoyN
Replied by RoyN on topic Android 11 support (my attempts)
ADB seems like it wont pass the wife test here... The delay is noticeable, and she is very picky... If there is a way to integrate the IrUSB it will be a one time cost, vs an every day complaint from my wife lol...

I think another user was successful in "creating his own integration" through TCP... From the irusb manual it shouldnt be too difficult, there isnt any authentication as far as I saw, just a question of sending a text string through a tcp port... I'll try and find the post here mentioning that and if I get the courage to try it out I'll order an irusb as I have no idea where my old ones have ended up... (they will surface once I have buoght others lol)

Please Log in to join the conversation.

More
2 years 3 months ago #2237 by bowlingbeeg
Replied by bowlingbeeg on topic Android 11 support (my attempts)
Easiest thing to do is just replace all of the hard and soft buttons with the correct IrUSB command. I would suggest adding a macro that takes the specific command as a parameter. I've done this with the Zidoo and Lumagen. The only thing you need to be weary of is if you use the same scene for devices in different rooms because if you hardcode the IrUSB command it will only ever send it to one device.

Please Log in to join the conversation.

Time to create page: 0.195 seconds