use of com.android.internal.location.ProviderRequest in project android_frameworks_base by crdroidandroid.
the class LocationManagerService method applyRequirementsLocked.
private void applyRequirementsLocked(String provider) {
LocationProviderInterface p = mProvidersByName.get(provider);
if (p == null)
return;
ArrayList<UpdateRecord> records = mRecordsByProvider.get(provider);
WorkSource worksource = new WorkSource();
ProviderRequest providerRequest = new ProviderRequest();
if (records != null) {
for (UpdateRecord record : records) {
if (isCurrentProfile(UserHandle.getUserId(record.mReceiver.mUid))) {
if (checkLocationAccess(record.mReceiver.mPid, record.mReceiver.mUid, record.mReceiver.mPackageName, record.mReceiver.mAllowedResolutionLevel)) {
LocationRequest locationRequest = record.mRequest;
providerRequest.locationRequests.add(locationRequest);
if (locationRequest.getInterval() < providerRequest.interval) {
providerRequest.reportLocation = true;
providerRequest.interval = locationRequest.getInterval();
}
}
}
}
if (providerRequest.reportLocation) {
// calculate who to blame for power
// This is somewhat arbitrary. We pick a threshold interval
// that is slightly higher that the minimum interval, and
// spread the blame across all applications with a request
// under that threshold.
long thresholdInterval = (providerRequest.interval + 1000) * 3 / 2;
for (UpdateRecord record : records) {
if (isCurrentProfile(UserHandle.getUserId(record.mReceiver.mUid))) {
LocationRequest locationRequest = record.mRequest;
// client has no permission to receive location data.
if (!providerRequest.locationRequests.contains(locationRequest)) {
continue;
}
if (locationRequest.getInterval() <= thresholdInterval) {
if (record.mReceiver.mWorkSource != null && record.mReceiver.mWorkSource.size() > 0 && record.mReceiver.mWorkSource.getName(0) != null) {
// Assign blame to another work source.
// Can only assign blame if the WorkSource contains names.
worksource.add(record.mReceiver.mWorkSource);
} else {
// Assign blame to caller.
worksource.add(record.mReceiver.mUid, record.mReceiver.mPackageName);
}
}
}
}
}
}
if (D)
Log.d(TAG, "provider request: " + provider + " " + providerRequest);
p.setRequest(providerRequest, worksource);
}
use of com.android.internal.location.ProviderRequest in project platform_frameworks_base by android.
the class LocationManagerService method applyRequirementsLocked.
private void applyRequirementsLocked(String provider) {
LocationProviderInterface p = mProvidersByName.get(provider);
if (p == null)
return;
ArrayList<UpdateRecord> records = mRecordsByProvider.get(provider);
WorkSource worksource = new WorkSource();
ProviderRequest providerRequest = new ProviderRequest();
if (records != null) {
for (UpdateRecord record : records) {
if (isCurrentProfile(UserHandle.getUserId(record.mReceiver.mUid))) {
if (checkLocationAccess(record.mReceiver.mPid, record.mReceiver.mUid, record.mReceiver.mPackageName, record.mReceiver.mAllowedResolutionLevel)) {
LocationRequest locationRequest = record.mRequest;
providerRequest.locationRequests.add(locationRequest);
if (locationRequest.getInterval() < providerRequest.interval) {
providerRequest.reportLocation = true;
providerRequest.interval = locationRequest.getInterval();
}
}
}
}
if (providerRequest.reportLocation) {
// calculate who to blame for power
// This is somewhat arbitrary. We pick a threshold interval
// that is slightly higher that the minimum interval, and
// spread the blame across all applications with a request
// under that threshold.
long thresholdInterval = (providerRequest.interval + 1000) * 3 / 2;
for (UpdateRecord record : records) {
if (isCurrentProfile(UserHandle.getUserId(record.mReceiver.mUid))) {
LocationRequest locationRequest = record.mRequest;
// client has no permission to receive location data.
if (!providerRequest.locationRequests.contains(locationRequest)) {
continue;
}
if (locationRequest.getInterval() <= thresholdInterval) {
if (record.mReceiver.mWorkSource != null && record.mReceiver.mWorkSource.size() > 0 && record.mReceiver.mWorkSource.getName(0) != null) {
// Assign blame to another work source.
// Can only assign blame if the WorkSource contains names.
worksource.add(record.mReceiver.mWorkSource);
} else {
// Assign blame to caller.
worksource.add(record.mReceiver.mUid, record.mReceiver.mPackageName);
}
}
}
}
}
}
if (D)
Log.d(TAG, "provider request: " + provider + " " + providerRequest);
p.setRequest(providerRequest, worksource);
}
use of com.android.internal.location.ProviderRequest in project android_frameworks_base by ParanoidAndroid.
the class LocationManagerService method applyRequirementsLocked.
private void applyRequirementsLocked(String provider) {
LocationProviderInterface p = mProvidersByName.get(provider);
if (p == null)
return;
ArrayList<UpdateRecord> records = mRecordsByProvider.get(provider);
WorkSource worksource = new WorkSource();
ProviderRequest providerRequest = new ProviderRequest();
if (records != null) {
for (UpdateRecord record : records) {
if (UserHandle.getUserId(record.mReceiver.mUid) == mCurrentUserId) {
if (checkLocationAccess(record.mReceiver.mUid, record.mReceiver.mPackageName, record.mReceiver.mAllowedResolutionLevel)) {
LocationRequest locationRequest = record.mRequest;
providerRequest.locationRequests.add(locationRequest);
if (locationRequest.getInterval() < providerRequest.interval) {
providerRequest.reportLocation = true;
providerRequest.interval = locationRequest.getInterval();
}
}
}
}
if (providerRequest.reportLocation) {
// calculate who to blame for power
// This is somewhat arbitrary. We pick a threshold interval
// that is slightly higher that the minimum interval, and
// spread the blame across all applications with a request
// under that threshold.
long thresholdInterval = (providerRequest.interval + 1000) * 3 / 2;
for (UpdateRecord record : records) {
if (UserHandle.getUserId(record.mReceiver.mUid) == mCurrentUserId) {
LocationRequest locationRequest = record.mRequest;
if (locationRequest.getInterval() <= thresholdInterval) {
worksource.add(record.mReceiver.mUid, record.mReceiver.mPackageName);
}
}
}
}
}
if (D)
Log.d(TAG, "provider request: " + provider + " " + providerRequest);
p.setRequest(providerRequest, worksource);
}
use of com.android.internal.location.ProviderRequest in project android_frameworks_base by AOSPA.
the class LocationManagerService method applyRequirementsLocked.
private void applyRequirementsLocked(String provider) {
LocationProviderInterface p = mProvidersByName.get(provider);
if (p == null)
return;
ArrayList<UpdateRecord> records = mRecordsByProvider.get(provider);
WorkSource worksource = new WorkSource();
ProviderRequest providerRequest = new ProviderRequest();
if (records != null) {
for (UpdateRecord record : records) {
if (record != null && record.mReceiver != null && isCurrentProfile(UserHandle.getUserId(record.mReceiver.mUid))) {
if (checkLocationAccess(record.mReceiver.mPid, record.mReceiver.mUid, record.mReceiver.mPackageName, record.mReceiver.mAllowedResolutionLevel)) {
LocationRequest locationRequest = record.mRequest;
providerRequest.locationRequests.add(locationRequest);
if (locationRequest.getInterval() < providerRequest.interval) {
providerRequest.reportLocation = true;
providerRequest.interval = locationRequest.getInterval();
}
}
}
}
if (providerRequest.reportLocation) {
// calculate who to blame for power
// This is somewhat arbitrary. We pick a threshold interval
// that is slightly higher that the minimum interval, and
// spread the blame across all applications with a request
// under that threshold.
long thresholdInterval = (providerRequest.interval + 1000) * 3 / 2;
for (UpdateRecord record : records) {
if (record != null && record.mReceiver != null && isCurrentProfile(UserHandle.getUserId(record.mReceiver.mUid))) {
LocationRequest locationRequest = record.mRequest;
// client has no permission to receive location data.
if (!providerRequest.locationRequests.contains(locationRequest)) {
continue;
}
if (locationRequest.getInterval() <= thresholdInterval) {
if (record.mReceiver.mWorkSource != null && record.mReceiver.mWorkSource.size() > 0 && record.mReceiver.mWorkSource.getName(0) != null) {
// Assign blame to another work source.
// Can only assign blame if the WorkSource contains names.
worksource.add(record.mReceiver.mWorkSource);
} else {
// Assign blame to caller.
worksource.add(record.mReceiver.mUid, record.mReceiver.mPackageName);
}
}
}
}
}
}
if (D)
Log.d(TAG, "provider request: " + provider + " " + providerRequest);
p.setRequest(providerRequest, worksource);
}
use of com.android.internal.location.ProviderRequest in project android_frameworks_base by DirtyUnicorns.
the class LocationManagerService method applyRequirementsLocked.
private void applyRequirementsLocked(String provider) {
LocationProviderInterface p = mProvidersByName.get(provider);
if (p == null)
return;
ArrayList<UpdateRecord> records = mRecordsByProvider.get(provider);
WorkSource worksource = new WorkSource();
ProviderRequest providerRequest = new ProviderRequest();
if (records != null) {
for (UpdateRecord record : records) {
if (isCurrentProfile(UserHandle.getUserId(record.mReceiver.mUid))) {
if (checkLocationAccess(record.mReceiver.mPid, record.mReceiver.mUid, record.mReceiver.mPackageName, record.mReceiver.mAllowedResolutionLevel)) {
LocationRequest locationRequest = record.mRequest;
providerRequest.locationRequests.add(locationRequest);
if (locationRequest.getInterval() < providerRequest.interval) {
providerRequest.reportLocation = true;
providerRequest.interval = locationRequest.getInterval();
}
}
}
}
if (providerRequest.reportLocation) {
// calculate who to blame for power
// This is somewhat arbitrary. We pick a threshold interval
// that is slightly higher that the minimum interval, and
// spread the blame across all applications with a request
// under that threshold.
long thresholdInterval = (providerRequest.interval + 1000) * 3 / 2;
for (UpdateRecord record : records) {
if (isCurrentProfile(UserHandle.getUserId(record.mReceiver.mUid))) {
LocationRequest locationRequest = record.mRequest;
// client has no permission to receive location data.
if (!providerRequest.locationRequests.contains(locationRequest)) {
continue;
}
if (locationRequest.getInterval() <= thresholdInterval) {
if (record.mReceiver.mWorkSource != null && record.mReceiver.mWorkSource.size() > 0 && record.mReceiver.mWorkSource.getName(0) != null) {
// Assign blame to another work source.
// Can only assign blame if the WorkSource contains names.
worksource.add(record.mReceiver.mWorkSource);
} else {
// Assign blame to caller.
worksource.add(record.mReceiver.mUid, record.mReceiver.mPackageName);
}
}
}
}
}
}
if (D)
Log.d(TAG, "provider request: " + provider + " " + providerRequest);
p.setRequest(providerRequest, worksource);
}
Aggregations