[How To] Make Script Run By Using Hardware Keys - EVO 4G Android Development

Ok, so it didn't take long before my little trick was found in my Droid ROM so I guess it's time to explain myself and share it here for the Evo.
I came up with a way to use the hardware keys to make services (a.k.a. scripts) run. It was rumored that these options were already built into Froyo and/or used in Cyanogen Mod, neither being true. This is just one of those ideas I wake up with in my head. After playing with it a few minutes it worked flawlessly.
To add these options to your boot.img add the following lines to your preferred init script inside the ramdisk before compiling.
#shutdown options by pete
service poweroff /system/bin/shutdown
oneshot
disabled
keycodes 107 211
service reboot /system/bin/shutdown -r
oneshot
disabled
keycodes 107 114
service recovery /system/bin/shutdown -rr
oneshot
disabled
keycodes 107 115
Obviously you can make these do different things other than shutdown. You can even choose different keys to make them run (hint: those keycodes are for droid).
As always please be respectful and atleast put idea by Pete or some sort of credit to make me feel happy if you use it.

BuglessPete said:
Ok, so it didn't take long before my little trick was found in my Droid ROM so I guess it's time to explain myself and share it here for the Evo.
I came up with a way to use the hardware keys to make services (a.k.a. scripts) run. It was rumored that these options were already built into Froyo and/or used in Cyanogen Mod, neither being true. This is just one of those ideas I wake up with in my head. After playing with it a few minutes it worked flawlessly.
To add these options to your boot.img add the following lines to your preferred init script inside the ramdisk before compiling.
#shutdown options by pete
service poweroff /system/bin/shutdown
disabled
keycodes 107 211
service reboot /system/bin/shutdown -r
disabled
keycodes 107 114
service recovery /system/bin/shutdown -rr
disabled
keycodes 107 115
Obviously you can make these do different things other than shutdown. You can even choose different keys to make them run (hint: those keycodes are for droid).
As always please be respectful and atleast put idea by Pete or some sort of credit to make me feel happy if you use it.
Click to expand...
Click to collapse
Genius. Expect a donation from me.

Bumping this cause it seems like it would be pretty useful...

Thanks Pete for the tutorial, so I see two keys assigned to a script, so is it a combo press or just a single press?

That is awesome Pete good work and keep it up!!!!!!!

glad i donated to this guy, hes a smart cookie. hopefully, you're close to having enough for an evo!

Donated.
Confirmation number: 036688013H805551B

Applied your 'how to' to an idea of launching any application(or intent) by hardkey press(Custom App Launching). Let me know what you think.

BuglessPete said:
Ok, so it didn't take long before my little trick was found in my Droid ROM so I guess it's time to explain myself and share it here for the Evo.
I came up with a way to use the hardware keys to make services (a.k.a. scripts) run. It was rumored that these options were already built into Froyo and/or used in Cyanogen Mod, neither being true. This is just one of those ideas I wake up with in my head. After playing with it a few minutes it worked flawlessly.
To add these options to your boot.img add the following lines to your preferred init script inside the ramdisk before compiling.
#shutdown options by pete
service poweroff /system/bin/shutdown
oneshot
disabled
keycodes 107 211
service reboot /system/bin/shutdown -r
oneshot
disabled
keycodes 107 114
service recovery /system/bin/shutdown -rr
oneshot
disabled
keycodes 107 115
Obviously you can make these do different things other than shutdown. You can even choose different keys to make them run (hint: those keycodes are for droid).
As always please be respectful and atleast put idea by Pete or some sort of credit to make me feel happy if you use it.
Click to expand...
Click to collapse
hi bro, i follow u doing this, i modified init.rc and add some line like this
Code:
service calculator /system/bin/calc
oneshot
disabled
keycodes 139
keycodes 139 is a code of a menu hardware button, and also i add a .txt file to /system/bin , that is
Code:
#! /system/bin/sh
am start -a android.intent.action.MAIN -n co.fira.dialogapplication/.DialogActivity
but nothing happens when i touch the menu button, any idea?

Hi there, so i'm trying to do this exact thing, mapping the camera button to run an app. However when I press the button nothing happens!! I have tried with all my button codes, 114, 115, 212 etc and used the exact code above at the end of my init.rc file. I use Android Image kitchen toi crack open the boot.img and re-pack it. flashing works fine and I know these buttons work because if I change the .kl files I have test mapped them to pre-defined functions like CAMERA or FOCUS.
So the device runs 4.4.2 so it should support the services and keycodes commands in the init.rc.
I can see the init.rc file in the root folder on the device has the new code in it. It simply just doesn't work and i'm tearing my hair out now!
Does simply adding the service with the keycodes above actually run or install the service ready for the button press? Or do I have to actually run the service somewhere later in the init.rc file?
Any help would be greatly appreciated.
Dave

Related

Stagefright/Streaming Audio Fix Scripts to Enable/Disable on the Go

First, I take absolutely no credit for this beyond bringing this to the Evo forums' attention. And, I take absolutely no responsibility for whatever happens to your phone, period, ever.
As you probably know already, when you move up to 2.2, your Pandora streaming will likely take an audio quality hit due to the stagefright encoding introduced in 2.2. The fix is to disable stagefright in your build.prop. Unfortunately, disabling stagefright permanently introduces other issues. glitzbd over in the Nexus Forum posted this method the other day in order to enable/disable stagefright on the fly.
"I just did this on MCR21 (FRF91) and what a difference! Here is what I did!
I downloaded GScript Light (buying the pay version ASAP haha)
Opened the program and ran the CPU script to give it SU
In the program hit the menu button and then add script
I put the following in:
Name: Enable
Needs SU?: Check
setprop media.stagefright.enable-player true
Save
Name: Disable
Needs SU?: Check
setprop media.stagefright.enable-player false
Save
Now go to your launcher and long press to add a shortcut, and then scroll down the GScript and it will bring up a list of all of your scripts, put both of those on the homescreen!
For convenience I will attach the scripts just in case you don't want to bother with it haha
I am not positive on how to add them, but I think you can just unzip them, and place them on your SD card and when you go to add script then hit Load File
Enjoy!"
and per beagz in the Nexus Forum
"Thanks for posting those. I was just about to do that myself. Great job.
Make sure you place them in the gscript folder on the sdcard.
Also long press on homescreen --> shortcuts --> gscript
then select which script you want to have a link to. Then you can just press the icon for enable or disable."
Link to scripts: http://forum.xda-developers.com/attachment.php?attachmentid=372654&d=1280871021
Now seeing as I don't have the skills for this, should anyone have the skills and would like to help, having a widget for this would be extremely helpful.
Thoughts?
MSmith1 said:
First, I take absolutely no credit for this beyond bringing this to the Evo forums' attention. And, I take absolutely no responsibility for whatever happens to your phone, period, ever.
As you probably know already, when you move up to 2.2, your Pandora streaming will likely take an audio quality hit due to the stagefright encoding introduced in 2.2. The fix is to disable stagefright in your build.prop. Unfortunately, disabling stagefright permanently introduces other issues. glitzbd over in the Nexus Forum posted this method the other day in order to enable/disable stagefright on the fly.
"I just did this on MCR21 (FRF91) and what a difference! Here is what I did!
I downloaded GScript Light (buying the pay version ASAP haha)
Opened the program and ran the CPU script to give it SU
In the program hit the menu button and then add script
I put the following in:
Name: Enable
Needs SU?: Check
setprop media.stagefright.enable-player true
Save
Name: Disable
Needs SU?: Check
setprop media.stagefright.enable-player false
Save
Now go to your launcher and long press to add a shortcut, and then scroll down the GScript and it will bring up a list of all of your scripts, put both of those on the homescreen!
For convenience I will attach the scripts just in case you don't want to bother with it haha
I am not positive on how to add them, but I think you can just unzip them, and place them on your SD card and when you go to add script then hit Load File
Enjoy!"
and per beagz in the Nexus Forum
"Thanks for posting those. I was just about to do that myself. Great job.
Make sure you place them in the gscript folder on the sdcard.
Also long press on homescreen --> shortcuts --> gscript
then select which script you want to have a link to. Then you can just press the icon for enable or disable."
Link to scripts: http://forum.xda-developers.com/attachment.php?attachmentid=372654&d=1280871021
Now seeing as I don't have the skills for this, should anyone have the skills and would like to help, having a widget for this would be extremely helpful.
Thoughts?
Click to expand...
Click to collapse
Isn't that kinda what you just did, set up an enable and disable widget?
To contribute, however, you could use tasker to create a desktop widget that brought up a menu with two options of disable and enable, and you could click each of those to perform the action.
I've only been using tasker for a week, but it's pretty awesome IMO. I have already created lots of custom stuff. For example, when I plug in my headphones, it sets my volume and opens Pandora.
Anyway, could be an option without having to do coding.
You mentioned that it caused other problems, can you share what those are? I've since changed my build prop too, so I guess I've got whatever those problems are. :/
I tried this...but the problems I encountered was with streaming radio apps such as RadioTime, Yahoo Music and WunderRadio). In my experience, when you switch to false they refuse to connect and stream.
I read in another forum someone wrote Pandora about their sound issues with Froyo. They acknowledged the issue and stated they'll be making changes in their next release. Of course, they didn't state when the next release will be.
Vegasden said:
I tried this...but the problems I encountered was with streaming radio apps such as RadioTime, Yahoo Music and WunderRadio). In my experience, when you switch to false they refuse to connect and stream.
I read in another forum someone wrote Pandora about their sound issues with Froyo. They acknowledged the issue and stated they'll be making changes in their next release. Of course, they didn't state when the next release will be.
Click to expand...
Click to collapse
then you actually havent tried this.
MSmith1 said:
First, I take absolutely no credit for this beyond bringing this to the Evo forums' attention. And, I take absolutely no responsibility for whatever happens to your phone, period, ever.
As you probably know already, when you move up to 2.2, your Pandora streaming will likely take an audio quality hit due to the stagefright encoding introduced in 2.2. The fix is to disable stagefright in your build.prop. Unfortunately, disabling stagefright permanently introduces other issues. glitzbd over in the Nexus Forum posted this method the other day in order to enable/disable stagefright on the fly.
"I just did this on MCR21 (FRF91) and what a difference! Here is what I did!
I downloaded GScript Light (buying the pay version ASAP haha)
Opened the program and ran the CPU script to give it SU
In the program hit the menu button and then add script
I put the following in:
Name: Enable
Needs SU?: Check
setprop media.stagefright.enable-player true
Save
Name: Disable
Needs SU?: Check
setprop media.stagefright.enable-player false
Save
Now go to your launcher and long press to add a shortcut, and then scroll down the GScript and it will bring up a list of all of your scripts, put both of those on the homescreen!
For convenience I will attach the scripts just in case you don't want to bother with it haha
I am not positive on how to add them, but I think you can just unzip them, and place them on your SD card and when you go to add script then hit Load File
Enjoy!"
and per beagz in the Nexus Forum
"Thanks for posting those. I was just about to do that myself. Great job.
Make sure you place them in the gscript folder on the sdcard.
Also long press on homescreen --> shortcuts --> gscript
then select which script you want to have a link to. Then you can just press the icon for enable or disable."
Link to scripts: http://forum.xda-developers.com/attachment.php?attachmentid=372654&d=1280871021
Now seeing as I don't have the skills for this, should anyone have the skills and would like to help, having a widget for this would be extremely helpful.
Thoughts?
Click to expand...
Click to collapse
I've been having streaming issues with Last.FM and Pandora. I'll give this a whirl and let you guys know how it goes. Thanks for the tip though, much appreciated!
I tried adding the scripts, but it seems that the build.prop file does not get updated no matter what I do.. there are no errors when running the script and it even confirms that it ran, but the value doesn't change...
Edit: I ran Quadrant to make sure the scripts worked and yes, they do affect my scores so it looks like it's changing as it should. Thanks again, hopefully it fixes my audio issues.
Edit2: Seems to have fixed my Last.FM, thanks a bunch!
I can confirm these scripts are working for me as well. Streaming radio stations without stagefright player enabled caused the same problems so these scripts allow me to get around this relatively easily. BTW, to the above user, these scripts are adb shell commands and will not modify the build.prop.
Question: Is there a way to open an app with a shell command? I would like to set the property to the appropriate value and proceed to open the streaming app afterward. So I would have a slacker script that would disable stagefright and start slacker, etc. Thanks!
jedil1c1ous said:
Question: Is there a way to open an app with a shell command? I would like to set the property to the appropriate value and proceed to open the streaming app afterward. So I would have a slacker script that would disable stagefright and start slacker, etc. Thanks!
Click to expand...
Click to collapse
Maybe tasker can do this? I'm not sure though.
jedil1c1ous said:
I can confirm these scripts are working for me as well. Streaming radio stations without stagefright player enabled caused the same problems so these scripts allow me to get around this relatively easily. BTW, to the above user, these scripts are adb shell commands and will not modify the build.prop.
Question: Is there a way to open an app with a shell command? I would like to set the property to the appropriate value and proceed to open the streaming app afterward. So I would have a slacker script that would disable stagefright and start slacker, etc. Thanks!
Click to expand...
Click to collapse
Another plug for tasker, it is able to run ASE (Android Scripting Environment 2.0+) scripts, so maybe we could make it work there.
Running shell commands in an app is more difficult than it sounds. I tried to do it a while back with a test app I was writing, and it doesn't really translate too well with the Android API. I'm sure there is a fairly good way to do it by leveraging an outside java api, but I didn't have a ton of luck.
Here's a link to the ASE (now known as SL4) google code page:
http://code.google.com/p/android-scripting/
MSmith1 said:
Maybe tasker can do this? I'm not sure though.
Click to expand...
Click to collapse
It looks like this is on his todo list for Tasker. From his website:
rooted phone: become root/user, Run Shell Script (bash, no ASE needed), Reboot, toggle background data,key events and injection
Thanks for this. Before, I either just pulled the build.prop file and edited it there, making it permanant, but then everytime I flashed a CM6 Nightly it would go away And then I would always manually type it in on Terminal Emulator, which would be a pain, because after restart, I would have to redo it!
Now, thanks to this, I can disable/enable very quickly, and should be able to keep these scripts when I flash the CM6 Nightlies
Glad I could bring this to everyone's attention.

how can you choose another keyboard

