Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[MOD] [TUTORIAL] [5.0 LOLLIPOP] Add Flashlight and Screenshot to Power Menu

OP ambasadii

21st January 2015, 11:50 AM   |  #1  
ambasadii's Avatar
OP Senior Member
Flag Warsaw
Thanks Meter: 452
 
381 posts
Join Date:Joined: May 2011
More
Hi xda!
This is not mine tutorial , full credits go to darkera13 (SAMSUNG Developer) from Samsungviet
Link to orginal thread here
I decided to translate it and add here (only for deodex files)

So lets start modding:

Decompile android.policy.jar and go to /com/android/internal/policy/impl/GlobalActions.smali

Search for:

Code:
.field private mRestart:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;
Add something like the following:

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

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

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

.field private mScreenshot:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;
Search for:

Code:
iput-object v3, p0, Lcom/android/internal/policy/impl/GlobalActions;->mAirplaneState:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

sget-object v3, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;->Off:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;
Add something like the following:

Code:
iput-object v3, p0, Lcom/android/internal/policy/impl/GlobalActions;->mAirplaneState:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

sget-object v3, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;->Off:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

iput-object v3, p0, Lcom/android/internal/policy/impl/GlobalActions;->mFlashlightState:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

sget-object v3, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;->Off:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;
Search for:

Code:
.method static synthetic access$4700()Ljava/lang/String;
Add to the below like this:

Code:
.method static synthetic access$4700()Ljava/lang/String;
    .registers 1

    .prologue
    .line 158
    sget-object v0, Lcom/android/internal/policy/impl/GlobalActions;->mScafe:Ljava/lang/String;

    return-object v0
.end method


.method static synthetic access$500(Lcom/android/internal/policy/impl/GlobalActions;)Landroid/content/Context;
    .registers 2

    iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions;->mContext:Landroid/content/Context;

    return-object v0
.end method

.method static synthetic access$5000(Lcom/android/internal/policy/impl/GlobalActions;)Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;
    .registers 2

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

    return-object v0
.end method

.method static synthetic access$5001(Lcom/android/internal/policy/impl/GlobalActions;)Z
    .registers 2

    invoke-direct {p0}, Lcom/android/internal/policy/impl/GlobalActions;->getTorchStatus()Z

    move-result v0

    return v0
.end method
Search for:

Code:
 iput-object v2, v0, Lcom/android/internal/policy/impl/GlobalActions;->mRestart:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;
Add something like the following (* Note this paragraph have the id, id have to create the corresponding public.xml then replaced in right here, guiding the bottom):
Code:
 iput-object v2, v0, Lcom/android/internal/policy/impl/GlobalActions;->mRestart:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

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

 const v4, 0x1080b74

 const v5, 0x1080b75

 const v6, 0x1040ba4

 const v7, 0x1040ba6

 const v8, 0x1040ba7

 move-object/from16 v3, p0

 invoke-direct/range {v2 .. v8}, Lcom/android/internal/policy/impl/GlobalActions$Flashlight;-><init>(Lcom/android/internal/policy/impl/GlobalActions;IIIII)V

 move-object/from16 v0, p0

 iput-object v2, v0, Lcom/android/internal/policy/impl/GlobalActions;->mFlashlight:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;

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

 const v3, 0x1080b76

 const v4, 0x1040ba3

 move-object/from16 v0, p0

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

 move-object/from16 v0, p0

 iput-object v2, v0, Lcom/android/internal/policy/impl/GlobalActions;->mScreenshot:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;
Search for:

Code:
 const/16 v2, 0x100
Add the following:

Code:

const/16 v2, 0x100

invoke-direct/range {p0 .. p0}, Lcom/android/internal/policy/impl/GlobalActions;->getBugReportAction()Lcom/android/internal/policy/impl/GlobalActions$Action;

move-result-object v3

move-object/from16 v0, p0

iget-object v4, v0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

const/4 v5, 0x1

move-object/from16 v0, p0

invoke-direct {v0, v2, v3, v4, v5}, Lcom/android/internal/policy/impl/GlobalActions;->addDialogItemsIfEnabled(ILcom/android/internal/policy/impl/GlobalActions$Action;Ljava/util/ArrayList;Z)Z

