Vai al contenuto

Interfaccia JavaScript (PLUS) ​

L'interfaccia JavaScript consente ai siti web di integrarsi con il dispositivo e le funzionalità Fully Kiosk. Per utilizzare questa API è necessario essere uno sviluppatore web o possedere competenze in JavaScript/HTML. Se si utilizza Node.js/React, questa libreria o quest'altra possono essere utili.

Non dimenticare di abilitare l'opzione "Abilita interfaccia JavaScript" in " Advanced Web Settings " quando utilizzi l'interfaccia JavaScript. Abilita questa opzione solo se ti fidi di tutti i siti web caricati (utilizza una whitelist di URL!). Questa opzione è potenzialmente insicura, poiché qualsiasi sito web può leggere TUTTI i tuoi file locali, modificare le impostazioni del dispositivo, ecc.

Le seguenti funzioni JavaScript sono implementate in Fully Kiosk Browser (incluse le versioni beta).

Ottieni device info
String fully.getCurrentLocale()
String fully.getIp4Address()  
String fully.getIp4Addresses()
String fully.getIp6Address()  
String fully.getIp6Addresses()
String fully.getHostname()
String fully.getHostname6()
String fully.getMacAddress()
String fully.getMacAddressForInterface(String interface)
String fully.getWifiSsid()  
String fully.getWifiBssid()
String fully.getWifiSignalLevel()
String fully.getSerialNumber()  
String fully.getSerialNumberDeviceOwner()
String fully.getAndroidId()
String fully.getDeviceId()  
String fully.getDeviceName()
String fully.getImei()
String fully.getSimSerialNumber()
float fully.getBatteryLevel()
float fully.getScreenBrightness()
int fully.getScreenOrientation()
int fully.getDisplayWidth()
int fully.getDisplayHeight()  
long fully.getIdleTime()  
long fully.getLastUserInteractionTime()
boolean fully.getScreenOn()
boolean fully.isPlugged()
boolean fully.isKeyboardVisible()
boolean fully.isWifiEnabled()  
boolean fully.isWifiConnected()  
boolean fully.isNetworkConnected()
boolean fully.isBluetoothEnabled()  
boolean fully.isScreenRotationLocked()
String fully.getFullyVersion()
int fully.getFullyVersionCode()
String fully.getWebviewVersion()
String fully.getAndroidVersion()
int fully.getAndroidSdk()
String fully.getDeviceModel()  
String fully.getLocation() // Returns a JSON String

// Get storage info
long fully.getInternalStorageTotalSpace()
long fully.getInternalStorageFreeSpace()
long fully.getExternalStorageTotalSpace()
long fully.getExternalStorageFreeSpace()

// Get environment sensor info
String fully.getSensorInfo()
float fully.getSensorValue(int type)
String fully.getSensorValues(int type)  
  
// Get data usage (Android 6+)  
long fully.getAllRxBytesMobile()  
long fully.getAllTxBytesMobile()  
long fully.getAllRxBytesWifi()  
long fully.getAllTxBytesWifi()
Controlla il dispositivo, mostra notifiche, invia dati di rete ecc.
void fully.turnScreenOn()
void fully.turnScreenOff() 
void fully.turnScreenOff(boolean keepAlive) 
void fully.forceSleep()
void fully.showToast(String text) 
void fully.setScreenBrightness(int level) // Use -1 for default
void fully.enableWifi() // In Android 10+ only with provisioned devices
void fully.disableWifi() // In Android 10+ only with provisioned devices
void fully.enableBluetooth()
void fully.disableBluetooth()
void fully.showKeyboard()
void fully.hideKeyboard()
void fully.openWifiSettings()
void fully.openBluetoothSettings()
void fully.vibrate(int millis)
void fully.sendHexDataToTcpPort(String hexData, String host, int port)
void fully.showNotification(String title, String text, String url, boolean highPriority)  
void fully.log(int type, String tag, String message)

// Access clipboard   
// No access with Android 10+ if Fully is in background
void fully.copyTextToClipboard(String text)
String fully.getClipboardText()
String fully.getClipboardHtmlText()  
  
// Run root command (rooted devices only)  
void fully.runCommand(String command)  
void fully.runSuCommand(String command)  
  
void fully.reboot() // Provisioned and rooted devices only  
void fully.shutdown() // Rooted devices only
Scarica e gestisci i file
// Note that write access to external SD card is not supported by many devices
void fully.deleteFile(String path)   
void fully.deleteFolder(String path) // recursive!
void fully.emptyFolder(String path)  // recursive!
void fully.createFolder(String path)
String fully.getFileList(String folder)  // get JSON array
boolean fully.writeFile(String path, String content)  
boolean fully.writeFileBase64(String path, String base64encodedContent)  
boolean fully.appendFile(String path, String content) // 1.61.4+  
boolean fully.appendFileBase64(String path, String base64encodedContent)  
String fully.readFile(String path) // ver. 1.55+
void fully.downloadFile(String url, String dirName)  
void fully.downloadFile(String url, String dirName, boolean showToastMessages)
void fully.unzipFile(String fileName)
void fully.downloadAndUnzipFile(String url, String dirName)
  
