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

Commit e83f9fbc authored by Felipe Leme's avatar Felipe Leme
Browse files

Initial definition of the Dumpstate HIDL interfaces.

BUG: 31982882
Test: manually built it

Change-Id: I3dd1d681061d16059ec9cf67869f20759fb75cd0
parent 17452436
Loading
Loading
Loading
Loading
+49 −0
Original line number Diff line number Diff line
// This file is autogenerated by hidl-gen. Do not edit manually.

genrule {
    name: "android.hardware.dumpstate@1.0_genc++",
    tools: ["hidl-gen"],
    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.dumpstate@1.0",
    srcs: [
        "IDumpstateDevice.hal",
    ],
    out: [
        "android/hardware/dumpstate/1.0/DumpstateDeviceAll.cpp",
    ],
}

genrule {
    name: "android.hardware.dumpstate@1.0_genc++_headers",
    tools: ["hidl-gen"],
    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.dumpstate@1.0",
    srcs: [
        "IDumpstateDevice.hal",
    ],
    out: [
        "android/hardware/dumpstate/1.0/IDumpstateDevice.h",
        "android/hardware/dumpstate/1.0/IHwDumpstateDevice.h",
        "android/hardware/dumpstate/1.0/BnDumpstateDevice.h",
        "android/hardware/dumpstate/1.0/BpDumpstateDevice.h",
        "android/hardware/dumpstate/1.0/BsDumpstateDevice.h",
    ],
}

cc_library_shared {
    name: "android.hardware.dumpstate@1.0",
    generated_sources: ["android.hardware.dumpstate@1.0_genc++"],
    generated_headers: ["android.hardware.dumpstate@1.0_genc++_headers"],
    export_generated_headers: ["android.hardware.dumpstate@1.0_genc++_headers"],
    shared_libs: [
        "libhidlbase",
        "libhidltransport",
        "libhwbinder",
        "libutils",
        "libcutils",
    ],
    export_shared_lib_headers: [
        "libhidlbase",
        "libhidltransport",
        "libhwbinder",
        "libutils",
    ],
}
+24 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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.
 */

package android.hardware.dumpstate@1.0;

interface IDumpstateDevice {
    /*
     * Dumps device-specific state into the given file descriptor.
     */
    dumpstateBoard(handle h);
};
+22 −0
Original line number Diff line number Diff line
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := android.hardware.dumpstate@1.0-impl
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_SRC_FILES := \
    DumpstateDevice.cpp \

LOCAL_SHARED_LIBRARIES := \
    android.hardware.dumpstate@1.0 \
    libbase \
    libcutils \
    libhidlbase \
    libhidltransport \
    libhwbinder \
    liblog \
    libutils

LOCAL_STATIC_LIBRARIES := \
    libdumpstateutil

include $(BUILD_SHARED_LIBRARY)
+51 −0
Original line number Diff line number Diff line
#define LOG_TAG "dumpstate"

#include "DumpstateDevice.h"

#include <log/log.h>

#include "DumpstateUtil.h"

namespace android {
namespace hardware {
namespace dumpstate {
namespace V1_0 {
namespace implementation {

// Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow.
Return<void> DumpstateDevice::dumpstateBoard(const native_handle_t* handle) {
    if (handle->numFds < 1) {
        ALOGE("no FDs\n");
        return Void();
    }

    int fd = handle->data[0];
    if (fd < 0) {
        ALOGE("invalid FD: %d\n", handle->data[0]);
        return Void();
    }
    ALOGD("DumpstateDevice::dumpstateBoard() FD: %d\n", fd);
    ALOGI("Dumpstate HIDL not provided by device\n");
    dprintf(fd, "Dumpstate HIDL not provided by device; providing bogus data.\n");

    // Shows some examples on how to use the libdumpstateutils API.
    dprintf(fd, "Time now is: ");
    RunCommandToFd(fd, {"/system/bin/date"});
    dprintf(fd, "Contents of a small file (/system/etc/hosts):\n");
    DumpFileToFd(fd, "/system/etc/hosts");

    return Void();
}


IDumpstateDevice* HIDL_FETCH_IDumpstateDevice(const char* /* name */) {
    // TODO: temporary returning nullptr until it's implemented on master devices
    return nullptr;
//    return new DumpstateDevice();
}

}  // namespace implementation
}  // namespace V1_0
}  // namespace dumpstate
}  // namespace hardware
}  // namespace android
+36 −0
Original line number Diff line number Diff line
#ifndef ANDROID_HARDWARE_DUMPSTATE_V1_0_DUMPSTATEDEVICE_H
#define ANDROID_HARDWARE_DUMPSTATE_V1_0_DUMPSTATEDEVICE_H

#include <android/hardware/dumpstate/1.0/IDumpstateDevice.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>

namespace android {
namespace hardware {
namespace dumpstate {
namespace V1_0 {
namespace implementation {

using ::android::hardware::dumpstate::V1_0::IDumpstateDevice;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;

struct DumpstateDevice : public IDumpstateDevice {
    // Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow.
    Return<void> dumpstateBoard(const native_handle_t* fd) override;

};

extern "C" IDumpstateDevice* HIDL_FETCH_IDumpstateDevice(const char* name);

}  // namespace implementation
}  // namespace V1_0
}  // namespace dumpstate
}  // namespace hardware
}  // namespace android

#endif  // ANDROID_HARDWARE_DUMPSTATE_V1_0_DUMPSTATEDEVICE_H
Loading