[Redmi Note 8 Pro Guides, News, & Discussion] Muad.Dib:
/*
* I am not responsible for bricked devices, dead SD cards, data loss,
* thermonuclear war, or you getting fired because the alarm app failed. Please
* do some research if you have any concerns about tips provided here.
* Before making any alteration to your system make sure you know what you
* are doing and have previously made a backup of all sensitive data!
* YOU are choosing to make these modifications, and if
* you point the finger at me for messing up your device, I will just laugh at you.
*/

BEWARE THE TIP/TRICKS SHARED IN THIS THREAD CAN LEAD TO MODIFICATIONS TO YOUR OPERATING SYSTEM WHICH CAN SERIOUSLY MESS UP YOUR DEVICE, SOME YOU MIGHT NOT BE ABLE TO RECOVER FROM. BE AWARE OF THIS BEFORE CONTIUE READING

Dear all,

Being new to the Xiamoi/MIUI world I recently found out at the cost of complete data loss needing a full factory restore (EDL), and 3 days to get everything back in order, that adb shell for our device (and all other Mi devices I suppose) are restricted, enbabling ADB debugging and/or being root not being enough.

I thought wrongly being root on the device was enough for doing stuff I needed. I was wrong, so I'll be sharing my findings to avoid any of you going through the pain.

Nothing really extraordinary, many XDA users probably know all this, but new Mi/MIUI users might not, so I'll share anyway.

Best way to verify this is by simply typing from an adb shell / or terminal the following command which normally does not need root on devices but on Xiaomi needs elevated (Mi) permissions from shell (which are restricted by default) :

begonia:/ $ wm size
Physical size: 1080x2340
begonia:/ $ wm density
Physical density: 440

If any of those two commands do not display like above the result of your current phone resolution, if it hangs in there displaying nothing or throw you off a security exception like this

Security exception: Must hold permission android.permission.WRITE_SECURE_SETTINGS
java.lang.SecurityException: Must hold permission android.permission.WRITE_SECURE_SETTINGS
at com.android.server.wm.WindowManagerService.clearForcedDisplaySize(WindowManagerService.java:5706)
at com.android.server.wm.WindowManagerShellCommand.runDisplaySize(WindowManagerShellCommand.java:129)
at com.android.server.wm.WindowManagerShellCommand.onCommand(WindowManagerShellCommand.java:66)
at android.os.ShellCommand.exec(ShellCommand.java:103)
at com.android.server.wm.WindowManagerService.onShellCommand(WindowManagerService.java:1063)
at android.os.Binder.shellCommand(Binder.java:629)
at android.os.Binder.onTransact(Binder.java:527)
at android.view.IWindowManager$Stub.onTransact(IWindowManager.java:1140)
at com.android.server.wm.WindowManagerService.onTransact(WindowManagerService.java:1278)
at android.os.Binder.execTransact(Binder.java:726)

it means your adb shell/terminal user is currently restricted and needs to be unlocked.

So before starting to mess up around with things like your screen resolution for example (which could render your phone completely unusable like i did), first make sure to unlock adb shell from the developer options.

In order to do so you will be prompted to log into your MIUI account.

Do it.

Turn both of the options on

- Install via USB (not exactly needed here, but pretty useful if you want to install/reinstall apps through adb)

- USB debugging

Once this is done and you accepted all the security warning pop ups, you are all set.

You can even log out from your Mi account, settings will stick around.

Hope this helps.