Edit 2014/03/28: Auto-Patcher is deprecated; see my more recent post.

Over the past six months or so, I've been running the very slick port of CyanogenMod 9.1 to Huawei's G300 phone by Dazzozo and collaborators as posted at g300.modaco.com. (It's considerably better than the official ICS ROM provided by Huawei and Vodafone.)

For several of the previous releases, a user had been supplying zip patches that could be flashed through recovery which allowed PDroid to function. Unfortunately, they seemed to have stopped providing them and this was one thing that was holding me back from upgrading my CM9 install to a newer version.

If you're unfamiliar with PDroid, it allows granular control of the data that each app on your phone can access. For example, you might install an app which requests location access permissions that aren't really necessary to the app's function. Using PDroid, you can override these permissions, blocking the app's access to this data. (I'm not overly paranoid, but neither do I want my phone spewing out personal data for no good reason.)

Other than basics of flashing ROMs, I know very little about Android. I assumed that patching a ROM in this way was fairly involved. It's actually really simple:

  1. Download a zipped copy of the latest Auto-Patcher and a copy of the ROM you want to modify.
  2. Boot into Linux; I used a DVD copy of Ubuntu that I had lying around, an existing Linux install or virtual machine would work equally well. (There is a Windows version of Auto-Patcher, though I didn't test this.)
  3. Install the Java JDK: sudo apt-get install openjdk-7-jre openjdk-7-jdk (you also require the cpio and patch packages to be installed, I found these were installed already, otherwise you need to sudo apt-get install cpio and sudo apt-get install patch).
  4. Extract the auto-patcher zip to a folder and copy the (still zipped) ROM to the same folder.
  5. As the Auto-Patcher instructions state, you need to open a terminal window, navigate to the auto-patcher folder and run ./batch.sh.
  6. Now, run ./auto_patcher <ROMNAME>.zip <MODTYPE> <ROMTYPE>. The MODTYPE is pdroid and, in my case, the ROMTYPE was cm9, so I used a command line like: ./auto_patcher cm-9-20130428-EXPERIMENTAL-u8815-R10.zip pdroid cm9

This process should result in two new zips in the Auto-Patcher folder: an update and a restore.

All that is left to do is to copy both the zipped ROM and the update zip generated by Auto-Patcher to your phone's storage. You can then use an Android custom recovery (such as ClockworkMod Recovery) to flash the ROM, followed by the update zip through an Android custom recovery. The restore zip that auto_patcher generates can be used, as the name suggests, to return the ROM to the unpatched state. Finally, you just need to install the PDroid app itself from the Play Store, and you're finished!