password protection - unlocking a screen via code in android -
how unlock phone screen when event happens?i tried following code not unlock screeen . unlock mean bypass pin or pattern
am using following code , triggered when sms received.
private void unlockscreen(context context){ log.d("dialog", "unlocking screen now"); powermanager powermanager = ((powermanager)context.getsystemservice(context.power_service)); wakelock wakelock = powermanager.newwakelock(powermanager.screen_bright_wake_lock | powermanager.acquire_causes_wakeup, "tag"); wakelock.acquire(); window wind = dialogactivity.this.getwindow(); wind.addflags(layoutparams.flag_dismiss_keyguard); wind.addflags(layoutparams.flag_show_when_locked); wind.addflags(layoutparams.flag_turn_screen_on); }
screen powered on user has enter pin/pattern.how on it?
straight android api site disablekeyguard()
:
disable keyguard showing. if keyguard showing, hide it. keyguard prevented showing again until reenablekeyguard() called. place call onresume() note: call has no effect while devicepolicymanager enabled requires password.
based off bolded statement cannot without password. way passed if had yourself(app) added phone device admin, control device admin application of removing password, wiping etc.
source : keyguardmanager.keyguardlock & devicepolicymanager
edit
i found source code of lockpatternutils
(i know older version, doubt has changed much) in part pattern locks , has devicepolicymanager on it. believe has internal service running root in system work. without being device admin, not have authority unlock phone when has security setting it.
Comments
Post a Comment