Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function setKeepScreenOn (opts = {}) {
let res = {errMsg: 'setKeepScreenOn:ok'} as any
const isObject = shouleBeObject(opts)
if (!isObject.res) {
res = {errMsg: `setKeepScreenOn${isObject.msg}`}
console.error(res.errMsg)
return Promise.reject(res)
}
const {keepScreenOn, success, fail, complete}: any = opts
await Permissions.askAsync(Permissions.SYSTEM_BRIGHTNESS)
const {status} = await Permissions.getAsync(Permissions.SYSTEM_BRIGHTNESS)
if (status === 'granted') {
try {
if (keepScreenOn) {
// activateKeepAwake()
} else {
// deactivateKeepAwake()
}
return successHandler(success, complete)(res)
} catch (e) {
res.errMsg = `setKeepScreenOn:fail invalid ${e}`
return errorHandler(fail, complete)(res)
}
}
}
export async function getScreenBrightness (opts = {}) {
let res = {errMsg: 'getScreenBrightness:ok'} as any
const isObject = shouleBeObject(opts)
if (!isObject.res) {
res = {errMsg: `getScreenBrightness${isObject.msg}`}
console.error(res.errMsg)
return Promise.reject(res)
}
const {success, fail, complete}: any = opts
await Permissions.askAsync(Permissions.SYSTEM_BRIGHTNESS)
const {status} = await Permissions.getAsync(Permissions.SYSTEM_BRIGHTNESS)
if (status === 'granted') {
try {
res.num = await (Brightness as any).getBrightnessAsync()
return successHandler(success, complete)(res)
} catch (e) {
res.errMsg = `getScreenBrightness:fail invalid ${e}`
return errorHandler(fail, complete)(res)
}
}
}