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

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;->(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!

0 comments:

Post a Comment

Open Panel

Blogroll

counter