Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Maemo: Developers

How to block the camera app from starting on lens cover open

 

 

Maemo developers RSS feed   Index | Next | Previous | View Threaded


martin at martin

Jul 23, 2010, 9:20 AM

Post #1 of 9 (762 views)
Permalink
How to block the camera app from starting on lens cover open

Hi,

I'm developing an app that uses the camera, and aiming for Ovi Store.

One of the issues that Ovi QA complained about is that if the lens cover
isn't opened, I should add a banner saying that to the user. That's easy
enough, but when the user actually opens the lens cover, the camera app
opens (but since my app has grabbed the camera, fails to start). Is there
any way to block this while my app is running - since if the user has
started my app, and my app displays a banner telling the user to open the
lens cover, the user obviously don't want the camera app to start.

I've tried to explore different ways to accomplish this, but most of them
requires the app to run as root. One really simple way would be to do

echo 1 > /sys/devices/platform/gpio-switch/cam_shutter/disable

but that obviously requires root. I also tried to check what other apps,
such as shortcutd do, but they don't seem to work as intended with the
camera button on PR 1.2. Other ways to accomplish it would be to
reroute/remove the signals, as outlined here:

http://talk.maemo.org/showpost.php?p=495516&postcount=72

But that requires root, too. And if the camera-ui process is killed, it
respawns immediately.

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".

I guess I should discuss this issue with Ovi Publisher Support, too, but I
don't really expect to get coding hints from there.

// Martin
_______________________________________________
maemo-developers mailing list
maemo-developers [at] maemo
https://lists.maemo.org/mailman/listinfo/maemo-developers


trippin1 at gmail

Jul 23, 2010, 9:43 AM

Post #2 of 9 (735 views)
Permalink
Re: How to block the camera app from starting on lens cover open [In reply to]

Hi,

http://maemo.org/community/maemo-developers/intercept_camera_slider_open_event_to_default_camera_app--n900/
suggests to do what BlessN900 currently does.

Best regards,
Faheem

On 23/07/2010, Martin Storsjö <martin [at] martin> wrote:
> Hi,
>
> I'm developing an app that uses the camera, and aiming for Ovi Store.
>
> One of the issues that Ovi QA complained about is that if the lens cover
> isn't opened, I should add a banner saying that to the user. That's easy
> enough, but when the user actually opens the lens cover, the camera app
> opens (but since my app has grabbed the camera, fails to start). Is there
> any way to block this while my app is running - since if the user has
> started my app, and my app displays a banner telling the user to open the
> lens cover, the user obviously don't want the camera app to start.
>
> I've tried to explore different ways to accomplish this, but most of them
> requires the app to run as root. One really simple way would be to do
>
> echo 1 > /sys/devices/platform/gpio-switch/cam_shutter/disable
>
> but that obviously requires root. I also tried to check what other apps,
> such as shortcutd do, but they don't seem to work as intended with the
> camera button on PR 1.2. Other ways to accomplish it would be to
> reroute/remove the signals, as outlined here:
>
> http://talk.maemo.org/showpost.php?p=495516&postcount=72
>
> But that requires root, too. And if the camera-ui process is killed, it
> respawns immediately.
>
> 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".
>
> I guess I should discuss this issue with Ovi Publisher Support, too, but I
> don't really expect to get coding hints from there.
>
> // Martin
> _______________________________________________
> maemo-developers mailing list
> maemo-developers [at] maemo
> https://lists.maemo.org/mailman/listinfo/maemo-developers
>
_______________________________________________
maemo-developers mailing list
maemo-developers [at] maemo
https://lists.maemo.org/mailman/listinfo/maemo-developers


martin at martin

Jul 23, 2010, 9:53 AM

Post #3 of 9 (734 views)
Permalink
Re: How to block the camera app from starting on lens cover open [In reply to]

Hi Faheem,

On Fri, 23 Jul 2010, Faheem Pervez wrote:

> http://maemo.org/community/maemo-developers/intercept_camera_slider_open_event_to_default_camera_app--n900/
> suggests to do what BlessN900 currently does.

Thanks for this link - doing "dsmetool -k /usr/bin/camera-ui" actually
seems to work, even as non-root. However, for the Ovi Store QA process, I
don't think this is acceptable. I already got one failure issue regarding
that my application keeps the camera object reserved if the user presses
the camera button, which launches the camera app. While the camera-ui
process is disabled this way, neither camera lens cover open nor the
camera button starts the camera application.

I guess I'll have to discuss it with Ovi Publisher Support then, if this
is acceptable (disabling both the lens cover open action and the camera
button), or if it is better to spuriously launch the camera app when the
lens cover is opened.

