diff options
author | Jim Miller <jaggies@google.com> | 2012-01-17 15:55:31 -0800 |
---|---|---|
committer | Jim Miller <jaggies@google.com> | 2012-01-17 18:11:05 -0800 |
commit | 93c518e4f8abd98f87cda1712b30a5a86cfa60dd (patch) | |
tree | fd9e7459bf5a228aef50826097a2cc714b8a6013 /services/java/com/android/server/DevicePolicyManagerService.java | |
parent | ff321d496a6a07fc667112ecfe4d9a107d44147b (diff) | |
download | frameworks_base-93c518e4f8abd98f87cda1712b30a5a86cfa60dd.zip frameworks_base-93c518e4f8abd98f87cda1712b30a5a86cfa60dd.tar.gz frameworks_base-93c518e4f8abd98f87cda1712b30a5a86cfa60dd.tar.bz2 |
Fix 5863053: Add method to lock screen immediately.
This fixes a bug where the device fails to lock when DevicePolicyManagerService
requests the device to be locked and the screen was off because the user hit
the power button.
The change allows DPMS to directly invoke screen lock, bypasssing the screen state.
Change-Id: Iecdda6fc61e9c519119de495be23c69c3b983921
Diffstat (limited to 'services/java/com/android/server/DevicePolicyManagerService.java')
-rw-r--r-- | services/java/com/android/server/DevicePolicyManagerService.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/services/java/com/android/server/DevicePolicyManagerService.java b/services/java/com/android/server/DevicePolicyManagerService.java index e8ca3ce..d8e3d59 100644 --- a/services/java/com/android/server/DevicePolicyManagerService.java +++ b/services/java/com/android/server/DevicePolicyManagerService.java @@ -60,6 +60,7 @@ import android.util.PrintWriterPrinter; import android.util.Printer; import android.util.Slog; import android.util.Xml; +import android.view.IWindowManager; import android.view.WindowManagerPolicy; import java.io.File; @@ -96,6 +97,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { final PowerManager.WakeLock mWakeLock; IPowerManager mIPowerManager; + IWindowManager mIWindowManager; int mActivePasswordQuality = DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED; int mActivePasswordLength = 0; @@ -506,6 +508,14 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return mIPowerManager; } + private IWindowManager getWindowManager() { + if (mIWindowManager == null) { + IBinder b = ServiceManager.getService(Context.WINDOW_SERVICE); + mIWindowManager = IWindowManager.Stub.asInterface(b); + } + return mIWindowManager; + } + ActiveAdmin getActiveAdminUncheckedLocked(ComponentName who) { ActiveAdmin admin = mAdminMap.get(who); if (admin != null @@ -1649,8 +1659,11 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { DeviceAdminInfo.USES_POLICY_FORCE_LOCK); long ident = Binder.clearCallingIdentity(); try { + // Power off the display mIPowerManager.goToSleepWithReason(SystemClock.uptimeMillis(), WindowManagerPolicy.OFF_BECAUSE_OF_ADMIN); + // Ensure the device is locked + getWindowManager().lockNow(); } catch (RemoteException e) { } finally { Binder.restoreCallingIdentity(ident); |