1#
2#  Copyright 2023 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
17description    "Start daemon for Minijailed Media Codec (MMC) Service"
18author         "ChromeOS BT <[email protected]>"
19
20# Mmc Codec Manager can recover by restarting.
21oom score -100
22
23# This service is started by D-Bus service activation through
24# org.chromium.mmc.CodecManager.service
25stop on stopping boot-services
26
27#  Minijail forks off the desired process and exits after forking.
28expect fork
29
30pre-start script
31  # Check if Boot-services is still running before starting mmc_service.
32  # This is to prevent new dbus-activated instances from getting
33  # started once the system is beginning to shut down.
34  if ! initctl status boot-services | grep -q running; then
35    stop
36    exit 0
37  fi
38end script
39
40exec minijail0 --config /usr/share/minijail/mmc.conf \
41  -- /usr/bin/mmc_service
42
43# Wait until DBus service becomes available.
44post-start exec minijail0 -u mmc_service -g mmc_service /usr/bin/gdbus \
45    wait --system --timeout 15 org.chromium.mmc.CodecManager
46