konqi / roborock-bridge

Bridge between a local mqtt broker and your roborock vaccuum through the vendor apis
MIT License
4 stars 1 forks source link

Problem with setup of virtual android device #56

Open Michl7 opened 2 weeks ago

Michl7 commented 2 weeks ago

The problem i have is at the stop with rootAVD: I have a virtual device running and followed the gif instructions for windows:

Getting errors regarding ADB commands not found:

Microsoft Windows [Version 10.0.22631.3737]
(c) Microsoft Corporation. Alle Rechte vorbehalten.

C:\Users\binde>g:

G:\>cd binde\Desktop\rootAVD-master

G:\binde\Desktop\rootAVD-master>rootAVD.bat
rootAVD A Script to root AVD by NewBit XDA

Usage:  rootAVD [DIR/ramdisk.img] [OPTIONS] | [EXTRA ARGUMENTS]
or:     rootAVD [ARGUMENTS]

Arguments:
        ListAllAVDs                     Lists Command Examples for ALL installed AVDs

        InstallApps                     Just install all APKs placed in the Apps folder

Main operation mode:
        DIR                             a path to an AVD system-image
                                        - must always be the 1st Argument after rootAVD

ADB Path | Ramdisk DIR| ANDROID_HOME:
        [M]ac/Darwin:                   export PATH=~/Library/Android/sdk/platform-tools:$PATH
                                        export PATH=$ANDROID_HOME/platform-tools:$PATH
                                        system-images/android-$API/google_apis_playstore/x86_64/

        [L]inux:                        export PATH=~/Android/Sdk/platform-tools:$PATH
                                        export PATH=$ANDROID_HOME/platform-tools:$PATH
                                        system-images/android-$API/google_apis_playstore/x86_64/

        [W]indows:                      set PATH=%LOCALAPPDATA%\Android\Sdk\platform-tools;%PATH%
                                        system-images\android-$API\google_apis_playstore\x86_64\

        ANDROID_HOME:                   By default, the script uses %LOCALAPPDATA%, to set its Android Home
                                        directory, search for AVD system-images and ADB binarys. This behaviour
                                        can be overwritten by setting the ANDROID_HOME variable.
                                        e.g. set ANDROID_HOME=%USERPROFILE%\Downloads\sdk

        $API:                           25,29,30,31,32,33,34,UpsideDownCake,etc.

Options:
        restore                         restore all existing .backup files, but doesn't delete them
                                        - the AVD doesn't need to be running
                                        - no other Argument after will be processed

        InstallKernelModules            install custom build kernel and its modules into ramdisk.img
                                        - kernel (bzImage) and its modules (initramfs.img) are inside rootAVD
                                        - both files will be deleted after installation

        InstallPrebuiltKernelModules    download and install an AOSP prebuilt kernel and its modules into ramdisk.img
                                        - similar to InstallKernelModules, but the AVD needs to be online

Options are exclusive, only one at the time will be processed.

Extra Arguments:
        DEBUG                           Debugging Mode, prevents rootAVD to pull back any patched file

        PATCHFSTAB                      fstab.ranchu will get patched to automount Block Devices like /dev/block/sda1
                                        - other entries can be added in the script as well
                                        - a custom build Kernel might be necessary

        GetUSBHPmodZ                    The USB HOST Permissions Module Zip will be downloaded into /sdcard/Download

        FAKEBOOTIMG                     Creates a fake Boot.img file that can directly be patched from the Magisk APP
                                        - Magisk will be launched to patch the fake Boot.img within 60s
                                        - the fake Boot.img will be placed under /sdcard/Download/fakeboot.img

Extra Arguments can be combined, there is no particular order.

Notes: rootAVD will
- always create .backup files of ramdisk*.img and kernel-ranchu
- replace both when done patching
- show a Menu, to choose the Magisk Version (Stable || Canary || Alpha), if the AVD is online
- make the choosen Magisk Version to its local
- install all APKs placed in the Apps folder
- use %LOCALAPPDATA%\Android\Sdk to search for AVD system images

Command Examples:
rootAVD.bat
rootAVD.bat ListAllAVDs
rootAVD.bat InstallApps

