mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-21 11:55:31 -04:00
universal7885: fm-aidl: Implement new settype
Creates a thread that can poll pid value passed by this settype. Can track the client status with this
This commit is contained in:
parent
0a1bb46140
commit
06ca6c2ea6
4 changed files with 24 additions and 4 deletions
|
|
@ -23,7 +23,7 @@ cc_binary {
|
||||||
"libbinder_ndk",
|
"libbinder_ndk",
|
||||||
"liblog",
|
"liblog",
|
||||||
"libfileio",
|
"libfileio",
|
||||||
"vendor.eureka.hardware.fmradio-V2-ndk",
|
"vendor.eureka.hardware.fmradio-V3-ndk",
|
||||||
"vendor.eureka.hardware.audio_route-V1-ndk",
|
"vendor.eureka.hardware.audio_route-V1-ndk",
|
||||||
],
|
],
|
||||||
header_libs: ["libaudioclient_headers"],
|
header_libs: ["libaudioclient_headers"],
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,10 @@
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
#include "CommonMacro.h"
|
#include "CommonMacro.h"
|
||||||
|
|
||||||
|
|
@ -94,9 +96,10 @@ namespace aidl::vendor::eureka::hardware::fmradio {
|
||||||
}
|
}
|
||||||
|
|
||||||
::ndk::ScopedAStatus FMDevControl::setValue(SetType type, int value) {
|
::ndk::ScopedAStatus FMDevControl::setValue(SetType type, int value) {
|
||||||
|
using audio_route::IAudioRoute;
|
||||||
|
|
||||||
RETURN_IF_FAILED_LOCK;
|
RETURN_IF_FAILED_LOCK;
|
||||||
assert(fd > 0);
|
assert(fd > 0);
|
||||||
std::shared_ptr<audio_route::IAudioRoute> svc;
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SetType::SET_TYPE_FM_FREQ:
|
case SetType::SET_TYPE_FM_FREQ:
|
||||||
fm_radio_slsi::set_frequency(fd, value);
|
fm_radio_slsi::set_frequency(fd, value);
|
||||||
|
|
@ -119,7 +122,7 @@ namespace aidl::vendor::eureka::hardware::fmradio {
|
||||||
fm_radio_slsi::stop_search(fd);
|
fm_radio_slsi::stop_search(fd);
|
||||||
break;
|
break;
|
||||||
case SetType::SET_TYPE_FM_SPEAKER_ROUTE:
|
case SetType::SET_TYPE_FM_SPEAKER_ROUTE:
|
||||||
svc = audio_route::IAudioRoute::fromBinder(ndk::SpAIBinder(AServiceManager_waitForService("vendor.eureka.hardware.audio_route.IAudioRoute/default")));
|
std::shared_ptr<IAudioRoute> svc = IAudioRoute::fromBinder(ndk::SpAIBinder(AServiceManager_waitForService("vendor.eureka.hardware.audio_route.IAudioRoute/default")));
|
||||||
svc->setParam(value ? "routing=2": "routing=8");
|
svc->setParam(value ? "routing=2": "routing=8");
|
||||||
break;
|
break;
|
||||||
case SetType::SET_TYPE_FM_SEARCH_START:
|
case SetType::SET_TYPE_FM_SEARCH_START:
|
||||||
|
|
@ -130,6 +133,22 @@ namespace aidl::vendor::eureka::hardware::fmradio {
|
||||||
});
|
});
|
||||||
search_thread.detach();
|
search_thread.detach();
|
||||||
break;
|
break;
|
||||||
|
case SetType::SET_TYPE_FM_APP_PID:
|
||||||
|
client_observe_thread = std::thread([=] {
|
||||||
|
std::shared_ptr<IAudioRoute> svc;
|
||||||
|
pid_t pid = value;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (kill(pid, 0) < 0 && errno == ESRCH) break;
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
fm_radio_slsi::fm_thread_set(fd, 0);
|
||||||
|
svc = IAudioRoute::fromBinder(ndk::SpAIBinder(AServiceManager_waitForService("vendor.eureka.hardware.audio_route.IAudioRoute/default")));
|
||||||
|
svc->setParam("l_fmradio_mode=off");
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
client_observe_thread.detach();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ struct FMDevControl : public BnFMDevControl {
|
||||||
int fd;
|
int fd;
|
||||||
unsigned int index;
|
unsigned int index;
|
||||||
std::timed_mutex lock;
|
std::timed_mutex lock;
|
||||||
std::thread search_thread;
|
std::thread search_thread, client_observe_thread;
|
||||||
std::vector<int> freqs_list;
|
std::vector<int> freqs_list;
|
||||||
middlestate_t *kMiddleState;
|
middlestate_t *kMiddleState;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,7 @@ constexpr const char *FM_FREQ_SEEK = FM_SYSFS_BASE "/radio_freq_seek";
|
||||||
case SetType::SET_TYPE_FM_RMSSI:
|
case SetType::SET_TYPE_FM_RMSSI:
|
||||||
case SetType::SET_TYPE_FM_SEARCH_CANCEL:
|
case SetType::SET_TYPE_FM_SEARCH_CANCEL:
|
||||||
case SetType::SET_TYPE_FM_SPEAKER_ROUTE:
|
case SetType::SET_TYPE_FM_SPEAKER_ROUTE:
|
||||||
|
case SetType::SET_TYPE_FM_APP_PID:
|
||||||
NOT_SUPPORTED;
|
NOT_SUPPORTED;
|
||||||
case SetType::SET_TYPE_FM_SEARCH_START:
|
case SetType::SET_TYPE_FM_SEARCH_START:
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue