[HOW TO] Add screenshot option in power menu for every rom

Search This thread

Tof37

Senior Member
Oct 6, 2009
624
2,468
Tours
Care to be more specific?:rolleyes:
;)

So I'll try to be as clear as possible ...

each command starts with this line :
const/4 v1, 0x...

and ends with :

aput-object ....

the first line (const/4 v1, 0x3 for eg) says where what is following is placed in the grid ...
In this example const/4 v1, 0x3 the option is in 3rd position ...

If you want to change the position of an option, just move the commands to the wanted position ...example :

const/4 v1, 0x3

new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$9;

const v3, 0x1080537

const v4, 0x1040437

invoke-direct {v2, p0, v3, v4}, Lcom/android/internal/policy/impl/GlobalActions$9;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V

aput-object v2, v0, v1

const/4 v1, 0x4

iget-object v2, p0, Lcom/android/internal/policy/impl/GlobalActions;->mCaptureScreenshot:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

aput-object v2, v0, v1

if you want to change the position it will become :

const/4 v1, 0x3

iget-object v2, p0, Lcom/android/internal/policy/impl/GlobalActions;->mCaptureScreenshot:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

aput-object v2, v0, v1

const/4 v1, 0x4

new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$9;

const v3, 0x1080537

const v4, 0x1040437

invoke-direct {v2, p0, v3, v4}, Lcom/android/internal/policy/impl/GlobalActions$9;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V

aput-object v2, v0, v1

Hope I made it clear ;)
 
  • Like
Reactions: blueowl0708

dettofatto

Senior Member
May 29, 2006
603
164
Roma
I've done again, without success.. But now I can see my screenshot option, then my phone reboot.. :-(

My issue:

1) What is the name of your png?
semc_ic_dialog_screenshot.png?


2) In public.xml I've 3 lines with screenshot, is it normal? I've Choosed as string's id (for globalaction) this 0x01040509 (renamed to 0x1040509)... Correct?

Code:
Line 2863:     <public type="string" name="global_action_screenshot_txt" id="0x01040509" />
	Line 2885:     <public type="string" name="global_action_screenshot" id="0x010404f5" />
	Line 4313:     <public type="drawable" name="semc_ic_dialog_screenshot" id="0x01080503" />
Search "screenshot" (2 hits in 1 files)

3) In GlobalAction you wrote:

Code:
Find this line

    invoke-static {v0}, Lcom/google/android/collect/Lists;->newArrayList([Ljava/lang/ObjectLjava/util/ArrayList;

just above add

    const/4 v1, 0x3

    iget-object v2, p0, Lcom/android/internal/policy/impl/GlobalActions;->mCaptureScreenshot:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

    aput-object v2, v0, v1

    const/4 v1, 0x4

I've 2 lines with: invoke-static {v0}, Lcom/google/android/collect/Lists;->newArrayList([Ljava/lang/Object......

And I have, also, 1 const/4 v1, 0x4 for GlobalAction$10 (reboot option)

So I must write this?:

Code:
 const/4 v1, 0x5
 
    iget-object v2, p0, Lcom/android/internal/policy/impl/GlobalActions;->mCaptureScreenshot:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

    aput-object v2, v0, v1

    const/4 v1, 0x6

    invoke-static {v0}, Lcom/google/android/collect/Lists;->newArrayList([Ljava/lang/Object;)Ljava/util/ArrayList;

Thank You!!!!!!!!!!!!!!!!!
I Can do it... :)
 

Tof37

Senior Member
Oct 6, 2009
624
2,468
Tours
Hi ,

1) yes

2) One line has nothing to do in public.xml ;) but have to be in strings.xml ... just to help all txt are in strings.xml

3) What you wrote is right ... just beware with const/4 v1, 0x5 alignement ... just move it on the right to be like the other lines ;)

You're near the full working ;)
 
  • Like
Reactions: dettofatto

dettofatto

Senior Member
May 29, 2006
603
164
Roma
Hi ,

1) yes

2) One line has nothing to do in public.xml ;) but have to be in strings.xml ... just to help all txt are in strings.xml

3) What you wrote is right ... just beware with const/4 v1, 0x5 alignement ... just move it on the right to be like the other lines ;)

You're near the full working ;)


I'm sorry.... I think now it is ok, but my phone gone into bootloop...
Maybe I must edit another file? Editing the power menu, for adding reboot option, I hade similar issue, because I must edit also another file..

This is my globalaction, strings and public again..

Where is my issue?

Thank you for your help!
 

Attachments

  • dist.zip
    69.3 KB · Views: 29

Tof37

Senior Member
Oct 6, 2009
624
2,468
Tours
I'm sorry.... I think now it is ok, but my phone gone into bootloop...
Maybe I must edit another file? Editing the power menu, for adding reboot option, I hade similar issue, because I must edit also another file..

This is my globalaction, strings and public again..

Where is my issue?

Thank you for your help!

In strings.xml all is ok

In public.xml delete this line
<public type="string" name="global_action_screenshot" id="0x010404f5" />

Your android policy seems fine ....

When you mean bootloop it's when phone starts or when you press power menu ?
 
  • Like
Reactions: dettofatto

dettofatto

Senior Member
May 29, 2006
603
164
Roma
In strings.xml all is ok

In public.xml delete this line
<public type="string" name="global_action_screenshot" id="0x010404f5" />

Your android policy seems fine ....

When you mean bootloop it's when phone starts or when you press power menu ?

Before when I pressed power menù...
Now (with these files) I can see my desktop, but all apps have force close and then my phone reboot...
I think that now it is framework-res related...
Tomorrow I'll try again!
Thank you, again!!!

Sent from My Motosola....
 

dettofatto

Senior Member
May 29, 2006
603
164
Roma
In strings.xml all is ok

In public.xml delete this line
<public type="string" name="global_action_screenshot" id="0x010404f5" />

Your android policy seems fine ....

When you mean bootloop it's when phone starts or when you press power menu ?

Sorry for double post...!
Nothing...! I have force close for all apps (launcher, usb, phone, etc...etc..) If i press power button, I can see my new option!, but with force close for all apps)
I've also found that when i have added reboot option, I've modified also framework.jar...
see this post (http://xdaforums.com/showthread.php?t=1406207)
Maybe?
 

Tof37

Senior Member
Oct 6, 2009
624
2,468
Tours
Sorry for double post...!
Nothing...! I have force close for all apps (launcher, usb, phone, etc...etc..) If i press power button, I can see my new option!, but with force close for all apps)
I've also found that when i have added reboot option, I've modified also framework.jar...
see this post (http://xdaforums.com/showthread.php?t=1406207)
Maybe?

Ok ;-) For the x10 I have made it but I realized it worked without doing it... I'll send you the line I added in framework.jar so that you should see what to write ;-)

Sent from my X10s using XDA
 

dettofatto

Senior Member
May 29, 2006
603
164
Roma
Ok ;-) For the x10 I have made it but I realized it worked without doing it... I'll send you the line I added in framework.jar so that you should see what to write ;-)

Sent from my X10s using XDA

Great! The simbolic donation has some issues... for you!! But I would like tell you that your work, is very important ;)
Thank you again....!

Sent from My Motosola....
 
  • Like
Reactions: Tof37

Tof37

Senior Member
Oct 6, 2009
624
2,468
Tours
Great! The simbolic donation has some issues... for you!! But I would like tell you that your work, is very important ;)
Thank you again....!

Sent from My Motosola....

Hi,

Sorry for long time answer ... was quite busy those last days ....

In framework.jar find in com/android/internal/app a file named shutdownthread.smali

Find this line :

sget v1, Lcom/android/internal/app/ShutdownThread;->mReboot:I

What is following is looking like that :

.line 400
sget v1, Lcom/android/internal/app/ShutdownThread;->mReboot:I

const/4 v2, 0x1

if-eq v1, v2, :cond_32

.line 401
return-void

:cond_32
const-string v4, "now"

invoke-static {v4}, Landroid/os/Power;->reboot(Ljava/lang/String;)V

