Kodi Community Forum

Full Version: Internet Archive Game Launcher
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Yes, Zach, and of course I sent you the two commands that I added to the main.py code and that effectively kill RetroArch.

Right now I can not but as soon as I can I'll upload it to you here. I'm not at home, sorry.

Really, they are two different commands launched on Android and I imagine one of them does the magic.

What actually do is throw the three (the one that is included in IAGL and the second one's i've added), so I do not know which of the three is the one that does the work. But if I leave only the initial one, the one that comes with your IAGL, it does not work.

Again, thanks very much for your addon. It's marvellous.
Sorry, "sent" not, I wanted to say "will send"
In my modified main.py I execute three commands.

The original of your addon, and these two:

'/system/xbin/su -c "/system/bin/killall -SIGKILL com.retroarch"'

and

'/system/xbin/su -c "/system/bin/am force-stop com.retroarch"'


I do not know which of the last two does it, but if I leave only the original, then it does not work. It does not kill RetroArch. I hope it serves you somehow and again, thank you very much for such a wonderful addon.
(2018-11-17, 00:19)lunamoon Wrote: [ -> ]In my modified main.py I execute three commands.

The original of your addon, and these two:

'/system/xbin/su -c "/system/bin/killall -SIGKILL com.retroarch"'

and

'/system/xbin/su -c "/system/bin/am force-stop com.retroarch"'


I do not know which of the last two does it, but if I leave only the original, then it does not work. It does not kill RetroArch. I hope it serves you somehow and again, thank you very much for such a wonderful addon.
 Thanks.  I'm surprised you need this in the first place.  Not sure if you can get a debug log from your box or not when trying to launch a game, but that might be helpful.

The second command:
xml:

'/system/xbin/su -c "/system/bin/am force-stop com.retroarch"'
Is essentially the same as the one already included in the addon, but run as root.

I'm hesitant to add this one:
xml:

'/system/xbin/su -c "/system/bin/killall -SIGKILL com.retroarch"'
Because, according to the documentation, "SIGKILL is used as a last resort when terminating processes in most system shutdown procedures if it does not voluntarily exit in response to SIGTERM."  I'm guessing you could potentially cause issues if the program was killed when say writing to a file.

It could be an issue with the way the command is sent.  My addon tries two different ways to send commands in Android (since android change permissions/access to 'system/bin/am' in recent versions of the OS).  To determine if thats the issue I'd need a debug log.
Hello, Zach

Sure enough, I saw that you were trying to throw the am force-stop command in two different ways, but as I said, at least I could not kill RetroArch.

So I tried to launch the same command but using the root user and also tried using the kill command. And I checked that it worked.

Although it is true that the use of the kill command is drastic, but we achieve the goal, which is to kill a possible Retroarch that was running at that moment.

I send you the changed code in the function launch_external_android. And if you need it, tell me and I'll send you the Kodi log. Again, thank you very much for your great addon.

This is the changed code:   



def launch_external_android(self):
        import subprocess
        self.update_external_launch_command()
        if self.external_launch_command != 'none':
            if xbmc.Player().isPlaying():
                xbmc.Player().stop()
                xbmc.sleep(500)
            xbmc.audioSuspend()
            xbmc.enableNavSounds(False)
            android_stop_command = '/system/bin/am force-stop com.retroarch'
            android_stop_command2 = '/system/xbin/su -c "/system/bin/killall -SIGKILL com.retroarch"'
            android_stop_command3 = '/system/xbin/su -c "/system/bin/am force-stop com.retroarch"'
            try:
                if self.IAGL.get_setting_as_bool(self.IAGL.handle.getSetting(id='iagl_enable_android_stop_command')):
                    xbmc.log(msg='IAGL:  Sending Android Stop Command: %(android_stop_command)s' % {'android_stop_command': android_stop_command}, level=xbmc.LOGNOTICE)
                    external_command_stop = subprocess.call(android_stop_command,shell=True,executable='/system/bin/sh')
                    xbmc.sleep(500)
                    external_command_stop = subprocess.call(android_stop_command2,shell=True,executable='/system/bin/sh')
                    xbmc.sleep(500)
                    external_command_stop = subprocess.call(android_stop_command3,shell=True,executable='/system/bin/sh')
                    xbmc.sleep(500)
                xbmc.log(msg='IAGL:  Sending Android Launch Command: %(external_command)s' % {'external_command': self.external_launch_command}, level=xbmc.LOGNOTICE)
                external_command = subprocess.call(self.external_launch_command,shell=True,executable='/system/bin/sh')
                xbmc.sleep(500)
                # Launch twice because it seems it doesn't open first time
                xbmc.log(msg='IAGL:  Sending Android Launch Command: %(external_command)s' % {'external_command': self.external_launch_command}, level=xbmc.LOGNOTICE)
                external_command = subprocess.call(self.external_launch_command,shell=True,executable='/system/bin/sh')
            except Exception as exc:
                xbmc.log(msg='IAGL:  Unable to use subprocess call.  Exception %(exc)s' % {'exc': exc}, level=xbmc.LOGNOTICE)
                if self.IAGL.get_setting_as_bool(self.IAGL.handle.getSetting(id='iagl_enable_android_stop_command')):
                    xbmc.log(msg='IAGL:  Sending Android Stop Command: %(android_stop_command)s' % {'android_stop_command': android_stop_command}, level=xbmc.LOGNOTICE)
                    os.system(android_stop_command)
                    xbmc.sleep(500)
                    os.system(android_stop_command2)
                    xbmc.sleep(500)
                    os.system(android_stop_command3)
                    xbmc.sleep(500)
                xbmc.log(msg='IAGL:  Sending Android Launch Command: %(external_command)s' % {'external_command': self.external_launch_command}, level=xbmc.LOGNOTICE)
                os.system(self.external_launch_command)
                # Launch twice because it seems it doesn't open first time
                xbmc.sleep(500)
                xbmc.log(msg='IAGL:  Sending Android Launch Command: %(external_command)s' % {'external_command': self.external_launch_command}, level=xbmc.LOGNOTICE)
                os.system(self.external_launch_command)
            xbmc.audioResume()
            xbmc.enableNavSounds(True)
            return True
        else:
            return False
I think only launching second command (killall -SIGKILL) it will achieve kill RetroArch. I launch the three ones so I am sure we kill RetroArch.

Perhaps, we could send SIGTERM first, then check if RetroArch is stopped, and if it is running, then send SIGKILL.

But I think that it is not necessary, really the objective is to stop the com.retroarch process and I really believe that what it was doing is not important at the moment we try to stop it.

Now I do not have time, but later, I will do a test by sending the original IAGL command (am force-stop) and then I will change it to only launch the SIGKILL signal and send you the logs of the two tests.
Hello again, Zach.

I already have the two logs.

I have seen that IAGL always enters by the first form of call you use (subprocess.call), and no exception is thrown, so os.system is not called.

However, as I have already mentioned, and as you will see in the logs if you want, I first launched the game Galaxian (MAME2003 core), and then the Pac-Man plus. And although in the log we can see that he is trying to launch the Pac-Man, I can assure you that the Galaxian is still opening for me.

However, by changing the main.py and launch SIGKILL signal to RetroArch, although in the log we still see the same, however, when launching the Pac-Man Plus, this game opens and not the Galaxian.

I do not know if you want I paste logs here or there is some way to make them arrive you, but if you are interested, tell me and I will send them to you in the way you indicate.

Greetings.
(2018-11-17, 21:10)lunamoon Wrote: [ -> ]Hello again, Zach.

I already have the two logs.

I have seen that IAGL always enters by the first form of call you use (subprocess.call), and no exception is thrown, so os.system is not called.

However, as I have already mentioned, and as you will see in the logs if you want, I first launched the game Galaxian (MAME2003 core), and then the Pac-Man plus. And although in the log we can see that he is trying to launch the Pac-Man, I can assure you that the Galaxian is still opening for me.

However, by changing the main.py and launch SIGKILL signal to RetroArch, although in the log we still see the same, however, when launching the Pac-Man Plus, this game opens and not the Galaxian.

I do not know if you want I paste logs here or there is some way to make them arrive you, but if you are interested, tell me and I will send them to you in the way you indicate.

Greetings.
Thanks for the info.  The issue I think lies with Android, and different versions of the OS act differently.
Newer versions of Android, if permission is denied with subprocess will fail with exception and then call os.system.  It looks like your system doesn't have permission and it doesn't raise an error.   I'm willing to bet if you swapped the original commands between subprocess.call and os.system as follows, it will work for you:
python:

try:
    if self.IAGL.get_setting_as_bool(self.IAGL.handle.getSetting(id='iagl_enable_android_stop_command')):
        #external_command_stop = subprocess.call(android_stop_command,shell=True,executable='/system/bin/sh')
        os.system(android_stop_command)
        ...
        #external_command = subprocess.call(self.external_launch_command,shell=True,executable='/system/bin/sh')
        os.system(self.external_launch_command)
except Exception as exc:
    ...
The easiest thing to do here is probably just make an 'advanced setting' to let the user force a certain command type.
Probably, I wrote you because if I change the code to directly launch the call to os.system instead of calling subprocess.call, then it may work. I haven't tested it, but in next update from repository, this modification will be deleted, as you know.

But you're right. Maybe in some OS an exception is thrown and in others like mine, IAGL doesn't launch exception; and therefore, directly fails, it does not kill the com.retroarch process, but in the log it seems that it does.

So, if you want, you can incorporate, as I have done, the command to send the SIGKILL signal, so you make sure that in those systems, like mine, you kill the RetroArch process.

It's up to you.

Again, Zach, thank you very much for this wonderful addon.
On v18, I added the repo zip listed here and when selecting it I'm getting "Could not connect to repository".

Log

Also, not sure if it matters, but I'm running current master on a Debug build with the portable mode (-p cmd argument).
(2018-11-18, 18:38)velocity Wrote: [ -> ]On v18, I added the repo zip listed here and when selecting it I'm getting "Could not connect to repository".

Log

Also, not sure if it matters, but I'm running current master on a Debug build with the portable mode (-p cmd argument).
It shouldn't matter.  I just checked and could access the repository.  The repository is hosted on github here, so as long as you have access to the interenet and github is up, you should be able to get to it.
The board language is English only please.
Just installed your repo and addon @zachmorris and wow! Media centre software has definitely now come full circle. I’m from the Windows MCE era, and had Game Ex as a launcher for emulators. This is a fantastic addon.....

Now to replicate it on the 60” screen Laugh

Thanks for the hard work.
how do i go about to change the backgrounds in all the menus(the ones that say internet archive with a grey background ,to a custom one?
So, im still a bit confused. Do we still need to use a special Retroplayer build to play games with Kodi video player? Has the support been added in the latest Leia yet? Can we just install binary liberto cores on the latest Leia to use with IAGL??