mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-02-16 11:50:47 +01:00
Prevent crashes on devices before Oreo version
This commit is contained in:
parent
3919384928
commit
69bddaa3d7
@ -286,10 +286,15 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
||||
if (storageVolume.isPrimary) {
|
||||
// internal storage
|
||||
volumeName = PRIMARY_VOLUME_NAME
|
||||
val storageStatsManager = context.getSystemService(AppCompatActivity.STORAGE_STATS_SERVICE) as StorageStatsManager
|
||||
val uuid = StorageManager.UUID_DEFAULT
|
||||
totalStorageSpace = storageStatsManager.getTotalBytes(uuid)
|
||||
freeStorageSpace = storageStatsManager.getFreeBytes(uuid)
|
||||
if (isOreoPlus()) {
|
||||
val storageStatsManager = context.getSystemService(AppCompatActivity.STORAGE_STATS_SERVICE) as StorageStatsManager
|
||||
val uuid = StorageManager.UUID_DEFAULT
|
||||
totalStorageSpace = storageStatsManager.getTotalBytes(uuid)
|
||||
freeStorageSpace = storageStatsManager.getFreeBytes(uuid)
|
||||
} else {
|
||||
totalStorageSpace = file.totalSpace
|
||||
freeStorageSpace = file.freeSpace
|
||||
}
|
||||
} else {
|
||||
volumeName = storageVolume.uuid!!.lowercase(Locale.US)
|
||||
totalStorageSpace = file.totalSpace
|
||||
|
Loading…
x
Reference in New Issue
Block a user