DroidSans Tweak Tools Released : Enable Auto Rotate for your G1

Search This thread

Koush

Retired Recognized Developer
Sep 21, 2007
917
872
=O

Now i'd definitely like to see the source ^^. Well source or not I eagerly await your next offering.

There are several ways to do this (I dug through this code for several hours), and I'm reciting this off the top of my head, so forgive me if I misspeak:

Method 1 (easy but hackish):
Call Surface.setRotation(...)
That lets you rotate the screen (you to run this from a console Java app with root).
However, that doesn't rotate the touch screen input. The only way to do that is to fake out the keyboard "lid" state being open here:
\mydroid\frameworks\base\core\jni\server\com_android_server_KeyInputQueue.cpp

Method 2 (less hackish):
Alternatively, you can probably further modify the aforementioned file to fake out lid state change events to do rotations.

Method 3 (least hackish):
Change the default requested orientation to ORIENTATION_SENSOR. This should work in theory, but it was causing my emulator to crash like crazy due to some dex file and OpenGL issue. Not sure why. It would probably work just fine on the phone, but I didn't want to mess with it.

Method 4 (not a hack at all, but doesn't work automatically with future apps and it is tedious):
Modify the Activity classes for all the apps and set their Orientation to ORIENTATION_SENSOR.
 

nuuneoi

Member
Jul 9, 2007
19
1
Question, will enabling auto rotate cause any performance or battery issues with the g1?

Are you polling the accelerometer every couple of secs or are you using a different method?

Not polling method I'm using since polling method consume battery quite much. The way I use is to change parameter in firmware binary, so all application will have ability to rotate screen by sensor.
 

nuuneoi

Member
Jul 9, 2007
19
1
Um..... So you are saying everyone can trust you with their (expensive) device, but you cant trust them with the source.... I think you should reword that a little. I was hoping you were thinking against releasing the source for monetary reasons (which is your choice) but this reason is rediculous. Anyone here who knows how to make your code into a "virus" (erm, linux and virus do not mix very well) would know how to do it without your code.

That's fine. The method is here.

1. Open the /system/framework/framework.odex with hex editor.
2. Go to offset: 1104724
3. Change 0x0F0012F6 to 0x0F001246

(0xF6 means default orientation = unspecified, 0x46 mean default orientation = by sensor)

However, you can't replace it back with your modified version because the yaffs2 issue.
 

Koush

Retired Recognized Developer
Sep 21, 2007
917
872
That's fine. The method is here.

1. Open the /system/framework/framework.odex with hex editor.
2. Go to offset: 1104724
3. Change 0x0F0012F6 to 0x0F001246

(0xF6 means default orientation = unspecified, 0x46 mean default orientation = by sensor)

However, you can't replace it back with your modified version because the yaffs2 issue.

Koush said:
Method 3 (least hackish):
Change the default requested orientation to ORIENTATION_SENSOR. This should work in theory, but it was causing my emulator to crash like crazy due to some dex file and OpenGL issue. Not sure why. It would probably work just fine on the phone, but I didn't want to mess with it.

Method #3 on my list :)
But yeah, doing a hex edit rather than a recompile, is a very very scary change.
You should do a hash comparison of the file first, if you aren't already.
 

dwang

Senior Member
Nov 23, 2008
2,453
318
That's fine. The method is here.

1. Open the /system/framework/framework.odex with hex editor.
2. Go to offset: 1104724
3. Change 0x0F0012F6 to 0x0F001246

(0xF6 means default orientation = unspecified, 0x46 mean default orientation = by sensor)

However, you can't replace it back with your modified version because the yaffs2 issue.

So does that mean when you set the auto-rotate option in your application, your code goes through all the apps installed on the g1 and modifies the offset? Is the offset the same for all applications?

Why doesn't that offset work for the browser?
 

swarttsc

Member
Apr 14, 2006
21
0
37
Marysville
thank you very much for this app! i've been waiting awhile for this, a suggestion, unless i am crazy it does not auto rotate when your viewing pictures, my apologies if thats already been posted but thats my suggestion, be able to rotate so you can view the landscape pictures without opening the keyboard, but still awesome app and I look foward to more of your releases!
 

Koush

Retired Recognized Developer
Sep 21, 2007
917
872
So does that mean when you set the auto-rotate option in your application, your code goes through all the apps installed on the g1 and modifies the offset? Is the offset the same for all applications?

Why doesn't that offset work for the browser?

It modifies the offset for a single base class.

The Browser explicitly set's it orientation:
BrowserActivity.java
setRequestedOrientation(mSettings.getOrientation());

Changing the default to OREINTATION_SENSOR will only be used if it has not been explicitly set (which is not the case in the browser).
 
Last edited:

dwang

Senior Member
Nov 23, 2008
2,453
318
It modifies the offset for a single base class.

The Browser explicitly set's it orientation:
BrowserActivity.java
setRequestedOrientation(mSettings.getOrientation());

Changing the default to OREINTATION_SENSOR will only be used if it has not been explicitly set (which is not the case in the browser).

Ok thanks.. so probably the easiest way to add auto-rotate to the browser is to modify the source, recompile it, and replace the default browser app.

Is that even possible?
 

Darkrift

Senior Member
Oct 5, 2006
535
22
San Tan Valley, Arizona
Can the recompiled browser just be replaced on the device or does it require the system image to be replaced? If the former is true, and you wouldnt mind, would you be able to upload the file and give path info?
 

dwang

Senior Member
Nov 23, 2008
2,453
318
Can the recompiled browser just be replaced on the device or does it require the system image to be replaced? If the former is true, and you wouldnt mind, would you be able to upload the file and give path info?

My guess is you probably have to replace the system image.
 
K

korndub

Guest
root password

will you be implementing a way to use our root passwords with this app? maybe a menu item that specifies the password we set?
 

Zappza

Senior Member
Nov 16, 2008
237
21
I am having some problems with getting the orientation mode to change to landscape when I pull out the keyboard. Some times it will change the orientation mode from landscape to portrain when I pull out the keyboard, and sometimes it won't react at all.

This could very well be caused by a conflict between the mod and Androids default settings.

If this is a fact, it would be a very good thing if the mod got overrided when the keyboard gets pulled out.

In theory this shouldn't be a problem, since we always type on the keyboard while holding the phone in landscape mode, but I don't know why it won't work for me in practice.

Otherwise, good app :)
 