// Get storage paths (ver. 1.59+)  
String fully.getInternalSharedStoragePath()  
String fully.getInternalAppSpecificStoragePath()  
String fully.getInternalAppPrivateStoragePath()  
String fully.getExternalSharedStoragePath()  
String fully.getExternalAppSpecificStoragePath()  
  
// Respond to download/unzip events  
void fully.bind('onDownloadSuccess','todo("$url","$dir","$code","$fileLength","$lastModified","$mimetype");')  
void fully.bind('onDownloadFailure','todo("$url","$dir","$code");')
void fully.bind('onUnzipSuccess','todo("$url","$dir");')
void fully.bind('onUnzipFailure','todo("$url","$dir","$message");')
Utilizza TTS, contenuti multimediali e PDF
void fully.textToSpeech(String text)
void fully.textToSpeech(String text, String localeOrVoice)
void fully.textToSpeech(String text, String localeOrVoice, String engine)
void fully.textToSpeech(String text, String localeOrVoice, String engine, boolean queue)  // ver. 1.38+
void fully.stopTextToSpeech()  
void fully.initTts() // ver. 1.55, listen for ttsInitSuccess event for $info, containing available engines, voices and locales  
void fully.shutdownTts() // ver. 1.60+
  
void fully.playVideo(String url, boolean loop, boolean showControls, boolean exitOnTouch, boolean exitOnCompletion)
void fully.stopVideo()
  
// Audio Streams: 0 – Voice Call, 1 – System, 2 –  Ring, 3 – Music, 4 – Alarm, 5 – Notification, 6 – Bluetooth, 8 – DTMF, 9  – TTS, 10 – Accessibility  
void fully.setAudioVolume(int level, int stream) // level: 0..100
void fully.playSound(String url, boolean loop)
void fully.playSound(String url, boolean loop, int stream)
void fully.stopSound()
void fully.showPdf(String url)
int fully.getAudioVolume(int stream)
boolean fully.isWiredHeadsetOn()
boolean fully.isMusicActive()
Controlla la navigazione web
// Manage web browsing  
String fully.getStartUrl()
void fully.setStartUrl(String url)  
void fully.loadStartUrl()  
void fully.addToHomeScreen()  
void fully.shareUrl()
void fully.print()  // window.print() doesn't work
void fully.print2Pdf(String filename)  // Print A4 paper w/o prompt  
String fully.getScreenshotPngBase64()
String fully.loadStatsCSV()  
void fully.requestWebAutomation(int index) // Ver. 1.60+
  
// Purge web items  
void fully.clearCache()
void fully.clearFormData()
void fully.clearHistory()
void fully.clearCookies()
void fully.clearCookiesForUrl(String url)
void fully.clearWebstorage()  
void fully.resetWebview // ver. 1.55.3+  

// Manage web tabs  
void fully.focusThisTab()  
void fully.focusNextTab()  
void fully.focusPrevTab()
void fully.focusTabByIndex(int index)
int fully.getCurrentTabIndex()  
int fully.getThisTabIndex()
void fully.closeTabByIndex(int index)
void fully.closeThisTab()
String fully.getTabList() // returns a JSON array
void fully.loadUrlInTabByIndex(int index, String url)
void fully.loadUrlInNewTab(String url, boolean focus)
Scanner di codici a barre
// Use $code placeholder in the resultUrl, see example below
void fully.scanQrCode(String prompt, String resultUrl)

// Enhanced interface
// Use -1 for cameraId and timeout (in seconds) for defaults 
void fully.scanQrCode(String prompt, String resultUrl, int cameraId, int timeout, boolean beepEnabled, boolean showCancelButton)  
  
// Activate flashlight if needed  
void fully.scanQrCode(String prompt, String resultUrl, int cameraId, int timeout, boolean beepEnabled, boolean showCancelButton, boolean useFlashlight)

// Respond to QR events
void fully.bind('onQrScanSuccess','todo(\'$code\');')
void fully.bind('onQrScanCancelled','todo();')
Interfaccia Bluetooth
// Get a list of known devices incl. connection state and battery level  
String fully.btGetDeviceListJson()  
  
// Open a serial (SPP) bluetooth connection (GATT is not supported!)
// These functions are async, listen to events below to get results
void fully.btOpenByMac(String mac)
void fully.btOpenByUuid(String uuid)
void fully.btOpenByName(String name)

// Get info about connected device and close connection
boolean fully.btIsConnected()
String fully.btGetDeviceInfoJson()
void fully.btClose()

// Send data
boolean fully.btSendStringData(String stringData)
boolean fully.btSendHexData(String hexData)
boolean fully.btSendByteData(byte[] data)

// Respond to events
void fully.bind('onBtConnectSuccess','todo("$device");');
void fully.bind('onBtConnectFailure','todo();');
void fully.bind('onBtDataRead','todo("$data");'); // Data is buffered until LF symbol found
Leggere i tag NFC
// Note that NFC scan usually doesn't work if the screen is locked or the camera is in use  
bool fully.nfcScanStart();  
bool fully.nfcScanStart(int flags, int debounceMs);  
bool fully.nfcScanStop();  
void fully.bind('onNdefDiscovered','todo("$serial", "$message", "$data");');  
void fully.bind('onNfcTagDiscovered','todo("$serial", "$type", "$message", "$data");');  
void fully.bind('onNfcTagRemoved','todo("$serial");'); // Android 7+
Rispondere agli eventi
// The second parameter is a String containing JavaScript code to perform  
void fully.bind('screenOn','todo();')
void fully.bind('screenOff','todo();')
void fully.bind('showKeyboard','todo();')
void fully.bind('hideKeyboard','todo();')
void fully.bind('networkDisconnect','todo();')
void fully.bind('networkReconnect','todo();')
void fully.bind('internetDisconnect','todo();')
void fully.bind('internetReconnect','todo();')
void fully.bind('unplugged','todo();')
void fully.bind('pluggedAC','todo();')
void fully.bind('pluggedUSB','todo();')
void fully.bind('pluggedWireless','todo();')
void fully.bind('onScreensaverStart','todo();')
void fully.bind('onScreensaverStop','todo();')
void fully.bind('onDaydreamStart','todo();')
void fully.bind('onDaydreamStop','todo();')
void fully.bind('onBatteryLevelChanged','todo("$level");')
void fully.bind('volumeUp','todo();')
void fully.bind('volumeDown','todo();')  
void fully.bind('headphonesPlugged','todo();')  
void fully.bind('headphonesUnplugged','todo();')
void fully.bind('onMotion','todo();') // Max. one per second  
void fully.bind('facesDetected','todo($number);') // 1.48+
void fully.bind('onDarkness','todo();') // Requires screen off on darkness
void fully.bind('onMovement','todo();') 
void fully.bind('onIBeacon','todo("$id1","$id2","$id3",$distance);')  
void fully.bind('broadcastReceived','todo("$action","$extras");');  
void fully.bind('onQrScanSuccess','todo("$code","$extras");');  
void fully.bind('ttsInitSuccess','todo("$info");'); // ver. 1.55+  
void fully.bind('ttsTextQueued','todo("Text Queued: $id for $text with status $status");');  
void fully.bind('ttsSilenceQueued','todo("Silence Queued: $id for $millis ms with status $status");');  
void fully.bind('ttsUtteranceStart','todo("Utterance Start: $id");');  
void fully.bind('ttsUtteranceError','todo("Utterance Error: $id");');  
void fully.bind('ttsUtteranceDone','todo("Utterance Done: $id");');
Gestisci screensaver, altre app, intent, chiosco ecc.
// Manage fully kiosk screensaver  
void fully.startScreensaver()
void fully.stopScreensaver()
void fully.startDaydream()
void fully.stopDaydream()  
  
// Manage fully kiosk app  
boolean fully.isInForeground()
void fully.bringToForeground()
void fully.bringToForeground(long millis)   // Delay in ms
void fully.bringToBackground()
void fully.restartApp()  
void fully.exit()  
  
// Manage kiosk mode and maintenance mode  
void fully.enableMaintenanceMode()
void fully.disableMaintenanceMode()
void fully.setMessageOverlay(String text)  
void fully.lockKiosk()  
void fully.unlockKiosk()  
void fully.checkKioskPin()  
boolean fully.isKioskLocked()  
  
// Manage other apps and broadcasts  
void fully.startApplication(String packageName)
void fully.startApplication(String packageName, String action, String url)  // Can put null to omit the parameter
void fully.startIntent(String url)
void fully.broadcastIntent(String url)
void fully.registerBroadcastReceiver(String action)  
void fully.unregisterBroadcastReceiver(String action)  
void fully.killBackgroundProcesses(String package) // Android 13 and older  
void fully.installApkFile(String url)       // Not in Google Play Edition
Rilevamento del movimento
void fully.startMotionDetection()
void fully.stopMotionDetection()
boolean fully.isMotionDetectionRunning()
String fully.getCamshotJpgBase64()  
int fully.getFaceNumber()  
int fully.getAverageLuma() // Ver. 1.60+
void fully.triggerMotion()
void fully.bind('onMotion','todo();') // Triggered max. once per second
Gestisci tutte le impostazioni complete
// Look in Remote Admin settings for the settings keys
// Or export a JSON settings file and look there  
String fully.getBooleanSetting(String key)
String fully.getStringSetting(String key)
  
// Changes apply immediately
void fully.setBooleanSetting(String key, boolean value)
void fully.setStringSetting(String key, String value)
void fully.importSettingsFile(String url)
Gestisci le impostazioni di sistema
// Look here for keys and restrictions  
// Changing system settings usually requires provisioning or special permissions  
// https://developer.android.com/reference/android/provider/Settings  
  
int fully.getSettingsGlobalInt(String name, int default)  
long fully.getSettingsGlobalLong(String name, long default)  
String fully.getSettingsGlobalString(String name)  
void fully.putSettingsGlobalInt(String name, int value)  
void fully.putSettingsGlobalLong(String name, long value)  
void fully.putSettingsGlobalString(String name, String value)  
  
int fully.getSettingsSystemInt(String name, int def)  
long fully.getSettingsSystemLong(String name, long def)  
String fully.getSettingsSystemString(String name)  
void fully.putSettingsSystemInt(String name, int value)  
void fully.putSettingsSystemLong(String name, long value)  
void fully.putSettingsSystemString(String name, String value)  
  
int fully.getSettingsSecureInt(String name, int def)  
long fully.getSettingsSecureLong(String name, long def)  
String fully.getSettingsSecureString(String name)  
void fully.putSettingsSecureInt(String name, int value)  
void fully.putSettingsSecureLong(String name, long value)  
void fully.putSettingsSecureString(String name, String value)

Esempi che mostrano come utilizzare l'interfaccia JavaScript:

Come utilizzare l'interfaccia JavaScript?
<!-- Make actions -->
<button type="button" onclick="fully.openWifiSettings();">Wifi</button>

<!-- Show device info -->
<button type="button" onclick="alert(fully.getMacAddress());">Mac address</button>
  
<!-- Play Text to Speech -->  
<script>  
fully.bind('ttsTextQueued','showResult("Text Queued: $id for $text with status $status");');  
fully.bind('ttsSilenceQueued','showResult("Silence Queued: $id for $millis ms with status $status");');  
fully.bind('ttsUtteranceStart','showResult("Utterance Start: $id");');  
fully.bind('ttsUtteranceError','showResult("Utterance Error: $id");');  
fully.bind('ttsUtteranceDone','showResult("Utterance Done: $id");');  
</script>  
<button type="button" onclick="fully.textToSpeech('How do you do?','en_GB');">Say hello</button>  
  
<!-- Change Fully Kiosk settings -->  
<button type="button" onclick="fully.setStringSetting('screenBrightness','255');">Full brightness</button>  
<button type="button" onclick="fully.setBooleanSetting('motionDetection',true);">Enable MD</button>  

<!-- Listen for events -->
<script>
function myMotion() { alert("Motion"); }
fully.bind('onMotion','myMotion();');
</script>

<!-- Listen for iBeacon -->
<script>
function onBeacon (id1,id2,id3,distance) {
  alert("iBeacon found: "+id1+"/"+id2+"/"+id3+" in "+distance+" meter");
}
fully.bind('onIBeacon','onBeacon("$id1","$id2","$id3",$distance);');
// You can also use $mac, $name, $type, $manufactorer as placeholders
</script>

<!-- Scan QR Code -->
<button type="button" onclick="fully.scanQrCode('Prompt text','javascript:alert(\'$code\');');">Scan QR Code</button>  

<!-- Identify Fully Kiosk Browser -->
<script>
if (typeof FullyKiosk !== "undefined")
  document.writeln("<h1>Fully Kiosk working</h1>");
</script>

<!-- Print on Bluetooth Printer -->
<script>
fully.bind('onBtConnectSuccess','alert(\'BT connected: $device\');
fully.bind('onBtConnectFailure','alert(\'BT failed\');');
fully.btOpenByUuid('0000110a-0000-1000-8000-00805f9b34fb');
</script>
<button type="button" onclick="alert(fully.btSendHexData('68656c6c6f0a'));">btSendHexData()</button>
<button type="button" onclick="alert(fully.btSendStringData('Hello\n'));">btSendStringData()</button>
<button type="button" onclick="alert(fully.btSendByteData(new Uint8Array([104, 101, 108, 108, 111, 10])));">btSendByteData()</button>

Se non puoi modificare il sito web, puoi utilizzare la funzione "Inietta JavaScript" per aggiungere i tuoi script ad altri siti web.