Loading services/java/com/android/server/WindowManagerService.java +25 −19 Original line number Diff line number Diff line Loading @@ -224,20 +224,22 @@ public class WindowManagerService extends IWindowManager.Stub /** * Condition waited on by {@link #reenableKeyguard} to know the call to * the window policy has finished. * This is set to true only if mKeyguardTokenWatcher.acquired() has * actually disabled the keyguard. */ private boolean mWaitingUntilKeyguardReenabled = false; private boolean mKeyguardDisabled = false; final TokenWatcher mKeyguardDisabled = new TokenWatcher( new Handler(), "WindowManagerService.mKeyguardDisabled") { final TokenWatcher mKeyguardTokenWatcher = new TokenWatcher( new Handler(), "WindowManagerService.mKeyguardTokenWatcher") { public void acquired() { mPolicy.enableKeyguard(false); mKeyguardDisabled = true; } public void released() { mPolicy.enableKeyguard(true); synchronized (mKeyguardDisabled) { mWaitingUntilKeyguardReenabled = false; mKeyguardDisabled.notifyAll(); synchronized (mKeyguardTokenWatcher) { mKeyguardDisabled = false; mKeyguardTokenWatcher.notifyAll(); } } }; Loading Loading @@ -4040,8 +4042,8 @@ public class WindowManagerService extends IWindowManager.Stub != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires DISABLE_KEYGUARD permission"); } synchronized (mKeyguardDisabled) { mKeyguardDisabled.acquire(token, tag); synchronized (mKeyguardTokenWatcher) { mKeyguardTokenWatcher.acquire(token, tag); } } Loading @@ -4050,16 +4052,20 @@ public class WindowManagerService extends IWindowManager.Stub != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires DISABLE_KEYGUARD permission"); } synchronized (mKeyguardDisabled) { mKeyguardDisabled.release(token); if (!mKeyguardDisabled.isAcquired()) { // if we are the last one to reenable the keyguard wait until // we have actaully finished reenabling until returning mWaitingUntilKeyguardReenabled = true; while (mWaitingUntilKeyguardReenabled) { synchronized (mKeyguardTokenWatcher) { mKeyguardTokenWatcher.release(token); if (!mKeyguardTokenWatcher.isAcquired()) { // If we are the last one to reenable the keyguard wait until // we have actaully finished reenabling until returning. // It is possible that reenableKeyguard() can be called before // the previous disableKeyguard() is handled, in which case // neither mKeyguardTokenWatcher.acquired() or released() would // be called. In that case mKeyguardDisabled will be false here // and we have nothing to wait for. while (mKeyguardDisabled) { try { mKeyguardDisabled.wait(); mKeyguardTokenWatcher.wait(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } Loading Loading @@ -10854,7 +10860,7 @@ public class WindowManagerService extends IWindowManager.Stub public void monitor() { synchronized (mWindowMap) { } synchronized (mKeyguardDisabled) { } synchronized (mKeyguardTokenWatcher) { } synchronized (mKeyWaiter) { } } Loading Loading
services/java/com/android/server/WindowManagerService.java +25 −19 Original line number Diff line number Diff line Loading @@ -224,20 +224,22 @@ public class WindowManagerService extends IWindowManager.Stub /** * Condition waited on by {@link #reenableKeyguard} to know the call to * the window policy has finished. * This is set to true only if mKeyguardTokenWatcher.acquired() has * actually disabled the keyguard. */ private boolean mWaitingUntilKeyguardReenabled = false; private boolean mKeyguardDisabled = false; final TokenWatcher mKeyguardDisabled = new TokenWatcher( new Handler(), "WindowManagerService.mKeyguardDisabled") { final TokenWatcher mKeyguardTokenWatcher = new TokenWatcher( new Handler(), "WindowManagerService.mKeyguardTokenWatcher") { public void acquired() { mPolicy.enableKeyguard(false); mKeyguardDisabled = true; } public void released() { mPolicy.enableKeyguard(true); synchronized (mKeyguardDisabled) { mWaitingUntilKeyguardReenabled = false; mKeyguardDisabled.notifyAll(); synchronized (mKeyguardTokenWatcher) { mKeyguardDisabled = false; mKeyguardTokenWatcher.notifyAll(); } } }; Loading Loading @@ -4040,8 +4042,8 @@ public class WindowManagerService extends IWindowManager.Stub != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires DISABLE_KEYGUARD permission"); } synchronized (mKeyguardDisabled) { mKeyguardDisabled.acquire(token, tag); synchronized (mKeyguardTokenWatcher) { mKeyguardTokenWatcher.acquire(token, tag); } } Loading @@ -4050,16 +4052,20 @@ public class WindowManagerService extends IWindowManager.Stub != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires DISABLE_KEYGUARD permission"); } synchronized (mKeyguardDisabled) { mKeyguardDisabled.release(token); if (!mKeyguardDisabled.isAcquired()) { // if we are the last one to reenable the keyguard wait until // we have actaully finished reenabling until returning mWaitingUntilKeyguardReenabled = true; while (mWaitingUntilKeyguardReenabled) { synchronized (mKeyguardTokenWatcher) { mKeyguardTokenWatcher.release(token); if (!mKeyguardTokenWatcher.isAcquired()) { // If we are the last one to reenable the keyguard wait until // we have actaully finished reenabling until returning. // It is possible that reenableKeyguard() can be called before // the previous disableKeyguard() is handled, in which case // neither mKeyguardTokenWatcher.acquired() or released() would // be called. In that case mKeyguardDisabled will be false here // and we have nothing to wait for. while (mKeyguardDisabled) { try { mKeyguardDisabled.wait(); mKeyguardTokenWatcher.wait(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } Loading Loading @@ -10854,7 +10860,7 @@ public class WindowManagerService extends IWindowManager.Stub public void monitor() { synchronized (mWindowMap) { } synchronized (mKeyguardDisabled) { } synchronized (mKeyguardTokenWatcher) { } synchronized (mKeyWaiter) { } } Loading