diff --git a/packages/SystemUI/res/layout-xlarge/status_bar.xml b/packages/SystemUI/res/layout-xlarge/status_bar.xml index 0eaf08e53009a..0533b6f5e66c1 100644 --- a/packages/SystemUI/res/layout-xlarge/status_bar.xml +++ b/packages/SystemUI/res/layout-xlarge/status_bar.xml @@ -25,7 +25,8 @@ mListeners = new ArrayList(); + WindowManager mWindowManager; + int mHeight; + + public HeightReceiver(Context context) { + mContext = context; + mWindowManager = WindowManagerImpl.getDefault(); + } + + public void addOnBarHeightChangedListener(OnBarHeightChangedListener l) { + mListeners.add(l); + l.onBarHeightChanged(mHeight); + } + + public void removeOnBarHeightChangedListener(OnBarHeightChangedListener l) { + mListeners.remove(l); + } + + @Override + public void onReceive(Context context, Intent intent) { + final boolean plugged + = intent.getBooleanExtra(WindowManagerPolicy.EXTRA_HDMI_PLUGGED_STATE, false); + setPlugged(plugged); + } + + public void registerReceiver() { + final IntentFilter filter = new IntentFilter(); + filter.addAction(WindowManagerPolicy.ACTION_HDMI_PLUGGED); + final Intent val = mContext.registerReceiver(this, filter); + onReceive(mContext, val); + } + + private void setPlugged(boolean plugged) { + final Resources res = mContext.getResources(); + + Slog.d(TAG, "plugged=" + plugged); + int height = -1; + if (plugged) { + final DisplayMetrics metrics = new DisplayMetrics(); + mWindowManager.getDefaultDisplay().getMetrics(metrics); + Slog.d(TAG, "metrics=" + metrics); + height = metrics.heightPixels - 720; + } + + final int minHeight + = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); + if (height < minHeight) { + height = minHeight; + } + Slog.d(TAG, "using height=" + height + " old=" + mHeight); + mHeight = height; + + final int N = mListeners.size(); + for (int i=0; i 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. */