[Q] Remove Preference in smali - Java for Android App Development

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>
[b][SIZE="4"]<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>[/SIZE][/b]
</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

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

arpitkh96 said:
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
Click to expand...
Click to collapse
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

u can also let that preference load custom layout... and make that layout 0.0dip
thats what i did when some preferences were linked to id in smali
check touchwiz resurection settings.apk and then settings.xml
in it i used custom layout called empty_pref.xml
Sent from my Acer S500 CloudMobile

Related

view flipper

i have some doubts related to view flipper in android
1>when to use setAnimation and setInAnimation/setOutAnimation? or what the difference between them?
2>can u decipher push_left_in.xml in animation folder(available in sample folder in sdk) as i have to make push_right_in.xml ?
HTML:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="300"/>
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" />
</set>

Noob App Development

I've just started developing my first app a couple weeks ago, I learned coding in flash and with HTML(not 5).
I'm developing an aggregator app to help you check stuff on your device faster.
I am completly stuck on the simpliest thing, I need to know how to properly add @string's to my XML for buttons, etc. and how to add to the strings file so I dont get those warnings.
Also I want to know how to add a new activity to my project without deleting the MainActivity's "strings" file.
Thank you so much to anyone who can guide me!! I need this app done for me to get a passing grade in my class. Whoever helps gets my apps free for life when i'm a puplisher. Thank you so much!!
Sent from my HUAWEI-M835 using xda app-developers app
Ok.
Add a string this way:
Code:
<string name="[name goes here]">[the string]</string>
(Add this in the strings.xml file in the res/values directory.)
Then in your app you can get it this way:
Code:
String s = getString(R.string.[name goes here]);
Set the text in the xml file that way:
Code:
<Button ...
android:text="@string/[name goes here]"
... />
Add the Activity the normal way. You do not need a second strings.xml file. Just add it to the old one. One for everything.
That helps alot, but,
But whenever I add the @string/ before the text it changes the button name on the visual editor to @string/...."
Also when I added a new activity it replaced my strings file, deleting what I thought was proper strings.
Sent from my HUAWEI-M835 using xda app-developers app
crazy4creationstudios said:
That helps alot, but,
But whenever I add the @string/ before the text it changes the button name on the visual editor to @string/...."
Also when I added a new activity it replaced my strings file, deleting what I thought was proper strings.
Sent from my HUAWEI-M835 using xda app-developers app
Click to expand...
Click to collapse
Which revision of the Android SDK do you have? Updating might help.
Could you please post some pieces of your code which do not work (just the important parts, you can change the names etc.)?
Also im using the SDK and IDE from Google (Eclipse).
And Java JDK
Sent from my HUAWEI-M835 using xda app-developers app
crazy4creationstudios said:
Also im using the SDK and IDE from Google (Eclipse).
And Java JDK
Sent from my HUAWEI-M835 using xda app-developers app
Click to expand...
Click to collapse
Eclipse has not been created by Google. But this does not matter.
Which version of the SDK did you install? (To check this and whether updates are available open the SDK manager. You might need to do this as an administrator.)
I don't know, i'll check in a few minutes at lunch. I downloaded it about 2 weeks ago.
I'll post the codes then too.
Btw none of the code is custom it is from Eclipse when I used the GUI tools
Sent from my HUAWEI-M835 using xda app-developers app
nikwen said:
Eclipse has not been created by Google. But this does not matter.
Which version of the SDK did you install? (To check this and whether updates are available open the SDK manager. You might need to do this as an administrator.)
Click to expand...
Click to collapse
I know but developer.google.com includes it with the ADT bundle.
And I meant to send that b4 u replied haha
Sent from my HUAWEI-M835 using xda app-developers app
Codes
nikwen said:
Which revision of the Android SDK do you have? Updating might help.
Could you please post some pieces of your code which do not work (just the important parts, you can change the names etc.)?
Click to expand...
Click to collapse
Im using API level 17 the Rev. is 2 im using the latest version for x86 systems (32-bit)
My strings file looks like this:
<resources>
<string name="title_activity_socialpage1">Socialpage1</string>
<string name="action_settings">Settings</string>
</resources>
And my Main xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="c4cs.try4.everydayagian"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="c4cs.try4.everydayagian.MainActivity"
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</activity>
<activity
android:name="c4cs.try4.everydayagian.Socialpage1"
android:label="@string/title_activity_socialpage1"
androidarentActivityName="c4cs.try4.everydayagian.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="c4cs.try4.everydayagian.MainActivity" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
And finally, my Activity_main's XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
androidaddingBottom="@dimen/activity_vertical_margin"
androidaddingLeft="@dimen/activity_horizontal_margin"
androidaddingRight="@dimen/activity_horizontal_margin"
androidaddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="32dp"
android:text="Web" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button1"
android:layout_alignParentRight="true"
android:layout_marginRight="46dp"
android:text="Social" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button1"
android:layout_below="@+id/button1"
android:layout_marginTop="41dp"
android:text="To Do" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button3"
android:layout_alignBottom="@+id/button3"
android:layout_alignRight="@+id/button2"
android:text="News" />
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/button3"
android:layout_below="@+id/button3"
android:layout_marginTop="48dp"
android:text="Weather" />
<Button
android:id="@+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button5"
android:layout_alignRight="@+id/button4"
android:text="Button" />
</RelativeLayout>
crazy4creationstudios said:
Im using API level 17 the Rev. is 2 im using the latest version for x86 systems (32-bit)
My strings file looks like this:
<resources>
<string name="title_activity_socialpage1">Socialpage1</string>
<string name="action_settings">Settings</string>
</resources>
And my Main xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="c4cs.try4.everydayagian"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="c4cs.try4.everydayagian.MainActivity"
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</activity>
<activity
android:name="c4cs.try4.everydayagian.Socialpage1"
android:label="@string/title_activity_socialpage1"
androidarentActivityName="c4cs.try4.everydayagian.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="c4cs.try4.everydayagian.MainActivity" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
And finally, my Activity_main's XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
androidaddingBottom="@dimen/activity_vertical_margin"
androidaddingLeft="@dimen/activity_horizontal_margin"
androidaddingRight="@dimen/activity_horizontal_margin"
androidaddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="32dp"
android:text="Web" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button1"
android:layout_alignParentRight="true"
android:layout_marginRight="46dp"
android:text="Social" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button1"
android:layout_below="@+id/button1"
android:layout_marginTop="41dp"
android:text="To Do" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button3"
android:layout_alignBottom="@+id/button3"
android:layout_alignRight="@+id/button2"
android:text="News" />
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/button3"
android:layout_below="@+id/button3"
android:layout_marginTop="48dp"
android:text="Weather" />
<Button
android:id="@+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button5"
android:layout_alignRight="@+id/button4"
android:text="Button" />
</RelativeLayout>
Click to expand...
Click to collapse
What is the exact name of your strings file and where is it located?
Where are the problems in the rest of the code?
try right clicking the button or textview from the graphical layout page of your xml. then go to edit text and click on project resources at the top. this should list all the strings that you have. you can choose a string that you have already made or you can click the new string button to create a new string directly from there.
In the "res" folder directory near "layout", where Eclipse puts it automatically.
The other errors were in the manifiest becuase I had ".r" in some wrong places (wich I dont get becuase I never did it in the first place
Sent from my HUAWEI-M835 using xda app-developers app
crazy4creationstudios said:
In the "res" folder directory near "layout", where Eclipse puts it automatically.
The other errors were in the manifiest becuase I had ".r" in some wrong places (wich I dont get becuase I never did it in the first place
Sent from my HUAWEI-M835 using xda app-developers app
Click to expand...
Click to collapse
What does "near layout" mean? Is it in the res/value folder? And is the file called "strings.xml"?
Yes, I just checked
Its in the res/values folder named strings.xml
Sent from my HUAWEI-M835 using xda app-developers app
nikwen said:
What is the exact name of your strings file and where is it located?
Where are the problems in the rest of the code?
Click to expand...
Click to collapse
Did you see that?
nikwen said:
Did you see that?
Click to expand...
Click to collapse
Yeah. The other problems I was having are:
My Manifiest has some incorrect snippets that I didnt add involving action settings(?) Check my strings it was one from it
Sent from my HUAWEI-M835 using xda app-developers app
crazy4creationstudios said:
Yeah. The other problems I was having are:
My Manifiest has some incorrect snippets that I didnt add involving action settings(?) Check my strings it was one from it
Sent from my HUAWEI-M835 using xda app-developers app
Click to expand...
Click to collapse
It was one from it? Which one? We cannot tell what is wrong with your app if we do not get enough information. You know where the error occurs. If you want help, provide us the information we need.
It has got nothing to do with that, but it is still something to correct: In the line
Code:
android:value="c4cs.try4.everydayagian.MainActivit y" />
there is a space between Activit and the y. Remove the space.
Ill find some more specific sections when I have the class tommorrow and PM it to you.
Sent from my HUAWEI-M835 using xda app-developers app
crazy4creationstudios said:
Ill find some more specific sections when I have the class tommorrow and PM it to you.
Sent from my HUAWEI-M835 using xda app-developers app
Click to expand...
Click to collapse
Great.
Set the android:targetSdkVersion to 17 in your manifest
Envoyé depuis mon CINK SLIM avec Tapatalk

[SHARE][TUTORIAL][HOWTO]disabling/Enabling option for system APP

hi,
in different customization of the same device for region or operator , we find some option in system configuration enabled in some and other no then we can do it by changing variable value in application files in system by decompiling and recompiling after modifying ( bools or arrays...etc ) it take a lot of time
so customization Sony has choose to make a little files for a region customization or enabling or disabling option in system app without modifying the original app file by using {real_application_name}-res.apk what will be adding in /system/vendor/overlay
in 4.0.4 and before sony ericsson used /system/etc/customization/ folder for enabling and parameterizing apps, so in JB 4.2 and 4.3or 4.4 these files are incompatible only 4.3 and 4.4 are compatible (attached files)
for JB 4.2
4.3 and 4.4
How to use ??
example :
for enabling data traffic notification and status icon in status bar we must change in or semcphone.apk phone.apk this line after decompiling Phone.apk or SemcPhone.apk in res/value/bools/xml we find a default value of application :
Code:
<bool name="data_connection_except_mms_can_clear_icon">true</bool>
<bool name="data_connection_except_mms_show_icon_when_disabled">true</bool>
<bool name="data_connection_except_mms_show_icon_when_enabled">false</bool>
Click to expand...
Click to collapse
they must be change to :
Code:
<bool name="data_connection_except_mms_can_clear_icon">false</bool> ----->[COLOR="red"] icon always visible can't be removed[/COLOR]
<bool name="data_connection_except_mms_show_icon_when_disabled">true</bool>
<bool name="data_connection_except_mms_show_icon_when_enabled">true</bool>
Click to expand...
Click to collapse
then it can be inserted in com.phone-res.apk and injected in system/vendor/overlay and rebooting after that the options are activated.
just know what value to want be activated in the main application apk
Another exemple :
in this post http://forum.xda-developers.com/showthread.php?t=2703113 to have mod for activating low cost in conversations.apk but with decompiling main apk conversations.apk but the simple one is using -res.apk
default value are :
Code:
<bool name="character_conversion">false</bool>
<bool name="character_conversion_visibility">false</bool>
Click to expand...
Click to collapse
and must be changed to
Code:
<bool name="character_conversion">true</bool>
<bool name="character_conversion_visibility">true</bool>
Click to expand...
Click to collapse
then modifing com.sonyericsson.conversations-res.apk
after decomiling
we have
Code:
[CODE]
[/CODE]
res
|-------> bools.xml -------------> to be modified
|-------> public.xml ---------------important contains all variable defined
bools.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="three_digit_number_linkify">true</bool>
<bool name="delivery_report">true</bool>
<bool name="mms_retrieval_during_roaming_visibility">true</bool>
[COLOR="Red"]<bool name="character_conversion">true</bool>
<bool name="character_conversion_visibility">true</bool>[/COLOR]
</resources>
public.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<public type="bool" name="three_digit_number_linkify" id="0x7f020000" />
<public type="bool" name="delivery_report" id="0x7f020001" />
<public type="bool" name="mms_retrieval_during_roaming_visibility" id="0x7f020002" />
[COLOR="red"]<public type="bool" name="character_conversion" id="0x7f020003" />
<public type="bool" name="character_conversion_visibility" id="0x7f020004" />[/COLOR]
<public type="bool" name="enable_send_empty_message" id="0x7f020005" />
<public type="integer" name="max_recipients" id="0x7f030000" />
<public type="integer" name="mms_max_size" id="0x7f030001" />
<public type="integer" name="sms_max_segments" id="0x7f030002" />
<public type="integer" name="mms_trigger_sms_segments" id="0x7f030003" />
</resources>
and recompile , push it in system/vendor/overlay and done.

[Q]Custom Settings and Viper

Hello,
I have a Pyrana settings that launches several utilitaires.Je would add Viper but I can not find the command to start? an idea?
Link to xml:
<PreferenceScreen android:icon="@drawable/ic_viper" android:title="Viper">
<intent android:targetPackage="com.vipercn.viper4android_v2" android:action="android.intent.action.MAIN" android:targetClass="???????????????????" />
</PreferenceScreen>
Thank you in advance

CarrierConfig VoLTE / VoWiFi

Hi all
I'm running a Nexus 6P on a carrier which does not support volte / vowifi officially. But I managed to get all the specific values for this carrier. But the big question is, how to implement those values into the phone?
I did some research and found out that some parameters are specified in the carrierconfig app. An example:
HTML:
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<carrier_config_list>
<carrier_config>
<int name="vvm_port_number_int" value="1808" />
<string name="vvm_destination_number_string">122</string>
<string name="carrier_vvm_package_name_string">com.tmobile.vvm.application</string>
<boolean name="carrier_volte_available_bool" value="true" />
<string name="vvm_type_string">vvm_type_cvvm</string>
<boolean name="carrier_volte_tty_supported_bool" value="false" />
<boolean name="carrier_wfc_ims_available_bool" value="true" />
<boolean name="carrier_ims_gba_required_bool" value="true" />
<int name="maxMessageSize" value="1048576" />
<int name="maxImageWidth" value="2592" />
<int name="maxImageHeight" value="1944" />
<int name="volte_replacement_rat_int" value="3" />
</carrier_config>
</carrier_config_list>
Search for platform/packages/apps/CarrierConfig to find it
So I tried to decompile the carrierconfig app and add my carrier aswell, but unfortunately I can not install the app again (parsing error, defect package). But where is the rest of the data stored (P-CSCF address, used algorithms, ePDG address and so on) ?? How was VoLTE / VoWiFi Calling brought to AOSP roms for EE and T-Mobile USA??
Thanks for your help!

Categories

Resources