[General Questions and Answers] GiantChicken:
Hi everyone!

I have a 4.4.2 AOSP-based ROM which has always showed the audio profile when in normal/general mode. It bugged me a bit but never found an easy approach as to how to remove it.

As a personal challenge and now that I could spare some free time, I decompiled SystemUI.apk and proceed to edit the PhoneStatusBarPolicy.smali file where the audio icons are set. After a hard time understanding the nasty Smali, now it does not show the normal profile icon while still showing the silent, vibrate and outdoor icons when selected. :good:

The problem is that, when restarting SystemUI.apk or rebooting the phone, it will show the normal profile icon again. After I change to another profile and go back, it disappears and behaves as it should. So restarting is restoring the icon visibility somehow :crying:

I commented the lines for "setIcon" in the updateProfile() method of the same .smali file and the icon then does NOT appear at startup (nor any profile icon), which means that the very same function that makes it disappear when switching, is making it appear at the start.

So the answer lies there but no matter how hard I try I do not find what is the difference between startup and switching the profile mode. It must be either the method initializes with that visibility by default and then it loops when running, or an external input is making it :confused:

Here it is the method that sets the icons (with my edit in blue, at the end):

.method private final updateProfile()V
.locals 10

.prologue
const/4 v5, 0x1

const/4 v6, 0x0

.line 142
iget-object v7, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBarPolicy;->mContext:Landroid/content/Context;

const-string v8, "audio"

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

move-result-object v1

check-cast v1, Landroid/media/AudioManager;

.line 143
.local v1, "audioManager":Landroid/media/AudioManager;
invoke-virtual {v1}, Landroid/media/AudioManager;->getRingerMode()I

move-result v4

.line 145
.local v4, "ringerMode":I
if-eqz v4, :cond_0

if-eq v4, v5, :cond_0

const/4 v7, 0x2

if-ne v4, v7, :cond_2

.line 147

.local v5, "visible":Z
:cond_0
:goto_0
iget-object v7, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBarPolicy;->mProfileManager:Lcom/mediatek/audioprofile/AudioProfileManager;

invoke-virtual {v7}, Lcom/mediatek/audioprofile/AudioProfileManager;->getActiveProfileKey()Ljava/lang/String;

move-result-object v0

.line 149
.local v0, "activeProfileKey":Ljava/lang/String;
const/4 v2, 0x0

.line 150
.local v2, "contentDescription":Ljava/lang/String;
const-string v7, "zcl"

new-instance v8, Ljava/lang/StringBuilder;

invoke-direct {v8}, Ljava/lang/StringBuilder;-><init>()V

const-string v9, "ringerMode:"

invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v8

invoke-virtual {v8, v4}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

move-result-object v8

const-string v9, "visible:"

invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v8

invoke-virtual {v8, v5}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

move-result-object v8

invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

move-result-object v8

invoke-static {v7, v8}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

.line 151
iget-object v7, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBarPolicy;->mProfileManager:Lcom/mediatek/audioprofile/AudioProfileManager;

sget-object v7, Lcom/mediatek/audioprofile/AudioProfileManager$Scenario;->SILENT:Lcom/mediatek/audioprofile/AudioProfileManager$Scenario;

invoke-static {v7}, Lcom/mediatek/audioprofile/AudioProfileManager;->getProfileKey(Lcom/mediatek/audioprofile/AudioProfileManager$Scenario;)Ljava/lang/String;

move-result-object v7

