Tesla style headunit steering wheel key mod - Android Head-Units

Hi everyone,
I recently caved and bought one of the tesla style PX6 headunits from ali-express.
While the unit seems nice, it is unfortunately NOT an MTC head unit and so the mods that I had for my previous headunits do not work-- including the various steering wheel key mods out there.
As a result I started working on my own and have made quite a bit of progress, but I just need some help getting to the finish line.
Problem: factory steering wheel control app only allows for very limited actions in response to key presses.
Required end result: a user-customizable method of capturing steering wheel key presses and translating them into actions in android.
Current process in factory system: (fairly similar to the MTC headunits)
Key pressed on steering wheel ---> resistance value changes>>>MCU picks up this value and sends serial data to tablet--->App named "Eventcenter.apk" (com.szchoiceway.eventcenter) ---->protected method called startprocessCmdThread (runs on a loop and waits for serial data)----->private processCmd which then reads the serial data and determines (amongst other things) if it is a steering wheel command event---->private onCmdWheelEvent method which puts the byte data in an intent with action "com.choiceway.eventcenter.EventUtils.STEER_WHEEL_INFOR"
in the extras "EventUtils.STEER_WHEEL_INFOR_WPARAM" and "EventUtils.STEER_WHEEL_INFOR_LARAM"
where LPARAM is the actual byte data and wparam is either 4 or 3 (likely keydown vs key up event)
It then broadcasts this intent with permission: com.szchoiceway.permission.broadcast
This intent is picked up by the relevant "choiceway" app like for example the navisettings app which registers a receiver for this intent when you're in the steering wheel study activity and assigns the steering wheel key to one of very limited, pre-defined actions.
While listening for this intent would have been ideal to be able to assign your own actions to steering wheel key presses, unfortunately, the presence of a declared permission makes it impossible to do so without declaring this same permission in your app manifest. And since android 5.0, two apps cannot declare the same permission in their manifest unless they share the same signature.
As a result, in the process above the only solution i can see is either
1) we modify the relevant system apps to NOT require that permission when broadcasting an intent
or
2) create an xposed (or magisk?) module which hooks into the method calls above to capture the direct byte data being put into the intent extras and broadcast it's own intent/perform our desired system actions.
or
3) something else I haven't thought of
I have been trying to do this but have not been able to compile/sign any of the above mentioned apps after making my modifications.
I know xposed modules can do what i'm looking for but since this tablet runs android 9.0, it would have to use edxposed which i'm not as familiar with. Does anyone know if using edxposed is capable of hooking into the above method calls?
Alternatively can magisk modules hook into this method? I've never written a magisk module before so i'm not sure what the capabilities are.
Are there any other solutions you guys can think off in this process to getting this working?
thanks!

So far I've been using tasker Logcat to listen for the 'iCan key' events. I have been able to toggle play/pause on mute and my now useless onstar button opens google assistant in Headunit Reloaded. I would like to re-map the source/mode button to NOT switch to the FM radio since I never use it. I didn't even think to look at the eventcenter apk, have you had any further luck in the last year?

Related

Referencing Sub-Components of Custom Compound Controls

