[guardian-dev] developer sneak peak: CacheWord

Abel Luck abel at guardianproject.info
Tue Apr 9 10:25:38 EDT 2013


Mark Murphy:
> On Wed, Mar 20, 2013 at 3:40 PM, G. Blake Meike <blake.meike at gmail.com> wrote:
>> I've been wondering if there isn't the possibility of holding this stuff in a bound service.  If the app requests the data from safe storage in the service only when it needs it and zeroizationifies it any time it isn't actually using it, then the service could delete it when it notices that the binding application has died.
> 
> The current implementation uses a bound service, though it also starts
> the service and marks it as foreground.
> 
> The problem with binding is one of timing. Android can be very twitchy
> about destroying a service once the last unbinding occurs, even if we
> going to bind again to that service in a moment. I know that, in
> particular, unbinding from the old activity on a configuration change
> would destroy the service before binding again in the new activity
> instance (assuming no other bound connections), which is why we have
> to maintain an active binding across configuration changes.
> 
> I'm not saying a bound service is unusable here. I'm merely pointing
> to the spot on the map, near bound services, that has "Here there be
> dragons"... :-)
> 

Indeed my investigation led me to believe using a bound-only service
would not work.

Between Activity changes the service was getting destroyed and recreated.

So I'm explicitly calling startService(), but binding is still useful as
it allows CacheWord to count the number of open activities using the
service.

~abel


More information about the Guardian-dev mailing list