universal7885: parts: Show free space and swapfile size

This commit is contained in:
roynatech2544 2022-04-20 11:31:13 +09:00
commit 0a612ac913
8 changed files with 59 additions and 17 deletions

View file

@ -0,0 +1,21 @@
#include <filesystem>
#include <sys/stat.h>
#include <jni.h>
namespace fs = std::filesystem;
extern "C" JNIEXPORT jdouble JNICALL
Java_com_eurekateam_samsungextras_interfaces_Swap_getFreeSpace(
JNIEnv *env, jclass clazz) {
fs::space_info data = fs::space("/data");
auto freespace = data.free / 1024 / 1024;
return static_cast<double>(freespace) / 1024;
}
extern "C" JNIEXPORT jlong JNICALL
Java_com_eurekateam_samsungextras_interfaces_Swap_getSwapSize(
JNIEnv *env, jclass clazz){
struct stat stat_buf;
int rc = stat("/data/swap/swapfile", &stat_buf);
return rc == 0 ? stat_buf.st_size / 1024 / 1024 : -1;
}