1/*
2 * Copyright (C) 2007 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
17package com.android.internal.location;
18
19import android.location.ILocationManager;
20import android.location.LocationProvider;
21
22/**
23 * A stub implementation of LocationProvider used by LocationManager.
24 * A DummyLocationProvider may be queried to determine the properties
25 * of the provider whcih it shadows, but does not actually provide location
26 * data.
27 *
28 * {@hide}
29 */
30public class DummyLocationProvider extends LocationProvider {
31
32    private static final String TAG = "DummyLocationProvider";
33
34    String mName;
35    boolean mRequiresNetwork;
36    boolean mRequiresSatellite;
37    boolean mRequiresCell;
38    boolean mHasMonetaryCost;
39    boolean mSupportsAltitude;
40    boolean mSupportsSpeed;
41    boolean mSupportsBearing;
42    int mPowerRequirement;
43    int mAccuracy;
44
45    public DummyLocationProvider(String name, ILocationManager service) {
46        super(name, service);
47    }
48
49    public void setRequiresNetwork(boolean requiresNetwork) {
50        mRequiresNetwork = requiresNetwork;
51    }
52
53    public void setRequiresSatellite(boolean requiresSatellite) {
54        mRequiresSatellite = requiresSatellite;
55    }
56
57    public void setRequiresCell(boolean requiresCell) {
58        mRequiresCell = requiresCell;
59    }
60
61    public void setHasMonetaryCost(boolean hasMonetaryCost) {
62        mHasMonetaryCost = hasMonetaryCost;
63    }
64
65    public void setSupportsAltitude(boolean supportsAltitude) {
66        mSupportsAltitude = supportsAltitude;
67    }
68
69    public void setSupportsSpeed(boolean supportsSpeed) {
70        mSupportsSpeed = supportsSpeed;
71    }
72
73    public void setSupportsBearing(boolean supportsBearing) {
74        mSupportsBearing = supportsBearing;
75    }
76
77    public void setPowerRequirement(int powerRequirement) {
78        mPowerRequirement = powerRequirement;
79    }
80
81    public void setAccuracy(int accuracy) {
82        mAccuracy = accuracy;
83    }
84
85    /**
86     * Returns true if the provider requires access to a
87     * data network (e.g., the Internet), false otherwise.
88     */
89    public boolean requiresNetwork() {
90        return mRequiresNetwork;
91    }
92
93    /**
94     * Returns true if the provider requires access to a
95     * satellite-based positioning system (e.g., GPS), false
96     * otherwise.
97     */
98    public boolean requiresSatellite() {
99        return mRequiresSatellite;
100    }
101
102    /**
103     * Returns true if the provider requires access to an appropriate
104     * cellular network (e.g., to make use of cell tower IDs), false
105     * otherwise.
106     */
107    public boolean requiresCell() {
108        return mRequiresCell;
109    }
110
111    /**
112     * Returns true if the use of this provider may result in a
113     * monetary charge to the user, false if use is free.  It is up to
114     * each provider to give accurate information.
115     */
116    public boolean hasMonetaryCost() {
117        return mHasMonetaryCost;
118    }
119
120    /**
121     * Returns true if the provider is able to provide altitude
122     * information, false otherwise.  A provider that reports altitude
123     * under most circumstances but may occassionally not report it
124     * should return true.
125     */
126    public boolean supportsAltitude() {
127        return mSupportsAltitude;
128    }
129
130    /**
131     * Returns true if the provider is able to provide speed
132     * information, false otherwise.  A provider that reports speed
133     * under most circumstances but may occassionally not report it
134     * should return true.
135     */
136    public boolean supportsSpeed() {
137        return mSupportsSpeed;
138    }
139
140    /**
141     * Returns true if the provider is able to provide bearing
142     * information, false otherwise.  A provider that reports bearing
143     * under most circumstances but may occassionally not report it
144     * should return true.
145     */
146    public boolean supportsBearing() {
147        return mSupportsBearing;
148    }
149
150    /**
151     * Returns the power requirement for this provider.
152     *
153     * @return the power requirement for this provider, as one of the
154     * constants Criteria.POWER_REQUIREMENT_*.
155     */
156    public int getPowerRequirement() {
157        return mPowerRequirement;
158    }
159
160    /**
161     * Returns a constant describing the horizontal accuracy returned
162     * by this provider.
163     *
164     * @return the horizontal accuracy for this provider, as one of the
165     * constants Criteria.ACCURACY_*.
166     */
167    public int getAccuracy() {
168        return mAccuracy;
169    }
170}
171
172