const/16 v2, 0x200

 move-object/from16 v0, p0

 iget-object v3, v0, Lcom/android/internal/policy/impl/GlobalActions;->mFlashlight:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;

 move-object/from16 v0, p0

 iget-object v4, v0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

 const/4 v5, 0x1

 move-object/from16 v0, p0

 invoke-direct {v0, v2, v3, v4, v5}, Lcom/android/internal/policy/impl/GlobalActions;->addDialogItemsIfEnabled(ILcom/android/internal/policy/impl/GlobalActions$Action;Ljava/util/ArrayList;Z)Z

 const/16 v2, 0x400

 move-object/from16 v0, p0

 iget-object v3, v0, Lcom/android/internal/policy/impl/GlobalActions;->mScreenshot:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

 move-object/from16 v0, p0

 iget-object v4, v0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

 const/4 v5, 0x1

 move-object/from16 v0, p0

 invoke-direct {v0, v2, v3, v4, v5}, Lcom/android/internal/policy/impl/GlobalActions;->addDialogItemsIfEnabled(ILcom/android/internal/policy/impl/GlobalActions$Action;Ljava/util/ArrayList;Z)Z
Search for:

Code:
const-string v2, "emergencymode"
change this value like this:

Code:
  if-eqz v2, :cond_315
Add to the above as follows::

