Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 503f9e89 authored by Chris Tran's avatar Chris Tran Committed by Android (Google) Code Review
Browse files

Merge "Log location enabled state for location battery metrics"

parents a83230a8 5435fe43
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -202,6 +202,9 @@ public class LocationManagerService extends ILocationManager.Stub implements
        @Override
        public void onUserStarting(TargetUser user) {
            mUserInfoHelper.onUserStarted(user.getUserIdentifier());

            // log location enabled state on start to minimize coverage loss
            mService.logLocationEnabledState();
        }

        @Override
@@ -553,6 +556,7 @@ public class LocationManagerService extends ILocationManager.Stub implements
        }

        EVENT_LOG.logLocationEnabled(userId, enabled);
        logLocationEnabledState();

        Intent intent = new Intent(LocationManager.MODE_CHANGED_ACTION)
                .putExtra(LocationManager.EXTRA_LOCATION_ENABLED, enabled)
@@ -563,6 +567,20 @@ public class LocationManagerService extends ILocationManager.Stub implements
        refreshAppOpsRestrictions(userId);
    }

    private void logLocationEnabledState() {
        boolean locationEnabled = false;
        // Location setting is considered on if it is enabled for any one user
        int[] runningUserIds = mInjector.getUserInfoHelper().getRunningUserIds();
        for (int userId : runningUserIds) {
            locationEnabled = mInjector.getSettingsHelper().isLocationEnabled(userId);
            if (locationEnabled) {
                break;
            }
        }
        mInjector.getLocationUsageLogger()
            .logLocationEnabledStateChanged(locationEnabled);
    }

    @Override
    public int getGnssYearOfHardware() {
        return mGnssManagerService == null ? 0 : mGnssManagerService.getGnssYearOfHardware();
+7 −0
Original line number Diff line number Diff line
@@ -122,6 +122,13 @@ public class LocationUsageLogger {
        }
    }

    /**
     * Log a location enabled state change event.
     */
    public synchronized void logLocationEnabledStateChanged(boolean enabled) {
        FrameworkStatsLog.write(FrameworkStatsLog.LOCATION_ENABLED_STATE_CHANGED, enabled);
    }

    private static int bucketizeProvider(String provider) {
        if (LocationManager.NETWORK_PROVIDER.equals(provider)) {
            return LocationStatsEnums.PROVIDER_NETWORK;