5,595,428 Members 48,541 Now Online
XDA Developers Android and Mobile Development Forum

[Q] Remove Preference in smali

Tip us?
 
Wooaarr
Old
#1  
Member - OP
Thanks Meter 27
Posts: 47
Join Date: May 2012
Question [Q] Remove Preference in smali

Hello there,

i want to achive a simple thing. Removing an entry in the "SpareParts" app.

This is the xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
  xmlns:android="http://schemas.android.com/apk/res/android">
    <PreferenceCategory android:title="@string/device_info_title">
        <PreferenceScreen android:title="@string/title_battery_history" android:key="battery_history_settings" android:summary="@string/summary_battery_history">
            <intent android:targetPackage="com.android.settings" android:action="android.intent.action.MAIN" android:targetClass="com.android.settings.battery_history.BatteryHistory" />
        </PreferenceScreen>
        <PreferenceScreen android:title="@string/title_battery_information" android:key="battery_information_settings" android:summary="@string/summary_battery_information">
            <intent android:targetPackage="com.android.settings" android:action="android.intent.action.MAIN" android:targetClass="com.android.settings.BatteryInfo" />
        </PreferenceScreen>
        <PreferenceScreen android:title="@string/title_usage_statistics" android:key="usage_statistics_settings" android:summary="@string/summary_usage_statistics">
            <intent android:targetPackage="com.android.settings" android:action="android.intent.action.MAIN" android:targetClass="com.android.settings.UsageStats" />
        </PreferenceScreen>
    </PreferenceCategory>
    <PreferenceCategory android:title="@string/general_title">
        <ListPreference android:entries="@array/entries_animations" android:title="@string/title_window_animations" android:key="window_animations" android:summary="@string/summary_window_animations" android:dialogTitle="@string/dialog_title_window_animations" android:entryValues="@array/entryvalues_animations" />
        <ListPreference android:entries="@array/entries_animations" android:title="@string/title_transition_animations" android:key="transition_animations" android:summary="@string/summary_transition_animations" android:dialogTitle="@string/dialog_title_transition_animations" android:entryValues="@array/entryvalues_animations" />
        <CheckBoxPreference android:title="@string/title_fancy_ime_animations" android:key="fancy_ime_animations" android:summaryOn="@string/summary_on_fancy_ime_animations" android:summaryOff="@string/summary_off_fancy_ime_animations" />
        <ListPreference android:entries="@array/entries_font_size" android:title="@string/title_font_size" android:key="font_size" android:summary="@string/summary_font_size" android:dialogTitle="@string/dialog_title_font_size" android:entryValues="@array/entryvalues_font_size" />
        <CheckBoxPreference android:title="@string/title_haptic_feedback" android:key="haptic_feedback" android:summaryOn="@string/summary_on_haptic_feedback" android:summaryOff="@string/summary_off_haptic_feedback" />
        <CheckBoxPreference android:title="@string/compatibility_mode_title" android:key="compatibility_mode" android:summaryOn="@string/compatibility_mode_summary_on" android:summaryOff="@string/compatibility_mode_summary_off" />
    </PreferenceCategory>
    <PreferenceCategory android:enabled="false" android:title="@string/disabled">
        <ListPreference android:entries="@array/entries_end_button" android:title="@string/title_end_button" android:key="end_button" android:summary="@string/summary_end_button" android:dialogTitle="@string/dialog_title_end_button" android:entryValues="@array/entryvalues_end_button" />
    </PreferenceCategory>
</PreferenceScreen>
The preference i want to remove is in bold. Now just deleting it, obviously will cause the app to fc. I have to remove the preference in the smali code.
Unfortunatly i have no idea, where and how exactly implement the right code to remove the preference.

An example on how to remove a preference would be (Just an example, thats not what i want to remove):
Code:
invoke-virtual {p0}, Lcom/android/settings/WirelessSettings;->getPreferenceScreen()Landroid/preference/PreferenceScreen;
move-result-object v12
const-string v13, "toggle_wifi"
invoke-virtual {p0, v13}, Lcom/android/settings/WirelessSettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v13
invoke-virtual {v12, v13}, Landroid/preference/PreferenceScreen;->removePreference(Landroid/preference/Preference;)Z
If anyone could help me out on where to implement the appropiate code i would be glad to learn about this.

I attached the smali code.

Thanks in advance
Attached Files
File Type: txt Spare.txt - [Click for QR Code] (29.0 KB, 8 views)
 
arpitkh96
Old
#2  
arpitkh96's Avatar
Senior Member
Thanks Meter 336
Posts: 983
Join Date: Feb 2012
Location: panipat
This is a system app right? So it's sources might be present. That could save you from smali
Edit-And upto what I remember. Removing a preference from settings.apk mainsetting.xml didn't make it fc
Sent from my GT-S7392 using XDA Premium 4 mobile app
 
Wooaarr
Old
#3  
Member - OP
Thanks Meter 27
Posts: 47
Join Date: May 2012
Quote:
Originally Posted by arpitkh96 View Post
This is a system app right? So it's sources might be present. That could save you from smali
Edit-And upto what I remember. Removing a preference from settings.apk mainsetting.xml didn't make it fc
Thank you for your reply.

Unfortunatly just removing it from the *.xml will cause a fc. I think the system trys to call the preference and as it won't be defined, causing a "Javalang nullPointer exception".

The app is of course available as a source, which would make it very easy to remove the preference in java.
Code:
preferenceScreen.removePreference((ListPreference) findPreference("*********"));
Then again i don't have the appropriate tools at hand and not unlimited bandwidth to download them.

Hence my question if somebody knows how to do it in smali.

Take care
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes