Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,733,293 Members 38,556 Now Online
XDA Developers Android and Mobile Development Forum

[MOD][HOW-TO][2.0] Long press volume to skip tracks (the right way!)

Tip us?
 
loserskater
Old
(Last edited by loserskater; 20th January 2014 at 07:13 PM.)
#1  
loserskater's Avatar
Recognized Developer - OP
Thanks Meter 3284
Posts: 1,847
Join Date: Jun 2008
Location: San Diego, CA

 
DONATE TO ME
Default [MOD][HOW-TO][2.0] Long press volume to skip tracks (the right way!)

This has been updated. Check out the new thread: http://forum.xda-developers.com/show....php?t=2254022

Now includes checkbox in settings to enable and disable!

Thanks to jakubklos for his diff file and getting me in the right direction.
And a HUGE thanks to the CM team.

CODE IN RED IS NEW!
CODE IN BLUE IS MODIFIED!

Some of your lines/variables may be different.
I've attached the original and modified files so you can diff them yourself!
 

First, decompile SecSettings.apk. If you're unsure how to do that you're going to have some pretty big issues ahead.

Navigate to res/values/strings.xml
and add the following to the end:
Code:
    <string name="volbtn_music_controls_title">Volume rocker music controls</string>
    <string name="volbtn_music_controls_summary">When screen off, long-pressing the volume rockers will seek music tracks</string>
Next navigate to res/xml/sound_settings.xml
and add the section in red:
Code:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen android:title="@string/sound_settings" android:key="sound_settings"
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
    <com.android.settings.RingerVolumePreference android:persistent="false" android:title="@string/all_volume_title" android:key="ring_volume" android:widgetLayout="@layout/round_more_icon" android:dialogTitle="@string/all_volume_title" android:streamType="ring" />
    <com.android.settings.VibrationFeedbackPreference android:title="@string/vibration_intensity" android:key="vibration_feedback_intensity" android:summary="" android:widgetLayout="@layout/round_more_icon" android:dialogTitle="@string/vibration_intensity" />
    <PreferenceScreen android:title="@string/phone_profile" android:key="phone_profile" android:summary="@string/normal" android:fragment="com.android.settings.phoneprofile.PhoneProfileSettings" />
    <Preference android:title="@string/musicfx_title" android:key="musicfx">
        <intent android:targetPackage="com.android.musicfx" android:targetClass="com.android.musicfx.ControlPanelPicker" />
    </Preference>
    <PreferenceCategory android:title="@string/sound_category_calls_and_notification_title" android:key="category_calls_and_notification" />
    <PreferenceScreen android:title="@string/download_ringtones" android:key="download_ringtone" android:summary="">
        <intent android:action="android.intent.action.VIEW" android:data="http://waprd.telstra.com/redirect?target=3glatesttones" />
    </PreferenceScreen>
    <com.android.settings.DefaultRingtonePreference android:persistent="false" android:title="@string/ringtone_title" android:key="ringtone" android:widgetLayout="@layout/round_more_icon" android:dialogTitle="@string/ringtone_title" android:ringtoneType="ringtone" />
    <com.android.settings.DefaultRingtonePreference android:persistent="false" android:title="@string/voice_call_ringtone2" android:key="ringtone2" android:widgetLayout="@layout/round_more_icon" android:dialogTitle="@string/voice_call_ringtone2" android:ringtoneType="ringtone2" />
    <PreferenceScreen android:title="@string/phone_vibration_title" android:key="phone_vibration" android:summary="@string/phone_vibration_summary" android:widgetLayout="@layout/round_more_icon">
        <intent android:targetPackage="com.android.settings" android:action="android.intent.action.MAIN" android:targetClass="com.android.settings.personalvibration.SelectPatternDialog" />
    </PreferenceScreen>
    <com.android.settings.DefaultRingtonePreference android:persistent="false" android:title="@string/notification_sound_title" android:key="notification_sound" android:widgetLayout="@layout/round_more_icon" android:dialogTitle="@string/notification_sound_dialog_title" android:ringtoneType="notification" />
    <CheckBoxPreference android:persistent="false" android:title="@string/vibrate_on_ring_title" android:key="vibrate_when_ringing" />
    <PreferenceCategory android:title="@string/sound_category_system_title" />
    <CheckBoxPreference android:title="@string/dtmf_tone_enable_title" android:key="dtmf_tone" android:defaultValue="true" android:summaryOn="@string/dtmf_tone_enable_summary_on" android:summaryOff="@string/dtmf_tone_enable_summary_off" />
    <CheckBoxPreference android:title="@string/sound_effects_enable_title" android:key="sound_effects" android:defaultValue="true" android:summaryOn="@string/sound_effects_enable_summary_on" android:summaryOff="@string/sound_effects_enable_summary_off" />
    <CheckBoxPreference android:title="@string/lock_sounds_enable_title" android:key="lock_sounds" android:defaultValue="true" android:summaryOn="@string/lock_sounds_enable_summary_on" android:summaryOff="@string/lock_sounds_enable_summary_off" />
    <CheckBoxPreference android:title="@string/gps_notification_sounds_title" android:key="gps_notification_sounds" />
    <CheckBoxPreference android:title="@string/haptic_feedback_enable_title" android:key="haptic_feedback" android:defaultValue="true" android:summaryOn="@string/haptic_feedback_enable_summary_on" android:summaryOff="@string/haptic_feedback_enable_summary_off" />
    <SwitchPreferenceScreen android:title="@string/auto_haptic" android:key="autohaptic_settings" android:fragment="com.android.settings.autohaptic.AutoHapticSettings" />
    <ListPreference android:entries="@array/emergency_tone_entries" android:title="@string/emergency_tone_title" android:key="emergency_tone" android:widgetLayout="@layout/round_more_icon" android:entryValues="@array/emergency_tone_values" />
    <CheckBoxPreference android:persistent="false" android:title="@string/volbtn_music_controls_title" android:key="volbtn_music_controls" android:summary="@string/volbtn_music_controls_summary" />
</PreferenceScreen>
Now let's get into some smail.

Open up com/android/settings/SoundSettings.smali
 
Code:
.field private mSoundSettings:Landroid/preference/PreferenceGroup;

.field private mUnloadSoundEffectRunnable:Ljava/lang/Runnable;

.field private mVibrateWhenRinging:Landroid/preference/CheckBoxPreference;

.field private mVolBtnMusicCtrl:Landroid/preference/CheckBoxPreference;

.field private mVolume:Lcom/android/settings/RingerVolumePreference;
method onCreate:
 
Code:
    const-string v18, "lockscreen_sounds_enabled"

    const/16 v20, 0x1

    move-object/from16 v0, v18

    move/from16 v1, v20

    invoke-static {v15, v0, v1}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

    move-result v18

    if-eqz v18, :cond_f

    const/16 v18, 0x1

    :goto_6
    move-object/from16 v0, v19

    move/from16 v1, v18

    invoke-virtual {v0, v1}, Landroid/preference/CheckBoxPreference;->setChecked(Z)V

    .line 291
    const-string v18, "volbtn_music_controls"

    move-object/from16 v0, p0

    move-object/from16 v1, v18

    invoke-virtual {v0, v1}, Lcom/android/settings/SoundSettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

    move-result-object v18

    check-cast v18, Landroid/preference/CheckBoxPreference;

    move-object/from16 v0, v18

    move-object/from16 v1, p0

    iput-object v0, v1, Lcom/android/settings/SoundSettings;->mVolBtnMusicCtrl:Landroid/preference/CheckBoxPreference;

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/settings/SoundSettings;->mVolBtnMusicCtrl:Landroid/preference/CheckBoxPreference;

    move-object/from16 v18, v0

    const/16 v19, 0x0

    invoke-virtual/range {v18 .. v19}, Landroid/preference/CheckBoxPreference;->setPersistent(Z)V

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/settings/SoundSettings;->mVolBtnMusicCtrl:Landroid/preference/CheckBoxPreference;

    move-object/from16 v19, v0

    const-string v18, "volbtn_music_controls"

    const/16 v20, 0x1

    move-object/from16 v0, v18

    move/from16 v1, v20

    invoke-static {v15, v0, v1}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

    move-result v18

    if-eqz v18, :cond_long

    const/16 v18, 0x1

    :goto_long
    move-object/from16 v0, v19

    move/from16 v1, v18

    invoke-virtual {v0, v1}, Landroid/preference/CheckBoxPreference;->setChecked(Z)V

    const-string v18, "ringtone"

    move-object/from16 v0, p0

    move-object/from16 v1, v18

    invoke-virtual {v0, v1}, Lcom/android/settings/SoundSettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
Code:
:cond_d
    const/16 v18, 0x0

    goto/16 :goto_4

    .line 280
    :cond_e
    const/16 v18, 0x0

    goto/16 :goto_5

    .line 288
    :cond_f
    const/16 v18, 0x0

    goto/16 :goto_6

    :cond_long
    const/16 v18, 0x0

    goto/16 :goto_long

    .line 315
    .restart local v17       #vibrator:Landroid/os/Vibrator;
    :cond_11
    invoke-virtual/range {p0 .. p0}, Lcom/android/settings/SoundSettings;->getActivity()Landroid/app/Activity;

    move-result-object v18

    invoke-static/range {v18 .. v18}, Lcom/android/settings/Utils;->isTablet(Landroid/content/Context;)Z


method onPreferenceTreeClick:
 
Code:
    iget-object v4, p0, Lcom/android/settings/SoundSettings;->mLockSounds:Landroid/preference/CheckBoxPreference;

    invoke-virtual {v4}, Landroid/preference/CheckBoxPreference;->isChecked()Z

    move-result v4

    if-eqz v4, :cond_e

    :goto_8
    invoke-static {v2, v3, v0}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z

    goto/16 :goto_1

    :cond_e
    move v0, v1

    goto :goto_8

    .line 640
    :cond_f
    iget-object v2, p0, Lcom/android/settings/SoundSettings;->mVolBtnMusicCtrl:Landroid/preference/CheckBoxPreference;

    if-ne p2, v2, :cond_next

    .line 637
    invoke-virtual {p0}, Lcom/android/settings/SoundSettings;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v2

    const-string v3, "volbtn_music_controls"

    iget-object v4, p0, Lcom/android/settings/SoundSettings;->mVolBtnMusicCtrl:Landroid/preference/CheckBoxPreference;

    invoke-virtual {v4}, Landroid/preference/CheckBoxPreference;->isChecked()Z

    move-result v4

    if-eqz v4, :cond_long

    :goto_long
    invoke-static {v2, v3, v0}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z

    goto/16 :goto_1

    :cond_long
    move v0, v1

    goto :goto_long

    :cond_next
    iget-object v0, p0, Lcom/android/settings/SoundSettings;->mMusicFx:Landroid/preference/Preference;

    if-ne p2, v0, :cond_0

    goto/16 :goto_2
.end method


Now recompile SecSettings and the setting should be there. It won't do anything though.

Next we need to decompile android.policy.jar.

First file is com\android\internal\policy\impl\PhoneWindowManage r$PolicyHandler.smali

 
Add another switch statement:
Code:
    :pswitch_4
    iget-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager$PolicyHandler;->this$0:Lcom/android/internal/policy/impl/PhoneWindowManager;

    #calls: Lcom/android/internal/policy/impl/PhoneWindowManager;->enableSPenGesture()V
    invoke-static {v0}, Lcom/android/internal/policy/impl/PhoneWindowManager;->access$300(Lcom/android/internal/policy/impl/PhoneWindowManager;)V

    goto :goto_0
    
    :pswitch_5
    iget-object v1, p0, Lcom/android/internal/policy/impl/PhoneWindowManager$PolicyHandler;->this$0:Lcom/android/internal/policy/impl/PhoneWindowManager;

    iget-object v0, p1, Landroid/os/Message;->obj:Ljava/lang/Object;

    check-cast v0, Landroid/view/KeyEvent;

    invoke-virtual {v1, v0}, Lcom/android/internal/policy/impl/PhoneWindowManager;->dispatchMediaKeyWithWakeLockToAudioService(Landroid/view/KeyEvent;)V

    iget-object v1, p0, Lcom/android/internal/policy/impl/PhoneWindowManager$PolicyHandler;->this$0:Lcom/android/internal/policy/impl/PhoneWindowManager;

    iget-object v0, p1, Landroid/os/Message;->obj:Ljava/lang/Object;

    check-cast v0, Landroid/view/KeyEvent;
        
    const/16 v3, 0x01

    invoke-static {v0, v3}, Landroid/view/KeyEvent;->changeAction(Landroid/view/KeyEvent;I)Landroid/view/KeyEvent;

    move-result-object v0

    invoke-virtual {v1, v0}, Lcom/android/internal/policy/impl/PhoneWindowManager;->dispatchMediaKeyWithWakeLockToAudioService(Landroid/view/KeyEvent;)V

    iget-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager$PolicyHandler;->this$0:Lcom/android/internal/policy/impl/PhoneWindowManager;

    const/4 v2, 0x1
    
    iput-boolean v2, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeAction:Z
    
    goto :goto_0

    .line 828
    :pswitch_data_0
    .packed-switch 0x1
        :pswitch_0
        :pswitch_1
        :pswitch_2
        :pswitch_3
        :pswitch_4
        :pswitch_5
    .end packed-switch
.end method


Next: com\android\internal\policy\impl\PhoneWindowManage r$SettingsObserver.smali
 
method observe:
Code:
const-string v1, "incall_power_button_behavior"

    invoke-static {v1}, Landroid/provider/Settings$Secure;->getUriFor(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v1

    invoke-virtual {v0, v1, v2, p0}, Landroid/content/ContentResolver;->registerContentObserver(Landroid/net/Uri;ZLandroid/database/ContentObserver;)V

    const-string v1, "volbtn_music_controls"

    invoke-static {v1}, Landroid/provider/Settings$System;->getUriFor(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v1

    invoke-virtual {v0, v1, v2, p0}, Landroid/content/ContentResolver;->registerContentObserver(Landroid/net/Uri;ZLandroid/database/ContentObserver;)V

    .line 878
    const-string v1, "accelerometer_rotation"

    invoke-static {v1}, Landroid/provider/Settings$System;->getUriFor(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v1

    invoke-virtual {v0, v1, v2, p0}, Landroid/content/ContentResolver;->registerContentObserver(Landroid/net/Uri;ZLandroid/database/ContentObserver;)V


Next: com\android\internal\policy\impl\PhoneWindowManage r.smali

 
Code:
.field static final LONG_PRESS_POWER_NOTHING:I = 0x0

.field static final LONG_PRESS_POWER_SHUT_OFF:I = 0x2

.field private static final LONG_PRESS_TIMEOUT:I = 0x190

.field static final MINI_APP_DIALOG_LAYER:I = 0x5

.field static final MINI_APP_LAYER:I = 0x3
Code:
.field private mIsSensorhubEnabled:Z

.field private mIsVisibleSPenGestureView:Z

.field mIsVolumeAction:Z

.field mIsVolumeBlocking:Z

.field mKeyboardTapVibePattern:[J

.field mKeyguard:Landroid/view/WindowManagerPolicy$WindowState;
Code:
.field mVoiceTalkDefaultLaunch:Z

.field mVoiceTalkIntent:Landroid/content/Intent;

.field mVolBtnMusicControls:I

.field private mVolumeDownKeyConsumedByScreenshotChord:Z
method handleVolumeKey:
 

Code:
.method handleVolumeKey(II)V
    .locals 5

    move-object/from16 v0, p0

    iget-boolean v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeBlocking:Z

    if-nez v0, :cond_vc

    invoke-static {}, Lcom/android/internal/policy/impl/PhoneWindowManager;->getAudioService()Landroid/media/IAudioService;

    move-result-object v0

    if-nez v0, :cond_0

    .line 4898
    :cond_vc
    :goto_0
    return-void

    .line 4875
    :cond_0


Add the following after the above method handleVolumeKey
 

Code:
.method handleVolumeLongPress(Landroid/view/KeyEvent;)V
    .locals 11
    .parameter "event"

    .prologue
    const/4 v7, 0x0

    .line 26
    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeBlocking:Z

    .line 27
    iput-boolean v7, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeAction:Z

    .line 28
    invoke-virtual {p1}, Landroid/view/KeyEvent;->getKeyCode()I

    move-result v0

    const/16 v1, 0x18

    if-ne v0, v1, :cond_0

    .line 29
    const/16 v6, 0x57

    .line 30
    .local v6, newKeyCode:I
    :goto_0
    iget-object v9, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mHandler:Landroid/os/Handler;

    const/4 v10, 0x6

    .line 31
    new-instance v0, Landroid/view/KeyEvent;

    invoke-virtual {p1}, Landroid/view/KeyEvent;->getDownTime()J

    move-result-wide v1

    invoke-virtual {p1}, Landroid/view/KeyEvent;->getEventTime()J

    move-result-wide v3

    invoke-virtual {p1}, Landroid/view/KeyEvent;->getAction()I

    move-result v5

    invoke-direct/range {v0 .. v7}, Landroid/view/KeyEvent;->(JJIII)V

    .line 30
    invoke-virtual {v9, v10, v0}, Landroid/os/Handler;->obtainMessage(ILjava/lang/Object;)Landroid/os/Message;

    move-result-object v8

    .line 32
    .local v8, msg:Landroid/os/Message;
    iget-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mHandler:Landroid/os/Handler;

    sget v1, Lcom/android/internal/policy/impl/PhoneWindowManager;->LONG_PRESS_TIMEOUT:I

    int-to-long v1, v1

    invoke-virtual {v0, v8, v1, v2}, Landroid/os/Handler;->sendMessageDelayed(Landroid/os/Message;J)Z

    .line 33
    return-void

    .line 29
    .end local v6           #newKeyCode:I
    .end local v8           #msg:Landroid/os/Message;
    :cond_0
    const/16 v6, 0x58

    goto :goto_0
.end method

.method handleVolumeLongPressAbort()V
    .locals 2

    .prologue
    .line 36
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeBlocking:Z

    .line 37
    iget-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mHandler:Landroid/os/Handler;

    const/4 v1, 0x6

    invoke-virtual {v0, v1}, Landroid/os/Handler;->removeMessages(I)V

    .line 38
    return-void
.end method


method interceptKeyBeforeQueueing:
 
This one's kind of hard to find so here's some extra lines before and after:
Code:
.line 5201
    const/16 v23, 0x0

    move/from16 v0, v23

    move-object/from16 v1, p0

    iput-boolean v0, v1, Lcom/android/internal/policy/impl/PhoneWindowManager;->mVolumeDownKeyConsumedByScreenshotChord:Z

    .line 5202
    invoke-direct/range {p0 .. p0}, Lcom/android/internal/policy/impl/PhoneWindowManager;->cancelPendingPowerKeyAction()V

    .line 5203
    invoke-direct/range {p0 .. p0}, Lcom/android/internal/policy/impl/PhoneWindowManager;->cancelPendingScreenrecordChordAction()V

    .line 5204
    invoke-direct/range {p0 .. p0}, Lcom/android/internal/policy/impl/PhoneWindowManager;->interceptScreenshotChord()V

    .line 5246
    :cond_1a
    :goto_8
    if-eqz v5, :cond_long

    .line 5247
    invoke-static {}, Lcom/android/internal/policy/impl/PhoneWindowManager;->getTelephonyService()Lcom/android/internal/telephony/ITelephony;

    move-result-object v22

    .line 5248
    .local v22, telephonyService:Lcom/android/internal/telephony/ITelephony;
    if-eqz v22, :cond_20

    .line 5250
    :try_start_0
    invoke-interface/range {v22 .. v22}, Lcom/android/internal/telephony/ITelephony;->isRinging()Z
Code:
const-string v23, "WindowManager"

    const-string v24, "ITelephony threw RemoteException"

    move-object/from16 v0, v23

    move-object/from16 v1, v24

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

    .line 5333
    .end local v6           #ex:Landroid/os/RemoteException;
    :cond_20
    move-object/from16 v0, p0

   iget-boolean v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mScreenOnEarly:Z

    if-nez v0, :cond_reg

    invoke-virtual/range {p0 .. p0}, Lcom/android/internal/policy/impl/PhoneWindowManager;->isMusicActive()Z

    move-result v21

    if-eqz v21, :cond_reg

    const/16 v1, 0x1

    move-object/from16 v0, p0

    iget v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mVolBtnMusicControls:I

    if-ne v0, v1, :cond_reg

    move-object/from16 v0, p0
    
    move-object/from16 v1, p1

    invoke-virtual {v0, v1}, Lcom/android/internal/policy/impl/PhoneWindowManager;->handleVolumeLongPress(Landroid/view/KeyEvent;)V

    :cond_reg
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mSamsungVolumeControlThread:Lcom/android/internal/policy/impl/PhoneWindowManager$SamsungVolumeControlThread;

    move-object/from16 v23, v0

    if-nez v23, :cond_1
and a couple lines down:
Code:
move-object/from16 v23, v0

    invoke-virtual/range {v23 .. v23}, Lcom/android/internal/policy/impl/PhoneWindowManager$SamsungVolumeControlThread;->start()V

    goto/16 :goto_2

    .line 5341
    .end local v22           #telephonyService:Lcom/android/internal/telephony/ITelephony;
    :cond_long
    if-nez v5, :cond_vc

    move-object/from16 v0, p0

    iget-boolean v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeBlocking:Z

    if-eqz v0, :cond_vc

    const/16 v1, 0x1

    move-object/from16 v0, p0

    iget v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mVolBtnMusicControls:I

    if-ne v0, v1, :cond_vc

    invoke-virtual/range {p0 .. p0}, Lcom/android/internal/policy/impl/PhoneWindowManager;->handleVolumeLongPressAbort()V

    move-object/from16 v0, p0

    iget-boolean v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeAction:Z

    if-nez v0, :cond_vc

    move-object/from16 v0, p0

    const/4 v3, 0x0

    invoke-virtual {v0, v3, v15}, Lcom/android/internal/policy/impl/PhoneWindowManager;->handleVolumeKey(II)V

    :cond_vc
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mSamsungVolumeControlThread:Lcom/android/internal/policy/impl/PhoneWindowManager$SamsungVolumeControlThread;

    move-object/from16 v23, v0

    if-eqz v23, :cond_1


method updateSettings:
 
Code:
const-string v19, "incall_power_button_behavior"

    const/16 v20, 0x1

    move-object/from16 v0, v19

    move/from16 v1, v20

    invoke-static {v13, v0, v1}, Landroid/provider/Settings$Secure;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

    move-result v9

    const-string v19, "volbtn_music_controls"

    const/16 v20, 0x0

    move-object/from16 v0, v19

    move/from16 v1, v20

    invoke-static {v13, v0, v1}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

    move-result v3

    .line 2006
    const-string v19, "user_rotation"
Code:
iput v6, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mEndcallBehavior:I

    .line 2028
    move-object/from16 v0, p0

    iput v9, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIncallPowerBehavior:I

    move-object/from16 v0, p0

    iput v3, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mVolBtnMusicControls:I

    .line 2030
    move-object/from16 v0, p0

    iget v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mUserRotation:I


Newer Firmwares:(Sprint 4.1.2 MR2, etc.)
 
com\android\internal\policy\impl\PhoneWindowManage r.smali
We need to edit one of the sections in method interceptKeyBeforeQueueing.
Remove the code in purple and add the code in green.
Code:
move-object/from16 v23, v0

    invoke-virtual/range {v23 .. v23}, Lcom/android/internal/policy/impl/PhoneWindowManager$SamsungVolumeControlThread;->start()V

    goto/16 :goto_2

    .line 5341
    .end local v22           #telephonyService:Lcom/android/internal/telephony/ITelephony;
    :cond_long
    if-nez v5, :cond_vc

    move-object/from16 v0, p0

    iget-boolean v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeBlocking:Z

    if-eqz v0, :cond_vc

    invoke-virtual/range {p0 .. p0}, Lcom/android/internal/policy/impl/PhoneWindowManager;->handleVolumeLongPressAbort()V

    move-object/from16 v0, p0

    iget-boolean v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeAction:Z

    if-nez v0, :cond_vc

    move-object/from16 v0, p0

    const/4 v3, 0x0

    invoke-virtual {v0, v3, v15}, Lcom/android/internal/policy/impl/PhoneWindowManager;->handleVolumeKey(II)V

    iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mSamsungVolumeControlThread:Lcom/android/internal/policy/impl/PhoneWindowManager$SamsungVolumeControlThread;

    move-object/from16 v23, v0

    move-object/from16 v0, v23

    invoke-virtual {v0, v3, v15}, Lcom/android/internal/policy/impl/PhoneWindowManager$SamsungVolumeControlThread;->handleVolume(II)V

    :cond_vc
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mSamsungVolumeControlThread:Lcom/android/internal/policy/impl/PhoneWindowManager$SamsungVolumeControlThread;

    move-object/from16 v23, v0

    if-eqz v23, :cond_1

com\android\internal\policy\impl\PhoneWindowManage r$SamsungVolumeControlThread.smali

method handleVolume:
 
Code:
.method handleVolume(II)V
    .locals 6

    iget-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager$SamsungVolumeControlThread;->this$0:Lcom/android/internal/policy/impl/PhoneWindowManager;

    iget-boolean v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeBlocking:Z

    if-nez v0, :cond_vc
    
    iget-object v3, p0, Lcom/android/internal/policy/impl/PhoneWindowManager$SamsungVolumeControlThread;->this$0:Lcom/android/internal/policy/impl/PhoneWindowManager;

    iget-object v3, v3, Lcom/android/internal/policy/impl/PhoneWindowManager;->mContext:Landroid/content/Context;

    const-string v4, "audio"

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

    move-result-object v0

    check-cast v0, Landroid/media/AudioManager;

    if-nez v0, :cond_0

    :cond_vc
    :goto_0
    return-void

    :cond_0
    :try_start_0
    invoke-virtual {v0}, Landroid/media/AudioManager;->dismissVolumePanel()V

    sparse-switch p2, :sswitch_data_0

    goto :goto_0



ISSUES:
Pressing volume up or down both turn the volume down(or up):
 
Looking at a little bit more from the last entry:
Code:
    move-object/from16 v23, v0

    invoke-virtual/range {v23 .. v23}, Lcom/android/internal/policy/impl/PhoneWindowManager$SamsungVolumeControlThread;->start()V

    goto/16 :goto_2

    .line 5341
    .end local v22           #telephonyService:Lcom/android/internal/telephony/ITelephony;
    :cond_long
    if-nez v5, :cond_vc

    move-object/from16 v0, p0

    iget-boolean v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeBlocking:Z

    if-eqz v0, :cond_vc

    invoke-virtual/range {p0 .. p0}, Lcom/android/internal/policy/impl/PhoneWindowManager;->handleVolumeLongPressAbort()V

    move-object/from16 v0, p0

    iget-boolean v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeAction:Z

    if-nez v0, :cond_vc

    move-object/from16 v0, p0

    const/4 v3, 0x0

    invoke-virtual {v0, v3, v15}, Lcom/android/internal/policy/impl/PhoneWindowManager;->handleVolumeKey(II)V

    :cond_vc
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mSamsungVolumeControlThread:Lcom/android/internal/policy/impl/PhoneWindowManager$SamsungVolumeControlThread;

    move-object/from16 v23, v0

    if-eqz v23, :cond_1

    .line 5342
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mSamsungVolumeControlThread:Lcom/android/internal/policy/impl/PhoneWindowManager$SamsungVolumeControlThread;

    move-object/from16 v23, v0

    move-object/from16 v0, v23

    invoke-virtual {v0, v15, v5, v4}, Lcom/android/internal/policy/impl/PhoneWindowManager$SamsungVolumeControlThread;->updateInfo(IZZ)V
Pull the variable in orange from the last line and replace the variable in line
Code:
    invoke-virtual {v0, v3, v15}, Lcom/android/internal/policy/impl/PhoneWindowManager;->handleVolumeKey(II)V
Make sure you're not replacing the last line with anything, but using it as reference.
Attached Files
File Type: zip PhoneWindowManagerDiffs.zip - [Click for QR Code] (128.3 KB, 615 views)
File Type: zip Volume Mod 2.0 diffs.zip - [Click for QR Code] (153.3 KB, 558 views)
The Following 41 Users Say Thank You to loserskater For This Useful Post: [ Click to Expand ]
 
Lilsir64
Old
#2  
Member
Thanks Meter 3
Posts: 36
Join Date: Aug 2012
Cool

Sent from my SAMSUNG-SGH-I747 using xda app-developers app
 
enewman17
Old
#3  
enewman17's Avatar
Recognized Contributor
Thanks Meter 5784
Posts: 2,493
Join Date: Sep 2010
Location: Fort Wayne, IN

 
DONATE TO ME
This is great! made the changes and everything is running great.

Sent you a donation, Cheers! have a beer on me *Happy New Year!*

Thanks for all your hard work it is much appreciated
The Following User Says Thank You to enewman17 For This Useful Post: [ Click to Expand ]
 
loserskater
Old
#4  
loserskater's Avatar
Recognized Developer - OP
Thanks Meter 3284
Posts: 1,847
Join Date: Jun 2008
Location: San Diego, CA

 
DONATE TO ME
Quote:
Originally Posted by enewman17 View Post
This is great! made the changes and everything is running great.

Sent you a donation, Cheers! have a beer on me *Happy New Year!*

Thanks for all your hard work it is much appreciated
Did you use the cond's in green? Or did you just replace the file?
HTC One (M8)

Do not PM me for help trying to get one of my mods to work.
That's what the threads are for. I posted the threads so you can see what I did, not as an advertisement that I will do it for you.
The Following 2 Users Say Thank You to loserskater For This Useful Post: [ Click to Expand ]
 
enewman17
Old
(Last edited by enewman17; 29th December 2012 at 10:55 PM.)
#5  
enewman17's Avatar
Recognized Contributor
Thanks Meter 5784
Posts: 2,493
Join Date: Sep 2010
Location: Fort Wayne, IN

 
DONATE TO ME
Quote:
Originally Posted by loserskater View Post
Did you use the cond's in green? Or did you just replace the file?
I did not use the cond's in green, I manually made the changes excluding them.
I am curious now if it will work using those cond's I will try it later. I'm just so happy you were able to get it working! and well!

I had problems compiling it with apktool after I made the changes, but doing it manually worked and now apktool will compile and decompile without error. I don't get it.

I've only tested it with the stock player and google play music and it works perfectly. I don't use anything else so i didn't test.
 
loserskater
Old
(Last edited by loserskater; 29th December 2012 at 11:04 PM.)
#6  
loserskater's Avatar
Recognized Developer - OP
Thanks Meter 3284
Posts: 1,847
Join Date: Jun 2008
Location: San Diego, CA

 
DONATE TO ME
Quote:
Originally Posted by enewman17 View Post
I did not use the cond's in green, I manually made the changes excluding them.
I am curious now if it will work using those cond's I will try it later. I'm just so happy you were able to get it working! and well!

I had problems compiling it with apktool after I made the changes, but doing it manually worked and now apktool will compile and decompile without error. I don't get it.

I've only tested it with the stock player and google play music and it works perfectly. I don't use anything else so i didn't test.
What showed up with apktool? It's possible you missed a cond somewhere...
HTC One (M8)

Do not PM me for help trying to get one of my mods to work.
That's what the threads are for. I posted the threads so you can see what I did, not as an advertisement that I will do it for you.
 
enewman17
Old
(Last edited by enewman17; 29th December 2012 at 11:51 PM.)
#7  
enewman17's Avatar
Recognized Contributor
Thanks Meter 5784
Posts: 2,493
Join Date: Sep 2010
Location: Fort Wayne, IN

 
DONATE TO ME
Quote:
Originally Posted by loserskater View Post
What showed up with apktool? It's possible you missed a cond somewhere...
I don't remember, something like false value blah blah...

I diff'ed the the files using win merge and they are exactly the same. It's not the first time it's happened to me seem's like it's the way notepad++ saves the file... maybe.... I had more problems using getdiz as a text editor. I don't know maybe it's me. But I do know it works.

When I changed the sound file in the SecContacts to get rid of the water drop sound from the dial pad I could not get apktool to compile it for the life of me, If I put the original sound back, apktool worked. Used manual commands and poof it worked like some sort of fairy magic. It was really starting to annoy me, but persistence pays off. Now apktool will decompile and compile my modded SecContacts with no problem. Also had the same problem when editing the SecPhone to get rid of the increasing ringtone. Same false value error. did it manually and it worked but I kind of figured it would happen cause that mod is kind of hacky to begin with, I didn't delete the lines for that mod, but rather omitted those lines with a #
 
MikHaiL_08
Old
#8  
MikHaiL_08's Avatar
Senior Member
Thanks Meter 557
Posts: 329
Join Date: Oct 2012
Location: Brooklyn
Thanks for sharing man. Works great with both att and tmo!
The Following User Says Thank You to MikHaiL_08 For This Useful Post: [ Click to Expand ]
 
upndwn4par
Old
#9  
upndwn4par's Avatar
Recognized Developer
Thanks Meter 9072
Posts: 3,280
Join Date: Jan 2012
Location: New Jersey
Thanks! Will be trying this soon.
 
hellsgod
Old
#10  
hellsgod's Avatar
Senior Member
Thanks Meter 2882
Posts: 666
Join Date: Oct 2007
Location: Earth

 
DONATE TO ME
First of all, thank you for this Tutorial. I'll try it now since a few hours, but it won't recompile. I'll tried it with the green ones and without it. Apktool gives me this errors:

I: Checking whether sources has changed...
I: Smaling...
Exception in thread "main" brut.androlib.AndrolibException: Could not smali file
: java.io.FileInputStream@61bedd7d
at brut.androlib.src.DexFileBuilder.addSmaliFile(DexF ileBuilder.java:45)

at brut.androlib.src.DexFileBuilder.addSmaliFile(DexF ileBuilder.java:33)

at brut.androlib.src.SmaliBuilder.buildFile(SmaliBuil der.java:64)
at brut.androlib.src.SmaliBuilder.build(SmaliBuilder. java:48)
at brut.androlib.src.SmaliBuilder.build(SmaliBuilder. java:35)
at brut.androlib.Androlib.buildSourcesSmali(Androlib. java:243)
at brut.androlib.Androlib.buildSources(Androlib.java: 200)
at brut.androlib.Androlib.build(Androlib.java:191)
at brut.androlib.Androlib.build(Androlib.java:174)
at brut.apktool.Main.cmdBuild(Main.java:188)
at brut.apktool.Main.main(Main.java:70)
Drücken Sie eine beliebige Taste . . .

Maybe someone have an idea. Thank you (=

hells

Tags
long press, skip, tracks, volume mod
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes