Merge "andriod.location.Criteria: Simplify new location criteria APIs a bit." into gingerbread

This commit is contained in:
Mike Lockwood
2010-06-23 13:14:47 -07:00
committed by Android (Google) Code Review
2 changed files with 26 additions and 187 deletions

View File

@@ -81821,17 +81821,6 @@
visibility="public" visibility="public"
> >
</method> </method>
<method name="getPriority"
return="int"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
</method>
<method name="getSpeedAccuracy" <method name="getSpeedAccuracy"
return="int" return="int"
abstract="false" abstract="false"
@@ -81989,19 +81978,6 @@
<parameter name="level" type="int"> <parameter name="level" type="int">
</parameter> </parameter>
</method> </method>
<method name="setPreferredPriority"
return="void"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="priority" type="int">
</parameter>
</method>
<method name="setSpeedAccuracy" <method name="setSpeedAccuracy"
return="void" return="void"
abstract="false" abstract="false"
@@ -82056,17 +82032,6 @@
<parameter name="flags" type="int"> <parameter name="flags" type="int">
</parameter> </parameter>
</method> </method>
<field name="ACCURACY_BEST"
type="int"
transient="false"
volatile="false"
value="4"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="ACCURACY_COARSE" <field name="ACCURACY_COARSE"
type="int" type="int"
transient="false" transient="false"
@@ -82122,17 +82087,6 @@
visibility="public" visibility="public"
> >
</field> </field>
<field name="BEARING_ACCURACY_PRIORITY"
type="int"
transient="false"
volatile="false"
value="4"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="CREATOR" <field name="CREATOR"
type="android.os.Parcelable.Creator" type="android.os.Parcelable.Creator"
transient="false" transient="false"
@@ -82143,17 +82097,6 @@
visibility="public" visibility="public"
> >
</field> </field>
<field name="HORIZONTAL_ACCURACY_PRIORITY"
type="int"
transient="false"
volatile="false"
value="1"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="NO_REQUIREMENT" <field name="NO_REQUIREMENT"
type="int" type="int"
transient="false" transient="false"
@@ -82198,39 +82141,6 @@
visibility="public" visibility="public"
> >
</field> </field>
<field name="POWER_REQUIREMENT_PRIORITY"
type="int"
transient="false"
volatile="false"
value="5"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="SPEED_ACCURACY_PRIORITY"
type="int"
transient="false"
volatile="false"
value="3"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="VERTICAL_ACCURACY_PRIORITY"
type="int"
transient="false"
volatile="false"
value="2"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
</class> </class>
<class name="Geocoder" <class name="Geocoder"
extends="java.lang.Object" extends="java.lang.Object"
@@ -219137,7 +219047,7 @@
deprecated="not deprecated" deprecated="not deprecated"
visibility="public" visibility="public"
> >
<parameter name="arg0" type="T"> <parameter name="t" type="T">
</parameter> </parameter>
</method> </method>
</interface> </interface>

View File

