yashsingh1/xdaforums huggingface dataset:
[Android Head-Units] TorstenH:
I enhanced the sh file so we should get the output of the commands in file /sdcard/out.txt

Please put the changed file to /sdcard and repot the content of out.txt

To trigger it, it should be sufficient to force stop MainUI via

Settings > Apps and Notifications > MainUI

Alternatively you can reboot the head unit.

It's great if the mode button is still not workout after a reboot because that means the mod is still in place.

The mode button will automatically work after we got the authorizations managed. I use an existing method of MainUI to execute the sh file so my assumption is that it should work because the same method gets used to execute other su commands.
[Android Head-Units] M_4axx:
Hi, TorstenH. Still nothing, no any out put file.
[Android Head-Units] M_4axx:
i try to connect via adb but in command ./adb devices --> empty too.

before i start server ./adb start-server

its looks like starts, then i try execute command adb shell pm grant

its says --> adb: no devices/emulators found

there is no developer menu, just a factory settings where i saw usb debugging yes or no

upd! when click on build it says you are developer but there is no any developer menu
[Android Head-Units] M_4axx:
but as i saw MainUI process is reading ts8667factory.bin in /sdcard and its shows a information menu thats: settings imported successfuly or something like that, may be by this way its possible execute a shell file?
[Android Head-Units] TorstenH:
You could try this method:

https://xdaforums.com/t/junsun-v1-pro-8667-system-modifications.4553045/post-88141329

If you can get an adb session you could try to execute the "pm grant..." commands.
[Android Head-Units] TorstenH:
I added new version of MainUiUpdater

https://xdaforums.com/t/appswitcher...-devices-incl-autostart.4593865/post-88620909

You could try to enable "Use old SU command" and try again to grant Logcat Reader the required permission.

Background: On old firmwares the command to get root permission was different. So let's give it a try because you never updated the firmware.
[Android Head-Units] TorstenH:
You could expand the activities for Settings app in AppSwitcher menu "Set media apps/activities":

Search for the developer settings and tap on the entry to open them.
[Android Head-Units] M_4axx:
i'll try it today, my version android in menu show "android 12" version but i think its fake, its looks like a android 9 or 10. kernel 4.14 if i remember
[Android Head-Units] TorstenH:
Yes. It's fake on most head units and even the latest firmwares may not provide a later Android version.
[Android Head-Units] M_4axx:
again failed...

does not want to give any rights

what if i use --> KingoRoot.apk does it help?
[Android Head-Units] TorstenH:
I think it's better to try getting adb running before using some root apps which may harm your system. Especially because you don't have a firmware file as fallback.
[Android Head-Units] M_4axx:
ok, i understand. i need to find a android device as host for HU
[Android Head-Units] TorstenH:
As I suggested you can try to use

Remote ADB Shell

https://xdaforums.com/t/junsun-v1-pro-8667-system-modifications.4553045/#post-88141329
[Android Head-Units] M_4axx:
hi, TorstenH sorry for long time not answering.

i try to download remote adb shell and connect via your tutorial, its looks like connects and possible to execute commands

but still no luck with su.

as there explained that device must be rooted to exec a su commands, stack0verfl0w i dont see any other ways, but i dont have a firmware if do that.

i will try to replace my audio panel, to my old panel and watch what will happend
[Android Head-Units] TorstenH:
Great you got it running.

Please use this command to grant the permission to logcat reader

pm grant com.dp.logcatapp android.permission.READ_LOGS

Regarding su please add a backslash and try

\su
[Android Head-Units] TorstenH:
I know that usually a simple execution of the su command isn't possible. But on most head units (incl. 8667) su is possible with this command.

su @#zxcvbnmasdfghjklqwertyuiop1234567890,.

You could also try

\su @#zxcvbnmasdfghjklqwertyuiop1234567890,.
[Android Head-Units] M_4axx:
ok, i grant permissions for logcat reader but su still no luck

in logcatreader i catch a multimedia button

but bottom buttons left and right in down are no any actions in log
[Android Head-Units] TorstenH:
After installation of modded MainUI search for "original key" to find such entries:
[Android Head-Units] TorstenH:
And you can give AppSwitcher the required permissions. Please note that a new version of AppSwitcher is available.

pm grant com.thf.AppSwitcher android.permission.WRITE_SECURE_SETTINGS

pm grant com.thf.AppSwitcher android.permission.READ_LOGS

pm grant com.thf.AppSwitcher android.permission.PACKAGE_USAGE_STATS
[Android Head-Units] M_4axx:
If click on mode button and then write original key it gives me a original key: 10

