Question

Because I'm creating a custom ROM I want to remove some entries from the settings.apk Because there is no way to hide a preference with XML I have to change the source code from the apk and have to delete the preference from the PreferenceScreen. So I decompiled the classes.dex with dex2jar copied the source code and add the following line:

getPreferenceScreen().removePreference(findPreference("toggle_wifi"));

Now my problem is that I do not know how to recompile the app. I can't compile it wit Eclipse because it uses some system namespaces (in Eclipse it is an error so I can't compile) How can I recompile the app? I only have the *.java files.

EDIT: The smali code I added to the smali files:

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

invoke-virtual {p0}, Lcom/android/settings/WirelessSettings;->getPreferenceScreen()Landroid/preference/PreferenceScreen;
move-result-object v12
const-string v13, "wifi_settings"
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

invoke-virtual {p0}, Lcom/android/settings/WirelessSettings;->getPreferenceScreen()Landroid/preference/PreferenceScreen;
move-result-object v12
const-string v13, "toggle_bluetooth"
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

invoke-virtual {p0}, Lcom/android/settings/WirelessSettings;->getPreferenceScreen()Landroid/preference/PreferenceScreen;
move-result-object v12
const-string v13, "bt_settings"
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
Était-ce utile?

La solution

You can find a detailed tutorial in the following link:

Decompile and Recompile

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top