yashsingh1/xdaforums huggingface dataset:
[Android Head-Units] vassandrei:
Oh! I would love to try the version without the killAppWhenSleep() code! If you could upload it that would be awesome!
[Android Head-Units] sonof:
Are you sure it does go to sleep when killAppWhenSleep(); has been commented out? Any way to check if it has? Maybe with multimeter after half an hour just to see if the radio still draws current from the battery. Maybe there are some apps that could prevent it from going to sleep.
[Android Head-Units] nico84:
I think so.

public static void killAppWhenSleep() {
killAllAppButSome();
}

public static void killAllAppButSome() {
ActivityManager am = ObjApp.getActivityManager();
ComparableSparseIntArray<String> appUnkill = new ComparableSparseIntArray(0);
appUnkill.put(getDefaultLauncher(), 1);
putPackageName(appUnkill, getWallpaper());
putPackageName(appUnkill, getInputMethod());
List<RunningAppProcessInfo> infoList = am.getRunningAppProcesses();
if (infoList != null) {
for (RunningAppProcessInfo info : infoList) {
if (appUnkill.get(info.processName, 0) == 0 && (DataApp.APP_PROPERTY.get(info.processName) & 32) == 0 && !info.processName.startsWith("com.antutu")) {
killApp(info.processName);
}
}
}
}

Can someone help me to find the equivalent for Sofia-1-C9-Server-V1.0.apk on not Joying MTCD Sofia HeadUnits?
[Android Head-Units] gustden:
The hook later in the code is very intentional for the media keys. The issue is if you do it earlier in the code, you totally lose the functionality of the keys in the Joying applications. For example, the Joying applications such as their music, video player, radio, etc do not respond to the normal keyevents within android. If hooked earlier, it would make it impossible to do things like pause or skip fwd in their applications. If you bypass their code completely, you cannot even change radio stations using the keys.

It would have been quite a bit easier to just grab the data direct from the MCU data stream. If you read through the thread, I did post an apk file that dumps the bytes of the raw data stream from every message sent by the MCU to the logcat. This was used to identify the non-functional DVD & eject keys present on some units. For these, I invoke the shell program very early since it will not affect any joying apps.

I am almost done with testing my next version, which includes the "hang" soft key, and the "home" and "back" hard keys. These are hooked early and pass the key codes in all the apps.

I also removed the line that kills all the applications on suspend. I'm still puzzled by why they are doing that. The unit seems to work much better without it. No more missing processes and dead widgets after suspend.
[Android Head-Units] gustden:
That is the only reason I haven't put the updated version up. I still need to do some deeper investigation into this. I have a program installed called CPU spy that is supposed to measure the times at each of the CPU frequencies. I just reset the timers and ran a full wake lock program, will check in the morning. It's not even supposed to let wifi disconnect ( which it already has ). I would expect overnight, the entire time should show up under the 'deep sleep' heading, even with the wakelock.
[Android Head-Units] gustden:
I left torque, 2 nav apps (gmaps & here), pandora playing, set a forced wakelock, and forced wifi lock all running overnight. I also had a shell script running that printed a date/time to a file every minute. It was missing about 8 hours worth of time. Far as I can tell, she slept like a baby.
[Android Head-Units] sonof:
Seems to be working great. Please share the apk :)
[Android Head-Units] gustden:
V2.0 - 2/8/2017

Version 1: Initial version

Version 2:

Removed killAppWhenSleep(); - Eliminates tasks being killed on sleep

Added support for additional keys / Minor changes to example shell script ( launcher.sh )

HOME - hard key on unit

BACK - hard key on unit

HANG - steering wheel softkey

DVD - hard key on unit (if available)

EJECT- hard key on unit (if available)

CALL/BT - Fixed issue where key would not respond after call disconnect.

Please see "notes.html" included with the zip file for full key list, and more complete documentation. Let me know if you see any issues. File moved to 1st post of thread.
[Android Head-Units] gustden:
The exit code from an 'input keyevent' is always success, even if the app running doesn't act on it. Much easier to let it go through their code and do a more selective fire and forget. I was also concerned with taking extra time with processing, so I just launch the command and don't wait for a return. This allows me to do things like launch an application, wait a couple seconds, and perform an action like play without any concern of it taking too long. It works pretty good the way I am doing it.

There is a constant (serial) data stream from the MCU to the "android" side of things. From what I seen a button press vs a long press gives a single message on the android side. I did remove some code to allow a quick press, as they were limiting it to one press per second, and I wanted a double press (since long press didn't seem to be avalable). In the radio, a long press does scan the frequencies, but from what I can tell it is done in the MCU and the changes in frequency are communicated through the bus. I haven't even looked at the volume buttons, as they seem to be handled within the MCU.

The MCU may be a holdover from previous generations and does have some limitations. I am pretty happy with my unit in general especially considering the price point. I also enjoy digging into code, so really don't mind modifying things for how I want to use them.
[Android Head-Units] vassandrei:
I can't get Waze to launch from the script! If I do just

am start com.waze/com.waze.MainActivity

it gives me

Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.waze/.MainActivity }
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.waze/.MainActivity } from null (pid=5285, uid=2000) not exported from uid 10104
at android.os.Parcel.readException(Parcel.java:1546)
at android.os.Parcel.readException(Parcel.java:1499)
at android.app.ActivityManagerProxy.startActivityAsUser(ActivityManagerNative.java:2467)
at com.android.commands.am.Am.runStart(Am.java:766)
at com.android.commands.am.Am.onRun(Am.java:305)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
at com.android.commands.am.Am.main(Am.java:97)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:249)

I can launch it only through superuser in adb shell, and I can do it in one line like this

su -c am start com.waze/com.waze.MainActivity

but it doesnt want to work if I put that as a variable in the shell script.

How can I fix this?

For some reason google maps launches just fine without superuser priviliges :(
[Android Head-Units] gustden:
It looks like the activity you are trying to call is not defined as a launch point ( android.intent.category.LAUNCHER )

I looked in the manifest for waze, this should work: am start com.waze/com.waze.FreeMapAppActivity

Also, the "su -c" should have worked, if it worked on the command line. Did you check your su applicaition (SuperSU) to see if it got denied somehow? I use su -c from the script and haven't had issue.
[Android Head-Units] vassandrei:
Okay so apparently for some reason my new variable just wasn't working. When I put that command into the one for the "maps" variable it worked. Now all is well.

It's just fantastic now with the apps not closing. My background apps like the anti-radar keep working, my Spotify remembers and even continues playing where I left off... everything is wonderful! Even google voice search works great and launches apps and songs for me.

The only thing is that I can't set waze as my default app for navigating but that's more of a google thing from what I understand.

Anyway, with this mod the head unit is a million times better !!

Thank you for all your hard work!
[Android Head-Units] Polluti0n:
You have solved the most annoying problem with an otherwise great HU. Thank you so much for your work. This will benefit so many users.

-Polluti0n
[Android Head-Units] VWCC_GERMANY:
Could you please describe (or correct my below understanding) of the complete install process for your mod for an beginner?

As I understood I need:

- Root Accesss

- BusyBox installed

- Make backup of originally Sofia-1-C9-Server-V1.0.apk

- launcher.sh script must be placed in the /data directory ( /data/launcher.sh )

- Copy install.sh, launcher.sh or launcher_simple.sh and Sofia-1-C9-Server-V1.0.apk to the MCU or usb storage

- Perform install.sh

Thanks
[Android Head-Units] vassandrei:
Hey all,

Anyone else have location settings pop up on resume with the v2 button mod?
[Android Head-Units] gtxaspec:
Having some issues where the system will not sleep with the modified Server APK. Once ACC is cut, instead of going to sleep after a timeout, the unit shuts down. Happens with all versions of the Mod posted for 6.0. Anyone else have this opportunity? Re-flashed stock rom, installed nothing else, works fine until the modified APK is installed :( [MENTION=3076686]gustden[/MENTION]
[Android Head-Units] AssassinsLament:
As you a couple of you have mentioned this, I'm starting to think I'm having the same issue too. The thing is though, I made my own version of Server apk and didn't include any of the NoKill code in my version, only the custom keys code, and my joying seems to shut down also. I'll try to see if I can figure it out also, but sadly I just installed my Joying into my car, so my testing/coding will take a lot longer now. Hopefully gustden can figure it out.
[Android Head-Units] gtxaspec:
Hmmm... Is it too much trouble to start documenting where the no kill code is in the smali? Maybe a fresh set of eyes can solve this.
[Android Head-Units] edit:
I also have the issue but I only noticed that is happening constantly when I leave XiiaLive Pro on pause. Somehow I managed to find a workaround it (found a combination of settings that prevent the Xiia app from triggering a shutdown)

Wrote about it here : https://xdaforums.com/showpost.php?p=72208449&postcount=245
[Android Head-Units] AssassinsLament:
That would be up to gustden, since he's the original author of the mod. That said, it's pretty easy to figure out, it's just removal of a few lines of code.
[Android Head-Units] surfer63:
A simple diff -u on the apktool unpacked original and nokill version over the subfolder tree does the trick

command:

$ for file in NoKill-Sofia-1-C9-Server-V1.0/smali/*; do diff -u "$file" "Sofia-1-C9-Server-V1.0/smali/${file##*/}"; done > diff.txt

result: (the diff.txt file minus some superfluous unnecessary lines)

diff -u NoKill-Sofia-1-C9-Server-V1.0/smali/chip/ChipSofia$1.smali Sofia-1-C9-Server-V1.0/smali/chip/ChipSofia$1.smali
--- NoKill-Sofia-1-C9-Server-V1.0/smali/chip/ChipSofia$1.smali	2017-05-08 13:50:20.219366900 +0200
+++ Sofia-1-C9-Server-V1.0/smali/chip/ChipSofia$1.smali	2017-05-08 13:55:16.732110300 +0200
@@ -64,6 +64,8 @@
invoke-virtual {v0, v1}, Lui/DebugView;->msg(Ljava/lang/String;)V

.line 149
+ invoke-static {}, Lapp/ToolkitApp;->killAppWhenSleep()V
+
.line 150
const-string v0, "audio.hw.allow_close"

diff -u NoKill-Sofia-1-C9-Server-V1.0/smali/dev/ReceiverMcu.smali Sofia-1-C9-Server-V1.0/smali/dev/ReceiverMcu.smali
--- NoKill-Sofia-1-C9-Server-V1.0/smali/dev/ReceiverMcu.smali	2017-05-08 13:50:20.464415900 +0200
+++ Sofia-1-C9-Server-V1.0/smali/dev/ReceiverMcu.smali	2017-05-08 13:55:17.038140900 +0200
@@ -5382,6 +5382,8 @@
invoke-static {v5}, Lutil/ToolkitPlatform;->muteAmp(I)V

.line 1389
+ invoke-static {}, Lapp/ToolkitApp;->killAppWhenSleep()V
+
.line 1390
invoke-static {}, Lapp/ToolkitApp;->go2Sleep()V

@@ -5611,6 +5613,8 @@
goto/16 :goto_0

.line 920
+ nop
+
:sswitch_data_0
.sparse-switch
-0x78 -> :sswitch_6c

diff -u NoKill-Sofia-1-C9-Server-V1.0/smali/monitor/MonitorTop.smali Sofia-1-C9-Server-V1.0/smali/monitor/MonitorTop.smali
--- NoKill-Sofia-1-C9-Server-V1.0/smali/monitor/MonitorTop.smali	2017-05-08 13:50:25.959514700 +0200
+++ Sofia-1-C9-Server-V1.0/smali/monitor/MonitorTop.smali	2017-05-08 13:55:23.151752200 +0200
@@ -162,6 +162,8 @@
if-eqz v2, :cond_3

.line 144
+ invoke-static {}, Lapp/ToolkitApp;->killAppWhenSleep()V
+
.line 146
:cond_3
return-void
@@ -374,6 +376,8 @@
goto :goto_1

.line 92
+ nop
+
:array_0
.array-data 4
0x1

The lines with the + in front of it, are additional lines in the standard Sofia-1-C9-Server-V1.0

The lines with - in front of it (none, but as explanation), are additional lines in the Nokill version NoKill-Sofia-1-C9-Server-V1.0

note that I only compared the "pure" NoKill version with the standard. This NoKill version does not contain other mods
[Android Head-Units] gustden:
I'm not seeing this issue, using the key mod apk w/ no kill. Been standby/restoring perfectly. I am having it pause any music on key off, and playing on key on. Usually Pandora or Spotify. What music apps are you using? Are you using viper? I'm guessing it is related to a specific app.
[Android Head-Units] sanangel:
Is there a "no kill" version without changing the steering wheel keys for the Marshmallow firmware?
[Android Head-Units] ant0ni084:
Here you are. http://cloud.tapatalk.com/s/591073a59c9d4/Sofia-1-C9-Server-V1.0.apk

Inviato dal mio MI 5 utilizzando Tapatalk
[Android Head-Units] PsychoMcSatan:
Happened to me three drives in a row (full boot on car start), but my last couple restarts have now been fine. I'm using the nokill with just the SRC button changed to Google Search. Also running PowerAmp, Waze, Bluetooth tether, Torque. Have also swapped in the more complete Settings.apk. I've been pretty random with what I leave running when I shutdown, but I'll try to document from now on.

Thanks for you work!
[Android Head-Units] sweetnothings:
happened to me to on android 6 with the v6 version. (viper installed but only stock music apps running)

[MENTION=2550900]surfer63[/MENTION] enjoy your holidays bro :)
[Android Head-Units] gustden:
Are you leaving the music player playing when entering standby? I was having reboots coming out of standby occasionally, which seemed related to Pandora still playing. I can add a pause/stop to the key off for the apk you are using and see if that helps.

As a side note, is BT tether stable for you on 6? I have resorted to using a hotspot, as BT in general is very unstable for me on 6.
[Android Head-Units] PsychoMcSatan:
Could be that PowerAmp was still playing the times it rebooted. I'll keep an eye on that.

As for the BT tether, I've only had it running for a few days and not many drives, but haven't observed any issues yet.
[Android Head-Units] chammock:
hey gustden,

Thanks for the ACC_ON feature I have just upgraded and this works a treat, much more consistent function than resume (based on the 5 minute power down window).

I have a question regarding a key I have on my steering wheel of my Audi, the key is marked as Mode, it doesn't seem to trigger a function at present and to be honest I am not sure if it would register via the MCU (based on experience with a different headunit model) but wondered if there is some sort of debug mode I could define so I could press the button and see if it registers as a button press in a log or on the screen in a toast?

Thanks
[Android Head-Units] edit:
I am using Viper and with XiiaLive Pro (probably with XiiaLive non-Pro free version behaves the same) and the unit shutdown instead of going to sleep.

Wrote more about i, in detail, here and it's easy to replicate: https://xdaforums.com/showpost.php?p=72208449&postcount=245

I can't tell if it's from your mod or simply a bug but there is definitely a problem.

Thank you !
[Android Head-Units] gustden:
I have been using it. Once it disconnects and reconnects, it shows BT tethering is active, but the connection doesn't work. I have to toggle BT off and back on on the phone before the data can actually be used.
[Android Head-Units] Astur_Torque:
Can you helpme?

I am unable to map steering wheel keys...

I have a Opel dedicated version of Joying 2GB, with canbus box
[Android Head-Units] sweetnothings:
Try to press and hold steering wheel button while touching the button to map to on HU.
[Android Head-Units] vassandrei:
gustden, sorry to bug you -- I just set up the newest version of the mod. I copied the script to switch from navi app and the last app like you shared, but it doesnt seem to be working. Here's what I'm using:

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
;;

I've changed $maps to be "am start com.waze/com.waze.FreeMapAppActivity"

because I use waze
[Android Head-Units] gustden:
See if this works better:

x=`dumpsys activity activities | grep "Run #" | cut -f 13 -d" "| head -1 | grep waze`
if [ "$x" = "" ]
then
$maps
else
am start `dumpsys activity activities | grep "Run #" | cut -f 13 -d" " | grep -v launcher | grep -v systemui | grep -v waze |head -1`
fi
;;
[Android Head-Units] wanb1i:
Is there a version of this that just has the Google Voice for PTT Key, Maps Toggle to Previous APP and No Kill for the Marshmallow Firmware? I checked the 1st Page, but I only saw 5.1.1 related apps.
[Android Head-Units] dayanandgp:
[MENTION=3076686]gustden[/MENTION] Quick question, i installed the latest version and have Poweramp running. The script pauses the music but for some reason doesnt resume after wakeup. Do i need to modify or add power amp to " RESUME " use case ?

I thought ACC_ON would have been enough to continuing playing the music...help appreciated !!

97) # ACC_ON - execute on key on

$play

;;

98) # ACC_OFF - executes on key off

$pause;

;;

99) # RESUME - executes on resume of system

# Commands to be executed on resume
[Android Head-Units] gustden:
I don't use poweramp, all the players I use the $pause / $play seem to work.

You might want to try running an "am start" command for poweramp before you $play. Something like:

97) # ACC_ON - execute on key on

( $poweramp && sleep 2 && $play ) &

;;

- where $poweramp is the start command.
[Android Head-Units] swanie2000:
Just to chime in on this subject.

I am also having trouble getting PowerAmp to automatically play.

However, I am not trying to launch it every time the radio boots.

I am using PowerAmp in rotation with the SRC button.

Pandora

PowerAmp

Stock Video Player

Radio

Everything seems to work.

Example: When you press the SRC button when Pandora is playing; Pandora will pause, PowerAmp will open, but it will not play, until you press the play button.

Press the SRC button again, PowerAmp pauses, then the stock video player opens, and begins to play.

Press the SRC button again, the video player pauses, and the radio opens and plays.