I click three times and there is 3 logs
[Android Head-Units] M_4axx:
So looks like i can catch all mapped buttons via searching by original key
[Android Head-Units] TorstenH:
Excellent. After granting the required permissions to AppSwitcher and starting it the very first time manually it should respond to the mode button.
[Android Head-Units] TorstenH:
Check if that buttons provide an "original key" log entry.
[Android Head-Units] M_4axx:
By oiriginal key i catch all buttons except that bottom keys

Hwkeys

OK = 60

Arrow Down = 46

Arrow Up = 47

Arrow Left = 45

Arrow Right = 44

TA Button = 49

Melody button = 17

Power button = 70

Previus button = 45

Next button = 44

Info button = 11

Eject button = 71

Menu button = 8

Phone button = 29

Aux button = 2

Radio button = 43

Cd button = 13

Volume Up = 19

Volume Down = 20

Swc mode button = 10

Swc Next button = 44

Swc previus button = 45

Swc Volume Up = 19

Swc Volume Down = 20

1 button = 32

2 button = 33

3 button = 34

4 button = 35

5 button = 36

6 button = 37

7 button = 38

8 button = 39

9 button = 40

0 button = 31

Star button = 42

Clock button = 41

It'looks interesting. Is there a way to re map them?

I can also watch a can codes via can logger
[Android Head-Units] TorstenH:
Another thing you could check in parallel:

If you installed MainUI from here

Post in thread 'Android Head Unit, Remap physical buttons with Ford Fiesta' https://xdaforums.com/t/android-hea...uttons-with-ford-fiesta.4614603/post-88869523

and placed the root.sh we should see a log entry from MainUI after reboot:

execute '/sdcard/root.sh'

OR

execute '/storage/emulated/0/root.sh'
[Android Head-Units] M_4axx:
I think its already installed but is there a way a execute it (root.sh) from adb shell?
[Android Head-Units] TorstenH:
Here you can find the description how to remap:

Post in thread 'AppSwitcher v3 - smart SWC launcher (for Junsun, Xtrons and similar devices) incl. autostart' https://xdaforums.com/t/appswitcher...-devices-incl-autostart.4593865/post-88621023

You could even invent your own codes

11:12345

and use Automate to execute a sequence of custom actions.

This is possible because the modded MainUI sends a broadcast on every key press.

Automate is available in Google PlayStore and AppSwitcher can start Automate after boot and sleep.
[Android Head-Units] TorstenH:
No. But by checking the logs we may figure out why MainUI is not executing our root.sh.
[Android Head-Units] TorstenH:
Additionally you may find some log entries containing the text "DealSu".
[Android Head-Units] M_4axx:
About this is empty, but i can try get again install mainui again tomorrow, no computer right now

Can you please send me a link in to automate, i cannot find a correct app
[Android Head-Units] M_4axx:
So AppSwitcher starts working, it success
[Android Head-Units] TorstenH:
Automate - Apps on Google Play

An automation app for Android that can perform almost any task.

play.google.com
[Android Head-Units] M_4axx:
Hi, TorstenH

its looks like keyMapping.ini working i got remapped buttons

Phone -> carplay now

Aux -> flashdrive

in file keyMapping.ini

2:28

29:103

but the behavior is a little strange, it sometimes still gives out a bluetooth menu instead of a car play, or it just didn’t load (maybe bluetooth connects first) , or maybe of a change in theme it clear this settings, I didn’t understand it that way and the aux is a little strange, sometimes it’s pressed or not, but it’s much better than just clicking on the sensor. In the future see how it works to understand this stranges

about bottom side keys maybe there is problem in canbus, i dont know how to get data from canbus transformed data which is sent to HU.

but right now is much better UX
[Android Head-Units] TorstenH:
I'm happy to read that. Unfortunately I don't know what "CarPlay now" and "Flashdrive" are.

For CarPlay I only know AutoLink, CarLetter and Zlink. Flash drive I only know as description for (removable) storage drives but not as name of an app.
[Android Head-Units] TorstenH:
You could export the Android log with Logcat reader after a reboot so I can have a look on it.
[Android Head-Units] TorstenH:
I checked key 103:

It checks if package com.suding.speedplay is installed. If yes, it gets started. com.suding.speedplay is the app "AutoLink" which can be used for CarPlay and Android Auto.
[Android Head-Units] M_4axx:
Car play i means that it starts a AutoLink app for android auto and car play for ios.

i tested app (AppSwitcher) it working good but when i start HU, it takes some time i need click more that 2 times to start app,

