Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,734,168 Members 50,718 Now Online
XDA Developers Android and Mobile Development Forum

[MOD] status bar bluetooth/silent toggles improved - update 10/23/2010

Tip us?
 
untermensch
Old
(Last edited by untermensch; 5th November 2010 at 10:29 AM.) Reason: added flashables
#1  
untermensch's Avatar
Senior Member - OP
Thanks Meter 617
Posts: 480
Join Date: Apr 2009
Location: Portland
Default [MOD] status bar bluetooth/silent toggles improved - update 10/23/2010

s0niqu3 brought it to my attention how much the status bar bluetooth toggle
sucked so I changed the onClick method to toggle the bluetooth state instead
of opening settings to the bluetooth page

this is the replacement method for com/android/server/status/StatusBarService$31
which is in the services file in framework.

Code:
.method public onClick(Landroid/view/View;)V
    .registers 7
    .parameter "v"

    .prologue
    const-string v1, "StatusBar"

    iget-object v3, p0, Lcom/android/server/status/StatusBarService$31;->this$0:Lcom/android/server/status/StatusBarService;

    iget-object v3, v3, Lcom/android/server/status/StatusBarService;->mContentResolver:Landroid/content/ContentResolver;

    const-string v4, "airplane_mode_on"

    const/4 v5, 0x0

    invoke-static {v3, v4, v5}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

    move-result v2

    if-nez v2, :exit

    invoke-static {}, Landroid/bluetooth/BluetoothAdapter;->getDefaultAdapter()Landroid/bluetooth/BluetoothAdapter;

    move-result-object v0

    if-eqz v0, :exit
	
    const/4 v5, 0x1
	
    const-string v3, "bluetooth"

    invoke-static {v3}, Landroid/os/ServiceManager;->checkService(Ljava/lang/String;)Landroid/os/IBinder;

    move-result-object v3

    invoke-static {v3}, Landroid/bluetooth/IBluetooth$Stub;->asInterface(Landroid/os/IBinder;)Landroid/bluetooth/IBluetooth;

    move-result-object v2
	
    invoke-interface {v2}, Landroid/bluetooth/IBluetooth;->getBluetoothState()I

    move-result v3

    const/16 v4, 0xc

    if-ne v3, v4, :toggleOn
	
    :toggleOff
	
    const-string v4, "Disabling Bluetooth"

    invoke-static {v1, v4}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I
	
    invoke-interface {v2, v5}, Landroid/bluetooth/IBluetooth;->disable(Z)Z

    goto :exit

    :toggleOn
	
    const/16 v4, 0xa

    if-ne v3, v4, :exit
	
    const-string v4, "Enabling Bluetooth"

    invoke-static {v1, v4}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    invoke-interface {v2, v5}, Landroid/bluetooth/IBluetooth;->enable(Z)Z
	
    :exit
	
    return-void
	
.end method
I added flashables to this post use the stock updater to install, these should
be compatible with any JI6 based ROM because I don't think there are a lot
of mods for /system/framework/services.*. I also killed the battery full notification.

EDIT:

added 3 state toggle to the silent button so now you can toggle from Ringer on --> Vibrate --> Silent

below is the replacement onClick method com/android/server/status/StatusBarService$33
which is in the services file in framework.

Code:
.method public onClick(Landroid/view/View;)V
    .registers 7
    .parameter "v"

    .prologue
    const/4 v2, 0x0
	
    const/4 v3, 0x1
	
    const/4 v4, 0x2

    .line 3641
    iget-object v0, p0, Lcom/android/server/status/StatusBarService$33;->this$0:Lcom/android/server/status/StatusBarService;

    iget-boolean v0, v0, Lcom/android/server/status/StatusBarService;->mSilentStatus:Z

    if-nez v0, :cond_10

    .line 3642
    iget-object v0, p0, Lcom/android/server/status/StatusBarService$33;->this$0:Lcom/android/server/status/StatusBarService;

    iget-object v0, v0, Lcom/android/server/status/StatusBarService;->mContentResolver:Landroid/content/ContentResolver;

    const-string v1, "driving_mode_on"

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

    .line 3646
    :cond_10
    iget-object v0, p0, Lcom/android/server/status/StatusBarService$33;->this$0:Lcom/android/server/status/StatusBarService;

    iget-object v0, v0, Lcom/android/server/status/StatusBarService;->mContext:Landroid/content/Context;

    const-string v1, "audio"

    invoke-virtual {v0, v1}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/media/AudioManager;

    iget-object v1, p0, Lcom/android/server/status/StatusBarService$33;->this$0:Lcom/android/server/status/StatusBarService;

    iget v1, v1, Lcom/android/server/status/StatusBarService;->mSoundProfile:I

    if-eqz v1, :ringerOn
	
    if-eq v1, v4, :vibrate

    if-eq v1, v3, :ringerOff

    :ringerOn

    move v1, v4
	
    :goto_23
    invoke-virtual {v0, v1}, Landroid/media/AudioManager;->setRingerMode(I)V

    .line 3648
    return-void

    :ringerOff
	
    move v1, v2
	
    goto :goto_23

    :vibrate
	
    	iget-object v1, p0, Lcom/android/server/status/StatusBarService$33;->this$0:Lcom/android/server/status/StatusBarService;

	iget-object v1, v1, Lcom/android/server/status/StatusBarService;->mContext:Landroid/content/Context;

    const-string v2, "vibrator"

    invoke-virtual {v1, v2}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Landroid/os/Vibrator;

    const-wide/16 v2, 0x32

    invoke-virtual {v1, v2, p3}, Landroid/os/Vibrator;->vibrate(J)V	

    const/4 v1, 0x1
	
    goto :goto_23

.end method
replacement method for StatusBarService.smali, this enables the 3 icons for the silent button.

you also have to add the image resource to twframework-res.apk and a line in public.xml

Code:
<public type="drawable" name="quick_panel_icon_vibrate" id="0x020200d8" />
Code:
.method private prepareQuickPanelSettingIcon(I)V
    .registers 7
    .parameter "mask"

    .prologue
    .line 1344
    const/4 v2, 0x0

    .line 1345
    .local v2, textColor:I
    const/4 v0, 0x0

    .line 1346
    .local v0, btnTextView:Landroid/widget/TextView;
    const/4 v1, 0x0

    .line 1348
    .local v1, settingIcon:Landroid/graphics/drawable/Drawable;
    packed-switch p1, :pswitch_data_c6

    .line 1400
    :goto_6
    :pswitch_6
    invoke-direct {p0, v0, v1, v2}, Lcom/android/server/status/StatusBarService;->updateQuickPanelSettingIcon(Landroid/widget/TextView;Landroid/graphics/drawable/Drawable;I)V

    .line 1401
    return-void

    .line 1350
    :pswitch_a
    iget-object v0, p0, Lcom/android/server/status/StatusBarService;->mWiFiBtn:Landroid/widget/TextView;

    .line 1352
    iget-boolean v3, p0, Lcom/android/server/status/StatusBarService;->mWiFiStatus:Z

    if-eqz v3, :cond_2a

    .line 1353
    iget-object v3, p0, Lcom/android/server/status/StatusBarService;->mContext:Landroid/content/Context;

    invoke-virtual {v3}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v3

    const v4, 0x2020062

    invoke-virtual {v3, v4}, Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;

    move-result-object v1

    .line 1354
    const v2, -0xff8b34

    .line 1355
    iget-object v3, p0, Lcom/android/server/status/StatusBarService;->mWiFiBtn:Landroid/widget/TextView;

    const-string v4, "WI-FI(ON)"

    invoke-virtual {v3, v4}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    .line 1360
    :goto_27
    iget-object v0, p0, Lcom/android/server/status/StatusBarService;->mWiFiBtn:Landroid/widget/TextView;

    .line 1361
    goto :goto_6

    .line 1357
    :cond_2a
    iget-object v3, p0, Lcom/android/server/status/StatusBarService;->mContext:Landroid/content/Context;

    invoke-virtual {v3}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v3

    const v4, 0x202005f

    invoke-virtual {v3, v4}, Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;

    move-result-object v1

    .line 1358
    const/4 v2, -0x1

    goto :goto_27

    .line 1364
    :pswitch_39
    iget-object v0, p0, Lcom/android/server/status/StatusBarService;->mBTBtn:Landroid/widget/TextView;

    .line 1366
    iget-boolean v3, p0, Lcom/android/server/status/StatusBarService;->mBTStatus:Z

    if-eqz v3, :cond_50

    .line 1367
    iget-object v3, p0, Lcom/android/server/status/StatusBarService;->mContext:Landroid/content/Context;

    invoke-virtual {v3}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v3

    const v4, 0x202005d

    invoke-virtual {v3, v4}, Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;

    move-result-object v1

    .line 1368
    const v2, -0xff8b34

    goto :goto_6

    .line 1370
    :cond_50
    iget-object v3, p0, Lcom/android/server/status/StatusBarService;->mContext:Landroid/content/Context;

    invoke-virtual {v3}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v3

    const v4, 0x202005c

    invoke-virtual {v3, v4}, Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;

    move-result-object v1

    .line 1371
    const/4 v2, -0x1

    .line 1373
    goto :goto_6

    .line 1376
    :pswitch_5f
    iget-object v0, p0, Lcom/android/server/status/StatusBarService;->mSoundBtn:Landroid/widget/TextView;

    .line 1378
    iget v3, p0, Lcom/android/server/status/StatusBarService;->mSoundProfile:I

    const/4 v2, 0x2

    if-eq v3, v2, :cond_8c

    const/4 v2, 0x1

    if-eq v3, v2, :cond_7a

    .line 1379
    iget-object v3, p0, Lcom/android/server/status/StatusBarService;->mContext:Landroid/content/Context;

    invoke-virtual {v3}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v3

    const v4, 0x20200b3

    invoke-virtual {v3, v4}, Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;

    move-result-object v1

    .line 1380
    const v2, -0xff8b34

    goto :goto_6

    :cond_7a
    iget-object v3, p0, Lcom/android/server/status/StatusBarService;->mContext:Landroid/content/Context;

    invoke-virtual {v3}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v3

    const v4, 0x20200d8

    invoke-virtual {v3, v4}, Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;

    move-result-object v1

    .line 1380
    const v2, -0xff8b34

    goto/16 :goto_6

    .line 1382
    :cond_8c
    iget-object v3, p0, Lcom/android/server/status/StatusBarService;->mContext:Landroid/content/Context;

    invoke-virtual {v3}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v3

    const v4, 0x20200b2

    invoke-virtual {v3, v4}, Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;

    move-result-object v1

    .line 1383
    const/4 v2, -0x1

    .line 1385
    goto/16 :goto_6

    .line 1388
    :pswitch_9c
    iget-object v0, p0, Lcom/android/server/status/StatusBarService;->mGpsBtn:Landroid/widget/TextView;

    .line 1390
    iget-boolean v3, p0, Lcom/android/server/status/StatusBarService;->mGpsStatus:Z

    if-eqz v3, :cond_b4

    .line 1391
    iget-object v3, p0, Lcom/android/server/status/StatusBarService;->mContext:Landroid/content/Context;

    invoke-virtual {v3}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v3

    const v4, 0x202005e

    invoke-virtual {v3, v4}, Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;

    move-result-object v1

    .line 1392
    const v2, -0xff8b34

    goto/16 :goto_6

    .line 1394
    :cond_b4
    iget-object v3, p0, Lcom/android/server/status/StatusBarService;->mContext:Landroid/content/Context;

    invoke-virtual {v3}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v3

    const v4, 0x20200b4

    invoke-virtual {v3, v4}, Landroid/content/res/Resources;->getDrawable(I)Landroid/graphics/drawable/Drawable;

    move-result-object v1

    .line 1395
    const/4 v2, -0x1

    goto/16 :goto_6

    .line 1348
    nop

    nop

    :pswitch_data_c6
    .packed-switch 0x1
        :pswitch_a
        :pswitch_39
        :pswitch_6
        :pswitch_5f
        :pswitch_6
        :pswitch_6
        :pswitch_6
        :pswitch_9c
    .end packed-switch
.end method
Attached Images
 
Attached Files
File Type: zip JI6_deodex.zip - [Click for QR Code] (971.6 KB, 46 views)
File Type: zip JI6_stock.zip - [Click for QR Code] (967.9 KB, 42 views)
 
mikey98277
Old
#2  
mikey98277's Avatar
Senior Member
Thanks Meter 7
Posts: 259
Join Date: May 2009
Location: Jamestown

 
DONATE TO ME
Sounds great, one less widget I will have to use, any way someone could make it a flashable zip so us none coders can use it?
If I help you please hit the thanks button!

Phone: Straight Talk Samsung Galaxy S III
ROM: STOCK
Radio: STOCK
Recovery: STOCK

Old Phones:
Straight Talk Samsung Galaxy S II (Died)
Sprint Samsung Galaxy Nexus(Retired)
HTC Inspire 4G(Retired)
Samsung Vibrant (Retired)
Samsung Captivate (Died)
G1 (Retired)


"GOOGLE now controls my entire life...and I'm loving it!!!"
 
untermensch
Old
#3  
untermensch's Avatar
Senior Member - OP
Thanks Meter 617
Posts: 480
Join Date: Apr 2009
Location: Portland
I added flashables to this thread use the stock updater to install, these should
be compatible with any JI6 based ROM because I don't think there are a lot
of mods for /system/framework/services.*. I also killed the battery full notification.
which I don't think any one will miss.
 
s0niqu3
Old
#4  
s0niqu3's Avatar
Senior Member
Thanks Meter 388
Posts: 716
Join Date: Feb 2005

 
DONATE TO ME
Quote:
Originally Posted by untermensch View Post
s0niqu3 brought it to my attention how much the status bar bluetooth toggle
sucked so I changed the onClick method to toggle the bluetooth state instead
of opening settings to the bluetooth page

this is the replacement method for com/android/server/status/StatusBarService$31
which is in the services file in framework.

Code:
.method public onClick(Landroid/view/View;)V
    .registers 7
    .parameter "v"

    .prologue
    const-string v1, "StatusBar"

    iget-object v3, p0, Lcom/android/server/status/StatusBarService$31;->this$0:Lcom/android/server/status/StatusBarService;

    iget-object v3, v3, Lcom/android/server/status/StatusBarService;->mContentResolver:Landroid/content/ContentResolver;

    const-string v4, "airplane_mode_on"

    const/4 v5, 0x0

    invoke-static {v3, v4, v5}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

    move-result v2

    if-nez v2, :exit

    invoke-static {}, Landroid/bluetooth/BluetoothAdapter;->getDefaultAdapter()Landroid/bluetooth/BluetoothAdapter;

    move-result-object v0

    if-eqz v0, :exit
	
    const/4 v5, 0x1
	
    const-string v3, "bluetooth"

    invoke-static {v3}, Landroid/os/ServiceManager;->checkService(Ljava/lang/String;)Landroid/os/IBinder;

    move-result-object v3

    invoke-static {v3}, Landroid/bluetooth/IBluetooth$Stub;->asInterface(Landroid/os/IBinder;)Landroid/bluetooth/IBluetooth;

    move-result-object v2
	
    invoke-interface {v2}, Landroid/bluetooth/IBluetooth;->getBluetoothState()I

    move-result v3

    const/16 v4, 0xc

    if-ne v3, v4, :toggleOn
	
    :toggleOff
	
    const-string v4, "Disabling Bluetooth"

    invoke-static {v1, v4}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I
	
    invoke-interface {v2, v5}, Landroid/bluetooth/IBluetooth;->disable(Z)Z

    goto :exit

    :toggleOn
	
    const/16 v4, 0xa

    if-ne v3, v4, :exit
	
    const-string v4, "Enabling Bluetooth"

    invoke-static {v1, v4}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    invoke-interface {v2, v5}, Landroid/bluetooth/IBluetooth;->enable(Z)Z
	
    :exit
	
    return-void
	
.end method
I added flashables to this post use the stock updater to install, these should
be compatible with any JI6 based ROM because I don't think there are a lot
of mods for /system/framework/services.*. I also killed the battery full notification.
Thanks again for everything you've done, glad to have so many annoying samsung bugs fixed by such awesome people in the community.

Cheers, =)
~Jocelyn
@jocelyndev
fork me on github
Apparently posting personal signatures outside of this little block is too offensive for some.
 
murse
Old
#5  
murse's Avatar
Senior Member
Thanks Meter 28
Posts: 277
Join Date: Dec 2008
Thanks for a fix to a very annoying issue. Noob question: which of these would I use with the Bionix. ROMs?


Sent from my SGH-T959 using XDA App
 
s0niqu3
Old
#6  
s0niqu3's Avatar
Senior Member
Thanks Meter 388
Posts: 716
Join Date: Feb 2005

 
DONATE TO ME
Quote:
Originally Posted by murse View Post
Thanks for a fix to a very annoying issue. Noob question: which of these would I use with the Bionix. ROMs?


Sent from my SGH-T959 using XDA App
Hi,

I can't guarantee anything, but always try the JI6 deodexed version on the bionix roms first.

Cheers, =)
~Jocelyn
@jocelyndev
fork me on github
Apparently posting personal signatures outside of this little block is too offensive for some.
 
