Class Storage#upgradeApplication

storage

Class Summary
Constructor Attributes Constructor Name and Description
 
Storage#upgradeApplication(successCallback, errorCallback, options)

Upgrades application stored in local or USB using the one from remote server.

Class Detail

Storage#upgradeApplication(successCallback, errorCallback, options)

Upgrades application stored in local or USB using the one from remote server. Remote server information(serverIP and serverPort) is set in display menu.
New application will be launched at next boot time and old application will be deleted at the same time. Application on the server should be at
"http://serverIP:serverPort/procentric/scap/application/scap_app.zip" or
"http://serverIP:serverPort/application/com.lg.signage.ipk"

Note : Size of scap_app.zip, com.lg.signage.ipk (zip or ipk file itself and extracted files) should not exceed free storage size of the platform.

When application is being upgraded, following files exist at the same time :
- old application
- downloaded scap_app.zip or com.lg.signage.ipk
- content data stored by storage.copyFile() API and
- new application extracted from the downloaded scap_app.zip or com.lg.signage.ipk
So before upgrading the application, call storage.getStorageInfo() and check the free storage size.

Note : Application should not include 'content' directory under application's root folder.
(It is reserved for Storage.copyFile() API.)

function upgradeZipApplication() {
   var successCb = function (cbObject) { 
     console.log("zip type application Update successful"); 
   };

   var failureCb = function(cbObject) { 
     var errorCode = cbObject.errorCode;
     var errorText = cbObject.errorText; console.log( " Error Code [" + errorCode + "]: " + errorText); 
   };

   var options = {
      to : Storage.AppMode.USB,
      recovery : false
   };   
   
   var storage = new Storage(); 
   storage.upgradeApplication(successCb, failureCb, options);
}

//Sample code for ipk type
function upgradeIpkApplication() {
   var successCb = function (cbObject) { 
     console.log("ipk type Application Update successful"); 
   };

   var failureCb = function(cbObject) { 
     var errorCode = cbObject.errorCode;
     var errorText = cbObject.errorText; console.log( " Error Code [" + errorCode + "]: " + errorText); 
   };

   var options = {
      type : ipk, 
      to : Storage.AppMode.USB,
      recovery : false
   };   
   
   var storage = new Storage(); 
   storage.upgradeApplication(successCb, failureCb, options);
}
Parameters:
{Function} successCallback
success callback function.
{Function} errorCallback
failure callback function.
{Object} options
PropertyTypeDescriptionRequired
typeStringzip : copmressed by zip same as 'scap_app.zip'. Defualt value.
ipk : compressed by ipk same as 'com.lg.signage.ipk' for JS Service.
optional
toStringStorage.AppModerequired
recoveryBooleantrue : Recover old application if there was an error during upgrade. Default value.
false : Remove old application to obtain free storage space.
optional
Since:
1.0, 1.1 options.to options.recovery added, 1.3 option.type added
Returns:

After the method is successfully executed, successCallback is called without any parameter.
If an error occurs, errorCallback is called with errorCode and errorText.

See:
Storage.removeApplication()