return-void

Modify it to be like that :

.line 400
sget v1, Lcom/android/internal/app/ShutdownThread;->mReboot:I

const/4 v2, 0x1

if-eq v1, v2, :cond_32

const/4 v2, 0x2

if-eq v1, v2, :cond_38

invoke-static {}, Landroid/os/Power;->shutdown()V

.line 401
return-void

:cond_32
const-string v4, "now"

invoke-static {v4}, Landroid/os/Power;->reboot(Ljava/lang/String;)V

return-void

:cond_38
const-string v4, "Take Screenshot"

invoke-static {v4}, Landroid/os/Power;->reboot(Ljava/lang/String;)V

return-void

Hope it'll work ;)
 

dettofatto

Senior Member
May 29, 2006
603
164
Roma
Hi,

Sorry for long time answer ... was quite busy those last days ....

In framework.jar find in com/android/internal/app a file named shutdownthread.smali

Find this line :

sget v1, Lcom/android/internal/app/ShutdownThread;->mReboot:I

What is following is looking like that :



Modify it to be like that :



Hope it'll work ;)

I'll try in this week! Thank you!

Sent from My Motosola....
 

RedSpyderX

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

My rom has const/4 v0, 0x6 :

-Header: Device Options
-Silent Mode
-Data Network Mode
-Airplane Mode
-Power Off
-Restart

Since I'll be adding one more option, do I have to modify const/4 v0. 0x6 to 0x7?


Also, my drawable section seems to have all the memory values used up, and some of them are reserved for APKTOOL DUMMY or something like that. Can I assign one of those to my new drawable line?

Thanks in advance
 

encik_racun

Senior Member
Apr 10, 2012
906
179
Can someone make it for me? The screenshot in power menu...

My pc broke down :(

Sent from my GT-I9001 using xda premium
 

Tof37

Senior Member
Oct 6, 2009
624
2,468
Tours
My rom has const/4 v0, 0x6 :

-Header: Device Options
-Silent Mode
-Data Network Mode
-Airplane Mode
-Power Off
-Restart

Since I'll be adding one more option, do I have to modify const/4 v0. 0x6 to 0x7?


Also, my drawable section seems to have all the memory values used up, and some of them are reserved for APKTOOL DUMMY or something like that. Can I assign one of those to my new drawable line?

Thanks in advance

Hello,
For the first question : your're right you have to modify const/4 v0. 0x6 to 0x7

For the other question: don't touch apktool dummy id...if you correctly add your lines in strings.XML and got the png in drawable-hdpi folder you just have to add the lines in public.xml like writen in op ;-)

Sent from my X10s using XDA
 

sparkplugDev

Senior Member
Apr 6, 2012
383
113
Maryland
I probably missed something really obvious but what part of the utility do you use to decompile android.policy.jar? I finished decompiling, editing, and recompiling framework-res.apk with the apk re-engineering tool but when I went to try to use the same tool to work on android.policy.jar it occured to me that it wouldn't work because it isn't an apk. like i said this is probably something really simple but could someone please point me into the right direction? thanks :)
 

Tof37

Senior Member
Oct 6, 2009
624
2,468
Tours
I probably missed something really obvious but what part of the utility do you use to decompile android.policy.jar? I finished decompiling, editing, and recompiling framework-res.apk with the apk re-engineering tool but when I went to try to use the same tool to work on android.policy.jar it occured to me that it wouldn't work because it isn't an apk. like i said this is probably something really simple but could someone please point me into the right direction? thanks :)

The option to edit jar files is choice 9 (7 re-engeneering) ;)

Sent from my X10S using xda app-developers app
 
  • Like
Reactions: sparkplugDev

