From df6fd1e5f840fe694e4c9c91f0842c1b3611e4bf Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Wed, 15 Aug 2012 13:15:16 -0700 Subject: [PATCH 1/6] Glyph cache optimization Precaching at startup was not working. One-liner fix to init the caches so that precaching would kick in earlier, saving time at startup by avoiding the multiple-upload issue of caching at render time. Issue #6893691 long app launch time on manta for some apps comparing to nakasi/stingray Change-Id: Ie5c7f0536ec8ea371c7892e5e09c1db14795531c --- libs/hwui/FontRenderer.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index a596fa9464675..b352ffc538ae5 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -699,7 +699,6 @@ void FontRenderer::flushAllAndInvalidate() { } #if DEBUG_FONT_RENDERER - ALOGD("FontRenderer: flushAllAndInvalidatel"); // Erase caches, just as a debugging facility if (mCacheTextureSmall && mCacheTextureSmall->mTexture) { memset(mCacheTextureSmall->mTexture, 0, @@ -792,14 +791,12 @@ void FontRenderer::allocateTextureMemory(CacheTexture* cacheTexture) { void FontRenderer::cacheBitmap(const SkGlyph& glyph, CachedGlyphInfo* cachedGlyph, uint32_t* retOriginX, uint32_t* retOriginY) { + checkInit(); cachedGlyph->mIsValid = false; // If the glyph is too tall, don't cache it - if (mCacheLines.size() == 0 || - glyph.fHeight + TEXTURE_BORDER_SIZE * 2 > mCacheLines[mCacheLines.size() - 1]->mMaxHeight) { - if (mCacheLines.size() != 0) { - ALOGE("Font size too large to fit in cache. width, height = %i, %i", - (int) glyph.fWidth, (int) glyph.fHeight); - } + if (glyph.fHeight + TEXTURE_BORDER_SIZE * 2 > mCacheLines[mCacheLines.size() - 1]->mMaxHeight) { + ALOGE("Font size too large to fit in cache. width, height = %i, %i", + (int) glyph.fWidth, (int) glyph.fHeight); return; } From dacce4ca5426e2bd8ead51682eaa77dc23aa5b2c Mon Sep 17 00:00:00 2001 From: Daniel Sandler Date: Thu, 16 Aug 2012 11:37:41 -0400 Subject: [PATCH 2/6] Fix status bar disabling. Bug: 6998403 Change-Id: I8a47e694f2f3914ef5cf0d180b0309783148c627 --- .../src/com/android/systemui/statusbar/phone/PanelBar.java | 7 +++++++ .../android/systemui/statusbar/phone/PhoneStatusBar.java | 4 ---- .../systemui/statusbar/phone/PhoneStatusBarView.java | 6 ++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java index 78ec4b6373fff..427cd8c9c969b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java @@ -69,8 +69,15 @@ public class PanelBar extends FrameLayout { return mPanels.get((int)(N * x / getMeasuredWidth())); } + public boolean isEnabled() { + return true; + } + @Override public boolean onTouchEvent(MotionEvent event) { + // Allow subclasses to implement enable/disable semantics + if (!isEnabled()) return false; + // figure out which panel needs to be talked to here if (event.getAction() == MotionEvent.ACTION_DOWN) { mTouchingPanel = selectPanelForTouchX(event.getX()); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 4ce4e293790ef..8884179a9a6fd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -1309,10 +1309,6 @@ public class PhoneStatusBar extends BaseStatusBar { mGestureRec.add(event); - if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) { - return false; - } - return false; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java index 924e45d6d66db..a42e455c2bfc5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.phone; import android.app.ActivityManager; +import android.app.StatusBarManager; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; @@ -69,6 +70,11 @@ public class PhoneStatusBarView extends PanelBar { } } + @Override + public boolean isEnabled() { + return ((mBar.mDisabled & StatusBarManager.DISABLE_EXPAND) == 0); + } + @Override public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) { if (super.onRequestSendAccessibilityEvent(child, event)) { From 94c194a7631de38927347a429508b673b1b5e5f1 Mon Sep 17 00:00:00 2001 From: Daniel Sandler Date: Thu, 16 Aug 2012 13:52:06 -0400 Subject: [PATCH 3/6] Turn off an assert. Change-Id: Ifad4bd65ddcedc6e2dd018695fd37ddbf9163e80 --- .../src/com/android/systemui/statusbar/GestureRecorder.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/GestureRecorder.java b/packages/SystemUI/src/com/android/systemui/statusbar/GestureRecorder.java index 81a16ae42e4a7..0f894a154f391 100755 --- a/packages/SystemUI/src/com/android/systemui/statusbar/GestureRecorder.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/GestureRecorder.java @@ -101,8 +101,7 @@ public class GestureRecorder { mDownTime = ev.getDownTime(); } else { if (mDownTime != ev.getDownTime()) { - // TODO: remove - throw new RuntimeException("Assertion failure in GestureRecorder: event downTime (" + Slog.w(TAG, "Assertion failure in GestureRecorder: event downTime (" +ev.getDownTime()+") does not match gesture downTime ("+mDownTime+")"); } } From 5844f3b9fdb1f9e8e18128033676e1f1560b8061 Mon Sep 17 00:00:00 2001 From: Daniel Sandler Date: Thu, 16 Aug 2012 13:50:40 -0400 Subject: [PATCH 4/6] Fix crash in SystemUI. It looks like we were end()ing the main timing animation in the middle of the animation (and too many times, at that). Bug: 6992223 Change-Id: I6a4b7d692171baa73f6211c7843e164b05383a30 --- .../com/android/systemui/statusbar/phone/PanelView.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java index d0fba4256ba76..336eee4a9cf5b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java @@ -59,6 +59,11 @@ public class PanelView extends FrameLayout { } }; + private final Runnable mStopAnimator = new Runnable() { public void run() { + if (mTimeAnimator.isStarted()) { + mTimeAnimator.end(); } + }}; + private float mVel, mAccel; private int mFullHeight = 0; private String mViewName; @@ -117,7 +122,7 @@ public class PanelView extends FrameLayout { if (mVel == 0 || (closing && mExpandedHeight == 0) || (!closing && mExpandedHeight == getFullHeight())) { - mTimeAnimator.end(); + post(mStopAnimator); } } } @@ -277,7 +282,7 @@ public class PanelView extends FrameLayout { public void setExpandedHeight(float height) { - mTimeAnimator.end(); + post(mStopAnimator); setExpandedHeightInternal(height); } From ab94faf3d7d9a02bd808a5ef0c73e54b4d52ace6 Mon Sep 17 00:00:00 2001 From: Daniel Sandler Date: Thu, 16 Aug 2012 14:10:53 -0400 Subject: [PATCH 5/6] Allow the panels to be temporarily dragged past their contents. Once the user lets go, restore the "correct" height of the panel. Bug: 6999596 Change-Id: I2db393873cee876cf17fea25c9d25fe5e3a78424 --- .../res/layout/status_bar_expanded.xml | 4 +- .../systemui/statusbar/phone/PanelBar.java | 4 +- .../systemui/statusbar/phone/PanelView.java | 54 +++++++++++++------ .../statusbar/phone/PhoneStatusBar.java | 2 +- .../statusbar/phone/PhoneStatusBarView.java | 2 +- .../policy/NotificationRowLayout.java | 1 + 6 files changed, 46 insertions(+), 21 deletions(-) diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml index 828dba46b5a38..cb32d63a4a13d 100644 --- a/packages/SystemUI/res/layout/status_bar_expanded.xml +++ b/packages/SystemUI/res/layout/status_bar_expanded.xml @@ -23,10 +23,11 @@ xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui" android:id="@+id/notification_panel" android:layout_width="0dp" - android:layout_height="0dp" + android:layout_height="wrap_content" android:background="@drawable/notification_panel_bg" android:paddingTop="@dimen/notification_panel_padding_top" android:layout_marginLeft="@dimen/notification_panel_margin_left" + android:animateLayoutChanges="true" > getFullHeight(); + mClosing = (mExpandedHeight > 0 && mVel < 0) || mRubberbanding; } else if (dtms > 0) { final float dt = dtms * 0.001f; // ms -> s LOG("tick: v=%.2fpx/s dt=%.4fs", mVel, dt); LOG("tick: before: h=%d", (int) mExpandedHeight); final float fh = getFullHeight(); - final boolean closing = mExpandedHeight > 0 && mVel < 0; boolean braking = false; if (BRAKES) { - if (closing) { + if (mClosing) { braking = mExpandedHeight <= mCollapseBrakingDistancePx; mAccel = braking ? 10*mCollapseAccelPx : -mCollapseAccelPx; } else { @@ -92,36 +99,40 @@ public class PanelView extends FrameLayout { mAccel = braking ? 10*-mExpandAccelPx : mExpandAccelPx; } } else { - mAccel = closing ? -mCollapseAccelPx : mExpandAccelPx; + mAccel = mClosing ? -mCollapseAccelPx : mExpandAccelPx; } mVel += mAccel * dt; if (braking) { - if (closing && mVel > -mBrakingSpeedPx) { + if (mClosing && mVel > -mBrakingSpeedPx) { mVel = -mBrakingSpeedPx; - } else if (!closing && mVel < mBrakingSpeedPx) { + } else if (!mClosing && mVel < mBrakingSpeedPx) { mVel = mBrakingSpeedPx; } } else { - if (closing && mVel > -mFlingCollapseMinVelocityPx) { + if (mClosing && mVel > -mFlingCollapseMinVelocityPx) { mVel = -mFlingCollapseMinVelocityPx; - } else if (!closing && mVel > mFlingGestureMaxOutputVelocityPx) { + } else if (!mClosing && mVel > mFlingGestureMaxOutputVelocityPx) { mVel = mFlingGestureMaxOutputVelocityPx; } } float h = mExpandedHeight + mVel * dt; + + if (mRubberbanding && h < fh) { + h = fh; + } - LOG("tick: new h=%d closing=%s", (int) h, closing?"true":"false"); + LOG("tick: new h=%d closing=%s", (int) h, mClosing?"true":"false"); setExpandedHeightInternal(h); mBar.panelExpansionChanged(PanelView.this, mExpandedFraction); if (mVel == 0 - || (closing && mExpandedHeight == 0) - || (!closing && mExpandedHeight == getFullHeight())) { + || (mClosing && mExpandedHeight == 0) + || ((mRubberbanding || !mClosing) && mExpandedHeight == fh)) { post(mStopAnimator); } } @@ -183,6 +194,7 @@ public class PanelView extends FrameLayout { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: + mTracking = true; mVelocityTracker = VelocityTracker.obtain(); trackMovement(event); mBar.onTrackingStarted(PanelView.this); @@ -190,7 +202,7 @@ public class PanelView extends FrameLayout { break; case MotionEvent.ACTION_MOVE: - PanelView.this.setExpandedHeight(rawY - mAbsPos[1] - mTouchOffset); + PanelView.this.setExpandedHeightInternal(rawY - mAbsPos[1] - mTouchOffset); mBar.panelExpansionChanged(PanelView.this, mExpandedFraction); @@ -199,6 +211,7 @@ public class PanelView extends FrameLayout { case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: + mTracking = false; mBar.onTrackingStopped(PanelView.this); trackMovement(event); mVelocityTracker.computeCurrentVelocity(1000); @@ -275,6 +288,10 @@ public class PanelView extends FrameLayout { LOG("onMeasure(%d, %d) -> (%d, %d)", widthMeasureSpec, heightMeasureSpec, getMeasuredWidth(), getMeasuredHeight()); mFullHeight = getMeasuredHeight(); + // if one of our children is getting smaller, we should track that + if (!mTracking && !mRubberbanding && !mTimeAnimator.isStarted() && mExpandedHeight > 0 && mExpandedHeight != mFullHeight) { + mExpandedHeight = mFullHeight; + } heightMeasureSpec = MeasureSpec.makeMeasureSpec( (int) mExpandedHeight, MeasureSpec.AT_MOST); // MeasureSpec.getMode(heightMeasureSpec)); setMeasuredDimension(widthMeasureSpec, heightMeasureSpec); @@ -286,17 +303,22 @@ public class PanelView extends FrameLayout { setExpandedHeightInternal(height); } + @Override + protected void onLayout (boolean changed, int left, int top, int right, int bottom) { + LOG("onLayout: changed=%s, bottom=%d eh=%d fh=%d", changed?"T":"f", bottom, (int)mExpandedHeight, (int)mFullHeight); + super.onLayout(changed, left, top, right, bottom); + } + public void setExpandedHeightInternal(float h) { float fh = getFullHeight(); if (fh == 0) { // Hmm, full height hasn't been computed yet } - LOG("setExpansion: height=%.1f fh=%.1f", h, fh); + LOG("setExpansion: height=%.1f fh=%.1f tracking=%s rubber=%s", h, fh, mTracking?"T":"f", mRubberbanding?"T":"f"); if (h < 0) h = 0; - else if (h > fh) h = fh; - + if (!(STRETCH_PAST_CONTENTS && (mTracking || mRubberbanding)) && h > fh) h = fh; mExpandedHeight = h; requestLayout(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 8884179a9a6fd..8ecfe386750f0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -109,7 +109,7 @@ public class PhoneStatusBar extends BaseStatusBar { public static final String ACTION_STATUSBAR_START = "com.android.internal.policy.statusbar.START"; - private static final boolean SHOW_CARRIER_LABEL = true; + private static final boolean SHOW_CARRIER_LABEL = false; // XXX: doesn't work with rubberband panels right now private static final int MSG_OPEN_NOTIFICATION_PANEL = 1000; private static final int MSG_CLOSE_NOTIFICATION_PANEL = 1001; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java index a42e455c2bfc5..2a96d6d679d36 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java @@ -71,7 +71,7 @@ public class PhoneStatusBarView extends PanelBar { } @Override - public boolean isEnabled() { + public boolean panelsEnabled() { return ((mBar.mDisabled & StatusBarManager.DISABLE_EXPAND) == 0); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java index e63735677ccfb..89eed1bd6138f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java @@ -78,6 +78,7 @@ public class NotificationRowLayout super(context, attrs, defStyle); mRealLayoutTransition = new LayoutTransition(); + mRealLayoutTransition.setAnimateParentHierarchy(true); setLayoutTransitionsEnabled(true); setOrientation(LinearLayout.VERTICAL); From 396efde6dabd649fce7562a281b991128eb49c73 Mon Sep 17 00:00:00 2001 From: Iliyan Malchev Date: Thu, 16 Aug 2012 12:47:21 -0700 Subject: [PATCH 6/6] Set the brightness to zero on screen-off Fixes b/6996990 Ideally, the HWC HAL should turn off the backlight when the display is turned off. This patch enforces this at the PowerManager, which can guard against errant HWC implementations. Change-Id: Ibb826a02871c983f8a68034d010e68abe9c5c1d5 Signed-off-by: Iliyan Malchev --- services/java/com/android/server/power/DisplayPowerState.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/java/com/android/server/power/DisplayPowerState.java b/services/java/com/android/server/power/DisplayPowerState.java index ad242c08fcbcb..f61872537e572 100644 --- a/services/java/com/android/server/power/DisplayPowerState.java +++ b/services/java/com/android/server/power/DisplayPowerState.java @@ -242,8 +242,8 @@ final class DisplayPowerState { mElectronBeam.draw(mElectronBeamLevel); } - if ((mDirty & DIRTY_BRIGHTNESS) != 0) { - mScreenBrightnessModulator.setBrightness(mScreenBrightness); + if ((mDirty & (DIRTY_BRIGHTNESS | DIRTY_SCREEN_ON)) != 0) { + mScreenBrightnessModulator.setBrightness(mScreenOn ? mScreenBrightness : 0); } if ((mDirty & DIRTY_SCREEN_ON) != 0 && mScreenOn) {