diff options
author | Dianne Hackborn <hackbod@google.com> | 2011-01-07 14:06:50 -0800 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2011-01-07 14:07:20 -0800 |
commit | ad7fa7fa77318d416ed338ede6aae582c239f822 (patch) | |
tree | d9cdecef4cd5c35dc652dcadfa14c4c6f73b28e2 | |
parent | 483f2c277250278722f1a056124c608cc1bb3cc2 (diff) | |
download | frameworks_base-ad7fa7fa77318d416ed338ede6aae582c239f822.zip frameworks_base-ad7fa7fa77318d416ed338ede6aae582c239f822.tar.gz frameworks_base-ad7fa7fa77318d416ed338ede6aae582c239f822.tar.bz2 |
WM part of #3293405: Screen needs to be redrawn when HDMI is plugged in
Change-Id: If5ceb28073c6abf14165871bd99cb481b31a863b
-rw-r--r-- | core/java/android/view/WindowManagerPolicy.java | 11 | ||||
-rwxr-xr-x | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 36 |
2 files changed, 43 insertions, 4 deletions
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index 3479bf5..cb0a2a9 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -85,6 +85,17 @@ public interface WindowManagerPolicy { public final static boolean WATCH_POINTER = false; + /** + * Sticky broadcast of the current HDMI plugged state. + */ + public final static String ACTION_HDMI_PLUGGED = "android.intent.action.HDMI_PLUGGED"; + + /** + * Extra in {@link #ACTION_HDMI_PLUGGED} indicating the state: true if + * plugged in to HDMI, false if not. + */ + public final static String EXTRA_HDMI_PLUGGED_STATE = "state"; + // flags for interceptKeyTq /** * Pass this event to the user / app. To be returned from {@link #interceptKeyTq}. diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 281ac2e..5ad0edb 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -37,12 +37,12 @@ import android.graphics.Rect; import android.os.Handler; import android.os.IBinder; import android.os.LocalPowerManager; -import android.os.Looper; import android.os.PowerManager; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; import android.os.SystemProperties; +import android.os.UEventObserver; import android.os.Vibrator; import android.provider.Settings; @@ -120,6 +120,7 @@ import android.view.animation.AnimationUtils; import android.media.IAudioService; import android.media.AudioManager; +import java.io.File; import java.util.ArrayList; /** @@ -236,6 +237,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean mSystemReady; boolean mLidOpen; + boolean mHdmiPlugged; int mUiMode = Configuration.UI_MODE_TYPE_NORMAL; int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED; int mLidOpenRotation; @@ -351,6 +353,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { final KeyCharacterMap.FallbackAction mFallbackAction = new KeyCharacterMap.FallbackAction(); + private UEventObserver mHDMIObserver = new UEventObserver() { + @Override + public void onUEvent(UEventObserver.UEvent event) { + setHdmiPlugged("1".equals(event.get("SWITCH_STATE"))); + } + }; + class SettingsObserver extends ContentObserver { SettingsObserver(Handler handler) { super(handler); @@ -698,6 +707,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { mSafeModeEnabledVibePattern = getLongIntArray(mContext.getResources(), com.android.internal.R.array.config_safeModeEnabledVibePattern); + // watch for HDMI plug messages if the hdmi switch exists + if (new File("/sys/devices/virtual/switch/hdmi/state").exists()) { + mHDMIObserver.startObserving("DEVPATH=/devices/virtual/switch/hdmi"); + } + // Note: the Configuration is not stable here, so we cannot load mStatusBarCanHide from // config_statusBarCanHide because the latter depends on the screen size } @@ -1963,7 +1977,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean awakeNow = mKeyguardMediator.doLidChangeTq(mLidOpen); updateRotation(Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE); if (awakeNow) { - // If the lid opening and we don't have to keep the + // If the lid is opening and we don't have to keep the // keyguard up, then we can turn on the screen // immediately. mKeyguardMediator.pokeWakelock(); @@ -1987,6 +2001,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } + void setHdmiPlugged(boolean plugged) { + if (mHdmiPlugged != plugged) { + mHdmiPlugged = plugged; + updateRotation(Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE); + Intent intent = new Intent(ACTION_HDMI_PLUGGED); + intent.putExtra(EXTRA_HDMI_PLUGGED_STATE, plugged); + mContext.sendStickyBroadcast(intent); + } + } + /** * @return Whether music is being played right now. */ @@ -2418,7 +2442,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { // case for nosensor meaning ignore sensor and consider only lid // or orientation sensor disabled //or case.unspecified - if (mLidOpen) { + if (mHdmiPlugged) { + return Surface.ROTATION_0; + } else if (mLidOpen) { return mLidOpenRotation; } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR && mCarDockRotation >= 0) { return mCarDockRotation; @@ -2586,7 +2612,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { void updateRotation(int animFlags) { mPowerManager.setKeyboardVisibility(mLidOpen); int rotation = Surface.ROTATION_0; - if (mLidOpen) { + if (mHdmiPlugged) { + rotation = Surface.ROTATION_0; + } else if (mLidOpen) { rotation = mLidOpenRotation; } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR && mCarDockRotation >= 0) { rotation = mCarDockRotation; |