d4rken-org / sdmaid

SD Maid is an Android app that helps you manage files and apps.
https://play.google.com/store/apps/details?id=eu.thedarken.sdm
1.51k stars 745 forks source link

External sdcard detection on Sony Xperia Compact F5321 @ 8.0.0 #3558

Closed d4rken closed 1 year ago

d4rken commented 4 years ago

SD Maid can match the SAF permission if manually granted, but can't related it to the external card.

1590133905890  D/StorageVolumeMapper: Updating mappings.
1590133905892  D/StorageVolumeMapper: Trying to map: UriPermission {uri=content://com.android.externalstorage.documents/tree/4E39-DCD4%3A, modeFlags=3, persistedTime=1589801573748}
1590133905893  D/StorageVolumeRepository: Attempting getVolumeRoot(UriPermission {uri=content://com.android.externalstorage.documents/tree/4E39-DCD4%3A, modeFlags=3, persistedTime=1589801573748}) via getVolumeList().
1590133905897  D/StorageVolumeRepository: StorageVolumeX: StorageVolumeX(uuid=null, state=mounted, path=/storage/emulated/0, primary=true, emulated=true, owner=UserHandle{0}, userlabel=Internal shared storage)
1590133905898  D/StorageVolumeRepository: StorageVolumeX: StorageVolumeX(uuid=4E39-DCD4, state=mounted, path=/storage/4E39-DCD4, primary=false, emulated=false, owner=UserHandle{0}, userlabel=SD card)
1590133905900  D/StorageVolumeRepository: Found mapping StorageVolumeX(uuid=4E39-DCD4, state=mounted, path=/storage/4E39-DCD4, primary=false, emulated=false, owner=UserHandle{0}, userlabel=SD card) -> VolumeRoot(treeUri=/tree/4E39-DCD4:, rootId=4E39-DCD4, title=SD card, documentId=4E39-DCD4:, storagePath=/storage/4E39-DCD4)
1590133905901  D/StorageVolumeMapper: Mapped VolumeRoot(treeUri=/tree/4E39-DCD4:, rootId=4E39-DCD4, title=SD card, documentId=4E39-DCD4:, storagePath=/storage/4E39-DCD4) to UriPermission {uri=content://com.android.externalstorage.documents/tree/4E39-DCD4%3A, modeFlags=3, persistedTime=1589801573748}

The system exposes only exposes EXTERNAL_STORAGE=/sdcard.

1590133900735  D/Debug:EnvPrinter: Environment variables:
1590133900735  D/Debug:EnvPrinter: _=/system/bin/printenv
1590133900735  D/Debug:EnvPrinter: ANDROID_DATA=/data
1590133900735  D/Debug:RXSDebug: Stop Process[pid=31854 ,hasExited=true, exitcode=0], now 0 (total: 1) processes: []
1590133900735  D/Debug:EnvPrinter: ANDROID_SOCKET_zygote=8
1590133900735  D/Debug:EnvPrinter: ANDROID_ROOT=/system
1590133900735  V/RXS:RxProcess: Process finished, clearing session
1590133900735  D/Debug:EnvPrinter: EXTERNAL_STORAGE=/sdcard
1590133900736  D/Debug:EnvPrinter: ANDROID_BOOTLOGO=1
1590133900736  D/Debug:EnvPrinter: ANDROID_ASSETS=/system/app
1590133900736  D/Debug:EnvPrinter: BOOTCLASSPATH=/system/framework/QPerformance.jar:/system/framework/core-oj.jar:/system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/legacy-test.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/apache-xml.jar:/system/framework/org.apache.http.legacy.boot.jar:/system/framework/android.hidl.base-V1.0-java.jar:/system/framework/android.hidl.manager-V1.0-java.jar:/system/framework/tcmiface.jar:/system/framework/telephony-ext.jar:/system/framework/WfdCommon.jar
1590133900736  D/Debug:EnvPrinter: ASEC_MOUNTPOINT=/mnt/asec
1590133900736  D/Debug:EnvPrinter: DOWNLOAD_CACHE=/data/cache
1590133900736  D/Debug:EnvPrinter: ANDROID_STORAGE=/storage
1590133900736  D/Debug:EnvPrinter: PATH=/sbin:/system/sbin:/system/bin:/system/xbin:/vendor/bin:/vendor/xbin
1590133900736  D/Debug:EnvPrinter: SYSTEMSERVERCLASSPATH=/system/framework/services.jar:/system/framework/ethernet-service.jar:/system/framework/wifi-service.jar

And that's not enough for SD Maid to understand the relation.

1590133890682  D/Debug:BuildProp: Fingerprint: Sony/F5321/F5321:8.0.0/34.4.A.2.118/1631208121:user/release-keys
1590133890682  D/Debug:SysInfoModule: App locales: [en_DE,de_DE], Device locales: [en_DE,de_DE]
1590133890682  I/Debug:ApkInfo: F: VERSIONNAME: 4.15.8, VERSIONCODE: 41508
1590133890682  D/Debug:BuildProp: ro.build.version.codename=REL
1590133890683  D/Debug:BuildProp: ro.build.version.incremental=1631208121
1590133890684  D/Debug:BuildProp: ro.build.version.base_os=
1590133890685  I/Debug:ApkInfo: P: VERSIONNAME: 4.4.1, VERSIONCODE: 40401
1590133890685  D/Debug:BuildProp: ro.build.version.release=8.0.0
1590133890686  D/Debug:BuildProp: ro.build.display.id=34.4.A.2.118
1590133890686  D/Debug:BuildProp: ro.product.name=F5321
1590133890687  D/Debug:BuildProp: ro.product.device=F5321
1590133890691  D/Debug:BuildProp: ro.product.board=msm8952
1590133890692  D/Debug:BuildProp: ro.product.manufacturer=Sony
1590133890692  D/Debug:BuildProp: ro.product.brand=Sony
1590133890693  D/Debug:BuildProp: ro.product.model=F5321
1590133890693  D/Debug:BuildProp: ro.bootloader=s1
1590133905846  D/MountFactory: Found 18 mounts (normal).
1590133905847  D/MountFactory: Mountpoint(path=/dev/memcg, blockDevice=none, fileSystemType=CGROUP, options=[memory, rw, relatime])
1590133905847  D/MountFactory: Mountpoint(path=/acct, blockDevice=none, fileSystemType=CGROUP, options=[rw, relatime, cpuacct])
1590133905847  D/MountFactory: Mountpoint(path=/mnt/runtime/write/emulated, blockDevice=/data/media, fileSystemType=SDCARDFS, options=[noexec, rw, fsuid=1023, nodev, derive_gid, fsgid=1023, nosuid, noatime, multiuser, gid=9997, mask=7])
1590133905848  D/MountFactory: Mountpoint(path=/sys, blockDevice=sysfs, fileSystemType=SYSFS, options=[rw, relatime, seclabel])
1590133905848  D/MountFactory: Mountpoint(path=/dev/cpuset, blockDevice=none, fileSystemType=CGROUP, options=[release_agent=/sbin/cpuset_release_agent, rw, relatime, cpuset, noprefix])
1590133905848  D/MountFactory: Mountpoint(path=/, blockDevice=rootfs, fileSystemType=ROOTFS, options=[seclabel, ro])
1590133905848  D/MountFactory: Mountpoint(path=/proc, blockDevice=proc, fileSystemType=PROC, options=[hidepid=2, rw, relatime, gid=3009])
1590133905849  D/MountFactory: Mountpoint(path=/dev, blockDevice=tmpfs, fileSystemType=TMPFS, options=[rw, nr_inodes=359666, relatime, seclabel, nosuid, mode=755, size=1438664k])
1590133905849  D/MountFactory: Mountpoint(path=/dev/cpuctl, blockDevice=none, fileSystemType=CGROUP, options=[rw, relatime, cpu])
1590133905849  D/MountFactory: Mountpoint(path=/dev/usb-ffs/adb, blockDevice=adb, fileSystemType=UNKNOWN, options=[rw, relatime])
1590133905849  D/MountFactory: Mountpoint(path=/sys/fs/selinux, blockDevice=selinuxfs, fileSystemType=UNKNOWN, options=[rw, relatime])
1590133905849  D/MountFactory: Mountpoint(path=/mnt/runtime/read/emulated, blockDevice=/data/media, fileSystemType=SDCARDFS, options=[mask=23, noexec, rw, fsuid=1023, nodev, derive_gid, fsgid=1023, nosuid, noatime, multiuser, gid=9997])
1590133905850  D/MountFactory: Mountpoint(path=/dev/pts, blockDevice=devpts, fileSystemType=DEVPTS, options=[rw, relatime, seclabel, mode=600])
1590133905850  D/MountFactory: Mountpoint(path=/mnt, blockDevice=tmpfs, fileSystemType=TMPFS, options=[gid=1000, rw, nr_inodes=359666, relatime, seclabel, mode=755, size=1438664k])
1590133905850  D/MountFactory: Mountpoint(path=/sys/kernel/debug, blockDevice=debugfs, fileSystemType=DEBUGFS, options=[rw, relatime, seclabel])
1590133905850  D/MountFactory: Mountpoint(path=/mnt/runtime/default/emulated, blockDevice=/data/media, fileSystemType=SDCARDFS, options=[gid=1015, noexec, rw, fsuid=1023, nodev, derive_gid, fsgid=1023, mask=6, nosuid, noatime, multiuser])
1590133905850  D/MountFactory: Mountpoint(path=/sys/fs/pstore, blockDevice=pstore, fileSystemType=UNKNOWN, options=[rw, relatime, seclabel])
1590133905851  D/MountFactory: Mountpoint(path=/system, blockDevice=/dev/block/dm-0, fileSystemType=EXT4, options=[discard, relatime, seclabel, data=ordered, ro])

sdmaid_logfile_1590133889663.txt.zip

d4rken commented 4 years ago

The system also doesn't expose the external sdcard via API:

D/SdcardModule: getExternalCacheDirs(): {/storage/emulated/0/Android/data/eu.thedarken.sdm/cache}
d4rken commented 4 years ago

Adding /sdcard is too vague to match against /storage/4E39-DCD4 as /sdcard is present on any device.

Matching would need to be reversed, instead of:

we'd need to

Basically include the list of mapped permissions as source for storage detection, that would allow users on any device where SD Maid doesn't detect external storage to manually add it.