am 04d7e83e
: Added SensorManager.getAltitude()
Merge commit '04d7e83e65e246e154b5b346e3eb0081b741ae88' into gingerbread-plus-aosp * commit '04d7e83e65e246e154b5b346e3eb0081b741ae88': Added SensorManager.getAltitude()
This commit is contained in:
@ -77870,6 +77870,21 @@
|
|||||||
deprecated="not deprecated"
|
deprecated="not deprecated"
|
||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
|
<method name="getAltitude"
|
||||||
|
return="float"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="true"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="p0" type="float">
|
||||||
|
</parameter>
|
||||||
|
<parameter name="p" type="float">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
<method name="getDefaultSensor"
|
<method name="getDefaultSensor"
|
||||||
return="android.hardware.Sensor"
|
return="android.hardware.Sensor"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
@ -78449,6 +78464,17 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</field>
|
</field>
|
||||||
|
<field name="PRESSURE_STANDARD_ATMOSPHERE"
|
||||||
|
type="float"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value="1013.25f"
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
<field name="RAW_DATA_INDEX"
|
<field name="RAW_DATA_INDEX"
|
||||||
type="int"
|
type="int"
|
||||||
transient="false"
|
transient="false"
|
||||||
|
@ -268,6 +268,10 @@ public class SensorManager
|
|||||||
public static final float MAGNETIC_FIELD_EARTH_MIN = 30.0f;
|
public static final float MAGNETIC_FIELD_EARTH_MIN = 30.0f;
|
||||||
|
|
||||||
|
|
||||||
|
/** Standard atmosphere, or average sea-level pressure in hPa (millibar) */
|
||||||
|
public static final float PRESSURE_STANDARD_ATMOSPHERE = 1013.25f;
|
||||||
|
|
||||||
|
|
||||||
/** Maximum luminance of sunlight in lux */
|
/** Maximum luminance of sunlight in lux */
|
||||||
public static final float LIGHT_SUNLIGHT_MAX = 120000.0f;
|
public static final float LIGHT_SUNLIGHT_MAX = 120000.0f;
|
||||||
/** luminance of sunlight in lux */
|
/** luminance of sunlight in lux */
|
||||||
@ -1514,6 +1518,25 @@ public class SensorManager
|
|||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes the Altitude in meters from the atmospheric pressure and the
|
||||||
|
* pressure at sea level.
|
||||||
|
* <p>
|
||||||
|
* Typically the atmospheric pressure is read from a
|
||||||
|
* {@link Sensor#TYPE_PRESSURE} sensor. The pressure at sea level must be
|
||||||
|
* known, usually it can be retrieved from airport databases in the
|
||||||
|
* vicinity.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param p0 pressure at sea level
|
||||||
|
* @param p atmospheric pressure
|
||||||
|
* @return Altitude in meters
|
||||||
|
*/
|
||||||
|
public static float getAltitude(float p0, float p) {
|
||||||
|
final float coef = 1.0f / 5.255f;
|
||||||
|
return 44330.0f * (1.0f - (float)Math.pow(p/p0, coef));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@hide}
|
* {@hide}
|
||||||
|
Reference in New Issue
Block a user