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

 

Robotium – basic setup and sample

Prerequisites

  • Java
  • Eclipse
  • Android SDK with updated path variable
  • ADT plugin in eclipse

Steps for setting up proper environment for automation

  1. Install java
  2. Install eclipse
  3. Install android sdk
    with proper installation typing “adb” in command prompt from any path should give you something like this …                          
  4. Install adt plugin in eclipse.                                                                                    Above points can referred here and here
  5. Set android SDK location in eclipse.                                                                            In eclipse go to Window -> Preferences -> Android. With proper ADT plugin installation it should appear something like this ….                                                      Provide exact installation location of the android SDK here. If successful set you will see this                                              
  6. Create AVD.  In Eclipse go to Window -> Android sdk and avd manager. This will open up the “Android SDK and AVD manager” (you can also open it from windows programs and android SDK). Click on new and provide name, target(android version), sd card size, resolution(built in). After filling in all the required fields hit “Create AVD”                                                                                             Select the AVD created just now and hit “start” and then “launch”. This should launch the emulator with the above selected configuration.

Now everything is setup for running Robotium tests.

Running the sample test

  1. Download the sample code from here. Unzip the file to some location.
  2. Import the code into eclipse. In eclipse go to File -> Import -> Existing Projects into Workspace.                                                                                                        On successful import of the projects you should see all the project files and folders visible in the package explorer of eclipse.
  3. Install the app in the emulator. Download the FileManager app from here. (this app is signed with the debug key, details about signing apps with your own keys can be found here). From the saved path open a command prompt and type – adb install <app-name>.apk                                 
  4. Open the app “OI File Manager”(the application we installed) and click on “Accept” and “Continue” (I havent handeled this in the tests). Now we are all set to run the test.
  5. Select the test and run as “Android Junit tests”.
  6. In few secs you could see running tests. First time it fails(its intentional) and creates a screenshot, which is a very useful information for debugging. You can check out the code for how the screenshot is captured, its not a robotium feature, its achieved using native android apis. Open the app in the emulator you could see the screenshot named as ‘testname…..’ . After viewing get back to the view below in the app, you can hit back in the emulator.
  7. Run the tests again, it should pass.

You can enhance the tests further and use it for automating your own/other apps.

References.

Sign apps with your key

When testing apps with Robotium it is required that the signature of the app and that of the test match. For apps created by us(or rather same IDE) it shouldn’t be a problem but for external(downloaded apps or apps not created by you) they don’t.

Every developer signs his apps with a key so that he is identified individually from everyone else. The apps built using eclipse by default is been signed by ‘debug’ key. The Robotium tests when run, using eclipse in our case installs itself as an app in the device/emulator. So essentially even our test gets signed using the debug key.

Now both these signatures should match. We cant sign our test using the app’s key because its obviously not at our disposal. What we can do is sign the app using our debug key. Now lets change the signature of FileManager app.

  1. Download the app from the above link.
  2. Download the re-signer jar from here. This jar is a drag and drop tool which rips off the signature from the app and leaves it off without any signature.
  3. Open the jar and drag and drop the app in the window.
  4. Provide file name of app and save. Now it will show the package and the main activity name. Save it some where, it is required when testing the app.
  5. Now that it doesn’t have any signature, lets sign it using debug key. Eclipse stores the debug key in a file debug.keystore in the location C:\Users\<username>\.android. Copy it to the java bin folder C:\Program Files\Java\jdk1.x.x\bin.
  6. Java comes with a tool called jarsigner which can sign files using the provided key. In the java bin folder open a command prompt in admin mode(it wont work without admin mode) and type this command.                                                                            jarsigner -verbose -keystore debug.keystore <filename>.apk androiddebugkey      The last part ‘androiddebugkey’ is the alias name of the keystore. After entering the command, when asked provide the password : android.
  7. You are done. You have the app now signed with the debug key.

Few hints/pointers

  • Always run in admin mode.
  • It might happen that the debug key has expired in which case, go to the debug.keystore location(provided above) and delete the file. Now come to eclipse select a android app/test and then hit Project -> Clean. A new debug.keystore file would have been created for you.

References