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:

committed by
Julian Bouzas

parent
8e7611fa9f
commit
6762de3990
@@ -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
|
Reference in New Issue
Block a user