Search in sources :

Example 21 with MockProvider

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

the class LocationManagerService method clearTestProviderLocation.

@Override
public void clearTestProviderLocation(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.clearLocation();
    }
}
Also used : MockProvider(com.android.server.location.MockProvider)

Example 22 with MockProvider

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

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 23 with MockProvider

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

the class LocationManagerService method setTestProviderLocation.

@Override
public void setTestProviderLocation(String provider, Location loc, String opPackageName) {
    if (!canCallerAccessMockLocation(opPackageName)) {
        return;
    }
    synchronized (mLock) {
        MockProvider mockProvider = mMockProviders.get(provider);
        if (mockProvider == null) {
            throw new IllegalArgumentException("Provider \"" + provider + "\" unknown");
        }
        // Ensure that the location is marked as being mock. There's some logic to do this in
        // handleLocationChanged(), but it fails if loc has the wrong provider (bug 33091107).
        Location mock = new Location(loc);
        mock.setIsFromMockProvider(true);
        if (!TextUtils.isEmpty(loc.getProvider()) && !provider.equals(loc.getProvider())) {
            // The location has an explicit provider that is different from the mock provider
            // name. The caller may be trying to fool us via bug 33091107.
            EventLog.writeEvent(0x534e4554, "33091107", Binder.getCallingUid(), provider + "!=" + loc.getProvider());
        }
        // clear calling identity so INSTALL_LOCATION_PROVIDER permission is not required
        long identity = Binder.clearCallingIdentity();
        mockProvider.setLocation(mock);
        Binder.restoreCallingIdentity(identity);
    }
}
Also used : MockProvider(com.android.server.location.MockProvider) Location(android.location.Location)

Example 24 with MockProvider

use of com.android.server.location.MockProvider in project platform_frameworks_base by android.

the class LocationManagerService method clearTestProviderEnabled.

@Override
public void clearTestProviderEnabled(String provider, String opPackageName) {
    if (!canCallerAccessMockLocation(opPackageName)) {
        return;
    }
    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 25 with MockProvider

use of com.android.server.location.MockProvider in project platform_frameworks_base by android.

the class LocationManagerService method clearTestProviderLocation.

@Override
public void clearTestProviderLocation(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.clearLocation();
    }
}
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