title: WindowManager.LayoutParams and screenBrightness
body: <p>I have some problem with WindowManager.LayoutParams. I need to poweroff and poweron the screen using the proximity sensors. The proximity sensor is OK, but layoutParams doesn't work</p>
  
  <pre><code>    public void setBright(float value) {
      Window mywindow = getWindow();
      WindowManager.LayoutParams lp = mywindow.getAttributes();
      lp.screenBrightness = value;
      lp.buttonBrightness = value;
  
      if (value != WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF) {
          lp.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
      }
  
      mywindow.setAttributes(lp);
  }
  </code></pre>
  
  <p>The screen poweroff correctly. But if I use setBright(WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE) the screen remains black. I also tried using wakeLock</p>
  
  <pre><code>private void powerOnScreen() {
      setBright(WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE);
  
      onResume();
      if (!wakeLock.isHeld())
          wakeLock.acquire();
  }
  </code></pre>
  
  <p>where wakeLock is:</p>
  
  <pre><code>PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
      wakeLock = powerManager.newWakeLock(
              PowerManager.SCREEN_DIM_WAKE_LOCK
              | PowerManager.ON_AFTER_RELEASE,
              "MY_TAG");
  </code></pre>
  
  <p>but it still doesn't work. Any idea? Target platform is Android 2.2</p>