Search in sources :

Example 21 with PackageProviderKey

use of com.android.server.location.LocationRequestStatistics.PackageProviderKey in project android_frameworks_base by ResurrectionRemix.

the class LocationRequestStatisticsTest method testSinglePackage.

/**
     * Tests that adding a single package works correctly.
     */
public void testSinglePackage() {
    mStatistics.startRequesting(PACKAGE1, PROVIDER1, INTERVAL1);
    assertEquals(1, mStatistics.statistics.size());
    PackageProviderKey key = mStatistics.statistics.keySet().iterator().next();
    assertEquals(PACKAGE1, key.packageName);
    assertEquals(PROVIDER1, key.providerName);
    PackageStatistics stats = mStatistics.statistics.values().iterator().next();
    verifyStatisticsTimes(stats);
    assertEquals(INTERVAL1, stats.getFastestIntervalMs());
    assertEquals(INTERVAL1, stats.getSlowestIntervalMs());
    assertTrue(stats.isActive());
}
Also used : PackageStatistics(com.android.server.location.LocationRequestStatistics.PackageStatistics) PackageProviderKey(com.android.server.location.LocationRequestStatistics.PackageProviderKey)

Example 22 with PackageProviderKey

use of com.android.server.location.LocationRequestStatistics.PackageProviderKey in project android_frameworks_base by ResurrectionRemix.

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

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

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 24 with PackageProviderKey

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

the class LocationRequestStatisticsTest method testMultiplePackages.

/**
     * Tests that adding multiple packages works correctly.
     */
public void testMultiplePackages() {
    mStatistics.startRequesting(PACKAGE1, PROVIDER1, INTERVAL1);
    mStatistics.startRequesting(PACKAGE1, PROVIDER2, INTERVAL1);
    mStatistics.startRequesting(PACKAGE1, PROVIDER2, INTERVAL2);
    mStatistics.startRequesting(PACKAGE2, PROVIDER1, INTERVAL1);
    assertEquals(3, mStatistics.statistics.size());
    PackageProviderKey key1 = new PackageProviderKey(PACKAGE1, PROVIDER1);
    PackageStatistics stats1 = mStatistics.statistics.get(key1);
    verifyStatisticsTimes(stats1);
    assertEquals(INTERVAL1, stats1.getSlowestIntervalMs());
    assertEquals(INTERVAL1, stats1.getFastestIntervalMs());
    assertTrue(stats1.isActive());
    PackageProviderKey key2 = new PackageProviderKey(PACKAGE1, PROVIDER2);
    PackageStatistics stats2 = mStatistics.statistics.get(key2);
    verifyStatisticsTimes(stats2);
    assertEquals(INTERVAL2, stats2.getSlowestIntervalMs());
    assertEquals(INTERVAL1, stats2.getFastestIntervalMs());
    assertTrue(stats2.isActive());
    PackageProviderKey key3 = new PackageProviderKey(PACKAGE2, PROVIDER1);
    PackageStatistics stats3 = mStatistics.statistics.get(key3);
    verifyStatisticsTimes(stats3);
    assertEquals(INTERVAL1, stats3.getSlowestIntervalMs());
    assertEquals(INTERVAL1, stats3.getFastestIntervalMs());
    assertTrue(stats3.isActive());
    mStatistics.stopRequesting(PACKAGE1, PROVIDER1);
    assertFalse(stats1.isActive());
    assertTrue(stats2.isActive());
    assertTrue(stats3.isActive());
    mStatistics.stopRequesting(PACKAGE1, PROVIDER2);
    assertFalse(stats1.isActive());
    assertTrue(stats2.isActive());
    assertTrue(stats3.isActive());
    mStatistics.stopRequesting(PACKAGE1, PROVIDER2);
    assertFalse(stats2.isActive());
    mStatistics.stopRequesting(PACKAGE2, PROVIDER1);
    assertFalse(stats1.isActive());
    assertFalse(stats2.isActive());
    assertFalse(stats3.isActive());
}
Also used : PackageStatistics(com.android.server.location.LocationRequestStatistics.PackageStatistics) PackageProviderKey(com.android.server.location.LocationRequestStatistics.PackageProviderKey)

Example 25 with PackageProviderKey

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

the class LocationRequestStatisticsTest method testSinglePackage.

/**
     * Tests that adding a single package works correctly.
     */
public void testSinglePackage() {
    mStatistics.startRequesting(PACKAGE1, PROVIDER1, INTERVAL1);
    assertEquals(1, mStatistics.statistics.size());
    PackageProviderKey key = mStatistics.statistics.keySet().iterator().next();
    assertEquals(PACKAGE1, key.packageName);
    assertEquals(PROVIDER1, key.providerName);
    PackageStatistics stats = mStatistics.statistics.values().iterator().next();
    verifyStatisticsTimes(stats);
    assertEquals(INTERVAL1, stats.getFastestIntervalMs());
    assertEquals(INTERVAL1, stats.getSlowestIntervalMs());
    assertTrue(stats.isActive());
}
Also used : PackageStatistics(com.android.server.location.LocationRequestStatistics.PackageStatistics) PackageProviderKey(com.android.server.location.LocationRequestStatistics.PackageProviderKey)

Aggregations

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