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