[Miscellaneous Android Development] jman0:
ROOT:

We've been discussing about this for about a month, and I think it's time to sum it all up and open a new cleaner thread.

First, how do you root the Alcatel Onetouch 997D?

This phone is quite new (less than 2 months in the market) and is one of the few phones which can't be rooted by the script developed by Bin4ry or the other well-known methods, such as Unlockroot or SuperOneClick, but it is not unrootable.

In order to root this phone, you must first boot it into Factory mode, a special menu, present in all Mediatek based phones, which can be used to test the various parts of the phone. You get to this menu by turning the phone on while pressing the volume down batton and power button at the same time, until it appears.

Once in factory mode menu, you can connect the phone to a pc, which, if the appropiate adb drivers are installed, will detect it. At this point, the phone can be rooted, by the use of an app called MTK Droid tools. I've succesfully tested versions 2.2.8 and 2.2.9.

After MTK Droid Tools finds the phone, you just have to press the "root" button. The phone will be rebooted two times, and after the second reboot, MTK Droid Tools achieves a temporary root which enables it to install Superuser, su and busybox, so the root is permanent.

During this process, MTK Droid Tools asks whether you want to make a backup. You'd better answer no, since this process is very buggy and fails on this phone, so it's a complete waste of time.

When "Task is complete" message appears, you can reboot the phone, but it won't work right away. Due to a problem not yet identified, it's mandatory to wipe data from recovery for the phone to work. Some people have reported the loss of Google Play Store, and others have lost a lot of apps. Anyway, a wipe solves the problem and the phone remains rooted.

MTK Droid Tools 2.2.8 can be found here: http://www.4shared.com/zip/NyHaro3-/MTKdroidTools.html

CWM Recovery:

We have a 99% working CWMR. I compiled it myself with the help of the dsixda kitchen and the MT6577 CWMR porting plugin developed by Bruno Martins.

I say it's 99% working because backup doesn't work 100%. Alcatel phones have a non standard partition called "custpack", which contains a lot of apps bundled with the phone and whose deletion prevents OTA updates from working, so it's not something one would like to remove. My knowledge of Android is not enough to try to dig inside CWMR source code, to see if I can modify the backup process and make it recognize the custpack partition, so I left it as is. Instead, I decided to develop a shell script which can make CWMR-compatible backups, which can at least be restored from it.

Everything else is fully functional. It's version 6.0.1.2.

To flash it, you need to root the phone, using the method explained above, and flash the recovery image using Mobileuncle Tools utility, which can be freely downloaded from Google Play Store. It's very important to download the latest version from Google Play, since previous versions lying around, and the version MTK Droid Tools installs during the root process can't flash a recovery on MT6577 processors.

To flash the recovery with Mobileuncle tools, you have to place it on the root of the external sd card and open Mobileuncle tools. After granting root permissions, if you haven't done yet, you choose "change recovery" and choose the corresponding .img file. Once the process is done, the phone will automatically reboot into the new recovery. It may fail, which you'll notice because the phone boots into the stock recovery, and you may need to do it again. I've noticed that, at least in mine, it works best if I do it while the phone is unplugged from the computer.

As I said abpove, everything, except backup, works well. Restore works, if you have the correct backup (more on this later).

My CWMR can be downloaded from my Mediafire account: http://www.mediafire.com/?v7wfjr6v1t7b0z5

NANDROID BACKUP:

After noticing the backup process in CWMR can't backup the Alcatel exclusive custpack partition, I began trying to solve this. I guess the best way to do it should be modifying the source code of CWMR to adapt the backup process, but, since that exceedes my current knowledge level, I tried differemt approaches. I downloaded the app Online Nandroid backup from Google Play, and learnt that a nandroid backup can be easily done using a shell script, given you have a rooted phone and a way to execute shell scripts. The good news is that it's done, and I have achieved my goal, and now have a working shell script, which creates backups that can later be restored from CWMR.

This script creates 7 files, like the standard CWMR backup process does. The files are:

1) boot.img

2) recovery.img

3) system.ext4.tar

4) cache.ext4.tar

5) data.ext4.tar

6) .android_secure.vfat.tar

7) nandroid.md5

Files 1, 2, 4, 5 and 6 are exactly what you now get if you use my CWMR port and perform a backup. The difference lies in file 3.

In a backup created from our current CWMR, this are the contents of the tar archives:

system.ext4.tar: files under /system, and all its subdirectories

cache.ext4.tar: files under /cache, and all its subdirectories

data.ext4.tar: files under /data, and all its subdirectories

.android_secure.vfat.tar: files under /sdcard/.android_secure

In a backup created by my script, it's slightly different:

system.ext4.tar: files under /system, and all its subdirectories, and also files under /custpack, and all it's subdirectories

cache.ext4.tar: files under /cache, and all its subdirectories

data.ext4.tar: files under /data, and all its subdirectories

.android_secure.vfat.tar: files under /sdcard/.android_secure

On both backups, boot.img and recovery.img are images compatible with Mediatek Flash Tool or Mobileuncle Tools (in the case recovery.img), and nandroid.md5 contains the md5 sum of every file, so the restore process can validate the integrity of them, to prevent you from ever restoring a corrupt archive.

In order to use my script, you need an app which can execute them. My preference (and the only one I have fully tested the script with) is GScript, which can be freely downloaded from Google Play Store.

There's also a paid version, but the only difference between them is that the paid version is updated more often than the free one.

How to install the script:

1) Download and install GScript, free or paid. You can use the apk file provided by me inside the attached zip.

2) Download the attached zip file with the scipt, if you haven't done so to install GScript.

3) Put the script on the external sd card, under a folder called "gscript". Use lowercase characters for the name and never change the name, as this would result in GScript not working or finding your scripts. The resulting structure should be:

/sdcard/gscript

|

------------> bin

Inside /sdcard/gscript you have the script itself, called "Alcatel_OT_997D_nandroid.sh" and inside /sdcard/gscript/bin, you have the busybox

binary, used by the script. Even if you have busybox already installed, don't delete this binary, since it's the only one the script will use, and

the only one it's been fully tested with.

4) Open GScript.

5) On the GScript main window, you can see a pair of sample scripts already included. You need to touch the menu button and then on "Add script".

6) Browse for the .sh file on /sdcard/gscript, and tick "Needs SU?" if it's not already ticked, since this script needs a rooted phone.

7) Once the new script is in the list of installed scripts, you only need to touch its name to launch it. The first time you do it, GScript will ask for root permissions. Allow it.

Once you open the script, it will run automatically, and will end around 5-10 min. later, depending on how loaded your phone is. In order to be able to see every message shown by the script, it's better to raise the screen timeout, to at least 10 minutes. After execution, the output window will auto close, unless you cancel auto closing by touching anywhere on the screen except, of course, the close button.

The backups are stored under the /sdcard/clockworkmod directory (the script will create it if its not already there), under which it will create a new subdirectory, with the date and time of the backup, just in the same format CWMR uses.

During the execution of the script, you may see two error messages, which are not really errors, but warnings you can ignore. These errors are:

1) Errors creating directories at startup. If the script has already been used, or you have tried the backup inside CWMR, sdcard/clockworkmod/backup already exists. The script will tell you that, but it will keep working.

2) Removing leading "/" from member names: tar utility removes "/" from the input parameters, just that.

3) XXXXXXXX: socket ignored, where XXXXXXXX is the name of a file. Sockets are temporary files Unix apps use to communicate with other apps. Since they are temporary, tar just ignores them, so you can also ignore the error message.

On mi phone, after I close the results window, GScript force closes, but this doesn't affect the execution of the script. As I've read somewhere, it

looks like this is a problem common to a lot of users.

DISCLAIMER:

This script is offered AS IS, with no warranty. It has been successfully tested on my own phone, and the generated backup was then perfectly restored from recovery with no issues, but I can't say it won't fail on other people's phones.

It's the first version, fully functional, but with some room for improvement. As it is right now, it's not error free, since it doesn't check if you have enough space left on the sdcard, or if you don't have any apps moved to the sd card. In fact, I have not tested it in such a situation, and I don't know what would happen if you backup your phone with no apps moved. On the other hand, it doesn't bakcup sd-ext, so if anyone has a second partition on the sdcard, to use Link2SD o a2sd, that partition won't be backed up, although data for apps linked to the second partition will. Anyway, even if it fails, you don't have to worry, since it won't change anything inside the phone. If you later restore a backup made with this script, you are doing it AT YOUR OWN RISK. I will not accept any responsibility for damage or data loss caused by the use of this script or restoration or any backup created with it.

Don't forget this script needs a rooted phone, and that performing some things on rooted phones is risky. If the worst case, you will always be able to recover the phone using Alcatel One Touch Upgrade on your pc.

Any comments or improvements are welcome, but if you change / improve anything, don't forget to share it with the community, so everyone can take advantage of it.

IMPORTANT:

This script is only suitable for the Alcatel OT-997D, and probably other phones by the same brand, if they have the "custpack" partition, exclusive to Alcatel. It won't work, unless code regarding the custpack partition is modified, in other phones, and I will not give support to users complaining the script doesn't work on their non Alcatel phones, or their Alcatel phones without s custpack partition.

FINAL NOTE:

Ok, that's it. Now, I'm going to have a rest, maybe until Alcatel release the long waited Jelly Bean update.

EDIT:

I had forgotten the "thanks" section:

Thanks to:

@dsixda, for the great kitchen

Bruno Martins (@bgcngm) for his valueable advice and his scripts to unpack/repack recovery of any MT657x based device

@yuweng, who developed the great kitchen plugin to port CWMR to any MT657x based device. and also pointed me in the right directory when I was trying to root the phone

@ameer1234567890, author of the great onandroid script. I haven't used your code, but it taught me I had to unmount and remount the sdcard on a different location to be able to backup .android_secure