[MOD][SOURCE][AOSP][4.1.1] How to enable Rotation Lock on the Galaxy Nexus

Search This thread

djp952

Senior Member
Jan 12, 2010
801
987
Baltimore
Apologies if this has been posted before, but I've found a very simple way to enable to AOSP Rotation Lock control for the Galaxy Nexus on Jelly Bean 4.1.1. By default, that highly useful control is only enabled if the device has a minimum width (or length) of 3.75" (DP >= 600), but in reality it fits just fine on much smaller devices like ours.

All you have to do is edit the isRotationLockToggleSupported() function in frameworks/base/core/java/com/android/internal/view/RotationPolicy.java to allow this control to display on smaller devices. I suggest a DP >= 360, which not surprisingly happens to match the GNex.

You can view my edit here: https://github.com/djp952/sch-i515-...mmit/dc8598f75f84c57c92b8a8920606ffb695ef10cb

Or ... you can just open that file and edit line 49 to read ">=" 360 instead of ">= 600" and rebuild. I can't find any reason that the control should not be included on any phone device with a screen > 2.25" wide as it's very useful and will not get in the way of anything else.
 
Last edited:

minooch

Senior Member
Oct 16, 2008
660
1,417
Apologies if this has been posted before, but I've found a very simple way to enable to AOSP Rotation Lock control for the Galaxy Nexus on Jelly Bean 4.1.1. By default, that highly useful control is only enabled if the device has a minimum width (or length) of 3.75" (DP >= 600), but in reality it fits just fine on much smaller devices like ours.

All you have to do is edit the isRotationLockToggleSupported() function in frameworks/base/core/java/com/android/internal/view/RotationPolicy.java to allow this control to display on smaller devices. I suggest a DP >= 360, which not surprisingly happens to match the GNex.

You can view my edit here: https://github.com/djp952/sch-i515-...mmit/dc8598f75f84c57c92b8a8920606ffb695ef10cb

Or ... you can just open that file and edit line 49 to read ">=" 360 instead of ">= 600" and rebuild. I can't find any reason that the control should not be included on any phone device with a screen > 2.25" wide as it's very useful and will not get in the way of anything else.


Many thanks - I was going to upload my ROM today & was just about to look for this - I will enable this in the next version

Cheers,

Minooch


EDIT: It will be in version 1 after all :D
 
Last edited:
  • Like
Reactions: marhensa

arifqur

Senior Member
Nov 12, 2005
3,700
1,118
Thanks brother for this development but can you explain in simpler terms what this does?
Sorry to bother you.
Thanks again
 

McDV

Senior Member
May 26, 2008
326
112
Is it only possible to compile it from source? Or can I use apktool to decompile and modify framework-res.apk for this?

The point is that I'm running stock ROM but would really like this rotation-lock-toggle as a MOD. ;)
 

djp952

Senior Member
Jan 12, 2010
801
987
Baltimore
Thanks brother for this development but can you explain in simpler terms what this does?
Sorry to bother you.
Thanks again

It enables a feature in JB that tablets use called the Rotation Lock. It sits up in the main drop-down between the date and the settings button. Instead of having to turn on and off rotation to keep the device orientation in place, you can just lock it with this control. It also removes the option from display settings (but not accessibility). I think it's extremely useful and don't know why it's not enabled by default for any device that has enough real estate to show it.

Screen shot attached. This is my phone and it's currently locked in portrait mode. If you press it, the lock changes to a little phone and normal rotation rules apply
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    22.7 KB · Views: 2,616
  • Like
Reactions: marhensa

djp952

Senior Member
Jan 12, 2010
801
987
Baltimore
Is it only possible to compile it from source? Or can I use apktool to decompile and modify framework-res.apk for this?

The point is that I'm running stock ROM but would really like this rotation-lock-toggle as a MOD. ;)

You could use apktool, but you'd have to edit the RotationPolicy.smali file in SystemUI.apk. The 600 was a constant, it's likely going to stick out and be easy to find in the .smali.

I think mods to SystemUI are going to be commonplace now, the battery icons and xml descriptors are in that APK as well. Not sure if that's new for JB or if ICS also did it that way, I haven't modded anything since GB.
 

FaithCry

Senior Member
Aug 26, 2010
1,869
1,861
You could use apktool, but you'd have to edit the RotationPolicy.smali file in SystemUI.apk. The 600 was a constant, it's likely going to stick out and be easy to find in the .smali.

I think mods to SystemUI are going to be commonplace now, the battery icons and xml descriptors are in that APK as well. Not sure if that's new for JB or if ICS also did it that way, I haven't modded anything since GB.

just checked systemUI smali, theres isn't a file called RotationPolicy, closest thing is RotationToggle.smali and there is no 600 constant :(

i'm on GSM Bigxies build, just a side note.
 

djp952

Senior Member
Jan 12, 2010
801
987
Baltimore
just checked systemUI smali, theres isn't a file called RotationPolicy, closest thing is RotationToggle.smali and there is no 600 constant :(

i'm on GSM Bigxies build, just a side note.

Oh yeah, duh, it's not in SystemUI. Hadn't had my coffee yet. Check android.policy.jar, otherwise I can look to find out where that class goes. Sorry!!!
 

FaithCry

Senior Member
Aug 26, 2010
1,869
1,861
Oh yeah, duh, it's not in SystemUI. Hadn't had my coffee yet. Check android.policy.jar, otherwise I can look to find out where that class goes. Sorry!!!

