Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh internal storage data when usb storage is attached #2635

Open
d4rken opened this issue May 31, 2019 · 7 comments

Comments

Projects
None yet
2 participants
@d4rken
Copy link
Owner

commented May 31, 2019

Currently SD Maid only reads the storage setup once, before the first task is executed.
If the devices storage changes, e.g. a usb device is attached, SD Maid has to be restarted to recognize the new storage.

To fix this, SD Maid needs to listen to storage change events and propagate the new storage data to all tools, possibly via Rx, though it will be tricky to not get into an undefined state as some workers cache additional data to improve performance.

@d4rken d4rken added this to the Next Tasks milestone May 31, 2019

@d4rken

This comment has been minimized.

Copy link
Owner Author

commented May 31, 2019

Procedure on first launch that would need to re-execute:

SD Maid detects these storages:

I/StorageManager: Storage(location=SDCARD, path=/storage/80D4-0A03, userHandle=-1, flags=[SECONDARY], safUri=null, mount=Mountpoint(path=/storage/80D4-0A03,  (....))
I/StorageManager: Storage(location=SDCARD, path=/storage/emulated/0, userHandle=0, flags=[PRIMARY, EMULATED], safUri=null, mount=Mountpoint(path=/storage/emulated,  (....))
I/StorageManager: Storage(location=SDCARD, path=/storage/0073-1E0D, userHandle=-1, flags=[SECONDARY], safUri=null, mount=Mountpoint(path=/storage/0073-1E0D, (....))

then detects that additional setup is necessary:

I/Setup:Controller: Setup is necessary(setupItems=[SAFSetupStep(requests=[RequestObject(storage=Storage(location=SDCARD, path=/storage/80D4-0A03, userHandle=-1, flags=[SECONDARY], safUri=null, mount=Mountpoint(path=/storage/80D4-0A03), RequestObject(storage=Storage(location=SDCARD, path=/storage/0073-1E0D, userHandle=-1, flags=[SECONDARY], safUri=null, mount=Mountpoint(path=/storage/0073-1E0D), freeSpace=26892173312)], skippable=false, result=null)])

Then checks the system for mappings:

D/StorageVolumeRepository: StorageVolumeX: StorageVolumeX(uuid=null, state=mounted, path=/storage/emulated/0, primary=true, emulated=true, owner=UserHandle{0}, userlabel=Phone storage)
D/StorageVolumeRepository: StorageVolumeX: StorageVolumeX(uuid=0073-1E0D, state=mounted, path=/storage/0073-1E0D, primary=false, emulated=false, owner=UserHandle{0}, userlabel=SD card)
D/StorageVolumeRepository: StorageVolumeX: StorageVolumeX(uuid=80D4-0A03, state=mounted, path=/storage/80D4-0A03, primary=false, emulated=false, owner=UserHandle{0}, userlabel=UsbStorage)
 
and finds the correct matches

D/StorageVolumeMapper: Mapped VolumeRoot(treeUri=/tree/80D4-0A03:, rootId=80D4-0A03, title=UsbStorage, documentId=80D4-0A03:, storagePath=/storage/80D4-0A03) to UriPermission {uri=content://com.android.externalstorage.documents/tree/80D4-0A03%3A, modeFlags=3, persistedTime=1559178054278}
D/StorageVolumeMapper: Mapped VolumeRoot(treeUri=/tree/0073-1E0D:, rootId=0073-1E0D, title=SD card, documentId=0073-1E0D:, storagePath=/storage/0073-1E0D) to UriPermission {uri=content://com.android.externalstorage.documents/tree/0073-1E0D%3A, modeFlags=3, persistedTime=1559178050220}
@GabrielMGitHub

This comment has been minimized.

Copy link

commented May 31, 2019

Yes, in the old days, when opening SD Maid for the first time, permissions were requested.

Today only requested all permissions when I go to clean something, with the exception of clicking on settings that only asks for the permission of the internal storage, but later does not appear but the request for access to the SD Card, I am required to activate manually within the Guide General / Advanced.

Screenshot_20190531-122252_Gallery

@d4rken

This comment has been minimized.

Copy link
Owner Author

commented May 31, 2019

Today only requested all permissions when I go to clean something, with the exception of clicking on settings that only asks for the permission of the internal storage, but later does not appear but the request for access to the SD Card, I am required to activate manually within the Guide General / Advanced.

Can you make a bug ticket with a log for this? Setup should either ask for all storage permission or none, this seems wrong if it only asks for half 🤔

@GabrielMGitHub

This comment has been minimized.

Copy link

commented May 31, 2019

You can reproduce it yourself. Clear the data from the SD Maid, when you open it for the first time it does not ask for any permissions, if you click on Settings it asks permission from the internal storage and not the SD Card. Now clear the data from the SD Maid again, the first time you open it, will not ask for permission, do a residue search, click clean and show to give permission on both internal storage and SD Card.

@GabrielMGitHub

This comment has been minimized.

Copy link

commented May 31, 2019

How much I click on settings.

sdmaid_logfile_1559334292348.txt.zip

@GabrielMGitHub

This comment has been minimized.

Copy link

commented May 31, 2019

How much I click on finding corpses.

sdmaid_logfile_1559334468029.txt.zip

@GabrielMGitHub

This comment has been minimized.

Copy link

commented May 31, 2019

I make it clear that when opening the SD Maid for the first time no permission is requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.