Search in sources :

Example 31 with MockProvider

use of com.android.server.location.MockProvider in project android_frameworks_base by ParanoidAndroid.

the class LocationManagerService method clearTestProviderStatus.

@Override
public void clearTestProviderStatus(String provider) {
    checkMockPermissionsSafe();
    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 32 with MockProvider

use of com.android.server.location.MockProvider in project android_frameworks_base by ParanoidAndroid.

the class LocationManagerService method setTestProviderLocation.

@Override
public void setTestProviderLocation(String provider, Location loc) {
    checkMockPermissionsSafe();
    synchronized (mLock) {
        MockProvider mockProvider = mMockProviders.get(provider);
        if (mockProvider == null) {
            throw new IllegalArgumentException("Provider \"" + provider + "\" unknown");
        }
        // clear calling identity so INSTALL_LOCATION_PROVIDER permission is not required
        long identity = Binder.clearCallingIdentity();
        mockProvider.setLocation(loc);
        Binder.restoreCallingIdentity(identity);
    }
}
Also used : MockProvider(com.android.server.location.MockProvider)

Example 33 with MockProvider

use of com.android.server.location.MockProvider in project android_frameworks_base by ParanoidAndroid.

the class LocationManagerService method clearTestProviderEnabled.

@Override
public void clearTestProviderEnabled(String provider) {
    checkMockPermissionsSafe();
    synchronized (mLock) {
        MockProvider mockProvider = mMockProviders.get(provider);
        if (mockProvider == null) {
            throw new IllegalArgumentException("Provider \"" + provider + "\" unknown");
        }
        long identity = Binder.clearCallingIdentity();
        mEnabledProviders.remove(provider);
        mDisabledProviders.remove(provider);
        updateProvidersLocked();
        Binder.restoreCallingIdentity(identity);
    }
}
Also used : MockProvider(com.android.server.location.MockProvider)

Example 34 with MockProvider

use of com.android.server.location.MockProvider in project android_frameworks_base by ParanoidAndroid.

the class LocationManagerService method removeTestProvider.

@Override
public void removeTestProvider(String provider) {
    checkMockPermissionsSafe();
    synchronized (mLock) {
        MockProvider mockProvider = mMockProviders.remove(provider);
        if (mockProvider == null) {
            throw new IllegalArgumentException("Provider \"" + provider + "\" unknown");
        }
        long identity = Binder.clearCallingIdentity();
        removeProviderLocked(mProvidersByName.get(provider));
        if (mGeoFencer != null) {
            mGeoFencerEnabled = true;
        }
        // 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 35 with MockProvider

use of com.android.server.location.MockProvider in project android_frameworks_base by DirtyUnicorns.

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)

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