v2.9.5.6-3dfx

- Fixed bug when importing rom from Rom store.
- Added not allowing you to use Vectras VM when available storage space is too low.
- Added auto-show keyboard when editing Qemu params.
- Thumbnails in Rom store no longer download automatically, it only downloads when importing valid rom.
This commit is contained in:
An Bui 2025-09-03 23:20:06 +07:00
parent 347d769308
commit 2dfb569cc4
16 changed files with 261 additions and 247 deletions

View file

@ -1,13 +1,62 @@
package com.vectras.vm.utils;
import android.app.ActivityManager;
import android.app.usage.StorageStatsManager;
import android.content.Context;
import android.os.Build;
import android.os.Environment;
import android.os.StatFs;
import android.os.storage.StorageManager;
import android.util.Log;
import androidx.annotation.RequiresApi;
import java.io.File;
import java.io.IOException;
import java.util.UUID;
public class DeviceUtils {
public static String TAG = "DeviceUtils";
public static double totalMemoryCapacity(Context context) {
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
activityManager.getMemoryInfo(memoryInfo);
return memoryInfo.totalMem;
}
public static boolean isStorageLow(Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
try {
File path = Environment.getDataDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSizeLong();
long availableBlocks = stat.getAvailableBlocksLong();
long availableBytes = availableBlocks * blockSize;
long availableMB = availableBytes / (1024 * 1024);
return availableMB < 2048;
} catch (Exception e) {
Log.e(TAG, "Error getting storage stats", e);
}
} else {
StorageManager storageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
StorageStatsManager statsManager = (StorageStatsManager) context.getSystemService(Context.STORAGE_STATS_SERVICE);
try {
UUID uuid = storageManager.getUuidForPath(Environment.getDataDirectory());
long availableBytes = statsManager.getFreeBytes(uuid);
long availableMB = availableBytes / (1024 * 1024);
return availableMB < 2048;
} catch (IOException e) {
Log.e(TAG, "Error getting storage stats", e);
}
}
return false;
}
}