Sunday, December 27, 2015

Dialog Optima 2 Custom Recovery + Root


Well peeps, it hasn't even been a month since the phone was released but as I had access to a pre release device, I had some more time playing with the device. This device however was a slightly different story when it came to rooting. After trying almost all the one click root apps and windows software (damn I even installed Windows on a 70GiB partition on my precious Linux box. :/ ) I kinda “knew” this cannot be rooted that way. The only option seemed to be compiling/porting a custom recovery and flashing root zip using the recovery. Again, no auto port worked and when I've finally found a link to the original compiler and asked him for help/advice his reply was something like “There's a problem with some mt6580 devices” and that's that. So I had to do a manual port/compile. Compiling a recovery was kinda out of range as I'm running so low on space.

So I HAD to port, manually. But with what? There was almost no device that fits the device specs/build version etc. The Doogie X5 was kinda OK but I didn't go anywhere farther than a bootloop with that. So I kept searching and searching for like two weeks. And after crawling through almost every China phone forum and with the use of some Google dorks, I found two devices with the exact custom build. (Lucky me eh?)

Fly FS504 Cirrus 2 and Nomi i504. And now I had to find if anyone had compiled a recovery for any of them. The thing was, the forums were in Russian. So with “excellent” Google translate I finally found a TWRP for the Nomi. A little play with the props,fstabs, init.rcs and the kernel, voila!

Yeah yeah I know you don't wanna here my story but just DEAL WITH IT!

Now to the actual thing.
Configure adb, fastboot on your machine. Ubuntu/Aptitude users, do (I know you already have these but in case you don't)
sudo apt-get install android-tools-adb android-tools-fastboot


And fix the udev rules. Don't forget to restart udev.

Windows users? Use Google.

Enable USB Debugging and Unknown sources and toggle the “Allow OEM Unlocking” option. Now check if adb and fastboot work.

Fire up a terminal, do some stuff like
adb reboot bootloader
 fastboot reboot


Before flashing anything we need to unlock the bootloader, do,
adb reboot bootloader
fastboot oem unlock
#if this doesn't work try fastboot oem unlock 0x0e8b

Once you've unlocked the bootloader, flash the recovery.
fastboot flash recovery recovery.img
fastboot reboot
When rebooting hold Volume Up + Power. You will see the “Punisher” face and then taken to the TWRP. If this doesn't happen, you fucked up somewhere. Figure out where you did wrong, fix it.

Now to the actual rooting, though TWRP has its own rooting functions it's a little messy and broken. So we'll flash the superSU.zip manually. Do,

adb push superSU.zip /sdcard/


Then in the recovery INSTALL >> select “superSU.zip” >> slide to the right.
Once it's done, wipe cache partition and reboot. And congratulations, you got yourself a rooted device. Use Root Checker to check root.


NOTE: Even the superSU is not so compatible with the device yet. So we cannot use “Prompt”, until it's fixed we will have to use “Grant”. Other superuser applications didn't even work. So if you got anything better, please tell us. :)

bb.

tl;dr

Ubuntu, Extreme Night Mode

If you're a night owl just like me you might need much lower brightness than Ubuntu's minimum brightness (when using hotkeys) which is around 5% of your screen's max brightness. When using very bright backlit screens like mine even this 5% is just too much. So you have to lower it even more. But this is not possible ( well actually you can if you have time|patience|stupidity to fiddle with the brightness keys which most people don't ) with the hotkeys. You can use the system settings menu to lower it but come on that much trouble just to lower the brightness? Nah.. not something I'd do. So let's get to it.

What we have to do is to echo the brightness value we want to
/sys/class/backlight/intel_backlight/brightness

(the intel_backlight part may vary)

So we could just do this,
sudo echo 3 >
/sys/class/backlight/intel_backlight/brightness

or assign a shortcut to,
pkexec echo 3 >
/sys/class/backlight/intel_backlight/brightness


So is that it? Yes if you want to enter your password every damn time we want to change the brightness. We have to set the permissions of the file so that it will allow us to play with it. To do that we need to do,
sudo chmod 666
/sys/class/backlight/intel_backlight/brightness
#so evil isn't it?


But this permission change won't survive a reboot, so we need to add this to the /etc/rc.local so the permissions are set correct every time we reboot.

Do,
sudo nano /etc/rc.local


then above “exit 0” add,
chmod 666 /sys/class/backlight/intel_backlight/brightness
#no you don't need sudo

then press CTRL+X and then enter “y” then exit.

Now you could assign a shortcut to,
echo 3 > /sys/class/backlight/intel_backlight/brightness


And that's it, instant night mode.

NOTE: IF you don't want to 666 the file you could just create a new group, add you and root to that group, then own the file by root:group and 664 the file.
INFO: cat /sys/class/backlight/intel_backlight/max_brightness is your max brightness.
PS: Play with the values to get the right one. I'd recommend 1.