mirror of
https://github.com/xoureldeen/Vectras-VM-Android.git
synced 2026-04-28 06:19:49 +00:00
- Added auto return to Home after importing rom and creating virtual machine in Rom store. - Improved image viewer. - Fixed Unknow display error in architecture in rom info if it is PowerPC architecture. - New setup wizard interface that automatically changes according to screen size. - New ID generator for virtual machine. - Added dialog when deleting virtual machine.
78 lines
2.8 KiB
Java
78 lines
2.8 KiB
Java
package com.vectras.vm.utils;
|
|
|
|
import android.app.ActivityManager;
|
|
import android.app.usage.StorageStatsManager;
|
|
import android.content.Context;
|
|
import android.content.res.Configuration;
|
|
import android.os.Build;
|
|
import android.os.Environment;
|
|
import android.os.StatFs;
|
|
import android.os.storage.StorageManager;
|
|
import android.util.DisplayMetrics;
|
|
import android.util.Log;
|
|
|
|
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, boolean isCheckVeryLow) {
|
|
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 < (isCheckVeryLow ? 256 : 2048);
|
|
} catch (IOException e) {
|
|
Log.e(TAG, "Error getting storage stats", e);
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public static boolean is64bit() {
|
|
return Build.SUPPORTED_ABIS[0].contains("arm64");
|
|
}
|
|
|
|
public static boolean isLargeScreen(Context context) {
|
|
Configuration config = context.getResources().getConfiguration();
|
|
return config.smallestScreenWidthDp >= 600;
|
|
}
|
|
|
|
public static boolean isHighDpi(Context context) {
|
|
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
|
|
int currentDpi = metrics.densityDpi;
|
|
Log.i(TAG, "isHighDpi: " + currentDpi);
|
|
return currentDpi >= 600;
|
|
}
|
|
}
|