Loading location/java/android/location/LocationManagerInternal.java +8 −0 Original line number Diff line number Diff line Loading @@ -80,4 +80,12 @@ public abstract class LocationManagerInternal { */ // TODO: there is no reason for this to exist as part of any API. move all the logic into gnss public abstract void sendNiResponse(int notifId, int userResponse); /** * Returns the GNSS provided time. * * @return LocationTime object that includes the current time, according to the GNSS location * provider, and the elapsed nanos since boot the current time was computed at. */ public abstract @Nullable LocationTime getGnssTimeMillis(); } services/core/java/com/android/server/location/LocationManagerService.java +20 −16 Original line number Diff line number Diff line Loading @@ -807,22 +807,7 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public LocationTime getGnssTimeMillis() { synchronized (mLock) { LocationProviderManager gpsManager = getLocationProviderManager(GPS_PROVIDER); if (gpsManager == null) { return null; } Location location = gpsManager.getLastLocationUnsafe(UserHandle.USER_ALL, PERMISSION_FINE, false, Long.MAX_VALUE); if (location == null) { return null; } long currentNanos = SystemClock.elapsedRealtimeNanos(); long deltaMs = NANOSECONDS.toMillis(location.getElapsedRealtimeAgeNanos(currentNanos)); return new LocationTime(location.getTime() + deltaMs, currentNanos); } return mLocalService.getGnssTimeMillis(); } @Override Loading Loading @@ -1292,6 +1277,25 @@ public class LocationManagerService extends ILocationManager.Stub { mGnssManagerService.sendNiResponse(notifId, userResponse); } } @Override public @Nullable LocationTime getGnssTimeMillis() { LocationProviderManager gpsManager = getLocationProviderManager(GPS_PROVIDER); if (gpsManager == null) { return null; } Location location = gpsManager.getLastLocationUnsafe(UserHandle.USER_ALL, PERMISSION_FINE, false, Long.MAX_VALUE); if (location == null) { return null; } long currentNanos = SystemClock.elapsedRealtimeNanos(); long deltaMs = NANOSECONDS.toMillis( location.getElapsedRealtimeAgeNanos(currentNanos)); return new LocationTime(location.getTime() + deltaMs, currentNanos); } } private static class SystemInjector implements Injector { Loading Loading
location/java/android/location/LocationManagerInternal.java +8 −0 Original line number Diff line number Diff line Loading @@ -80,4 +80,12 @@ public abstract class LocationManagerInternal { */ // TODO: there is no reason for this to exist as part of any API. move all the logic into gnss public abstract void sendNiResponse(int notifId, int userResponse); /** * Returns the GNSS provided time. * * @return LocationTime object that includes the current time, according to the GNSS location * provider, and the elapsed nanos since boot the current time was computed at. */ public abstract @Nullable LocationTime getGnssTimeMillis(); }
services/core/java/com/android/server/location/LocationManagerService.java +20 −16 Original line number Diff line number Diff line Loading @@ -807,22 +807,7 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public LocationTime getGnssTimeMillis() { synchronized (mLock) { LocationProviderManager gpsManager = getLocationProviderManager(GPS_PROVIDER); if (gpsManager == null) { return null; } Location location = gpsManager.getLastLocationUnsafe(UserHandle.USER_ALL, PERMISSION_FINE, false, Long.MAX_VALUE); if (location == null) { return null; } long currentNanos = SystemClock.elapsedRealtimeNanos(); long deltaMs = NANOSECONDS.toMillis(location.getElapsedRealtimeAgeNanos(currentNanos)); return new LocationTime(location.getTime() + deltaMs, currentNanos); } return mLocalService.getGnssTimeMillis(); } @Override Loading Loading @@ -1292,6 +1277,25 @@ public class LocationManagerService extends ILocationManager.Stub { mGnssManagerService.sendNiResponse(notifId, userResponse); } } @Override public @Nullable LocationTime getGnssTimeMillis() { LocationProviderManager gpsManager = getLocationProviderManager(GPS_PROVIDER); if (gpsManager == null) { return null; } Location location = gpsManager.getLastLocationUnsafe(UserHandle.USER_ALL, PERMISSION_FINE, false, Long.MAX_VALUE); if (location == null) { return null; } long currentNanos = SystemClock.elapsedRealtimeNanos(); long deltaMs = NANOSECONDS.toMillis( location.getElapsedRealtimeAgeNanos(currentNanos)); return new LocationTime(location.getTime() + deltaMs, currentNanos); } } private static class SystemInjector implements Injector { Loading