maybe it loads in to memory takes about 2-3 seconds to start app???

with keyMapping file with remapped buttons when i restart HU it load this remapped file but after it stay some time , for example 1-2 hour and then start HU, its looks like clear all re mapped buttons. so when i try click them and they are still old mapped by default

You write about LogCatReader to get a log, how to this? just open app, start record then make reboot?
[Android Head-Units] TorstenH:
AppSwitcher should start automatically and you should see the AppSwitcher icon on the Android status bar.

AppSwitcher has a configurable countdown and you can see how the progress bar gets smaller before an app gets started.

Watch the video in AppSwitcher thread to see the progress bar in action.

Reboot or wake up from sleep?

MainUI should report both, the original key and the remapped key. Check if the mapping is still in place, please.

Here an example:

Reboot, then start Logcat Reader. Check if the log starts before and ends after the reboot (timestamps), save the log and export it via the three dots menu.
[Android Head-Units] M_4axx:
Yeah i got suding.speedplay

Yes, after sleep or wakeup resets to default keys

So when i restart and when click on phone (default 29) it opens autolink suding.speedplay, this photo after restart and still shows 29 🤔
[Android Head-Units] M_4axx:
It can be that after sleep/wakeup it loads default MainUi and default MainUI don't know about re mapped keys?

I dont know but when restarting it opens autolink automaticaly and media (flashdrive) too.
[Android Head-Units] TorstenH:
Please check the log as suggested before. Additionally you can search for the log entry "start AppSwitcher" which gets only written by the modded MainUI.

I don't think MainUI gets changed during/after sleep.

AppSwitcher can start the last used media app automatically. Check AppSwitcher settings.

Additionally your head unit has a last memory option in factory settings (code 8878). Disable it by switching from "remember" to "unremember". This will prevent your head unit to autostart apps especially because this option only works for specific apps and not all media apps.
[Android Head-Units] TorstenH:
Please share both log entries. "key:..." and "original key:..."

Original key logs always the unchanged key code. But there should be a second log entry with the changed key. I think you mapped to key code 103.

And let me mention that only the modded MainUI writes the "original key:..." log entry. This is the proof MainUI gets not resetted while/after sleep.
[Android Head-Units] M_4axx:
Yeah, i fixed, unclick that and its good, so now application looks very good. Now i can change mode to static where they always. I get a log, later will upload here (need a computer).

it is clear from the behavior that the new buttons fly off after waking up, and why??
[Android Head-Units] M_4axx:
Yeah, after reboot its shows

Original key 29 and key 103

After

Sleep

Original key 29 and key 29
[Android Head-Units] M_4axx:
As i understand this codes are from canbus -> 1,2,3..103 etc, and then MainUi gives then a action ?

Like a

Arrow Up = 1

Arrow Down = 2

??
[Android Head-Units] TorstenH:
This are the entries we're interested in:

Please provide a log file after sleep so I can check the log entries by myself.

Please tell me the timestamp you turned on ignition so I have a starting point for log investigation.

You can filter the log by tag "MainUI". This can be done by setting a filter via the three dots menu.
[Android Head-Units] TorstenH:
This codes represent a specific action MainUI should execute. A translation of the CAN message happens already before, on MCU level.
[Android Head-Units] M_4axx:
I understand.

What i want that re map arrow keys as arrow keys, but logcat shows that next and prev buttons as same as arrow keys, and i dont understand who give it them canbus mainui or operationg system?

How i see this can code -> canbus -> number -> mainui catch this and gives them action or event? Or this is incorrect? There is no way to catch unknown buttons or they real id ?

Log i will upload, i need to car get a sleep and wake up
[Android Head-Units] TorstenH:
I think a further investigation of this advanced case makes only sense if all other topics are fixed. It makes no sense to mix several issues because this would only lead to confusion.
[Android Head-Units] M_4axx:
yeah, i understand

something strange now when i wake again it working but before i make some action i copy a keyMapping.ini in to real sd card that i have in top of

so timestamp when i get keyignition on is 17:36

aux by default is 2 but mapped in to media 28 and working strange

its open this flash drive but only if i in radio window other no action

i saw here other variants don't know for what they

AUDIO = 101;

IPOD = 25;

MEDIA = 28; (right now)

USB = 14; (not working)

https://www.sendspace.com/file/1ny9nb
[Android Head-Units] TorstenH:
I will investigate the log but here I want you to provide the logic of key code 28. A lot of things are going on. Please send me a photo of the screen you call "flash drive" because I have no glue what you mean with it.

case 28:
int GetWorkMode = Iop.GetWorkMode();
if (GetWorkMode == 2) {
if (FtSet.IsIconExist(4) != 1) {
if (FtSet.IsIconExist(3) == 1) {
WinShow.GotoWin(4, 0);
break;
}
}
WinShow.GotoWin(6, 0);
break;
} else if (GetWorkMode == 3) {
if (FtSet.IsIconExist(2) != 1) {
if (FtSet.IsIconExist(4) == 1) {
WinShow.GotoWin(6, 0);
break;
}
}
WinShow.GotoWin(3, 0);
break;
} else if (GetWorkMode == 4) {
if (FtSet.IsIconExist(3) != 1) {
if (FtSet.IsIconExist(2) == 1) {
WinShow.GotoWin(3, 0);
break;
}
}
WinShow.GotoWin(4, 0);
break;
} else if (FtSet.IsIconExist(4) != 1) {
if (FtSet.IsIconExist(3) != 1) {
if (FtSet.IsIconExist(2) == 1) {
WinShow.GotoWin(3, 0);
break;
}
}
WinShow.GotoWin(4, 0);
break;
} else {
WinShow.GotoWin(6, 0);
break;
}
break;
case 29:
[Android Head-Units] M_4axx:
Flashdrive i mean this menu where audio playing, when put off flashdrive it disapears and it says no audio files

I cant show a button number because there is no a button, its looks on old audio panel a sound button.
[Android Head-Units] TorstenH:
I would call this media player or maybe mp3 player.

But because this thing lacks of so many features I would suggest to use another app instead.
[Android Head-Units] TorstenH:
The ini file gets read from /sdcard

If your usb drive is /sdcard after sleep, the ini file needs to be placed on the usb drive.

You should check if your usb drive is configured as internal storage in Android settings because this would be a bad selection for head units.
[Android Head-Units] TorstenH:
After installation of Automate you can click on the attached sample flow to import it. Start the flow and check if you're getting toast messages as soon as you press a button.

This is the base to define custom key codes and to run e.g. a good media player.
[Android Head-Units] TorstenH:
The action performed by key code 28 depends on the current work mode (running MainUI activity). See coding I shared before.

But the media player is not worth to invest time to get it running.
[Android Head-Units] M_4axx:
I get installed this file but i dont know what to do, it shows me info but what to do 🫣

Its strange because i have old audio panel with button sound instead new panel with phone button, and i saw somewhere that its mapped (sound button) to that mp3 player. (In this days i need make a connection to back camera and i can put that old audio panel and watch how it works and catch this button)

This player is ok for me, i'm just want the hardware buttons work.

The ini file gets read from /sdcard

Yeah, now again re map is resets to default buttons after night. :|
[Android Head-Units] TorstenH:
Du you see a toast message with the key code?

And was the ini file available on /sdcard after night? Please check the configuration of your usb drive as I've written in an earlier message.

Please provide a log file directly after sleep when it's not working the next time.
[Android Head-Units] M_4axx:
Automate buttons is highlighted by red?

As i remember sdcard was setup as internal memory, but all other not configured at all.

Flashdrive with music always was as plug'n'play. An second flashdrive just plug get files and plugout.

If click a button always popup a info menu NaN from automate as i understand

I will remove sdcard, no need it

Bottom buttons which not mapped, do not shows. No any actions
[Android Head-Units] TorstenH:
No. You should see three toast messages. One with the text "Key X was pressed". Please check if Automate has permission to show notifications.

As i said check the path of ini file after sleep and provide a log when it's not working after sleep.

You could modify the flow to show only the first toast message which is the important one to show the key code.
[Android Head-Units] M_4axx:
I see automate set to deal_key, if write deal_key in logcat it show errors and they show after clicking a button (any mapped) in activity manager
[Android Head-Units] TorstenH:
This error can be ignored because the Automate log shows "broadcast receive". The question is if we can read the key code from the broadcast. This should be shown by Automate with the first toast.
[Android Head-Units] M_4axx:
Hi,TorstenH

Here i have some news

today I tried to check the functionality again, but this time nothing came off, i.e. those buttons that were yesterday for the maplens remained. I left the logcat yesterday in order to get the logs, but when i turn on HU morning logstarts new log as i understand.

yesterday I completely removed the SD card, i need to test more... (1,2.. days)

automate i can't get a permissions it asking for adb i saw a help manual but it required some serial, what serial i don't know. i will get android device and later again try.

in logcat reader i found this

when i click a button it shows a log and number for this button

i catch them all but bottom on sides buttons still not working, no any action, not in logger and not in automate.

OK = 65580

Arrow Down = 65598

Arrow UP = 65599

Arrow Left = 65603

Arrow Right = 65604

TA = 65562

Melody = 65564

Power = 65554

Previus = 65603

Next = 65604

Info = 65563

Eject = 65561

Menu = 65607

Phone = 65539

Aux = 65559

Radio = 65588

Sound = ????

Cd = 65557

Volume up = 65537

Volume Down = 65538

Swc mode = 65541

Swc next = 65604

Swc previus = 65603

Swc volume up = 65537

Swc volume down = 65538

1 button = 65543

2 button = 65544

3 button = 65545

4 button = 65546

5 button = 65547

6 button = 65548

7 button = 65549

8 button = 65550

9 button = 65551

0 button = 65542

Star Button = 65552

Clock Button = 65553

my default audio panel what was

and there is no bottom side buttons

and audio panel i got installed right now

in old panel i got SOUND button and new panel got PHONE button (in original first a simple audio and second is sync 1 audio)

i have theory if logcat via "can native" log shows data from canbox so the MainUI everything understand correct, and that installed canbox just keeping send wrong data, and bypassing that sidebuttons. maybe need a change a canbox?

its just in case,

i don't understand what means can native and what to do with automate? its also silence side buttons.
[Android Head-Units] TorstenH:
Your last message is a wild mixture of different topics which makes it hard to follow you.

Nevertheless I modified the flow. It should write the information we're looking for directly to the Automate log.

If Automate requires an additional permission you must grant it via adb. Automate should show the command which has to be used.

Automate is free as long as you don't need to much action blocks.
[Android Head-Units] M_4axx:
Ok, i understand.

I try last file and its shows this
[Android Head-Units] TorstenH:
Thanks for the test. I re-entered the formulas after activating the formula button. Please try again with attached flow.
[Android Head-Units] M_4axx:
Yeah, its still look failure.

I think its need this adb permission requests, but i dont know what exactly i need allow
[Android Head-Units] TorstenH:
Automate should tell you if there are missing permissions.
[Android Head-Units] TorstenH:
Once more please. String concatenation needs to be done with ++ and not only +.
[Android Head-Units] M_4axx:
Yeah, right now i got key shown, i need to save them? Its also show same buttons as logcat reader in original key
[Android Head-Units] M_4axx:
Automate show same keys except swc mode button it shows 9010

Automate keys ---

OK = 60

Arrow Down = 46

Arrow Up = 47

Arrow Left = 45

Arrow Right = 44

TA = 49

Melody = 17

Power = 70 or 20

Previus = 45

Next = 44

Info = 11

Eject = 71

MENU = 8

PHONE = 103 (re mapped)

AUX = 28 (re mapped)

RADIO = 43

SOUND = ????????????

CD = 13

Volume Up = 13

Volume Down = 19

Swc Mode button = 9010

Swc Next button = 44

Swc previus button = 45

Swc Volume Up = 19

Swc Volume Down = 20

1 button = 32

2 button = 33

3 button = 34

4 button = 35

5 button = 36

6 button = 37

7 button = 38

8 button = 39

9 button = 40

0 button = 31

Star button = 42

Clock button = 41
[Android Head-Units] M_4axx:
Its looks like keyMapping scan problem was after sleep was in real sdcard after remove its never resets always remapped keys and

If i try to use MainUiUpdater.apk i got error (with old su choise) password wrong instead permission denied.
[Android Head-Units] TorstenH:
Well observed! The modded MainUI remaps key 10 to 9010 by default because this is the key code AppSwitcher is listening to.

You can remap your button to an invented one, now:

2:90002

Use an "expression true?" and an "app start" block to run an app / activity for code 90002. You may even find the media player as one of the activities of MainUI.
[Android Head-Units] TorstenH:
You may need to add the key mapping ini file additionally to your "real sd card" as I tried to tell in one of my earlier posts.

Great, now this is a error message we can work with. But I'm surprised you not provided this information after I told you that I added that option to MainUiUpdater.

My question is: Do we need to invest time in this after you was able to install the modded MainUI and you can remap the keys?
[Android Head-Units] M_4axx:
I'm not correctly understand what i need to do, i'm add this expression and re map 2:90002 button but its resets to 2 (button when clicking its shows 2) i change in to 2 and its able to start next block. (In my case app 70mai)

Are you want use it as permanent solution or i need to search something. I saw there is some ui actions in automate