Top Liked Posts

  • There are no posts matching your filters.
  • 62
    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*:

    <string name="add_region_in_locale_picker_dummy_string">+</string>
    <string name="global_action_sleep">Sleep mode</string>
    <string name="global_action_screenshot_txt">Take screenshot</string>
    </resources>


    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 :
    # annotations
    .annotation system Ldalvik/annotation/MemberClasses;
    value = {
    Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;,
    Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;,
    Lcom/android/internal/policy/impl/GlobalActions$Action;,
    Lcom/android/internal/policy/impl/GlobalActions$MyAdapter;
    }
    .end annotation

    In the # instance fields thread add this line :
    .field private mCaptureScreenshot:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

    It must look like this :

    # instance fields
    .field private mAdapter:Lcom/android/internal/policy/impl/GlobalActions$MyAdapter;

    .field private mAirplaneModeOn:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;

    .field private mAirplaneState:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

    .field private final mAudioManager:Landroid/media/AudioManager;

    .field private mBroadcastReceiver:Landroid/content/BroadcastReceiver;

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

    .field private final mContext:Landroid/content/Context;

    .field private mDeviceProvisioned:Z

    .field private mDialog:Landroid/app/AlertDialog;

    .field private mHandler:Landroid/os/Handler;

    .field private mIsWaitingForEcmExit:Z

    .field private mItems:Ljava/util/ArrayList;
    .annotation system Ldalvik/annotation/Signature;
    value = {
    "Ljava/util/ArrayList",
    "<",
    "Lcom/android/internal/policy/impl/GlobalActions$Action;",
    ">;"
    }
    .end annotation
    .end field

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

    Search the line 195
    It must be like this in stock rom :

    .line 195
    const/4 v0, 0x3

    new-array v0, v0, [Lcom/android/internal/policy/impl/GlobalActions$Action;

    const/4 v1, 0x0

    iget-object v2, p0, Lcom/android/internal/policy/impl/GlobalActions;->mSilentModeToggle:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;

    aput-object v2, v0, v1

    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 :

    new-instance v0, Lcom/android/internal/policy/impl/GlobalActions$8;

    const v1, 0x108057f

    const v2, 0x10403da

    invoke-direct {v0, p0, v1, v2}, Lcom/android/internal/policy/impl/GlobalActions$8;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V

    iput-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mCaptureScreenshot:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

    Now it must look like this

    .line 195
    new-instance v0, Lcom/android/internal/policy/impl/GlobalActions$8;

    const v1, 0x108057f

    const v2, 0x10403da

    invoke-direct {v0, p0, v1, v2}, Lcom/android/internal/policy/impl/GlobalActions$8;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V

    iput-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mCaptureScreenshot:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

    const/4 v0, 0x4

    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

    invoke-direct {v0, p0, v1, v2}, Lcom/android/internal/policy/impl/GlobalActions$8
    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
    invoke-static {v0}, Lcom/google/android/collect/Lists;->newArrayList([Ljava/lang/Object;)Ljava/util/ArrayList;

    just above add

    const/4 v1, 0x3

    iget-object v2, p0, Lcom/android/internal/policy/impl/GlobalActions;->mCaptureScreenshot:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

    aput-object v2, v0, v1

    const/4 v1, 0x4

    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)

    copy_dir PACKAGE:system SYSTEM:
    set_perm 0 0 04755 SYSTEM:bin/screenshot

    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 ... ;)
    5
    FAQ :

    Q: Can't find GlobalActions$8.smali in attachment

    A: Download GlobalActions$8.zip and rename it GlobalActions$8.smali ....

    Q: Can't find the screenshot file to place in bin folder

    A : download bin.zip .... it's in ;)

    Q: Why can't I use the screencapture.apk from Arc, Neo, Xperia S etc ...

    A: We still fighting to make it working ... :D
    2
    I thought..ID's are reading automatically if they miss...only if you add them in strings and xmls…
    Finaly here thanks Tof )
    2
    really nice of you to make such a easy tutorial ...

    i love it when people share there development knowledge so that others can also learn :)
    1
    sir i got it phones open after reboot...screenshots icon showing in power menu But when i take a screenshoots this errors come...

    error unable to save screenshoots:Mbitmap=null........

    sir pls reply if you have tym... tnx:angel::angel:

    Check the permission of the name screensnhot in /bin
    The permission have to be like I wrote in op

    Sent from my XT890 using XDA Free mobile app