yashsingh1/xdaforums huggingface dataset:
[Android Head-Units] TorstenH:
Here I list the log entries for TAG 'AppSwitcherService'. Problematic could be if 1 has no successor.

1.

"send onPress broadcast - short or long press will follow"

Log entry indicating the push down of the SWC button. Timer will be stopped if dialog is visible. No action if dialog is not shown.

2.

"start dialog"

Log entry indicating the release of the button after a short amount of time. AppSwitcher dialog currently not visible. First item will be selected. Timer will start.

3.

"send broadcast to dialog"

Log entry indicating the release of the button after a short amount of time. AppSwitcher dialog is already visible. Next item will be selected. Timer will be resetted and start again.

4.

"send broadcast to close to dialog"

Log entry indicating the release of the button after a long period of time. AppSwitcher dialog is already visible. Dialog will be closed without action.
[Android Head-Units] demolite:
Maybe run a separate timer in the background to close dialog if no follow-up entry is received?
[Android Head-Units] cabraspower:
Hi, thanks for your work!

I have a junsun v1 (similar) with canbus box, so I cannot remap swc to navigator app.

Is there any way to make to work your app?

Thanks in advance.
[Android Head-Units] TorstenH:
Which functions are currently predefined on your steering wheel keys (volume (+/-), next/previous track, ...)?
[Android Head-Units] cabraspower:
Volume +/- Phone, assistant, next and previous, and the other two that changes the media. Everything works ok with their original functions.

thanks for replying ☺️
[Android Head-Units] TorstenH:
You're welcome.

Please install logcat reader from Google PlayStore and let me know if you can find log entries (e.g. for the media button):

You can filter on TAG "MainUI" and should be able to find entries like "nDealPkey = = xxx" whereby xxx is a three digit number.

This will help me to find the relevant coding part in MainUI and to identify if we have a chance to overwrite the standard functionality. Unfortunately I can't do that by myself because I don't have canbus.
[Android Head-Units] cabraspower:
Ok thanks a lot. Tomorrow will try,
[Android Head-Units] cabraspower:
Hi the

Hi the key that appear each time I press the "mode" button is == 10

If I configure this number in the AppSwitcher nothing happens.

Thx
[Android Head-Units] TorstenH:
If you set "nDealPkey = = 10" (including the spaces) as 'Short button press log entry' one of your set apps should start - maybe just in background. Please select at least one media app and one navigation app and start AppSwitcher Service.

I will have a look which coding blocks MainUI will execute on key 10.
[Android Head-Units] cabraspower:
It works perfectly now, thanks for your help!

Edit1: The app stops working after 15 sec. I have duraspeed option activated. If I reopen the service it works again so something is killing the service but I cannot find what.

It occurs with stock and others launchers.
[Android Head-Units] TorstenH:
Please check again logcat. Maybe you can find a fatal error message in combination with AppSwitcher.

Open logcat reader directly after AppSwitcher is gone and search for "fatal". Don't set filter on a specific Tag. Maybe one of the latest messages contains com.thf.AppSwitcher
[Android Head-Units] cabraspower:
This is what I see when I press the button.

Thanks.
[Android Head-Units] TorstenH:
Please check log cat after! AppSwitcher was closed. If AppSwitcher is not working after 15s I think you won't see the app icon in status bar anymore. But maybe an error message in log.
[Android Head-Units] cabraspower:
This logcat is after the AppSwitcher stops working, I always see the icon in the status bar.

When the service starts the switcher works ok, but a few seconds later doesn't work anymore but the service continues running, and doesn't see any errors in logcat . . .

Tomorrow I will try giving permissions from adb and deactivating duraspeed.

Thanks for your help!!
[Android Head-Units] TorstenH:
Then I was misleaded by your message "something is killing the service".

Please check if AppSwitcher has the permissions to show dialog and appear on top of other apps (if your head unit allows to set those permissions).
[Android Head-Units] TorstenH:
Do you know this feature of Agama Car Launcher to use an overlay mask to darken the screen? Unfortunately it only works on Agamas screen itself.

Just want to know if you want to see this feature in AppSwitcher whereby I would show the mask on top of all apps to reduce screen brightness to improve driving experience at night.
[Android Head-Units] Jetblack31:
Hi,

I am very new on this forum. I've just installed a Junsen V1pro on my car. Your app is exactly what I was looking for. My car is a Renault Mégane and I have a can bus decoder for the SWC. So I will read carefully the thread and try to make your app work on my car. I will keep you posted. Many thanks for your work and your development !

