Loading core/java/com/android/server/SystemConfig.java +19 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,10 @@ public class SystemConfig { // background while in data-usage save mode, as read from the configuration files. final ArraySet<String> mAllowInDataUsageSave = new ArraySet<>(); // These are the packages that are white-listed to be able to run background location // without throttling, as read from the configuration files. final ArraySet<String> mAllowUnthrottledLocation = new ArraySet<>(); // These are the action strings of broadcasts which are whitelisted to // be delivered anonymously even to apps which target O+. final ArraySet<String> mAllowImplicitBroadcasts = new ArraySet<>(); Loading Loading @@ -182,6 +186,10 @@ public class SystemConfig { return mAllowInDataUsageSave; } public ArraySet<String> getAllowUnthrottledLocation() { return mAllowUnthrottledLocation; } public ArraySet<String> getLinkedApps() { return mLinkedApps; } Loading Loading @@ -446,6 +454,17 @@ public class SystemConfig { XmlUtils.skipCurrentTag(parser); continue; } else if ("allow-unthrottled-location".equals(name) && allowAll) { String pkgname = parser.getAttributeValue(null, "package"); if (pkgname == null) { Slog.w(TAG, "<allow-unthrottled-location> without package in " + permFile + " at " + parser.getPositionDescription()); } else { mAllowUnthrottledLocation.add(pkgname); } XmlUtils.skipCurrentTag(parser); continue; } else if ("allow-implicit-broadcast".equals(name) && allowAll) { String action = parser.getAttributeValue(null, "action"); if (action == null) { Loading services/core/java/com/android/server/LocationManagerService.java +28 −18 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server; import android.app.ActivityManager; import android.annotation.NonNull; import android.content.pm.PackageManagerInternal; import android.util.ArraySet; import com.android.internal.content.PackageMonitor; import com.android.internal.location.ProviderProperties; import com.android.internal.location.ProviderRequest; Loading Loading @@ -135,8 +136,6 @@ public class LocationManagerService extends ILocationManager.Stub { private static final String FUSED_LOCATION_SERVICE_ACTION = "com.android.location.service.FusedLocationProvider"; private static final String GMSCORE_PACKAGE = "com.android.google.gms"; private static final int MSG_LOCATION_CHANGED = 1; private static final long NANOS_PER_MILLI = 1000000L; Loading Loading @@ -224,7 +223,7 @@ public class LocationManagerService extends ILocationManager.Stub { private final ArrayList<LocationProviderProxy> mProxyProviders = new ArrayList<>(); private String[] mBackgroundThrottlePackageWhitelist = new String[]{}; private final ArraySet<String> mBackgroundThrottlePackageWhitelist = new ArraySet<>(); // current active user on the device - other users are denied location data private int mCurrentUserId = UserHandle.USER_SYSTEM; Loading Loading @@ -345,6 +344,8 @@ public class LocationManagerService extends ILocationManager.Stub { mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); updateUserProfiles(mCurrentUserId); updateThrottlingWhitelistLocked(); // prepare providers loadProvidersLocked(); updateProvidersLocked(); Loading Loading @@ -380,14 +381,7 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void onChange(boolean selfChange) { synchronized (mLock) { String setting = Settings.Global.getString( mContext.getContentResolver(), Settings.Global.LOCATION_BACKGROUND_THROTTLE_PACKAGE_WHITELIST); if (setting == null) { setting = ""; } mBackgroundThrottlePackageWhitelist = setting.split(","); updateThrottlingWhitelistLocked(); updateProvidersLocked(); } } Loading Loading @@ -1747,12 +1741,27 @@ public class LocationManagerService extends ILocationManager.Stub { p.setRequest(providerRequest, worksource); } private void updateThrottlingWhitelistLocked() { String setting = Settings.Global.getString( mContext.getContentResolver(), Settings.Global.LOCATION_BACKGROUND_THROTTLE_PACKAGE_WHITELIST); if (setting == null) { setting = ""; } mBackgroundThrottlePackageWhitelist.clear(); mBackgroundThrottlePackageWhitelist.addAll( SystemConfig.getInstance().getAllowUnthrottledLocation()); mBackgroundThrottlePackageWhitelist.addAll( Arrays.asList(setting.split(","))); } private boolean isThrottlingExemptLocked(Receiver receiver) { if (receiver.mUid == Process.SYSTEM_UID) { return true; } if (receiver.mPackageName.equals(GMSCORE_PACKAGE)) { if (mBackgroundThrottlePackageWhitelist.contains(receiver.mPackageName)) { return true; } Loading @@ -1762,12 +1771,6 @@ public class LocationManagerService extends ILocationManager.Stub { } } for (String whitelistedPackage : mBackgroundThrottlePackageWhitelist) { if (receiver.mPackageName.equals(whitelistedPackage)) { return true; } } return false; } Loading Loading @@ -2999,6 +3002,13 @@ public class LocationManagerService extends ILocationManager.Stub { } } if (!mBackgroundThrottlePackageWhitelist.isEmpty()) { pw.println(" Throttling Whitelisted Packages:"); for (String packageName : mBackgroundThrottlePackageWhitelist) { pw.println(" " + packageName); } } pw.append(" fudger: "); mLocationFudger.dump(fd, pw, args); Loading Loading
core/java/com/android/server/SystemConfig.java +19 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,10 @@ public class SystemConfig { // background while in data-usage save mode, as read from the configuration files. final ArraySet<String> mAllowInDataUsageSave = new ArraySet<>(); // These are the packages that are white-listed to be able to run background location // without throttling, as read from the configuration files. final ArraySet<String> mAllowUnthrottledLocation = new ArraySet<>(); // These are the action strings of broadcasts which are whitelisted to // be delivered anonymously even to apps which target O+. final ArraySet<String> mAllowImplicitBroadcasts = new ArraySet<>(); Loading Loading @@ -182,6 +186,10 @@ public class SystemConfig { return mAllowInDataUsageSave; } public ArraySet<String> getAllowUnthrottledLocation() { return mAllowUnthrottledLocation; } public ArraySet<String> getLinkedApps() { return mLinkedApps; } Loading Loading @@ -446,6 +454,17 @@ public class SystemConfig { XmlUtils.skipCurrentTag(parser); continue; } else if ("allow-unthrottled-location".equals(name) && allowAll) { String pkgname = parser.getAttributeValue(null, "package"); if (pkgname == null) { Slog.w(TAG, "<allow-unthrottled-location> without package in " + permFile + " at " + parser.getPositionDescription()); } else { mAllowUnthrottledLocation.add(pkgname); } XmlUtils.skipCurrentTag(parser); continue; } else if ("allow-implicit-broadcast".equals(name) && allowAll) { String action = parser.getAttributeValue(null, "action"); if (action == null) { Loading
services/core/java/com/android/server/LocationManagerService.java +28 −18 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server; import android.app.ActivityManager; import android.annotation.NonNull; import android.content.pm.PackageManagerInternal; import android.util.ArraySet; import com.android.internal.content.PackageMonitor; import com.android.internal.location.ProviderProperties; import com.android.internal.location.ProviderRequest; Loading Loading @@ -135,8 +136,6 @@ public class LocationManagerService extends ILocationManager.Stub { private static final String FUSED_LOCATION_SERVICE_ACTION = "com.android.location.service.FusedLocationProvider"; private static final String GMSCORE_PACKAGE = "com.android.google.gms"; private static final int MSG_LOCATION_CHANGED = 1; private static final long NANOS_PER_MILLI = 1000000L; Loading Loading @@ -224,7 +223,7 @@ public class LocationManagerService extends ILocationManager.Stub { private final ArrayList<LocationProviderProxy> mProxyProviders = new ArrayList<>(); private String[] mBackgroundThrottlePackageWhitelist = new String[]{}; private final ArraySet<String> mBackgroundThrottlePackageWhitelist = new ArraySet<>(); // current active user on the device - other users are denied location data private int mCurrentUserId = UserHandle.USER_SYSTEM; Loading Loading @@ -345,6 +344,8 @@ public class LocationManagerService extends ILocationManager.Stub { mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); updateUserProfiles(mCurrentUserId); updateThrottlingWhitelistLocked(); // prepare providers loadProvidersLocked(); updateProvidersLocked(); Loading Loading @@ -380,14 +381,7 @@ public class LocationManagerService extends ILocationManager.Stub { @Override public void onChange(boolean selfChange) { synchronized (mLock) { String setting = Settings.Global.getString( mContext.getContentResolver(), Settings.Global.LOCATION_BACKGROUND_THROTTLE_PACKAGE_WHITELIST); if (setting == null) { setting = ""; } mBackgroundThrottlePackageWhitelist = setting.split(","); updateThrottlingWhitelistLocked(); updateProvidersLocked(); } } Loading Loading @@ -1747,12 +1741,27 @@ public class LocationManagerService extends ILocationManager.Stub { p.setRequest(providerRequest, worksource); } private void updateThrottlingWhitelistLocked() { String setting = Settings.Global.getString( mContext.getContentResolver(), Settings.Global.LOCATION_BACKGROUND_THROTTLE_PACKAGE_WHITELIST); if (setting == null) { setting = ""; } mBackgroundThrottlePackageWhitelist.clear(); mBackgroundThrottlePackageWhitelist.addAll( SystemConfig.getInstance().getAllowUnthrottledLocation()); mBackgroundThrottlePackageWhitelist.addAll( Arrays.asList(setting.split(","))); } private boolean isThrottlingExemptLocked(Receiver receiver) { if (receiver.mUid == Process.SYSTEM_UID) { return true; } if (receiver.mPackageName.equals(GMSCORE_PACKAGE)) { if (mBackgroundThrottlePackageWhitelist.contains(receiver.mPackageName)) { return true; } Loading @@ -1762,12 +1771,6 @@ public class LocationManagerService extends ILocationManager.Stub { } } for (String whitelistedPackage : mBackgroundThrottlePackageWhitelist) { if (receiver.mPackageName.equals(whitelistedPackage)) { return true; } } return false; } Loading Loading @@ -2999,6 +3002,13 @@ public class LocationManagerService extends ILocationManager.Stub { } } if (!mBackgroundThrottlePackageWhitelist.isEmpty()) { pw.println(" Throttling Whitelisted Packages:"); for (String packageName : mBackgroundThrottlePackageWhitelist) { pw.println(" " + packageName); } } pw.append(" fudger: "); mLocationFudger.dump(fd, pw, args); Loading