[Galaxy S II Android Development] remuntada78:
trying to work with smali

Hi Goldieking I'm trying to modify my SecSettings.apk trying to make a mod for toggle

In Settings/display i'm trying to add a ListPreference to show something like this View attachment 2337822

In my DisplaySetting.smali i've add this in red:

.field private mSmartRotationAnimationImage:[I

.field private mSmartStayAnimationImage:[I

.field mStatusbarColor:Lcom/loser/colorpicker/ColorPickerPreference;

.field mSupportFolderType:Z

[COLOR="Red"].field private mTogglesStyle:Landroid/preference/ListPreference;[/COLOR]

.field private mTouchKeyLight:Landroid/preference/ListPreference;

In the .method public onCreate(Landroid/os/Bundle)V i've add this

const-string v12, "battery_icon_list"

invoke-virtual {p0, v12}, Lcom/android/settings/DisplaySettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

move-result-object v12

check-cast v12, Landroid/preference/ListPreference;

iput-object v12, p0, Lcom/android/settings/DisplaySettings;->mBatteryStyle:Landroid/preference/ListPreference;

const-string v12, "battery_icon_list"

const/4 v13, 0x0

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

move-result v12

iget-object v13, p0, Lcom/android/settings/DisplaySettings;->mBatteryStyle:Landroid/preference/ListPreference;

invoke-static {v12}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

move-result-object v12

invoke-virtual {v13, v12}, Landroid/preference/ListPreference;->setValue(Ljava/lang/String;)V

iget-object v13, p0, Lcom/android/settings/DisplaySettings;->mBatteryStyle:Landroid/preference/ListPreference;

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

[COLOR="Red"]	const-string v12, "toggles_icon_list"

invoke-virtual {p0, v12}, Lcom/android/settings/DisplaySettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

move-result-object v12

check-cast v12, Landroid/preference/ListPreference;

iput-object v12, p0, Lcom/android/settings/DisplaySettings;->mTogglesStyle:Landroid/preference/ListPreference;

const-string v12, "toggles_icon_list"

const/4 v13, 0x0

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

move-result v12

iget-object v13, p0, Lcom/android/settings/DisplaySettings;->mTogglesStyle:Landroid/preference/ListPreference;

invoke-static {v12}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

move-result-object v12

invoke-virtual {v13, v12}, Landroid/preference/ListPreference;->setValue(Ljava/lang/String;)V

iget-object v13, p0, Lcom/android/settings/DisplaySettings;->mTogglesStyle:Landroid/preference/ListPreference;

invoke-virtual {v13, p0}, Landroid/preference/SwitchPreferenceScreen;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V[/COLOR]

And in the .method public onPreferenceChange i' ve add this:

:cond_d
const-string v2, "contextualpage_settings"

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

move-result v0

if-eqz v0, :cond_12

const-string v2, "contextualpage_settings"

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

move-result v0

[COLOR="Red"] if-eqz v0, :cond_13	[/COLOR]

.line 1089
check-cast p2, Ljava/lang/Boolean;

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

move-result v0

if-eqz v0, :cond_e

move v0, v6

.line 1090
:goto_6

:cond_11
move-wide v0, v4

goto/16 :goto_3

:cond_12
iget-object v1, p0, Lcom/android/settings/DisplaySettings;->mBatteryStyle:Landroid/preference/ListPreference;

if-ne p1, v1, :cond_2

check-cast p2, Ljava/lang/String;

invoke-static {p2}, Ljava/lang/Integer;->valueOf(Ljava/lang/String;)Ljava/lang/Integer;

move-result-object v1

invoke-virtual {v1}, Ljava/lang/Integer;->intValue()I

move-result v0

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

move-result-object v1

const-string v2, "battery_icon_list"

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

goto/16 :goto_4

[COLOR="Red"][/COLOR] :cond_13
iget-object v1, p0, Lcom/android/settings/DisplaySettings;->mTogglesStyle:Landroid/preference/ListPreference;

if-ne p1, v1, :cond_1

check-cast p2, Ljava/lang/String;

invoke-static {p2}, Ljava/lang/Integer;->valueOf(Ljava/lang/String;)Ljava/lang/Integer;

move-result-object v1

invoke-virtual {v1}, Ljava/lang/Integer;->intValue()I

move-result v0

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

move-result-object v1

const-string v2, "toggles_icon_list"

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

goto/16 :goto_4	[/COLOR]
.end method

The logcat show this:

W/dalvikvm( 3982): VFY: register1 v0 type 5, wanted ref

W/dalvikvm( 3982): VFY: bad arg 1 (into Ljava/lang/Object;)

W/dalvikvm( 3982): VFY: rejecting call to Ljava/lang/String;.equals (Ljava/lang/Object;)Z

W/dalvikvm( 3982): VFY: rejecting opcode 0x6e at 0x0215

W/dalvikvm( 3982): VFY: rejected Lcom/android/settings/DisplaySettings;.onPreferenceChange (Landroid/preference/Preference;Ljava/lang/Object;)Z

W/dalvikvm( 3982): Verifier rejected class Lcom/android/settings/DisplaySettings;

W/dalvikvm( 3982): Class init failed in newInstance call (Lcom/android/settings/DisplaySettings;)

D/AndroidRuntime( 3982): Shutting down VM

W/dalvikvm( 3982): threadid=1: thread exiting with uncaught exception (group=0x41af32a0)

E/AndroidRuntime( 3982): FATAL EXCEPTION: main

E/AndroidRuntime( 3982): java.lang.VerifyError: com/android/settings/DisplaySettings

E/AndroidRuntime( 3982):	at java.lang.Class.newInstanceImpl(Native Method)

E/AndroidRuntime( 3982):	at java.lang.Class.newInstance(Class.java:1319)

E/AndroidRuntime( 3982):	at android.app.Fragment.instantiate(Fragment.java:577)

E/AndroidRuntime( 3982):	at android.preference.PreferenceActivity.switchToHeaderInner(PreferenceActivity.java:1229)

E/AndroidRuntime( 3982):	at android.preference.PreferenceActivity.switchToHeader(PreferenceActivity.java:1245)

E/AndroidRuntime( 3982):	at android.preference.PreferenceActivity.onCreate(PreferenceActivity.java:618)

E/AndroidRuntime( 3982):	at com.android.settings.Settings.onCreate(Settings.java:191)

E/AndroidRuntime( 3982):	at android.app.Activity.performCreate(Activity.java:5206)

E/AndroidRuntime( 3982):	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)

E/AndroidRuntime( 3982):	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)

E/AndroidRuntime( 3982):	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)

E/AndroidRuntime( 3982):	at android.app.ActivityThread.access$700(ActivityThread.java:140)

E/AndroidRuntime( 3982):	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)

E/AndroidRuntime( 3982):	at android.os.Handler.dispatchMessage(Handler.java:99)

E/AndroidRuntime( 3982):	at android.os.Looper.loop(Looper.java:137)

E/AndroidRuntime( 3982):	at android.app.ActivityThread.main(ActivityThread.java:4921)

E/AndroidRuntime( 3982):	at java.lang.reflect.Method.invokeNative(Native Method)

E/AndroidRuntime( 3982):	at java.lang.reflect.Method.invoke(Method.java:511)

E/AndroidRuntime( 3982):	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)

E/AndroidRuntime( 3982):	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)

E/AndroidRuntime( 3982):	at dalvik.system.NativeStart.main(Native Method)

So i know i make errors in the .method public onPreferenceChange (Landroid/preference/Preference;Ljava/lang/Object;)Z

can you teach me how to add new lines to make it work?