mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-22 20:15:32 -04:00
universal7885: format code using clang-format-15
This commit is contained in:
parent
bfcbd0d355
commit
cb072badd5
55 changed files with 3946 additions and 3783 deletions
|
|
@ -16,65 +16,69 @@
|
|||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
static int mChannelSpacing = 3;
|
||||
|
||||
namespace vendor::eureka::hardware::fmradio::V1_2 {
|
||||
|
||||
Return<void> FMRadio::setManualFreq(float freq) {
|
||||
std::ofstream file;
|
||||
file.open("/sys/devices/virtual/s610_radio/s610_radio/radio_freq_ctrl");
|
||||
file << freq * 1000;
|
||||
file.close();
|
||||
return Void();
|
||||
std::ofstream file;
|
||||
file.open("/sys/devices/virtual/s610_radio/s610_radio/radio_freq_ctrl");
|
||||
file << freq * 1000;
|
||||
file.close();
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> FMRadio::adjustFreqByStep(fmradio::V1_0::Direction dir) {
|
||||
std::ofstream file;
|
||||
std::string value = "";
|
||||
if (dir == V1_0::Direction::UP){
|
||||
value = "1 " + std::to_string(mChannelSpacing * 10);
|
||||
} else if (dir == V1_0::Direction::DOWN){
|
||||
value = "0 " + std::to_string(mChannelSpacing * 10);
|
||||
}
|
||||
file.open("/sys/devices/virtual/s610_radio/s610_radio/radio_freq_seek");
|
||||
file << value;
|
||||
file.close();
|
||||
return Void();
|
||||
std::ofstream file;
|
||||
std::string value = "";
|
||||
if (dir == V1_0::Direction::UP) {
|
||||
value = "1 " + std::to_string(mChannelSpacing * 10);
|
||||
} else if (dir == V1_0::Direction::DOWN) {
|
||||
value = "0 " + std::to_string(mChannelSpacing * 10);
|
||||
}
|
||||
file.open("/sys/devices/virtual/s610_radio/s610_radio/radio_freq_seek");
|
||||
file << value;
|
||||
file.close();
|
||||
return Void();
|
||||
}
|
||||
Return<V1_1::Status> FMRadio::isAvailable(){
|
||||
struct stat info;
|
||||
if(stat("/sys/devices/virtual/s610_radio/s610_radio/", &info ) != 0) {
|
||||
return V1_1::Status::NO;
|
||||
} else {
|
||||
return V1_1::Status::YES;
|
||||
}
|
||||
Return<V1_1::Status> FMRadio::isAvailable() {
|
||||
struct stat info;
|
||||
if (stat("/sys/devices/virtual/s610_radio/s610_radio/", &info) != 0) {
|
||||
return V1_1::Status::NO;
|
||||
} else {
|
||||
return V1_1::Status::YES;
|
||||
}
|
||||
}
|
||||
Return<void> FMRadio::setChannelSpacing(V1_2::Space space){
|
||||
mChannelSpacing = (int) space;
|
||||
return 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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
IFMRadio* FMRadio::getInstance(void) {
|
||||
return new FMRadio();
|
||||
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;
|
||||
}
|
||||
}
|
||||
} // namespace vendor::eureka::hardware::fmradio::V1_0
|
||||
IFMRadio *FMRadio::getInstance(void) { return new FMRadio(); }
|
||||
} // namespace vendor::eureka::hardware::fmradio::V1_2
|
||||
|
|
|
|||
|
|
@ -29,16 +29,16 @@ using ::android::hardware::Return;
|
|||
using ::android::hardware::Void;
|
||||
|
||||
struct FMRadio : public IFMRadio {
|
||||
// Methods from ::vendor::eureka::hardware::fmradio::V1_0::IFMRadio follow.
|
||||
Return<void> setManualFreq(float freq);
|
||||
Return<void> adjustFreqByStep(V1_0::Direction dir);
|
||||
// Methods from ::vendor::eureka::hardware::fmradio::V1_1::IFMRadio follow.
|
||||
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.
|
||||
static IFMRadio* getInstance(void);
|
||||
// Methods from ::vendor::eureka::hardware::fmradio::V1_0::IFMRadio follow.
|
||||
Return<void> setManualFreq(float freq);
|
||||
Return<void> adjustFreqByStep(V1_0::Direction dir);
|
||||
// Methods from ::vendor::eureka::hardware::fmradio::V1_1::IFMRadio follow.
|
||||
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.
|
||||
static IFMRadio *getInstance(void);
|
||||
};
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
} // namespace vendor::eureka::hardware::fmradio::V1_2
|
||||
|
|
|
|||
|
|
@ -27,21 +27,21 @@ using vendor::eureka::hardware::fmradio::V1_2::FMRadio;
|
|||
using vendor::eureka::hardware::fmradio::V1_2::IFMRadio;
|
||||
|
||||
int main() {
|
||||
int ret;
|
||||
android::sp<IFMRadio> mFMService = FMRadio::getInstance();
|
||||
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||||
int ret;
|
||||
android::sp<IFMRadio> mFMService = FMRadio::getInstance();
|
||||
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||||
|
||||
if (mFMService != nullptr) {
|
||||
ret = mFMService->registerAsService();
|
||||
if (ret != 0) {
|
||||
ALOGE("Can't register instance of FMRadio HAL, nullptr");
|
||||
} else {
|
||||
ALOGI("registered FMRadio HAL");
|
||||
}
|
||||
if (mFMService != nullptr) {
|
||||
ret = mFMService->registerAsService();
|
||||
if (ret != 0) {
|
||||
ALOGE("Can't register instance of FMRadio HAL, nullptr");
|
||||
} else {
|
||||
ALOGE("Can't create instance of FMRadio HAL, nullptr");
|
||||
ALOGI("registered FMRadio HAL");
|
||||
}
|
||||
joinRpcThreadpool();
|
||||
} else {
|
||||
ALOGE("Can't create instance of FMRadio HAL, nullptr");
|
||||
}
|
||||
joinRpcThreadpool();
|
||||
|
||||
return -1; // should never get here
|
||||
return -1; // should never get here
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,97 +13,99 @@
|
|||
// limitations under the License.
|
||||
|
||||
#include "Battery.h"
|
||||
#include <unistd.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace vendor::eureka::hardware::parts::V1_0 {
|
||||
|
||||
// Methods from ::android::hardware::battery::V1_0::IBattery follow.
|
||||
Return<int32_t> BatteryStats::getBatteryStats(parts::V1_0::SysfsType stats) {
|
||||
std::ifstream file;
|
||||
std::string filename;
|
||||
switch (stats) {
|
||||
case SysfsType::CAPACITY_MAX:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/charge_full";
|
||||
break;
|
||||
case SysfsType::TEMP:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/batt_temp";
|
||||
break;
|
||||
case SysfsType::CAPACITY_CURRENT:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/capacity";
|
||||
break;
|
||||
case SysfsType::CURRENT:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/current_now";
|
||||
break;
|
||||
case SysfsType::FASTCHARGE:
|
||||
filename = "/sys/class/sec/switch/afc_disable";
|
||||
break;
|
||||
case SysfsType::CHARGE:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/batt_slate_mode";
|
||||
break;
|
||||
default:
|
||||
filename = "";
|
||||
break;
|
||||
}
|
||||
std::string value;
|
||||
int32_t intvalue;
|
||||
file.open(filename);
|
||||
if (file.is_open()) {
|
||||
getline(file, value);
|
||||
file.close();
|
||||
std::stringstream val(value);
|
||||
val >> intvalue;
|
||||
return intvalue;
|
||||
}
|
||||
return -1;
|
||||
std::ifstream file;
|
||||
std::string filename;
|
||||
switch (stats) {
|
||||
case SysfsType::CAPACITY_MAX:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/charge_full";
|
||||
break;
|
||||
case SysfsType::TEMP:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/batt_temp";
|
||||
break;
|
||||
case SysfsType::CAPACITY_CURRENT:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/capacity";
|
||||
break;
|
||||
case SysfsType::CURRENT:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/current_now";
|
||||
break;
|
||||
case SysfsType::FASTCHARGE:
|
||||
filename = "/sys/class/sec/switch/afc_disable";
|
||||
break;
|
||||
case SysfsType::CHARGE:
|
||||
filename =
|
||||
"/sys/devices/platform/battery/power_supply/battery/batt_slate_mode";
|
||||
break;
|
||||
default:
|
||||
filename = "";
|
||||
break;
|
||||
}
|
||||
std::string value;
|
||||
int32_t intvalue;
|
||||
file.open(filename);
|
||||
if (file.is_open()) {
|
||||
getline(file, value);
|
||||
file.close();
|
||||
std::stringstream val(value);
|
||||
val >> intvalue;
|
||||
return intvalue;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
Return<void> BatteryStats::setBatteryWritable(parts::V1_0::SysfsType stats,
|
||||
parts::V1_0::Number value) {
|
||||
std::ofstream file;
|
||||
std::string filename;
|
||||
bool FastCharge = false;
|
||||
switch (stats) {
|
||||
case SysfsType::CAPACITY_MAX:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/charge_full";
|
||||
break;
|
||||
case SysfsType::TEMP:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/batt_temp";
|
||||
break;
|
||||
case SysfsType::CAPACITY_CURRENT:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/capacity";
|
||||
break;
|
||||
case SysfsType::CURRENT:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/current_now";
|
||||
break;
|
||||
case SysfsType::FASTCHARGE:
|
||||
filename = "/sys/class/sec/switch/afc_disable";
|
||||
FastCharge = true;
|
||||
break;
|
||||
case SysfsType::CHARGE:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/batt_slate_mode";
|
||||
break;
|
||||
default:
|
||||
filename = "";
|
||||
break;
|
||||
}
|
||||
if (FastCharge) seteuid(ANDROID_SYSTEM_UID);
|
||||
file.open(filename);
|
||||
int write;
|
||||
if (value == Number::ENABLE) {
|
||||
write = 1;
|
||||
} else {
|
||||
write = 0;
|
||||
}
|
||||
file << write;
|
||||
file.close();
|
||||
if (FastCharge) seteuid(ANDROID_ROOT_UID);
|
||||
return Void();
|
||||
parts::V1_0::Number value) {
|
||||
std::ofstream file;
|
||||
std::string filename;
|
||||
bool FastCharge = false;
|
||||
switch (stats) {
|
||||
case SysfsType::CAPACITY_MAX:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/charge_full";
|
||||
break;
|
||||
case SysfsType::TEMP:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/batt_temp";
|
||||
break;
|
||||
case SysfsType::CAPACITY_CURRENT:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/capacity";
|
||||
break;
|
||||
case SysfsType::CURRENT:
|
||||
filename = "/sys/devices/platform/battery/power_supply/battery/current_now";
|
||||
break;
|
||||
case SysfsType::FASTCHARGE:
|
||||
filename = "/sys/class/sec/switch/afc_disable";
|
||||
FastCharge = true;
|
||||
break;
|
||||
case SysfsType::CHARGE:
|
||||
filename =
|
||||
"/sys/devices/platform/battery/power_supply/battery/batt_slate_mode";
|
||||
break;
|
||||
default:
|
||||
filename = "";
|
||||
break;
|
||||
}
|
||||
if (FastCharge)
|
||||
seteuid(ANDROID_SYSTEM_UID);
|
||||
file.open(filename);
|
||||
int write;
|
||||
if (value == Number::ENABLE) {
|
||||
write = 1;
|
||||
} else {
|
||||
write = 0;
|
||||
}
|
||||
file << write;
|
||||
file.close();
|
||||
if (FastCharge)
|
||||
seteuid(ANDROID_ROOT_UID);
|
||||
return Void();
|
||||
}
|
||||
|
||||
IBatteryStats* BatteryStats::getInstance(void) {
|
||||
return new BatteryStats();
|
||||
}
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
IBatteryStats *BatteryStats::getInstance(void) { return new BatteryStats(); }
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@ using ::android::hardware::Return;
|
|||
using ::android::hardware::Void;
|
||||
|
||||
struct BatteryStats : public IBatteryStats {
|
||||
// Methods from ::vendor::eureka::hardware::parts::V1_0::IBatteryStats follow.
|
||||
Return<int32_t> getBatteryStats(SysfsType stats) override;
|
||||
Return<void> setBatteryWritable(SysfsType stats, Number value) override;
|
||||
// Methods from ::vendor::eureka::hardware::parts::V1_0::IBatteryStats follow.
|
||||
Return<int32_t> getBatteryStats(SysfsType stats) override;
|
||||
Return<void> setBatteryWritable(SysfsType stats, Number value) override;
|
||||
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
static IBatteryStats* getInstance(void);
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
static IBatteryStats *getInstance(void);
|
||||
};
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
|
|
|
|||
|
|
@ -18,27 +18,28 @@
|
|||
#include <sstream>
|
||||
namespace vendor::eureka::hardware::parts::V1_0 {
|
||||
|
||||
Return<void> DisplayConfigs::writeDisplay(parts::V1_0::Number enable, parts::V1_0::Display type) {
|
||||
std::ofstream file;
|
||||
std::string writevalue;
|
||||
if (type == Display::DOUBLE_TAP){
|
||||
writevalue = "aot_enable";
|
||||
} else if (type == Display::GLOVE_MODE){
|
||||
writevalue = "glove_mode";
|
||||
}
|
||||
Return<void> DisplayConfigs::writeDisplay(parts::V1_0::Number enable,
|
||||
parts::V1_0::Display type) {
|
||||
std::ofstream file;
|
||||
std::string writevalue;
|
||||
if (type == Display::DOUBLE_TAP) {
|
||||
writevalue = "aot_enable";
|
||||
} else if (type == Display::GLOVE_MODE) {
|
||||
writevalue = "glove_mode";
|
||||
}
|
||||
|
||||
if (enable == Number::ENABLE) {
|
||||
writevalue += ",1";
|
||||
} else {
|
||||
writevalue += ",0";
|
||||
}
|
||||
file.open("/sys/class/sec/tsp/cmd");
|
||||
file << writevalue;
|
||||
file.close();
|
||||
return Void();
|
||||
if (enable == Number::ENABLE) {
|
||||
writevalue += ",1";
|
||||
} else {
|
||||
writevalue += ",0";
|
||||
}
|
||||
file.open("/sys/class/sec/tsp/cmd");
|
||||
file << writevalue;
|
||||
file.close();
|
||||
return Void();
|
||||
}
|
||||
|
||||
IDisplayConfigs* DisplayConfigs::getInstance(void) {
|
||||
return new DisplayConfigs();
|
||||
IDisplayConfigs *DisplayConfigs::getInstance(void) {
|
||||
return new DisplayConfigs();
|
||||
}
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
|
|
|
|||
|
|
@ -29,9 +29,10 @@ using ::android::hardware::Return;
|
|||
using ::android::hardware::Void;
|
||||
|
||||
struct DisplayConfigs : public IDisplayConfigs {
|
||||
// Methods from ::vendor::eureka::hardware::parts::V1_0::IDisplayConfigs follow.
|
||||
Return<void> writeDisplay(Number enable, Display type);
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
static IDisplayConfigs* getInstance(void);
|
||||
// Methods from ::vendor::eureka::hardware::parts::V1_0::IDisplayConfigs
|
||||
// follow.
|
||||
Return<void> writeDisplay(Number enable, Display type);
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
static IDisplayConfigs *getInstance(void);
|
||||
};
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
|
|
|
|||
|
|
@ -20,91 +20,92 @@ namespace vendor::eureka::hardware::parts::V1_0 {
|
|||
|
||||
// Methods from ::android::hardware::parts::V1_0::IFlashLight follow.
|
||||
Return<void> FlashBrightness::setFlashlightEnable(parts::V1_0::Number enable) {
|
||||
std::ofstream file;
|
||||
std::string writevalue;
|
||||
switch (enable) {
|
||||
case Number::ENABLE:
|
||||
writevalue = "1";
|
||||
break;
|
||||
case Number::DISABLE:
|
||||
writevalue = "0";
|
||||
break;
|
||||
default:
|
||||
writevalue = "";
|
||||
break;
|
||||
}
|
||||
file.open("/sys/class/camera/flash/torch_brightness_lvl_enable");
|
||||
file << writevalue;
|
||||
file.close();
|
||||
return Void();
|
||||
std::ofstream file;
|
||||
std::string writevalue;
|
||||
switch (enable) {
|
||||
case Number::ENABLE:
|
||||
writevalue = "1";
|
||||
break;
|
||||
case Number::DISABLE:
|
||||
writevalue = "0";
|
||||
break;
|
||||
default:
|
||||
writevalue = "";
|
||||
break;
|
||||
}
|
||||
file.open("/sys/class/camera/flash/torch_brightness_lvl_enable");
|
||||
file << writevalue;
|
||||
file.close();
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> FlashBrightness::setFlashlightWritable(parts::V1_0::Value value) {
|
||||
std::ofstream file;
|
||||
std::string writevalue;
|
||||
switch (value) {
|
||||
case Value::ONEUI:
|
||||
writevalue = "1";
|
||||
break;
|
||||
case Value::TWOUI:
|
||||
writevalue = "2";
|
||||
break;
|
||||
case Value::THREEUI:
|
||||
writevalue = "3";
|
||||
break;
|
||||
case Value::FOURUI:
|
||||
writevalue = "4";
|
||||
break;
|
||||
case Value::FIVEUI:
|
||||
writevalue = "5";
|
||||
break;
|
||||
case Value::SIXUI:
|
||||
writevalue = "6";
|
||||
break;
|
||||
case Value::SEVENUI:
|
||||
writevalue = "7";
|
||||
break;
|
||||
case Value::EIGHTUI:
|
||||
writevalue = "8";
|
||||
break;
|
||||
case Value::NINEUI:
|
||||
writevalue = "9";
|
||||
break;
|
||||
case Value::TENUI:
|
||||
writevalue = "10";
|
||||
break;
|
||||
default:
|
||||
writevalue = "";
|
||||
break;
|
||||
}
|
||||
file.open("/sys/class/camera/flash/torch_brightness_lvl");
|
||||
file << writevalue;
|
||||
std::ofstream file;
|
||||
std::string writevalue;
|
||||
switch (value) {
|
||||
case Value::ONEUI:
|
||||
writevalue = "1";
|
||||
break;
|
||||
case Value::TWOUI:
|
||||
writevalue = "2";
|
||||
break;
|
||||
case Value::THREEUI:
|
||||
writevalue = "3";
|
||||
break;
|
||||
case Value::FOURUI:
|
||||
writevalue = "4";
|
||||
break;
|
||||
case Value::FIVEUI:
|
||||
writevalue = "5";
|
||||
break;
|
||||
case Value::SIXUI:
|
||||
writevalue = "6";
|
||||
break;
|
||||
case Value::SEVENUI:
|
||||
writevalue = "7";
|
||||
break;
|
||||
case Value::EIGHTUI:
|
||||
writevalue = "8";
|
||||
break;
|
||||
case Value::NINEUI:
|
||||
writevalue = "9";
|
||||
break;
|
||||
case Value::TENUI:
|
||||
writevalue = "10";
|
||||
break;
|
||||
default:
|
||||
writevalue = "";
|
||||
break;
|
||||
}
|
||||
file.open("/sys/class/camera/flash/torch_brightness_lvl");
|
||||
file << writevalue;
|
||||
file.close();
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<int32_t>
|
||||
FlashBrightness::readFlashlightstats(parts::V1_0::Device device) {
|
||||
std::ifstream file;
|
||||
std::string value;
|
||||
int32_t intvalue;
|
||||
file.open("/sys/class/camera/flash/torch_brightness_lvl");
|
||||
if (file.is_open()) {
|
||||
getline(file, value);
|
||||
file.close();
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<int32_t> FlashBrightness::readFlashlightstats(parts::V1_0::Device device) {
|
||||
std::ifstream file;
|
||||
std::string value;
|
||||
int32_t intvalue;
|
||||
file.open("/sys/class/camera/flash/torch_brightness_lvl");
|
||||
if (file.is_open()) {
|
||||
getline(file, value);
|
||||
file.close();
|
||||
std::stringstream val(value);
|
||||
val >> intvalue;
|
||||
if (device == Device::A10) {
|
||||
return intvalue;
|
||||
} else if (device == Device::NOTA10) {
|
||||
return intvalue / 21;
|
||||
}
|
||||
// Never Here
|
||||
return -1;
|
||||
std::stringstream val(value);
|
||||
val >> intvalue;
|
||||
if (device == Device::A10) {
|
||||
return intvalue;
|
||||
} else if (device == Device::NOTA10) {
|
||||
return intvalue / 21;
|
||||
}
|
||||
// Never Here
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
IFlashBrightness* FlashBrightness::getInstance(void) {
|
||||
return new FlashBrightness();
|
||||
IFlashBrightness *FlashBrightness::getInstance(void) {
|
||||
return new FlashBrightness();
|
||||
}
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
|
|
|
|||
|
|
@ -29,11 +29,12 @@ using ::android::hardware::Return;
|
|||
using ::android::hardware::Void;
|
||||
|
||||
struct FlashBrightness : public IFlashBrightness {
|
||||
// Methods from ::vendor::eureka::hardware::parts::V1_0::IFlashBrightness follow.
|
||||
Return<void> setFlashlightEnable(Number enable);
|
||||
Return<void> setFlashlightWritable(Value value);
|
||||
Return<int32_t> readFlashlightstats(Device device);
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
static IFlashBrightness* getInstance(void);
|
||||
// Methods from ::vendor::eureka::hardware::parts::V1_0::IFlashBrightness
|
||||
// follow.
|
||||
Return<void> setFlashlightEnable(Number enable);
|
||||
Return<void> setFlashlightWritable(Value value);
|
||||
Return<int32_t> readFlashlightstats(Device device);
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
static IFlashBrightness *getInstance(void);
|
||||
};
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
|
|
|
|||
|
|
@ -14,63 +14,64 @@
|
|||
|
||||
#define LOG_TAG "vendor.eureka.hardware.parts@1.0-service"
|
||||
|
||||
#include <vendor/eureka/hardware/parts/1.0/IBatteryStats.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IFlashBrightness.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IDisplayConfigs.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IBatteryStats.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IDisplayConfigs.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IFlashBrightness.h>
|
||||
|
||||
#include "Battery.h"
|
||||
#include "FlashLight.h"
|
||||
#include "Display.h"
|
||||
#include "FlashLight.h"
|
||||
|
||||
using android::sp;
|
||||
using android::hardware::configureRpcThreadpool;
|
||||
using android::hardware::joinRpcThreadpool;
|
||||
using vendor::eureka::hardware::parts::V1_0::BatteryStats;
|
||||
using vendor::eureka::hardware::parts::V1_0::IBatteryStats;
|
||||
using vendor::eureka::hardware::parts::V1_0::FlashBrightness;
|
||||
using vendor::eureka::hardware::parts::V1_0::IFlashBrightness;
|
||||
using vendor::eureka::hardware::parts::V1_0::DisplayConfigs;
|
||||
using vendor::eureka::hardware::parts::V1_0::FlashBrightness;
|
||||
using vendor::eureka::hardware::parts::V1_0::IBatteryStats;
|
||||
using vendor::eureka::hardware::parts::V1_0::IDisplayConfigs;
|
||||
using vendor::eureka::hardware::parts::V1_0::IFlashBrightness;
|
||||
|
||||
int main() {
|
||||
int ret;
|
||||
android::sp<IBatteryStats> mBatteryService = BatteryStats::getInstance();
|
||||
android::sp<IFlashBrightness> mFlashLightService = FlashBrightness::getInstance();
|
||||
android::sp<IDisplayConfigs> mDisplayService = DisplayConfigs::getInstance();
|
||||
configureRpcThreadpool(4, true /*callerWillJoin*/);
|
||||
int ret;
|
||||
android::sp<IBatteryStats> mBatteryService = BatteryStats::getInstance();
|
||||
android::sp<IFlashBrightness> mFlashLightService =
|
||||
FlashBrightness::getInstance();
|
||||
android::sp<IDisplayConfigs> mDisplayService = DisplayConfigs::getInstance();
|
||||
configureRpcThreadpool(4, true /*callerWillJoin*/);
|
||||
|
||||
if (mBatteryService != nullptr) {
|
||||
ret = mBatteryService->registerAsService();
|
||||
if (ret != 0) {
|
||||
ALOGE("Can't register instance of Battery HAL, nullptr");
|
||||
} else {
|
||||
ALOGI("registered Battery HAL");
|
||||
}
|
||||
if (mBatteryService != nullptr) {
|
||||
ret = mBatteryService->registerAsService();
|
||||
if (ret != 0) {
|
||||
ALOGE("Can't register instance of Battery HAL, nullptr");
|
||||
} else {
|
||||
ALOGE("Can't create instance of Battery HAL, nullptr");
|
||||
ALOGI("registered Battery HAL");
|
||||
}
|
||||
if (mFlashLightService != nullptr) {
|
||||
ret = mFlashLightService->registerAsService();
|
||||
if (ret != 0) {
|
||||
ALOGE("Can't register instance of FlashLight HAL, nullptr");
|
||||
} else {
|
||||
ALOGI("registered FlashLight HAL");
|
||||
}
|
||||
} else {
|
||||
ALOGE("Can't create instance of Battery HAL, nullptr");
|
||||
}
|
||||
if (mFlashLightService != nullptr) {
|
||||
ret = mFlashLightService->registerAsService();
|
||||
if (ret != 0) {
|
||||
ALOGE("Can't register instance of FlashLight HAL, nullptr");
|
||||
} else {
|
||||
ALOGE("Can't create instance of FlashLight HAL, nullptr");
|
||||
ALOGI("registered FlashLight HAL");
|
||||
}
|
||||
if (mDisplayService != nullptr) {
|
||||
ret = mDisplayService->registerAsService();
|
||||
if (ret != 0) {
|
||||
ALOGE("Can't register instance of Display HAL, nullptr");
|
||||
} else {
|
||||
ALOGI("registered Display HAL");
|
||||
}
|
||||
} else {
|
||||
ALOGE("Can't create instance of FlashLight HAL, nullptr");
|
||||
}
|
||||
if (mDisplayService != nullptr) {
|
||||
ret = mDisplayService->registerAsService();
|
||||
if (ret != 0) {
|
||||
ALOGE("Can't register instance of Display HAL, nullptr");
|
||||
} else {
|
||||
ALOGE("Can't create instance of Display HAL, nullptr");
|
||||
ALOGI("registered Display HAL");
|
||||
}
|
||||
joinRpcThreadpool();
|
||||
} else {
|
||||
ALOGE("Can't create instance of Display HAL, nullptr");
|
||||
}
|
||||
joinRpcThreadpool();
|
||||
|
||||
return -1; // should never get here
|
||||
return -1; // should never get here
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue