diff options
| -rw-r--r-- | api/current.xml | 165 | ||||
| -rw-r--r-- | core/java/android/webkit/GoogleLocationSettingManager.java (renamed from core/java/android/GoogleLocationSettingManager.java) | 0 | ||||
| -rw-r--r-- | core/java/android/webkit/LoadListener.java | 1 | ||||
| -rw-r--r-- | core/java/android/webkit/WebView.java | 43 | ||||
| -rw-r--r-- | core/java/android/webkit/WebViewClient.java | 44 | ||||
| -rw-r--r-- | core/java/android/widget/Scroller.java | 11 | ||||
| -rw-r--r-- | location/java/android/location/LocationManager.java | 3 | ||||
| -rw-r--r-- | services/java/com/android/server/LocationManagerService.java | 131 |
8 files changed, 258 insertions, 140 deletions
diff --git a/api/current.xml b/api/current.xml index 3e616a4..7e6c2df 100644 --- a/api/current.xml +++ b/api/current.xml @@ -167386,6 +167386,171 @@ <parameter name="url" type="java.lang.String"> </parameter> </method> +<field name="ERROR_AUTHENTICATION" + type="int" + transient="false" + volatile="false" + value="-4" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="ERROR_BAD_URL" + type="int" + transient="false" + volatile="false" + value="-12" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="ERROR_CONNECT" + type="int" + transient="false" + volatile="false" + value="-6" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="ERROR_FAILED_SSL_HANDSHAKE" + type="int" + transient="false" + volatile="false" + value="-11" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="ERROR_FILE" + type="int" + transient="false" + volatile="false" + value="-13" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="ERROR_FILE_NOT_FOUND" + type="int" + transient="false" + volatile="false" + value="-14" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="ERROR_HOST_LOOKUP" + type="int" + transient="false" + volatile="false" + value="-2" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="ERROR_IO" + type="int" + transient="false" + volatile="false" + value="-7" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="ERROR_PROXY_AUTHENTICATION" + type="int" + transient="false" + volatile="false" + value="-5" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="ERROR_REDIRECT_LOOP" + type="int" + transient="false" + volatile="false" + value="-9" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="ERROR_TIMEOUT" + type="int" + transient="false" + volatile="false" + value="-8" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="ERROR_TOO_MANY_REQUESTS" + type="int" + transient="false" + volatile="false" + value="-15" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="ERROR_UNKNOWN" + type="int" + transient="false" + volatile="false" + value="-1" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="ERROR_UNSUPPORTED_AUTH_SCHEME" + type="int" + transient="false" + volatile="false" + value="-3" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="ERROR_UNSUPPORTED_SCHEME" + type="int" + transient="false" + volatile="false" + value="-10" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> </class> <class name="WebViewDatabase" extends="java.lang.Object" diff --git a/core/java/android/GoogleLocationSettingManager.java b/core/java/android/webkit/GoogleLocationSettingManager.java index fe7fce6..fe7fce6 100644 --- a/core/java/android/GoogleLocationSettingManager.java +++ b/core/java/android/webkit/GoogleLocationSettingManager.java diff --git a/core/java/android/webkit/LoadListener.java b/core/java/android/webkit/LoadListener.java index 43c76a8..1a5b2eb 100644 --- a/core/java/android/webkit/LoadListener.java +++ b/core/java/android/webkit/LoadListener.java @@ -606,6 +606,7 @@ class LoadListener extends Handler implements EventHandler { // before calling it. if (mCacheLoader != null) { mCacheLoader.load(); + mFromCache = true; if (DebugFlags.LOAD_LISTENER) { Log.v(LOGTAG, "LoadListener cache load url=" + url()); } diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index e39e3f1..792fdf2 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -342,6 +342,9 @@ public class WebView extends AbsoluteLayout */ VelocityTracker mVelocityTracker; private int mMaximumFling; + private float mLastVelocity; + private float mLastVelX; + private float mLastVelY; // use this flag to control whether enabling the new double tap zoom static final boolean ENABLE_DOUBLETAP_ZOOM = true; @@ -1795,6 +1798,13 @@ public class WebView extends AbsoluteLayout , contentToView(x.right), contentToView(x.bottom)); } + // stop the scroll animation, and don't let a subsequent fling add + // to the existing velocity + private void abortAnimation() { + mScroller.abortAnimation(); + mLastVelocity = 0; + } + /* call from webcoreview.draw(), so we're still executing in the UI thread */ private void recordNewContentSize(int w, int h, boolean updateLayout) { @@ -1819,7 +1829,7 @@ public class WebView extends AbsoluteLayout mScrollY = pinLocY(mScrollY); // android.util.Log.d("skia", "recordNewContentSize - // abortAnimation"); - mScroller.abortAnimation(); // just in case + abortAnimation(); // just in case if (oldX != mScrollX || oldY != mScrollY) { sendOurVisibleRect(); } @@ -2339,7 +2349,7 @@ public class WebView extends AbsoluteLayout animationDuration > 0 ? animationDuration : computeDuration(dx, dy)); invalidate(); } else { - mScroller.abortAnimation(); // just in case + abortAnimation(); // just in case scrollTo(x, y); } return true; @@ -2963,7 +2973,7 @@ public class WebView extends AbsoluteLayout mLastTouchX = halfW; int halfH = height >> 1; mLastTouchY = halfH; - mScroller.abortAnimation(); + abortAnimation(); mZoomScrollStart = System.currentTimeMillis(); Rect zoomFrame = scrollZoomFrame(width, height , scrollZoomMagScale(mZoomScrollInvLimit)); @@ -3850,6 +3860,9 @@ public class WebView extends AbsoluteLayout mLastScrollY = mZoomScrollY; // If two taps are close, ignore the first tap } else if (!mScroller.isFinished()) { + // stop the current scroll animation, but if this is + // the start of a fling, allow it to add to the current + // fling's velocity mScroller.abortAnimation(); mTouchMode = TOUCH_DRAG_START_MODE; mPrivateHandler.removeMessages(RESUME_WEBCORE_UPDATE); @@ -4110,6 +4123,7 @@ public class WebView extends AbsoluteLayout doFling(); break; } + mLastVelocity = 0; WebViewCore.resumeUpdate(mWebViewCore); break; case TOUCH_DRAG_START_MODE: @@ -4475,6 +4489,27 @@ public class WebView extends AbsoluteLayout vx = vx * 3 / 4; vy = vy * 3 / 4; } + float currentVelocity = mScroller.getCurrVelocity(); + if (mLastVelocity > 0 && currentVelocity > 0) { + float deltaR = (float) (Math.abs(Math.atan2(mLastVelY, mLastVelX) + - Math.atan2(vy, vx))); + final float circle = (float) (Math.PI) * 2.0f; + if (deltaR > circle * 0.9f || deltaR < circle * 0.1f) { + vx += currentVelocity * mLastVelX / mLastVelocity; + vy += currentVelocity * mLastVelY / mLastVelocity; + if (DebugFlags.WEB_VIEW) { + Log.v(LOGTAG, "doFling vx= " + vx + " vy=" + vy); + } + } else if (DebugFlags.WEB_VIEW) { + Log.v(LOGTAG, "doFling missed " + deltaR / circle); + } + } else if (DebugFlags.WEB_VIEW) { + Log.v(LOGTAG, "doFling start last=" + mLastVelocity + + " current=" + currentVelocity); + } + mLastVelX = vx; + mLastVelY = vy; + mLastVelocity = (float) Math.hypot(vx, vy); mScroller.fling(mScrollX, mScrollY, -vx, -vy, 0, maxX, 0, maxY); // TODO: duration is calculated based on velocity, if the range is @@ -4683,7 +4718,7 @@ public class WebView extends AbsoluteLayout mLastTouchY = y + (float) (mWebTextView.getTop() - mScrollY); mLastTouchTime = eventTime; if (!mScroller.isFinished()) { - mScroller.abortAnimation(); + abortAnimation(); mPrivateHandler.removeMessages(RESUME_WEBCORE_UPDATE); } mSnapScrollMode = SNAP_NONE; diff --git a/core/java/android/webkit/WebViewClient.java b/core/java/android/webkit/WebViewClient.java index a185779..30dea74 100644 --- a/core/java/android/webkit/WebViewClient.java +++ b/core/java/android/webkit/WebViewClient.java @@ -92,14 +92,46 @@ public class WebViewClient { cancelMsg.sendToTarget(); } + // These ints must match up to the hidden values in EventHandler. + /** Generic error */ + public static final int ERROR_UNKNOWN = -1; + /** Server or proxy hostname lookup failed */ + public static final int ERROR_HOST_LOOKUP = -2; + /** Unsupported authentication scheme (not basic or digest) */ + public static final int ERROR_UNSUPPORTED_AUTH_SCHEME = -3; + /** User authentication failed on server */ + public static final int ERROR_AUTHENTICATION = -4; + /** User authentication failed on proxy */ + public static final int ERROR_PROXY_AUTHENTICATION = -5; + /** Failed to connect to the server */ + public static final int ERROR_CONNECT = -6; + /** Failed to read or write to the server */ + public static final int ERROR_IO = -7; + /** Connection timed out */ + public static final int ERROR_TIMEOUT = -8; + /** Too many redirects */ + public static final int ERROR_REDIRECT_LOOP = -9; + /** Unsupported URI scheme */ + public static final int ERROR_UNSUPPORTED_SCHEME = -10; + /** Failed to perform SSL handshake */ + public static final int ERROR_FAILED_SSL_HANDSHAKE = -11; + /** Malformed URL */ + public static final int ERROR_BAD_URL = -12; + /** Generic file error */ + public static final int ERROR_FILE = -13; + /** File not found */ + public static final int ERROR_FILE_NOT_FOUND = -14; + /** Too many requests during this load */ + public static final int ERROR_TOO_MANY_REQUESTS = -15; + /** - * Report an error to an activity. These errors come up from WebCore, and - * are network errors. - * + * Report an error to the host application. These errors are unrecoverable + * (i.e. the main resource is unavailable). The errorCode parameter + * corresponds to one of the ERROR_* constants. * @param view The WebView that is initiating the callback. - * @param errorCode The HTTP error code. - * @param description A String description. - * @param failingUrl The url that failed. + * @param errorCode The error code corresponding to an ERROR_* value. + * @param description A String describing the error. + * @param failingUrl The url that failed to load. */ public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { diff --git a/core/java/android/widget/Scroller.java b/core/java/android/widget/Scroller.java index 381641f..11dab02 100644 --- a/core/java/android/widget/Scroller.java +++ b/core/java/android/widget/Scroller.java @@ -133,6 +133,17 @@ public class Scroller { } /** + * @hide + * Returns the current velocity. + * + * @return The original velocity less the deceleration. Result may be + * negative. + */ + public float getCurrVelocity() { + return mVelocity - mDeceleration * timePassed() / 2000.0f; + } + + /** * Returns the start X offset in the scroll. * * @return The start X offset as an absolute distance from the origin. diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index 8326361..94ced22 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -105,9 +105,6 @@ public class LocationManager { */ public static final String KEY_LOCATION_CHANGED = "location"; - /** @hide */ - public static final String SYSTEM_DIR = "/data/system/location"; - // Map from LocationListeners to their associated ListenerTransport objects private HashMap<LocationListener,ListenerTransport> mListeners = new HashMap<LocationListener,ListenerTransport>(); diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java index 7c33e37..af60556 100644 --- a/services/java/com/android/server/LocationManagerService.java +++ b/services/java/com/android/server/LocationManagerService.java @@ -16,12 +16,7 @@ package com.android.server; -import java.io.BufferedReader; -import java.io.File; import java.io.FileDescriptor; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; @@ -31,7 +26,6 @@ import java.util.Map; import java.util.Observable; import java.util.Observer; import java.util.Set; -import java.util.regex.Pattern; import android.app.PendingIntent; import android.content.BroadcastReceiver; @@ -64,7 +58,6 @@ import android.os.Message; import android.os.PowerManager; import android.os.Process; import android.os.RemoteException; -import android.os.SystemClock; import android.provider.Settings; import android.util.Log; import android.util.PrintWriterPrinter; @@ -84,17 +77,9 @@ public class LocationManagerService extends ILocationManager.Stub implements Run private static final String TAG = "LocationManagerService"; private static final boolean LOCAL_LOGV = false; - // Minimum time interval between last known location writes, in milliseconds. - private static final long MIN_LAST_KNOWN_LOCATION_TIME = 60L * 1000L; - - // Max time to hold wake lock for, in milliseconds. - private static final long MAX_TIME_FOR_WAKE_LOCK = 60 * 1000L; - // The last time a location was written, by provider name. private HashMap<String,Long> mLastWriteTime = new HashMap<String,Long>(); - private static final Pattern PATTERN_COMMA = Pattern.compile(","); - private static final String ACCESS_FINE_LOCATION = android.Manifest.permission.ACCESS_FINE_LOCATION; private static final String ACCESS_COARSE_LOCATION = @@ -416,97 +401,6 @@ public class LocationManagerService extends ILocationManager.Stub implements Run } } - private Location readLastKnownLocationLocked(String provider) { - Location location = null; - String s = null; - try { - File f = new File(LocationManager.SYSTEM_DIR + "/location." - + provider); - if (!f.exists()) { - return null; - } - BufferedReader reader = new BufferedReader(new FileReader(f), 256); - s = reader.readLine(); - } catch (IOException e) { - Log.w(TAG, "Unable to read last known location", e); - } - - if (s == null) { - return null; - } - try { - String[] tokens = PATTERN_COMMA.split(s); - int idx = 0; - long time = Long.parseLong(tokens[idx++]); - double latitude = Double.parseDouble(tokens[idx++]); - double longitude = Double.parseDouble(tokens[idx++]); - double altitude = Double.parseDouble(tokens[idx++]); - float bearing = Float.parseFloat(tokens[idx++]); - float speed = Float.parseFloat(tokens[idx++]); - - location = new Location(provider); - location.setTime(time); - location.setLatitude(latitude); - location.setLongitude(longitude); - location.setAltitude(altitude); - location.setBearing(bearing); - location.setSpeed(speed); - } catch (NumberFormatException nfe) { - Log.e(TAG, "NumberFormatException reading last known location", nfe); - return null; - } - - return location; - } - - private void writeLastKnownLocationLocked(String provider, - Location location) { - long now = SystemClock.elapsedRealtime(); - Long last = mLastWriteTime.get(provider); - if ((last != null) - && (now - last.longValue() < MIN_LAST_KNOWN_LOCATION_TIME)) { - return; - } - mLastWriteTime.put(provider, now); - - StringBuilder sb = new StringBuilder(100); - sb.append(location.getTime()); - sb.append(','); - sb.append(location.getLatitude()); - sb.append(','); - sb.append(location.getLongitude()); - sb.append(','); - sb.append(location.getAltitude()); - sb.append(','); - sb.append(location.getBearing()); - sb.append(','); - sb.append(location.getSpeed()); - - FileWriter writer = null; - try { - File d = new File(LocationManager.SYSTEM_DIR); - if (!d.exists()) { - if (!d.mkdirs()) { - Log.w(TAG, "Unable to create directory to write location"); - return; - } - } - File f = new File(LocationManager.SYSTEM_DIR + "/location." + provider); - writer = new FileWriter(f); - writer.write(sb.toString()); - } catch (IOException e) { - Log.w(TAG, "Unable to write location", e); - } finally { - if (writer != null) { - try { - writer.close(); - } catch (IOException e) { - Log.w(TAG, "Exception closing file", e); - } - } - } - } - private void addProvider(LocationProviderProxy provider) { mProviders.add(provider); mProvidersByName.put(provider.getName(), provider); @@ -854,7 +748,9 @@ public class LocationManagerService extends ILocationManager.Stub implements Run */ void disposeLocked() { ArrayList<UpdateRecord> records = mRecordsByProvider.get(this.mProvider); - records.remove(this); + if (records != null) { + records.remove(this); + } } @Override @@ -873,15 +769,6 @@ public class LocationManagerService extends ILocationManager.Stub implements Run mLastFixBroadcast.dump(new PrintWriterPrinter(pw), prefix + " "); pw.println(prefix + "mLastStatusBroadcast=" + mLastStatusBroadcast); } - - /** - * Calls dispose(). - */ - @Override protected void finalize() { - synchronized (mLock) { - disposeLocked(); - } - } } private Receiver getReceiver(ILocationListener listener) { @@ -1512,16 +1399,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run return null; } - Location location = mLastKnownLocation.get(provider); - if (location == null) { - // Get the persistent last known location for the provider - location = readLastKnownLocationLocked(provider); - if (location != null) { - mLastKnownLocation.put(provider, location); - } - } - - return location; + return mLastKnownLocation.get(provider); } private static boolean shouldBroadcastSafe(Location loc, Location lastLoc, UpdateRecord record) { @@ -1566,7 +1444,6 @@ public class LocationManagerService extends ILocationManager.Stub implements Run } else { lastLocation.set(location); } - writeLastKnownLocationLocked(provider, location); // Fetch latest status update time long newStatusUpdateTime = p.getStatusUpdateTime(); |
