/** Write information from a single location provider */ private void dumpProvider(String provider) { LocationProvider info = mgr.getProvider(provider); StringBuilder builder = new StringBuilder(); builder .append("LocationProvider:") .append(" name=") .append(info.getName()) .append("\nenabled=") .append(mgr.isProviderEnabled(provider)) .append("\ngetAccuracy=") .append(ACCURACY[info.getAccuracy() + 1]) .append("\ngetPowerRequirement=") .append(POWER[info.getPowerRequirement() + 1]) .append("\nhasMonetaryCost=") .append(info.hasMonetaryCost()) .append("\nrequiresCell=") .append(info.requiresCell()) .append("\nrequiresNetwork=") .append(info.requiresNetwork()) .append("\nrequiresSatellite=") .append(info.requiresSatellite()) .append("\nsupportsAltitude=") .append(info.supportsAltitude()) .append("\nsupportsBearing=") .append(info.supportsBearing()) .append("\nsupportsSpeed=") .append(info.supportsSpeed()) .append("\n\n\n"); log(builder.toString()); }
/** * The most recent measure of accuracy, in meters. If no value is available, 0 will be returned. */ @SimpleProperty(category = PropertyCategory.BEHAVIOR) public double Accuracy() { if (lastLocation != null && lastLocation.hasAccuracy()) { return lastLocation.getAccuracy(); } else if (locationProvider != null) { return locationProvider.getAccuracy(); } else { return UNKNOWN_VALUE; } }
public static String formatLocationProvider(Context context, LocationProvider provider) { String name = provider.getName(); int horizontalAccuracy = provider.getAccuracy(); int powerRequirements = provider.getPowerRequirement(); boolean hasMonetaryCost = provider.hasMonetaryCost(); boolean requiresCell = provider.requiresCell(); boolean requiresNetwork = provider.requiresNetwork(); boolean requiresSatellite = provider.requiresSatellite(); boolean supportsAltitude = provider.supportsAltitude(); boolean supportsBearing = provider.supportsBearing(); boolean supportsSpeed = provider.supportsSpeed(); String enabledMessage = "UNKNOWN"; if (context != null) { LocationManager lm = (LocationManager) context.getSystemService(context.LOCATION_SERVICE); enabledMessage = yOrN(lm.isProviderEnabled(name)); } String horizontaAccuracyDisplay = translateAccuracyFineCourse(horizontalAccuracy); // String powerRequirementsDisplay =translatePower(powerRequirements); String logMessage = String.format( name + " | " + " enabled: " + enabledMessage + " | horizontal accuracy: " + horizontaAccuracyDisplay + "| power: " + powerRequirements + " | cost: " + yOrN(hasMonetaryCost) + " | uses cell: " + yOrN(requiresCell) + " | uses network: " + yOrN(requiresNetwork) + " | uses satellite: " + yOrN(requiresSatellite) + " | " + "has altitude: " + yOrN(supportsAltitude) + " | has bearing: " + yOrN(supportsBearing)); return logMessage; }
/** * Adds new LocationTestProvider matching actual provider on device. * * @param currentProvider * @param providerType */ private void addTestProvider(LocationProvider currentProvider, String providerType) { LocationManager locationManager = (LocationManager) RobotiumInstrumentationBackend.solo .getCurrentActivity() .getSystemService(Context.LOCATION_SERVICE); locationManager.addTestProvider( providerType, currentProvider.requiresNetwork(), currentProvider.requiresSatellite(), currentProvider.requiresCell(), currentProvider.hasMonetaryCost(), currentProvider.supportsAltitude(), currentProvider.supportsSpeed(), currentProvider.supportsBearing(), currentProvider.getPowerRequirement(), currentProvider.getAccuracy()); }