Code:
    const-string v2, "emergencymode"

    invoke-virtual {v2, v9}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_315

    .line 1255
    move-object/from16 v0, p0

    iget-object v2, v0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/internal/policy/impl/GlobalActions;->mEmergency:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;

    invoke-virtual {v2, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    goto :goto_24b

	.line 1255
    :cond_315
    const-string v2, "flashlight"

    invoke-virtual {v2, v9}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_32a

    move-object/from16 v0, p0

    iget-object v2, v0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/internal/policy/impl/GlobalActions;->mFlashlight:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;

    invoke-virtual {v2, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    goto :goto_24b

    :cond_32a
    const-string v2, "screenshot"

    invoke-virtual {v2, v9}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_2ca

    move-object/from16 v0, p0

    iget-object v2, v0, Lcom/android/internal/policy/impl/GlobalActions;->mItems:Ljava/util/ArrayList;

    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/internal/policy/impl/GlobalActions;->mScreenshot:Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;

    invoke-virtual {v2, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    goto :goto_24b
Search for:

Code:
.method private prepareDialog()V
    .registers 8
Add to the below as follows:

Code:
.method private prepareDialog()V
    .registers 8

	.prologue
    .line 1820
	
	invoke-direct {p0}, Lcom/android/internal/policy/impl/GlobalActions;->getTorchStatus()Z

    move-result v1

    if-eqz v1, :cond_b

    sget-object v4, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;->On:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

    iput-object v4, p0, Lcom/android/internal/policy/impl/GlobalActions;->mFlashlightState:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

    goto :goto_10

    :cond_b
    sget-object v4, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;->Off:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

    iput-object v4, p0, Lcom/android/internal/policy/impl/GlobalActions;->mFlashlightState:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

    goto :goto_10

search for:

Code:
.method private handleShow()V
    .registers 5
Add to the above as follows:

Code:
.method private getTorchStatus()Z
    .registers 5

    .prologue
    const/4 v0, 0x0

    iget-object v1, p0, Lcom/android/internal/policy/impl/GlobalActions;->mContext:Landroid/content/Context;

    invoke-virtual {v1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v1

    const-string v2, "torch_light"

    const/4 v3, -0x2

    invoke-static {v1, v2, v0, v3}, Landroid/provider/Settings$System;->getIntForUser(Landroid/content/ContentResolver;Ljava/lang/String;II)I

    move-result v1

    if-eqz v1, :cond_11

    const/4 v0, 0x1

    :cond_11
    return v0
.end method

.method private handleShow()V
    .registers 5
Search for:

Code:
 const-string v4, "content://com.sec.knox.provider2/KnoxCustomManagerService1"
Add to the above like this:

Code:
	.line 1840
	iget-object v4, p0, Lcom/android/internal/policy/impl/GlobalActions;->mFlashlight:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;

    iget-object v5, p0, Lcom/android/internal/policy/impl/GlobalActions;->mFlashlightState:Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;

    invoke-virtual {v4, v5}, Lcom/android/internal/policy/impl/GlobalActions$ToggleAction;->updateState(Lcom/android/internal/policy/impl/GlobalActions$ToggleAction$State;)V
	
    .line 1842
    const-string v4, "content://com.sec.knox.provider2/KnoxCustomManagerService1"
Save and unzip attachments GlobalMenu_darkera13_samsungviet.vn.zip copy the entire file in andorid.policy in / com / android / internal / policy / impl /

Decompile framework-res.apk and go to /res/values/arrays.xml

Search for:
Code:
 <string-array name="config_globalActionsList">
Add the following:

Code:
<string-array name="config_globalActionsList">
<item>power</item>
<item>datamode</item>
<item>airplane</item>
<item>restart</item>
<item>lockdown</item>
<item>bugreport</item>
<item>users</item>
<item>emergencymode</item>
<item>flashlight</item>
<item>screenshot</item>
</string-array>
Save and open files /res/values/strings.xml

Add to the end of the file is as follows:

Code:
 <string name="global_action_screenshot">Take Screenshot</string>
 <string name="global_action_flashlight">Flashlight</string>
 <string name="global_actions_flashlight_on_status">On</string>
 <string name="global_actions_flashlight_off_status">Off</string>
 </resources>
Save and open files /res/values/public.xml

Add to the end of the file is as follows:

Code:
 <public type="string" name="global_action_screenshot" id="0x01040ba3" />
 <public type="string" name="global_action_flashlight" id="0x01040ba4" />
 <public type="string" name="global_actions_flashlight_on_status" id="0x01040ba5" />
 <public type="string" name="global_actions_flashlight_off_status" id="0x01040ba6" />
 <public type="drawable" name="tw_ic_lock_flashlight_on" id="0x01080b74" />
 <public type="drawable" name="tw_ic_lock_flashlight_off" id="0x01080b75" />
 <public type="drawable" name="tw_ic_lock_screenshot" id="0x01080b76" />

The id of public.xml may vary depending on the change of the file before public.xml so id have to figure out the right to revise section above id.
The principle of the id is constantly and have the right type, each type will have its own code (eg look at the section on the string is found 0x0104, 0x0108 will be drawable)

So to know the correct id id must be the biggest find in each type, try before going straight string,
here we see this guy 0x0104xxxx code is wrong we try to thousands and hundreds, tens and units ie instead of to find us every turn from 0x01040 -> 0x01049 guy, the guy does not have before it the biggest guy,
for example 0x01045 guy does not have the biggest guy thousands of it is 0x01044, so look down to the hundreds, tens and units. Note small as it used id hexadecimal should turn from small to large 0 -> 9, a, b, c, d, e, f

After finding the largest id translational then 1 unit and instead turn to the id in public.xml similar.

Afterward, they must determine the correct id id in the code Smail (noted above) with the correct id (Note that in the smali code id dropping 1 to 0 on, eg 0x01040ba3 going into 0x1040ba3)

something like this:

Code:
<public type="drawable" name="tw_ic_lock_flashlight_off" 	id="0x01080b84" />	->	0x1080b84	-> const v5
    <public type="drawable" name="tw_ic_lock_flashlight_on" 	id="0x01080b85" />	->	0x1080b85	-> const v4
    <public type="drawable" name="tw_ic_lock_screenshot" 	id="0x01080b86" />	->	0x1080b86 	-> const v3

    <public type="string" name="global_action_screenshot" 	id="0x01040b85" />		-> 0x1040b85    ->	const v4
    <public type="string" name="global_actions_flashlight_on_status" id="0x01040b87" />	-> 0x1040b87	 - > const v7
    <public type="string" name="global_actions_flashlight_off_status" id="0x01040b88" />	-> 0x1040b88	  -> const v8
    <public type="string" name="global_action_flashlight" 	id="0x01040b86" />		-> 0x1040b86  -> const v6
Next copy the image file in framework-res attachments / *. Png into the framework-res / res / drawable-xhdpi

Recompile and done!

Download smali and framework-res files from here

Power Menu Mod with screenshot and flashlight button + 5 way reboot menu (G900FXXU1BNL9)
download

Credits:
@darkera13
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2015-01-24-12-49-41.png
Views:	646
Size:	109.0 KB
ID:	3131160  
Last edited by ambasadii; 25th January 2015 at 09:14 PM.
The Following 14 Users Say Thank You to ambasadii For This Useful Post: [ View ]
21st January 2015, 12:39 PM   |  #2  
daxgirl's Avatar
Senior Member
Flag Jerusalem
Thanks Meter: 4,134
 
2,077 posts
Join Date:Joined: Jun 2012
More
AWESOME GUIDE!!! Thank you so much!!!

Sent from my SM-G900F using Tapatalk
21st January 2015, 02:29 PM   |  #3  
ambasadii's Avatar
OP Senior Member
Flag Warsaw
Thanks Meter: 452
 
381 posts
Join Date:Joined: May 2011
More
i didn't test it yet , if someone make it for deodex android.policy.jar and framework-res.apk (only clean not earlier modded) please share with us here and wrote phone model, thank you
Last edited by ambasadii; 21st January 2015 at 02:51 PM.
21st January 2015, 04:20 PM   |  #4  
Senior Member
Flag Santiago
Thanks Meter: 108
 
245 posts
Join Date:Joined: May 2014
Donate to Me
More
Smile :)
Any way to add flashlight to notification bar toogles?

Thanks!
21st January 2015, 07:53 PM   |  #5  
ambasadii's Avatar
OP Senior Member
Flag Warsaw
Thanks Meter: 452
 
381 posts
Join Date:Joined: May 2011
More
Quote:
Originally Posted by aguarello

Any way to add flashlight to notification bar toogles?

Thanks!

Yes you can by Sqlite Editor from Google playstore
Last edited by ambasadii; 21st January 2015 at 11:45 PM.
22nd January 2015, 07:24 PM   |  #6  
churapa's Avatar
Senior Member
Thanks Meter: 4,536
 
1,456 posts
Join Date:Joined: Jun 2008
Excellent guide. Keep it up!
22nd January 2015, 08:01 PM   |  #7  
ambasadii's Avatar
OP Senior Member
Flag Warsaw
Thanks Meter: 452
 
381 posts
Join Date:Joined: May 2011
More
you need to change some line to correct with your Global.Action.smali (do not copy/paste all code it not work becouse this tutorial is for Note 3!)
Last edited by ambasadii; 24th January 2015 at 12:42 AM.
22nd January 2015, 08:01 PM   |  #8  
Senior Member
Thanks Meter: 222
 
322 posts
Join Date:Joined: Apr 2011
Quote:
Originally Posted by ambasadii

Yes you can by Sqlite Editor from Google playstore

Can you please share how?

Thanx in advance
22nd January 2015, 08:08 PM   |  #9  
ambasadii's Avatar
OP Senior Member
Flag Warsaw
Thanks Meter: 452
 
381 posts
Join Date:Joined: May 2011
More
Quote:
Originally Posted by seky0405

Can you please share how?

Thanx in advance

1) download from playstore SQLite Editor
2) install and run, we grant root permissions
3) find the APPS tab and go to "this" and open it
4) press the "settings.db" and then select "system"
5) locate the "notification_panel_active_app_list" and press it to be is highlighted in gray after which choose the pencil icon to enter the settings, see here
6) complement entry with missing buttons below:

Wifi;MobileData;Bluetooth;Location;AutoRotate;Sile ntMode;Location;NetworkBooster;Toolbox;SFinder;Qui ckConnect;MultiWindow;WiFiHotspot;Nfc;SBeam;AllSha reCast;SmartStay;SmartPause;Sync;AirView;AirGestur e;AirplaneMode;CarMode;PersonalMode;Ebook;UltraPow erSaving;PowerSaving;TouchSensitivity;DormantMode; SideKey;Flashlight;

7) press "save" and restart the phone
Last edited by ambasadii; 22nd January 2015 at 08:11 PM.
The Following 2 Users Say Thank You to ambasadii For This Useful Post: [ View ]
22nd January 2015, 08:10 PM   |  #10  
Senior Member
Thanks Meter: 222
 
322 posts
Join Date:Joined: Apr 2011
Quote:
Originally Posted by ambasadii

1) download from playstore SQLite Editor
2) install and run, we grant root permissions
3) find the APPS tab "Pamięć ustawień" and open it
4) press the "settings.db" and then select "system"
5) locate the "notification_panel_active_app_list" and press it to be is highlighted in gray after which choose the pencil icon to enter the settings, see tutaj
6) complement entry with missing buttons below:

Wifi;MobileData;Bluetooth;Location;AutoRotate;Sile ntMode;Location;NetworkBooster;Toolbox;SFinder;Qui ckConnect;MultiWindow;WiFiHotspot;Nfc;SBeam;AllSha reCast;SmartStay;SmartPause;Sync;AirView;AirGestur e;AirplaneMode;CarMode;PersonalMode;Ebook;UltraPow erSaving;PowerSaving;TouchSensitivity;DormantMode; SideKey;Flashlight

7) press "save" and restart the phone

WoW! Thanx

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes