Restarting an AIR desktop application

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Restarting an AIR desktop application

After24
Hello,

I need the AIR application I'm working on to be able to restart itself after
an update process.

The way to achieve this seems to be :

/var productManager:ProductManager = new ProductManager("airappinstaller");
productManager.launch("-launch " +
NativeApplication.nativeApplication.applicationID);/

But this code doesn't works. I think that it is because the
<allowBrowserInvocation></allowBrowserInvocation> tag of the application
descriptor must bet set to true.

But my application is package as a captive runtime bundle and in that case
the <allowBrowserInvocation> tag cannot be used.

Does someone has a solution to solve this problem ?

Thanks.
Vincent.



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Restarting an AIR desktop application

Alex Harui-2
A hack might be to install two apps.  The first app is your app.  The other app can be launched via NativeProcess to launch your app.

HTH,
-Alex

On 7/4/18, 12:02 AM, "After24" <[hidden email]> wrote:

    Hello,
   
    I need the AIR application I'm working on to be able to restart itself after
    an update process.
   
    The way to achieve this seems to be :
   
    /var productManager:ProductManager = new ProductManager("airappinstaller");
    productManager.launch("-launch " +
    NativeApplication.nativeApplication.applicationID);/
   
    But this code doesn't works. I think that it is because the
    <allowBrowserInvocation></allowBrowserInvocation> tag of the application
    descriptor must bet set to true.
   
    But my application is package as a captive runtime bundle and in that case
    the <allowBrowserInvocation> tag cannot be used.
   
    Does someone has a solution to solve this problem ?
   
    Thanks.
    Vincent.
   
   
   
    --
    Sent from: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-flex-users.2333346.n4.nabble.com%2F&data=02%7C01%7Caharui%40adobe.com%7C4b23f6cfe7aa4542e9a808d5e17c1d12%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C1%7C636662845537893849&sdata=Yu8gQDFA2nf8lS6AolnOmm1xBmoRYLzkxZWT6swDVKY%3D&reserved=0
   

Reply | Threaded
Open this post in threaded view
|

Re: Restarting an AIR desktop application

After24
This post was updated on .
hi Alex,

It means the user will have to install two applications ?



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Restarting an AIR desktop application

Alex Harui-2
Well, it depends on what you mean by "install".  The Apache Flex Installer 3.3.2 that we hope to release soon is doing something similar.  When you install Apache Flex Installer 3.3.2 for Windows, you are installing a 32-bit app.  When that 32-bit app runs, it automatically downloads a 64-bit app into the Application Storage folder.  Once the 64-bit app is there, the 32-bit app launches the 64-bit app.  So you only installed one thing once, but it brought down other things.

It might also be possible to package the second app as part of the captive runtime bundle.

HTH,
-Alex

On 7/4/18, 12:31 AM, "After24" <[hidden email]> wrote:

    hi Alex,
   
    It means the user will have to install to applications ?
   
   
   
    --
    Sent from: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-flex-users.2333346.n4.nabble.com%2F&data=02%7C01%7Caharui%40adobe.com%7C14a8c5a7b91549780b6f08d5e1801cb8%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C1%7C636662862712127935&sdata=aYLrNn%2FkoWq0PFeefvHu51g6kjOWHr2pvQ4R0J82cXI%3D&reserved=0
   

Reply | Threaded
Open this post in threaded view
|

Re: Restarting an AIR desktop application

OmPrakash Muppirala
In reply to this post by After24
Perhaps you can try to do what the Flex Installer does?

The gist is to download the new file, execute it and then exit itself after
a short timeout.

Please take a look at:
https://github.com/apache/flex-utilities/blob/master/installer/src/org/apache/flex/packageflexsdk/view/UpdaterDialog.mxml

Function: installFromFile()

Thanks,
Om


On Wed, Jul 4, 2018, 12:02 AM After24 <[hidden email]> wrote:

> Hello,
>
> I need the AIR application I'm working on to be able to restart itself
> after
> an update process.
>
> The way to achieve this seems to be :
>
> /var productManager:ProductManager = new ProductManager("airappinstaller");
> productManager.launch("-launch " +
> NativeApplication.nativeApplication.applicationID);/
>
> But this code doesn't works. I think that it is because the
> <allowBrowserInvocation></allowBrowserInvocation> tag of the application
> descriptor must bet set to true.
>
> But my application is package as a captive runtime bundle and in that case
> the <allowBrowserInvocation> tag cannot be used.
>
> Does someone has a solution to solve this problem ?
>
> Thanks.
> Vincent.
>
>
>
> --
> Sent from: http://apache-flex-users.2333346.n4.nabble.com/
>
Reply | Threaded
Open this post in threaded view
|

Re: Restarting an AIR desktop application

After24
Hi Alex, Hi Om,

Thank you both for your answers.

Alex I gave a try to your solution by creating a simple launcher.app

When it's update is complete, the main application open the launcher app
using the "usr/bin/open" command and closed itself, than the launcher.app re
open the main application the same way.

It works great but then I release the launcher.app size is 38 Mb even if
laucher.swf weight only 778 bytes because of the AIR runtime
encapsulation... so this solution is not viable.

Om, I gave a try to the executeFile method you suggest but I get the
following error :

Error #3214: NativeProcessStartupInfo.executable does not specify a valid
executable file


Vincent.



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Restarting an AIR desktop application

Alex Harui-2
Hi,

Just so we understand, having another 38Mb download is not viable because of the time it takes to download it, or something else?

If what your launcher app does is simple enough, you could look into writing them as shell and batch scripts or tiny native apps.

HTH,
-Alex

On 7/5/18, 2:26 AM, "After24" <[hidden email]> wrote:

    Hi Alex, Hi Om,
   
    Thank you both for your answers.
   
    Alex I gave a try to your solution by creating a simple launcher.app
   
    When it's update is complete, the main application open the launcher app
    using the "usr/bin/open" command and closed itself, than the launcher.app re
    open the main application the same way.
   
    It works great but then I release the launcher.app size is 38 Mb even if
    laucher.swf weight only 778 bytes because of the AIR runtime
    encapsulation... so this solution is not viable.
   
    Om, I gave a try to the executeFile method you suggest but I get the
    following error :
   
    Error #3214: NativeProcessStartupInfo.executable does not specify a valid
    executable file
   
   
    Vincent.
   
   
   
    --
    Sent from: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-flex-users.2333346.n4.nabble.com%2F&data=02%7C01%7Caharui%40adobe.com%7Cd65ce551d48b4729222b08d5e2595fd2%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C1%7C636663795844407813&sdata=W4lf%2BvBzfmu%2BPMVEFbybnQAJK46Xz7Z4c2ozLfmMTJ0%3D&reserved=0
   

Reply | Threaded
Open this post in threaded view
|

Re: Restarting an AIR desktop application

hugo
In reply to this post by After24
Check this out: https://github.com/SolidSoft-Lda/AIR-AutoUpdate
This AutoUpdate engine auto restart the Desktop App after the update
(compatible with macOS, Win-32 and Win-64).



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Restarting an AIR desktop application

After24
Alex,

Yes, I was a bit reluctant about the idea of doubling the bundle size only
to be able to restart the application.

But finally, Om's suggestion turned out to work perfectly (I wasn't setting
a valid path to my executable file).

Thank you Hugo, your link is very interesting. The restart method used here
is based on the NativeProcess object too and the way the executable file is
constructed allowed me to understand my mistake.

Updating an Air dekstop application with captive runtime is perfectly
viable. The only remaining issue I encounter is the fact that, on Windows,
it is not allowed to write files into the ProgramFiles directory. I don't
know if there is a way to circumvent this restriction programmatically ? My
workaround is to set the .msi installer to copy the application files at the
root of the system hard drive instead of the programFiles directory.

Thank you all.

Vincent.




--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Restarting an AIR desktop application

hugo
I spent a lot of time on this issue and a working solution for me for almost
a year.

- 0 external runtime dependencies: AIR captive runtime on both Windows and
macOS
- Optimal processor architecture: I provide 3 options: macOS, Win-32 and
more recently Win-64
- 0 Windows security issues about folders (on C:\ you may have security
issues): I install on Main Drive:\User Documents\AppData\roaming\My App Id
(ex: C:\Users\hugo\AppData\roaming\pt.mygreatecompany.greatapp) - This is
the same strategy and Spotify Windows App for years (User Documents folder
change from Windows Version and language)
- 0 dependencies of external dlls: For example, I have an ANE for Toast that
depend on C++ .NET runtime, so I isulated the needed files and bring with
the App folders (it turns out that was only 2 small dlls and the license for
this 2 dlls allows to do that)
- And last but not least an auto updater mechanism tested on about 10
combinations of Windows versions + macOS



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Restarting an AIR desktop application

Nemi
In reply to this post by After24
What package type are you using? If native installer, try
https://github.com/pwalczyszyn/nativeapplicationupdater

Anyway, here it starts and exits app to do restart:
https://github.com/pwalczyszyn/nativeapplicationupdater/blob/master/src/com/riaspace/nativeUpdater/NativeApplicationUpdater.as#L367-L371

Also note this line:
setTimeout(installUpdate, 10); // This is a hack for windows platform as
download complete event is fired before file is released



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Restarting an AIR desktop application

After24
Hi Nemi,

Thank you.

I already implement a restart method that works based on Alex, Om and Hugo
tips.

For those who can be interested :

public  function restartApplication():void
{
   var applicationDescriptor:XML =
NativeApplication.nativeApplication.applicationDescriptor;
   var xmlns:Namespace = new Namespace(applicationDescriptor.namespace());
   var applicationName:String = applicationDescriptor.xmlns::filename;
   var nativeProcessStartupInfo:NativeProcessStartupInfo = new
NativeProcessStartupInfo();
   var nativeProcess:NativeProcess = new NativeProcess();
   var applicationExecutable:File;

   if (Capabilities.os.indexOf("Win") > -1)
   {
        applicationExecutable = new
File(File.applicationDirectory.nativePath + "/" + applicationName + ".exe");

   }else{
 
        applicationExecutable = new
File(File.applicationDirectory.nativePath.replace("Resources", "MacOS/" +
applicationName));
   }

   nativeProcessStartupInfo.executable = applicationExecutable;
   nativeProcess.start(nativeProcessStartupInfo);
   NativeApplication.nativeApplication.exit();
}



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/