[Galaxy S Advance I9070 Android Development] AntaresOne:
[MENTION=3531145]fedevd[/MENTION]

I tried again to patch smalis, now Phone's FC is gone but volume still low...

From CM10.1's 20131117 Phone.apk:

InCallScreen.smali from line 5545 to 5624

.method private onPhoneStateChanged(Landroid/os/AsyncResult;)V
.locals 3
.parameter "r"

.prologue
.line 1770
iget-object v1, p0, Lcom/android/phone/InCallScreen;->mCM:Lcom/android/internal/telephony/CallManager;

invoke-virtual {v1}, Lcom/android/internal/telephony/CallManager;->getState()Lcom/android/internal/telephony/PhoneConstants$State;

move-result-object v0

.line 1771
.local v0, state:Lcom/android/internal/telephony/PhoneConstants$State;
sget-boolean v1, Lcom/android/phone/InCallScreen;->DBG:Z

if-eqz v1, :cond_0

new-instance v1, Ljava/lang/StringBuilder;

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

const-string v2, "onPhoneStateChanged: current state = "

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

move-result-object v1

invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

move-result-object v1

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

move-result-object v1

invoke-direct {p0, v1}, Lcom/android/phone/InCallScreen;->log(Ljava/lang/String;)V

.line 1776
:cond_0
iget-boolean v1, p0, Lcom/android/phone/InCallScreen;->mIsForegroundActivity:Z

if-nez v1, :cond_2

.line 1777
sget-boolean v1, Lcom/android/phone/InCallScreen;->DBG:Z

if-eqz v1, :cond_1

const-string v1, "onPhoneStateChanged: Activity not in foreground! Bailing out..."

invoke-direct {p0, v1}, Lcom/android/phone/InCallScreen;->log(Ljava/lang/String;)V

.line 1800
:cond_1
:goto_0
return-void

.line 1781
:cond_2
invoke-direct {p0}, Lcom/android/phone/InCallScreen;->updateExpandedViewState()V

.line 1789
invoke-virtual {p0}, Lcom/android/phone/InCallScreen;->requestUpdateScreen()V

.line 1793
iget-object v1, p0, Lcom/android/phone/InCallScreen;->mApp:Lcom/android/phone/PhoneGlobals;

invoke-virtual {v1}, Lcom/android/phone/PhoneGlobals;->updateWakeState()V

.line 1797
sget-object v1, Lcom/android/internal/telephony/PhoneConstants$State; >OFFHOOK:Lcom/android/internal/telephony/PhoneConstants$State;

if-ne v0, v1, :cond_1

[COLOR="Red"][B].line 1798
invoke-static {}, Lcom/android/phone/PhoneUtils;->resetAudioStreamVolume()V First part of volume fix[/COLOR][/B]

goto :goto_0
.end method

InCallScreen.smali from line 12149 to 12323

.method public switchInCallAudio(Lcom/android/phone/InCallScreen$InCallAudioMode;)V
.locals 4
.parameter "newMode"

.prologue
const/4 v3, 0x0

const/4 v2, 0x1

.line 3051
new-instance v0, Ljava/lang/StringBuilder;

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

const-string v1, "switchInCallAudio: new mode = "

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

move-result-object v0

invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

move-result-object v0

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

move-result-object v0

invoke-direct {p0, v0}, Lcom/android/phone/InCallScreen;->log(Ljava/lang/String;)V

