mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-21 19:55:33 -04:00
universal7885: parts: swap: Round down
The free space on /data Also fix some issues with it
This commit is contained in:
parent
0faf51929d
commit
4a8c870b6b
3 changed files with 13 additions and 2 deletions
|
|
@ -4,12 +4,20 @@
|
|||
|
||||
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;
|
||||
return static_cast<double>(freespace) / 1024;
|
||||
auto result = static_cast<double>(freespace) / 1024;
|
||||
return roundDouble(result);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
|
|
|
|||
|
|
@ -72,6 +72,8 @@ class SwapFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChangeLi
|
|||
mSwapEnable.isEnabled = true
|
||||
mSharedPreferences.edit().putBoolean(PREF_SWAP_ENABLE, isChecked).apply()
|
||||
mSwapSizePref.isEnabled = !isChecked
|
||||
mFreeSpace.summary = "${Swap.getFreeSpace()} GB"
|
||||
mSwapFileSize.summary = "${Swap.getSwapSize()} MB"
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,9 @@ allow system_app hal_parts_hwservice:hwservice_manager find;
|
|||
|
||||
allow system_app hal_parts_default:binder call;
|
||||
|
||||
# FMRadio
|
||||
r_dir_file(system_app, parts_data_file)
|
||||
|
||||
# FMRadio
|
||||
allow system_app hal_fmradio_hwservice:hwservice_manager find;
|
||||
|
||||
allow system_app hal_fmradio_default:binder call;
|
||||
|
|
|
|||
Loading…
Reference in a new issue