summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/Fragment.java9
-rw-r--r--core/java/android/app/FragmentManager.java4
-rw-r--r--core/java/android/app/FragmentTransaction.java2
-rw-r--r--core/java/android/app/Notification.java1
-rw-r--r--core/java/android/bluetooth/BluetoothA2dp.java3
-rw-r--r--core/java/android/content/res/AssetManager.java16
-rw-r--r--core/java/android/content/res/StringBlock.java10
-rw-r--r--core/java/android/gesture/GestureOverlayView.java2
-rw-r--r--core/java/android/gesture/GestureStroke.java3
-rw-r--r--core/java/android/gesture/GestureUtils.java8
-rw-r--r--core/java/android/hardware/GeomagneticField.java2
-rw-r--r--core/java/android/net/LocalSocket.java2
-rw-r--r--core/java/android/net/Proxy.java29
-rw-r--r--core/java/android/net/SSLCertificateSocketFactory.java2
-rw-r--r--core/java/android/net/http/CharArrayBuffers.java89
-rw-r--r--core/java/android/net/http/Connection.java57
-rw-r--r--core/java/android/net/http/Headers.java59
-rw-r--r--core/java/android/net/http/HttpsConnection.java2
-rw-r--r--core/java/android/net/http/Timer.java41
-rw-r--r--core/java/android/net/http/X509TrustManagerExtensions.java3
-rw-r--r--core/java/android/os/Build.java3
-rw-r--r--core/java/android/provider/DocumentsProvider.java2
-rw-r--r--core/java/android/text/BoringLayout.java5
-rw-r--r--core/java/android/text/Html.java2
-rw-r--r--core/java/android/text/TextUtils.java9
-rwxr-xr-xcore/java/android/text/format/DateFormat.java75
-rw-r--r--core/java/android/text/format/Time.java33
-rw-r--r--core/java/android/util/FloatMath.java43
-rw-r--r--core/java/android/util/MathUtils.java4
-rw-r--r--core/java/android/view/ScaleGestureDetector.java3
-rw-r--r--core/java/android/view/ViewGroup.java8
-rw-r--r--core/java/android/webkit/LegacyErrorStrings.java (renamed from core/java/android/net/http/ErrorStrings.java)11
-rw-r--r--core/java/android/webkit/WebView.java2
-rw-r--r--core/java/android/webkit/WebViewDelegate.java3
-rw-r--r--core/java/android/widget/AbsListView.java4
-rw-r--r--core/java/android/widget/AbsSeekBar.java21
-rw-r--r--core/java/android/widget/DateTimeView.java21
-rw-r--r--core/java/android/widget/ListView.java19
-rw-r--r--core/java/android/widget/OverScroller.java5
-rw-r--r--core/java/android/widget/PopupWindow.java6
-rw-r--r--core/java/android/widget/Scroller.java5
-rw-r--r--core/java/android/widget/StackView.java6
-rw-r--r--core/java/android/widget/TextClock.java8
-rw-r--r--core/java/android/widget/TextView.java33
44 files changed, 308 insertions, 367 deletions
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/app/Notification.java b/core/java/android/app/Notification.java
index 9e8a793..8dce59a 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -1736,6 +1736,7 @@ public class Notification implements Parcelable
builder.setSound(this.sound, this.audioStreamType);
builder.setDefaults(this.defaults);
builder.setVibrate(this.vibrate);
+ builder.setDeleteIntent(this.deleteIntent);
// now apply the latestEventInfo fields
if (contentTitle != null) {
diff --git a/core/java/android/bluetooth/BluetoothA2dp.java b/core/java/android/bluetooth/BluetoothA2dp.java
index 5175490..0450150 100644
--- a/core/java/android/bluetooth/BluetoothA2dp.java
+++ b/core/java/android/bluetooth/BluetoothA2dp.java
@@ -199,7 +199,8 @@ public final class BluetoothA2dp implements BluetoothProfile {
}
public void finalize() {
- close();
+ // The empty finalize needs to be kept or the
+ // cts signature tests would fail.
}
/**
* Initiate connection to a profile of the remote bluetooth device.
diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java
index ecae52c..a176593 100644
--- a/core/java/android/content/res/AssetManager.java
+++ b/core/java/android/content/res/AssetManager.java
@@ -627,7 +627,21 @@ public final class AssetManager implements AutoCloseable {
*
* {@hide}
*/
- public native final int addOverlayPath(String idmapPath);
+
+ public final int addOverlayPath(String idmapPath) {
+ synchronized (this) {
+ int res = addOverlayPathNative(idmapPath);
+ makeStringBlocks(mStringBlocks);
+ return res;
+ }
+ }
+
+ /**
+ * See addOverlayPath.
+ *
+ * {@hide}
+ */
+ public native final int addOverlayPathNative(String idmapPath);
/**
* Add multiple sets of assets to the asset manager at once. See
diff --git a/core/java/android/content/res/StringBlock.java b/core/java/android/content/res/StringBlock.java
index 77b8a33..9652db7 100644
--- a/core/java/android/content/res/StringBlock.java
+++ b/core/java/android/content/res/StringBlock.java
@@ -311,13 +311,13 @@ final class StringBlock {
* the color black is returned instead.
*
* @param color The color as a string. Can be a resource reference,
- * HTML hexadecimal, octal or a name
+ * hexadecimal, octal or a name
* @param foreground True if the color will be used as the foreground color,
* false otherwise
*
* @return A CharacterStyle
*
- * @see Color#getHtmlColor(String)
+ * @see Color#parseColor(String)
*/
private static CharacterStyle getColor(String color, boolean foreground) {
int c = 0xff000000;
@@ -336,7 +336,11 @@ final class StringBlock {
}
}
} else {
- c = Color.getHtmlColor(color);
+ try {
+ c = Color.parseColor(color);
+ } catch (IllegalArgumentException e) {
+ c = Color.BLACK;
+ }
}
}
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..4a324f9 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/net/Proxy.java b/core/java/android/net/Proxy.java
index 3477b02..17a84a7 100644
--- a/core/java/android/net/Proxy.java
+++ b/core/java/android/net/Proxy.java
@@ -22,8 +22,6 @@ import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
-import org.apache.http.HttpHost;
-
import java.net.InetSocketAddress;
import java.net.ProxySelector;
import java.net.URI;
@@ -37,8 +35,6 @@ import java.util.regex.Pattern;
*/
public final class Proxy {
- // Set to true to enable extra debugging.
- private static final boolean DEBUG = false;
private static final String TAG = "Proxy";
private static final ProxySelector sDefaultProxySelector;
@@ -192,31 +188,6 @@ public final class Proxy {
}
}
- /**
- * Returns the preferred proxy to be used by clients. This is a wrapper
- * around {@link android.net.Proxy#getHost()}.
- *
- * @param context the context which will be passed to
- * {@link android.net.Proxy#getHost()}
- * @param url the target URL for the request
- * @note Calling this method requires permission
- * android.permission.ACCESS_NETWORK_STATE
- * @return The preferred proxy to be used by clients, or null if there
- * is no proxy.
- * {@hide}
- */
- // TODO: Get rid of this method. It's used only in tests.
- public static final HttpHost getPreferredHttpHost(Context context,
- String url) {
- java.net.Proxy prefProxy = getProxy(context, url);
- if (prefProxy.equals(java.net.Proxy.NO_PROXY)) {
- return null;
- } else {
- InetSocketAddress sa = (InetSocketAddress)prefProxy.address();
- return new HttpHost(sa.getHostName(), sa.getPort(), "http");
- }
- }
-
private static final boolean isLocalHost(String host) {
if (host == null) {
return false;
diff --git a/core/java/android/net/SSLCertificateSocketFactory.java b/core/java/android/net/SSLCertificateSocketFactory.java
index c15e6e5..6654577 100644
--- a/core/java/android/net/SSLCertificateSocketFactory.java
+++ b/core/java/android/net/SSLCertificateSocketFactory.java
@@ -208,7 +208,7 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory {
private SSLSocketFactory makeSocketFactory(
KeyManager[] keyManagers, TrustManager[] trustManagers) {
try {
- OpenSSLContextImpl sslContext = new OpenSSLContextImpl();
+ OpenSSLContextImpl sslContext = OpenSSLContextImpl.getPreferred();
sslContext.engineInit(keyManagers, trustManagers, null);
sslContext.engineGetClientSessionContext().setPersistentCache(mSessionCache);
return sslContext.engineGetSocketFactory();
diff --git a/core/java/android/net/http/CharArrayBuffers.java b/core/java/android/net/http/CharArrayBuffers.java
deleted file mode 100644
index 77d45f6..0000000
--- a/core/java/android/net/http/CharArrayBuffers.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.http;
-
-import org.apache.http.util.CharArrayBuffer;
-import org.apache.http.protocol.HTTP;
-
-/**
- * Utility methods for working on CharArrayBuffers.
- *
- * {@hide}
- */
-class CharArrayBuffers {
-
- static final char uppercaseAddon = 'a' - 'A';
-
- /**
- * Returns true if the buffer contains the given string. Ignores leading
- * whitespace and case.
- *
- * @param buffer to search
- * @param beginIndex index at which we should start
- * @param str to search for
- */
- static boolean containsIgnoreCaseTrimmed(CharArrayBuffer buffer,
- int beginIndex, final String str) {
- int len = buffer.length();
- char[] chars = buffer.buffer();
- while (beginIndex < len && HTTP.isWhitespace(chars[beginIndex])) {
- beginIndex++;
- }
- int size = str.length();
- boolean ok = len >= beginIndex + size;
- for (int j=0; ok && (j<size); j++) {
- char a = chars[beginIndex+j];
- char b = str.charAt(j);
- if (a != b) {
- a = toLower(a);
- b = toLower(b);
- ok = a == b;
- }
- }
- return ok;
- }
-
- /**
- * Returns index of first occurence ch. Lower cases characters leading up
- * to first occurrence of ch.
- */
- static int setLowercaseIndexOf(CharArrayBuffer buffer, final int ch) {
-
- int beginIndex = 0;
- int endIndex = buffer.length();
- char[] chars = buffer.buffer();
-
- for (int i = beginIndex; i < endIndex; i++) {
- char current = chars[i];
- if (current == ch) {
- return i;
- } else if (current >= 'A' && current <= 'Z'){
- // make lower case
- current += uppercaseAddon;
- chars[i] = current;
- }
- }
- return -1;
- }
-
- private static char toLower(char c) {
- if (c >= 'A' && c <= 'Z'){
- c += uppercaseAddon;
- }
- return c;
- }
-}
diff --git a/core/java/android/net/http/Connection.java b/core/java/android/net/http/Connection.java
index 834ad69..831bd0e 100644
--- a/core/java/android/net/http/Connection.java
+++ b/core/java/android/net/http/Connection.java
@@ -436,7 +436,7 @@ abstract class Connection {
ret = false;
String error;
if (errorId < 0) {
- error = ErrorStrings.getString(errorId, mContext);
+ error = getEventHandlerErrorString(errorId);
} else {
Throwable cause = e.getCause();
error = cause != null ? cause.toString() : e.getMessage();
@@ -451,6 +451,61 @@ abstract class Connection {
return ret;
}
+ private static String getEventHandlerErrorString(int errorId) {
+ switch (errorId) {
+ case EventHandler.OK:
+ return "OK";
+
+ case EventHandler.ERROR:
+ return "ERROR";
+
+ case EventHandler.ERROR_LOOKUP:
+ return "ERROR_LOOKUP";
+
+ case EventHandler.ERROR_UNSUPPORTED_AUTH_SCHEME:
+ return "ERROR_UNSUPPORTED_AUTH_SCHEME";
+
+ case EventHandler.ERROR_AUTH:
+ return "ERROR_AUTH";
+
+ case EventHandler.ERROR_PROXYAUTH:
+ return "ERROR_PROXYAUTH";
+
+ case EventHandler.ERROR_CONNECT:
+ return "ERROR_CONNECT";
+
+ case EventHandler.ERROR_IO:
+ return "ERROR_IO";
+
+ case EventHandler.ERROR_TIMEOUT:
+ return "ERROR_TIMEOUT";
+
+ case EventHandler.ERROR_REDIRECT_LOOP:
+ return "ERROR_REDIRECT_LOOP";
+
+ case EventHandler.ERROR_UNSUPPORTED_SCHEME:
+ return "ERROR_UNSUPPORTED_SCHEME";
+
+ case EventHandler.ERROR_FAILED_SSL_HANDSHAKE:
+ return "ERROR_FAILED_SSL_HANDSHAKE";
+
+ case EventHandler.ERROR_BAD_URL:
+ return "ERROR_BAD_URL";
+
+ case EventHandler.FILE_ERROR:
+ return "FILE_ERROR";
+
+ case EventHandler.FILE_NOT_FOUND_ERROR:
+ return "FILE_NOT_FOUND_ERROR";
+
+ case EventHandler.TOO_MANY_REQUESTS_ERROR:
+ return "TOO_MANY_REQUESTS_ERROR";
+
+ default:
+ return "UNKNOWN_ERROR";
+ }
+ }
+
HttpContext getHttpContext() {
return mHttpContext;
}
diff --git a/core/java/android/net/http/Headers.java b/core/java/android/net/http/Headers.java
index 657e071..0f8b105 100644
--- a/core/java/android/net/http/Headers.java
+++ b/core/java/android/net/http/Headers.java
@@ -158,7 +158,7 @@ public final class Headers {
}
public void parseHeader(CharArrayBuffer buffer) {
- int pos = CharArrayBuffers.setLowercaseIndexOf(buffer, ':');
+ int pos = setLowercaseIndexOf(buffer, ':');
if (pos == -1) {
return;
}
@@ -459,12 +459,63 @@ public final class Headers {
}
private void setConnectionType(CharArrayBuffer buffer, int pos) {
- if (CharArrayBuffers.containsIgnoreCaseTrimmed(
- buffer, pos, HTTP.CONN_CLOSE)) {
+ if (containsIgnoreCaseTrimmed(buffer, pos, HTTP.CONN_CLOSE)) {
connectionType = CONN_CLOSE;
- } else if (CharArrayBuffers.containsIgnoreCaseTrimmed(
+ } else if (containsIgnoreCaseTrimmed(
buffer, pos, HTTP.CONN_KEEP_ALIVE)) {
connectionType = CONN_KEEP_ALIVE;
}
}
+
+
+ /**
+ * Returns true if the buffer contains the given string. Ignores leading
+ * whitespace and case.
+ *
+ * @param buffer to search
+ * @param beginIndex index at which we should start
+ * @param str to search for
+ */
+ static boolean containsIgnoreCaseTrimmed(CharArrayBuffer buffer,
+ int beginIndex, final String str) {
+ int len = buffer.length();
+ char[] chars = buffer.buffer();
+ while (beginIndex < len && HTTP.isWhitespace(chars[beginIndex])) {
+ beginIndex++;
+ }
+ int size = str.length();
+ boolean ok = len >= (beginIndex + size);
+ for (int j=0; ok && (j < size); j++) {
+ char a = chars[beginIndex + j];
+ char b = str.charAt(j);
+ if (a != b) {
+ a = Character.toLowerCase(a);
+ b = Character.toLowerCase(b);
+ ok = a == b;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns index of first occurence ch. Lower cases characters leading up
+ * to first occurrence of ch.
+ */
+ static int setLowercaseIndexOf(CharArrayBuffer buffer, final int ch) {
+
+ int beginIndex = 0;
+ int endIndex = buffer.length();
+ char[] chars = buffer.buffer();
+
+ for (int i = beginIndex; i < endIndex; i++) {
+ char current = chars[i];
+ if (current == ch) {
+ return i;
+ } else {
+ chars[i] = Character.toLowerCase(current);
+ }
+ }
+ return -1;
+ }
}
diff --git a/core/java/android/net/http/HttpsConnection.java b/core/java/android/net/http/HttpsConnection.java
index 6bf01e2..a8674de 100644
--- a/core/java/android/net/http/HttpsConnection.java
+++ b/core/java/android/net/http/HttpsConnection.java
@@ -79,7 +79,7 @@ public class HttpsConnection extends Connection {
cache = FileClientSessionCache.usingDirectory(sessionDir);
}
- OpenSSLContextImpl sslContext = new OpenSSLContextImpl();
+ OpenSSLContextImpl sslContext = OpenSSLContextImpl.getPreferred();
// here, trust managers is a single trust-all manager
TrustManager[] trustManagers = new TrustManager[] {
diff --git a/core/java/android/net/http/Timer.java b/core/java/android/net/http/Timer.java
deleted file mode 100644
index cc15a30..0000000
--- a/core/java/android/net/http/Timer.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.http;
-
-import android.os.SystemClock;
-
-/**
- * {@hide}
- * Debugging tool
- */
-class Timer {
-
- private long mStart;
- private long mLast;
-
- public Timer() {
- mStart = mLast = SystemClock.uptimeMillis();
- }
-
- public void mark(String message) {
- long now = SystemClock.uptimeMillis();
- if (HttpLog.LOGV) {
- HttpLog.v(message + " " + (now - mLast) + " total " + (now - mStart));
- }
- mLast = now;
- }
-}
diff --git a/core/java/android/net/http/X509TrustManagerExtensions.java b/core/java/android/net/http/X509TrustManagerExtensions.java
index 6a63a0c..bb36c20 100644
--- a/core/java/android/net/http/X509TrustManagerExtensions.java
+++ b/core/java/android/net/http/X509TrustManagerExtensions.java
@@ -36,7 +36,7 @@ import javax.net.ssl.X509TrustManager;
*/
public class X509TrustManagerExtensions {
- TrustManagerImpl mDelegate;
+ final TrustManagerImpl mDelegate;
/**
* Constructs a new X509TrustManagerExtensions wrapper.
@@ -48,6 +48,7 @@ public class X509TrustManagerExtensions {
if (tm instanceof TrustManagerImpl) {
mDelegate = (TrustManagerImpl) tm;
} else {
+ mDelegate = null;
throw new IllegalArgumentException("tm is an instance of " + tm.getClass().getName() +
" which is not a supported type of X509TrustManager");
}
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index 4b0cef6..b209690 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -518,7 +518,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 4135e8b..1316471 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
* &lt;img&gt; 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/DateFormat.java b/core/java/android/text/format/DateFormat.java
index 72bbb2b..c03f7a6 100755
--- a/core/java/android/text/format/DateFormat.java
+++ b/core/java/android/text/format/DateFormat.java
@@ -278,73 +278,18 @@ public class DateFormat {
*/
public static String getTimeFormatString(Context context, int userHandle) {
LocaleData d = LocaleData.get(context.getResources().getConfiguration().locale);
- return is24HourFormat(context, userHandle) ? d.timeFormat24 : d.timeFormat12;
+ return is24HourFormat(context, userHandle) ? d.timeFormat_Hm : d.timeFormat_hm;
}
/**
* Returns a {@link java.text.DateFormat} object that can format the date
- * in short form (such as 12/31/1999) according
- * to the current locale and the user's date-order preference.
+ * in short form according to the current locale.
+ *
* @param context the application context
* @return the {@link java.text.DateFormat} object that properly formats the date.
*/
public static java.text.DateFormat getDateFormat(Context context) {
- String value = Settings.System.getString(context.getContentResolver(),
- Settings.System.DATE_FORMAT);
-
- return getDateFormatForSetting(context, value);
- }
-
- /**
- * Returns a {@link java.text.DateFormat} object to format the date
- * as if the date format setting were set to <code>value</code>,
- * including null to use the locale's default format.
- * @param context the application context
- * @param value the date format setting string to interpret for
- * the current locale
- * @hide
- */
- public static java.text.DateFormat getDateFormatForSetting(Context context,
- String value) {
- String format = getDateFormatStringForSetting(context, value);
- return new java.text.SimpleDateFormat(format);
- }
-
- private static String getDateFormatStringForSetting(Context context, String value) {
- if (value != null) {
- int month = value.indexOf('M');
- int day = value.indexOf('d');
- int year = value.indexOf('y');
-
- if (month >= 0 && day >= 0 && year >= 0) {
- String template = context.getString(R.string.numeric_date_template);
- if (year < month && year < day) {
- if (month < day) {
- value = String.format(template, "yyyy", "MM", "dd");
- } else {
- value = String.format(template, "yyyy", "dd", "MM");
- }
- } else if (month < day) {
- if (day < year) {
- value = String.format(template, "MM", "dd", "yyyy");
- } else { // unlikely
- value = String.format(template, "MM", "yyyy", "dd");
- }
- } else { // day < month
- if (month < year) {
- value = String.format(template, "dd", "MM", "yyyy");
- } else { // unlikely
- value = String.format(template, "dd", "yyyy", "MM");
- }
- }
-
- return value;
- }
- }
-
- // The setting is not set; use the locale's default.
- LocaleData d = LocaleData.get(context.getResources().getConfiguration().locale);
- return d.shortDateFormat4;
+ return java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT);
}
/**
@@ -377,14 +322,16 @@ public class DateFormat {
* order returned here.
*/
public static char[] getDateFormatOrder(Context context) {
- return ICU.getDateFormatOrder(getDateFormatString(context));
+ return ICU.getDateFormatOrder(getDateFormatString());
}
- private static String getDateFormatString(Context context) {
- String value = Settings.System.getString(context.getContentResolver(),
- Settings.System.DATE_FORMAT);
+ private static String getDateFormatString() {
+ java.text.DateFormat df = java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT);
+ if (df instanceof SimpleDateFormat) {
+ return ((SimpleDateFormat) df).toPattern();
+ }
- return getDateFormatStringForSetting(context, value);
+ throw new AssertionError("!(df instanceof SimpleDateFormat)");
}
/**
diff --git a/core/java/android/text/format/Time.java b/core/java/android/text/format/Time.java
index 1e04eb4..0c66709 100644
--- a/core/java/android/text/format/Time.java
+++ b/core/java/android/text/format/Time.java
@@ -215,13 +215,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);
@@ -317,6 +319,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}
@@ -730,6 +737,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) {
@@ -825,6 +840,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) &lt; 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
*/
@@ -837,6 +856,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) &gt; 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
*/
@@ -917,6 +940,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/FloatMath.java b/core/java/android/util/FloatMath.java
index bdcf5ca..8f488af 100644
--- a/core/java/android/util/FloatMath.java
+++ b/core/java/android/util/FloatMath.java
@@ -17,10 +17,13 @@
package android.util;
/**
- * Math routines similar to those found in {@link java.lang.Math}. On
- * versions of Android with a JIT, these are significantly slower than
- * the equivalent {@code Math} functions, which should be used in preference
- * to these.
+ * Math routines similar to those found in {@link java.lang.Math}.
+ *
+ * <p>Historically these methods were faster than the equivalent double-based
+ * {@link java.lang.Math} methods. On versions of Android with a JIT they
+ * became slower and have since been re-implemented to wrap calls to
+ * {@link java.lang.Math}. {@link java.lang.Math} should be used in
+ * preference.
*
* @deprecated Use {@link java.lang.Math} instead.
*/
@@ -37,7 +40,9 @@ public class FloatMath {
* @param value to be converted
* @return the floor of value
*/
- public static native float floor(float value);
+ public static float floor(float value) {
+ return (float) Math.floor(value);
+ }
/**
* Returns the float conversion of the most negative (i.e. closest to
@@ -46,7 +51,9 @@ public class FloatMath {
* @param value to be converted
* @return the ceiling of value
*/
- public static native float ceil(float value);
+ public static float ceil(float value) {
+ return (float) Math.ceil(value);
+ }
/**
* Returns the closest float approximation of the sine of the argument.
@@ -54,7 +61,9 @@ public class FloatMath {
* @param angle to compute the cosine of, in radians
* @return the sine of angle
*/
- public static native float sin(float angle);
+ public static float sin(float angle) {
+ return (float) Math.sin(angle);
+ }
/**
* Returns the closest float approximation of the cosine of the argument.
@@ -62,7 +71,9 @@ public class FloatMath {
* @param angle to compute the cosine of, in radians
* @return the cosine of angle
*/
- public static native float cos(float angle);
+ public static float cos(float angle) {
+ return (float) Math.cos(angle);
+ }
/**
* Returns the closest float approximation of the square root of the
@@ -71,7 +82,9 @@ public class FloatMath {
* @param value to compute sqrt of
* @return the square root of value
*/
- public static native float sqrt(float value);
+ public static float sqrt(float value) {
+ return (float) Math.sqrt(value);
+ }
/**
* Returns the closest float approximation of the raising "e" to the power
@@ -80,7 +93,9 @@ public class FloatMath {
* @param value to compute the exponential of
* @return the exponential of value
*/
- public static native float exp(float value);
+ public static float exp(float value) {
+ return (float) Math.exp(value);
+ }
/**
* Returns the closest float approximation of the result of raising {@code
@@ -90,7 +105,9 @@ public class FloatMath {
* @param y the exponent of the operation.
* @return {@code x} to the power of {@code y}.
*/
- public static native float pow(float x, float y);
+ public static float pow(float x, float y) {
+ return (float) Math.pow(x, y);
+ }
/**
* Returns {@code sqrt(}<i>{@code x}</i><sup>{@code 2}</sup>{@code +} <i>
@@ -100,5 +117,7 @@ public class FloatMath {
* @param y a float number
* @return the hypotenuse
*/
- public static native float hypot(float x, float y);
+ public static float hypot(float x, float y) {
+ return (float) Math.hypot(x, y);
+ }
}
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 1551504..512ea99 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -6453,8 +6453,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"),
@@ -6464,8 +6464,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/net/http/ErrorStrings.java b/core/java/android/webkit/LegacyErrorStrings.java
index 8383681..11fc05d 100644
--- a/core/java/android/net/http/ErrorStrings.java
+++ b/core/java/android/webkit/LegacyErrorStrings.java
@@ -14,9 +14,10 @@
* limitations under the License.
*/
-package android.net.http;
+package android.webkit;
import android.content.Context;
+import android.net.http.EventHandler;
import android.util.Log;
/**
@@ -24,8 +25,8 @@ import android.util.Log;
*
* {@hide}
*/
-public class ErrorStrings {
- private ErrorStrings() { /* Utility class, don't instantiate. */ }
+class LegacyErrorStrings {
+ private LegacyErrorStrings() { /* Utility class, don't instantiate. */ }
private static final String LOGTAG = "Http";
@@ -33,7 +34,7 @@ public class ErrorStrings {
* Get the localized error message resource for the given error code.
* If the code is unknown, we'll return a generic error message.
*/
- public static String getString(int errorCode, Context context) {
+ static String getString(int errorCode, Context context) {
return context.getText(getResource(errorCode)).toString();
}
@@ -41,7 +42,7 @@ public class ErrorStrings {
* Get the localized error message resource for the given error code.
* If the code is unknown, we'll return a generic error message.
*/
- public static int getResource(int errorCode) {
+ private static int getResource(int errorCode) {
switch(errorCode) {
case EventHandler.OK:
return com.android.internal.R.string.httpErrorOk;
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 8d2c51f..6793634 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -2151,7 +2151,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/webkit/WebViewDelegate.java b/core/java/android/webkit/WebViewDelegate.java
index e03445e..ac360fa 100644
--- a/core/java/android/webkit/WebViewDelegate.java
+++ b/core/java/android/webkit/WebViewDelegate.java
@@ -22,7 +22,6 @@ import android.app.Application;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
-import android.net.http.ErrorStrings;
import android.os.SystemProperties;
import android.os.Trace;
import android.util.SparseArray;
@@ -150,7 +149,7 @@ public final class WebViewDelegate {
* Returns the error string for the given {@code errorCode}.
*/
public String getErrorString(Context context, int errorCode) {
- return ErrorStrings.getString(errorCode, context);
+ return LegacyErrorStrings.getString(errorCode, context);
}
/**
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 6927660..ae10a9a 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/AbsSeekBar.java b/core/java/android/widget/AbsSeekBar.java
index 4800c7f..a3ce808 100644
--- a/core/java/android/widget/AbsSeekBar.java
+++ b/core/java/android/widget/AbsSeekBar.java
@@ -695,19 +695,20 @@ public abstract class AbsSeekBar extends ProgressBar {
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (isEnabled()) {
- int progress = getProgress();
+ int increment = mKeyProgressIncrement;
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_LEFT:
- if (progress <= 0) break;
- setProgress(progress - mKeyProgressIncrement, true);
- onKeyChange();
- return true;
-
+ increment = -increment;
+ // fallthrough
case KeyEvent.KEYCODE_DPAD_RIGHT:
- if (progress >= getMax()) break;
- setProgress(progress + mKeyProgressIncrement, true);
- onKeyChange();
- return true;
+ increment = isLayoutRtl() ? -increment : increment;
+ int progress = getProgress() + increment;
+ if (progress > 0 && progress < getMax()) {
+ setProgress(progress, true);
+ onKeyChange();
+ return true;
+ }
+ break;
}
}
diff --git a/core/java/android/widget/DateTimeView.java b/core/java/android/widget/DateTimeView.java
index 443884a..db17df7 100644
--- a/core/java/android/widget/DateTimeView.java
+++ b/core/java/android/widget/DateTimeView.java
@@ -156,7 +156,7 @@ public class DateTimeView extends TextView {
format = getTimeFormat();
break;
case SHOW_MONTH_DAY_YEAR:
- format = getDateFormat();
+ format = DateFormat.getDateInstance(DateFormat.SHORT);
break;
default:
throw new RuntimeException("unknown display value: " + display);
@@ -196,21 +196,6 @@ public class DateTimeView extends TextView {
return android.text.format.DateFormat.getTimeFormat(getContext());
}
- private DateFormat getDateFormat() {
- String format = Settings.System.getString(getContext().getContentResolver(),
- Settings.System.DATE_FORMAT);
- if (format == null || "".equals(format)) {
- return DateFormat.getDateInstance(DateFormat.SHORT);
- } else {
- try {
- return new SimpleDateFormat(format);
- } catch (IllegalArgumentException e) {
- // If we tried to use a bad format string, fall back to a default.
- return DateFormat.getDateInstance(DateFormat.SHORT);
- }
- }
- }
-
void clearFormatAndUpdate() {
mLastFormat = null;
update();
@@ -283,14 +268,10 @@ public class DateTimeView extends TextView {
filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
context.registerReceiver(mReceiver, filter);
-
- final Uri uri = Settings.System.getUriFor(Settings.System.DATE_FORMAT);
- context.getContentResolver().registerContentObserver(uri, true, mObserver);
}
void unregister(Context context) {
context.unregisterReceiver(mReceiver);
- context.getContentResolver().unregisterContentObserver(mObserver);
}
}
}
diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java
index 2e9858c..ba6f061 100644
--- a/core/java/android/widget/ListView.java
+++ b/core/java/android/widget/ListView.java
@@ -2420,10 +2420,15 @@ public class ListView extends AbsListView {
(ViewGroup) selectedView, currentFocus, direction);
if (nextFocus != null) {
// do the math to get interesting rect in next focus' coordinates
- currentFocus.getFocusedRect(mTempRect);
- offsetDescendantRectToMyCoords(currentFocus, mTempRect);
- offsetRectIntoDescendantCoords(nextFocus, mTempRect);
- if (nextFocus.requestFocus(direction, mTempRect)) {
+ Rect focusedRect = mTempRect;
+ if (currentFocus != null) {
+ currentFocus.getFocusedRect(focusedRect);
+ offsetDescendantRectToMyCoords(currentFocus, focusedRect);
+ offsetRectIntoDescendantCoords(nextFocus, focusedRect);
+ } else {
+ focusedRect = null;
+ }
+ if (nextFocus.requestFocus(direction, focusedRect)) {
return true;
}
}
@@ -2556,8 +2561,10 @@ public class ListView extends AbsListView {
if (mItemsCanFocus && (focusResult == null)
&& selectedView != null && selectedView.hasFocus()) {
final View focused = selectedView.findFocus();
- if (!isViewAncestorOf(focused, this) || distanceToView(focused) > 0) {
- focused.clearFocus();
+ if (focused != null) {
+ if (!isViewAncestorOf(focused, this) || distanceToView(focused) > 0) {
+ focused.clearFocus();
+ }
}
}
diff --git a/core/java/android/widget/OverScroller.java b/core/java/android/widget/OverScroller.java
index a40d4f8..451e493 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/PopupWindow.java b/core/java/android/widget/PopupWindow.java
index 396c0b9..5419ab6 100644
--- a/core/java/android/widget/PopupWindow.java
+++ b/core/java/android/widget/PopupWindow.java
@@ -378,10 +378,10 @@ public class PopupWindow {
}
/**
- * Set the flag on popup to ignore cheek press event; by default this flag
+ * Set the flag on popup to ignore cheek press events; by default this flag
* is set to false
- * which means the pop wont ignore cheek press dispatch events.
- *
+ * which means the popup will not ignore cheek press dispatch events.
+ *
* <p>If the popup is showing, calling this method will take effect only
* the next time the popup is shown or through a manual call to one of
* the {@link #update()} methods.</p>
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/TextClock.java b/core/java/android/widget/TextClock.java
index a98d272..e2acaac 100644
--- a/core/java/android/widget/TextClock.java
+++ b/core/java/android/widget/TextClock.java
@@ -230,10 +230,10 @@ public class TextClock extends TextView {
if (mFormat12 == null || mFormat24 == null) {
LocaleData ld = LocaleData.get(getContext().getResources().getConfiguration().locale);
if (mFormat12 == null) {
- mFormat12 = ld.timeFormat12;
+ mFormat12 = ld.timeFormat_hm;
}
if (mFormat24 == null) {
- mFormat24 = ld.timeFormat24;
+ mFormat24 = ld.timeFormat_Hm;
}
}
@@ -457,9 +457,9 @@ public class TextClock extends TextView {
LocaleData ld = LocaleData.get(getContext().getResources().getConfiguration().locale);
if (format24Requested) {
- mFormat = abc(mFormat24, mFormat12, ld.timeFormat24);
+ mFormat = abc(mFormat24, mFormat12, ld.timeFormat_Hm);
} else {
- mFormat = abc(mFormat12, mFormat24, ld.timeFormat12);
+ mFormat = abc(mFormat12, mFormat24, ld.timeFormat_hm);
}
boolean hadSeconds = mHasSeconds;
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 34b3a72..597de1e 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -93,7 +93,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;
@@ -3815,7 +3814,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// Display the error later, after the first layout pass
post(new Runnable() {
public void run() {
- setError(error);
+ if (mEditor == null || !mEditor.mErrorWasChanged) {
+ setError(error);
+ }
}
});
}
@@ -4795,7 +4796,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;
}
@@ -4805,10 +4806,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++) {
@@ -6500,7 +6501,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);
}
/**
@@ -6577,7 +6578,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 {
@@ -6607,7 +6608,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 {
@@ -6913,8 +6914,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;
@@ -6926,10 +6927,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) {
@@ -7004,8 +7005,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();