Press the SRC button again, the radio stops, and pandora opens up and begins to play.

It will loop through all the sources as expected, but each time Power Amp is brought to the front, it will not press the play button. You have to manually touch it every time. I have experimented with putting PowerAmp in a different order in the rotation, but no matter where it is, it refuses to play automatically.

I was thinking it was something I did wrong when editing the code, but after reading that others are having nearly the same problem, it wonder if it is not a bug in PowerAmp? Maybe not a bug, but needing a different command?
[Android Head-Units] gustden:
I just added updates for the latest Joying ROM dated 5/8/2017 to the first post of the thread.

There are 3 separate files depending on what you want. I believe that the 2nd one is what your looking for. I have had issues with the music player advancing with the no kill patch, so I added a "pause" on sleep to the nokill code.

It is working real good on my unit with the latest ROM. There is a bug with the current ROM where google navigation does NOT speak while listening to the RADIO. This is unrelated to this mod.

All include additional navigation apps listed in the navi_app.txt file within the apk.

V6.1-Sofia-1-C9-Server_NOKILL.zip - Original file with task killer removed, pauses music before sleep, .

V6.1-Sofia-1-C9-Server_NOKILL_GVS.zip - Task killer removed, Google Voice Search on 'SRC' key, pauses music before sleep.

V6.1-Custom_Keys-Mods.zip - Complete key modifications ( requires launcher.sh )
[Android Head-Units] wanb1i:
Thank you! I will test this tomorrow! :D

You're correct, the 2nd one is what I wanted and it works GREAT!

Thank you again!
[Android Head-Units] dayanandgp:
Thanks ! will give it a try
[Android Head-Units] Stoersender:
So I just upgraded my HU to the version from May ,12th.

When I replace the apk with V6.1-Sofia-1-C9-Server_NOKILL the HU reboots after a few minutes and none of the keys are working.
[Android Head-Units] chammock:
I am running version 4.1 as I am still on Android 5. If I try and use Google Voice while in the stock radio app or the joying DAB radio app it doesn't mute the audio (spotify and tunein radio work fine).

I have been through this thread and it looks like this was a bug fixed in 4.1 can anyone confirm if they had this issue and how they resolved it?
[Android Head-Units] gustden:
The changes put in 4.1 fixed it for the android generated music (spotify, tunein, etc), but does not lower the volume when playing radio.
[Android Head-Units] chammock:
Thanks gustden, do you know what maybe involved in fixing for fm and DAB radio apps (I assume if it was something simple you would have done it already)? Or is that outside of the scope of this project? I assume if it was broken in 4.0 and you fixed it in 4.1 you must have an idea of the scale of the problem?

Also any news on gtxaspec request for adding audi steering wheel up and down controls to the app? I would be interested in this as well as the audi mode button. Happy to do whatever testing or fact finding you need to assist with the development.
[Android Head-Units] Astur_Torque:
How do you set poweramp in rotation? I only have Radio, BT and aux (because I freeze original apk music)

About autoplay, you can put tasker with intent:

-----------------

Action: com.maxmpz.audioplayer.API_COMMAND

Extra: cmd:1

Target: Service

---------------

and the trigger Poweramp to the front or something like that
[Android Head-Units] swanie2000:
That sounds like the stock rotation of stock aps?

I am using Gustden's Joying 2GB - Steering wheel key customization - (NO KILL).

https://xdaforums.com/android-auto/android-head-units/joying-2gb-steering-wheel-key-t3543390

I am still using ver 4.1, as I haven't updated to 6.0 yet. At the bottom of that post are all the different versions.

Download one, unzip it, and there are some instructions inside. It still takes a bit of programming code experience, but I was able to make changes to the provided script, to change what apks are rotated through when you press the SRC button. Make sure you edit the launcher.sh file with Notepad++ or similar. Regular text editors will break the code when it saves it. NotePad++ is free, and does a nice job displaying the code, to help you follow it.

As for Tasker, I am sure I could get something working to automatically press play on power amp, but I didn't need to do anything special before, it used to work, and now it doesn't. Not sure what changed. Haven't had the time to sit in the truck and mess with it. Maybe next weekend.
[Android Head-Units] nyogtha:
Hi! Is there a way to exclude some of the media players from automatic pause/start on acc off/on? I use a radio stream app for Norwegian radio which I don't want paused when I leave the car, but I'd like to keep the functionality for Spotify...
[Android Head-Units] KyeDavey:
Is there any known fix for the Google Navigation not speaking whilst the radio is playing in the current Rom?