Merge "Added damr box for AMR (NB and WB) sample entry" into gingerbread
diff --git a/api/current.xml b/api/current.xml
index f1a383f..4dd0909 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -77549,6 +77549,17 @@
visibility="public"
>
</method>
+<method name="getMinDelay"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
<method name="getName"
return="java.lang.String"
abstract="false"
@@ -77847,6 +77858,21 @@
deprecated="not deprecated"
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"
return="android.hardware.Sensor"
abstract="false"
@@ -78426,6 +78452,17 @@
visibility="public"
>
</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"
type="int"
transient="false"
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 7951a30..aecdcb3 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -1206,6 +1206,8 @@
* for management of input methods.
* <dt> {@link #UI_MODE_SERVICE} ("uimode")
* <dd> An {@link android.app.UiModeManager} for controlling UI modes.
+ * <dt> {@link #DOWNLOAD_SERVICE} ("download")
+ * <dd> A {@link android.net.DownloadManager} for requesting HTTP downloads
* </dl>
*
* <p>Note: System services obtained via this API may be closely associated with
@@ -1253,6 +1255,8 @@
* @see android.view.inputmethod.InputMethodManager
* @see #UI_MODE_SERVICE
* @see android.app.UiModeManager
+ * @see #DOWNLOAD_SERVICE
+ * @see android.net.DownloadManager
*/
public abstract Object getSystemService(String name);
diff --git a/core/java/android/hardware/Sensor.java b/core/java/android/hardware/Sensor.java
index 3490ac0..b49a409 100644
--- a/core/java/android/hardware/Sensor.java
+++ b/core/java/android/hardware/Sensor.java
@@ -92,6 +92,7 @@
private float mMaxRange;
private float mResolution;
private float mPower;
+ private int mMinDelay;
private int mLegacyType;
@@ -147,6 +148,15 @@
return mPower;
}
+ /**
+ * @return the minimum delay allowed between two events in microsecond
+ * or zero if this sensor only returns a value when the data it's measuring
+ * changes.
+ */
+ public int getMinDelay() {
+ return mMinDelay;
+ }
+
int getHandle() {
return mHandle;
}
diff --git a/core/java/android/hardware/SensorManager.java b/core/java/android/hardware/SensorManager.java
index e6750e6..f6d237a 100644
--- a/core/java/android/hardware/SensorManager.java
+++ b/core/java/android/hardware/SensorManager.java
@@ -268,6 +268,10 @@
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 */
public static final float LIGHT_SUNLIGHT_MAX = 120000.0f;
/** luminance of sunlight in lux */
@@ -573,11 +577,11 @@
// which won't get the rotated values
try {
sRotation = sWindowManager.watchRotation(
- new IRotationWatcher.Stub() {
- public void onRotationChanged(int rotation) {
- SensorManager.this.onRotationChanged(rotation);
+ new IRotationWatcher.Stub() {
+ public void onRotationChanged(int rotation) {
+ SensorManager.this.onRotationChanged(rotation);
+ }
}
- }
);
} catch (RemoteException e) {
}
@@ -638,7 +642,7 @@
break;
case Sensor.TYPE_ORIENTATION:
result |= SensorManager.SENSOR_ORIENTATION |
- SensorManager.SENSOR_ORIENTATION_RAW;
+ SensorManager.SENSOR_ORIENTATION_RAW;
break;
}
}
@@ -935,7 +939,8 @@
* received faster or slower than the specified rate. Usually events
* are received faster. The value must be one of
* {@link #SENSOR_DELAY_NORMAL}, {@link #SENSOR_DELAY_UI},
- * {@link #SENSOR_DELAY_GAME}, or {@link #SENSOR_DELAY_FASTEST}.
+ * {@link #SENSOR_DELAY_GAME}, or {@link #SENSOR_DELAY_FASTEST}
+ * or, the desired delay between events in microsecond.
*
* @return <code>true</code> if the sensor is supported and successfully
* enabled.
@@ -967,6 +972,7 @@
* are received faster. The value must be one of
* {@link #SENSOR_DELAY_NORMAL}, {@link #SENSOR_DELAY_UI},
* {@link #SENSOR_DELAY_GAME}, or {@link #SENSOR_DELAY_FASTEST}.
+ * or, the desired delay between events in microsecond.
*
* @param handler
* The {@link android.os.Handler Handler} the
@@ -992,16 +998,17 @@
delay = 0;
break;
case SENSOR_DELAY_GAME:
- delay = 20;
+ delay = 20000;
break;
case SENSOR_DELAY_UI:
- delay = 60;
+ delay = 60000;
break;
case SENSOR_DELAY_NORMAL:
- delay = 200;
+ delay = 200000;
break;
default:
- return false;
+ delay = rate;
+ break;
}
synchronized (sListeners) {
@@ -1485,7 +1492,7 @@
* @see #getRotationMatrix(float[], float[], float[], float[])
* @see GeomagneticField
*/
- public static float[] getOrientation(float[] R, float values[]) {
+ public static float[] getOrientation(float[] R, float values[]) {
/*
* 4x4 (length=16) case:
* / R[ 0] R[ 1] R[ 2] 0 \
@@ -1511,8 +1518,27 @@
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}
*/
public void onRotationChanged(int rotation) {
diff --git a/core/java/android/widget/BaseExpandableListAdapter.java b/core/java/android/widget/BaseExpandableListAdapter.java
index 396b7ae..b4d6ad7 100644
--- a/core/java/android/widget/BaseExpandableListAdapter.java
+++ b/core/java/android/widget/BaseExpandableListAdapter.java
@@ -43,14 +43,14 @@
}
/**
- * {@see DataSetObservable#notifyInvalidated()}
+ * @see DataSetObservable#notifyInvalidated()
*/
public void notifyDataSetInvalidated() {
mDataSetObservable.notifyInvalidated();
}
/**
- * {@see DataSetObservable#notifyChanged()}
+ * @see DataSetObservable#notifyChanged()
*/
public void notifyDataSetChanged() {
mDataSetObservable.notifyChanged();
diff --git a/core/java/android/widget/HeterogeneousExpandableList.java b/core/java/android/widget/HeterogeneousExpandableList.java
index 1292733..e7e0933 100644
--- a/core/java/android/widget/HeterogeneousExpandableList.java
+++ b/core/java/android/widget/HeterogeneousExpandableList.java
@@ -23,12 +23,13 @@
* Additional methods that when implemented make an
* {@link ExpandableListAdapter} take advantage of the {@link Adapter} view type
* mechanism.
- *
- * An {@link ExpandableListAdapter} declares one view type for its group items
+ * <p>
+ * An {@link ExpandableListAdapter} declares it has one view type for its group items
* and one view type for its child items. Although adapted for most {@link ExpandableListView}s,
- * these values should be tuned heterogeneous {@link ExpandableListView}s. Lists that contain
- * different types of group and/or child item views, should use an adapter that implements this
- * interface. This way, the recycled views that will be provided to
+ * these values should be tuned for heterogeneous {@link ExpandableListView}s.
+ * </p>
+ * Lists that contain different types of group and/or child item views, should use an adapter that
+ * implements this interface. This way, the recycled views that will be provided to
* {@link android.widget.ExpandableListAdapter#getGroupView(int, boolean, View, ViewGroup)}
* and
* {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
@@ -48,7 +49,7 @@
* . Note: Integers must be in the range 0 to {@link #getGroupTypeCount} - 1.
* {@link android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE} can also be returned.
* @see android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE
- * @see getGroupTypeCount()
+ * @see #getGroupTypeCount()
*/
int getGroupType(int groupPosition);
@@ -65,7 +66,7 @@
* Note: Integers must be in the range 0 to {@link #getChildTypeCount} - 1.
* {@link android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE} can also be returned.
* @see android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE
- * @see getChildTypeCount()
+ * @see #getChildTypeCount()
*/
int getChildType(int groupPosition, int childPosition);
@@ -78,13 +79,11 @@
* . If the adapter always returns the same type of View for all group items, this method should
* return 1.
* </p>
- * <p>
* This method will only be called when the adapter is set on the {@link AdapterView}.
- * </p>
*
* @return The number of types of group Views that will be created by this adapter.
- * @see getChildTypeCount()
- * @see getGroupType()
+ * @see #getChildTypeCount()
+ * @see #getGroupType(int)
*/
int getGroupTypeCount();
@@ -97,13 +96,11 @@
* , for any group. If the adapter always returns the same type of View for
* all child items, this method should return 1.
* </p>
- * <p>
* This method will only be called when the adapter is set on the {@link AdapterView}.
- * </p>
*
* @return The total number of types of child Views that will be created by this adapter.
- * @see getGroupTypeCount()
- * @see getChildType()
+ * @see #getGroupTypeCount()
+ * @see #getChildType(int, int)
*/
int getChildTypeCount();
}
diff --git a/core/jni/android_hardware_SensorManager.cpp b/core/jni/android_hardware_SensorManager.cpp
index 7b23418..e29495c 100644
--- a/core/jni/android_hardware_SensorManager.cpp
+++ b/core/jni/android_hardware_SensorManager.cpp
@@ -38,6 +38,7 @@
jfieldID range;
jfieldID resolution;
jfieldID power;
+ jfieldID minDelay;
} gSensorOffsets;
/*
@@ -74,6 +75,7 @@
env->SetFloatField(sensor, sensorOffsets.range, list->getMaxValue());
env->SetFloatField(sensor, sensorOffsets.resolution, list->getResolution());
env->SetFloatField(sensor, sensorOffsets.power, list->getPowerUsage());
+ env->SetIntField(sensor, sensorOffsets.minDelay, list->getMinDelay());
next++;
return next<count ? next : 0;
@@ -154,6 +156,7 @@
sensorOffsets.range = _env->GetFieldID(sensorClass, "mMaxRange", "F");
sensorOffsets.resolution = _env->GetFieldID(sensorClass, "mResolution","F");
sensorOffsets.power = _env->GetFieldID(sensorClass, "mPower", "F");
+ sensorOffsets.minDelay = _env->GetFieldID(sensorClass, "mMinDelay", "I");
}
static JNINativeMethod gMethods[] = {
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/ConnectivityManagerMobileTest.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/ConnectivityManagerMobileTest.java
index cdaefc8..ad8d444 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/ConnectivityManagerMobileTest.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/ConnectivityManagerMobileTest.java
@@ -91,30 +91,30 @@
// DISCONNECTING, DISCONNECTED, UNKNOWN
private void waitForNetworkState(int networkType, State expectedState, long timeout) {
long startTime = System.currentTimeMillis();
- // In case the broadcast is already sent out, no need to wait
- if (cmActivity.mCM.getNetworkInfo(networkType).getState() == expectedState) {
- return;
- } else {
- while (true) {
- if ((System.currentTimeMillis() - startTime) > timeout) {
+ while (true) {
+ if ((System.currentTimeMillis() - startTime) > timeout) {
+ if (cmActivity.mCM.getNetworkInfo(networkType).getState() != expectedState) {
assertFalse("Wait for network state timeout", true);
+ } else {
+ // the broadcast has been sent out. the state has been changed.
+ return;
}
- Log.v(LOG_TAG, "Wait for the connectivity state for network: " + networkType +
- " to be " + expectedState.toString());
- synchronized (cmActivity.connectivityObject) {
- try {
- cmActivity.connectivityObject.wait(STATE_TRANSITION_SHORT_TIMEOUT);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- if ((cmActivity.mNetworkInfo.getType() != networkType) ||
- (cmActivity.mNetworkInfo.getState() != expectedState)) {
- Log.v(LOG_TAG, "network state for " + cmActivity.mNetworkInfo.getType() +
- "is: " + cmActivity.mNetworkInfo.getState());
- continue;
- }
- break;
+ }
+ Log.v(LOG_TAG, "Wait for the connectivity state for network: " + networkType +
+ " to be " + expectedState.toString());
+ synchronized (cmActivity.connectivityObject) {
+ try {
+ cmActivity.connectivityObject.wait(STATE_TRANSITION_SHORT_TIMEOUT);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
}
+ if ((cmActivity.mNetworkInfo.getType() != networkType) ||
+ (cmActivity.mNetworkInfo.getState() != expectedState)) {
+ Log.v(LOG_TAG, "network state for " + cmActivity.mNetworkInfo.getType() +
+ "is: " + cmActivity.mNetworkInfo.getState());
+ continue;
+ }
+ break;
}
}
}
@@ -123,26 +123,26 @@
// WIFI_STATE_ENALBING, WIFI_STATE_UNKNOWN
private void waitForWifiState(int expectedState, long timeout) {
long startTime = System.currentTimeMillis();
- if (cmActivity.mWifiState == expectedState) {
- return;
- } else {
- while (true) {
- if ((System.currentTimeMillis() - startTime) > timeout) {
+ while (true) {
+ if ((System.currentTimeMillis() - startTime) > timeout) {
+ if (cmActivity.mWifiState != expectedState) {
assertFalse("Wait for Wifi state timeout", true);
+ } else {
+ return;
}
- Log.v(LOG_TAG, "Wait for wifi state to be: " + expectedState);
- synchronized (cmActivity.wifiObject) {
- try {
- cmActivity.wifiObject.wait(5*1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- if (cmActivity.mWifiState != expectedState) {
- Log.v(LOG_TAG, "Wifi state is: " + cmActivity.mWifiNetworkInfo.getState());
- continue;
- }
- break;
+ }
+ Log.v(LOG_TAG, "Wait for wifi state to be: " + expectedState);
+ synchronized (cmActivity.wifiObject) {
+ try {
+ cmActivity.wifiObject.wait(5*1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
}
+ if (cmActivity.mWifiState != expectedState) {
+ Log.v(LOG_TAG, "Wifi state is: " + cmActivity.mWifiNetworkInfo.getState());
+ continue;
+ }
+ break;
}
}
}
diff --git a/docs/html/guide/topics/resources/providing-resources.jd b/docs/html/guide/topics/resources/providing-resources.jd
index 7e2f8a0..1d6ab25 100644
--- a/docs/html/guide/topics/resources/providing-resources.jd
+++ b/docs/html/guide/topics/resources/providing-resources.jd
@@ -450,8 +450,8 @@
to match the device density.</li>
</ul>
<p><em>Added in API Level 4.</em></p>
- <p>There is thus a 4:3 scaling factor between each density, so a 9x9 bitmap
- in ldpi is 12x12 in mdpi and 16x16 in hdpi.</p>
+ <p>There is thus a 3:4:6 scaling ratio between the three densities, so a 9x9 bitmap
+ in ldpi is 12x12 in mdpi and 18x18 in hdpi.</p>
<p>When Android selects which resource files to use,
it handles screen density differently than the other qualifiers.
In step 1 of <a href="#BestMatch">How Android finds the best
@@ -895,7 +895,7 @@
drawable-port-notouch-12key/
</pre>
<p class="note"><strong>Exception:</strong> Screen pixel density is the one qualifier that is not
-eliminated due to a contradiction. Even though the screen density of the device is mdpi,
+eliminated due to a contradiction. Even though the screen density of the device is hdpi,
<code>drawable-port-ldpi/</code> is not eliminated because every screen density is
considered to be a match at this point. More information is available in the <a
href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple
@@ -922,9 +922,8 @@
<strike>drawable-port-notouch-12key/</strike>
</pre>
<p class="note"><strong>Exception:</strong> If the qualifier in question is screen pixel density,
-Android
-selects the option that most closely matches the device, and the selection process is complete.
-In general, Android prefers scaling down a larger original image to scaling up a smaller
+Android selects the option that most closely matches the device screen density.
+In general, Android prefers scaling down a larger original image to scaling up a smaller
original image. See <a href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple
Screens</a>.</p>
</li>
diff --git a/include/camera/Camera.h b/include/camera/Camera.h
index 9974f2f..964700b 100644
--- a/include/camera/Camera.h
+++ b/include/camera/Camera.h
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2008 The Android Open Source Project
- * Copyright (C) 2008 HTC Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/include/gui/Sensor.h b/include/gui/Sensor.h
index e696d63..2de07b1 100644
--- a/include/gui/Sensor.h
+++ b/include/gui/Sensor.h
@@ -63,6 +63,7 @@
float getMaxValue() const;
float getResolution() const;
float getPowerUsage() const;
+ int32_t getMinDelay() const;
// Flattenable interface
virtual size_t getFlattenedSize() const;
@@ -81,6 +82,7 @@
float mMaxValue;
float mResolution;
float mPower;
+ int32_t mMinDelay;
};
// ----------------------------------------------------------------------------
diff --git a/include/gui/SensorEventQueue.h b/include/gui/SensorEventQueue.h
index ad36dac..6581ae3 100644
--- a/include/gui/SensorEventQueue.h
+++ b/include/gui/SensorEventQueue.h
@@ -65,7 +65,7 @@
status_t setEventRate(Sensor const* sensor, nsecs_t ns) const;
// these are here only to support SensorManager.java
- status_t enableSensor(int32_t handle, int32_t ms) const;
+ status_t enableSensor(int32_t handle, int32_t us) const;
status_t disableSensor(int32_t handle) const;
private:
diff --git a/include/media/IMediaRecorder.h b/include/media/IMediaRecorder.h
index cfc17a5..54adca8 100644
--- a/include/media/IMediaRecorder.h
+++ b/include/media/IMediaRecorder.h
@@ -1,6 +1,6 @@
/*
**
- ** Copyright 2008, HTC Inc.
+ ** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
diff --git a/include/media/PVMediaRecorder.h b/include/media/PVMediaRecorder.h
index f75d80d..c091c39 100644
--- a/include/media/PVMediaRecorder.h
+++ b/include/media/PVMediaRecorder.h
@@ -1,6 +1,6 @@
/*
**
- ** Copyright 2008, HTC Inc.
+ ** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
diff --git a/include/ui/InputReader.h b/include/ui/InputReader.h
index d7ec8ea..6bf1bfa 100644
--- a/include/ui/InputReader.h
+++ b/include/ui/InputReader.h
@@ -210,7 +210,7 @@
* IMPORTANT INVARIANT:
* Because the policy and dispatcher can potentially block or cause re-entrance into
* the input reader, the input reader never calls into other components while holding
- * an exclusive internal lock.
+ * an exclusive internal lock whenever re-entrance can happen.
*/
class InputReader : public InputReaderInterface, private InputReaderContext {
public:
@@ -414,6 +414,8 @@
virtual int32_t getMetaState();
private:
+ Mutex mLock;
+
struct KeyDown {
int32_t keyCode;
int32_t scanCode;
@@ -423,17 +425,22 @@
uint32_t mSources;
int32_t mKeyboardType;
- Vector<KeyDown> mKeyDowns; // keys that are down
- int32_t mMetaState;
- nsecs_t mDownTime; // time of most recent key down
+ struct LockedState {
+ Vector<KeyDown> keyDowns; // keys that are down
+ int32_t metaState;
+ nsecs_t downTime; // time of most recent key down
+ } mLocked;
- void initialize();
+ void initializeLocked();
bool isKeyboardOrGamepadKey(int32_t scanCode);
+
void processKey(nsecs_t when, bool down, int32_t keyCode, int32_t scanCode,
uint32_t policyFlags);
+ void applyPolicyAndDispatch(nsecs_t when, uint32_t policyFlags,
+ bool down, int32_t keyCode, int32_t scanCode, int32_t metaState, nsecs_t downTime);
- ssize_t findKeyDown(int32_t scanCode);
+ ssize_t findKeyDownLocked(int32_t scanCode);
};
@@ -451,6 +458,8 @@
// Amount that trackball needs to move in order to generate a key event.
static const int32_t TRACKBALL_MOVEMENT_THRESHOLD = 6;
+ Mutex mLock;
+
int32_t mAssociatedDisplayId;
struct Accumulator {
@@ -475,17 +484,21 @@
}
} mAccumulator;
- bool mDown;
- nsecs_t mDownTime;
-
float mXScale;
float mYScale;
float mXPrecision;
float mYPrecision;
- void initialize();
+ struct LockedState {
+ bool down;
+ nsecs_t downTime;
+ } mLocked;
+
+ void initializeLocked();
void sync(nsecs_t when);
+ void applyPolicyAndDispatch(nsecs_t when, int32_t motionEventAction,
+ PointerCoords* pointerCoords, nsecs_t downTime);
};
@@ -509,6 +522,8 @@
* (This is limited by our use of BitSet32 to track pointer assignments.) */
static const uint32_t MAX_POINTER_ID = 31;
+ Mutex mLock;
+
struct VirtualKey {
int32_t keyCode;
int32_t scanCode;
@@ -561,7 +576,6 @@
};
int32_t mAssociatedDisplayId;
- Vector<VirtualKey> mVirtualKeys;
// Immutable configuration parameters.
struct Parameters {
@@ -583,67 +597,65 @@
RawAbsoluteAxisInfo orientation;
} mAxes;
- // The surface orientation and width and height set by configureSurface().
- int32_t mSurfaceOrientation;
- int32_t mSurfaceWidth, mSurfaceHeight;
-
- // Translation and scaling factors, orientation-independent.
- int32_t mXOrigin;
- float mXScale;
- float mXPrecision;
-
- int32_t mYOrigin;
- float mYScale;
- float mYPrecision;
-
- int32_t mPressureOrigin;
- float mPressureScale;
-
- int32_t mSizeOrigin;
- float mSizeScale;
-
- float mOrientationScale;
-
- // Oriented motion ranges for input device info.
- struct OrientedRanges {
- InputDeviceInfo::MotionRange x;
- InputDeviceInfo::MotionRange y;
- InputDeviceInfo::MotionRange pressure;
- InputDeviceInfo::MotionRange size;
- InputDeviceInfo::MotionRange touchMajor;
- InputDeviceInfo::MotionRange touchMinor;
- InputDeviceInfo::MotionRange toolMajor;
- InputDeviceInfo::MotionRange toolMinor;
- InputDeviceInfo::MotionRange orientation;
- } mOrientedRanges;
-
- // Oriented dimensions and precision.
- float mOrientedSurfaceWidth, mOrientedSurfaceHeight;
- float mOrientedXPrecision, mOrientedYPrecision;
-
- // The touch data of the current sample being processed.
+ // Current and previous touch sample data.
TouchData mCurrentTouch;
-
- // The touch data of the previous sample that was processed. This is updated
- // incrementally while the current sample is being processed.
TouchData mLastTouch;
// The time the primary pointer last went down.
nsecs_t mDownTime;
- struct CurrentVirtualKeyState {
- bool down;
- nsecs_t downTime;
- int32_t keyCode;
- int32_t scanCode;
- } mCurrentVirtualKey;
+ struct LockedState {
+ Vector<VirtualKey> virtualKeys;
- // Lock for virtual key state.
- Mutex mVirtualKeyLock; // methods use "Lvk" suffix
+ // The surface orientation and width and height set by configureSurfaceLocked().
+ int32_t surfaceOrientation;
+ int32_t surfaceWidth, surfaceHeight;
+
+ // Translation and scaling factors, orientation-independent.
+ int32_t xOrigin;
+ float xScale;
+ float xPrecision;
+
+ int32_t yOrigin;
+ float yScale;
+ float yPrecision;
+
+ int32_t pressureOrigin;
+ float pressureScale;
+
+ int32_t sizeOrigin;
+ float sizeScale;
+
+ float orientationScale;
+
+ // Oriented motion ranges for input device info.
+ struct OrientedRanges {
+ InputDeviceInfo::MotionRange x;
+ InputDeviceInfo::MotionRange y;
+ InputDeviceInfo::MotionRange pressure;
+ InputDeviceInfo::MotionRange size;
+ InputDeviceInfo::MotionRange touchMajor;
+ InputDeviceInfo::MotionRange touchMinor;
+ InputDeviceInfo::MotionRange toolMajor;
+ InputDeviceInfo::MotionRange toolMinor;
+ InputDeviceInfo::MotionRange orientation;
+ } orientedRanges;
+
+ // Oriented dimensions and precision.
+ float orientedSurfaceWidth, orientedSurfaceHeight;
+ float orientedXPrecision, orientedYPrecision;
+
+ struct CurrentVirtualKeyState {
+ bool down;
+ nsecs_t downTime;
+ int32_t keyCode;
+ int32_t scanCode;
+ } currentVirtualKey;
+ } mLocked;
virtual void configureAxes();
- virtual bool configureSurface();
- virtual void configureVirtualKeys();
+ virtual bool configureSurfaceLocked();
+ virtual void configureVirtualKeysLocked();
enum TouchResult {
// Dispatch the touch normally.
@@ -696,15 +708,19 @@
uint64_t distance : 48; // squared distance
};
- void initialize();
+ void initializeLocked();
TouchResult consumeOffScreenTouches(nsecs_t when, uint32_t policyFlags);
void dispatchTouches(nsecs_t when, uint32_t policyFlags);
void dispatchTouch(nsecs_t when, uint32_t policyFlags, TouchData* touch,
BitSet32 idBits, uint32_t changedId, int32_t motionEventAction);
- bool isPointInsideSurface(int32_t x, int32_t y);
- const VirtualKey* findVirtualKeyHitLvk(int32_t x, int32_t y);
+ void applyPolicyAndDispatchVirtualKey(nsecs_t when, uint32_t policyFlags,
+ int32_t keyEventAction, int32_t keyEventFlags,
+ int32_t keyCode, int32_t scanCode, nsecs_t downTime);
+
+ bool isPointInsideSurfaceLocked(int32_t x, int32_t y);
+ const VirtualKey* findVirtualKeyHitLocked(int32_t x, int32_t y);
bool applyBadTouchFilter();
bool applyJumpyTouchFilter();
diff --git a/libs/camera/Camera.cpp b/libs/camera/Camera.cpp
index 0037399..7efc6d7 100644
--- a/libs/camera/Camera.cpp
+++ b/libs/camera/Camera.cpp
@@ -1,7 +1,6 @@
/*
**
** Copyright (C) 2008, The Android Open Source Project
-** Copyright (C) 2008 HTC Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
diff --git a/libs/gui/Sensor.cpp b/libs/gui/Sensor.cpp
index cb85df9..b1f37ff 100644
--- a/libs/gui/Sensor.cpp
+++ b/libs/gui/Sensor.cpp
@@ -32,7 +32,7 @@
Sensor::Sensor()
: mHandle(0), mType(0),
mMinValue(0), mMaxValue(0), mResolution(0),
- mPower(0)
+ mPower(0), mMinDelay(0)
{
}
@@ -46,6 +46,7 @@
mMaxValue = hwSensor->maxRange; // FIXME: maxValue
mResolution = hwSensor->resolution;
mPower = hwSensor->power;
+ mMinDelay = hwSensor->minDelay;
}
Sensor::~Sensor()
@@ -84,12 +85,17 @@
return mPower;
}
+int32_t Sensor::getMinDelay() const {
+ return mMinDelay;
+}
+
size_t Sensor::getFlattenedSize() const
{
return sizeof(int32_t) + ((mName.length() + 3) & ~3) +
sizeof(int32_t) + ((mVendor.length() + 3) & ~3) +
sizeof(int32_t) * 2 +
- sizeof(float) * 4;
+ sizeof(float) * 4 +
+ sizeof(int32_t);
}
size_t Sensor::getFdCount() const
@@ -132,6 +138,7 @@
offset += write(buffer, offset, mMaxValue);
offset += write(buffer, offset, mResolution);
offset += write(buffer, offset, mPower);
+ offset += write(buffer, offset, mMinDelay);
return NO_ERROR;
}
@@ -169,6 +176,7 @@
offset += read(buffer, offset, &mMaxValue);
offset += read(buffer, offset, &mResolution);
offset += read(buffer, offset, &mPower);
+ offset += read(buffer, offset, &mMinDelay);
return NO_ERROR;
}
diff --git a/libs/gui/SensorEventQueue.cpp b/libs/gui/SensorEventQueue.cpp
index 4b46842..3396f25 100644
--- a/libs/gui/SensorEventQueue.cpp
+++ b/libs/gui/SensorEventQueue.cpp
@@ -114,10 +114,10 @@
return mSensorEventConnection->enableDisable(sensor->getHandle(), false);
}
-status_t SensorEventQueue::enableSensor(int32_t handle, int32_t ms) const {
+status_t SensorEventQueue::enableSensor(int32_t handle, int32_t us) const {
status_t err = mSensorEventConnection->enableDisable(handle, true);
if (err == NO_ERROR) {
- mSensorEventConnection->setEventRate(handle, ms2ns(ms));
+ mSensorEventConnection->setEventRate(handle, us2ns(us));
}
return err;
}
diff --git a/libs/ui/InputReader.cpp b/libs/ui/InputReader.cpp
index 56e2977..6618702 100644
--- a/libs/ui/InputReader.cpp
+++ b/libs/ui/InputReader.cpp
@@ -713,15 +713,15 @@
uint32_t sources, int32_t keyboardType) :
InputMapper(device), mAssociatedDisplayId(associatedDisplayId), mSources(sources),
mKeyboardType(keyboardType) {
- initialize();
+ initializeLocked();
}
KeyboardInputMapper::~KeyboardInputMapper() {
}
-void KeyboardInputMapper::initialize() {
- mMetaState = AMETA_NONE;
- mDownTime = 0;
+void KeyboardInputMapper::initializeLocked() {
+ mLocked.metaState = AMETA_NONE;
+ mLocked.downTime = 0;
}
uint32_t KeyboardInputMapper::getSources() {
@@ -735,17 +735,27 @@
}
void KeyboardInputMapper::reset() {
- // Synthesize key up event on reset if keys are currently down.
- while (! mKeyDowns.isEmpty()) {
- const KeyDown& keyDown = mKeyDowns.top();
+ for (;;) {
+ int32_t keyCode, scanCode;
+ { // acquire lock
+ AutoMutex _l(mLock);
+
+ // Synthesize key up event on reset if keys are currently down.
+ if (mLocked.keyDowns.isEmpty()) {
+ initializeLocked();
+ break; // done
+ }
+
+ const KeyDown& keyDown = mLocked.keyDowns.top();
+ keyCode = keyDown.keyCode;
+ scanCode = keyDown.scanCode;
+ } // release lock
+
nsecs_t when = systemTime(SYSTEM_TIME_MONOTONIC);
- processKey(when, false, keyDown.keyCode, keyDown.scanCode, 0);
+ processKey(when, false, keyCode, scanCode, 0);
}
InputMapper::reset();
-
- // Reinitialize.
- initialize();
getContext()->updateGlobalMetaState();
}
@@ -768,56 +778,76 @@
|| (scanCode >= BTN_GAMEPAD && scanCode < BTN_DIGI);
}
-void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t keyCode, int32_t scanCode,
- uint32_t policyFlags) {
- if (down) {
- // Rotate key codes according to orientation.
- if (mAssociatedDisplayId >= 0) {
- int32_t orientation;
- if (! getPolicy()->getDisplayInfo(mAssociatedDisplayId, NULL, NULL, & orientation)) {
- return;
+void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t keyCode,
+ int32_t scanCode, uint32_t policyFlags) {
+ int32_t newMetaState;
+ nsecs_t downTime;
+ bool metaStateChanged = false;
+
+ { // acquire lock
+ AutoMutex _l(mLock);
+
+ if (down) {
+ // Rotate key codes according to orientation if needed.
+ // Note: getDisplayInfo is non-reentrant so we can continue holding the lock.
+ if (mAssociatedDisplayId >= 0) {
+ int32_t orientation;
+ if (! getPolicy()->getDisplayInfo(mAssociatedDisplayId, NULL, NULL, & orientation)) {
+ return;
+ }
+
+ keyCode = rotateKeyCode(keyCode, orientation);
}
- keyCode = rotateKeyCode(keyCode, orientation);
+ // Add key down.
+ ssize_t keyDownIndex = findKeyDownLocked(scanCode);
+ if (keyDownIndex >= 0) {
+ // key repeat, be sure to use same keycode as before in case of rotation
+ keyCode = mLocked.keyDowns.top().keyCode;
+ } else {
+ // key down
+ mLocked.keyDowns.push();
+ KeyDown& keyDown = mLocked.keyDowns.editTop();
+ keyDown.keyCode = keyCode;
+ keyDown.scanCode = scanCode;
+ }
+
+ mLocked.downTime = when;
+ } else {
+ // Remove key down.
+ ssize_t keyDownIndex = findKeyDownLocked(scanCode);
+ if (keyDownIndex >= 0) {
+ // key up, be sure to use same keycode as before in case of rotation
+ keyCode = mLocked.keyDowns.top().keyCode;
+ mLocked.keyDowns.removeAt(size_t(keyDownIndex));
+ } else {
+ // key was not actually down
+ LOGI("Dropping key up from device %s because the key was not down. "
+ "keyCode=%d, scanCode=%d",
+ getDeviceName().string(), keyCode, scanCode);
+ return;
+ }
}
- // Add key down.
- ssize_t keyDownIndex = findKeyDown(scanCode);
- if (keyDownIndex >= 0) {
- // key repeat, be sure to use same keycode as before in case of rotation
- keyCode = mKeyDowns.top().keyCode;
- } else {
- // key down
- mKeyDowns.push();
- KeyDown& keyDown = mKeyDowns.editTop();
- keyDown.keyCode = keyCode;
- keyDown.scanCode = scanCode;
+ int32_t oldMetaState = mLocked.metaState;
+ newMetaState = updateMetaState(keyCode, down, oldMetaState);
+ if (oldMetaState != newMetaState) {
+ mLocked.metaState = newMetaState;
+ metaStateChanged = true;
}
- } else {
- // Remove key down.
- ssize_t keyDownIndex = findKeyDown(scanCode);
- if (keyDownIndex >= 0) {
- // key up, be sure to use same keycode as before in case of rotation
- keyCode = mKeyDowns.top().keyCode;
- mKeyDowns.removeAt(size_t(keyDownIndex));
- } else {
- // key was not actually down
- LOGI("Dropping key up from device %s because the key was not down. "
- "keyCode=%d, scanCode=%d",
- getDeviceName().string(), keyCode, scanCode);
- return;
- }
- }
- int32_t oldMetaState = mMetaState;
- int32_t newMetaState = updateMetaState(keyCode, down, oldMetaState);
- if (oldMetaState != newMetaState) {
- mMetaState = newMetaState;
+ downTime = mLocked.downTime;
+ } // release lock
+
+ if (metaStateChanged) {
getContext()->updateGlobalMetaState();
}
- /* Apply policy. */
+ applyPolicyAndDispatch(when, policyFlags, down, keyCode, scanCode, newMetaState, downTime);
+}
+void KeyboardInputMapper::applyPolicyAndDispatch(nsecs_t when, uint32_t policyFlags, bool down,
+ int32_t keyCode, int32_t scanCode, int32_t metaState, nsecs_t downTime) {
int32_t policyActions = getPolicy()->interceptKey(when,
getDeviceId(), down, keyCode, scanCode, policyFlags);
@@ -825,30 +855,20 @@
return; // event dropped
}
- /* Enqueue key event for dispatch. */
-
- int32_t keyEventAction;
- if (down) {
- mDownTime = when;
- keyEventAction = AKEY_EVENT_ACTION_DOWN;
- } else {
- keyEventAction = AKEY_EVENT_ACTION_UP;
- }
-
+ int32_t keyEventAction = down ? AKEY_EVENT_ACTION_DOWN : AKEY_EVENT_ACTION_UP;
int32_t keyEventFlags = AKEY_EVENT_FLAG_FROM_SYSTEM;
if (policyFlags & POLICY_FLAG_WOKE_HERE) {
keyEventFlags = keyEventFlags | AKEY_EVENT_FLAG_WOKE_HERE;
}
getDispatcher()->notifyKey(when, getDeviceId(), AINPUT_SOURCE_KEYBOARD, policyFlags,
- keyEventAction, keyEventFlags, keyCode, scanCode,
- mMetaState, mDownTime);
+ keyEventAction, keyEventFlags, keyCode, scanCode, metaState, downTime);
}
-ssize_t KeyboardInputMapper::findKeyDown(int32_t scanCode) {
- size_t n = mKeyDowns.size();
+ssize_t KeyboardInputMapper::findKeyDownLocked(int32_t scanCode) {
+ size_t n = mLocked.keyDowns.size();
for (size_t i = 0; i < n; i++) {
- if (mKeyDowns[i].scanCode == scanCode) {
+ if (mLocked.keyDowns[i].scanCode == scanCode) {
return i;
}
}
@@ -869,7 +889,10 @@
}
int32_t KeyboardInputMapper::getMetaState() {
- return mMetaState;
+ { // acquire lock
+ AutoMutex _l(mLock);
+ return mLocked.metaState;
+ } // release lock
}
@@ -882,7 +905,7 @@
mXScale = 1.0f / TRACKBALL_MOVEMENT_THRESHOLD;
mYScale = 1.0f / TRACKBALL_MOVEMENT_THRESHOLD;
- initialize();
+ initializeLocked();
}
TrackballInputMapper::~TrackballInputMapper() {
@@ -899,26 +922,33 @@
info->addMotionRange(AINPUT_MOTION_RANGE_Y, -1.0f, 1.0f, 0.0f, mYScale);
}
-void TrackballInputMapper::initialize() {
+void TrackballInputMapper::initializeLocked() {
mAccumulator.clear();
- mDown = false;
- mDownTime = 0;
+ mLocked.down = false;
+ mLocked.downTime = 0;
}
void TrackballInputMapper::reset() {
- // Synthesize trackball button up event on reset if trackball button is currently down.
- if (mDown) {
+ for (;;) {
+ { // acquire lock
+ AutoMutex _l(mLock);
+
+ if (! mLocked.down) {
+ initializeLocked();
+ break; // done
+ }
+ } // release lock
+
+ // Synthesize trackball button up event on reset.
nsecs_t when = systemTime(SYSTEM_TIME_MONOTONIC);
- mAccumulator.fields |= Accumulator::FIELD_BTN_MOUSE;
+ mAccumulator.fields = Accumulator::FIELD_BTN_MOUSE;
mAccumulator.btnMouse = false;
sync(when);
+ mAccumulator.clear();
}
InputMapper::reset();
-
- // Reinitialize.
- initialize();
}
void TrackballInputMapper::process(const RawEvent* rawEvent) {
@@ -962,33 +992,79 @@
}
void TrackballInputMapper::sync(nsecs_t when) {
- /* Get display properties so for rotation based on display orientation. */
+ int motionEventAction;
+ PointerCoords pointerCoords;
+ nsecs_t downTime;
+ { // acquire lock
+ AutoMutex _l(mLock);
- int32_t orientation;
- if (mAssociatedDisplayId >= 0) {
- if (! getPolicy()->getDisplayInfo(mAssociatedDisplayId, NULL, NULL, & orientation)) {
- return;
+ uint32_t fields = mAccumulator.fields;
+ bool downChanged = fields & Accumulator::FIELD_BTN_MOUSE;
+
+ if (downChanged) {
+ if (mAccumulator.btnMouse) {
+ mLocked.down = true;
+ mLocked.downTime = when;
+ } else {
+ mLocked.down = false;
+ }
}
- } else {
- orientation = InputReaderPolicyInterface::ROTATION_0;
- }
- /* Update saved trackball state */
+ downTime = mLocked.downTime;
+ float x = fields & Accumulator::FIELD_REL_X ? mAccumulator.relX * mXScale : 0.0f;
+ float y = fields & Accumulator::FIELD_REL_Y ? mAccumulator.relY * mYScale : 0.0f;
- uint32_t fields = mAccumulator.fields;
- bool downChanged = fields & Accumulator::FIELD_BTN_MOUSE;
-
- if (downChanged) {
- if (mAccumulator.btnMouse) {
- mDown = true;
- mDownTime = when;
+ if (downChanged) {
+ motionEventAction = mLocked.down ? AMOTION_EVENT_ACTION_DOWN : AMOTION_EVENT_ACTION_UP;
} else {
- mDown = false;
+ motionEventAction = AMOTION_EVENT_ACTION_MOVE;
}
- }
- /* Apply policy */
+ pointerCoords.x = x;
+ pointerCoords.y = y;
+ pointerCoords.pressure = mLocked.down ? 1.0f : 0.0f;
+ pointerCoords.size = 0;
+ pointerCoords.touchMajor = 0;
+ pointerCoords.touchMinor = 0;
+ pointerCoords.toolMajor = 0;
+ pointerCoords.toolMinor = 0;
+ pointerCoords.orientation = 0;
+ if (mAssociatedDisplayId >= 0 && (x != 0.0f || y != 0.0f)) {
+ // Rotate motion based on display orientation if needed.
+ // Note: getDisplayInfo is non-reentrant so we can continue holding the lock.
+ int32_t orientation;
+ if (! getPolicy()->getDisplayInfo(mAssociatedDisplayId, NULL, NULL, & orientation)) {
+ return;
+ }
+
+ float temp;
+ switch (orientation) {
+ case InputReaderPolicyInterface::ROTATION_90:
+ temp = pointerCoords.x;
+ pointerCoords.x = pointerCoords.y;
+ pointerCoords.y = - temp;
+ break;
+
+ case InputReaderPolicyInterface::ROTATION_180:
+ pointerCoords.x = - pointerCoords.x;
+ pointerCoords.y = - pointerCoords.y;
+ break;
+
+ case InputReaderPolicyInterface::ROTATION_270:
+ temp = pointerCoords.x;
+ pointerCoords.x = - pointerCoords.y;
+ pointerCoords.y = temp;
+ break;
+ }
+ }
+ } // release lock
+
+ applyPolicyAndDispatch(when, motionEventAction, & pointerCoords, downTime);
+}
+
+void TrackballInputMapper::applyPolicyAndDispatch(nsecs_t when, int32_t motionEventAction,
+ PointerCoords* pointerCoords, nsecs_t downTime) {
uint32_t policyFlags = 0;
int32_t policyActions = getPolicy()->interceptGeneric(when, policyFlags);
@@ -996,62 +1072,24 @@
return; // event dropped
}
- /* Enqueue motion event for dispatch. */
-
- int32_t motionEventAction;
- if (downChanged) {
- motionEventAction = mDown ? AMOTION_EVENT_ACTION_DOWN : AMOTION_EVENT_ACTION_UP;
- } else {
- motionEventAction = AMOTION_EVENT_ACTION_MOVE;
- }
-
- int32_t pointerId = 0;
- PointerCoords pointerCoords;
- pointerCoords.x = fields & Accumulator::FIELD_REL_X
- ? mAccumulator.relX * mXScale : 0;
- pointerCoords.y = fields & Accumulator::FIELD_REL_Y
- ? mAccumulator.relY * mYScale : 0;
- pointerCoords.pressure = 1.0f; // XXX Consider making this 1.0f if down, 0 otherwise.
- pointerCoords.size = 0;
- pointerCoords.touchMajor = 0;
- pointerCoords.touchMinor = 0;
- pointerCoords.toolMajor = 0;
- pointerCoords.toolMinor = 0;
- pointerCoords.orientation = 0;
-
- float temp;
- switch (orientation) {
- case InputReaderPolicyInterface::ROTATION_90:
- temp = pointerCoords.x;
- pointerCoords.x = pointerCoords.y;
- pointerCoords.y = - temp;
- break;
-
- case InputReaderPolicyInterface::ROTATION_180:
- pointerCoords.x = - pointerCoords.x;
- pointerCoords.y = - pointerCoords.y;
- break;
-
- case InputReaderPolicyInterface::ROTATION_270:
- temp = pointerCoords.x;
- pointerCoords.x = - pointerCoords.y;
- pointerCoords.y = temp;
- break;
- }
-
int32_t metaState = mContext->getGlobalMetaState();
+ int32_t pointerId = 0;
+
getDispatcher()->notifyMotion(when, getDeviceId(), AINPUT_SOURCE_TRACKBALL, policyFlags,
motionEventAction, metaState, AMOTION_EVENT_EDGE_FLAG_NONE,
- 1, & pointerId, & pointerCoords, mXPrecision, mYPrecision, mDownTime);
+ 1, & pointerId, pointerCoords, mXPrecision, mYPrecision, downTime);
}
// --- TouchInputMapper ---
TouchInputMapper::TouchInputMapper(InputDevice* device, int32_t associatedDisplayId) :
- InputMapper(device), mAssociatedDisplayId(associatedDisplayId),
- mSurfaceOrientation(-1), mSurfaceWidth(-1), mSurfaceHeight(-1) {
- initialize();
+ InputMapper(device), mAssociatedDisplayId(associatedDisplayId) {
+ mLocked.surfaceOrientation = -1;
+ mLocked.surfaceWidth = -1;
+ mLocked.surfaceHeight = -1;
+
+ initializeLocked();
}
TouchInputMapper::~TouchInputMapper() {
@@ -1064,26 +1102,29 @@
void TouchInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
InputMapper::populateDeviceInfo(info);
- // FIXME: Should ensure the surface information is up to date so that orientation changes
- // are noticed immediately. Unfortunately we will need to add some extra locks here
- // to prevent race conditions.
- // configureSurface();
+ { // acquire lock
+ AutoMutex _l(mLock);
- info->addMotionRange(AINPUT_MOTION_RANGE_X, mOrientedRanges.x);
- info->addMotionRange(AINPUT_MOTION_RANGE_Y, mOrientedRanges.y);
- info->addMotionRange(AINPUT_MOTION_RANGE_PRESSURE, mOrientedRanges.pressure);
- info->addMotionRange(AINPUT_MOTION_RANGE_SIZE, mOrientedRanges.size);
- info->addMotionRange(AINPUT_MOTION_RANGE_TOUCH_MAJOR, mOrientedRanges.touchMajor);
- info->addMotionRange(AINPUT_MOTION_RANGE_TOUCH_MINOR, mOrientedRanges.touchMinor);
- info->addMotionRange(AINPUT_MOTION_RANGE_TOOL_MAJOR, mOrientedRanges.toolMajor);
- info->addMotionRange(AINPUT_MOTION_RANGE_TOOL_MINOR, mOrientedRanges.toolMinor);
- info->addMotionRange(AINPUT_MOTION_RANGE_ORIENTATION, mOrientedRanges.orientation);
+ // Ensure surface information is up to date so that orientation changes are
+ // noticed immediately.
+ configureSurfaceLocked();
+
+ info->addMotionRange(AINPUT_MOTION_RANGE_X, mLocked.orientedRanges.x);
+ info->addMotionRange(AINPUT_MOTION_RANGE_Y, mLocked.orientedRanges.y);
+ info->addMotionRange(AINPUT_MOTION_RANGE_PRESSURE, mLocked.orientedRanges.pressure);
+ info->addMotionRange(AINPUT_MOTION_RANGE_SIZE, mLocked.orientedRanges.size);
+ info->addMotionRange(AINPUT_MOTION_RANGE_TOUCH_MAJOR, mLocked.orientedRanges.touchMajor);
+ info->addMotionRange(AINPUT_MOTION_RANGE_TOUCH_MINOR, mLocked.orientedRanges.touchMinor);
+ info->addMotionRange(AINPUT_MOTION_RANGE_TOOL_MAJOR, mLocked.orientedRanges.toolMajor);
+ info->addMotionRange(AINPUT_MOTION_RANGE_TOOL_MINOR, mLocked.orientedRanges.toolMinor);
+ info->addMotionRange(AINPUT_MOTION_RANGE_ORIENTATION, mLocked.orientedRanges.orientation);
+ } // release lock
}
-void TouchInputMapper::initialize() {
+void TouchInputMapper::initializeLocked() {
+ mCurrentTouch.clear();
mLastTouch.clear();
mDownTime = 0;
- mCurrentVirtualKey.down = false;
for (uint32_t i = 0; i < MAX_POINTERS; i++) {
mAveragingTouchFilter.historyStart[i] = 0;
@@ -1091,6 +1132,8 @@
}
mJumpyTouchFilter.jumpyPointsDropped = 0;
+
+ mLocked.currentVirtualKey.down = false;
}
void TouchInputMapper::configure() {
@@ -1104,48 +1147,52 @@
// Configure absolute axis information.
configureAxes();
- // Configure pressure factors.
- if (mAxes.pressure.valid) {
- mPressureOrigin = mAxes.pressure.minValue;
- mPressureScale = 1.0f / mAxes.pressure.getRange();
- } else {
- mPressureOrigin = 0;
- mPressureScale = 1.0f;
- }
+ { // acquire lock
+ AutoMutex _l(mLock);
- mOrientedRanges.pressure.min = 0.0f;
- mOrientedRanges.pressure.max = 1.0f;
- mOrientedRanges.pressure.flat = 0.0f;
- mOrientedRanges.pressure.fuzz = mPressureScale;
+ // Configure pressure factors.
+ if (mAxes.pressure.valid) {
+ mLocked.pressureOrigin = mAxes.pressure.minValue;
+ mLocked.pressureScale = 1.0f / mAxes.pressure.getRange();
+ } else {
+ mLocked.pressureOrigin = 0;
+ mLocked.pressureScale = 1.0f;
+ }
- // Configure size factors.
- if (mAxes.size.valid) {
- mSizeOrigin = mAxes.size.minValue;
- mSizeScale = 1.0f / mAxes.size.getRange();
- } else {
- mSizeOrigin = 0;
- mSizeScale = 1.0f;
- }
+ mLocked.orientedRanges.pressure.min = 0.0f;
+ mLocked.orientedRanges.pressure.max = 1.0f;
+ mLocked.orientedRanges.pressure.flat = 0.0f;
+ mLocked.orientedRanges.pressure.fuzz = mLocked.pressureScale;
- mOrientedRanges.size.min = 0.0f;
- mOrientedRanges.size.max = 1.0f;
- mOrientedRanges.size.flat = 0.0f;
- mOrientedRanges.size.fuzz = mSizeScale;
+ // Configure size factors.
+ if (mAxes.size.valid) {
+ mLocked.sizeOrigin = mAxes.size.minValue;
+ mLocked.sizeScale = 1.0f / mAxes.size.getRange();
+ } else {
+ mLocked.sizeOrigin = 0;
+ mLocked.sizeScale = 1.0f;
+ }
- // Configure orientation factors.
- if (mAxes.orientation.valid && mAxes.orientation.maxValue > 0) {
- mOrientationScale = float(M_PI_2) / mAxes.orientation.maxValue;
- } else {
- mOrientationScale = 0.0f;
- }
+ mLocked.orientedRanges.size.min = 0.0f;
+ mLocked.orientedRanges.size.max = 1.0f;
+ mLocked.orientedRanges.size.flat = 0.0f;
+ mLocked.orientedRanges.size.fuzz = mLocked.sizeScale;
- mOrientedRanges.orientation.min = - M_PI_2;
- mOrientedRanges.orientation.max = M_PI_2;
- mOrientedRanges.orientation.flat = 0;
- mOrientedRanges.orientation.fuzz = mOrientationScale;
+ // Configure orientation factors.
+ if (mAxes.orientation.valid && mAxes.orientation.maxValue > 0) {
+ mLocked.orientationScale = float(M_PI_2) / mAxes.orientation.maxValue;
+ } else {
+ mLocked.orientationScale = 0.0f;
+ }
- // Configure surface dimensions and orientation.
- configureSurface();
+ mLocked.orientedRanges.orientation.min = - M_PI_2;
+ mLocked.orientedRanges.orientation.max = M_PI_2;
+ mLocked.orientedRanges.orientation.flat = 0;
+ mLocked.orientedRanges.orientation.fuzz = mLocked.orientationScale;
+
+ // Configure surface dimensions and orientation.
+ configureSurfaceLocked();
+ } // release lock
}
void TouchInputMapper::configureAxes() {
@@ -1160,11 +1207,12 @@
mAxes.orientation.valid = false;
}
-bool TouchInputMapper::configureSurface() {
+bool TouchInputMapper::configureSurfaceLocked() {
// Update orientation and dimensions if needed.
int32_t orientation;
int32_t width, height;
if (mAssociatedDisplayId >= 0) {
+ // Note: getDisplayInfo is non-reentrant so we can continue holding the lock.
if (! getPolicy()->getDisplayInfo(mAssociatedDisplayId, & width, & height, & orientation)) {
return false;
}
@@ -1174,150 +1222,152 @@
height = mAxes.y.getRange();
}
- bool orientationChanged = mSurfaceOrientation != orientation;
+ bool orientationChanged = mLocked.surfaceOrientation != orientation;
if (orientationChanged) {
- mSurfaceOrientation = orientation;
+ mLocked.surfaceOrientation = orientation;
}
- bool sizeChanged = mSurfaceWidth != width || mSurfaceHeight != height;
+ bool sizeChanged = mLocked.surfaceWidth != width || mLocked.surfaceHeight != height;
if (sizeChanged) {
- mSurfaceWidth = width;
- mSurfaceHeight = height;
+ mLocked.surfaceWidth = width;
+ mLocked.surfaceHeight = height;
// Compute size-dependent translation and scaling factors and place virtual keys.
if (mAxes.x.valid && mAxes.y.valid) {
- mXOrigin = mAxes.x.minValue;
- mYOrigin = mAxes.y.minValue;
+ mLocked.xOrigin = mAxes.x.minValue;
+ mLocked.yOrigin = mAxes.y.minValue;
LOGI("Device configured: id=0x%x, name=%s (display size was changed)",
getDeviceId(), getDeviceName().string());
- mXScale = float(width) / mAxes.x.getRange();
- mYScale = float(height) / mAxes.y.getRange();
- mXPrecision = 1.0f / mXScale;
- mYPrecision = 1.0f / mYScale;
+ mLocked.xScale = float(width) / mAxes.x.getRange();
+ mLocked.yScale = float(height) / mAxes.y.getRange();
+ mLocked.xPrecision = 1.0f / mLocked.xScale;
+ mLocked.yPrecision = 1.0f / mLocked.yScale;
- configureVirtualKeys();
+ configureVirtualKeysLocked();
} else {
- mXOrigin = 0;
- mYOrigin = 0;
- mXScale = 1.0f;
- mYScale = 1.0f;
- mXPrecision = 1.0f;
- mYPrecision = 1.0f;
+ mLocked.xOrigin = 0;
+ mLocked.yOrigin = 0;
+ mLocked.xScale = 1.0f;
+ mLocked.yScale = 1.0f;
+ mLocked.xPrecision = 1.0f;
+ mLocked.yPrecision = 1.0f;
}
// Configure touch and tool area ranges.
float diagonal = sqrt(float(width * width + height * height));
- float diagonalFuzz = sqrt(mXScale * mXScale + mYScale * mYScale);
+ float diagonalFuzz = sqrt(mLocked.xScale * mLocked.xScale
+ + mLocked.yScale * mLocked.yScale);
- mOrientedRanges.touchMajor.min = 0.0f;
- mOrientedRanges.touchMajor.max = diagonal;
- mOrientedRanges.touchMajor.flat = 0.0f;
- mOrientedRanges.touchMajor.fuzz = diagonalFuzz;
- mOrientedRanges.touchMinor = mOrientedRanges.touchMajor;
+ InputDeviceInfo::MotionRange area;
+ area.min = 0.0f;
+ area.max = diagonal;
+ area.flat = 0.0f;
+ area.fuzz = diagonalFuzz;
- mOrientedRanges.toolMinor = mOrientedRanges.toolMajor = mOrientedRanges.touchMajor;
+ mLocked.orientedRanges.touchMajor = area;
+ mLocked.orientedRanges.touchMinor = area;
+
+ mLocked.orientedRanges.toolMajor = area;
+ mLocked.orientedRanges.toolMinor = area;
}
if (orientationChanged || sizeChanged) {
// Compute oriented surface dimensions, precision, and scales.
float orientedXScale, orientedYScale;
- switch (mSurfaceOrientation) {
+ switch (mLocked.surfaceOrientation) {
case InputReaderPolicyInterface::ROTATION_90:
case InputReaderPolicyInterface::ROTATION_270:
- mOrientedSurfaceWidth = mSurfaceHeight;
- mOrientedSurfaceHeight = mSurfaceWidth;
- mOrientedXPrecision = mYPrecision;
- mOrientedYPrecision = mXPrecision;
- orientedXScale = mYScale;
- orientedYScale = mXScale;
+ mLocked.orientedSurfaceWidth = mLocked.surfaceHeight;
+ mLocked.orientedSurfaceHeight = mLocked.surfaceWidth;
+ mLocked.orientedXPrecision = mLocked.yPrecision;
+ mLocked.orientedYPrecision = mLocked.xPrecision;
+ orientedXScale = mLocked.yScale;
+ orientedYScale = mLocked.xScale;
break;
default:
- mOrientedSurfaceWidth = mSurfaceWidth;
- mOrientedSurfaceHeight = mSurfaceHeight;
- mOrientedXPrecision = mXPrecision;
- mOrientedYPrecision = mYPrecision;
- orientedXScale = mXScale;
- orientedYScale = mYScale;
+ mLocked.orientedSurfaceWidth = mLocked.surfaceWidth;
+ mLocked.orientedSurfaceHeight = mLocked.surfaceHeight;
+ mLocked.orientedXPrecision = mLocked.xPrecision;
+ mLocked.orientedYPrecision = mLocked.yPrecision;
+ orientedXScale = mLocked.xScale;
+ orientedYScale = mLocked.yScale;
break;
}
// Configure position ranges.
- mOrientedRanges.x.min = 0;
- mOrientedRanges.x.max = mOrientedSurfaceWidth;
- mOrientedRanges.x.flat = 0;
- mOrientedRanges.x.fuzz = orientedXScale;
+ mLocked.orientedRanges.x.min = 0;
+ mLocked.orientedRanges.x.max = mLocked.orientedSurfaceWidth;
+ mLocked.orientedRanges.x.flat = 0;
+ mLocked.orientedRanges.x.fuzz = orientedXScale;
- mOrientedRanges.y.min = 0;
- mOrientedRanges.y.max = mOrientedSurfaceHeight;
- mOrientedRanges.y.flat = 0;
- mOrientedRanges.y.fuzz = orientedYScale;
+ mLocked.orientedRanges.y.min = 0;
+ mLocked.orientedRanges.y.max = mLocked.orientedSurfaceHeight;
+ mLocked.orientedRanges.y.flat = 0;
+ mLocked.orientedRanges.y.fuzz = orientedYScale;
}
return true;
}
-void TouchInputMapper::configureVirtualKeys() {
+void TouchInputMapper::configureVirtualKeysLocked() {
assert(mAxes.x.valid && mAxes.y.valid);
+ // Note: getVirtualKeyDefinitions is non-reentrant so we can continue holding the lock.
Vector<InputReaderPolicyInterface::VirtualKeyDefinition> virtualKeyDefinitions;
getPolicy()->getVirtualKeyDefinitions(getDeviceName(), virtualKeyDefinitions);
- { // acquire virtual key lock
- AutoMutex _l(mVirtualKeyLock);
+ mLocked.virtualKeys.clear();
- mVirtualKeys.clear();
+ if (virtualKeyDefinitions.size() == 0) {
+ return;
+ }
- if (virtualKeyDefinitions.size() == 0) {
- return;
+ mLocked.virtualKeys.setCapacity(virtualKeyDefinitions.size());
+
+ int32_t touchScreenLeft = mAxes.x.minValue;
+ int32_t touchScreenTop = mAxes.y.minValue;
+ int32_t touchScreenWidth = mAxes.x.getRange();
+ int32_t touchScreenHeight = mAxes.y.getRange();
+
+ for (size_t i = 0; i < virtualKeyDefinitions.size(); i++) {
+ const InputReaderPolicyInterface::VirtualKeyDefinition& virtualKeyDefinition =
+ virtualKeyDefinitions[i];
+
+ mLocked.virtualKeys.add();
+ VirtualKey& virtualKey = mLocked.virtualKeys.editTop();
+
+ virtualKey.scanCode = virtualKeyDefinition.scanCode;
+ int32_t keyCode;
+ uint32_t flags;
+ if (getEventHub()->scancodeToKeycode(getDeviceId(), virtualKey.scanCode,
+ & keyCode, & flags)) {
+ LOGW(" VirtualKey %d: could not obtain key code, ignoring", virtualKey.scanCode);
+ mLocked.virtualKeys.pop(); // drop the key
+ continue;
}
- mVirtualKeys.setCapacity(virtualKeyDefinitions.size());
+ virtualKey.keyCode = keyCode;
+ virtualKey.flags = flags;
- int32_t touchScreenLeft = mAxes.x.minValue;
- int32_t touchScreenTop = mAxes.y.minValue;
- int32_t touchScreenWidth = mAxes.x.getRange();
- int32_t touchScreenHeight = mAxes.y.getRange();
+ // convert the key definition's display coordinates into touch coordinates for a hit box
+ int32_t halfWidth = virtualKeyDefinition.width / 2;
+ int32_t halfHeight = virtualKeyDefinition.height / 2;
- for (size_t i = 0; i < virtualKeyDefinitions.size(); i++) {
- const InputReaderPolicyInterface::VirtualKeyDefinition& virtualKeyDefinition =
- virtualKeyDefinitions[i];
+ virtualKey.hitLeft = (virtualKeyDefinition.centerX - halfWidth)
+ * touchScreenWidth / mLocked.surfaceWidth + touchScreenLeft;
+ virtualKey.hitRight= (virtualKeyDefinition.centerX + halfWidth)
+ * touchScreenWidth / mLocked.surfaceWidth + touchScreenLeft;
+ virtualKey.hitTop = (virtualKeyDefinition.centerY - halfHeight)
+ * touchScreenHeight / mLocked.surfaceHeight + touchScreenTop;
+ virtualKey.hitBottom = (virtualKeyDefinition.centerY + halfHeight)
+ * touchScreenHeight / mLocked.surfaceHeight + touchScreenTop;
- mVirtualKeys.add();
- VirtualKey& virtualKey = mVirtualKeys.editTop();
-
- virtualKey.scanCode = virtualKeyDefinition.scanCode;
- int32_t keyCode;
- uint32_t flags;
- if (getEventHub()->scancodeToKeycode(getDeviceId(), virtualKey.scanCode,
- & keyCode, & flags)) {
- LOGW(" VirtualKey %d: could not obtain key code, ignoring", virtualKey.scanCode);
- mVirtualKeys.pop(); // drop the key
- continue;
- }
-
- virtualKey.keyCode = keyCode;
- virtualKey.flags = flags;
-
- // convert the key definition's display coordinates into touch coordinates for a hit box
- int32_t halfWidth = virtualKeyDefinition.width / 2;
- int32_t halfHeight = virtualKeyDefinition.height / 2;
-
- virtualKey.hitLeft = (virtualKeyDefinition.centerX - halfWidth)
- * touchScreenWidth / mSurfaceWidth + touchScreenLeft;
- virtualKey.hitRight= (virtualKeyDefinition.centerX + halfWidth)
- * touchScreenWidth / mSurfaceWidth + touchScreenLeft;
- virtualKey.hitTop = (virtualKeyDefinition.centerY - halfHeight)
- * touchScreenHeight / mSurfaceHeight + touchScreenTop;
- virtualKey.hitBottom = (virtualKeyDefinition.centerY + halfHeight)
- * touchScreenHeight / mSurfaceHeight + touchScreenTop;
-
- LOGI(" VirtualKey %d: keyCode=%d hitLeft=%d hitRight=%d hitTop=%d hitBottom=%d",
- virtualKey.scanCode, virtualKey.keyCode,
- virtualKey.hitLeft, virtualKey.hitRight, virtualKey.hitTop, virtualKey.hitBottom);
- }
- } // release virtual key lock
+ LOGI(" VirtualKey %d: keyCode=%d hitLeft=%d hitRight=%d hitTop=%d hitBottom=%d",
+ virtualKey.scanCode, virtualKey.keyCode,
+ virtualKey.hitLeft, virtualKey.hitRight, virtualKey.hitTop, virtualKey.hitBottom);
+ }
}
void TouchInputMapper::reset() {
@@ -1329,20 +1379,16 @@
syncTouch(when, true);
}
- InputMapper::reset();
+ { // acquire lock
+ AutoMutex _l(mLock);
+ initializeLocked();
+ } // release lock
- // Reinitialize.
- initialize();
+ InputMapper::reset();
}
void TouchInputMapper::syncTouch(nsecs_t when, bool havePointerIds) {
- /* Refresh associated display information and update our size configuration if needed. */
-
- if (! configureSurface()) {
- return;
- }
-
- /* Apply policy */
+ // Apply generic policy actions.
uint32_t policyFlags = 0;
int32_t policyActions = getPolicy()->interceptGeneric(when, policyFlags);
@@ -1352,7 +1398,7 @@
return; // event dropped
}
- /* Preprocess pointer data */
+ // Preprocess pointer data.
if (mParameters.useBadTouchFilter) {
if (applyBadTouchFilter()) {
@@ -1381,14 +1427,14 @@
savedTouch = & mCurrentTouch;
}
- /* Process touches and virtual keys */
+ // Process touches and virtual keys.
TouchResult touchResult = consumeOffScreenTouches(when, policyFlags);
if (touchResult == DISPATCH_TOUCH) {
dispatchTouches(when, policyFlags);
}
- /* Copy current touch to last touch in preparation for the next cycle. */
+ // Copy current touch to last touch in preparation for the next cycle.
if (touchResult == DROP_STROKE) {
mLastTouch.clear();
@@ -1403,13 +1449,19 @@
int32_t keyCode, scanCode, downTime;
TouchResult touchResult;
- { // acquire virtual key lock
- AutoMutex _l(mVirtualKeyLock);
+ { // acquire lock
+ AutoMutex _l(mLock);
- if (mCurrentVirtualKey.down) {
+ // Update surface size and orientation, including virtual key positions.
+ if (! configureSurfaceLocked()) {
+ return DROP_STROKE;
+ }
+
+ // Check for virtual key press.
+ if (mLocked.currentVirtualKey.down) {
if (mCurrentTouch.pointerCount == 0) {
// Pointer went up while virtual key was down.
- mCurrentVirtualKey.down = false;
+ mLocked.currentVirtualKey.down = false;
#if DEBUG_VIRTUAL_KEYS
LOGD("VirtualKeys: Generating key up: keyCode=%d, scanCode=%d",
mCurrentVirtualKey.keyCode, mCurrentVirtualKey.scanCode);
@@ -1423,8 +1475,8 @@
if (mCurrentTouch.pointerCount == 1) {
int32_t x = mCurrentTouch.pointers[0].x;
int32_t y = mCurrentTouch.pointers[0].y;
- const VirtualKey* virtualKey = findVirtualKeyHitLvk(x, y);
- if (virtualKey && virtualKey->keyCode == mCurrentVirtualKey.keyCode) {
+ const VirtualKey* virtualKey = findVirtualKeyHitLocked(x, y);
+ if (virtualKey && virtualKey->keyCode == mLocked.currentVirtualKey.keyCode) {
// Pointer is still within the space of the virtual key.
return SKIP_TOUCH;
}
@@ -1434,7 +1486,7 @@
// Send key cancellation and drop the stroke so subsequent motions will be
// considered fresh downs. This is useful when the user swipes away from the
// virtual key area into the main display surface.
- mCurrentVirtualKey.down = false;
+ mLocked.currentVirtualKey.down = false;
#if DEBUG_VIRTUAL_KEYS
LOGD("VirtualKeys: Canceling key: keyCode=%d, scanCode=%d",
mCurrentVirtualKey.keyCode, mCurrentVirtualKey.scanCode);
@@ -1449,16 +1501,16 @@
// Pointer just went down. Handle off-screen touches, if needed.
int32_t x = mCurrentTouch.pointers[0].x;
int32_t y = mCurrentTouch.pointers[0].y;
- if (! isPointInsideSurface(x, y)) {
+ if (! isPointInsideSurfaceLocked(x, y)) {
// If exactly one pointer went down, check for virtual key hit.
// Otherwise we will drop the entire stroke.
if (mCurrentTouch.pointerCount == 1) {
- const VirtualKey* virtualKey = findVirtualKeyHitLvk(x, y);
+ const VirtualKey* virtualKey = findVirtualKeyHitLocked(x, y);
if (virtualKey) {
- mCurrentVirtualKey.down = true;
- mCurrentVirtualKey.downTime = when;
- mCurrentVirtualKey.keyCode = virtualKey->keyCode;
- mCurrentVirtualKey.scanCode = virtualKey->scanCode;
+ mLocked.currentVirtualKey.down = true;
+ mLocked.currentVirtualKey.downTime = when;
+ mLocked.currentVirtualKey.keyCode = virtualKey->keyCode;
+ mLocked.currentVirtualKey.scanCode = virtualKey->scanCode;
#if DEBUG_VIRTUAL_KEYS
LOGD("VirtualKeys: Generating key down: keyCode=%d, scanCode=%d",
mCurrentVirtualKey.keyCode, mCurrentVirtualKey.scanCode);
@@ -1478,12 +1530,20 @@
DispatchVirtualKey:
// Collect remaining state needed to dispatch virtual key.
- keyCode = mCurrentVirtualKey.keyCode;
- scanCode = mCurrentVirtualKey.scanCode;
- downTime = mCurrentVirtualKey.downTime;
- } // release virtual key lock
+ keyCode = mLocked.currentVirtualKey.keyCode;
+ scanCode = mLocked.currentVirtualKey.scanCode;
+ downTime = mLocked.currentVirtualKey.downTime;
+ } // release lock
// Dispatch virtual key.
+ applyPolicyAndDispatchVirtualKey(when, policyFlags, keyEventAction, keyEventFlags,
+ keyCode, scanCode, downTime);
+ return touchResult;
+}
+
+void TouchInputMapper::applyPolicyAndDispatchVirtualKey(nsecs_t when, uint32_t policyFlags,
+ int32_t keyEventAction, int32_t keyEventFlags,
+ int32_t keyCode, int32_t scanCode, nsecs_t downTime) {
int32_t metaState = mContext->getGlobalMetaState();
if (keyEventAction == AKEY_EVENT_ACTION_DOWN) {
@@ -1497,7 +1557,6 @@
getDispatcher()->notifyKey(when, getDeviceId(), AINPUT_SOURCE_KEYBOARD, policyFlags,
keyEventAction, keyEventFlags, keyCode, scanCode, metaState, downTime);
}
- return touchResult;
}
void TouchInputMapper::dispatchTouches(nsecs_t when, uint32_t policyFlags) {
@@ -1566,107 +1625,118 @@
uint32_t pointerCount = 0;
int32_t pointerIds[MAX_POINTERS];
PointerCoords pointerCoords[MAX_POINTERS];
-
- // Walk through the the active pointers and map touch screen coordinates (TouchData) into
- // display coordinates (PointerCoords) and adjust for display orientation.
- while (! idBits.isEmpty()) {
- uint32_t id = idBits.firstMarkedBit();
- idBits.clearBit(id);
- uint32_t index = touch->idToIndex[id];
-
- float x = float(touch->pointers[index].x - mXOrigin) * mXScale;
- float y = float(touch->pointers[index].y - mYOrigin) * mYScale;
- float pressure = float(touch->pointers[index].pressure - mPressureOrigin) * mPressureScale;
- float size = float(touch->pointers[index].size - mSizeOrigin) * mSizeScale;
-
- float orientation = float(touch->pointers[index].orientation) * mOrientationScale;
-
- float touchMajor, touchMinor, toolMajor, toolMinor;
- if (abs(orientation) <= M_PI_4) {
- // Nominally vertical orientation: scale major axis by Y, and scale minor axis by X.
- touchMajor = float(touch->pointers[index].touchMajor) * mYScale;
- touchMinor = float(touch->pointers[index].touchMinor) * mXScale;
- toolMajor = float(touch->pointers[index].toolMajor) * mYScale;
- toolMinor = float(touch->pointers[index].toolMinor) * mXScale;
- } else {
- // Nominally horizontal orientation: scale major axis by X, and scale minor axis by Y.
- touchMajor = float(touch->pointers[index].touchMajor) * mXScale;
- touchMinor = float(touch->pointers[index].touchMinor) * mYScale;
- toolMajor = float(touch->pointers[index].toolMajor) * mXScale;
- toolMinor = float(touch->pointers[index].toolMinor) * mYScale;
- }
-
- switch (mSurfaceOrientation) {
- case InputReaderPolicyInterface::ROTATION_90: {
- float xTemp = x;
- x = y;
- y = mSurfaceWidth - xTemp;
- orientation -= M_PI_2;
- if (orientation < - M_PI_2) {
- orientation += M_PI;
- }
- break;
- }
- case InputReaderPolicyInterface::ROTATION_180: {
- x = mSurfaceWidth - x;
- y = mSurfaceHeight - y;
- orientation = - orientation;
- break;
- }
- case InputReaderPolicyInterface::ROTATION_270: {
- float xTemp = x;
- x = mSurfaceHeight - y;
- y = xTemp;
- orientation += M_PI_2;
- if (orientation > M_PI_2) {
- orientation -= M_PI;
- }
- break;
- }
- }
-
- pointerIds[pointerCount] = int32_t(id);
-
- pointerCoords[pointerCount].x = x;
- pointerCoords[pointerCount].y = y;
- pointerCoords[pointerCount].pressure = pressure;
- pointerCoords[pointerCount].size = size;
- pointerCoords[pointerCount].touchMajor = touchMajor;
- pointerCoords[pointerCount].touchMinor = touchMinor;
- pointerCoords[pointerCount].toolMajor = toolMajor;
- pointerCoords[pointerCount].toolMinor = toolMinor;
- pointerCoords[pointerCount].orientation = orientation;
-
- if (id == changedId) {
- motionEventAction |= pointerCount << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
- }
-
- pointerCount += 1;
- }
-
- // Check edge flags by looking only at the first pointer since the flags are
- // global to the event.
int32_t motionEventEdgeFlags = 0;
- if (motionEventAction == AMOTION_EVENT_ACTION_DOWN) {
- if (pointerCoords[0].x <= 0) {
- motionEventEdgeFlags |= AMOTION_EVENT_EDGE_FLAG_LEFT;
- } else if (pointerCoords[0].x >= mOrientedSurfaceWidth) {
- motionEventEdgeFlags |= AMOTION_EVENT_EDGE_FLAG_RIGHT;
+ float xPrecision, yPrecision;
+
+ { // acquire lock
+ AutoMutex _l(mLock);
+
+ // Walk through the the active pointers and map touch screen coordinates (TouchData) into
+ // display coordinates (PointerCoords) and adjust for display orientation.
+ while (! idBits.isEmpty()) {
+ uint32_t id = idBits.firstMarkedBit();
+ idBits.clearBit(id);
+ uint32_t index = touch->idToIndex[id];
+
+ float x = float(touch->pointers[index].x - mLocked.xOrigin) * mLocked.xScale;
+ float y = float(touch->pointers[index].y - mLocked.yOrigin) * mLocked.yScale;
+ float pressure = float(touch->pointers[index].pressure - mLocked.pressureOrigin)
+ * mLocked.pressureScale;
+ float size = float(touch->pointers[index].size - mLocked.sizeOrigin)
+ * mLocked.sizeScale;
+
+ float orientation = float(touch->pointers[index].orientation)
+ * mLocked.orientationScale;
+
+ float touchMajor, touchMinor, toolMajor, toolMinor;
+ if (abs(orientation) <= M_PI_4) {
+ // Nominally vertical orientation: scale major axis by Y, and scale minor axis by X.
+ touchMajor = float(touch->pointers[index].touchMajor) * mLocked.yScale;
+ touchMinor = float(touch->pointers[index].touchMinor) * mLocked.xScale;
+ toolMajor = float(touch->pointers[index].toolMajor) * mLocked.yScale;
+ toolMinor = float(touch->pointers[index].toolMinor) * mLocked.xScale;
+ } else {
+ // Nominally horizontal orientation: scale major axis by X, and scale minor axis by Y.
+ touchMajor = float(touch->pointers[index].touchMajor) * mLocked.xScale;
+ touchMinor = float(touch->pointers[index].touchMinor) * mLocked.yScale;
+ toolMajor = float(touch->pointers[index].toolMajor) * mLocked.xScale;
+ toolMinor = float(touch->pointers[index].toolMinor) * mLocked.yScale;
+ }
+
+ switch (mLocked.surfaceOrientation) {
+ case InputReaderPolicyInterface::ROTATION_90: {
+ float xTemp = x;
+ x = y;
+ y = mLocked.surfaceWidth - xTemp;
+ orientation -= M_PI_2;
+ if (orientation < - M_PI_2) {
+ orientation += M_PI;
+ }
+ break;
+ }
+ case InputReaderPolicyInterface::ROTATION_180: {
+ x = mLocked.surfaceWidth - x;
+ y = mLocked.surfaceHeight - y;
+ orientation = - orientation;
+ break;
+ }
+ case InputReaderPolicyInterface::ROTATION_270: {
+ float xTemp = x;
+ x = mLocked.surfaceHeight - y;
+ y = xTemp;
+ orientation += M_PI_2;
+ if (orientation > M_PI_2) {
+ orientation -= M_PI;
+ }
+ break;
+ }
+ }
+
+ pointerIds[pointerCount] = int32_t(id);
+
+ pointerCoords[pointerCount].x = x;
+ pointerCoords[pointerCount].y = y;
+ pointerCoords[pointerCount].pressure = pressure;
+ pointerCoords[pointerCount].size = size;
+ pointerCoords[pointerCount].touchMajor = touchMajor;
+ pointerCoords[pointerCount].touchMinor = touchMinor;
+ pointerCoords[pointerCount].toolMajor = toolMajor;
+ pointerCoords[pointerCount].toolMinor = toolMinor;
+ pointerCoords[pointerCount].orientation = orientation;
+
+ if (id == changedId) {
+ motionEventAction |= pointerCount << AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
+ }
+
+ pointerCount += 1;
}
- if (pointerCoords[0].y <= 0) {
- motionEventEdgeFlags |= AMOTION_EVENT_EDGE_FLAG_TOP;
- } else if (pointerCoords[0].y >= mOrientedSurfaceHeight) {
- motionEventEdgeFlags |= AMOTION_EVENT_EDGE_FLAG_BOTTOM;
+
+ // Check edge flags by looking only at the first pointer since the flags are
+ // global to the event.
+ if (motionEventAction == AMOTION_EVENT_ACTION_DOWN) {
+ if (pointerCoords[0].x <= 0) {
+ motionEventEdgeFlags |= AMOTION_EVENT_EDGE_FLAG_LEFT;
+ } else if (pointerCoords[0].x >= mLocked.orientedSurfaceWidth) {
+ motionEventEdgeFlags |= AMOTION_EVENT_EDGE_FLAG_RIGHT;
+ }
+ if (pointerCoords[0].y <= 0) {
+ motionEventEdgeFlags |= AMOTION_EVENT_EDGE_FLAG_TOP;
+ } else if (pointerCoords[0].y >= mLocked.orientedSurfaceHeight) {
+ motionEventEdgeFlags |= AMOTION_EVENT_EDGE_FLAG_BOTTOM;
+ }
}
- }
+
+ xPrecision = mLocked.orientedXPrecision;
+ yPrecision = mLocked.orientedYPrecision;
+ } // release lock
getDispatcher()->notifyMotion(when, getDeviceId(), AINPUT_SOURCE_TOUCHSCREEN, policyFlags,
motionEventAction, getContext()->getGlobalMetaState(), motionEventEdgeFlags,
pointerCount, pointerIds, pointerCoords,
- mOrientedXPrecision, mOrientedYPrecision, mDownTime);
+ xPrecision, yPrecision, mDownTime);
}
-bool TouchInputMapper::isPointInsideSurface(int32_t x, int32_t y) {
+bool TouchInputMapper::isPointInsideSurfaceLocked(int32_t x, int32_t y) {
if (mAxes.x.valid && mAxes.y.valid) {
return x >= mAxes.x.minValue && x <= mAxes.x.maxValue
&& y >= mAxes.y.minValue && y <= mAxes.y.maxValue;
@@ -1674,9 +1744,11 @@
return true;
}
-const TouchInputMapper::VirtualKey* TouchInputMapper::findVirtualKeyHitLvk(int32_t x, int32_t y) {
- for (size_t i = 0; i < mVirtualKeys.size(); i++) {
- const VirtualKey& virtualKey = mVirtualKeys[i];
+const TouchInputMapper::VirtualKey* TouchInputMapper::findVirtualKeyHitLocked(
+ int32_t x, int32_t y) {
+ size_t numVirtualKeys = mLocked.virtualKeys.size();
+ for (size_t i = 0; i < numVirtualKeys; i++) {
+ const VirtualKey& virtualKey = mLocked.virtualKeys[i];
#if DEBUG_VIRTUAL_KEYS
LOGD("VirtualKeys: Hit test (%d, %d): keyCode=%d, scanCode=%d, "
@@ -2224,50 +2296,53 @@
}
int32_t TouchInputMapper::getKeyCodeState(uint32_t sourceMask, int32_t keyCode) {
- { // acquire virtual key lock
- AutoMutex _l(mVirtualKeyLock);
+ { // acquire lock
+ AutoMutex _l(mLock);
- if (mCurrentVirtualKey.down && mCurrentVirtualKey.keyCode == keyCode) {
+ if (mLocked.currentVirtualKey.down && mLocked.currentVirtualKey.keyCode == keyCode) {
return AKEY_STATE_VIRTUAL;
}
- for (size_t i = 0; i < mVirtualKeys.size(); i++) {
- const VirtualKey& virtualKey = mVirtualKeys[i];
+ size_t numVirtualKeys = mLocked.virtualKeys.size();
+ for (size_t i = 0; i < numVirtualKeys; i++) {
+ const VirtualKey& virtualKey = mLocked.virtualKeys[i];
if (virtualKey.keyCode == keyCode) {
return AKEY_STATE_UP;
}
}
- } // release virtual key lock
+ } // release lock
return AKEY_STATE_UNKNOWN;
}
int32_t TouchInputMapper::getScanCodeState(uint32_t sourceMask, int32_t scanCode) {
- { // acquire virtual key lock
- AutoMutex _l(mVirtualKeyLock);
+ { // acquire lock
+ AutoMutex _l(mLock);
- if (mCurrentVirtualKey.down && mCurrentVirtualKey.scanCode == scanCode) {
+ if (mLocked.currentVirtualKey.down && mLocked.currentVirtualKey.scanCode == scanCode) {
return AKEY_STATE_VIRTUAL;
}
- for (size_t i = 0; i < mVirtualKeys.size(); i++) {
- const VirtualKey& virtualKey = mVirtualKeys[i];
+ size_t numVirtualKeys = mLocked.virtualKeys.size();
+ for (size_t i = 0; i < numVirtualKeys; i++) {
+ const VirtualKey& virtualKey = mLocked.virtualKeys[i];
if (virtualKey.scanCode == scanCode) {
return AKEY_STATE_UP;
}
}
- } // release virtual key lock
+ } // release lock
return AKEY_STATE_UNKNOWN;
}
bool TouchInputMapper::markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes,
const int32_t* keyCodes, uint8_t* outFlags) {
- { // acquire virtual key lock
- AutoMutex _l(mVirtualKeyLock);
+ { // acquire lock
+ AutoMutex _l(mLock);
- for (size_t i = 0; i < mVirtualKeys.size(); i++) {
- const VirtualKey& virtualKey = mVirtualKeys[i];
+ size_t numVirtualKeys = mLocked.virtualKeys.size();
+ for (size_t i = 0; i < numVirtualKeys; i++) {
+ const VirtualKey& virtualKey = mLocked.virtualKeys[i];
for (size_t i = 0; i < numCodes; i++) {
if (virtualKey.keyCode == keyCodes[i]) {
@@ -2275,7 +2350,7 @@
}
}
}
- } // release virtual key lock
+ } // release lock
return true;
}
@@ -2304,7 +2379,6 @@
void SingleTouchInputMapper::reset() {
TouchInputMapper::reset();
- // Reinitialize.
initialize();
}
@@ -2436,7 +2510,6 @@
void MultiTouchInputMapper::reset() {
TouchInputMapper::reset();
- // Reinitialize.
initialize();
}
diff --git a/media/java/android/media/Equalizer.java b/media/java/android/media/Equalizer.java
index 21c37bb..b062b64 100644
--- a/media/java/android/media/Equalizer.java
+++ b/media/java/android/media/Equalizer.java
@@ -182,9 +182,9 @@
}
int[] param = new int[1];
param[0] = PARAM_NUM_BANDS;
- short[] value = new short[1];
- checkStatus(getParameter(param, value));
- mNumBands = value[0];
+ short[] result = new short[1];
+ checkStatus(getParameter(param, result));
+ mNumBands = result[0];
return mNumBands;
}
@@ -199,16 +199,8 @@
*/
public short[] getBandLevelRange()
throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException {
- int[] param = new int[1];
- int[] value = new int[2];
- param[0] = PARAM_LEVEL_RANGE;
- checkStatus(getParameter(param, value));
-
short[] result = new short[2];
-
- result[0] = (short)value[0];
- result[1] = (short)value[1];
-
+ checkStatus(getParameter(PARAM_LEVEL_RANGE, result));
return result;
}
@@ -222,14 +214,14 @@
* @throws IllegalArgumentException
* @throws UnsupportedOperationException
*/
- public void setBandLevel(int band, short level)
+ public void setBandLevel(short band, short level)
throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException {
int[] param = new int[2];
- int[] value = new int[1];
+ short[] value = new short[1];
param[0] = PARAM_BAND_LEVEL;
- param[1] = band;
- value[0] = (int)level;
+ param[1] = (int)band;
+ value[0] = level;
checkStatus(setParameter(param, value));
}
@@ -242,16 +234,16 @@
* @throws IllegalArgumentException
* @throws UnsupportedOperationException
*/
- public short getBandLevel(int band)
+ public short getBandLevel(short band)
throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException {
int[] param = new int[2];
- int[] result = new int[1];
+ short[] result = new short[1];
param[0] = PARAM_BAND_LEVEL;
- param[1] = band;
+ param[1] = (int)band;
checkStatus(getParameter(param, result));
- return (short)result[0];
+ return result[0];
}
@@ -264,13 +256,13 @@
* @throws IllegalArgumentException
* @throws UnsupportedOperationException
*/
- public int getCenterFreq(int band)
+ public int getCenterFreq(short band)
throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException {
int[] param = new int[2];
int[] result = new int[1];
param[0] = PARAM_CENTER_FREQ;
- param[1] = band;
+ param[1] = (int)band;
checkStatus(getParameter(param, result));
return result[0];
@@ -286,12 +278,12 @@
* @throws IllegalArgumentException
* @throws UnsupportedOperationException
*/
- public int[] getBandFreqRange(int band)
+ public int[] getBandFreqRange(short band)
throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException {
int[] param = new int[2];
int[] result = new int[2];
param[0] = PARAM_BAND_FREQ_RANGE;
- param[1] = band;
+ param[1] = (int)band;
checkStatus(getParameter(param, result));
return result;
@@ -305,10 +297,10 @@
* @throws IllegalArgumentException
* @throws UnsupportedOperationException
*/
- public int getBand(int frequency)
+ public short getBand(int frequency)
throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException {
int[] param = new int[2];
- int[] result = new int[1];
+ short[] result = new short[1];
param[0] = PARAM_GET_BAND;
param[1] = frequency;
@@ -326,11 +318,9 @@
*/
public short getCurrentPreset()
throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException {
- int[] param = new int[1];
- param[0] = PARAM_CURRENT_PRESET;
- short[] value = new short[1];
- checkStatus(getParameter(param, value));
- return value[0];
+ short[] result = new short[1];
+ checkStatus(getParameter(PARAM_CURRENT_PRESET, result));
+ return result[0];
}
/**
@@ -356,11 +346,9 @@
*/
public short getNumberOfPresets()
throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException {
- int[] param = new int[1];
- param[0] = PARAM_GET_NUM_OF_PRESETS;
- short[] value = new short[1];
- checkStatus(getParameter(param, value));
- return value[0];
+ short[] result = new short[1];
+ checkStatus(getParameter(PARAM_GET_NUM_OF_PRESETS, result));
+ return result[0];
}
/**
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
index 4c3ebca..a70bdff 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
@@ -1848,6 +1848,8 @@
case EQ_PARAM_NUM_BANDS:
case EQ_PARAM_CUR_PRESET:
case EQ_PARAM_GET_NUM_OF_PRESETS:
+ case EQ_PARAM_BAND_LEVEL:
+ case EQ_PARAM_GET_BAND:
if (*pValueSize < sizeof(int16_t)) {
LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1 %d", *pValueSize);
return -EINVAL;
@@ -1856,6 +1858,13 @@
break;
case EQ_PARAM_LEVEL_RANGE:
+ if (*pValueSize < 2 * sizeof(int16_t)) {
+ LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 2 %d", *pValueSize);
+ return -EINVAL;
+ }
+ *pValueSize = 2 * sizeof(int16_t);
+ break;
+
case EQ_PARAM_BAND_FREQ_RANGE:
if (*pValueSize < 2 * sizeof(int32_t)) {
LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 2 %d", *pValueSize);
@@ -1863,8 +1872,7 @@
}
*pValueSize = 2 * sizeof(int32_t);
break;
- case EQ_PARAM_BAND_LEVEL:
- case EQ_PARAM_GET_BAND:
+
case EQ_PARAM_CENTER_FREQ:
if (*pValueSize < sizeof(int32_t)) {
LOGV("\tLVM_ERROR : Equalizer_getParameter() invalid pValueSize 1 %d", *pValueSize);
@@ -1891,13 +1899,13 @@
switch (param) {
case EQ_PARAM_NUM_BANDS:
- *(int16_t *)pValue = FIVEBAND_NUMBANDS;
+ *(uint16_t *)pValue = (uint16_t)FIVEBAND_NUMBANDS;
//LOGV("\tEqualizer_getParameter() EQ_PARAM_NUM_BANDS %d", *(int16_t *)pValue);
break;
case EQ_PARAM_LEVEL_RANGE:
- *(int32_t *)pValue = -1500;
- *((int32_t *)pValue + 1) = 1500;
+ *(int16_t *)pValue = -1500;
+ *((int16_t *)pValue + 1) = 1500;
//LOGV("\tEqualizer_getParameter() EQ_PARAM_LEVEL_RANGE min %d, max %d",
// *(int32_t *)pValue, *((int32_t *)pValue + 1));
break;
@@ -1908,7 +1916,7 @@
status = -EINVAL;
break;
}
- *(int32_t *)pValue = EqualizerGetBandLevel(pContext, param2);
+ *(int16_t *)pValue = (int16_t)EqualizerGetBandLevel(pContext, param2);
//LOGV("\tEqualizer_getParameter() EQ_PARAM_BAND_LEVEL band %d, level %d",
// param2, *(int32_t *)pValue);
break;
@@ -1937,18 +1945,18 @@
case EQ_PARAM_GET_BAND:
param2 = *pParam;
- *(int32_t *)pValue = EqualizerGetBand(pContext, param2);
+ *(uint16_t *)pValue = (uint16_t)EqualizerGetBand(pContext, param2);
//LOGV("\tEqualizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d",
// param2, *(int32_t *)pValue);
break;
case EQ_PARAM_CUR_PRESET:
- *(int16_t *)pValue = EqualizerGetPreset(pContext);
+ *(uint16_t *)pValue = (uint16_t)EqualizerGetPreset(pContext);
//LOGV("\tEqualizer_getParameter() EQ_PARAM_CUR_PRESET %d", *(int32_t *)pValue);
break;
case EQ_PARAM_GET_NUM_OF_PRESETS:
- *(int16_t *)pValue = EqualizerGetNumPresets();
+ *(uint16_t *)pValue = (uint16_t)EqualizerGetNumPresets();
//LOGV("\tEqualizer_getParameter() EQ_PARAM_GET_NUM_OF_PRESETS %d", *(int16_t *)pValue);
break;
@@ -1968,12 +1976,12 @@
break;
case EQ_PARAM_PROPERTIES: {
- uint16_t *p = (uint16_t *)pValue;
+ int16_t *p = (int16_t *)pValue;
LOGV("\tEqualizer_getParameter() EQ_PARAM_PROPERTIES");
- p[0] = EqualizerGetPreset(pContext);
- p[1] = FIVEBAND_NUMBANDS;
+ p[0] = (int16_t)EqualizerGetPreset(pContext);
+ p[1] = (int16_t)FIVEBAND_NUMBANDS;
for (int i = 0; i < FIVEBAND_NUMBANDS; i++) {
- p[2 + i] = EqualizerGetBandLevel(pContext, i);
+ p[2 + i] = (int16_t)EqualizerGetBandLevel(pContext, i);
}
} break;
@@ -2011,7 +2019,7 @@
//LOGV("\tEqualizer_setParameter start");
switch (param) {
case EQ_PARAM_CUR_PRESET:
- preset = *(int16_t *)pValue;
+ preset = (int32_t)(*(uint16_t *)pValue);
//LOGV("\tEqualizer_setParameter() EQ_PARAM_CUR_PRESET %d", preset);
if ((preset >= EqualizerGetNumPresets())||(preset < 0)) {
@@ -2022,7 +2030,7 @@
break;
case EQ_PARAM_BAND_LEVEL:
band = *pParam;
- level = *(int32_t *)pValue;
+ level = (int32_t)(*(int16_t *)pValue);
//LOGV("\tEqualizer_setParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", band, level);
if (band >= FIVEBAND_NUMBANDS) {
status = -EINVAL;
@@ -2030,8 +2038,28 @@
}
EqualizerSetBandLevel(pContext, band, level);
break;
+ case EQ_PARAM_PROPERTIES: {
+ //LOGV("\tEqualizer_setParameter() EQ_PARAM_PROPERTIES");
+ int16_t *p = (int16_t *)pValue;
+ if ((int)p[0] >= EqualizerGetNumPresets()) {
+ status = -EINVAL;
+ break;
+ }
+ if (p[0] >= 0) {
+ EqualizerSetPreset(pContext, (int)p[0]);
+ } else {
+ if ((int)p[1] != FIVEBAND_NUMBANDS) {
+ status = -EINVAL;
+ break;
+ }
+ for (int i = 0; i < FIVEBAND_NUMBANDS; i++) {
+ EqualizerSetBandLevel(pContext, i, (int)p[2 + i]);
+ }
+ }
+ } break;
default:
LOGV("\tLVM_ERROR : setParameter() invalid param %d", param);
+ status = -EINVAL;
break;
}
diff --git a/media/libeffects/testlibs/EffectEqualizer.cpp b/media/libeffects/testlibs/EffectEqualizer.cpp
index a71f236..f8e4357 100644
--- a/media/libeffects/testlibs/EffectEqualizer.cpp
+++ b/media/libeffects/testlibs/EffectEqualizer.cpp
@@ -350,6 +350,8 @@
case EQ_PARAM_NUM_BANDS:
case EQ_PARAM_CUR_PRESET:
case EQ_PARAM_GET_NUM_OF_PRESETS:
+ case EQ_PARAM_BAND_LEVEL:
+ case EQ_PARAM_GET_BAND:
if (*pValueSize < sizeof(int16_t)) {
return -EINVAL;
}
@@ -357,14 +359,19 @@
break;
case EQ_PARAM_LEVEL_RANGE:
+ if (*pValueSize < 2 * sizeof(int16_t)) {
+ return -EINVAL;
+ }
+ *pValueSize = 2 * sizeof(int16_t);
+ break;
+
case EQ_PARAM_BAND_FREQ_RANGE:
if (*pValueSize < 2 * sizeof(int32_t)) {
return -EINVAL;
}
*pValueSize = 2 * sizeof(int32_t);
break;
- case EQ_PARAM_BAND_LEVEL:
- case EQ_PARAM_GET_BAND:
+
case EQ_PARAM_CENTER_FREQ:
if (*pValueSize < sizeof(int32_t)) {
return -EINVAL;
@@ -375,19 +382,26 @@
case EQ_PARAM_GET_PRESET_NAME:
break;
+ case EQ_PARAM_PROPERTIES:
+ if (*pValueSize < (2 + kNumBands) * sizeof(uint16_t)) {
+ return -EINVAL;
+ }
+ *pValueSize = (2 + kNumBands) * sizeof(uint16_t);
+ break;
+
default:
return -EINVAL;
}
switch (param) {
case EQ_PARAM_NUM_BANDS:
- *(int16_t *)pValue = kNumBands;
+ *(uint16_t *)pValue = (uint16_t)kNumBands;
LOGV("Equalizer_getParameter() EQ_PARAM_NUM_BANDS %d", *(int16_t *)pValue);
break;
case EQ_PARAM_LEVEL_RANGE:
- *(int32_t *)pValue = -9600;
- *((int32_t *)pValue + 1) = 4800;
+ *(int16_t *)pValue = -9600;
+ *((int16_t *)pValue + 1) = 4800;
LOGV("Equalizer_getParameter() EQ_PARAM_LEVEL_RANGE min %d, max %d", *(int32_t *)pValue, *((int32_t *)pValue + 1));
break;
@@ -397,7 +411,7 @@
status = -EINVAL;
break;
}
- *(int32_t *)pValue = pEqualizer->getGain(param2);
+ *(int16_t *)pValue = (int16_t)pEqualizer->getGain(param2);
LOGV("Equalizer_getParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", param2, *(int32_t *)pValue);
break;
@@ -423,17 +437,17 @@
case EQ_PARAM_GET_BAND:
param2 = *pParam;
- *(int32_t *)pValue = pEqualizer->getMostRelevantBand(param2);
+ *(uint16_t *)pValue = (uint16_t)pEqualizer->getMostRelevantBand(param2);
LOGV("Equalizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d", param2, *(int32_t *)pValue);
break;
case EQ_PARAM_CUR_PRESET:
- *(int16_t *)pValue = pEqualizer->getPreset();
+ *(uint16_t *)pValue = (uint16_t)pEqualizer->getPreset();
LOGV("Equalizer_getParameter() EQ_PARAM_CUR_PRESET %d", *(int32_t *)pValue);
break;
case EQ_PARAM_GET_NUM_OF_PRESETS:
- *(int16_t *)pValue = pEqualizer->getNumPresets();
+ *(uint16_t *)pValue = (uint16_t)pEqualizer->getNumPresets();
LOGV("Equalizer_getParameter() EQ_PARAM_GET_NUM_OF_PRESETS %d", *(int16_t *)pValue);
break;
@@ -450,6 +464,16 @@
LOGV("Equalizer_getParameter() EQ_PARAM_GET_PRESET_NAME preset %d, name %s len %d", param2, gEqualizerPresets[param2].name, *pValueSize);
break;
+ case EQ_PARAM_PROPERTIES: {
+ int16_t *p = (int16_t *)pValue;
+ LOGV("Equalizer_getParameter() EQ_PARAM_PROPERTIES");
+ p[0] = (int16_t)pEqualizer->getPreset();
+ p[1] = (int16_t)kNumBands;
+ for (int i = 0; i < kNumBands; i++) {
+ p[2 + i] = (int16_t)pEqualizer->getGain(i);
+ }
+ } break;
+
default:
LOGV("Equalizer_getParameter() invalid param %d", param);
status = -EINVAL;
@@ -489,10 +513,10 @@
switch (param) {
case EQ_PARAM_CUR_PRESET:
- preset = *(int16_t *)pValue;
+ preset = (int32_t)(*(uint16_t *)pValue);
LOGV("setParameter() EQ_PARAM_CUR_PRESET %d", preset);
- if (preset >= pEqualizer->getNumPresets()) {
+ if (preset < 0 || preset >= pEqualizer->getNumPresets()) {
status = -EINVAL;
break;
}
@@ -501,7 +525,7 @@
break;
case EQ_PARAM_BAND_LEVEL:
band = *pParam;
- level = *(int32_t *)pValue;
+ level = (int32_t)(*(int16_t *)pValue);
LOGV("setParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", band, level);
if (band >= kNumBands) {
status = -EINVAL;
@@ -510,8 +534,29 @@
pEqualizer->setGain(band, level);
pEqualizer->commit(true);
break;
+ case EQ_PARAM_PROPERTIES: {
+ LOGV("setParameter() EQ_PARAM_PROPERTIES");
+ int16_t *p = (int16_t *)pValue;
+ if ((int)p[0] >= pEqualizer->getNumPresets()) {
+ status = -EINVAL;
+ break;
+ }
+ if (p[0] >= 0) {
+ pEqualizer->setPreset((int)p[0]);
+ } else {
+ if ((int)p[1] != kNumBands) {
+ status = -EINVAL;
+ break;
+ }
+ for (int i = 0; i < kNumBands; i++) {
+ pEqualizer->setGain(i, (int32_t)p[2 + i]);
+ }
+ }
+ pEqualizer->commit(true);
+ } break;
default:
LOGV("setParameter() invalid param %d", param);
+ status = -EINVAL;
break;
}
diff --git a/media/libmedia/IMediaRecorder.cpp b/media/libmedia/IMediaRecorder.cpp
index 9fe207c..4eb63e8 100644
--- a/media/libmedia/IMediaRecorder.cpp
+++ b/media/libmedia/IMediaRecorder.cpp
@@ -1,6 +1,6 @@
/*
**
- ** Copyright 2008, HTC Inc.
+ ** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
diff --git a/media/libmediaplayerservice/MediaRecorderClient.cpp b/media/libmediaplayerservice/MediaRecorderClient.cpp
index fef3e6e..73862c3 100644
--- a/media/libmediaplayerservice/MediaRecorderClient.cpp
+++ b/media/libmediaplayerservice/MediaRecorderClient.cpp
@@ -1,5 +1,5 @@
/*
- ** Copyright 2008, HTC Inc.
+ ** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
diff --git a/media/libmediaplayerservice/MediaRecorderClient.h b/media/libmediaplayerservice/MediaRecorderClient.h
index d12e558..1d1913d 100644
--- a/media/libmediaplayerservice/MediaRecorderClient.h
+++ b/media/libmediaplayerservice/MediaRecorderClient.h
@@ -1,6 +1,6 @@
/*
**
- ** Copyright 2008, HTC Inc.
+ ** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp
index f26676d..c40d285 100644
--- a/media/libmediaplayerservice/StagefrightRecorder.cpp
+++ b/media/libmediaplayerservice/StagefrightRecorder.cpp
@@ -344,7 +344,7 @@
status_t StagefrightRecorder::setParamMaxFileDurationUs(int64_t timeUs) {
LOGV("setParamMaxFileDurationUs: %lld us", timeUs);
- if (timeUs <= 1000000LL) { // XXX: 1 second
+ if (timeUs <= 100000LL) { // XXX: 100 milli-seconds
LOGE("Max file duration is too short: %lld us", timeUs);
return BAD_VALUE;
}
diff --git a/native/android/sensor.cpp b/native/android/sensor.cpp
index e1fc4e7..db534e0 100644
--- a/native/android/sensor.cpp
+++ b/native/android/sensor.cpp
@@ -149,3 +149,7 @@
return static_cast<Sensor const*>(sensor)->getResolution();
}
+int ASensor_getMinDelay(ASensor const* sensor)
+{
+ return static_cast<Sensor const*>(sensor)->getMinDelay();
+}
diff --git a/native/include/android/sensor.h b/native/include/android/sensor.h
index 00d95d8..b4ce024 100644
--- a/native/include/android/sensor.h
+++ b/native/include/android/sensor.h
@@ -121,6 +121,7 @@
float temperature;
float distance;
float light;
+ float pressure;
};
int32_t reserved1[4];
} ASensorEvent;
@@ -188,7 +189,8 @@
/*
* Sets the delivery rate of events in microseconds for the given sensor.
* Note that this is a hint only, generally event will arrive at a higher
- * rate.
+ * rate. It is an error to set a rate inferior to the value returned by
+ * ASensor_getMinDelay().
* Returns a negative error code on failure.
*/
int ASensorEventQueue_setEventRate(ASensorEventQueue* queue, ASensor const* sensor, int32_t usec);
@@ -239,6 +241,13 @@
*/
float ASensor_getResolution(ASensor const* sensor);
+/*
+ * Returns the minimum delay allowed between events in microseconds.
+ * A value of zero means that this sensor doesn't report events at a
+ * constant rate, but rather only when a new data is available.
+ */
+int ASensor_getMinDelay(ASensor const* sensor);
+
#ifdef __cplusplus
};
diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp
index 714fd3e..665446a 100644
--- a/opengl/libs/EGL/egl.cpp
+++ b/opengl/libs/EGL/egl.cpp
@@ -42,7 +42,6 @@
#include "egl_impl.h"
#include "Loader.h"
-#define MAKE_CONFIG(_impl, _index) ((EGLConfig)(((_impl)<<24) | (_index)))
#define setError(_e, _r) setErrorEtc(__FUNCTION__, __LINE__, _e, _r)
// ----------------------------------------------------------------------------
@@ -143,6 +142,22 @@
SortedVector<egl_object_t*> egl_object_t::sObjects;
Mutex egl_object_t::sLock;
+
+struct egl_config_t {
+ egl_config_t() {}
+ egl_config_t(int impl, EGLConfig config)
+ : impl(impl), config(config), configId(0), implConfigId(0) { }
+ int impl; // the implementation this config is for
+ EGLConfig config; // the implementation's EGLConfig
+ EGLint configId; // our CONFIG_ID
+ EGLint implConfigId; // the implementation's CONFIG_ID
+ inline bool operator < (const egl_config_t& rhs) const {
+ if (impl < rhs.impl) return true;
+ if (impl > rhs.impl) return false;
+ return config < rhs.config;
+ }
+};
+
struct egl_display_t {
enum { NOT_INITIALIZED, INITIALIZED, TERMINATED };
@@ -163,13 +178,14 @@
strings_t queryString;
};
- uint32_t magic;
- DisplayImpl disp[IMPL_NUM_IMPLEMENTATIONS];
- EGLint numTotalConfigs;
- uint32_t refs;
- Mutex lock;
+ uint32_t magic;
+ DisplayImpl disp[IMPL_NUM_IMPLEMENTATIONS];
+ EGLint numTotalConfigs;
+ egl_config_t* configs;
+ uint32_t refs;
+ Mutex lock;
- egl_display_t() : magic('_dpy'), numTotalConfigs(0) { }
+ egl_display_t() : magic('_dpy'), numTotalConfigs(0), configs(0) { }
~egl_display_t() { magic = 0; }
inline bool isValid() const { return magic == '_dpy'; }
inline bool isAlive() const { return isValid(); }
@@ -179,14 +195,15 @@
{
typedef egl_object_t::LocalRef<egl_surface_t, EGLSurface> Ref;
- egl_surface_t(EGLDisplay dpy, EGLSurface surface,
+ egl_surface_t(EGLDisplay dpy, EGLSurface surface, EGLConfig config,
int impl, egl_connection_t const* cnx)
- : dpy(dpy), surface(surface), impl(impl), cnx(cnx) {
+ : dpy(dpy), surface(surface), config(config), impl(impl), cnx(cnx) {
}
~egl_surface_t() {
}
EGLDisplay dpy;
EGLSurface surface;
+ EGLConfig config;
int impl;
egl_connection_t const* cnx;
};
@@ -195,7 +212,7 @@
{
typedef egl_object_t::LocalRef<egl_context_t, EGLContext> Ref;
- egl_context_t(EGLDisplay dpy, EGLContext context,
+ egl_context_t(EGLDisplay dpy, EGLContext context, EGLConfig config,
int impl, egl_connection_t const* cnx, int version)
: dpy(dpy), context(context), read(0), draw(0), impl(impl), cnx(cnx),
version(version)
@@ -203,6 +220,7 @@
}
EGLDisplay dpy;
EGLContext context;
+ EGLConfig config;
EGLSurface read;
EGLSurface draw;
int impl;
@@ -354,7 +372,7 @@
{
while (first <= last) {
int mid = (first + last) / 2;
- if (key > sortedArray[mid]) {
+ if (sortedArray[mid] < key) {
first = mid + 1;
} else if (key < sortedArray[mid]) {
last = mid - 1;
@@ -365,26 +383,11 @@
return -1;
}
-static EGLint configToUniqueId(egl_display_t const* dp, int i, int index)
-{
- // NOTE: this mapping works only if we have no more than two EGLimpl
- return (i>0 ? dp->disp[0].numConfigs : 0) + index;
-}
-
-static void uniqueIdToConfig(egl_display_t const* dp, EGLint configId,
- int& i, int& index)
-{
- // NOTE: this mapping works only if we have no more than two EGLimpl
- size_t numConfigs = dp->disp[0].numConfigs;
- i = configId / numConfigs;
- index = configId % numConfigs;
-}
-
static int cmp_configs(const void* a, const void *b)
{
- EGLConfig c0 = *(EGLConfig const *)a;
- EGLConfig c1 = *(EGLConfig const *)b;
- return c0<c1 ? -1 : (c0>c1 ? 1 : 0);
+ const egl_config_t& c0 = *(egl_config_t const *)a;
+ const egl_config_t& c1 = *(egl_config_t const *)b;
+ return c0<c1 ? -1 : (c1<c0 ? 1 : 0);
}
struct extention_map_t {
@@ -477,20 +480,15 @@
static egl_connection_t* validate_display_config(
EGLDisplay dpy, EGLConfig config,
- egl_display_t const*& dp, int& impl, int& index)
+ egl_display_t const*& dp)
{
dp = get_display(dpy);
if (!dp) return setError(EGL_BAD_DISPLAY, (egl_connection_t*)NULL);
- impl = uintptr_t(config)>>24;
- if (uint32_t(impl) >= IMPL_NUM_IMPLEMENTATIONS) {
- return setError(EGL_BAD_CONFIG, (egl_connection_t*)NULL);
- }
- index = uintptr_t(config) & 0xFFFFFF;
- if (index >= dp->disp[impl].numConfigs) {
+ if (intptr_t(config) >= dp->numTotalConfigs) {
return setError(EGL_BAD_CONFIG, (egl_connection_t*)NULL);
}
- egl_connection_t* const cnx = &gEGLImpl[impl];
+ egl_connection_t* const cnx = &gEGLImpl[dp->configs[intptr_t(config)].impl];
if (cnx->dso == 0) {
return setError(EGL_BAD_CONFIG, (egl_connection_t*)NULL);
}
@@ -718,11 +716,6 @@
dp->disp[i].dpy, dp->disp[i].config, n,
&dp->disp[i].numConfigs))
{
- // sort the configurations so we can do binary searches
- qsort( dp->disp[i].config,
- dp->disp[i].numConfigs,
- sizeof(EGLConfig), cmp_configs);
-
dp->numTotalConfigs += n;
res = EGL_TRUE;
}
@@ -732,6 +725,30 @@
}
if (res == EGL_TRUE) {
+ dp->configs = new egl_config_t[ dp->numTotalConfigs ];
+ for (int i=0, k=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
+ egl_connection_t* const cnx = &gEGLImpl[i];
+ if (cnx->dso && cnx->major>=0 && cnx->minor>=0) {
+ for (int j=0 ; j<dp->disp[i].numConfigs ; j++) {
+ dp->configs[k].impl = i;
+ dp->configs[k].config = dp->disp[i].config[j];
+ dp->configs[k].configId = k + 1; // CONFIG_ID start at 1
+ // store the implementation's CONFIG_ID
+ cnx->egl.eglGetConfigAttrib(
+ dp->disp[i].dpy,
+ dp->disp[i].config[j],
+ EGL_CONFIG_ID,
+ &dp->configs[k].implConfigId);
+ k++;
+ }
+ }
+ }
+
+ // sort our configurations so we can do binary-searches
+ qsort( dp->configs,
+ dp->numTotalConfigs,
+ sizeof(egl_config_t), cmp_configs);
+
dp->refs++;
if (major != NULL) *major = VERSION_MAJOR;
if (minor != NULL) *minor = VERSION_MINOR;
@@ -784,6 +801,7 @@
dp->refs--;
dp->numTotalConfigs = 0;
+ delete [] dp->configs;
clearTLS();
return res;
}
@@ -804,14 +822,13 @@
*num_config = numConfigs;
return EGL_TRUE;
}
+
GLint n = 0;
- for (int j=0 ; j<IMPL_NUM_IMPLEMENTATIONS ; j++) {
- for (int i=0 ; i<dp->disp[j].numConfigs && config_size ; i++) {
- *configs++ = MAKE_CONFIG(j, i);
- config_size--;
- n++;
- }
- }
+ for (intptr_t i=0 ; i<dp->numTotalConfigs && config_size ; i++) {
+ *configs++ = EGLConfig(i);
+ config_size--;
+ n++;
+ }
*num_config = n;
return EGL_TRUE;
@@ -834,7 +851,7 @@
// It is unfortunate, but we need to remap the EGL_CONFIG_IDs,
- // to do this, we have to go through the attrib_list array once
+ // to do this, we have to go through the attrib_list array once
// to figure out both its size and if it contains an EGL_CONFIG_ID
// key. If so, the full array is copied and patched.
// NOTE: we assume that there can be only one occurrence
@@ -858,16 +875,20 @@
memcpy(new_list, attrib_list, size*sizeof(EGLint));
// patch the requested EGL_CONFIG_ID
- int i, index;
+ bool found = false;
+ EGLConfig ourConfig(0);
EGLint& configId(new_list[patch_index+1]);
- uniqueIdToConfig(dp, configId, i, index);
-
- egl_connection_t* const cnx = &gEGLImpl[i];
- if (cnx->dso) {
- cnx->egl.eglGetConfigAttrib(
- dp->disp[i].dpy, dp->disp[i].config[index],
- EGL_CONFIG_ID, &configId);
+ for (intptr_t i=0 ; i<dp->numTotalConfigs ; i++) {
+ if (dp->configs[i].configId == configId) {
+ ourConfig = EGLConfig(i);
+ configId = dp->configs[i].implConfigId;
+ found = true;
+ break;
+ }
+ }
+ egl_connection_t* const cnx = &gEGLImpl[dp->configs[intptr_t(ourConfig)].impl];
+ if (found && cnx->dso) {
// and switch to the new list
attrib_list = const_cast<const EGLint *>(new_list);
@@ -880,12 +901,13 @@
// which one.
res = cnx->egl.eglChooseConfig(
- dp->disp[i].dpy, attrib_list, configs, config_size, &n);
+ dp->disp[ dp->configs[intptr_t(ourConfig)].impl ].dpy,
+ attrib_list, configs, config_size, &n);
if (res && n>0) {
// n has to be 0 or 1, by construction, and we already know
// which config it will return (since there can be only one).
if (configs) {
- configs[0] = MAKE_CONFIG(i, index);
+ configs[0] = ourConfig;
}
*num_config = 1;
}
@@ -895,6 +917,7 @@
return res;
}
+
for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
egl_connection_t* const cnx = &gEGLImpl[i];
if (cnx->dso) {
@@ -902,15 +925,14 @@
dp->disp[i].dpy, attrib_list, configs, config_size, &n)) {
if (configs) {
// now we need to convert these client EGLConfig to our
- // internal EGLConfig format. This is done in O(n log n).
+ // internal EGLConfig format.
+ // This is done in O(n Log(n)) time.
for (int j=0 ; j<n ; j++) {
- int index = binarySearch<EGLConfig>(
- dp->disp[i].config, 0,
- dp->disp[i].numConfigs-1, configs[j]);
+ egl_config_t key(i, configs[j]);
+ intptr_t index = binarySearch<egl_config_t>(
+ dp->configs, 0, dp->numTotalConfigs, key);
if (index >= 0) {
- if (configs) {
- configs[j] = MAKE_CONFIG(i, index);
- }
+ configs[j] = EGLConfig(index);
} else {
return setError(EGL_BAD_CONFIG, EGL_FALSE);
}
@@ -930,18 +952,16 @@
EGLint attribute, EGLint *value)
{
egl_display_t const* dp = 0;
- int i=0, index=0;
- egl_connection_t* cnx = validate_display_config(dpy, config, dp, i, index);
+ egl_connection_t* cnx = validate_display_config(dpy, config, dp);
if (!cnx) return EGL_FALSE;
if (attribute == EGL_CONFIG_ID) {
- // EGL_CONFIG_IDs must be unique, just use the order of the selected
- // EGLConfig.
- *value = configToUniqueId(dp, i, index);
+ *value = dp->configs[intptr_t(config)].configId;
return EGL_TRUE;
}
return cnx->egl.eglGetConfigAttrib(
- dp->disp[i].dpy, dp->disp[i].config[index], attribute, value);
+ dp->disp[ dp->configs[intptr_t(config)].impl ].dpy,
+ dp->configs[intptr_t(config)].config, attribute, value);
}
// ----------------------------------------------------------------------------
@@ -953,13 +973,14 @@
const EGLint *attrib_list)
{
egl_display_t const* dp = 0;
- int i=0, index=0;
- egl_connection_t* cnx = validate_display_config(dpy, config, dp, i, index);
+ egl_connection_t* cnx = validate_display_config(dpy, config, dp);
if (cnx) {
EGLSurface surface = cnx->egl.eglCreateWindowSurface(
- dp->disp[i].dpy, dp->disp[i].config[index], window, attrib_list);
+ dp->disp[ dp->configs[intptr_t(config)].impl ].dpy,
+ dp->configs[intptr_t(config)].config, window, attrib_list);
if (surface != EGL_NO_SURFACE) {
- egl_surface_t* s = new egl_surface_t(dpy, surface, i, cnx);
+ egl_surface_t* s = new egl_surface_t(dpy, surface, config,
+ dp->configs[intptr_t(config)].impl, cnx);
return s;
}
}
@@ -971,13 +992,14 @@
const EGLint *attrib_list)
{
egl_display_t const* dp = 0;
- int i=0, index=0;
- egl_connection_t* cnx = validate_display_config(dpy, config, dp, i, index);
+ egl_connection_t* cnx = validate_display_config(dpy, config, dp);
if (cnx) {
EGLSurface surface = cnx->egl.eglCreatePixmapSurface(
- dp->disp[i].dpy, dp->disp[i].config[index], pixmap, attrib_list);
+ dp->disp[ dp->configs[intptr_t(config)].impl ].dpy,
+ dp->configs[intptr_t(config)].config, pixmap, attrib_list);
if (surface != EGL_NO_SURFACE) {
- egl_surface_t* s = new egl_surface_t(dpy, surface, i, cnx);
+ egl_surface_t* s = new egl_surface_t(dpy, surface, config,
+ dp->configs[intptr_t(config)].impl, cnx);
return s;
}
}
@@ -988,13 +1010,14 @@
const EGLint *attrib_list)
{
egl_display_t const* dp = 0;
- int i=0, index=0;
- egl_connection_t* cnx = validate_display_config(dpy, config, dp, i, index);
+ egl_connection_t* cnx = validate_display_config(dpy, config, dp);
if (cnx) {
EGLSurface surface = cnx->egl.eglCreatePbufferSurface(
- dp->disp[i].dpy, dp->disp[i].config[index], attrib_list);
+ dp->disp[ dp->configs[intptr_t(config)].impl ].dpy,
+ dp->configs[intptr_t(config)].config, attrib_list);
if (surface != EGL_NO_SURFACE) {
- egl_surface_t* s = new egl_surface_t(dpy, surface, i, cnx);
+ egl_surface_t* s = new egl_surface_t(dpy, surface, config,
+ dp->configs[intptr_t(config)].impl, cnx);
return s;
}
}
@@ -1030,27 +1053,35 @@
egl_display_t const * const dp = get_display(dpy);
egl_surface_t const * const s = get_surface(surface);
- return s->cnx->egl.eglQuerySurface(
- dp->disp[s->impl].dpy, s->surface, attribute, value);
+ EGLBoolean result(EGL_TRUE);
+ if (attribute == EGL_CONFIG_ID) {
+ // We need to remap EGL_CONFIG_IDs
+ *value = dp->configs[intptr_t(s->config)].configId;
+ } else {
+ result = s->cnx->egl.eglQuerySurface(
+ dp->disp[s->impl].dpy, s->surface, attribute, value);
+ }
+
+ return result;
}
// ----------------------------------------------------------------------------
-// contextes
+// Contexts
// ----------------------------------------------------------------------------
EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config,
EGLContext share_list, const EGLint *attrib_list)
{
egl_display_t const* dp = 0;
- int i=0, index=0;
- egl_connection_t* cnx = validate_display_config(dpy, config, dp, i, index);
+ egl_connection_t* cnx = validate_display_config(dpy, config, dp);
if (cnx) {
if (share_list != EGL_NO_CONTEXT) {
egl_context_t* const c = get_context(share_list);
share_list = c->context;
}
EGLContext context = cnx->egl.eglCreateContext(
- dp->disp[i].dpy, dp->disp[i].config[index],
+ dp->disp[ dp->configs[intptr_t(config)].impl ].dpy,
+ dp->configs[intptr_t(config)].config,
share_list, attrib_list);
if (context != EGL_NO_CONTEXT) {
// figure out if it's a GLESv1 or GLESv2
@@ -1068,7 +1099,8 @@
}
};
}
- egl_context_t* c = new egl_context_t(dpy, context, i, cnx, version);
+ egl_context_t* c = new egl_context_t(dpy, context, config,
+ dp->configs[intptr_t(config)].impl, cnx, version);
return c;
}
}
@@ -1213,8 +1245,16 @@
egl_display_t const * const dp = get_display(dpy);
egl_context_t * const c = get_context(ctx);
- return c->cnx->egl.eglQueryContext(
- dp->disp[c->impl].dpy, c->context, attribute, value);
+ EGLBoolean result(EGL_TRUE);
+ if (attribute == EGL_CONFIG_ID) {
+ *value = dp->configs[intptr_t(c->config)].configId;
+ } else {
+ // We need to remap EGL_CONFIG_IDs
+ result = c->cnx->egl.eglQueryContext(
+ dp->disp[c->impl].dpy, c->context, attribute, value);
+ }
+
+ return result;
}
EGLContext eglGetCurrentContext(void)
@@ -1586,13 +1626,13 @@
EGLConfig config, const EGLint *attrib_list)
{
egl_display_t const* dp = 0;
- int i=0, index=0;
- egl_connection_t* cnx = validate_display_config(dpy, config, dp, i, index);
+ egl_connection_t* cnx = validate_display_config(dpy, config, dp);
if (!cnx) return EGL_FALSE;
if (cnx->egl.eglCreatePbufferFromClientBuffer) {
return cnx->egl.eglCreatePbufferFromClientBuffer(
- dp->disp[i].dpy, buftype, buffer,
- dp->disp[i].config[index], attrib_list);
+ dp->disp[ dp->configs[intptr_t(config)].impl ].dpy,
+ buftype, buffer,
+ dp->configs[intptr_t(config)].config, attrib_list);
}
return setError(EGL_BAD_CONFIG, EGL_NO_SURFACE);
}
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index c786f94..3b3904a 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -1,7 +1,6 @@
/*
**
** Copyright (C) 2008, The Android Open Source Project
-** Copyright (C) 2008 HTC Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index b0b2d7a..77ccf41 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -1,7 +1,6 @@
/*
**
** Copyright (C) 2008, The Android Open Source Project
-** Copyright (C) 2008 HTC Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.