summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorJoe Onorato <joeo@google.com>2011-04-06 11:41:11 -0700
committerJoe Onorato <joeo@google.com>2011-04-06 11:41:11 -0700
commitea495d4c1f6e0aefe145a9a6c75a2aab4daf2037 (patch)
tree32367019df2c0eb2cb4b8ae0300eea39e3a3e9ee /policy
parent782c9d870998511672c18e362c05d373572cd392 (diff)
downloadframeworks_base-ea495d4c1f6e0aefe145a9a6c75a2aab4daf2037.zip
frameworks_base-ea495d4c1f6e0aefe145a9a6c75a2aab4daf2037.tar.gz
frameworks_base-ea495d4c1f6e0aefe145a9a6c75a2aab4daf2037.tar.bz2
Move around the HDMI switch detection so we don't try to get the status if we can't listen to it.
Change-Id: I46f4e92923ba010f68109b6d043c817e25dfe650
Diffstat (limited to 'policy')
-rwxr-xr-xpolicy/src/com/android/internal/policy/impl/PhoneWindowManager.java62
1 files changed, 32 insertions, 30 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 44f55b3..768c0cd 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -728,15 +728,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");
- }
- 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
+
+ // Controls rotation and the like.
+ initializeHdmiState();
}
public void updateSettings() {
@@ -2075,31 +2071,37 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
}
- 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) {
+ void initializeHdmiState() {
+ // 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");
+
+ boolean plugged = false;
+ 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) {
+ plugged = 0 != Integer.parseInt(new String(buf, 0, n-1));
+ }
+ } catch (IOException ex) {
+ Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex);
+ } catch (NumberFormatException ex) {
+ Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex);
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException ex) {
+ }
}
}
+
+ // This dance forces the code in setHdmiPlugged to run.
+ mHdmiPlugged = !plugged;
+ setHdmiPlugged(!mHdmiPlugged);
}
}