summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorJoe Onorato <joeo@google.com>2011-01-11 17:09:16 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-01-11 17:09:16 -0800
commit14770e049e10377bd963623891ccb0976b2dd6ee (patch)
treeaff1116fd09ff5387dce5af03b5eab00cccbed1a /policy
parentd938e216cb24f7c154cf62135e90b8e6f3de2464 (diff)
parentdc10030581d6eec1c96acd62ed511f91d25d73a1 (diff)
downloadframeworks_base-14770e049e10377bd963623891ccb0976b2dd6ee.zip
frameworks_base-14770e049e10377bd963623891ccb0976b2dd6ee.tar.gz
frameworks_base-14770e049e10377bd963623891ccb0976b2dd6ee.tar.bz2
Merge "The status bar half of making the status bar resize when hdmi is plugged in." into honeycomb
Diffstat (limited to 'policy')
-rwxr-xr-xpolicy/src/com/android/internal/policy/impl/PhoneWindowManager.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 3e8318e..243fa07 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -122,6 +122,8 @@ import android.media.IAudioService;
import android.media.AudioManager;
import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
import java.util.ArrayList;
/**
@@ -712,6 +714,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (new File("/sys/devices/virtual/switch/hdmi/state").exists()) {
mHDMIObserver.startObserving("DEVPATH=/devices/virtual/switch/hdmi");
}
+ mHdmiPlugged = !readHdmiState();
+ setHdmiPlugged(!mHdmiPlugged);
// Note: the Configuration is not stable here, so we cannot load mStatusBarCanHide from
// config_statusBarCanHide because the latter depends on the screen size
@@ -2000,11 +2004,40 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mHdmiPlugged = plugged;
updateRotation(Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE);
Intent intent = new Intent(ACTION_HDMI_PLUGGED);
+ intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
intent.putExtra(EXTRA_HDMI_PLUGGED_STATE, plugged);
mContext.sendStickyBroadcast(intent);
}
}
+ boolean readHdmiState() {
+ final String filename = "/sys/class/switch/hdmi/state";
+ FileReader reader = null;
+ try {
+ reader = new FileReader(filename);
+ char[] buf = new char[15];
+ int n = reader.read(buf);
+ if (n > 1) {
+ return 0 != Integer.parseInt(new String(buf, 0, n-1));
+ } else {
+ return false;
+ }
+ } catch (IOException ex) {
+ Slog.d(TAG, "couldn't read hdmi state from " + filename + ": " + ex);
+ return false;
+ } catch (NumberFormatException ex) {
+ Slog.d(TAG, "couldn't read hdmi state from " + filename + ": " + ex);
+ return false;
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException ex) {
+ }
+ }
+ }
+ }
+
/**
* @return Whether music is being played right now.
*/