[MOD / How To][5/11/13] - Extended Reboot Menu - De-Odex - MDL - AT&T Samsung Galaxy S 4 Android Development

Reboot options as show :good:
Pre-requisites
De-Odex'ed devices only! Will not work on stock ROM!
Must have the the MDL De-Odex mod by Nottach to use this mod!
Installation
I used similar install method as Nottach to apply this mod.
Download the attachment. Unzip it to your desktop.
Simply copy the "Mods" folder to your internal storage
Run the "Mod Me.bat" file after copying
It will copy the mod to the correct location, clear cache, then reboot phone.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Feel free to use this in any mod or ROM you make.
Hit Thanks!​

To make this mod your self or further modify it do the following;
First decompile classes.dex in android.policy.jar. I wont get into that part as this mini tutorial assumes you know how to modify smali code.
Add the following BOLD ITALIC code to \com\android\internal\policy\impl\GlobalActions$SinglePressAction.smali
Modded Code:
Code:
# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
value = Lcom/android/internal/policy/impl/GlobalActions;
.end annotation
.annotation system Ldalvik/annotation/InnerClass;
accessFlags = 0x40a
name = "SinglePressAction"
.end annotation
[B][I]# static fields
.field protected static rebootMode:I
.field protected static final rebootOptions:[Ljava/lang/String;
[/I][/B]
# instance fields
.field private final mIcon:Landroid/graphics/drawable/Drawable;
.field private final mIconResId:I
.field private final mMessage:Ljava/lang/CharSequence;
.field private final mMessageResId:I
# direct methods
[B][I].method static constructor <clinit>()V
.registers 3
const/4 v0, 0x4
new-array v0, v0, [Ljava/lang/String;
const/4 v1, 0x0
const-string v2, "Reboot"
aput-object v2, v0, v1
const/4 v1, 0x1
const-string v2, "Restart Shell"
aput-object v2, v0, v1
const/4 v1, 0x2
const-string v2, "Download"
aput-object v2, v0, v1
const/4 v1, 0x3
const-string v2, "Recovery"
aput-object v2, v0, v1
sput-object v0, Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;->rebootOptions:[Ljava/lang/String;
return-void
.end method[/I][/B]
.method protected constructor <init>(II)V[I][/I]
FYI: You can change the string names to what you like best. For example most people word the second string as "Hot reboot" but I think that sounds lame so I call it what it is and that is a shell restart. Another example would be to change "Download" to "Download Mode"
Then change \com\android\internal\policy\impl\GlobalActions.smali
right below .line 566
new-instance v0, Lcom/android/internal/policy/impl/GlobalActions$5;
to
new-instance v0, Lcom/android/internal/policy/impl/GlobalActions$99;
Then create three smali files as shown below and add them to: \com\android\internal\policy\impl\
GlobalActions$99.smali
Code:
.class Lcom/android/internal/policy/impl/GlobalActions$99;
.super Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;
.source "GlobalActions.java"
# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
value = Lcom/android/internal/policy/impl/GlobalActions;->createDialog()Landroid/app/AlertDialog;
.end annotation
.annotation system Ldalvik/annotation/InnerClass;
accessFlags = 0x0
name = null
.end annotation
# instance fields
.field final synthetic this$0:Lcom/android/internal/policy/impl/GlobalActions;
# direct methods
.method constructor <init>(Lcom/android/internal/policy/impl/GlobalActions;II)V
.registers 4
iput-object p1, p0, Lcom/android/internal/policy/impl/GlobalActions$99;->this$0:Lcom/android/internal/policy/impl/GlobalActions;
invoke-direct {p0, p2, p3}, Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;-><init>(II)V
return-void
.end method
# virtual methods
.method public onPress()V
.registers 7
const/4 v5, 0x4
new-instance v1, Landroid/app/AlertDialog$Builder;
iget-object v2, p0, Lcom/android/internal/policy/impl/GlobalActions$99;->this$0:Lcom/android/internal/policy/impl/GlobalActions;
#getter for: Lcom/android/internal/policy/impl/GlobalActions;->mContext:Landroid/content/Context;
invoke-static {v2}, Lcom/android/internal/policy/impl/GlobalActions;->access$000(Lcom/android/internal/policy/impl/GlobalActions;)Landroid/content/Context;
move-result-object v2
invoke-direct {v1, v2}, Landroid/app/AlertDialog$Builder;-><init>(Landroid/content/Context;)V
const-string v2, "Reboot Menu"
invoke-virtual {v1, v2}, Landroid/app/AlertDialog$Builder;->setTitle(Ljava/lang/CharSequence;)Landroid/app/AlertDialog$Builder;
move-result-object v1
sget-object v2, Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;->rebootOptions:[Ljava/lang/String;
const/4 v3, 0x0
new-instance v4, Lcom/android/internal/policy/impl/GlobalActions$99$2;
invoke-direct {v4, p0}, Lcom/android/internal/policy/impl/GlobalActions$99$2;-><init>(Lcom/android/internal/policy/impl/GlobalActions$99;)V
invoke-virtual {v1, v2, v3, v4}, Landroid/app/AlertDialog$Builder;->setSingleChoiceItems([Ljava/lang/CharSequence;ILandroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;
move-result-object v1
const v2, 0x104000a
new-instance v3, Lcom/android/internal/policy/impl/GlobalActions$99$1;
invoke-direct {v3, p0}, Lcom/android/internal/policy/impl/GlobalActions$99$1;-><init>(Lcom/android/internal/policy/impl/GlobalActions$99;)V
invoke-virtual {v1, v2, v3}, Landroid/app/AlertDialog$Builder;->setPositiveButton(ILandroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;
move-result-object v1
const/high16 v2, 0x104
const/4 v3, 0x0
invoke-virtual {v1, v2, v3}, Landroid/app/AlertDialog$Builder;->setNegativeButton(ILandroid/content/DialogInterface$OnClickListener;)Landroid/app/AlertDialog$Builder;
move-result-object v1
invoke-virtual {v1}, Landroid/app/AlertDialog$Builder;->create()Landroid/app/AlertDialog;
move-result-object v0
invoke-virtual {v0}, Landroid/app/AlertDialog;->getWindow()Landroid/view/Window;
move-result-object v1
const/16 v2, 0x7d9
invoke-virtual {v1, v2}, Landroid/view/Window;->setType(I)V
iget-object v1, p0, Lcom/android/internal/policy/impl/GlobalActions$99;->this$0:Lcom/android/internal/policy/impl/GlobalActions;
#getter for: Lcom/android/internal/policy/impl/GlobalActions;->mContext:Landroid/content/Context;
invoke-static {v1}, Lcom/android/internal/policy/impl/GlobalActions;->access$000(Lcom/android/internal/policy/impl/GlobalActions;)Landroid/content/Context;
move-result-object v1
invoke-virtual {v1}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;
move-result-object v1
const v2, 0x111000f
invoke-virtual {v1, v2}, Landroid/content/res/Resources;->getBoolean(I)Z
move-result v1
if-nez v1, :cond_58
invoke-virtual {v0}, Landroid/app/AlertDialog;->getWindow()Landroid/view/Window;
move-result-object v1
invoke-virtual {v1, v5, v5}, Landroid/view/Window;->setFlags(II)V
:cond_58
invoke-virtual {v0}, Landroid/app/AlertDialog;->show()V
return-void
.end method
.method public showBeforeProvisioning()Z
.registers 2
.prologue
.line 307
const/4 v0, 0x1
return v0
.end method
.method public showConditional()Z
.registers 2
.prologue
.line 311
const/4 v0, 0x1
return v0
.end method
.method public showDuringKeyguard()Z
.registers 2
.prologue
.line 304
const/4 v0, 0x1
return v0
.end method
GlobalActions$99$1.smali
Code:
.class Lcom/android/internal/policy/impl/GlobalActions$99$1;
.super Ljava/lang/Object;
.source "GlobalActions.java"
# interfaces
.implements Landroid/content/DialogInterface$OnClickListener;
# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
value = Lcom/android/internal/policy/impl/GlobalActions$99;->onPress()V
.end annotation
.annotation system Ldalvik/annotation/InnerClass;
accessFlags = 0x0
name = null
.end annotation
# instance fields
.field final synthetic this$1:Lcom/android/internal/policy/impl/GlobalActions$99;
# direct methods
.method constructor <init>(Lcom/android/internal/policy/impl/GlobalActions$99;)V
.registers 2
.parameter
.prologue
.line 281
iput-object p1, p0, Lcom/android/internal/policy/impl/GlobalActions$99$1;->this$1:Lcom/android/internal/policy/impl/GlobalActions$99;
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
# virtual methods
.method public onClick(Landroid/content/DialogInterface;I)V
.registers 7
.parameter "dialog"
.parameter "whichButton"
.prologue
const/4 v2, 0x1
const/4 v3, 0x0
.line 282
sget v0, Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;->rebootMode:I
const/4 v1, -0x1
if-le v0, v1, :cond_20
.line 291
sget v0, Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;->rebootMode:I
const/4 v1, 0x4
if-eq v0, v1, :cond_4d
.line 283
sget v0, Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;->rebootMode:I
if-eq v0, v2, :cond_2c
.line 284
iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions$99$1;->this$1:Lcom/android/internal/policy/impl/GlobalActions$99;
iget-object v0, v0, Lcom/android/internal/policy/impl/GlobalActions$99;->this$0:Lcom/android/internal/policy/impl/GlobalActions;
#getter for: Lcom/android/internal/policy/impl/GlobalActions;->mContext:Landroid/content/Context;
invoke-static {v0}, Lcom/android/internal/policy/impl/GlobalActions;->access$000(Lcom/android/internal/policy/impl/GlobalActions;)Landroid/content/Context;
move-result-object v0
sget v1, Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;->rebootMode:I
if-nez v1, :cond_21
const/4 v1, 0x0
:goto_1d
invoke-static {v0, v1, v3}, Lcom/android/server/power/ShutdownThread;->reboot(Landroid/content/Context;Ljava/lang/String;Z)V
.line 291
:cond_20
:goto_20
return-void
.line 284
:cond_21
sget-object v1, Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;->rebootOptions:[Ljava/lang/String;
sget v2, Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;->rebootMode:I
aget-object v1, v1, v2
invoke-virtual {v1}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;
move-result-object v1
goto :goto_1d
.line 288
:cond_2c
:try_start_2c
invoke-static {}, Ljava/lang/Runtime;->getRuntime()Ljava/lang/Runtime;
move-result-object v0
const/4 v1, 0x4
new-array v1, v1, [Ljava/lang/String;
const/4 v2, 0x0
const-string v3, "pkill"
aput-object v3, v1, v2
const/4 v2, 0x1
const-string v3, "-TERM"
aput-object v3, v1, v2
const/4 v2, 0x2
const-string v3, "-f"
aput-object v3, v1, v2
const/4 v2, 0x3
const-string v3, "system_server"
aput-object v3, v1, v2
invoke-virtual {v0, v1}, Ljava/lang/Runtime;->exec([Ljava/lang/String;)Ljava/lang/Process;
:try_end_4a
.catch Ljava/lang/Exception; {:try_start_2c .. :try_end_4a} :catch_4b
goto :goto_20
.line 290
:catch_4b
move-exception v0
goto :goto_20
:cond_4d
iget-object v0, p0, Lcom/android/internal/policy/impl/GlobalActions$99$1;->this$1:Lcom/android/internal/policy/impl/GlobalActions$99;
iget-object v0, v0, Lcom/android/internal/policy/impl/GlobalActions$99;->this$0:Lcom/android/internal/policy/impl/GlobalActions;
#getter for: Lcom/android/internal/policy/impl/GlobalActions;->mContext:Landroid/content/Context;
invoke-static {v0}, Lcom/android/internal/policy/impl/GlobalActions;->access$000(Lcom/android/internal/policy/impl/GlobalActions;)Landroid/content/Context;
move-result-object v0
const/4 v1, 0x0
invoke-static {v0, v1}, Lcom/android/server/power/ShutdownThread;->shutdown(Landroid/content/Context;Z)V
goto :goto_20
.end method
GlobalActions$99$2.smali
Code:
.class Lcom/android/internal/policy/impl/GlobalActions$99$2;
.super Ljava/lang/Object;
.source "GlobalActions.java"
# interfaces
.implements Landroid/content/DialogInterface$OnClickListener;
# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
value = Lcom/android/internal/policy/impl/GlobalActions$99;->onPress()V
.end annotation
.annotation system Ldalvik/annotation/InnerClass;
accessFlags = 0x0
name = null
.end annotation
# instance fields
.field final synthetic this$1:Lcom/android/internal/policy/impl/GlobalActions$99;
# direct methods
.method constructor <init>(Lcom/android/internal/policy/impl/GlobalActions$99;)V
.registers 2
iput-object p1, p0, Lcom/android/internal/policy/impl/GlobalActions$99$2;->this$1:Lcom/android/internal/policy/impl/GlobalActions$99;
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
# virtual methods
.method public onClick(Landroid/content/DialogInterface;I)V
.registers 3
sput p2, Lcom/android/internal/policy/impl/GlobalActions$SinglePressAction;->rebootMode:I
return-void
.end method
Recompile and done!
You can also change the names of the reboot method to your liking!

Slowly but surely here comes the goodies. Cant wait for flashy time for AT&T.
ATT S4 Rooted. Beastin.
4.2.2

Scrosler you are the man! Hell ya dude thanks!! I envy your talent

"Tettering" ay, right. Slow down a little, I can't keep up. Very usefull reboot menu. Works for me.
sent from my SGH-i317

Dean1650 said:
"Tettering" ay, right. Slow down a little, I can't keep up. Very usefull reboot menu. Works for me.
sent from my SGH-i317
Click to expand...
Click to collapse
Hehehehe.... It was a tough choice my friend. Hardest phone choice I had to make but then after owning both I decided this was going to be a power house!
Me slow down? Never! :angel:
Did you see my launcher mod in themes and apps?

scrosler said:
Hehehehe.... It was a tough choice my friend. Hardest phone choice I had to make but then after owning both I decided this was going to be a power house!
Me slow down? Never! :angel:
Did you see my launcher mod in themes and apps?
Click to expand...
Click to collapse
No, but I'm headed over there now.
sent from my SGH-i317

scrosler said:
Hehehehe.... It was a tough choice my friend. Hardest phone choice I had to make but then after owning both I decided this was going to be a power house!
Me slow down? Never! :angel:
Did you see my launcher mod in themes and apps?
Click to expand...
Click to collapse
Thought you were going back to Verizon?
Sent from my HTC One using Tapatalk 2

powerwagon said:
Thought you were going back to Verizon?
Sent from my HTC One using Tapatalk 2
Click to expand...
Click to collapse
I did. The people on Verizon bought me a Note II (when it came out). But I wanted the SGS4 so I broke into my donation fund and bought (part of it anyways).
I now develop for 4 phones, SGS4, Note II (All carriers), SGS3, and HTC One X... and the Nexus 10 Tablet.

scrosler said:
I did. The people on Verizon bought me a Note II (when it came out). But I wanted the SGS4 so I broke into my donation fund and bought (part of it anyways).
I now develop for 4 phones, SGS4, Note II (All carriers), SGS3, and HTC One X... and the Nexus 10 Tablet.
Click to expand...
Click to collapse
Cant wait to be running cleanrom on this! Def one of the best devs in the game, glad you kept it
Sent from my SAMSUNG-SGH-I337 using Tapatalk 2

Can't wait for mine to come in the mail... Thanks to you guys who able to do this awesome work. Hope I can help out or at least test some stuff out for you guys.
Sent from my SGS3 using xda premium

Deodexed System Installer ran from Noattach but i am still not able to get this mod to work i am updated to the lastest AMDL and deodexed verifiyed by checking build info Nottach.JDQ39.I337UCUAMDL anyone have any ideas ? as to what the problem is .

tokoam said:
Deodexed System Installer ran from Noattach but i am still not able to get this mod to work i am updated to the lastest AMDL and deodexed verifiyed by checking build info Nottach.JDQ39.I337UCUAMDL anyone have any ideas ? as to what the problem is .
Click to expand...
Click to collapse
And you used the installer with this mod?

Yes I did
Sent from my SAMSUNG-SGH-I337 using Tapatalk 2

tokoam said:
Yes I did
Sent from my SAMSUNG-SGH-I337 using Tapatalk 2
Click to expand...
Click to collapse
Did you get an error messages?

scrosler said:
Did you get an error messages?
Click to expand...
Click to collapse
No error message in cmd batch file
Sent from my SAMSUNG-SGH-I337 using Tapatalk 2

i try right

It does not work for me either
Just says waiting for s4. The other installer works fine I even tried just pushing me jar file but that did not work either
Sent from my SAMSUNG-SGH-I337 using xda premium

And you have ADB installed and in the Windows path?

I have updated the instructions to be more specific and included an alternate installer with the ADB executables.

Related

[MOD] [UPDATED]Top battery line indicator with pngs

Hi there, I want to share this tutorial for implementing Top line battery indicator mod.
I have re-made and tweaked (for XWLA4) one of my favourite theme (Dark Theme by Mr. Megi), just to show you how it looks like!
You will find this mod with this theme on the attached zip cwm file - only for deodexed xwla4.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Watch it on youtube fullscreen mode
I started by studying the java source code for handling battery info!
source code -> here
Then i looked into a couple of classes inside SystemUI.apk just to see where i could put my hands..
To better understand the smali code of the classes i modified, i used the java source code here, it is a bit different by the Galaxy S2 implementation but a good start point!
Requirement:
1. Decompiled SystemUI.apk with Apk Manager.
2. Some advanced understanding about editing xml file and smali code.
3. Backup SystemUI.apk first!
Before to start, i'd like to point out that i used XWLA4 firmware as base, but it should work for any firmware with some changes.
Files to be edited in SystemUI.apk:
1. res/layout/status_bar.xml
2. res/values/ids.xml
3. smali/com/android/systemui/statusbar/StatusBarService.smali
4. smali/com/android/systemui/statusbar/StatusBarView.smali
1. Editing SystemUI.apk
1.1 Editing res/layout/status_bar.xml
We need to insert a ViewImage item on the xml for displaying our battery line indicator, normal/charging
Add the following line just above <LinearLayout androidrientation="horizontal" android:id="@id/icons" android:layout_width="fill_parent" android:layout_height="fill_parent">
Code:
<ImageView android:id="@id/battery_indicator_charging" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/battery_indicator_charging" />
2 Edit res/values/ids.xml
We need to add IDs for the item we have added on the status_bar.xml
Add this line at the TOP of the file, this should be the first line!
Code:
<item type="id" name="battery_indicator_charging">false</item>
2.1 Add images to res/drawable-hdpi
We need to add the following 3 images, you will find them attached on my source code!
z_battery_indicator_charging.png
z_battery_indicator.9.png
z_battery_indicator_low.9.png
2.2 Recompile SystemUI.apk
We need to recompile the apk because we need to take care about the ID ref assigned to battery_indicator_charging, and the drawable IDs for images we have added on the previus step.
Now decompile again SystemUI.apk and open res/values/public.xml:
You should see these new entries:
Code:
<public type="drawable" name="z_battery_indicator" id="0x7f0200b8" />
<public type="drawable" name="z_battery_indicator_charging" id="0x7f0200b9" />
<public type="drawable" name="z_battery_indicator_low" id="0x7f0200ba" />
...
<public type="id" name="battery_indicator_charging" id="0x7f0a0034" />
Take note of these 3 IDS: 0x7f0200b8, 0x7f0200ba, 0x7f0a0034
Please note that in your system they can have different values.
3 Editing StatusBarService.smali
We need to intercept addIcon function and when the battery icon is passed as parameter we need to call our function updateBatteryIndicator.
Find this method:
Code:
.method public addIcon(Ljava/lang/String;IILcom/android/internal/statusbar/StatusBarIcon;)V
Add replace it with the code below
Code:
.method public addIcon(Ljava/lang/String;IILcom/android/internal/statusbar/StatusBarIcon;)V
.locals 6
.parameter "slot"
.parameter "index"
.parameter "viewIndex"
.parameter "icon"
.prologue
const-string v5, "battery"
.line 466
new-instance v0, Lcom/android/systemui/statusbar/StatusBarIconView;
invoke-direct {v0, p0, p1}, Lcom/android/systemui/statusbar/StatusBarIconView;-><init>(Landroid/content/Context;Ljava/lang/String;)V
.line 467
.local v0, view:Lcom/android/systemui/statusbar/StatusBarIconView;
invoke-virtual {v0, p4}, Lcom/android/systemui/statusbar/StatusBarIconView;->set(Lcom/android/internal/statusbar/StatusBarIcon;)Z
.line 468
iget-object v1, p0, Lcom/android/systemui/statusbar/StatusBarService;->mStatusIcons:Landroid/widget/LinearLayout;
new-instance v2, Landroid/widget/LinearLayout$LayoutParams;
iget v3, p0, Lcom/android/systemui/statusbar/StatusBarService;->mIconSize:I
iget v4, p0, Lcom/android/systemui/statusbar/StatusBarService;->mIconSize:I
invoke-direct {v2, v3, v4}, Landroid/widget/LinearLayout$LayoutParams;-><init>(II)V
invoke-virtual {v1, v0, p3, v2}, Landroid/widget/LinearLayout;->addView(Landroid/view/View;ILandroid/view/ViewGroup$LayoutParams;)V
invoke-virtual {v5, p1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v1
if-eqz v1, :cond_0
.line 410
invoke-direct {p0, p4}, Lcom/android/systemui/statusbar/StatusBarService;->updateBatteryIndicator(Lcom/android/internal/statusbar/StatusBarIcon;)V
.line 469
:cond_0
return-void
.end method
Now we need to do the same for "updateIcon" method. Find this method:
Code:
.method public updateIcon(Ljava/lang/String;IILcom/android/internal/statusbar/StatusBarIcon;Lcom/android/internal/statusbar/StatusBarIcon;)V
Replace it with the code below:
Code:
.method public updateIcon(Ljava/lang/String;IILcom/android/internal/statusbar/StatusBarIcon;Lcom/android/internal/statusbar/StatusBarIcon;)V
.locals 2
.parameter "slot"
.parameter "index"
.parameter "viewIndex"
.parameter "old"
.parameter "icon"
.prologue
.line 477
iget-object v1, p0, Lcom/android/systemui/statusbar/StatusBarService;->mStatusIcons:Landroid/widget/LinearLayout;
invoke-virtual {v1, p3}, Landroid/widget/LinearLayout;->getChildAt(I)Landroid/view/View;
move-result-object v0
check-cast v0, Lcom/android/systemui/statusbar/StatusBarIconView;
.line 478
.local v0, view:Lcom/android/systemui/statusbar/StatusBarIconView;
invoke-virtual {v0, p5}, Lcom/android/systemui/statusbar/StatusBarIconView;->set(Lcom/android/internal/statusbar/StatusBarIcon;)Z
const-string v1, "battery"
invoke-virtual {v1, p1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v1
if-eqz v1, :cond_0
.line 424
invoke-direct {p0, p5}, Lcom/android/systemui/statusbar/StatusBarService;->updateBatteryIndicator(Lcom/android/internal/statusbar/StatusBarIcon;)V
.line 479
:cond_0
return-void
.end method
It's time to add our method to handle the Update our Battery Indicator!
Code:
.method private updateBatteryIndicator(Lcom/android/internal/statusbar/StatusBarIcon;)V
.locals 2
.parameter "icon"
.prologue
.line 462
iget-object v0, p0, Lcom/android/systemui/statusbar/StatusBarService;->mStatusBarView:Lcom/android/systemui/statusbar/StatusBarView;
iget-object v0, v0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicator:Landroid/widget/ImageView;
iget v1, p1, Lcom/android/internal/statusbar/StatusBarIcon;->iconLevel:I
invoke-static {v1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v1
invoke-virtual {v0, v1}, Landroid/widget/ImageView;->setTag(Ljava/lang/Object;)V
.line 463
iget-object v0, p0, Lcom/android/systemui/statusbar/StatusBarService;->mStatusBarView:Lcom/android/systemui/statusbar/StatusBarView;
iget-object v0, v0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicatorCharging:Landroid/widget/ImageView;
iget v1, p1, Lcom/android/internal/statusbar/StatusBarIcon;->iconId:I
invoke-static {v1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v1
invoke-virtual {v0, v1}, Landroid/widget/ImageView;->setTag(Ljava/lang/Object;)V
.line 464
iget-object v0, p0, Lcom/android/systemui/statusbar/StatusBarService;->mStatusBarView:Lcom/android/systemui/statusbar/StatusBarView;
invoke-virtual {v0}, Lcom/android/systemui/statusbar/StatusBarView;->requestLayout()V
.line 465
iget-object v0, p0, Lcom/android/systemui/statusbar/StatusBarService;->mStatusBarView:Lcom/android/systemui/statusbar/StatusBarView;
invoke-virtual {v0}, Lcom/android/systemui/statusbar/StatusBarView;->invalidate()V
.line 466
return-void
.end method
Add this code where you prefer!
Note:
We use setTag function to store an useful info: "batteryLevel" inside the two views we created.
4 Editing StatusBarView.smali
Well on this class we need to change a lot of stuff, i advice to see my attached source code and diff it.
To sum up, this is the class responsible to display the status bar view.
We need to instantiate a "BroadcastReceiver" to intercept this intent: "android.intent.action.SCREEN_ON" That's because we don't want to play the charging animation while the screen is off.
I will report, just to let you understand it better, the java pseudo code where the view is created, here we need to do some calculation to get the correct values (width) for our Barline indicator images. In addition we are creating the animation for battery charging state.
Pseudo Java source code:
Code:
protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
{
super.onLayout(paramBoolean, paramInt1, paramInt2, paramInt3, paramInt4);
if ((!this.mShowBatteryIndicator))
{
this.mBatteryIndicator.setVisibility(8);
this.mBatteryIndicatorCharging.setVisibility(8);
this.mBatteryIndicatorCharging.clearAnimation();
}
else
{
this.mBatteryIndicator.setVisibility(0);
this.mBatteryIndicatorCharging.setVisibility(0);
int j = ((Integer)this.mBatteryIndicator.getTag()).intValue();
this.mBatteryIndicatorWidth = (j * (paramInt3 - paramInt1) / 100);
this.mBatteryIndicatorCharging.layout(paramInt3, paramInt2, paramInt3 + this.mBatteryIndicatorCharging.getMeasuredWidth(), paramInt2 + this.mBatteryIndicatorCharging.getMeasuredHeight());
int i = BATTERY_INDICATOR_ID;
if ((!this.mScreenIsOn) || (chargeIconID != ((Integer)this.mBatteryIndicatorCharging.getTag()).intValue()))
{
this.mBatteryIndicatorCharging.clearAnimation();
if (j < this.mBatteryLowLevel)
i = LOW_BATTERY_INDICATOR_ID;
}
else
{
TranslateAnimation localTranslateAnimation = new TranslateAnimation(0.0F, this.mBatteryIndicatorWidth - (paramInt3 - paramInt1), 0.0F, 0.0F);
localTranslateAnimation.setDuration(1500L);
localTranslateAnimation.setStartOffset(3500L);
localTranslateAnimation.setRepeatCount(-1);
localTranslateAnimation.setRepeatMode(1);
this.mBatteryIndicatorCharging.startAnimation(localTranslateAnimation);
}
this.mBatteryIndicator.setImageResource(i);
this.mBatteryIndicator.layout(paramInt1, paramInt2, paramInt3, paramInt2 + this.mBatteryIndicator.getDrawable().getIntrinsicHeight());
}
}
Smali code
We need to add new field member to this class: StatusBarView. You can add these lines just below: "# instance fields" at the very top!
Code:
.field mBatteryIndicator:Landroid/widget/ImageView;
.field mBatteryIndicatorCharging:Landroid/widget/ImageView;
.field private mBatteryIndicatorWidth:I
.field private mBatteryLowLevel:I
.field private mShowBatteryIndicator:Z
.field mScreenIsOn:Z
.field mIntentReceiver:Landroid/content/BroadcastReceiver;
Now we need to change the constructor of this class to set values for our field members:
Find this method:
Code:
.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
and replace with the one below.
Code:
.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
.locals 1
.parameter "context"
.parameter "attrs"
.prologue
.line 56
invoke-direct {p0, p1, p2}, Landroid/widget/FrameLayout;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
.line 54
const/4 v0, 0x0
iput-boolean v0, p0, Lcom/android/systemui/statusbar/StatusBarView;->mScreenIsOn:Z
const/4 v0, 0x1
iput-boolean v0, p0, Lcom/android/systemui/statusbar/StatusBarView;->mShowBatteryIndicator:Z
.line 55
new-instance v0, Lcom/android/systemui/statusbar/StatusBarView$1;
invoke-direct {v0, p0}, Lcom/android/systemui/statusbar/StatusBarView$1;-><init>(Lcom/android/systemui/statusbar/StatusBarView;)V
iput-object v0, p0, Lcom/android/systemui/statusbar/StatusBarView;->mIntentReceiver:Landroid/content/BroadcastReceiver;
const v0, 0x1e
iput v0, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryLowLevel:I
.line 49
const/4 v0, 0x1
iput v0, p0, Lcom/android/systemui/statusbar/StatusBarView;->mStatusBarMarqueeDirection:I
.line 50
const/4 v0, 0x0
iput v0, p0, Lcom/android/systemui/statusbar/StatusBarView;->mStatusBarMarqueeRange:I
.line 57
return-void
.end method
Please note on the code above this line: const v0, 0x1e, 0x1e = 30, i set the lowbattery threshold to 30% which means that from this point, the battery charging indicator png will be used! Change it as you like!
Now we need to register our receiver for "Screen On" and "Screen Off" intents.
Find the following method
Code:
.method protected onAttachedToWindow()V
Replace with the following:
Code:
.method protected onAttachedToWindow()V
.locals 5
.prologue
.line 76
invoke-super {p0}, Landroid/widget/FrameLayout;->onAttachedToWindow()V
.line 77
iget-object v0, p0, Lcom/android/systemui/statusbar/StatusBarView;->mService:Lcom/android/systemui/statusbar/StatusBarService;
invoke-virtual {v0}, Lcom/android/systemui/statusbar/StatusBarService;->onBarViewAttached()V
.line 110
new-instance v0, Landroid/content/IntentFilter;
invoke-direct {v0}, Landroid/content/IntentFilter;-><init>()V
.line 111
.local v0, filter:Landroid/content/IntentFilter;
const-string v1, "android.intent.action.SCREEN_OFF"
invoke-virtual {v0, v1}, Landroid/content/IntentFilter;->addAction(Ljava/lang/String;)V
.line 112
const-string v1, "android.intent.action.SCREEN_ON"
invoke-virtual {v0, v1}, Landroid/content/IntentFilter;->addAction(Ljava/lang/String;)V
.line 113
iget-object v1, p0, Lcom/android/systemui/statusbar/StatusBarView;->mContext:Landroid/content/Context;
iget-object v2, p0, Lcom/android/systemui/statusbar/StatusBarView;->mIntentReceiver:Landroid/content/BroadcastReceiver;
const/4 v3, 0x0
new-instance v4, Landroid/os/Handler;
invoke-direct {v4}, Landroid/os/Handler;-><init>()V
invoke-virtual {v1, v2, v0, v3, v4}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;Ljava/lang/String;Landroid/os/Handler;)Landroid/content/Intent;
return-void
.end method
At this point we need to add a method that take care of unregister our broadcast receiver. Add the following method where you prefer.
Code:
.method protected onDetachedFromWindow()V
.locals 2
.prologue
.line 127
invoke-super {p0}, Landroid/widget/FrameLayout;->onDetachedFromWindow()V
.line 128
iget-object v0, p0, Lcom/android/systemui/statusbar/StatusBarView;->mContext:Landroid/content/Context;
iget-object v1, p0, Lcom/android/systemui/statusbar/StatusBarView;->mIntentReceiver:Landroid/content/BroadcastReceiver;
invoke-virtual {v0, v1}, Landroid/content/Context;->unregisterReceiver(Landroid/content/BroadcastReceiver;)V
.line 130
return-void
.end method
Let's add a new method responsible for clipping our battery indicator png image based on the current value of mBatteryIndicatorWidth field (i.e the current level)
Code:
.method public onDraw(Landroid/graphics/Canvas;)V
.locals 4
.parameter "canvas"
.prologue
.line 224
iget-boolean v0, p0, Lcom/android/systemui/statusbar/StatusBarView;->mShowBatteryIndicator:Z
if-eqz v0, :cond_0
.line 225
invoke-virtual {p1}, Landroid/graphics/Canvas;->save()I
.line 226
iget-object v0, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicator:Landroid/widget/ImageView;
invoke-virtual {v0}, Landroid/widget/ImageView;->getLeft()I
move-result v0
iget-object v1, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicator:Landroid/widget/ImageView;
invoke-virtual {v1}, Landroid/widget/ImageView;->getTop()I
move-result v1
iget v2, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicatorWidth:I
iget-object v3, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicator:Landroid/widget/ImageView;
invoke-virtual {v3}, Landroid/widget/ImageView;->getBottom()I
move-result v3
invoke-virtual {p1, v0, v1, v2, v3}, Landroid/graphics/Canvas;->clipRect(IIII)Z
.line 231
iget-object v0, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicator:Landroid/widget/ImageView;
invoke-virtual {v0, p1}, Landroid/widget/ImageView;->draw(Landroid/graphics/Canvas;)V
.line 232
invoke-virtual {p1}, Landroid/graphics/Canvas;->restore()V
.line 234
:cond_0
invoke-super {p0, p1}, Landroid/widget/FrameLayout;->onDraw(Landroid/graphics/Canvas;)V
.line 235
return-void
.end method
4.1 Create a new smali file: StatusBarView$1.smali
Copy the following code in your file, and save it in smali/com/android/systemui/statusbar/
Code:
.method constructor <init>(Lcom/android/systemui/statusbar/StatusBarView;)V
.locals 0
.parameter
.prologue
.line 60
iput-object p1, p0, Lcom/android/systemui/statusbar/StatusBarView$1;->this$0:Lcom/android/systemui/statusbar/StatusBarView;
invoke-direct {p0}, Landroid/content/BroadcastReceiver;-><init>()V
return-void
.end method
# virtual methods
.method public onReceive(Landroid/content/Context;Landroid/content/Intent;)V
.locals 3
.parameter "context"
.parameter "intent"
.prologue
.line 63
iget-object v0, p0, Lcom/android/systemui/statusbar/StatusBarView$1;->this$0:Lcom/android/systemui/statusbar/StatusBarView;
const-string v1, "android.intent.action.SCREEN_ON"
invoke-virtual {p2}, Landroid/content/Intent;->getAction()Ljava/lang/String;
move-result-object v2
invoke-virtual {v1, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v1
iput-boolean v1, v0, Lcom/android/systemui/statusbar/StatusBarView;->mScreenIsOn:Z
.line 64
iget-object v0, p0, Lcom/android/systemui/statusbar/StatusBarView$1;->this$0:Lcom/android/systemui/statusbar/StatusBarView;
invoke-virtual {v0}, Lcom/android/systemui/statusbar/StatusBarView;->requestLayout()V
.line 65
iget-object v0, p0, Lcom/android/systemui/statusbar/StatusBarView$1;->this$0:Lcom/android/systemui/statusbar/StatusBarView;
invoke-virtual {v0}, Lcom/android/systemui/statusbar/StatusBarView;->invalidate()V
.line 66
return-void
.end method
Now replace the methods: "onAttachedToWindow" with the code below:
Code:
.method protected onAttachedToWindow()V
.locals 5
.prologue
.line 76
invoke-super {p0}, Landroid/widget/FrameLayout;->onAttachedToWindow()V
.line 77
iget-object v0, p0, Lcom/android/systemui/statusbar/StatusBarView;->mService:Lcom/android/systemui/statusbar/StatusBarService;
invoke-virtual {v0}, Lcom/android/systemui/statusbar/StatusBarService;->onBarViewAttached()V
.line 110
new-instance v0, Landroid/content/IntentFilter;
invoke-direct {v0}, Landroid/content/IntentFilter;-><init>()V
.line 111
.local v0, filter:Landroid/content/IntentFilter;
const-string v1, "android.intent.action.SCREEN_OFF"
invoke-virtual {v0, v1}, Landroid/content/IntentFilter;->addAction(Ljava/lang/String;)V
.line 112
const-string v1, "android.intent.action.SCREEN_ON"
invoke-virtual {v0, v1}, Landroid/content/IntentFilter;->addAction(Ljava/lang/String;)V
.line 113
iget-object v1, p0, Lcom/android/systemui/statusbar/StatusBarView;->mContext:Landroid/content/Context;
iget-object v2, p0, Lcom/android/systemui/statusbar/StatusBarView;->mIntentReceiver:Landroid/content/BroadcastReceiver;
const/4 v3, 0x0
new-instance v4, Landroid/os/Handler;
invoke-direct {v4}, Landroid/os/Handler;-><init>()V
invoke-virtual {v1, v2, v0, v3, v4}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;Ljava/lang/String;Landroid/os/Handler;)Landroid/content/Intent;
return-void
.end method
Almost finished , now we need to modify the method "onLayout":
search for this line: return-void and replace with goto :goto_3 then add the following code just belowe this line: goto :goto_0
Code:
:goto_3
const/4 v4, 0x0
iget-boolean v3, p0, Lcom/android/systemui/statusbar/StatusBarView;->mShowBatteryIndicator:Z
if-eqz v3, :cond_3
iget-object v3, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicator:Landroid/widget/ImageView;
invoke-virtual {v3, v4}, Landroid/widget/ImageView;->setVisibility(I)V
iget-object v3, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicatorCharging:Landroid/widget/ImageView;
invoke-virtual {v3, v4}, Landroid/widget/ImageView;->setVisibility(I)V
iget-object v3, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicator:Landroid/widget/ImageView;
invoke-virtual {v3}, Landroid/widget/ImageView;->getTag()Ljava/lang/Object;
move-result-object v3
check-cast v3, Ljava/lang/Integer;
invoke-virtual {v3}, Ljava/lang/Integer;->intValue()I
move-result v2
.local v2, batteryLevel:I
sub-int v3, p4, p2
mul-int/2addr v3, v2
div-int/lit8 v3, v3, 0x64
iput v3, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicatorWidth:I
iget-object v3, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicatorCharging:Landroid/widget/ImageView;
iget-object v4, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicatorCharging:Landroid/widget/ImageView;
invoke-virtual {v4}, Landroid/widget/ImageView;->getMeasuredWidth()I
move-result v4
add-int/2addr v4, p4
iget-object v5, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicatorCharging:Landroid/widget/ImageView;
invoke-virtual {v5}, Landroid/widget/ImageView;->getMeasuredHeight()I
move-result v5
add-int/2addr v5, p3
invoke-virtual {v3, p4, p3, v4, v5}, Landroid/widget/ImageView;->layout(IIII)V
const v1, 0x7f0200b8
.local v1, batteryIndicatorDrawableId:I
iget-boolean v3, p0, Lcom/android/systemui/statusbar/StatusBarView;->mScreenIsOn:Z
if-eqz v3, :cond_4
const v4, 0x10802c3
iget-object v3, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicatorCharging:Landroid/widget/ImageView;
invoke-virtual {v3}, Landroid/widget/ImageView;->getTag()Ljava/lang/Object;
move-result-object v3
check-cast v3, Ljava/lang/Integer;
invoke-virtual {v3}, Ljava/lang/Integer;->intValue()I
move-result v3
if-eq v4, v3, :cond_4
new-instance v0, Landroid/view/animation/TranslateAnimation;
iget v3, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicatorWidth:I
sub-int v4, p4, p2
sub-int/2addr v3, v4
int-to-float v3, v3
invoke-direct {v0, v6, v3, v6, v6}, Landroid/view/animation/TranslateAnimation;-><init>(FFFF)V
.local v0, animation:Landroid/view/animation/TranslateAnimation;
const-wide/16 v3, 0x5dc
invoke-virtual {v0, v3, v4}, Landroid/view/animation/TranslateAnimation;->setDuration(J)V
const-wide/16 v3, 0xdac
invoke-virtual {v0, v3, v4}, Landroid/view/animation/TranslateAnimation;->setStartOffset(J)V
const/4 v3, -0x1
invoke-virtual {v0, v3}, Landroid/view/animation/TranslateAnimation;->setRepeatCount(I)V
const/4 v3, 0x1
invoke-virtual {v0, v3}, Landroid/view/animation/TranslateAnimation;->setRepeatMode(I)V
iget-object v3, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicatorCharging:Landroid/widget/ImageView;
invoke-virtual {v3, v0}, Landroid/widget/ImageView;->startAnimation(Landroid/view/animation/Animation;)V
.end local v0 #animation:Landroid/view/animation/TranslateAnimation;
:cond_5
:goto_2
iget-object v3, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicator:Landroid/widget/ImageView;
invoke-virtual {v3, v1}, Landroid/widget/ImageView;->setImageResource(I)V
iget-object v3, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicator:Landroid/widget/ImageView;
iget-object v4, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicator:Landroid/widget/ImageView;
invoke-virtual {v4}, Landroid/widget/ImageView;->getDrawable()Landroid/graphics/drawable/Drawable;
move-result-object v4
invoke-virtual {v4}, Landroid/graphics/drawable/Drawable;->getIntrinsicHeight()I
move-result v4
add-int/2addr v4, p3
invoke-virtual {v3, p2, p3, p4, v4}, Landroid/widget/ImageView;->layout(IIII)V
.end local v1 #batteryIndicatorDrawableId:I
.end local v2 #batteryLevel:I
:goto_1
return-void
.restart local v1 #batteryIndicatorDrawableId:I
.restart local v2 #batteryLevel:I
:cond_4
iget-object v3, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicatorCharging:Landroid/widget/ImageView;
invoke-virtual {v3}, Landroid/widget/ImageView;->clearAnimation()V
iget v3, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryLowLevel:I
if-ge v2, v3, :cond_5
const v1, 0x7f0200ba
goto :goto_2
.end local v1 #batteryIndicatorDrawableId:I
.end local v2 #batteryLevel:I
:cond_3
const/16 v5, 0x8
iget-object v3, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicator:Landroid/widget/ImageView;
invoke-virtual {v3, v5}, Landroid/widget/ImageView;->setVisibility(I)V
iget-object v3, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicatorCharging:Landroid/widget/ImageView;
invoke-virtual {v3, v5}, Landroid/widget/ImageView;->setVisibility(I)V
iget-object v3, p0, Lcom/android/systemui/statusbar/StatusBarView;->mBatteryIndicatorCharging:Landroid/widget/ImageView;
invoke-virtual {v3}, Landroid/widget/ImageView;->clearAnimation()V
goto :goto_1
.end method
Finally, we need to adjust values to match our Ref ID (drawable images and battery_indicator ID)
chargeIconID in my pseudo code is used to verify if the phone is charging, in my attached source code you will see the line below
The following value (inside onLayout method) is used to verify if the phone is charging.
const v6, 0x10802c3
Decompile framework-res.apk and open /res/values/public.xml, search for this string: name="stat_sys_battery_charge"
Code:
<public type="drawable" name="stat_sys_battery_charge" id="0x10802c3" />
Make sure that the id you are using match with that value!
Now we need to take care about one ID used by onFinishInflate method:
const v1, 0x7f0a0034
need to match with our ID in res/values/public.xml
<public type="id" name="battery_indicator_charging" id="0x7f0a0034" />
The same for the method onLayout but this time we need to take care about 2 IDs:
const v1, 0x7f0200b8
<public type="drawable" name="z_battery_indicator" id="0x7f0200b8" />
const v1, 0x7f0200ba
<public type="drawable" name="z_battery_indicator_low" id="0x7f0200ba" />
Hope this helps you guys!
nice! thank you
Good work Leo.
I will try to port it to ICS .
nice work, but who is SanX and what has he cracked? lol
Congratulations for this very detailed howto! Just a thought: MIUI has this by default, you'll most probably take less time flashing MIUI than applying these mods!
thunderteaser said:
Congratulations for this very detailed howto! Just a thought: MIUI has this by default, you'll most probably take less time flashing MIUI than applying these mods!
Click to expand...
Click to collapse
It's for the devs, not regular users
I've been using the application onibar which does this really well as its an overlay.
Sent from my GT-I9100 using xda premium
Are there any advantages compared to this?
xethor said:
Are there any advantages compared to this?
Click to expand...
Click to collapse
Well if you go with the OP approach then you don't need the app. From an end user the app you linked to is fine. For devs however this can be integrated and forgo the need for the app altogether.
Tomorrow i will update this tutorial as i have made another mod that uses png for battery line indicator, it's much better since themer can change color, trasparency,..
xethor said:
Are there any advantages compared to this?
Click to expand...
Click to collapse
Yes, that applications start a background service that poll battery info, it will drain your battery..
Also this application doesn't animate the battery indicator while charging.
The mod i post instead is built in on the systemUI statusbar service!
In addition, with this mod (it will be updated tomorrow) it is also possible to change png for battery line indicator, not just the color as the app you mentioned!
Hey Leo, will this be implemented in CheckROM RevoHD™ V4 and future versions?Or at least given as a MOD in the kitchen?
Hollow.Droid said:
It's for the devs, not regular users
Click to expand...
Click to collapse
But it's so well written and clear! I guess a user could do this, that's why I'm talking just about time.
Hi Leo !
Will you make it as a script and we just need to flash it ?
Pleaseeeee...
joezy07 said:
Hi Leo !
Will you make it as a script and we just need to flash it ?
Pleaseeeee...
Click to expand...
Click to collapse
Yes please in ICS blue too!!!!!!!!!!!!!!!!!!!!!!
sorry. i just flashd Intratech's Frankenstein LA4. it has the top battery line indicator. did he already implement this.?
what is the diff from this ?
what is different from this Leo? thanks
mariosraptor said:
what is different from this Leo? thanks
Click to expand...
Click to collapse
see the post a few ones back... it drains the battery more... and also the charging is not animated in the market app
Yes, that applications start a background service that poll battery info, it will drain your battery..
Also this application doesn't animate the battery indicator while charging.
The mod i post instead is built in on the systemUI statusbar service!
In addition, with this mod (it will be updated tomorrow) it is also possible to change png for battery line indicator, not just the color as the app you mentioned!
Click to expand...
Click to collapse
seriously awesome....
I have updated the OP, now this mod uses png images, it's much better since themers can change the aspect of these bars without any effort.

[MOD][GUIDE] Lockscreen torch

I built this guide for the VW GS3 but I have to assume its extremely close for the Sprint varient as well.
The lockscreen torch will allow you to quickly turn on your flashlight from the lockscreen. Simply hold the home button in for torch, let it go and it will turn off. It is meant to function this way so you dont accidentally turn it on in your pocket or something and forget about it. Not sure who originally wrote the MOD but I have spent some time re-writing it to fit the GS3 based on a dozen or so other tutorials.
After reboot, it will take about 20 seconds before the MOD will engage. Then it will work at will as long as you are on the lockscreen.
I will include the three files that are being modified in the zip below so you can use them in your compare tool.
DEVs if you want to use this in your ROM feel free, just shoot me some credit and some thanks!
Hit the Thanks Button!
Here is the guide.....
First you will need to download the torch file below and drop it in /system/app. This will be in the zip file with the smali files.
We will be working with three smali files inside of android.policy.jar.
Navigate to smali/com/android/internal/policy/impl/KeyguardViewMediator$2.smali
Find the following code and add the part in RED
Code:
packed-switch v2, :pswitch_data_0
.line 1172
:goto_0
[COLOR="Red"][B] :pswitch_0
[/B][/COLOR] return-void
Find the 13 : pswitch_ lines and increase them by 1. For example
Code:
:pswitch_0 becomes :pswitch_1
:pswitch_1 becomes :pswitch_2
:pswitch_2 becomes :pswitch_3
:pswitch_3 becomes :pswitch_4
:pswitch_4 becomes :pswitch_5
:pswitch_5 becomes :pswitch_6
:pswitch_6 becomes :pswitch_7
:pswitch_7 becomes :pswitch_8
:pswitch_8 becomes :pswitch_9
:pswitch_9 becomes :pswitch_a
:pswitch_a becomes :pswitch_b
:pswitch_b becomes :pswitch_c
:pswitch_c becomes :pswitch_d
Find the following code
Code:
invoke-static {v0}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->access$300(Lcom/android/internal/policy/impl/KeyguardViewMediator;)V
.line 1169
monitor-exit v1
goto :goto_0
Add the following directly after
Code:
.line 974
:pswitch_e
iget-object v2, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator$2;->this$0:Lcom/android/internal/policy/impl/KeyguardViewMediator;
iget v3, p1, Landroid/os/Message;->arg1:I
if-eqz v3, :cond_2
move v3, v0
:goto_3
#calls: Lcom/android/internal/policy/impl/KeyguardViewMediator;->handleSetTorch(Z)V
invoke-static {v2, v3}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->access$1900(Lcom/android/internal/policy/impl/KeyguardViewMediator;Z)V
goto :goto_0
:cond_2
move v3, v1
goto :goto_3
Find the "nop' at the end and add another one right below it
Code:
throw v0
.line 1129
nop
nop
Find the stack of : pswitch_ lines at the end of the smali and delete : pswitch_0
Then add the following so the entire stack will end up looking like this
Code:
.packed-switch 0x1
:pswitch_1
:pswitch_2
:pswitch_3
:pswitch_4
:pswitch_5
:pswitch_6
:pswitch_7
:pswitch_8
:pswitch_9
:pswitch_a
:pswitch_b
:pswitch_c
:pswitch_d
:pswitch_0
:pswitch_0
:pswitch_0
:pswitch_0
:pswitch_0
:pswitch_0
:pswitch_e
.end packed-switch
.end method
Thats it for KeyguardViewMediator$2.smali. Save and close the file.
Navigate to smali/com/android/internal/policy/impl/KeyguardViewMediator.smali
Find the following code
Code:
.field private static final SET_HIDDEN:I = 0xc
Add this right after
Code:
[hide]
.field private static final SET_TORCH:I = 0x14
Find the following code
Code:
.field private mTelephonyManager:Landroid/telephony/TelephonyManager;
Add this right after
Code:
.field private mTorchEnabled:Z
.field private mTorchStateChanged:Z
Find the following code
Code:
const/4 v10, 0x0
const/4 v9, 0x1
.line 301
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
Add this after
Code:
iput-boolean v9, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchEnabled:Z
Find the following code
Code:
iput-object v0, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mHandler:Landroid/os/Handler;
.line 302
iput-object p1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mContext:Landroid/content/Context;
.line 304
iput-object p3, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mRealPowerManager:Landroid/os/LocalPowerManager;
Add this after
Code:
iput-boolean v10, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchEnabled:Z
.line 1188
iput-boolean v10, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchStateChanged:Z
Find this method
Code:
.method static synthetic access$200(Lcom/android/internal/policy/impl/KeyguardViewMediator;)V
Add this entire NEW method RIGHT BEFORE it.
Code:
.method static synthetic access$1900(Lcom/android/internal/policy/impl/KeyguardViewMediator;Z)V
.locals 0
.parameter "x0"
.parameter "x1"
.prologue
invoke-direct {p0, p1}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->handleSetTorch(Z)V
return-void
.end method
Find the following code
Code:
const/4 v0, 0x1
invoke-direct {p0, v0}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->adjustLocked(Z)V
.line 1315
monitor-exit p0
Add this right after
Code:
invoke-direct {p0}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->resetTorchState()V
Find the following code
Code:
.line 1496
iget-object v0, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mKeyguardViewManager:Lcom/android/internal/policy/impl/KeyguardViewManager;
invoke-virtual {v0}, Lcom/android/internal/policy/impl/KeyguardViewManager;->onScreenTurnedOff()V
.line 1497
monitor-exit p0
Add this directly after
Code:
invoke-direct {p0}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->resetTorchState()V
Find the following code
Code:
iput-boolean p1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mHidden:Z
.line 611
invoke-direct {p0}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->adjustUserActivityLocked()V
.line 612
invoke-direct {p0}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->adjustStatusBarLocked()V
Add this directly after
Code:
invoke-direct {p0}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->resetTorchState()V
Find the following code
Code:
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
throw v0
.end method
Add this ENTIRE NEW METHOD directly after
Code:
.method private handleSetTorch(Z)V
.locals 6
.parameter "enable"
.prologue
const/4 v5, 0x0
const/4 v4, 0x1
.line 504
:try_start_0
iget-boolean v1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchStateChanged:Z
if-nez v1, :cond_1
.line 505
iput-boolean v1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchEnabled:Z
.line 506
const/4 v1, 0x1
iput-boolean v1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchStateChanged:Z
.line 515
:cond_0
:goto_0
return-void
.line 507
:cond_1
iget-boolean v1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchEnabled:Z
if-eq v1, p1, :cond_0
.line 508
iput-boolean p1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchEnabled:Z
.line 509
new-instance v0, Landroid/content/Intent;
const-string v1, "net.cactii.flash2.TOGGLE_FLASHLIGHT"
invoke-direct {v0, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V
.line 510
.local v0, intent:Landroid/content/Intent;
const-string v1, "net.cactii.flash2.EXTRA_DISABLE_NOTIFICATION"
const/4 v2, 0x1
invoke-virtual {v0, v1, v2}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Z)Landroid/content/Intent;
.line 511
iget-object v1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mContext:Landroid/content/Context;
invoke-virtual {v1, v0}, Landroid/content/Context;->sendBroadcast(Landroid/content/Intent;)V
:try_end_0
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
goto :goto_0
.line 514
.end local v0 #intent:Landroid/content/Intent;
:catch_0
move-exception v1
goto :goto_0
.end method
Find the following code
Code:
:goto_1
:try_start_2
iget-object v0, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mShowKeyguardWakeLock:Landroid/os/PowerManager$WakeLock;
invoke-virtual {v0}, Landroid/os/PowerManager$WakeLock;->release()V
Add the following after
Code:
.line 995
const/4 v0, 0x1
iput-boolean v0, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchStateChanged:Z
Find the following code
Code:
iget-object v1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mHandler:Landroid/os/Handler;
invoke-virtual {v1, v0}, Landroid/os/Handler;->sendMessage(Landroid/os/Message;)Z
.line 752
return-void
.end method
Add this ENTIRE NEW METHOD after
Code:
.method private resetTorchState()V
.locals 1
.prologue
.line 1193
iget-boolean v0, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchStateChanged:Z
if-eqz v0, :cond_0
.line 1194
const/4 v0, 0x0
invoke-direct {p0, v0}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->handleSetTorch(Z)V
.line 1196
:cond_0
return-void
.end method
Find the following code
Code:
:try_end_3
.catchall {:try_start_3 .. :try_end_3} :catchall_0
goto :goto_1
.end method
Add this ENTIRE NEW METHOD after
Code:
.method public setTorch(Z)V
.locals 5
.parameter "enable"
.prologue
const/16 v4, 0x14
const/4 v3, 0x0
.line 1155
iget-boolean v1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mScreenOn:Z
if-eqz v1, :cond_0
.line 1157
iget-object v1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mHandler:Landroid/os/Handler;
invoke-virtual {v1, v4}, Landroid/os/Handler;->removeMessages(I)V
.line 1158
iget-object v1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mHandler:Landroid/os/Handler;
if-eqz p1, :cond_1
const/4 v2, 0x1
:goto_0
invoke-virtual {v1, v4, v2, v3}, Landroid/os/Handler;->obtainMessage(III)Landroid/os/Message;
move-result-object v0
.line 1159
.local v0, msg:Landroid/os/Message;
iget-object v1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mHandler:Landroid/os/Handler;
invoke-virtual {v1, v0}, Landroid/os/Handler;->sendMessage(Landroid/os/Message;)Z
.line 1161
.end local v0 #msg:Landroid/os/Message;
:cond_0
return-void
:cond_1
move v2, v3
.line 1158
goto :goto_0
.end method
Thats it for KeyguardViewMediator.smali. Save the file and close.
Navigate to smali/com/android/internal/policy/impl/PhoneWindowManager.smali
Find the following code
Code:
const/16 v41, 0x3
move/from16 v0, v22
move/from16 v1, v41
Change the next line to the following
Code:
if-ne v0, v1, :cond_2b
Find the following code
Code:
invoke-static/range {v41 .. v42}, Landroid/util/safelog/Log;->i(Ljava/lang/String;Ljava/lang/String;)I
goto :goto_a
:cond_20
Change the next line to the following
Code:
if-eqz v4, :cond_26
Find the following code
Code:
const/16 v41, 0x7d9
move/from16 v0, v38
move/from16 v1, v41
Change the next line to the following
Code:
if-ne v0, v1, :cond_23
Directly after that last change in code, add the following
Code:
:cond_21
move-object/from16 v0, p0
iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mKeyguardMediator:Lcom/android/internal/policy/impl/KeyguardViewMediator;
move-object/from16 v41, v0
invoke-virtual/range {v41 .. v41}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->isShowingAndNotHidden()Z
move-result v41
if-eqz v41, :cond_22
.line 1275
move-object/from16 v0, p0
iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mKeyguardMediator:Lcom/android/internal/policy/impl/KeyguardViewMediator;
move-object/from16 v41, v0
move-object/from16 v0, v41
move v1, v8
invoke-virtual {v0, v1}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->setTorch(Z)V
.line 1276
rem-int/lit8 v41, v31, 0xf
if-nez v41, :cond_22
.line 1277
move-object/from16 v0, p0
iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mKeyguardMediator:Lcom/android/internal/policy/impl/KeyguardViewMediator;
move-object/from16 v41, v0
invoke-virtual/range {v41 .. v41}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->pokeWakelock()V
:cond_22
Here is a sort of tricky part. Starting right after the above code change you need to comb the rest of this entire method for all references to ":cond_X" and increment them by one. THERE ARE A LOT! Take your time and find them all. For example
Code:
:cond_23 becomes :cond_24
:cond_29 becomes :cond_2a
:cond_3f becomes :cond_40
....etc. MAKE SURE YOU FIND THEM ALL! The last one you change should be :cond_47.
[/hide]
Thats it. Save all fines, recompile and push to /system/framework.
Enjoy and hit the Thanks Button!
So many smilies...
Sent from my SPH-L710 running FreeGS3 v1.0.0 Jellybean
Can I flash this on the leaked jelly bean touch wiz?
Humzaman said:
So many smilies...
Sent from my SPH-L710 running FreeGS3 v1.0.0 Jellybean
Click to expand...
Click to collapse
Turn off the code in your settings or just know that the smilies are semicolons followed by a lower case P.
Tornadobarrage said:
Can I flash this on the leaked jelly bean touch wiz?
Click to expand...
Click to collapse
This is not a flashable zip. It's just the files needed to compare and build the mod. It will work with JB and modifying the code I have attached a little.
Hope to see this on all roms soon... I love this feature on MIUI and would love to see it on TW
Maybe we could even get it like MIUI to where as if you press the power button with the light on it will stay on
I agree, that is the most missed mod of MIUI for me... Just so convenient to have such easy access to the flashlight!
I'd love this on Fre3 2.2.
Sent from my SPH-L710 using xda premium
Yo Didact, just wondering... do you play Halo? Or read the books?
_____________________________________________________
Sent from my SPH-L710 running FreeGS3 v1.0.0
"Wake me... when you need me." -Master Chief John 117
This is probably a noob question, but I am trying to use your guide for the Samsung Note II and the android.policy.jar does not contain the smali files. I cannot find the smali files anywhere as a matter of fact. Also to push them back to framework, do I just copy them via recovery using the updater-script or do they get injected into the jar file?
PS: I opened the android.policy.jar with winrar
Humzaman said:
Yo Didact, just wondering... do you play Halo? Or read the books?
_____________________________________________________
Sent from my SPH-L710 running FreeGS3 v1.0.0
"Wake me... when you need me." -Master Chief John 117
Click to expand...
Click to collapse
I do..
Sent from my SPH-L710 using xda premium
---------- Post added at 07:44 PM ---------- Previous post was at 07:41 PM ----------
Humzaman said:
Yo Didact, just wondering... do you play Halo? Or read the books?
_____________________________________________________
Sent from my SPH-L710 running FreeGS3 v1.0.0
"Wake me... when you need me." -Master Chief John 117
Click to expand...
Click to collapse
I just beat the campaign legendary solo with 5 skulls
Sent from my SPH-L710 using xda premium
I got the file deodexed, but now stuck at "Save all fines, recompile and push to /system/framework." How do I "push it"? Is it via ADB? Do I need to create a new dex file?
OK, so I got the smali files extracted. When I merge them with the android.policy.jar from note II, i get the optimizing apps screen followed by a reboot. I suspect the smali files in your ZIP may be specific to GS3.
Question: If I follow the guide to make the changes to the smali files directly from the Note II's android.policy.jar instead of using your files to merge, should that work or are these changes specific to the GS3?
Thanks!
geekasso said:
OK, so I got the smali files extracted. When I merge them with the android.policy.jar from note II, i get the optimizing apps screen followed by a reboot. I suspect the smali files in your ZIP may be specific to GS3.
Question: If I follow the guide to make the changes to the smali files directly from the Note II's android.policy.jar instead of using your files to merge, should that work or are these changes specific to the GS3?
Thanks!
Click to expand...
Click to collapse
You can not just make the changes as is directly to the Note or merge it. You can follow the guide to port it to your device but the registers are not the same e.g. iput-boolean v10, p0, could be iput-boolean v7, p0, on your device. Assuming you already know that and how to fix it and are on TW Jellybean this guide should help you port. :good:
I've been looking EVERYWHERE for this great feature...Does anyone know if this would work on the Galaxy Note II (AT&T)?
Thank you
Thanks Didact74, you are the man! I'm definitely adding this to my rom.
metalfan78 said:
Thanks Didact74, you are the man! I'm definitely adding this to my rom.
Click to expand...
Click to collapse
I just started this mod and on the sprint gs3 the first step is in KeyguardViewMediator$4. I will keep working on this, but I wont have much time today, just thought some people would like to know.
After getting into this a little it's way above my head. There are too many differences between Verizon and Sprint. I get a little lost. Lol
metalfan78 said:
After getting into this a little it's way above my head. There are too many differences between Verizon and Sprint. I get a little lost. Lol
Click to expand...
Click to collapse
Didact made an updated one for MD4...that's what MOAR is using
Maybe ask either rompnit or didact74 if they can share/explain how it was added
Thanks CNexus. Hey Didact74, do you think you can hook me up with the changes for MD4? I'd like to diff what I have so I can learn a little more about what I'm doing. Thanks.
It might help if you call them like this
@rompnit @Didact74

[GUIDE][How-to] Music Skip Mod for JB

Music Skip Mod for JB
Credits to Mirko DDD in i9100 thread for the original guide for this.
Android.policy.jar changes
Add attached files to:
com/android/internal/policy/impl/
Smali edit:
com/android/internal/policy/impl/PhoneWindowManager.smali
Before:
Code:
.field private mIsVisibleSPenGestureView:Z
.field mKeyboardTapVibePattern:[J
After:
Code:
.field private mIsVisibleSPenGestureView:Z
[COLOR="Red"].field mIsVolumeAction:Z
.field mIsVolumeBlocking:Z
[/COLOR]
.field mKeyboardTapVibePattern:[J
Before:
Code:
.field private mVolumeDownKeyTriggered:Z
.field private final mVolumeKeyLongPressforOneTouchReport:Ljava/lang/Runnable;
After:
Code:
.field private mVolumeDownKeyTriggered:Z
[COLOR="Red"].field mVolumeDownLongPress:Ljava/lang/Runnable;[/COLOR]
.field private final mVolumeKeyLongPressforOneTouchReport:Ljava/lang/Runnable;
Before:
[CODE .line 7619
new-instance v0, Lcom/android/internal/policy/impl/PhoneWindowManager$35;
invoke-direct {v0, p0}, Lcom/android/internal/policy/impl/PhoneWindowManager$35;-><init>(Lcom/android/internal/policy/impl/PhoneWindowManagerV
iput-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mScreenLockTimeout:Ljava/lang/Runnable;
.line 8566
return-void
.end method][/CODE]
After:
Code:
.line 7619
new-instance v0, Lcom/android/internal/policy/impl/PhoneWindowManager$35;
invoke-direct {v0, p0}, Lcom/android/internal/policy/impl/PhoneWindowManager$35;-><init>(Lcom/android/internal/policy/impl/PhoneWindowManager;)V
iput-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mScreenLockTimeout:Ljava/lang/Runnable;
[COLOR="Red"] .line 8130
new-instance v0, Lcom/android/internal/policy/impl/PhoneWindowManager$SkipNext;
invoke-direct {v0, p0}, Lcom/android/internal/policy/impl/PhoneWindowManager$SkipNext;-><init>(Lcom/android/internal/policy/impl/PhoneWindowManager;)V
iput-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mVolumeUpLongPress:Ljava/lang/Runnable;
.line 8131
new-instance v0, Lcom/android/internal/policy/impl/PhoneWindowManager$SkipPrev;
invoke-direct {v0, p0}, Lcom/android/internal/policy/impl/PhoneWindowManager$SkipPrev;-><init>(Lcom/android/internal/policy/impl/PhoneWindowManager;)V
iput-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mVolumeDownLongPress:Ljava/lang/Runnable;
[/COLOR]
.line 8566
return-void
.end method
Before:
Code:
.method handleVolumeKey(II)V
.registers 8
.parameter "stream"
.parameter "keycode"
.prologue
.line 5724
invoke-static {}, Lcom/android/internal/policy/impl/PhoneWindowManager;->getAudioService()Landroid/media/IAudioService;
move-result-object v0
.line 5725
.local v0, audioService:Landroid/media/IAudioService;
if-nez v0, :cond_7
.line 5750
:goto_0
return-void
After:
Code:
.method handleVolumeKey(II)V
.registers 8
.parameter "stream"
.parameter "keycode"
.prologue
.line 5724
[COLOR="Red"]move-object/from16 v0, p0
iget-boolean v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeBlocking:Z
if-nez v0, :cond_c[/COLOR]
invoke-static {}, Lcom/android/internal/policy/impl/PhoneWindowManager;->getAudioService()Landroid/media/IAudioService;
move-result-object v0
.line 5725
.local v0, audioService:Landroid/media/IAudioService;
if-nez v0, :cond_7
.line 5750
[COLOR="Red"]:cond_c[/COLOR]
:goto_0
return-void
New method. Insert right above:
.method public hasNavigationBar()Z
Code:
[COLOR="Red"].method handleVolumeLongPress(I)V
.registers 6
.parameter "keycode"
.prologue
const/4 v1, 0x1
move-object/from16 v0, p0
iput-boolean v1, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeBlocking:Z
const/4 v1, 0x0
iput-boolean v1, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeAction:Z
const/16 v1, 0x18
if-ne p1, v1, :cond_19
iget-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mVolumeUpLongPress:Ljava/lang/Runnable;
.local v0, btnHandler:Ljava/lang/Runnable;
:goto_e
iget-object v1, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mHandler:Landroid/os/Handler;
invoke-static {}, Landroid/view/ViewConfiguration;->getTapTimeout()I
move-result v2
int-to-long v2, v2
invoke-virtual {v1, v0, v2, v3}, Landroid/os/Handler;->postDelayed(Ljava/lang/Runnable;J)Z
return-void
.end local v0 #btnHandler:Ljava/lang/Runnable;
:cond_19
iget-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mVolumeDownLongPress:Ljava/lang/Runnable;
.restart local v0 #btnHandler:Ljava/lang/Runnable;
goto :goto_e
.end method
.method handleVolumeLongPressAbort()V
.registers 3
.prologue
const/4 v1, 0x0
move-object/from16 v0, p0
iput-boolean v1, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeBlocking:Z
iget-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mHandler:Landroid/os/Handler;
iget-object v1, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mVolumeUpLongPress:Ljava/lang/Runnable;
invoke-virtual {v0, v1}, Landroid/os/Handler;->removeCallbacks(Ljava/lang/Runnable;)V
iget-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mHandler:Landroid/os/Handler;
iget-object v1, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mVolumeDownLongPress:Ljava/lang/Runnable;
invoke-virtual {v0, v1}, Landroid/os/Handler;->removeCallbacks(Ljava/lang/Runnable;)V
return-void
.end method
[/COLOR]
.method public hasNavigationBar()Z
Before:
Code:
.line 6215
:cond_46b
:goto_46b
if-eqz v5, :cond_547
After:
Code:
.line 6215
:cond_46b
:goto_46b
[COLOR="Red"]if-eqz v5, :cond_55a[/COLOR]
Before:
Code:
.line 6297
.end local v6 #ex:Landroid/os/RemoteException;
:cond_514
move-object/from16 v0, p0
iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mSamsungVolumeControlThread:Lcom/android/internal/policy/impl/PhoneWindowManager$SamsungVolumeControlThread;
move-object/from16 v29, v0
if-nez v29, :cond_6a
After:
Code:
.line 6297
.end local v6 #ex:Landroid/os/RemoteException;
:cond_514
move-object/from16 v0, p0
[COLOR="Red"] iget-boolean v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mScreenOnEarly:Z
if-nez v0, :cond_new
invoke-virtual/range {p0 .. p0}, Lcom/android/internal/policy/impl/PhoneWindowManager;->isMusicActive()Z
move-result v26
if-eqz v26, :cond_new
move-object/from16 v0, p0
move/from16 v14, v18
invoke-virtual {v0, v14}, Lcom/android/internal/policy/impl/PhoneWindowManager;->handleVolumeLongPress(I)V
:cond_new
move-object/from16 v0, p0
[/COLOR]
iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mSamsungVolumeControlThread:Lcom/android/internal/policy/impl/PhoneWindowManager$SamsungVolumeControlThread;
move-object/from16 v29, v0
if-nez v29, :cond_6a
Before:
Code:
.line 6305
.end local v26 #telephonyService:Lcom/android/internal/telephony/ITelephony;
.end local v28 #voipInterfaceService:Landroid/os/IVoIPInterface;
:cond_547
move-object/from16 v0, p0
iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mSamsungVolumeControlThread:Lcom/android/internal/policy/impl/PhoneWindowManager$SamsungVolumeControlThread;
move-object/from16 v29, v0
if-eqz v29, :cond_6a
After:
Code:
.line 6305
.end local v26 #telephonyService:Lcom/android/internal/telephony/ITelephony;
.end local v28 #voipInterfaceService:Landroid/os/IVoIPInterface;
[COLOR="Red"]:cond_55a
[/COLOR] [COLOR="Red"]if-nez v5, :cond_ko
move-object/from16 v0, p0
iget-boolean v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeBlocking:Z
if-eqz v0, :cond_ko
invoke-virtual/range {p0 .. p0}, Lcom/android/internal/policy/impl/PhoneWindowManager;->handleVolumeLongPressAbort()V
move-object/from16 v0, p0
iget-boolean v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeAction:Z
if-nez v0, :cond_ko
move-object/from16 v0, p0
const/4 v3, 0x0
move/from16 v14, v18
invoke-virtual {v0, v3, v14}, Lcom/android/internal/policy/impl/PhoneWindowManager;->handleVolumeKey(II)V
:cond_ko[/COLOR]
move-object/from16 v0, p0
iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mSamsungVolumeControlThread:Lcom/android/internal/policy/impl/PhoneWindowManager$SamsungVolumeControlThread;
move-object/from16 v29, v0
if-eqz v29, :cond_6a
New method. Insert right above:
.method sendCloseSystemWindows(Ljava/lang/StringV
Code:
[COLOR="Red"].method protected sendMediaButtonEvent(I)V
.registers 15
.parameter "code"
.prologue
invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J
move-result-wide v1
.local v1, eventtime:J
new-instance v11, Landroid/content/Intent;
const-string v4, "android.intent.action.MEDIA_BUTTON"
const/4 v5, 0x0
invoke-direct {v11, v4, v5}, Landroid/content/Intent;-><init>(Ljava/lang/String;Landroid/net/Uri;)V
.local v11, downIntent:Landroid/content/Intent;
new-instance v0, Landroid/view/KeyEvent;
const/4 v5, 0x0
const/4 v7, 0x0
move-wide v3, v1
move v6, p1
invoke-direct/range {v0 .. v7}, Landroid/view/KeyEvent;-><init>(JJIII)V
.local v0, downEvent:Landroid/view/KeyEvent;
const-string v4, "android.intent.extra.KEY_EVENT"
invoke-virtual {v11, v4, v0}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Landroid/os/Parcelable;)Landroid/content/Intent;
iget-object v4, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mContext:Landroid/content/Context;
const/4 v5, 0x0
invoke-virtual {v4, v11, v5}, Landroid/content/Context;->sendOrderedBroadcast(Landroid/content/Intent;Ljava/lang/String;)V
new-instance v12, Landroid/content/Intent;
const-string v4, "android.intent.action.MEDIA_BUTTON"
const/4 v5, 0x0
invoke-direct {v12, v4, v5}, Landroid/content/Intent;-><init>(Ljava/lang/String;Landroid/net/Uri;)V
.local v12, upIntent:Landroid/content/Intent;
new-instance v3, Landroid/view/KeyEvent;
const/4 v8, 0x1
const/4 v10, 0x0
move-wide v4, v1
move-wide v6, v1
move v9, p1
invoke-direct/range {v3 .. v10}, Landroid/view/KeyEvent;-><init>(JJIII)V
.local v3, upEvent:Landroid/view/KeyEvent;
const-string v4, "android.intent.extra.KEY_EVENT"
invoke-virtual {v12, v4, v3}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Landroid/os/Parcelable;)Landroid/content/Intent;
iget-object v4, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mContext:Landroid/content/Context;
const/4 v5, 0x0
invoke-virtual {v4, v12, v5}, Landroid/content/Context;->sendOrderedBroadcast(Landroid/content/Intent;Ljava/lang/String;)V
const/4 v8, 0x1
move-object/from16 v9, p0
iput-boolean v8, v9, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeAction:Z
return-void
.end method[/COLOR]
.method sendCloseSystemWindows(Ljava/lang/String;)V
Wow. Is this volume rocker music skip?
I got a scrolling finger cramp.
Pp.
sent from a jellybean filled epic touch.
PanchoPlanet said:
Wow. Is this volume rocker music skip?
I got a scrolling finger cramp.
Pp.
sent from a jellybean filled epic touch.
Click to expand...
Click to collapse
Yes, it was a lot of fun to port over.
Sent from my SPH-D710 using xda premium
hey tdunham
I tried your mod on jds gb28 rom, and got this while recompiling the dex file
classout\com\android\internal\policy\impl\PhoneWindowManager$SkipNext.smali[27,4
] Error for input '.parameter': Invalid directive
classout\com\android\internal\policy\impl\PhoneWindowManager$SkipPrev.smali[27,4
] Error for input '.parameter': Invalid directive
classout\com\android\internal\policy\impl\PhoneWindowManager.smali[10932,4] Erro
r for input '.parameter': Invalid directive
classout\com\android\internal\policy\impl\PhoneWindowManager.smali[10932,15] mis
matched input '"keycode"' expecting END_METHOD_DIRECTIVE
classout\com\android\internal\policy\impl\PhoneWindowManager.smali[25318,4] Erro
r for input '.parameter': Invalid directive
classout\com\android\internal\policy\impl\PhoneWindowManager.smali[25318,15] mis
matched input '"code"' expecting END_METHOD_DIRECTIVE
I started tinkering with the .parameter command and switched it to .param p1, and fived the error for the error on (10932,4) error but ave me another regarding btnHanler being invaled.
any thoughts to help?
sickysticky said:
hey tdunham
I tried your mod on jds gb28 rom, and got this while recompiling the dex file
classout\com\android\internal\policy\impl\PhoneWindowManager$SkipNext.smali[27,4
] Error for input '.parameter': Invalid directive
classout\com\android\internal\policy\impl\PhoneWindowManager$SkipPrev.smali[27,4
] Error for input '.parameter': Invalid directive
classout\com\android\internal\policy\impl\PhoneWindowManager.smali[10932,4] Erro
r for input '.parameter': Invalid directive
classout\com\android\internal\policy\impl\PhoneWindowManager.smali[10932,15] mis
matched input '"keycode"' expecting END_METHOD_DIRECTIVE
classout\com\android\internal\policy\impl\PhoneWindowManager.smali[25318,4] Erro
r for input '.parameter': Invalid directive
classout\com\android\internal\policy\impl\PhoneWindowManager.smali[25318,15] mis
matched input '"code"' expecting END_METHOD_DIRECTIVE
I started tinkering with the .parameter command and switched it to .param p1, and fived the error for the error on (10932,4) error but ave me another regarding btnHanler being invaled.
any thoughts to help?
Click to expand...
Click to collapse
I think you didn't add all of the code in one of the sections as it scrolls past what is displayed and you have missing .end method for a section that is expecting it. Double check your work.
And you added the additional files posted at the bottom of post #1?
Also, in case you didn't know, only red code is new. I always add surrounding code as black text so it can be found and matched to existing sections.
hey there
now I double checked, and even re-input the process and still came up with the same errors while using smali. im pretty sure its is the .parameter command.
below is the code in the guide
.method handleVolumeKey(II)V
.registers 8
.parameter "stream"
.parameter "keycode"
and this is the code in the phonewindowmanager.smali
.method handelVolumeKey(II)V
.registers 8
.param p1, "stream" # I
.param p2, "keycode" # I
now down where the input for the code provided in the guide
.method handleVolumeLongPress(I)V
.registers 6
.parameter "keycode"
/|\
|_____this is line 10932, colum 4
so when I switched the code from .parameter "keycode" to .param p1, "keycode" the error is fixed but sends me to a new error a few lines down in the code that contains (.local v0, btnHandler:Ljava/lang/Runnable
so if there is any way to help can you let me know
sickysticky said:
hey there
now I double checked, and even re-input the process and still came up with the same errors while using smali. im pretty sure its is the .parameter command.
below is the code in the guide
so if there is any way to help can you let me know
Click to expand...
Click to collapse
It depends on what you are using to decompile. Some code will change I think.
Zip up 3 things and post them:
1. Stock android.policy.jar
2. decompiled android.policy.jar. stock without any changes
3. your modified decompiled android.policy.jar
Im currently using baksmali beta 2.0.
Ill zip it up n upload it to my dropbox once I get off work.
Sent from my SPH-D710VMUB using Tapatalk
ok ive zip up the android.policy.jar, the modified smali files and the stock smali files in the link below
https://www.dropbox.com/s/d9fdcwjnj3n1fdg/D710-GB28.zip
sickysticky said:
ok ive zip up the android.policy.jar, the modified smali files and the stock smali files in the link below
https://www.dropbox.com/s/d9fdcwjnj3n1fdg/D710-GB28.zip
Click to expand...
Click to collapse
Here is the modified file.
I think you should try using apktool or something else to compile and recompile. I don't see anything obviously wrong with the code but like I said, it is very different because of what you are using to decompile. Can you decompile and recompile the file without making any changes?
Edit: I've use baksmali also but haven't run into any issues with either ICS or JB. The only thing I can think of is maybe the version you're using. I also made a change to the code above as I was getting a minor error when compiling due to a different variable.
awesome thanks for this.
I think ill consider using vts to compile next time.
Sent from my SPH-D710VMUB using Tapatalk

[Guide][tut] Enable/Disable Navigation Bar Swipe to sleep/Lock

Hello guys
i had got you a new tut
Which is Swipe on nav bar to sleep/lock
Lets start work
All you need is Deodexed Systemui.apk, settings.apk and Good patience ( if you dont have any of these then just dont try this )
Ok
1. Decompile SystemUI.apk
2. Now download this View attachment SystemUI.zip and merge to your systemui.apk
3. Open com/android/systemui/statusbar/phone/NavigationBarView.smali
Look for this annotation
Code:
Lcom/android/systemui/statusbar/phone/NavigationBarView$OnVerticalChangedListener;,
Below that add this annotation
Code:
Lcom/android/systemui/statusbar/phone/NavigationBarView$SettingsObserver;,
Now look for
Code:
.field final mDisplay:Landroid/view/Display;
Below that add these definitions
Code:
.field private mDownTime:J
.field private mDownX:F
.field private mDownY:F
.field private mIsDown:Z
.field private mPowerManager:Landroid/os/PowerManager;
.field mSwipe2SleepActive:Z
Now look for this method ( this #1 post will have completely on this method only dont confuse )
Code:
.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
in that method first Change .locals 4 to .locals 6
after this
Code:
const/4 v3, 0x0
add this
Code:
const/4 v4, 0x1
look for this line
Code:
iput-object v1, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mImeSwitcherClickListener:Landroid/view/View$OnClickListener;
Below that add this
Code:
iput-boolean v2, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mIsDown:Z
Look for this line
Code:
iput-object v1, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mDisplay:Landroid/view/Display;
Below that add this
Code:
const-string v1, "power"
invoke-virtual {p1, v1}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;
move-result-object v1
check-cast v1, Landroid/os/PowerManager;
iput-object v1, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mPowerManager:Landroid/os/PowerManager;
Now look for this line
Code:
iput-object v1, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mTaskSwitchHelper:Lcom/android/systemui/statusbar/phone/NavigationBarViewTaskSwitchHelper;
Below that add this
Code:
invoke-direct {p0, v0}, Lcom/android/systemui/statusbar/phone/NavigationBarView;->getIcons(Landroid/content/res/Resources;)V
Now look for this line
Code:
invoke-direct {p0, v0}, Lcom/android/systemui/statusbar/phone/NavigationBarView;->getIcons(Landroid/content/res/Resources;)V
Replace the above line with this code
Code:
iget-object v1, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mContext:Landroid/content/Context;
invoke-virtual {v1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v1
const-string v3, "navbar_swipe_to_sleep"
invoke-static {v1, v3, v2}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
move-result v1
if-ne v1, v4, :cond_0
:goto_0
iput-boolean v4, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mSwipe2SleepActive:Z
.line 207
new-instance p1, Lcom/android/systemui/statusbar/phone/NavigationBarView$SettingsObserver;
iget-object v1, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mHandler:Lcom/android/systemui/statusbar/phone/NavigationBarView$H;
invoke-direct {p1, p0, v1}, Lcom/android/systemui/statusbar/phone/NavigationBarView$SettingsObserver;-><init>(Lcom/android/systemui/statusbar/phone/NavigationBarView;Landroid/os/Handler;)V
.line 208
.local p1, "settingsObserver":Lcom/android/systemui/statusbar/phone/NavigationBarView$SettingsObserver;
invoke-virtual {p1}, Lcom/android/systemui/statusbar/phone/NavigationBarView$SettingsObserver;->observe()V
Now in the same method you will find this return-void
Below that add this code
Code:
.end local p1 # "settingsObserver":Lcom/android/systemui/statusbar/phone/NavigationBarView$SettingsObserver;
:cond_0
move v4, v2
.line 205
goto :goto_0
save and Continued in 2nd and 3rd post
part 2
In the same file
4. continue
Look for this method
Code:
.method private adjustExtraKeyGravity(Landroid/view/View;Z)V
Above that method
add these methods
Code:
.method static synthetic access$200(Lcom/android/systemui/statusbar/phone/NavigationBarView;)Landroid/content/Context;
.locals 1
.param p0, "x0" # Lcom/android/systemui/statusbar/phone/NavigationBarView;
.prologue
.line 64
iget-object v0, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mContext:Landroid/content/Context;
return-object v0
.end method
.method static synthetic access$300(Lcom/android/systemui/statusbar/phone/NavigationBarView;)Landroid/content/Context;
.locals 1
.param p0, "x0" # Lcom/android/systemui/statusbar/phone/NavigationBarView;
.prologue
.line 64
iget-object v0, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mContext:Landroid/content/Context;
return-object v0
.end method
5. Look for this method
Code:
.method private notifyVerticalChangedListener(Z)V
Above that method add these code
Code:
.method private mySwipeDetector(FFJFFJ)V
.locals 11
.param p1, "e1X" # F
.param p2, "e1Y" # F
.param p3, "e1Time" # J
.param p5, "e2X" # F
.param p6, "e2Y" # F
.param p7, "e2Time" # J
.prologue
.line 276
iget-object v6, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mContext:Landroid/content/Context;
invoke-virtual {v6}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;
move-result-object v6
invoke-virtual {v6}, Landroid/content/res/Resources;->getConfiguration()Landroid/content/res/Configuration;
move-result-object v6
iget v6, v6, Landroid/content/res/Configuration;->orientation:I
const/4 v7, 0x1
if-ne v6, v7, :cond_1
const/4 v2, 0x1
.line 277
.local v2, "isPortrait":Z
:goto_0
sub-float v0, p5, p1
.line 278
.local v0, "distanceX":F
sub-float v1, p6, p2
.line 279
.local v1, "distanceY":F
sub-long v6, p7, p3
long-to-float v6, v6
div-float v6, v0, v6
const/high16 v7, 0x447a0000 # 1000.0f
mul-float v4, v6, v7
.line 280
.local v4, "velocityX":F
sub-long v6, p7, p3
long-to-float v6, v6
div-float v6, v1, v6
const/high16 v7, 0x447a0000 # 1000.0f
mul-float v5, v6, v7
.line 281
.local v5, "velocityY":F
const-string v3, ""
.line 282
.local v3, "summary":Ljava/lang/String;
if-eqz v2, :cond_2
.line 283
invoke-static {v0}, Ljava/lang/Math;->abs(F)F
move-result v6
invoke-static {v1}, Ljava/lang/Math;->abs(F)F
move-result v7
cmpl-float v6, v6, v7
if-lez v6, :cond_0
invoke-static {v0}, Ljava/lang/Math;->abs(F)F
move-result v6
const/high16 v7, 0x43960000 # 300.0f
cmpl-float v6, v6, v7
if-lez v6, :cond_0
const/high16 v6, -0x3db80000 # -50.0f
cmpl-float v6, p6, v6
if-lez v6, :cond_0
invoke-static {v4}, Ljava/lang/Math;->abs(F)F
move-result v6
const/high16 v7, 0x447a0000 # 1000.0f
cmpl-float v6, v6, v7
if-lez v6, :cond_0
.line 285
iget-object v6, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mPowerManager:Landroid/os/PowerManager;
invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J
move-result-wide v8
invoke-virtual {v6, v8, v9}, Landroid/os/PowerManager;->goToSleep(J)V
.line 303
:cond_0
:goto_1
return-void
.line 276
.end local v0 # "distanceX":F
.end local v1 # "distanceY":F
.end local v2 # "isPortrait":Z
.end local v3 # "summary":Ljava/lang/String;
.end local v4 # "velocityX":F
.end local v5 # "velocityY":F
:cond_1
const/4 v2, 0x0
goto :goto_0
.line 298
.restart local v0 # "distanceX":F
.restart local v1 # "distanceY":F
.restart local v2 # "isPortrait":Z
.restart local v3 # "summary":Ljava/lang/String;
.restart local v4 # "velocityX":F
.restart local v5 # "velocityY":F
:cond_2
invoke-static {v1}, Ljava/lang/Math;->abs(F)F
move-result v6
invoke-static {v0}, Ljava/lang/Math;->abs(F)F
move-result v7
cmpl-float v6, v6, v7
if-lez v6, :cond_0
invoke-static {v1}, Ljava/lang/Math;->abs(F)F
move-result v6
const/high16 v7, 0x43960000 # 300.0f
cmpl-float v6, v6, v7
if-lez v6, :cond_0
const/high16 v6, -0x3db80000 # -50.0f
cmpl-float v6, p5, v6
if-lez v6, :cond_0
invoke-static {v5}, Ljava/lang/Math;->abs(F)F
move-result v6
const/high16 v7, 0x447a0000 # 1000.0f
cmpl-float v6, v6, v7
if-lez v6, :cond_0
.line 300
iget-object v6, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mPowerManager:Landroid/os/PowerManager;
invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J
move-result-wide v8
invoke-virtual {v6, v8, v9}, Landroid/os/PowerManager;->goToSleep(J)V
goto :goto_1
.end method
6. Now Find this
Code:
# virtual methods
Below that add this code
Code:
.method public dp2Px(F)I
.locals 3
.param p1, "dp" # F
.prologue
.line 544
iget-object v1, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mContext:Landroid/content/Context;
invoke-virtual {v1}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;
move-result-object v1
invoke-virtual {v1}, Landroid/content/res/Resources;->getDisplayMetrics()Landroid/util/DisplayMetrics;
move-result-object v1
iget v0, v1, Landroid/util/DisplayMetrics;->density:F
.line 545
.local v0, "scale":F
mul-float v1, p1, v0
const/high16 v2, 0x3f000000 # 0.5f
add-float/2addr v1, v2
float-to-int v1, v1
return v1
.end method
7. Look for this method
Code:
.method public onInterceptTouchEvent(Landroid/view/MotionEvent;)Z
In this code Change .locals 3 to .locals 4
Look for this
Code:
.local v1, "intercept":Z
if-nez v1, :cond_[COLOR="Red"]0[/COLOR]
Change to
Code:
.local v1, "intercept":Z
if-nez v1, :cond_[COLOR="red"]1[/COLOR]
Look for this line
Code:
iget-boolean v1, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mDelegateIntercepted:Z
Below that add this code
Code:
iget-boolean v2, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mSwipe2SleepActive:Z
if-eqz v2, :cond_0
invoke-virtual {p1}, Landroid/view/MotionEvent;->getAction()I
move-result v2
if-nez v2, :cond_0
.line 318
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v2
iput-wide v2, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mDownTime:J
.line 319
invoke-virtual {p1}, Landroid/view/MotionEvent;->getX()F
move-result v2
iput v2, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mDownX:F
.line 320
invoke-virtual {p1}, Landroid/view/MotionEvent;->getY()F
move-result v2
iput v2, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mDownY:F
.line 321
const/4 v2, 0x1
iput-boolean v2, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mIsDown:Z
.line 329
:cond_0
After adding this, just below 2 lines you will find this
After return v1 you will find this
:cond_0 to :cond_1
8. Now look for this method
Code:
.method public onTouchEvent(Landroid/view/MotionEvent;)Z
Replace complete method from the below method
Code:
.method public onTouchEvent(Landroid/view/MotionEvent;)Z
.locals 11
.param p1, "event" # Landroid/view/MotionEvent;
.prologue
const/4 v10, 0x1
.line 248
iget-boolean v1, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mSwipe2SleepActive:Z
if-eqz v1, :cond_0
invoke-virtual {p1}, Landroid/view/MotionEvent;->getAction()I
move-result v1
if-ne v1, v10, :cond_0
iget-boolean v1, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mIsDown:Z
if-eqz v1, :cond_0
.line 249
const/4 v1, 0x0
iput-boolean v1, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mIsDown:Z
.line 250
iget v2, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mDownX:F
iget v3, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mDownY:F
iget-wide v4, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mDownTime:J
invoke-virtual {p1}, Landroid/view/MotionEvent;->getX()F
move-result v6
invoke-virtual {p1}, Landroid/view/MotionEvent;->getY()F
move-result v7
invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
move-result-wide v8
move-object v1, p0
invoke-direct/range {v1 .. v9}, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mySwipeDetector(FFJFFJ)V
.line 252
:cond_0
invoke-direct {p0, p1}, Lcom/android/systemui/statusbar/phone/NavigationBarView;->initDownStates(Landroid/view/MotionEvent;)V
.line 217
iget-boolean v1, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mDelegateIntercepted:Z
if-nez v1, :cond_1
iget-object v1, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mTaskSwitchHelper:Lcom/android/systemui/statusbar/phone/NavigationBarViewTaskSwitchHelper;
invoke-virtual {v1, p1}, Lcom/android/systemui/statusbar/phone/NavigationBarViewTaskSwitchHelper;->onTouchEvent(Landroid/view/MotionEvent;)Z
move-result v1
if-eqz v1, :cond_1
move v1, v10
.line 227
:goto_0
return v1
.line 220
:cond_1
iget-object v1, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mDeadZone:Lcom/android/systemui/statusbar/policy/DeadZone;
if-eqz v1, :cond_2
invoke-virtual {p1}, Landroid/view/MotionEvent;->getAction()I
move-result v1
const/4 v2, 0x4
if-ne v1, v2, :cond_2
.line 221
iget-object v1, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mDeadZone:Lcom/android/systemui/statusbar/policy/DeadZone;
invoke-virtual {v1, p1}, Lcom/android/systemui/statusbar/policy/DeadZone;->poke(Landroid/view/MotionEvent;)V
.line 223
:cond_2
iget-object v1, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mDelegateHelper:Lcom/android/systemui/statusbar/DelegateViewHelper;
if-eqz v1, :cond_3
iget-boolean v1, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mDelegateIntercepted:Z
if-eqz v1, :cond_3
.line 224
iget-object v1, p0, Lcom/android/systemui/statusbar/phone/NavigationBarView;->mDelegateHelper:Lcom/android/systemui/statusbar/DelegateViewHelper;
invoke-virtual {v1, p1}, Lcom/android/systemui/statusbar/DelegateViewHelper;->onInterceptTouchEvent(Landroid/view/MotionEvent;)Z
move-result v0
.line 225
.local v0, "ret":Z
if-eqz v0, :cond_3
move v1, v10
goto :goto_0
.line 227
.end local v0 # "ret":Z
:cond_3
invoke-super {p0, p1}, Landroid/widget/LinearLayout;->onTouchEvent(Landroid/view/MotionEvent;)Z
move-result v1
goto :goto_0
.end method
9. Finally save and compile/sign and replace the systemui.apk
10. Now time to add switch from setting
Look for the below 3rd post
settings
Welcome to easy part on adding the option to hide/show in settings
1. Decompile the settings.apk
2. Download this View attachment Settings.zip and merge to your settings
3. Add the below code to your settings ( i had added to my own settings ) and your wish
Code:
<PreferenceScreen android:title="Navigation" android:key="navigation" android:fragment="com.android.settings.rz.Navigation" />
4. Compile it and Decompile and open
Settings.apk/smali/com/android/settings/rz/Navigation.smali
5. Compare the Public ID and replace it and recompile
6. God you did man,,, now replace and have fun
Thanks to atl4ntis for his Awesome rom Cataclysm and Cyanogenmod
I gonna try now ?
Working. ? ?
Works fine bro thanks a lot
woww.good job,thank bro
venkat kamesh said:
Welcome to easy part on adding the option to hide/show in settings
1. Decompile the settings.apk
2. Download this View attachment 3617852 and merge to your settings
3. Add the below code to your settings ( i had added to my own settings ) and your wish
Code:
<PreferenceScreen android:title="Navigation" android:key="navigation" android:fragment="com.android.settings.rz.Navigation" />
4. Compile it and Decompile and open
Settings.apk/smali/com/android/settings/rz/Navigation.smali
5. Compare the Public ID and replace it and recompile
6. God you did man,,, now replace and have fun
Thanks to atl4ntis for his Awesome rom Cataclysm and Cyanogenmod
Click to expand...
Click to collapse
when i recompile,,i have bug with @string/lockscreen_display_category
dark90
brother, give your SystemUI with the mod Enable/Disable Navigation Bar Swipe to sleep/Lock, pliz
Quoclam851995 said:
when i recompile,,i have bug with @string/lockscreen_display_category
Click to expand...
Click to collapse
haha its a dump string
not a deal bro
rename the @string/lockscreen_display_category to any thing like "display"
or remove the line and leave it or add string
nothing is a problem
dark90 said:
Working.
Click to expand...
Click to collapse
can you give me your systemui
Thanks bro.. Works like a charm.. Great tutorial. Expecting more from you..
Rajeev said:
Thanks bro.. Works like a charm.. Great tutorial. Expecting more from you..
Click to expand...
Click to collapse
Can you share with me your system ui
Quoclam851995 said:
Can you share with me your system ui
Click to expand...
Click to collapse
Why?
Rajeev said:
Why?
Click to expand...
Click to collapse
Maybe don't know how to make the tut i think .-.
Rajeev said:
Why?
Click to expand...
Click to collapse
I want compare some code to complete my system ui.
Quoclam851995 said:
I want compare some code to complete my system ui.
Click to expand...
Click to collapse
I am sorry my Friend. I am using 2g and very low signal. With my Samsung Galaxy Y
@Rajeev @venkat kamesh
why is there nobody to explain me how to "merge" a file to another.
in this case (and all other tuts as well from venkat) i don´t unterstand how to merge my public.xml with the downloaded from the OP.
this drives me crazy. i did all steps before but always failed at this point in each tutorial
all other things are clear and replacing the ID after re- and decompiling is no problem, but if nobody explain to me how to merge both public.xml, i
can´t re- and decompile the settings.apk without a failure.
Each dev started like me with little little steps, so come on guys, plz teach me this simple thing
There are tousand of tuts here from hundreds of devs, but nobody explain this thing - very very frustrating....
moonryder said:
@Rajeev @venkat kamesh
why is there nobody to explain me how to "merge" a file to another.
in this case (and all other tuts as well from venkat) i don´t unterstand how to merge my public.xml with the downloaded from the OP.
this drives me crazy. i did all steps before but always failed at this point in each tutorial
all other things are clear and replacing the ID after re- and decompiling is no problem, but if nobody explain to me how to merge both public.xml, i
can´t re- and decompile the settings.apk without a failure.
Each dev started like me with little little steps, so come on guys, plz teach me this simple thing
There are tousand of tuts here from hundreds of devs, but nobody explain this thing - very very frustrating....
Click to expand...
Click to collapse
Bro u don't need to merge the public.xml u only need to search the lines that the files u added to xml, layout etc and then compile and recompile and replace the public id and recompile ,sing and replace bro
moonryder said:
@Rajeev @venkat kamesh
why is there nobody to explain me how to "merge" a file to another.
in this case (and all other tuts as well from venkat) i don´t unterstand how to merge my public.xml with the downloaded from the OP.
this drives me crazy. i did all steps before but always failed at this point in each tutorial
all other things are clear and replacing the ID after re- and decompiling is no problem, but if nobody explain to me how to merge both public.xml, i
can´t re- and decompile the settings.apk without a failure.
Each dev started like me with little little steps, so come on guys, plz teach me this simple thing
There are tousand of tuts here from hundreds of devs, but nobody explain this thing - very very frustrating....
Click to expand...
Click to collapse
You need check the smali file and find 0x7fxxxx code, then search That code in the public(compare).xml and you get a specific líne now search That líne into your public.xml and copy your code 0x7fxxxx from the líne into your public.xml to the smali code.
You can use this to make it easy http://forum.xda-developers.com/showthread.php?p=64160375

[Guide Dev][Smali DIY] How to Switch, Checkbox, Seekbar,ListPreferences Preferences

Today i would like to explain the tut on how these Switch,CheckBox,ListPreferences work
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Firstly i am not good in explanation
Hope you will surely understand it
Before Going to the main part you should know what switch checkbox and list preferences work
Look at this code
Code:
private boolean mBrightnessSliderEnabled;
private int isBrightnessSliderEnabled()
{
int i = Settings.System.getInt(this.mContext.getContentResolver(), "[COLOR="red"]brightness_slider_enabled[/COLOR]", 1); #key
int j = 0;
if (i != 0) {
j = 1;
}
this.mBrightnessSliderEnabled = j;
return j;
}
private boolean showBrightnessSlider()
{
int i = isBrightnessSliderEnabled();
ToggleSlider localToggleSlider = (ToggleSlider)findViewById(id.brightness_slider);
if ((i != 0) && (this.mBrightnessSliderEnabled))
{
this.mBrightnessView.setVisibility(0);
localToggleSlider.setVisibility(0);
}
for (;;)
{
updateResources();
return this.mBrightnessSliderEnabled;
this.mBrightnessView.setVisibility(8);
localToggleSlider.setVisibility(8);
}
}
public void setListening(boolean paramBoolean)
{
if (this.mListening == paramBoolean) {
return;
}
this.mListening = paramBoolean;
Iterator localIterator = this.mRecords.iterator();
while (localIterator.hasNext())
{
TileRecord localTileRecord = (TileRecord)localIterator.next();
try
{
localTileRecord.tile.setListening(this.mListening);
}
catch (IllegalArgumentException localIllegalArgumentException) {}
}
this.mFooter.setListening(this.mListening);
if (this.mListening) {
refreshAllTiles();
}
if ((paramBoolean) && (showBrightnessSlider()))
{
this.mBrightnessController.registerCallbacks();
return;
}
this.mBrightnessController.unregisterCallbacks();
}
In Smali Look here http://forum.xda-developers.com/cro...es-apps/guide-hide-brightness-slider-t3284141
See here in the above code
In code you will find 0 and 1 ( nothing but true or false / on/off)
and you can see a key in red line ( which receives the 1 or 0 from settings)
So The CheckBox and Switch preference created a boolean 1 or 0 ( nothing but on / off)
Hope you got what i meant
List preference in android persists string. That means that it writes object of string type into the shared preferences.
You need to create 2 string arrays for each list preference.
One for Entries - what is displayed in the dialog as single choice items for user.
and One is for entryValues (what is being written into the preferences). You can from your mod read them as integers or strings using content resolver.
f.e., if your values are 200, 300, 400, android will persist them as strings. But when you restrieve them from database in your systemui smali mod, f.e.,
you can call either getInt (to get them as integers) or getString to get them as strings. Of course strings array like bread, milk, cookies cannot be retrieved as integer.
But a string 200 can be either.
Now time to main part of explanation
So you know that switch and checkbox give same out of valued 1 or 0
How to make it ?
Here i will start with 2 types of codes
Post 2
Look at these 2 xml code which give same result with variation of view
Code:
<SwitchPreference android:title="Brightness Slider" android:key="[COLOR="red"]key_brightness_slider_show[/COLOR]" android:summaryOn="Brightness Slider Shown" android:summaryOff="Brightness Slider Hidden" />
or
Code:
<CheckBoxPreference android:title="Brightness Slider" android:key="[COLOR="red"]key_brightness_slider_show[/COLOR]" android:summaryOn="Brightness Slider Shown" android:summaryOff="Brightness Slider Hidden" />
You MUST provide defaultValue for ANY switch preference you create
It writes boolean (true or false) into the shared preferences
We copy it as integer (1 or 0) into the Settings.System database
It mush have a unique key, none of existent in databse.
It must be the same key as you use in your mod for that function. key_brightness_slider_show.
So thea Slider can be either visible or invisible.
Also will checkbox preference. In your mod when you retrieve and integer using ContentResolver you specify the default value (if the key is not found).
You have to specify the same default value here. If in smali it was 0x1,. then in the app it must be android:defaultValue = "true".
android:summaryOn="Brightness Slider Shown" android:summaryOff="Brightness Slider Hidden"
These will show the below summary when value is 1 you will get summaryOn else off
This is not much mandatory.. its your wish or you can leave it or you can just only define summary
You can also make Dependence of the switch example
Network mod- this contain turn on/off, color, auto hide and more
When you add the dependency code so that when you only get bool 1 you can control other next string
Look below code of strings
Code:
<ListPreference android:persistent="false" android:entries="@array/show_network_traffic_state_entries" android:title="@string/show_network_traffic_state" android:key="[COLOR="red"]network_traffic_state[/COLOR]" android:entryValues="@array/show_network_traffic_state_values" />
<net.margaritov.preference.colorpicker.ColorPickerPreference android:title="@string/network_traffic_color_style" android:key="network_traffic_color" [COLOR="Orange"]android:dependency="[COLOR="Red"]network_traffic_state[/COLOR]" [/COLOR]android:defaultValue="0xffffffff" />
in the above code you can see the dependency
mean, when you turn on the first string
only then next string works
Now its time to go for smali
First create your own xml code
Example look this empty code
Code:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen android:title="New"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
</PreferenceScreen>
save this in any name of your xml (settings.apk/res/xml)
now i like to control Brightness slider
so i will add this to the xml and will look like
Code:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen android:title="New"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
<SwitchPreference android:title="Brightness Slider" android:key="key_brightness_slider_show" android:defaultValue="0" android:summaryOn="Brightness Slider Shown" android:summaryOff="Brightness Slider Hidden"
</PreferenceScreen>
Look here the main part is Key android:key="key_brightness_slider_show" (where i had defined brightness_slider_show in above code )
I think you are clear till now
So time to create a boolean
Lets start with new empty code
This is an Empty code Which or where you can create new Switch or Checkbox preference
The path of the file is Settings.apk/smali/com/android/settings/rz/
and File name was Statusmod.smali
Code:
.class public Lcom/android/settings/rz/Statusmod;
.super Lcom/android/settings/SettingsPreferenceFragment;
.source "Statusmod.java"
# instance fields
# direct methods
.method public constructor <init>()V
.locals 0
.prologue
.line 28
invoke-direct {p0}, Lcom/android/settings/SettingsPreferenceFragment;-><init>()V
return-void
.end method
# virtual methods
.method public onCreate(Landroid/os/Bundle;)V
.locals 5
.param p1, "savedInstanceState" # Landroid/os/Bundle;
.prologue
const/4 v3, 0x0
const/4 v2, 0x1
.line 42
invoke-super {p0, p1}, Lcom/android/settings/SettingsPreferenceFragment;->onCreate(Landroid/os/Bundle;)V
.line 43
invoke-virtual {p0}, Lcom/android/settings/rz/Statusmod;->getActivity()Landroid/app/Activity;
move-result-object v1
invoke-virtual {v1}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v0
.line 44
.local v0, "resolver":Landroid/content/ContentResolver;
const v1, 0x7f060092 #Xml preference
invoke-virtual {p0, v1}, Lcom/android/settings/rz/Statusmod;->addPreferencesFromResource(I)V
.end method
.method public onPreferenceTreeClick(Landroid/preference/PreferenceScreen;Landroid/preference/Preference;)Z
.locals 5
.param p1, "preferenceScreen" # Landroid/preference/PreferenceScreen;
.param p2, "preference" # Landroid/preference/Preference;
.prologue
const/4 v1, 0x0
const/4 v2, 0x1
.end method
Here i had added a part of Switch settings
Code:
.class public Lcom/android/settings/rz/Statusmod;
.super Lcom/android/settings/SettingsPreferenceFragment;
.source "Statusmod.java"
# instance fields
.field private mENABLE_SLIDER:Landroid/preference/[COLOR="SeaGreen"]SwitchPreference[/COLOR];
# direct methods
.method public constructor <init>()V
.locals 0
.prologue
.line 28
invoke-direct {p0}, Lcom/android/settings/SettingsPreferenceFragment;-><init>()V
return-void
.end method
# virtual methods
.method public onCreate(Landroid/os/Bundle;)V
.locals 5
.param p1, "savedInstanceState" # Landroid/os/Bundle;
.prologue
const/4 v3, 0x0
const/4 v2, 0x1
.line 42
invoke-super {p0, p1}, Lcom/android/settings/SettingsPreferenceFragment;->onCreate(Landroid/os/Bundle;)V
.line 43
invoke-virtual {p0}, Lcom/android/settings/rz/Statusmod;->getActivity()Landroid/app/Activity;
move-result-object v1
invoke-virtual {v1}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v0
.line 44
.local v0, "resolver":Landroid/content/ContentResolver;
const v1, 0x7f060092 # xml public key
invoke-virtual {p0, v1}, Lcom/android/settings/rz/Statusmod;->addPreferencesFromResource(I)V
.line 46
const-string v1, "key_brightness_slider_show"
invoke-virtual {p0, v1}, Lcom/android/settings/rz/Statusmod;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v1
check-cast v1, Landroid/preference/[COLOR="seagreen"]SwitchPreference[/COLOR];
iput-object v1, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_SLIDER:Landroid/preference/[COLOR="seagreen"]SwitchPreference[/COLOR];
.line 47
iget-object v4, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_SLIDER:Landroid/preference/[COLOR="seagreen"]SwitchPreference[/COLOR];
const-string v1, "brightness_slider_show"
invoke-static {v0, v1, v2}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
move-result v1
if-ne v1, v2, :cond_0
move v1, v2
:goto_0
invoke-virtual {v4, v1}, Landroid/preference/[COLOR="seagreen"]SwitchPreference[/COLOR];->setChecked(Z)V
.line 57
return-void
:cond_0
move v1, v3
.line 47
goto :goto_0
.end method
.method public onPreferenceTreeClick(Landroid/preference/PreferenceScreen;Landroid/preference/Preference;)Z
.locals 5
.param p1, "preferenceScreen" # Landroid/preference/PreferenceScreen;
.param p2, "preference" # Landroid/preference/Preference;
.prologue
const/4 v1, 0x0
const/4 v2, 0x1
.line 61
iget-object v3, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_SLIDER:Landroid/preference/[COLOR="seagreen"]SwitchPreference[/COLOR];
if-ne p2, v3, :cond_1
.line 62
iget-object v3, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_SLIDER:Landroid/preference/[COLOR="seagreen"]SwitchPreference[/COLOR];
invoke-virtual {v3}, Landroid/preference/[COLOR="seagreen"]SwitchPreference[/COLOR];->isChecked()Z
move-result v0
.line 63
.local v0, "value":Z
invoke-virtual {p0}, Lcom/android/settings/rz/Statusmod;->getActivity()Landroid/app/Activity;
move-result-object v3
invoke-virtual {v3}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v3
const-string v4, "brightness_slider_show"
if-eqz v0, :cond_0
move v1, v2
:cond_0
invoke-static {v3, v4, v1}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z
.line 78
.end local v0 # "value":Z
:goto_0
return v2
.line 65
:cond_1
invoke-super {p0, p1, p2}, Lcom/android/settings/SettingsPreferenceFragment;->onPreferenceTreeClick(Landroid/preference/PreferenceScreen;Landroid/preference/Preference;)Z
move-result v2
goto :goto_0
.end method
Now you had done with the code
in this you should look for public id
Where you need to match with xml you created above
This is Switch box preference
If you like to change it to Check Box preference then change all Switch to Checkbox ( also in Xml)
As like below Code ( Look for green part of changes)
Code:
.class public Lcom/android/settings/rz/Statusmod;
.super Lcom/android/settings/SettingsPreferenceFragment;
.source "Statusmod.java"
# instance fields
.field private mENABLE_SLIDER:Landroid/preference/CheckBoxPreference;
# direct methods
.method public constructor <init>()V
.locals 0
.prologue
.line 28
invoke-direct {p0}, Lcom/android/settings/SettingsPreferenceFragment;-><init>()V
return-void
.end method
# virtual methods
.method public onCreate(Landroid/os/Bundle;)V
.locals 5
.param p1, "savedInstanceState" # Landroid/os/Bundle;
.prologue
const/4 v3, 0x0
const/4 v2, 0x1
.line 42
invoke-super {p0, p1}, Lcom/android/settings/SettingsPreferenceFragment;->onCreate(Landroid/os/Bundle;)V
.line 43
invoke-virtual {p0}, Lcom/android/settings/rz/Statusmod;->getActivity()Landroid/app/Activity;
move-result-object v1
invoke-virtual {v1}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v0
.line 44
.local v0, "resolver":Landroid/content/ContentResolver;
const v1, 0x7f060092
invoke-virtual {p0, v1}, Lcom/android/settings/rz/Statusmod;->addPreferencesFromResource(I)V
.line 46
const-string v1, "key_brightness_slider_show"
invoke-virtual {p0, v1}, Lcom/android/settings/rz/Statusmod;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v1
check-cast v1, Landroid/preference/CheckBoxPreference;
iput-object v1, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_SLIDER:Landroid/preference/CheckBoxPreference;
.line 47
iget-object v4, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_SLIDER:Landroid/preference/CheckBoxPreference;
const-string v1, "brightness_slider_show"
invoke-static {v0, v1, v2}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
move-result v1
if-ne v1, v2, :cond_0
move v1, v2
:goto_0
invoke-virtual {v4, v1}, Landroid/preference/CheckBoxPreference;->setChecked(Z)V
.line 57
return-void
:cond_0
move v1, v3
.line 47
goto :goto_0
.end method
.method public onPreferenceTreeClick(Landroid/preference/PreferenceScreen;Landroid/preference/Preference;)Z
.locals 5
.param p1, "preferenceScreen" # Landroid/preference/PreferenceScreen;
.param p2, "preference" # Landroid/preference/Preference;
.prologue
const/4 v1, 0x0
const/4 v2, 0x1
.line 61
iget-object v3, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_SLIDER:Landroid/preference/CheckBoxPreference;
if-ne p2, v3, :cond_1
.line 62
iget-object v3, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_SLIDER:Landroid/preference/CheckBoxPreference;
invoke-virtual {v3}, Landroid/preference/CheckBoxPreference;->isChecked()Z
move-result v0
.line 63
.local v0, "value":Z
invoke-virtual {p0}, Lcom/android/settings/rz/Statusmod;->getActivity()Landroid/app/Activity;
move-result-object v3
invoke-virtual {v3}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v3
const-string v4, "brightness_slider_show"
if-eqz v0, :cond_0
move v1, v2
:cond_0
invoke-static {v3, v4, v1}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z
.line 78
.end local v0 # "value":Z
:goto_0
return v2
.line 65
:cond_1
invoke-super {p0, p1, p2}, Lcom/android/settings/SettingsPreferenceFragment;->onPreferenceTreeClick(Landroid/preference/PreferenceScreen;Landroid/preference/Preference;)Z
move-result v2
goto :goto_0
.end method
If you like to add more in this
Example if you had added new Switch or checkbox
Code:
<PreferenceScreen android:title="New"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
<SwitchPreference android:title="Brightness Slider" android:key="brightness_slider_show" android:defaultValue="0" android:summaryOn="Brightness Slider Shown" android:summaryOff="Brightness Slider Hidden"
<CheckBoxPreference android:title="Nothing Bomb" android:key="key_bomb_show" />
</PreferenceScreen>
first define in xml then i code
i will explain in simple
Look for the above code
Look at this boolean ( from above code)
Code:
.field private mENABLE_SLIDER:Landroid/preference/SwitchPreference;
above/Below Add this line
Code:
.field private mENABLE_BOMB:Landroid/preference/CheckBoxPreference; #define boolean
In this method
.method public onCreate(Landroid/os/BundleV
After :goto_0
You need to add this code
Code:
invoke-virtual {v4, v1}, Landroid/preference/CheckBoxPreference;->setChecked(Z)V
const-string v1, "key_bomb_show"
invoke-virtual {p0, v1}, Lcom/android/settings/rz/Statusmod;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v1
check-cast v1, Landroid/preference/CheckBoxPreference;
iput-object v1, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_BOMB:Landroid/preference/CheckBoxPreference;
.line 50
iget-object v4, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_BOMB:Landroid/preference/CheckBoxPreference;
const-string v1, "bomb_show"
invoke-static {v0, v1, v2}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
move-result v1
if-ne v1, v2, :cond_1
move v1, v2
:goto_1
After goto :goto_0
Add this Code
Code:
:cond_1
move v1, v3
.line 50
goto :goto_1
In this code when you add more first look cond_? and goto_?
Now look for this method
.method public onPreferenceTreeClick(Landroid/preference/PreferenceScreen;Landroid/preference/PreferenceZ
in that after
.line 65
:cond_1
Add this code
Code:
iget-object v3, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_BOMB:Landroid/preference/SwitchPreference;
if-ne p2, v3, :cond_2
.line 62
iget-object v3, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_BOMB:Landroid/preference/SwitchPreference;
invoke-virtual {v3}, Landroid/preference/SwitchPreference;->isChecked()Z
move-result v0
.line 63
.local v0, "value":Z
invoke-virtual {p0}, Lcom/android/settings/rz/Statusmod;->getActivity()Landroid/app/Activity;
move-result-object v3
invoke-virtual {v3}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v3
const-string v4, "bomb_show"
if-eqz v0, :cond_1
move v1, v2
:cond_1
invoke-static {v3, v4, v1}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z
.line 78
.end local v0 # "value":Z
:goto_1
return v2
.line 65
:cond_2
and save finally it looks like this
Code:
.class public Lcom/android/settings/rz/Statusmod;
.super Lcom/android/settings/SettingsPreferenceFragment;
.source "Statusmod.java"
# instance fields
.field private mENABLE_SLIDER:Landroid/preference/SwitchPreference;
.field private mENABLE_BOMB:Landroid/preference/CheckBoxPreference;
# direct methods
.method public constructor <init>()V
.locals 0
.prologue
.line 28
invoke-direct {p0}, Lcom/android/settings/SettingsPreferenceFragment;-><init>()V
return-void
.end method
# virtual methods
.method public onCreate(Landroid/os/Bundle;)V
.locals 5
.param p1, "savedInstanceState" # Landroid/os/Bundle;
.prologue
const/4 v3, 0x0
const/4 v2, 0x1
.line 42
invoke-super {p0, p1}, Lcom/android/settings/SettingsPreferenceFragment;->onCreate(Landroid/os/Bundle;)V
.line 43
invoke-virtual {p0}, Lcom/android/settings/rz/Statusmod;->getActivity()Landroid/app/Activity;
move-result-object v1
invoke-virtual {v1}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v0
.line 44
.local v0, "resolver":Landroid/content/ContentResolver;
const v1, 0x7f060092
invoke-virtual {p0, v1}, Lcom/android/settings/rz/Statusmod;->addPreferencesFromResource(I)V
.line 46
const-string v1, "key_brightness_slider_show"
invoke-virtual {p0, v1}, Lcom/android/settings/rz/Statusmod;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v1
check-cast v1, Landroid/preference/SwitchPreference;
iput-object v1, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_SLIDER:Landroid/preference/SwitchPreference;
.line 47
iget-object v4, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_SLIDER:Landroid/preference/SwitchPreference;
const-string v1, "brightness_slider_show"
invoke-static {v0, v1, v2}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
move-result v1
if-ne v1, v2, :cond_0
move v1, v2
:goto_0
invoke-virtual {v4, v1}, Landroid/preference/CheckBoxPreference;->setChecked(Z)V
const-string v1, "key_bomb_show"
invoke-virtual {p0, v1}, Lcom/android/settings/rz/Statusmod;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v1
check-cast v1, Landroid/preference/CheckBoxPreference;
iput-object v1, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_BOMB:Landroid/preference/CheckBoxPreference;
.line 50
iget-object v4, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_BOMB:Landroid/preference/CheckBoxPreference;
const-string v1, "bomb_show"
invoke-static {v0, v1, v2}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I
move-result v1
if-ne v1, v2, :cond_1
move v1, v2
:goto_1
invoke-virtual {v4, v1}, Landroid/preference/SwitchPreference;->setChecked(Z)V
.line 57
return-void
:cond_0
move v1, v3
.line 47
goto :goto_0
:cond_1
move v1, v3
.line 50
goto :goto_1
.end method
.method public onPreferenceTreeClick(Landroid/preference/PreferenceScreen;Landroid/preference/Preference;)Z
.locals 5
.param p1, "preferenceScreen" # Landroid/preference/PreferenceScreen;
.param p2, "preference" # Landroid/preference/Preference;
.prologue
const/4 v1, 0x0
const/4 v2, 0x1
.line 61
iget-object v3, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_SLIDER:Landroid/preference/SwitchPreference;
if-ne p2, v3, :cond_1
.line 62
iget-object v3, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_SLIDER:Landroid/preference/SwitchPreference;
invoke-virtual {v3}, Landroid/preference/SwitchPreference;->isChecked()Z
move-result v0
.line 63
.local v0, "value":Z
invoke-virtual {p0}, Lcom/android/settings/rz/Statusmod;->getActivity()Landroid/app/Activity;
move-result-object v3
invoke-virtual {v3}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v3
const-string v4, "brightness_slider_show"
if-eqz v0, :cond_0
move v1, v2
:cond_0
invoke-static {v3, v4, v1}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z
.line 78
.end local v0 # "value":Z
:goto_0
return v2
.line 65
:cond_1
iget-object v3, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_BOMB:Landroid/preference/SwitchPreference;
if-ne p2, v3, :cond_2
.line 62
iget-object v3, p0, Lcom/android/settings/rz/Statusmod;->mENABLE_BOMB:Landroid/preference/SwitchPreference;
invoke-virtual {v3}, Landroid/preference/SwitchPreference;->isChecked()Z
move-result v0
.line 63
.local v0, "value":Z
invoke-virtual {p0}, Lcom/android/settings/rz/Statusmod;->getActivity()Landroid/app/Activity;
move-result-object v3
invoke-virtual {v3}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;
move-result-object v3
const-string v4, "bomb_show"
if-eqz v0, :cond_1
move v1, v2
:cond_1
invoke-static {v3, v4, v1}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z
.line 78
.end local v0 # "value":Z
:goto_1
return v2
.line 65
:cond_2
invoke-super {p0, p1, p2}, Lcom/android/settings/SettingsPreferenceFragment;->onPreferenceTreeClick(Landroid/preference/PreferenceScreen;Landroid/preference/Preference;)Z
move-result v2
goto :goto_0
.end method
and save it compile and done with your settings preferences
This is how to add preferences
If you add more with different smlai name then change the code path and definition
If you got confused look for my guides that will surely help you
post 3
Method 2
which is very simple
no need to work like in 2nd post (this works but not accurate as above )
Download this View attachment Cm_Settings.zip and merge to your settings
while you create a preference in xml define it as this way
Code:
<PreferenceScreen android:title="New"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
<com.android.settings.cyanogenmod.SystemSettingSwitchPreference android:title="Brightness Slider" android:key="brightness_slider_show" android:defaultValue="0" android:summaryOn="Brightness Slider Shown" android:summaryOff="Brightness Slider Hidden"
<com.android.settings.cyanogenmod.SystemCheckBoxPreference android:title="Nothing Bomb" android:key="bomb_show" />
</PreferenceScreen>
Remember the key code is directly defined ( if you had doubt just start compare)
and done
This is expalantion of these things
It's seems I'm very noob in smali
Lol yeah best guide from @venkat kamesh
Thanks bro works well
learnt to decompile
will learn more bro
sorry bad english
translated
Thanks for your awesome work, bro! This makes it easy to give my ROM a custom feel. There is one bug, the switches always revert back to default every time the page/fragment/etc. is displayed. I have found a way around this and also figured out why it isn't working correctly...but I am not knowledgeable enough in smali to fix it. The issue is that the CM switches don't create a boolean one first instance. They will however control the boolean correctly if it exists.
How I solved:
I put my switches in settings because i'm running 4.4 and don't have rom control. So the path here will be different depending on where you put your switches. If they are in settings like mine you will navigate to /data/data/com.android.settings/shared_prefs/ and open the file com.android.settings_preferences.xml with a root file explorer. You will also need a text editor unless your file explorer has one built in.
Now you have to remember your keys that you used for your switches in your mod
mine are "aokpram_recent," "show_clock," and "stock_battery."
***Note that you have to type them in, I've tried copying and pasting and it will not work.***
Example:
boolean name="show_clock" value="true"
Do this for all of your mod keys and your switches will start working correctly. If I ever figure out a way to make the cmsettings switches generate their own boolean I will post it.

Categories

Resources