diff options
| -rw-r--r-- | core/java/android/preference/PreferenceScreen.java | 7 | ||||
| -rw-r--r-- | core/java/android/text/DynamicLayout.java | 10 | ||||
| -rw-r--r-- | core/java/android/text/StaticLayout.java | 10 | ||||
| -rw-r--r-- | core/java/android/view/TextureView.java | 5 | ||||
| -rw-r--r-- | core/java/android/view/View.java | 9 | ||||
| -rw-r--r-- | core/java/android/view/ViewGroup.java | 4 | ||||
| -rw-r--r-- | core/java/android/view/Window.java | 6 | ||||
| -rw-r--r-- | core/java/android/webkit/WebView.java | 2 | ||||
| -rw-r--r-- | core/java/android/widget/GridLayout.java | 141 | ||||
| -rw-r--r-- | core/java/android/widget/Space.java | 24 | ||||
| -rw-r--r-- | core/java/android/widget/TextView.java | 2 | ||||
| -rw-r--r-- | libs/hwui/TextDropShadowCache.h | 2 | ||||
| -rw-r--r-- | services/java/com/android/server/BackupManagerService.java | 10 | ||||
| -rw-r--r-- | tools/aapt/Command.cpp | 10 |
14 files changed, 164 insertions, 78 deletions
diff --git a/core/java/android/preference/PreferenceScreen.java b/core/java/android/preference/PreferenceScreen.java index dd9dd2562851..8b9945925da2 100644 --- a/core/java/android/preference/PreferenceScreen.java +++ b/core/java/android/preference/PreferenceScreen.java @@ -26,6 +26,7 @@ import android.text.TextUtils; import android.util.AttributeSet; import android.view.View; import android.view.Window; +import android.widget.AbsListView; import android.widget.Adapter; import android.widget.AdapterView; import android.widget.ListAdapter; @@ -190,9 +191,13 @@ public final class PreferenceScreen extends PreferenceGroup implements AdapterVi } public void onItemClick(AdapterView parent, View view, int position, long id) { + // If the list has headers, subtract them from the index. + if (parent instanceof ListView) { + position -= ((ListView) parent).getHeaderViewsCount(); + } Object item = getRootAdapter().getItem(position); if (!(item instanceof Preference)) return; - + final Preference preference = (Preference) item; preference.performClick(this); } diff --git a/core/java/android/text/DynamicLayout.java b/core/java/android/text/DynamicLayout.java index f82c9c4f06e8..c3a2308d9df7 100644 --- a/core/java/android/text/DynamicLayout.java +++ b/core/java/android/text/DynamicLayout.java @@ -76,7 +76,7 @@ extends Layout boolean includepad, TextUtils.TruncateAt ellipsize, int ellipsizedWidth) { this(base, display, paint, width, align, TextDirectionHeuristics.FIRSTSTRONG_LTR, - spacingmult, spacingadd, includepad, ellipsize, ellipsizedWidth); + spacingmult, spacingadd, includepad, ellipsize, ellipsizedWidth, Integer.MAX_VALUE); } /** @@ -93,7 +93,7 @@ extends Layout int width, Alignment align, TextDirectionHeuristic textDir, float spacingmult, float spacingadd, boolean includepad, - TextUtils.TruncateAt ellipsize, int ellipsizedWidth) { + TextUtils.TruncateAt ellipsize, int ellipsizedWidth, int maxLines) { super((ellipsize == null) ? display : (display instanceof Spanned) @@ -135,6 +135,8 @@ extends Layout mEllipsize = true; } + mMaxLines = maxLines; + // Initial state is a single line with 0 characters (0 to 0), // with top at 0 and bottom at whatever is natural, and // undefined ellipsis. @@ -283,7 +285,7 @@ extends Layout reflowed.generate(text, where, where + after, getPaint(), getWidth(), getAlignment(), getTextDirectionHeuristic(), getSpacingMultiplier(), getSpacingAdd(), - false, true, mEllipsizedWidth, mEllipsizeAt); + false, true, mEllipsizedWidth, mEllipsizeAt, mMaxLines); int n = reflowed.getLineCount(); // If the new layout has a blank line at the end, but it is not @@ -488,6 +490,8 @@ extends Layout private int mTopPadding, mBottomPadding; + private int mMaxLines; + private static StaticLayout sStaticLayout = new StaticLayout(null); private static final Object[] sLock = new Object[0]; diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java index 583cbe615fa4..7c273964fa5d 100644 --- a/core/java/android/text/StaticLayout.java +++ b/core/java/android/text/StaticLayout.java @@ -139,7 +139,7 @@ public class StaticLayout extends Layout { generate(source, bufstart, bufend, paint, outerwidth, align, textDir, spacingmult, spacingadd, includepad, includepad, - ellipsizedWidth, ellipsize); + ellipsizedWidth, ellipsize, mMaximumVisibleLineCount); mMeasured = MeasuredText.recycle(mMeasured); mFontMetricsInt = null; @@ -160,7 +160,7 @@ public class StaticLayout extends Layout { Alignment align, TextDirectionHeuristic textDir, float spacingmult, float spacingadd, boolean includepad, boolean trackpad, - float ellipsizedWidth, TextUtils.TruncateAt ellipsize) { + float ellipsizedWidth, TextUtils.TruncateAt ellipsize, int maxLines) { mLineCount = 0; int v = 0; @@ -477,13 +477,13 @@ public class StaticLayout extends Layout { width = restWidth; } } - if (mLineCount >= mMaximumVisibleLineCount) { + if (mLineCount >= maxLines) { break; } } } - if (paraEnd != here && mLineCount < mMaximumVisibleLineCount) { + if (paraEnd != here && mLineCount < maxLines) { if ((fitTop | fitBottom | fitDescent | fitAscent) == 0) { paint.getFontMetricsInt(fm); @@ -514,7 +514,7 @@ public class StaticLayout extends Layout { } if ((bufEnd == bufStart || source.charAt(bufEnd - 1) == CHAR_NEW_LINE) && - mLineCount < mMaximumVisibleLineCount) { + mLineCount < maxLines) { // Log.e("text", "output last " + bufEnd); paint.getFontMetricsInt(fm); diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java index c974ba19d916..d57132aef84d 100644 --- a/core/java/android/view/TextureView.java +++ b/core/java/android/view/TextureView.java @@ -250,6 +250,11 @@ public class TextureView extends View { return LAYER_TYPE_HARDWARE; } + @Override + boolean hasStaticLayer() { + return true; + } + /** * Calling this method has no effect. */ diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 2ebe756bebfa..d193d6e41504 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -10001,6 +10001,15 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal } /** + * Indicates whether this view has a static layer. A view with layer type + * {@link #LAYER_TYPE_NONE} is a static layer. Other types of layers are + * dynamic. + */ + boolean hasStaticLayer() { + return mLayerType == LAYER_TYPE_NONE; + } + + /** * Indicates what type of layer is currently associated with this view. By default * a view does not have a layer, and the layer type is {@link #LAYER_TYPE_NONE}. * Refer to the documentation of {@link #setLayerType(int, android.graphics.Paint)} diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index ddb982a1ce57..fb0d80a688e4 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -2560,8 +2560,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager final View[] children = mChildren; for (int i = 0; i < count; i++) { final View child = children[i]; - if (((child.mViewFlags & VISIBILITY_MASK) == VISIBLE || - child.getAnimation() != null) && child.getLayerType() == LAYER_TYPE_NONE) { + if (((child.mViewFlags & VISIBILITY_MASK) == VISIBLE || child.getAnimation() != null) && + child.hasStaticLayer()) { child.mRecreateDisplayList = (child.mPrivateFlags & INVALIDATED) == INVALIDATED; child.mPrivateFlags &= ~INVALIDATED; child.getDisplayList(); diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java index 75c75927a769..d0841dd2b3e7 100644 --- a/core/java/android/view/Window.java +++ b/core/java/android/view/Window.java @@ -26,6 +26,7 @@ import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; import android.os.IBinder; +import android.os.SystemProperties; import android.util.Slog; import android.view.accessibility.AccessibilityEvent; @@ -472,11 +473,14 @@ public abstract class Window { } private class LocalWindowManager extends WindowManagerImpl.CompatModeWrapper { + private static final String PROPERTY_HARDWARE_UI = "persist.sys.ui.hw"; + private final boolean mHardwareAccelerated; LocalWindowManager(WindowManager wm, boolean hardwareAccelerated) { super(wm, getCompatInfo(mContext)); - mHardwareAccelerated = hardwareAccelerated; + mHardwareAccelerated = hardwareAccelerated || + SystemProperties.getBoolean(PROPERTY_HARDWARE_UI, false); } public boolean isHardwareAccelerated() { diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 530b230b348b..370cce40b704 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -4308,7 +4308,7 @@ public class WebView extends AbsoluteLayout selectionDone(); } mOrientation = newConfig.orientation; - contentInvalidateAll(); + mWebViewCore.sendMessage(EventHub.CLEAR_CONTENT); } /** diff --git a/core/java/android/widget/GridLayout.java b/core/java/android/widget/GridLayout.java index ba692885a768..fb9047b35b28 100644 --- a/core/java/android/widget/GridLayout.java +++ b/core/java/android/widget/GridLayout.java @@ -850,32 +850,65 @@ public class GridLayout extends ViewGroup { return c.getVisibility() == View.GONE; } - private void measureChildWithMargins(View child, int widthMeasureSpec, int heightMeasureSpec) { - LayoutParams lp = getLayoutParams(child); - int childWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec, - mPaddingLeft + mPaddingRight + getTotalMargin(child, true), lp.width); - int childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec, - mPaddingTop + mPaddingBottom + getTotalMargin(child, false), lp.height); - child.measure(childWidthMeasureSpec, childHeightMeasureSpec); + private void measureChildWithMargins2(View child, int parentWidthSpec, int parentHeightSpec, + int childWidth, int childHeight) { + int childWidthSpec = getChildMeasureSpec(parentWidthSpec, + mPaddingLeft + mPaddingRight + getTotalMargin(child, true), childWidth); + int childHeightSpec = getChildMeasureSpec(parentHeightSpec, + mPaddingTop + mPaddingBottom + getTotalMargin(child, false), childHeight); + child.measure(childWidthSpec, childHeightSpec); } - private void measureChildrenWithMargins(int widthMeasureSpec, int heightMeasureSpec) { + private void measureChildrenWithMargins(int widthSpec, int heightSpec, boolean firstPass) { for (int i = 0, N = getChildCount(); i < N; i++) { View c = getChildAt(i); if (isGone(c)) continue; - measureChildWithMargins(c, widthMeasureSpec, heightMeasureSpec); + LayoutParams lp = getLayoutParams(c); + if (firstPass) { + measureChildWithMargins2(c, widthSpec, heightSpec, lp.width, lp.height); + } else { + Spec spec = (orientation == HORIZONTAL) ? lp.columnSpec : lp.rowSpec; + if (spec.alignment == FILL) { + Interval span = spec.span; + Axis axis = (orientation == HORIZONTAL) ? horizontalAxis : verticalAxis; + int[] locations = axis.getLocations(); + int size = locations[span.max] - locations[span.min]; + if (orientation == HORIZONTAL) { + measureChildWithMargins2(c, widthSpec, heightSpec, size, lp.height); + } else { + measureChildWithMargins2(c, widthSpec, heightSpec, lp.width, size); + } + } + } } } @Override protected void onMeasure(int widthSpec, int heightSpec) { - measureChildrenWithMargins(widthSpec, heightSpec); + /** If we have been called by {@link View#measure(int, int)}, one of width or height + * is likely to have changed. We must invalidate if so. */ + invalidateValues(); + + measureChildrenWithMargins(widthSpec, heightSpec, true); + + int width, height; + + // Use the orientation property to decide which axis should be laid out first. + if (orientation == HORIZONTAL) { + width = horizontalAxis.getMeasure(widthSpec); + measureChildrenWithMargins(widthSpec, heightSpec, false); + height = verticalAxis.getMeasure(heightSpec); + } else { + height = verticalAxis.getMeasure(heightSpec); + measureChildrenWithMargins(widthSpec, heightSpec, false); + width = horizontalAxis.getMeasure(widthSpec); + } - int width = getPaddingLeft() + horizontalAxis.getMeasure(widthSpec) + getPaddingRight(); - int height = getPaddingTop() + verticalAxis.getMeasure(heightSpec) + getPaddingBottom(); + int hPadding = getPaddingLeft() + getPaddingRight(); + int vPadding = getPaddingTop() + getPaddingBottom(); - int measuredWidth = Math.max(width, getSuggestedMinimumWidth()); - int measuredHeight = Math.max(height, getSuggestedMinimumHeight()); + int measuredWidth = Math.max(hPadding + width, getSuggestedMinimumWidth()); + int measuredHeight = Math.max(vPadding + height, getSuggestedMinimumHeight()); setMeasuredDimension( resolveSizeAndState(measuredWidth, widthSpec, 0), @@ -1015,8 +1048,6 @@ public class GridLayout extends ViewGroup { for the vertical one. */ final class Axis { - private static final int MIN_VALUE = -1000000; - private static final int NEW = 0; private static final int PENDING = 1; private static final int COMPLETE = 2; @@ -1024,7 +1055,7 @@ public class GridLayout extends ViewGroup { public final boolean horizontal; public int definedCount = UNDEFINED; - private int inferredCount = UNDEFINED; + private int maxIndex = UNDEFINED; PackedMap<Spec, Bounds> groupBounds; public boolean groupBoundsValid = false; @@ -1056,28 +1087,29 @@ public class GridLayout extends ViewGroup { this.horizontal = horizontal; } - private int maxIndex() { - // note the number Integer.MIN_VALUE + 1 comes up in undefined cells - int count = -1; + private int calculateMaxIndex() { + // the number Integer.MIN_VALUE + 1 comes up in undefined cells + int result = -1; for (int i = 0, N = getChildCount(); i < N; i++) { View c = getChildAt(i); LayoutParams params = getLayoutParams(c); Spec spec = horizontal ? params.columnSpec : params.rowSpec; - count = max(count, spec.span.min); - count = max(count, spec.span.max); + Interval span = spec.span; + result = max(result, span.min); + result = max(result, span.max); } - return count == -1 ? UNDEFINED : count; + return result == -1 ? UNDEFINED : result; } - private int getInferredCount() { - if (inferredCount == UNDEFINED) { - inferredCount = max(0, maxIndex()); // if there are no cells, actual count is zero + private int getMaxIndex() { + if (maxIndex == UNDEFINED) { + maxIndex = max(0, calculateMaxIndex()); // use zero when there are no children } - return inferredCount; + return maxIndex; } public int getCount() { - return max(definedCount, getInferredCount()); + return max(definedCount, getMaxIndex()); } public void setCount(int count) { @@ -1179,7 +1211,7 @@ public class GridLayout extends ViewGroup { } private void include(List<Arc> arcs, Interval key, MutableInt size, - boolean ignoreIfAlreadyPresent) { + boolean ignoreIfAlreadyPresent) { /* Remove self referential links. These appear: @@ -1341,19 +1373,18 @@ public class GridLayout extends ViewGroup { } private void init(int[] locations) { - Arrays.fill(locations, MIN_VALUE); - locations[0] = 0; + Arrays.fill(locations, 0); } private String arcsToString(List<Arc> arcs) { - String var = horizontal ? "c" : "r"; + String var = horizontal ? "x" : "y"; StringBuilder result = new StringBuilder(); - boolean first = false; - for(Arc arc : arcs) { - if (!first) { - first = true; + boolean first = true; + for (Arc arc : arcs) { + if (first) { + first = false; } else { - result =result.append(", "); + result = result.append(", "); } int src = arc.span.min; int dst = arc.span.max; @@ -1434,10 +1465,6 @@ public class GridLayout extends ViewGroup { if (originalCulprits != null) { logError(axisName, arcs, originalCulprits); } - if (DEBUG) { - Log.v(TAG, axisName + " iteration completed in " + - (1 + i) + " steps of " + N); - } return; } } @@ -1506,6 +1533,18 @@ public class GridLayout extends ViewGroup { private void computeLocations(int[] a) { solve(getArcs(), a); + if (!orderPreserved) { + // Solve returns the smallest solution to the constraint system for which all + // values are positive. One value is therefore zero - though if the row/col + // order is not preserved this may not be the first vertex. For consistency, + // translate all the values so that they measure the distance from a[0]; the + // leading edge of the parent. After this transformation some values may be + // negative. + int a0 = a[0]; + for (int i = 0, N = a.length; i < N; i++) { + a[i] = a[i] - a0; + } + } } public int[] getLocations() { @@ -1521,7 +1560,10 @@ public class GridLayout extends ViewGroup { } private int size(int[] locations) { - return max2(locations, 0) - locations[0]; + // The parental edges are attached to vertices 0 and N - even when order is not + // being preserved and other vertices fall outside this range. Measure the distance + // between vertices 0 and N, assuming that locations[0] = 0. + return locations[getCount()]; } private void setParentConstraints(int min, int max) { @@ -1561,7 +1603,7 @@ public class GridLayout extends ViewGroup { } public void invalidateStructure() { - inferredCount = UNDEFINED; + maxIndex = UNDEFINED; groupBounds = null; forwardLinks = null; @@ -2139,8 +2181,8 @@ public class GridLayout extends ViewGroup { /** * A Spec defines the horizontal or vertical characteristics of a group of - * cells. Each spec. defines the <em>grid indices</em>, <em>alignment</em> and - * <em>flexibility</em> along the appropriate axis. + * cells. Each spec. defines the <em>grid indices</em> and <em>alignment</em> + * along the appropriate axis. * <p> * The <em>grid indices</em> are the leading and trailing edges of this cell group. * See {@link GridLayout} for a description of the conventions used by GridLayout @@ -2149,6 +2191,15 @@ public class GridLayout extends ViewGroup { * The <em>alignment</em> property specifies how cells should be aligned in this group. * For row groups, this specifies the vertical alignment. * For column groups, this specifies the horizontal alignment. + * <p> + * Use the following static methods to create specs: + * <ul> + * <li>{@link #spec(int)}</li> + * <li>{@link #spec(int, int)}</li> + * <li>{@link #spec(int, Alignment)}</li> + * <li>{@link #spec(int, int, Alignment)}</li> + * </ul> + * */ public static class Spec { static final Spec UNDEFINED = spec(GridLayout.UNDEFINED); diff --git a/core/java/android/widget/Space.java b/core/java/android/widget/Space.java index d7b2ec27fee4..bb53a7732f10 100644 --- a/core/java/android/widget/Space.java +++ b/core/java/android/widget/Space.java @@ -32,20 +32,24 @@ public final class Space extends View { */ public Space(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); + if (getVisibility() == VISIBLE) { + setVisibility(INVISIBLE); + } } /** * {@inheritDoc} */ public Space(Context context, AttributeSet attrs) { - super(context, attrs); + this(context, attrs, 0); } /** * {@inheritDoc} */ public Space(Context context) { - super(context); + //noinspection NullableProblems + this(context, null); } /** @@ -58,22 +62,6 @@ public final class Space extends View { } /** - * {@inheritDoc} - */ - @Override - public ViewGroup.LayoutParams getLayoutParams() { - return super.getLayoutParams(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setLayoutParams(ViewGroup.LayoutParams params) { - super.setLayoutParams(params); - } - - /** * Compare to: {@link View#getDefaultSize(int, int)} * If mode is AT_MOST, return the child size instead of the parent size * (unless it is too big). diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index cde36c83ee9c..3624ac168425 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -6253,7 +6253,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener result = new DynamicLayout(mText, mTransformed, mTextPaint, w, alignment, mTextDir, mSpacingMult, mSpacingAdd, mIncludePad, mInput == null ? effectiveEllipsize : null, - ellipsisWidth); + ellipsisWidth, mMaxMode == LINES ? mMaximum : Integer.MAX_VALUE); } else { if (boring == UNKNOWN_BORING) { boring = BoringLayout.isBoring(mTransformed, mTextPaint, mTextDir, mBoring); diff --git a/libs/hwui/TextDropShadowCache.h b/libs/hwui/TextDropShadowCache.h index 28dba13dec35..e2bdde1eca89 100644 --- a/libs/hwui/TextDropShadowCache.h +++ b/libs/hwui/TextDropShadowCache.h @@ -81,7 +81,7 @@ struct ShadowText { LTE_INT(flags) { LTE_INT(italicStyle) { LTE_INT(scaleX) { - return strncmp16(text, rhs.text, len >> 1) < 0; + return memcmp(text, rhs.text, len) < 0; } } } diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java index e30ce72e5790..fe49cd2bd4c8 100644 --- a/services/java/com/android/server/BackupManagerService.java +++ b/services/java/com/android/server/BackupManagerService.java @@ -5596,6 +5596,16 @@ class BackupManagerService extends IBackupManager.Stub { } private void dumpInternal(PrintWriter pw) { + if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) + != PackageManager.PERMISSION_GRANTED) { + pw.println("Permission Denial: can't dump Backup Manager service from from pid=" + + Binder.getCallingPid() + + ", uid=" + Binder.getCallingUid() + + " without permission " + + android.Manifest.permission.DUMP); + return; + } + synchronized (mQueueLock) { pw.println("Backup Manager is " + (mEnabled ? "enabled" : "disabled") + " / " + (!mProvisioned ? "not " : "") + "provisioned / " diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp index 178e7fdcffd3..413a2dcf3768 100644 --- a/tools/aapt/Command.cpp +++ b/tools/aapt/Command.cpp @@ -368,6 +368,7 @@ enum { REQUIRES_SMALLEST_WIDTH_DP_ATTR = 0x01010364, COMPATIBLE_WIDTH_LIMIT_DP_ATTR = 0x01010365, LARGEST_WIDTH_LIMIT_DP_ATTR = 0x01010366, + PUBLIC_KEY_ATTR = 0x010103a6, }; const char *getComponentName(String8 &pkgName, String8 &componentName) { @@ -1021,6 +1022,15 @@ int doDump(Bundle* bundle) } else if (tag == "compatible-screens") { printCompatibleScreens(tree); depth--; + } else if (tag == "package-verifier") { + String8 name = getAttribute(tree, NAME_ATTR, &error); + if (name != "" && error == "") { + String8 publicKey = getAttribute(tree, PUBLIC_KEY_ATTR, &error); + if (publicKey != "" && error == "") { + printf("package-verifier: name='%s' publicKey='%s'\n", + name.string(), publicKey.string()); + } + } } } else if (depth == 3 && withinApplication) { withinActivity = false; |