FORUMS
Remove All Ads from XDA

Joying 2GB - Steering wheel key customization - V6 (NO KILL)

366 posts
Thanks Meter: 322
 
By gustden, Senior Member on 23rd January 2017, 03:54 AM
Post Reply Email Thread
THIS MOD IS ONLY FOR THE JOYING / 2GB / Sofia models - It is stable and working well .

Please use V4.1 if you have not upgraded to Marshmallow!

History:

V6.4: Update using code base 9/1/2017 Joying Update ( Android 6.0 ) (updated Oct 7)
Changes:
- Meida keys - Removed support for media keys customization. No longer sent to launcher.sh due to slow response time.
- Media keys - Modified code to only send media keys to the active media player.
- Changed reboot timer from 1/2 second to 2 seconds. Should help eliminate random reboots when coming from standby.
- Updated player_app.txt and navi_app.txt to latest from @surfer63
- Fixed issue with button 33 not working

- Files included:
- V6.4-Sofia-1-C9-Server_NOKILL.zip - Original file with task killer removed
- V6.4-Sofia-1-C9-Server_NOKILL_GVS.zip - Task killer removed, Google Voice Search on 'SRC' key
- V6.4-Custom_Keys-Mods.zip - Complete key modifications ( requires launcher.sh - description below )


V6.3: Update using code base 5/25/2017 Joying Update ( Android 6.0 )
- Files included:
- V6.3-Sofia-1-C9-Server_NOKILL.zip - Original file with task killer removed
- V6.3-Sofia-1-C9-Server_NOKILL_GVS.zip - Task killer removed, Google Voice Search on 'SRC' key
- V6.3-Custom_Keys-Mods.zip - Complete key modifications ( requires launcher.sh - description below )

V6.2: Updated using code base 5/8/2017 Joying Update ( Android 6.0 )
- Added fix for google maps voice output on radio from @xdamember2

V6.1: Updated code base using 5/8/2017 Joying Update ( Android 6.0 )

V6: Updated code base using 4/27/2017 Joying Update ( Android 6.0 )

Android 5.1.1
V4.1 - Fixed issue with "Google Voice Search" not lowering music volume (3/23/2017) - Android 5.1.1
V4: Updated code base using 3/14/2017 Joying ROM
Changes/Added support for:
- MEDIA KEY - hard key on unit
- BAND KEY - hard key on unit
- ACC_ON - Triggers on key on
- Minor changes to example shell scripts to add cases for MEDIA, BAND, ACC_ON ( launcher.sh )
- FIX/UPDATE - Updated list of NAVI APPS in assets/property/navi_app.txt ( allows more applications to speak during radio )
- Many thanks to @surfer63 for navi app radio fix and windows install script

V3 - Rebuilt using latest Joying ROM dated 2/22/2017 - Includes V1 & V2 steering wheel / key modifications.
Changes/Added support for:
- ACC_OFF - Added support for running actions at key off (case 98 )
- Added case 98 to example scripts to perform "PAUSE" - to stop current music player when key off

V2 Removed killAppWhenSleep(); - Eliminates tasks being killed on sleep
Added support for additional keys / Minor changes to example shell script ( launcher.sh )
- HANG - steering wheel softkey
- DVD - hard key on unit (if available)
- EJECT- hard key on unit (if available)
- CALL/BT softkey - Fixed issue where key would not respond after call disconnect.

V1 Initial version
There is little risk with this mod, but please understand what you are doing, and make backup of the original apk file ( in case you want to revert back ). The installer script does make a backup, but will overwrite the backup if installed more than once.

I also added a simpler "launcher_simple.sh" into the zip, which only changes the functionality of the Source (rotates radio, pandora, spotify ) and Call buttons ( google voice command ). These scripts are working examples of what can be done. If you want the simpler version, just rename "launcher_simple.sh" to "launcher.sh" before installing.

---------------------- Original Post -----------------
I have spent quite a bit of time working on being able to customize the steering wheel keys of my Joying 2GB headunit (JY-UL135N2 / 2GB / Sofia unit). I have made some good progress and thought I would share what I have done so far.

The system package /system/app/Sofia-1-C9-Server-V1.0/Sofia-1-C9-Server-V1.0.apk has been modified to intercept the keys sent by the MCU, and thus able to change the behavior of the key presses. The keys listed below are supported, and will launch a "shell" process, so any action that can be done by the command line can be performed. If your not familiar with the Android command line, you might be surprised how powerful it is. As a side note, this works very fast and efficient. From my testing the overhead of the system call and shell script is almost non-existent, and key presses are registered with no delay. In other words, it is working very nicely.

In addition to the steering wheel button mods, also provided is the ability to launch a command or series of commands when a RESUME is received.

Included is my shell script (example) that can be used as a model for your own customization. The example script included performs the following actions:

CALL/BT PHONE(27) - One press is HOME, 2 presses is BACK, 3 presses brings up Google Voice Commands

