Loading services/core/java/com/android/server/location/GnssLocationProvider.java +21 −12 Original line number Original line Diff line number Diff line Loading @@ -359,8 +359,8 @@ public class GnssLocationProvider extends AbstractLocationProvider implements // The WorkSource associated with the most recent client request (i.e, most recent call to // The WorkSource associated with the most recent client request (i.e, most recent call to // setRequest). // setRequest). private WorkSource mWorkSource = null; private WorkSource mWorkSource = null; // True if gps should be disabled (used to support battery saver mode in settings). // True if gps should be disabled because of PowerManager controls private boolean mDisableGps = false; private boolean mDisableGpsForPowerManager = false; /** /** * Properties loaded from PROPERTIES_FILE. * Properties loaded from PROPERTIES_FILE. Loading Loading @@ -538,18 +538,19 @@ public class GnssLocationProvider extends AbstractLocationProvider implements private void updateLowPowerMode() { private void updateLowPowerMode() { // Disable GPS if we are in device idle mode. // Disable GPS if we are in device idle mode. boolean disableGps = mPowerManager.isDeviceIdleMode(); boolean disableGpsForPowerManager = mPowerManager.isDeviceIdleMode(); final PowerSaveState result = final PowerSaveState result = mPowerManager.getPowerSaveState(ServiceType.LOCATION); mPowerManager.getPowerSaveState(ServiceType.LOCATION); switch (result.locationMode) { switch (result.locationMode) { case PowerManager.LOCATION_MODE_GPS_DISABLED_WHEN_SCREEN_OFF: case PowerManager.LOCATION_MODE_GPS_DISABLED_WHEN_SCREEN_OFF: case PowerManager.LOCATION_MODE_ALL_DISABLED_WHEN_SCREEN_OFF: case PowerManager.LOCATION_MODE_ALL_DISABLED_WHEN_SCREEN_OFF: // If we are in battery saver mode and the screen is off, disable GPS. // If we are in battery saver mode and the screen is off, disable GPS. disableGps |= result.batterySaverEnabled && !mPowerManager.isInteractive(); disableGpsForPowerManager |= result.batterySaverEnabled && !mPowerManager.isInteractive(); break; break; } } if (disableGps != mDisableGps) { if (disableGpsForPowerManager != mDisableGpsForPowerManager) { mDisableGps = disableGps; mDisableGpsForPowerManager = disableGpsForPowerManager; updateEnabled(); updateEnabled(); updateRequirements(); updateRequirements(); } } Loading Loading @@ -953,11 +954,19 @@ public class GnssLocationProvider extends AbstractLocationProvider implements private void updateEnabled() { private void updateEnabled() { synchronized (mLock) { synchronized (mLock) { boolean enabled = // Generally follow location setting ((mProviderRequest != null && mProviderRequest.reportLocation boolean enabled = mContext.getSystemService(LocationManager.class).isLocationEnabled(); && mProviderRequest.locationSettingsIgnored) || ( mContext.getSystemService(LocationManager.class).isLocationEnabled() // ... but disable if PowerManager overrides && !mDisableGps)) && !mShutdown; enabled &= !mDisableGpsForPowerManager; // .. but enable anyway, if there's an active settings-ignored request (e.g. ELS) enabled |= (mProviderRequest != null && mProviderRequest.reportLocation && mProviderRequest.locationSettingsIgnored); // ... and, finally, disable anyway, if device is being shut down enabled &= !mShutdown; if (enabled == mEnabled) { if (enabled == mEnabled) { return; return; } } Loading Loading @@ -2133,7 +2142,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements .append(mGnssMeasurementsProvider.isRegistered()).append('\n'); .append(mGnssMeasurementsProvider.isRegistered()).append('\n'); s.append(" mGnssNavigationMessageProvider.isRegistered()=") s.append(" mGnssNavigationMessageProvider.isRegistered()=") .append(mGnssNavigationMessageProvider.isRegistered()).append('\n'); .append(mGnssNavigationMessageProvider.isRegistered()).append('\n'); s.append(" mDisableGps (battery saver mode)=").append(mDisableGps).append('\n'); s.append(" mDisableGpsForPowerManager=").append(mDisableGpsForPowerManager).append('\n'); s.append(" mEngineCapabilities=0x").append(Integer.toHexString(mEngineCapabilities)); s.append(" mEngineCapabilities=0x").append(Integer.toHexString(mEngineCapabilities)); s.append(" ( "); s.append(" ( "); if (hasCapability(GPS_CAPABILITY_SCHEDULING)) s.append("SCHEDULING "); if (hasCapability(GPS_CAPABILITY_SCHEDULING)) s.append("SCHEDULING "); Loading Loading
services/core/java/com/android/server/location/GnssLocationProvider.java +21 −12 Original line number Original line Diff line number Diff line Loading @@ -359,8 +359,8 @@ public class GnssLocationProvider extends AbstractLocationProvider implements // The WorkSource associated with the most recent client request (i.e, most recent call to // The WorkSource associated with the most recent client request (i.e, most recent call to // setRequest). // setRequest). private WorkSource mWorkSource = null; private WorkSource mWorkSource = null; // True if gps should be disabled (used to support battery saver mode in settings). // True if gps should be disabled because of PowerManager controls private boolean mDisableGps = false; private boolean mDisableGpsForPowerManager = false; /** /** * Properties loaded from PROPERTIES_FILE. * Properties loaded from PROPERTIES_FILE. Loading Loading @@ -538,18 +538,19 @@ public class GnssLocationProvider extends AbstractLocationProvider implements private void updateLowPowerMode() { private void updateLowPowerMode() { // Disable GPS if we are in device idle mode. // Disable GPS if we are in device idle mode. boolean disableGps = mPowerManager.isDeviceIdleMode(); boolean disableGpsForPowerManager = mPowerManager.isDeviceIdleMode(); final PowerSaveState result = final PowerSaveState result = mPowerManager.getPowerSaveState(ServiceType.LOCATION); mPowerManager.getPowerSaveState(ServiceType.LOCATION); switch (result.locationMode) { switch (result.locationMode) { case PowerManager.LOCATION_MODE_GPS_DISABLED_WHEN_SCREEN_OFF: case PowerManager.LOCATION_MODE_GPS_DISABLED_WHEN_SCREEN_OFF: case PowerManager.LOCATION_MODE_ALL_DISABLED_WHEN_SCREEN_OFF: case PowerManager.LOCATION_MODE_ALL_DISABLED_WHEN_SCREEN_OFF: // If we are in battery saver mode and the screen is off, disable GPS. // If we are in battery saver mode and the screen is off, disable GPS. disableGps |= result.batterySaverEnabled && !mPowerManager.isInteractive(); disableGpsForPowerManager |= result.batterySaverEnabled && !mPowerManager.isInteractive(); break; break; } } if (disableGps != mDisableGps) { if (disableGpsForPowerManager != mDisableGpsForPowerManager) { mDisableGps = disableGps; mDisableGpsForPowerManager = disableGpsForPowerManager; updateEnabled(); updateEnabled(); updateRequirements(); updateRequirements(); } } Loading Loading @@ -953,11 +954,19 @@ public class GnssLocationProvider extends AbstractLocationProvider implements private void updateEnabled() { private void updateEnabled() { synchronized (mLock) { synchronized (mLock) { boolean enabled = // Generally follow location setting ((mProviderRequest != null && mProviderRequest.reportLocation boolean enabled = mContext.getSystemService(LocationManager.class).isLocationEnabled(); && mProviderRequest.locationSettingsIgnored) || ( mContext.getSystemService(LocationManager.class).isLocationEnabled() // ... but disable if PowerManager overrides && !mDisableGps)) && !mShutdown; enabled &= !mDisableGpsForPowerManager; // .. but enable anyway, if there's an active settings-ignored request (e.g. ELS) enabled |= (mProviderRequest != null && mProviderRequest.reportLocation && mProviderRequest.locationSettingsIgnored); // ... and, finally, disable anyway, if device is being shut down enabled &= !mShutdown; if (enabled == mEnabled) { if (enabled == mEnabled) { return; return; } } Loading Loading @@ -2133,7 +2142,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements .append(mGnssMeasurementsProvider.isRegistered()).append('\n'); .append(mGnssMeasurementsProvider.isRegistered()).append('\n'); s.append(" mGnssNavigationMessageProvider.isRegistered()=") s.append(" mGnssNavigationMessageProvider.isRegistered()=") .append(mGnssNavigationMessageProvider.isRegistered()).append('\n'); .append(mGnssNavigationMessageProvider.isRegistered()).append('\n'); s.append(" mDisableGps (battery saver mode)=").append(mDisableGps).append('\n'); s.append(" mDisableGpsForPowerManager=").append(mDisableGpsForPowerManager).append('\n'); s.append(" mEngineCapabilities=0x").append(Integer.toHexString(mEngineCapabilities)); s.append(" mEngineCapabilities=0x").append(Integer.toHexString(mEngineCapabilities)); s.append(" ( "); s.append(" ( "); if (hasCapability(GPS_CAPABILITY_SCHEDULING)) s.append("SCHEDULING "); if (hasCapability(GPS_CAPABILITY_SCHEDULING)) s.append("SCHEDULING "); Loading