diff options
author | Jim Miller <jaggies@google.com> | 2010-06-07 19:26:28 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-06-07 19:26:28 -0700 |
commit | c4e37ac0ea01e346ffa635a074222f6bc8671e14 (patch) | |
tree | c3dd1f3ffc1bd8f4b502657c2c51f52f05405320 /services | |
parent | d5f401ba51d9f200cd25ee58eec99134576d78d9 (diff) | |
parent | bde25c207731783a62e3611586fe05cd35add0d9 (diff) | |
download | frameworks_base-c4e37ac0ea01e346ffa635a074222f6bc8671e14.zip frameworks_base-c4e37ac0ea01e346ffa635a074222f6bc8671e14.tar.gz frameworks_base-c4e37ac0ea01e346ffa635a074222f6bc8671e14.tar.bz2 |
am bde25c20: Merge "Fix 2737842: disable keyguard API when device policy is enabled." into froyo
Merge commit 'bde25c207731783a62e3611586fe05cd35add0d9' into froyo-plus-aosp
* commit 'bde25c207731783a62e3611586fe05cd35add0d9':
Fix 2737842: disable keyguard API when device policy is enabled.
Diffstat (limited to 'services')
-rw-r--r-- | services/java/com/android/server/WindowManagerService.java | 61 |
1 files changed, 43 insertions, 18 deletions
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index be5cc7b..3a181b2 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -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; @@ -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; @@ -4171,13 +4173,31 @@ 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"); } - synchronized (mKeyguardTokenWatcher) { - mKeyguardTokenWatcher.acquire(token, tag); + + if (allowDisableKeyguard()) { + synchronized (mKeyguardTokenWatcher) { + mKeyguardTokenWatcher.acquire(token, tag); + } + } else { + Log.w(TAG, tag + ": disableKeyguard() ignored while DevicePolicyAmin is enabled."); } } @@ -4186,25 +4206,30 @@ public class WindowManagerService extends IWindowManager.Stub != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Requires DISABLE_KEYGUARD permission"); } - 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 { - mKeyguardTokenWatcher.wait(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); + + if (allowDisableKeyguard()) { + 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 { + mKeyguardTokenWatcher.wait(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } } } } + } else { + Log.w(TAG, "reenableKeyguard() ignored while DevicePolicyAmin is enabled."); } } |