Loading services/core/java/com/android/server/LocationManagerService.java +5 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,7 @@ import android.util.ArraySet; import android.util.EventLog; import android.util.Log; import android.util.Slog; import android.util.TimeUtils; import com.android.internal.annotations.GuardedBy; import com.android.internal.content.PackageMonitor; Loading Loading @@ -3567,6 +3568,10 @@ public class LocationManagerService extends ILocationManager.Stub { return; } pw.println("Current Location Manager state:"); pw.print(" Current System Time: " + TimeUtils.logTimeOfDay(System.currentTimeMillis())); pw.println(", Current Elapsed Time: " + TimeUtils.formatDuration(SystemClock.elapsedRealtime())); pw.println(" Current user: " + mCurrentUserId + " " + Arrays.toString( mCurrentUserProfiles)); pw.println(" Location mode: " + isLocationEnabled()); Loading services/core/java/com/android/server/location/GnssLocationProvider.java +40 −7 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ import android.telephony.gsm.GsmCellLocation; import android.text.TextUtils; import android.util.Log; import android.util.StatsLog; import android.util.TimeUtils; import com.android.internal.annotations.GuardedBy; import com.android.internal.app.IBatteryStats; Loading Loading @@ -332,9 +333,16 @@ public class GnssLocationProvider extends AbstractLocationProvider implements // true if low power mode for the GNSS chipset is part of the latest request. private boolean mLowPowerMode = false; // true if we started navigation // true if we started navigation in the HAL, only change value of this in setStarted private boolean mStarted; // for logging of latest change, and warning of ongoing location after a stop private long mStartedChangedElapsedRealtime; // threshold for delay in GNSS engine turning off before warning & error private static final long LOCATION_OFF_DELAY_THRESHOLD_WARN_MILLIS = 2 * 1000; private static final long LOCATION_OFF_DELAY_THRESHOLD_ERROR_MILLIS = 15 * 1000; // capabilities reported through the top level IGnssCallback.hal private volatile int mTopHalCapabilities; Loading Loading @@ -1192,7 +1200,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements if (DEBUG) Log.d(TAG, "startNavigating"); mTimeToFirstFix = 0; mLastFixTime = 0; mStarted = true; setStarted(true); mPositionMode = GPS_POSITION_MODE_STANDALONE; // Notify about suppressed output, if speed limit was previously exceeded. // Elsewhere, we check again with every speed output reported. Loading Loading @@ -1230,12 +1238,12 @@ public class GnssLocationProvider extends AbstractLocationProvider implements mLowPowerMode = mProviderRequest.lowPowerMode; if (!setPositionMode(mPositionMode, GPS_POSITION_RECURRENCE_PERIODIC, interval, 0, 0, mLowPowerMode)) { mStarted = false; setStarted(false); Log.e(TAG, "set_position_mode failed in startNavigating()"); return; } if (!native_start()) { mStarted = false; setStarted(false); Log.e(TAG, "native_start failed in startNavigating()"); return; } Loading @@ -1258,7 +1266,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements private void stopNavigating() { if (DEBUG) Log.d(TAG, "stopNavigating"); if (mStarted) { mStarted = false; setStarted(false); native_stop(); mLastFixTime = 0; // native_stop() may reset the position mode in hardware. Loading @@ -1270,6 +1278,13 @@ public class GnssLocationProvider extends AbstractLocationProvider implements } } private void setStarted(boolean started) { if (mStarted != started) { mStarted = started; mStartedChangedElapsedRealtime = SystemClock.elapsedRealtime(); } } private void hibernate() { // stop GPS until our next fix interval arrives stopNavigating(); Loading Loading @@ -1319,6 +1334,21 @@ public class GnssLocationProvider extends AbstractLocationProvider implements mGnssMetrics.logMissedReports(mFixInterval, timeBetweenFixes); } } } else { // Warn or error about long delayed GNSS engine shutdown as this generally wastes // power and sends location when not expected. long locationAfterStartedFalseMillis = SystemClock.elapsedRealtime() - mStartedChangedElapsedRealtime; if (locationAfterStartedFalseMillis > LOCATION_OFF_DELAY_THRESHOLD_WARN_MILLIS) { String logMessage = "Unexpected GNSS Location report " + TimeUtils.formatDuration(locationAfterStartedFalseMillis) + " after location turned off"; if (locationAfterStartedFalseMillis > LOCATION_OFF_DELAY_THRESHOLD_ERROR_MILLIS) { Log.e(TAG, logMessage); } else { Log.w(TAG, logMessage); } } } mLastFixTime = SystemClock.elapsedRealtime(); Loading Loading @@ -1538,7 +1568,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements private void restartLocationRequest() { if (DEBUG) Log.d(TAG, "restartLocationRequest"); mStarted = false; setStarted(false); updateRequirements(); } Loading Loading @@ -2152,7 +2182,10 @@ public class GnssLocationProvider extends AbstractLocationProvider implements @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { StringBuilder s = new StringBuilder(); s.append(" mStarted=").append(mStarted).append('\n'); s.append(" mStarted=").append(mStarted).append(" (changed "); TimeUtils.formatDuration(SystemClock.elapsedRealtime() - mStartedChangedElapsedRealtime, s); s.append(" ago)").append('\n'); s.append(" mFixInterval=").append(mFixInterval).append('\n'); s.append(" mLowPowerMode=").append(mLowPowerMode).append('\n'); s.append(" mGnssMeasurementsProvider.isRegistered()=") Loading Loading
services/core/java/com/android/server/LocationManagerService.java +5 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,7 @@ import android.util.ArraySet; import android.util.EventLog; import android.util.Log; import android.util.Slog; import android.util.TimeUtils; import com.android.internal.annotations.GuardedBy; import com.android.internal.content.PackageMonitor; Loading Loading @@ -3567,6 +3568,10 @@ public class LocationManagerService extends ILocationManager.Stub { return; } pw.println("Current Location Manager state:"); pw.print(" Current System Time: " + TimeUtils.logTimeOfDay(System.currentTimeMillis())); pw.println(", Current Elapsed Time: " + TimeUtils.formatDuration(SystemClock.elapsedRealtime())); pw.println(" Current user: " + mCurrentUserId + " " + Arrays.toString( mCurrentUserProfiles)); pw.println(" Location mode: " + isLocationEnabled()); Loading
services/core/java/com/android/server/location/GnssLocationProvider.java +40 −7 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ import android.telephony.gsm.GsmCellLocation; import android.text.TextUtils; import android.util.Log; import android.util.StatsLog; import android.util.TimeUtils; import com.android.internal.annotations.GuardedBy; import com.android.internal.app.IBatteryStats; Loading Loading @@ -332,9 +333,16 @@ public class GnssLocationProvider extends AbstractLocationProvider implements // true if low power mode for the GNSS chipset is part of the latest request. private boolean mLowPowerMode = false; // true if we started navigation // true if we started navigation in the HAL, only change value of this in setStarted private boolean mStarted; // for logging of latest change, and warning of ongoing location after a stop private long mStartedChangedElapsedRealtime; // threshold for delay in GNSS engine turning off before warning & error private static final long LOCATION_OFF_DELAY_THRESHOLD_WARN_MILLIS = 2 * 1000; private static final long LOCATION_OFF_DELAY_THRESHOLD_ERROR_MILLIS = 15 * 1000; // capabilities reported through the top level IGnssCallback.hal private volatile int mTopHalCapabilities; Loading Loading @@ -1192,7 +1200,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements if (DEBUG) Log.d(TAG, "startNavigating"); mTimeToFirstFix = 0; mLastFixTime = 0; mStarted = true; setStarted(true); mPositionMode = GPS_POSITION_MODE_STANDALONE; // Notify about suppressed output, if speed limit was previously exceeded. // Elsewhere, we check again with every speed output reported. Loading Loading @@ -1230,12 +1238,12 @@ public class GnssLocationProvider extends AbstractLocationProvider implements mLowPowerMode = mProviderRequest.lowPowerMode; if (!setPositionMode(mPositionMode, GPS_POSITION_RECURRENCE_PERIODIC, interval, 0, 0, mLowPowerMode)) { mStarted = false; setStarted(false); Log.e(TAG, "set_position_mode failed in startNavigating()"); return; } if (!native_start()) { mStarted = false; setStarted(false); Log.e(TAG, "native_start failed in startNavigating()"); return; } Loading @@ -1258,7 +1266,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements private void stopNavigating() { if (DEBUG) Log.d(TAG, "stopNavigating"); if (mStarted) { mStarted = false; setStarted(false); native_stop(); mLastFixTime = 0; // native_stop() may reset the position mode in hardware. Loading @@ -1270,6 +1278,13 @@ public class GnssLocationProvider extends AbstractLocationProvider implements } } private void setStarted(boolean started) { if (mStarted != started) { mStarted = started; mStartedChangedElapsedRealtime = SystemClock.elapsedRealtime(); } } private void hibernate() { // stop GPS until our next fix interval arrives stopNavigating(); Loading Loading @@ -1319,6 +1334,21 @@ public class GnssLocationProvider extends AbstractLocationProvider implements mGnssMetrics.logMissedReports(mFixInterval, timeBetweenFixes); } } } else { // Warn or error about long delayed GNSS engine shutdown as this generally wastes // power and sends location when not expected. long locationAfterStartedFalseMillis = SystemClock.elapsedRealtime() - mStartedChangedElapsedRealtime; if (locationAfterStartedFalseMillis > LOCATION_OFF_DELAY_THRESHOLD_WARN_MILLIS) { String logMessage = "Unexpected GNSS Location report " + TimeUtils.formatDuration(locationAfterStartedFalseMillis) + " after location turned off"; if (locationAfterStartedFalseMillis > LOCATION_OFF_DELAY_THRESHOLD_ERROR_MILLIS) { Log.e(TAG, logMessage); } else { Log.w(TAG, logMessage); } } } mLastFixTime = SystemClock.elapsedRealtime(); Loading Loading @@ -1538,7 +1568,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements private void restartLocationRequest() { if (DEBUG) Log.d(TAG, "restartLocationRequest"); mStarted = false; setStarted(false); updateRequirements(); } Loading Loading @@ -2152,7 +2182,10 @@ public class GnssLocationProvider extends AbstractLocationProvider implements @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { StringBuilder s = new StringBuilder(); s.append(" mStarted=").append(mStarted).append('\n'); s.append(" mStarted=").append(mStarted).append(" (changed "); TimeUtils.formatDuration(SystemClock.elapsedRealtime() - mStartedChangedElapsedRealtime, s); s.append(" ago)").append('\n'); s.append(" mFixInterval=").append(mFixInterval).append('\n'); s.append(" mLowPowerMode=").append(mLowPowerMode).append('\n'); s.append(" mGnssMeasurementsProvider.isRegistered()=") Loading