Home | History | Annotate | Download | only in provider
      1 /*
      2  * Copyright (C) 2012 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.location.provider;
     18 
     19 import android.location.LocationRequest;
     20 
     21 /**
     22  * This class is an interface to LocationRequests for unbundled applications.
     23  *
     24  * <p>IMPORTANT: This class is effectively a public API for unbundled
     25  * applications, and must remain API stable. See README.txt in the root
     26  * of this package for more information.
     27  */
     28 public final class LocationRequestUnbundled {
     29     /**
     30      * Returned by {@link #getQuality} when requesting the most accurate locations available.
     31      *
     32      * <p>This may be up to 1 meter accuracy, although this is implementation dependent.
     33      */
     34     public static final int ACCURACY_FINE = LocationRequest.ACCURACY_FINE;
     35 
     36     /**
     37      * Returned by {@link #getQuality} when requesting "block" level accuracy.
     38      *
     39      * <p>Block level accuracy is considered to be about 100 meter accuracy,
     40      * although this is implementation dependent. Using a coarse accuracy
     41      * such as this often consumes less power.
     42      */
     43     public static final int ACCURACY_BLOCK = LocationRequest.ACCURACY_BLOCK;
     44 
     45     /**
     46      * Returned by {@link #getQuality} when requesting "city" level accuracy.
     47      *
     48      * <p>City level accuracy is considered to be about 10km accuracy,
     49      * although this is implementation dependent. Using a coarse accuracy
     50      * such as this often consumes less power.
     51      */
     52     public static final int ACCURACY_CITY = LocationRequest.ACCURACY_CITY;
     53 
     54     /**
     55      * Returned by {@link #getQuality} when requiring no direct power impact (passive locations).
     56      *
     57      * <p>This location request will not trigger any active location requests,
     58      * but will receive locations triggered by other applications. Your application
     59      * will not receive any direct power blame for location work.
     60      */
     61     public static final int POWER_NONE = LocationRequest.POWER_NONE;
     62 
     63     /**
     64      * Returned by {@link #getQuality} when requesting low power impact.
     65      *
     66      * <p>This location request will avoid high power location work where
     67      * possible.
     68      */
     69     public static final int POWER_LOW = LocationRequest.POWER_LOW;
     70 
     71     /**
     72      * Returned by {@link #getQuality} when allowing high power consumption for location.
     73      *
     74      * <p>This location request will allow high power location work.
     75      */
     76     public static final int POWER_HIGH = LocationRequest.POWER_HIGH;
     77 
     78     private final LocationRequest delegate;
     79 
     80     LocationRequestUnbundled(LocationRequest delegate) {
     81         this.delegate = delegate;
     82     }
     83 
     84     /**
     85      * Get the desired interval of this request, in milliseconds.
     86      *
     87      * @return desired interval in milliseconds, inexact
     88      */
     89     public long getInterval() {
     90         return delegate.getInterval();
     91     }
     92 
     93     /**
     94      * Get the fastest interval of this request, in milliseconds.
     95      *
     96      * <p>The system will never provide location updates faster
     97      * than the minimum of {@link #getFastestInterval} and
     98      * {@link #getInterval}.
     99      *
    100      * @return fastest interval in milliseconds, exact
    101      */
    102     public long getFastestInterval() {
    103         return delegate.getFastestInterval();
    104     }
    105 
    106     /**
    107      * Get the quality of the request.
    108      *
    109      * @return an accuracy or power constant
    110      */
    111     public int getQuality() {
    112         return delegate.getQuality();
    113     }
    114 
    115     /**
    116      * Get the minimum distance between location updates, in meters.
    117      *
    118      * @return minimum distance between location updates in meters
    119      */
    120     public float getSmallestDisplacement() {
    121         return delegate.getSmallestDisplacement();
    122     }
    123 
    124     @Override
    125     public String toString() {
    126       return delegate.toString();
    127     }
    128 }
    129