[PATCH] GSM/WCDMA Network BUG FIX [ICS]

serajr

Recognized Developer / Recognized Themer
Apr 21, 2011
5,011
18,603
263
São Paulo - SP
Found!!!

Anyone, please? what specific part of RIL.smali was changed? so I won't replace my RIL.smali.. maybe that will lessen the chances of Force close..

I´ve found exactly where the code is, and here is a simple guide showing how to patch your own RIL.smali file:

Try at your own risk

1. Inside RIL.smali file look for blue lines at the end of processUnsolicited method:
Code:
.method private [B]processUnsolicited[/B](Landroid/os/Parcel;)V
    .registers 27
    .parameter "p"

    .prologue
    .line 2611
    invoke-virtual/range {p1 .. p1}, Landroid/os/Parcel;->readInt()I

    .
    .
    .
    .
    .
    .
    .
    .

    .line 2977
    :pswitch_687
    move-object/from16 v0, p0

    move-object/from16 v1, v16

    invoke-direct {v0, v14, v1}, Lcom/android/internal/telephony/RIL;->unsljLogRet(ILjava/lang/Object;)V

    .line 2979
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/internal/telephony/BaseCommands;->mExitEmergencyCallbackModeRegistrants:Landroid/os/RegistrantList;

    move-object/from16 v20, v0

    if-eqz v20, :cond_4b

    .line 2980
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/internal/telephony/BaseCommands;->mExitEmergencyCallbackModeRegistrants:Landroid/os/RegistrantList;

    move-object/from16 v20, v0

    new-instance v21, Landroid/os/AsyncResult;

    const/16 v22, 0x0

    const/16 v23, 0x0

    const/16 v24, 0x0

    invoke-direct/range {v21 .. v24}, Landroid/os/AsyncResult;-><init>(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Throwable;)V

    invoke-virtual/range {v20 .. v21}, Landroid/os/RegistrantList;->notifyRegistrants(Landroid/os/AsyncResult;)V

    goto/16 :goto_4b

    .line 2986
    [COLOR="blue"][B]:pswitch_6ac
    move-object/from16 v0, p0

    move-object/from16 v1, v16

    invoke-direct {v0, v14, v1}, Lcom/android/internal/telephony/RIL;->unsljLogRet(ILjava/lang/Object;)V[/B][/COLOR]	
	
    .line 2992
    check-cast v16, [I

    check-cast v16, [I

    const/16 v20, 0x0

    aget v20, v16, v20

    move-object/from16 v0, p0

    move/from16 v1, v20

    invoke-direct {v0, v1}, Lcom/android/internal/telephony/RIL;->notifyRegistrantsRilConnectionChanged(I)V

    goto/16 :goto_4b

    .line 2613
    nop

    :pswitch_data_6f4
    .packed-switch 0x3e8
        :pswitch_4c
        :pswitch_71
        :pswitch_76
        :pswitch_7b
        :pswitch_80
        :pswitch_85
        :pswitch_8a
        :pswitch_7
        :pswitch_8f
        :pswitch_94
        :pswitch_99
        :pswitch_9e
        :pswitch_a3
        :pswitch_a8
        :pswitch_ad
        :pswitch_b2
        :pswitch_b7
        :pswitch_bc
        :pswitch_c1
        :pswitch_cb
        :pswitch_d0
        :pswitch_d6
        :pswitch_dc
        :pswitch_c6
        :pswitch_e2
        :pswitch_e8
        :pswitch_ee
        :pswitch_f4
        :pswitch_fa
        :pswitch_100
        :pswitch_106
        :pswitch_10c
        :pswitch_112
        :pswitch_118
        :pswitch_11e
        :pswitch_7
        :pswitch_124
    .end packed-switch

    .line 2664
    :pswitch_data_742
    .packed-switch 0x3e8
        :pswitch_54
        :pswitch_12a
        :pswitch_145
        :pswitch_160
        :pswitch_199
        :pswitch_1c4
        :pswitch_223
        :pswitch_53
        :pswitch_27b
        :pswitch_2c0
        :pswitch_2e4
        :pswitch_307
        :pswitch_332
        :pswitch_35b
        :pswitch_386
        :pswitch_3b1
        :pswitch_3dc
        :pswitch_3f4
        :pswitch_41f
        :pswitch_475
        :pswitch_48d
        :pswitch_4ba
        :pswitch_4e3
        :pswitch_44a
        :pswitch_4fb
        :pswitch_513
        :pswitch_53e
        :pswitch_569
        :pswitch_597
        :pswitch_5cc
        :pswitch_606
        :pswitch_631
        :pswitch_65c
        :pswitch_687
        [B][COLOR="Blue"]:pswitch_6ac[/COLOR][/B]
    .end packed-switch
.end method
Here a curiousity: Pay attention to the blue value above >> pswitch_6ac << this is the line where the "switch" will jump when the "switch" given value is RIL_UNSOL_RIL_CONNECTED (1034), now speaking java (this is not part of guide):
Code:
case [B]RIL_UNSOL_RIL_CONNECTED[/B]: {
	if (RILJ_LOGD) unsljLogRet(response, ret);
	
	// Initial conditions
	[B][COLOR="Red"]setRadioPower(false, null);
	setPreferredNetworkType(mPreferredNetworkType, null);
	setCdmaSubscriptionSource(mCdmaSubscription, null);[/COLOR][/B]
	notifyRegistrantsRilConnectionChanged(((int[])ret)[0]);
	break;
}
Now let´s put the red lines above as smali inside the "switch", that is the patch itself!!

2. Add some empty lines between blue and green lines:
Code:
    .line 2986
    [B][COLOR="Blue"]:pswitch_6ac
    move-object/from16 v0, p0

    move-object/from16 v1, v16

    invoke-direct {v0, v14, v1}, Lcom/android/internal/telephony/RIL;->unsljLogRet(ILjava/lang/Object;)V[/COLOR][/B]	
    
    


    




    [B][COLOR="SeaGreen"].line 2992
    check-cast v16, [I

    check-cast v16, [I

    const/16 v20, 0x0

    aget v20, v16, v20

    move-object/from16 v0, p0

    move/from16 v1, v20

    invoke-direct {v0, v1}, Lcom/android/internal/telephony/RIL;->notifyRegistrantsRilConnectionChanged(I)V

    goto/16 :goto_4b

    .line 2613
    nop[/COLOR][/B]
3. Add red smali lines and you´ll get:
Code:
    .line 2986
    [COLOR="blue"][B]:pswitch_6ac
    move-object/from16 v0, p0

    move-object/from16 v1, v16

    invoke-direct {v0, v14, v1}, Lcom/android/internal/telephony/RIL;->unsljLogRet(ILjava/lang/Object;)V[/B][/COLOR]	
    
 
    
    
    [B][COLOR="Red"].line 2989
    const/16 v20, 0x0

    const/16 v21, 0x0

    move-object/from16 v0, p0

    move/from16 v1, v20

    move-object/from16 v2, v21

    invoke-virtual {v0, v1, v2}, Lcom/android/internal/telephony/RIL;->setRadioPower(ZLandroid/os/Message;)V

    .line 2990
    move-object/from16 v0, p0

    iget v0, v0, Lcom/android/internal/telephony/BaseCommands;->mPreferredNetworkType:I

    move/from16 v20, v0

    const/16 v21, 0x0

    move-object/from16 v0, p0

    move/from16 v1, v20

    move-object/from16 v2, v21

    invoke-virtual {v0, v1, v2}, Lcom/android/internal/telephony/RIL;->setPreferredNetworkType(ILandroid/os/Message;)V

    .line 2991
    move-object/from16 v0, p0

    iget v0, v0, Lcom/android/internal/telephony/BaseCommands;->mCdmaSubscription:I

    move/from16 v20, v0

    const/16 v21, 0x0

    move-object/from16 v0, p0

    move/from16 v1, v20

    move-object/from16 v2, v21

    invoke-virtual {v0, v1, v2}, Lcom/android/internal/telephony/RIL;->setCdmaSubscriptionSource(ILandroid/os/Message;)V[/COLOR][/B]    




    [B][COLOR="SeaGreen"].line 2992
    check-cast v16, [I

    check-cast v16, [I

    const/16 v20, 0x0

    aget v20, v16, v20

    move-object/from16 v0, p0

    move/from16 v1, v20

    invoke-direct {v0, v1}, Lcom/android/internal/telephony/RIL;->notifyRegistrantsRilConnectionChanged(I)V

    goto/16 :goto_4b

    .line 2613
    nop[/COLOR][/B]
(You can leave the empty lines, compiler will remove them)

4. Save file and close it.
5. Done!!

Now compile your new framework.jar classes.dex!!! I hope the guide helps you... ;)
And thanks trojan01 and savel-76
 
Last edited:

00DSoul00

Senior Member
May 18, 2012
137
8
0
Quito
greetings! I have my SK17 with Android 4.0 (official .587) anyone can help me to put the zip through CWM, I have only led the final fix I have not any modification more ... thank you!
 

adulfo

Senior Member
Apr 26, 2012
1,190
755
0
Pagadian City
Sad to say that the patch will affect the features of G-MON... If I will use the patch, 0 Neighboring Cells will be detected. G-MON is very important to my job...

I'll try serajr's method and will report...

Thanks..

Edit:

Everything works after using serajr's method... Upon comparing, there are 17 lines of invoke-direct {v0, v14, v1}, Lcom/android/internal/telephony/RIL;->unsljLogRet(ILjava/lang/Object;)V on the OP's patch so maybe this patch has overdid it whereas on serajr's there is only one and it works perfectly with my G-MON..

Attached for those who want it... It is in .587 official with 30 volume step FW.
 

Attachments

Last edited:
  • Like
Reactions: iflawlietasgod

RajeshNethaniah

Senior Member
Jun 29, 2013
105
12
0
Hyderabad
Xposed Module

Hi, is there any Xposed Module for this or can anyone make it to fix this issue? Because it would avoid all this process/procedure.

Please let me know if there is one already. Thanks :good:

PS: Please excuse my language :p
 

luweitest

Member
Oct 25, 2013
18
7
0
Thank you trojan01 and serajr. Your posts shed some light on a similar problem of Moto Defy: Network preference is set to GSM 2G only, but after running for some time, it will get stuck into "wcdma preferred" (seen from *#*#4636#*#* testing), and any function relates to mobile network fails (cannot call, receive call, hang up, data packet transfer, turn off radio, etc) in spite of good signal (-50~-60dbm, maybe it's WCDMA signal which I cannot use). The problem occurs most frequently when the real GSM sigal is weak, or when at night (lower temperature). Battery drains very quickly at this state. Only reboot can recover the phone to normal for some time temporary.

I tried your method of modifying RIL.smali, but with no luck, maybe because Defy has a different RIL.smali? I'll paste some of it below:

Code:
.method protected processUnsolicited(Landroid/os/Parcel;)V
    .registers 28
    .param p1, "p"    # Landroid/os/Parcel;
...
<snip>
...
    .line 2737
    :pswitch_63c
    move-object/from16 v0, p0

    move v1, v15

    move-object/from16 v2, v17

    invoke-virtual {v0, v1, v2}, Lcom/android/internal/telephony/RIL;->unsljLogRet(ILjava/lang/Object;)V

    .line 2739
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/internal/telephony/RIL;->mResendIncallMuteRegistrants:Landroid/os/RegistrantList;

    move-object/from16 v21, v0

    if-eqz v21, :cond_4f

    .line 2740
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/internal/telephony/RIL;->mResendIncallMuteRegistrants:Landroid/os/RegistrantList;

    move-object/from16 v21, v0

    new-instance v22, Landroid/os/AsyncResult;

    const/16 v23, 0x0

    const/16 v24, 0x0

    move-object/from16 v0, v22

    move-object/from16 v1, v23

    move-object/from16 v2, v17

    move-object/from16 v3, v24

    invoke-direct {v0, v1, v2, v3}, Landroid/os/AsyncResult;-><init>(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Throwable;)V

    invoke-virtual/range {v21 .. v22}, Landroid/os/RegistrantList;->notifyRegistrants(Landroid/os/AsyncResult;)V

    goto/16 :goto_4f

    .line 2399
    :pswitch_data_668
    .packed-switch 0x3e8
        :pswitch_50
        :pswitch_77
        :pswitch_7c
        :pswitch_81
        :pswitch_86
        :pswitch_8b
        :pswitch_90
        :pswitch_7
        :pswitch_95
        :pswitch_9a
        :pswitch_9f
        :pswitch_a4
        :pswitch_a9
        :pswitch_ae
        :pswitch_b3
        :pswitch_b8
        :pswitch_bd
        :pswitch_c2
        :pswitch_c7
        :pswitch_d1
        :pswitch_d7
        :pswitch_dd
        :pswitch_e3
        :pswitch_cc
        :pswitch_e9
        :pswitch_ef
        :pswitch_f5
        :pswitch_fb
        :pswitch_101
        :pswitch_107
        :pswitch_10d
    .end packed-switch

    .line 2446
    :pswitch_data_6aa
    .packed-switch 0x3e8
        :pswitch_58
        :pswitch_113
        :pswitch_12f
        :pswitch_14b
        :pswitch_186
        :pswitch_1b2
        :pswitch_214
        :pswitch_57
        :pswitch_273
        :pswitch_2bf
        :pswitch_2e3
        :pswitch_307
        :pswitch_333
        :pswitch_35d
        :pswitch_389
        :pswitch_3b5
        :pswitch_3e1
        :pswitch_3fa
        :pswitch_426
        :pswitch_47e
        :pswitch_497
        :pswitch_4c7
        :pswitch_4f1
        :pswitch_452
        :pswitch_50a
        :pswitch_523
        :pswitch_54f
        :pswitch_57b
        :pswitch_5ad
        :pswitch_5fb
        :pswitch_63c
    .end packed-switch
.end method
What I have tried is inserting your red line codes before ".line 2739" and modified the number to 2738, deleted the other two numbers.

If you would like, the whole RIL.smali is in the attachment. Thanks for anybody who is willing to help!
 

Attachments

serajr

Recognized Developer / Recognized Themer
Apr 21, 2011
5,011
18,603
263
São Paulo - SP
Thank you trojan01 and serajr. Your posts shed some light on a similar problem of Moto Defy: Network preference is set to GSM 2G only, but after running for some time, it will get stuck into "wcdma preferred" (seen from *#*#4636#*#* testing), and any function relates to mobile network fails (cannot call, receive call, hang up, data packet transfer, turn off radio, etc) in spite of good signal (-50~-60dbm, maybe it's WCDMA signal which I cannot use). The problem occurs most frequently when the real GSM sigal is weak, or when at night (lower temperature). Battery drains very quickly at this state. Only reboot can recover the phone to normal for some time temporary.

I tried your method of modifying RIL.smali, but with no luck, maybe because Defy has a different RIL.smali? I'll paste some of it below:

Code:
.method protected processUnsolicited(Landroid/os/Parcel;)V
    .registers 28
    .param p1, "p"    # Landroid/os/Parcel;
...
<snip>
...
    .line 2737
    :pswitch_63c
    move-object/from16 v0, p0

    move v1, v15

    move-object/from16 v2, v17

    invoke-virtual {v0, v1, v2}, Lcom/android/internal/telephony/RIL;->unsljLogRet(ILjava/lang/Object;)V

    .line 2739
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/internal/telephony/RIL;->mResendIncallMuteRegistrants:Landroid/os/RegistrantList;

    move-object/from16 v21, v0

    if-eqz v21, :cond_4f

    .line 2740
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/internal/telephony/RIL;->mResendIncallMuteRegistrants:Landroid/os/RegistrantList;

    move-object/from16 v21, v0

    new-instance v22, Landroid/os/AsyncResult;

    const/16 v23, 0x0

    const/16 v24, 0x0

    move-object/from16 v0, v22

    move-object/from16 v1, v23

    move-object/from16 v2, v17

    move-object/from16 v3, v24

    invoke-direct {v0, v1, v2, v3}, Landroid/os/AsyncResult;-><init>(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Throwable;)V

    invoke-virtual/range {v21 .. v22}, Landroid/os/RegistrantList;->notifyRegistrants(Landroid/os/AsyncResult;)V

    goto/16 :goto_4f

    .line 2399
    :pswitch_data_668
    .packed-switch 0x3e8
        :pswitch_50
        :pswitch_77
        :pswitch_7c
        :pswitch_81
        :pswitch_86
        :pswitch_8b
        :pswitch_90
        :pswitch_7
        :pswitch_95
        :pswitch_9a
        :pswitch_9f
        :pswitch_a4
        :pswitch_a9
        :pswitch_ae
        :pswitch_b3
        :pswitch_b8
        :pswitch_bd
        :pswitch_c2
        :pswitch_c7
        :pswitch_d1
        :pswitch_d7
        :pswitch_dd
        :pswitch_e3
        :pswitch_cc
        :pswitch_e9
        :pswitch_ef
        :pswitch_f5
        :pswitch_fb
        :pswitch_101
        :pswitch_107
        :pswitch_10d
    .end packed-switch

    .line 2446
    :pswitch_data_6aa
    .packed-switch 0x3e8
        :pswitch_58
        :pswitch_113
        :pswitch_12f
        :pswitch_14b
        :pswitch_186
        :pswitch_1b2
        :pswitch_214
        :pswitch_57
        :pswitch_273
        :pswitch_2bf
        :pswitch_2e3
        :pswitch_307
        :pswitch_333
        :pswitch_35d
        :pswitch_389
        :pswitch_3b5
        :pswitch_3e1
        :pswitch_3fa
        :pswitch_426
        :pswitch_47e
        :pswitch_497
        :pswitch_4c7
        :pswitch_4f1
        :pswitch_452
        :pswitch_50a
        :pswitch_523
        :pswitch_54f
        :pswitch_57b
        :pswitch_5ad
        :pswitch_5fb
        :pswitch_63c
    .end packed-switch
.end method
What I have tried is inserting your red line codes before ".line 2739" and modified the number to 2738, deleted the other two numbers.

If you would like, the whole RIL.smali is in the attachment. Thanks for anybody who is willing to help!
Bro.. here is your pacthed RIL.smali
Take a look at lines I put following the guide and changes I have made too. I can´t guarantee that it will work, so try at your own risk!!
 

Attachments

luweitest

Member
Oct 25, 2013
18
7
0
Bro.. here is your pacthed RIL.smali
Take a look at lines I put following the guide and changes I have made too. I can´t guarantee that it will work, so try at your own risk!!
Sadly it did not work :( I see that you appended the whole block at the end of the method processUnsolicited. Which switch does it belong? Unlike the original patch for ICS, there is no RIL_UNSOL_RIL_CONNECTED (at the beginning of the file there seems a block defining those values, start from row 1638). Maybe it should be moved to another place? Or maybe even the bug does not relates to unsolicited response or something, but just lost signal and cannot acquire it again?