i can't even choose wii controller in tnt? i just got tnt lite 2.0 going and i just realized i can't even use wiimote because tnt won't let you change keyboards. this sucks bad, that would be great if someone figured out a way to bypass this little security measure they have to keep you from using other keyboards.
Yea, i paid $20 for a bluetooth keyboard i can't use because of that...
I am a developer though I already have the android source on my computers so perhaps i will have some time to look tomorrow at how exactly they do it in the code.
Usually that stuff is restricted but perhaps there is a way around as root. I know there is a command you can run to force apps to install to the SDcard on my droid under froyo, perhaps the same command can change this setting.
Has anybody tried loading up the stock froyo settings app?
--Robert
FYI: it's in android-source/packages/apps/Settings/src/com/android/settings/LanguageSettings.java
Code:
Settings.Secure.putString(getContentResolver(),
Settings.Secure.ENABLED_INPUT_METHODS, builder.toString());
Settings.Secure.putString(getContentResolver(),
Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS, disabledSysImes.toString());
Settings.Secure.putString(getContentResolver(),
Settings.Secure.DEFAULT_INPUT_METHOD,
mLastInputMethodId != null ? mLastInputMethodId : "");
Read from
Code:
mLastInputMethodId = Settings.Secure.getString(getContentResolver(),
Settings.Secure.DEFAULT_INPUT_METHOD);
String enabledStr = Settings.Secure.getString(getContentResolver(),
Settings.Secure.ENABLED_INPUT_METHODS);
final TextUtils.SimpleStringSplitter splitter = mStringColonSplitter;
splitter.setString(enabledStr);
the Settings.secure permission is restricted from normal apps- but maybe we can gain that permission if we put the app in the /System/ folder?
This would be a major accomplishment if you figure this out. For the life of me I don't know why they would have done this...makes no sense.
Sent from my ADR6300 using XDA App
I did find a way into the accounts and settings (sync settings) - but I don't have checkboxes to enable syncing on contacts and calendars for some reason....
Perhaps i did the tntlite2.0 upgrade wrong - i did NOT do a factory reset because I didn't want to reinstall everything
I'll try to remember to post the sync settings launcher app tonight after i get home from work- all it does is fire the necessary intention to get into the app (com.android.providers.subscribedfeeds/com.android.settings.ManageAccountsSettings)
Hopefully they screwed up the settings app, which i can probably fix by making a new one, but if they hosed the settingsProvider that is supposed to store this stuff we might be screwed :-(
I just figured out how to write a video streaming app (from android) for my work, so this should be easy by comparison
On a dissapointed note- my sound is still F-ed up after the 11/22 update (randomly stops working, plays static and floods the logs w/ errors) anybody else have this problem?
Thanks for working on this, this is one of my biggest complaints with tnt.
Sent from my ADR6300 using XDA App
If anybody could find a way to get around this:
PackageManager W Not granting permission android.permission.WRITE_SECURE_SETTINGS to package com.DroidMunkey.gTabletHacks (protectionLevel=3 flags=0xbe44)
I would have this finished.
Sticking it in /system/app doesn't work so i must be missing something - it's rejected in: android-source/frameworks/base/services/java/com/android/server/PackageManagerService.java if anybody else wants to take a look
I figured it out, but they screwed something else up in the system and must have disabled it on purpose...
if i select a different keyboard the input box expands to take up the entire screen when i click on it!
So if you have an alt keyboard selected and you hit the search key, you can't see the history below, or the icons next to the box to do the voice search/location selection!!!
see attached image
Very annoying.. wasted an entire day to figure this out. I suppose it wasn't a total waste though I learned alot about the android core
Are there any other settings missing that people need? I might put together an app that will let you do this despite the annoying bug if people are still interested.
I already wrote an app like HomeCatcher, but it shows me the "recent apps" list, since you can't long-press the damn home-key anymore. Anybody interested in something like that?
BTW- since nobody spells out in plain english how to get the WRITE_SECURE_SETTINGS permission, here it is for those of you hitting this page via Googling my error
1) You need to request the permission in your app manifest
2) the app has to be in /system/app/
3) it has to be owned by root w/ the correct permissions (nobody tells you this part!)
4) when you reboot, the app will be automatically installed, and you will get the additional permissions (if it's already installed, you have to uninstall it before you reboot!)
5) you will NOT be able to uninstall the app after you do this (just delete it, but make SURE you manually 'clear cache' for the app in settings->applications->manage->yourapp before you delete it or all your extra settings data will be orphaned in memory!!)
su
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
cat /sdcard/YourApp.apk > /system/app/YourApp.apk
chown 0.0 /system/app/YourApp.apk
chmod 0644 /system/app/YourApp.apk
mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system
reboot
Click to expand...
Click to collapse
KinkyMunkey said:
I figured it out, but they screwed something else up in the system and must have disabled it on purpose...
if i select a different keyboard the input box expands to take up the entire screen when i click on it!
So if you have an alt keyboard selected and you hit the search key, you can't see the history below, or the icons next to the box to do the voice search/location selection!!!
Click to expand...
Click to collapse
Thanks! Mind if I ask you which alternate keyboard you are using? On my another device I also get this exact same huge textbox if I some alternate keyboard (e.g. the Better Keyboard), but not all (e.g. the Thumb Keyboard).
Also: which ROM are you using? Does it matter (with respect to your 5-steps procedure)?
Are there any other settings missing that people need? I might put together an app that will let you do this despite the annoying bug if people are still interested.
I already wrote an app like HomeCatcher, but it shows me the "recent apps" list, since you can't long-press the damn home-key anymore. Anybody interested in something like that?
Click to expand...
Click to collapse
Absolutely! (I know that it's available via roebeet's TnT Lite 2.0.2 supplement, but I'd like to stick to 2.0.0's contact & calendar...)
Thanks!
Save time just install zpad . Cleaner look runs faster and can use other keyboard inputs.. played super Mario bros 3 with wiimote this morning. I just need a stand now
I tried the blueInput and full keyboard, both did it, they do not do it on my droid which is why i am convinced something is wrong with the tablet
I have been thinking about it, I wonder if there is a build setting (related to the USB keyboard support) that is telling android to do this. I can't imagine why it would happen unless it's a "feature" for phones w/ small screens or no touchscreen.
It happens in every input box, so it's GOTTA be an android setting, going to dig around and see if i can figure out what causes it
btw here is the code i used, combined w/ the steps to gain the SETTING_SECURE priv above, in case anybody is pulling their hair out to do it.
Code:
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
List<InputMethodInfo> mInputMethodProperties = imm.getInputMethodList();
StringBuilder builder = new StringBuilder(256);
int N = (mInputMethodProperties == null ? 0 : mInputMethodProperties.size());
for (int i = 0; i < N; ++i) {
InputMethodInfo property = mInputMethodProperties.get(i);
String prefKey = property.getId();
CharSequence label = property.loadLabel(getPackageManager());
Log.i(LOGTAG, "found " + label);
if (builder.length() > 0) builder.append(':');
builder.append(prefKey);
}
String mLastInputMethodId = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
String enabledStr = Settings.Secure.getString(getContentResolver(),
Settings.Secure.ENABLED_INPUT_METHODS);
Log.i(LOGTAG, "last: " + mLastInputMethodId + " enabled " + enabledStr + " we would like: " + builder.toString());
try {
Settings.Secure.putString(getContentResolver(), Settings.Secure.ENABLED_INPUT_METHODS, builder.toString());
Toast.makeText(getApplicationContext(), "SUCCESS!! keyboard enabled!", Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Failed to set keyboard: " + e.getMessage(), Toast.LENGTH_LONG).show();
}
KinkyMunkey said:
I tried the blueInput and full keyboard, both did it, they do not do it on my droid which is why i am convinced something is wrong with the tablet
Click to expand...
Click to collapse
Thanks! Could you try the thumb keyboard
http://forum.xda-developers.com/showthread.php?t=830772
and see if you get the same result?
yes, same problem with thumb keyboard
I did get "hidd --search" to find my bluetooth keyboard! I can use it without doing anything special now, works just like a usb keyboard would
KinkyMunkey said:
yes, same problem with thumb keyboard
I did get "hidd --search" to find my bluetooth keyboard! I can use it without doing anything special now, works just like a usb keyboard would
Click to expand...
Click to collapse
http://code.google.com/p/androidobex/downloads/detail?name=hidd
get that, stick it in /system/bin, go into a terminal (adb shell) do su, then type 'hidd --search'
that will automatically search for bluetooth HIDD devices and connect to any it finds
Then, the bluetooth keyboard will work w/out having to switch input methods
This may reset your wifi connection and force a reconnect when it does it's bluetooth scan, not sure why it does that, if you use the --connect option and specify the bluetooth ID instead of searching it won't do that
http://linux.die.net/man/1/hidd
Horray for linux based phones!
KinkyMunkey said:
http://code.google.com/p/androidobex/downloads/detail?name=hidd
get that, stick it in /system/bin, go into a terminal (adb shell) do su, then type 'hidd --search'
that will automatically search for bluetooth HIDD devices and connect to any it finds
Then, the bluetooth keyboard will work w/out having to switch input methods
This may reset your wifi connection and force a reconnect when it does it's bluetooth scan, not sure why it does that, if you use the --connect option and specify the bluetooth ID instead of searching it won't do that
http://linux.die.net/man/1/hidd
Horray for linux based phones!
Click to expand...
Click to collapse
awesome so you got it to work? i was never able to get adb to proplerly work though. i may work on that later.
if you are on linux- you need a rule for it in /etc/udev/rules/ so ADB has permission to access the device (otherwise you have to run adb as sudo)
create an android file if you don't have it (i use the file name '99-android.rules' so it runs last)
Code:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0955", ATTRS{idProduct}=="7100", MODE="0666"
(FYI, you use the 'lsusb' command to get these numbers if you have a new device- Bus 001 Device 008: ID 0955:7100 NVidia Corp.)
didn't know if anyone had seen this thread, they say this method works but seems like it may be a hassle to switch back and forth between keyboards http://forum.xda-developers.com/showthread.php?t=856476

[How-To][Mod] Changing the Keyboard Characters

Quick and short of it:
The SK4G has the same exact physical Keyboard layout of the G1. But it sucks in comparison to the G1's layout because someone at Samsung dropped the ball. Shift + a number does not give you the normal expected symbol. There is a lack of a comma on the right hand side. Shift+Alt tends to not do anything on most keys. With this mod, I fixed 90% of the annoyances of the hardware keyboard (Just need to turn the [useless everywhere but the stock messaging app] smilie key into the voice key, and the voice key into an alt key and I'll be 100% good)
By hacking the corresponding kcm.bin file in the /system/usr/keychars/ directory, you can change the action of a key. This is not the same as changing the kl file in /system/usr/keylayout/ which allows you to change the behavior of a physical key. (A bit of semantics really.)
I modded the default kcm.bin (Binary Keyboard Character Map) file s3c-keypad.kcm.bin to match the G1 kcm closely, adjusting for what is printed on the SK4g keyboard, so w, e, and r are still smilies, and m is still /, while alt+shift+? is now ¿ as the g1 has. Only change to what is printed was fixing the multiplication sign symbol on alt+o to show an actual multiplication sign, instead of an x. Some unused alt+shift+key were used to improve usage, and for flair.
Main Changes:
shift+number provides its corresponding symbol, like it should.
alt+shift+O is the Umlat combining accent (press another character afterwards it it might combined, like ¨ + u is ü. Same result as longpressing U).
Alt+Q default by Samsung is a Space. Alt+Shift+Q is now Tab.
Alt+Shift+T is the "¬" not symbol. Sideways L. Useful for ¬_¬ sideway glances.
Alt+Shift+Y is the unicode STAR AND CRESCENT. SK4G can't display it, but it will show up correctly in OSes that understand it/have the right encoding (like the G1).
Shift+Period is a comma. Because the comma belongs on the right side of the keyboard dammit.
Alt+Period is a bullet symbol.
Alt+Shift+Period is a "`" Grave combining accent (same as Umlat. Grave + space is regular grave)
Alt+Shift+Enter is a CR return key, instead of the normal LF return key. Some apps recognize the difference (ConnectBot)
[email protected] and [email protected] is the ~ tilde. I did not add the combining accent version. An adult keyboard requires the ~.
[email protected] is the Eighth Note. Because we all need some music in our lives. Displays properly on the SK4g.
Instructions:
If you want to use the character map I created, you will need root, adb, and be comfortable mucking about the phone's system files. You can install with RootExplorer or any other file manager instead, if you know how to do it:
Code:
adb push /path/to/unzipped/files/mods3c-keypad.kcm.bin /data/local/tmp/
adb shell
su
mount -o remount,rw /dev/block/stl9 /system
cp /data/local/tmp/mods3c-keypad.kcm.bin /system/usr/keychars/
cp /system/usr/keychars/s3c-keypad.kcm.bin /system/usr/keychars/s3c-keypad.bu
mv /system/usr/keychars/mods3c-keypad.kcm.bin /system/usr/keychars/s3c-keypad.kcm.bin
chmod 644 /system/usr/keychars/s3c-keypad.kcm.bin
You need to push the file to the tmp folder, then going in as superuser, remount the system partition.
Once remounted, you can copy the file to the correct folder.
Safety first, make a backup of the original file. A copy of the original is also provided in the zip folder.
Now you overwrite the original.
Once that's done, you want to correct the permissions to 644 like the original.
At this point, you can reboot. If you want to give it a try before rebooting, you can just load any app that isn't in memory, or kill an existing app, and load it back up, and type to see the difference. You must reboot if you want to see the changes everywhere. Any app in memory, including home and system, will not see the new file till you kill it/reboot.
What's in the zip:
Four files are provided in the zip.
1: "s3c-keypad.kcm.bin" This is the original kcm.bin from the stock KD1 firmware. Most likely, it has not been change in KG2.
2: "trout-keypad-v3.kcm" This is a plain text readable version of the G1 kcm. Look at this if you want to see the format android uses to build the kcm.bin file. Easy to read.
3: "mods3c-keypad.kcm" This is a modified kcm file, easy to read showing what my modded layout is, with notes.
4: "mods3c-keypad.kcm.bin" the actual kcm.bin file you can use to drastically improve your keyboard.
If You want to make your own:
Some Resources First:
ASOP Developers Guide to the Keyboard:
http://www.kandroid.org/online-pdk/guide/keymaps_keyboard_input.html
Describes how Android uses (some of) the keyboard files, and the file layouts.
Extending the keyboard mapping of an Android system
http://jahrome.free.fr/index.php/keyboard-mapping-android-htc-desire?lang=en
Found this after the fact, some xda members doing this on the g1 way back when:
http://forum.xda-developers.com/showthread.php?t=468703
Someone had a python tool to turn kcm.bin to kcm files.
http://forum.xda-developers.com/showthread.php?t=837002
Basically, you will be mucking around a hexeditor to change the kcm.bin file.
Make the hex editor show you 16 bytes per line, and you will see a nice pattern, as shown on the http://jahrome.free.fr/index.php/keyboard-mapping-android-htc-desire?lang=en.
Any non-normal (unicode) character should be put on the hex side, so 0x0300 would be typed in. Additionally, hex editors tend to show lsb first. So unicode 0x0300 would show up as "00 03". 0xEF01 will be seen as 01 EF.
If you look and compare the hex editor screen to the kcm file provided, you can easily modify the kcm.bin file to your liking.
Future:
I'm trying to find where the LongPress Keyboard character maps are. Like when you longpress ! lets you choose ¡, or long pressing shift+4 ($) gives you the option to insert a couple of currency marks, or longpressing a will let you choose from accented a characters (å,ä,â etc).
Additionally, also looking for the same on the Extended Feature keys, like SYM, and the smilies. The smilies are just macros that get typed when you press them, as using the regular smilie types ":" "-" and ")", and you can delete each one individually. Having a customizable macro key would be great.
But from my guess, one or both of those features are embedded in the keyboard device driver. I will muck around the filesystem to see what I can find.
Notes:
I am not responsible for anything ever anywhere. You break it, you pay it, not me.
Also, this is only for the hardware keyboard, not the virtual IMEs. Changing those would require apk code signing, and desamali and everything. headthefrickache.
thank you!
this is gonna be really helpful and fun to mess around and make my own. glad to have another dev aboard!
Update: I poked around a bit, and looked at the ime-htc.apk that is floating around. Decompiled the apk, and found that it's popup alternatives for the virtual keyboard is in res/values/strings.xml, with the fields pointed at it by res/xml-normal-hdpi/*.xml depending on which language/shape/layout keyboard you are using.
So I think I am right in assuming that the hardware keyboard popups are in the device driver. :/ Will investigate further.
Oh, and a note about the sidekick keyboard. You cannot press and hold ALT+SHIFT and a third key at the same time. You can't press any three keys and have it register at the same time at all. Another instance where the g1 was just better
Additionally, doesn't seem like all keys respond to a alt-lock+shift-lock the same. The @ and ? key seems to only produce the alt or shift version, while most of the others produce the alt+shift version of the key.
This ****ing guy, eh? When can I buy you strippers and blow, eh? I ****ing love you.
chaostic_2k1 said:
Update: I poked around a bit, and looked at the ime-htc.apk that is floating around. Decompiled the apk, and found that it's popup alternatives for the virtual keyboard is in res/values/strings.xml, with the fields pointed at it by res/xml-normal-hdpi/*.xml depending on which language/shape/layout keyboard you are using.
So I think I am right in assuming that the hardware keyboard popups are in the device driver. :/ Will investigate further.
Oh, and a note about the sidekick keyboard. You cannot press and hold ALT+SHIFT and a third key at the same time. You can't press any three keys and have it register at the same time at all. Another instance where the g1 was just better
Additionally, doesn't seem like all keys respond to a alt-lock+shift-lock the same. The @ and ? key seems to only produce the alt or shift version, while most of the others produce the alt+shift version of the key.
Click to expand...
Click to collapse
Port G1 driver? Whoz got the sauce? erm Source?
Well, I figure the g1 just dedicated more gpio than sumsung did for the keyboard. I doubt the g1 driver can be ported. And the sumsung keyboard driver might be hackable, but without the source for it, it be a pain to try. Still looking for the long press keys though.
I may be confused about your question. I can't seem to understand what you mean by hardware keyboard popup, but yes, the keyboard driver is in the kernel, so you'd need a custom kernel to change that.
The kernel source is available at opensource.samsung.com
If you can pm me/write what you're trying to do/fix (as I'm currently a bit confused as to your goal) I would be open to helping work on this
If you hold down the a key on the keyboard, you get a little popup screen that lets you choose the alternative versions of a, like å, ä, á, etc. Same for holding shift+4 or alt+4, would give you the alternatives for $, like ¥, british pound symbol, etc.
I am trying to find where that information is held. On an ime, it's in the strings.xml file inside the apk. For the hardware keyboard, I'm guessing its in the driver. I'm trying to locate that, so that it can be changed to include more things (and in the sk4g, even add macros like the smilies).
Unfortunately, noone else has found it, or if they have, it's buried in some obscure thread inside some obscure device's forum. The problem with android information, is that with so many devices, and versions, there is a ton of information, being redundantly found/created, and buried under other information.
Haha I hear that. I guess I was testing it out using the wrong buttons before, as I didn't get that popup before. Now I was able to, but it looks like it's only for certain keys. At any rate, let me look in the kernel source to see if I can find the correct files there.
sduvick said:
Haha I hear that. I guess I was testing it out using the wrong buttons before, as I didn't get that popup before. Now I was able to, but it looks like it's only for certain keys. At any rate, let me look in the kernel source to see if I can find the correct files there.
Click to expand...
Click to collapse
I will donate money to this project. No ****ing joke. I wanna see this **** happen.
$50 is what I'm putting down at the moment. I'll put down more if more coders want to help out sduvick and make this work wonderfully.
Requirements,
01. Have all the features which the OP is attempting to incorporate.
02. Have a secondary .apk which allows users to modify key layout whilst using the phone.
Update/message towards chaostic: it appears that the longpress popup is coming from /system/framework/services.jar (desmali'd) com/android/server/KeyInputQueue.
On a somewhat related note, trying to find the keymaps for smileys to remove the extra alt added after the '<3' alt key if anyone might know where that is. EDIT: re-read your OP, looks like you couldn't find these either, but apparently this was fixed in the KG2 update, so maybe the kernel updates might give me more details. will update shortly.
UPDATE: found the smileys in /system/framework/framework.jar (desmali'd) com/android/internal/widget/smileys.smali
sduvick said:
Update/message towards chaostic: it appears that the longpress popup is coming from /system/framework/services.jar (desmali'd) com/android/server/KeyInputQueue.
On a somewhat related note, trying to find the keymaps for smileys to remove the extra alt added after the '<3' alt key if anyone might know where that is. EDIT: re-read your OP, looks like you couldn't find these either, but apparently this was fixed in the KG2 update, so maybe the kernel updates might give me more details. will update shortly.
UPDATE: found the smileys in /system/framework/framework.jar (desmali'd) com/android/internal/widget/smileys.smali
Click to expand...
Click to collapse
So the smilies have been found is great, but the two things of note is how difficult it would be for a regular edit, so for rom builders or themers its great, but individuals would be hard press to change it.
Just to make sure, these are the alt+w or alt+e or alt+r smilies/macros, or is it the smiliey key widgets?
Either way it gives me somewhere to look. Seems the longpress alternatives is a longshot for easy modding at this time. But ever forward. Thanks.
I would integrate it as part of the tweaks thread I've been working out of, but it's a matter of changing some very simple (once you get it extracted and desmali'd) source, just looking through one file and looking for the strings for each smiley. Mind you, this is only for the smiley button itself, that is the popup that appears in messaging when you try to use the smiley button. This doesn't really relate at all to the keyboard at all actually.
Any key presses are gonna be from the kernel somewhere, still waiting on the download, samsung's opensource server is slow as balls.
Works great; how to edit
I just did this and it solved one of my two huge dissatisfiers with the Sk4G over the G1 and the actual original Sidekicks (where I was one of the people who convinced them to add | and ` and ~ back at Danger).
I really wanted to type ` by itself, so I edited my keymap so that [email protected] is ~ but alt-~ is `. I did this using emacs, with hexl-mode, and it was a snap!
Also, even though I've used adb in the past, I got stuck at su and it did nothing. I realized I needed to be running the SuperUser app first, and once I did that and ^C'd out of the su, it prompted me and I allowed it to remember shell request, and everything from then on worked great!
Thanks!
Leigh.
Glad it Helped someone
Can you hack the keyboard to allow virtual keyboard to work while in landscape mode?
Thanks that is awesome
This was really helpful.
I'm been bothered with the funky behaviour of shift+0-9
I also mapped alt-a a to escape
and changed alt-q from space to really being tab
The .kl file was also interesting:
/system/usr/keylayout/s3c-keypad.kl
It is just a textfile, so easy to edit and I was able to remap the mostly useless SMILEY key to GRAVE.
which is helpfull when I need a ~.
The .kl file also has all the other buttons on the SK4G so they can be reassigned.
I moved VOICE_INPUT to what was MULTITASKER, so I can enter voice commands without opening the keyboard.
and made myself a ALT_LEFT.
Smart Quote-enabled Physical Keyboard
First off, a huge thanks to chaostic_2k1, whose hack of the Sidekick 4G keyboard is brilliant. It was the only one I could find, and his instructions are first-rate. Using his modified s3c-keypad.kcm.bin file, I’ve been able to concoct a keyboard that has all of his fine variations along with smart-quote and easier em-dash ability.
If users are trying to write a professional manuscript, they need smart quotes (curly quotes), em dashes, and ellipses. The attached file has these modifications:
ALT-f = left double quotation mark
SHIFT-ALT-f = still gives the left bracket
ALT-g = right double quotation mark
SHIFT-ALT-g = still gives the right bracket
[These brackets are also stock-accessible with ALT-space]
[Right and left double quotation marks are stock-accessible with ALT-k, long press, etc. The keystrokes in this file cut down the number of steps]
ALT-lowercase L = right single quotation mark (curly apostrophe)
SHIFT-ALT-lowercase L = straight apostrophe
ALT-t = regular hyphen
SHIFT-ALT-t = em dash
[The em dash is still stock-accessible with ALT-t, long press, etc.]
The ellipsis is stock-accessible with ALT-space. I didn't modify anything connected with the ellipsis.
Follow the instructions in the first post of this thread for proper s3c-keypad.kcm.bin copying into /system/usr/keychars
Root obviously a must, and I used Total Commander file manager to copy file from sd card to /system/usr/keychars
If using Total Commander, remember to change /system directory to read-write.
Proper screen display of smart quotes: neither ThinkFree or Kingsoft word processors will display the actual right and left double quotes, though the quotes will enter correctly and display on a desktop word processor, printer, etc. In order to see double quotes correctly, users must use QuickOffice or TextMaker word processors [for reasons I can’t figure, KingSoft doesn’t even allow ALT-space or any SHIFT-ALT keystroke].
This keyboard mapping works on my Sidekick 4G, but I take no responsibility for any problem. I’ve also hacked the /system/usr/keylayout/s3c-keypad.kl to change key 54 SMILEY to key 54 TAB WAKE_DROPPED
This changes the SMILEY to a proper tab.
Do take care with the /system/usr/keylayout/s3c-keypad.kl If you screw it up, all physical keys, including Menu, etc, are dead, and you have to touch-screen the restoration of the original file. A little scary.
EDIT/UPDATE: Attached is the kcm file with an additional character: the left apostrophe. SHIFT-ALT-k = left single quotation mark
This is needed for smart quote usage when quoting within double quotes: "So when you said 'yes,' you really meant no."
Jake

How to remap mouse buttons and is possible to make .kl and .kcm files for it?

Hi,
I've read all possible threads trying to answer my question and tried editing and creating .kl files with no effect.
None of my mouse buttons can be remapped using the simplest method - by making a .kl file .kl.
Key list:
0x110 (key 272) left click button - mapping BTN_LEFT
0x111 (key 273) right click button - mapping BTN_RIGHT
0x112 (key 274) middle button (scroll button) - mapping BTN_MIDDLE
0x113 (key 275) back/previous button - mapping BTN_SIDE
0x114 (key 276) forward/next button - mapping BTN_EXTRA
KeyTest app that shows details on keypresses returns info only for the FORWARD and BACK mouse buttons. Pressing the rest gives no output.
I managed to remap these two keys with Xposed Additions Xposed Framework module.
Unfortunetly I couldn't do the same for 3 remaining keys
Some questions relating the issue:
Are mouse devices remapped some other way then by making a .kl file for them? Is there even an official, Google way to remap them? Just like the one in the Dev site?
Can you determine which .kl file is used by a specific device? With a shell command maybe?
RESEARCH:
Android Button State
An Android button state is a standard identifier defined in the Android API for indicating which buttons (on a mouse or stylus) are pressed. Android button states are defined by the android.view.MotionEvent class as constants that begin with the prefix BUTTON_.
The current button state is determined by the Android InputReader component which monitors when buttons (on a mouse or stylus) are pressed / released and sets / resets appropriate button state flag.
The relationship between buttons and button states is hardcoded.
Click to expand...
Click to collapse
Source Android official website - > Devices -> Interfaces -> Input -> Key Layout Files site describing .kl files usage and syntax doesn't mention anything about the mouse - so is there no .kl for mouse? No "official" way of remapping the keys? or if I think right, basing on "Android Button State" mentioned above; left, right and middle mouse buttons are hardcoded and can't be just remapped? So where is it hardcoded then?
Source Android official website - > Devices -> Interfaces -> Input -> Input Device Configuration Files
The default behavior for a mouse is to present an on-screen cursor which tracks the mouse's movements and simulates touches when the mouse is clicked. Although the mouse can be configured differently, the default behavior is usually sufficient for standard mouse peripherals.
Click to expand...
Click to collapse
Eem... ok so it says it can be configured otherwise, but how... if the .kl files are not working...
Input Device Configuration File - /system/usr/idc/Vendor_XXXX_Product_XXXX.idc
I have tried making an .idc file for my mouse and it's being used, but I don't know what I should put in it so Android would also use a .kl or .kcm file for the mouse just like it does for keyboards.
Logcat output:
I/EventHub( 656): New device: id=32, fd=173, path='/dev/input/event6', name='Bluetooth Mouse', classes=0x80000008,
configuration='/system/usr/idc/Vendor_099a_Product_0500.idc', keyLayout='', keyCharacterMap='', builtinKeyboard=false, wakeMechanism=EVIOCSSUSPENDBLOCK, usingClockIoctl=true
Click to expand...
Click to collapse
After connecting keyboard: (I don't have an .idc file for the keyboard, there is no need for it)
I/EventHub( 656): New device: id=33, fd=173, path='/dev/input/event6', name='MEDION MD86853', classes=0x80000003,
configuration='',keyLayout='/system/usr/keylayout/Vendor_04e8_Product_7021.kl', keyCharacterMap='/system/usr/keychars/Vendor_04e8_Product_7021.kcm', builtinKeyboard=false, wakeMechanism=EVIOCSSUSPENDBLOCK, usingClockIoctl=true
Click to expand...
Click to collapse
Can I add some parameters to the .idc file that would force using a specific .kl file? I can't find any documentation for .idc files contect that would be more exensive - a list of possible variables/values would be nice, but I can't find it.
Try using this app: https://play.google.com/store/apps/details?id=com.tincore.and.keymapper&hl=en
@Ventricle have you found ansolution?
@Ventricle - did you find a solution for this? I am trying to move pointer with a gamepad X and Y axis. so far i couldn't do this. thanks.
No, sorry I couldn't do it with any known methods. It's hardcoded I guess - still possible to change, but would require more in-depth looking and then changing some files.
I've been using PhoenixOS and RemixOS recently and they have mouse right click and middle click sorted out. I'll look into the system files and maybe I can reproduce the method (I hope that's legal )
I know something about this but, only if somebody still need help.
Nickescd said:
I know something about this but, only if somebody still need help.
Click to expand...
Click to collapse
Hi, I need to change usb mouse right button from "back" fuction to "menu" is that possible? I am android 8.1 rooted, thanks
Nickescd said:
I know something about this but, only if somebody still need help.
Click to expand...
Click to collapse
Please, I've looked into this for months and there's literally nothing I can find to help me. I just want to be able to rebind right click and it's impossible.
I'm also looking for solutions. I've tried tincore, many other remappers, going into the .kl files directly.. I thought about making one but I don't know the vendor id and such for a Logitech m535. Also Phoenix is and remix os are old at this point and don't seem like there's been updates since about 2018.
This is the most accurate problem (which I am having) description and research on the internet.
Sadly no news I believe?
Of course if you only need to forward mouse to PC you can use virtualhere. Quite expensive piece of software 25$ with current 50% discount. And needs to purchase new one on new Android device
I am using latest PrimeOS Mainline in a quad boot system with a logitech K400r wireless keyboard/trackpad. I tried to change the right mouse button behavior but failed. I am writing what I learned/did before giving up as it might aid others with troubleshooting similar issues.
Problem:
Right mouse button clearly does not act as back button and it is really annoying if you are used to the default behaviour.
Right mouse button seems to be same as left mouse button (possibly long click lmb) unless right click on desktop icon and works as menu button. Looks like they try and make rmb like windows where you are supposed to get a context menu.
Troubleshooting Steps:
Make backup of PrimeOS partition (just in case).
Identify keyboard and get vendor and product id.
Code:
cat /sys/kernel/debug/usb/devices
I check the output and get vendor=046d product=c52b.
Now create custom files for my keyboard. Don't want to mess with generic files. Input device files are located in /system/usr on my device. Some devices use /vendor/usr or /odm/usr for these files. A rough idea for the search path order here https://source.android.com/devices/input/input-device-configuration-files. I am in terminal as root user and /system folder has RW access.
Code:
cd /system/usr/keylayout
cp Generic.kl Vendor_046d_Product_c52b.kl
chmod 644 Vendor_046d_Product_c52b.kl
cd /system/usr/keychars
cp Generic.kcm Vendor_046d_Product_c52b.kcm
chmod 644 Vendor_046d_Product_c52b.kcm
I examine the files and nothing in particular stands out as a problem. I compare files with files from another device where the keyboard works as expected, again nothing stands out.
I begin troubleshooting further. I identify input stream from keyboard.
Code:
getevent -p
From the list I find my keyboard interacts via /dev/input/event10.
Now I can view the scan codes for keyboard.
Code:
getevent -l /dev/input/event10
Right mouse button gives EV_MSC MSC_SCAN 00090002 and EV_KEY BTN_RIGHT. This seems normal. I do the same for working device and get same codes.
I try and add line 'key usage 0x090002 BACK' to .kl file in the 'keys defined by HID usages' section but this does not work (yes I rebooted after).
Conclusions:
Doesn't look like you can change right mouse button behavior using config files in this instance. Perhaps problem in kernel. AndroidX86 does not have this issue but doesn't have the great UI.
Might be able to mod /system/framework/hid.jar or /system/framework/input.jar perhaps.
PrimeOS should have provided an option in settings to change rmb behavior if they veered away from the default usage. I'll post on PrimeOS thread.
Use esc key instead
I know this thread is old, but did anyone find solution to this? Remapping mouse clicks is the only thing I can't remap as well. Quite frustrating! Any help is greatly appreciated. I'm rooted on LineageOS via Magisk on an Onn box (Android TV)

Software Development [XPOSED][INTEL][PX5] 4 Xposed modules to tweak your FYT based (Joying) unit

Currently there are 4 Xposed modules available for the FYT based Intel (Joying) Sofia 3GR Intel and (Joying) Rockchip PX5-A53 units.
GPSSpeedFix V1.12 (by lbdroid, not by me) (Changelog in post #3)
[*]XSofiaTweaker V1.26 (Global Xposed repository) DISCONTINUED
XFytTweaker V1.2.0 (Global Xposed repository)
SofiaServerNoKill V1.01 (Global Xposed repository)
SofiaServerCustomKeyMod V1.01 (Global Xposed repository) (Changelog in post #3)
All modules function on the Joying 6.0.1 stock ROMs (when rooted and with Xposed installed) or on the GTX custom ROMs (pre-rooted and pre-installed with Xposed)
Only the first module can *currently* be installed from my apk, as it is not my module. The other 3 my modules are avalaible on http://repo.xposed.info. The Xposed Installer on the unit can be used to install them.
GPSPeedFix: (stable)
This Xposed module is written by lbdroid. (lbdroids repository)
Since the Joying July 2017 ROMs, there is an error in the GPS Speed on the Sofia 3GR units. The GPS HAL in the Joying Sofia 3GR units uses integers instead of floats to calculate the meters/second. This give speed steps of 3.6 km/hr, or actually rounded to 3 or 4 km/hr steps. This Xposed module calculates the right GPS speed and feeds it back to the "system", so that all dependent apps like navigation apps or GPS trackers can use the correct speed. (require full reboot on installation/activation)
XFytTweaker: (Stable).
This is the successor module of the XSofiaServerTweaker, which on its turn was the successor of the SofiaServerCustommod (See Gustdens post).
The reason for the XFytTweaker was that actually any FYT based unit is running the same FYT/SYU software no matter whether it is an Intel Sofia or a Rockchip PX5. So after making the module suitable for Android 8.0.0, I changed the name.
captures the hardware keys from the Joying unit and allows you to reprogram them. This must/can be configured from the Settings (sub)screen.
allows you to switch on/off the nokill.
allows you to unmute channel 4, which is used for Google voice feedback.
can act on the ACC_ON, ACC_OFF and Resume events.
option to prevent the Bluetooth app from staying full screen on top (thanks to @gtxaspec)
option to prevent the CANbus overlays popping up on heat/airco change or door(s) opening
Option to run system calls as root (Know what you do!)
Option to display the CPU temperature in the status bar next to the time
option to disable the yellow MCU errors overlay (in case this happens to you) (thanks to @RoNeReR)
option to disable the overlay display of the volume bar on volume changes (the volume is always numerically displayed in the status bar)(thanks to @IG_Vasilich for pointing me to the right hook)
supports a usb dac where volume control will be rerouted to stock android volume control (thanks to @RoNeReR)
eliminates feedback during the call if you have OK Google anywhere enabled (thanks to @gtxaspec)
Translated into Spanish (tOz-666), German (mitchum67), Russian (gorlexx @ 4pda), Dutch. Help translate in your own language.
Big thanks to @gustden who analyzed which functions to hook (or directly mod in his case). Note that this module is extended with the EQ and Eject key (when applicable).
Below this post are some images attached from the XSofiaTweaker.
Changelog in post #3.
SofiaServerNoKill: (Stable)
This Xposed module skips the SofiaServer "kill all apps" when going to sleep. This should replace the old nokill mod from Gustden.
Note: Some apps prevent the unit from going into deep-sleep by setting a "wakelock". The old SofiaServer simply killed these apps. This module doesn't do that. The MCU detects the apps using the wakelock to keep the CPU awake and the MCU will completely switch off the unit, resulting in a cold-boot upon switching on the contact. That is not the fault of this module. It is the fault of these bad behaving apps.
Big thanks to @gustden who analyzed which functions to hook (or directly mod in his case)
SofiaServerCustomKeyMod: (Stable)
This is a direct "functionality" copy of Gustdens CustomKeymod, but then as an Xposed module.
This Xposed module captures the hardware keys from the Joying unit and allows you to reprogram them. This should replace the custom key mod from Gustden. It mimics the same behavior and therefore also needs a launcher.sh. In contradiction to the mods of Gustden, these Xposed modules do not touch the original SofiaServer binary and are therefore firmware version independent.
Big thanks to @gustden who analyzed which functions to hook (or directly mod in his case) and how to apply them in the launcher.sh script
XFytTweaker HowTo
(previously XSofiaTweaker)
Every button or event (acc_on/off) has a "Call method" and a "String to be used".
Currently there are 3 options to "start something" with the "Call method"
by package name
by intent (package name / intent)
by system call (terminal command(s) or script)
by package name: This is NOT the name of the apk but the internal package name. How do you get this "package name"?
Use the "List all Installed apps" option in the main screen of the settings. It shows the app icon, the app name and the package name. This package name is what you need. You can select it and copy & paste it into the field.
use the "Display my installed apps (with package name)" option from the JET apk from the top-left menu.
Search in play.google.com for the app you want to start. Say you want to start the navigation app "Magic Earth" and you have selected that one in the play store (in a browser, not the android app). In the address bar you will then see "https://play.google.com/store/apps/details?id=com.generalmagic.magicearth". The bold part behind the "id=" is your package name.
by intent: Every app has a "launch" intent to start the app. Some apps can also be started with other intents to immediately start a specific function. Google Search can be started with the launch intent, but you can also start it with the Google Voice search option intent. The Google (Search) package name is "com.google.android.googlequicksearchbox", the specific intent for google voice search is "com.google.android.googlequicksearchbox.VoiceSearchActivity". The combined "String to be used" is therefore "com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.VoiceSearchActivity".
Another example is the Joying Bluetooth apk having intents for the dialer (default launch), the call receiver, the bluetooth streaming, the pairing and a few more.
by system call: A system call can be a direct (linux) command or a shell script or a binary (to do something).
= Commands can be a single command as in:
"ls -l > /sdcard/some_file.txt" to capture a directory listing to a file
"input keyevent 3" => Go to the Home screen (of the default launcher)
"am start -a android.intent.action.MAIN -c android.intent.category.HOME" => Go to the Home screen (of the default launcher)
"input keyevent 127" => pause active media player (any media player)
"input key event 126" => (re)start last used media player.
"am start com.syu.radio/com.syu.radio.Launch" => Start the radio app with the default launch intent (or better use "by package name": com.syu.radio; Or use "by intent": com.syu.radio/com.syu.radio.Launch)
As you can see from the 2nd and 3rd example, there are multiple ways to do something.
From the 6th example you can see that you can start an app (the radio) from the command line with "am start <full intent>", or by package name, or by intent directly.
= A system call can also be a number of commands separated by a ";".
Say you want to pause the media player and switch of the leds, when switching of the contact (ACC_OFF event), you can use as "String to use"
Code:
input keyevent 127; echo -n "h" > /sys/fytver/colorled
Upon switching on your car, you might want to continue your media player and switch on your leds to green
Code:
input keyevent 126; echo -n "b" > /sys/fytver/colorled
Note that you need to separate the commands with a ";" (a semi-colon without the quotes). I have currently no idea how long the entire command can be but I assume some system standard like 255, or 1024 or 2048 or 32767 or 65535, but I advise to use a script anyway when it gets that long (see next point)
= A system call can also be a call to a shell script
Say you want to pause the active media player and switch off the leds (like the example above), you can also put these commands (and 2-200? more) in a script like:
Code:
#!/system/bin/sh
input keyevent 127
echo -n "h" > /sys/fytver/colorled
You copy that script to a location where you can give it the execute bit (necessary on linux), which means not the internal or any external sdcard, but for example /data. You need adb, a rooted terminal or a rooted file manager to do that. Give it the execute rights like "chmod 755 my_great_script.sh"
Multi-tap options (preferred method)
The XFytTweaker and previously the XSofiaTweaker (since v1.22) directly supports double-tap and triple-tap options for hardware and steering wheel buttons, thanks to @gtxaspec.
Simply assign a call option and call entry to the double-tap and triple-tap option. The default delay is 300 ms, but this is user configurable via the "tap delay" setting.
Using NoKill and experiencing cold boots
The NoKill module/option in XFytTweaker is NOT the cause of the cold boots! Bad behaving apps keeping the CPU awake by setting a "wake lock", thereby preventing the unit to go into deep-sleep, are the cause. They make the MCU shutdown the unit completely after about 20 minutes.
The original sofiaServer app simply kills everything, so no problem there.
Especially some GPS, tasker and media player apps are bad behaving apps holding a "wake lock".
You can completely, safely use the NoKill option, but you should find those bad behaving apps and get rid of them, or kill them on going into deep-sleep using the ACC_OFF event and start them again using the ACC_ON event.
To kill an app on going into deep-sleep and start it when coming out of deep-sleep, AND to pause any mediaplayer on going into deep sleep, you can for example use the ACC_OFF option with a "system call".
Code:
am force-stop com.waze; input keyevent 127
And in the ACC_ON command to restart waze (in this case) and restart any media player on coming out of deep sleep:
Code:
am start com.waze/.MainActivity; input keyevent 126
Multi-tap options (deprecated method)
The customkeymod from Gustden and my sofiaservercustomkeymod xposed module both use the launcher script that enables multi-tap options.
The XFytTweaker (previously XSofiaTweaker) does support that as well using a script approach by using a "by system call". But it is advised to use above mentioned method.
So lets say we want to capture the src/mode button and assign 3 apps to that by consecutive key-presses, and lets say we call our script "src_mode.sh"
Code:
#!/system/bin/sh
# Goto Home screen
home="input keyevent 3"
# my apps
app_no1="blah"
app_no2="blahblah"
app_no3="blahblahblah"
last=`cat /data/src_mode.cnt`
last=$((last+1))
case $last in
1)
echo $last > /data/src_mode.cnt
(sleep .7 && [ `cat /data/src_mode.cnt` = $last ] && echo 0 > /data/src_mode.cnt && ${app_no1} ) &
;;
2)
echo $last > /data/src_mode.cnt
(sleep .5 && [ `cat /data/src_mode.cnt` = $last ] && echo 0 > /data/src_mode.cnt && ${app_no2} ) &
;;
3)
echo 0 > /data/src_mode.cnt
${app_no3}
;;
*)
echo 0 > /data/src_mode.cnt
$home
;;
esac
;;
Save that script to /data as "src_mode.sh" (for example) and make it executable "chmod 755 src_mod.sh". Make the call method in the XFytTweaker "system call" and the string "/data/src_mod.sh"
Assign full launch intent calls to the ${app_no1} for your apps.
In case of google maps like
Code:
app_no1="am start com.google.android.apps.maps/com.google.android.maps.MapsActivity"
And use something more logical that "app_no1"
- Use an editor that can handle unix line ends/line feeds, so not notepad.
- Some of the "complaints" about the previous mods from gustden was the "delay". This was also caused by the multitap, as the scripts waits 0.7 seconds for the second tap, and 0.3 seconds for the 3rd tap. If you are a "fast tapper", you could reduce this to 0.5 and 0.3 (or 0.2) seconds.
(Will be further expanded)
Changelogs
Changelog GPSSpeedFix:
1.12 Fix int/float bug in GPSSpeedFix (thanks to IG_Vasilich)
1.11
Switch from 5 moving average samples to 3 moving average samples to improve responsiveness on speed changes. (note: 2 samples and 1 sample simply work worse)
Remove appcompat layer library. Size reduction from 1.3MB to 98KB.
1.1 fix bearing error (user jvdv): prevents the "jump all over the place and point into wrong direction" cursor when navigating.
1.0 first version
Changelog XFytTweaker:
(previously XSofiaTweaker)
Version 1.4.0, 18 August 2018
Created a small wiki on the repository. Added link as third option in "Information Screen"
Added option to disable the overlay display of the volume bar on volume changes (the volume is always numerically displayed in the status bar)(thanks to @IG_Vasilich for pointing me to the right hook)
Some more code cleanup
Version 1.3.0, 12 August 2018
Option to display all installed apps with their package name. This makes it easier to assign an app by its package name to a button.
major code clean up of all unused and/or incorrect, rubbish code.
Version 1.2.0, 11 August 2018, First version of follow up XFytTweaker
Functionally unchanged when compared with XSofiaTweaker 1.26
internal renaming
Major rewrite to make it work on Android 8.0.0.
Version 1.26, 19 May 2018. Final and last version of XSofiaTweaker
Improved mute function for USB DAC mode (RoNeReR)
Improved and correct hook for the EQ button (RoNeReR)
Re-enable EQ button in the preferences
Add double-tap and triple-tap also to EQ button
Version 1.24, 11 May 2018
Really fix mode_src button configuration this time
Version 1.23, 08 May 2018
Correct typos in mode_src button settingsFragment
re-enable debugging messages
Version 1.22, 05 May 2018
next/previous/playpause functions work (gtxaspec)
Make double-tap, triple-tap functionality for keys internal instead of via a script (gtxaspec)
Updated German translation (mitchum67)
Version 1.21, 14 April 2018
improved USB DAC functioning (thanks to RoNeReR)
Version 1.20, 7 April 2018
Added Russian translation (thanks to gorlexx @ 4pda)
Version 1.19, 3 April 2018
eliminates feedback during the call if you have OK Google anywhere enabled (gtxaspec)
Version 1.18, 2 April 2018
Now supports a usb dac where volume control will be rerouted to stock android volume control (thanks to RoNeReR)
Create separate (sub) settings screen for CAN bus settings as it might expand (and users without CAN bus can skip it)
Version 1.17, 29 March 2018
option to disable the yellow MCU errors overlay (in case this happens to you) (thanks to RoNeReR)
Version 1.16, 28 March 2018
Option to display the CPU temperature in the status bar next to the time (It reads all 4 cores and displays the highest core temperature)
Dialog box to immediately do a soft reboot for the options that need it (not yet for HOME/MUTE as they are combined options. I have to think about those)
Version 1.15, 25 March 2018
Updated Spanish translation (thanks to tOz-666)
Made separate Settings screen for hardware buttons and for Steering wheel buttons
Added option to execute "system calls" under normal or root access. root access is necessary if you want to kill an app (for example upon ACC_OFF)
Version 1.14, 18 March 2018
Added German translation (thanks to mitchum67)
Version 1.13, 14 March 2018
Added option to prevent Bluetooth phone app from staying "full screen on top" during a call (thanks to gtxaspec)
Options to prevent Canbus overlays from being displayed on changes in heating/airco, door(s) opening (slightly improved to v1.1).
Remove appcompat layer library. Size reduction from 1.4MB to 195KB.
Version 1.11
bugfix: bt_phone button function used wrong key to call action to be executed
functionally identical to 1.1
Version 1.1
Added Spanish translation (tOz666) and Dutch translation.
Added options to disable CANbus overlay on heating/airconditioning change or door opened (untested; no canbus)
Modified BT/phone button hook (gtxaspec)
1.0: First release
Looks like there has been great progress on these units with xposed, custom roms & twrp. I hope to get a chance to try it all out this week. Finally back home with access to my car
Great work guys!
gustden said:
Looks like there has been great progress on these units with xposed, custom roms & twrp. I hope to get a chance to try it all out this week. Finally back home with access to my car
Great work guys!
Click to expand...
Click to collapse
Great to see you back!
When you say "finally back home" I hope your health is OK and that it's not your health that kept you away from home (and here) so long.
And yes, I finally picked up java.
Hey @surfer63, great work on this! Quick question, if I want to initiate the Google voice search, that intent do I use for com.google.android.search?
bogdi1988 said:
Hey @surfer63, great work on this! Quick question, if I want to initiate the Google voice search, that intent do I use for com.google.android.search?
Click to expand...
Click to collapse
For the customkeymod with launcher.sh "am start com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.VoiceSearchActivity"
For the XSofiaTweaker:
Use the "by intent (package name / intent)" with string "com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.VoiceSearchActivity"
Alternative 1, but some milliseconds slower: "by broadcast" with string "com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.VoiceSearchActivity"
Alternative 2, but some more miliseconds slower: "system call" with "am start com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.VoiceSearchActivity".
Somehow the "update on change" in the XSofiaTweaker does not work correctly (yet). It requires a soft boot from the Xposed installer (main page, "triple dot menu", soft boot")
surfer63 said:
For the customkeymod with launcher.sh "am start com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.VoiceSearchActivity"
For the XSofiaTweaker:
Use the "by intent (package name / intent)" with string "com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.VoiceSearchActivity"
Alternative 1, but some milliseconds slower: "by broadcast" with string "com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.VoiceSearchActivity"
Alternative 2, but some more miliseconds slower: "system call" with "am start com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.VoiceSearchActivity".
Somehow the "update on change" does not work correctly (yet). It requires a soft boot from the Xposed installer (main page, "triple dot menu", soft boot")
Click to expand...
Click to collapse
Thanks! I will give this a try in the morning! Last question, does the V5 rom include the Sofia no kill fix? Figured you'd know the answer to that
bogdi1988 said:
Thanks! I will give this a try in the morning! Last question, does the V5 rom include the Sofia no kill fix? Figured you'd know the answer to that
Click to expand...
Click to collapse
No, it does not. You can currently install it from my apk, or use the Xposed Installer on the ROM (preferred) as the NoKill and Customkeymod are already there.
Note: you mention the "Sofia no kill fix". The GPSSpeedFix is fixed, not the NoKill.
That fixed GPSSpeedFix is not in the V5, and due to the fact that it is installed as a system app, you currently need to install it via adb or a rooted file manager.
You can temporarily download the "fixed" GPSSpeedFix from here.
It contains the fix and uses 3 samples instead of 5. This should reduce the lag somewhat.
Edit: My new apk will support the system/app install from the gpsspeedfix.
surfer63 said:
No, it does not. You can currently install it from my apk, or use the Xposed Installer on the ROM (preferred) as the NoKill and Customkeymod are already there.
Note: you mention the "Sofia no kill fix". The GPSSpeedFix is fixed, not the NoKill.
That one is not in the V5, and due to the fact that it is installed as a system app, you currently need to install it via adb or a rooted file manager.
You can temporarily download the "fixed" GPSSpeedFix from here.
It contains the fix and uses 3 samples instead of 5. This should reduce the lag somewhat.
Edit: My new apk will support the system/app install from the gpsspeedfix.
Click to expand...
Click to collapse
Awesome! And yes, the server no kill fix. The other I updated manually - Total Commander to the rescue! I tear with nostalgia each time I use it! ???
surfer63 said:
Somehow the "update on change" in the XSofiaTweaker does not work correctly (yet). It requires a soft boot from the Xposed installer (main page, "triple dot menu", soft boot")
Click to expand...
Click to collapse
I found why it does not get updated. I use a broadcast to update (from the example), but I do not have a broadcast receiver. So now find a new example to implement that broadcast receiver
I tried installing Xposed on my rooted Joying Sofia JY-VL130N2 and ended up with a brick (stuck in Android boot logo).
My steps were:
1) Downloaded and installed XposedInstaller_3.1.5.apk from the official XDA page https://forum.xda-developers.com/showthread.php?t=3034811
2) Installed some "v89" thing (sorry, I am a newbie to Xposed)
3) Accepted the dialog which warns about soft-bricks and the app restarted the unit
4) Not starting up anymore. Stuck in Android's boot logo after its animations had played.
What was wrong?
EDIT by myself: I did not use the Superuser apk for Sofia as documented by you. Sorry for the noise.
realzoulou said:
I tried installing Xposed on my rooted Joying Sofia JY-VL130N2 and ended up with a brick (stuck in Android boot logo).
My steps were:
1) Downloaded and installed XposedInstaller_3.1.5.apk from the official XDA page https://forum.xda-developers.com/showthread.php?t=3034811
2) Installed some "v89" thing (sorry, I am a newbie to Xposed)
3) Accepted the dialog which warns about soft-bricks and the app restarted the unit
4) Not starting up anymore. Stuck in Android's boot logo after its animations had played.
What was wrong?
Click to expand...
Click to collapse
Need to reflash the unit.
@surfer63 when I try to download and install package in Xposed installer I get an error that package name is incorrect
bogdi1988 said:
@surfer63 when I try to download and install package in Xposed installer I get an error that package name is incorrect
Click to expand...
Click to collapse
Please be a bit more concrete.
Any package or "my" modules?
Did you already had the NoKill and/or CustomKeymod installed via my apk?
If so , first uninstall them as they are signed differently by the repo.
If it is a "fresh" install, then it is weird.
surfer63 said:
Please be a bit more concrete.
Any package or "my" modules?
Did you already had the NoKill and/or CustomKeymod installed via my apk?
If so , first uninstall them as they are signed differently by the repo.
If it is a "fresh" install, then it is weird.
Click to expand...
Click to collapse
Fresh install I even tried clearing Xposed app data/cache and same issue. Downloads like 71kb and then errors out that package name is incorrect and that a different name was expected.
EDIT: I was also driving when I posted that, so I had to be short :silly:
bogdi1988 said:
Fresh install I even tried clearing Xposed app data/cache and same issue. Downloads like 71kb and then errors out that package name is incorrect and that a different name was expected.
EDIT: I was also driving when I posted that, so I had to be short :silly:
Click to expand...
Click to collapse
I did not even try if it worked. I simply assumed that the global repository would simply work.
Will test tomorrow.
surfer63 said:
I did not even try if it worked. I simply assumed that the global repository would simply work.
Will test tomorrow.
Click to expand...
Click to collapse
How do I manually install the module?
bogdi1988 said:
How do I manually install the module?
Click to expand...
Click to collapse
manually via adb or a rooted file manager.
You can also install the latest nokill and customkeymod from my apk.
Probably this evening I will release my new JET apk also allowing you to overwrite/install the current, as system app installed, GPSSpeedFix in the gtx ROM.
And I will add my XSofiaTweaker to the apk. I need to do some final tests this afternoon.
I had done it wrong with my modules on the xposed repo, but I corrected that and they still give errors. Customkeymod still gives a package error.
The Nokill gives a 404 error and can't be downloaded. I really don't understand it.
if I install the Xposed modules with the version 40, I find you in Xposed not. with version 39 this worked. I use the GTX Rom.
greeting

Categories

Resources