.line 3052
sget-object v0, Lcom/android/phone/InCallScreen$19;->$SwitchMap$com$android$phone$InCallScreen$InCallAudioMode:[I

invoke-virtual {p1}, Lcom/android/phone/InCallScreen$InCallAudioMode;->ordinal()I

move-result v1

aget v0, v0, v1

packed-switch v0, :pswitch_data_0

.line 3092
const-string v0, "InCallScreen"

new-instance v1, Ljava/lang/StringBuilder;

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

const-string v2, "switchInCallAudio: unexpected mode "

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

move-result-object v1

invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

move-result-object v1

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

move-result-object v1

invoke-static {v0, v1}, Landroid/util/Log;->wtf(Ljava/lang/String;Ljava/lang/String;)I

[COLOR="Red"][B].line 3098
:cond_0
:goto_0
invoke-static {}, Lcom/android/phone/PhoneUtils;->resetAudioStreamVolume()V Second part of volume fix[/B][/COLOR]

.line 3103
invoke-direct {p0}, Lcom/android/phone/InCallScreen;->updateInCallTouchUi()V

.line 3104
return-void

.line 3054
:pswitch_0
invoke-static {p0}, Lcom/android/phone/PhoneUtils;->isSpeakerOn(Landroid/content/Context;)Z

move-result v0

if-nez v0, :cond_0

.line 3056
invoke-virtual {p0}, Lcom/android/phone/InCallScreen;->isBluetoothAvailable()Z

move-result v0

if-eqz v0, :cond_1

invoke-virtual {p0}, Lcom/android/phone/InCallScreen;->isBluetoothAudioConnected()Z

move-result v0

if-eqz v0, :cond_1

.line 3057
invoke-virtual {p0}, Lcom/android/phone/InCallScreen;->disconnectBluetoothAudio()V

.line 3059
:cond_1
invoke-static {p0, v2, v2}, Lcom/android/phone/PhoneUtils;->turnOnSpeaker(Landroid/content/Context;ZZ)V

goto :goto_0

.line 3065
:pswitch_1
invoke-virtual {p0}, Lcom/android/phone/InCallScreen;->isBluetoothAvailable()Z

move-result v0

if-eqz v0, :cond_0

invoke-virtual {p0}, Lcom/android/phone/InCallScreen;->isBluetoothAudioConnected()Z

move-result v0

if-nez v0, :cond_0

.line 3073
invoke-static {p0}, Lcom/android/phone/PhoneUtils;->isSpeakerOn(Landroid/content/Context;)Z

move-result v0

if-eqz v0, :cond_2

.line 3074
invoke-static {p0, v3, v2}, Lcom/android/phone/PhoneUtils;->turnOnSpeaker(Landroid/content/Context;ZZ)V

.line 3076
:cond_2
invoke-virtual {p0}, Lcom/android/phone/InCallScreen;->connectBluetoothAudio()V

goto :goto_0

.line 3083
:pswitch_2
invoke-virtual {p0}, Lcom/android/phone/InCallScreen;->isBluetoothAvailable()Z

move-result v0

if-eqz v0, :cond_3

invoke-virtual {p0}, Lcom/android/phone/InCallScreen;->isBluetoothAudioConnected()Z

move-result v0

if-eqz v0, :cond_3

.line 3084
invoke-virtual {p0}, Lcom/android/phone/InCallScreen;->disconnectBluetoothAudio()V

.line 3086
:cond_3
invoke-static {p0}, Lcom/android/phone/PhoneUtils;->isSpeakerOn(Landroid/content/Context;)Z

move-result v0

if-eqz v0, :cond_0

.line 3087
invoke-static {p0, v3, v2}, Lcom/android/phone/PhoneUtils;->turnOnSpeaker(Landroid/content/Context;ZZ)V

goto :goto_0

.line 3052
nop

:pswitch_data_0
.packed-switch 0x1
:pswitch_0
:pswitch_1
:pswitch_2
.end packed-switch
.end method

InCallScreen.smali from line 12325 to 12392

.method public toggleBluetooth()V
.locals 2

.prologue
.line 3002
const-string v0, "toggleBluetooth()..."

invoke-direct {p0, v0}, Lcom/android/phone/InCallScreen;->log(Ljava/lang/String;)V

.line 3004
invoke-virtual {p0}, Lcom/android/phone/InCallScreen;->isBluetoothAvailable()Z

move-result v0

if-eqz v0, :cond_2

.line 3006
invoke-virtual {p0}, Lcom/android/phone/InCallScreen;->isBluetoothAudioConnected()Z

move-result v0

if-eqz v0, :cond_0

.line 3007
invoke-virtual {p0}, Lcom/android/phone/InCallScreen;->disconnectBluetoothAudio()V

[COLOR="Red"][B].line 3030
:goto_0
invoke-static {}, Lcom/android/phone/PhoneUtils;->resetAudioStreamVolume()V Third part of volume fix[/B][/COLOR]

.line 3035
invoke-direct {p0}, Lcom/android/phone/InCallScreen;->updateInCallTouchUi()V

.line 3036
return-void

.line 3016
:cond_0
invoke-static {p0}, Lcom/android/phone/PhoneUtils;->isSpeakerOn(Landroid/content/Context;)Z

move-result v0

if-eqz v0, :cond_1

.line 3017
const/4 v0, 0x0

const/4 v1, 0x1

invoke-static {p0, v0, v1}, Lcom/android/phone/PhoneUtils;->turnOnSpeaker(Landroid/content/Context;ZZ)V

.line 3020
:cond_1
invoke-virtual {p0}, Lcom/android/phone/InCallScreen;->connectBluetoothAudio()V

goto :goto_0

.line 3025
:cond_2
const-string v0, "InCallScreen"

const-string v1, "toggleBluetooth(): bluetooth is unavailable"

invoke-static {v0, v1}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

goto :goto_0
.end method

InCallScreen.smali from line 12393 to 12468

.method public toggleSpeaker()V
.locals 4

.prologue
const/4 v1, 0x1

.line 2964
invoke-static {p0}, Lcom/android/phone/PhoneUtils;->isSpeakerOn(Landroid/content/Context;)Z

move-result v2

if-nez v2, :cond_1

move v0, v1

.line 2965
.local v0, newSpeakerState:Z
:goto_0
new-instance v2, Ljava/lang/StringBuilder;

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

const-string v3, "toggleSpeaker(): newSpeakerState = "

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

move-result-object v2

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

move-result-object v2

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

move-result-object v2

invoke-direct {p0, v2}, Lcom/android/phone/InCallScreen;->log(Ljava/lang/String;)V

.line 2967
if-eqz v0, :cond_0

invoke-virtual {p0}, Lcom/android/phone/InCallScreen;->isBluetoothAvailable()Z

move-result v2

if-eqz v2, :cond_0

invoke-virtual {p0}, Lcom/android/phone/InCallScreen;->isBluetoothAudioConnected()Z

move-result v2

if-eqz v2, :cond_0

.line 2968
invoke-virtual {p0}, Lcom/android/phone/InCallScreen;->disconnectBluetoothAudio()V

.line 2970
:cond_0
invoke-static {p0, v0, v1}, Lcom/android/phone/PhoneUtils;->turnOnSpeaker(Landroid/content/Context;ZZ)V

[COLOR="Red"][B].line 2974
invoke-static {}, Lcom/android/phone/PhoneUtils;->resetAudioStreamVolume()V Fourth part of volume fix[/COLOR][/B]

.line 2979
invoke-direct {p0}, Lcom/android/phone/InCallScreen;->updateInCallTouchUi()V

.line 2980
return-void

.line 2964
.end local v0 #newSpeakerState:Z
:cond_1
const/4 v0, 0x0

goto :goto_0
.end method

PhoneUtils.smali from line 6482 to 6581, last part of volume fix

.method static resetAudioStreamVolume()V
.locals 8

.prologue
const/4 v7, 0x0

.line 2016
invoke-static {}, Lcom/android/phone/PhoneGlobals;->getInstance()Lcom/android/phone/PhoneGlobals;

move-result-object v0

.line 2017
.local v0, app:Lcom/android/phone/PhoneGlobals;
const-string v5, "audio"

invoke-virtual {v0, v5}, Lcom/android/phone/PhoneGlobals;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

move-result-object v1

check-cast v1, Landroid/media/AudioManager;

.line 2019
.local v1, audioManager:Landroid/media/AudioManager;
const/4 v3, 0x0

.line 2020
.local v3, streamType:I
invoke-virtual {v0}, Lcom/android/phone/PhoneGlobals;->isBluetoothHeadsetAudioOn()Z

move-result v5

if-eqz v5, :cond_0

.line 2021
const/4 v3, 0x6

.line 2024
:cond_0
invoke-virtual {v1, v3}, Landroid/media/AudioManager;->getStreamVolume(I)I

move-result v4

.line 2025
.local v4, volume:I
add-int/lit8 v2, v4, -0x1

.line 2026
.local v2, lowerVolume:I
if-gez v2, :cond_1

.line 2027
const/4 v2, 0x0

.line 2029
:cond_1
new-instance v5, Ljava/lang/StringBuilder;

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

const-string v6, "resetAudioStreamVolume (streamType="

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

move-result-object v5

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

move-result-object v5

const-string v6, ", streamVolume="

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

move-result-object v5

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

move-result-object v5

const-string v6, ")..."

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

move-result-object v5

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

move-result-object v5

invoke-static {v5}, Lcom/android/phone/PhoneUtils;->log(Ljava/lang/String;)V

.line 2032
invoke-virtual {v1, v3, v2, v7}, Landroid/media/AudioManager;->setStreamVolume(III)V

.line 2033
invoke-virtual {v1, v3, v4, v7}, Landroid/media/AudioManager;->setStreamVolume(III)V

.line 2034
return-void
.end method

My problems are :cond_0 and :goto_0 on resetAudioStreamVolume of InCallScreen, because when smaling I get errors:

Label cond_0 has multiple defintions.
Label goto_0 has multiple defintions.
mismatched tree node: I_LABEL expecting I_PACKED_SWITCH_DECLARATIONS
A non-abstract/non-native method must have at least 1 instruction

Removing these cond and goto under .line_3098 and .line_3030 I get no errors when smaling but obviously volume is still low...