How to auto-hide mobile signal icons for empty SIM slots on MTK6589 devices
Introduction
Many users using only one SIM card tend to get fed up with the mobile signal
icon that's always displayed for empty SIM slot in the status bar. This how-to will show you
how to smali hack the SystemUI to make these icons auto-hide - according to presence
of a SIM card in a SIM slots. This is a clean solution - since it will dynamically reflect
which sim slot is in use and which is not. If both SIM slots are used, both icons will be visible.
For devs: It took me several hours to figure out how this could be achieved,
so please, if you decide to use this how-to to include the mod in your custom roms,
I expect you to give proper credits. Thanks in advance.
The guide does not cover things like deodexing/decompiling/compiling/odexing jars and apks.
It expects you already are familiar with these processes.
There are already many guides for those out there.
Solution
1) Decompile SystemUI.apk
2) Open smali/com/android/systemui/statusbar/SignalClusterViewGemini.smali
3) search for "apply" method
4) Make note of constants defined at the beginning of the method.
We will need 0x0, 0x1, and 0x8 later.
v5 = 0x0 - ID for SIM Slot 1
v9 = 0x1 - ID for SIM Slot 2
v6 = 0x8 - constant used to set visibility of a view (0x8 == View.GONE)
5) Search for first occurence of isSimInserted method call in "apply" method
v5 constant which value ix 0x0 is used - this means it checks for SIM presense in Slot 1
As you can see, if a return value of isSimInserted method is equal to zero (if-eqz v4...)
this means that the SIM for tested Slot is not inserted and code execution jumps to label :cond_1f
(label name might be different in your case)
6) Search for label name we found in the previous step to locate the start
of the code section for this label (:cond_1f in my case) Should look similat to this
7) Now add these lines before iget-object v4, p0 (start on new line, right after :cond_1f)
This will reference the ViewGroup containing the signal icon for SIM Slot 1 and set it's visibility to 0x8 (View.GONE)
Make sure you use the correct parameter in setVisibility Call. In my case it's v6 (its value is 0x8)
8) Now search for next occurrence of isSimInserted call in "apply" method - this time for SIM Slot 2
v9 constant which value ix 0x1 is used - this means it checks for SIM presense in Slot 2
As you can see, if a return value of isSimInserted method is equal to zero (if-eqz v4...)
this means that the SIM for tested Slot is not inserted and code execution jumps to label :cond_2f
(label name might be different in your case)
9) Search for label name we found in the previous step to locate the start
of the code section for this label (:cond_2f in my case) Should look similar to this
10) Now add these lines before iget-object v4, p0 (start on new line, right after :cond_2f)
This will reference the ViewGroup containing the signal icon for SIM Slot 2 and set it's visibility to 0x8 (View.GONE)
Make sure you use the correct parameter in setVisibility Call. In my case it's v6 (its value is 0x8)
11) Recompile SystemUI and push it to phone. Done.
Introduction
Many users using only one SIM card tend to get fed up with the mobile signal
icon that's always displayed for empty SIM slot in the status bar. This how-to will show you
how to smali hack the SystemUI to make these icons auto-hide - according to presence
of a SIM card in a SIM slots. This is a clean solution - since it will dynamically reflect
which sim slot is in use and which is not. If both SIM slots are used, both icons will be visible.
For devs: It took me several hours to figure out how this could be achieved,
so please, if you decide to use this how-to to include the mod in your custom roms,
I expect you to give proper credits. Thanks in advance.
The guide does not cover things like deodexing/decompiling/compiling/odexing jars and apks.
It expects you already are familiar with these processes.
There are already many guides for those out there.
Solution
1) Decompile SystemUI.apk
2) Open smali/com/android/systemui/statusbar/SignalClusterViewGemini.smali
3) search for "apply" method
Code:
# virtual methods
.method public apply()V
We will need 0x0, 0x1, and 0x8 later.
v5 = 0x0 - ID for SIM Slot 1
v9 = 0x1 - ID for SIM Slot 2
v6 = 0x8 - constant used to set visibility of a view (0x8 == View.GONE)
Code:
.prologue
const/4 v11, 0x4
const/4 v10, 0x0
const/4 v9, 0x1
const/16 v6, 0x8
const/4 v5, 0x0
Code:
.line 421
.local v3, state:I
invoke-direct {p0, v5}, Lcom/android/systemui/statusbar/SignalClusterViewGemini;->isSimInserted(I)Z // v5 == 0x0 which is SIM Slot #1
move-result v4
if-eqz v4, :cond_1f
As you can see, if a return value of isSimInserted method is equal to zero (if-eqz v4...)
this means that the SIM for tested Slot is not inserted and code execution jumps to label :cond_1f
(label name might be different in your case)
6) Search for label name we found in the previous step to locate the start
of the code section for this label (:cond_1f in my case) Should look similat to this
Code:
.line 452
.end local v0 #id:I
.end local v1 #resId:Lcom/mediatek/systemui/ext/IconIdWrapper;
.end local v2 #simColorId:I
:cond_1f
iget-object v4, p0, Lcom/android/systemui/statusbar/SignalClusterViewGemini;->mSignalNetworkType:Landroid/widget/ImageView;
Code:
iget-object v4, p0, Lcom/android/systemui/statusbar/SignalClusterViewGemini;->mMobileGroup:Landroid/view/ViewGroup;
invoke-virtual {v4, v6}, Landroid/view/ViewGroup;->setVisibility(I)V
Make sure you use the correct parameter in setVisibility Call. In my case it's v6 (its value is 0x8)
8) Now search for next occurrence of isSimInserted call in "apply" method - this time for SIM Slot 2
Code:
.line 546
.restart local v3 #state:I
invoke-direct {p0, v9}, Lcom/android/systemui/statusbar/SignalClusterViewGemini;->isSimInserted(I)Z // v9 == 0x1 which is SIM Slot #2
move-result v4
if-eqz v4, :cond_2f
As you can see, if a return value of isSimInserted method is equal to zero (if-eqz v4...)
this means that the SIM for tested Slot is not inserted and code execution jumps to label :cond_2f
(label name might be different in your case)
9) Search for label name we found in the previous step to locate the start
of the code section for this label (:cond_2f in my case) Should look similar to this
Code:
.line 578
.end local v0 #id:I
.end local v1 #resId:Lcom/mediatek/systemui/ext/IconIdWrapper;
.end local v2 #simColorId:I
:cond_2f
iget-object v4, p0, Lcom/android/systemui/statusbar/SignalClusterViewGemini;->mSignalNetworkTypeGemini:Landroid/widget/ImageView;
Code:
iget-object v4, p0, Lcom/android/systemui/statusbar/SignalClusterViewGemini;->mMobileGroupGemini:Landroid/view/ViewGroup;
invoke-virtual {v4, v6}, Landroid/view/ViewGroup;->setVisibility(I)V
Make sure you use the correct parameter in setVisibility Call. In my case it's v6 (its value is 0x8)
11) Recompile SystemUI and push it to phone. Done.