Search in sources :

Example 6 with MockProvider

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

the class LocationManagerService method setTestProviderStatus.

@Override
public void setTestProviderStatus(String provider, int status, Bundle extras, long updateTime, String opPackageName) {
    if (!canCallerAccessMockLocation(opPackageName)) {
        return;
    }
    synchronized (mLock) {
        MockProvider mockProvider = mMockProviders.get(provider);
        if (mockProvider == null) {
            throw new IllegalArgumentException("Provider \"" + provider + "\" unknown");
        }
        mockProvider.setStatus(status, extras, updateTime);
    }
}
Also used : MockProvider(com.android.server.location.MockProvider)

Example 7 with MockProvider

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

the class LocationManagerService method setTestProviderEnabled.

@Override
public void setTestProviderEnabled(String provider, boolean enabled, 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();
        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)

Example 8 with MockProvider

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

the class LocationManagerService method setTestProviderStatus.

@Override
public void setTestProviderStatus(String provider, int status, Bundle extras, long updateTime, String opPackageName) {
    if (!canCallerAccessMockLocation(opPackageName)) {
        return;
    }
    synchronized (mLock) {
        MockProvider mockProvider = mMockProviders.get(provider);
        if (mockProvider == null) {
            throw new IllegalArgumentException("Provider \"" + provider + "\" unknown");
        }
        mockProvider.setStatus(status, extras, updateTime);
    }
}
Also used : MockProvider(com.android.server.location.MockProvider)

Example 9 with MockProvider

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

the class LocationManagerService method dump.

@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
        pw.println("Permission Denial: can't dump LocationManagerService from from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
        return;
    }
    synchronized (mLock) {
        pw.println("Current Location Manager state:");
        pw.println("  Location Listeners:");
        for (Receiver receiver : mReceivers.values()) {
            pw.println("    " + receiver);
        }
        pw.println("  Active Records by Provider:");
        for (Map.Entry<String, ArrayList<UpdateRecord>> entry : mRecordsByProvider.entrySet()) {
            pw.println("    " + entry.getKey() + ":");
            for (UpdateRecord record : entry.getValue()) {
                pw.println("      " + record);
            }
        }
        pw.println("  Historical Records by Provider:");
        for (Map.Entry<PackageProviderKey, PackageStatistics> entry : mRequestStatistics.statistics.entrySet()) {
            PackageProviderKey key = entry.getKey();
            PackageStatistics stats = entry.getValue();
            pw.println("    " + key.packageName + ": " + key.providerName + ": " + stats);
        }
        pw.println("  Last Known Locations:");
        for (Map.Entry<String, Location> entry : mLastLocation.entrySet()) {
            String provider = entry.getKey();
            Location location = entry.getValue();
            pw.println("    " + provider + ": " + location);
        }
        pw.println("  Last Known Locations Coarse Intervals:");
        for (Map.Entry<String, Location> entry : mLastLocationCoarseInterval.entrySet()) {
            String provider = entry.getKey();
            Location location = entry.getValue();
            pw.println("    " + provider + ": " + location);
        }
        mGeofenceManager.dump(pw);
        if (mEnabledProviders.size() > 0) {
            pw.println("  Enabled Providers:");
            for (String i : mEnabledProviders) {
                pw.println("    " + i);
            }
        }
        if (mDisabledProviders.size() > 0) {
            pw.println("  Disabled Providers:");
            for (String i : mDisabledProviders) {
                pw.println("    " + i);
            }
        }
        pw.append("  ");
        mBlacklist.dump(pw);
        if (mMockProviders.size() > 0) {
            pw.println("  Mock Providers:");
            for (Map.Entry<String, MockProvider> i : mMockProviders.entrySet()) {
                i.getValue().dump(pw, "      ");
            }
        }
        pw.append("  fudger: ");
        mLocationFudger.dump(fd, pw, args);
        if (args.length > 0 && "short".equals(args[0])) {
            return;
        }
        for (LocationProviderInterface provider : mProviders) {
            pw.print(provider.getName() + " Internal State");
            if (provider instanceof LocationProviderProxy) {
                LocationProviderProxy proxy = (LocationProviderProxy) provider;
                pw.print(" (" + proxy.getConnectedPackageName() + ")");
            }
            pw.println(":");
            provider.dump(fd, pw, args);
        }
    }
}
Also used : PackageStatistics(com.android.server.location.LocationRequestStatistics.PackageStatistics) LocationProviderProxy(com.android.server.location.LocationProviderProxy) ArrayList(java.util.ArrayList) BroadcastReceiver(android.content.BroadcastReceiver) PackageProviderKey(com.android.server.location.LocationRequestStatistics.PackageProviderKey) MockProvider(com.android.server.location.MockProvider) LocationProviderInterface(com.android.server.location.LocationProviderInterface) Map(java.util.Map) HashMap(java.util.HashMap) Location(android.location.Location)

Example 10 with MockProvider

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

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)

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