no worries! i'll probably look into source later, i think everyone should learn how to at least compile from source, its a very useful tool! :)
 

FaithCry

Senior Member
Aug 26, 2010
1,869
1,861
found the smali, can't interpret it like waht you're saying. maybe you'll know which line to edit? :D

found in framework.jar/smali/com/android/internal/view/RotationPolicy.smali
 

Attachments

  • RotationPolicy.zip
    1.2 KB · Views: 139
Last edited:
  • Like
Reactions: phone_user

phone_user

Senior Member
Nov 13, 2011
791
644
found the smali, can't interpret it like waht you're saying. maybe you'll know which line to edit? :D

found in framework.jar/smali/com/android/internal/view/RotationPolicy.smali

Code:
...


.method public static isRotationLockToggleVisible(Landroid/content/Context;)Z
    .locals 3
    .parameter "context"

    .prologue
    const/4 v0, [COLOR="Red"]0x0[/COLOR]

...

0x1
 

Bavilo

Senior Member
Apr 20, 2009
682
28
Marburg
found the smali, can't interpret it like waht you're saying. maybe you'll know which line to edit? :D

found in framework.jar/smali/com/android/internal/view/RotationPolicy.smali


The constant is right there...

600 is displayed in hex. Thus you will need to edit this line...

Code:
const/16 v1, 0x258

and change it to

Code:
const/16 v1, 0x168
if you want the DPI to be set at 360...


There you go.

---------- Post added at 08:33 PM ---------- Previous post was at 08:19 PM ----------

Code:
...


.method public static isRotationLockToggleVisible(Landroid/content/Context;)Z
    .locals 3
    .parameter "context"

    .prologue
    const/4 v0, [COLOR="Red"]0x0[/COLOR]

...

0x1



That alone probably won't work as the method
Code:
isRotationLockToggleVisible

is invoking the method
Code:
isRotationLockToggleSupported

and in there it is still only going to activate at DPI 600.
 
  • Like
Reactions: phone_user

fdfdrere

Member
Feb 8, 2010
48
16
Could you please make a flashable zip for the stock rom (deodexed JRO03)? All the compiling thing looks too much for me. Thank you a lot!
 
Last edited:

pwc realtor

Senior Member
Jun 14, 2007
490
64
I'm trying to put this mod into XenonHD but running into a wall. The github link is down and I tried flashing both zips in this thread one wouldn't flash through clockworkMod and the other caused the phone to hang at the boot animation.

I did try to decompile the franework-res.apk file and although I'm fairly tech savvy I think I hit my limit. Any ideas?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 10
    Apologies if this has been posted before, but I've found a very simple way to enable to AOSP Rotation Lock control for the Galaxy Nexus on Jelly Bean 4.1.1. By default, that highly useful control is only enabled if the device has a minimum width (or length) of 3.75" (DP >= 600), but in reality it fits just fine on much smaller devices like ours.

    All you have to do is edit the isRotationLockToggleSupported() function in frameworks/base/core/java/com/android/internal/view/RotationPolicy.java to allow this control to display on smaller devices. I suggest a DP >= 360, which not surprisingly happens to match the GNex.

    You can view my edit here: https://github.com/djp952/sch-i515-...mmit/dc8598f75f84c57c92b8a8920606ffb695ef10cb

    Or ... you can just open that file and edit line 49 to read ">=" 360 instead of ">= 600" and rebuild. I can't find any reason that the control should not be included on any phone device with a screen > 2.25" wide as it's very useful and will not get in the way of anything else.
    1
    Apologies if this has been posted before, but I've found a very simple way to enable to AOSP Rotation Lock control for the Galaxy Nexus on Jelly Bean 4.1.1. By default, that highly useful control is only enabled if the device has a minimum width (or length) of 3.75" (DP >= 600), but in reality it fits just fine on much smaller devices like ours.

    All you have to do is edit the isRotationLockToggleSupported() function in frameworks/base/core/java/com/android/internal/view/RotationPolicy.java to allow this control to display on smaller devices. I suggest a DP >= 360, which not surprisingly happens to match the GNex.

    You can view my edit here: https://github.com/djp952/sch-i515-...mmit/dc8598f75f84c57c92b8a8920606ffb695ef10cb

    Or ... you can just open that file and edit line 49 to read ">=" 360 instead of ">= 600" and rebuild. I can't find any reason that the control should not be included on any phone device with a screen > 2.25" wide as it's very useful and will not get in the way of anything else.


    Many thanks - I was going to upload my ROM today & was just about to look for this - I will enable this in the next version

    Cheers,

    Minooch


    EDIT: It will be in version 1 after all :D
    1
    Thanks brother for this development but can you explain in simpler terms what this does?
    Sorry to bother you.
    Thanks again

    It enables a feature in JB that tablets use called the Rotation Lock. It sits up in the main drop-down between the date and the settings button. Instead of having to turn on and off rotation to keep the device orientation in place, you can just lock it with this control. It also removes the option from display settings (but not accessibility). I think it's extremely useful and don't know why it's not enabled by default for any device that has enough real estate to show it.

    Screen shot attached. This is my phone and it's currently locked in portrait mode. If you press it, the lock changes to a little phone and normal rotation rules apply
    1
    found the smali, can't interpret it like waht you're saying. maybe you'll know which line to edit? :D

    found in framework.jar/smali/com/android/internal/view/RotationPolicy.smali