[Tutorial] How to apply ADB hacks to Xiaomi devices

Roboboard

New member
In fact it came from the security to be granted on xiaomi.
I have enabled security debugging in addition to usb debugging.

Thank you
 

Roboboard

New member
I know that this is not where to talk about it, but when restarting the smartphone the settings seem lost. I try to buy LADB but it doesn't work, Google says you need an internet connection, while yet I can download other applications...
 

tanutanu

Well-known member
I know that this is not where to talk about it, but when restarting the smartphone the settings seem lost. I try to buy LADB but it doesn't work, Google says you need an internet connection, while yet I can download other applications...
I recommend you to use adb on Termux. After install it, simply execute "pkg install android-tools -y" command.

EDITED: @chaoscreater made the full detailed instruction.

The exception is raised when the debugging option turned off. If you had typos in the package name, another exception was raised. So, adb command was limited in this case. The wireless debugging option is turned off after reboot normally. You seemd to use the adb console on PC via USB though. You might cancel the popup to grant the PC. It always shows when the first connection to PC after rebooting as well.
 
Last edited:

Hapatapa_

New member
Here i made an exported version : just extract it and import also you can change it to open your app instead
 

Attachments

  • Adb_setup.zip
    801 bytes · Views: 31

chaoscreater

Active member
I know that this is not where to talk about it, but when restarting the smartphone the settings seem lost. I try to buy LADB but it doesn't work, Google says you need an internet connection, while yet I can download other applications...

I just read your previous replies and you're getting confused on 2 different things.

First of all, you mentioned that you got an exception error when running this:

If I apply the command adb shell pm grant com.arlosoft.macrodroid android.permission.WRITE_SECURE_SETTINGS I have error messages.

I own like 5 different Xiaomi devices and I'm familiar with this error. This is purely due to the fact that you haven't enabled USB Debugging and USB Debugging (Security Options) on your phone. The instructions in the OP is actually not entirely accurate. On your phone, all you need to do is this:

1.1-Enable Developer options (google to find how to do it)
1.2-Enable USB debugging
1.4-Enable USB debugging (Security Options)
1.5.Disable adb authorization timeout

Then, connect your phone to your PC and then run the adb shell command again. You might need to install the ADB driver on your PC, I'm not going to go over this, you can read up the instructions yourself - https://forum.xda-developers.com/t/...vers-15-seconds-adb-installer-v1-4-3.2588979/

The Macrodroid ADB shell command just needs to be done once. You do NOT need to do this every time your phone reboots.



As for the discussions related to wireless debugging / Termux / LADB, that is completely separate to the instructions above and it is optional. There are certain MacroDroid features and certain ADB commands that require elevated permissions to run. To get elevated permissions, you either need to ROOT your phone, or you need to run using elevated ADB.

For example, if you want to disable an app using ADB shell command, then it would look something like this:

adb shell pm disable-user --user 0 com.android.randomApp

You can put that into a .sh script and run it using MacroDroid. The problem is that if your phone is not running as ROOT, then you won't be able to run the command above. If you want to run the command while keeping your phone unrooted, then the only other way is to make your phone use elevated ADB. To do this, connect your phone to your PC and run:

adb tcpip 5555

Now, you should be able to run pretty much ANY adb shell commands on your phone directly.

But here's another problem. Elevated ADB is only temporary. Whenever you restart your phone, you need to connect to your PC and run "adb tcpip 5555" again. This is where wireless debugging + Termux or LADB comes in. You essentially run "adb tcpip 5555" locally on the phone, without a need of tethering your phone to a PC.

I'm not going to go into this in detail and you can decide if you actually need this or not. My only recommendation is to use Termux, it's free and it's much better than the alternatives. You don't need LADB, it actually sucks in my opinion.

Follow the instructions I posted on how to get this set up for Termux to work with MacroDroid. It's a one-time set up. tanutanu has already shared the link to the instructions.


Lastly, I recommend you Google or look up guides on XDA to learn about ADB commands, USB debugging and wireless debugging. You're confusing the requirements for wireless ADB, USB Debugging and USB Debugging (Security Options). Familiarize yourself with them first, or else you'll just be asking random questions that don't make sense and confusing yourself even more.
 

chaoscreater

Active member
@pr3jker

I just re-read your OP and there's actually a lot of unnecessary stuff that can be removed, which will make it less confusing for newbies who aren't familiar with ADB.

You don't need to pair your phone and use wireless debugging to do this. All you really need to do on a Xiaomi device is this:

1.1-Enable Developer options (google to find how to do it)
1.2-Enable USB debugging
1.4-Enable USB debugging (Security Options)
1.5.Disable adb authorization timeout

And this is pretty much the same step as any other Android device. The only difference is that the other devices don't really need to do step 1.4 and 1.5, because they don't have those settings.

I own like 5 Xiaomi devices and never had to enable wireless debugging just to grant MacroDroid adb permissions. I do use wireless debugging for something else, but it's 100% not required for this.

The point of using ADB from your PC is that Android trusts it as the ADB server. Any ADB command you send from your PC to your phone will run using elevated ADB permissions. As long as your phone is connected to your PC via a USB cable, you can run those ADB commands just fine.

The ONLY reason why you'd use wireless debugging is if you don't want to connect a cable from your PC to your phone. Also, if you want to run ADB elevated commands directly on your phone, you need to use wireless debugging + Termux (or something else). Anyway, running the MacroDroid ADB command is a one time thing, so there's absolutely no reason to do this via wireless ADB and it's an unnecessary extra step.

Just to emphasize again. Wireless debugging is literally running ADB wirelessly.

Might be a good idea to update the instructions.
 

FrameXX

Well-known member
The ONLY reason why you'd use wireless debugging is if you don't want to connect a cable from your PC to your phone. Also, if you want to run ADB elevated commands directly on your phone, you need to use wireless debugging + Termux (or something else). Anyway, running the MacroDroid ADB command is a one time thing, so there's absolutely no reason to do this via wireless ADB and it's an unnecessary extra step.

Sometimes if you don't have Linux/Windows/Mac computer nearby it's easyer to run
Bash:
adb connect 192.168.x.x:5555
from another android device (adb on start is not needed since you already run in shell enviroment). Note that on Android 11+ you also need to have wireless debugging allowed in developer settings.

Simple app to easily achieve wireless debugging. I noticed some new device refuse connection no matter what you do. Then you need to use USB :(.

 
Last edited:

chaoscreater

Active member
If you're trying to use ADB Connect, then yes you need to turn on wireless debugging in A11+.

But as I said, if you're trying to set MacroDroid adb permission (which is the point of OP's thread), then this is a one time thing. So doing this over wireless ADB is kinda pointless.
 
Last edited:

smarter-phone

New member
I've got termux on rooted android13 and have used adb via usb, but trying to do adb on local device, with wireless debug.

When I enable wireless debug I'm prompted, and consent, not ticked "every time on this network".
I've already installed the package action-tools via termux, and I'm in split-screen / popup to use the wi-fi pairing code, but

adb tcpip (port) doesn't work, and
adb connect (ip : port) doesn't work...

NB: I'm currently connected via usb to pc, charging, which may be confusing things, but I've read termux can do 'ladb'
(with android-tools package)... so what am I doing wrong?

Just re-read and "adb connect" may be an app, not a command!
Anyone able to confirm the steps? Not sure if load-order is important (when to adb start server and launch termux and get the termux session to prompt for the wifi pairing code

🙏
 

smarter-phone

New member
I've got termux on rooted android13 and have used adb via usb, but trying to do adb on local device, with wireless debug.

When I enable wireless debug I'm prompted, and consent, not ticked "every time on this network".
I've already installed the package action-tools via termux, and I'm in split-screen / popup to use the wi-fi pairing code, but

adb tcpip (port) doesn't work, and
adb connect (ip : port) doesn't work...

NB: I'm currently connected via usb to pc, charging, which may be confusing things, but I've read termux can do 'ladb'
(with android-tools package)... so what am I doing wrong?

Just re-read and "adb connect" may be an app, not a command!
Anyone able to confirm the steps? Not sure if load-order is important (when to adb start server and launch termux and get the termux session to prompt for the wifi pairing code

🙏
got it! adb help (easier to read on a laptop than a phone!)
adb pair ip : port pair-code

But still adb devices is empty, adb connect [ip : port] fails.. connects ok via adb on pc via usb, perhaps that's interfering...
 
Last edited:
Top