Search in sources :

Example 26 with MockProvider

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);
    }
}
Also used : MockProvider(com.android.server.location.MockProvider) LocationProviderInterface(com.android.server.location.LocationProviderInterface)

Example 27 with MockProvider

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();
    }
}
Also used : MockProvider(com.android.server.location.MockProvider)

Example 28 with MockProvider

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);
}
Also used : MockProvider(com.android.server.location.MockProvider)

Example 29 with MockProvider

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();
    }
}
Also used : MockProvider(com.android.server.location.MockProvider)

Example 30 with MockProvider

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);
    }
}
Also used : MockProvider(com.android.server.location.MockProvider)

Aggregations

MockProvider (com.android.server.location.MockProvider)54 LocationProviderInterface (com.android.server.location.LocationProviderInterface)13 Location (android.location.Location)9 BroadcastReceiver (android.content.BroadcastReceiver)6 LocationProviderProxy (com.android.server.location.LocationProviderProxy)6 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 PackageProviderKey (com.android.server.location.LocationRequestStatistics.PackageProviderKey)5 PackageStatistics (com.android.server.location.LocationRequestStatistics.PackageStatistics)5