blob: 5bda14d5d7bf01ce33035e0a1c9ab45461aa9492 [file] [log] [blame] [edit]
# Copyright 2023 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
description "Job to start ARC++ services to share media files like MyFiles"
author "chromium-os-dev@chromium.org"
stop on stop-arc-instance or stopping ui
# Default score for Android system processes.
oom score -100
# Export for arc-myfiles* and arc-removable-media-full.
import IS_ANDROID_CONTAINER_RVC
export IS_ANDROID_CONTAINER_RVC
import MEDIA_PROVIDER_UID
export MEDIA_PROVIDER_UID
pre-start script
MOUNT_POINTS="/run/arc/media/MyFiles \
/run/arc/media/MyFiles-default \
/run/arc/media/MyFiles-read \
/run/arc/media/MyFiles-write \
/run/arc/media/removable \
/run/arc/media/removable-default \
/run/arc/media/removable-read \
/run/arc/media/removable-write"
if [ "${IS_ANDROID_CONTAINER_RVC}" = "true" ]; then
# Verify input string provided by chronos. See crbug/1414511.
if ! expr "${MEDIA_PROVIDER_UID}" : "^[0-9]\+$" > /dev/null; then
logger -t "${UPSTART_JOB}" \
"Invalid MEDIA_PROVIDER_UID: ${MEDIA_PROVIDER_UID}"
exit 1
fi
MOUNT_POINTS="${MOUNT_POINTS} \
/run/arc/media/MyFiles-full \
/run/arc/media/removable-full"
fi
# Wait for the mount points to appear up to 5 seconds.
elapsed_millisecs=0
for mount_point in ${MOUNT_POINTS}; do
while ! mountpoint -q "${mount_point}"; do
if status | grep -q stop; then
exit 0
fi
if [ "${elapsed_millisecs}" -ge 5000 ]; then
logger -t "${UPSTART_JOB}" "Timed out while waiting for ${mount_point}"
exit 1
fi
sleep 0.1
elapsed_millisecs=$((elapsed_millisecs+10))
done
done
end script