diff --git a/app/src/main/java/com/yinuo/safetywatcher/watcher/utils/SoundUtils.kt b/app/src/main/java/com/yinuo/safetywatcher/watcher/utils/SoundUtils.kt index fa8fd9f..bcb568b 100644 --- a/app/src/main/java/com/yinuo/safetywatcher/watcher/utils/SoundUtils.kt +++ b/app/src/main/java/com/yinuo/safetywatcher/watcher/utils/SoundUtils.kt @@ -54,5 +54,6 @@ object SoundUtils { fun stopSoundIo() { soundPlaying = false + GPIOUtils.setGpioValue(152, 0) } } \ No newline at end of file diff --git a/library-common/src/main/java/com/common/commonlib/utils/StorageUtils.kt b/library-common/src/main/java/com/common/commonlib/utils/StorageUtils.kt index e30ea9e..0553069 100644 --- a/library-common/src/main/java/com/common/commonlib/utils/StorageUtils.kt +++ b/library-common/src/main/java/com/common/commonlib/utils/StorageUtils.kt @@ -6,8 +6,7 @@ import android.os.storage.StorageManager import android.os.storage.StorageVolume import java.lang.reflect.InvocationTargetException -val USB_KEYWORDS = arrayOf("USB", "U 盘") -val NVME_KEYWORDS = arrayOf("新加卷") +val NVME_KEYWORDS = arrayOf("yinuo nvme", "YINUO NVME", "YINUO", "NVME") object StorageUtils { /** @@ -31,15 +30,21 @@ object StorageUtils { val getUserLabel = storageVolumeClazz.getMethod("getUserLabel") for (i in 0 until length) { val storageVolumeElement: StorageVolume = result[i] + // 内部存储 + if (storageVolumeElement.isPrimary) { + continue + } val userLabel = getUserLabel.invoke(storageVolumeElement) as String val path = getPath.invoke(storageVolumeElement) as String - if (isUsb) { - if (USB_KEYWORDS.contains(userLabel)) { + // nvme + if (!isUsb) { + // 大于400GB的也当硬盘看待 + if (containsNvmeKeys(userLabel) || getSizeInGB(path) > 400) { targetpath = path } } else { - // 大于400GB的也当硬盘看待 - if (NVME_KEYWORDS.contains(userLabel) || getSizeInGB(path) > 400) { + // 不是内部存储,也不是硬盘,就当作U盘 + if (!containsNvmeKeys(userLabel)) { targetpath = path } } @@ -56,6 +61,16 @@ object StorageUtils { return targetpath } + private fun containsNvmeKeys(label: String): Boolean { + NVME_KEYWORDS.forEach { + if (label.contains(it)) { + LogUtils.w("label:${label} is nvme") + return true + } + } + return false + } + private const val BYTE_GB = 1024 * 1024 * 1024f private fun getSizeInGB(path: String): Int { val statfs = StatFs(path) diff --git a/library-push/src/main/java/com/yinuo/library/vlc/encoder/CameraHelper.java b/library-push/src/main/java/com/yinuo/library/vlc/encoder/CameraHelper.java index d794e8e..d02ec53 100644 --- a/library-push/src/main/java/com/yinuo/library/vlc/encoder/CameraHelper.java +++ b/library-push/src/main/java/com/yinuo/library/vlc/encoder/CameraHelper.java @@ -226,11 +226,20 @@ public class CameraHelper { if (context != null) { String nvmePath = StorageUtils.INSTANCE.getStoragePath(context, false); if (!TextUtils.isEmpty(nvmePath)) { - File mediaStorageDir = new File(nvmePath + File.separator + "video"); - if (!mediaStorageDir.exists() && !mediaStorageDir.mkdirs()) { + File parentFile = new File(nvmePath); + File[] externalFilesDir = context.getExternalMediaDirs(); + int length = externalFilesDir.length; + for (int i = 0; i< length; i++){ + File file = externalFilesDir[i]; + if (file.getAbsolutePath().contains(nvmePath)){ + parentFile = file; + break; + } + } + if (!parentFile.exists() && !parentFile.mkdirs()) { return null; } - return mediaStorageDir; + return parentFile; } else { if (!Environment.getExternalStorageState().equalsIgnoreCase(Environment.MEDIA_MOUNTED)) { return null;