summaryrefslogtreecommitdiffstats
path: root/Alsa-Plugin/Alsa-Policy-Hook/README.md
blob: 108c2b558a99b0a0f61e2975d914c14ccaa17678 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Alsa-Hook-Plugin

Object: Provide a Hook on Alsa PCM to check permission again AGL Advance Audio Agent
Status: Working Proof of Concept
Author: Fulup Ar Foll fulup@iot.bzh
Date  : August-2017

Functionalities:
 - Execute a set of websocket RPC request again AGL binders to allow/deny access
 - Keep websocket open in an idepandant thread on order to monitor event receive from AGL audio agent 

Installation
 - Alsaplugins are typically search in /usr/share/alsa-lib. Nevertheless a full path might be given
 - This plugin implement a hook on a slave PCM. Typically this slave PCM is a dedicated virtual channel (eg: navigation, emergency,...)
 - Config should be place in ~/.asoundrc (see config sample in PROJECT_ROOT/conf.d/alsa)

Config
```
# Define sharelib location and entry point
# -----------------------------------------
pcm_hook_type.MyHookPlugin {
    install "AlsaInstallHook" 
    lib "/home/fulup/Workspace/AGL-AppFW/audio-bindings-dev/build/Alsa-Plugin/Alsa-Hook-Callback/alsa_hook_cb.so"
}

# Create PCM HOOK with corresponding request calls to AGL Audio Agent
# --------------------------------------------------------------------
pcm.MyNavigationHook {
    type hooks
    slave.pcm "MyMixerPCM" # Target PCM to effectively play sound 

    # Call request that should succeed before accessing slave PCM
    hooks.0 {
        type "MyHookPlugin"   # Name=xxxx should match with pcm_hook_type.xxxx
        hook_args {

            # URI to AGL-Advance-Audio-Agent binder
            uri   "ws://localhost:1234/api?token='audio-agent-token'"

            # Call request to send to binder (initial label is free, query is optional)
            request {
                MyFirstCheck {
                    api   "alsacore"
                    verb  "ping"
                } 
                MySecondCheck {
                    api   "alsacore"
                    verb  "ucmset"
                    query "{'devid':'hw:v1340','verb':'Navigation','dev':'speakers'}"
                }    
            }
        }
    }
}

```

NOTE: 

* Hook plugin is loaded by Alsa libasound within player context. It inherits client process attributes, as UID/GID or
the SMACK label on AGL. This smack label is tested by AGL security framework when requested a call on the audio-agent binder.
As a result the call will only succeed it the permission attached the application in Cynara matches. 

* Hook plugin keep a connection with the Audio-Agent until PCM is closed by the application. This connection allow the
Audio-Agent to send events. eg: pause, quit, mute, ...