[maemo-developers] How to block the camera app from starting on lens cover open

From: Martin Storsjö martin at martin.st
Date: Fri Jul 30 12:38:22 EEST 2010
Hi,

On Fri, 30 Jul 2010, Eero Tamminen wrote:

> ext Martin Storsjö wrote:
> > On Sat, 24 Jul 2010, Yves-Alexis Perez wrote:
> >> On ven., 2010-07-23 at 19:20 +0300, Martin Storsjö wrote:
> >>> Any hints on how to solve this in the best way? I don't want my app to 
> >>> fail in the next QA round with the reason "camera app is launched and 
> >>> closes immediately if the lens cover is opened while your app is running". 
> >> Did you check how fcamera is doing it?
> > 
> > Thanks for the pointer!
> > 
> > It seems that the FCam library kills camera-ui using dsmetool - which 
> > totally makes sense for an application that tries to grab the camera 
> > button for itself, too.
> 
> And what happens in the application crashes without restoring camera-ui,
> user needs to reboot to get camera working again?

Yes, that's what I'm fearing. Althoug, in this case, the user still can 
launch the camera app through the app menu, but not via opening the lens 
cover or pressing the camera button.

> (better may be a small wrapper / watchdog for the process that does
> the camera-ui removal before launching the program and restores it
> after the program terminates?)

Ugh, that gets even more complicated, but probably is a good idea.

I tried implementing it, and it wasn't hard at all, actually. At the start 
of my app, I do this:

        pid_t child = fork();
        if (child) {
                int status = 0;
                waitpid(child, &status, 0);
                system("dsmetool -U user -t /usr/bin/camera-ui"); 
                return 0;
        } 

That should make sure that camera-ui is alive after my process exits.

I still kill/restart camera-ui from within the app, too, to make sure the 
camera events are ignored when I want to use the camera.

// Martin
More information about the maemo-developers mailing list