policy-{bluetooth|device-profile|device-routes}.lua: Optimize for Event stack

- Sharpen the hooks.
- Make settings live, apply them when they are changed.
- Move some of the common functions to common_utils.lua
This commit is contained in:
Ashok Sidipotu
2022-09-06 19:24:33 +05:30
committed by Julian Bouzas
parent 8e7611fa9f
commit 6762de3990
7 changed files with 158 additions and 170 deletions

View File

@@ -93,6 +93,28 @@ function cutils.parseArray (str, convert_value, with_type)
return array
end
function cutils.arrayContains (a, value)
for _, v in ipairs (a) do
if v == value then
return true
end
end
return false
end
function cutils.storeAfterTimeout (state, state_table)
if timeout_source then
timeout_source:destroy ()
end
local timeout_source = Core.timeout_add (1000, function ()
local saved, err = state:save (state_table)
if not saved then
Log.warning (err)
end
timeout_source = nil
end)
end
cutils.default_metadata_om:activate ()
return cutils