[Android Q&A, Help & Troubleshooting] rauleeros:
Hello everyone, I have recently started doing modifications in the .smali world. I have already successfully modified my first application by converting the .apk to (almost) .java and then analyzing the method I needed to change. Then, going through the .smali code and modifying it there and compiling the .apk again.

This last one was a non-system apk, but I am currently working on a system apk, more explicitly OPSystemUI.apk.

Since it is odexed (.odex), I had to decompile this into a classes.dex and from there to (almost) .java to analyze the code.

Then, after decompiling the .dex to .smali, I found the function from the .java that I wanted to change.

Here is where the problem starts:

The function in .java I am modifying is (com\android\systemui\statusbar\policy\SignalController.class):

public int getCurrentIconId()
{
if (this.mCurrentState.connected) {
return getIcons().mSbIcons[this.mCurrentState.inetCondition][this.mCurrentState.level];
}
if (this.mCurrentState.enabled) {
return getIcons().mSbDiscState;
}
return getIcons().mSbNullState;
}

This same function in .smali is (SignalController.smali):

.method public getCurrentIconId()I
.registers 3

.prologue
.line 137
.local p0, "this":Lcom/android/systemui/statusbar/policy/SignalController;, "Lcom/android/systemui/statusbar/policy/SignalController<TT;TI;>;"
iget-object v0, p0, Lcom/android/systemui/statusbar/policy/SignalController;->mCurrentState:Lcom/android/systemui/statusbar/policy/SignalController$State;

iget-boolean v0, v0, Lcom/android/systemui/statusbar/policy/SignalController$State;->connected:Z

if-eqz v0, :cond_19

.line 138
invoke-virtual {p0}, Lcom/android/systemui/statusbar/policy/SignalController;->getIcons()Lcom/android/systemui/statusbar/policy/SignalController$IconGroup;

move-result-object v0

iget-object v0, v0, Lcom/android/systemui/statusbar/policy/SignalController$IconGroup;->mSbIcons:[[I

iget-object v1, p0, Lcom/android/systemui/statusbar/policy/SignalController;->mCurrentState:Lcom/android/systemui/statusbar/policy/SignalController$State;

iget v1, v1, Lcom/android/systemui/statusbar/policy/SignalController$State;->inetCondition:I

aget-object v0, v0, v1

iget-object v1, p0, Lcom/android/systemui/statusbar/policy/SignalController;->mCurrentState:Lcom/android/systemui/statusbar/policy/SignalController$State;

iget v1, v1, Lcom/android/systemui/statusbar/policy/SignalController$State;->level:I

aget v0, v0, v1

.line 142
:goto_18
return v0

.line 139
:cond_19
iget-object v0, p0, Lcom/android/systemui/statusbar/policy/SignalController;->mCurrentState:Lcom/android/systemui/statusbar/policy/SignalController$State;

iget-boolean v0, v0, Lcom/android/systemui/statusbar/policy/SignalController$State;->enabled:Z

if-eqz v0, :cond_26

.line 140
invoke-virtual {p0}, Lcom/android/systemui/statusbar/policy/SignalController;->getIcons()Lcom/android/systemui/statusbar/policy/SignalController$IconGroup;

move-result-object v0

iget v0, v0, Lcom/android/systemui/statusbar/policy/SignalController$IconGroup;->mSbDiscState:I

goto :goto_18

.line 142
:cond_26
invoke-virtual {p0}, Lcom/android/systemui/statusbar/policy/SignalController;->getIcons()Lcom/android/systemui/statusbar/policy/SignalController$IconGroup;

move-result-object v0

iget v0, v0, Lcom/android/systemui/statusbar/policy/SignalController$IconGroup;->mSbNullState:I

goto :goto_18
.end method

and I modify it by adding a logcat command in the beginning to see when this is executed, so it looks like so:

.method public getCurrentIconId()I
.registers 3

.prologue
.line 137
.local p0, "this":Lcom/android/systemui/statusbar/policy/SignalController;, "Lcom/android/systemui/statusbar/policy/SignalController<TT;TI;>;"
iget-object v0, p0, Lcom/android/systemui/statusbar/policy/SignalController;->mCurrentState:Lcom/android/systemui/statusbar/policy/SignalController$State;

iget-boolean v0, v0, Lcom/android/systemui/statusbar/policy/SignalController$State;->connected:Z

[COLOR="Red"]	const-string v3, "getCurrentIconId SIM"

const-string v4, "Beginning of function SIM"

invoke-static {v3, v4}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I[/COLOR]

if-eqz v0, :cond_19
. . .

- If I try to recompile the .apk from this .smali code, without the .odex, it works perfect (so recompiling should not be the problem)

-However, if I add the logcat command, my phone does not execute OPSystemUI properly (the logcat command is just to modify in some way the code and see its result, it shouldn't change the apk behavior, right?)

Is my added code for logcat wrong? Else, what could it be? I am out of ideas :confused:

Overall, the final goal is to remove an icon from the statusbar (the NoSIM icon), and this was a start.