Jetblack
[Android Head-Units] Jetblack31:
Hi,

I've logged the SWC. So regarding the previous posts, it should work fine. I'll keep you posted !

Jetblack

By the way, it seems I don't have "long press feature" through the canbus decoder. So I will set another key for the long press. That's not an issue, there are so many keys on Renault SWC !

TorstenH, thank you so much for your amazing and brilliant software development!
[Android Head-Units] TorstenH:
You could check if in case of long press you will get a log entry from "[1gb]CanNative" with message "handle key = xxxxx".
[Android Head-Units] Jetblack31:
Thank you for your help. For the moment I have a problem. It does not work. I set AppSwitcher like in the picture but with no results. When I press the mode key (key 10), the HU keeps its native behavior, i.e. changing the source.

Some notes :

I had to enable READ LOGS for logcat to run properly, perhaps AppSwitcher is not granted with enough permissions to read the logs ?

When I set AppSwitcherStarter as NAVI app, each time I reboot the HU, the NAVI app goes back to Maps. So I put AppSwitcherStarter as an autorun app in AGAMA car launcher.

Thank you very much for you help !

Jetblack

EDIT : for long press, I have no supplementary log for "CanNative". For some keys, like vol+ vol-, if I long press then the message ky pressed is repeated each second.
[Android Head-Units] TorstenH:
You could try to grant the permission. On my Junsun V1pro that was not needed wherby one user already mentioned that he had to grant the permission.

Unfortunately then the head unit doesn't provide the long press information and for AppSwitcher we don't have a trigger.
[Android Head-Units] Jetblack31:
I'm new in Android, could you give me the command line to grant the proper permission to AppSwitcher ?

Many thanks!
[Android Head-Units] TorstenH:
Should work similar to Logcat Reader:

adb shell pm grant com.thf.AppSwitcher android.permission.READ_LOGS
[Android Head-Units] Jetblack31:
Thanks ! I try now !
[Android Head-Units] TorstenH:
My expectation is that you head unit will still change the mode. But maybe you can see the AppSwitcher dialog appearing.
[Android Head-Units] Jetblack31:
So I made the change with abd. Now I can activate AppSwitcher but when I pressed the key, I obtain a mix between the native behavior and AppSwitcher. I have to press twice to obtain AppSwitcher and when it is on screen, next key press doesn't select an application, I cannot navigate in the AppSwitcher window.

I tried 3 keys : 10, 11, and 29, see picture. I obtain the same behavior.
[Android Head-Units] Jetblack31:
Yes, that's exactly what I've just described !
[Android Head-Units] Jetblack31:
Is it possible to do something to suppress the native behavior of the HU ?
[Android Head-Units] TorstenH:
Is the mode button usually starting the navigation app if it's not already in foreground?
[Android Head-Units] Jetblack31:
Hello,

Key 11 (RADIO) allows to switch between the last used media app and the NAVI app selected in the navigation preferences.

So this behavior is fine.

Key 10 (MEDIA) allows to switch between the native media apps : radio, audio player, video player and auxilliary AV input. I would like to change this behavior to switch between a list of apps.

Key 29 displays the native BT interface. I would like to change this behavior to have the Home page to appear (the launcher) because I don't have any HOME key on the SWC.

Others keys of the SWC are ok (volume, mute, phone, and on the rear side track + and -, >>> and <<<, and Ok that calls the equalizer).

So is it possible to remap Key 10 and 29 ?

Many thanks !

Jetblack
[Android Head-Units] TorstenH:
Based on your description you could try to make AppSwitcher listen to key 11. If AppSwitcherStarter is set as navigation app it should work.

Key 10 is more complex because it's not controlled by a separate activity of the central MainUI application and so I can't disable WinShow temporarily to suppress the native behavior. The list of media apps seems to be the list of app icons selected in factory settings (8888 / 8878). Another approach could be to remove all app icons within the factory settings. But: This would affect your launcher (if you use the weird stock launcher).

I will have a more detailed look into the source code of MainUI asap.
[Android Head-Units] TorstenH:
You could try with another navigation software from Google PlayStore to check if it's a specific problem with AppSwitcherStarter on your device.

Please be aware that USB storage devices can prevent the head unit from saving settings. And as soon as you change factory settings (8888 / 8878) the navigation app will be changed back to Maps automatically which is imho a bug.
[Android Head-Units] Jetblack31:
Thank you very much, I will try what you suggest in your 2 messages and I keep you posted !
[Android Head-Units] Jetblack31:
Hi,

I made some tests. I use AGAMA as CL.

- Whatever the app I put as NAVI app, the NAVI app is restored to Maps after a reboot (I make the reboot through 8878 as I don't know another way to make a complete reboot).

- I set AppSwitcherStarter as NAVI app and set key 11 in AppSwitcher. When I press the key, AppSwitcher window pops up but if I press again, I'm not able to select an app, nothing happens and the window closes after a few seconds.

- I removed all the menu icons in the factory settings 8878. Following that, nothing happens when I press key 10 (media/mode). However, if I make AppSwitcher listen to key 10, nothing happens, the AppSwitcher window is not displayed at all... And something weird : the menu entry to select the default navigation app has disappeared! So I've restored some apps in the menu icons 8878, key 10 is working as expected but the menu entry to select the default navigation app is still missing ! Perhaps a reset to factory settings will fix that ?

Jetblack

PS: I've also tried FytHWOneKey but it doesn't work
[Android Head-Units] TorstenH:
Which firmware are you using?

Latest FW for Junsun V1pro is from April 2022:

https://xdaforums.com/t/junsun-v1-pro-mtk8259-mtk8257-firmware.4283365/post-87146423
[Android Head-Units] Jetblack31:
I have a firmware 8667 from August 2022. I have a link to download it if you want !
[Android Head-Units] TorstenH:
Thanks but I don't need the link.

There should also be the possibility to add "NAVI":
[Android Head-Units] Jetblack31:
I didn't see the possibility to add NAVI. I will look to that tomorrow morning and keep you informed.

Thank you very much for your help!

I like this Junsun unit. Some details has just to be improved (fine tuning) to make it perfect ;)

I'm also pretty sure I cannot add CarPlay as shown in your picture. (CarPlay is working well on my HU (wireless))
[Android Head-Units] TorstenH:
Unfortunately you have another device (only have a Junsun V1 pro with MTK8259/MTK8257 CPU here) and the menu might be different.
[Android Head-Units] Jetblack31:
Hello,

I've checked this morning. NAVI and CarPlay are not available in Menu Icon. I've added all proposed App. Unfortunately the menu entry to select the default navigation app is still missing. I will try a factory reset.

Jetblack

EDIT: I checked some picture I took. Actually the menu was the same as yours in FW 20220518 but not in FW 20220801. A new FW is available. I'll try this new one. Alternatively I can restore FW 20220518.

EDIT2: Finally I installed a more recent FW 20220825. The NAVI app is back in the menu icon, as well as the entry to choose the navigation app. So I will keep this version now. Note that the Stock UI in this version is new too, a bit more convenient than UI3. But I will reinstall AGAMA. I will try to reinstall AppSwitcher, I'll keep you posted.
[Android Head-Units] Jetblack31:
Dear Torsten,

I'm quite new in Android but I was thinking of something. The canbus decoder sends the information to HU through serial. There should be a process that translates this information to the key number understandable by the Android and the other apps. As I have to configure a canbus decoder model in the HU, perhaps there is a config file for my can decoder in the filesystem containing a conversion table between canbus codes and key numbers. I will try to learn how to explore the full filesystem of the system. What do you think of this idea?

Best regards,

Jetblack
[Android Head-Units] TorstenH:
I don't understand what's your goal. Enabling long press feature?

Can you change the navigation app and does the setting survive reboot?
[Android Head-Units] Jetblack31:
Hi,

Sorry if I'm not clear, I'm not very fluent in English.

My goals are:

- I would like to have a way to come back to the launcher (AGAMA) with SWC. Currently none of my SWC keys do that. (no HOME key)

- I would like to be able to switch between apps, including NAVI.

Of course these 2 features can be merged. If I have a key allowing to switch between several apps, including HOME and NAVI, I would be happy.

I will try to set another app as NAVI to see if it survive reboot (with the new FW).

Thank you very much. Your Appswitcher seems so amazing that I would like to have it on my HU !

Jetblack
[Android Head-Units] TorstenH:
It would be possible to add "home" as additional, selectable entry. But such an enhancement makes sense only if the basic function works.
[Android Head-Units] Jetblack31:
Hi,

I have a very good news! Appswitcher is working !

I installed it on the new firmware. I selected key 11 as the short press key and it works!

(with other keys 10 or 29, it does not work, so I have only one key available for Appswitcher).

I've put AGAMA among the media app, and I can access to the launcher and any other app in the list.

That's great !

Many thanks, you did an amazing great and brilliant job :)

Jetblack

EDIT: The default NAVI app services also survives the reboot ;)

EDIT2: It would be great to have another key for long press or one key feature, but I don't know how to do...
[Android Head-Units] TorstenH:
Great to hear that! And working key 11 matches my expectation. You could try again to remove the app icons in factory settings to make key 10 out of function.

- if you set AppSwitcherStarter as navigation app it shouldn't be a problem to keep the NAVI entry (if it is available in the app icon setting of your current fw) to avoid loss of the Android setting to define navigation app.

- if AppSwitcher is not triggered by key 10 you could check if it is still in the log. If not: you may find the log entry log entry from "[1gb]CanNative" with message "handle key = xxxxx".

In this case you also have to change the "log tag" setting of AppSwitcher to "[1gb]CanNative" and use the "handle key = xxxxx"-messages (corresponding to key 10 / key 11) for "Short button press log entry" and "Long button press log entry".
[Android Head-Units] Jetblack31:
Hi,

Some news after some more tests:

-it seems that AppSwitcher/AppSwitcherStarter stops working after a few tens of seconds. If I restart AppSwitcherStarter It works again but for a few tens of seconds again. When stopped, Key 11 retrieves its native function : starting the NAVI app. So it restarts AppSwitcher. In this situation I have to press the button twice : once to restart AppSwitcher, and a second time to open the pop-up menu and select an App.

-I reduce Menu Icon to only NAVI and Car Info. As a consequence Key 10 does nothing when pressed. If I make AppSwitcher listen to Key 10 (short press), AppSwitcher works well, excepting the fact that after a few tens of seconds, it stops working (see previous point). But there is a side effect : as RADIO is not in the Menu Icon apps anymore, the stock radio app doesn't work anymore!! The radio frequency is frozen to 0.0 MHz and buttons have no effect :( Perhaps a third party FM radio app would work. I will try.

So for the moment, the main issue is that AppSwitcher/AppSwitcherStarter stops working after a few tens of seconds.

Thank you again for your help!

Jetblack
[Android Head-Units] TorstenH:
Is AppSwitcher icon still present in Android status bar? Is the "running" notification still present?

Is MainUI still writing the logs? Maybe MainUI doesn't continue to write the log entries so it only looks like AppSwitcher is not running anymore?

Are there Error entries in log related to tags MainUI or AppSwitcher?
[Android Head-Units] Jetblack31:
Thanks your your help! I check these points tonight, after work ;)

One question: what does the AppSwitcher icon looks like ?
[Android Head-Units] TorstenH:
Don't invest too much time finding an alternative radio app. Radio is part of the MainUI application and only a facade to control the radio chip. I've never seen a custom Radio app for Junsun devices.
[Android Head-Units] TorstenH:
It's a triangle pointing to the right. But you can also pull down the status bar and check if there is a notification from AppSwitcher.

I think there are only two possibilities:

- AppSwitcher force closed and you will find an error log entry. Additionally search in logcat reader for "fatal" by not filtering the log before.

- MainUI doesn't continue to write logs.

Is AppSwitchers setting "disable navi start activity" on or off?
[Android Head-Units] Jetblack31:
I don't remember, will look at this too!
[Android Head-Units] Jetblack31:
Hello,

I've found the problem: AppsWsitcher was not allowed to be displayed on top of other apps. I authorized this in "application settings" and AppSwitcher works all time.

Currently AppSwitchers setting "disable navi start activity" is off, and I have no flickering effect.

My current set-up : Key 10 (initially MODE) = Short press

Key 11 (initially switch between NAVI and native MEDIA) = Long press

So Key 10 opens the pop-up to select apps

and Key 11 display the car Launcher.

That's almost perfect except I would like to have Key 11 to switch between NAVI, last media app and/or launcher.

Ceoncerning FM RADIO, I didn't find possibility to keep it working and freeing Key 10 by suppressing it from Menu Icon. It seems that Menu Icon is used both to define native Apps for the MODE SWC key and to start/initialize the native apps at reboot.

I would like to recover the native FM radio because DAB is not very developed yet in France...

Thank you

Jetblack
[Android Head-Units] TorstenH:
Okay. Sounds like we're on a good way.

Yes, DAB is rare in France according to my last vacation experience, too.

It would be possible to add an additional icon to the app list of the pop-up menu which allows to switch to the home app but that will only have the same effect as adding Agama as media/navigation app. That we don't see a log event for long button press could be already suppressed by the Canbus-Adapter. Or by the MainUI app itself which would required a modification of the system app. Both very complex solutions.

Another approach could be to check if your cars steering wheel buttons are based on a resistance matrix and the KEY wires are just connected to the Canbus-Adapter. In this case it would be possible to connect the KEY wire directly to the head unit which allows to read the long press information.
[Android Head-Units] TorstenH:
Added two of your findings to FAQs.
[Android Head-Units] Jetblack31:
Hi,

I've already added AGAMA to the Apps List, it works. For the moment I mapped my 2 keys to short and long press. I will map one of the 2 to the "One key feature" of AppSwitcher to see what happens.

I have a Renault Megane, so the SWC are a bit over-engineered ;) 7 wires come from the SWC to the canbus decoder. So I think it would be tricky to use a resistance matrix just with 1 or 2 KEY wires. Perhaps not impossible but not straightforward.

So for now I have 2 options :

- FM RADIO and just 1 SWC button for AppSwitcher

- no FM RADIO and 2 SWC for AppSwitcher

Another option would be to be able to "initialize" the FM RADIO feature by myself after boot.

Thank you very very much for your App and your support !

Jetblack
[Android Head-Units] Jetblack31:
One more information:

I use Waze as NAVI. I've noticed that sometimes when Waze is not in foreground and that I switch back to Waze, Waze has lost its internet connexion and I can take a very long time before it recovers. During this time, the 4G network of the HU is Ok. I don't think it is linked to AppSwitcher but I don't remember I had this issue before. I deactivated Duraspeed in AppSwitcher but with no result.

Any idea ?
[Android Head-Units] Jetblack31:
Hi,

I've tried several settings. I didn't succeed to configure the "one key feature", it doesn't switch between last NAVI and last MEDIA apps...

The current one that is satisfying is :

- Key 10 (initially MEDIA) : long press. If I press, it comes back to HOME

- Key 11 (initially NAVI) : short press, it opens Appswitcher pop-up menu

I configured a static list of apps, only media apps. I've put Waze as the 1st one, then CarPlay, then other apps.

So, Key 10 = HOME, one press on Key 11 = NAVI Waze, double press = CarPlay, and following press = my other apps

:)

Jetblack
[Android Head-Units] TorstenH:
Please grant permission to read usage statistic. It may be in an separate setting menu (special permission, special app access,...)

This is required to track the last opened app even if app was opened manually without AppSwitcher).

Restart if AppSwitcher Service is required (or perform a reboot, please).
[Android Head-Units] Jetblack31:
Hi,

Haven't seen yet this kind of permission for AppSwitcher. I will continue to find.

Regarding the READ_LOGS permission I had to give, perhaps it is because the FW is based on Android 11, not 10.

I'll keep you posted!
[Android Head-Units] Jetblack31:
Hi,

Unfortunatly, I didn't find any menu to grant the permission "read usage statistic". IS it possible to grant using adb ? what would be the command?

Thank you

Jetblack
[Android Head-Units] TorstenH:
Sorry. Currently I'm a little busy so my answer is delayed. This should do the job:

adb shell pm grant com.thf.AppSwitcher android.permission.PACKAGE_USAGE_STATS
[Android Head-Units] Jetblack31:
Hi,

Don't worry for the delay!

So I've granted the permission and rebooted the HU.

I've tried several combination of keys and features, unfortunately I'm not able to make the "one key feature" to work...

So currently my best set-up is Key 10 --> long press as a shortcut to HOME and Key 11 --> short press to select an app.

Thank you,

Jetblack
[Android Head-Units] TorstenH:
You could check if you see messages according to the pattern

Collected: <package name>

after you started an app which is defined as media app in Android log for tag AppSwitcherService.
[Android Head-Units] DarkTWH:
So how can I get the App to work with a cunbus adapter? Even after reading the entire thread I am still not getting the gist of it. I have a Junsun V1 Pro installed in my Peugeot 207, which has a canbus adapter. I also know that I can not easily change the assigned keys. So is there any way to get it to work? On the Remote Stock I can change between Apps (Source Button) (ie Home, Phone, Music, Navi), change the volume and the track and can access the Info Monitor (Fuel consummption and more). Is there any way to reconfigure either the Source or the Info Monitor key for Appswitcher?

Thanks for any help and sorry for the bad english (not native)

Best wishes