pressing hold/power-btn does not lock/unlock screen in native app

741 views
Skip to first unread message

Nalin Savara

unread,
Jul 31, 2012, 3:24:00 PM7/31/12
to andro...@googlegroups.com
Dear Friends and Senior Colleagues,

I have a android app; that uses parts of Qt widget-set ported to android (ofcourse it's a rough and not perfect and incomplete port) and running on Galaxy Note.

When power-btn is pressed--- screen goes off; and seemingly locked (because it's unresponsive to touch)... but when we press center-button OR power-button--->> which should show us a lock-screen-- and prompt us to unlock...

then, instead of seeing lock screen--- we just see the app... ie: the screen/touch got powered-off--->> but it was not actually locked.

How to ensure that pressing power button makes lock happen in app built around native activity ???

Do help... since it's getting rejected in a app-store's QA due to this reason...

Regards,

Nalin

RichardC

unread,
Jul 31, 2012, 3:38:34 PM7/31/12
to andro...@googlegroups.com
You don't need to DO anything.

What you do need to do is UNDO whatever developer(s) have done in your app or toolkit.  It should be impossible to bypass the power-button locking the device.

Try looking for "KeyEvent.KEYCODE_POWER" anywhere in your code base.

RichardC

unread,
Jul 31, 2012, 3:40:53 PM7/31/12
to andro...@googlegroups.com
Forgot to add:

If you have
<uses-permission android:name="android.permission.PREVENT_POWER_KEY" />
in your manifest remove that as well.

Nalin Savara

unread,
Jul 31, 2012, 3:47:12 PM7/31/12
to andro...@googlegroups.com
Thanks a ton Richard... but that didnt help-- as none of that's done.

BTW am using Necessitas Qt SDK... 

However, your suggestions  much appreciated-- and if any other comments/suggestions/pointers... do share...

Regards,

Nalin

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/LeZ98XiRx58J.

To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.

RichardC

unread,
Jul 31, 2012, 5:03:11 PM7/31/12
to andro...@googlegroups.com
This are some posts on this issue (people trying to intercept the power-button) on  http://stackoverflow.com/


One thing I thought of is are your holding any WakeLock(s)  http://developer.android.com/reference/android/os/PowerManager.WakeLock.html 
and should you be releasing them when your app goes to the background?


On Tuesday, July 31, 2012 8:47:12 PM UTC+1, n.s wrote:
Thanks a ton Richard... but that didnt help-- as none of that's done.

BTW am using Necessitas Qt SDK... 

However, your suggestions  much appreciated-- and if any other comments/suggestions/pointers... do share...

Regards,

Nalin

On Wed, Aug 1, 2012 at 1:10 AM, RichardC <richard.critten@googlemail.com> wrote:
Forgot to add:

If you have
<uses-permission android:name="android.permission.PREVENT_POWER_KEY" />
in your manifest remove that as well.


On Tuesday, July 31, 2012 8:38:34 PM UTC+1, RichardC wrote:
You don't need to DO anything.

What you do need to do is UNDO whatever developer(s) have done in your app or toolkit.  It should be impossible to bypass the power-button locking the device.

Try looking for "KeyEvent.KEYCODE_POWER" anywhere in your code base.


 

On Tuesday, July 31, 2012 8:24:00 PM UTC+1, n.s wrote:
Dear Friends and Senior Colleagues,

I have a android app; that uses parts of Qt widget-set ported to android (ofcourse it's a rough and not perfect and incomplete port) and running on Galaxy Note.

When power-btn is pressed--- screen goes off; and seemingly locked (because it's unresponsive to touch)... but when we press center-button OR power-button--->> which should show us a lock-screen-- and prompt us to unlock...

then, instead of seeing lock screen--- we just see the app... ie: the screen/touch got powered-off--->> but it was not actually locked.

How to ensure that pressing power button makes lock happen in app built around native activity ???

Do help... since it's getting rejected in a app-store's QA due to this reason...

Regards,

Nalin

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/LeZ98XiRx58J.

To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk+unsubscribe@googlegroups.com.

Nalin Savara

unread,
Aug 1, 2012, 7:42:51 AM8/1/12
to andro...@googlegroups.com
Hi Richard,

Thanks... however, this happens even when our app's AndroidManifest.xml never asks for permissions "DEVICE_POWER" OR "WAKELOCK".

So, logically, it is unlikely that something is holding a WAKELOCK.

To me it seems much more likely that some kind of modal dialog is active--- and that's preventing the unlock screen from being shown.

Logically this should not happen--->> because this means a app could spoof the unlock screen... and 

On Wed, Aug 1, 2012 at 2:33 AM, RichardC <richard...@googlemail.com> wrote:
This are some posts on this issue (people trying to intercept the power-button) on  http://stackoverflow.com/


One thing I thought of is are your holding any WakeLock(s)  http://developer.android.com/reference/android/os/PowerManager.WakeLock.html 
and should you be releasing them when your app goes to the background?

Hi Richard,
Thanks.


 
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/LDIvGj4LQDEJ.

To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.

Nalin Savara

unread,
Aug 1, 2012, 7:44:53 AM8/1/12
to andro...@googlegroups.com
To complete my last message, in which I'd pressed send midway by mistake:
Hi Richard,

Thanks... however, this happens even when our app's AndroidManifest.xml never asks for permissions "DEVICE_POWER" OR "WAKELOCK".

So, logically, it is unlikely that something is holding a WAKELOCK.

To me it seems much more likely that some kind of modal dialog is active--- and that's preventing the unlock screen from being shown.

Logically this should not happen--->> because this means a app could spoof the unlock screen... but ok... that's happening; and I'm just looking for ways to make sure a lock screen is shown-- so it passes QA of the store to which I'm submitting.

Regards,

Nalin
Reply all
Reply to author
Forward
0 new messages