Loading core/java/android/app/KeyguardManager.java +7 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,9 @@ public class KeyguardManager { * * A good place to call this is from {@link android.app.Activity#onResume()} * * Note: This call has no effect while any {@link DevicePolicyManager} is enabled * that requires a password. * * @see #reenableKeyguard() */ public void disableKeyguard() { Loading @@ -68,6 +71,9 @@ public class KeyguardManager { * * A good place to call this is from {@link android.app.Activity#onPause()} * * Note: This call has no effect while any {@link DevicePolicyManager} is enabled * that requires a password. * * @see #disableKeyguard() */ public void reenableKeyguard() { Loading services/java/com/android/server/WindowManagerService.java +43 −18 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ import com.android.server.am.BatteryStatsService; import android.Manifest; import android.app.ActivityManagerNative; import android.app.IActivityManager; import android.app.admin.DevicePolicyManager; import android.content.Context; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; Loading Loading @@ -86,6 +87,7 @@ import android.os.TokenWatcher; import android.provider.Settings; import android.util.DisplayMetrics; import android.util.EventLog; import android.util.Log; import android.util.Slog; import android.util.SparseIntArray; import android.view.Display; Loading Loading @@ -4171,14 +4173,32 @@ public class WindowManagerService extends IWindowManager.Stub // Misc IWindowSession methods // ------------------------------------------------------------- private boolean allowDisableKeyguard() { // We fail safe if this gets called before the service has started. boolean allow = false; DevicePolicyManager dpm = (DevicePolicyManager) mContext.getSystemService( Context.DEVICE_POLICY_SERVICE); if (dpm != null) { allow = dpm.getPasswordQuality(null) == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED; } return allow; } public void disableKeyguard(IBinder token, String tag) { if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires DISABLE_KEYGUARD permission"); } if (allowDisableKeyguard()) { synchronized (mKeyguardTokenWatcher) { mKeyguardTokenWatcher.acquire(token, tag); } } else { Log.w(TAG, tag + ": disableKeyguard() ignored while DevicePolicyAmin is enabled."); } } public void reenableKeyguard(IBinder token) { Loading @@ -4186,6 +4206,8 @@ public class WindowManagerService extends IWindowManager.Stub != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires DISABLE_KEYGUARD permission"); } if (allowDisableKeyguard()) { synchronized (mKeyguardTokenWatcher) { mKeyguardTokenWatcher.release(token); Loading @@ -4206,6 +4228,9 @@ public class WindowManagerService extends IWindowManager.Stub } } } } else { Log.w(TAG, "reenableKeyguard() ignored while DevicePolicyAmin is enabled."); } } /** Loading Loading
core/java/android/app/KeyguardManager.java +7 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,9 @@ public class KeyguardManager { * * A good place to call this is from {@link android.app.Activity#onResume()} * * Note: This call has no effect while any {@link DevicePolicyManager} is enabled * that requires a password. * * @see #reenableKeyguard() */ public void disableKeyguard() { Loading @@ -68,6 +71,9 @@ public class KeyguardManager { * * A good place to call this is from {@link android.app.Activity#onPause()} * * Note: This call has no effect while any {@link DevicePolicyManager} is enabled * that requires a password. * * @see #disableKeyguard() */ public void reenableKeyguard() { Loading
services/java/com/android/server/WindowManagerService.java +43 −18 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ import com.android.server.am.BatteryStatsService; import android.Manifest; import android.app.ActivityManagerNative; import android.app.IActivityManager; import android.app.admin.DevicePolicyManager; import android.content.Context; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; Loading Loading @@ -86,6 +87,7 @@ import android.os.TokenWatcher; import android.provider.Settings; import android.util.DisplayMetrics; import android.util.EventLog; import android.util.Log; import android.util.Slog; import android.util.SparseIntArray; import android.view.Display; Loading Loading @@ -4171,14 +4173,32 @@ public class WindowManagerService extends IWindowManager.Stub // Misc IWindowSession methods // ------------------------------------------------------------- private boolean allowDisableKeyguard() { // We fail safe if this gets called before the service has started. boolean allow = false; DevicePolicyManager dpm = (DevicePolicyManager) mContext.getSystemService( Context.DEVICE_POLICY_SERVICE); if (dpm != null) { allow = dpm.getPasswordQuality(null) == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED; } return allow; } public void disableKeyguard(IBinder token, String tag) { if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires DISABLE_KEYGUARD permission"); } if (allowDisableKeyguard()) { synchronized (mKeyguardTokenWatcher) { mKeyguardTokenWatcher.acquire(token, tag); } } else { Log.w(TAG, tag + ": disableKeyguard() ignored while DevicePolicyAmin is enabled."); } } public void reenableKeyguard(IBinder token) { Loading @@ -4186,6 +4206,8 @@ public class WindowManagerService extends IWindowManager.Stub != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires DISABLE_KEYGUARD permission"); } if (allowDisableKeyguard()) { synchronized (mKeyguardTokenWatcher) { mKeyguardTokenWatcher.release(token); Loading @@ -4206,6 +4228,9 @@ public class WindowManagerService extends IWindowManager.Stub } } } } else { Log.w(TAG, "reenableKeyguard() ignored while DevicePolicyAmin is enabled."); } } /** Loading