diff options
Diffstat (limited to 'core/java')
30 files changed, 108 insertions, 205 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index dd49009..17a31f3 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -1943,7 +1943,7 @@ public final class ActivityThread { if (dumpFullInfo) { printRow(pw, HEAP_FULL_COLUMN, "", "Pss", "Pss", "Shared", "Private", "Shared", "Private", "Swapped", "Heap", "Heap", "Heap"); - printRow(pw, HEAP_FULL_COLUMN, "", "Total", "Clean", "Dirty", "", + printRow(pw, HEAP_FULL_COLUMN, "", "Total", "Clean", "Dirty", "Dirty", "Clean", "Clean", "Dirty", "Size", "Alloc", "Free"); printRow(pw, HEAP_FULL_COLUMN, "", "------", "------", "------", "------", "------", "------", "------", "------", "------", "------"); diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java index af45731..ab28d95 100644 --- a/core/java/android/app/Fragment.java +++ b/core/java/android/app/Fragment.java @@ -219,8 +219,8 @@ final class FragmentState implements Parcelable { * state of its view hierarchy has been restored. * <li> {@link #onStart} makes the fragment visible to the user (based on its * containing activity being started). - * <li> {@link #onResume} makes the fragment interacting with the user (based on its - * containing activity being resumed). + * <li> {@link #onResume} makes the fragment begin interacting with the user + * (based on its containing activity being resumed). * </ol> * * <p>As a fragment is no longer being used, it goes through a reverse @@ -564,7 +564,7 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene * and later retrieved by the Fragment with {@link #getArguments}. * * <p>Applications should generally not implement a constructor. The - * first place application code an run where the fragment is ready to + * first place application code can run where the fragment is ready to * be used is in {@link #onAttach(Activity)}, the point where the fragment * is actually associated with its activity. Some applications may also * want to implement {@link #onInflate} to retrieve attributes from a @@ -720,8 +720,7 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene } /** - * Return the arguments supplied when the fragment was instantiated, - * if any. + * Return the arguments supplied to {@link #setArguments}, if any. */ final public Bundle getArguments() { return mArguments; diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java index fc761fe..ccceef4 100644 --- a/core/java/android/app/FragmentManager.java +++ b/core/java/android/app/FragmentManager.java @@ -70,7 +70,7 @@ public abstract class FragmentManager { * with {@link FragmentTransaction#addToBackStack(String) * FragmentTransaction.addToBackStack()}. Entries can later be * retrieved with {@link FragmentManager#getBackStackEntryAt(int) - * FragmentManager.getBackStackEntry()}. + * FragmentManager.getBackStackEntryAt()}. * * <p>Note that you should never hold on to a BackStackEntry object; * the identifier as returned by {@link #getId} is the only thing that @@ -260,7 +260,7 @@ public abstract class FragmentManager { /** * Return the BackStackEntry at index <var>index</var> in the back stack; - * entries start index 0 being the bottom of the stack. + * where the item on the bottom of the stack has index 0. */ public abstract BackStackEntry getBackStackEntryAt(int index); diff --git a/core/java/android/app/FragmentTransaction.java b/core/java/android/app/FragmentTransaction.java index 25cd3cc..dc7075c 100644 --- a/core/java/android/app/FragmentTransaction.java +++ b/core/java/android/app/FragmentTransaction.java @@ -26,7 +26,7 @@ public abstract class FragmentTransaction { /** * Add a fragment to the activity state. This fragment may optionally * also have its view (if {@link Fragment#onCreateView Fragment.onCreateView} - * returns non-null) into a container view of the activity. + * returns non-null) inserted into a container view of the activity. * * @param containerViewId Optional identifier of the container this fragment is * to be placed in. If 0, it will not be placed in a container. diff --git a/core/java/android/gesture/GestureOverlayView.java b/core/java/android/gesture/GestureOverlayView.java index 6e3a00f..e1a2a25 100644 --- a/core/java/android/gesture/GestureOverlayView.java +++ b/core/java/android/gesture/GestureOverlayView.java @@ -640,7 +640,7 @@ public class GestureOverlayView extends FrameLayout { mStrokeBuffer.add(new GesturePoint(x, y, event.getEventTime())); if (mHandleGestureActions && !mIsGesturing) { - mTotalLength += (float) Math.sqrt(dx * dx + dy * dy); + mTotalLength += (float) Math.hypot(dx, dy); if (mTotalLength > mGestureStrokeLengthThreshold) { final OrientedBoundingBox box = diff --git a/core/java/android/gesture/GestureStroke.java b/core/java/android/gesture/GestureStroke.java index 1d0f0fe..bed904e 100644 --- a/core/java/android/gesture/GestureStroke.java +++ b/core/java/android/gesture/GestureStroke.java @@ -69,8 +69,7 @@ public class GestureStroke { bx.bottom = p.y; len = 0; } else { - len += Math.sqrt(Math.pow(p.x - tmpPoints[(i - 1) * 2], 2) - + Math.pow(p.y - tmpPoints[(i -1 ) * 2 + 1], 2)); + len += Math.hypot(p.x - tmpPoints[(i - 1) * 2], p.y - tmpPoints[(i -1 ) * 2 + 1]); bx.union(p.x, p.y); } index++; diff --git a/core/java/android/gesture/GestureUtils.java b/core/java/android/gesture/GestureUtils.java index dd221fc..416279e 100644 --- a/core/java/android/gesture/GestureUtils.java +++ b/core/java/android/gesture/GestureUtils.java @@ -293,7 +293,7 @@ public final class GestureUtils { } float deltaX = currentPointX - lstPointX; float deltaY = currentPointY - lstPointY; - float distance = (float) Math.sqrt(deltaX * deltaX + deltaY * deltaY); + float distance = (float) Math.hypot(deltaX, deltaY); if (distanceSoFar + distance >= increment) { float ratio = (increment - distanceSoFar) / distance; float nx = lstPointX + ratio * deltaX; @@ -379,7 +379,7 @@ public final class GestureUtils { for (int i = 0; i < count; i += 2) { float dx = points[i + 2] - points[i]; float dy = points[i + 3] - points[i + 1]; - sum += Math.sqrt(dx * dx + dy * dy); + sum += Math.hypot(dx, dy); } return sum; } @@ -388,13 +388,13 @@ public final class GestureUtils { float totalLen = computeTotalLength(points); float dx = points[2] - points[0]; float dy = points[3] - points[1]; - return (float) Math.sqrt(dx * dx + dy * dy) / totalLen; + return (float) Math.hypot(dx, dy) / totalLen; } static float computeStraightness(float[] points, float totalLen) { float dx = points[2] - points[0]; float dy = points[3] - points[1]; - return (float) Math.sqrt(dx * dx + dy * dy) / totalLen; + return (float) Math.hypot(dx, dy) / totalLen; } /** diff --git a/core/java/android/hardware/GeomagneticField.java b/core/java/android/hardware/GeomagneticField.java index ef05732..eb26ee5 100644 --- a/core/java/android/hardware/GeomagneticField.java +++ b/core/java/android/hardware/GeomagneticField.java @@ -281,7 +281,7 @@ public class GeomagneticField { * @return Horizontal component of the field strength in nonoteslas. */ public float getHorizontalStrength() { - return (float) Math.sqrt(mX * mX + mY * mY); + return (float) Math.hypot(mX, mY); } /** diff --git a/core/java/android/net/LocalSocket.java b/core/java/android/net/LocalSocket.java index 31bc20b..a374a86 100644 --- a/core/java/android/net/LocalSocket.java +++ b/core/java/android/net/LocalSocket.java @@ -29,7 +29,7 @@ import java.net.SocketOptions; */ public class LocalSocket implements Closeable { - private LocalSocketImpl impl; + private final LocalSocketImpl impl; private volatile boolean implCreated; private LocalSocketAddress localAddress; private boolean isBound; diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java index ee36012..ff194c5 100644 --- a/core/java/android/os/Build.java +++ b/core/java/android/os/Build.java @@ -515,7 +515,8 @@ public class Build { * <p>Applications targeting this or a later release will get these * new changes in behavior:</p> * <ul> - * <li> The default result of {android.preference.PreferenceActivity#isValidFragment + * <li> The default result of + * {@link android.preference.PreferenceActivity#isValidFragment(String) * PreferenceActivity.isValueFragment} becomes false instead of true.</li> * <li> In {@link android.webkit.WebView}, apps targeting earlier versions will have * JS URLs evaluated directly and any result of the evaluation will not replace diff --git a/core/java/android/provider/DocumentsProvider.java b/core/java/android/provider/DocumentsProvider.java index 270d786..932e873 100644 --- a/core/java/android/provider/DocumentsProvider.java +++ b/core/java/android/provider/DocumentsProvider.java @@ -355,7 +355,7 @@ public abstract class DocumentsProvider extends ContentProvider { } /** - * Return documents that that match the given query under the requested + * Return documents that match the given query under the requested * root. The returned documents should be sorted by relevance in descending * order. How documents are matched against the query string is an * implementation detail left to each provider, but it's suggested that at diff --git a/core/java/android/text/BoringLayout.java b/core/java/android/text/BoringLayout.java index 6f00707..e78cf8f 100644 --- a/core/java/android/text/BoringLayout.java +++ b/core/java/android/text/BoringLayout.java @@ -20,7 +20,6 @@ import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Path; import android.text.style.ParagraphStyle; -import android.util.FloatMath; /** * A BoringLayout is a very simple Layout implementation for text that @@ -207,7 +206,7 @@ public class BoringLayout extends Layout implements TextUtils.EllipsizeCallback TextLine line = TextLine.obtain(); line.set(paint, source, 0, source.length(), Layout.DIR_LEFT_TO_RIGHT, Layout.DIRS_ALL_LEFT_TO_RIGHT, false, null); - mMax = (int) FloatMath.ceil(line.metrics(null)); + mMax = (int) Math.ceil(line.metrics(null)); TextLine.recycle(line); } @@ -301,7 +300,7 @@ public class BoringLayout extends Layout implements TextUtils.EllipsizeCallback TextLine line = TextLine.obtain(); line.set(paint, text, 0, length, Layout.DIR_LEFT_TO_RIGHT, Layout.DIRS_ALL_LEFT_TO_RIGHT, false, null); - fm.width = (int) FloatMath.ceil(line.metrics(fm)); + fm.width = (int) Math.ceil(line.metrics(fm)); TextLine.recycle(line); return fm; diff --git a/core/java/android/text/Html.java b/core/java/android/text/Html.java index 2fcc597..dc93bc2 100644 --- a/core/java/android/text/Html.java +++ b/core/java/android/text/Html.java @@ -61,7 +61,7 @@ public class Html { */ public static interface ImageGetter { /** - * This methos is called when the HTML parser encounters an + * This method is called when the HTML parser encounters an * <img> tag. The <code>source</code> argument is the * string from the "src" attribute; the return value should be * a Drawable representation of the image or <code>null</code> diff --git a/core/java/android/text/TextUtils.java b/core/java/android/text/TextUtils.java index 3502b52..8a8c6d8 100644 --- a/core/java/android/text/TextUtils.java +++ b/core/java/android/text/TextUtils.java @@ -63,6 +63,8 @@ import java.util.regex.Pattern; public class TextUtils { private static final String TAG = "TextUtils"; + private static final String ELLIPSIS = new String(Layout.ELLIPSIS_NORMAL); + private static final String ELLIPSIS_TWO_DOTS = new String(Layout.ELLIPSIS_TWO_DOTS); private TextUtils() { /* cannot be instantiated */ } @@ -1081,14 +1083,9 @@ public class TextUtils { float avail, TruncateAt where, boolean preserveLength, EllipsizeCallback callback) { - - final String ellipsis = (where == TruncateAt.END_SMALL) ? - Resources.getSystem().getString(R.string.ellipsis_two_dots) : - Resources.getSystem().getString(R.string.ellipsis); - return ellipsize(text, paint, avail, where, preserveLength, callback, TextDirectionHeuristics.FIRSTSTRONG_LTR, - ellipsis); + (where == TruncateAt.END_SMALL) ? ELLIPSIS_TWO_DOTS : ELLIPSIS); } /** diff --git a/core/java/android/text/format/Time.java b/core/java/android/text/format/Time.java index aa6ad20..3c90ab6 100644 --- a/core/java/android/text/format/Time.java +++ b/core/java/android/text/format/Time.java @@ -212,13 +212,15 @@ public class Time { * <p> * If "ignoreDst" is true, then this method sets the "isDst" field to -1 * (the "unknown" value) before normalizing. It then computes the - * correct value for "isDst". + * time in milliseconds and sets the correct value for "isDst" if the + * fields resolve to a valid date / time. * * <p> * See {@link #toMillis(boolean)} for more information about when to - * use <tt>true</tt> or <tt>false</tt> for "ignoreDst". + * use <tt>true</tt> or <tt>false</tt> for "ignoreDst" and when {@code -1} + * might be returned. * - * @return the UTC milliseconds since the epoch + * @return the UTC milliseconds since the epoch, or {@code -1} */ public long normalize(boolean ignoreDst) { calculator.copyFieldsFromTime(this); @@ -314,6 +316,11 @@ public class Time { * a} is less than {@code b}, a positive number if {@code a} is greater than * {@code b}, or 0 if they are equal. * + * <p> + * This method can return an incorrect answer when the date / time fields of + * either {@code Time} have been set to a local time that contradicts the + * available timezone information. + * * @param a first {@code Time} instance to compare * @param b second {@code Time} instance to compare * @throws NullPointerException if either argument is {@code null} @@ -727,6 +734,14 @@ public class Time { * <p> * You should also use <tt>toMillis(false)</tt> if you want * to read back the same milliseconds that you set with {@link #set(long)} + * + * <p> + * This method can return {@code -1} when the date / time fields have been + * set to a local time that conflicts with available timezone information. + * For example, when daylight savings transitions cause an hour to be + * skipped: times within that hour will return {@code -1} if isDst = + * {@code -1}. + * * or {@link #set(Time)} or after parsing a date string. */ public long toMillis(boolean ignoreDst) { @@ -822,6 +837,10 @@ public class Time { * Returns true if the time represented by this Time object occurs before * the given time. * + * <p> + * Equivalent to {@code Time.compare(this, that) < 0}. See + * {@link #compare(Time, Time)} for details. + * * @param that a given Time object to compare against * @return true if this time is less than the given time */ @@ -834,6 +853,10 @@ public class Time { * Returns true if the time represented by this Time object occurs after * the given time. * + * <p> + * Equivalent to {@code Time.compare(this, that) > 0}. See + * {@link #compare(Time, Time)} for details. + * * @param that a given Time object to compare against * @return true if this time is greater than the given time */ @@ -914,6 +937,10 @@ public class Time { * Returns true if the day of the given time is the epoch on the Julian Calendar * (January 1, 1970 on the Gregorian calendar). * + * <p> + * This method can return an incorrect answer when the date / time fields have + * been set to a local time that contradicts the available timezone information. + * * @param time the time to test * @return true if epoch. */ diff --git a/core/java/android/util/MathUtils.java b/core/java/android/util/MathUtils.java index 13a692e..36d5b50 100644 --- a/core/java/android/util/MathUtils.java +++ b/core/java/android/util/MathUtils.java @@ -94,7 +94,7 @@ public final class MathUtils { public static float dist(float x1, float y1, float x2, float y2) { final float x = (x2 - x1); final float y = (y2 - y1); - return (float) Math.sqrt(x * x + y * y); + return (float) Math.hypot(x, y); } public static float dist(float x1, float y1, float z1, float x2, float y2, float z2) { @@ -105,7 +105,7 @@ public final class MathUtils { } public static float mag(float a, float b) { - return (float) Math.sqrt(a * a + b * b); + return (float) Math.hypot(a, b); } public static float mag(float a, float b, float c) { diff --git a/core/java/android/view/ScaleGestureDetector.java b/core/java/android/view/ScaleGestureDetector.java index 42a58a8..6508cca 100644 --- a/core/java/android/view/ScaleGestureDetector.java +++ b/core/java/android/view/ScaleGestureDetector.java @@ -21,7 +21,6 @@ import android.content.res.Resources; import android.os.Build; import android.os.Handler; import android.os.SystemClock; -import android.util.FloatMath; /** * Detects scaling transformation gestures using the supplied {@link MotionEvent}s. @@ -394,7 +393,7 @@ public class ScaleGestureDetector { if (inDoubleTapMode()) { span = spanY; } else { - span = FloatMath.sqrt(spanX * spanX + spanY * spanY); + span = (float) Math.hypot(spanX, spanY); } // Dispatch begin/end events as needed. diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index 7538dff..ca68654 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -6340,8 +6340,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager /** * Information about how wide the view wants to be. Can be one of the - * constants FILL_PARENT (replaced by MATCH_PARENT , - * in API Level 8) or WRAP_CONTENT. or an exact size. + * constants FILL_PARENT (replaced by MATCH_PARENT + * in API Level 8) or WRAP_CONTENT, or an exact size. */ @ViewDebug.ExportedProperty(category = "layout", mapping = { @ViewDebug.IntToString(from = MATCH_PARENT, to = "MATCH_PARENT"), @@ -6351,8 +6351,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager /** * Information about how tall the view wants to be. Can be one of the - * constants FILL_PARENT (replaced by MATCH_PARENT , - * in API Level 8) or WRAP_CONTENT. or an exact size. + * constants FILL_PARENT (replaced by MATCH_PARENT + * in API Level 8) or WRAP_CONTENT, or an exact size. */ @ViewDebug.ExportedProperty(category = "layout", mapping = { @ViewDebug.IntToString(from = MATCH_PARENT, to = "MATCH_PARENT"), diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 40aee96..592d6e2 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -2143,7 +2143,7 @@ public class WebView extends AbsoluteLayout /** * In addition to the FindListener that the user may set via the WebView.setFindListener * API, FindActionModeCallback will register it's own FindListener. We keep them separate - * via this class so that that the two FindListeners can potentially exist at once. + * via this class so that the two FindListeners can potentially exist at once. */ private class FindListenerDistributor implements FindListener { private FindListener mFindDialogFindListener; diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 0439168..6a34c80 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -2392,7 +2392,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te lp.itemId = mAdapter.getItemId(position); } lp.viewType = mAdapter.getItemViewType(position); - child.setLayoutParams(lp); + if (lp != vlp) { + child.setLayoutParams(lp); + } } class ListItemAccessibilityDelegate extends AccessibilityDelegate { diff --git a/core/java/android/widget/OverScroller.java b/core/java/android/widget/OverScroller.java index 7b3dd31..84b1d13 100644 --- a/core/java/android/widget/OverScroller.java +++ b/core/java/android/widget/OverScroller.java @@ -18,7 +18,6 @@ package android.widget; import android.content.Context; import android.hardware.SensorManager; -import android.util.FloatMath; import android.util.Log; import android.view.ViewConfiguration; import android.view.animation.AnimationUtils; @@ -181,9 +180,7 @@ public class OverScroller { * @return The original velocity less the deceleration, norm of the X and Y velocity vector. */ public float getCurrVelocity() { - float squaredNorm = mScrollerX.mCurrVelocity * mScrollerX.mCurrVelocity; - squaredNorm += mScrollerY.mCurrVelocity * mScrollerY.mCurrVelocity; - return FloatMath.sqrt(squaredNorm); + return (float) Math.hypot(mScrollerX.mCurrVelocity, mScrollerY.mCurrVelocity); } /** diff --git a/core/java/android/widget/Scroller.java b/core/java/android/widget/Scroller.java index 5e88a96..357c9c3 100644 --- a/core/java/android/widget/Scroller.java +++ b/core/java/android/widget/Scroller.java @@ -19,7 +19,6 @@ package android.widget; import android.content.Context; import android.hardware.SensorManager; import android.os.Build; -import android.util.FloatMath; import android.view.ViewConfiguration; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; @@ -425,7 +424,7 @@ public class Scroller { float dx = (float) (mFinalX - mStartX); float dy = (float) (mFinalY - mStartY); - float hyp = FloatMath.sqrt(dx * dx + dy * dy); + float hyp = (float) Math.hypot(dx, dy); float ndx = dx / hyp; float ndy = dy / hyp; @@ -442,7 +441,7 @@ public class Scroller { mMode = FLING_MODE; mFinished = false; - float velocity = FloatMath.sqrt(velocityX * velocityX + velocityY * velocityY); + float velocity = (float) Math.hypot(velocityX, velocityY); mVelocity = velocity; mDuration = getSplineFlingDuration(velocity); diff --git a/core/java/android/widget/StackView.java b/core/java/android/widget/StackView.java index d2e718c..9e168b8 100644 --- a/core/java/android/widget/StackView.java +++ b/core/java/android/widget/StackView.java @@ -1050,10 +1050,8 @@ public class StackView extends AdapterViewAnimator { if (mView != null) { final LayoutParams viewLp = (LayoutParams) mView.getLayoutParams(); - float d = (float) Math.sqrt(Math.pow(viewLp.horizontalOffset, 2) + - Math.pow(viewLp.verticalOffset, 2)); - float maxd = (float) Math.sqrt(Math.pow(mSlideAmount, 2) + - Math.pow(0.4f * mSlideAmount, 2)); + float d = (float) Math.hypot(viewLp.horizontalOffset, viewLp.verticalOffset); + float maxd = (float) Math.hypot(mSlideAmount, 0.4f * mSlideAmount); if (velocity == 0) { return (invert ? (1 - d / maxd) : d / maxd) * DEFAULT_ANIMATION_DURATION; diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 5cdee53..6345b79 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -92,7 +92,6 @@ import android.text.style.URLSpan; import android.text.style.UpdateAppearance; import android.text.util.Linkify; import android.util.AttributeSet; -import android.util.FloatMath; import android.util.Log; import android.util.TypedValue; import android.view.AccessibilityIterators.TextSegmentIterator; @@ -4790,7 +4789,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * make sure the entire cursor gets invalidated instead of * sometimes missing half a pixel. */ - float thick = FloatMath.ceil(mTextPaint.getStrokeWidth()); + float thick = (float) Math.ceil(mTextPaint.getStrokeWidth()); if (thick < 1.0f) { thick = 1.0f; } @@ -4800,10 +4799,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // mHighlightPath is guaranteed to be non null at that point. mHighlightPath.computeBounds(TEMP_RECTF, false); - invalidate((int) FloatMath.floor(horizontalPadding + TEMP_RECTF.left - thick), - (int) FloatMath.floor(verticalPadding + TEMP_RECTF.top - thick), - (int) FloatMath.ceil(horizontalPadding + TEMP_RECTF.right + thick), - (int) FloatMath.ceil(verticalPadding + TEMP_RECTF.bottom + thick)); + invalidate((int) Math.floor(horizontalPadding + TEMP_RECTF.left - thick), + (int) Math.floor(verticalPadding + TEMP_RECTF.top - thick), + (int) Math.ceil(horizontalPadding + TEMP_RECTF.right + thick), + (int) Math.ceil(verticalPadding + TEMP_RECTF.bottom + thick)); } } else { for (int i = 0; i < mEditor.mCursorCount; i++) { @@ -6491,7 +6490,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener max = Math.max(max, layout.getLineWidth(i)); } - return (int) FloatMath.ceil(max); + return (int) Math.ceil(max); } /** @@ -6568,7 +6567,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (boring == null || boring == UNKNOWN_BORING) { if (des < 0) { - des = (int) FloatMath.ceil(Layout.getDesiredWidth(mTransformed, mTextPaint)); + des = (int) Math.ceil(Layout.getDesiredWidth(mTransformed, mTextPaint)); } width = des; } else { @@ -6598,7 +6597,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (hintBoring == null || hintBoring == UNKNOWN_BORING) { if (hintDes < 0) { - hintDes = (int) FloatMath.ceil(Layout.getDesiredWidth(mHint, mTextPaint)); + hintDes = (int) Math.ceil(Layout.getDesiredWidth(mHint, mTextPaint)); } hintWidth = hintDes; } else { @@ -6904,8 +6903,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * keep leading edge in view. */ - int left = (int) FloatMath.floor(layout.getLineLeft(line)); - int right = (int) FloatMath.ceil(layout.getLineRight(line)); + int left = (int) Math.floor(layout.getLineLeft(line)); + int right = (int) Math.ceil(layout.getLineRight(line)); if (right - left < hspace) { scrollx = (right + left) / 2 - hspace / 2; @@ -6917,10 +6916,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } } else if (a == Layout.Alignment.ALIGN_RIGHT) { - int right = (int) FloatMath.ceil(layout.getLineRight(line)); + int right = (int) Math.ceil(layout.getLineRight(line)); scrollx = right - hspace; } else { // a == Layout.Alignment.ALIGN_LEFT (will also be the default) - scrollx = (int) FloatMath.floor(layout.getLineLeft(line)); + scrollx = (int) Math.floor(layout.getLineLeft(line)); } if (ht < vspace) { @@ -6995,8 +6994,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener final int top = layout.getLineTop(line); final int bottom = layout.getLineTop(line + 1); - int left = (int) FloatMath.floor(layout.getLineLeft(line)); - int right = (int) FloatMath.ceil(layout.getLineRight(line)); + int left = (int) Math.floor(layout.getLineLeft(line)); + int right = (int) Math.ceil(layout.getLineRight(line)); int ht = layout.getHeight(); int hspace = mRight - mLeft - getCompoundPaddingLeft() - getCompoundPaddingRight(); diff --git a/core/java/com/android/internal/app/ExternalMediaFormatActivity.java b/core/java/com/android/internal/app/ExternalMediaFormatActivity.java index 6ed3bdc..fc213c5 100644 --- a/core/java/com/android/internal/app/ExternalMediaFormatActivity.java +++ b/core/java/com/android/internal/app/ExternalMediaFormatActivity.java @@ -25,6 +25,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; +import android.os.storage.StorageVolume; import android.util.Log; /** @@ -94,6 +95,10 @@ public class ExternalMediaFormatActivity extends AlertActivity implements Dialog if (which == POSITIVE_BUTTON) { Intent intent = new Intent(ExternalStorageFormatter.FORMAT_ONLY); intent.setComponent(ExternalStorageFormatter.COMPONENT_NAME); + // Transfer the storage volume to the new intent + final StorageVolume storageVolume = getIntent().getParcelableExtra( + StorageVolume.EXTRA_STORAGE_VOLUME); + intent.putExtra(StorageVolume.EXTRA_STORAGE_VOLUME, storageVolume); startService(intent); } diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java index cca340c..fced092 100644 --- a/core/java/com/android/internal/os/Zygote.java +++ b/core/java/com/android/internal/os/Zygote.java @@ -20,12 +20,9 @@ package com.android.internal.os; import dalvik.system.ZygoteHooks; import android.system.ErrnoException; import android.system.Os; -import android.os.SystemClock; -import android.util.Slog; /** @hide */ public final class Zygote { - private static final String TAG = "Zygote"; /* * Bit values for "debugFlags" argument. The definitions are duplicated * in the native code. @@ -87,15 +84,11 @@ public final class Zygote { public static int forkAndSpecialize(int uid, int gid, int[] gids, int debugFlags, int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToClose, String instructionSet, String appDataDir) { - long startTime = SystemClock.elapsedRealtime(); VM_HOOKS.preFork(); - checkTime(startTime, "Zygote.preFork"); int pid = nativeForkAndSpecialize( uid, gid, gids, debugFlags, rlimits, mountExternal, seInfo, niceName, fdsToClose, instructionSet, appDataDir); - checkTime(startTime, "Zygote.nativeForkAndSpecialize"); VM_HOOKS.postForkCommon(); - checkTime(startTime, "Zygote.postForkCommon"); return pid; } @@ -104,18 +97,6 @@ public final class Zygote { String instructionSet, String appDataDir); /** - * Temporary hack: check time since start time and log if over a fixed threshold. - * - */ - private static void checkTime(long startTime, String where) { - long now = SystemClock.elapsedRealtime(); - if ((now-startTime) > 1000) { - // If we are taking more than a second, log about it. - Slog.w(TAG, "Slow operation: " + (now-startTime) + "ms so far, now at " + where); - } - } - - /** * Special method to start the system server process. In addition to the * common actions performed in forkAndSpecialize, the pid of the child * process is recorded such that the death of the child process will cause @@ -151,9 +132,7 @@ public final class Zygote { int[][] rlimits, long permittedCapabilities, long effectiveCapabilities); private static void callPostForkChildHooks(int debugFlags, String instructionSet) { - long startTime = SystemClock.elapsedRealtime(); VM_HOOKS.postForkChild(debugFlags, instructionSet); - checkTime(startTime, "Zygote.callPostForkChildHooks"); } diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java index 2ef8a20..24820bc 100644 --- a/core/java/com/android/internal/os/ZygoteConnection.java +++ b/core/java/com/android/internal/os/ZygoteConnection.java @@ -37,8 +37,6 @@ import java.io.PrintStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import libcore.io.IoUtils; -import android.os.SystemClock; -import android.util.Slog; /** * A connection that can make spawn requests. @@ -93,7 +91,7 @@ class ZygoteConnection { new InputStreamReader(socket.getInputStream()), 256); mSocket.setSoTimeout(CONNECTION_TIMEOUT_MILLIS); - + try { peer = mSocket.getPeerCredentials(); } catch (IOException ex) { @@ -105,23 +103,11 @@ class ZygoteConnection { } /** - * Temporary hack: check time since start time and log if over a fixed threshold. - * - */ - private void checkTime(long startTime, String where) { - long now = SystemClock.elapsedRealtime(); - if ((now-startTime) > 1000) { - // If we are taking more than a second, log about it. - Slog.w(TAG, "Slow operation: " + (now-startTime) + "ms so far, now at " + where); - } - } - - /** * Returns the file descriptor of the associated socket. * * @return null-ok; file descriptor */ - FileDescriptor getFileDescriptor() { + FileDescriptor getFileDesciptor() { return mSocket.getFileDescriptor(); } @@ -145,8 +131,6 @@ class ZygoteConnection { Arguments parsedArgs = null; FileDescriptor[] descriptors; - long startTime = SystemClock.elapsedRealtime(); - try { args = readArgumentList(); descriptors = mSocket.getAncillaryFileDescriptors(); @@ -156,7 +140,6 @@ class ZygoteConnection { return true; } - checkTime(startTime, "zygoteConnection.runOnce: readArgumentList"); if (args == null) { // EOF reached. closeSocket(); @@ -188,19 +171,14 @@ class ZygoteConnection { ", effective=0x" + Long.toHexString(parsedArgs.effectiveCapabilities)); } - applyUidSecurityPolicy(parsedArgs, peer, peerSecurityContext); applyRlimitSecurityPolicy(parsedArgs, peer, peerSecurityContext); applyInvokeWithSecurityPolicy(parsedArgs, peer, peerSecurityContext); applyseInfoSecurityPolicy(parsedArgs, peer, peerSecurityContext); - checkTime(startTime, "zygoteConnection.runOnce: apply security policies"); - applyDebuggerSystemProperty(parsedArgs); applyInvokeWithSystemProperty(parsedArgs); - checkTime(startTime, "zygoteConnection.runOnce: apply security policies"); - int[][] rlimits = null; if (parsedArgs.rlimits != null) { @@ -242,12 +220,10 @@ class ZygoteConnection { fd = null; - checkTime(startTime, "zygoteConnection.runOnce: preForkAndSpecialize"); pid = Zygote.forkAndSpecialize(parsedArgs.uid, parsedArgs.gid, parsedArgs.gids, parsedArgs.debugFlags, rlimits, parsedArgs.mountExternal, parsedArgs.seInfo, parsedArgs.niceName, fdsToClose, parsedArgs.instructionSet, parsedArgs.appDataDir); - checkTime(startTime, "zygoteConnection.runOnce: postForkAndSpecialize"); } catch (IOException ex) { logAndPrintError(newStderr, "Exception creating pipe", ex); } catch (ErrnoException ex) { @@ -620,7 +596,7 @@ class ZygoteConnection { } // See bug 1092107: large argc can be used for a DOS attack - if (argc > MAX_ZYGOTE_ARGC) { + if (argc > MAX_ZYGOTE_ARGC) { throw new IOException("max arg count exceeded"); } @@ -637,7 +613,7 @@ class ZygoteConnection { } /** - * Applies zygote security policy per bugs #875058 and #1082165. + * Applies zygote security policy per bugs #875058 and #1082165. * Based on the credentials of the process issuing a zygote command: * <ol> * <li> uid 0 (root) may specify any uid, gid, and setgroups() list @@ -668,7 +644,7 @@ class ZygoteConnection { /* In normal operation, SYSTEM_UID can only specify a restricted * set of UIDs. In factory test mode, SYSTEM_UID may specify any uid. */ - uidRestricted + uidRestricted = !(factoryTest.equals("1") || factoryTest.equals("2")); if (uidRestricted diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index 4dde217..46850da 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -91,12 +91,6 @@ public class ZygoteInit { private static Resources mResources; /** - * The number of times that the main Zygote loop - * should run before calling gc() again. - */ - static final int GC_LOOP_COUNT = 10; - - /** * The name of a resource file that contains classes to preload. */ private static final String PRELOADED_CLASSES = "preloaded-classes"; @@ -301,11 +295,6 @@ public class ZygoteInit { float defaultUtilization = runtime.getTargetHeapUtilization(); runtime.setTargetHeapUtilization(0.8f); - // Start with a clean slate. - System.gc(); - runtime.runFinalizationSync(); - Debug.startAllocCounting(); - try { BufferedReader br = new BufferedReader(new InputStreamReader(is), 256); @@ -324,15 +313,6 @@ public class ZygoteInit { Log.v(TAG, "Preloading " + line + "..."); } Class.forName(line); - if (Debug.getGlobalAllocSize() > PRELOAD_GC_THRESHOLD) { - if (false) { - Log.v(TAG, - " GC at " + Debug.getGlobalAllocSize()); - } - System.gc(); - runtime.runFinalizationSync(); - Debug.resetGlobalAllocSize(); - } count++; } catch (ClassNotFoundException e) { Log.w(TAG, "Class not found for preloading: " + line); @@ -362,8 +342,6 @@ public class ZygoteInit { // Fill in dex caches with classes, fields, and methods brought in by preloading. runtime.preloadDexCaches(); - Debug.stopAllocCounting(); - // Bring back root. We'll need it later. setEffectiveUser(ROOT_UID); setEffectiveGroup(ROOT_GID); @@ -381,10 +359,7 @@ public class ZygoteInit { private static void preloadResources() { final VMRuntime runtime = VMRuntime.getRuntime(); - Debug.startAllocCounting(); try { - System.gc(); - runtime.runFinalizationSync(); mResources = Resources.getSystem(); mResources.startPreloading(); if (PRELOAD_RESOURCES) { @@ -409,22 +384,12 @@ public class ZygoteInit { mResources.finishPreloading(); } catch (RuntimeException e) { Log.w(TAG, "Failure preloading resources", e); - } finally { - Debug.stopAllocCounting(); } } private static int preloadColorStateLists(VMRuntime runtime, TypedArray ar) { int N = ar.length(); for (int i=0; i<N; i++) { - if (Debug.getGlobalAllocSize() > PRELOAD_GC_THRESHOLD) { - if (false) { - Log.v(TAG, " GC at " + Debug.getGlobalAllocSize()); - } - System.gc(); - runtime.runFinalizationSync(); - Debug.resetGlobalAllocSize(); - } int id = ar.getResourceId(i, 0); if (false) { Log.v(TAG, "Preloading resource #" + Integer.toHexString(id)); @@ -445,14 +410,6 @@ public class ZygoteInit { private static int preloadDrawables(VMRuntime runtime, TypedArray ar) { int N = ar.length(); for (int i=0; i<N; i++) { - if (Debug.getGlobalAllocSize() > PRELOAD_GC_THRESHOLD) { - if (false) { - Log.v(TAG, " GC at " + Debug.getGlobalAllocSize()); - } - System.gc(); - runtime.runFinalizationSync(); - Debug.resetGlobalAllocSize(); - } int id = ar.getResourceId(i, 0); if (false) { Log.v(TAG, "Preloading resource #" + Integer.toHexString(id)); @@ -474,7 +431,7 @@ public class ZygoteInit { * softly- and final-reachable objects, along with any other garbage. * This is only useful just before a fork(). */ - /*package*/ static void gc() { + /*package*/ static void gcAndFinalize() { final VMRuntime runtime = VMRuntime.getRuntime(); /* runFinalizationSync() lets finalizers be called in Zygote, @@ -483,9 +440,6 @@ public class ZygoteInit { System.gc(); runtime.runFinalizationSync(); System.gc(); - runtime.runFinalizationSync(); - System.gc(); - runtime.runFinalizationSync(); } /** @@ -676,7 +630,7 @@ public class ZygoteInit { SamplingProfilerIntegration.writeZygoteSnapshot(); // Do an initial gc to clean up after startup - gc(); + gcAndFinalize(); // Disable tracing so that forked processes do not inherit stale tracing tags from // Zygote. @@ -745,27 +699,9 @@ public class ZygoteInit { fds.add(sServerSocket.getFileDescriptor()); peers.add(null); - int loopCount = GC_LOOP_COUNT; while (true) { int index; - /* - * Call gc() before we block in select(). - * It's work that has to be done anyway, and it's better - * to avoid making every child do it. It will also - * madvise() any free memory as a side-effect. - * - * Don't call it every time, because walking the entire - * heap is a lot of overhead to free a few hundred bytes. - */ - if (loopCount <= 0) { - gc(); - loopCount = GC_LOOP_COUNT; - } else { - loopCount--; - } - - try { fdArray = fds.toArray(fdArray); index = selectReadable(fdArray); @@ -778,7 +714,7 @@ public class ZygoteInit { } else if (index == 0) { ZygoteConnection newPeer = acceptCommandPeer(abiList); peers.add(newPeer); - fds.add(newPeer.getFileDescriptor()); + fds.add(newPeer.getFileDesciptor()); } else { boolean done; done = peers.get(index).runOnce(); diff --git a/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java b/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java index b680fab..11ac19e 100644 --- a/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java +++ b/core/java/com/android/internal/widget/multiwaveview/GlowPadView.java @@ -863,7 +863,7 @@ public class GlowPadView extends View { // tx and ty are relative to wave center float tx = eventX - mWaveCenterX; float ty = eventY - mWaveCenterY; - float touchRadius = (float) Math.sqrt(dist2(tx, ty)); + float touchRadius = (float) Math.hypot(tx, ty); final float scale = touchRadius > mOuterRadius ? mOuterRadius / touchRadius : 1.0f; float limitX = tx * scale; float limitY = ty * scale; diff --git a/core/java/com/android/internal/widget/multiwaveview/PointCloud.java b/core/java/com/android/internal/widget/multiwaveview/PointCloud.java index f299935..6f26b99 100644 --- a/core/java/com/android/internal/widget/multiwaveview/PointCloud.java +++ b/core/java/com/android/internal/widget/multiwaveview/PointCloud.java @@ -22,7 +22,6 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.drawable.Drawable; -import android.util.FloatMath; import android.util.Log; public class PointCloud { @@ -151,8 +150,8 @@ public class PointCloud { float eta = PI/2.0f; float dEta = 2.0f * PI / pointsInBand; for (int i = 0; i < pointsInBand; i++) { - float x = r * FloatMath.cos(eta); - float y = r * FloatMath.sin(eta); + float x = r * (float) Math.cos(eta); + float y = r * (float) Math.sin(eta); eta += dEta; mPointCloud.add(new Point(x, y, r)); } @@ -167,32 +166,24 @@ public class PointCloud { return mScale; } - private static float hypot(float x, float y) { - return FloatMath.sqrt(x*x + y*y); - } - - private static float max(float a, float b) { - return a > b ? a : b; - } - public int getAlphaForPoint(Point point) { // Contribution from positional glow - float glowDistance = hypot(glowManager.x - point.x, glowManager.y - point.y); + float glowDistance = (float) Math.hypot(glowManager.x - point.x, glowManager.y - point.y); float glowAlpha = 0.0f; if (glowDistance < glowManager.radius) { - float cosf = FloatMath.cos(PI * 0.25f * glowDistance / glowManager.radius); - glowAlpha = glowManager.alpha * max(0.0f, (float) Math.pow(cosf, 10.0f)); + float cosf = (float) Math.cos(PI * 0.25f * glowDistance / glowManager.radius); + glowAlpha = glowManager.alpha * Math.max(0.0f, (float) Math.pow(cosf, 10.0f)); } // Compute contribution from Wave - float radius = hypot(point.x, point.y); + float radius = (float) Math.hypot(point.x, point.y); float waveAlpha = 0.0f; if (radius < waveManager.radius * 2) { float distanceToWaveRing = (radius - waveManager.radius); - float cosf = FloatMath.cos(PI * 0.5f * distanceToWaveRing / waveManager.radius); - waveAlpha = waveManager.alpha * max(0.0f, (float) Math.pow(cosf, 6.0f)); + float cosf = (float) Math.cos(PI * 0.5f * distanceToWaveRing / waveManager.radius); + waveAlpha = waveManager.alpha * Math.max(0.0f, (float) Math.pow(cosf, 6.0f)); } - return (int) (max(glowAlpha, waveAlpha) * 255); + return (int) (Math.max(glowAlpha, waveAlpha) * 255); } private float interp(float min, float max, float f) { |