Skip to content

Commit

Permalink
Introduce useWifi, update README
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed Feb 2, 2023
1 parent 1afa2bf commit 8a24957
Show file tree
Hide file tree
Showing 5 changed files with 282 additions and 0 deletions.
220 changes: 220 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,226 @@ yarn add fullykiosk

```

## Progress

### Fully Kiosk API functions implemented

- [x] getCurrentLocale()
- [x] getIp4Address()
- [x] getIp6Address()
- [x] getHostname()
- [x] getHostname6()
- [x] getMacAddress()
- [x] getMacAddressForInterface(interface)
- [x] getWifiSsid()
- [x] getWifiBssid()
- [x] getWifiSignalLevel()
- [x] getSerialNumber()
- [x] getSerialNumberDeviceOwner()
- [x] getAndroidId()
- [x] getDeviceId()
- [x] getDeviceName()
- [x] getImei()
- [x] getSimSerialNumber()
- [x] getBatteryLevel()
- [x] getScreenBrightness()
- [x] getScreenOrientation()
- [x] getDisplayWidth()
- [x] getDisplayHeight()
- [x] getScreenOn()
- [x] isPlugged()
- [x] isKeyboardVisible()
- [x] isWifiEnabled()
- [x] isWifiConnected()
- [x] isNetworkConnected()
- [ ] isBluetoothEnabled()
- [ ] isScreenRotationLocked()
- [ ] getFullyVersion()
- [ ] getFullyVersionCode()
- [ ] getWebviewVersion()
- [ ] getAndroidVersion()
- [ ] getAndroidSdk()
- [ ] getDeviceModel()
- [ ] getInternalStorageTotalSpace()
- [ ] getInternalStorageFreeSpace()
- [ ] getExternalStorageTotalSpace()
- [ ] getExternalStorageFreeSpace()
- [ ] getSensorInfo()
- [ ] getSensorValue(int type)
- [ ] getSensorValues(int type)
- [ ] getAllRxBytesMobile()
- [ ] getAllTxBytesMobile()
- [x] getAllRxBytesWifi()
- [x] getAllTxBytesWifi()

- [x] turnScreenOn()
- [x] turnScreenOff()
- [x] turnScreenOff(boolean keepAlive)
- [x] forceSleep()
- [ ] showToast(String text)
- [x] setScreenBrightness(float level)
- [x] enableWifi() // In Android 10+ only with provisioned devices
- [x] disableWifi() // In Android 10+ only with provisioned devices
- [ ] enableBluetooth()
- [ ] disableBluetooth()
- [x] showKeyboard()
- [x] hideKeyboard()
- [x] openWifiSettings()
- [ ] openBluetoothSettings()
- [ ] vibrate(int millis)
- [ ] sendHexDataToTcpPort(String hexData, String host, int port)
- [ ] showNotification(String title, String text, String url, boolean highPriority) // ver. 1.33+
- [ ] log(int type, String tag, String message) // ver. 1.41+
- [ ] copyTextToClipboard(String text)
- [ ] getClipboardText()
- [ ] getClipboardHtmlText()

- [ ] deleteFile(String path)
- [ ] deleteFolder(String path) // recursive!
- [ ] emptyFolder(String path) // recursive, ver. 1.30+
- [ ] createFolder(String path) // ver. 1.42+
- [ ] getFileList(String folder) // get JSON array, ver. 1.31+
- [ ] downloadFile(String url, String dirName)
- [ ] unzipFile(String fileName) // ver. 1.40.2+
- [ ] downloadAndUnzipFile(String url, String dirName)
- [ ] bind('onDownloadSuccess','todo("$url","$dir","$code","$fileLength","$lastModified","$mimetype");')
- [ ] bind('onDownloadFailure','todo("$url","$dir","$code");')
- [ ] bind('onUnzipSuccess','todo("$url","$dir");')
- [ ] bind('onUnzipFailure','todo("$url","$dir","$message");')

- [ ] textToSpeech(String text)
- [ ] textToSpeech(String text, String locale)
- [ ] textToSpeech(String text, String locale, String engine)
- [ ] textToSpeech(String text, String locale, String engine, boolean queue)
- [ ] stopTextToSpeech()
- [ ] playVideo(String url, boolean loop, boolean showControls, boolean exitOnTouch, boolean exitOnCompletion)
- [ ] stopVideo()
- [ ] setAudioVolume(int level, int stream)
- [ ] playSound(String url, boolean loop)
- [ ] playSound(String url, boolean loop, int stream)
- [ ] stopSound()
- [ ] showPdf(String url)
- [ ] getAudioVolume(int stream)
- [ ] isWiredHeadsetOn()
- [ ] isMusicActive()

- [ ] loadStartUrl()
- [ ] setActionBarTitle(String text)
- [x] startScreensaver()
- [x] stopScreensaver()
- [x] startDaydream()
- [x] stopDaydream()
- [ ] addToHomeScreen()
- [ ] print()
- [ ] exit()
- [ ] restartApp()
- [ ] getScreenshotPngBase64()
- [ ] loadStatsCSV()
- [ ] clearCache()
- [ ] clearFormData()
- [ ] clearHistory()
- [ ] clearCookies()
- [ ] clearCookiesForUrl(String url)
- [ ] clearWebstorage()
- [ ] focusNextTab()
- [ ] focusPrevTab()
- [ ] focusTabByIndex(int index)
- [ ] getCurrentTabIndex()
- [ ] shareUrl()
- [ ] closeTabByIndex(int index)
- [ ] closeThisTab()
- [ ] getTabList()
- [ ] loadUrlInTabByIndex(int index, String url)
- [ ] loadUrlInNewTab(String url, boolean focus)
- [ ] getThisTabIndex()
- [ ] getCurrentTabIndex()
- [ ] focusThisTab()
- [ ] focusTabByIndex(int index)

- [ ] scanQrCode(String prompt, String resultUrl)
- [ ] scanQrCode(String prompt, String resultUrl, int cameraId, int timeout, boolean beepEnabled, boolean showCancelButton)
- [ ] scanQrCode(String prompt, String resultUrl, int cameraId, int timeout, boolean beepEnabled, boolean showCancelButton, boolean useFlashlight)
- [ ] bind('onQrScanSuccess','todo(\'$code\');')
- [ ] bind('onQrScanCancelled','todo();')

- [ ] btOpenByMac(String mac)
- [ ] btOpenByUuid(String uuid)
- [ ] btOpenByName(String name)
- [ ] fully.btIsConnected()
- [ ] fully.btGetDeviceInfoJson()
- [ ] fully.btClose()
- [ ] btSendStringData(String stringData)
- [ ] btSendHexData(String hexData)
- [ ] btSendByteData(byte[] data)
- [ ] bind('onBtConnectSuccess','todo("$device");');
- [ ] bind('onBtConnectFailure','todo();');
- [ ] bind('onBtDataRead','todo("$data");');

- [ ] nfcScanStart();
- [ ] nfcScanStart(int flags, int debounceMs);
- [ ] nfcScanStop();
- [ ] bind('onNdefDiscovered','todo("$serial", "$message", "$data");');
- [ ] bind('onNfcTagDiscovered','todo("$serial", "$type", "$message", "$data");');
- [ ] bind('onNfcTagRemoved','todo("$serial");');

- [x] bind('screenOn','todo();')
- [x] bind('screenOff','todo();')
- [x] bind('showKeyboard','todo();')
- [x] bind('hideKeyboard','todo();')
- [x] bind('networkDisconnect','todo();')
- [x] bind('networkReconnect','todo();')
- [ ] bind('internetDisconnect','todo();')
- [ ] bind('internetReconnect','todo();')
- [x] bind('unplugged','todo();')
- [x] bind('pluggedAC','todo();')
- [x] bind('pluggedUSB','todo();')
- [x] bind('pluggedWireless','todo();')
- [ ] bind('onScreensaverStart','todo();')
- [ ] bind('onScreensaverStop','todo();')
- [ ] bind('onDaydreamStart','todo();')
- [ ] bind('onDaydreamStop','todo();')
- [x] bind('onBatteryLevelChanged','todo();')
- [ ] bind('volumeUp','todo();')
- [ ] bind('volumeDown','todo();')
- [ ] bind('onMotion','todo();')
- [ ] bind('facesDetected','todo($number);')
- [ ] bind('onDarkness','todo();')
- [ ] bind('onMovement','todo();')
- [ ] bind('onIBeacon','todo("$id1","$id2","$id3",$distance);')
- [ ] bind('broadcastReceived','todo("$action","$extras");');
- [ ] bind('onQrScanSuccess','todo("$code","$extras");');

- [ ] startApplication(String packageName)
- [ ] startApplication(String packageName, String action, String url)
- [ ] startIntent(String url)
- [ ] broadcastIntent(String url)
- [ ] isInForeground()
- [ ] bringToForeground()
- [ ] bringToForeground(long millis)
- [ ] bringToBackground()
- [ ] installApkFile(String url)
- [ ] enableMaintenanceMode()
- [ ] disableMaintenanceMode()
- [ ] setMessageOverlay(String text)
- [ ] registerBroadcastReceiver(String action)
- [ ] unregisterBroadcastReceiver(String action)

- [ ] fully.startMotionDetection()
- [ ] stopMotionDetection()
- [ ] isMotionDetectionRunning()
- [ ] getCamshotJpgBase64()
- [ ] getFaceNumber()
- [ ] triggerMotion()
- [ ] bind('onMotion','todo();')

- [ ] fully.getStartUrl()
- [ ] fully.setStartUrl(String url)
- [ ] fully.getBooleanSetting(String key)
- [ ] fully.getStringSetting(String key)
- [ ] fully.setBooleanSetting(String key, boolean value)
- [ ] fully.setStringSetting(String key, String value)
- [ ] fully.importSettingsFile(String url)

## Contributors

[![](https://contrib.rocks/image?repo=v3xlabs/node-fullykiosk)](https://github.com/v3xlabs/node-fullykiosk/graphs/contributors)
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/useBatteryLevel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { useEffect, useMemo, useState } from 'react';

import { is_fully } from '../utils/is_fully';

window._fullykiosk = window._fullykiosk || {};

// Returns undefined if fully not available
export const useBatteryLevel = () => {
if (!is_fully()) return { batteryLevel: undefined };
Expand Down
43 changes: 43 additions & 0 deletions src/hooks/useWifi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { useEffect, useMemo } from 'react';

window._fullykiosk = window._fullykiosk || {};

export const useWifi = () => {
const wifiEnabled = fully.isWifiEnabled();
const wifiConnected = fully.isWifiConnected();
const networkConnected = fully.isNetworkConnected();

const vId = useMemo(() => Math.random().toString(36).slice(2, 11), []);

useEffect(() => {
window._fullykiosk[vId] = (state: 'reconnect' | 'disconnect') => {
// setBatteryLevel(fully.getBatteryLevel());
alert(state);
};

// Register events
fully.bind('networkReconnect', `_fullykiosk['${vId}']('reconnect');`);
fully.bind('networkDisconnect', `_fullykiosk['${vId}']('disconnect');`);

return () => {
// Unregister events
window._fullykiosk[vId] = undefined;
};
}, [0]);

return {
wifiEnabled,
wifiConnected,
networkConnected,
enableWifi: () => fully.enableWifi(),
disableWifi: () => fully.disableWifi(),
openWifiSettings: () => fully.openWifiSettings(),
};
};

export const useWifiBytes = () => {
return {
getAllRxBytesWifi: () => fully.getAllRxBytesWifi(),
getAllTxBytesWifi: () => fully.getAllTxBytesWifi(),
};
};
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ export * from './hooks/useScreenBrightness';
export * from './hooks/useScreenSleep';
export * from './hooks/useSerialNumber';
export * from './hooks/useSimSerialNumber';
export * from './hooks/useWifi';
export * from './hooks/useWifiSignalLevel';
export * from './hooks/useWifiSSID';
16 changes: 16 additions & 0 deletions test/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
useSerialNumber,
useSerialNumberDeviceOwner,
useSimSerialNumber,
useWifi,
useWifiBSSID,
useWifiSignalLevel,
useWifiSSID,
Expand Down Expand Up @@ -58,6 +59,14 @@ export const App: FC = () => {
turnOff,
} = useScreenSleep();
const { keyboardVisible, hideKeyboard, showKeyboard } = useKeyboard();
const {
enableWifi,
disableWifi,
openWifiSettings,
networkConnected,
wifiConnected,
wifiEnabled,
} = useWifi();

return (
<div>
Expand Down Expand Up @@ -124,6 +133,13 @@ export const App: FC = () => {
Show n Hide (5s)
</button>
</p>
<p>
<div>Wifi Enabled: {wifiEnabled ? 'yes' : 'no'}</div>
<div>Wifi Connected: {wifiConnected ? 'yes' : 'no'}</div>
<div>Network Connected: {networkConnected ? 'yes' : 'no'}</div>
<button onClick={openWifiSettings}>Settings</button>
<button onClick={enableWifi}>Enable</button>
</p>
</div>
);
};

0 comments on commit 8a24957

Please sign in to comment.