Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a7f366d4 authored by Yifan Hong's avatar Yifan Hong Committed by android-build-merger
Browse files

Merge changes from topic 'lshal_debug'

am: d4f5bb4c

Change-Id: I0d7b068421152d9c2bfb1c53718abcb7e09c26a1
parents d1058fb9 d4f5bb4c
Loading
Loading
Loading
Loading
+40 −3
Original line number Diff line number Diff line
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

cc_binary {
    name: "lshal",
cc_library_shared {
    name: "liblshal",
    shared_libs: [
        "libbase",
        "libcutils",
@@ -24,7 +24,44 @@ cc_binary {
        "libvintf",
    ],
    srcs: [
        "DebugCommand.cpp",
        "Lshal.cpp",
        "PipeRelay.cpp"
        "ListCommand.cpp",
        "PipeRelay.cpp",
        "utils.cpp",
    ],
}

cc_defaults {
    name: "lshal_defaults",
    shared_libs: [
        "libbase",
        "libhidlbase",
        "libhidltransport",
        "liblshal",
        "libutils",
    ]
}

cc_binary {
    name: "lshal",
    defaults: ["lshal_defaults"],
    srcs: [
        "main.cpp"
    ]
}

cc_test {
    name: "lshal_test",
    defaults: ["lshal_defaults"],
    gtest: true,
    static_libs: [
        "libgmock"
    ],
    shared_libs: [
        "android.hardware.tests.baz@1.0"
    ],
    srcs: [
        "test.cpp"
    ]
}
+54 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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 "DebugCommand.h"

#include "Lshal.h"

namespace android {
namespace lshal {

DebugCommand::DebugCommand(Lshal &lshal) : mLshal(lshal) {
}

Status DebugCommand::parseArgs(const std::string &command, const Arg &arg) {
    if (optind >= arg.argc) {
        mLshal.usage(command);
        return USAGE;
    }
    mInterfaceName = arg.argv[optind];
    ++optind;
    for (; optind < arg.argc; ++optind) {
        mOptions.push_back(arg.argv[optind]);
    }
    return OK;
}

Status DebugCommand::main(const std::string &command, const Arg &arg) {
    Status status = parseArgs(command, arg);
    if (status != OK) {
        return status;
    }
    auto pair = splitFirst(mInterfaceName, '/');
    return mLshal.emitDebugInfo(
            pair.first, pair.second.empty() ? "default" : pair.second, mOptions,
            mLshal.out().buf(),
            mLshal.err());
}

}  // namespace lshal
}  // namespace android
+49 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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.
 */

#ifndef FRAMEWORK_NATIVE_CMDS_LSHAL_DEBUG_COMMAND_H_
#define FRAMEWORK_NATIVE_CMDS_LSHAL_DEBUG_COMMAND_H_

#include <string>

#include <android-base/macros.h>

#include "utils.h"

namespace android {
namespace lshal {

class Lshal;

class DebugCommand {
public:
    DebugCommand(Lshal &lshal);
    Status main(const std::string &command, const Arg &arg);
private:
    Status parseArgs(const std::string &command, const Arg &arg);

    Lshal &mLshal;
    std::string mInterfaceName;
    std::vector<std::string> mOptions;

    DISALLOW_COPY_AND_ASSIGN(DebugCommand);
};


}  // namespace lshal
}  // namespace android

#endif  // FRAMEWORK_NATIVE_CMDS_LSHAL_DEBUG_COMMAND_H_
Loading