[Galaxy S II Themes and Apps] LeoMar75:
Hi guys,

As you already know i always like to share everything with this amazing community! :D

This time i will show you how to properly mod Phone.apk!

Why i said "Properly" ??

The Story

Well, let's start talking about Call Rec Mod..

No one on XDA did this port on the latest firmwares, that's because there is no source code available..

If i remember good, designgears toke files from an Asian ROM which included a Phone.apk with call recording feature built in, he also translated the apk in English.

However everyone is still using the one dated 09/09/11 posted by sicopat!

With the latest firmwares Phone.apk has been improved and optimized that's the reason why i do not recommend to use the current available Call Rec Mod based on that very old apk (Text Alignment issue, translation problem, different image resources which makes the life hard for themers, poor optimized code..)

That being said, i will start to explain how to implement the following

Mods

:

1) Call Rec

2) No increasing Ring

3) Noise Reduction Inverted (NR Off by default for those ppl who is having echo issue during call)

4) Big Photo (I hate this mod, but everyone like it)

Note

2 and 3 have been already explained in other threads but there is a bit of confusion regarding which one is the real working one, therefore i will report here the working approach.

Call Rec Mod

Actually this mod is not that hard to do, that's because the Samsung Stock apk has already this feature built in!

The only thing we need to do is to modify a bit the code used to handle in call buttons!

a) Decompile Phone.apk (apktool or whatever wrapper you prefer)

b) Open in your preferred Text Editor (notepad++) this file: InCallButtonsView.smali

c) Find the following method signature:

.method updateState(Lcom/android/internal/telephony/CallManager;I)V

Locate the code below and modify it from

if-ne v6, v10, :cond_9

.line 219
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mAddButton:Landroid/widget/Button;

invoke-virtual {v6, v8}, Landroid/widget/Button;->setVisibility(I)V

to

if-ne v6, v10, :cond_9

.line 219
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mRecordButton:Landroid/widget/Button;

invoke-virtual {v6, v8}, Landroid/widget/Button;->setVisibility(I)V

Locate the code below and modify it from

.line 239
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mHDVideoButton:Landroid/widget/Button;

invoke-virtual {v6, v8}, Landroid/widget/Button;->setVisibility(I)V

.line 283
:goto_3
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mDialpadButton:Landroid/widget/Button;

to

.line 239
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mHDVideoButton:Landroid/widget/Button;

invoke-virtual {v6, v8}, Landroid/widget/Button;->setVisibility(I)V

.line 283
:goto_3
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mInCallScreen:Lcom/android/phone/InCallScreen;

sget-object v6, Lcom/android/phone/InCallScreen;->mPhoneVoiceRecorder:Lcom/android/phone/PhoneVoiceRecorder;

invoke-virtual {v6}, Lcom/android/phone/PhoneVoiceRecorder;->isVoiceRecording()Z

move-result v6

if-nez v6, :cond_leo

.line 274
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mRecordButton:Landroid/widget/Button;

const v7, 0x7f0d0330

invoke-virtual {v6, v7}, Landroid/widget/Button;->setText(I)V

.line 275
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mRecordButton:Landroid/widget/Button;

iget-object v7, p0, Lcom/android/phone/InCallButtonsView;->mStartRecordIcon:Landroid/graphics/drawable/Drawable;

invoke-virtual {v6, v11, v7, v11, v11}, Landroid/widget/Button;->setCompoundDrawablesWithIntrinsicBounds(Landroid/graphics/drawable/Drawable;Landroid/graphics/drawable/Drawable;Landroid/graphics/drawable/Drawable;Landroid/graphics/drawable/Drawable;)V

:goto_gc
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mDialpadButton:Landroid/widget/Button;

Locate the code below and modify it from

iget-boolean v6, v6, Lcom/android/phone/InCallControlState;->dialpadVisible:Z

if-eqz v6, :cond_f

.line 287
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mDialpadButton:Landroid/widget/Button;

to

iget-boolean v6, v6, Lcom/android/phone/InCallControlState;->dialpadVisible:Z

if-eqz v6, :cond_fig

.line 287
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mDialpadButton:Landroid/widget/Button;

Locate the code below and modify it from

invoke-virtual {v6, v11, v7, v11, v11}, Landroid/widget/Button;->setCompoundDrawablesWithIntrinsicBounds(Landroid/graphics/drawable/Drawable;Landroid/graphics/drawable/Drawable;Landroid/graphics/drawable/Drawable;Landroid/graphics/drawable/Drawable;)V

.line 307
:goto_4
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mBluetoothButton:Landroid/widget/ToggleButton;

invoke-virtual {v3}, Lcom/android/internal/telephony/Call;->isDialingOrAlerting()Z

move-result v7

if-nez v7, :cond_10

to

invoke-virtual {v6, v11, v7, v11, v11}, Landroid/widget/Button;->setCompoundDrawablesWithIntrinsicBounds(Landroid/graphics/drawable/Drawable;Landroid/graphics/drawable/Drawable;Landroid/graphics/drawable/Drawable;Landroid/graphics/drawable/Drawable;)V

.line 307
:goto_4
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->inCallControlState:Lcom/android/phone/InCallControlState;

iget-boolean v6, v6, Lcom/android/phone/InCallControlState;->bluetoothIndicatorOn:Z

if-eqz v6, :cond_fra

iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mInCallScreen:Lcom/android/phone/InCallScreen;

sget-object v6, Lcom/android/phone/InCallScreen;->mPhoneVoiceRecorder:Lcom/android/phone/PhoneVoiceRecorder;

invoke-virtual {v6}, Lcom/android/phone/PhoneVoiceRecorder;->isVoiceRecording()Z

move-result v6

if-eqz v6, :cond_fra

.line 301
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mInCallScreen:Lcom/android/phone/InCallScreen;

sget-object v6, Lcom/android/phone/InCallScreen;->mPhoneVoiceRecorder:Lcom/android/phone/PhoneVoiceRecorder;

invoke-virtual {v6}, Lcom/android/phone/PhoneVoiceRecorder;->stopRecord()V

.line 303
:cond_fra
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mBluetoothButton:Landroid/widget/ToggleButton;

invoke-virtual {v3}, Lcom/android/internal/telephony/Call;->isDialingOrAlerting()Z

iget-object v7, p0, Lcom/android/phone/InCallButtonsView;->inCallControlState:Lcom/android/phone/InCallControlState;

iget-boolean v7, v7, Lcom/android/phone/InCallControlState;->bluetoothEnabled:Z

if-eqz v7, :cond_10

iget-object v7, p0, Lcom/android/phone/InCallButtonsView;->mInCallScreen:Lcom/android/phone/InCallScreen;

sget-object v7, Lcom/android/phone/InCallScreen;->mPhoneVoiceRecorder:Lcom/android/phone/PhoneVoiceRecorder;

invoke-virtual {v7}, Lcom/android/phone/PhoneVoiceRecorder;->isVoiceRecording()Z

move-result v7

if-nez v7, :cond_10

Locate the code below and modify it from

.line 252
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mInCallSaveButton:Landroid/widget/Button;

invoke-virtual {v6, v8}, Landroid/widget/Button;->setVisibility(I)V

goto/16 :goto_3

.line 292
:cond_f
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mDialpadButton:Landroid/widget/Button;

const v7, 0x7f0d01b7

to

.line 252
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mInCallSaveButton:Landroid/widget/Button;

invoke-virtual {v6, v8}, Landroid/widget/Button;->setVisibility(I)V

iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mRecordButton:Landroid/widget/Button;

iget-object v7, p0, Lcom/android/phone/InCallButtonsView;->mInCallScreen:Lcom/android/phone/InCallScreen;

invoke-virtual {v7}, Lcom/android/phone/InCallScreen;->getUpdatedInCallControlState()Lcom/android/phone/InCallControlState;

move-result-object v7

iget-boolean v7, v7, Lcom/android/phone/InCallControlState;->bluetoothIndicatorOn:Z

if-nez v7, :cond_f

move v7, v10

:goto_c
invoke-virtual {v6, v7}, Landroid/widget/Button;->setEnabled(Z)V

.line 260
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mInCallScreen:Lcom/android/phone/InCallScreen;

sget-boolean v6, Lcom/android/phone/InCallScreen;->liveshare_option:Z

if-eqz v6, :cond_ci

iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mInCallScreen:Lcom/android/phone/InCallScreen;

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

move-result v6

if-nez v6, :cond_ci

.line 262
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mHDVideoButton:Landroid/widget/Button;

invoke-virtual {v6, v9}, Landroid/widget/Button;->setVisibility(I)V

.line 263
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mHDVideoButton:Landroid/widget/Button;

invoke-virtual {v6, v11}, Landroid/widget/Button;->setEnabled(Z)V
goto/16 :goto_3

.line 292
:cond_f
move v7, v9

goto :goto_c

:cond_ci
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mHDVideoButton:Landroid/widget/Button;

invoke-virtual {v6, v8}, Landroid/widget/Button;->setVisibility(I)V

goto/16 :goto_3

:cond_leo
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mRecordButton:Landroid/widget/Button;

const v7, 0x7f0d0331

invoke-virtual {v6, v7}, Landroid/widget/Button;->setText(I)V

iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mRecordButton:Landroid/widget/Button;

iget-object v7, p0, Lcom/android/phone/InCallButtonsView;->mStopRecordIcon:Landroid/graphics/drawable/Drawable;

invoke-virtual {v6, v11, v7, v11, v11}, Landroid/widget/Button;->setCompoundDrawablesWithIntrinsicBounds(Landroid/graphics/drawable/Drawable;Landroid/graphics/drawable/Drawable;Landroid/graphics/drawable/Drawable;Landroid/graphics/drawable/Drawable;)V

goto/16 :goto_gc

:cond_fig
iget-object v6, p0, Lcom/android/phone/InCallButtonsView;->mDialpadButton:Landroid/widget/Button;

const v7, 0x7f0d01b7

That's it :D

Please note that the code i used as reference is the one based on XWLA4 Firmware, nevertheless it's pretty easy to diff the code and change stuff accordly..

IMPORANT!!

We need to double check two Reference IDs used by the code we have just added:

const v7, 0x7f0d0331

needs to match with the one you will find in your res/values/public.xml

<public type="string" name="menu_save_recording" id="0x7f0d0331" />

const v7, 0x7f0d0330

needs to match with the following one:

<public type="string" name="menu_record_voice" id="0x7f0d0330" />

Finally

We will need to include the following attached lib: /system/lib/libaudiopolicy.so

You can grab it from the cwm zip attached!