FORUMS
Remove All Ads from XDA

[MOD] Disable Full/Low Battery Notification (no vibration)

3,102 posts
Thanks Meter: 6,328
 
By LeoMar75, Retired Recognized Developer / Retired Forum Moderator on 25th August 2011, 07:40 PM
Post Reply Email Thread
Hi guys, i have noticed that most people here in order to disable battery Full/Low sound notification just delete these files:
-system/media/audio/ui/TW_Battery_caution.ogg
-system/media/audio/ui/TW_Low_Battery.ogg

Well this is not the right way to do it, because the vibration is still here to wake us up while sleeping

I decided to share this simple mod to avoid this inconvenience!

How to (for dev)

Decompile SystemUI.apk
Open with your favourite Text Editor this file: smali\com\android\systemui\statusbar\policy\Status BarPolicy.smali
search for this method signature: .method private onBatteryLow(Landroid/content/IntentV

The following code will disable Dialog popup for low battery warning (if you don't want to disable it but just sound and vibration then leave this function as it is)

Change code from
Code:
.method private onBatteryLow(Landroid/content/Intent;)V
    .locals 0
    .parameter "intent"

    .prologue
    .line 985
    invoke-direct {p0}, Lcom/android/systemui/statusbar/policy/StatusBarPolicy;->showLowBatteryWarning()V

    .line 990
    return-void
.end method
to

Code:
.method private onBatteryLow(Landroid/content/Intent;)V
    .locals 0
    .parameter "intent"

    .prologue
    return-void

    .line 985
    invoke-direct {p0}, Lcom/android/systemui/statusbar/policy/StatusBarPolicy;->showLowBatteryWarning()V

    .line 990
    return-void
.end method
Now to disable Sound and Vibration notification search for this method signature: .method private playTone(Landroid/net/UriV

Edit code from
Code:
.method private playTone(Landroid/net/Uri;)V
    .locals 5
    .parameter

    .prologue
    const-string v4, "StatusBarPolicy"

    .line 1180
    const-string v0, "StatusBarPolicy"
...
...
...
to

Code:
.method private playTone(Landroid/net/Uri;)V
    .locals 5
    .parameter

    .prologue
    return-void

    const-string v4, "StatusBarPolicy"

    .line 1180
    const-string v0, "StatusBarPolicy"
...
...
...
That's it! Recompile apk and you can sleep deeply

In addition it is possible to leave it as an option! I got it working following the IDEA behind JKAY theme settings application! (big thanks to Jkay)
If you'd like to get sound back, you can create a folder "battery_SOUND_ON" in some places for this example i used this path: /sdcard/Revolution/battery_SOUND_ON (if you don't want sound just delete or rename this folder)

Now we can modify smali code as following:
Code:
.method private playTone(Landroid/net/Uri;)V
    .locals 5
    .parameter

    .prologue
    new-instance v0, Ljava/io/File;

    const-string v1, "/sdcard/Revolution/battery_SOUND_ON"

    invoke-direct {v0, v1}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0}, Ljava/io/File;->exists()Z

    move-result v0

    if-eqz v0, :goto_1

    const-string v4, "StatusBarPolicy"

    .line 1180
    const-string v0, "StatusBarPolicy"
...
...
...
"goto_1" label if followed by return-void which means that if this folder does not exists this method will return straight away, if this folder exists then the normal code will be executed!


Note:
This mod will also display battery full charge icon on the status bar when the charge is completed!
The Following 11 Users Say Thank You to LeoMar75 For This Useful Post: [ View ] Gift LeoMar75 Ad-Free
 
 
25th August 2011, 08:20 PM |#2  
Senior Member
Thanks Meter: 130
 
More
so could any dev make a mod to enable to battery full notifacations and sounds and vibrations??

would be handy to have one in the kitchen for your rom leo so peeps can either have it or not have it etc :)

it is another way to customise the device as well which is always good :)
25th August 2011, 11:08 PM |#3  
LeoMar75's Avatar
OP Retired Recognized Developer / Retired Forum Moderator
Flag Pescara
Thanks Meter: 6,328
 
Donate to Me
More
Quote:
Originally Posted by buxz777

so could any dev make a mod to enable to battery full notifacations and sounds and vibrations??

would be handy to have one in the kitchen for your rom leo so peeps can either have it or not have it etc :)

it is another way to customise the device as well which is always good :)

Yes it is also possible to leave it as an option, i am testing it now and if it works i will update the OP!

\EDIT
It is working, OP has been updated!
The Following User Says Thank You to LeoMar75 For This Useful Post: [ View ] Gift LeoMar75 Ad-Free
26th August 2011, 10:07 PM |#4  
kahvitahra's Avatar
Senior Member
Thanks Meter: 1,159
 
More
Yeah, working great! Allways great thing when user can decide whether use it or not.

Thanks LeoMar!
27th August 2011, 01:37 AM |#5  
Junior Member
Thanks Meter: 0
 
More
fisrt off thanks alot about the grate MOD

but can i use it only with LOW battery?? and keep the notification when the battery is full
27th August 2011, 01:46 AM |#6  
LeoMar75's Avatar
OP Retired Recognized Developer / Retired Forum Moderator
Flag Pescara
Thanks Meter: 6,328
 
Donate to Me
More
Quote:
Originally Posted by KinG_Ruin

fisrt off thanks alot about the grate MOD

but can i use it only with LOW battery?? and keep the notification when the battery is full

\EDIT
Yes it is possible of course!

1)Modify method "private onBatteryLow(Landroid/content/Intent; )V" as shown to the OP.
2)Don't change code (leave the original code) for this method ".method private playTone(Landroid/net/Uri; )V"

In this way you will only disable Low battery notification Dialod + Sound

The Following User Says Thank You to LeoMar75 For This Useful Post: [ View ] Gift LeoMar75 Ad-Free
27th August 2011, 10:02 PM |#7  
Junior Member
Thanks Meter: 0
 
More
thanks alot dude

it works fine, keep it up

edit:-

when i tried to edit another ROM i got this code

Code:
.method private onBatteryLow(Landroid/content/Intent;)V
    .registers 2
    .parameter "intent"

    .prologue
    .line 985
    invoke-direct {p0}, Lcom/android/systemui/statusbar/policy/StatusBarPolicy;->showLowBatteryWarning()V

    .line 990
    return-void
.end method
so is it save to replace it with

Code:
.method private onBatteryLow(Landroid/content/Intent;)V
    .locals 0
    .parameter "intent"

    .prologue
    return-void

    .line 985
    invoke-direct {p0}, Lcom/android/systemui/statusbar/policy/StatusBarPolicy;->showLowBatteryWarning()V

    .line 990
    return-void
.end method
28th August 2011, 12:00 PM |#8  
LeoMar75's Avatar
OP Retired Recognized Developer / Retired Forum Moderator
Flag Pescara
Thanks Meter: 6,328
 
Donate to Me
More
Quote:
Originally Posted by KinG_Ruin

thanks alot dude

it works fine, keep it up

edit:-

when i tried to edit another ROM i got this code

Code:
.method private onBatteryLow(Landroid/content/Intent;)V
    .registers 2
    .parameter "intent"

    .prologue
    .line 985
    invoke-direct {p0}, Lcom/android/systemui/statusbar/policy/StatusBarPolicy;->showLowBatteryWarning()V

    .line 990
    return-void
.end method
so is it save to replace it with

Code:
.method private onBatteryLow(Landroid/content/Intent;)V
    .locals 0
    .parameter "intent"

    .prologue
    return-void

    .line 985
    invoke-direct {p0}, Lcom/android/systemui/statusbar/policy/StatusBarPolicy;->showLowBatteryWarning()V

    .line 990
    return-void
.end method

It's not safe, therefore just add "return-void" after .prologue don't change anithing else!
The Following User Says Thank You to LeoMar75 For This Useful Post: [ View ] Gift LeoMar75 Ad-Free
28th August 2011, 04:10 PM |#9  
juberg's Avatar
Junior Member
Thanks Meter: 0
 
More
hi, thanks for sharing, works great.

one thing...
when i use this code:

.method private playTone(Landroid/net/UriV
.locals 5
.parameter

.prologue
new-instance v0, Ljava/io/File;

const-string v1, "/sdcard/Revolution/battery_SOUND_ON"

invoke-direct {v0, v1}, Ljava/io/File;-><init>(Ljava/lang/StringV

invoke-virtual {v0}, Ljava/io/File;->exists()Z

move-result v0

if-eqz v0, :goto_1

const-string v4, "StatusBarPolicy"

.line 1180
const-string v0, "StatusBarPolicy"


compiling classes.dex gives me an error "goto_1" not specified.

i am on kh3, can you tell me where to go?

methux
28th August 2011, 05:49 PM |#10  
Junior Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by LeoMar75

It's not safe, therefore just add "return-void" after .prologue don't change anithing else!

I love u
thanks alot dude, it works fine
28th August 2011, 05:50 PM |#11  
LeoMar75's Avatar
OP Retired Recognized Developer / Retired Forum Moderator
Flag Pescara
Thanks Meter: 6,328
 
Donate to Me
More
Quote:
Originally Posted by juberg

hi, thanks for sharing, works great.

one thing...
when i use this code:

.method private playTone(Landroid/net/UriV
.locals 5
.parameter

.prologue
new-instance v0, Ljava/io/File;

const-string v1, "/sdcard/Revolution/battery_SOUND_ON"

invoke-direct {v0, v1}, Ljava/io/File;-><init>(Ljava/lang/StringV

invoke-virtual {v0}, Ljava/io/File;->exists()Z

move-result v0

if-eqz v0, :goto_1

const-string v4, "StatusBarPolicy"

.line 1180
const-string v0, "StatusBarPolicy"


compiling classes.dex gives me an error "goto_1" not specified.

i am on kh3, can you tell me where to go?

methux

You should find a label followed by return-void then modify
Code:
 if-eqz v0, :goto_1
to the correct label!

Pls quote your complete function code if you need help!
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes