OnePlus 3/3T ResurrectionRemix complete flashing guide

Most smartphone OEMs don’t want their phones to be messed around with make their life difficult by repairing a tampered smartphone. And subsequently you lose warranty when you unlock. Thankfully OP doesn’t do that. So, if you are waiting just for your warranty period to lapse, then don’t!

Why ResurrectionRemix

First I will reason out why I chose RR over other ROMS.

  • First and foremost, has insane amount of customization. You can customise notification header, recent apps menu, gestures, lock screen, status bar icons, gestures, and a lot more.
  • It has a pretty good Screen on Time (SOT). This is a measure of how good the battery performance is. RR gives 4 hours on an average (which is pretty good). The stock ROM had a SOT of less than 3 hours and my previous phone the LG V10 had a SOT of about 1:30 hours (pretty rubbish).
  • Very stable, which is usually difficult to achieve in a custom ROM. Though many ROMs give you a lot of feature, there will be certain stability issues. I have had for almost 30 days, there is none.
  • Pie control. It is a very fancy and useful feature to do quick actions (home key, recent, last app, close app) seamlessly from anywhere.
  • A couple of more useful gestures than what stock provides. For e.g., accessing flashlight from lock screen by drawing ‘V’ wasn’t consistent, but you can just do a single finger upward motion to do it.
  • Last but not the least, substratum theme. Theoretically, you can change the looks of system UI and also any app to the colour and theme you prefer. Stock offers only dark and white mode. I currently have dark UI with red accents, which to me, is gorgeous.

 

This slideshow requires JavaScript.

I will try to explain the entire process in 4 different steps which can be used individually for other works/process.

1) Unlock

Please be noted that, at the end of these steps all your data will be wiped, please have a backup of the same.

  1. Enable ‘developer options‘ from settings. This is done by clicking ‘Build Number‘ from ‘About Phone‘ in settings a couple of times (7 to 8 times).
  2. After enabling go into the ‘Developer options‘ sub settings and select ‘OEM unlocking’ and  ‘USB debugging‘.
  3. Download the ‘SDK Platform Tools – for <your OS>‘ from here.
  4. Connect your smartphone with the charging cable to your computer. Unzip the downloaded file and using command line(windows) or terminal (linux and mac) navigate to the unzipped folder.
  5. Check if things work until now by issuing command:
    Windows:
adb devices

Linux/mac:

./adb devices
  • Boot to bootloader. Unzip the above downloaded file and using command line(windows) or terminal (linux and mac) navigate to the unzipped folder and issue command:
    Windows:

    adb reboot bootloader
    

    Linux/mac:

    ./adb reboot bootloader
  • In about a minute you would boot to bootloader. From here type:
    Windows:

    fastboot oem unlock
    

    Linux/mac:

    ./fastboot oem unlock

    And select ‘yes’ when it is prompted on the screen.

Now that we have unlocked the bootloader we are free to install any recovery or firmware/ROM

2) Install Recovery

TWRP is a pretty good recovery which allows basic actions like installing, wiping cache, etc and also has other features like file browser, flashing multiple images, mounting file system among other things. Download the correct (recovery) image file from here and copy the file into the same folder as your adb. Make sure your phone is connected to your computer (see pt. 4 & 5 above). Also notice the command usage above, Linux and mac begin with ‘./‘ before the command, please use the same format even for below commands.

Rename the image to twrp.img and from bootloader (see pt. 6 above) type:

fastboot flash recovery twrp.img

After flashing type this while holding Power and Volume-Down keys to boot to recovery.

fastboot reboot

If for some reason, you are booted into your OS, select either ‘recovery‘ from power menu or shutdown and use the above hardware key combinations to boot into recovery. In very few cases you might want to repeat this “Install Recovery” step alone if the recovery wasn’t installed properly.

3) Download ROM and Gapps

Download the latest RR ROM from here. Usually any custom ROM doesn’t ship with any of the google apps (instead they might have other stock apps). Hence, we need to download gapps from opengapps. From here select ‘Arm64‘, ‘7.1‘(your RR ROM version) and ‘micro‘ (which has all basic google apps). If you try to get too experimental use ‘aroma’. Transfer both the files into a single folder of your smartphone.

4) Install ROM and Gapps

Before this step make sure you make a backup of data (message, logs, app, app-data), but other data like music, images, etc. would be in-tact. Again, boot into recovery and select ‘wipe‘ (Dalvik cache, system, data, cache). Select Install, browse for the ROM file (from where you saved in the above step) and slide to select. After successful RR installation, select flash another file and select Gapps. After the installation completes you are good to reboot.

Past the few mins of the initial boring setup you would be sticking to your OP 3T for quite a few days going around the various customization.

Glossary

 

Test coverage for service/UI tests using Jacoco

Though as a QA, using test coverage tool/library might not be the ideal way to figure out your test suit’s (be it junit, cucumber, selenium, etc) coverage, it helps to get a lot of insights from time to time.

When you search for java test coverage you get these 2 on top, Emma and Jacoco. I tried Jacoco, and its a 2 step process.

1 ) Gather execution data :

The idea is to instrument your application when you are running your test. As I said earlier, it can be any test like rest assured api test, selenium UI tests or even manual tests. So you start with instrumenting your application, viz. the jar file. You use the java agent to read class files in your jar file and dump the readings in an execution file. This is the command format :

java -javaagent:[yourpath/]jacocoagent.jar=[option1]=[value1],[option2]=[value2]

An example would be :

java -javaagent:jacocoagent.jar=destfile=jacoco.exec -jar myApp.jar --some.variable=value

In above command we specify the path to the jacocoagent.jar file which is available for download from the above link. jacoco.exec is the path to the file were the execution dump is stored. Followed by path to your application jar file, myApp.jar. And finally any params, some.variable which you would normally give when you start your app in regular fashion.

You run this command right before you start your test use and exit it when your suit stops. Now the .exec file contains all the information. So next step would be extract a readable report from this file.

2) Generate Report :

You use another jar file jacococli.jar to generate the report. This is the format :

java -jar jacococli.jar report [ ...] --classfiles  [--csv ] [--encoding ] [--help] [--html

] [–name ] [–quiet] [–sourcefiles ] [–tabwith ] [–xml ]An example would be :

java -jar jacococli.jar report jacoco.exec --classfiles ./build/classes/ --html ./coverage/report

In the above command we specify path to the jacococli.jar , the execution file jacoco.exec , path to the class files ./build/classes/ , followed by the type of report you need –html finally the path to the directory were reports need to be saved ./coverage/report. After this command you would find the reports in the coverage/report folder.

The report has great details with visual indications of how much of the code is covered and how much is not, you can see at a package level and right through individual classes.

I hope this gives a good start to use the tool. Please comment if you think there are other great/easier/useful tools for coverage.

Glossary

http://www.jacoco.org/jacoco/
http://www.jacoco.org/jacoco/trunk/doc/cli.html
http://www.jacoco.org/jacoco/trunk/doc/agent.html

nginx – 404 on refresh

When you have configured a vhost for your site it might happen that when you access your application using your host name for eg http://<host-name>/ it all works good. Also you would be able to browse through links with in your app. The problem comes when you are in a path  for eg http://<host-name>/some/path and you hit refresh you get a 404 error page. After a lot of digging finally found this on github issues. This extra line in the vhost could save your day.

location /{
                try_files $uri $uri/ /index.html?/$request_uri;
        }

After adding do a nginx service restart and everything works great !

intellij lombok

When you are using lombok plugin in your application everything works fine when running through a build/dependency management tool like gradle or maven. But running through intellij gives you errors like “cannot find symbol …”. You might have to enable the annotation processor at 2 places.

1.) Intellij Idea -> Preferences -> Compiler -> Annotation Processors

2.) File -> Other Settings -> Default Settings -> Compiler -> Annotation Processors

 

Nginx 403 forbidden

Though you have set all permissions right for files and folders which nginx needs to access you might face with the strange 403 error. That would be probably because of the SELinux. You would probably need to set enforce level to permissive. Run this command :

# setenforce Permissive

This will set the particular enforce level till reboot. Or else you can choose to change the SELinux context for your directory alone using this :

# chcon -Rt httpd_sys_content_t /path/to/www

Remember to change back the enforce level after using above command. This is the original stackoverflow post.

ansible unarchive – file not found

This strange thing happened where I tried this :

- name: Extract archive
  unarchive: src=src/dir/file.ext dest=dest/dir

It started complaining that “input file not found at src/dir/file.ext”. After trying out a lot of options like checking file path, checking permissions, I finally found from this stackoverflow post that “copy=no” would do the magic. So basically it was searching in the host machine, rather than the remote. Hence this worked

unarchive: src=src/dir/file.ext dest=dest/dir copy=no

Simple !

Ansible Password-less sudo

It gets tricky when you have to escalate an user and the machine doesn’t require a password as such. ‘become’, ‘become_pass’ or anything does not work. You might encounter this error :

“Timeout (62s) waiting for privilege escalation prompt:”

in those cases try using :

sudo: yes

And dont club it with anything else. Hope it works !