===== Rooting a Moto G Power running Android 11 ==== //aka how I wasted a Saturday morning// The intention with rooting was to optimize memory usage. I did this with my last Google Fi phone by rooting it and it improved the performance dramatically. This time, after the root process was complete, the same memory optimization tricks weren't applicable as directory ''/sys/module/lowmemorykiller'' does not exist. It appears somewhere between Android 9 and Android 11 they changed how to set the memory optimization stuff. This means that so far I have gained nothing by rooting the phone. At some point I might look at the memory optimization stuff again as it's totally possible to optimize I just don't want to take the time digging to find out how right now... ==== Description of Phone ==== * On Google Fi * Running stock Android 11 provided OTA by Google Fi * Apparently this phone (hardware?) goes by ''sofia''. There's also a ''sofiar'' which is a Moto G8 or something? Different hardware I guess... ==== Steps ==== * Unlock Bootloader * boot to fastboot: ''adb reboot bootloader'' * get unlock key: ''fastboot oem get_unlock_data'' * submit key to [[https://accounts.motorola.com/ssoauth/login?TARGET=https://motorola-global-portal.custhelp.com/cc/cas/sso/redirect/standalone%2Fbootloader%2Funlock-your-device-b|motorola]] * ''fastboot oem unlock UNIQUE_KEY'' (UNIQUE_KEY) is emailed to you * get ''boot.img'' for current installed firmware * used Lenovo's Windows-based rescue utility ''LMSA'' to identify and download the stock firmware * while the rescue utility was downloading the firmware I disconnected the phone so the utility wouldn't try to install it * install ''Magisk'' using ''adb'' * run ''Magisk'' to patch ''boot.img'' * install patched ''boot.img'' with ''fastboot'' ==== Noise and Failed attempts/ideas ==== * Didn't use TWRP because I couldn't find a version of TWRP I was convinced would work with Moto G Power/Android 11. * Didn't go with Lineage OS because I was worried about Google Fi. I know it //should// work but I installed Lineage OS on my last Google Fi phone and soon after (maybe immediately?) it had trouble establishing reliable connections with phone networks. Could have been unrelated but I didn't want to risk it. * There's a ''slot A'' and ''slot B'' partition. I believe these are recovery partitions? The phone alternates between the partitions when updating. Lineage OS talked about how these partitions needed to have the same updated content or you might brick your phone if somehow your phone tried to boot the wrong one. It didn't seem to be an issue with the method I used. FWIW my installation is currently in ''slot B'' * Used the Lenovo utility to extract ''boot.img'' even though the stock firmware might have been available online. There were matches on the Firmware version etc. but by getting it from Lenovo there was less chance of getting the wrong thing. ==== Handy stuff to know ==== * get a bunch of info, like firmware version details and stuff: ''fastboot getvar all'' ==== Gotchas ==== * Didn't back up ''Google Authenticator'' before unlocking the bootloader. Since unlocking the bootloader resets the phone to factory I lost all my 2FA authentication codes. :( ==== Future Work ==== * [[https://source.android.com/devices/tech/perf/lmkd|Memory Optimization]] ==== Resources ==== * [[https://wiki.robotz.com/index.php?title=Motorola_Moto_G_Power|Wiki overviewing the process of rooting and putting in custom firwamare]]