MODE/SRC(37) - Rotates through music apps: Radio, Pandora, Spotify, Stock Music App - If it has been longer than 1 minute since the last press it will return you to the last selected music app with first press, then continue with the rotation. ( I'm working on a more intelligent way of doing this, that looks at the process list and will post soon)

NAVI(9) - One press is Torque, 2 presses is google maps

PAUSE/PLAY(85*),NEXT(87*), PREVIOUS(88*), FASTBACK(89*), FASTFWD(90*),HOME(3), BACK(4) - Currently set to perform stock functions. They ARE passed to script so they can be assigned other functions if wanted.

ACC_ON(97) - Executes at ignition switch on. Sample script has a 'play' here to restart music player that was paused at key off.

ACC_OFF(98) - Executes at ignition switch off. I suggest you assign "pause" on this case, to stop current music player. Resolves issue of music player advancing for several minutes after key is turned off.

RESUME(99) - Executes on system resume.

Please note the media control keys marked with a (*) are hardcoded to specific functions within the stock Joying applications. They are only passed through to the shell script when you are NOT using a Joying media application. They will ONLY work as the original keys when you are within the Joying media applications.

Remember, the apk is just handing codes to you, what you do with them after that is up to you! I have tried to comment the example script enough to be understandable to someone with basic programming knowledge.

Attached is a zip file with the updated Sofia-1-C9-Server-V1.0.apk, launcher.sh ( my example script), and install script. The launcher.sh script must be placed in the /data directory ( /data/launcher.sh ), as it is hardcoded in the apk file.

The install script is a shell/linux script, but you can easily copy/paste the adb commands if your using windows.

[NOTE: Please update to the latest version of busybox! I found some bugs in the version included by Joying that caused several issues.]
The Following 24 Users Say Thank You to gustden For This Useful Post: [ View ] Gift gustden Ad-Free
 
 
23rd January 2017, 04:05 AM |#2  
Senior Member
Thanks Meter: 80
 
More
Awesome work. I will mess with this sometime this week. I still need to root my unit. Just installed it last week.

Sent from my SAMSUNG-SM-G935A using Tapatalk
23rd January 2017, 11:12 AM |#3  
Senior Member
Thanks Meter: 43
 
More
Excellent work, sir! Before I start modifying the script for personal taste, could you help how to find key number for DVD and Eject buttons that currently have no function as the DVD drive is non-existent? Maybe logcat or something?
23rd January 2017, 01:33 PM |#4  
OP Senior Member
Flag Chicago
Thanks Meter: 322
 
More
Quote:
Originally Posted by sonof

Excellent work, sir! Before I start modifying the script for personal taste, could you help how to find key number for DVD and Eject buttons that currently have no function as the DVD drive is non-existent? Maybe logcat or something?

I see a few references in the code for the DVD/eject button in the common code. My 'best guess' would be to add a system call to the cases listed below, but I seriously doubt the MCU would even send the codes if there is no DVD present.

bsp/FinalBsp.java
public static final int KEY_CODE_DVD = 242;
public static final int KEY_CODE_EJECT = 231;

bsp/HandlerBspKey.java
public static void keyEvent(int paramInt1, int paramInt2)
case 242:
bspKeyDvd(paramInt2);
return;
case 231:
bspKeyEject(paramInt2);
return;
The Following 3 Users Say Thank You to gustden For This Useful Post: [ View ] Gift gustden Ad-Free
23rd January 2017, 01:54 PM |#5  
Senior Member
Thanks Meter: 43
 
More
Quote:
Originally Posted by gustden

I see a few references in the code for the DVD/eject button in the common code. My 'best guess' would be to add a system call to the cases listed below, but I seriously doubt the MCU would even send the codes if there is no DVD present.

bsp/FinalBsp.java
public static final int KEY_CODE_DVD = 242;
public static final int KEY_CODE_EJECT = 231;

bsp/HandlerBspKey.java
public static void keyEvent(int paramInt1, int paramInt2)
case 242:
bspKeyDvd(paramInt2);
return;
case 231:
bspKeyEject(paramInt2);
return;

Seems that MCU does send the codes as seen here.

I will see what I can do but I doubt I am able to do anything as I just installed apktool the first time today and am new with apk's. Thanks for your efforts! Very appreciated.
24th January 2017, 05:11 AM |#6  
OP Senior Member
Flag Chicago
Thanks Meter: 322
 
More
Quote:
Originally Posted by sonof

Excellent work, sir! Before I start modifying the script for personal taste, could you help how to find key number for DVD and Eject buttons that currently have no function as the DVD drive is non-existent? Maybe logcat or something?

Quote:
Originally Posted by sonof

Seems that MCU does send the codes as seen here.

I will see what I can do but I doubt I am able to do anything as I just installed apktool the first time today and am new with apk's. Thanks for your efforts! Very appreciated.

If I create and send you a apk file with additional debug statements, would you be able to install it, and capture the 'logcat' of the buttons being pressed? It makes it much more difficult since I don't have the DVD buttons. Hacking smali code is a LOT of trial and errors. Their code is quite complex, and doesn't decompile into Java very nicely in some critical areas.
The Following 2 Users Say Thank You to gustden For This Useful Post: [ View ] Gift gustden Ad-Free
24th January 2017, 06:42 AM |#7  
Senior Member
Thanks Meter: 43
 
More
Quote:
Originally Posted by gustden

If I create and send you a apk file with additional debug statements, would you be able to install it, and capture the 'logcat' of the buttons being pressed? It makes it much more difficult since I don't have the DVD buttons. Hacking smali code is a LOT of trial and errors. Their code is quite complex, and doesn't decompile into Java very nicely in some critical areas.

Yes I am capable of doing that!
27th January 2017, 12:46 PM |#8  
OP Senior Member
Flag Chicago
Thanks Meter: 322
 
More
Quote:
Originally Posted by sonof

Excellent work, sir! Before I start modifying the script for personal taste, could you help how to find key number for DVD and Eject buttons that currently have no function as the DVD drive is non-existent? Maybe logcat or something?

Quote:
Originally Posted by sonof

Yes I am capable of doing that!

I put in debugging code that parses the data stream from the MCU and dumps the first 4 bytes of EVERY message that is received from the MCU (skipping checksum info). Simply replace the original file (make a copy first ) and reboot. When looking for the keys, I suggest you do not use the radio, as it sends a constant flood of messages, such as RDS updates.

Even when the radio is off, there are still messages constantly being sent. If you filter on the debug messages MCUKEY in adb, and press the button in question a few times quickly, you should see a consistent pattern. I was able to identify the 'HANG' key in a couple minutes using this method. You should see something like this in the logcat:

D/MCUKEY ( 693): MCUKEYINPUT: B1=1 B2=0 B2=5 B2=224
D/MCUKEY ( 693): MCUKEYINPUT: B1=1 B2=7 B2=16 B2=0
D/MCUKEY ( 693): MCUKEYINPUT: B1=1 B2=0 B2=0 B2=49
D/MCUKEY ( 693): MCUKEYINPUT: B1=1 B2=7 B2=16 B2=0
D/MCUKEY ( 693): MCUKEYINPUT: B1=1 B2=3 B2=34 B2=0

In this case the HANG key is in bold ( 1, 7, 16, 0 ) messages. IF the DVD and eject keys are sent, they should definitely show up here. Not every key is sent by the MCU, if it is not relevant to the current state of the system. For example the media buttons are not sent when the radio is on, since the MCU is in control of the radio, however it does send the results such as a frequency change resulting from the button press.

It is possible that the MCU knows there is no DVD present and suppresses the messages. From looking at the code, it may be the action of a disc being ejected that is sent from the MCU, with the eject button press handled internally by the MCU. Your more likely to find the press of the DVD button than the eject button, but may find both.

When your done searching, you want to put back the original file and reboot. If you find the codes, I can certainly add them to trigger the shell script and you can take whatever action you want with them.
Attached Files
File Type: apk Sofia-1-C9-Server-V1.0_DEBUG.apk - [Click for QR Code] (1.22 MB, 116 views)
The Following 3 Users Say Thank You to gustden For This Useful Post: [ View ] Gift gustden Ad-Free
27th January 2017, 01:49 PM |#9  
Senior Member
Thanks Meter: 43
 
More
Thank you! I will try this the first thing next week when I get back home from a weekend trip.
29th January 2017, 02:13 PM |#10  
Senior Member
Flag Moscow
Thanks Meter: 34
 
More
Question: if I remove a customization from the script file for a key, the key should then perform its default functions, correct?
29th January 2017, 09:38 PM |#11  
OP Senior Member
Flag Chicago
Thanks Meter: 322
 
More
Quote:
Originally Posted by vassandrei

Question: if I remove a customization from the script file for a key, the key should then perform its default functions, correct?

The keys being passed to the shell script (launcher.sh) is hard-coded in the APK file and is just sent to the script. If you remove it from the script, the key would no longer do anything.

If you want to keep the stock functionality of a specific button, it should be fairly easy to duplicate it in the shell script. For example:

BT/CALL button: "am start com.syu.bt/com.syu.bt.BtAct"
NAVI: By default, I think NAVI just toggles between a Navi app, and the previous activity on the stack.

The code below should behave the same as the original for both the NAVI an BTPHONE buttons ( assuming your using google maps )
Code:
case $key in
        9) # NAVI
              x=`dumpsys activity activities | grep "Run #"  | cut -f 13 -d" "| head -1 | grep maps`
        if  [ "$x" =  ""  ]
        then      
                $maps                     
        else
                am start `dumpsys activity activities | grep "Run #"  | cut -f 13 -d" " | grep -v launcher | grep -v systemui | grep -v maps |head -1`
           fi
        ;;            
        27) # BTPHONE/PTT                                                              
            am start com.syu.bt/com.syu.bt.BtAct
        ;;
Play/Pause: you can just remove the 85 case, it would just hit the default case and pass "input keyevent 85" which is identical in functionality.
The Following 3 Users Say Thank You to gustden For This Useful Post: [ View ] Gift gustden Ad-Free
Post Reply Subscribe to Thread

Tags
2gb, headunit, joying, steering wheel controls

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes