mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-24 04:45:32 -04:00
universal7885: parts: jni: Link against libc++ fs
Also fix Kotlin src issues Also clang-format the cpp src
This commit is contained in:
parent
0a612ac913
commit
0faf51929d
10 changed files with 57 additions and 55 deletions
|
|
@ -12,6 +12,7 @@ cc_library_shared {
|
||||||
"libhidlbase",
|
"libhidlbase",
|
||||||
"liblog",
|
"liblog",
|
||||||
"libutils",
|
"libutils",
|
||||||
|
"libc++fs",
|
||||||
"vendor.eureka.hardware.parts@1.0",
|
"vendor.eureka.hardware.parts@1.0",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ using vendor::eureka::hardware::parts::V1_0::Value;
|
||||||
static android::sp<IFlashBrightness> service = IFlashBrightness::getService();
|
static android::sp<IFlashBrightness> service = IFlashBrightness::getService();
|
||||||
|
|
||||||
extern "C" JNIEXPORT void JNICALL
|
extern "C" JNIEXPORT void JNICALL
|
||||||
Java_com_eurekateam_samsungextras_interfaces_Flashlight_setEnabled
|
Java_com_eurekateam_samsungextras_interfaces_Flashlight_setEnabled(
|
||||||
(JNIEnv *env, __unused jobject obj, jboolean enabled) {
|
JNIEnv *env, __unused jobject obj, jboolean enabled) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
service->setFlashlightEnable(Number::ENABLE);
|
service->setFlashlightEnable(Number::ENABLE);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
extern "C" JNIEXPORT jdouble JNICALL
|
extern "C" JNIEXPORT jdouble JNICALL
|
||||||
Java_com_eurekateam_samsungextras_interfaces_Swap_getFreeSpace(
|
Java_com_eurekateam_samsungextras_interfaces_Swap_getFreeSpace(JNIEnv *env,
|
||||||
JNIEnv *env, jclass clazz) {
|
jclass clazz) {
|
||||||
fs::space_info data = fs::space("/data");
|
fs::space_info data = fs::space("/data");
|
||||||
auto freespace = data.free / 1024 / 1024;
|
auto freespace = data.free / 1024 / 1024;
|
||||||
return static_cast<double>(freespace) / 1024;
|
return static_cast<double>(freespace) / 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" JNIEXPORT jlong JNICALL
|
extern "C" JNIEXPORT jlong JNICALL
|
||||||
Java_com_eurekateam_samsungextras_interfaces_Swap_getSwapSize(
|
Java_com_eurekateam_samsungextras_interfaces_Swap_getSwapSize(JNIEnv *env,
|
||||||
JNIEnv *env, jclass clazz){
|
jclass clazz) {
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
int rc = stat("/data/swap/swapfile", &stat_buf);
|
int rc = stat("/data/swap/swapfile", &stat_buf);
|
||||||
return rc == 0 ? stat_buf.st_size / 1024 / 1024 : -1;
|
return rc == 0 ? stat_buf.st_size / 1024 / 1024 : -1;
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,10 @@ Java_com_eurekateam_samsungextras_interfaces_Swap_setSize(JNIEnv *env,
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" JNIEXPORT void JNICALL
|
extern "C" JNIEXPORT void JNICALL
|
||||||
Java_com_eurekateam_samsungextras_interfaces_Swap_setSwapOn(
|
Java_com_eurekateam_samsungextras_interfaces_Swap_setSwapOn(JNIEnv *env,
|
||||||
JNIEnv *env, jclass clazz, jboolean enable) {
|
jclass clazz,
|
||||||
if (enable){
|
jboolean enable) {
|
||||||
|
if (enable) {
|
||||||
service->setSwapOn();
|
service->setSwapOn();
|
||||||
} else {
|
} else {
|
||||||
service->setSwapOff();
|
service->setSwapOff();
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,8 @@ class BatteryFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChang
|
||||||
mSharedPreferences.edit().putBoolean(PREF_CHARGE, Battery.chargeSysfs == 0).apply()
|
mSharedPreferences.edit().putBoolean(PREF_CHARGE, Battery.chargeSysfs == 0).apply()
|
||||||
return true
|
return true
|
||||||
} else if (preference == mFastChargePref) {
|
} else if (preference == mFastChargePref) {
|
||||||
Battery.setFastCharge(if (newValue as Boolean) 0 else 1) mFastChargePref.isChecked = Battery.fastChargeSysfs == 0
|
Battery.setFastCharge(if (newValue as Boolean) 0 else 1)
|
||||||
|
mFastChargePref.isChecked = Battery.fastChargeSysfs == 0
|
||||||
mSharedPreferences.edit().putBoolean(PREF_FASTCHARGE, Battery.fastChargeSysfs == 0).apply()
|
mSharedPreferences.edit().putBoolean(PREF_FASTCHARGE, Battery.fastChargeSysfs == 0).apply()
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,6 @@ package com.eurekateam.samsungextras.interfaces
|
||||||
object Swap {
|
object Swap {
|
||||||
external fun setSwapOn(mEnabled: Boolean)
|
external fun setSwapOn(mEnabled: Boolean)
|
||||||
external fun setSize(mSize: Int)
|
external fun setSize(mSize: Int)
|
||||||
external fun getFreeSize(): Double
|
external fun getFreeSpace(): Double
|
||||||
external fun getSwapSize(): Long
|
external fun getSwapSize(): Long
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,8 @@ class SwapFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChangeLi
|
||||||
mSwapSizePref.isEnabled = !isChecked
|
mSwapSizePref.isEnabled = !isChecked
|
||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
} companion object {
|
}
|
||||||
|
companion object {
|
||||||
const val PREF_SWAP_SIZE = "swap_size"
|
const val PREF_SWAP_SIZE = "swap_size"
|
||||||
const val PREF_SWAP_ENABLE = "swap_enable"
|
const val PREF_SWAP_ENABLE = "swap_enable"
|
||||||
const val INFO_FREE_SPACE = "free_space"
|
const val INFO_FREE_SPACE = "free_space"
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,9 @@ Return<void> SwapOnData::setSwapSize(int32_t size) {
|
||||||
return Void();
|
return Void();
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<void> SwapOnData::setSwapOn(){
|
Return<void> SwapOnData::setSwapOn() {
|
||||||
string cmd = string("dd if=/dev/zero of=") + string(SWAP_PATH) + string(" bs=") + std::to_string(mSwapSize)
|
string cmd = string("dd if=/dev/zero of=") + string(SWAP_PATH) +
|
||||||
+ "M count=10";
|
string(" bs=") + std::to_string(mSwapSize) + "M count=10";
|
||||||
system(cmd.c_str());
|
system(cmd.c_str());
|
||||||
cmd = string("mkswap ") + string(SWAP_PATH);
|
cmd = string("mkswap ") + string(SWAP_PATH);
|
||||||
system(cmd.c_str());
|
system(cmd.c_str());
|
||||||
|
|
@ -38,7 +38,7 @@ Return<void> SwapOnData::setSwapOn(){
|
||||||
return Void();
|
return Void();
|
||||||
}
|
}
|
||||||
|
|
||||||
Return<void> SwapOnData::setSwapOff(){
|
Return<void> SwapOnData::setSwapOff() {
|
||||||
std::string cmd = string("swapoff ") + string(SWAP_PATH);
|
std::string cmd = string("swapoff ") + string(SWAP_PATH);
|
||||||
system(cmd.c_str());
|
system(cmd.c_str());
|
||||||
cmd = string("rm ") + string(SWAP_PATH);
|
cmd = string("rm ") + string(SWAP_PATH);
|
||||||
|
|
@ -46,7 +46,5 @@ Return<void> SwapOnData::setSwapOff(){
|
||||||
return Void();
|
return Void();
|
||||||
}
|
}
|
||||||
|
|
||||||
ISwapOnData *SwapOnData::getInstance(void) {
|
ISwapOnData *SwapOnData::getInstance(void) { return new SwapOnData(); }
|
||||||
return new SwapOnData();
|
|
||||||
}
|
|
||||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,11 @@ using android::hardware::joinRpcThreadpool;
|
||||||
using vendor::eureka::hardware::parts::V1_0::BatteryStats;
|
using vendor::eureka::hardware::parts::V1_0::BatteryStats;
|
||||||
using vendor::eureka::hardware::parts::V1_0::DisplayConfigs;
|
using vendor::eureka::hardware::parts::V1_0::DisplayConfigs;
|
||||||
using vendor::eureka::hardware::parts::V1_0::FlashBrightness;
|
using vendor::eureka::hardware::parts::V1_0::FlashBrightness;
|
||||||
using vendor::eureka::hardware::parts::V1_0::SwapOnData;
|
|
||||||
using vendor::eureka::hardware::parts::V1_0::IBatteryStats;
|
using vendor::eureka::hardware::parts::V1_0::IBatteryStats;
|
||||||
using vendor::eureka::hardware::parts::V1_0::IDisplayConfigs;
|
using vendor::eureka::hardware::parts::V1_0::IDisplayConfigs;
|
||||||
using vendor::eureka::hardware::parts::V1_0::IFlashBrightness;
|
using vendor::eureka::hardware::parts::V1_0::IFlashBrightness;
|
||||||
using vendor::eureka::hardware::parts::V1_0::ISwapOnData;
|
using vendor::eureka::hardware::parts::V1_0::ISwapOnData;
|
||||||
|
using vendor::eureka::hardware::parts::V1_0::SwapOnData;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue