[XPERIA X10 Android Development] Tof37:
Here it is ....

As some people here asked for it I'll try to explain how I learned to add screenshot option in power menu.

First I'd like to thank some special members that helped me a lot for doing this :

Championswimmer, Barath_000, Achotjan

First you need to know it's not an easy thing to do and you may have bootloop, reboot etc ... that's why you need time and most of everything backup to restore the modded files.

You'll need tools to do this.

I used a "all in one tool": android utility (thanks to tommytomatoe)

http://xdaforums.com/showthread.php?t=1167623

It can be used on linux / mac laptop

If you don't want to use it or using windows laptop you'll need apktool and dex2jar

Before beginning :

Make a backup of these 2 files in system/framework :

framework-res.apk

android.poilicy.jar

Why ? you'll work on these files so if it doesn't work you'll have a "safe working base" ...

Ready ?

1.Framework-res.apk

Decompile this file (with android utility or apktool)

In the "drawable-hpdi" folder place the png attached, and named it "whateveryouwant".

I advice you to keep the name it got as all my how to will name it like that ;)

Then go in the values folder,

You'll find several xml files, with notepad ++ or other xml editor open*: strings.xml and public*.xml

In strings.xml:

Add this line at the end of the file just above </resources> add the line*:

<string name="global_action_screenshot_txt">Take screenshot</string>

It must look like that*:

Save and close strings.xml

Open public.xml

In the fitting section (drawable and strings) add these lines :

<public type="string" name="global_action_screenshot_txt" id="0x010403da" />

<public type="drawable" name="semc_ic_dialog_screenshot" id="0x0108057f" />

Little tip for "how to" choose the id's (0x010403da and 0x0108057f)

- Search for the last ID for the category (for drawable the last one was0x0108057e)

- write the next letter or number ... (last one was 0x0108057e so the next one is 0x0108057f)

Tip number 2 for the ID ... :)

the letter list begin to a and finish to f

the number list begins to 0 and finish to 9

Finding the fitting ID can take time so stay calm and relax :D

Once you've done that, save public.xml but don't close it you'll need it later ....

Now you can compile your framework-res.apk

If you did something wrong apktool will write it .. just read and repair what's wrong.

Now the framework is set, you need now to tell the device wich action you want to run when you tap the option on screen.

2. Andorid.policy.jar

Decompile this file.

Go to com/android/internal/policy/impl folder

Here you'll fond some smali files.

Find the smali named GlobalActions.smali and open it.

In the # annotations thread add this line

Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;,

in must look like this :

In the # instance fields thread add this line :

.field private mCaptureScreenshot:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

It must look like this :

Is that all ??? No !!!!! :D:D:D

Search the line 195

It must be like this in stock rom :

If there's const/4 v0, 0x4 : this tell the system how many options you've got in the power menu (here 4)

Just under .line 195 add these lines :

Now it must look like this

What that mean ???? :eek::eek::eek:

= the ID in public.xml for the Drawable ... ATTENTION : the ID must be written without the 0 (in public.xml = 0x0108057f ; in android policy 0x108057f )

= the ID in public.xml for the string

respect this order

In the IMPL folder of the decompiled android.policy.jar you'll see several files named GlobalActions$1.smali ; GlobalActions$2.smali; etc ....

You'll need to create a smali file, it's name will follow the already existing name ... if the last one is GlobalActions$7.smali then you'll create GlobalActions$8.smali ...

:eek::eek: What should I get in this file ????? :eek::eek:

Calm down and take the GlobalActions$8.smali attached, rename it if you need, but don't forget to rename inside it all GlobalActions$8 entries in GlobalActions$thenumberyouchoose

Once you've done that get back to GlobalActions.smali ....

Find this line

just above add

Added Globalactions.txt file so you can compare with yours

Here it is, work in android.policy is over ... save and close the GlobalActions file, and recompile android.policy.jar

Ready to flash ? .. so must build a zip file with good permissions and all the files ... :D:D

Find a flashing zip and decompress it

Create these folder

system/framework

system/app

system/bin

Inside framework folder get framework-res.apk and android.policy.jar you compiled

inside bin get the screenshot file (see attachement)

inside app get CMscreenshot.apk (see attachement)

edit your update-script to get these line : (translation for edify script can be done easily)

permissions are needed or else you'll get error (saved to null ...) will taking screenshot

save, compresss make your zip ...

MAKE A BACKUP

And flash ....

reboot .... and enjoy the screenshot option :D

Hope it helps ..

Once again take your time ... if you're novice in modding it'll take time ... it took me nearly one month to do it ... ;)