Add few debug commands

This commit is contained in:
Pierre-Hugues Husson 2019-03-31 19:41:09 +02:00
parent f00f7f4402
commit afae0a4d6f
4 changed files with 154 additions and 0 deletions

View File

@ -63,3 +63,39 @@ cc_binary {
"mtk-sms-fwk-ready.rc"
],
}
cc_binary {
name: "xiaomi-display-feature",
srcs: [
"xiaomi-display-feature.cpp",
],
shared_libs: [
"vendor.xiaomi.hardware.displayfeature@1.0",
"libutils",
"libhidlbase",
],
}
cc_binary {
name: "xiaomi-fp",
srcs: [
"xiaomi-fp.cpp",
],
shared_libs: [
"vendor.xiaomi.hardware.fingerprintextension@1.0",
"libutils",
"libhidlbase",
],
}
cc_binary {
name: "lightsctl-sec",
srcs: [
"lightsctl-sec.cpp",
],
shared_libs: [
"vendor.samsung.hardware.light@2.0",
"libutils",
"libhidlbase",
],
}

59
cmds/lightsctl-sec.cpp Normal file
View File

@ -0,0 +1,59 @@
#include <iostream>
#include <vendor/samsung/hardware/light/2.0/ISecLight.h>
#include <vendor/samsung/hardware/light/2.0/types.h>
using ::vendor::samsung::hardware::light::V2_0::ISecLight;
using ::android::sp;
int main(int argc, char **argv) {
auto svc = ISecLight::getService();
svc->getSupportedTypes([](auto types) {
for(const auto& type: types) {
std::cout << "Got type " << toString(type) << std::endl;
}
});
if(argc <= 1) return 0;
if(argc != 3 && argc != 6) return 1;
std::string typeArg(argv[1]);
vendor::samsung::hardware::light::V2_0::SecType type;
if(typeArg == "BACKLIGHT")
type = vendor::samsung::hardware::light::V2_0::SecType::BACKLIGHT;
if(typeArg == "KEYBOARD")
type = vendor::samsung::hardware::light::V2_0::SecType::KEYBOARD;
if(typeArg == "BUTTONS")
type = vendor::samsung::hardware::light::V2_0::SecType::BUTTONS;
if(typeArg == "BATTERY")
type = vendor::samsung::hardware::light::V2_0::SecType::BATTERY;
if(typeArg == "NOTIFICATIONS")
type = vendor::samsung::hardware::light::V2_0::SecType::NOTIFICATIONS;
if(typeArg == "ATTENTION")
type = vendor::samsung::hardware::light::V2_0::SecType::ATTENTION;
if(typeArg == "BLUETOOTH")
type = vendor::samsung::hardware::light::V2_0::SecType::BLUETOOTH;
if(typeArg == "WIFI")
type = vendor::samsung::hardware::light::V2_0::SecType::WIFI;
std::cout << "Set request type " << toString(type) << std::endl;
android::hardware::light::V2_0::LightState state;
state.color = (uint32_t)strtoll(argv[2], NULL, 16);
state.flashMode = android::hardware::light::V2_0::Flash::NONE;
state.brightnessMode = android::hardware::light::V2_0::Brightness::USER;
if(argc == 6) {
std::string flashArg(argv[3]);
if(flashArg == "NONE")
state.flashMode = android::hardware::light::V2_0::Flash::NONE;
if(flashArg == "TIMED")
state.flashMode = android::hardware::light::V2_0::Flash::TIMED;
if(flashArg == "HARDWARE")
state.flashMode = android::hardware::light::V2_0::Flash::HARDWARE;
state.flashOnMs = atoi(argv[4]);
state.flashOffMs = atoi(argv[5]);
}
std::cout << "Set flash type to " << toString(state.flashMode) << std::endl;
auto ret = svc->setLightSec(type, state);
std::cout << "Set light returned " << toString(ret) << std::endl;
}

View File

@ -0,0 +1,38 @@
#include <iostream>
#include <unistd.h>
#include <vendor/xiaomi/hardware/displayfeature/1.0/IDisplayFeature.h>
using ::vendor::xiaomi::hardware::displayfeature::V1_0::IDisplayFeature;
using ::android::sp;
int main(int argc, char **argv) {
auto svc = IDisplayFeature::getService();
if(svc == nullptr) {
std::cerr << "Failed getting IDisplayFeature" << std::endl;
return -1;
}
if(argc != 3) {
fprintf(stderr, "Usage: %s <ADAPT|ENHANCE|STANDARD|EYECARE|MONOCHROME|SUNLIGHT|NIGHTLIGHT|HIGHLIGHT> <value>\n", argv[0]);
return -2;
}
int mode = -1;
std::string modeArg(argv[1]);
if(modeArg == "ADAPT")
mode = 0;
if(modeArg == "ENHANCE")
mode = 1;
if(modeArg == "STANDARD")
mode = 2;
if(modeArg == "EYECARE")
mode = 3;
if(modeArg == "MONOCHROME")
mode = 4;
if(modeArg == "SUNLIGHT")
mode = 8;
if(modeArg == "NIGHTLIGHT")
mode = 9;
if(modeArg == "HIGHLIGHT")
mode = 11;
svc->setFeature(0, mode, atoi(argv[2]), 255);
}

21
cmds/xiaomi-fp.cpp Normal file
View File

@ -0,0 +1,21 @@
#include <iostream>
#include <unistd.h>
#include <vendor/xiaomi/hardware/fingerprintextension/1.0/IXiaomiFingerprint.h>
using ::vendor::xiaomi::hardware::fingerprintextension::V1_0::IXiaomiFingerprint;
using ::android::sp;
int main(int argc, char **argv) {
auto svc = IXiaomiFingerprint::getService();
if(svc == nullptr) {
std::cerr << "Failed getting IDisplayFeature" << std::endl;
return -1;
}
if(argc != 3) {
fprintf(stderr, "Usage: %s <command> <value>\n", argv[0]);
return -2;
}
uint32_t cmd = (uint32_t)strtoll(argv[1], NULL, 16);
uint32_t value = (uint32_t)strtoll(argv[2], NULL, 16);
svc->extCmd(cmd, value);
}