service profcollectd /system/bin/profcollectd
    class late_start
    disabled
    oneshot
    user root
    group root shell wakelock
    task_profiles ServiceCapacityLow

service profcollectctl_set_property /system/bin/profcollectctl set-property
    class main
    user root
    group root shell
    disabled
    oneshot

service profcollectctl_reset /system/bin/profcollectctl reset
    class main
    user root
    group root shell
    disabled
    oneshot

on post-fs-data
    # Create directory for profcollectd.
    mkdir /data/misc/profcollectd 0770 shell shell
    mkdir /data/misc/profcollectd/trace 0770 shell shell
    mkdir /data/misc/profcollectd/output 0770 shell shell
    mkdir /data/misc/profcollectd/report 0770 shell shell

on property:sys.boot_completed=1
    # Sync device configs to system properties. This is a workaround for b/433651427,
    # where device configs for profcollect_native_boot may not be synced to system
    # properties on some devices due to a race condition.
    start profcollectctl_set_property

on property:persist.profcollectd.enabled=true
    start profcollectd

on property:persist.profcollectd.enabled_override=true
    start profcollectd

on property:persist.profcollectd.enabled=false && property:persist.profcollectd.enabled_override!=true
    start profcollectctl_reset
