"n" button hacking

Search This thread

Renate

Recognized Contributor / Inactive Recognized Dev
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

Senior Member
Nov 12, 2009
650
514
California
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

* 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
 
  • Like
Reactions: Renate

Renate

Recognized Contributor / Inactive Recognized Dev
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

Senior Member
May 23, 2011
468
50
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

Recognized Contributor / Inactive Recognized Dev
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.
 

forumache

Member
Jun 1, 2010
25
5
Hilversum
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.

Hi,

I, same as you, like to modify my Nook as little as possible. In case of a future software upgrade, I would like to know what to change back before applying it.

Of course, I know I can just save the partitions (internal disk) and restore it as needed, but I would like to not need to do this.

Right now, I modified the gpio file for Search and created my own Launcher (base on Home Sample code in Android SDK).

Still, I don't like the need for Long Press on Search.

Could you please post the links which shows how to hack the android.policy.jar?
Maybe, if I don't ask too much, your edits to it?

Thanks!
 

bobstro

Senior Member
Jun 6, 2009
479
137
[...] Why would anyone want "QuickNav"?
It's not part of Android anywhere, it's just something B&N put in.
Mainly because I don't like every device looking like an iPhone wannabe with a grid of icons. I like the reader focus with apps secondary. I do wish the QuickNav could be fully customized, including icons, easily.
 

Renate

Recognized Contributor / Inactive Recognized Dev
Mainly because I don't like every device looking like an iPhone wannabe with a grid of icons.

Mmm, Ok. Still, I don't like having to do three taps to do a non-book activity.
"n", then [launcher select] gets me anywhere.
The "currently reading" icon gets me back to my book.

I'm not fond of icons at all and have considered a list-oriented launcher,
but the fact remains that visually locking onto an icon is quicker.
That's why the QuickNav has icons on it.
 

bobstro

Senior Member
Jun 6, 2009
479
137
Mmm, Ok. Still, I don't like having to do three taps to do a non-book activity.
There are only a few apps I use regularly on the NST, so I've just remapped the QuickNav buttons using Xor's NookTouch Tools to launch them directly: Library, maildroid, astrid tasks, calendar pad and dropsync. I find it quicker than pulling up a full launcher.

It's definitely a personal preference thing. I rather like that the NST isn't trying to be an iDevice. There's a minimalist 'Zen' to it I like.

I know you don't like additional software, but you can take it a step further using Folder Organizer. I set it to show items in the Notification menu, then show the "Starred items" and "Applications" menus in the Notification menu. You can launch apps and submenus this way, and also shortcuts, which can be handy to have 2 clicks away.
"n", then [launcher select] gets me anywhere.
The "currently reading" icon gets me back to my book.
For me, it's:
  • "n" then run my top 5 most often used apps directly from QuickNav (2 taps)
  • or tap Notification->app for regularly used (still 2 taps)
  • or at worst, Notification->Menu->app for stuff I don't use regularly (3 taps)
This give me progressively more focused listof apps. At no point do I have to go through a launcher, thus avoiding the dreaded iPhone-wannabe look. I never use a launcher except for maintenance tasks.
I'm not fond of icons at all and have considered a list-oriented launcher, but the fact remains that visually locking onto an icon is quicker. That's why the QuickNav has icons on it.
Folder Organizer does essentially what you've described. You can change the folder display to show:
  • icons with text
  • icons only
  • list with icon and text
  • list with text only.
I don't recall which features are available in the free version, but I like to toss a few bucks to developers when I can, so happily paid the few bucks for the full version.

Unfortunately, NookTouch Tools only allows you to set the 'n' key to show QuickNav or not. If it allowed setting it to launch a shortcut, you could pull up a nice targeted list of apps directly, thus bypassing the 5 item limit of QuickNav.
 

Renate

Recognized Contributor / Inactive Recognized Dev
Unfortunately, NookTouch Tools only allows you to set the 'n' key to show QuickNav or not.

Although I have no experience with any of the Tools, I presume that they
(like my mod) just generate an android.intent.category.HOME/android.intent.action.MAIN

Most "home-based" apps should already have this as a filtered intent.
You should be able to easily select one of them as the default.
Using specific "shortcuts" defeats the purpose of the Android intents system.
 

bobstro

Senior Member
Jun 6, 2009
479
137
[...] Using specific "shortcuts" defeats the purpose of the Android intents system.
Does it have to be one or the other exclusively? For a basic launcher, pulling up the main app is sufficient. Other programs, such as Folder Organizer, provide shortcuts to user-defined categories, so I could have a subset of all available apps appear rather than a full launcher. Various readers provide shortcuts to books, and so on. Sometimes you don't want/need the full program.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    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

    * 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