mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-23 04:25:33 -04:00
universal7885: interfaces: use seteuid() to set fastcharge sysfs value
* SELinux denials
type=1400 audit(0.0:731): avc: denied { dac_override } for capability=1 scontext=u:r:hal_battery_default:s0 tcontext=u:r:hal_battery_default:s0 tclass=capability permissive=0
Change-Id: I500682520503e14594eb8661a97ebc0d199c77ff
Signed-off-by: roynatech2544 <whiteshell2544@naver.com>
This commit is contained in:
parent
e4569f7c82
commit
4549ce06a0
2 changed files with 9 additions and 0 deletions
|
|
@ -16,6 +16,8 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
namespace vendor::eureka::hardware::battery::V1_0 {
|
namespace vendor::eureka::hardware::battery::V1_0 {
|
||||||
|
|
||||||
// Methods from ::android::hardware::battery::V1_0::IBattery follow.
|
// Methods from ::android::hardware::battery::V1_0::IBattery follow.
|
||||||
|
|
@ -61,6 +63,7 @@ Return<int32_t> Battery::getBatteryStats(battery::V1_0::SysfsType stats) {
|
||||||
Return<int32_t> Battery::setBatteryWritable(battery::V1_0::SysfsType stats, battery::V1_0::Number value) {
|
Return<int32_t> Battery::setBatteryWritable(battery::V1_0::SysfsType stats, battery::V1_0::Number value) {
|
||||||
std::ofstream file;
|
std::ofstream file;
|
||||||
std::string filename;
|
std::string filename;
|
||||||
|
bool FastCharge = false;
|
||||||
switch (stats){
|
switch (stats){
|
||||||
case SysfsType::CAPACITY_MAX:
|
case SysfsType::CAPACITY_MAX:
|
||||||
filename = "/sys/devices/platform/battery/power_supply/battery/charge_full";
|
filename = "/sys/devices/platform/battery/power_supply/battery/charge_full";
|
||||||
|
|
@ -76,6 +79,7 @@ Return<int32_t> Battery::setBatteryWritable(battery::V1_0::SysfsType stats, batt
|
||||||
break;
|
break;
|
||||||
case SysfsType::FASTCHARGE:
|
case SysfsType::FASTCHARGE:
|
||||||
filename = "/sys/class/sec/switch/afc_disable";
|
filename = "/sys/class/sec/switch/afc_disable";
|
||||||
|
FastCharge = true;
|
||||||
break;
|
break;
|
||||||
case SysfsType::CHARGE:
|
case SysfsType::CHARGE:
|
||||||
filename = "/sys/devices/platform/battery/power_supply/battery/batt_slate_mode";
|
filename = "/sys/devices/platform/battery/power_supply/battery/batt_slate_mode";
|
||||||
|
|
@ -84,6 +88,7 @@ Return<int32_t> Battery::setBatteryWritable(battery::V1_0::SysfsType stats, batt
|
||||||
filename = "";
|
filename = "";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(FastCharge) seteuid(ANDROID_SYSTEM_UID);
|
||||||
file.open(filename);
|
file.open(filename);
|
||||||
int write;
|
int write;
|
||||||
if (value == Number::ENABLE){
|
if (value == Number::ENABLE){
|
||||||
|
|
@ -93,6 +98,7 @@ Return<int32_t> Battery::setBatteryWritable(battery::V1_0::SysfsType stats, batt
|
||||||
}
|
}
|
||||||
file << write;
|
file << write;
|
||||||
file.close();
|
file.close();
|
||||||
|
if(FastCharge) seteuid(ANDROID_ROOT_UID);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,9 @@
|
||||||
#include <hidl/MQDescriptor.h>
|
#include <hidl/MQDescriptor.h>
|
||||||
#include <hidl/Status.h>
|
#include <hidl/Status.h>
|
||||||
|
|
||||||
|
#define ANDROID_SYSTEM_UID 1000
|
||||||
|
#define ANDROID_ROOT_UID 0
|
||||||
|
|
||||||
namespace vendor::eureka::hardware::battery::V1_0 {
|
namespace vendor::eureka::hardware::battery::V1_0 {
|
||||||
|
|
||||||
using ::android::hardware::hidl_array;
|
using ::android::hardware::hidl_array;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue