mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-21 19:55:33 -04:00
universal7885: parts-jni: Use std::round
This commit is contained in:
parent
0f241e7998
commit
b2b0515b28
1 changed files with 2 additions and 9 deletions
|
|
@ -1,23 +1,16 @@
|
|||
#include <filesystem>
|
||||
#include <jni.h>
|
||||
#include <cmath>
|
||||
#include <sys/stat.h>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
double roundDouble(double origin) {
|
||||
int first = static_cast<int>(origin);
|
||||
double second = origin - first;
|
||||
second = static_cast<int>(second * 10);
|
||||
return static_cast<double>(first *= 10 + second) / 10;
|
||||
}
|
||||
|
||||
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;
|
||||
auto result = static_cast<double>(freespace) / 1024;
|
||||
return roundDouble(result);
|
||||
return std::round((static_cast<double>(freespace) / 1024) / 0.1) * 0.1;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
|
|
|
|||
Loading…
Reference in a new issue