Merge "HTTP auth for Chromium HTTP stack (Java side)"
diff --git a/include/ui/EventHub.h b/include/ui/EventHub.h
index 25d5afb..d6b09dc 100644
--- a/include/ui/EventHub.h
+++ b/include/ui/EventHub.h
@@ -111,10 +111,10 @@
/* The input device is a multi-touch touchscreen. */
INPUT_DEVICE_CLASS_TOUCHSCREEN_MT= 0x00000010,
- /* The input device is a directional pad. */
+ /* The input device is a directional pad (implies keyboard, has DPAD keys). */
INPUT_DEVICE_CLASS_DPAD = 0x00000020,
- /* The input device is a gamepad (implies keyboard). */
+ /* The input device is a gamepad (implies keyboard, has BUTTON keys). */
INPUT_DEVICE_CLASS_GAMEPAD = 0x00000040,
/* The input device has switches. */
diff --git a/include/ui/InputDispatcher.h b/include/ui/InputDispatcher.h
index e466ddd..96b4fae 100644
--- a/include/ui/InputDispatcher.h
+++ b/include/ui/InputDispatcher.h
@@ -851,8 +851,8 @@
// Inbound event processing.
void drainInboundQueueLocked();
- void releasePendingEventLocked(bool wasDropped);
- void releaseInboundEventLocked(EventEntry* entry, bool wasDropped);
+ void releasePendingEventLocked();
+ void releaseInboundEventLocked(EventEntry* entry);
bool isEventFromReliableSourceLocked(EventEntry* entry);
// Dispatch state.
@@ -886,10 +886,10 @@
nsecs_t currentTime, ConfigurationChangedEntry* entry);
bool dispatchKeyLocked(
nsecs_t currentTime, KeyEntry* entry, nsecs_t keyRepeatTimeout,
- nsecs_t* nextWakeupTime);
+ bool dropEvent, nsecs_t* nextWakeupTime);
bool dispatchMotionLocked(
nsecs_t currentTime, MotionEntry* entry,
- nsecs_t* nextWakeupTime);
+ bool dropEvent, nsecs_t* nextWakeupTime);
void dispatchEventToCurrentInputTargetsLocked(
nsecs_t currentTime, EventEntry* entry, bool resumeWithAppendedMotionSample);
@@ -914,8 +914,8 @@
bool mInputTargetWaitTimeoutExpired;
// Finding targets for input events.
- void startFindingTargetsLocked();
- void finishFindingTargetsLocked(const InputWindow* window);
+ void resetTargetsLocked();
+ void commitTargetsLocked(const InputWindow* window);
int32_t handleTargetsNotReadyLocked(nsecs_t currentTime, const EventEntry* entry,
const InputApplication* application, const InputWindow* window,
nsecs_t* nextWakeupTime);
diff --git a/include/utils/Looper.h b/include/utils/Looper.h
index 92e4b0a..7d90866 100644
--- a/include/utils/Looper.h
+++ b/include/utils/Looper.h
@@ -83,16 +83,20 @@
* This method does not return until it has finished invoking the appropriate callbacks
* for all file descriptors that were signalled.
*/
- int pollOnce(int timeoutMillis,
- int* outFd = NULL, int* outEvents = NULL, void** outData = NULL);
+ int pollOnce(int timeoutMillis, int* outFd, int* outEvents, void** outData);
+ inline int pollOnce(int timeoutMillis) {
+ return pollOnce(timeoutMillis, NULL, NULL, NULL);
+ }
/**
* Like pollOnce(), but performs all pending callbacks until all
* data has been consumed or a file descriptor is available with no callback.
* This function will never return ALOOPER_POLL_CALLBACK.
*/
- int pollAll(int timeoutMillis,
- int* outFd = NULL, int* outEvents = NULL, void** outData = NULL);
+ int pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outData);
+ inline int pollAll(int timeoutMillis) {
+ return pollAll(timeoutMillis, NULL, NULL, NULL);
+ }
/**
* Wakes the poll asynchronously.
@@ -128,8 +132,7 @@
* This method can be called on any thread.
* This method may block briefly if it needs to wake the poll.
*/
- int addFd(int fd, int ident,
- int events, ALooper_callbackFunc callback, void* data = NULL);
+ int addFd(int fd, int ident, int events, ALooper_callbackFunc callback, void* data);
/**
* Removes a previously added file descriptor from the looper.
diff --git a/libs/gui/SensorEventQueue.cpp b/libs/gui/SensorEventQueue.cpp
index c3a9f22..f935524 100644
--- a/libs/gui/SensorEventQueue.cpp
+++ b/libs/gui/SensorEventQueue.cpp
@@ -70,9 +70,13 @@
ssize_t SensorEventQueue::read(ASensorEvent* events, size_t numEvents)
{
ssize_t size = mSensorChannel->read(events, numEvents*sizeof(events[0]));
+ LOGE_IF(size<0 && size!=-EAGAIN,
+ "SensorChannel::read error (%s)", strerror(-size));
if (size >= 0) {
if (size % sizeof(events[0])) {
// partial read!!! should never happen.
+ LOGE("SensorEventQueue partial read (event-size=%u, read=%d)",
+ sizeof(events[0]), int(size));
return -EINVAL;
}
// returns number of events read
@@ -95,8 +99,18 @@
{
const int fd = getFd();
sp<Looper> looper(getLooper());
- int32_t result = looper->pollOnce(-1);
- return (result == fd) ? status_t(NO_ERROR) : status_t(-1);
+
+ int32_t result;
+ do {
+ result = looper->pollOnce(-1);
+ if (result == ALOOPER_EVENT_ERROR) {
+ LOGE("SensorChannel::waitForEvent error (errno=%d)", errno);
+ result = -EPIPE; // unknown error, so we make up one
+ break;
+ }
+ } while (result != fd);
+
+ return (result == fd) ? status_t(NO_ERROR) : result;
}
status_t SensorEventQueue::wake() const
diff --git a/libs/ui/GraphicLog.cpp b/libs/ui/GraphicLog.cpp
index b55ce23..7ba2779 100644
--- a/libs/ui/GraphicLog.cpp
+++ b/libs/ui/GraphicLog.cpp
@@ -30,7 +30,11 @@
static inline
void writeInt32(uint8_t* base, size_t& pos, int32_t value) {
+#ifdef HAVE_LITTLE_ENDIAN
+ int32_t v = value;
+#else
int32_t v = htole32(value);
+#endif
base[pos] = EVENT_TYPE_INT;
memcpy(&base[pos+1], &v, sizeof(int32_t));
pos += 1+sizeof(int32_t);
@@ -38,7 +42,11 @@
static inline
void writeInt64(uint8_t* base, size_t& pos, int64_t value) {
+#ifdef HAVE_LITTLE_ENDIAN
+ int64_t v = value;
+#else
int64_t v = htole64(value);
+#endif
base[pos] = EVENT_TYPE_LONG;
memcpy(&base[pos+1], &v, sizeof(int64_t));
pos += 1+sizeof(int64_t);
diff --git a/libs/ui/InputDispatcher.cpp b/libs/ui/InputDispatcher.cpp
index 3b3c483..1cf7592 100644
--- a/libs/ui/InputDispatcher.cpp
+++ b/libs/ui/InputDispatcher.cpp
@@ -122,7 +122,7 @@
AutoMutex _l(mLock);
resetKeyRepeatLocked();
- releasePendingEventLocked(true);
+ releasePendingEventLocked();
drainInboundQueueLocked();
}
@@ -174,7 +174,7 @@
if (! mDispatchEnabled) {
if (mPendingEvent || ! mInboundQueue.isEmpty()) {
LOGI("Dropping pending events because input dispatch is disabled.");
- releasePendingEventLocked(true);
+ releasePendingEventLocked();
drainInboundQueueLocked();
}
return;
@@ -281,51 +281,50 @@
// Now we have an event to dispatch.
assert(mPendingEvent != NULL);
- bool wasDispatched = false;
- bool wasDropped = false;
+ bool done = false;
switch (mPendingEvent->type) {
case EventEntry::TYPE_CONFIGURATION_CHANGED: {
ConfigurationChangedEntry* typedEntry =
static_cast<ConfigurationChangedEntry*>(mPendingEvent);
- wasDispatched = dispatchConfigurationChangedLocked(currentTime, typedEntry);
+ done = dispatchConfigurationChangedLocked(currentTime, typedEntry);
break;
}
case EventEntry::TYPE_KEY: {
KeyEntry* typedEntry = static_cast<KeyEntry*>(mPendingEvent);
- if (isAppSwitchPendingLocked()) {
- if (isAppSwitchKey(typedEntry->keyCode)) {
+ bool appSwitchKey = isAppSwitchKey(typedEntry->keyCode);
+ bool dropEvent = isAppSwitchDue && ! appSwitchKey;
+ done = dispatchKeyLocked(currentTime, typedEntry, keyRepeatTimeout, dropEvent,
+ nextWakeupTime);
+ if (done) {
+ if (dropEvent) {
+ LOGI("Dropped key because of pending overdue app switch.");
+ } else if (appSwitchKey) {
resetPendingAppSwitchLocked(true);
- } else if (isAppSwitchDue) {
- LOGI("Dropping key because of pending overdue app switch.");
- wasDropped = true;
- break;
}
}
- wasDispatched = dispatchKeyLocked(currentTime, typedEntry, keyRepeatTimeout,
- nextWakeupTime);
break;
}
case EventEntry::TYPE_MOTION: {
MotionEntry* typedEntry = static_cast<MotionEntry*>(mPendingEvent);
- if (isAppSwitchDue) {
- LOGI("Dropping motion because of pending overdue app switch.");
- wasDropped = true;
- break;
+ bool dropEvent = isAppSwitchDue;
+ done = dispatchMotionLocked(currentTime, typedEntry, dropEvent, nextWakeupTime);
+ if (done) {
+ if (dropEvent) {
+ LOGI("Dropped motion because of pending overdue app switch.");
+ }
}
- wasDispatched = dispatchMotionLocked(currentTime, typedEntry, nextWakeupTime);
break;
}
default:
assert(false);
- wasDropped = true;
break;
}
- if (wasDispatched || wasDropped) {
- releasePendingEventLocked(wasDropped);
+ if (done) {
+ releasePendingEventLocked();
*nextWakeupTime = LONG_LONG_MIN; // force next poll to wake up immediately
}
}
@@ -403,21 +402,21 @@
void InputDispatcher::drainInboundQueueLocked() {
while (! mInboundQueue.isEmpty()) {
EventEntry* entry = mInboundQueue.dequeueAtHead();
- releaseInboundEventLocked(entry, true /*wasDropped*/);
+ releaseInboundEventLocked(entry);
}
}
-void InputDispatcher::releasePendingEventLocked(bool wasDropped) {
+void InputDispatcher::releasePendingEventLocked() {
if (mPendingEvent) {
- releaseInboundEventLocked(mPendingEvent, wasDropped);
+ releaseInboundEventLocked(mPendingEvent);
mPendingEvent = NULL;
}
}
-void InputDispatcher::releaseInboundEventLocked(EventEntry* entry, bool wasDropped) {
- if (wasDropped) {
+void InputDispatcher::releaseInboundEventLocked(EventEntry* entry) {
+ if (entry->injectionResult == INPUT_EVENT_INJECTION_PENDING) {
#if DEBUG_DISPATCH_CYCLE
- LOGD("Pending event was dropped.");
+ LOGD("Inbound event was dropped. Setting injection result to failed.");
#endif
setInjectionResultLocked(entry, INPUT_EVENT_INJECTION_FAILED);
}
@@ -492,7 +491,41 @@
bool InputDispatcher::dispatchKeyLocked(
nsecs_t currentTime, KeyEntry* entry, nsecs_t keyRepeatTimeout,
- nsecs_t* nextWakeupTime) {
+ bool dropEvent, nsecs_t* nextWakeupTime) {
+ // Give the policy a chance to intercept the key.
+ if (entry->interceptKeyResult == KeyEntry::INTERCEPT_KEY_RESULT_UNKNOWN) {
+ bool trusted;
+ if (! dropEvent && mFocusedWindow) {
+ trusted = checkInjectionPermission(mFocusedWindow,
+ entry->injectorPid, entry->injectorUid);
+ } else {
+ trusted = isEventFromReliableSourceLocked(entry);
+ }
+ if (trusted) {
+ CommandEntry* commandEntry = postCommandLocked(
+ & InputDispatcher::doInterceptKeyBeforeDispatchingLockedInterruptible);
+ if (! dropEvent && mFocusedWindow) {
+ commandEntry->inputChannel = mFocusedWindow->inputChannel;
+ }
+ commandEntry->keyEntry = entry;
+ entry->refCount += 1;
+ return false; // wait for the command to run
+ } else {
+ entry->interceptKeyResult = KeyEntry::INTERCEPT_KEY_RESULT_CONTINUE;
+ }
+ } else if (entry->interceptKeyResult == KeyEntry::INTERCEPT_KEY_RESULT_SKIP) {
+ resetTargetsLocked();
+ setInjectionResultLocked(entry, INPUT_EVENT_INJECTION_SUCCEEDED);
+ return true;
+ }
+
+ // Clean up if dropping the event.
+ if (dropEvent) {
+ resetTargetsLocked();
+ setInjectionResultLocked(entry, INPUT_EVENT_INJECTION_FAILED);
+ return true;
+ }
+
// Preprocessing.
if (! entry->dispatchInProgress) {
logOutboundKeyDetailsLocked("dispatchKey - ", entry);
@@ -521,7 +554,7 @@
}
entry->dispatchInProgress = true;
- startFindingTargetsLocked(); // resets mCurrentInputTargetsValid
+ resetTargetsLocked();
}
// Identify targets.
@@ -539,20 +572,7 @@
}
addMonitoringTargetsLocked();
- finishFindingTargetsLocked(window);
- }
-
- // Give the policy a chance to intercept the key.
- if (entry->interceptKeyResult == KeyEntry::INTERCEPT_KEY_RESULT_UNKNOWN) {
- CommandEntry* commandEntry = postCommandLocked(
- & InputDispatcher::doInterceptKeyBeforeDispatchingLockedInterruptible);
- commandEntry->inputChannel = mCurrentInputChannel;
- commandEntry->keyEntry = entry;
- entry->refCount += 1;
- return false; // wait for the command to run
- }
- if (entry->interceptKeyResult == KeyEntry::INTERCEPT_KEY_RESULT_SKIP) {
- return true;
+ commitTargetsLocked(window);
}
// Dispatch the key.
@@ -576,13 +596,20 @@
}
bool InputDispatcher::dispatchMotionLocked(
- nsecs_t currentTime, MotionEntry* entry, nsecs_t* nextWakeupTime) {
+ nsecs_t currentTime, MotionEntry* entry, bool dropEvent, nsecs_t* nextWakeupTime) {
+ // Clean up if dropping the event.
+ if (dropEvent) {
+ resetTargetsLocked();
+ setInjectionResultLocked(entry, INPUT_EVENT_INJECTION_FAILED);
+ return true;
+ }
+
// Preprocessing.
if (! entry->dispatchInProgress) {
logOutboundMotionDetailsLocked("dispatchMotion - ", entry);
entry->dispatchInProgress = true;
- startFindingTargetsLocked(); // resets mCurrentInputTargetsValid
+ resetTargetsLocked();
}
bool isPointerEvent = entry->source & AINPUT_SOURCE_CLASS_POINTER;
@@ -610,7 +637,7 @@
}
addMonitoringTargetsLocked();
- finishFindingTargetsLocked(window);
+ commitTargetsLocked(window);
}
// Dispatch the motion.
@@ -705,14 +732,14 @@
}
}
-void InputDispatcher::startFindingTargetsLocked() {
+void InputDispatcher::resetTargetsLocked() {
mCurrentInputTargetsValid = false;
mCurrentInputTargets.clear();
mCurrentInputChannel.clear();
mInputTargetWaitCause = INPUT_TARGET_WAIT_CAUSE_NONE;
}
-void InputDispatcher::finishFindingTargetsLocked(const InputWindow* window) {
+void InputDispatcher::commitTargetsLocked(const InputWindow* window) {
mCurrentInputWindowType = window->layoutParamsType;
mCurrentInputChannel = window->inputChannel;
mCurrentInputTargetsValid = true;
@@ -776,11 +803,16 @@
// Give up.
mInputTargetWaitTimeoutExpired = true;
+ // Release the touch target.
+ releaseTouchedWindowLocked();
+
// Input state will not be realistic. Mark it out of sync.
- ssize_t connectionIndex = getConnectionIndexLocked(inputChannel);
- if (connectionIndex >= 0) {
- sp<Connection> connection = mConnectionsByReceiveFd.valueAt(connectionIndex);
- connection->inputState.setOutOfSync();
+ if (inputChannel.get()) {
+ ssize_t connectionIndex = getConnectionIndexLocked(inputChannel);
+ if (connectionIndex >= 0) {
+ sp<Connection> connection = mConnectionsByReceiveFd.valueAt(connectionIndex);
+ connection->inputState.setOutOfSync();
+ }
}
}
}
@@ -2157,9 +2189,8 @@
{ // acquire lock
AutoMutex _l(mLock);
- sp<InputChannel> oldFocusedWindowChannel = mFocusedWindow
- ? mFocusedWindow->inputChannel : NULL;
- int32_t oldFocusedWindowLayer = mFocusedWindow ? mFocusedWindow->layer : -1;
+ // Clear old window pointers but remember their associated channels.
+ mFocusedWindow = NULL;
sp<InputChannel> touchedWindowChannel;
if (mTouchedWindow) {
@@ -2173,11 +2204,11 @@
}
mTouchedWallpaperWindows.clear();
}
-
- mFocusedWindow = NULL;
mWallpaperWindows.clear();
-
mWindows.clear();
+
+ // Loop over new windows and rebuild the necessary window pointers for
+ // tracking focus and touch.
mWindows.appendVector(inputWindows);
size_t numWindows = mWindows.size();
@@ -2201,41 +2232,8 @@
mTouchedWindow = window;
}
}
-
mTempTouchedWallpaperChannels.clear();
- bool preempt = false;
- if (mFocusedWindow
- && mFocusedWindow->inputChannel != oldFocusedWindowChannel
- && mFocusedWindow->canReceiveKeys) {
- // If the new input focus is an error window or appears above the current
- // input focus, drop the current touched window so that we can start
- // delivering events to the new input focus as soon as possible.
- if (mFocusedWindow->layoutParamsFlags & InputWindow::FLAG_SYSTEM_ERROR) {
-#if DEBUG_FOCUS
- LOGD("Preempting: New SYSTEM_ERROR window; resetting state");
-#endif
- preempt = true;
- } else if (oldFocusedWindowChannel.get() != NULL
- && mFocusedWindow->layer > oldFocusedWindowLayer) {
-#if DEBUG_FOCUS
- LOGD("Preempting: Transferring focus to new window at higher layer: "
- "old win layer=%d, new win layer=%d",
- oldFocusedWindowLayer, mFocusedWindow->layer);
-#endif
- preempt = true;
- }
- }
- if (mTouchedWindow && ! mTouchedWindow->visible) {
-#if DEBUG_FOCUS
- LOGD("Preempting: Touched window became invisible.");
-#endif
- preempt = true;
- }
- if (preempt) {
- releaseTouchedWindowLocked();
- }
-
#if DEBUG_FOCUS
logDispatchStateLocked();
#endif
@@ -2310,7 +2308,17 @@
void InputDispatcher::logDispatchStateLocked() {
String8 dump;
dumpDispatchStateLocked(dump);
- LOGD("%s", dump.string());
+
+ char* text = dump.lockBuffer(dump.size());
+ char* start = text;
+ while (*start != '\0') {
+ char* end = strchr(start, '\n');
+ if (*end == '\n') {
+ *(end++) = '\0';
+ }
+ LOGD("%s", start);
+ start = end;
+ }
}
void InputDispatcher::dumpDispatchStateLocked(String8& dump) {
@@ -2324,28 +2332,30 @@
} else {
dump.append(" focusedApplication: <null>\n");
}
- dump.appendFormat(" focusedWindow: '%s'\n",
- mFocusedWindow != NULL ? mFocusedWindow->inputChannel->getName().string() : "<null>");
- dump.appendFormat(" touchedWindow: '%s', touchDown=%d\n",
- mTouchedWindow != NULL ? mTouchedWindow->inputChannel->getName().string() : "<null>",
+ dump.appendFormat(" focusedWindow: name='%s'\n",
+ mFocusedWindow != NULL ? mFocusedWindow->name.string() : "<null>");
+ dump.appendFormat(" touchedWindow: name='%s', touchDown=%d\n",
+ mTouchedWindow != NULL ? mTouchedWindow->name.string() : "<null>",
mTouchDown);
for (size_t i = 0; i < mTouchedWallpaperWindows.size(); i++) {
- dump.appendFormat(" touchedWallpaperWindows[%d]: '%s'\n",
- i, mTouchedWallpaperWindows[i]->inputChannel->getName().string());
+ dump.appendFormat(" touchedWallpaperWindows[%d]: name='%s'\n",
+ i, mTouchedWallpaperWindows[i]->name.string());
}
for (size_t i = 0; i < mWindows.size(); i++) {
- dump.appendFormat(" windows[%d]: '%s', paused=%s, hasFocus=%s, hasWallpaper=%s, "
- "visible=%s, flags=0x%08x, type=0x%08x, "
+ dump.appendFormat(" windows[%d]: name='%s', paused=%s, hasFocus=%s, hasWallpaper=%s, "
+ "visible=%s, canReceiveKeys=%s, flags=0x%08x, type=0x%08x, layer=%d, "
"frame=[%d,%d][%d,%d], "
"visibleFrame=[%d,%d][%d,%d], "
"touchableArea=[%d,%d][%d,%d], "
"ownerPid=%d, ownerUid=%d, dispatchingTimeout=%0.3fms\n",
- i, mWindows[i].inputChannel->getName().string(),
+ i, mWindows[i].name.string(),
toString(mWindows[i].paused),
toString(mWindows[i].hasFocus),
toString(mWindows[i].hasWallpaper),
toString(mWindows[i].visible),
+ toString(mWindows[i].canReceiveKeys),
mWindows[i].layoutParamsFlags, mWindows[i].layoutParamsType,
+ mWindows[i].layer,
mWindows[i].frameLeft, mWindows[i].frameTop,
mWindows[i].frameRight, mWindows[i].frameBottom,
mWindows[i].visibleFrameLeft, mWindows[i].visibleFrameTop,
diff --git a/libs/ui/InputReader.cpp b/libs/ui/InputReader.cpp
index 88084c0..783cbc4 100644
--- a/libs/ui/InputReader.cpp
+++ b/libs/ui/InputReader.cpp
@@ -325,9 +325,6 @@
if (classes & INPUT_DEVICE_CLASS_DPAD) {
keyboardSources |= AINPUT_SOURCE_DPAD;
}
- if (classes & INPUT_DEVICE_CLASS_GAMEPAD) {
- keyboardSources |= AINPUT_SOURCE_GAMEPAD;
- }
if (keyboardSources != 0) {
device->addMapper(new KeyboardInputMapper(device,
diff --git a/libs/ui/InputTransport.cpp b/libs/ui/InputTransport.cpp
index 4c402dc..2c6346e 100644
--- a/libs/ui/InputTransport.cpp
+++ b/libs/ui/InputTransport.cpp
@@ -131,7 +131,10 @@
}
status_t InputChannel::sendSignal(char signal) {
- ssize_t nWrite = ::write(mSendPipeFd, & signal, 1);
+ ssize_t nWrite;
+ do {
+ nWrite = ::write(mSendPipeFd, & signal, 1);
+ } while (nWrite == -1 && errno == EINTR);
if (nWrite == 1) {
#if DEBUG_CHANNEL_SIGNALS
@@ -147,7 +150,11 @@
}
status_t InputChannel::receiveSignal(char* outSignal) {
- ssize_t nRead = ::read(mReceivePipeFd, outSignal, 1);
+ ssize_t nRead;
+ do {
+ nRead = ::read(mReceivePipeFd, outSignal, 1);
+ } while (nRead == -1 && errno == EINTR);
+
if (nRead == 1) {
#if DEBUG_CHANNEL_SIGNALS
LOGD("channel '%s' ~ received signal '%c'", mName.string(), *outSignal);
diff --git a/libs/utils/Looper.cpp b/libs/utils/Looper.cpp
index fd287da..b46279e 100644
--- a/libs/utils/Looper.cpp
+++ b/libs/utils/Looper.cpp
@@ -162,9 +162,11 @@
struct epoll_event eventItems[EPOLL_MAX_EVENTS];
int eventCount = epoll_wait(mEpollFd, eventItems, EPOLL_MAX_EVENTS, timeoutMillis);
if (eventCount < 0) {
- if (errno != EINTR) {
- LOGW("Poll failed with an unexpected error, errno=%d", errno);
+ if (errno == EINTR) {
+ return ALOOPER_POLL_WAKE;
}
+
+ LOGW("Poll failed with an unexpected error, errno=%d", errno);
return ALOOPER_POLL_ERROR;
}
@@ -182,44 +184,50 @@
#if DEBUG_POLL_AND_WAKE
LOGD("%p ~ pollOnce - handling events from %d fds", this, eventCount);
#endif
- { // acquire lock
- AutoMutex _l(mLock);
- for (int i = 0; i < eventCount; i++) {
- int fd = eventItems[i].data.fd;
- uint32_t epollEvents = eventItems[i].events;
- if (fd == mWakeReadPipeFd) {
- if (epollEvents & EPOLLIN) {
+ bool acquiredLock = false;
+ for (int i = 0; i < eventCount; i++) {
+ int fd = eventItems[i].data.fd;
+ uint32_t epollEvents = eventItems[i].events;
+ if (fd == mWakeReadPipeFd) {
+ if (epollEvents & EPOLLIN) {
#if DEBUG_POLL_AND_WAKE
- LOGD("%p ~ pollOnce - awoken", this);
+ LOGD("%p ~ pollOnce - awoken", this);
#endif
- char buffer[16];
- ssize_t nRead;
- do {
- nRead = read(mWakeReadPipeFd, buffer, sizeof(buffer));
- } while (nRead == sizeof(buffer));
- } else {
- LOGW("Ignoring unexpected epoll events 0x%x on wake read pipe.", epollEvents);
- }
+ char buffer[16];
+ ssize_t nRead;
+ do {
+ nRead = read(mWakeReadPipeFd, buffer, sizeof(buffer));
+ } while ((nRead == -1 && errno == EINTR) || nRead == sizeof(buffer));
} else {
- ssize_t requestIndex = mRequests.indexOfKey(fd);
- if (requestIndex >= 0) {
- int events = 0;
- if (epollEvents & EPOLLIN) events |= ALOOPER_EVENT_INPUT;
- if (epollEvents & EPOLLOUT) events |= ALOOPER_EVENT_OUTPUT;
- if (epollEvents & EPOLLERR) events |= ALOOPER_EVENT_ERROR;
- if (epollEvents & EPOLLHUP) events |= ALOOPER_EVENT_HANGUP;
+ LOGW("Ignoring unexpected epoll events 0x%x on wake read pipe.", epollEvents);
+ }
+ } else {
+ if (! acquiredLock) {
+ mLock.lock();
+ acquiredLock = true;
+ }
- Response response;
- response.events = events;
- response.request = mRequests.valueAt(requestIndex);
- mResponses.push(response);
- } else {
- LOGW("Ignoring unexpected epoll events 0x%x on fd %d that is "
- "no longer registered.", epollEvents, fd);
- }
+ ssize_t requestIndex = mRequests.indexOfKey(fd);
+ if (requestIndex >= 0) {
+ int events = 0;
+ if (epollEvents & EPOLLIN) events |= ALOOPER_EVENT_INPUT;
+ if (epollEvents & EPOLLOUT) events |= ALOOPER_EVENT_OUTPUT;
+ if (epollEvents & EPOLLERR) events |= ALOOPER_EVENT_ERROR;
+ if (epollEvents & EPOLLHUP) events |= ALOOPER_EVENT_HANGUP;
+
+ Response response;
+ response.events = events;
+ response.request = mRequests.valueAt(requestIndex);
+ mResponses.push(response);
+ } else {
+ LOGW("Ignoring unexpected epoll events 0x%x on fd %d that is "
+ "no longer registered.", epollEvents, fd);
}
}
}
+ if (acquiredLock) {
+ mLock.unlock();
+ }
for (size_t i = 0; i < mResponses.size(); i++) {
const Response& response = mResponses.itemAt(i);
@@ -272,7 +280,11 @@
LOGD("%p ~ wake", this);
#endif
- ssize_t nWrite = write(mWakeWritePipeFd, "W", 1);
+ ssize_t nWrite;
+ do {
+ nWrite = write(mWakeWritePipeFd, "W", 1);
+ } while (nWrite == -1 && errno == EINTR);
+
if (nWrite != 1) {
if (errno != EAGAIN) {
LOGW("Could not write wake signal, errno=%d", errno);
diff --git a/opengl/include/GLES/glext.h b/opengl/include/GLES/glext.h
index a5b3ead..65ab5e4 100644
--- a/opengl/include/GLES/glext.h
+++ b/opengl/include/GLES/glext.h
@@ -211,9 +211,12 @@
#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5
#endif
-/* GL_OES_texture_external */
-#ifndef GL_TEXTURE_EXTERNAL_OES
+/* GL_OES_EGL_image_external */
+#ifndef GL_OES_EGL_image_external
#define GL_TEXTURE_EXTERNAL_OES 0x8D65
+#define GL_SAMPLER_EXTERNAL_OES 0x8D66
+#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67
+#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68
#endif
/*------------------------------------------------------------------------*
@@ -782,9 +785,9 @@
typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array);
#endif
-/* GL_OES_texture_external */
-#ifndef GL_OES_texture_external
-#define GL_OES_texture_external 1
+/* GL_OES_EGL_image_external */
+#ifndef GL_OES_EGL_image_external
+#define GL_OES_EGL_image_external 1
#endif
/*------------------------------------------------------------------------*
diff --git a/opengl/include/GLES2/gl2ext.h b/opengl/include/GLES2/gl2ext.h
index de5d65a..9db4e25 100644
--- a/opengl/include/GLES2/gl2ext.h
+++ b/opengl/include/GLES2/gl2ext.h
@@ -146,9 +146,12 @@
#define GL_INT_10_10_10_2_OES 0x8DF7
#endif
-/* GL_OES_texture_external */
-#ifndef GL_TEXTURE_EXTERNAL_OES
+/* GL_OES_EGL_image_external */
+#ifndef GL_OES_EGL_image_external
#define GL_TEXTURE_EXTERNAL_OES 0x8D65
+#define GL_SAMPLER_EXTERNAL_OES 0x8D66
+#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67
+#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68
#endif
/*------------------------------------------------------------------------*
@@ -546,9 +549,9 @@
#define GL_OES_vertex_type_10_10_10_2 1
#endif
-/* GL_OES_texture_external */
-#ifndef GL_OES_texture_external
-#define GL_OES_texture_external 1
+/* GL_OES_EGL_image_external */
+#ifndef GL_OES_EGL_image_external
+#define GL_OES_EGL_image_external 1
#endif
/*------------------------------------------------------------------------*
diff --git a/services/surfaceflinger/GLExtensions.cpp b/services/surfaceflinger/GLExtensions.cpp
index 7f4f9fc..850866a 100644
--- a/services/surfaceflinger/GLExtensions.cpp
+++ b/services/surfaceflinger/GLExtensions.cpp
@@ -86,7 +86,7 @@
mHaveNpot = true;
}
- if (hasExtension("GL_OES_texture_external")) {
+ if (hasExtension("GL_OES_EGL_image_external")) {
mHaveTextureExternal = true;
} else if (strstr(mRenderer.string(), "Adreno")) {
// hack for Adreno 200
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 194c295..833181b 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -380,6 +380,7 @@
mReqWidth = reqWidth;
mReqHeight = reqHeight;
mReqFormat = reqFormat;
+ mFixedSize = reqWidth && reqHeight;
lcblk->reallocateAllExcept(index);
}
diff --git a/services/surfaceflinger/LayerBlur.cpp b/services/surfaceflinger/LayerBlur.cpp
index 2ee21b9..4cfcfe3 100644
--- a/services/surfaceflinger/LayerBlur.cpp
+++ b/services/surfaceflinger/LayerBlur.cpp
@@ -146,7 +146,7 @@
Region::const_iterator it = clip.begin();
Region::const_iterator const end = clip.end();
if (it != end) {
-#if defined(GL_OES_texture_external)
+#if defined(GL_OES_EGL_image_external)
if (GLExtensions::getInstance().haveTextureExternal()) {
glDisable(GL_TEXTURE_EXTERNAL_OES);
}
diff --git a/services/surfaceflinger/LayerDim.cpp b/services/surfaceflinger/LayerDim.cpp
index a1f339e..80cc52c 100644
--- a/services/surfaceflinger/LayerDim.cpp
+++ b/services/surfaceflinger/LayerDim.cpp
@@ -71,7 +71,7 @@
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0, 0, 0, alpha);
-#if defined(GL_OES_texture_external)
+#if defined(GL_OES_EGL_image_external)
if (GLExtensions::getInstance().haveTextureExternal()) {
glDisable(GL_TEXTURE_EXTERNAL_OES);
}
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 5a27fc5..b45f6fe 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1003,7 +1003,7 @@
glVertexPointer(2, GL_SHORT, 0, vertices);
glTexCoordPointer(2, GL_SHORT, 0, tcoords);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-#if defined(GL_OES_texture_external)
+#if defined(GL_OES_EGL_image_external)
if (GLExtensions::getInstance().haveTextureExternal()) {
glDisable(GL_TEXTURE_EXTERNAL_OES);
}
diff --git a/services/surfaceflinger/TextureManager.cpp b/services/surfaceflinger/TextureManager.cpp
index 76f6159..c9a15f5 100644
--- a/services/surfaceflinger/TextureManager.cpp
+++ b/services/surfaceflinger/TextureManager.cpp
@@ -43,7 +43,7 @@
}
GLenum TextureManager::getTextureTarget(const Image* image) {
-#if defined(GL_OES_texture_external)
+#if defined(GL_OES_EGL_image_external)
switch (image->target) {
case Texture::TEXTURE_EXTERNAL:
return GL_TEXTURE_EXTERNAL_OES;
@@ -85,7 +85,7 @@
pImage->height = 0;
GLenum target = GL_TEXTURE_2D;
-#if defined(GL_OES_texture_external)
+#if defined(GL_OES_EGL_image_external)
if (GLExtensions::getInstance().haveTextureExternal()) {
if (format && isYuvFormat(format)) {
target = GL_TEXTURE_EXTERNAL_OES;
@@ -306,7 +306,7 @@
if (target == GL_TEXTURE_2D) {
glBindTexture(GL_TEXTURE_2D, texture.name);
glEnable(GL_TEXTURE_2D);
-#if defined(GL_OES_texture_external)
+#if defined(GL_OES_EGL_image_external)
if (GLExtensions::getInstance().haveTextureExternal()) {
glDisable(GL_TEXTURE_EXTERNAL_OES);
}
@@ -329,7 +329,7 @@
void TextureManager::deactivateTextures()
{
glDisable(GL_TEXTURE_2D);
-#if defined(GL_OES_texture_external)
+#if defined(GL_OES_EGL_image_external)
if (GLExtensions::getInstance().haveTextureExternal()) {
glDisable(GL_TEXTURE_EXTERNAL_OES);
}