Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 1,632
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: How to lock the device BB 10 programmatically


smcveigh wrote:

Being able to programatically reboot or lock the device could lead to some very bad things <tm>.

 

If I write an app that just locks the screen constantly, people will get angry.

If I write a headless app that constantly reboots the device, people will get angry.


smcveigh: I can see this happening since with the current OS there is no way to warm boot and delete the "app".

 

Request to have a warm boot like OS7 to bypass headless apps so that they aren't running so that bad apps can be deleted without reinstalling the OS.  I'm finding a hard way now.  For whatever reason one of my headless will hang during reset and need to reinstall the os to get the BB back

New Developer
Posts: 4
Registered: ‎06-10-2014
My Device: 9780
My Carrier: Mobifone

Re: How to lock the device BB 10 programmatically

[ Edited ]

I'm looking for a way to write a simple app that turns off screen right after the app is opened and it is automatically closed.

 

This way the users won't have to look for the power button.

 

After reading the posts, I have two questions:

 

1. If an app tries to constantly lock the screen, should a reboot fix it? since the app won't be triggered after a restart. In case it is a headless app, should blackberry already review the app before allowing it on BB World?

 

2. I don't have a BB10 device so I use the simulator, however, when I tried to set the screen property to SCREEN_POWER_MODE_OFF, nothing happens. What is this API supposed to do then?

BlackBerry Development Advisor
Posts: 683
Registered: ‎11-29-2011
My Device: PRIV
My Carrier: Rogers

Re: How to lock the device BB 10 programmatically

If you read the rest of this thread, you will note that there is no way to force the screen off.  The best you can do when your application is visible is allow the usual timeout, or disable the timeout using SCREEN_PROPERTY_IDLE_MODE.

 

SCREEN_PROPERTY_POWER_MODE is restricted to display manager contexts. (though the current version of the documentation doesn't seem to mention it).

Have you checked the return code from your screen_set_display_property_iv() call, or your call to screen_flush_context()?  I suspect you'll get EPERM.

New Developer
Posts: 4
Registered: ‎06-10-2014
My Device: 9780
My Carrier: Mobifone

Re: How to lock the device BB 10 programmatically

[ Edited ]

Thanks Sean for the explanation.

This is my first attempt to make an app for BB10 via core API. Initially I thought it would be very quick to get done but it turns out this is impossible today.

I think you're right that I would get EPERM though I couldn't verify it since the Momentics IDE lead me to Assembly Debug (which I had no clue) when I went into the call to set power mode.

Additionally, I am really concerned why it can't be done with such a simple request in our platform.

Your points in previous post are valid. But shouldn't we have a way to avoid it. I believe on iOS and Android there are a tremendous amount of apps that simply locks the device and turn off display upon the click. Don't they face the same hazard?

Plus, do you know if we would have a way to do this down the road? in 10.4 maybe? Since Blackberry is still in early age compared to the other platforms but we should be quick in order to catch up.

BlackBerry Development Advisor
Posts: 683
Registered: ‎11-29-2011
My Device: PRIV
My Carrier: Rogers

Re: How to lock the device BB 10 programmatically

Perhaps other platforms have a way to do this.. I have not checked.  They would probably still run into the same issues, but maybe have provisions for "safe mode reboots" or other such ways to get out of any potential sticky situations.

 

It's possible that a way to do this could show up eventually, but it would have to be deemed more important than something else that someone is working on (we're all really busy!), and solutions to these side-effect problems would have to be addressed.

 

(Hypothetically, if I were budgeting development time for this, off the top of my head, it would involve at least 4 different system components, an API plus documentation, new bar file capabilities and installation prompts, test coverage, and then new mechanisms for forcefully waking up the device to bypass a misbehaving app.  So multiple people from several teams working for several weeks.  If a business case for this existed, it could be done.. but I'd probably rank it pretty low if it were my personal budget Smiley Happy )

 

New Developer
Posts: 4
Registered: ‎06-10-2014
My Device: 9780
My Carrier: Mobifone

Re: How to lock the device BB 10 programmatically

I'm with you on that, considering the current situation Blackberry is in today.

Hopefully John Chen can bring the company back to profitable then we have resources and budget to build up the BB10 even stronger.

Thanks again. Smiley Happy