[Galaxy S II Android Development] Neme77:
Hello friends today I want to share with you this little mod on how to integrate a button to switch 3G/2G in lidroidbar......:laugh:

We need to change 4 packages which include: lidroid-res.apk, the Secphone.apk, the quikpanel.apk and SystemUI.apk

First we have to add the receivers at Secphone.Apk and register them at runtime throug phone app startup..

Download this zip and paste into SecPhone.apk classes

1- Decompile Secphone.apk classes with apktool or simply extract the classes.dex and decompile with smali utility

Find the class PhoneApp.smali ( \com\android\phone ) and add this values : .

field private final mModeReceiver:Landroid/content/BroadcastReceiver; *

.field private mLastNumber:Ljava/lang/String;

.field private mLastPhoneState:Lcom/android/internal/telephony/Phone$State;

.field private mLockPatternUtils:Lcom/android/internal/widget/LockPatternUtils;

.field private final mMediaButtonReceiver:Landroid/content/BroadcastReceiver;

[COLOR=DarkRed].field private final mModeReceiver:Landroid/content/BroadcastReceiver;[/COLOR] *

.field public mMmiInitMsg:Landroid/os/AsyncResult;

Search for new-instance v0, Lcom/android/phone/PhoneApp$PhoneAppBroadcastReceiver;

And after this line add this :

new-instance v0, Lcom/android/phone/NetworkModeReceiver;

invoke-direct {v0}, Lcom/android/phone/NetworkModeReceiver;-><init>()V

iput-object v0, p0, Lcom/android/phone/PhoneApp;->mModeReceiver:Landroid/content/BroadcastReceiver;

Now search this line iget-object v1, p0, Lcom/android/phone/PhoneApp;->mReceiver:Landroid/content/BroadcastReceiver;

and after invoke-virtual {p0, v1, v0}, Lcom/android/phone/PhoneApp;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

Add this code :

new-instance v0, Landroid/content/IntentFilter;

const-string v1, "com.android.phone.CHANGE_NETWORK_MODE"

invoke-direct {v0, v1}, Landroid/content/IntentFilter;-><init>(Ljava/lang/String;)V

iget-object v1, p0, Lcom/android/phone/PhoneApp;->mModeReceiver:Landroid/content/BroadcastReceiver;

invoke-virtual {p0, v1, v0}, Lcom/android/phone/PhoneApp;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

Thats all for Secphone.apk and you can recompile them.....

2- Now we need to add the button values to lidroid-res.apk ( easy part )

Decompile the lidroid framework and add this values to string : <string name="quickpanel_networkmode_text">2G/3G/Auto</string>

After we need to add to drawable-hdmi 3 png image and renaming in stat_gsm_on stat_gsm_off stat_gsm_auto, search for your favorite icon araund the web. Thats all for lidroid framework recompile.

After compiling lidroid-res.apk you need to decompile again and copy the corresponding values from the public file : Example in my case the string

quickpanel_networkmode_text have this value 0x050b0063 ( 0x50b0063 in systemui ), do this even for images that you have added ....We will need these values ​​when we're going to add the button to lidroidbar within the systemui.

3- Add button to lidroid values inside the systemui:

Decompile your SystemUI classes.dex ( where the lidroidbar setting are ) and copy this file inside \com\lidroid\systemui\quickpanel

Search the power button.smali and add this values

[COLOR=DarkRed]sget-object v0, Lcom/lidroid/systemui/quickpanel/PowerButton;->BUTTONS:Ljava/util/HashMap;

const-string v1, "toggleNetworkMode"

const-class v2, Lcom/lidroid/systemui/quickpanel/NetworkModeButton;

invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;[/COLOR]

.line 71
new-instance v0, Ljava/util/HashMap;

invoke-direct {v0}, Ljava/util/HashMap;-><init>()V

sput-object v0, Lcom/lidroid/systemui/quickpanel/PowerButton;->BUTTONS_LOADED:Ljava/util/HashMap;

.line 80
sput-object v3, Lcom/lidroid/systemui/quickpanel/PowerButton;->GLOBAL_ON_CLICK_LISTENER:Landroid/view/View$OnClickListener;

.line 83
sput-object v3, Lcom/lidroid/systemui/quickpanel/PowerButton;->GLOBAL_ON_LONG_CLICK_LISTENER:Landroid/view/View$OnLongClickListener;

return-void
.end method

In case adjust for your directory...

Now enter to com/lidroid/constants/ and open statusbar.smali and add this line:

.field public static final BUTTON_NETWORKMODE:Ljava/lang/String; = "toggleNetworkMode"

Now open out/lidroid and search for R$drawable.smali open and add this values:

.field public static final stat_gsm_on:I = 0x50200ff

.field public static final stat_gsm_off:I = 0x50200fe

.field public static final stat_gsm_auto:I = 0x5020100

adjusted values ​​with those of your lidroid framework.....

Now open R$string.smali and add this line:

.field public static final quickpanel_networkmode_text:I = 0x50b0063

Also adjusted again values ​​with those of your lidroid framework.....

Finally open the file we added before: the "NetworkModeButton.smali"

We have to adjust the values for the image and string take from the lidroid framework....

Thats all for SystemUI you can recompile.....:laugh:

4- Final part...Add toggle in the quikpanel.apk

Decompile the quikpanel.apk and insert this value to string.xml ( inside values/string )

<string name="title_toggle_NetworkMode">Toggle 2G/3G</string>

Compile and after decompile again, We need the string value that we added, take this value...

Now search into smali files the PowerWidjetUtil.smali and add another button like this:

const-string v1, "toggleNetworkMode"

new-instance v2, Lcom/goatrip/statusbar/PowerWidgetUtil$ButtonInfo;

const-string v3, "toggleNetworkMode"

const v4, 0x7f080049

const-string v5, "goatrip:drawable/stat_gsm_on"

invoke-direct {v2, v3, v4, v5}, Lcom/goatrip/statusbar/PowerWidgetUtil$ButtonInfo;-><init>(Ljava/lang/String;ILjava/lang/String;)V

invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

The button structure may be different than mine simply copy and paste a your existing button source.

Now adjust the string value with the one obtained first

Thats all Enjoy;)

If you like this mod simply give me a thanks!!!!!!