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

Commit 36ec1bc7 authored by Steven Moreland's avatar Steven Moreland Committed by android-build-merger
Browse files

Merge "Revert "dumpsys: add option to list hardware services."" am: 9555a5d4 am: d2390bea

am: 8d306950

Change-Id: I6f4d5148e41181a4498fe1bcc3b2e9e0551785fb
parents cd983732 8d306950
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -15,8 +15,6 @@ cc_defaults {
        "libutils",
        "liblog",
        "libbinder",
        "android.hidl.manager@1.0",
        "libhidlbase"
    ],

    clang: true,
+4 −38
Original line number Diff line number Diff line
@@ -45,7 +45,8 @@ using android::base::StringPrintf;
using android::base::unique_fd;
using android::base::WriteFully;

static int sort_func(const String16* lhs, const String16* rhs) {
static int sort_func(const String16* lhs, const String16* rhs)
{
    return lhs->compare(*rhs);
}

@@ -54,11 +55,10 @@ static void usage() {
        "usage: dumpsys\n"
            "         To dump all services.\n"
            "or:\n"
            "       dumpsys [-t TIMEOUT] [--help | --hw | -l | --skip SERVICES | SERVICE [ARGS]]\n"
            "       dumpsys [-t TIMEOUT] [--help | -l | --skip SERVICES | SERVICE [ARGS]]\n"
            "         --help: shows this help\n"
            "         -l: only list services, do not dump them\n"
            "         -t TIMEOUT: TIMEOUT to use in seconds instead of default 10 seconds\n"
            "         --hw: list all hw services running on the device\n"
            "         --skip SERVICES: dumps all services but SERVICES (comma-separated list)\n"
            "         SERVICE [ARGS]: dumps only service SERVICE, optionally passing ARGS to it\n");
}
@@ -72,42 +72,16 @@ static bool IsSkipped(const Vector<String16>& skipped, const String16& service)
    return false;
}

static void ListHardwareServices(android::hidl::manager::V1_0::IServiceManager* hm) {
    using android::hardware::hidl_vec;
    using android::hardware::hidl_string;
    using android::hardware::Return;
    using android::sp;

    if (hm == nullptr) {
        ALOGE("Unable to get hardware service manager!");
        aerr << "Failed to get hardware service manager!";
        return;
    }

    Return<void> ret = hm->list([](const hidl_vec<hidl_string> &registered){
        aout << "Currently running hardware services:" << endl;
        for (const auto &service : registered) {
            aout << "  " << service << endl;
        }
    });

    if (!ret.isOk()) {
        aerr << "Failed to list hardware services: " << ret.description();
    }
}

int Dumpsys::main(int argc, char* const argv[]) {
    Vector<String16> services;
    Vector<String16> args;
    Vector<String16> skippedServices;
    bool showListOnly = false;
    bool listHwOnly = false;
    bool skipServices = false;
    int timeoutArg = 10;
    static struct option longOptions[] = {
        {"skip", no_argument, 0,  0 },
        {"help", no_argument, 0,  0 },
        {"hw",   no_argument, 0,  0 },
        {     0,           0, 0,  0 }
    };

@@ -131,8 +105,6 @@ int Dumpsys::main(int argc, char* const argv[]) {
            } else if (!strcmp(longOptions[optionIndex].name, "help")) {
                usage();
                return 0;
            } else if (!strcmp(longOptions[optionIndex].name, "hw")) {
                listHwOnly = true;
            }
            break;

@@ -171,17 +143,11 @@ int Dumpsys::main(int argc, char* const argv[]) {
    }

    if ((skipServices && skippedServices.empty()) ||
            (showListOnly && (!services.empty() || !skippedServices.empty())) ||
            (listHwOnly && (skipServices || services.size() > 0 || showListOnly))) {
            (showListOnly && (!services.empty() || !skippedServices.empty()))) {
        usage();
        return -1;
    }

    if (listHwOnly) {
        ListHardwareServices(hm_);
        return 0;
    }

    if (services.empty() || showListOnly) {
        // gets all services
        services = sm_->listServices();
+1 −4
Original line number Diff line number Diff line
@@ -17,21 +17,18 @@
#ifndef FRAMEWORK_NATIVE_CMD_DUMPSYS_H_
#define FRAMEWORK_NATIVE_CMD_DUMPSYS_H_

#include <android/hidl/manager/1.0/IServiceManager.h>
#include <binder/IServiceManager.h>

namespace android {

class Dumpsys {
  public:
    Dumpsys(android::IServiceManager* sm,
            android::hidl::manager::V1_0::IServiceManager* hm) : sm_(sm), hm_(hm) {
    Dumpsys(android::IServiceManager* sm) : sm_(sm) {
    }
    int main(int argc, char* const argv[]);

  private:
    android::IServiceManager* sm_;
    android::hidl::manager::V1_0::IServiceManager* hm_;
};
}

+1 −4
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@
#include <stdio.h>

using namespace android;
using HServiceManager = android::hidl::manager::V1_0::IServiceManager;

int main(int argc, char* const argv[]) {
    signal(SIGPIPE, SIG_IGN);
@@ -39,8 +38,6 @@ int main(int argc, char* const argv[]) {
        return 20;
    }

    sp<HServiceManager> hm = HServiceManager::getService("manager");

    Dumpsys dumpsys(sm.get(), hm.get());
    Dumpsys dumpsys(sm.get());
    return dumpsys.main(argc, argv);
}
+0 −4
Original line number Diff line number Diff line
@@ -5,12 +5,8 @@ cc_test {
    srcs: ["dumpsys_test.cpp"],

    shared_libs: [
        "android.hidl.manager@1.0",
        "libbase",
        "libbinder",
        "liblog",
        "libhidlbase",
        "libhidltransport",
        "libutils",
    ],

Loading