@@ -60,68 +60,31 @@ public class Criteria implements Parcelable {
/** /**
* A constant indicating a low location accuracy requirement * A constant indicating a low location accuracy requirement
* - may be used for horizontal, altitude, speed or bearing accuracy. * - may be used for horizontal, altitude, speed or bearing accuracy.
* For horizontal and vertical position this corresponds to an accuracy * For horizontal and vertical position this corresponds roughly to
* greater than 500 meters. For speed and bearing, this corresponds * an accuracy of greater than 500 meters.
* to greater than 5 meters/second velocity and 10 degrees for bearing.
*/ */
public static final int ACCURACY_LOW = 1; public static final int ACCURACY_LOW = 1;
/** /**
* A constant indicating a medium accuracy requirement * A constant indicating a medium accuracy requirement
* - may be used for horizontal, altitude, speed or bearing accuracy. * - currently used only for horizontal accuracy.
* For horizontal position this corresponds to an accuracy of between * For horizontal position this corresponds roughly to to an accuracy
* 100 and 500 meters, and between 200 and 500 meters for vertical accuracy. * of between 100 and 500 meters.
* For speed and bearing, this corresponds to 1 meter/second to 5 meters/second
* velocity and and between 5 and 10 degrees for bearing.
*/ */
public static final int ACCURACY_MEDIUM = 2; public static final int ACCURACY_MEDIUM = 2;
/** /**
* a constant indicating a high accuracy requirement * a constant indicating a high accuracy requirement
* - may be used for horizontal, altitude, speed or bearing accuracy. * - may be used for horizontal, altitude, speed or bearing accuracy.
* For horizontal and vertical position this corresponds to an accuracy * For horizontal and vertical position this corresponds roughly to
* less than 100 meters. For speed and bearing, this corresponds * an accuracy of less than 100 meters.
* to less 1 meter/second velocity less than 5 degrees for bearing.
*/ */
public static final int ACCURACY_HIGH = 3; public static final int ACCURACY_HIGH = 3;
/**
* a constant indicating the best accuracy that is available for any
* location provider available
* - may be used for horizontal, altitude, speed or bearing accuracy.
*/
public static final int ACCURACY_BEST = 4;
/**
* A constant indicating horizontal accuracy has the top priority
*/
public static final int HORIZONTAL_ACCURACY_PRIORITY = 1;
/**
* A constant indicating altitude accuracy has the top priority
*/
public static final int VERTICAL_ACCURACY_PRIORITY = 2;
/**
* A constant indicating speed accuracy has the top priority
*/
public static final int SPEED_ACCURACY_PRIORITY = 3;
/**
* A constant indicating bearing accuracy has the top priority
*/
public static final int BEARING_ACCURACY_PRIORITY = 4;
/**
* A constant indicating power requirement has the top priority
*/
public static final int POWER_REQUIREMENT_PRIORITY = 5;
private int mHorizontalAccuracy = NO_REQUIREMENT; private int mHorizontalAccuracy = NO_REQUIREMENT;
private int mVerticalAccuracy = NO_REQUIREMENT; private int mVerticalAccuracy = NO_REQUIREMENT;
private int mSpeedAccuracy = NO_REQUIREMENT; private int mSpeedAccuracy = NO_REQUIREMENT;
private int mBearingAccuracy = NO_REQUIREMENT; private int mBearingAccuracy = NO_REQUIREMENT;
private int mPriority = HORIZONTAL_ACCURACY_PRIORITY;
private int mPowerRequirement = NO_REQUIREMENT; private int mPowerRequirement = NO_REQUIREMENT;
private boolean mAltitudeRequired = false; private boolean mAltitudeRequired = false;
private boolean mBearingRequired = false; private boolean mBearingRequired = false;
@@ -144,7 +107,6 @@ public class Criteria implements Parcelable {
mVerticalAccuracy = criteria.mVerticalAccuracy; mVerticalAccuracy = criteria.mVerticalAccuracy;
mSpeedAccuracy = criteria.mSpeedAccuracy; mSpeedAccuracy = criteria.mSpeedAccuracy;
mBearingAccuracy = criteria.mBearingAccuracy; mBearingAccuracy = criteria.mBearingAccuracy;
mPriority = criteria.mPriority;
mPowerRequirement = criteria.mPowerRequirement; mPowerRequirement = criteria.mPowerRequirement;
mAltitudeRequired = criteria.mAltitudeRequired; mAltitudeRequired = criteria.mAltitudeRequired;
mBearingRequired = criteria.mBearingRequired; mBearingRequired = criteria.mBearingRequired;
@@ -155,13 +117,13 @@ public class Criteria implements Parcelable {
/** /**
* Indicates the desired horizontal accuracy (latitude and longitude). * Indicates the desired horizontal accuracy (latitude and longitude).
* Accuracy may be {@link #ACCURACY_LOW}, {@link #ACCURACY_MEDIUM}, * Accuracy may be {@link #ACCURACY_LOW}, {@link #ACCURACY_MEDIUM},
* {@link #ACCURACY_HIGH}, {@link #ACCURACY_BEST}, * {@link #ACCURACY_HIGH} or {@link #NO_REQUIREMENT}.
* More accurate location may consume more power and may take longer. * More accurate location may consume more power and may take longer.
* *
* @throws IllegalArgumentException if accuracy is not one of the supported constants * @throws IllegalArgumentException if accuracy is not one of the supported constants
*/ */
public void setHorizontalAccuracy(int accuracy) { public void setHorizontalAccuracy(int accuracy) {
if (accuracy < NO_REQUIREMENT || accuracy > ACCURACY_BEST) { if (accuracy < NO_REQUIREMENT || accuracy > ACCURACY_HIGH) {
throw new IllegalArgumentException("accuracy=" + accuracy); throw new IllegalArgumentException("accuracy=" + accuracy);
} }
mHorizontalAccuracy = accuracy; mHorizontalAccuracy = accuracy;
@@ -170,7 +132,7 @@ public class Criteria implements Parcelable {
/** /**
* Returns a constant indicating the desired horizontal accuracy (latitude and longitude). * Returns a constant indicating the desired horizontal accuracy (latitude and longitude).
* Accuracy may be {@link #ACCURACY_LOW}, {@link #ACCURACY_MEDIUM}, * Accuracy may be {@link #ACCURACY_LOW}, {@link #ACCURACY_MEDIUM},
* {@link #ACCURACY_HIGH}, {@link #ACCURACY_BEST}, * {@link #ACCURACY_HIGH} or {@link #NO_REQUIREMENT}.
*/ */
public int getHorizontalAccuracy() { public int getHorizontalAccuracy() {
return mHorizontalAccuracy; return mHorizontalAccuracy;
@@ -179,13 +141,13 @@ public class Criteria implements Parcelable {
/** /**
* Indicates the desired vertical accuracy (altitude). * Indicates the desired vertical accuracy (altitude).
* Accuracy may be {@link #ACCURACY_LOW}, {@link #ACCURACY_MEDIUM}, * Accuracy may be {@link #ACCURACY_LOW}, {@link #ACCURACY_MEDIUM},
* {@link #ACCURACY_HIGH}, {@link #ACCURACY_BEST}, * {@link #ACCURACY_HIGH} or {@link #NO_REQUIREMENT}.
* More accurate location may consume more power and may take longer. * More accurate location may consume more power and may take longer.
* *
* @throws IllegalArgumentException if accuracy is not one of the supported constants * @throws IllegalArgumentException if accuracy is not one of the supported constants
*/ */
public void setVerticalAccuracy(int accuracy) { public void setVerticalAccuracy(int accuracy) {
if (accuracy < NO_REQUIREMENT || accuracy > ACCURACY_BEST) { if (accuracy < NO_REQUIREMENT || accuracy > ACCURACY_HIGH) {
throw new IllegalArgumentException("accuracy=" + accuracy); throw new IllegalArgumentException("accuracy=" + accuracy);
} }
mVerticalAccuracy = accuracy; mVerticalAccuracy = accuracy;
@@ -193,8 +155,8 @@ public class Criteria implements Parcelable {
/** /**
* Returns a constant indicating the desired vertical accuracy (altitude). * Returns a constant indicating the desired vertical accuracy (altitude).
* Accuracy may be {@link #ACCURACY_LOW}, {@link #ACCURACY_MEDIUM}, * Accuracy may be {@link #ACCURACY_LOW}, {@link #ACCURACY_HIGH},
* {@link #ACCURACY_HIGH}, {@link #ACCURACY_BEST}, * or {@link #NO_REQUIREMENT}.
*/ */
public int getVerticalAccuracy() { public int getVerticalAccuracy() {
return mVerticalAccuracy; return mVerticalAccuracy;
@@ -202,14 +164,14 @@ public class Criteria implements Parcelable {
/** /**
* Indicates the desired speed accuracy. * Indicates the desired speed accuracy.
* Accuracy may be {@link #ACCURACY_LOW}, {@link #ACCURACY_MEDIUM}, * Accuracy may be {@link #ACCURACY_LOW}, {@link #ACCURACY_HIGH},
* {@link #ACCURACY_HIGH}, {@link #ACCURACY_BEST}, * or {@link #NO_REQUIREMENT}.
* More accurate location may consume more power and may take longer. * More accurate location may consume more power and may take longer.
* *
* @throws IllegalArgumentException if accuracy is not one of the supported constants * @throws IllegalArgumentException if accuracy is not one of the supported constants
*/ */
public void setSpeedAccuracy(int accuracy) { public void setSpeedAccuracy(int accuracy) {
if (accuracy < NO_REQUIREMENT || accuracy > ACCURACY_BEST) { if (accuracy < NO_REQUIREMENT || accuracy > ACCURACY_HIGH) {
throw new IllegalArgumentException("accuracy=" + accuracy); throw new IllegalArgumentException("accuracy=" + accuracy);
} }
mSpeedAccuracy = accuracy; mSpeedAccuracy = accuracy;
@@ -217,8 +179,8 @@ public class Criteria implements Parcelable {
/** /**
* Returns a constant indicating the desired speed accuracy * Returns a constant indicating the desired speed accuracy
* Accuracy may be {@link #ACCURACY_LOW}, {@link #ACCURACY_MEDIUM}, * Accuracy may be {@link #ACCURACY_LOW}, {@link #ACCURACY_HIGH},
* {@link #ACCURACY_HIGH}, {@link #ACCURACY_BEST}, * or {@link #NO_REQUIREMENT}.
*/ */
public int getSpeedAccuracy() { public int getSpeedAccuracy() {
return mSpeedAccuracy; return mSpeedAccuracy;
@@ -226,14 +188,14 @@ public class Criteria implements Parcelable {
/** /**
* Indicates the desired bearing accuracy. * Indicates the desired bearing accuracy.
* Accuracy may be {@link #ACCURACY_LOW}, {@link #ACCURACY_MEDIUM}, * Accuracy may be {@link #ACCURACY_LOW}, {@link #ACCURACY_HIGH},
* {@link #ACCURACY_HIGH}, {@link #ACCURACY_BEST}, * or {@link #NO_REQUIREMENT}.
* More accurate location may consume more power and may take longer. * More accurate location may consume more power and may take longer.
* *
* @throws IllegalArgumentException if accuracy is not one of the supported constants * @throws IllegalArgumentException if accuracy is not one of the supported constants
*/ */
public void setBearingAccuracy(int accuracy) { public void setBearingAccuracy(int accuracy) {
if (accuracy < NO_REQUIREMENT || accuracy > ACCURACY_BEST) { if (accuracy < NO_REQUIREMENT || accuracy > ACCURACY_HIGH) {
throw new IllegalArgumentException("accuracy=" + accuracy); throw new IllegalArgumentException("accuracy=" + accuracy);
} }
mBearingAccuracy = accuracy; mBearingAccuracy = accuracy;
@@ -241,44 +203,13 @@ public class Criteria implements Parcelable {
/** /**
* Returns a constant indicating the desired bearing accuracy. * Returns a constant indicating the desired bearing accuracy.
* Accuracy may be {@link #ACCURACY_LOW}, {@link #ACCURACY_MEDIUM}, * Accuracy may be {@link #ACCURACY_LOW}, {@link #ACCURACY_HIGH},
* {@link #ACCURACY_HIGH}, {@link #ACCURACY_BEST}, * or {@link #NO_REQUIREMENT}.
*/ */
public int getBearingAccuracy() { public int getBearingAccuracy() {
return mBearingAccuracy; return mBearingAccuracy;
} }
/**
* Indicates the top priority to optimize for if the criteria parameters are
* found to be in conflict.
* Since a location provider might only be able to optimize for one requirement,
* the other requirements are considered good to have, but not guaranteed.
* This parameter does not override the priorities communicated through the
* preferred accuracy and power consumption parameters.
* If this parameter is not specified and conflicts occur, the location manager
* will use thefollowing default priority (high priority to low priority):
* {@link #HORIZONTAL_ACCURACY_PRIORITY}, {@link #POWER_REQUIREMENT_PRIORITY},
* {@link #VERTICAL_ACCURACY_PRIORITY}, {@link #SPEED_ACCURACY_PRIORITY},
* {@link #BEARING_ACCURACY_PRIORITY}.
*/
public void setPreferredPriority(int priority) {
if (priority < HORIZONTAL_ACCURACY_PRIORITY || priority > POWER_REQUIREMENT_PRIORITY) {
throw new IllegalArgumentException("priority=" + priority);
}
mPriority = priority;
}
/**
* Returns a constant indicating the top priority to optimize for if the
* criteria parameters are found to be in conflict.
* The value can be {@link #HORIZONTAL_ACCURACY_PRIORITY},
* {@link #VERTICAL_ACCURACY_PRIORITY}, {@link #SPEED_ACCURACY_PRIORITY},
* {@link #BEARING_ACCURACY_PRIORITY} or {@link #POWER_REQUIREMENT_PRIORITY}.
*/
public int getPriority() {
return mPriority;
}
/** /**
* Indicates the desired accuracy for latitude and longitude. Accuracy * Indicates the desired accuracy for latitude and longitude. Accuracy
* may be {@link #ACCURACY_FINE} if desired location * may be {@link #ACCURACY_FINE} if desired location
@@ -292,7 +223,7 @@ public class Criteria implements Parcelable {
throw new IllegalArgumentException("accuracy=" + accuracy); throw new IllegalArgumentException("accuracy=" + accuracy);
} }
if (accuracy == ACCURACY_FINE) { if (accuracy == ACCURACY_FINE) {
mHorizontalAccuracy = ACCURACY_BEST; mHorizontalAccuracy = ACCURACY_HIGH;
} else { } else {
mHorizontalAccuracy = ACCURACY_LOW; mHorizontalAccuracy = ACCURACY_LOW;
} }
@@ -401,7 +332,6 @@ public class Criteria implements Parcelable {
c.mVerticalAccuracy = in.readInt(); c.mVerticalAccuracy = in.readInt();
c.mSpeedAccuracy = in.readInt(); c.mSpeedAccuracy = in.readInt();
c.mBearingAccuracy = in.readInt(); c.mBearingAccuracy = in.readInt();
c.mPriority = in.readInt();
c.mPowerRequirement = in.readInt(); c.mPowerRequirement = in.readInt();
c.mAltitudeRequired = in.readInt() != 0; c.mAltitudeRequired = in.readInt() != 0;
c.mBearingRequired = in.readInt() != 0; c.mBearingRequired = in.readInt() != 0;
@@ -424,7 +354,6 @@ public class Criteria implements Parcelable {
parcel.writeInt(mVerticalAccuracy); parcel.writeInt(mVerticalAccuracy);
parcel.writeInt(mSpeedAccuracy); parcel.writeInt(mSpeedAccuracy);
parcel.writeInt(mBearingAccuracy); parcel.writeInt(mBearingAccuracy);
parcel.writeInt(mPriority);
parcel.writeInt(mPowerRequirement); parcel.writeInt(mPowerRequirement);
parcel.writeInt(mAltitudeRequired ? 1 : 0); parcel.writeInt(mAltitudeRequired ? 1 : 0);
parcel.writeInt(mBearingRequired ? 1 : 0); parcel.writeInt(mBearingRequired ? 1 : 0);