rootAVD.bat system-images\android-34\google_apis\x86_64\ramdisk.img
rootAVD.bat system-images\android-34\google_apis\x86_64\ramdisk.img FAKEBOOTIMG
rootAVD.bat system-images\android-34\google_apis\x86_64\ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
rootAVD.bat system-images\android-34\google_apis\x86_64\ramdisk.img restore
rootAVD.bat system-images\android-34\google_apis\x86_64\ramdisk.img InstallKernelModules
rootAVD.bat system-images\android-34\google_apis\x86_64\ramdisk.img InstallPrebuiltKernelModules
rootAVD.bat system-images\android-34\google_apis\x86_64\ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG

G:\binde\Desktop\rootAVD-master>rootAVD.bat ListAllAVDs
rootAVD A Script to root AVD by NewBit XDA

Usage:  rootAVD [DIR/ramdisk.img] [OPTIONS] | [EXTRA ARGUMENTS]
or:     rootAVD [ARGUMENTS]

Arguments:
        ListAllAVDs                     Lists Command Examples for ALL installed AVDs

        InstallApps                     Just install all APKs placed in the Apps folder

Main operation mode:
        DIR                             a path to an AVD system-image
                                        - must always be the 1st Argument after rootAVD

ADB Path | Ramdisk DIR| ANDROID_HOME:
        [M]ac/Darwin:                   export PATH=~/Library/Android/sdk/platform-tools:$PATH
                                        export PATH=$ANDROID_HOME/platform-tools:$PATH
                                        system-images/android-$API/google_apis_playstore/x86_64/

        [L]inux:                        export PATH=~/Android/Sdk/platform-tools:$PATH
                                        export PATH=$ANDROID_HOME/platform-tools:$PATH
                                        system-images/android-$API/google_apis_playstore/x86_64/

        [W]indows:                      set PATH=%LOCALAPPDATA%\Android\Sdk\platform-tools;%PATH%
                                        system-images\android-$API\google_apis_playstore\x86_64\

        ANDROID_HOME:                   By default, the script uses %LOCALAPPDATA%, to set its Android Home
                                        directory, search for AVD system-images and ADB binarys. This behaviour
                                        can be overwritten by setting the ANDROID_HOME variable.
                                        e.g. set ANDROID_HOME=%USERPROFILE%\Downloads\sdk

        $API:                           25,29,30,31,32,33,34,UpsideDownCake,etc.

Options:
        restore                         restore all existing .backup files, but doesn't delete them
                                        - the AVD doesn't need to be running
                                        - no other Argument after will be processed

        InstallKernelModules            install custom build kernel and its modules into ramdisk.img
                                        - kernel (bzImage) and its modules (initramfs.img) are inside rootAVD
                                        - both files will be deleted after installation

        InstallPrebuiltKernelModules    download and install an AOSP prebuilt kernel and its modules into ramdisk.img
                                        - similar to InstallKernelModules, but the AVD needs to be online

Options are exclusive, only one at the time will be processed.

Extra Arguments:
        DEBUG                           Debugging Mode, prevents rootAVD to pull back any patched file

        PATCHFSTAB                      fstab.ranchu will get patched to automount Block Devices like /dev/block/sda1
                                        - other entries can be added in the script as well
                                        - a custom build Kernel might be necessary

        GetUSBHPmodZ                    The USB HOST Permissions Module Zip will be downloaded into /sdcard/Download

        FAKEBOOTIMG                     Creates a fake Boot.img file that can directly be patched from the Magisk APP
                                        - Magisk will be launched to patch the fake Boot.img within 60s
                                        - the fake Boot.img will be placed under /sdcard/Download/fakeboot.img

Extra Arguments can be combined, there is no particular order.

Notes: rootAVD will
- always create .backup files of ramdisk*.img and kernel-ranchu
- replace both when done patching
- show a Menu, to choose the Magisk Version (Stable || Canary || Alpha), if the AVD is online
- make the choosen Magisk Version to its local
- install all APKs placed in the Apps folder
- use %LOCALAPPDATA%\Android\Sdk to search for AVD system images

Command Examples:
rootAVD.bat
rootAVD.bat ListAllAVDs
rootAVD.bat InstallApps