ultimind

Senior Member
Aug 12, 2007
70
1
I'm having the same issue of the screen not rotating when pulling the keyboard out. You have to close it, turn the phone in landscape, then re open the keyboard.
 

parrothd

Senior Member
Nov 10, 2008
189
3
Opening the keyboard no longer flips the orientation, you need to turn the phone to flip the orientation...
 

Gary13579

Retired Moderator
Nov 14, 2008
524
69
Imagine this convo between someone who buys an anti virus software and the company that produces it.

Person: "Oh hey, I bought your product but it won't install. wtf?"
Company: "Are you sure that you're running it as an admin?"
Person: "WHAT THE **** YOU ****ING EXPECT ME TO RUN THAT AS AN ADMIN ARE YOU ****ING CRAZY. I DEMAND YOU GIVE ME THE SOURCE CODE TO YOUR PROGRAM OR I WANT A FULL REFUND".

Yeah, you guys are sounding that stupid right now. This program REQUIRES ROOT ACCESS. IT WILL NOT WORK WITHOUT IT.
 

Darkrift

Senior Member
Oct 5, 2006
535
22
San Tan Valley, Arizona
Yes but most linux program do not require root to run. This is why linux is more secure and windows is not. Breaking that security is not a good idea. When programs require root access to function you are giving a lot of blind trust in the author. Your example using windows is not a good comparison because everything uses "admin" which is why there is a need for antivirus in the first place.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    Hi,

    I just finished beta version of tweak tools name DroidSans Tweak Tools. It provides some cool abilities, for example, Auto Rotate Screen, Reboot your Phone and etc.

    droidsanstweaktools02.png


    Please check this page for instructions and more information http://www.droidsans.com/droidsans-tweak-tools.

    Please note that it works only on modified firmware G1.

    Enjoy!

    Sittiphol Phanvilai
    DroidSans.com