Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,728,048 Members 45,916 Now Online
XDA Developers Android and Mobile Development Forum

"n" button hacking

Tip us?
 
Renate NST
Old
#1  
Renate NST's Avatar
Recognized Contributor / Recognized Developer - OP
Thanks Meter 773
Posts: 1,942
Join Date: Feb 2012
Location: Boston
Smile "n" button hacking

I've seen miscellaneous info around on the common task of repurposing the "n" button. I'd like to see a concise rundown of ways to hack it.

The "n" button is a scancode 102 that normally gets mapped to keycode 3 with /system/usr/keylayout/gpio-keys.kl

Keycode 3 in intercepted by the interceptKeyTi method of PhoneWindowManager in /system/framework/android.policy.jar

Keycode 3 is handled directly without using any intents.

It's not easy to hack a key to give an intent. You have CALL_BUTTTON, CAMERA_BUTTON & MEDIA_BUTTON. I haven't managed to catch them. The easy one to hack is SEARCH_LONG_PRESS.

You can easily change gpio-keys.kl to key 102 SEARCH
A normal press will bring up the default Nook search. A long press will generate an intent. All you have to do is insert another intent filter in your favorite app.

Code:
<intent-filter>
    <action android:name="android.intent.action.SEARCH_LONG_PRESS" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
I have this running on my ADW Launcher and I uninstalled Button Savior.

Personally, I prefer hacking to installing yet another app just to do one thing. I would like to come up with a solution for a dedicated action for the "n" key.

Any thoughts?
 
GabrialDestruir
Old
#2  
Senior Member
Thanks Meter 504
Posts: 632
Join Date: Nov 2009
Location: California
If you use NookTouchTools this allows you to remap the buttons/quicknav etc without all the hassle.
Nexus 4 - Paranoid Android
Nexus 7 - Stock Rooted
Nook Glow - Stock
__________________
TV Shows anywhere with HuluPlus - HuluPlus Referral
File storage anywhere with Dropbox - Dropbox Referral
 
Renate NST
Old
#3  
Renate NST's Avatar
Recognized Contributor / Recognized Developer - OP
Thanks Meter 773
Posts: 1,942
Join Date: Feb 2012
Location: Boston
Quote:
Originally Posted by GabrialDestruir View Post
... without all the hassle.
Well, I'd really like to learn things, not just load another app.

So how exactly do the Tools work? Do they need to have another process just to listen for a keycode and translate it to an intent?
 
GabrialDestruir
Old
#4  
Senior Member
Thanks Meter 504
Posts: 632
Join Date: Nov 2009
Location: California
Quote:
Originally Posted by Renate NST View Post
Well, I'd really like to learn things, not just load another app.

So how exactly do the Tools work? Do they need to have another process just to listen for a keycode and translate it to an intent?
It uses modification of various .jar files

Quote:
Originally Posted by XorZone View Post
* Patched android.policy.jar:
*** Injected home button code from AOSP, with configuration check between goto home and b&n quicknav toggle
*** Fixed recent apps dialog with configuration check to launch recent apps dialog or configured app launch
* Patched services.jar
*** "Reading now" button check for configured launch value (possible values: Home, Back, Menu, Search, Long Search, Custom App, B&N default)
*** All quicknav buttons configurable and will load icons (once, onCreate) possible values same as above.
* ActivityPicker - B&N removed default activity (usually in Settings.apk) to serve ACTION_PICK_ACTIVITY requests, so I added it back to the app and now able to add shortcuts/edit doc shortcuts in Launcher Pro...
* Configuration - All above configurable values stored in Settings.System so both system jars and Conf app can access it.
* Clear dalvik-cache button
Nexus 4 - Paranoid Android
Nexus 7 - Stock Rooted
Nook Glow - Stock
__________________
TV Shows anywhere with HuluPlus - HuluPlus Referral
File storage anywhere with Dropbox - Dropbox Referral
The Following User Says Thank You to GabrialDestruir For This Useful Post: [ Click to Expand ]
 
Renate NST
Old
#5  
Renate NST's Avatar
Recognized Contributor / Recognized Developer - OP
Thanks Meter 773
Posts: 1,942
Join Date: Feb 2012
Location: Boston
Thanks, Gabrial. I had read through this entire thread before and it had left me confused. 10 pages of talking about changing the UI and not a single screenshot? I'm still not sure how an activity picker or a recent apps dialog looks like. Heck, I'm not even sure what additional things you get in Settings. Is there even a tree list of what people should have?

Yes, I do have a penchant for doing things the hard way. I like things lean and mean. If I knew how to inject code into jars I would just have fixed android.policy.jar and left it at that. My main need was a way to globally get back to my launcher desktop without onscreen controls (like Button Savior).
 
ApokrifX
Old
#6  
Senior Member
Thanks Meter 46
Posts: 410
Join Date: May 2011
Quote:
Originally Posted by Renate NST View Post
Thanks, Gabrial. I had read through this entire thread before and it had left me confused. 10 pages of talking about changing the UI and not a single screenshot? I'm still not sure how an activity picker or a recent apps dialog looks like. Heck, I'm not even sure what additional things you get in Settings. Is there even a tree list of what people should have?

Yes, I do have a penchant for doing things the hard way. I like things lean and mean. If I knew how to inject code into jars I would just have fixed android.policy.jar and left it at that. My main need was a way to globally get back to my launcher desktop without onscreen controls (like Button Savior).
Well said
I'd try to ask Nook Color forums too...
 
Renate NST
Old
#7  
Renate NST's Avatar
Recognized Contributor / Recognized Developer - OP
Thanks Meter 773
Posts: 1,942
Join Date: Feb 2012
Location: Boston
Well, I finally learned how to hack compiled Java code.
Now, I've got a simple press the "n" and it goes directly to your desktop.
It required just a bit of editing of android.policy.jar

Why would anyone want "QuickNav"?
It's not part of Android anywhere, it's just something B&N put in.
 
brendan10211
Old
#8  
brendan10211's Avatar
Senior Member
Thanks Meter 12
Posts: 200
Join Date: Feb 2012
Location: Cary
Sometimes I use library...
Nexus 7 32GB
Nook Simple Touch - Rooted
 
Renate NST
Old
#9  
Renate NST's Avatar
Recognized Contributor / Recognized Developer - OP
Thanks Meter 773
Posts: 1,942
Join Date: Feb 2012
Location: Boston
Quote:
Originally Posted by brendan10211 View Post
Sometimes I use library...
You can drag the stock Library icon onto your desktop.
You can even put the stock Home or Shop there also.
 
brendan10211
Old
#10  
brendan10211's Avatar
Senior Member
Thanks Meter 12
Posts: 200
Join Date: Feb 2012
Location: Cary
I also use it to force refresh, but XorZone just made that soo
Nexus 7 32GB
Nook Simple Touch - Rooted

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


TRENDING IN THEMER...