rootAVD.bat system-images\android-34\google_apis\x86_64\ramdisk.img
rootAVD.bat system-images\android-34\google_apis\x86_64\ramdisk.img FAKEBOOTIMG
rootAVD.bat system-images\android-34\google_apis\x86_64\ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
rootAVD.bat system-images\android-34\google_apis\x86_64\ramdisk.img restore
rootAVD.bat system-images\android-34\google_apis\x86_64\ramdisk.img InstallKernelModules
rootAVD.bat system-images\android-34\google_apis\x86_64\ramdisk.img InstallPrebuiltKernelModules
rootAVD.bat system-images\android-34\google_apis\x86_64\ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG

rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img FAKEBOOTIMG
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img DEBUG PATCHFSTAB GetUSBHPmodZ
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img restore
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img InstallKernelModules
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img InstallPrebuiltKernelModules
rootAVD.bat system-images\android-33\google_apis_playstore\x86_64\ramdisk.img InstallPrebuiltKernelModules GetUSBHPmodZ PATCHFSTAB DEBUG

G:\binde\Desktop\rootAVD-master>rootAVD.bat system-images\android-34\google_apis\x86_64\ramdisk.img
[*] Set Directorys
[*] Testing for write permissions
[-] creating TEMPFILE File
[-] deleating TEMPFILE File
[^!] NO elevated write permissions are needed to access $ANDROID_HOME
[-] Test IF ADB SHELL is working
[-] In any AVD via ADB, you can execute code without root in /data/data/com.android.shell
[*] Testing the ADB working space
[!] /data/data/com.android.shell is available
[*] Cleaning up the ADB working space
Der Befehl "adb" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
[*] Creating the ADB working space
Der Befehl "adb" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
[*] looking for Magisk installer Zip
[*] Push Magisk.zip into /data/data/com.android.shell/Magisk
[-] Der Befehl "adb" ist entweder falsch geschrieben oder
[-] Backup exists already
[*] Push ramdisk.img into /data/data/com.android.shell/Magisk/ramdisk.img
[-] Der Befehl "adb" ist entweder falsch geschrieben oder
[-] Copy rootAVD Script into Magisk DIR
Der Befehl "adb" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
[-] run the actually Boot/Ramdisk/Kernel Image Patch Script
[*] from Magisk by topjohnwu and modded by NewBit XDA
Der Befehl "adb" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

G:\binde\Desktop\rootAVD-master>

image

I checked that i have the Android SDK Platform-Tools installed. I am running Windows 11 Pro 23H2.

konqi commented 2 weeks ago

Looks like it is unable to locate the adb binary. Possible fixes:

I haven't done this on Windows, but I can try it and see what happens.

Edit: Did you follow these instruction? (Source) image

konqi commented 2 weeks ago

Just tested the setup on my windows machine. The Platform-Tools should be installed by default, but your terminal can't find it. You can execute set PATH=%PATH%;C:\Users\<YOUR USERNAME>\AppData\Local\Android\Sdk\platform-tools before the actual rooting command.

I'm working on an updated documentation here but I'm a bit stuck. Some things only work in Powershell, some in a command prompt - it's a mess. Usually I would do this in Windows Subsystem Linux, but I also like the challenge.

Michl7 commented 1 week ago

thanks, got it working but now i am stuck with the app. The roborock app needs a arm version of android but all arm versions i tried did not run. Not even the phone emulation window opens just shows "Starting up" but nothing happens.
The x86_64 version runs fine but as said the apk is not compatible. Do you have a arm version running?

Maybe WSL would be easier as you write? If i find a little more time maybe i read into it and try that way.

Have to say now i appreciate people who know this stuff and create scripts and programs a lot more.

Michl7 commented 5 days ago

Okay i got it figured out. Have now an AVD Android 11 with Magdisk, roborock app and wireguard app. Also have mitmproxy installed on PC and the modul installed in magdisk on AVD.

Now i am stuck with my knowledge on how to get it working all together.

I think i would need a little help hor to do this step now:

konqi commented 3 days ago

Those are instructions for linux

on Windows (in PowerShell): $env:SSLKEYLOGFILE="~/.mitmproxy/sslkeylogfile.txt" and then mitmdump --mode wireguard

should work. Files will be generated to your X:\Users\<Username>\.mitmproxy - directory once the device starts making requests. That is also about as far as I got last time on my Windows machine. Basically, you need to tell Wireshark about the sslkeylogfile.txt and after that the traffic should be readable.