diff options
32 files changed, 354 insertions, 351 deletions
diff --git a/api/current.txt b/api/current.txt index 18b29d32236f..6cef3a767354 100644 --- a/api/current.txt +++ b/api/current.txt @@ -183,19 +183,19 @@ package android { public static final class R.attr { ctor public R.attr(); field public static final int absListViewStyle = 16842858; // 0x101006a - field public static final int accessibilityEventTypes = 16843646; // 0x101037e - field public static final int accessibilityFeedbackType = 16843648; // 0x1010380 - field public static final int accessibilityFlags = 16843650; // 0x1010382 + field public static final int accessibilityEventTypes = 16843644; // 0x101037c + field public static final int accessibilityFeedbackType = 16843646; // 0x101037e + field public static final int accessibilityFlags = 16843648; // 0x1010380 field public static final int accountPreferences = 16843423; // 0x101029f field public static final int accountType = 16843407; // 0x101028f field public static final int action = 16842797; // 0x101002d field public static final int actionBarSize = 16843499; // 0x10102eb - field public static final int actionBarSplitStyle = 16843668; // 0x1010394 + field public static final int actionBarSplitStyle = 16843666; // 0x1010392 field public static final int actionBarStyle = 16843470; // 0x10102ce field public static final int actionBarTabBarStyle = 16843508; // 0x10102f4 field public static final int actionBarTabStyle = 16843507; // 0x10102f3 field public static final int actionBarTabTextStyle = 16843509; // 0x10102f5 - field public static final int actionBarWidgetTheme = 16843683; // 0x10103a3 + field public static final int actionBarWidgetTheme = 16843681; // 0x10103a1 field public static final int actionButtonStyle = 16843480; // 0x10102d8 field public static final int actionDropDownStyle = 16843479; // 0x10102d7 field public static final int actionLayout = 16843515; // 0x10102fb @@ -207,10 +207,10 @@ package android { field public static final int actionModeCopyDrawable = 16843538; // 0x1010312 field public static final int actionModeCutDrawable = 16843537; // 0x1010311 field public static final int actionModePasteDrawable = 16843539; // 0x1010313 - field public static final int actionModeSelectAllDrawable = 16843644; // 0x101037c - field public static final int actionModeStyle = 16843680; // 0x10103a0 + field public static final int actionModeSelectAllDrawable = 16843642; // 0x101037a + field public static final int actionModeStyle = 16843678; // 0x101039e field public static final int actionOverflowButtonStyle = 16843510; // 0x10102f6 - field public static final int actionProviderClass = 16843669; // 0x1010395 + field public static final int actionProviderClass = 16843667; // 0x1010393 field public static final int actionViewClass = 16843516; // 0x10102fc field public static final int activatedBackgroundIndicator = 16843517; // 0x10102fd field public static final int activityCloseEnterAnimation = 16842938; // 0x10100ba @@ -256,8 +256,8 @@ package android { field public static final int background = 16842964; // 0x10100d4 field public static final int backgroundDimAmount = 16842802; // 0x1010032 field public static final int backgroundDimEnabled = 16843295; // 0x101021f - field public static final int backgroundSplit = 16843671; // 0x1010397 - field public static final int backgroundStacked = 16843670; // 0x1010396 + field public static final int backgroundSplit = 16843669; // 0x1010395 + field public static final int backgroundStacked = 16843668; // 0x1010394 field public static final int backupAgent = 16843391; // 0x101027f field public static final int baseline = 16843548; // 0x101031c field public static final int baselineAlignBottom = 16843042; // 0x1010122 @@ -266,7 +266,7 @@ package android { field public static final int borderlessButtonStyle = 16843563; // 0x101032b field public static final int bottom = 16843184; // 0x10101b0 field public static final int bottomBright = 16842957; // 0x10100cd - field public static final int bottomChevronDrawable = 16843657; // 0x1010389 + field public static final int bottomChevronDrawable = 16843655; // 0x1010387 field public static final int bottomDark = 16842953; // 0x10100c9 field public static final int bottomLeftRadius = 16843179; // 0x10101ab field public static final int bottomMedium = 16842958; // 0x10100ce @@ -285,7 +285,7 @@ package android { field public static final int cacheColorHint = 16843009; // 0x1010101 field public static final int calendarViewShown = 16843596; // 0x101034c field public static final int calendarViewStyle = 16843613; // 0x101035d - field public static final int canRetrieveWindowContent = 16843651; // 0x1010383 + field public static final int canRetrieveWindowContent = 16843649; // 0x1010381 field public static final int candidatesTextStyleSpans = 16843312; // 0x1010230 field public static final deprecated int capitalize = 16843113; // 0x1010169 field public static final int centerBright = 16842956; // 0x10100cc @@ -314,15 +314,15 @@ package android { field public static final int codes = 16843330; // 0x1010242 field public static final int collapseColumns = 16843083; // 0x101014b field public static final int color = 16843173; // 0x10101a5 - field public static final int colorActivatedHighlight = 16843676; // 0x101039c + field public static final int colorActivatedHighlight = 16843674; // 0x101039a field public static final int colorBackground = 16842801; // 0x1010031 field public static final int colorBackgroundCacheHint = 16843435; // 0x10102ab - field public static final int colorFocusedHighlight = 16843675; // 0x101039b + field public static final int colorFocusedHighlight = 16843673; // 0x1010399 field public static final int colorForeground = 16842800; // 0x1010030 field public static final int colorForegroundInverse = 16843270; // 0x1010206 - field public static final int colorLongPressedHighlight = 16843674; // 0x101039a - field public static final int colorMultiSelectHighlight = 16843677; // 0x101039d - field public static final int colorPressedHighlight = 16843673; // 0x1010399 + field public static final int colorLongPressedHighlight = 16843672; // 0x1010398 + field public static final int colorMultiSelectHighlight = 16843675; // 0x101039b + field public static final int colorPressedHighlight = 16843671; // 0x1010397 field public static final int columnCount = 16843635; // 0x1010373 field public static final int columnDelay = 16843215; // 0x10101cf field public static final int columnOrderPreserved = 16843636; // 0x1010374 @@ -379,11 +379,11 @@ package android { field public static final int drawSelectorOnTop = 16843004; // 0x10100fc field public static final int drawable = 16843161; // 0x1010199 field public static final int drawableBottom = 16843118; // 0x101016e - field public static final int drawableEnd = 16843679; // 0x101039f + field public static final int drawableEnd = 16843677; // 0x101039d field public static final int drawableLeft = 16843119; // 0x101016f field public static final int drawablePadding = 16843121; // 0x1010171 field public static final int drawableRight = 16843120; // 0x1010170 - field public static final int drawableStart = 16843678; // 0x101039e + field public static final int drawableStart = 16843676; // 0x101039c field public static final int drawableTop = 16843117; // 0x101016d field public static final int drawingCacheQuality = 16842984; // 0x10100e8 field public static final int dropDownAnchor = 16843363; // 0x1010263 @@ -440,7 +440,7 @@ package android { field public static final int fastScrollTextColor = 16843609; // 0x1010359 field public static final int fastScrollThumbDrawable = 16843574; // 0x1010336 field public static final int fastScrollTrackDrawable = 16843577; // 0x1010339 - field public static final int feedbackCount = 16843663; // 0x101038f + field public static final int feedbackCount = 16843661; // 0x101038d field public static final int fillAfter = 16843197; // 0x10101bd field public static final int fillBefore = 16843196; // 0x10101bc field public static final int fillEnabled = 16843343; // 0x101024f @@ -493,7 +493,7 @@ package android { field public static final int hand_hour = 16843011; // 0x1010103 field public static final int hand_minute = 16843012; // 0x1010104 field public static final int handle = 16843354; // 0x101025a - field public static final int handleDrawable = 16843653; // 0x1010385 + field public static final int handleDrawable = 16843651; // 0x1010383 field public static final int handleProfiling = 16842786; // 0x1010022 field public static final int hapticFeedbackEnabled = 16843358; // 0x101025e field public static final int hardwareAccelerated = 16843475; // 0x10102d3 @@ -502,12 +502,12 @@ package android { field public static final int headerDividersEnabled = 16843310; // 0x101022e field public static final int height = 16843093; // 0x1010155 field public static final int hint = 16843088; // 0x1010150 - field public static final int hitRadius = 16843660; // 0x101038c + field public static final int hitRadius = 16843658; // 0x101038a field public static final int homeAsUpIndicator = 16843531; // 0x101030b field public static final int homeLayout = 16843549; // 0x101031d field public static final int horizontalDivider = 16843053; // 0x101012d field public static final int horizontalGap = 16843327; // 0x101023f - field public static final int horizontalOffset = 16843665; // 0x1010391 + field public static final int horizontalOffset = 16843663; // 0x101038f field public static final int horizontalScrollViewStyle = 16843603; // 0x1010353 field public static final int horizontalSpacing = 16843028; // 0x1010114 field public static final int host = 16842792; // 0x1010028 @@ -553,7 +553,7 @@ package android { field public static final int installLocation = 16843447; // 0x10102b7 field public static final int interpolator = 16843073; // 0x1010141 field public static final int isAlwaysSyncable = 16843571; // 0x1010333 - field public static final int isAuxiliary = 16843645; // 0x101037d + field public static final int isAuxiliary = 16843643; // 0x101037b field public static final int isDefault = 16843297; // 0x1010221 field public static final int isIndicator = 16843079; // 0x1010147 field public static final int isModifier = 16843334; // 0x1010246 @@ -606,8 +606,7 @@ package android { field public static final int layout_centerInParent = 16843151; // 0x101018f field public static final int layout_centerVertical = 16843153; // 0x1010191 field public static final int layout_column = 16843084; // 0x101014c - field public static final deprecated int layout_columnFlexibility = 16843643; // 0x101037b - field public static final int layout_columnSpan = 16843642; // 0x101037a + field public static final int layout_columnSpan = 16843641; // 0x1010379 field public static final int layout_gravity = 16842931; // 0x10100b3 field public static final int layout_height = 16842997; // 0x10100f5 field public static final int layout_margin = 16842998; // 0x10100f6 @@ -616,7 +615,6 @@ package android { field public static final int layout_marginRight = 16843001; // 0x10100f9 field public static final int layout_marginTop = 16843000; // 0x10100f8 field public static final int layout_row = 16843639; // 0x1010377 - field public static final deprecated int layout_rowFlexibility = 16843641; // 0x1010379 field public static final int layout_rowSpan = 16843640; // 0x1010378 field public static final int layout_scale = 16843155; // 0x1010193 field public static final int layout_span = 16843085; // 0x101014d @@ -627,7 +625,7 @@ package android { field public static final int layout_x = 16843135; // 0x101017f field public static final int layout_y = 16843136; // 0x1010180 field public static final int left = 16843181; // 0x10101ad - field public static final int leftChevronDrawable = 16843654; // 0x1010386 + field public static final int leftChevronDrawable = 16843652; // 0x1010384 field public static final int lineSpacingExtra = 16843287; // 0x1010217 field public static final int lineSpacingMultiplier = 16843288; // 0x1010218 field public static final int lines = 16843092; // 0x1010154 @@ -639,8 +637,8 @@ package android { field public static final int listDividerAlertDialog = 16843525; // 0x1010305 field public static final int listPopupWindowStyle = 16843519; // 0x10102ff field public static final int listPreferredItemHeight = 16842829; // 0x101004d - field public static final int listPreferredItemHeightLarge = 16843666; // 0x1010392 - field public static final int listPreferredItemHeightSmall = 16843667; // 0x1010393 + field public static final int listPreferredItemHeightLarge = 16843664; // 0x1010390 + field public static final int listPreferredItemHeightSmall = 16843665; // 0x1010391 field public static final int listSelector = 16843003; // 0x10100fb field public static final int listSeparatorTextViewStyle = 16843272; // 0x1010208 field public static final int listViewStyle = 16842868; // 0x1010074 @@ -671,8 +669,8 @@ package android { field public static final int minHeight = 16843072; // 0x1010140 field public static final int minLevel = 16843185; // 0x10101b1 field public static final int minLines = 16843094; // 0x1010156 - field public static final int minResizeHeight = 16843682; // 0x10103a2 - field public static final int minResizeWidth = 16843681; // 0x10103a1 + field public static final int minResizeHeight = 16843680; // 0x10103a0 + field public static final int minResizeWidth = 16843679; // 0x101039f field public static final int minSdkVersion = 16843276; // 0x101020c field public static final int minWidth = 16843071; // 0x101013f field public static final int mode = 16843134; // 0x101017e @@ -688,7 +686,7 @@ package android { field public static final int nextFocusUp = 16842979; // 0x10100e3 field public static final int noHistory = 16843309; // 0x101022d field public static final int normalScreens = 16843397; // 0x1010285 - field public static final int notificationTimeout = 16843649; // 0x1010381 + field public static final int notificationTimeout = 16843647; // 0x101037f field public static final int numColumns = 16843032; // 0x1010118 field public static final int numStars = 16843076; // 0x1010144 field public static final deprecated int numeric = 16843109; // 0x1010165 @@ -702,11 +700,11 @@ package android { field public static final int orderingFromXml = 16843239; // 0x10101e7 field public static final int orientation = 16842948; // 0x10100c4 field public static final int outAnimation = 16843128; // 0x1010178 - field public static final int outerRadius = 16843659; // 0x101038b + field public static final int outerRadius = 16843657; // 0x1010389 field public static final int overScrollFooter = 16843459; // 0x10102c3 field public static final int overScrollHeader = 16843458; // 0x10102c2 field public static final int overScrollMode = 16843457; // 0x10102c1 - field public static final int packageNames = 16843647; // 0x101037f + field public static final int packageNames = 16843645; // 0x101037d field public static final int padding = 16842965; // 0x10100d5 field public static final int paddingBottom = 16842969; // 0x10100d9 field public static final int paddingLeft = 16842966; // 0x10100d6 @@ -791,7 +789,7 @@ package android { field public static final int restoreAnyVersion = 16843450; // 0x10102ba field public static final deprecated int restoreNeedsApplication = 16843421; // 0x101029d field public static final int right = 16843183; // 0x10101af - field public static final int rightChevronDrawable = 16843655; // 0x1010387 + field public static final int rightChevronDrawable = 16843653; // 0x1010385 field public static final int ringtonePreferenceStyle = 16842899; // 0x1010093 field public static final int ringtoneType = 16843257; // 0x10101f9 field public static final int rotation = 16843558; // 0x1010326 @@ -867,7 +865,7 @@ package android { field public static final int smallIcon = 16843422; // 0x101029e field public static final int smallScreens = 16843396; // 0x1010284 field public static final int smoothScrollbar = 16843313; // 0x1010231 - field public static final int snapMargin = 16843662; // 0x101038e + field public static final int snapMargin = 16843660; // 0x101038c field public static final int soundEffectsEnabled = 16843285; // 0x1010215 field public static final int spacing = 16843027; // 0x1010113 field public static final int spinnerDropDownItemStyle = 16842887; // 0x1010087 @@ -932,7 +930,7 @@ package android { field public static final int tag = 16842961; // 0x10100d1 field public static final int targetActivity = 16843266; // 0x1010202 field public static final int targetClass = 16842799; // 0x101002f - field public static final int targetDrawables = 16843652; // 0x1010384 + field public static final int targetDrawables = 16843650; // 0x1010382 field public static final int targetPackage = 16842785; // 0x1010021 field public static final int targetSdkVersion = 16843376; // 0x1010270 field public static final int taskAffinity = 16842770; // 0x1010012 @@ -947,7 +945,7 @@ package android { field public static final int tension = 16843370; // 0x101026a field public static final int testOnly = 16843378; // 0x1010272 field public static final int text = 16843087; // 0x101014f - field public static final int textAllCaps = 16843672; // 0x1010398 + field public static final int textAllCaps = 16843670; // 0x1010396 field public static final int textAppearance = 16842804; // 0x1010034 field public static final int textAppearanceButton = 16843271; // 0x1010207 field public static final int textAppearanceInverse = 16842805; // 0x1010035 @@ -1021,7 +1019,7 @@ package android { field public static final int toYScale = 16843205; // 0x10101c5 field public static final int top = 16843182; // 0x10101ae field public static final int topBright = 16842955; // 0x10100cb - field public static final int topChevronDrawable = 16843656; // 0x1010388 + field public static final int topChevronDrawable = 16843654; // 0x1010386 field public static final int topDark = 16842951; // 0x10100c7 field public static final int topLeftRadius = 16843177; // 0x10101a9 field public static final int topOffset = 16843352; // 0x1010258 @@ -1051,10 +1049,10 @@ package android { field public static final int verticalCorrection = 16843322; // 0x101023a field public static final int verticalDivider = 16843054; // 0x101012e field public static final int verticalGap = 16843328; // 0x1010240 - field public static final int verticalOffset = 16843664; // 0x1010390 + field public static final int verticalOffset = 16843662; // 0x101038e field public static final int verticalScrollbarPosition = 16843572; // 0x1010334 field public static final int verticalSpacing = 16843029; // 0x1010115 - field public static final int vibrationDuration = 16843661; // 0x101038d + field public static final int vibrationDuration = 16843659; // 0x101038b field public static final int visibility = 16842972; // 0x10100dc field public static final int visible = 16843156; // 0x1010194 field public static final int vmSafeMode = 16843448; // 0x10102b8 @@ -1071,7 +1069,7 @@ package android { field public static final int wallpaperIntraOpenExitAnimation = 16843416; // 0x1010298 field public static final int wallpaperOpenEnterAnimation = 16843411; // 0x1010293 field public static final int wallpaperOpenExitAnimation = 16843412; // 0x1010294 - field public static final int waveDrawable = 16843658; // 0x101038a + field public static final int waveDrawable = 16843656; // 0x1010388 field public static final int webTextViewStyle = 16843449; // 0x10102b9 field public static final int webViewStyle = 16842885; // 0x1010085 field public static final int weekDayTextAppearance = 16843592; // 0x1010348 diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 8931675dd914..c56610493825 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -2503,6 +2503,7 @@ public final class ActivityThread { mAvailThumbnailBitmap = thumbnail; thumbnail = null; } + cv.setBitmap(null); } } catch (Exception e) { diff --git a/core/java/android/app/LauncherActivity.java b/core/java/android/app/LauncherActivity.java index 7b9bd600f632..8eb9ba48b98e 100644 --- a/core/java/android/app/LauncherActivity.java +++ b/core/java/android/app/LauncherActivity.java @@ -314,6 +314,7 @@ public abstract class LauncherActivity extends ListActivity { icon.draw(canvas); icon.setBounds(mOldBounds); icon = new BitmapDrawable(getResources(), thumb); + canvas.setBitmap(null); } else if (iconWidth < width && iconHeight < height) { final Bitmap.Config c = Bitmap.Config.ARGB_8888; final Bitmap thumb = Bitmap.createBitmap(mIconWidth, mIconHeight, c); @@ -326,6 +327,7 @@ public abstract class LauncherActivity extends ListActivity { icon.draw(canvas); icon.setBounds(mOldBounds); icon = new BitmapDrawable(getResources(), thumb); + canvas.setBitmap(null); } } diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 935281a534c0..ad769288d014 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -10221,6 +10221,7 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit } canvas.restoreToCount(restoreCount); + canvas.setBitmap(null); if (attachInfo != null) { // Restore the cached Canvas for our siblings @@ -10289,9 +10290,9 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit mPrivateFlags = flags; canvas.restoreToCount(restoreCount); + canvas.setBitmap(null); if (attachInfo != null) { - canvas.setBitmap(null); // Restore the cached Canvas for our siblings attachInfo.mCanvas = canvas; } diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java index dbcbd6e5ae1f..95209581f7c5 100644 --- a/core/java/android/view/ViewConfiguration.java +++ b/core/java/android/view/ViewConfiguration.java @@ -220,6 +220,7 @@ public class ViewConfiguration { private final int mMaximumDrawingCacheSize; private final int mOverscrollDistance; private final int mOverflingDistance; + private final boolean mFadingMarqueeEnabled; private boolean sHasPermanentMenuKey; private boolean sHasPermanentMenuKeySet; @@ -246,6 +247,7 @@ public class ViewConfiguration { mMaximumDrawingCacheSize = MAXIMUM_DRAWING_CACHE_SIZE; mOverscrollDistance = OVERSCROLL_DISTANCE; mOverflingDistance = OVERFLING_DISTANCE; + mFadingMarqueeEnabled = true; } /** @@ -297,6 +299,9 @@ public class ViewConfiguration { sHasPermanentMenuKey = false; } } + + mFadingMarqueeEnabled = res.getBoolean( + com.android.internal.R.bool.config_ui_enableFadingMarquee); } /** @@ -673,4 +678,12 @@ public class ViewConfiguration { public boolean hasPermanentMenuKey() { return sHasPermanentMenuKey; } + + /** + * @hide + * @return Whether or not marquee should use fading edges. + */ + public boolean isFadingMarqueeEnabled() { + return mFadingMarqueeEnabled; + } } diff --git a/core/java/android/view/ViewDebug.java b/core/java/android/view/ViewDebug.java index 96e550e16c55..65e72c9c8123 100644 --- a/core/java/android/view/ViewDebug.java +++ b/core/java/android/view/ViewDebug.java @@ -1094,6 +1094,9 @@ public class ViewDebug { } public void post(Object... data) { + if (data[1] != null) { + ((Canvas) data[1]).setBitmap(null); + } if (data[0] != null) { ((Bitmap) data[0]).recycle(); } diff --git a/core/java/android/widget/GridLayout.java b/core/java/android/widget/GridLayout.java index f999960219da..f354c6ecd9e8 100644 --- a/core/java/android/widget/GridLayout.java +++ b/core/java/android/widget/GridLayout.java @@ -32,12 +32,13 @@ import com.android.internal.R; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import static android.view.Gravity.*; +import static android.view.View.MeasureSpec.EXACTLY; +import static android.view.View.MeasureSpec.makeMeasureSpec; import static java.lang.Math.max; import static java.lang.Math.min; @@ -92,8 +93,21 @@ import static java.lang.Math.min; * * <h4>Excess Space Distribution</h4> * - * A child's ability to stretch is controlled using the flexibility - * properties of its row and column groups. + * A child's ability to stretch is inferred from the alignment properties of + * its row and column groups (which are typically set by setting the + * {@link LayoutParams#setGravity(int) gravity} property of the child's layout parameters). + * If alignment was defined along a given axis then the component + * is taken as flexible in along that axis. If no alignment was set, + * the component is instead assumed to be inflexible. Multiple components in + * the same row or column group are considered to act in <em>parallel</em>. Such a + * group is flexible only if <em>all</em> of the components + * within it are flexible. Row and column groups that sit either side of a common boundary + * are instead considered to act in <em>series</em>. The composite group made of these two + * elements is flexible if <em>one</em> of its elements is flexible. + * <p> + * To make a column stretch, make sure all of the components inside it define a + * gravity. To prevent a column from stretching, ensure that one of the components + * in the column does not define a gravity. * <p> * <p> * See {@link GridLayout.LayoutParams} for a full description of the @@ -175,7 +189,7 @@ public class GridLayout extends ViewGroup { private static final int DEFAULT_ORIENTATION = HORIZONTAL; private static final int DEFAULT_COUNT = UNDEFINED; private static final boolean DEFAULT_USE_DEFAULT_MARGINS = false; - private static final boolean DEFAULT_ORDER_PRESERVED = false; + private static final boolean DEFAULT_ORDER_PRESERVED = true; private static final int DEFAULT_ALIGNMENT_MODE = ALIGN_MARGINS; private static final int DEFAULT_CONTAINER_MARGIN = 0; private static final int MAX_SIZE = 100000; @@ -198,8 +212,6 @@ public class GridLayout extends ViewGroup { private int mOrientation = DEFAULT_ORIENTATION; private boolean mUseDefaultMargins = DEFAULT_USE_DEFAULT_MARGINS; private int mAlignmentMode = DEFAULT_ALIGNMENT_MODE; - private Alignment mColumnAlignment = LEFT; - private Alignment mRowAlignment = BASELINE; private int mDefaultGap; // Constructors @@ -440,22 +452,13 @@ public class GridLayout extends ViewGroup { } /** - * When this property is {@code false}, the default state, GridLayout - * is at liberty to choose an order that better suits the heights of its children. - <p> * When this property is {@code true}, GridLayout is forced to place the row boundaries * so that their associated grid indices are in ascending order in the view. * <p> - * GridLayout implements this specification by creating ordering constraints between - * the variables that represent the locations of the row boundaries. - * - * When this property is {@code true}, constraints are added for each pair of consecutive - * indices: i.e. between row boundaries: {@code [0..1], [1..2], [2..3],...} etc. - * - * When the property is {@code false}, the ordering constraints are placed - * only between boundaries that separate opposing edges of the layout's children. + * When this property is {@code false} GridLayout is at liberty to place the vertical row + * boundaries in whatever order best fits the given constraints. * <p> - * The default value of this property is {@code false}. + * The default value of this property is {@code true}. * @param rowOrderPreserved {@code true} to force GridLayout to respect the order * of row boundaries @@ -485,22 +488,13 @@ public class GridLayout extends ViewGroup { } /** - * When this property is {@code false}, the default state, GridLayout - * is at liberty to choose an order that better suits the widths of its children. - <p> * When this property is {@code true}, GridLayout is forced to place the column boundaries * so that their associated grid indices are in ascending order in the view. * <p> - * GridLayout implements this specification by creating ordering constraints between - * the variables that represent the locations of the column boundaries. - * - * When this property is {@code true}, constraints are added for each pair of consecutive - * indices: i.e. between column boundaries: {@code [0..1], [1..2], [2..3],...} etc. - * - * When the property is {@code false}, the ordering constraints are placed - * only between boundaries that separate opposing edges of the layout's children. + * When this property is {@code false} GridLayout is at liberty to place the horizontal column + * boundaries in whatever order best fits the given constraints. * <p> - * The default value of this property is {@code false}. + * The default value of this property is {@code true}. * * @param columnOrderPreserved use {@code true} to force GridLayout to respect the order * of column boundaries. @@ -533,6 +527,7 @@ public class GridLayout extends ViewGroup { return result; } + @SuppressWarnings("unchecked") private static <T> T[] append(T[] a, T[] b) { T[] result = (T[]) Array.newInstance(a.getClass().getComponentType(), a.length + b.length); System.arraycopy(a, 0, result, 0, a.length); @@ -559,6 +554,9 @@ public class GridLayout extends ViewGroup { } private int getDefaultMargin(View c, boolean horizontal, boolean leading) { + if (c.getClass() == Space.class) { + return 0; + } return mDefaultGap / 2; } @@ -594,72 +592,92 @@ public class GridLayout extends ViewGroup { return (value != UNDEFINED) ? value : defaultValue; } - // install default indices for cells that don't define them - private void validateLayoutParams() { - new Object() { - public int maxSize = 0; - - private int valueIfDefined2(int value, int defaultValue) { - if (value != UNDEFINED) { - maxSize = 0; - return value; - } else { - return defaultValue; - } + private static boolean fits(int[] a, int value, int start, int end) { + if (end > a.length) { + return false; + } + for (int i = start; i < end; i++) { + if (a[i] > value) { + return false; } + } + return true; + } - { - final boolean horizontal = (mOrientation == HORIZONTAL); - final int axis = horizontal ? mHorizontalAxis.count : mVerticalAxis.count; - final int count = valueIfDefined(axis, Integer.MAX_VALUE); + private static void procrusteanFill(int[] a, int start, int end, int value) { + int length = a.length; + Arrays.fill(a, Math.min(start, length), Math.min(end, length), value); + } - int row = 0; - int col = 0; - for (int i = 0, N = getChildCount(); i < N; i++) { - View c = getChildAt(i); - LayoutParams lp = getLayoutParams1(c); + private static void setCellGroup(LayoutParams lp, int row, int rowSpan, int col, int colSpan) { + lp.setRowSpecSpan(new Interval(row, row + rowSpan)); + lp.setColumnSpecSpan(new Interval(col, col + colSpan)); + } - final Spec colSpec = lp.columnSpec; - final Interval cols = colSpec.span; - final int colSpan = cols.size(); + // Logic to avert infinite loops by ensuring that the cells can be placed somewhere. + private static int clip(Interval minorRange, boolean minorWasDefined, int count) { + int size = minorRange.size(); + if (count == 0) { + return size; + } + int min = minorWasDefined ? min(minorRange.min, count) : 0; + return min(size, count - min); + } - final Spec rowSpec = lp.rowSpec; - final Interval rows = rowSpec.span; - final int rowSpan = rows.size(); + // install default indices for cells that don't define them + private void validateLayoutParams() { + final boolean horizontal = (mOrientation == HORIZONTAL); + final int axisCount = horizontal ? mHorizontalAxis.count : mVerticalAxis.count; + final int count = valueIfDefined(axisCount, 0); - if (horizontal) { - row = valueIfDefined2(rows.min, row); + int major = 0; + int minor = 0; + int[] maxSizes = new int[count]; - int newCol = valueIfDefined(cols.min, (col + colSpan > count) ? 0 : col); - if (newCol < col) { - row += maxSize; - maxSize = 0; - } - col = newCol; - maxSize = max(maxSize, rowSpan); - } else { - col = valueIfDefined2(cols.min, col); - - int newRow = valueIfDefined(rows.min, (row + rowSpan > count) ? 0 : row); - if (newRow < row) { - col += maxSize; - maxSize = 0; + for (int i = 0, N = getChildCount(); i < N; i++) { + LayoutParams lp = getLayoutParams1(getChildAt(i)); + + final Interval majorRange = (horizontal ? lp.rowSpec : lp.columnSpec).span; + final boolean majorWasDefined = (majorRange.min != UNDEFINED); + final int majorSpan = majorRange.size(); + if (majorWasDefined) { + major = majorRange.min; + } + + final Interval minorRange = (horizontal ? lp.columnSpec : lp.rowSpec).span; + final boolean minorWasDefined = (minorRange.min != UNDEFINED); + final int minorSpan = clip(minorRange, minorWasDefined, count); + if (minorWasDefined) { + minor = minorRange.min; + } + + if (count != 0) { + // Find suitable row/col values when at least one is undefined. + if (!majorWasDefined || !minorWasDefined) { + while (!fits(maxSizes, major, minor, minor + minorSpan)) { + if (minorWasDefined) { + major++; + } else { + if (minor + minorSpan <= count) { + minor++; + } else { + minor = 0; + major++; + } } - row = newRow; - maxSize = max(maxSize, colSpan); - } - - lp.setColumnSpecSpan(new Interval(col, col + colSpan)); - lp.setRowSpecSpan(new Interval(row, row + rowSpan)); - - if (horizontal) { - col = col + colSpan; - } else { - row = row + rowSpan; } } + procrusteanFill(maxSizes, minor, minor + minorSpan, major + majorSpan); } - }; + + if (horizontal) { + setCellGroup(lp, major, majorSpan, minor, minorSpan); + } else { + setCellGroup(lp, minor, minorSpan, major, majorSpan); + } + + minor = minor + minorSpan; + } invalidateStructure(); } @@ -667,7 +685,7 @@ public class GridLayout extends ViewGroup { mLayoutParamsValid = false; mHorizontalAxis.invalidateStructure(); mVerticalAxis.invalidateStructure(); - // This can end up being done twice. But better that than not at all. + // This can end up being done twice. Better twice than not at all. invalidateValues(); } @@ -872,7 +890,7 @@ public class GridLayout extends ViewGroup { private Alignment getAlignment(Alignment alignment, boolean horizontal) { return (alignment != UNDEFINED_ALIGNMENT) ? alignment : - (horizontal ? mColumnAlignment : mRowAlignment); + (horizontal ? LEFT : BASELINE); } // Layout container @@ -970,6 +988,9 @@ public class GridLayout extends ViewGroup { int cx = paddingLeft + x1 + dx; int cy = paddingTop + y1 + dy; + if (width != c.getMeasuredWidth() || height != c.getMeasuredHeight()) { + c.measure(makeMeasureSpec(width, EXACTLY), makeMeasureSpec(height, EXACTLY)); + } c.layout(cx, cy, cx + width, cy + height); } } @@ -1237,53 +1258,6 @@ public class GridLayout extends ViewGroup { return topologicalSort(arcs.toArray(new Arc[arcs.size()])); } - private boolean[] findUsed(Collection<Arc> arcs) { - boolean[] result = new boolean[getCount()]; - for (Arc arc : arcs) { - Interval span = arc.span; - int min = min(span.min, span.max); - int max = max(span.min, span.max); - for (int i = min; i < max; i++) { - result[i] = true; - } - } - return result; - } - - // todo unify with findUsed above. Both routines analyze which rows/columns are empty. - private Collection<Interval> getSpacers() { - List<Interval> result = new ArrayList<Interval>(); - int V = getCount() + 1; - int[] leadingEdgeCount = new int[V]; - int[] trailingEdgeCount = new int[V]; - for (int i = 0, N = getChildCount(); i < N; i++) { - View c = getChildAt(i); - if (isGone(c)) continue; - LayoutParams lp = getLayoutParams(c); - Spec spec = horizontal ? lp.columnSpec : lp.rowSpec; - Interval span = spec.span; - leadingEdgeCount[span.min]++; - trailingEdgeCount[span.max]++; - } - - int lastTrailingEdge = 0; - - // treat the parent's edges like peer edges of the opposite type - trailingEdgeCount[0] = 1; - leadingEdgeCount[V - 1] = 1; - - for (int i = 0; i < V; i++) { - if (trailingEdgeCount[i] > 0) { - lastTrailingEdge = i; - continue; // if this is also a leading edge, don't add a space of length zero - } - if (leadingEdgeCount[i] > 0) { - result.add(new Interval(lastTrailingEdge, i)); - } - } - return result; - } - private void addComponentSizes(List<Arc> result, PackedMap<Interval, MutableInt> links) { for (int i = 0; i < links.keys.length; i++) { Interval key = links.keys[i]; @@ -1300,28 +1274,11 @@ public class GridLayout extends ViewGroup { // Add the maximum values from the components. addComponentSizes(maxs, getBackwardLinks()); - // Find redundant rows/cols and glue them together with 0-length arcs to link the tree - boolean[] used = findUsed(mins); - for (int i = 0; i < getCount(); i++) { - if (!used[i]) { - Interval span = new Interval(i, i + 1); - include(mins, span, new MutableInt(0)); - include(maxs, span.inverse(), new MutableInt(0)); - } - } - // Add ordering constraints to prevent row/col sizes from going negative if (mOrderPreserved) { // Add a constraint for every row/col for (int i = 0; i < getCount(); i++) { - if (used[i]) { - include(mins, new Interval(i, i + 1), new MutableInt(0)); - } - } - } else { - // Add a constraint for each row/col that separates opposing component edges - for (Interval gap : getSpacers()) { - include(mins, gap, new MutableInt(0)); + include(mins, new Interval(i, i + 1), new MutableInt(0)); } } @@ -1658,10 +1615,8 @@ public class GridLayout extends ViewGroup { * * @attr ref android.R.styleable#GridLayout_Layout_layout_row * @attr ref android.R.styleable#GridLayout_Layout_layout_rowSpan - * @attr ref android.R.styleable#GridLayout_Layout_layout_rowFlexibility * @attr ref android.R.styleable#GridLayout_Layout_layout_column * @attr ref android.R.styleable#GridLayout_Layout_layout_columnSpan - * @attr ref android.R.styleable#GridLayout_Layout_layout_columnFlexibility * @attr ref android.R.styleable#GridLayout_Layout_layout_gravity */ public static class LayoutParams extends MarginLayoutParams { @@ -1688,13 +1643,9 @@ public class GridLayout extends ViewGroup { private static final int COLUMN = R.styleable.GridLayout_Layout_layout_column; private static final int COLUMN_SPAN = R.styleable.GridLayout_Layout_layout_columnSpan; - private static final int COLUMN_FLEXIBILITY = - R.styleable.GridLayout_Layout_layout_columnFlexibility; private static final int ROW = R.styleable.GridLayout_Layout_layout_row; private static final int ROW_SPAN = R.styleable.GridLayout_Layout_layout_rowSpan; - private static final int ROW_FLEXIBILITY = - R.styleable.GridLayout_Layout_layout_rowFlexibility; private static final int GRAVITY = R.styleable.GridLayout_Layout_layout_gravity; @@ -1816,13 +1767,11 @@ public class GridLayout extends ViewGroup { int column = a.getInt(COLUMN, DEFAULT_COLUMN); int colSpan = a.getInt(COLUMN_SPAN, DEFAULT_SPAN_SIZE); - int hFlexibility = a.getInt(COLUMN_FLEXIBILITY, Spec.UNDEFINED_FLEXIBILITY); - this.columnSpec = spec(column, colSpan, getAlignment(gravity, true), hFlexibility); + this.columnSpec = spec(column, colSpan, getAlignment(gravity, true)); int row = a.getInt(ROW, DEFAULT_ROW); int rowSpan = a.getInt(ROW_SPAN, DEFAULT_SPAN_SIZE); - int vFlexibility = a.getInt(ROW_FLEXIBILITY, Spec.UNDEFINED_FLEXIBILITY); - this.rowSpec = spec(row, rowSpan, getAlignment(gravity, false), vFlexibility); + this.rowSpec = spec(row, rowSpan, getAlignment(gravity, false)); } finally { a.recycle(); } @@ -2150,19 +2099,19 @@ 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. - * <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 - * for grid indices. - * <p> - * 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. - */ + /** + * 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. + * <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 + * for grid indices. + * <p> + * 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. + */ public static class Spec { private static final int UNDEFINED_FLEXIBILITY = UNDEFINED; @@ -2170,18 +2119,18 @@ public class GridLayout extends ViewGroup { final Alignment alignment; - /** - * The <em>flexibility</em> property tells GridLayout how to derive minimum and maximum size - * values for a component. Specifications are made with respect to a child's - * 'measured size'. A child's measured size is, in turn, controlled by its - * height and width layout parameters which either specify a size or, in - * the case of {@link LayoutParams#WRAP_CONTENT WRAP_CONTENT}, defer to - * the computed size of the component. - * <p> - * A cell group is flexible only if <em>all</em> of its components are flexible. - * <p> - * By default, flexibility is {@link #INFLEXIBLE} only when alignment/gravity is undefined. - */ + /** + * The <em>flexibility</em> property tells GridLayout how to derive minimum and maximum size + * values for a component. Specifications are made with respect to a child's + * 'measured size'. A child's measured size is, in turn, controlled by its + * height and width layout parameters which either specify a size or, in + * the case of {@link LayoutParams#WRAP_CONTENT WRAP_CONTENT}, defer to + * the computed size of the component. + * <p> + * A cell group is flexible only if <em>all</em> of its components are flexible. + * <p> + * By default, flexibility is {@link #INFLEXIBLE} only when alignment/gravity is undefined. + */ final int flexibility; private Spec(Interval span, Alignment alignment, int flexibility) { @@ -2190,17 +2139,13 @@ public class GridLayout extends ViewGroup { this.flexibility = flexibility; } - private Spec(Interval span, Alignment alignment) { - this(span, alignment, UNDEFINED_FLEXIBILITY); - } - /* Copying constructor */ private Spec(Spec that) { this(that.span, that.alignment, that.flexibility); } - Spec(int start, int size, Alignment alignment, int flexibility) { - this(new Interval(start, start + size), alignment, flexibility); + private Spec(int start, int size, Alignment alignment) { + this(new Interval(start, start + size), alignment, UNDEFINED); } private Spec copyWriteSpan(Interval span) { @@ -2261,28 +2206,6 @@ public class GridLayout extends ViewGroup { } /** - * @deprecated Please use {@link #spec(int, int, Alignment)} instead, - * all spec's that define alignments (gravity) are assumed to be able to stretch. - * - * @hide - */ - @Deprecated - public static Spec spec(int start, int size, Alignment alignment, int flexibility) { - return new Spec(start, size, alignment, flexibility); - } - - /** - * @deprecated Please use {@link #spec(int, Alignment)} instead, - * all spec's that define alignments (gravity) are assumed to be able to stretch. - * - * @hide - */ - @Deprecated - public static Spec spec(int start, Alignment alignment, int flexibility) { - return spec(start, 1, alignment, flexibility); - } - - /** * Return a Spec, {@code spec}, where: * <ul> * <li> {@code spec.span = [start, start + size]} </li> @@ -2294,7 +2217,7 @@ public class GridLayout extends ViewGroup { * @param alignment the alignment */ public static Spec spec(int start, int size, Alignment alignment) { - return spec(start, size, alignment, Spec.UNDEFINED_FLEXIBILITY); + return new Spec(start, size, alignment); } /** diff --git a/core/java/android/widget/StackView.java b/core/java/android/widget/StackView.java index c4ba7c8c913f..4b08f2dc581b 100644 --- a/core/java/android/widget/StackView.java +++ b/core/java/android/widget/StackView.java @@ -1406,6 +1406,7 @@ public class StackView extends AdapterViewAnimator { v.setTranslationX(translationX); drawOutline(mCanvas, bitmap); + mCanvas.setBitmap(null); return bitmap; } @@ -1417,6 +1418,7 @@ public class StackView extends AdapterViewAnimator { dest.drawColor(0, PorterDuff.Mode.CLEAR); dest.setMatrix(mIdentityMatrix); dest.drawBitmap(mask, xy[0], xy[1], mHolographicPaint); + mMaskCanvas.setBitmap(null); mask.recycle(); } } diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index ab66676e3ddd..65ee74581a79 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -999,7 +999,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener setEllipsize(TextUtils.TruncateAt.END); break; case 4: - setHorizontalFadingEdgeEnabled(true); + setHorizontalFadingEdgeEnabled( + ViewConfiguration.get(context).isFadingMarqueeEnabled()); setEllipsize(TextUtils.TruncateAt.MARQUEE); break; } @@ -3067,7 +3068,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (text instanceof Spanned && ((Spanned) text).getSpanStart(TextUtils.TruncateAt.MARQUEE) >= 0) { - setHorizontalFadingEdgeEnabled(true); + setHorizontalFadingEdgeEnabled( + ViewConfiguration.get(mContext).isFadingMarqueeEnabled()); setEllipsize(TextUtils.TruncateAt.MARQUEE); } diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index f80f27dd3e6e..f70319be2138 100755 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -2632,12 +2632,12 @@ <attr name="alignmentMode" /> <!-- When set to true, forces row boundaries to appear in the same order as row indices. - The default is false. + The default is true. See {@link android.widget.GridLayout#setRowOrderPreserved(boolean)}.--> <attr name="rowOrderPreserved" format="boolean" /> <!-- When set to true, forces column boundaries to appear in the same order as column indices. - The default is false. + The default is true. See {@link android.widget.GridLayout#setColumnOrderPreserved(boolean)}.--> <attr name="columnOrderPreserved" format="boolean" /> </declare-styleable> @@ -3363,18 +3363,6 @@ The default is LEFT | BASELINE. See {@link android.widget.GridLayout.LayoutParams#setGravity(int)}. --> <attr name="layout_gravity" /> - <!-- {@deprecated To make a column group lexible, ensure that every component in the - group defines a horizontal gravity.} --> - <attr name="layout_columnFlexibility" > - <enum name="inflexible" value="0" /> - <enum name="canStretch" value="2" /> - </attr> - <!-- {@deprecated To make a row group flexible, ensure that every component in the - group defines a vertical gravity.} --> - <attr name="layout_rowFlexibility" > - <enum name="inflexible" value="0" /> - <enum name="canStretch" value="2" /> - </attr> </declare-styleable> <declare-styleable name="FrameLayout_Layout"> <attr name="layout_gravity" /> diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 65dce4977eeb..73443a026603 100755 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -84,6 +84,9 @@ specified for -large and -xlarge configurations. --> <dimen name="config_prefDialogWidth">320dp</dimen> + <!-- Enables or disables fading edges when marquee is enabled in TextView. --> + <bool name="config_ui_enableFadingMarquee">true</bool> + <!-- Whether dialogs should close automatically when the user touches outside of them. This should not normally be modified. --> <bool name="config_closeDialogWhenTouchOutside">false</bool> diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 0555d105a725..87e924927819 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -1728,10 +1728,8 @@ <public type="attr" name="layout_row" /> <public type="attr" name="layout_rowSpan" /> - <public type="attr" name="layout_rowFlexibility" /> <public type="attr" name="layout_columnSpan" /> - <public type="attr" name="layout_columnFlexibility" /> <public type="attr" name="actionModeSelectAllDrawable" /> diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java index 40d54bb0d580..3fc6463df80f 100644 --- a/graphics/java/android/graphics/Bitmap.java +++ b/graphics/java/android/graphics/Bitmap.java @@ -567,6 +567,7 @@ public final class Bitmap implements Parcelable { canvas.setBitmap(bitmap); canvas.drawBitmap(source, srcR, dstR, paint); + canvas.setBitmap(null); return bitmap; } diff --git a/media/java/android/media/ThumbnailUtils.java b/media/java/android/media/ThumbnailUtils.java index 7c181eeb569a..078d4afe1043 100644 --- a/media/java/android/media/ThumbnailUtils.java +++ b/media/java/android/media/ThumbnailUtils.java @@ -387,6 +387,7 @@ public class ThumbnailUtils { if (recycle) { source.recycle(); } + c.setBitmap(null); return b2; } float bitmapWidthF = source.getWidth(); diff --git a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java index 6b0fb12d86db..5bfdcdbac2be 100644 --- a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java +++ b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java @@ -3761,6 +3761,7 @@ class MediaArtistNativeHelper { final Canvas canvas = new Canvas(bitmap); canvas.drawBitmap(tempBitmap, new Rect(0, 0, newWidth, newHeight), new Rect(0, 0, width, height), sResizePaint); + canvas.setBitmap(null); } if (tempBitmap != null) { @@ -3837,6 +3838,7 @@ class MediaArtistNativeHelper { final Canvas canvas = new Canvas(bitmaps[i]); canvas.drawBitmap(tempBitmap, new Rect(0, 0, newWidth, newHeight), new Rect(0, 0, width, height), sResizePaint); + canvas.setBitmap(null); } } diff --git a/media/java/android/media/videoeditor/MediaImageItem.java b/media/java/android/media/videoeditor/MediaImageItem.java index 73cc7e2add21..f0cc1fe945d4 100755 --- a/media/java/android/media/videoeditor/MediaImageItem.java +++ b/media/java/android/media/videoeditor/MediaImageItem.java @@ -1008,6 +1008,7 @@ public class MediaImageItem extends MediaItem { srcBitmap.getHeight()), new Rect(0, 0, (int)bitmapWidth, (int)bitmapHeight), sResizePaint); + canvas.setBitmap(null); /** * Release the source bitmap */ diff --git a/media/java/android/media/videoeditor/OverlayFrame.java b/media/java/android/media/videoeditor/OverlayFrame.java index 131f5f0caf7a..d159df263637 100755 --- a/media/java/android/media/videoeditor/OverlayFrame.java +++ b/media/java/android/media/videoeditor/OverlayFrame.java @@ -420,6 +420,7 @@ public class OverlayFrame extends Overlay { } overlayCanvas.drawBitmap(overlayBitmap, srcRect, destRect, sResizePaint); + overlayCanvas.setBitmap(null); /* * Write to the dest file diff --git a/opengl/java/android/opengl/GLSurfaceView.java b/opengl/java/android/opengl/GLSurfaceView.java index 3f547fd8fe0f..4c7f84e4f49a 100644 --- a/opengl/java/android/opengl/GLSurfaceView.java +++ b/opengl/java/android/opengl/GLSurfaceView.java @@ -1073,6 +1073,15 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback return gl; } + public void purgeBuffers() { + mEgl.eglMakeCurrent(mEglDisplay, + EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, + EGL10.EGL_NO_CONTEXT); + mEgl.eglMakeCurrent(mEglDisplay, + mEglSurface, mEglSurface, + mEglContext); + } + /** * Display the current render surface. * @return false if the context has been lost. @@ -1415,6 +1424,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback if (LOG_RENDERER) { Log.w("GLThread", "onSurfaceChanged(" + w + ", " + h + ")"); } + mEglHelper.purgeBuffers(); mRenderer.onSurfaceChanged(gl, w, h); sizeChanged = false; } diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java index c896046e7a6e..d74b548564fc 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java @@ -501,6 +501,7 @@ public class RecentsPanelView extends RelativeLayout new RectF(mGlowBitmapPaddingLeftPx, mGlowBitmapPaddingTopPx, outBitmap.getWidth() - mGlowBitmapPaddingRightPx, outBitmap.getHeight() - mGlowBitmapPaddingBottomPx), paint); + canvas.setBitmap(null); } return outBitmap; } diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java index 3a47e6e8ba6b..fc21929db409 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java @@ -294,6 +294,7 @@ class GlobalScreenshot { c.rotate(360f - degrees); c.translate(-dims[0] / 2, -dims[1] / 2); c.drawBitmap(mScreenBitmap, 0, 0, null); + c.setBitmap(null); mScreenBitmap = ss; } diff --git a/policy/src/com/android/internal/policy/impl/IconUtilities.java b/policy/src/com/android/internal/policy/impl/IconUtilities.java index 99055cf73158..4564f904e83e 100644 --- a/policy/src/com/android/internal/policy/impl/IconUtilities.java +++ b/policy/src/com/android/internal/policy/impl/IconUtilities.java @@ -186,6 +186,7 @@ final class IconUtilities { mask.recycle(); dest.drawBitmap(src, 0, 0, mPaint); + dest.setBitmap(null); return result; } diff --git a/services/java/com/android/server/connectivity/Vpn.java b/services/java/com/android/server/connectivity/Vpn.java index 9cb772eb315a..ecbad09909d0 100644 --- a/services/java/com/android/server/connectivity/Vpn.java +++ b/services/java/com/android/server/connectivity/Vpn.java @@ -183,7 +183,9 @@ public class Vpn extends INetworkManagementEventObserver.Stub { android.R.dimen.notification_large_icon_height); icon.setBounds(0, 0, width, height); bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); - icon.draw(new Canvas(bitmap)); + Canvas c = new Canvas(bitmap); + icon.draw(c); + c.setBitmap(null); } // Configure the interface. Abort if any of these steps fails. diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java index 88e0fa88e5b1..3d977d0b97c3 100644 --- a/services/java/com/android/server/pm/PackageManagerService.java +++ b/services/java/com/android/server/pm/PackageManagerService.java @@ -3326,7 +3326,7 @@ public class PackageManagerService extends IPackageManager.Stub { if (pkg.applicationInfo.nativeLibraryDir != null) { try { final File nativeLibraryDir = new File(pkg.applicationInfo.nativeLibraryDir); - final String dataPathString = dataPath.getCanonicalFile().getPath(); + final String dataPathString = dataPath.getCanonicalPath(); if (isSystemApp(pkg) && !isUpdatedSystemApp(pkg)) { /* @@ -3340,7 +3340,7 @@ public class PackageManagerService extends IPackageManager.Stub { Log.i(TAG, "removed obsolete native libraries for system package " + path); } - } else if (nativeLibraryDir.getCanonicalFile().getParent() + } else if (nativeLibraryDir.getParentFile().getCanonicalPath() .equals(dataPathString)) { /* * Make sure the native library dir isn't a symlink to diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index f8059f57bfe1..e0b5e17b1332 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -4919,6 +4919,7 @@ public class WindowManagerService extends IWindowManager.Stub matrix.postTranslate(-(int)(frame.left*scale), -(int)(frame.top*scale)); Canvas canvas = new Canvas(bm); canvas.drawBitmap(rawss, matrix, null); + canvas.setBitmap(null); rawss.recycle(); return bm; diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp index 7bf3e0ae0957..f4be16838387 100644 --- a/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp +++ b/services/surfaceflinger/DisplayHardware/DisplayHardware.cpp @@ -40,6 +40,7 @@ #include "GLExtensions.h" #include "HWComposer.h" +#include "SurfaceFlinger.h" using namespace android; @@ -75,7 +76,7 @@ DisplayHardware::DisplayHardware( const sp<SurfaceFlinger>& flinger, uint32_t dpy) : DisplayHardwareBase(flinger, dpy), - mFlags(0), mHwc(0) + mFlinger(flinger), mFlags(0), mHwc(0) { init(dpy); } @@ -310,7 +311,7 @@ void DisplayHardware::init(uint32_t dpy) // initialize the H/W composer - mHwc = new HWComposer(); + mHwc = new HWComposer(mFlinger); if (mHwc->initCheck() == NO_ERROR) { mHwc->setFrameBuffer(mDisplay, mSurface); } diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardware.h b/services/surfaceflinger/DisplayHardware/DisplayHardware.h index cdf89fd0badb..40a6f1e8cdd3 100644 --- a/services/surfaceflinger/DisplayHardware/DisplayHardware.h +++ b/services/surfaceflinger/DisplayHardware/DisplayHardware.h @@ -95,6 +95,7 @@ private: void init(uint32_t displayIndex) __attribute__((noinline)); void fini() __attribute__((noinline)); + sp<SurfaceFlinger> mFlinger; EGLDisplay mDisplay; EGLSurface mSurface; EGLContext mContext; diff --git a/services/surfaceflinger/DisplayHardware/DisplayHardwareBase.h b/services/surfaceflinger/DisplayHardware/DisplayHardwareBase.h index 30eb2587793c..3ebc7b6cc54d 100644 --- a/services/surfaceflinger/DisplayHardware/DisplayHardwareBase.h +++ b/services/surfaceflinger/DisplayHardware/DisplayHardwareBase.h @@ -37,7 +37,7 @@ public: ~DisplayHardwareBase(); - // console managment + // console management void releaseScreen() const; void acquireScreen() const; bool isScreenAcquired() const; diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp index 4a3b20ded9dc..7d1bdf00217e 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp +++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp @@ -30,12 +30,14 @@ #include <EGL/egl.h> #include "HWComposer.h" +#include "SurfaceFlinger.h" namespace android { // --------------------------------------------------------------------------- -HWComposer::HWComposer() - : mModule(0), mHwc(0), mList(0), mCapacity(0), +HWComposer::HWComposer(const sp<SurfaceFlinger>& flinger) + : mFlinger(flinger), + mModule(0), mHwc(0), mList(0), mCapacity(0), mDpy(EGL_NO_DISPLAY), mSur(EGL_NO_SURFACE) { int err = hw_get_module(HWC_HARDWARE_MODULE_ID, &mModule); @@ -44,6 +46,13 @@ HWComposer::HWComposer() err = hwc_open(mModule, &mHwc); LOGE_IF(err, "%s device failed to initialize (%s)", HWC_HARDWARE_COMPOSER, strerror(-err)); + if (err == 0) { + if (mHwc->registerProcs) { + mCBContext.hwc = this; + mCBContext.procs.invalidate = &hook_invalidate; + mHwc->registerProcs(mHwc, &mCBContext.procs); + } + } } } @@ -58,6 +67,14 @@ status_t HWComposer::initCheck() const { return mHwc ? NO_ERROR : NO_INIT; } +void HWComposer::hook_invalidate(struct hwc_procs* procs) { + reinterpret_cast<cb_context *>(procs)->hwc->invalidate(); +} + +void HWComposer::invalidate() { + mFlinger->signalEvent(); +} + void HWComposer::setFrameBuffer(EGLDisplay dpy, EGLSurface sur) { mDpy = (hwc_display_t)dpy; mSur = (hwc_surface_t)sur; diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h index 5a9e9ebb1934..983898a42392 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.h +++ b/services/surfaceflinger/DisplayHardware/HWComposer.h @@ -24,16 +24,19 @@ #include <hardware/hwcomposer.h> +#include <utils/StrongPointer.h> + namespace android { // --------------------------------------------------------------------------- class String8; +class SurfaceFlinger; class HWComposer { public: - HWComposer(); + HWComposer(const sp<SurfaceFlinger>& flinger); ~HWComposer(); status_t initCheck() const; @@ -60,12 +63,21 @@ public: void dump(String8& out, char* scratch, size_t SIZE) const; private: + struct cb_context { + hwc_procs_t procs; + HWComposer* hwc; + }; + static void hook_invalidate(struct hwc_procs* procs); + void invalidate(); + + sp<SurfaceFlinger> mFlinger; hw_module_t const* mModule; hwc_composer_device_t* mHwc; hwc_layer_list_t* mList; size_t mCapacity; hwc_display_t mDpy; hwc_surface_t mSur; + cb_context mCBContext; }; diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 886bb2afeb73..32f300fff953 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -172,17 +172,14 @@ status_t Layer::setBuffers( uint32_t w, uint32_t h, void Layer::setGeometry(hwc_layer_t* hwcl) { - hwcl->compositionType = HWC_FRAMEBUFFER; - hwcl->hints = 0; - hwcl->flags = 0; - hwcl->transform = 0; - hwcl->blending = HWC_BLENDING_NONE; + LayerBaseClient::setGeometry(hwcl); + + hwcl->flags &= ~HWC_SKIP_LAYER; // we can't do alpha-fade with the hwc HAL const State& s(drawingState()); if (s.alpha < 0xFF) { hwcl->flags = HWC_SKIP_LAYER; - return; } /* @@ -205,26 +202,9 @@ void Layer::setGeometry(hwc_layer_t* hwcl) // we can only handle simple transformation if (finalTransform & Transform::ROT_INVALID) { hwcl->flags = HWC_SKIP_LAYER; - return; - } - - hwcl->transform = finalTransform; - - if (!isOpaque()) { - hwcl->blending = mPremultipliedAlpha ? - HWC_BLENDING_PREMULT : HWC_BLENDING_COVERAGE; + } else { + hwcl->transform = finalTransform; } - - // scaling is already applied in mTransformedBounds - hwcl->displayFrame.left = mTransformedBounds.left; - hwcl->displayFrame.top = mTransformedBounds.top; - hwcl->displayFrame.right = mTransformedBounds.right; - hwcl->displayFrame.bottom = mTransformedBounds.bottom; - - hwcl->visibleRegionScreen.rects = - reinterpret_cast<hwc_rect_t const *>( - visibleRegionScreen.getArray( - &hwcl->visibleRegionScreen.numRects)); } void Layer::setPerFrameData(hwc_layer_t* hwcl) { @@ -235,9 +215,9 @@ void Layer::setPerFrameData(hwc_layer_t* hwcl) { // HWC handle it. hwcl->flags |= HWC_SKIP_LAYER; hwcl->handle = NULL; - return; + } else { + hwcl->handle = buffer->handle; } - hwcl->handle = buffer->handle; if (isCropped()) { hwcl->sourceCrop.left = mCurrentCrop.left; diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp index c86c659ad6cd..e04c533efc3b 100644 --- a/services/surfaceflinger/LayerBase.cpp +++ b/services/surfaceflinger/LayerBase.cpp @@ -302,13 +302,47 @@ void LayerBase::drawRegion(const Region& reg) const } } -void LayerBase::setGeometry(hwc_layer_t* hwcl) { - hwcl->flags |= HWC_SKIP_LAYER; +void LayerBase::setGeometry(hwc_layer_t* hwcl) +{ + hwcl->compositionType = HWC_FRAMEBUFFER; + hwcl->hints = 0; + hwcl->flags = HWC_SKIP_LAYER; + hwcl->transform = 0; + hwcl->blending = HWC_BLENDING_NONE; + + // this gives us only the "orientation" component of the transform + const State& s(drawingState()); + const uint32_t finalTransform = s.transform.getOrientation(); + // we can only handle simple transformation + if (finalTransform & Transform::ROT_INVALID) { + hwcl->flags = HWC_SKIP_LAYER; + } else { + hwcl->transform = finalTransform; + } + + if (!isOpaque()) { + hwcl->blending = mPremultipliedAlpha ? + HWC_BLENDING_PREMULT : HWC_BLENDING_COVERAGE; + } + + // scaling is already applied in mTransformedBounds + hwcl->displayFrame.left = mTransformedBounds.left; + hwcl->displayFrame.top = mTransformedBounds.top; + hwcl->displayFrame.right = mTransformedBounds.right; + hwcl->displayFrame.bottom = mTransformedBounds.bottom; + hwcl->visibleRegionScreen.rects = + reinterpret_cast<hwc_rect_t const *>( + visibleRegionScreen.getArray( + &hwcl->visibleRegionScreen.numRects)); } void LayerBase::setPerFrameData(hwc_layer_t* hwcl) { hwcl->compositionType = HWC_FRAMEBUFFER; hwcl->handle = NULL; + hwcl->sourceCrop.left = 0; + hwcl->sourceCrop.top = 0; + hwcl->sourceCrop.right = mTransformedBounds.width(); + hwcl->sourceCrop.bottom = mTransformedBounds.height(); } void LayerBase::setFiltering(bool filtering) diff --git a/tests/GridLayoutTest/src/com/android/test/layout/Activity2.java b/tests/GridLayoutTest/src/com/android/test/layout/Activity2.java index e1871ac809a0..907ee9cadc9a 100644 --- a/tests/GridLayoutTest/src/com/android/test/layout/Activity2.java +++ b/tests/GridLayoutTest/src/com/android/test/layout/Activity2.java @@ -34,15 +34,17 @@ import static android.widget.GridLayout.*; public class Activity2 extends Activity { public static View create(Context context) { - GridLayout vg = new GridLayout(context); - vg.setUseDefaultMargins(true); - vg.setAlignmentMode(ALIGN_BOUNDS); + GridLayout p = new GridLayout(context); + p.setUseDefaultMargins(true); + p.setAlignmentMode(ALIGN_BOUNDS); + p.setRowOrderPreserved(false); + p.setPadding(0, 0, 0, 0); Spec row1 = spec(0); Spec row2 = spec(1); Spec row3 = spec(2, BASELINE); Spec row4 = spec(3, BASELINE); - Spec row5 = spec(4, FILL); + Spec row5 = spec(2, 3, FILL); // allow the last two rows to overlap the middle two Spec row6 = spec(5); Spec row7 = spec(6); @@ -55,63 +57,63 @@ public class Activity2 extends Activity { Spec col4b = spec(3, FILL); { - TextView v = new TextView(context); - v.setTextSize(32); - v.setText("Email setup"); - vg.addView(v, new LayoutParams(row1, col1a)); + TextView c = new TextView(context); + c.setTextSize(32); + c.setText("Email setup"); + p.addView(c, new LayoutParams(row1, col1a)); } { - TextView v = new TextView(context); - v.setTextSize(16); - v.setText("You can configure email in just a few steps:"); - vg.addView(v, new LayoutParams(row2, col1b)); + TextView c = new TextView(context); + c.setTextSize(16); + c.setText("You can configure email in just a few steps:"); + p.addView(c, new LayoutParams(row2, col1b)); } { - TextView v = new TextView(context); - v.setText("Email address:"); - vg.addView(v, new LayoutParams(row3, col1c)); + TextView c = new TextView(context); + c.setText("Email address:"); + p.addView(c, new LayoutParams(row3, col1c)); } { - EditText v = new EditText(context); - v.setInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_EMAIL_ADDRESS); + EditText c = new EditText(context); + c.setInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_EMAIL_ADDRESS); { LayoutParams lp = new LayoutParams(row3, col2); - lp.width = (int) v.getPaint().measureText("Frederick.W.Flintstone"); - vg.addView(v, lp); + lp.width = (int) c.getPaint().measureText("Frederick.W.Flintstone"); + p.addView(c, lp); } } { - TextView v = new TextView(context); - v.setText("Password:"); - vg.addView(v, new LayoutParams(row4, col1c)); + TextView c = new TextView(context); + c.setText("Password:"); + p.addView(c, new LayoutParams(row4, col1c)); } { - TextView v = new EditText(context); - v.setInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD); + TextView c = new EditText(context); + c.setInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD); { LayoutParams lp = new LayoutParams(row4, col2); - lp.width = (int) v.getPaint().measureText("************"); - vg.addView(v, lp); + lp.width = (int) c.getPaint().measureText("************"); + p.addView(c, lp); } } { - Space v = new Space(context); + Space c = new Space(context); LayoutParams lp = new LayoutParams(row5, col3); lp.setMargins(0, 0, 0, 0); - vg.addView(v, lp); + p.addView(c, lp); } { - Button v = new Button(context); - v.setText("Manual setup"); - vg.addView(v, new LayoutParams(row6, col4a)); + Button c = new Button(context); + c.setText("Manual setup"); + p.addView(c, new LayoutParams(row6, col4a)); } { - Button v = new Button(context); - v.setText("Next"); - vg.addView(v, new LayoutParams(row7, col4b)); + Button c = new Button(context); + c.setText("Next"); + p.addView(c, new LayoutParams(row7, col4b)); } - return vg; + return p; } protected void onCreate(Bundle savedInstanceState) { |