mirror of
https://github.com/xoureldeen/Vectras-VM-Android.git
synced 2026-04-29 06:49:52 +00:00
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:
parent
347d769308
commit
2dfb569cc4
16 changed files with 261 additions and 247 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue