use of com.android.server.location.MockProvider in project platform_frameworks_base by android.
the class LocationManagerService method removeTestProvider.
@Override
public void removeTestProvider(String provider, String opPackageName) {
if (!canCallerAccessMockLocation(opPackageName)) {
return;
}
synchronized (mLock) {
// These methods can't be called after removing the test provider, so first make sure
// we don't leave anything dangling.
clearTestProviderEnabled(provider, opPackageName);
clearTestProviderLocation(provider, opPackageName);
clearTestProviderStatus(provider, opPackageName);
MockProvider mockProvider = mMockProviders.remove(provider);
if (mockProvider == null) {
throw new IllegalArgumentException("Provider \"" + provider + "\" unknown");
}
long identity = Binder.clearCallingIdentity();
removeProviderLocked(mProvidersByName.get(provider));
// reinstate real provider if available
LocationProviderInterface realProvider = mRealProviders.get(provider);
if (realProvider != null) {
addProviderLocked(realProvider);
}
mLastLocation.put(provider, null);
mLastLocationCoarseInterval.put(provider, null);
updateProvidersLocked();
Binder.restoreCallingIdentity(identity);
}
}
use of com.android.server.location.MockProvider in project platform_frameworks_base by android.
the class LocationManagerService method clearTestProviderStatus.
@Override
public void clearTestProviderStatus(String provider, String opPackageName) {
if (!canCallerAccessMockLocation(opPackageName)) {
return;
}
synchronized (mLock) {
MockProvider mockProvider = mMockProviders.get(provider);
if (mockProvider == null) {
throw new IllegalArgumentException("Provider \"" + provider + "\" unknown");
}
mockProvider.clearStatus();
}
}
use of com.android.server.location.MockProvider in project platform_frameworks_base by android.
the class LocationManagerService method addTestProviderLocked.
private void addTestProviderLocked(String name, ProviderProperties properties) {
if (mProvidersByName.get(name) != null) {
throw new IllegalArgumentException("Provider \"" + name + "\" already exists");
}
MockProvider provider = new MockProvider(name, this, properties);
addProviderLocked(provider);
mMockProviders.put(name, provider);
mLastLocation.put(name, null);
mLastLocationCoarseInterval.put(name, null);
}
use of com.android.server.location.MockProvider in project android_frameworks_base by ParanoidAndroid.
the class LocationManagerService method clearTestProviderLocation.
@Override
public void clearTestProviderLocation(String provider) {
checkMockPermissionsSafe();
synchronized (mLock) {
MockProvider mockProvider = mMockProviders.get(provider);
if (mockProvider == null) {
throw new IllegalArgumentException("Provider \"" + provider + "\" unknown");
}
mockProvider.clearLocation();
}
}
use of com.android.server.location.MockProvider in project android_frameworks_base by ParanoidAndroid.
the class LocationManagerService method setTestProviderEnabled.
@Override
public void setTestProviderEnabled(String provider, boolean enabled) {
checkMockPermissionsSafe();
synchronized (mLock) {
MockProvider mockProvider = mMockProviders.get(provider);
if (mockProvider == null) {
throw new IllegalArgumentException("Provider \"" + provider + "\" unknown");
}
long identity = Binder.clearCallingIdentity();
if (enabled) {
mockProvider.enable();
mEnabledProviders.add(provider);
mDisabledProviders.remove(provider);
} else {
mockProvider.disable();
mEnabledProviders.remove(provider);
mDisabledProviders.add(provider);
}
updateProvidersLocked();
Binder.restoreCallingIdentity(identity);
}
}
Aggregations