Fix location INTERACT_ACROSS_USERS bug

Use UserHandle.getCallingUserId in LocationManager.isProviderEnabled

Bug: 72430849
Test: Manual
Change-Id: I1ddfc4fd308889b1f2247df038d22e2f7b08da74
This commit is contained in:
Maggie
2018-01-24 11:01:20 -08:00
parent d2c4f7f610
commit 9ebcf05596

View File

@@ -2570,7 +2570,7 @@ public class LocationManagerService extends ILocationManager.Stub {
// Check INTERACT_ACROSS_USERS permission if userId is not current user id.
checkInteractAcrossUsersPermission(userId);
// enable all location providers
// Enable or disable all location providers
synchronized (mLock) {
for(String provider : getAllProviders()) {
setProviderEnabledForUser(provider, enabled, userId);
@@ -2586,10 +2586,10 @@ public class LocationManagerService extends ILocationManager.Stub {
*/
@Override
public boolean isLocationEnabledForUser(int userId) {
// Check INTERACT_ACROSS_USERS permission if userId is not current user id.
checkInteractAcrossUsersPermission(userId);
// If at least one location provider is enabled, return true
synchronized (mLock) {
for (String provider : getAllProviders()) {
if (isProviderEnabledForUser(provider, userId)) {
@@ -2602,7 +2602,7 @@ public class LocationManagerService extends ILocationManager.Stub {
@Override
public boolean isProviderEnabled(String provider) {
return isProviderEnabledForUser(provider, UserHandle.myUserId());
return isProviderEnabledForUser(provider, UserHandle.getCallingUserId());
}
/**