mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-17 11:25:34 -04:00
Improved the scanning of ZIM files in the Play Store variant.
* Excluded the scanning of other directories in the Play Store variant, as only app-specific directories can be accessed, making it unnecessary to include other directories in the scan.
This commit is contained in:
parent
0969102778
commit
e309dde0c5
@ -22,6 +22,7 @@ import android.content.Context
|
||||
import android.content.ContextWrapper
|
||||
import android.os.Environment
|
||||
import androidx.core.content.ContextCompat
|
||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
||||
import java.io.File
|
||||
import java.io.FileFilter
|
||||
import java.io.RandomAccessFile
|
||||
@ -34,10 +35,9 @@ object StorageDeviceUtils {
|
||||
|
||||
@JvmStatic
|
||||
fun getReadableStorage(context: Context): List<StorageDevice> {
|
||||
var sharedPreferenceUtil: SharedPreferenceUtil? = SharedPreferenceUtil(context)
|
||||
val storageDevices = ArrayList<StorageDevice>().apply {
|
||||
add(environmentDevices(context))
|
||||
addAll(externalMountPointDevices())
|
||||
addAll(externalFilesDirsDevices(context, false))
|
||||
addAll(externalMediaFilesDirsDevices(context))
|
||||
// Scan the app-specific directory as well because we have limitations in scanning
|
||||
// all directories on Android 11 and above in the Play Store variant.
|
||||
@ -47,6 +47,15 @@ object StorageDeviceUtils {
|
||||
// Therefore, we need to explicitly include the app-specific directory for scanning.
|
||||
// See https://github.com/kiwix/kiwix-android/issues/3579
|
||||
addAll(externalFilesDirsDevices(context, true))
|
||||
// Do not scan storage directories in the Play Store build on Android 11 and above.
|
||||
// In the Play Store variant, we can only access app-specific directories,
|
||||
// so scanning other directories is unnecessary, wastes resources,
|
||||
// and increases the scanning time.
|
||||
if (sharedPreferenceUtil?.isNotPlayStoreBuildWithAndroid11OrAbove() == true) {
|
||||
addAll(externalMountPointDevices())
|
||||
addAll(externalFilesDirsDevices(context, false))
|
||||
}
|
||||
sharedPreferenceUtil = null
|
||||
}
|
||||
return validate(storageDevices, false)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user