2
[HOW TO] Installing incremental OTA on rooted+encrypted OPO (encryption optional)

  1. QuaqSim
    Gingerbread Aug 29, 2015

    QuaqSim , Aug 29, 2015 :
    The Story
    (tl;dr; Sideloading full package and skipping incremental is a bad idea)

    The OTA for 12.1 arrived (YOG4PAS1N0) and as usual, I attempted a normal install. This failed as I expected so I went about retrieving the full package, booting into TWRP and sideloading.

    This went without a hitch but on rebooting into the system, I found a notice telling me that my encryption password was correct but the data was corrupt. Booting into TWRP showed that this was a lie but the encryption method has changed and the incremental update was supposed to deal with that.

    This highlighted a more general problem; in this case there was a very major process I skipped by circumventing the incremental update and sideloading the full package but any of the incremental updates may be dealing with minor transitions and not running those may cause problems later.

    The Answer
    (Install incremental update)

    Note: The rest of this will be written specifically for the latest 12.0, updating to the first 12.1. If being used for reference in the future, references to "YNG1TAS2I3" mean "the version you're currently running" and references to "YOG4PAS1N0" mean "the next version that you're trying to update to."

    Preparation

    First we need to grab a few things, some of which you will already have as someone with a rooted+encrypted phone but I want to touch on it all anyway.
    Installation
    (There's a summary at the bottom if you know what you're doing and want to skip all the fluff.)

    Loosely what we're going to do is flash stock recovery and system, install the incremental package and then get back root. I've done this using Mac OSX with ADB installed by Homebrew, I am writing this as such and will leave it as an exercise for the reader to adjust appropriately for their setup.

    First start by unzipping the full fastboot package and change directory to the package with your terminal.
    Assuming your phone is plugged in with the system running, issue the following commands to revert to stock recovery and system.
    Hold power+volume down until it vibrates to reboot into recovery, select "Apply update" followed by "Apply from ADB". Back in your terminal, change directory to where you put the incremental package and run the following command to install it.
    At this point you should wipe caches and reboot to the system for it to go through the upgrade process. Hurray, you have 12.1 installed without having broken your encryption! Now let's get root back.

    Run these commands to flash TWRP, adjusting the name of the package if the version is different or you're using a different recovery.
    Reboot to recovery by holding power+volume down until it vibrates again and start sideload, this is under Advanced for TWRP. Run the following command to install the root package, again adjusting the filename if needed.
    Reboot. Yay, rooted!

    Summary
    1. Flash recovery and system to stock YNG1TAS2I3
    2. Sideload incremental update to YOG4PAS1N0
    3. Wipe caches and reboot for system to go through upgrade process
    4. Flash custom recovery
    5. Sideload root package
    Conclusion

    It's a bit more long-winded than sideloading a full package and sideloading the root package but as this encryption issue has highlighted, the incremental updates could be doing absolutely anything to transition between the versions and these should not be skipped if you're bringing existing settings and other data along for the ride.

    I spent a lot of time investigating the issues so this process took a lot longer but it's a painless process once you know the steps and a few extra steps is, in my mind, a good trade for ensuring these incremental updates do their stuff. My hope is that people will find this before getting as far along as I did.

    While this was triggered by the encryption issue, I think this is relevant for rooted phones in general as I believe the incremental updates fail when the system has been modified by rooting.

    Troubleshooting

    If you've already gotten yourself into the situation I had by sideloading the full package, this is actually pretty trivial to recover from. Just download the full package (not fastboot) for YNG1TAS2I3 and sideload that, then reboot and let the phone go through the upgrade process. You can now just follow the stuff above.
     
    Last edited: Aug 29, 2015

    #1
    gaster and groseron like this.
  2. groseron
    Cupcake Sep 4, 2015

    groseron , Sep 4, 2015 :
    I can confirm that using this method I was able to update successfully. The only difference is that I did not have my OPO encrypted, but mine was rooted and with custom recovery. This is what I did (couple of minor differences, but basically the same):

    Thanks for your help, was easy and quick, but, most importantly, it worked. :)
     
    Last edited: Sep 5, 2015

    #2
    QuaqSim likes this.
  3. QuaqSim
    Gingerbread Sep 12, 2015

    QuaqSim , Sep 12, 2015 :
    Excellent, glad it was useful for you. On your changes, yep, installing from internal memory will of course work just as well. I haven't tested it but I *think* just flashing the system partition will work.

    The incremental package runs scripts to check the integrity of the system, to ensure that the things it will be patching aren't different from what it expects, so flashing the system partition gets you back to a state where those checks will pass. (Obviously this also removes root and any other system modifications)

    That said, with one previous update I did see it fail because of some version checks where the recovery was mismatched, (actually it was TWRP) so I put that in for good measure since it's a fairly quick process to flash stock, then flash TWRP again after updating.
     

    #3
  4. jglassenberg
    Cupcake Oct 3, 2015

    jglassenberg , Oct 3, 2015 :
    This looks very helpful! Can you provide new instructions for the OPT? I rooted and then encrypted my OPT after the 2.1 update, but I'm struggling to handle a minor update this week due to TWRP not getting along with the OPT encryption. And yeah, I'm a n00b
     

    #4
  5. QuaqSim
    Gingerbread Oct 3, 2015

    QuaqSim , Oct 3, 2015 :
    From a quick search (not very thorough) it looks like TWRP doesn't yet support the encryption used on the OPT, which you've already seen anyway.

    I don't have a OPT (or OxygenOS) to write something proper but I would expect the basic premise to be similar; getting it back into a state where the incremental update can install normally.

    You'll need to find the full fastboot download for the version you're currently running and after downloading that, extract it so you have the recovery and system images, then flash them as above. (This doesn't touch your encrypted data but you'll lose root temporarily)

    Edit: Note that you need to be sure it's exactly the same system version. You should be able to find build numbers somewhere like Settings>About Phone

    At this point you'll be running a stock recovery and system so just install the OTA as normal, then install root as you did before.
     
    Last edited: Oct 3, 2015

    #5
  6. QuaqSim
    Gingerbread Oct 3, 2015

    QuaqSim , Oct 3, 2015 :
    Having said that, it seems like OP haven't released fastboot images for Oxygen.

    You don't actually need to decrypt your data for installing OTAs though, so you might get away with just putting TWRP into sideload mode after skipping decryption and using adb to sideload the OTA.
     

    #6
  7. shujin51
    Gingerbread Nov 29, 2015

    shujin51 , Nov 29, 2015 :
    Why cant they make it more simple for us to flash the latest OTA? Why must we do so many steps to get a freaking update? This is stupid and really makes me want to go back to stock without root, unlocking, twrp and shit...
     

    #7
    virgofiErce likes this.
  8. gaster
    Moderator Moderator Nov 29, 2015

    gaster , Nov 29, 2015 :
    Thank you for sharing
     

    #8
  9. QuaqSim
    Gingerbread Dec 1, 2015

    QuaqSim , Dec 1, 2015 :
    I've found myself weighing it up a few times and I've been close to going stock for simplicity but there are a few things that I just need root for, so I have no choice but to carry on juggling.

    I understand why OTAs in general can't Just Work™, to root you must modify the system and an OTA works by patching changes on to what it expects to be there. To just apply those patches without verifying the system is what it expects it to be would be dangerous and potentially much worse for those of us who have modified the system.

    That said, I wish that something like CyanogenMod was more root-friendly, perhaps verifying individual files that it's patching if throwing a blanket over the whole lot has found a lump anywhere, rather than just stopping when it sees that lump.

    You're welcome, hopefully it's been useful to some people. I'd like to update it, ideally making the writing less version-specific, but I don't know when I'll get to that with other things that I need to be doing first.
     

    #9
    gaster likes this.
  10. shujin51
    Gingerbread Dec 1, 2015

    shujin51 , Dec 1, 2015 :
    U know what would stop me from having a rooted system? A simple backup software like itunes that can simply backup ur phone exactly how it was before wiping. That includes save states from games, well basically everything. It cant be that hard for android to make a 1:1 copy.
     

    #10
  11. alpianon
    Cupcake Aug 17, 2016

    alpianon , Aug 17, 2016 :
    To update from 13.1 to 13.1.1 I had to flash also the stock boot.img in order to completely unroot the device, otherwise it was impossible to apply the update. Then I preferred to apply the update through the system standard method and not via adb sideload
    BTW, here is the full fastboot package for ZNH2KAS254 (13.1)
    http://builds.cyngn.com/factory/bacon/cm-13.1-ZNH2KAS254-bacon-signed-fastboot-d194f46bee.zip
    and here is the incremental package for ZNH2KAS254 (13.1) to ZNH2KAS2X1 (13.1.1)
    http://builds.cyngn.com/incremental/bacon/cm-bacon-9f339bddf2-to-3c3f0aca9b-signed.zip
     

    #11