Skip to content

voltmx.os Namespace

The voltmx.os namespace provides functions for the Operating System API. It contains the following API elements:

Constants

The voltmx.os Namespace contains the following types of constants.

Battery State Constants


These constants specify the current state of the device battery.

Constant Description
BATTERY_STATE_CHARGING Indicates that the state of the device battery as being charged.
BATTERY_STATE_DISCHARGING Indicates that the state of the device battery as being discharged.
BATTERY_STATE_FULL Indicates that the state of the device battery charge is completely full.
BATTERY_STATE_UNKNOWN Indicates that the state of the device battery charge as not known.

Example

When you query for the state of the device battery as shown in this example, any of the four available battery states is returned.

var batteryState = voltmx.os.getBatteryState();

if (voltmx.os.BATTERY_STATE_CHARGING == batteryState) {

    voltmx.print(“Battery State: Charging”);
}

Platform Availability

  • iOS
  • Android
  • Windows

=======

Functions

The voltmx.os namespace contains the following functions.

voltmx.os.addHiddenField


This API helps the developers to pass dynamic values when the form needs to be submitted to external sites.

Syntax


addHiddenField([key](#key),[value](#value),[private](#private));

Input Parameters

Parameter Description
key [String] - Mandatory Specifies the key of the hidden field that you would like to add.
value [String] - Mandatory Specifies the value that corresponds to the specified key in the hidden field.
private [String] - Optional Specifies if the hidden field can be read using the voltmx.os.readHiddenField API. The expected values for this field are either "private" or "public". The default value of this field id "public". > Note: Only when this value is specified, you can read the hidden value through voltmx.os.readHiddenField API.

Example

function addHiddenField() {
    voltmx.os.addHiddenField("myhiddenfield", "myvalue", "private");
    // private value is specified and hence this hiddenfield can be read through the voltmx.os.readHiddenField API
    voltmx.os.addHiddenField("myhiddenfield1", "myvalue");
    // As private value is not specified and hence this hiddenfield cannot be read through the voltmx.os.readHiddenField API
}

Return Values

None.

Platform Availability

Available only on Mobile Web.


voltmx.os.addMetaTag


This API adds a meta tag in.html header. This API result will effect only on header reload.

Syntax


addMetaTag (key, value);

Input Parameters

Parameter Description
key [String] - Mandatory Adds a meta tag in the HTML header
value [Object] - Mandatory Adds meta tag attributes in the.html header as key value pairs.

Example

voltmx.os.addMetaTag("test2", {
    "http-equiv": "refresh",
    "content": "30"
});

Return Values

This API has no return values.

Platform Availability

Applicable only on Mobile Web.


voltmx.os.createUUID


UUID (Universally Unique Identifier) is a universally unique value that can be used to identify types, interfaces, and other items. This API returns a string that contains a formatted UUID value. For example, E621E1F8-C36C-495A-93FC-0C247A3E6E5F.

Syntax


voltmx.os.createUUID();

Input Parameters

None

Example

function createMyUUIDFunc() {
var uuid = voltmx.os.createUUID();
voltmx.print("The created UUID is : " + uuid);
}

Return Type

String

Platform Availability

  • Android
  • iOS

voltmx.os.detectDynamicInstrumentation


This API helps your application to detect the presence of any Dynamic Instrumentation instance. Currently, this API only supports the detection of Frida server presence.

Syntax


voltmx.os.detectDynamicInstrumentation(object);

Input Parameters

Parameter Description
object[Object] -Mandatory This is a dictionary that contains the following keys: detectedCallback [Function] - OptionalThis callback is executed when the presence of Dynamic Instrumentation is detected. If you do not specify this key, the application safely exits by default whenever it detects Dynamic Instrumentation.undetectedCallback [Function] - OptionalThis callback is executed when Dynamic Instrumentation is not detected. type [String] - Mandatory This parameter specifies the type of detection that is to be performed. You can specify any one of the following values for this parameter:fridaquickscan - Returns results quickly and can be used synchronously in JS code.fridadeepscan - Performs a deep scan to search for the presence of Frida server, and it takes about six or more seconds to return the result. For this reason, you must use the fridadeepscan option in WorkerThread.

Example

var didobject = {
    detectedCallback: detectedCallbackFunction,
    undetectedCallback: undetectedCallbackFunction,
    "type": "fridaquickscan"
};
voltmx.os.detectDynamicInstrumentation(didobject);  

Return Value

None

Platform Availability

  • Android

voltmx.os.deviceInfo


This API allows the developers to get information about the device in which the application is launched.

You can view a video on using Device Info API here.

Syntax


deviceInfo();

Input Parameters

None

Example

var deviceInfo = voltmx.os.deviceInfo();
alert(deviceInfo);

for (var key in deviceInfo) {
    if (deviceInfo.hasOwnProperty(key)) {
        alert(key + ":" + deviceInfo[key]);
    }
}

Return Values

Return Value Description
values[Object] Returns a DeviceInfo object.

Platform Availability

Available on all platforms.


voltmx.os.endSecureTransaction


This API can be invoked on an event of a widget. This API should be invoked on forms of the application where user validation is not required or cross site request forgery is not a concern.

Syntax


voltmx.os.endSecureTransaction();

Input Parameters

None

Example

voltmx.os.endSecureTransaction();

Return Values

None

Platform Availability

Available only on Mobile Web.


voltmx.os.freeMemory


This API provides the ability to query and fetch the actual OS allocated memory available for the application on the mobile device.

You can use this API to:

  • Find out the free memory on the mobile device for the application, clear unwanted objects, and improve the application's performance.

Syntax


voltmx.os.freeMemory();

Input Parameters

None

Example

In the following example, voltmx.os.freeMemory returns the freememory available for allocation.

var freememory = voltmx.os.freeMemory();
voltmx.print(freememory);
//After the voltmx.os.freeMemory operation, the memory available for allocation is printed. 
//For example, 1070404 (indicates that 1046 KB of memory is available for allocation)

Return Values

Return Value Description
Free memory[Number] The available memory for allocation is returned. The returned memory always indicates the number of bytes available.

Platform Availability

Available on all platforms* except Windows. *Dummy implementation on Server Side Mobile Web, SPA, and DesktopWeb and returns a dummy value.


voltmx.os.getAppContext


This API allows the developers to get information about the mode in which the application is launched.

Syntax


voltmx.os.getAppContext();

Input Parameters

None

Example

function getAppContext() {
    var mycontext = voltmx.os.getAppContext();
    voltmx.print(mycontext); 
    /*prints {launchmode=0} if the application was launched in normal mode ,prints {launchmode=1} if the application was launched in full screen mode*/
}

Return Values

Return Value Description
contextDetails[Object] Returns an object with key-value pairs:launchmode:0 indicates that the application is launched in normal mode.launchmode:1 indicates that the application is launched in full screen mode.

Platform Availability

Applicable only on Mobile Web.


voltmx.os.getBatteryLevel


Retrieves the current percentage charge level of the device battery, as an integer value.

Syntax


voltmx.os.getBatteryLevel();

Input Parameters

None

Example

getBatteryLevel: function() {
    voltmx.os.registerBatteryService(this.batterySuccessCallback);
    var battery = voltmx.os.getBatteryLevel();
    voltmx.os.unregisterBatteryService();
    this.view.lblDisplay.text = battery + "%";
},

Return Values

Returns an integer that ranges from 0-100 (inclusive) that specifies the battery's current charge level in percentage. For example, a return value of 30 specifies that the current charge level of the battery is 30%.

Platform Availability

  • iOS
  • Android
  • Windows

voltmx.os.getBatteryState


Retrieves the current state of the battery.

Syntax


voltmx.os.getBatteryState();

Input Parameters

None

Example

//This code is used to obtain your device battery state
getBatteryState: function() {
    voltmx.os.registerBatteryService(this.batterySuccessCallback);
    var batteryState = voltmx.os.getBatteryState();
    if (voltmx.os.BATTERY_STATE_CHARGING == batteryState) {
        alert("The Device is charging");
        voltmx.os.unregisterBatteryService();
    } else if (voltmx.os.BATTERY_STATE_DISCHARGING == batteryState) {
        alert("The Device is discharging");
        voltmx.os.unregisterBatteryService();
    } else if (voltmx.os.BATTERY_STATE_FULL == batteryState) {
        alert("The Device is completely charged");
        voltmx.os.unregisterBatteryService();
    } else if (voltmx.os.BATTERY_STATE_UNKNOWN == batteryState) {
        alert("The Device charging state is unkonwn");
        voltmx.os.unregisterBatteryService();
    }
},

Return Values

Returns a constant from the Battery State Constants.

Remarks

The battery state indicates whether it is charging, discharging, and so forth.

Platform Availability

  • iOS
  • Android
  • Windows

voltmx.os.getDeviceId


This API is deprecated. It always returns null.


voltmx.os.getDeviceCurrentOrientation


This API returns the current orientation of the device. The possible values are portrait or landscape.

Syntax


voltmx.os.getDeviceCurrentOrientation();

Input Parameters

None

Example

voltmx.os.getDeviceCurrentOrientation(); //Returns the orientation of the device

Return Values

This API returns whether the device orientation is landscape or portrait.

  • constants.DEVICE_ORIENTATION_PORTRAIT
  • constants.DEVICE_ORIENTATION_LANDSCAPE

Platform Availability

Available on iPhone, iPad, Windows, Android, and Desktop Web


voltmx.os.getOpenGLESVersion


This API returns the maximum OpenGLES Version supported by the device.

Depending on the value returned, you can determine if the device supports AR capabilities.

Syntax


voltmx.os.getOpenGlESVersion();

Input Parameters

None.

Example

if (voltmx.os.getOpenGLESVersion() >= 3.0 && voltmx.os.deviceInfo().APILevel >= 24)
{
      voltmx.print("ARRenderer is supported")
}
else
{
     voltmx.print("none of the AR apis will work")
}

Return Values

Return Value Description
version Returns the Open GLES Version number.

Platform Availability

Android


voltmx.os.hasAccelerometerSupport


This API returns whether accelerometer is supported on a device.

Syntax


hasAccelerometerSupport();

Input Parameters

None.

Return Values

Return Value Description
value[Boolean] Returns whether accelerometer is supported on a device.

Platform Availability

Applicable only on iPhone, Android, and Windows platforms.

Example

voltmx.print(voltmx.os.hasAccelerometerSupport());
//prints true if device has accelerometer support


voltmx.os.hasCameraSupport


This API returns whether Camera is supported on a device.

Syntax


hasCameraSupport();

Input Parameters

None.

Example

voltmx.print(voltmx.os.hasCameraSupport());
//prints true if device has  camera support

Return Values

Return Value Description
value[Boolean] true: the platform supports Camera false: the platform does not support Camera

Platform Availability

Available on all platforms* except Mobile Web. *Dummy implementation for SPA and Desktop Web that always returns False.


voltmx.os.hasGPSSupport


This API returns whether GPS is supported on a device.

Syntax


voltmx.os.hasGPSSupport();

Input Parameters

None.

Example

voltmx.print(voltmx.os.hasGPSSupport());
//prints true if device has GPS support

Return Values

Return Value Description
value[Boolean] true: the platform supports GPS. false: the platform does not support GPS.

Platform Availability

Available on all platforms except Mobile Web.


voltmx.os.hasOrientationSupport


This API returns whether Orientation is supported on a device.

You can view a video on using Display Orientation here.

Syntax


voltmx.os.hasOrientationSupport();

Input Parameters

None.

Example

var orientation = voltmx.os.getDeviceCurrentOrientation();

if (orientation == constants.DEVICE_ORIENTATION_PORTRAIT) {
    alert("PORTRAIT");
} else if (orientation == constants.DEVICE_ORIENTATION_LANDSCAPE) {
    alert("LANDSCAPE");
} else {
    alert("UNKNOWN");
}

Return Values

Return Value Description
value[Boolean] true: the platform supports orientation. false: the platform does not support orientation.

Platform Availability

Available on all platforms except Mobile Web.


voltmx.os.hasTouchSupport


This API returns whether Touch is supported on a device.

Syntax


voltmx.os.hasTouchSupport();

Input Parameters

None.

Example

voltmx.print(voltmx.os.hasTouchSupport());
//prints true if device is a touch device

Return Values

Return Value Description
value[Boolean] true: the platform supports touch. false: the platform does not support touch.

Platform Availability

Available on all platforms except Mobile Web and Desktop Web.


voltmx.os.print


When invoked without any parameter, this API prints the entire form that is currently in view.

Syntax


voltmx.os.print(containerID);

Input Parameters

Parameter Description
containerID [Number] - Optional The containerID can be a ID of any container widget that can be directly referenced from a form.
> > Note:   If the user is typing in a text box, the typed content will not be printed. Print API can be used only after the target Form, Popup or Datagrid is rendered on the browser. Print API cannot be used in pre-show, post-show, pre and post app init or any other functionality that is run before the target Form, Popup, or Datagrid is fully rendered. When printing the form with widgets like ScrollBox, Image Strip, the print functionality prints only those widgets that are in the view or potentially occupy the available print space in portrait or landscape views.

|

Example

voltmx.os.print()

Return Values

None.

Platform Availability

Applicable only on Desktop Web.


voltmx.os.readHiddenField


This API allows the developers to read the hidden fields added by the os.addHiddenField API.

Syntax


readHiddenField([key](#key));

Input Parameters

Parameters Description
key [String] - Mandatory Specifies the key of the hidden field that you would like to read.

Example

function readHiddenField() {
    voltmx.os.readHiddenField("myhiddenfield");
    // Reads the value that corresponds to the myhiddenfield key, i.e., myvalue
}

Return Values

Return Value Description
value[String] Returns the value that corresponds to the specified key.
nil nil is returned if there is no value assigned to the corresponding key.

Platform Availability

Available only on Mobile Web.


voltmx.os.registerBatteryService


Registers for the battery monitoring service of the device operating system. The callback is delivered to the most recent registered battery service.

Note: Whenever the battery state changes or for every 1% change in the battery level, a callback to the registerBatteryService function is triggered.

Syntax


voltmx.os.registerBatteryService(callbackMethod);

Input Parameters

Parameter Description
callbackMethod A JavaScript function that is automatically invoked when you register to the battery monitoring service of the device OS.

Example

//This code is used to register a battery service and deregister the service based on your battery level
registerBatteryService: function() {
    voltmx.os.registerBatteryService(this.mybatterychangecallback);
    var batterylevel = voltmx.os.getBatteryLevel();
},

mybatterychangecallback: function(batteryInfo) {
    var batterylevel = batteryInfo.batterylevel;
    if (batterylevel <= 20) {
        alert("The Battery Level is below 20%, make sure that you charge your device");
    } else {
        voltmx.os.unregisterBatteryService();
        alert("We are unregistering the Battery Service as it might cause an overhead");
    }
},

Return Values

None

Limitations

  • The callback for the registered battery service is delivered only when the application is running; this is because, you can only receive notifications when the application is in the foreground for the iOS, Windows, and Android platforms.
  • The callback to the registered battery service is delivered after every one minute duration for iOS; whereas in case of in Android and Windows, the callback is delivered for every 1% change in the battery charge.

Platform Availability

  • iOS
  • Android
  • Windows

voltmx.os.registerSpeechRecognizer


Registers callbacks for speech recognition events.

Syntax


voltmx.os.registerSpeechRecognizer(callbackTable);

Input Parameters

Parameters Description
callbackTable[JSON object] - Mandatory The callbackTable is a mandatory key-value pair, that helps you to register JavaScript callbacks, which are triggered when any speech to text recognition events occur.Following are the key-value pairs:
> resultGenerated [callback]

Triggered continuously whenever a phrase is generated out of the recognized speech. Parameters for callback [JSON object]result [String] The recognized phrase of the speech recognition session.confidence [Number]The confidence level of the speech recognition result. For example, if the speech includes a word such as "weight," the confidence level is the certainty with which the app recognizes the word as "weight" and not as "wait."0 - High1 - Medium2 - Low3 - Rejectedstatus [Number]The status of the result. 0 - Success 1 - TopicLanguageNotSupported 2 - GrammarLanguageMismatch3 - GrammarCompilationFailure 4 - AudioQualityFailure5 - UserCanceled 6 - Unknown 7 - TimeoutExceeded8 - PauseLimitExceeded 9 - NetworkFailure10 - MicrophoneUnavailable

timeouts [JSON object]Set initial, in-session (continuous event), and end silence timeouts based on which the speech recognition session will be stopped.initialSilenceTimeout [Number] Minimum timeout value (in seconds) given to ignore the silence (no speech input) after the speech recognition session starts (that is, before the speech is recognized and text is generated). Default value is 5 seconds.autoStopSilenceTimeout [Number]Minimum timeout value (in seconds) given to ignore the silence between the event(s) that are triggered continuously (that is, during speech recognition process).endSilenceTimeout [Number]Minimum timeout value (in seconds) to ignore the silence (no speech input) after which the speech recognition should end (that is, after speech is recognized and text is generated). Default value is 150 milliseconds. |

Example

function registerCallbacks() {
    voltmx.os.registerSpeechRecognizer({
        "resultGenerated": resultGenCallback,
        "timeouts": {
            "initialSilenceTimeout": 5,
            "autoStopSilenceTimeout": 60,
            "endSilenceTimeout": 80
        }
    });
}

function resultGenCallback(data) {
    frmHome.txtareaSpeech.text = "Text: " + data.result + "confidence: " + data.confidence + "Status: " + data.status;
}

Return Values

None.

Platform Availability

Available only on Windows.

voltmx.os.removeAllMetaTags


This API removes all the user defined meta tags from a.html header. This API result will effect only on header reload.

Syntax


removeAllMetaTags();

Input P