mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-09 06:58:29 -04:00
fix(bluetooth): derive codec from locale-independent profile name in bluez-card-profile.lua
fixes #3004 port 1.5
This commit is contained in:
@@ -29,10 +29,24 @@ local function profile_available(profile)
|
|||||||
return profile and profile.available ~= "no"
|
return profile and profile.available ~= "no"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local codec_profile_prefixes = {
|
||||||
|
"^a2dp%-sink%-(.+)$",
|
||||||
|
"^a2dp%-source%-(.+)$",
|
||||||
|
"^headset%-head%-unit%-(.+)$",
|
||||||
|
"^headset%-audio%-gateway%-(.+)$",
|
||||||
|
}
|
||||||
|
|
||||||
local function codec_from_profile(profile)
|
local function codec_from_profile(profile)
|
||||||
if not profile then
|
if not profile then
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
|
local name = profile.name or ""
|
||||||
|
for _, pattern in ipairs(codec_profile_prefixes) do
|
||||||
|
local codec = name:match(pattern)
|
||||||
|
if codec then
|
||||||
|
return codec:gsub("%-", "_"):upper()
|
||||||
|
end
|
||||||
|
end
|
||||||
local desc = profile.description or ""
|
local desc = profile.description or ""
|
||||||
local codec = desc:match("[Cc]odec%s+([%w%+%-%._]+)")
|
local codec = desc:match("[Cc]odec%s+([%w%+%-%._]+)")
|
||||||
if not codec then
|
if not codec then
|
||||||
|
|||||||
Reference in New Issue
Block a user