mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-23 20:45:31 -04:00
universal7885: parts: Show free space and swapfile size
This commit is contained in:
parent
2151bd330a
commit
0a612ac913
8 changed files with 59 additions and 17 deletions
21
universal7885-common/apps/SamsungParts/jni/Storage.cpp
Normal file
21
universal7885-common/apps/SamsungParts/jni/Storage.cpp
Normal 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;
|
||||
}
|
||||
Loading…
Reference in a new issue