Merge "Fix for bug: #7173350. elapsedRealtimeNano() -> elapsedRealtimeNanos()" into jb-mr1-dev
This commit is contained in:
@@ -10665,7 +10665,7 @@ package android.location {
|
||||
method public float getAccuracy();
|
||||
method public double getAltitude();
|
||||
method public float getBearing();
|
||||
method public long getElapsedRealtimeNano();
|
||||
method public long getElapsedRealtimeNanos();
|
||||
method public android.os.Bundle getExtras();
|
||||
method public double getLatitude();
|
||||
method public double getLongitude();
|
||||
@@ -10685,7 +10685,7 @@ package android.location {
|
||||
method public void setAccuracy(float);
|
||||
method public void setAltitude(double);
|
||||
method public void setBearing(float);
|
||||
method public void setElapsedRealtimeNano(long);
|
||||
method public void setElapsedRealtimeNanos(long);
|
||||
method public void setExtras(android.os.Bundle);
|
||||
method public void setLatitude(double);
|
||||
method public void setLongitude(double);
|
||||
@@ -16574,7 +16574,7 @@ package android.os {
|
||||
public final class SystemClock {
|
||||
method public static long currentThreadTimeMillis();
|
||||
method public static long elapsedRealtime();
|
||||
method public static long elapsedRealtimeNano();
|
||||
method public static long elapsedRealtimeNanos();
|
||||
method public static boolean setCurrentTimeMillis(long);
|
||||
method public static void sleep(long);
|
||||
method public static long uptimeMillis();
|
||||
|
||||
@@ -50,7 +50,7 @@ package android.os;
|
||||
* interval does not span device sleep. Most methods that accept a
|
||||
* timestamp value currently expect the {@link #uptimeMillis} clock.
|
||||
*
|
||||
* <li> <p> {@link #elapsedRealtime} and {@link #elapsedRealtimeNano}
|
||||
* <li> <p> {@link #elapsedRealtime} and {@link #elapsedRealtimeNanos}
|
||||
* return the time since the system was booted, and include deep sleep.
|
||||
* This clock is guaranteed to be monotonic, and continues to tick even
|
||||
* when the CPU is in power saving modes, so is the recommend basis
|
||||
@@ -157,7 +157,7 @@ public final class SystemClock {
|
||||
*
|
||||
* @return elapsed nanoseconds since boot.
|
||||
*/
|
||||
public static native long elapsedRealtimeNano();
|
||||
public static native long elapsedRealtimeNanos();
|
||||
|
||||
/**
|
||||
* Returns milliseconds running in the current thread.
|
||||
|
||||
@@ -71,7 +71,7 @@ public class Location implements Parcelable {
|
||||
|
||||
private String mProvider;
|
||||
private long mTime = 0;
|
||||
private long mElapsedRealtimeNano = 0;
|
||||
private long mElapsedRealtimeNanos = 0;
|
||||
private double mLatitude = 0.0;
|
||||
private double mLongitude = 0.0;
|
||||
private boolean mHasAltitude = false;
|
||||
@@ -120,7 +120,7 @@ public class Location implements Parcelable {
|
||||
public void set(Location l) {
|
||||
mProvider = l.mProvider;
|
||||
mTime = l.mTime;
|
||||
mElapsedRealtimeNano = l.mElapsedRealtimeNano;
|
||||
mElapsedRealtimeNanos = l.mElapsedRealtimeNanos;
|
||||
mLatitude = l.mLatitude;
|
||||
mLongitude = l.mLongitude;
|
||||
mHasAltitude = l.mHasAltitude;
|
||||
@@ -140,7 +140,7 @@ public class Location implements Parcelable {
|
||||
public void reset() {
|
||||
mProvider = null;
|
||||
mTime = 0;
|
||||
mElapsedRealtimeNano = 0;
|
||||
mElapsedRealtimeNanos = 0;
|
||||
mLatitude = 0;
|
||||
mLongitude = 0;
|
||||
mHasAltitude = false;
|
||||
@@ -485,7 +485,7 @@ public class Location implements Parcelable {
|
||||
*
|
||||
* <p>Note that the UTC time on a device is not monotonic: it
|
||||
* can jump forwards or backwards unpredictably. So always use
|
||||
* {@link #getElapsedRealtimeNano} when calculating time deltas.
|
||||
* {@link #getElapsedRealtimeNanos} when calculating time deltas.
|
||||
*
|
||||
* <p>On the other hand, {@link #getTime} is useful for presenting
|
||||
* a human readable time to the user, or for carefully comparing
|
||||
@@ -515,7 +515,7 @@ public class Location implements Parcelable {
|
||||
* Return the time of this fix, in elapsed real-time since system boot.
|
||||
*
|
||||
* <p>This value can be reliably compared to
|
||||
* {@link android.os.SystemClock#elapsedRealtimeNano},
|
||||
* {@link android.os.SystemClock#elapsedRealtimeNanos},
|
||||
* to calculate the age of a fix and to compare Location fixes. This
|
||||
* is reliable because elapsed real-time is guaranteed monotonic for
|
||||
* each system boot and continues to increment even when the system
|
||||
@@ -526,8 +526,8 @@ public class Location implements Parcelable {
|
||||
*
|
||||
* @return elapsed real-time of fix, in nanoseconds since system boot.
|
||||
*/
|
||||
public long getElapsedRealtimeNano() {
|
||||
return mElapsedRealtimeNano;
|
||||
public long getElapsedRealtimeNanos() {
|
||||
return mElapsedRealtimeNanos;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -535,8 +535,8 @@ public class Location implements Parcelable {
|
||||
*
|
||||
* @param time elapsed real-time of fix, in nanoseconds since system boot.
|
||||
*/
|
||||
public void setElapsedRealtimeNano(long time) {
|
||||
mElapsedRealtimeNano = time;
|
||||
public void setElapsedRealtimeNanos(long time) {
|
||||
mElapsedRealtimeNanos = time;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -772,7 +772,7 @@ public class Location implements Parcelable {
|
||||
if (mProvider == null) return false;
|
||||
if (!mHasAccuracy) return false;
|
||||
if (mTime == 0) return false;
|
||||
if (mElapsedRealtimeNano == 0) return false;
|
||||
if (mElapsedRealtimeNanos == 0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -792,7 +792,7 @@ public class Location implements Parcelable {
|
||||
mAccuracy = 100.0f;
|
||||
}
|
||||
if (mTime == 0) mTime = System.currentTimeMillis();
|
||||
if (mElapsedRealtimeNano == 0) mElapsedRealtimeNano = SystemClock.elapsedRealtimeNano();
|
||||
if (mElapsedRealtimeNanos == 0) mElapsedRealtimeNanos = SystemClock.elapsedRealtimeNanos();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -832,11 +832,11 @@ public class Location implements Parcelable {
|
||||
if (mTime == 0) {
|
||||
s.append(" t=?!?");
|
||||
}
|
||||
if (mElapsedRealtimeNano == 0) {
|
||||
if (mElapsedRealtimeNanos == 0) {
|
||||
s.append(" et=?!?");
|
||||
} else {
|
||||
s.append(" et=");
|
||||
TimeUtils.formatDuration(mElapsedRealtimeNano / 1000000L, s);
|
||||
TimeUtils.formatDuration(mElapsedRealtimeNanos / 1000000L, s);
|
||||
}
|
||||
if (mHasAltitude) s.append(" alt=").append(mAltitude);
|
||||
if (mHasSpeed) s.append(" vel=").append(mSpeed);
|
||||
@@ -860,7 +860,7 @@ public class Location implements Parcelable {
|
||||
String provider = in.readString();
|
||||
Location l = new Location(provider);
|
||||
l.mTime = in.readLong();
|
||||
l.mElapsedRealtimeNano = in.readLong();
|
||||
l.mElapsedRealtimeNanos = in.readLong();
|
||||
l.mLatitude = in.readDouble();
|
||||
l.mLongitude = in.readDouble();
|
||||
l.mHasAltitude = in.readInt() != 0;
|
||||
@@ -890,7 +890,7 @@ public class Location implements Parcelable {
|
||||
public void writeToParcel(Parcel parcel, int flags) {
|
||||
parcel.writeString(mProvider);
|
||||
parcel.writeLong(mTime);
|
||||
parcel.writeLong(mElapsedRealtimeNano);
|
||||
parcel.writeLong(mElapsedRealtimeNanos);
|
||||
parcel.writeDouble(mLatitude);
|
||||
parcel.writeDouble(mLongitude);
|
||||
parcel.writeInt(mHasAltitude ? 1 : 0);
|
||||
|
||||
@@ -1186,7 +1186,7 @@ public class LocationManager {
|
||||
* Get the last known location.
|
||||
*
|
||||
* <p>This location could be very old so use
|
||||
* {@link Location#getElapsedRealtimeNano} to calculate its age. It can
|
||||
* {@link Location#getElapsedRealtimeNanos} to calculate its age. It can
|
||||
* also return null if no previous location is available.
|
||||
*
|
||||
* <p>Always returns immediately.
|
||||
|
||||
@@ -215,7 +215,7 @@ public class FusionEngine implements LocationListener {
|
||||
}
|
||||
|
||||
private static double weighAge(Location loc) {
|
||||
long ageSeconds = SystemClock.elapsedRealtimeNano() - loc.getElapsedRealtimeNano();
|
||||
long ageSeconds = SystemClock.elapsedRealtimeNanos() - loc.getElapsedRealtimeNanos();
|
||||
ageSeconds /= 1000000000L;
|
||||
if (ageSeconds < 0) ageSeconds = 0;
|
||||
return Math.exp(-ageSeconds * AGE_DECAY_CONSTANT_S);
|
||||
@@ -266,7 +266,7 @@ public class FusionEngine implements LocationListener {
|
||||
|
||||
// fused time - now
|
||||
fused.setTime(System.currentTimeMillis());
|
||||
fused.setElapsedRealtimeNano(SystemClock.elapsedRealtimeNano());
|
||||
fused.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
|
||||
|
||||
// fuse altitude
|
||||
if (mGpsLocation.hasAltitude() && !mNetworkLocation.hasAltitude() &&
|
||||
|
||||
@@ -17,17 +17,14 @@
|
||||
package com.android.server;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ContentQueryMap;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.res.Resources;
|
||||
import android.database.ContentObserver;
|
||||
import android.database.Cursor;
|
||||
import android.location.Address;
|
||||
import android.location.Criteria;
|
||||
import android.location.GeocoderParams;
|
||||
@@ -41,7 +38,6 @@ import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.location.LocationProvider;
|
||||
import android.location.LocationRequest;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.Binder;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -55,7 +51,6 @@ import android.os.SystemClock;
|
||||
import android.os.UserHandle;
|
||||
import android.os.WorkSource;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.NameValueTable;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
|
||||
@@ -80,8 +75,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -1343,7 +1336,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
||||
|
||||
// Check whether sufficient time has passed
|
||||
long minTime = record.mRequest.getFastestInterval();
|
||||
long delta = (loc.getElapsedRealtimeNano() - lastLoc.getElapsedRealtimeNano()) / 1000000L;
|
||||
long delta = (loc.getElapsedRealtimeNanos() - lastLoc.getElapsedRealtimeNanos()) / 1000000L;
|
||||
if (delta < minTime - MAX_PROVIDER_SCHEDULING_JITTER_MS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ public final class TwilightService {
|
||||
}
|
||||
|
||||
// if new location is older than the current one, the device hasn't moved.
|
||||
if (to.getElapsedRealtimeNano() < from.getElapsedRealtimeNano()) {
|
||||
if (to.getElapsedRealtimeNanos() < from.getElapsedRealtimeNanos()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -428,8 +428,8 @@ public final class TwilightService {
|
||||
mLocationManager.getLastKnownLocation(providers.next());
|
||||
// pick the most recent location
|
||||
if (location == null || (lastKnownLocation != null &&
|
||||
location.getElapsedRealtimeNano() <
|
||||
lastKnownLocation.getElapsedRealtimeNano())) {
|
||||
location.getElapsedRealtimeNanos() <
|
||||
lastKnownLocation.getElapsedRealtimeNanos())) {
|
||||
location = lastKnownLocation;
|
||||
}
|
||||
}
|
||||
@@ -447,7 +447,7 @@ public final class TwilightService {
|
||||
location.setLatitude(0);
|
||||
location.setAccuracy(417000.0f);
|
||||
location.setTime(System.currentTimeMillis());
|
||||
location.setElapsedRealtimeNano(SystemClock.elapsedRealtimeNano());
|
||||
location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
|
||||
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "Estimated location from timezone: " + location);
|
||||
|
||||
@@ -1029,7 +1029,7 @@ public class GpsLocationProvider implements LocationProviderInterface {
|
||||
mLocation.setTime(timestamp);
|
||||
// It would be nice to push the elapsed real-time timestamp
|
||||
// further down the stack, but this is still useful
|
||||
mLocation.setElapsedRealtimeNano(SystemClock.elapsedRealtimeNano());
|
||||
mLocation.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
|
||||
}
|
||||
if ((flags & LOCATION_HAS_ALTITUDE) == LOCATION_HAS_ALTITUDE) {
|
||||
mLocation.setAltitude(altitude);
|
||||
|
||||
@@ -115,8 +115,8 @@ public class LocationBasedCountryDetector extends CountryDetectorBase {
|
||||
Location lastKnownLocation = mLocationManager.getLastKnownLocation(provider);
|
||||
if (lastKnownLocation != null) {
|
||||
if (bestLocation == null ||
|
||||
bestLocation.getElapsedRealtimeNano() <
|
||||
lastKnownLocation.getElapsedRealtimeNano()) {
|
||||
bestLocation.getElapsedRealtimeNanos() <
|
||||
lastKnownLocation.getElapsedRealtimeNanos()) {
|
||||
bestLocation = lastKnownLocation;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user