use of com.android.server.location.LocationRequestStatistics.PackageProviderKey in project android_frameworks_base by crdroidandroid.
the class LocationRequestStatisticsTest method testSinglePackage_multipleProviders.
/**
* Tests that adding a single package works correctly when multiple providers are used.
*/
public void testSinglePackage_multipleProviders() {
mStatistics.startRequesting(PACKAGE1, PROVIDER1, INTERVAL1);
mStatistics.startRequesting(PACKAGE1, PROVIDER2, INTERVAL2);
assertEquals(2, 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(INTERVAL2, stats2.getFastestIntervalMs());
assertTrue(stats2.isActive());
mStatistics.stopRequesting(PACKAGE1, PROVIDER1);
assertFalse(stats1.isActive());
assertTrue(stats2.isActive());
mStatistics.stopRequesting(PACKAGE1, PROVIDER2);
assertFalse(stats1.isActive());
assertFalse(stats2.isActive());
}
use of com.android.server.location.LocationRequestStatistics.PackageProviderKey in project platform_frameworks_base by android.
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());
}
use of com.android.server.location.LocationRequestStatistics.PackageProviderKey in project platform_frameworks_base by android.
the class LocationRequestStatisticsTest method testSinglePackage_multipleProviders.
/**
* Tests that adding a single package works correctly when multiple providers are used.
*/
public void testSinglePackage_multipleProviders() {
mStatistics.startRequesting(PACKAGE1, PROVIDER1, INTERVAL1);
mStatistics.startRequesting(PACKAGE1, PROVIDER2, INTERVAL2);
assertEquals(2, 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(INTERVAL2, stats2.getFastestIntervalMs());
assertTrue(stats2.isActive());
mStatistics.stopRequesting(PACKAGE1, PROVIDER1);
assertFalse(stats1.isActive());
assertTrue(stats2.isActive());
mStatistics.stopRequesting(PACKAGE1, PROVIDER2);
assertFalse(stats1.isActive());
assertFalse(stats2.isActive());
}
use of com.android.server.location.LocationRequestStatistics.PackageProviderKey in project android_frameworks_base by AOSPA.
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);
}
}
}
use of com.android.server.location.LocationRequestStatistics.PackageProviderKey in project android_frameworks_base by ResurrectionRemix.
the class LocationRequestStatisticsTest method testSinglePackage_multipleIntervals.
/**
* Tests that adding a single package works correctly when multiple intervals are used.
*/
public void testSinglePackage_multipleIntervals() {
mStatistics.startRequesting(PACKAGE1, PROVIDER1, INTERVAL1);
mStatistics.startRequesting(PACKAGE1, PROVIDER1, INTERVAL2);
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());
assertTrue(stats.isActive());
mStatistics.stopRequesting(PACKAGE1, PROVIDER1);
assertTrue(stats.isActive());
mStatistics.stopRequesting(PACKAGE1, PROVIDER1);
assertFalse(stats.isActive());
}
Aggregations