yashsingh1/xdaforums huggingface dataset:
[Desire Android Development] FloHimself:
mhh not a sooo nice fix ;) so you want to extract only the needed changes for rotation from settings.smali from CM with the htc settings.smali? Is that right?
[Desire Android Development] liamstears:
Exactly!

But im not exactly good at this, still learning, i come from modding I8910 S60V5!! lol
[Desire Android Development] liamstears:
Can you help? Also I sent you a pm
[Desire Android Development] FloHimself:
Ok. It may be time consuming with porting low level smali parts from one to another dissably file (maybe with all htc modded stuff in it).

If I'm right the "WindowOrientationListener" just works? So you could just write your own simple application for these rotation settings...

Seen your PM. I'm not at my box right now. I'll add you to msn when I'm back! Maybe we'll find a solution.
[Desire Android Development] liamstears:
I dont think I quite have the knowlege to create my own app to do it but sounds like a solution maybe someone could come up with?

Would be nicer to have the settings in settings though :-P
[Desire Android Development] hshah:
It worked when I flashed the first file, but stopped working after I applied the fix. My phone is now back to how it was :(

/Edit: I lie! It works fine :)
[Desire Android Development] FloHimself:
@liamstears

could you please post your disassembled stuff as zip?
[Desire Android Development] liamstears:
Exactly what is it your after? everything would be extreme file size lol
[Desire Android Development] FloHimself:
Oh ok ;) will disassamble myself... thinking about the setting stuff...
[Desire Android Development] liamstears:
Oh ok yh please do have a look and see what you can find and please do post any/all findings on here and hopefully we can come up with a mod a bit more "final"

If you need anything please just ask

Cheers
[Desire Android Development] eightcore:
I can't notice anything that's different after flashing those files.

But maybe I don't understand what this mod shoud do at all!?

Can anybody help me?
[Desire Android Development] liamstears:
After flashing the first zip go into settings then sound and display and you will see instead of just turning rotation on and off you now have extra options to be able to rotate your phone right and completely upside down!

once chosen which one you want for good then flash settings fix zip :-D
[Desire Android Development] FloHimself:
Did you just include the Settings.apk from CM?

Can you build a MCR3.1 one with only:

Settings.apk/out/com/android/settings/R$array.smali

Settings.apk/out/com/android/settings/R$string.smali

Settings.apk/out/com/android/settings/SoundAndDisplaySettings.smali

replaced with CM ones?
[Desire Android Development] BlackLine7:
Just FYI:

You can easily rename the .apks to .zips and the extract or edit it in the zip :D

I'm editing the framework-res.zip for myself like that and no problems encountered yet :)
[Desire Android Development] liamstears:
Yes that's exactly what I did n I will try that first thing in the morning! Cheers
[Desire Android Development] liamstears:
Yes we are already doing this and then we are extracting the classes.dex from that and then decompile that to get to the java source :-D
[Desire Android Development] liamstears:
Doing this just causes a force close as soon as you click Sound & Display

I have attached the decompiled settings.apk from cm's rom for you to have a look at :-D
[Desire Android Development] liamstears:
Ok in the zip attached is a working R$array.smali and a working R$string.smali

All thats needed now is the rotation settings ported from cm's SoundAndDisplaySettings.smali to our SoundAndDisplaySettings.smali :-D
[Desire Android Development] FloHimself:
N1, one step forward! ;)

Are you using plain smali?

You may take a look at: http://code.google.com/p/android-apktool/

and: http://tiny.cc/t59lb on how to use it.

This tool gives us a more complete disassembly of the apk like smali + xml files.

ATM I'm investigating the language files and found the settings:

<string-array name="accelerometer_mode_entries">
<item>Off</item>
<item>Normal</item>
<item>270 degrees</item>
<item>360 degrees</item>
</string-array>
<string-array name="accelerometer_mode_summaries">
<item>No orientation switching when rotating phone</item>
<item>Normal (left only) orientation when rotating phone</item>
<item>270 degree (left + right) orientation when rotating phone</item>
<item>360 degree (including inversion) orientation when rotating phone</item>
</string-array>
[Desire Android Development] liamstears:
Nice, I will look at this now!
[Desire Android Development] FloHimself:
We should be able to reassemble the settings menu in Settings.apk first. If we can get the menu entry in original Settings.apk, we can take the next step and investigate the smali... still don't know if this will work at all... :cool:
[Desire Android Development] liamstears:
I cant even recompile :-(
[Desire Android Development] liamstears:
Have you had any luck? If I edit the xml and try to build I just get errors and it wont build the apk :(
[Desire Android Development] FloHimself:
Same here... :rolleyes:

Edit: resolved. can build an apk. check if the apktools are installed correctly (on windows to windows folder)
[Desire Android Development] liamstears:
I have resolved to, mine was conflicting type codes but properly changing hex values fixed this :-P
[Desire Android Development] eightcore:
Yes! It's working now!

Thanks for ur help.
[Desire Android Development] liamstears:
Progress report.

I have successfully changed all the xml and recompiled the apk and it works!/doesnt crash lol so all thats needed now is that smali and we should be good to go!!
[Desire Android Development] FloHimself:
Do you have the menu entry showing up already?
[Desire Android Development] liamstears:
No

You must have to change the smali to get it to show....
[Desire Android Development] liamstears:
Ok ive edited a couple lines in smali that should get it to show. Just testing. Can we talk on msn? would be a lot quicker and easier?

EDIT: Causes force close, damn!
[Desire Android Development] liamstears:
Im just about out of time for today so I thought I would share what I have so far.

As far as I know the 2 smali scripts and all xml's are as they should be with the correct changes for the rotation. Only thing left is the 3rd smali SoundAndDisplaySettings.smali

Build using apktool b -f settingsout

Builds fine just crashes as rotation settings are incomplete in the 3rd smali, ive only changed ".field private static final" and ".field private" in the 3rd smali, all the rest of the code still needs to be changed.

If anyones up for giving it a go then please do!

AccelerometerMode uses HtcListPreference not normal android ListPreference
[Desire Android Development] liamstears:
Found anything FloHimself?
[Desire Android Development] FloHimself:
Haven't had time to investigate any further. No new from here...

Is the settings application only crashing on "Display" settings?
[Desire Android Development] FloHimself:
Just leave it as ListPreference. I think HtcListPreference is just inherited from ListPreference and should work for a first try.

In SoundAndDisplaySettings.smali find the method:

.method protected onCreate(Landroid/os/Bundle;)V

It gets called when you open the dialog. We need to replace:

.line 315
const-string v23, "accelerometer"
move-object/from16 v0, p0
move-object/from16 v1, v23
invoke-virtual {v0, v1}, Lcom/android/settings/SoundAndDisplaySettings;->findPreference(Ljava/lang/CharSequence;)Lcom/htc/preference/HtcPreference;
move-result-object p1
check-cast p1, Lcom/htc/preference/HtcCheckBoxPreference;
move-object/from16 v0, p1
move-object/from16 v1, p0
iput-object v0, v1, Lcom/android/settings/SoundAndDisplaySettings;->mAccelerometer:Lcom/htc/preference/HtcCheckBoxPreference;
.line 316
move-object/from16 v0, p0
iget-object v0, v0, Lcom/android/settings/SoundAndDisplaySettings;->mAccelerometer:Lcom/htc/preference/HtcCheckBoxPreference;
move-object/from16 v23, v0
const/16 v24, 0x1
invoke-virtual/range {v23 .. v24}, Lcom/htc/preference/HtcCheckBoxPreference;->setPersistent(Z)V

With the part from CM settings.apk:

.line 153
const-string v5, "accelerometer_mode"
invoke-virtual {p0, v5}, Lcom/android/settings/SoundAndDisplaySettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v5
check-cast v5, Landroid/preference/ListPreference;
iput-object v5, p0, Lcom/android/settings/SoundAndDisplaySettings;->mAccelerometerMode:Landroid/preference/ListPreference;
.line 154
iget-object v5, p0, Lcom/android/settings/SoundAndDisplaySettings;->mAccelerometerMode:Landroid/preference/ListPreference;
invoke-virtual {v5, p0}, Landroid/preference/ListPreference;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V

So it should become:

.line 315
const-string v23, "accelerometer_mode"
invoke-virtual {p0, v23}, Lcom/android/settings/SoundAndDisplaySettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v23
check-cast v23, Landroid/preference/ListPreference;
iput-object v23, p0, Lcom/android/settings/SoundAndDisplaySettings;->mAccelerometerMode:Landroid/preference/ListPreference;
.line 316
iget-object v23, p0, Lcom/android/settings/SoundAndDisplaySettings;->mAccelerometerMode:Landroid/preference/ListPreference;
invoke-virtual {v23, p0}, Landroid/preference/ListPreference;->setOnPreferenceChangeListener(Landroid/preference/Preference$OnPreferenceChangeListener;)V

If this works, you should be able to see the option in settings dialog.

BUT: I can't test this atm, so I'm typing this blind... I don't know anything about smali format... maybe I'm totally wrong...
[Desire Android Development] liamstears:
I tried and this is what I got:
[Desire Android Development] FloHimself:
Please post your SoundAndDisplaySettings.smali...
[Desire Android Development] millen:
Guess this is a complete n00b question - but how do you install this? Copy the Zip to SD-card and flash it as a ROM?
[Desire Android Development] hshah:
Yep, it's as simple as that :)
[Desire Android Development] FloHimself:
Please choose HtcListPreference in instance fields instead of ListPreference and use the following snippet:

.line 315
const-string v23, "accelerometer_mode"

move-object/from16 v0, p0

move-object/from16 v1, v23

invoke-virtual {v0, v1}, Lcom/android/settings/SoundAndDisplaySettings;->findPreference(Ljava/lang/CharSequence;)Lcom/htc/preference/HtcPreference;

move-result-object p1

check-cast p1, Lcom/htc/preference/HtcListPreference;

move-object/from16 v0, p1

move-object/from16 v1, p0

iput-object v0, v1, Lcom/android/settings/SoundAndDisplaySettings;->mAnimations:Lcom/htc/preference/HtcListPreference;

.line 316
move-object/from16 v0, p0

iget-object v0, v0, Lcom/android/settings/SoundAndDisplaySettings;->mAnimations:Lcom/htc/preference/HtcListPreference;

move-object/from16 v23, v0

move-object/from16 v0, v23

move-object/from16 v1, p0

invoke-virtual {v0, v1}, Lcom/htc/preference/HtcListPreference;->setOnPreferenceChangeListener(Lcom/htc/preference/HtcPreference$OnPreferenceChangeListener;)V
[Desire Android Development] dread123:
my wifi was working without flashing the settings.zip? what was the reason for needing to flash that too??

cheers..mod works good..shame we cant use on the home screens?
[Desire Android Development] Thomashamka:
1.5 rom problem

PROBLEM with 1.5 rom, when chargin the red dot stays AND after that headphone jack doesnt react to anything, i have to restart the phone. THX for the rom though.
[Desire Android Development] liamstears:
Ok its built the apk without errors, thats a good start.

Just going to flash and test, will report back in 5!
[Desire Android Development] liamstears:
Doesnt work :-( still fc's when clickin sound and display :-(

Would SoundAndDisplaySettings$1.smali affect anything?

Also attached my SoundAndDisplaySettings.smali for you to look at :D
[Desire Android Development] liamstears:
Have you had a chance to look at my smali??

Thanks for all your help man!!
[Desire Android Development] cerede2000:
It's possible make a fix for 1.23 from? Thank!
[Desire Android Development] FloHimself:
Hey very busy atm, just took a look... I think your smali looks like mine... can you take a look at the log when opening Settings.apk? "adb logcat" should print something when it FCs...
[Desire Android Development] FloHimself:
My previous posted snippit is just wrong. "->mAnimations" should be "->mAccelerometerMode" ;)
[Desire Android Development] liamstears:
Trying that now :-D

Also ive never used adb, how does it work? lol
[Desire Android Development] FloHimself:
Can you post what files you have edited so far?

Are these all included?

values/arrays.xml
values/public.xml
values/strings.xml
xml/sound_and_display_settings.xml

You haven't used adb?? Oh come on, google it!! :P
[Desire Android Development] liamstears:
Yes ive edited all of those and heres the logcat:
[Desire Android Development] RicardoPT:
do you can post a video?
[Desire Android Development] liamstears:
Also ".line 567" and a couple lines below that and ".line 692" and below that:

iget-object v8, p0, Lcom/android/settings/SoundAndDisplaySettings;->mAccelerometer:Lcom/htc/preference/HtcCheckBoxPreference;

etc etc

Should we delete all that?
[Desire Android Development] FloHimself:
I think yes, you should remove any reference to "mAccelerometer". Thats why it crashes. "could find field ... mAccelerometer"
[Desire Android Development] FloHimself:
Sorry, I can't. Why a video? it just rotates in all directions...

Please remove this huge image from your signature!? It's really annoying while reading through forum threads...
[Desire Android Development] liamstears:
Im not sure what to remove though, from line 567 would you delete say line 571?

Please have a look through this and delete what you think should be deleted...
[Desire Android Development] FloHimself:
Please post your smali so we have one base...
[Desire Android Development] liamstears:
Attached :-D
[Desire Android Development] FloHimself:
Commented out some code... really don't know if this would work... :confused:
[Desire Android Development] liamstears:
Force close :-(

See attached pic
[Desire Android Development] FloHimself:
There should be commented out even more (or less?)...

Requested help...
[Desire Android Development] mikkle:
Having a look.

This should be doable :)

With a bit of luck, I'll be able to test a bit tonight.

Merging smali is so much fun! ;-D
[Desire Android Development] FloHimself:
That would be great! :D

It is not! :p
[Desire Android Development] liamstears:
I hope you can come up with something because its not been fun for me n flo :-(
[Desire Android Development] mikkle:
Right.

Had a hell of a time with all the conditionals and gotos :(

Will try a new approach tonight:

Change the definitions (mAccelerometer -> mAccelerometerMode) and checkboxpref -> listpref.

After that, I'll basically forget about merging in the various update* methods. In stead, I'll compile my own in a static helper class based on the sources from Cyanogen's github and just change the SoundAndDisplaysettings to call out to this utility stuff. Much simpler.

Will report progress later.

:-D Mikkle
[Desire Android Development] liamstears:
Sounds good! I look forward to your progress :-D

Good Luck!
[Desire Android Development] liamstears:
Any news for us?
[Desire Android Development] mikkle:
Oh yes!

Attached version works for me! :-D

zip contains the files I changed from the original, and a pre-build apk.

I've NOT wrapped it in an update zip

I installed your patched framework.jar and SettingsProvider.apk along with Settings_hack.apk from attached zip-file. works like a charm! :)

(i renamed Settings_hack.apk to Settings.apk before pushing it to /system/app - just to make sure.)

Have a look at my changes, see if they make sense!

Edit: Some other settings stuff seems to be broken. "Manage applications" FCs on clicking an app, and Brightness also FCs. Haven't looked properly into why, so I don't know if it's my patches or yours. "Manage apps" FC seems to be a2sd related - you guys have a2sd on oyur devices? - I haven't, and that might be th reason for this. More testing later. :]
[Desire Android Development] liamstears:
I think maybe you deleted something you shouldnt of?

I will check logs and see whats going on and hopefully we can fix it all!! :-D

EDIT: All is not as it seems :-(

My settings instantly fc's when clicking sound and display

Heres the logcat:

http://img16.imageshack.us/img16/5706/logcat.png

Also I dont have the fc's you mention...
[Desire Android Development] oursoul:
This is amazing! So responsive.

Thank you :) x
[Desire Android Development] mikkle:
Seriously strange!

SoundAndDisplaySettings works perfectly on my device (apart from the brightness-thing, obviously).

I wonder if we are on different sw versions somehow?

Edit: Could you try wiping cache - maybe when in recovery: adb shell rm /data/dalvik-cache/*
[Desire Android Development] oursoul:
I dont have any issues with brightness (in settings or with the extended control widget I use on my homescreen) nor any issues with manage applications.

In fact I've had no FC's at all. I'm not running A2SD atm.

As far as I can tell so far this is flawless.
[Desire Android Development] mikkle:
@oursoul just to keep the troublehooting sane: are you using the modded Settings.apk, I posted, or just the original mod fra @liamstears?
[Desire Android Development] oursoul:
the original afaik.. anything you want me to try?
[Desire Android Development] liamstears:
Does wireless sesttings work for you?

Have you flashed settings fix?
[Desire Android Development] liamstears:
What firmware and kernel are you using? What radio are you on?
[Desire Android Development] oursoul:
Yep wireless works fine & yes I flashed the settings fix from the OP.

I have 360 degree with no FC's just like I always imagined I would :D
[Desire Android Development] mikkle:
Firmware version: 2.1-update-1
Baseband version: 32.36.00.28U_4.06.00.02_2
Kernel version: 2.6.29-braco-mck-r1 paul(a)Paul-OBriens-iMac #2
Build number: 1.21.MCR.2 CLxxxxxx release-keys
Software number: MoDaCo Custom ROM r3.1 for the HTC Desire

I must say that I haven't looked at your framework/settingsprovider mods at all. Maybe they're not applicable for whatever I'm running on?

Note, I'm not running a pre-bake - I cooked my own in the online kitchen. Most interesting thing is A2SD was NOT chomped in.

A couple of customs were added - a hack I did myself to load ipv6.ko at boot, and my own modded Mms.apk. None of these should make any difference here...
[Desire Android Development] mikkle:
Woops:

SoundAndDisplaySettings.smali:415:

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

should be change to:

invoke-virtual {v0, v1}, Lcom/htc/preference/HtcListPreference;->setSummary(Ljava/lang/CharSequence;)V

Edit: Which, by the way, makes me wonder why anything worked for me at all... :-?

I don't have the time for building/testing right now - maybe tonight.

Could you try changing the above in the stuff I posted, rebuild, test, etc?
[Desire Android Development] mikkle:
Ok,

Some stuff is missing in my Settings.apk: BrighnessPreference.smali is gone, for some reason - I suspect other stuff as well. That explains my FC/NPE when entering Brightness settings.

I strongly suspect other stuff missing as well. I'll try doing a new merge with my changed (and amended) code and a fresh version of Settings.apk pulled from the belly of my working device.

Updates to follow.

Edit: One copy/paste troll found. some code ended up in the wrong method...
[Desire Android Development] liamstears:
I cant wait to hear from you and I really really do hope you can get this working for us!! :-D
[Desire Android Development] mikkle:
Some sort of progress:

I'm now down to Brightness Settings FC'ing with an NPE.

Trying to figure out where that gets whacked...
[Desire Android Development] mikkle:
Think I nailed it!

The Brightness FCs were caused by my text editor insisting on appending a crlf to the resource xmls.

Whaddayaknow. This evidently bungles up some resources - at least when using apktool...

Anyways. It works perfectly for me now.

Attached update-zip containing the modded framework/settingsprovider and my newly fixed (I believe) settings.apk.

Test (and hopefully, enjoy)!
[Desire Android Development] liamstears:
WOW!! Its now 100% working!!! Thanks Man!!!
[Desire Android Development] mikkle:
Np!

On the whole, I enjoyed the challenge.

A couple of half-days were spent being frustrated and annoyed, though. :-)

Next up: merge the homescreen-rotation mod into mcr as well?
[Desire Android Development] FloHimself:
Very nice work Mikkle!! Thank you! :D

Next step should be to include all languages from CM into this mod...
[Desire Android Development] mikkle:
Should be a matter of merging arrays.xml for the various locales.

Remember to strip trailing whitespace, though! :-)
[Desire Android Development] liamstears:
I will give it a try, it shouldnt be too hard.

Quick question though mickle, how did you get your settings.apk size so small?

If i recompile with apktool I get over 4mb! :-O

EDIT: change of plan, this wouldn't be a very easy task as our settings.apk only has one language - english. If our settings.apk had multi-lingual files it would be easier so im not going to worry about it as I only need english ;-)

As for homescreen rotation, mine already rotates as I use launcherpro :-D

Can the sense homescreen even be rotated?
[Desire Android Development] blackfox888:
hi, do i dl the file from page 95 or from the 1st page??

cheers great work!

btw will this auto rotate the screen, once I flash the zip? or will I be able to turn on/off rotation from setting?
[Desire Android Development] liamstears:
Flash the one in first post and it will give you the option in settings to change rotation to how you want it to rotate :-D
[Desire Android Development] JohnQ:
does it work on other ROMs? like pays??

btw,there are two folders in it and two apk in one folder..how to install actually? i previously read your post but failed to know how to install...please give some instructions..thank you.
[Desire Android Development] MastaPole:
Good News

It works on Pay´s ROM.

MFG

MastaPole
[Desire Android Development] Rudolfje:
Also works on modified Pays Rom v2.0 BraveSoul (with RTv14 kernel)

Thanks for this. :D

First boot took a while.
[Desire Android Development] liamstears:
Flash zip from sd in recovery mode :-P

Glad its working in pays for you guys!! :-D
[Desire Android Development] mikkle:
No VooDoo. What I did (in summary):

adb pull /system/framework/com.htc.resources.apk
apktool if com.htc.resources.apk htc
adb pull /system/app/Settings.apk
apktool d -t htc Settings.apk workdir
<hack><hack><hack>
apktool b -f workdir Settings_mod.apk
[Desire Android Development] blackfox888:
thanks. flash the zip and 360 rotation work perfectly, but I haven't issue with how long I have to wait before my phone boot back on.

I know first time when you reboot phone back on after flashing the zip it will take longer than usual to boot up, but the second time I rebooted the phone it took the same amount of time to turn it back on, this is almost 4 minutes rather the usual less than a minute!! I rebooted a few more times and the time for it to turn back on are the same:( is anyone having the same issue?
[Desire Android Development] JohnQ:
got it , thank you!
[Desire Android Development] hshah:
Yes, I am having the same issue :(
[Desire Android Development] yosidia:
What about the basic 1.21 rom ? can you do it too ?
[Desire Android Development] liamstears:
Try it n let us know :-D

Just make sure you do a nandroid backup first :-P
[Desire Android Development] Alkymia:
is there any possiblity bout porting it to 2.2? with sense roms u can't rotate and could be nice be able to :)
[Desire Android Development] liamstears:
Sense 2.2 (dj Droid) allows 270 rotation but I'm thinking bout porting the full 360 over :-P
[Desire Android Development] Alkymia:
im on latest modaco 2.2 with sense build and u can't so if u could bring it i would love u forever :P
[Desire Android Development] Alkymia:
still nothin ? :(