mikey98277
Old
(Last edited by mikey98277; 23rd October 2010 at 09:56 PM.)
#7  
mikey98277's Avatar
Senior Member
Thanks Meter 7
Posts: 259
Join Date: May 2009
Location: Jamestown

 
DONATE TO ME
Not sure why but JI6 deodexed would not install in clockwork, just got stuck saying installing update, So i just had to just pull the services.jar and use root explorer and pasted it in system/framework. It hung when restarting, but then I rebooted into recovery wiped both caches and that fixed the hang issue. Works great thanks for this. One of these days I will learn some coding stuff so i can do it myself.

For those interested, that is what i had to do to get it to work on fusion1.1 with the King Klicks Kernel.
If I help you please hit the thanks button!

Phone: Straight Talk Samsung Galaxy S III
ROM: STOCK
Radio: STOCK
Recovery: STOCK

Old Phones:
Straight Talk Samsung Galaxy S II (Died)
Sprint Samsung Galaxy Nexus(Retired)
HTC Inspire 4G(Retired)
Samsung Vibrant (Retired)
Samsung Captivate (Died)
G1 (Retired)


"GOOGLE now controls my entire life...and I'm loving it!!!"
 
a400meter
Old
(Last edited by a400meter; 23rd October 2010 at 10:07 PM.)
#8  
a400meter's Avatar
Member
Thanks Meter 16
Posts: 82
Join Date: Aug 2009
Quote:
Originally Posted by mikey98277 View Post
Not sure why but it would not install in clockwork, just got stuck saying installing update, So i just had to just pull the services.jar and use root explorer and pasted it in system/framework. It hung when restarting, but then I rebooted into recovery wiped both caches and that fixed the hang issue. Works great thanks for this. One of these days I will learn some coding stuff so i can do it myself.

For those interested, that is what i had to do to get it to work on fusion1.1 with the King Klicks Kernel.

FYI, the flashable update.zip is in the download file.


EDIT: Just installed on Bionix FINAL and the bluetooth status update works great. Nice addition. Haven't tried to charge 100%, but I certainly won't miss that notification. Thanks untermensch for all of your mods!!!
Phone: Nexus 4 | Retired Vibrant | MT3G
 
mikey98277
Old
#9  
mikey98277's Avatar
Senior Member
Thanks Meter 7
Posts: 259
Join Date: May 2009
Location: Jamestown

 
DONATE TO ME
[QUOTE=a400meter;8782815]FYI, the flashable update.zip is in the download file.


Not sure what you meant by that, As I said I tried the update.zip file and it did not work on Fusion 1.1 with KK Kernel. So I pulled the file from it and pushed it manually.
If I help you please hit the thanks button!

Phone: Straight Talk Samsung Galaxy S III
ROM: STOCK
Radio: STOCK
Recovery: STOCK

Old Phones:
Straight Talk Samsung Galaxy S II (Died)
Sprint Samsung Galaxy Nexus(Retired)
HTC Inspire 4G(Retired)
Samsung Vibrant (Retired)
Samsung Captivate (Died)
G1 (Retired)


"GOOGLE now controls my entire life...and I'm loving it!!!"
 
gbzbar
Old
#10  
Senior Member
Thanks Meter 381
Posts: 696
Join Date: Jun 2010

 
DONATE TO ME
[QUOTE=mikey98277;8783297]
Quote:
Originally Posted by a400meter View Post
FYI, the flashable update.zip is in the download file.


Not sure what you meant by that, As I said I tried the update.zip file and it did not work on Fusion 1.1 with KK Kernel. So I pulled the file from it and pushed it manually.
What that means is that the update.zip file that is located inside the zip you downloaded is not meant to be installed through clockwork, but instead through the stock phone recovery menu. Replace the clockwork update.zip on your internal memory with the downloaded one, and then go to the phone recovery and hit "Reinstall Packages".

I know you already installed the file manually, the clarification is more for others who may need help.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


XDA PORTAL POSTS

How to Root the Sony Xperia Z2 – XDA Developer TV

In this episode,XDA Developer TV Producer TK shows you how to root your Sony Xperia … more

TWRP Now Available for the LG G Watch and Samsung Gear Live

Over the past week or so, we’ve talkedquite a bit about the first … more

Slate Calendar Helps You Organize Your Life

Without calendars in some form or another, most of our lives would be utter chaos. Unless you are … more

Shane Francis to Talk Android, Robotics, and Vision at XDA:DevCon 2014

Our international xda:devcon 14in Manchester, UK on the weekend of … more