[new feature] background service for copy/move/del operation

Support for Android version of Total Commander

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
adyd
Junior Member
Junior Member
Posts: 13
Joined: 2011-07-26, 14:08 UTC
Location: Romania

[new feature] background service for copy/move/del operation

Post by *adyd »

Would it be very complicated to add a background service for copy/move/delete operations for large files and/or long list of files?

I think that such a feature combined with a notification icon that could show the progress would be very useful for long time operations.

Some times, during long file operations, (downloading/uploading files to an FTP server for eg.) it could be very useful to be able to start such an operation, send it to background and do something else on your phone until it is finished.
I would really like to see such a feature on TC for Android. (by the way, I think that something similar is available in AndFTP software - but this is only for FTP connections).

Many thanks for your good work!
-- AdyD
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Unfortunately I haven't found a way to get this working correctly. For example, the plugins are all services, but Android ends them when TC is closed.
Author of Total Commander
https://www.ghisler.com
User avatar
adyd
Junior Member
Junior Member
Posts: 13
Joined: 2011-07-26, 14:08 UTC
Location: Romania

Post by *adyd »

When the user starts such a service just display a notification icon in notification bar and then TC will automatically have a higher priority, thus it will be less likely to be killed by the OS while it is in background.
And by the way, you don't need to close TC, just put it to background and let it do it's job and when the user wants to come back, just click the notification bar icon... or something like this... :)
you know, I'm not at all an expert in Android development but I expect you to be since you made such a nice piece of sw :) and I think there are a lot of sw on the market implemented like this (I mean send it to bg and bring it back via notification icon).
Nevertheless, thank you for your efforts and can't wait to buy this sw on the Market!
-- AdyD
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

And by the way, you don't need to close TC, just put it to background and let it do it's job and when the user wants to come back, just click the notification bar icon... or something like this...
The problem is that Android ends apps whenever it wants, e.g. even when there is an incoming phone call. There seems to be no way to tell the system that TC is busy copying and shouldn't be closed...
Author of Total Commander
https://www.ghisler.com
User avatar
adyd
Junior Member
Junior Member
Posts: 13
Joined: 2011-07-26, 14:08 UTC
Location: Romania

Post by *adyd »

OK, you are right that the android system will shut down an app when there is a request for RAM space for a new app that is launched.
But you must also now that android system organizes the apps in different priority classes and depending to which class your app belongs, it will decide weather to kill it or kill another background app.
You maybe already know also that if you display a notification in the notification bar while your app is sent to background, your app will be cosidered as a FOREGROUND_APP class and it will be the "less likely" class to be killed when memory is required by the system.
Please do not think that I'm trying to teach you some android lessons, I'm just trying to tell you what I also found out from other sources and that maybe can help you for your development.
Here maybe you can find some hints: http://andrs.w3pla.net/autokiller/details (but maybe you already knew about this... :)
Thank you for your hard work!
-- AdyD
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Thanks for the interesting info! I wonder whether I really need to write a service for that. Currently copying, packing etc. is done in a background thread. This thread seems to continue when TC is in the background - all I need is to prevent Android from closing the program. Would it help to show a notification from the app itself when receiving the onPause() notification?
Author of Total Commander
https://www.ghisler.com
User avatar
adyd
Junior Member
Junior Member
Posts: 13
Joined: 2011-07-26, 14:08 UTC
Location: Romania

Post by *adyd »

I think this would be enough maybe...
I think you should enable an icon in the notification when TC is sent to background and when you click that in notification, bring back the main UI of TC (if still running... :) ). At least this is how I understand it.
If you do this, you should implement some feedback to the user also for when a BG operation finishes (something like a vibration and/or sound...)
You maybe can have a look at how the guys from AndFtp did it... (it is a FTP client implementation for Android that has this kind of feature - notification icon during bg operation).
Thanks for taking it into consideration! :)
-- AdyD
User avatar
adyd
Junior Member
Junior Member
Posts: 13
Joined: 2011-07-26, 14:08 UTC
Location: Romania

Post by *adyd »

Thank you for the new feature in RC6! :)
I will try to test it as soon as I will have some time.
-- AdyD
Kulsius
Junior Member
Junior Member
Posts: 4
Joined: 2012-04-20, 07:25 UTC

Post by *Kulsius »

it works like a charm in rc6, but there is some problems, when i open another resource demanding applications, like player or 3d camera. Most of the times, Total commander closes with all background processes in mid work... Since i have rooted phone, i made TC as system application. Since then i never had any problems.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Any idea what I could do to prevent it? I don't think that there is a function in non-root mode...
Author of Total Commander
https://www.ghisler.com
Kulsius
Junior Member
Junior Member
Posts: 4
Joined: 2012-04-20, 07:25 UTC

Post by *Kulsius »

I don't really know, because i'm just a newbie at programming, but i don't think it's quite possible to do in not rooted phone... I'll keep looking for response. Maybe it's possible, because media application is not closed even when system hangs up.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

After some searching, I found a workaround where TC is shown with priority "high" in a task manager. I couldn't cause a force close with this workaround.

It works like this: Instead of showing the taskbar icon in the main form, I create a background service and show it from there. Then I call the function "startForeground". Since this is a member of the Service class, it can only be called from a service. This gives the service foreground priority, so the App is treated as if it were a foreground program even when it's in the background!

You can find this in the Android SDK.

The other trick is to store the main form as a variable in the Application object (only during a copy operation). Since the Service isn't closed, the Application object isn't closed either. And since it holds a link to the main form, the main form stays around too! This way I can keep the file operations in the background thread of the main form, which makes it much easier than moving everyting to the background service.
Author of Total Commander
https://www.ghisler.com
Kulsius
Junior Member
Junior Member
Posts: 4
Joined: 2012-04-20, 07:25 UTC

Post by *Kulsius »

That's great news! So, how long until rc7? :D i hope i can use this much more than just for simple small file transferring :)
User avatar
adyd
Junior Member
Junior Member
Posts: 13
Joined: 2011-07-26, 14:08 UTC
Location: Romania

Post by *adyd »

I have tested the new feature and it's working great for me.
Thank you for considering it! ;)
Nevertheless, something to comment :) : when you have time please reconsider the design of the icons in the notification bar... it's not pretty at all! :D
-- AdyD
Kulsius
Junior Member
Junior Member
Posts: 4
Joined: 2012-04-20, 07:25 UTC

Post by *Kulsius »

About the icons, it could be a little more minimalistic... i mean, it's too fancy, but it's only my opinion. In my opinion, i would change layout of whole browser a little, so it would be much simpler and easy to use. That would be very good on qvga screens, which is quite small and sometimes hard to use...
Post Reply