Skip to content

Commit eed8f06

Browse files
Philip MilneAndroid (Google) Code Review
authored andcommitted
Merge "Fix for bug: #7173350. elapsedRealtimeNano() -> elapsedRealtimeNanos()" into jb-mr1-dev
2 parents 0c9bbf4 + 4118012 commit eed8f06

File tree

9 files changed

+31
-38
lines changed

9 files changed

+31
-38
lines changed

api/current.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10665,7 +10665,7 @@ package android.location {
1066510665
method public float getAccuracy();
1066610666
method public double getAltitude();
1066710667
method public float getBearing();
10668-
method public long getElapsedRealtimeNano();
10668+
method public long getElapsedRealtimeNanos();
1066910669
method public android.os.Bundle getExtras();
1067010670
method public double getLatitude();
1067110671
method public double getLongitude();
@@ -10685,7 +10685,7 @@ package android.location {
1068510685
method public void setAccuracy(float);
1068610686
method public void setAltitude(double);
1068710687
method public void setBearing(float);
10688-
method public void setElapsedRealtimeNano(long);
10688+
method public void setElapsedRealtimeNanos(long);
1068910689
method public void setExtras(android.os.Bundle);
1069010690
method public void setLatitude(double);
1069110691
method public void setLongitude(double);
@@ -16574,7 +16574,7 @@ package android.os {
1657416574
public final class SystemClock {
1657516575
method public static long currentThreadTimeMillis();
1657616576
method public static long elapsedRealtime();
16577-
method public static long elapsedRealtimeNano();
16577+
method public static long elapsedRealtimeNanos();
1657816578
method public static boolean setCurrentTimeMillis(long);
1657916579
method public static void sleep(long);
1658016580
method public static long uptimeMillis();

core/java/android/os/SystemClock.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
* interval does not span device sleep. Most methods that accept a
5151
* timestamp value currently expect the {@link #uptimeMillis} clock.
5252
*
53-
* <li> <p> {@link #elapsedRealtime} and {@link #elapsedRealtimeNano}
53+
* <li> <p> {@link #elapsedRealtime} and {@link #elapsedRealtimeNanos}
5454
* return the time since the system was booted, and include deep sleep.
5555
* This clock is guaranteed to be monotonic, and continues to tick even
5656
* when the CPU is in power saving modes, so is the recommend basis
@@ -157,7 +157,7 @@ public static void sleep(long ms)
157157
*
158158
* @return elapsed nanoseconds since boot.
159159
*/
160-
public static native long elapsedRealtimeNano();
160+
public static native long elapsedRealtimeNanos();
161161

162162
/**
163163
* Returns milliseconds running in the current thread.

location/java/android/location/Location.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public class Location implements Parcelable {
7171

7272
private String mProvider;
7373
private long mTime = 0;
74-
private long mElapsedRealtimeNano = 0;
74+
private long mElapsedRealtimeNanos = 0;
7575
private double mLatitude = 0.0;
7676
private double mLongitude = 0.0;
7777
private boolean mHasAltitude = false;
@@ -120,7 +120,7 @@ public Location(Location l) {
120120
public void set(Location l) {
121121
mProvider = l.mProvider;
122122
mTime = l.mTime;
123-
mElapsedRealtimeNano = l.mElapsedRealtimeNano;
123+
mElapsedRealtimeNanos = l.mElapsedRealtimeNanos;
124124
mLatitude = l.mLatitude;
125125
mLongitude = l.mLongitude;
126126
mHasAltitude = l.mHasAltitude;
@@ -140,7 +140,7 @@ public void set(Location l) {
140140
public void reset() {
141141
mProvider = null;
142142
mTime = 0;
143-
mElapsedRealtimeNano = 0;
143+
mElapsedRealtimeNanos = 0;
144144
mLatitude = 0;
145145
mLongitude = 0;
146146
mHasAltitude = false;
@@ -485,7 +485,7 @@ public void setProvider(String provider) {
485485
*
486486
* <p>Note that the UTC time on a device is not monotonic: it
487487
* can jump forwards or backwards unpredictably. So always use
488-
* {@link #getElapsedRealtimeNano} when calculating time deltas.
488+
* {@link #getElapsedRealtimeNanos} when calculating time deltas.
489489
*
490490
* <p>On the other hand, {@link #getTime} is useful for presenting
491491
* a human readable time to the user, or for carefully comparing
@@ -515,7 +515,7 @@ public void setTime(long time) {
515515
* Return the time of this fix, in elapsed real-time since system boot.
516516
*
517517
* <p>This value can be reliably compared to
518-
* {@link android.os.SystemClock#elapsedRealtimeNano},
518+
* {@link android.os.SystemClock#elapsedRealtimeNanos},
519519
* to calculate the age of a fix and to compare Location fixes. This
520520
* is reliable because elapsed real-time is guaranteed monotonic for
521521
* each system boot and continues to increment even when the system
@@ -526,17 +526,17 @@ public void setTime(long time) {
526526
*
527527
* @return elapsed real-time of fix, in nanoseconds since system boot.
528528
*/
529-
public long getElapsedRealtimeNano() {
530-
return mElapsedRealtimeNano;
529+
public long getElapsedRealtimeNanos() {
530+
return mElapsedRealtimeNanos;
531531
}
532532

533533
/**
534534
* Set the time of this fix, in elapsed real-time since system boot.
535535
*
536536
* @param time elapsed real-time of fix, in nanoseconds since system boot.
537537
*/
538-
public void setElapsedRealtimeNano(long time) {
539-
mElapsedRealtimeNano = time;
538+
public void setElapsedRealtimeNanos(long time) {
539+
mElapsedRealtimeNanos = time;
540540
}
541541

542542
/**
@@ -772,7 +772,7 @@ public boolean isComplete() {
772772
if (mProvider == null) return false;
773773
if (!mHasAccuracy) return false;
774774
if (mTime == 0) return false;
775-
if (mElapsedRealtimeNano == 0) return false;
775+
if (mElapsedRealtimeNanos == 0) return false;
776776
return true;
777777
}
778778

@@ -792,7 +792,7 @@ public void makeComplete() {
792792
mAccuracy = 100.0f;
793793
}
794794
if (mTime == 0) mTime = System.currentTimeMillis();
795-
if (mElapsedRealtimeNano == 0) mElapsedRealtimeNano = SystemClock.elapsedRealtimeNano();
795+
if (mElapsedRealtimeNanos == 0) mElapsedRealtimeNanos = SystemClock.elapsedRealtimeNanos();
796796
}
797797

798798
/**
@@ -832,11 +832,11 @@ public String toString() {
832832
if (mTime == 0) {
833833
s.append(" t=?!?");
834834
}
835-
if (mElapsedRealtimeNano == 0) {
835+
if (mElapsedRealtimeNanos == 0) {
836836
s.append(" et=?!?");
837837
} else {
838838
s.append(" et=");
839-
TimeUtils.formatDuration(mElapsedRealtimeNano / 1000000L, s);
839+
TimeUtils.formatDuration(mElapsedRealtimeNanos / 1000000L, s);
840840
}
841841
if (mHasAltitude) s.append(" alt=").append(mAltitude);
842842
if (mHasSpeed) s.append(" vel=").append(mSpeed);
@@ -860,7 +860,7 @@ public Location createFromParcel(Parcel in) {
860860
String provider = in.readString();
861861
Location l = new Location(provider);
862862
l.mTime = in.readLong();
863-
l.mElapsedRealtimeNano = in.readLong();
863+
l.mElapsedRealtimeNanos = in.readLong();
864864
l.mLatitude = in.readDouble();
865865
l.mLongitude = in.readDouble();
866866
l.mHasAltitude = in.readInt() != 0;
@@ -890,7 +890,7 @@ public int describeContents() {
890890
public void writeToParcel(Parcel parcel, int flags) {
891891
parcel.writeString(mProvider);
892892
parcel.writeLong(mTime);
893-
parcel.writeLong(mElapsedRealtimeNano);
893+
parcel.writeLong(mElapsedRealtimeNanos);
894894
parcel.writeDouble(mLatitude);
895895
parcel.writeDouble(mLongitude);
896896
parcel.writeInt(mHasAltitude ? 1 : 0);

location/java/android/location/LocationManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ public boolean isProviderEnabled(String provider) {
11861186
* Get the last known location.
11871187
*
11881188
* <p>This location could be very old so use
1189-
* {@link Location#getElapsedRealtimeNano} to calculate its age. It can
1189+
* {@link Location#getElapsedRealtimeNanos} to calculate its age. It can
11901190
* also return null if no previous location is available.
11911191
*
11921192
* <p>Always returns immediately.

packages/FusedLocation/src/com/android/location/fused/FusionEngine.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ private static double weighAccuracy(Location loc) {
215215
}
216216

217217
private static double weighAge(Location loc) {
218-
long ageSeconds = SystemClock.elapsedRealtimeNano() - loc.getElapsedRealtimeNano();
218+
long ageSeconds = SystemClock.elapsedRealtimeNanos() - loc.getElapsedRealtimeNanos();
219219
ageSeconds /= 1000000000L;
220220
if (ageSeconds < 0) ageSeconds = 0;
221221
return Math.exp(-ageSeconds * AGE_DECAY_CONSTANT_S);
@@ -266,7 +266,7 @@ private void updateFusedLocation() {
266266

267267
// fused time - now
268268
fused.setTime(System.currentTimeMillis());
269-
fused.setElapsedRealtimeNano(SystemClock.elapsedRealtimeNano());
269+
fused.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
270270

271271
// fuse altitude
272272
if (mGpsLocation.hasAltitude() && !mNetworkLocation.hasAltitude() &&

services/java/com/android/server/LocationManagerService.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,14 @@
1717
package com.android.server;
1818

1919
import android.app.PendingIntent;
20-
import android.content.ContentQueryMap;
2120
import android.content.ContentResolver;
2221
import android.content.Context;
2322
import android.content.Intent;
24-
import android.content.IntentFilter;
2523
import android.content.pm.ApplicationInfo;
2624
import android.content.pm.PackageManager;
2725
import android.content.pm.PackageManager.NameNotFoundException;
2826
import android.content.res.Resources;
2927
import android.database.ContentObserver;
30-
import android.database.Cursor;
3128
import android.location.Address;
3229
import android.location.Criteria;
3330
import android.location.GeocoderParams;
@@ -41,7 +38,6 @@
4138
import android.location.LocationManager;
4239
import android.location.LocationProvider;
4340
import android.location.LocationRequest;
44-
import android.net.ConnectivityManager;
4541
import android.os.Binder;
4642
import android.os.Bundle;
4743
import android.os.Handler;
@@ -55,7 +51,6 @@
5551
import android.os.UserHandle;
5652
import android.os.WorkSource;
5753
import android.provider.Settings;
58-
import android.provider.Settings.NameValueTable;
5954
import android.util.Log;
6055
import android.util.Slog;
6156

@@ -80,8 +75,6 @@
8075
import java.util.HashSet;
8176
import java.util.List;
8277
import java.util.Map;
83-
import java.util.Observable;
84-
import java.util.Observer;
8578
import java.util.Set;
8679

8780
/**
@@ -1343,7 +1336,7 @@ private static boolean shouldBroadcastSafe(Location loc, Location lastLoc, Updat
13431336

13441337
// Check whether sufficient time has passed
13451338
long minTime = record.mRequest.getFastestInterval();
1346-
long delta = (loc.getElapsedRealtimeNano() - lastLoc.getElapsedRealtimeNano()) / 1000000L;
1339+
long delta = (loc.getElapsedRealtimeNanos() - lastLoc.getElapsedRealtimeNanos()) / 1000000L;
13471340
if (delta < minTime - MAX_PROVIDER_SCHEDULING_JITTER_MS) {
13481341
return false;
13491342
}

services/java/com/android/server/TwilightService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private static boolean hasMoved(Location from, Location to) {
147147
}
148148

149149
// if new location is older than the current one, the device hasn't moved.
150-
if (to.getElapsedRealtimeNano() < from.getElapsedRealtimeNano()) {
150+
if (to.getElapsedRealtimeNanos() < from.getElapsedRealtimeNanos()) {
151151
return false;
152152
}
153153

@@ -428,8 +428,8 @@ private void retrieveLocation() {
428428
mLocationManager.getLastKnownLocation(providers.next());
429429
// pick the most recent location
430430
if (location == null || (lastKnownLocation != null &&
431-
location.getElapsedRealtimeNano() <
432-
lastKnownLocation.getElapsedRealtimeNano())) {
431+
location.getElapsedRealtimeNanos() <
432+
lastKnownLocation.getElapsedRealtimeNanos())) {
433433
location = lastKnownLocation;
434434
}
435435
}
@@ -447,7 +447,7 @@ private void retrieveLocation() {
447447
location.setLatitude(0);
448448
location.setAccuracy(417000.0f);
449449
location.setTime(System.currentTimeMillis());
450-
location.setElapsedRealtimeNano(SystemClock.elapsedRealtimeNano());
450+
location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
451451

452452
if (DEBUG) {
453453
Slog.d(TAG, "Estimated location from timezone: " + location);

services/java/com/android/server/location/GpsLocationProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ private void reportLocation(int flags, double latitude, double longitude, double
10291029
mLocation.setTime(timestamp);
10301030
// It would be nice to push the elapsed real-time timestamp
10311031
// further down the stack, but this is still useful
1032-
mLocation.setElapsedRealtimeNano(SystemClock.elapsedRealtimeNano());
1032+
mLocation.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
10331033
}
10341034
if ((flags & LOCATION_HAS_ALTITUDE) == LOCATION_HAS_ALTITUDE) {
10351035
mLocation.setAltitude(altitude);

services/java/com/android/server/location/LocationBasedCountryDetector.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ protected Location getLastKnownLocation() {
115115
Location lastKnownLocation = mLocationManager.getLastKnownLocation(provider);
116116
if (lastKnownLocation != null) {
117117
if (bestLocation == null ||
118-
bestLocation.getElapsedRealtimeNano() <
119-
lastKnownLocation.getElapsedRealtimeNano()) {
118+
bestLocation.getElapsedRealtimeNanos() <
119+
lastKnownLocation.getElapsedRealtimeNanos()) {
120120
bestLocation = lastKnownLocation;
121121
}
122122
}

0 commit comments

Comments
 (0)