Provides functions for interacting with the device at the OS level.
- Source:
Members
(static, readonly) BatteryState :number
Enum BatteryState
Type:
- number
Properties:
Name | Type | Description |
---|---|---|
UNKNOWN |
number | The battery state is unknown. |
CHARGING |
number | Indicates the unit is charging. |
DISCHARGING |
number | Indicates the battery is running down. |
FULL |
number | Battery is fully charged. |
NOT_CHARGING |
number | Battery is not charging. |
- Source:
(static, readonly) ButtonState :number
Enum ButtonState
Type:
- number
Properties:
Name | Type | Description |
---|---|---|
DOWN |
number | This state occurs when a finger is pressed down on a button; before UP. |
UP |
number | This state occurs when a finger is lifted off of a button; after DOWN. |
- Source:
(static, readonly) KeyState :number
Enum KeyState
Type:
- number
Properties:
Name | Type | Description |
---|---|---|
DOWN |
number | This state occurs when a finger is pressed down on a key; before UP. |
UP |
number | This state occurs when a finger is lifted off of a key; after DOWN. |
- Source:
(static, readonly) PowerSource :number
Enum PowerSource
Type:
- number
Properties:
Name | Type | Description |
---|---|---|
BATTERY |
number | A battery power source. |
EXTERNAL |
number | An external power supply such as mains power. |
- Source:
(static, readonly) RingerMode :number
Enum RingerMode
Type:
- number
Properties:
Name | Type | Description |
---|---|---|
NORMAL |
number | Ringer mode that may be audible and may vibrate. It will be audible if the volume before changing out of this mode was audible. It will vibrate if the vibrate setting is on. |
SILENT |
number | Ringer mode that will be silent and will not vibrate. (This overrides the vibrate setting.) |
VIBRATE |
number | Ringer mode that will be silent and will vibrate. (This will cause the phone ringer to always vibrate, but the notification vibrate to only vibrate if set.) |
- Source:
(static, readonly) StreamType :number
Enum StreamType
Type:
- number
Properties:
Name | Type | Description |
---|---|---|
NOTIFICATION_DEFAULT |
number | Suggests using the default stream type. This may not be used in all places a stream type is needed. |
VOICE_CALL |
number | Used to identify the volume of audio streams for phone calls. |
SYSTEM |
number | Used to identify the volume of audio streams for system sounds. |
RING |
number | Used to identify the volume of audio streams for the phone ring. |
MUSIC |
number | Used to identify the volume of audio streams for music playback. |
ALARM |
number | Used to identify the volume of audio streams for alarms. |
NOTIFICATION |
number | Used to identify the volume of audio streams for notifications. |
DTMF |
number | Used to identify the volume of audio streams for DTMF Tones. Dual-tone multi-frequency (DTMF) tones are used by automated dial-in systems such as voicemail or where prompts are used to navigate. |
- Source:
Methods
(static) beep(durationMSopt, toneFrequencyopt)
Plays a tone for the specified duration and at the specified frequency.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
durationMS |
number |
<optional> |
The duration in milliseconds. If not specified a default value is used. This default value is determined by the application settings. |
toneFrequency |
number |
<optional> |
The frequency of the tone played in Hz. If not specified a default value is used. This default value is determined by the application settings. |
- Source:
(static) getBrightness() → {float}
Obtains the screen brightness, which is a float value
between 0 and 1.
- Source:
Returns:
brightness between 0 and 1.
- Type
- float
(static) getMaxVolume(streamType) → {number}
Gets the highest volume value that can be applied using
the setVolume() function.
Parameters:
Name | Type | Description |
---|---|---|
streamType |
airlock.device.StreamType | Indicates the source of the volume. |
- Source:
- See:
Returns:
The maximum volume.
- Type
- number
Example
// Get the maximum music volume.
var maxVolume = airlock.device.getMaxVolume(airlock.device.StreamType.MUSIC);
(static) getPower() → {airlock.device.PowerInfo}
Gets an object representing the device's power source and charging state.
- Source:
Returns:
With fields representing the device's power source and charge level.
Example
var powerInfo = airlock.device.getPower();
// Test for external power source.
if (powerInfo.powerSource === airlock.device.PowerSource.EXTERNAL) {
// Perform power intensive task.
}
(static) getRingerMode() → {airlock.device.RingerMode}
Gets the ringer mode of the device.
Ringer mode determines how the phone behaves when a call
is incoming. Ringer mode may be 2 (normal), 0 (silent), or 1 (vibrate).
- Source:
Returns:
2 (normal), 0 (silent), or 1 (vibrate)
(static) getScreenTimeoutMS() → {number}
Gets the length of time in milliseconds following user inactivity
where the OS deems the user to be inactive, and locks the screen.
- Source:
Returns:
The length of time in milliseconds.
- Type
- number
(static) getSystemInfo() → {airlock.device.SystemInfo}
Gets a SystemInfo object containing various OS properties.
- Source:
Returns:
Containing various OS properties.
(static) getVolume(streamType) → {number}
Gets a value between 0 and the maximum volume, which can be
retrieved using the getMaxVolume function.
Parameters:
Name | Type | Description |
---|---|---|
streamType |
airlock.device.StreamType | Indicates the source of the volume. |
- Source:
- See:
Returns:
A number between zero and getMaxVolume()
- Type
- number
Example
// Gets the music stream volume.
var value = airlock.device.getVolume(airlock.device.StreamType.MUSIC);
(static) isPackageInstalled(packageName) → {boolean}
Gets a value indicating whether the specified package
exists on the system.
Parameters:
Name | Type | Description |
---|---|---|
packageName |
string | The package name. For example, 'com.google.android.apps.photos'. |
- Source:
Returns:
True if the package is installed on the system; false otherwise.
- Type
- boolean
Example
var installed = airlock.device.isPackageInstalled('com.google.android.apps.photos');
alert(installed ? "Installed" : "Not Installed");
(static) isScreenLocked() → {Boolean}
Gets a value indicating whether the display is currently locked.
The function requires device administration privileges be assigned to the app.
You can do this via the Enterprise Administration screen within Airlock Browser.
Throws:
-
Occurs if Airlock Browser has not been assigned device administration privileges.
- Type
- Exception
Returns:
true if the screen is locked; false otherwise.
- Type
- Boolean
(static) lockScreen()
Engages the devices screen lock.
The function requires device administration privileges be assigned to the app.
You can do this via the Enterprise Administration screen within Airlock Browser.
Throws:
-
Occurs if Airlock Browser has not been assigned device administration privileges.
- Type
- Exception
(static) setBrightness(brightness)
Sets the screen brightness to a value between 0 and 1.
The specified value is clamped between 0.1 and 1
to prevent the device being unusable.
Parameters:
Name | Type | Description |
---|---|---|
brightness |
number | A value between 0 and 1. |
- Source:
(static) setRingerMode(mode)
Sets the ringer mode of the device.
Ringer mode determines how the phone behaves when a call
is incoming. Ringer mode may be 2 (normal), 0 (silent), or 1 (vibrate).
Parameters:
Name | Type | Description |
---|---|---|
mode |
airlock.device.RingerMode | Allowed values are 2 (normal), 0 (silent), or 1 (vibrate) |
- Source:
Example
// Set the ringer mode to vibrate.
airlock.device.setRingerMode(airlock.device.RingerMode.VIBRATE);
(static) setScreenTimeoutMS(timeoutMS)
Sets the length of time in milliseconds following user inactivity
where the OS deems the user to be inactive, and locks the screen.
Parameters:
Name | Type | Description |
---|---|---|
timeoutMS |
number | The length of time in milliseconds. |
- Source:
(static) setVolume(streamType, volume)
Sets a value between 0 and the maximum volume, which can be
retrieved using the getMaxVolume function.
Parameters:
Name | Type | Description |
---|---|---|
streamType |
airlock.device.StreamType | Indicates the source of the volume. |
volume |
number | A value between 0 and the maximum volume, which can be retrieved using the getMaxVolume function. |
- Source:
Example
// Get the maximum music volume.
var maxVolume = airlock.device.getMaxVolume(airlock.device.StreamType.MUSIC);
// Set the music stream to maximum volume.
airlock.device.setVolume(airlock.device.StreamType.MUSIC, value);
(static) soundToneFollowedBySilence(soundMS, silenceMS, playCount, toneFrequency)
Plays a tone at the specified frequency, followed by silence.
This is repeated for the specified play count.
Parameters:
Name | Type | Description |
---|---|---|
soundMS |
number | The duration of the tone for each repetition. Must be greater than 0. |
silenceMS |
number | The duration of silence following the tone for each repetition. Must be greater than or equal to 0. |
playCount |
number | The number of times to play the tone followed by silence. Must be greater than 0. |
toneFrequency |
number | The audible frequency of the sound. Must be greater than 0. |
- Source:
(static) unlockScreen()
Disengages the devices screen lock.
The function requires device administration privileges be assigned to the app.
You can do this via the Enterprise Administration screen within Airlock Browser.
Throws:
-
Occurs if Airlock Browser has not been assigned device administration privileges.
- Type
- Exception
(static) vibrate(vibrateMSopt, intervalMSopt, countopt)
Causes the device to vibrate for the specified duration.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
vibrateMS |
number |
<optional> |
The duration for which to vibrate, in milliseconds. If not specified, a value of 100 MS is used. | |
intervalMS |
number |
<optional> |
0 | The pause time in milliseconds between repetitions. |
count |
number |
<optional> |
The number of times to vibrate then pause. |
- Source:
Type Definitions
ButtonPressArgs
Properties:
Name | Type | Description |
---|---|---|
buttonId |
string | The unique ID of the button. E.g., "1" |
state |
airlock.device.ButtonState | The pressed state of the button. |
handled |
boolean | This must be set to true to prevent the default button actions from being performed. |
- Source:
DisplayInfo
Properties:
Name | Type | Description |
---|---|---|
widthPixels |
number | Width of the screen in pixels. |
heightPixels |
number | Height of the screen in pixels. |
density |
number | The logical density of the display. |
scaledDensity |
number | A scaling factor for fonts on the display. |
widthDpi |
number | The physical pixels per inch of the screen in the X dimension. |
heightDpi |
number | The physical pixels per inch of the screen in the Y dimension. |
densityDpi |
number | The screen density expressed as dots per inch. |
- Source:
KeyPressEventArgs
Properties:
Name | Type | Description |
---|---|---|
keyId |
string | The unique ID of the key. E.g., "MENU" |
state |
airlock.device.KeyState | The pressed state of the key. |
handled |
boolean | This must be set to true to prevent the default key actions from being performed. |
- Source:
PowerInfo
Properties:
Name | Type | Description |
---|---|---|
powerSource |
airlock.device.PowerSource | 0 is battery, 1 is external (mains power) |
remainingBatteryMinutes |
number | An estimate of the number of minutes of remaining battery charge. |
remainingBatteryPercent |
number | A value between 0 and 100 indicating the battery charge remaining. Note that this value may not be indicative of the time until the device runs out of charge, as the device may be connected to mains power and charging. See the batteryState value. |
batteryState |
airlock.device.BatteryState | Indicates the charging state of battery. |
- Source:
SystemInfo
Properties:
Name | Type | Description |
---|---|---|
manufacturer |
string | The manufacturer of the device. |
brand |
string | The brand of the device. |
model |
string | The model of the device. |
board |
string | The name of the underlying board, like 'goldfish'. |
hardware |
string | The name of the hardware (from the kernel command line or /proc). |
serial |
string | A hardware serial, if available. |
deviceId |
string | A unique identifier for the device. This value may change with a factory reset. |
apiLevel |
string | The Android build level (the SdkInt). |
sdk |
string | The Android build name. For example 'kitkat'. |
buildId |
string | Either a changelist number or a number like "M4-rc20" |
buildTime |
string | A long value that is a Unix epoch timestamp (in milliseconds) indicating when the device's ROM was built |
buildVersion |
string | The OS's user-visible version string. E.g., "1.0" or "3.4b5". |
displayInfo |
airlock.device.DisplayInfo | Indicates the properties of the device display. |
- Source:
Events
onButtonPress
onButtonPress Event. Is raised on supported devices
when a custom hardware button is pressed.
To subscribe to the event use:
airlock.device.onButtonPress.addListener(function (args) {})
To unsubscribe to the event use:
airlock.device.onButtonPress.removeListener(afunctionReference)
Type:
- airlock.device.ButtonPressedEventArgs
- Source:
Example
// Subscribe to event
airlock.device.onButtonPress.addListener(handleHardwareButtonPress);
function handleButtonPress(args) {
if (args.State === ButtonState.UP && args.buttonId === "1") {
args.handled = true;
alert("Button 1 pressed.");
}
}
// Unsubscribe
airlock.device.onButtonPress.removeListener(handleHardwareButtonPress);
onKeyPress
onKeyPress Event. Is raised on supported devices
when a custom hardware key is pressed.
To subscribe to the event use:
airlock.device.onKeyPress.addListener(function (args) {})
To unsubscribe to the event use:
airlock.device.onKeyPress.removeListener(afunctionReference)
Type:
- airlock.device.KeyPressedEventArgs
- Source:
Example
// Subscribe to event
airlock.device.onKeyPress.addListener(handleKeyPress);
function handleKeyPress(args) {
if (args.State === KeyState.UP && args.keyId === "1") {
args.handled = true;
alert("Key 1 pressed.");
}
}
// Unsubscribe
airlock.device.onKeyPress.removeListener(handleHardwareKeyPress);
onPowerChanged
onPowerChanged Event. Is raised when the devices power source is changed;
the device is plugged-in to mains power for example.
It is also raised when the battery level changes.
To subscribe to the event use:
airlock.device.onPowerChanged.addListener(function (powerInfo) {})
To unsubscribe to the event use:
airlock.device.onPowerChanged.removeListener(afunctionReference)
Type:
- Source:
Example
// Subscribe to event
airlock.device.onPowerChanged.addListener(handlePowerChanged);
function handlePowerChanged(args) {
if (args.powerSource === airlock.device.PowerSource.BATTERY) {
// Using battery. Display remaining battery percentage.
alert(args.remainingBatteryPercent)
}
}
// Unsubscribe
airlock.device.onPowerChanged.removeListener(handlePowerChanged);