1#
2# Copyright (C) 2016 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17# These are needed for migration of data to wifi apex directory.
18on post-fs-data
19   restorecon_recursive /data/misc/apexdata/com.android.wifi
20
21on property:sys.user.0.ce_available=true
22   restorecon_recursive /data/misc_ce/0/apexdata/com.android.wifi
23
24# Below are for kernel tracing related stuff.
25on fs
26   setprop sys.wifitracing.started 0
27
28on property:sys.boot_completed=1 && property:sys.wifitracing.started=0
29   # Create trace buffer, and set basic configuration.
30   mkdir /sys/kernel/debug/tracing/instances/wifi 711
31   restorecon_recursive /sys/kernel/debug/tracing/instances/wifi
32   write /sys/kernel/debug/tracing/instances/wifi/tracing_on 0
33   write /sys/kernel/debug/tracing/instances/wifi/buffer_size_kb 1
34   write /sys/kernel/debug/tracing/instances/wifi/trace_options disable_on_free
35
36   mkdir /sys/kernel/tracing/instances/wifi 711
37   restorecon_recursive /sys/kernel/tracing/instances/wifi
38   write /sys/kernel/tracing/instances/wifi/tracing_on 0
39   write /sys/kernel/tracing/instances/wifi/buffer_size_kb 1
40   write /sys/kernel/tracing/instances/wifi/trace_options disable_on_free
41
42   # Enable cfg80211 events for connection and key management events.
43   # - Events are not actually logged until WifiService writes "1" to
44   #   /sys/kernel/debug/tracing/instances/wifi/tracing_on.
45   # - WifiService is responsible for turning tracing off and on.
46   write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/cfg80211_gtk_rekey_notify/enable 1
47   write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_add_key/enable 1
48   write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_assoc/enable 1
49   write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_auth/enable 1
50   write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_connect/enable 1
51   write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_set_default_key/enable 1
52   write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_set_default_mgmt_key/enable 1
53   write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_set_rekey_data/enable 1
54
55   write /sys/kernel/tracing/instances/wifi/events/cfg80211/cfg80211_gtk_rekey_notify/enable 1
56   write /sys/kernel/tracing/instances/wifi/events/cfg80211/rdev_add_key/enable 1
57   write /sys/kernel/tracing/instances/wifi/events/cfg80211/rdev_assoc/enable 1
58   write /sys/kernel/tracing/instances/wifi/events/cfg80211/rdev_auth/enable 1
59   write /sys/kernel/tracing/instances/wifi/events/cfg80211/rdev_connect/enable 1
60   write /sys/kernel/tracing/instances/wifi/events/cfg80211/rdev_set_default_key/enable 1
61   write /sys/kernel/tracing/instances/wifi/events/cfg80211/rdev_set_default_mgmt_key/enable 1
62   write /sys/kernel/tracing/instances/wifi/events/cfg80211/rdev_set_rekey_data/enable 1
63
64   # Enable datapath events for Wifi.
65   # - Events are not actually logged until WifiService writes "1" to
66   #   /sys/kernel/debug/tracing/instances/wifi/tracing_on.
67   # - WifiService will ensure that tracing is turned back off,
68   #   when a connection attempt ends (whether in success or failure)
69   write /sys/kernel/debug/tracing/instances/wifi/events/net/filter name==${wifi.interface:-wlan0}
70   write /sys/kernel/debug/tracing/instances/wifi/events/net/net_dev_queue/enable 1
71   write /sys/kernel/debug/tracing/instances/wifi/events/net/net_dev_xmit/enable 1
72   write /sys/kernel/debug/tracing/instances/wifi/events/net/netif_rx/enable 1
73   write /sys/kernel/debug/tracing/instances/wifi/events/net/netif_receive_skb/enable 1
74
75   write /sys/kernel/tracing/instances/wifi/events/net/filter name==${wifi.interface:-wlan0}
76   write /sys/kernel/tracing/instances/wifi/events/net/net_dev_queue/enable 1
77   write /sys/kernel/tracing/instances/wifi/events/net/net_dev_xmit/enable 1
78   write /sys/kernel/tracing/instances/wifi/events/net/netif_rx/enable 1
79   write /sys/kernel/tracing/instances/wifi/events/net/netif_receive_skb/enable 1
80
81   # Set DAC to allow system to enable/disable, and read wifi trace
82   # events.
83   chown system /sys/kernel/debug/tracing/instances/wifi/tracing_on
84   chown system /sys/kernel/debug/tracing/instances/wifi/free_buffer
85   chown system /sys/kernel/debug/tracing/instances/wifi/trace
86   chmod 200 /sys/kernel/debug/tracing/instances/wifi/tracing_on
87   chmod 400 /sys/kernel/debug/tracing/instances/wifi/free_buffer
88   chmod 600 /sys/kernel/debug/tracing/instances/wifi/trace
89
90   chown system /sys/kernel/tracing/instances/wifi/tracing_on
91   chown system /sys/kernel/tracing/instances/wifi/free_buffer
92   chown system /sys/kernel/tracing/instances/wifi/trace
93   chmod 200 /sys/kernel/tracing/instances/wifi/tracing_on
94   chmod 400 /sys/kernel/tracing/instances/wifi/free_buffer
95   chmod 600 /sys/kernel/tracing/instances/wifi/trace
96   setprop sys.wifitracing.started 1
97
98on property:sys.boot_completed=1 && property:wifi.interface=* && property:sys.wifitracing.started=1
99   # Override default value.
100   write /sys/kernel/debug/tracing/instances/wifi/events/net/filter name==${wifi.interface}
101   write /sys/kernel/tracing/instances/wifi/events/net/filter name==${wifi.interface}
102