invoke-virtual {v7, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

move-result v7

if-eqz v7, :cond_3

.line 152
const v3, 0x7f020164

.line 153
.local v3, "iconsId":I
iget-object v7, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBarPolicy;->mContext:Landroid/content/Context;

const v8, 0x7f0b00c1

invoke-virtual {v7, v8}, Landroid/content/Context;->getString(I)Ljava/lang/String;

move-result-object v2

.line 164
:goto_1
iget-object v7, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBarPolicy;->mService:Landroid/app/StatusBarManager;

const-string v8, "volume"

invoke-virtual {v7, v8, v3, v6, v2}, Landroid/app/StatusBarManager;->setIcon(Ljava/lang/String;IILjava/lang/String;)V

.line 165
iget-boolean v6, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBarPolicy;->mVolumeVisible:Z

if-eq v5, v6, :cond_1

.line 166
iget-object v6, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBarPolicy;->mService:Landroid/app/StatusBarManager;

const-string v7, "volume"

invoke-virtual {v6, v7, v5}, Landroid/app/StatusBarManager;->setIconVisibility(Ljava/lang/String;Z)V

.line 167
iput-boolean v5, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBarPolicy;->mVolumeVisible:Z

.line 170
:cond_1
return-void

.end local v0 # "activeProfileKey":Ljava/lang/String;
.end local v2 # "contentDescription":Ljava/lang/String;
.end local v3 # "iconsId":I
.end local v5 # "visible":Z
:cond_2
move v5, v6

.line 145
goto :goto_0

.line 154
.restart local v0 # "activeProfileKey":Ljava/lang/String;
.restart local v2 # "contentDescription":Ljava/lang/String;
.restart local v5 # "visible":Z
:cond_3
iget-object v7, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBarPolicy;->mProfileManager:Lcom/mediatek/audioprofile/AudioProfileManager;

sget-object v7, Lcom/mediatek/audioprofile/AudioProfileManager$Scenario;->MEETING:Lcom/mediatek/audioprofile/AudioProfileManager$Scenario;

invoke-static {v7}, Lcom/mediatek/audioprofile/AudioProfileManager;->getProfileKey(Lcom/mediatek/audioprofile/AudioProfileManager$Scenario;)Ljava/lang/String;

move-result-object v7

invoke-virtual {v7, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

move-result v7

if-eqz v7, :cond_4

.line 155
const v3, 0x7f020165

.line 156
.restart local v3 # "iconsId":I
iget-object v7, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBarPolicy;->mContext:Landroid/content/Context;

const v8, 0x7f0b00c0

invoke-virtual {v7, v8}, Landroid/content/Context;->getString(I)Ljava/lang/String;

move-result-object v2

goto :goto_1

.line 157
.end local v3 # "iconsId":I
:cond_4
iget-object v7, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBarPolicy;->mProfileManager:Lcom/mediatek/audioprofile/AudioProfileManager;

sget-object v7, Lcom/mediatek/audioprofile/AudioProfileManager$Scenario;->OUTDOOR:Lcom/mediatek/audioprofile/AudioProfileManager$Scenario;

invoke-static {v7}, Lcom/mediatek/audioprofile/AudioProfileManager;->getProfileKey(Lcom/mediatek/audioprofile/AudioProfileManager$Scenario;)Ljava/lang/String;

move-result-object v7

invoke-virtual {v7, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

move-result v7

if-eqz v7, :cond_5

.line 158
const v3, 0x7f020163

.restart local v3 # "iconsId":I
goto :goto_1

.line 161
.end local v3 # "iconsId":I
:cond_5
[COLOR="Blue"]move v5, v6[/COLOR]

const v3, 0x7f020162

.restart local v3 # "iconsId":I
goto :goto_1
.end method

There are a couple of lines above the method where the silence icon is handled. Also there is another method below in the file called updateVolume which changes the icons too. Though when uncommented they did not trigger the icon to appear at startup, so I am assuming the cause is not there. I will attach the .smali file also.

I really would like to complete this mod, I have done some further testing but it is too tiresome to test the .apk whenever I change a line of code. Also I am a noobie with all this so I do not want to screw it up. If someone is familliar with these kind of things, I will appreciate any help I can get! :fingers-crossed:

PD: If someone has a deodexed 4.4.x AOSP not showing the icon and be nice to share the SystemUI.apk, I could hopefully adapt it to my needs.

Here you can dw the file:

https://www.dropbox.com/s/jqnl7s3p3up9ysg/PhoneStatusBarPolicy_original.smali?dl=0