17ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu/* 27ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * Copyright (C) 2012 The Android Open Source Project 37ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * 47ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * Licensed under the Apache License, Version 2.0 (the "License"); 57ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * you may not use this file except in compliance with the License. 67ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * You may obtain a copy of the License at 77ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * 87ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * http://www.apache.org/licenses/LICENSE-2.0 97ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * 107ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * Unless required by applicable law or agreed to in writing, software 117ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * distributed under the License is distributed on an "AS IS" BASIS, 127ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 137ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * See the License for the specific language governing permissions and 147ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * limitations under the License. 157ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu */ 167ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu 177ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tupackage com.android.location.provider; 187ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu 197ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tuimport android.location.LocationRequest; 207ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu 217ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu/** 227ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * This class is an interface to LocationRequests for unbundled applications. 237ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * 247ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * <p>IMPORTANT: This class is effectively a public API for unbundled 257ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * applications, and must remain API stable. See README.txt in the root 267ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * of this package for more information. 277ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu */ 287ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tupublic final class LocationRequestUnbundled { 297ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu /** 307ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * Returned by {@link #getQuality} when requesting the most accurate locations available. 317ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * 327ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * <p>This may be up to 1 meter accuracy, although this is implementation dependent. 337ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu */ 347ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu public static final int ACCURACY_FINE = LocationRequest.ACCURACY_FINE; 357ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu 367ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu /** 377ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * Returned by {@link #getQuality} when requesting "block" level accuracy. 387ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * 397ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * <p>Block level accuracy is considered to be about 100 meter accuracy, 407ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * although this is implementation dependent. Using a coarse accuracy 417ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * such as this often consumes less power. 427ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu */ 437ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu public static final int ACCURACY_BLOCK = LocationRequest.ACCURACY_BLOCK; 447ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu 457ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu /** 467ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * Returned by {@link #getQuality} when requesting "city" level accuracy. 477ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * 487ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * <p>City level accuracy is considered to be about 10km accuracy, 497ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * although this is implementation dependent. Using a coarse accuracy 507ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * such as this often consumes less power. 517ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu */ 527ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu public static final int ACCURACY_CITY = LocationRequest.ACCURACY_CITY; 537ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu 547ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu /** 557ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * Returned by {@link #getQuality} when requiring no direct power impact (passive locations). 567ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * 577ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * <p>This location request will not trigger any active location requests, 587ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * but will receive locations triggered by other applications. Your application 597ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * will not receive any direct power blame for location work. 607ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu */ 617ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu public static final int POWER_NONE = LocationRequest.POWER_NONE; 627ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu 637ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu /** 647ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * Returned by {@link #getQuality} when requesting low power impact. 657ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * 667ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * <p>This location request will avoid high power location work where 677ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * possible. 687ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu */ 697ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu public static final int POWER_LOW = LocationRequest.POWER_LOW; 707ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu 717ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu /** 727ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * Returned by {@link #getQuality} when allowing high power consumption for location. 737ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * 747ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * <p>This location request will allow high power location work. 757ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu */ 767ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu public static final int POWER_HIGH = LocationRequest.POWER_HIGH; 777ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu 787ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu private final LocationRequest delegate; 797ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu 807ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu LocationRequestUnbundled(LocationRequest delegate) { 817ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu this.delegate = delegate; 827ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu } 837ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu 847ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu /** 857ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * Get the desired interval of this request, in milliseconds. 867ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * 877ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * @return desired interval in milliseconds, inexact 887ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu */ 897ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu public long getInterval() { 907ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu return delegate.getInterval(); 917ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu } 927ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu 937ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu /** 947ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * Get the fastest interval of this request, in milliseconds. 957ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * 967ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * <p>The system will never provide location updates faster 977ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * than the minimum of {@link #getFastestInterval} and 987ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * {@link #getInterval}. 997ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * 1007ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * @return fastest interval in milliseconds, exact 1017ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu */ 1027ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu public long getFastestInterval() { 1037ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu return delegate.getFastestInterval(); 1047ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu } 1057ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu 1067ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu /** 1077ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * Get the quality of the request. 1087ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * 1097ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * @return an accuracy or power constant 1107ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu */ 1117ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu public int getQuality() { 1127ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu return delegate.getQuality(); 1137ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu } 1147ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu 1157ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu /** 1167ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * Get the minimum distance between location updates, in meters. 1177ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * 1187ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu * @return minimum distance between location updates in meters 1197ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu */ 1207ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu public float getSmallestDisplacement() { 1217ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu return delegate.getSmallestDisplacement(); 1227ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu } 1237ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu 1247ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu @Override 1257ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu public String toString() { 1267ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu return delegate.toString(); 1277ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu } 1287ab7f538924371a9dd4be7a27a6ae3b4c04b301cLaurent Tu} 129