I have just figured out how to create my own custom compound controls. Now I am wondering how I go about accessing the subcomponents in my main activity.
For example, I created a dial pad compound control that consists of a TextView and 12 buttons (1,2,3,4,5,6,7,8,8,*,0,#)
now if I add this to my main.xml as
Code:
<net.iamcorbin.dialpad.DialPadView android:id="@+id/dialpad"
...
/>
how would I go about addressing the TextView inside of the DialPadView so I can get it's current value or change it?
[SOLVED]
Nevermind, answered my own question again...
The custom controls are automatically inflated out so you have all the components available to you in the usual findViewById() fashion.

[Q] HW Button, Finger Gesture, Bluetooth & input panel for HTC HD2

Help...!! I'm new with WM developing,
There are 4 questions I'm about to ask about HTC HD2 using WM6.5:
1. How to disable hardware function and handle their event 'on press' for every HW button (such as Home, Window, Talk, End and Back button)?
So far, I just able to disable it using :
[DllImport("coredll.dll")]
private static extern bool UnregisterFunc1(KeyModifiers modifiers, int keyID);
[DllImport("coredll.dll", SetLastError = true)]
public static extern bool RegisterHotKey(IntPtr hWnd, // handle to window
int id, // hot key identifier
KeyModifiers Modifiers, // key-modifier options
int key //virtual-key code
);
Buttons that I can successfully disable are Volume Up, Volume Down, Back, and Talk.
There is no way I can handle or disable Windows, Home and end button.
I have a trick by disable Window button:
IntPtr hTaskBar = FindWindow("HHTaskBar", null);
EnableWindow(hTaskBar, false);
But when I try to lock and unlock the screen using end button, Window button function will not disable anymore.
So far, some forums mention about SHCMBM_OVERRIDEKEY and handle the message by using Microsoft.WindowsCE.Forms.MessageWindow,
and again I still don't know how to attach MessageWindow to my foreground application
2. I'd like if my panel finger gesture behavior works as well as ListView or DataGrid. So, I found a library that can help me.
code.msdn.microsoft.com/gestureswm/Release/ProjectReleases.aspx?ReleaseId=3146
Unfortunatelly, it makes my controls in panel flicker badly. Do you have any other alternative?
3. To handle bluetooth, I'm using
[DllImport("BthUtil.dll")]
public static extern int BthGetMode(out BluetoothMode dwMode);
[DllImport("BthUtil.dll")]
public static extern int BthSetMode(BluetoothMode dwMode);
and InTheHand.Net Library to send data.
But since I'm starting with this device, I even cannot deactive the Bluetooth.
Can you help me with this Bluetooth control and data communication?
4. Since I'm using virtual keyboard as my input, How to define what kind of input panel it will show?
For Example, if my Textbox1 is focused, I have to show Numeric Keypad.
But if Textbox2 is focused, I have to show Qwerty keyboard.
Thank you very much.
PS : I'm using C# for developing the application. It'll be very good if you give me a C# example for those questions.
I know this is a few months old, and I don't wanna ressurect it per-say - and i'm not farmiliar with the rules as it relates to posting on these forums, but i've been viewing them forever, and as a member for a few months at least, and i've got to say that disabling the END key is a must for the HTC HD2, especially for Android NAND. At present with my phone, and thousands of others, everytime we press the END button, the screen stops being responsive. Funny thing is, if i NEVER press the end button, my screen works great. I end calls using the screen, and i've installed 'Button Saviour' from the market to use the 'END' button virtually on-screen, and I wake the phone using any of the other 4 buttons, save for 'END', and i get no problems. It's the Damned signal sent to the screen from the END button that causes the screen to disable and never re-enable the digitizer - I am just supposing these things, I'm in no way or shape a developer... Just something to think about?
This could be the end to thousands of HTC HD2 end user issues relating to lockscreen lock up in Android or otherwise...

Z1C and Tasker automation

Thought I would create a thread to discuss Tasker automation on the Z1C (help requests, troubleshooting, automation ideas, etc.)
First a help request:
Has anyone been successful in getting AutoInput or Sendevent shell commands (double taps, swipes) to work on the Z1C?
I've used this script in the past to record events and replicate them to create macros using Tasker shell, but the Z1C input devices (touchscreen, buttons) don't seem to be allowing capture using getevent:
http://forum.xda-developers.com/showthread.php?t=2233865
wernyuen said:
Thought I would create a thread to discuss Tasker automation on the Z1C (help requests, troubleshooting, automation ideas, etc.)
First a help request:
Has anyone been successful in getting AutoInput or Sendevent shell commands (double taps, swipes) to work on the Z1C?
I've used this script in the past to record events and replicate them to create macros using Tasker shell, but the Z1C input devices (touchscreen, buttons) don't seem to be allowing capture using getevent:
http://forum.xda-developers.com/showthread.php?t=2233865
Click to expand...
Click to collapse
Edit: always execute as root!!!!
task Swipe:
Script
execute Shell
input swipe x1 y1 x2 y2 speed
like:
input swipe 310 870 310 320 200
keyevents:
http://developer.android.com/reference/android/view/KeyEvent.html
like
power on/off
input keyevent 26 or
input keyevent KEYCODE_POWER
pause between actions:
sleep 1
sleep 2 etc.
tap:
input tap x y
start app:
am start -n app.name.name/ManifestActivity
close app:
am force-stop app.name.name
complete action screen on, unlock, start spotify, autoplay, screen off
am start -n com.spotify.music/.MainActivity;
sleep 2;
input keyevent 26;
sleep 1;
input swipe 310 870 310 320 200;
sleep 1;
input keyevent 126;
sleep 1;
input keyevent 26;
i hope it help
Maetz3 said:
Edit: always execute as root!!!!
task Swipe:
Script
execute Shell
input swipe x1 y1 x2 y2 speed
like:
input swipe 310 870 310 320 200
keyevents:
http://developer.android.com/reference/android/view/KeyEvent.html
like
power on/off
input keyevent 26 or
input keyevent KEYCODE_POWER
pause between actions:
sleep 1
sleep 2 etc.
tap:
input tap x y
start app:
am start -n app.name.name/ManifestActivity
close app:
am force-stop app.name.name
complete action screen on, unlock, start spotify, autoplay, screen off
am start -n com.spotify.music/.MainActivity;
sleep 2;
input keyevent 26;
sleep 1;
input swipe 310 870 310 320 200;
sleep 1;
input keyevent 126;
sleep 1;
input keyevent 26;
i hope it help
Click to expand...
Click to collapse
thanks! very helpful.
what about multi-touch or pinch-to-zoom? have not been able to find solutions that have bridged that online
double tap also seems to be a challenge for the Z1C, somehow even without sleep in between two "input taps" it is still too slow to be recognized as a double tap
wernyuen said:
thanks! very helpful.
what about multi-touch or pinch-to-zoom? have not been able to find solutions that have bridged that online
double tap also seems to be a challenge for the Z1C, somehow even without sleep in between two "input taps" it is still too slow to be recognized as a double tap
Click to expand...
Click to collapse
i dont know but i think you need something like nova launcher
i think you can combine this controls in tasker
for zoom you can use:
KEYCODE_ZOOM_IN (input keyevent 168)
KEYCODE_ZOOM_OUT (input keyevent 169)
Maetz3 said:
i dont know but i think you need something like nova launcher
i think you can combine this controls in tasker
for zoom you can use:
KEYCODE_ZOOM_IN (input keyevent 168)
KEYCODE_ZOOM_OUT (input keyevent 169)
Click to expand...
Click to collapse
Thanks ... tried the ZOOM_IN/OUT keyevents, but I think that is for the camera, I'm trying to implement this on Google Maps and Maps Engine, since they removed the Zoom and Scaling buttons on the official Google apps it's been a pain (and driving hazard) to manually zoom in and out with touchscreen input. (trying to map the zoom actions to my media controls on the steering wheel)
Hi all,
Let me start with an apology as I am not sure that I am in the right thread here, however tasker automation does seem to have alot of threads - I am confident that someone who knows more than me might be able to answer my questions/problems.
I am currently trying to automate a search in youtube using autovoice and autoinput. Via voice command so far I can get autoinput to launch youtube, and click the search bar, however I cant get it to input any text into the search bar! - So I really need to know, how to get autoinput to input variable text and search for it within youtube, not even sure which function of autoinput it would be to be honest.
Still learning.
Any help you can give would be fantastic,
Cheers
Dan
If what you want to achieve is to search YouTube, there are easier ways:
1. Simply ask Google Now to search or YouTube using the "watch" or "listen" command; or
2. Use an intent in Tasker to activate YouTube search with the search term %avcommnofilter (rather than try to use autoinput)
If you really must use autoinput, you can use the UI query action to find the right variable name for the search box, then use the 'autoinput action' action to paste your search term (%avcommnofilter) into the search box
dan34321 said:
Hi all,
Let me start with an apology as I am not sure that I am in the right thread here, however tasker automation does seem to have alot of threads - I am confident that someone who knows more than me might be able to answer my questions/problems.
I am currently trying to automate a search in youtube using autovoice and autoinput. Via voice command so far I can get autoinput to launch youtube, and click the search bar, however I cant get it to input any text into the search bar! - So I really need to know, how to get autoinput to input variable text and search for it within youtube, not even sure which function of autoinput it would be to be honest.
Still learning.
Any help you can give would be fantastic,
Cheers
Dan
Click to expand...
Click to collapse
I have a slightly different question how to make a script turning stamina mode on and off? It would be usefull because stamina sometimes prevents alarm apps from ringing in time.

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

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.]
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
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?
sonof said:
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?
Click to expand...
Click to collapse
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;
gustden said:
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;
Click to expand...
Click to collapse
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.
sonof said:
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?
Click to expand...
Click to collapse
sonof said:
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.
Click to expand...
Click to collapse
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.
gustden said:
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.
Click to expand...
Click to collapse
Yes I am capable of doing that!
sonof said:
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?
Click to expand...
Click to collapse
sonof said:
Yes I am capable of doing that!
Click to expand...
Click to collapse
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.
Thank you! I will try this the first thing next week when I get back home from a weekend trip.
Question: if I remove a customization from the script file for a key, the key should then perform its default functions, correct?
vassandrei said:
Question: if I remove a customization from the script file for a key, the key should then perform its default functions, correct?
Click to expand...
Click to collapse
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.
gustden said:
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:
9) # NAVI
x=`dumpsys activity activities | grep "Run #" | cut -f 13 -d" "| grep -v launcher | grep -v systemui | 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 | head -2 | tail -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.
Click to expand...
Click to collapse
brilliant! thank you so much!
Last thing: I want to have viper4android launch on resume (in the background ideally). where can I find the "app identifier" to put in the shell script?
vassandrei said:
Question: if I remove a customization from the script file for a key, the key should then perform its default functions, correct?
Click to expand...
Click to collapse
vassandrei said:
brilliant! thank you so much!
Last thing: I want to have viper4android launch on resume (in the background ideally). where can I find the "app identifier" to put in the shell script?
Click to expand...
Click to collapse
I made a slight change to the 'CODE' section of my previous post, so if you copy it make sure you get the edited version. I tested it and made a couple of changes.
There are several ways to get the package name and activity.
What I typically do is start the application on the unit and do the following in adb:
> adb shell
> dumpsys activity activities | grep "Run #"
This shows you a list of the activities ( package/activity ) in the task list with most recent at the top.
You should be able to pick it out pretty easily. If it is the app that I found with google, this should work to start it.
> am start com.vipercn.viper4android_v2/.activity.ViPER4Android
In most cases, you can just give the package name when using 'am start' with no need for the activity. It will default to the 'LAUNCHER' activity in the package. I usually always give the activity, just to be safe. I would sleep for a couple seconds to give it time to initialize and then $home to take you back to the Home screen. So whole command would look like this. It is easy to test using adb.
am start com.vipercn.viper4android_v2/.activity.ViPER4Android ; sleep 2 ; $home
Thanks for this, it's working great on my Joying (JY-UL135N2 ).
My only issue is that the CALL/BT PHONE (27) button is assigned to my "Pick Up/Call Out" button on my steering wheel. So I can't use it to pick up calls. I actually have another dedicated button on my steering to activate voice commands, so I'd rather assign the CALL/BT PHONE function to that. Do you happen to know how to find out what numbers corresponds to each button press?
akuma148 said:
Thanks for this, it's working great on my Joying (JY-UL135N2 ).
My only issue is that the CALL/BT PHONE (27) button is assigned to my "Pick Up/Call Out" button on my steering wheel. So I can't use it to pick up calls. I actually have another dedicated button on my steering to activate voice commands, so I'd rather assign the CALL/BT PHONE function to that. Do you happen to know how to find out what numbers corresponds to each button press?
Click to expand...
Click to collapse
I make and receive so few voice calls, It wasn't worth having a steering wheel button dedicated for the dialer/call pickup . I just tap the screen to answer and use google voice to make calls.
If you want to have a button answer a call, there *should* be a way to do it given the right command. I will play around with it more. Worse case I can just back out the changes for the (27) , and send you an updated apk.
I used the joying steering wheel control app and switched the dialer/call pickup to my voice button and that works, but my dialer/call pickup doesn't do anything. Please let me know if you want me to test anything. Thank you.
gustden said:
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.
Click to expand...
Click to collapse
Luckily the eject key was also found! Here are the codes:
DVD:
D/MCUKEY ( 691): MCUKEYINPUT: B1=1 B2=0 B2=16 B2=80
EJECT:
D/MCUKEY ( 691): MCUKEYINPUT: B1=1 B2=161 B2=2 B2=91
Looking forward to the modified apk. If you happen to take donations I'd be willing to give you a beer. Thank you.
Model number for reference: JY-AL003N2
sonof said:
Luckily the eject key was also found! Here are the codes:
DVD:
D/MCUKEY ( 691): MCUKEYINPUT: B1=1 B2=0 B2=16 B2=80
EJECT:
D/MCUKEY ( 691): MCUKEYINPUT: B1=1 B2=161 B2=2 B2=91
Looking forward to the modified apk. If you happen to take donations I'd be willing to give you a beer. Thank you.
Model number for reference: JY-AL003N2
Click to expand...
Click to collapse
Here is an updated apk file that should catch the code you listed. In the zip there is a file "keys.txt" and also updated APK file. The keys.txt is a complete list button codes for both the soft-keys ( steering wheel ) and hard-keys (on unit ) that the new apk sends to the script. This is a beta of V2.0 which I added:
3 - HOME ( On unit hard key )
4 - BACK ( On unit hard key )
28 - HANG/CALL END ( Steering wheel softkey)
31 - DVD ( On unit hard key )
32 - EJECT ( On unit hard key )
The HOME/BACK keys are sending the keycodes for the home/back actions. You don't need to map them in a script, as long as you have a default that passes keycodes at the end of the script.
*) input keyevent $key
;;
I have used it the last couple of days and it is working fine for me, but can't test the dvd or eject.
Let me know if it registers the keys.
sorry for the dumb question but do you need to root the unit to use this?
Is there a way to run a shell script when I switch ignition off and illumination on or off?

AppSwitcher v3 - smart SWC launcher (for Junsun, Xtrons and similar devices) incl. autostart

AppSwitcher v3​SWC (Steering Wheel Control) app launcher
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Stay focused on the street and don't touch the head units display to switch between apps.​
Your browser is not able to display this video.
Support the development of this free app via
ko-fi.com/appswitcher​
What is AppSwitcher?​
AppSwitcher enhances your steering wheel key to switch between apps.
Hereby you can select which apps should be offered and you can choose stock apps (e.g. the radio app) and 3rd party apps like your favorite mp3 or DAB player. You can switch between media and navigation app by only one key press.
Additionally AppSwitcher offers a lot of options:
- start the last used media app after boot and after sleep automatically.
- long button press to cancel (if dialog is shown) or to jump to home screen.
- reactivate accessibility service of Automate and start initial Automate Flow to realize your own automations
- enable/disable DuraSpeed to prevent the head unit from killing your apps
- change system property to make Android status bar visible (work as on other Android devices)
- automatic screen dimming based on sunset / sunrise information
- allows to start the (Junsun) equalizer app
- supports SWC key "mode" even if CAN box is in place (if modded MainUI gets used)
- ...
How it works​
AppSwitcher has two options to register for a SWC key. A basic understandinghow it works will help you to do the initial setup of AppSwitcher.
Option 1 - GPS​
The head units main app (MainUI) writes by default a log message on each key press. AppSwitcher can listen to the Android log and react on a log message.
This will not overwrite the standard behavior of the original key function but we can configure a SWC key and assigned it to "open navigation app". With a special app (AppSwitcherStarter) set as navigation app there is no need to modify system files or system apps.
This will only work if
a) a dedicated SWC key to start the navigation app is present. If no CAN box is used every SWC key can be configured
b) a dedicated SWC key to switch between apps (mode button) is present AND the radio app is not used/required
Option 2 - MainUI​
Replacing the head units main app (MainUI) with a modded version.
In this version, the SWC mode key is disabled so that its functionality can be overridden (replaced) by AppSwitcher.
Additionally the modded version starts AppSwitcher after boot / sleep and sends a broadcast on each key press. This allows AppSwitcher to register for the broadcasts to receive a trigger. Other apps (e.g. Automate) can also register for these broadcasts.
This will only work if
a) a modded version of MainUI is available
b) you are not afraid of replacing a system app and know how to flash a firmware in case of problems. You're replacing the system app at your own risk.
Installation​
Option 1 - GPS​
Please read previous post to check if this is the best installation type for you.
Spoiler
- Install AppSwitcher AND AppSwitcherStarter.
- Enable automatic start of navigation app in factory settings
and let your device reboot.
Please be aware that changing factory settings will reset some settings on your device like equalizer and radio station presets. This is not an issue of AppSwitcher(Starter).
- Open AppSwitcher and select your navigation and media apps. Additionally activate the log listener:
- Set 'AppSwitcher Starter' as navigation app:
Don't set AppSwitcher itself as navigation app.
- Configure one button of steering wheel to start navigation app (if not already done)
With this setup the head unit will start AppSwitcherStarter after each reboot/sleep whereby AppSwitcherStarter will start the service of AppSwitcher.
Pressing the SWC navigation key will also start AppSwitcherStarter but this will have no effect if the service is already running. Nevertheless the AppSwitcher service will recognize the log entry and can present the AppSwitcher dialog.
The log entry can vary from head unit to head unit so it may be required to adjust the log listener settings https://forum.xda-developers.com/t/...-devices-incl-autostart.4593865/post-88620913
​Option 2 - MainUI​
Please read previous post to check if this is the best installation type for you.
You choose this way of installation at your own risk. It may lead to a bootloop and you should be familiar how to flash a firmware to restore your device in case of problems.
Spoiler
- First you need to check if a suitable modded version of MainUI is available for your device.
You can find a list of modded versions here: https://forum.xda-developers.com/t/...-devices-incl-autostart.4593865/post-88620949
- Download the modded MainUI version, place it in the "Download" folder on the device and rename it to MainUI.apk
- Install MainUiUpdater and perform the replacement of MainUI system application. If the device freezes after the update simply use the reset hole to force a reboot.
- Install AppSwitcher
- Open AppSwitcher and select your navigation and media apps.
Ensure the log listener is disabled.
- Reboot your device. E.g. by using the Reboot.apk from here: https://forum.xda-developers.com/t/...r-aux-bt-music-carinfo-from-launcher.4237797/
Installation files​
Attached installation files are only for testing purposes.
V3 is still under construction and may be not stable. This version is not supported.
AppSwitcher: Core application
AppSwitcher Starter: Starter of AppSwitcher and dummy navigation app. Only needed for installation option "Option 1 - GPS".
MainUiUpdater: Helper tool to replace MainUI. Only needed for installation option "Option 2 - MainUI".
Reboot: Adds an icon to launcher for an easy reboot of the head unit. Can be found here.
Changelog
AppSwitcher
3.0.3
- Adjusted to new broadcast key
MainUiUpdater
0.7
- Changed backup dir to /sdcard/MainUIbackups
Adjust the log listener​
Installation type "Option 1 - GPS" may require to adjust the log listener settings. They are pre-configured for systems without CAN box and a SWC key assigned to the GPS function (see Installation instruction on previous posts).
First you have to identify which log entries get written as soon as you press the SWC key. I suggest to use "Logcat Reader" from Google Playstore to identify usable log messages.
The log listener settings​
Log tag: Tag of the log entry. On most systems this is "MainUI".
Short button press log entry: If this log entry occurs AppSwitcher will show the dialog or jump to the next app.
This is the most important entry.
If you get a set of log entries as soon as you push and release a SWC key "Short button press log entry" should be set to the log message which gets written as soon as you release the key after a short amount of time.
Optional:
On button press log entry: This log message gets written as soon as you push down the SWC key. AppSwitcher will stop the countdown as soon as this message gets detected. This allows to set a very short countdown time.
Long button press log entry: If you hold down the button you can cancel the AppSwitcher dialog or jump to the home screen / launcher if the dialog is currently not visible.
The log entries need not to contain the whole message. It's sufficient to enter a substring if this is unique and not part of other log messages.
Modded MainUI​
For MTK825X​
MainUI_825X_1.3.apk​Version 1.3 from 8259P_军灿UI02v1280x720-国外_v81_20230427
Changelog
23/6/18
- Allow remap of SWC keys even if CAN box is in place
For 8667​To bring this version on the same level as 825X I need your testing support!
MainUI_8667_1.1.apk​Version 1.1 from 8667Q军灿UI02-国外-1280x720_v28_20230302.zip
Remap SWC keys​
If a CAN box is in place Junsun devices doesn't allow to remap SWC keys and assign other functions to it. But if you install a modded MainUI it is possible to define a config file with a mapping according to your needs.
The mapping file must be called "keyMapping.ini" and must be stored on the top level of the memory next to the "Download" folder.
The file is a simple text file containing key code mappings:
Code:
[from value 1]:[to value 2]
[from value 2]:[to value 1]
[from value 3]:[to value 4]
This is an example to swap the volume keys:
Code:
19:20
20:19
The most used key codes:
Mode = 10
Vol + = 19
Vol - = 20
next track = 44
prev track = 45
All key codes:
Spoiler
0 = 31;
1 = 32;
2 = 33;
3 = 34;
4 = 35;
5 = 36;
6 = 37;
7 = 38;
8 = 39;
9 = 40;
AIR = 105;
AM = 53;
AMS = 58;
ANGLEDN = 74;
ANGLEUP = 73;
APPS = 100;
APP_LONG = 115;
APP_SHORT = 114;
AUDIO = 101;
AUX = 2;
AVIN = 3;
AVM = 107;
BKL = 6;
BT = 23;
BT_A2DP = 111;
CAMERA = 108;
CARINFO = 106;
CAR_DEVICE = 110;
CAR_PLAY = 103;
CLOCK = 5;
DEL = 109;
DELETE = 84;
DIM = 24;
DIMDN = 88;
DIMUP = 87;
DISP = 85;
DN = 67;
DTV = 1;
DVD = 13;
DVR = 27;
ECAR = 89;
EJECT = 71;
EJECT_L = 83;
ENT = 21;
EQ = 17;
FAV = 86;
FCAM = 26;
FEEL_BACKWARD = 198;
FEEL_CCW = 200;
FEEL_CW = 199;
FEEL_DOWN = 196;
FEEL_FORWARD = 197;
FEEL_LEFT = 194;
FEEL_RIGHT = 193;
FEEL_UP = 195;
FEEL_WAVE = 201;
FF = 46;
FM = 52;
FMAM = 51;
FR = 47;
HOME = 99;
INFO = 98;
IPOD = 25;
J = 41;
LEFT = 68;
LOC = 55;
LOUD = 18;
MEDIA = 28;
MEDIA_PP = 60;
MEDIA_RDM = 61;
MEDIA_RPT = 62;
MEDIA_SCAN = 63;
MEDIA_SEARCH = 65;
MEDIA_STOP = 64;
MENU = 8;
MODE = 10;
MODE_DN = 94;
MODE_UP = 93;
MUTE = 16;
NAVI = 11;
NEXT = 44;
OPEN = 72;
PAUSE = 91;
PHONE_SIM = 104;
PLAY = 90;
POWER = 70;
POWER_OFF = 82;
POWER_ON = 81;
PRE = 45;
RADIO = 12;
RADIO_1S = 75;
RADIO_2S = 76;
RADIO_3S = 77;
RADIO_4S = 78;
RADIO_5S = 79;
RADIO_6S = 80;
RADIO_BAND = 43;
RADIO_SCAN = 59;
RDS_AF = 48;
RDS_PTY = 50;
RDS_TA = 49;
RETURN = 22;
RIGHT = 69;
SD = 15;
SET = 7;
SPEAKER = 95;
SPEAKER_SW = 96;
ST = 54;
TELCALLOF = 30;
TELCALLON = 29;
TOGGLE_LEFT = 112;
TOGGLE_RIGHT = 113;
TOUCH = 9;
TPMS = 102;
TUNEDEC = 57;
TUNEINC = 56;
TV = 4;
UP = 66;
USB = 14;
VIEW360 = 92;
VIEW360_UP = 97;
VOLDN = 20;
VOLUP = 19;
X = 42;
reserved
reserved
TorstenH said:
Installation
Option 1 - GPS
Please read previous post to check if this is the best installation type for you.
- Install AppSwitcher AND AppSwitcherStarter.
- Enable automatic start of navigation app in factory settings
View attachment 5927899
and let your device reboot.
Please be aware that changing factory settings will reset some settings on your device like equalizer and radio station presets. This is not an issue of AppSwitcher(Starter).
- Open AppSwitcher and select your navigation and media apps
- Set 'AppSwitcher Starter' as navigation app:
View attachment 5927901
Don't set AppSwitcher itself as navigation app.
- Configure one button of steering wheel to start navigation app (if not already done)
View attachment 5927903
With this setup the head unit will start AppSwitcherStarter after each reboot/sleep whereby AppSwitcherStarter will start the service of AppSwitcher.
Pressing the SWC navigation key will also start AppSwitcherStarter but his will have no effect if the service is already running. Nevertheless the AppSwitcher service will recognize the log entry and can present the AppSwitcher dialog.
The log entry can vary from head unit to head unit so it may be required to adjust the Log listener settings.
Option 2 - MainUI
Please read previous post to check if this is the best installation type for you.
You choose this way of installation at your own risk. It may lead to a bootloop and you should be familiar how to flash a firmware to restore your device in case of problems.
Click to expand...
Click to collapse
Some models of a car - like mine , does not allow changing swc buttons and settings, is there a way to bypass that ?
Anton TNT said:
Some models of a car - like mine , does not allow changing swc buttons and settings, is there a way to bypass that ?
Click to expand...
Click to collapse
Sure. You can help to let the magic happen:
Junsun V1 - Codes
Code description from {Mod edit} Please note: Don't just try a code without to know what happens. E.g. 9191 will lead to the message "device not activated" and you need a file called license.dat. 8888 - restricted settings menu 8878 - full...
forum.xda-developers.com
TorstenH said:
Sure. You can help to let the magic happen:
Junsun V1 - Codes
Code description from {Mod edit} Please note: Don't just try a code without to know what happens. E.g. 9191 will lead to the message "device not activated" and you need a file called license.dat. 8888 - restricted settings menu 8878 - full...
forum.xda-developers.com
Click to expand...
Click to collapse
Thanks good to know
Here is working with mainui option
ramig said:
Here is working with mainui option
Click to expand...
Click to collapse
If you want to test the SWC key remapping via config file, let me know...
I can install MainUI on my unit (8667L), I need to know if the 8667L version is compatible or only for 8667. If it is compatible, is key mapping available for this version?
elalvaro19 said:
I can install MainUI on my unit (8667L), I need to know if the 8667L version is compatible or only for 8667. If it is compatible, is key mapping available for this version?
Click to expand...
Click to collapse
Could you please let me know which firmware you have currently installed by providing a link to the firmware zip file?
Key mapping can be made available but I need you to test because I don't have a 8667(L) unit.
TorstenH said:
Could you please let me know which firmware you have currently installed by providing a link to the firmware zip file?
Key mapping can be made available but I need you to test because I don't have a 8667(L) unit.
Click to expand...
Click to collapse
This is the firmware I currently have installed:
8227L 固件 - Google Drive
drive.google.com
elalvaro19 said:
This is the firmware I currently have installed:
8227L 固件 - Google Drive
drive.google.com
Click to expand...
Click to collapse
Unfortunately I can't extract the firmware with the same tools I use for 8867 and 825X.
Could you please install MainUiUpdater and perform replacement without a MainUI.apk in Download folder? This should create a backup of your MainUI.apk file you can share here.
Hello TorstenH, I have a Junsun 8667Q and I would like to reassign the steering wheel keys, I have a 2019 kia Sportage with CAN, does your MAINUI work for my radio?
The VOICE button opens the google search for me and I would like it to open the google assistant.
Thank you so much

Categories

Resources