/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include "cuttlefish/host/libs/config/config_instance_derived.h"

#include <string>

#include "cuttlefish/common/libs/utils/files.h"
#include "cuttlefish/host/libs/config/cuttlefish_config.h"
#include "cuttlefish/host/libs/log_names/log_names.h"

namespace cuttlefish {

std::string AccessKregistryPath(const CuttlefishConfig::InstanceSpecific& ins) {
  return AbsolutePath(ins.PerInstancePath("access-kregistry"));
}

std::string ConsoleInPipeName(const CuttlefishConfig::InstanceSpecific& ins) {
  return ConsolePipePrefix(ins) + ".in";
}

std::string ConsoleOutPipeName(const CuttlefishConfig::InstanceSpecific& ins) {
  return ConsolePipePrefix(ins) + ".out";
}

std::string ConsolePath(const CuttlefishConfig::InstanceSpecific& ins) {
  return AbsolutePath(ins.PerInstancePath("console"));
}

std::string ConsolePipePrefix(const CuttlefishConfig::InstanceSpecific& ins) {
  return AbsolutePath(ins.PerInstanceInternalPath("console"));
}

std::string GamepadSocketPath(const CuttlefishConfig::InstanceSpecific& ins) {
  return ins.PerInstanceInternalUdsPath("gamepad.sock");
}

std::string HwcomposerPmemPath(const CuttlefishConfig::InstanceSpecific& ins) {
  return AbsolutePath(ins.PerInstanceInternalPath("hwcomposer-pmem"));
}

std::string KernelLogPipeName(const CuttlefishConfig::InstanceSpecific& ins) {
  return AbsolutePath(ins.PerInstanceInternalPath("kernel-log-pipe"));
}

std::string KeyboardSocketPath(const CuttlefishConfig::InstanceSpecific& ins) {
  return ins.PerInstanceInternalUdsPath("keyboard.sock");
}

std::string LauncherMonitorSocketPath(
    const CuttlefishConfig::InstanceSpecific& ins) {
  return AbsolutePath(ins.PerInstanceUdsPath("launcher_monitor.sock"));
}

std::string LogcatPath(const CuttlefishConfig::InstanceSpecific& ins) {
  return AbsolutePath(ins.PerInstanceLogPath(kLogNameLogcat));
}

std::string LogcatPipeName(const CuttlefishConfig::InstanceSpecific& ins) {
  return AbsolutePath(ins.PerInstanceInternalPath("logcat-pipe"));
}

std::string MouseSocketPath(const CuttlefishConfig::InstanceSpecific& ins) {
  return ins.PerInstanceInternalUdsPath("mouse.sock");
}

std::string PflashPath(const CuttlefishConfig::InstanceSpecific& ins) {
  return AbsolutePath(ins.PerInstancePath("pflash.img"));
}

std::string PstorePath(const CuttlefishConfig::InstanceSpecific& ins) {
  return AbsolutePath(ins.PerInstancePath("pstore"));
}

std::string RotarySocketPath(const CuttlefishConfig::InstanceSpecific& ins) {
  return ins.PerInstanceInternalUdsPath("rotary.sock");
}

std::string SwitchesSocketPath(const CuttlefishConfig::InstanceSpecific& ins) {
  return ins.PerInstanceInternalUdsPath("switches.sock");
}

std::string RestoreAdbdPipeName(const CuttlefishConfig::InstanceSpecific& ins) {
  return AbsolutePath(ins.PerInstanceInternalPath("restore-pipe-adbd"));
}

}  // namespace cuttlefish

