Wednesday, July 6, 2016

SOLUTION! Moto XT1085 Fails to Install Cyanogenmod 12/13 [DRAFT QUALITY!]

WARNING: DRAFT QUALITY SOLUTION - I'M WORKING ON TRANSLATION OF SOME PARTS FROM CHINESE AND THE STEP-BY-STEP SOLUTION.

There are some hardware differences between the XT1085 (China), the XT1092(Europe), and the XT1097(USA) variants of the Moto X 2nd generation, 2014 edition also known as “victara”.  The three different versions of the phone are identical with the exception of two things:  [1] they have different regional networking standards (radio frequencies) and [2] they have different partition configurations.


Q: Can I install Cyanogenmod (or a variant of it) on the XT1085?
A: Yes you can, but not “as-is” from the main download page.


Q: Why would I want to install Cyanogenmod on my Moto X? The Motorola stock ROM is already very minimal compared to other vendors.
The main reason that you would want to install Cyanogenmod over the exiting version of Android on the XT1085 is to remove the special Chinese security software that’s installed...and which makes the phone suspicious to monitoring and tampering.  The other reason you would want to install CM is to get Marshmallow on a phone that would otherwise be stuck on Lollipop (5.1).


Q: Why does the Cyanogenmod packages for Victara fail to install on the XT1085?
A: It is because of the second reason mentioned in the introduction: the different partition sizes for the SYSTEM partition.


The sizes of the partitions are:
  1. XT1092/XT1097 = 2902458368 bytes (or 2.9G)
  2. XT1085 = 2046820352 byte (or 2.0G)


When you try to install the Cyanogenmod package directly on to the XT1085 you will corrupt the SYSTEM partition and the phone will become unusable. (Note: To recover from a phone that has been corrupted by overwriting the Cyanogenmod package, you should go to this article (will write it soon) for a solution...don’t worry - it’s easy to fix when you know how!)


Q: How can I install Cyanogenmod on my Chinese edition of the Moto X?
UPDATE: I've already performed these steps on the cm-12.1-20151117-SNAPSHOT image of Cyanogenmod 12 (Stable) and verified that it works on my phone...no issues!  You can download it and install it (at your own risk of course) from my Google Drive file share here: Download XT1085 Mod | I'll edit a 13.0 nightly soon and post it as well.

cm-12.1-20151117-SNAPSHOT-YOG7DAO1KI-victara-XT1085mod.zip
MD5: 3b274ed11214c4dd79f1373da1548242

UPDATE 2: I've rebuilt the image file for LineageOS 14.1.  Please see my other post to direct-download the image from Google Drive. [New Post]


METHOD 1

The main method is to mount the Cyanogenmod system.new.dat file in Linux (I use Ubuntu) and repackage the file to reflect the smaller partition size.

This method was written by XPIRT on the XDA forums here: XDA - [DEV] Lollipop/Marshmallow DAT files | Compression and Decompression


Another way is to use the correct parameters and repackage the system.new.dat, replace zip package system.new.dat and system.transfer.list, methods here:


METHOD 2


Background information: In Android 5.x and newer update packages are created when the system.img file and the system.new.dat files are combined and generate a new system.img file.  The command to do this is:

make_ext4fs -T 0 -S file_contexts -l 2046820352 -a system system_new.img
Note: Download the make_ext4fs android tool for Windows from XDA developers.
The -l option is normally the size of the system partition image, which cannot be larger than the actual size of the system partition. The default Cyanogenmod package is created with 2.9GB -l option; designed for the European and American versions of the Moto X.
“mokee” compilation works  because “mokee” rolls back the CM12/13 package to the “OTA” format which was used in versions of Android before 5.0.

So, we can unpack system.new.dat, modify compile script, to install like it did before the Android 5.0.