Version: Smart Feature Phone 3.0

AppsManager service

Instanciating the service#

Load the following scripts:

<script src="http://127.0.0.1/api/v1/shared/core.js"></script>
<script src="http://127.0.0.1/api/v1/shared/session.js"></script>
<script src="http://127.0.0.1/api/v1/apps/service.js"></script>

You can then get an instance of the service with code similar to:

const session = new lib_session.Session();
const sessionstate = {};
let _appsManager = null;
sessionstate.onsessionconnected = function () {
console.log(`AppsManager onsessionconnected`);
lib_apps.AppsManager.get(session).then((AppsManagerService) => {
console.log(`Got AppsManager : #AppsManagerService.service_id}`);
_appsManager = AppsManagerService;
}).catch((e) => {
console.log(`Error calling AppsManager service${JSON.stringify(e)}`);
_appsManager = null;
});
};
sessionstate.onsessiondisconnected = function () {
console.log(`AppsManager onsessiondisconnected Daemon Crashed`);
};
// On desktop version, set ENV WS_RUNTIME_TOKEN=secrettoken
session.open('websocket', 'localhost', 'secrettoken', sessionstate, true);

Then the developer can use _appsManager as AppsManager service instance.

This service implements the AppsEngine interface.


AppsInstallState enumeration#

{
INSTALLED,
INSTALLING,
PENDING
}

AppsServiceError enumeration#

{
APP_NOT_FOUND,
CANCELED,
CLEAR_DATA_ERROR,
DEPENDENCIES_ERROR,
DISK_SPACE_NOT_ENOUGH,
DOWNLOAD_MANIFEST_FAILED,
DOWNLOAD_PACKAGE_FAILED,
DUPLICATED_ACTION,
INVALID_APP_NAME,
INVALID_ICON,
INVALID_START_URL,
INVALID_STATE,
INVALID_MANIFEST,
INVALID_PACKAGE,
INVALID_SIGNATURE,
INVALID_CERTIFICATE,
NETWORK_FAILURE,
FILESYSTEM_FAILURE,
PACKAGE_CORRUPT,
REGISTRATION_ERROR,
REINSTALL_FORBIDDEN,
UPDATE_ERROR,
UNKNOWN_ERROR
}

AppsServiceState enumeration#

{
INITIALIZING,
RUNNING,
TERMINATING
}

AppsStatus enumeration#

{
ENABLED,
DISABLED
}

AppsUpdateState enumeration#

{
IDLE,
AVAILABLE,
DOWNLOADING,
UPDATING,
PENDING
}

ClearType enumeration#

{
BROWSER,
STORAGE
}

ConnectionType enumeration#

{
WI_FI_ONLY,
ANY
}

TokenType enumeration#

{
ACCOUNT,
RESTRICTED
}

AppsObject dictionnary#

{
name: string,
installState: <a href="#enumeration_AppsInstallState">AppsInstallState</a>,
manifestUrl: string,
removable: boolean,
status: <a href="#enumeration_AppsStatus">AppsStatus</a>,
updateManifestUrl: string,
updateState: <a href="#enumeration_AppsUpdateState">AppsUpdateState</a>,
updateUrl: string,
allowedAutoDownload: boolean,
preloaded: boolean
}

AppsOptions dictionnary#

{
autoInstall: boolean?
}

DownloadFailedReason dictionnary#

{
appsObject: <a href="#dictionary_AppsObject">AppsObject</a>,
reason: <a href="#enumeration_AppsServiceError">AppsServiceError</a>
}

Token dictionnary#

{
keyId: string,
macKey: string,
tokenType: <a href="#enumeration_TokenType">TokenType</a>
}

UpdatePolicy dictionnary#

{
enabled: boolean,
connType: <a href="#enumeration_ConnectionType">ConnectionType</a>,
delay: integer
}

TokenProvider callback object#

Creating a TokenProvider object#

Use code similar to:

class MyCallbackObject extends lib_apps.TokenProviderBase {
constructor(service, session) {
super(service.id, session);
}
getToken(...) {
...
}

Methods#

getToken

// tokenType: TokenType
getToken(tokenType)

Resolves with Token

Rejects with void

AppsEngine Interface#

Methods#

  cancelDownload checkForUpdate clear getAll getApp getState getUpdatePolicy installPackage installPwa setEnabled setTokenProvider setUpdatePolicy uninstall update verify

// updateUrl: string
cancelDownload(updateUrl)

Resolves with AppsObject

Rejects with AppsServiceError


// updateUrl: string
// appsOption: AppsOptions
checkForUpdate(updateUrl, appsOption)

Resolves with boolean

Rejects with AppsServiceError


// manifestUrl: string
// dataType: ClearType
clear(manifestUrl, dataType)

Resolves with boolean

Rejects with AppsServiceError


getAll()

Resolves with [AppsObject]?

Rejects with AppsServiceError


// manifestUrl: string
getApp(manifestUrl)

Resolves with AppsObject

Rejects with AppsServiceError


getState()

Resolves with AppsServiceState

Rejects with void


getUpdatePolicy()

Resolves with UpdatePolicy

Rejects with void


// updateUrl: string
installPackage(updateUrl)

Resolves with AppsObject

Rejects with AppsServiceError


// manifestUrl: string
installPwa(manifestUrl)

Resolves with AppsObject

Rejects with AppsServiceError


// manifestUrl: string
// status: AppsStatus
setEnabled(manifestUrl, status)

Resolves with AppsObject

Rejects with AppsServiceError


// provider: TokenProvider
setTokenProvider(provider)

Resolves with void

Rejects with void


// config: UpdatePolicy
setUpdatePolicy(config)

Resolves with boolean

Rejects with void


// manifestUrl: string
uninstall(manifestUrl)

Resolves with string

Rejects with AppsServiceError


// manifestUrl: string
update(manifestUrl)

Resolves with AppsObject

Rejects with AppsServiceError


// manifestUrl: string
// certType: string
// folderName: string
verify(manifestUrl, certType, folderName)

Resolves with string

Rejects with AppsServiceError


Events#

  APP_DOWNLOAD_FAILED APP_INSTALLED APP_INSTALLING APP_UNINSTALLED APP_UPDATE_AVAILABLE APP_UPDATED APP_UPDATING APPSTATUS_CHANGED

The APP_DOWNLOAD_FAILED event emits a DownloadFailedReason

To manage this event, use code similar to:

function handleEvent(value) {
...
}
_appsManager.addEventListener(_appsManager.APP_DOWNLOAD_FAILED_EVENT, handleEvent);
_appsManager.removeEventListener(_appsManager.APP_DOWNLOAD_FAILED_EVENT, handleEvent);

The APP_INSTALLED event emits a AppsObject

To manage this event, use code similar to:

function handleEvent(value) {
...
}
_appsManager.addEventListener(_appsManager.APP_INSTALLED_EVENT, handleEvent);
_appsManager.removeEventListener(_appsManager.APP_INSTALLED_EVENT, handleEvent);

The APP_INSTALLING event emits a AppsObject

To manage this event, use code similar to:

function handleEvent(value) {
...
}
_appsManager.addEventListener(_appsManager.APP_INSTALLING_EVENT, handleEvent);
_appsManager.removeEventListener(_appsManager.APP_INSTALLING_EVENT, handleEvent);

The APP_UNINSTALLED event emits a string

To manage this event, use code similar to:

function handleEvent(value) {
...
}
_appsManager.addEventListener(_appsManager.APP_UNINSTALLED_EVENT, handleEvent);
_appsManager.removeEventListener(_appsManager.APP_UNINSTALLED_EVENT, handleEvent);

The APP_UPDATE_AVAILABLE event emits a AppsObject

To manage this event, use code similar to:

function handleEvent(value) {
...
}
_appsManager.addEventListener(_appsManager.APP_UPDATE_AVAILABLE_EVENT, handleEvent);
_appsManager.removeEventListener(_appsManager.APP_UPDATE_AVAILABLE_EVENT, handleEvent);

The APP_UPDATED event emits a AppsObject

To manage this event, use code similar to:

function handleEvent(value) {
...
}
_appsManager.addEventListener(_appsManager.APP_UPDATED_EVENT, handleEvent);
_appsManager.removeEventListener(_appsManager.APP_UPDATED_EVENT, handleEvent);

The APP_UPDATING event emits a AppsObject

To manage this event, use code similar to:

function handleEvent(value) {
...
}
_appsManager.addEventListener(_appsManager.APP_UPDATING_EVENT, handleEvent);
_appsManager.removeEventListener(_appsManager.APP_UPDATING_EVENT, handleEvent);

The APPSTATUS_CHANGED event emits a AppsObject

To manage this event, use code similar to:

function handleEvent(value) {
...
}
_appsManager.addEventListener(_appsManager.APPSTATUS_CHANGED_EVENT, handleEvent);
_appsManager.removeEventListener(_appsManager.APPSTATUS_CHANGED_EVENT, handleEvent);

Sample code#

New APIs sample code