mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-23 04:25:33 -04:00
universal7885: interfaces: Implement FMRadio HAL V1.2
* Also, track our fork of OneUI theme lib
* Implement read from sysfs interface which can fix channel searching on some cases
* Commit link: fead45ba0e
Change-Id: I81532b7f8169637fdcad0f678790a2b1f1888ecc
Signed-off-by: roynatech2544 <whiteshell2544@naver.com>
This commit is contained in:
parent
02eded67c8
commit
e07865c670
14 changed files with 140 additions and 25 deletions
|
|
@ -14,6 +14,7 @@ android_app {
|
||||||
],
|
],
|
||||||
required: [
|
required: [
|
||||||
"privapp_whitelist_com.eurekateam.fmradio.xml",
|
"privapp_whitelist_com.eurekateam.fmradio.xml",
|
||||||
|
"vendor.eureka.hardware.fmradio@1.2-service",
|
||||||
],
|
],
|
||||||
optimize: {
|
optimize: {
|
||||||
proguard_flags_files: ["rules.pro"],
|
proguard_flags_files: ["rules.pro"],
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,14 @@ cc_library_shared {
|
||||||
"-Wno-unused-parameter",
|
"-Wno-unused-parameter",
|
||||||
],
|
],
|
||||||
srcs: ["fm_ioctl.cpp"],
|
srcs: ["fm_ioctl.cpp"],
|
||||||
|
shared_libs: [
|
||||||
|
"libhidlbase",
|
||||||
|
"liblog",
|
||||||
|
"libutils",
|
||||||
|
"vendor.eureka.hardware.fmradio@1.0",
|
||||||
|
"vendor.eureka.hardware.fmradio@1.1",
|
||||||
|
"vendor.eureka.hardware.fmradio@1.2",
|
||||||
|
],
|
||||||
header_libs: ["jni_headers"],
|
header_libs: ["jni_headers"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,16 @@
|
||||||
#include "kernel_internal.h"
|
#include "kernel_internal.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
|
#include <hardware/hardware.h>
|
||||||
|
#include <hidl/HidlSupport.h>
|
||||||
|
#include <hidl/LegacySupport.h>
|
||||||
|
#include <hidl/Status.h>
|
||||||
|
#include <vendor/eureka/hardware/fmradio/1.2/IFMRadio.h>
|
||||||
|
|
||||||
|
using android::sp;
|
||||||
|
using vendor::eureka::hardware::fmradio::V1_2::IFMRadio;
|
||||||
|
using vendor::eureka::hardware::fmradio::V1_0::Direction;
|
||||||
|
using vendor::eureka::hardware::fmradio::V1_1::Status;
|
||||||
|
|
||||||
//#define DEBUG
|
//#define DEBUG
|
||||||
#define TRACK_SIZE 30
|
#define TRACK_SIZE 30
|
||||||
|
|
@ -185,7 +195,12 @@ static long fm_radio_get_freqs(int fd){
|
||||||
long ret = 0;
|
long ret = 0;
|
||||||
fm_radio_set_mute(fd, true);
|
fm_radio_set_mute(fd, true);
|
||||||
for (long & track : tracks){
|
for (long & track : tracks){
|
||||||
|
if (mSysfs) {
|
||||||
|
service->adjustFreqByStep(Direction::UP);
|
||||||
|
ret = (long) service->getFreqFromSysfs();
|
||||||
|
} else {
|
||||||
fm_radio_channel_searching(fd, 1, 0, FM_CHANNEL_SPACING_50KHZ, &ret);
|
fm_radio_channel_searching(fd, 1, 0, FM_CHANNEL_SPACING_50KHZ, &ret);
|
||||||
|
}
|
||||||
if (contains(tracks, ret)) break;
|
if (contains(tracks, ret)) break;
|
||||||
track = ret;
|
track = ret;
|
||||||
printf("Found Freq %ld\n", ret);
|
printf("Found Freq %ld\n", ret);
|
||||||
|
|
|
||||||
|
|
@ -17,5 +17,6 @@ package vendor.eureka.hardware.fmradio@1.1;
|
||||||
import @1.0::IFMRadio;
|
import @1.0::IFMRadio;
|
||||||
|
|
||||||
interface IFMRadio extends @1.0::IFMRadio {
|
interface IFMRadio extends @1.0::IFMRadio {
|
||||||
|
getFreqFromSysfs() generates (int32_t freq);
|
||||||
isAvailable() generates (Status status);
|
isAvailable() generates (Status status);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
hidl_interface {
|
||||||
|
name: "vendor.eureka.hardware.fmradio@1.2",
|
||||||
|
root: "vendor.eureka",
|
||||||
|
srcs: [
|
||||||
|
"types.hal",
|
||||||
|
"IFMRadio.hal",
|
||||||
|
],
|
||||||
|
interfaces: [
|
||||||
|
"android.hidl.base@1.0",
|
||||||
|
"vendor.eureka.hardware.fmradio@1.1",
|
||||||
|
"vendor.eureka.hardware.fmradio@1.0",
|
||||||
|
],
|
||||||
|
gen_java: true,
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
// Copyright (C) 2021 Eureka Team
|
||||||
|
//
|
||||||
|
// 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 vendor.eureka.hardware.fmradio@1.2;
|
||||||
|
|
||||||
|
import @1.1::IFMRadio;
|
||||||
|
|
||||||
|
interface IFMRadio extends @1.1::IFMRadio {
|
||||||
|
setChannelSpacing(Space space);
|
||||||
|
getChannelSpacing() generates (Space space);
|
||||||
|
};
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// FIXME: your file license if you have one
|
// FIXME: your file license if you have one
|
||||||
|
|
||||||
cc_binary {
|
cc_binary {
|
||||||
name: "vendor.eureka.hardware.fmradio@1.1-service",
|
name: "vendor.eureka.hardware.fmradio@1.2-service",
|
||||||
relative_install_path: "hw",
|
relative_install_path: "hw",
|
||||||
proprietary: true,
|
proprietary: true,
|
||||||
srcs: [
|
srcs: [
|
||||||
|
|
@ -14,7 +14,8 @@ cc_binary {
|
||||||
"liblog",
|
"liblog",
|
||||||
"vendor.eureka.hardware.fmradio@1.0",
|
"vendor.eureka.hardware.fmradio@1.0",
|
||||||
"vendor.eureka.hardware.fmradio@1.1",
|
"vendor.eureka.hardware.fmradio@1.1",
|
||||||
|
"vendor.eureka.hardware.fmradio@1.2",
|
||||||
],
|
],
|
||||||
init_rc: [ "vendor.eureka.hardware.fmradio@1.1-service.rc" ],
|
init_rc: [ "vendor.eureka.hardware.fmradio@1.2-service.rc" ],
|
||||||
vintf_fragments: [ "vendor.eureka.hardware.fmradio@1.1.xml" ],
|
vintf_fragments: [ "vendor.eureka.hardware.fmradio@1.2.xml" ],
|
||||||
}
|
}
|
||||||
|
|
@ -19,9 +19,11 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
namespace vendor::eureka::hardware::fmradio::V1_1 {
|
static int mChannelSpacing = 3;
|
||||||
|
|
||||||
Return<void> IFMRadio::setManualFreq(float freq) {
|
namespace vendor::eureka::hardware::fmradio::V1_2 {
|
||||||
|
|
||||||
|
Return<void> FMRadio::setManualFreq(float freq) {
|
||||||
std::ofstream file;
|
std::ofstream file;
|
||||||
file.open("/sys/devices/virtual/s610_radio/s610_radio/radio_freq_ctrl");
|
file.open("/sys/devices/virtual/s610_radio/s610_radio/radio_freq_ctrl");
|
||||||
file << freq * 1000;
|
file << freq * 1000;
|
||||||
|
|
@ -29,13 +31,13 @@ Return<void> IFMRadio::setManualFreq(float freq) {
|
||||||
return Void();
|
return Void();
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<void> IFMRadio::adjustFreqByStep(fmradio::V1_0::Direction dir) {
|
Return<void> FMRadio::adjustFreqByStep(fmradio::V1_0::Direction dir) {
|
||||||
std::ofstream file;
|
std::ofstream file;
|
||||||
std::string value = "";
|
std::string value = "";
|
||||||
if (dir == Direction::UP){
|
if (dir == V1_0::Direction::UP){
|
||||||
value = "1 50";
|
value = "1 " + std::to_string(mChannelSpacing * 10);
|
||||||
} else if (dir == Direction::DOWN){
|
} else if (dir == V1_0::Direction::DOWN){
|
||||||
value = "0 50";
|
value = "0 " + std::to_string(mChannelSpacing * 10);
|
||||||
}
|
}
|
||||||
file.open("/sys/devices/virtual/s610_radio/s610_radio/radio_freq_seek");
|
file.open("/sys/devices/virtual/s610_radio/s610_radio/radio_freq_seek");
|
||||||
file << value;
|
file << value;
|
||||||
|
|
@ -45,12 +47,34 @@ Return<void> IFMRadio::adjustFreqByStep(fmradio::V1_0::Direction dir) {
|
||||||
Return<int32_t> IFMRadio::isAvailable(){
|
Return<int32_t> IFMRadio::isAvailable(){
|
||||||
struct stat info;
|
struct stat info;
|
||||||
if(stat("/sys/devices/virtual/s610_radio/s610_radio/", &info ) != 0) {
|
if(stat("/sys/devices/virtual/s610_radio/s610_radio/", &info ) != 0) {
|
||||||
return Status::NO;
|
return V1_1::Status::NO;
|
||||||
else
|
} else {
|
||||||
return Status::YES;
|
return V1_1::Status::YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IFMRadio* IFMRadio::getInstance(void) {
|
Return<void> FMRadio::setChannelSpacing(V1_2::Space space){
|
||||||
|
mChannelSpacing = (int) space;
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
Return<int32_t> FMRadio::getFreqFromSysfs(){
|
||||||
|
std::ifstream file;
|
||||||
|
std::string value;
|
||||||
|
file.open("/sys/devices/virtual/s610_radio/s610_radio/radio_freq_ctrl");
|
||||||
|
std::getline(file, value);
|
||||||
|
file.close();
|
||||||
|
return std::stoi(value);
|
||||||
|
}
|
||||||
|
Return<V1_2::Space> FMRadio::getChannelSpacing(){
|
||||||
|
switch (mChannelSpacing) {
|
||||||
|
case 1: return V1_2::Space::CHANNEL_SPACING_10HZ;
|
||||||
|
case 2: return V1_2::Space::CHANNEL_SPACING_20HZ;
|
||||||
|
case 3: return V1_2::Space::CHANNEL_SPACING_30HZ;
|
||||||
|
case 4: return V1_2::Space::CHANNEL_SPACING_40HZ;
|
||||||
|
case 5: return V1_2::Space::CHANNEL_SPACING_50HZ;
|
||||||
|
default: return V1_2::Space::CHANNEL_SPACING_30HZ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IFMRadio* FMRadio::getInstance(void) {
|
||||||
return new FMRadio();
|
return new FMRadio();
|
||||||
}
|
}
|
||||||
} // namespace vendor::eureka::hardware::fmradio::V1_0
|
} // namespace vendor::eureka::hardware::fmradio::V1_0
|
||||||
|
|
@ -16,9 +16,9 @@
|
||||||
|
|
||||||
#include <hidl/MQDescriptor.h>
|
#include <hidl/MQDescriptor.h>
|
||||||
#include <hidl/Status.h>
|
#include <hidl/Status.h>
|
||||||
#include <vendor/eureka/hardware/fmradio/1.1/IFMRadio.h>
|
#include <vendor/eureka/hardware/fmradio/1.2/IFMRadio.h>
|
||||||
|
|
||||||
namespace vendor::eureka::hardware::fmradio::V1_1 {
|
namespace vendor::eureka::hardware::fmradio::V1_2 {
|
||||||
|
|
||||||
using ::android::sp;
|
using ::android::sp;
|
||||||
using ::android::hardware::hidl_array;
|
using ::android::hardware::hidl_array;
|
||||||
|
|
@ -31,9 +31,13 @@ using ::android::hardware::Void;
|
||||||
struct FMRadio : public IFMRadio {
|
struct FMRadio : public IFMRadio {
|
||||||
// Methods from ::vendor::eureka::hardware::fmradio::V1_0::IFMRadio follow.
|
// Methods from ::vendor::eureka::hardware::fmradio::V1_0::IFMRadio follow.
|
||||||
Return<void> setManualFreq(float freq);
|
Return<void> setManualFreq(float freq);
|
||||||
Return<void> adjustFreqByStep(Direction dir);
|
Return<void> adjustFreqByStep(V1_0::Direction dir);
|
||||||
// Methods from ::vendor::eureka::hardware::fmradio::V1_1::IFMRadio follow.
|
// Methods from ::vendor::eureka::hardware::fmradio::V1_1::IFMRadio follow.
|
||||||
Return<int32_t> isAvailable();
|
Return<V1_1::Status> isAvailable();
|
||||||
|
Return<int32_t> getFreqFromSysfs();
|
||||||
|
// Methods from ::vendor::eureka::hardware::fmradio::V1_2::IFMRadio follow.
|
||||||
|
Return<void> setChannelSpacing(V1_2::Space space);
|
||||||
|
Return<V1_2::Space> getChannelSpacing();
|
||||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||||
static IFMRadio* getInstance(void);
|
static IFMRadio* getInstance(void);
|
||||||
};
|
};
|
||||||
|
|
@ -12,9 +12,9 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#define LOG_TAG "vendor.eureka.hardware.fmradio@1.0-service"
|
#define LOG_TAG "vendor.eureka.hardware.fmradio@1.2-service"
|
||||||
|
|
||||||
#include <vendor/eureka/hardware/fmradio/1.1/IFMRadio.h>
|
#include <vendor/eureka/hardware/fmradio/1.2/IFMRadio.h>
|
||||||
|
|
||||||
#include <hidl/LegacySupport.h>
|
#include <hidl/LegacySupport.h>
|
||||||
|
|
||||||
|
|
@ -23,8 +23,8 @@
|
||||||
using android::sp;
|
using android::sp;
|
||||||
using android::hardware::configureRpcThreadpool;
|
using android::hardware::configureRpcThreadpool;
|
||||||
using android::hardware::joinRpcThreadpool;
|
using android::hardware::joinRpcThreadpool;
|
||||||
using vendor::eureka::hardware::fmradio::V1_1::FMRadio;
|
using vendor::eureka::hardware::fmradio::V1_2::FMRadio;
|
||||||
using vendor::eureka::hardware::fmradio::V1_1::IFMRadio;
|
using vendor::eureka::hardware::fmradio::V1_2::IFMRadio;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
service vendor.parts-hal /vendor/bin/hw/vendor.eureka.hardware.fmradio@1.1-service
|
service vendor.parts-hal /vendor/bin/hw/vendor.eureka.hardware.fmradio@1.2-service
|
||||||
interface vendor.eureka.hardware.fmradio@1.0::IFMRadio default
|
interface vendor.eureka.hardware.fmradio@1.0::IFMRadio default
|
||||||
interface vendor.eureka.hardware.fmradio@1.1::IFMRadio default
|
interface vendor.eureka.hardware.fmradio@1.1::IFMRadio default
|
||||||
|
interface vendor.eureka.hardware.fmradio@1.2::IFMRadio default
|
||||||
class hal
|
class hal
|
||||||
user root
|
user root
|
||||||
group root
|
group root
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<hal format="hidl">
|
<hal format="hidl">
|
||||||
<name>vendor.eureka.hardware.fmradio</name>
|
<name>vendor.eureka.hardware.fmradio</name>
|
||||||
<transport>hwbinder</transport>
|
<transport>hwbinder</transport>
|
||||||
<version>1.1</version>
|
<version>1.2</version>
|
||||||
<interface>
|
<interface>
|
||||||
<name>IFMRadio</name>
|
<name>IFMRadio</name>
|
||||||
<instance>default</instance>
|
<instance>default</instance>
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
// Copyright (C) 2021 Eureka Team
|
||||||
|
//
|
||||||
|
// 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 vendor.eureka.hardware.fmradio@1.2;
|
||||||
|
|
||||||
|
enum Space : int32_t {
|
||||||
|
CHANNEL_SPACING_10HZ = 1,
|
||||||
|
CHANNEL_SPACING_20HZ,
|
||||||
|
CHANNEL_SPACING_30HZ,
|
||||||
|
CHANNEL_SPACING_40HZ,
|
||||||
|
CHANNEL_SPACING_50HZ = 5,
|
||||||
|
};
|
||||||
|
|
@ -11,6 +11,7 @@ git clone https://github.com/lineageos/android_hardware_samsung_nfc hardware/sam
|
||||||
git clone https://github.com/lineageos/android_hardware_samsung_slsi_libbt hardware/samsung_slsi/libbt
|
git clone https://github.com/lineageos/android_hardware_samsung_slsi_libbt hardware/samsung_slsi/libbt
|
||||||
git clone https://github.com/eurekadevelopment/android_hardware_samsung_slsi_scsc_wifibt_wifi_hal.git hardware/samsung_slsi/scsc_wifibt/wifi_hal
|
git clone https://github.com/eurekadevelopment/android_hardware_samsung_slsi_scsc_wifibt_wifi_hal.git hardware/samsung_slsi/scsc_wifibt/wifi_hal
|
||||||
git clone https://github.com/lineageos/android_hardware_samsung_slsi_scsc_wifibt_wpa_supplicant_lib hardware/samsung_slsi/scsc_wifibt/wpa_supplicant_lib
|
git clone https://github.com/lineageos/android_hardware_samsung_slsi_scsc_wifibt_wpa_supplicant_lib hardware/samsung_slsi/scsc_wifibt/wpa_supplicant_lib
|
||||||
|
git clone https://github.com/eurekadevelopment/OneUI-Design-Library external/OneUI --depth=1
|
||||||
# Vendors
|
# Vendors
|
||||||
git clone --depth=1 https://github.com/eurekadevelopment/android_vendor_samsung_exynos7885.git -b master vendor/samsung
|
git clone --depth=1 https://github.com/eurekadevelopment/android_vendor_samsung_exynos7885.git -b master vendor/samsung
|
||||||
if test -f device/samsung/universal7885-common/vendor_name; then
|
if test -f device/samsung/universal7885-common/vendor_name; then
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue