From d4520330a65e59e5e3d07d450f061c088b0f5a9b Mon Sep 17 00:00:00 2001 From: Pierre-Hugues Husson Date: Mon, 11 Apr 2022 08:26:21 -0400 Subject: [PATCH] Add some samsung cmds --- cmds/Android.bp | 30 ++++++++++++++++++++++++++++++ cmds/sec-camera-list.cpp | 4 ++-- cmds/sec-ril.cpp | 37 +++++++++++++++++++++++++++++++++++++ cmds/sec-torch.cpp | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 cmds/sec-ril.cpp create mode 100644 cmds/sec-torch.cpp diff --git a/cmds/Android.bp b/cmds/Android.bp index a2f373d..520c59f 100644 --- a/cmds/Android.bp +++ b/cmds/Android.bp @@ -189,6 +189,7 @@ cc_binary { "sec-camera-list.cpp", ], shared_libs: [ + "vendor.samsung.hardware.camera.provider@4.0", "vendor.samsung.hardware.camera.provider@3.0", "libutils", "libhidlbase", @@ -211,3 +212,32 @@ cc_binary { "xiaomi-touch.cpp", ], } + +cc_binary { + name: "sec-ril", + srcs: [ + "sec-ril.cpp", + ], + shared_libs: [ + "android.hardware.radio@1.6", + "vendor.samsung.hardware.radio@2.0", + "vendor.samsung.hardware.radio@2.1", + "vendor.samsung.hardware.radio@2.2", + "libutils", + "libhidlbase", + ], +} + +cc_binary { + name: "sec-torch", + srcs: [ + "sec-torch.cpp", + ], + shared_libs: [ + "vendor.samsung.hardware.camera.provider@4.0", + "vendor.samsung.hardware.camera.provider@3.0", + "vendor.samsung.hardware.camera.device@5.0", + "libutils", + "libhidlbase", + ], +} diff --git a/cmds/sec-camera-list.cpp b/cmds/sec-camera-list.cpp index a8e3bf6..b5094b0 100644 --- a/cmds/sec-camera-list.cpp +++ b/cmds/sec-camera-list.cpp @@ -1,7 +1,7 @@ #include -#include +#include -using ::vendor::samsung::hardware::camera::provider::V3_0::ISehCameraProvider; +using ::vendor::samsung::hardware::camera::provider::V4_0::ISehCameraProvider; using ::android::sp; int main(int argc, char **argv) { diff --git a/cmds/sec-ril.cpp b/cmds/sec-ril.cpp new file mode 100644 index 0000000..c0b32c7 --- /dev/null +++ b/cmds/sec-ril.cpp @@ -0,0 +1,37 @@ +#include +#include +#include +#include +#include + +using ::vendor::samsung::hardware::radio::V2_2::ISehRadio; +using ::android::hardware::radio::V1_6::IRadio; +using ::android::sp; + +int main(int argc, char **argv) { + auto svc = ISehRadio::getService(argv[1]); + + //setNrMode +#if 0 + android::hardware::hidl_vec cmd = { + 2, 131, 0, 5, (uint8_t)atoi(argv[2]), + }; + svc->sendRequestRaw(5556, cmd); + svc->setNrMode(5555, atoi(argv[1])); +#endif + +#if 0 + //notifyRilConnected + android::hardware::hidl_vec cmd = { + 11,24,0,5,0, + }; + svc->sendRequestRaw(5556, cmd); +#endif + svc->setNrMode_2_2(5555, atoi(argv[2]), true); + +#if 0 + auto svcRadio = IRadio::getService(argv[1]); + svcRadio->setAllowedNetworkTypesBitmap(4444, 0x1bfffe); + svcRadio->setPreferredNetworkTypeBitmap(4443, 0x1bfffe); +#endif +} diff --git a/cmds/sec-torch.cpp b/cmds/sec-torch.cpp new file mode 100644 index 0000000..087f534 --- /dev/null +++ b/cmds/sec-torch.cpp @@ -0,0 +1,37 @@ +#include +#include +#include + +using ::vendor::samsung::hardware::camera::provider::V4_0::ISehCameraProvider; +using ::android::sp; + +int main(int argc, char **argv) { + auto svc = ISehCameraProvider::getService("legacy/0"); + android::hardware::camera::common::V1_0::Status status; + android::sp camera_old; + android::hardware::Return ret = svc->getCameraDeviceInterface_V3_x(argv[3], [&status, &camera_old](android::hardware::camera::common::V1_0::Status s, android::sp intf) { + status = s; + if(intf == nullptr) { + fprintf(stderr, "Failed getting camera intf\n"); + } + camera_old = intf; + }); + if(!ret.isOk()) + fprintf(stderr, "Failed getting camera 0\n"); + + auto cameraResult = vendor::samsung::hardware::camera::device::V5_0::ISehCameraDevice::castFrom(camera_old); + android::sp camera = cameraResult; + if(camera == nullptr) { + fprintf(stderr, "Coulnd't get sammy device\n"); + } + if(camera != nullptr) { + fprintf(stderr, "Got sammy camera device\n"); + if(strcmp(argv[1], "on") == 0) { + fprintf(stderr, "Truning torch mode on power %d\n", atoi(argv[2])); + camera->sehSetTorchModeStrength(android::hardware::camera::common::V1_0::TorchMode::ON, atoi(argv[2])); + } else { + camera->sehSetTorchModeStrength(android::hardware::camera::common::V1_0::TorchMode::OFF, 0); + } + } + +}