Quantcast
Channel: xda-developers - AT&T Galaxy S III Android Development
Viewing all articles
Browse latest Browse all 285

[MOD][HOW-TO] Long press volume mod 3.0

$
0
0
This new version will allow users to select timeout and what each volume button can do.

We're going to be working with the following two files:
SecSettings.apk
android.policy.jar



KEY
REMOVE what's in BLUE
ADD what's in RED



Issues
Play will not work if the device is in deep sleep.
I'm looking into a way to allow volume buttons to wake the device from deep sleep but at the moment the only way is a custom kernel.


SecSettings.apk
 
Navigate to /res/values/arrays.xml
Add the following to the end of the file
 
Code:

<string-array name="volbtn_action_entries">
        <item>Next</item>
        <item>Pause</item>
        <item>Play</item>
        <item>Play/Pause</item>
        <item>Previous</item>
        <item>Stop</item>
    </string-array>
    <string-array name="volbtn_action_values">
        <item>87</item>
        <item>127</item>
        <item>126</item>
        <item>85</item>
        <item>88</item>
        <item>86</item>
    </string-array>
    <string-array name="volbtn_timeout_entries">
        <item>100ms</item>
        <item>150ms</item>
        <item>200ms</item>
        <item>250ms</item>
        <item>300ms</item>
        <item>350ms</item>
        <item>400ms</item>
        <item>450ms</item>
        <item>500ms</item>
    </string-array>
    <string-array name="volbtn_timeout_values">
        <item>100</item>
        <item>150</item>
        <item>200</item>
        <item>250</item>
        <item>300</item>
        <item>350</item>
        <item>400</item>
        <item>450</item>
        <item>500</item>
    </string-array>


Navigate to /res/values/strings.xml
Add the following to the end of the file
 
Code:

    <string name="volbtn_toggle_title">Music Control</string>
    <string name="volbtn_vol_up_title">Volume Up action</string>
    <string name="volbtn_vol_up_summary">%s</string>
    <string name="volbtn_vol_down_title">Volume Down action</string>
    <string name="volbtn_vol_down_summary">%s</string>


Navigate to /xml/sound_settings.xml
 
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" />
    <SwitchPreferenceScreen android:title="@string/volbtn_toggle_title" android:key="volbtn_music_controls" android:fragment="com.android.settings.VolBtnSettings" />
</PreferenceScreen>



Navigate to /smali/com/android/settings/SoundSettings.smali
 
Code:

.field private mUnloadSoundEffectRunnable:Ljava/lang/Runnable;

.field private mVibrateWhenRinging:Landroid/preference/CheckBoxPreference;

.field private mVolBtnMusicCtrl:Landroid/preference/SwitchPreferenceScreen;

.field private mVolume:Lcom/android/settings/RingerVolumePreference;



method private updateState(Z)V
 
Code:

    :cond_0
    :goto_0
    return-void

    .line 521
    :cond_1
    iget-object v1, p0, Lcom/android/settings/SoundSettings;->mAudioManager:Landroid/media/AudioManager;

    invoke-virtual {v1}, Landroid/media/AudioManager;->getRingerMode()I

    move-result v8

    .line 522
    .local v8, ringerMode:I
    iget-object v1, p0, Lcom/android/settings/SoundSettings;->mVolBtnMusicCtrl:Landroid/preference/SwitchPreferenceScreen;

    if-eqz v1, :cond_next

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

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

    move-result-object v1

    const-string v9, "volbtn_music_controls"

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

    move-result v1

    if-eqz v1, :cond_vol

    move v1, v3

    :goto_vol
    invoke-virtual {v2, v1}, Landroid/preference/SwitchPreferenceScreen;->setChecked(Z)V

    :cond_2

    const-string v1, "CTC"

    const-string v2, "ro.csc.sales_code"

    invoke-static {v2}, Landroid/os/SystemProperties;->get(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

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

    move-result v1


 
Code:

    iget-object v1, p0, Lcom/android/settings/SoundSettings;->mPhoneProfile:Landroid/preference/Preference;

    const-string v2, "profile_name"

    invoke-interface {v7, v2}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v2

    invoke-interface {v7, v2}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Landroid/preference/Preference;->setSummary(Ljava/lang/CharSequence;)V

    .line 539
    invoke-interface {v7}, Landroid/database/Cursor;->close()V

    goto/16 :goto_2

    :cond_vol
    move v1, v4

    goto/16 :goto_vol

.end method



method public onCreate(Landroid/os/Bundle;)V
 
Code:

    const-string v18, "autohaptic_settings"

    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/SwitchPreferenceScreen;

    move-object/from16 v0, v18

    move-object/from16 v1, p0

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

    .line 296
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/settings/SoundSettings;->mAutoHaptic:Landroid/preference/SwitchPreferenceScreen;

    move-object/from16 v18, v0

    move-object/from16 v0, v18

    move-object/from16 v1, p0

    invoke-virtual {v0, v1}, Landroid/preference/SwitchPreferenceScreen;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V

    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/SwitchPreferenceScreen;

    move-object/from16 v0, v18

    move-object/from16 v1, p0

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

    move-object/from16 v0, p0

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

    move-object/from16 v18, v0

    move-object/from16 v0, v18

    move-object/from16 v1, p0

    invoke-virtual {v0, v1}, Landroid/preference/SwitchPreferenceScreen;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V


    .line 298
    const-string v18, "phone_vibration"

    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

    move-object/from16 v0, v18

    move-object/from16 v1, p0

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



.method public onPreferenceChange(Landroid/preference/Preference;Ljava/lang/Object;)Z
 
Code:

    const-string v9, "SoundSettings"

    new-instance v10, Ljava/lang/StringBuilder;

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

    const-string v11, "onPreferenceChange : "

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

    move-result-object v10

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

    move-result-object v10

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

    move-result-object v10

    invoke-static {v9, v10}, Landroid/util/secutil/Log;->secV(Ljava/lang/String;Ljava/lang/String;)I

    .line 653
    const-string v9, "volbtn_music_controls"

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

    move-result v9

    if-eqz v9, :cond_next

    check-cast p2, Ljava/lang/Boolean;

    invoke-virtual {p2}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v9

    if-eqz v9, :cond_vol

    const/4 v6, 0x1

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

    move-result-object v7

    const-string v9, "volbtn_music_controls"

    invoke-static {v7, v9, v6}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z

    goto :goto_1

    :cond_vol
    const/4 v6, 0x0

    goto :goto_vol

    :cond_next

    const-string v9, "emergency_tone"

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

    move-result v9

    if-eqz v9, :cond_3

    .line 655
    :try_start_0
    check-cast p2, Ljava/lang/String;

    .end local p2



Now download the zip attached to this post and copy into your SecSettings folder.
You need compile and decompile so we can get some ID's.

Navigate to /smali/com/android/settings/VolBtnSettings.smali
And look for the commented (#) sections and replace the ID's with the ones in /res/values/public.xml

Now compile and move on to android.policy.jar.

Attached Thumbnails
Click image for larger version

Name:	2013-04-27 18.21.48.jpg
Views:	N/A
Size:	15.5 KB
ID:	1917759   Click image for larger version

Name:	2013-04-27 18.21.55.jpg
Views:	N/A
Size:	19.3 KB
ID:	1917760  
Attached Files
File Type: zip Volume Mod 3.0 SecSettings files.zip - [Click for QR Code] (24.4 KB)

Viewing all articles
Browse latest Browse all 285

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>