Merge "Revert "make FLP play nicely with multiuser"" into jb-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
167282f19f
@ -405,10 +405,8 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
|||||||
mLastLocation.clear();
|
mLastLocation.clear();
|
||||||
for (LocationProviderInterface p : mProviders) {
|
for (LocationProviderInterface p : mProviders) {
|
||||||
updateProviderListenersLocked(p.getName(), false, mCurrentUserId);
|
updateProviderListenersLocked(p.getName(), false, mCurrentUserId);
|
||||||
if (!LocationManager.FUSED_PROVIDER.equals(p.getName())) {
|
|
||||||
p.switchUser(userId);
|
p.switchUser(userId);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
mCurrentUserId = userId;
|
mCurrentUserId = userId;
|
||||||
updateProvidersLocked();
|
updateProvidersLocked();
|
||||||
}
|
}
|
||||||
@ -666,27 +664,9 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
|||||||
mProvidersByName.remove(provider.getName());
|
mProvidersByName.remove(provider.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the specified UID is SYSTEM_UID or matches the current user.
|
|
||||||
*
|
|
||||||
* @param uid the uid
|
|
||||||
* @return true if uid is SYSTEM_UID or matches the current user
|
|
||||||
*/
|
|
||||||
private boolean isCurrentUserOrSystemLocked(int uid) {
|
|
||||||
return uid == Process.SYSTEM_UID || UserHandle.getUserId(uid) == mCurrentUserId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
private boolean isAllowedBySettingsLocked(String provider, int userId) {
|
||||||
* Returns the first UID in the current user's range.
|
if (userId != mCurrentUserId) {
|
||||||
*
|
|
||||||
* @return the first UID in the current user's range
|
|
||||||
*/
|
|
||||||
private int getCurrentUidBaseLocked() {
|
|
||||||
return UserHandle.getUid(mCurrentUserId, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isAllowedBySettingsLocked(String provider, int uid) {
|
|
||||||
if (!isCurrentUserOrSystemLocked(uid)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (mEnabledProviders.contains(provider)) {
|
if (mEnabledProviders.contains(provider)) {
|
||||||
@ -695,10 +675,6 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
|||||||
if (mDisabledProviders.contains(provider)) {
|
if (mDisabledProviders.contains(provider)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (uid == Process.SYSTEM_UID) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use system settings
|
// Use system settings
|
||||||
ContentResolver resolver = mContext.getContentResolver();
|
ContentResolver resolver = mContext.getContentResolver();
|
||||||
|
|
||||||
@ -852,8 +828,8 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
|||||||
public List<String> getProviders(Criteria criteria, boolean enabledOnly) {
|
public List<String> getProviders(Criteria criteria, boolean enabledOnly) {
|
||||||
int allowedResolutionLevel = getCallerAllowedResolutionLevel();
|
int allowedResolutionLevel = getCallerAllowedResolutionLevel();
|
||||||
ArrayList<String> out;
|
ArrayList<String> out;
|
||||||
final int callingUid = Binder.getCallingUid();
|
int callingUserId = UserHandle.getCallingUserId();
|
||||||
final long identity = Binder.clearCallingIdentity();
|
long identity = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
out = new ArrayList<String>(mProviders.size());
|
out = new ArrayList<String>(mProviders.size());
|
||||||
@ -863,7 +839,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (allowedResolutionLevel >= getMinimumResolutionLevelForProviderUse(name)) {
|
if (allowedResolutionLevel >= getMinimumResolutionLevelForProviderUse(name)) {
|
||||||
if (enabledOnly && !isAllowedBySettingsLocked(name, callingUid)) {
|
if (enabledOnly && !isAllowedBySettingsLocked(name, callingUserId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (criteria != null && !LocationProvider.propertiesMeetCriteria(
|
if (criteria != null && !LocationProvider.propertiesMeetCriteria(
|
||||||
@ -939,7 +915,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
|||||||
LocationProviderInterface p = mProviders.get(i);
|
LocationProviderInterface p = mProviders.get(i);
|
||||||
boolean isEnabled = p.isEnabled();
|
boolean isEnabled = p.isEnabled();
|
||||||
String name = p.getName();
|
String name = p.getName();
|
||||||
boolean shouldBeEnabled = isAllowedBySettingsLocked(name, getCurrentUidBaseLocked());
|
boolean shouldBeEnabled = isAllowedBySettingsLocked(name, mCurrentUserId);
|
||||||
if (isEnabled && !shouldBeEnabled) {
|
if (isEnabled && !shouldBeEnabled) {
|
||||||
updateProviderListenersLocked(name, false, mCurrentUserId);
|
updateProviderListenersLocked(name, false, mCurrentUserId);
|
||||||
changesMade = true;
|
changesMade = true;
|
||||||
@ -967,7 +943,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
|||||||
final int N = records.size();
|
final int N = records.size();
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
UpdateRecord record = records.get(i);
|
UpdateRecord record = records.get(i);
|
||||||
if (isCurrentUserOrSystemLocked(record.mReceiver.mUid)) {
|
if (UserHandle.getUserId(record.mReceiver.mUid) == userId) {
|
||||||
// Sends a notification message to the receiver
|
// Sends a notification message to the receiver
|
||||||
if (!record.mReceiver.callProviderEnabledLocked(provider, enabled)) {
|
if (!record.mReceiver.callProviderEnabledLocked(provider, enabled)) {
|
||||||
if (deadReceivers == null) {
|
if (deadReceivers == null) {
|
||||||
@ -1006,7 +982,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
|||||||
|
|
||||||
if (records != null) {
|
if (records != null) {
|
||||||
for (UpdateRecord record : records) {
|
for (UpdateRecord record : records) {
|
||||||
if (isCurrentUserOrSystemLocked(record.mReceiver.mUid)) {
|
if (UserHandle.getUserId(record.mReceiver.mUid) == mCurrentUserId) {
|
||||||
LocationRequest locationRequest = record.mRequest;
|
LocationRequest locationRequest = record.mRequest;
|
||||||
providerRequest.locationRequests.add(locationRequest);
|
providerRequest.locationRequests.add(locationRequest);
|
||||||
if (locationRequest.getInterval() < providerRequest.interval) {
|
if (locationRequest.getInterval() < providerRequest.interval) {
|
||||||
@ -1024,7 +1000,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
|||||||
// under that threshold.
|
// under that threshold.
|
||||||
long thresholdInterval = (providerRequest.interval + 1000) * 3 / 2;
|
long thresholdInterval = (providerRequest.interval + 1000) * 3 / 2;
|
||||||
for (UpdateRecord record : records) {
|
for (UpdateRecord record : records) {
|
||||||
if (isCurrentUserOrSystemLocked(record.mReceiver.mUid)) {
|
if (UserHandle.getUserId(record.mReceiver.mUid) == mCurrentUserId) {
|
||||||
LocationRequest locationRequest = record.mRequest;
|
LocationRequest locationRequest = record.mRequest;
|
||||||
if (locationRequest.getInterval() <= thresholdInterval) {
|
if (locationRequest.getInterval() <= thresholdInterval) {
|
||||||
worksource.add(record.mReceiver.mUid);
|
worksource.add(record.mReceiver.mUid);
|
||||||
@ -1247,7 +1223,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
|||||||
oldRecord.disposeLocked(false);
|
oldRecord.disposeLocked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isProviderEnabled = isAllowedBySettingsLocked(name, uid);
|
boolean isProviderEnabled = isAllowedBySettingsLocked(name, UserHandle.getUserId(uid));
|
||||||
if (isProviderEnabled) {
|
if (isProviderEnabled) {
|
||||||
applyRequirementsLocked(name);
|
applyRequirementsLocked(name);
|
||||||
} else {
|
} else {
|
||||||
@ -1302,10 +1278,9 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update provider
|
// update provider
|
||||||
int currentUidBase = getCurrentUidBaseLocked();
|
|
||||||
for (String provider : providers) {
|
for (String provider : providers) {
|
||||||
// If provider is already disabled, don't need to do anything
|
// If provider is already disabled, don't need to do anything
|
||||||
if (!isAllowedBySettingsLocked(provider, currentUidBase)) {
|
if (!isAllowedBySettingsLocked(provider, mCurrentUserId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1323,8 +1298,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
|||||||
request.getProvider());
|
request.getProvider());
|
||||||
// no need to sanitize this request, as only the provider name is used
|
// no need to sanitize this request, as only the provider name is used
|
||||||
|
|
||||||
final int callingUid = Binder.getCallingUid();
|
long identity = Binder.clearCallingIdentity();
|
||||||
final long identity = Binder.clearCallingIdentity();
|
|
||||||
try {
|
try {
|
||||||
if (mBlacklist.isBlacklisted(packageName)) {
|
if (mBlacklist.isBlacklisted(packageName)) {
|
||||||
if (D) Log.d(TAG, "not returning last loc for blacklisted app: " +
|
if (D) Log.d(TAG, "not returning last loc for blacklisted app: " +
|
||||||
@ -1340,9 +1314,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
|||||||
LocationProviderInterface provider = mProvidersByName.get(name);
|
LocationProviderInterface provider = mProvidersByName.get(name);
|
||||||
if (provider == null) return null;
|
if (provider == null) return null;
|
||||||
|
|
||||||
if (!isAllowedBySettingsLocked(name, callingUid)) {
|
if (!isAllowedBySettingsLocked(name, mCurrentUserId)) return null;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Location location = mLastLocation.get(name);
|
Location location = mLastLocation.get(name);
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
@ -1499,14 +1471,13 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
|||||||
provider);
|
provider);
|
||||||
if (LocationManager.FUSED_PROVIDER.equals(provider)) return false;
|
if (LocationManager.FUSED_PROVIDER.equals(provider)) return false;
|
||||||
|
|
||||||
final int callingUid = Binder.getCallingUid();
|
long identity = Binder.clearCallingIdentity();
|
||||||
final long identity = Binder.clearCallingIdentity();
|
|
||||||
try {
|
try {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
LocationProviderInterface p = mProvidersByName.get(provider);
|
LocationProviderInterface p = mProvidersByName.get(provider);
|
||||||
if (p == null) return false;
|
if (p == null) return false;
|
||||||
|
|
||||||
return isAllowedBySettingsLocked(provider, callingUid);
|
return isAllowedBySettingsLocked(provider, mCurrentUserId);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(identity);
|
Binder.restoreCallingIdentity(identity);
|
||||||
@ -1645,10 +1616,10 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
|||||||
Receiver receiver = r.mReceiver;
|
Receiver receiver = r.mReceiver;
|
||||||
boolean receiverDead = false;
|
boolean receiverDead = false;
|
||||||
|
|
||||||
final int receiverUid = receiver.mUid;
|
int receiverUserId = UserHandle.getUserId(receiver.mUid);
|
||||||
if (!isCurrentUserOrSystemLocked(receiverUid)) {
|
if (receiverUserId != mCurrentUserId) {
|
||||||
if (D) {
|
if (D) {
|
||||||
Log.d(TAG, "skipping loc update for background uid " + receiverUid +
|
Log.d(TAG, "skipping loc update for background user " + receiverUserId +
|
||||||
" (current user: " + mCurrentUserId + ", app: " +
|
" (current user: " + mCurrentUserId + ", app: " +
|
||||||
receiver.mPackageName + ")");
|
receiver.mPackageName + ")");
|
||||||
}
|
}
|
||||||
@ -1745,7 +1716,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
|
|||||||
}
|
}
|
||||||
|
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (isAllowedBySettingsLocked(provider, getCurrentUidBaseLocked())) {
|
if (isAllowedBySettingsLocked(provider, mCurrentUserId)) {
|
||||||
handleLocationChangedLocked(location, passive);
|
handleLocationChangedLocked(location, passive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user