It really is a pity that the guidelines of what is acceptable and what
isn't aren't available (as far as I've seen).

// Martin
_______________________________________________
maemo-developers mailing list
maemo-developers [at] maemo
https://lists.maemo.org/mailman/listinfo/maemo-developers


trippin1 at gmail

Jul 23, 2010, 12:37 PM

Post #4 of 9 (736 views)
Permalink
Re: How to block the camera app from starting on lens cover open [In reply to]

Hello Martin,

On 23/07/2010, Martin Storsjö <martin [at] martin> wrote:
> On Fri, 23 Jul 2010, Faheem Pervez wrote:
>
>> http://maemo.org/community/maemo-developers/intercept_camera_slider_open_event_to_default_camera_app--n900/
>> suggests to do what BlessN900 currently does.
>
> Thanks for this link - doing "dsmetool -k /usr/bin/camera-ui" actually
> seems to work, even as non-root. However, for the Ovi Store QA process, I
> don't think this is acceptable. I already got one failure issue regarding
> that my application keeps the camera object reserved if the user presses
> the camera button, which launches the camera app. While the camera-ui
> process is disabled this way, neither camera lens cover open nor the
> camera button starts the camera application.
>

I know it's not the cleanest in terms of solutions, but the way I see
it is if Nokia really wished for developers to have a proper solution,
they'd've introduced one in PR 1.1/1.1.1/1.2. Since they didn't appear
to care, I can only conclude that hacks are the way to go. :)

BlessN900 will start camera-ui again after it's closed by running
"dsmetool -t" IIRC; and, TBH, this behaviour (stopping camera-ui on
start and loading it up again on exit) makes sense because you
wouldn't be able to run the Camera app anyway whilst your program is
running. Of course, once camera-ui is running again, opening the lens
cover/pressing the camera button proceed to perform their default
functions.

> I guess I'll have to discuss it with Ovi Publisher Support then, if this
> is acceptable (disabling both the lens cover open action and the camera
> button), or if it is better to spuriously launch the camera app when the
> lens cover is opened.
>

My thoughts on the former are above (I'd find it rather dodgy if they
were to refuse your app due to it stopping camera-ui) and the latter
just really seems like an inconvienence to your users. :\ Qik took
another approach: it'd tell the user to open the cover and wait. When
the camera application popped up onto the screen, Qik'd close the
window and proceed to carrying on as normal.

Anyway, best of luck getting your application into the Ovi Store!

Best regards,
Faheem
_______________________________________________
maemo-developers mailing list
maemo-developers [at] maemo
https://lists.maemo.org/mailman/listinfo/maemo-developers


corsac at debian

Jul 23, 2010, 11:32 PM

Post #5 of 9 (724 views)
Permalink
Re: How to block the camera app from starting on lens cover open [In reply to]

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?

Cheers,
--
Yves-Alexis
Attachments: signature.asc (0.82 KB)


martin at martin

Jul 24, 2010, 3:29 AM

Post #6 of 9 (724 views)
Permalink
Re: How to block the camera app from starting on lens cover open [In reply to]

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.

// Martin


eero.tamminen at nokia

Jul 30, 2010, 1:47 AM

Post #7 of 9 (653 views)
Permalink
Re: How to block the camera app from starting on lens cover open [In reply to]

Hi,

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?


- Eero

(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?)
_______________________________________________
maemo-developers mailing list
maemo-developers [at] maemo
https://lists.maemo.org/mailman/listinfo/maemo-developers


talvala at stanford

Jul 30, 2010, 2:03 AM

Post #8 of 9 (653 views)
Permalink
Re: How to block the camera app from starting on lens cover open [In reply to]

On 7/30/2010 1:47 AM, Eero Tamminen wrote:
> Hi,
>
> 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?
>
>
> - Eero
>
> (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?)

In the case of FCam programs, which as mentioned use the dsmetool tool
hack: If the program crashes, normal camera function isn't restored.
The camera can be started from the app menu manually, which I believe
restores normal lens cover function, but at that point the camera app is
running as a regular app, not under dsmetool (so it can't be killed
through dsmetool). Alternatively, starting and then quitting an FCam
program will restore the lens cover function. As a safety fallback,
FCam first tries to kill the camera program with dsmetool, and then with
regular kill - the regular kill is needed in the second case (regular
camera program started outside of dsmetool).

A wrapper shellscript or a watchdog process might be a better idea,
although if an app only uses the camera part of the time, it might be
nice to be able to re-enable the normal camera function sooner (so if
camera functionality is only a small part of the app's functionality,
you're not hogging the camera for the whole of program execution).

Eddy Talvala
Stanford University
_______________________________________________
maemo-developers mailing list
maemo-developers [at] maemo
https://lists.maemo.org/mailman/listinfo/maemo-developers


martin at martin

Jul 30, 2010, 2:38 AM

Post #9 of 9 (658 views)
Permalink
Re: How to block the camera app from starting on lens cover open [In reply to]

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

Maemo developers RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.