Merge "Refactoring Transaction_test continued"
diff --git a/include/input/InputEventLabels.h b/include/input/InputEventLabels.h
index 59d16d1..eaa562b 100644
--- a/include/input/InputEventLabels.h
+++ b/include/input/InputEventLabels.h
@@ -359,6 +359,9 @@
DEFINE_AXIS(BRAKE),
DEFINE_AXIS(DISTANCE),
DEFINE_AXIS(TILT),
+ DEFINE_AXIS(SCROLL),
+ DEFINE_AXIS(RELATIVE_X),
+ DEFINE_AXIS(RELATIVE_Y),
DEFINE_AXIS(GENERIC_1),
DEFINE_AXIS(GENERIC_2),
DEFINE_AXIS(GENERIC_3),
diff --git a/libs/binder/Android.bp b/libs/binder/Android.bp
index 8af2872..f3d4b7e 100644
--- a/libs/binder/Android.bp
+++ b/libs/binder/Android.bp
@@ -102,9 +102,6 @@
android: {
srcs: libbinder_device_interface_sources,
},
- host: {
- cflags: ["-D__ANDROID_HOST__"],
- },
vendor: {
exclude_srcs: libbinder_device_interface_sources,
},
diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp
index b6f3d7b..f3e8f45 100644
--- a/libs/binder/IServiceManager.cpp
+++ b/libs/binder/IServiceManager.cpp
@@ -30,7 +30,7 @@
#include <binder/IPermissionController.h>
#endif
-#ifndef __ANDROID_HOST__
+#ifdef __ANDROID__
#include <cutils/properties.h>
#endif
@@ -63,7 +63,7 @@
return gDefaultServiceManager;
}
-#if !defined(__ANDROID_VNDK__) && !defined(__ANDROID_HOST__)
+#if !defined(__ANDROID_VNDK__) && defined(__ANDROID__)
// IPermissionController is not accessible to vendors
bool checkCallingPermission(const String16& permission)
@@ -166,14 +166,14 @@
const bool isVendorService =
strcmp(ProcessState::self()->getDriverName().c_str(), "/dev/vndbinder") == 0;
const long timeout = uptimeMillis() + 5000;
+ // Vendor code can't access system properties
if (!gSystemBootCompleted && !isVendorService) {
-#ifdef __ANDROID_HOST__
- gSystemBootCompleted = true;
-#else
- // Vendor code can't access system properties
+#ifdef __ANDROID__
char bootCompleted[PROPERTY_VALUE_MAX];
property_get("sys.boot_completed", bootCompleted, "0");
gSystemBootCompleted = strcmp(bootCompleted, "1") == 0 ? true : false;
+#else
+ gSystemBootCompleted = true;
#endif
}
// retry interval in millisecond; note that vendor services stay at 100ms
diff --git a/libs/binder/include/private/binder/binder_module.h b/libs/binder/include/private/binder/binder_module.h
index 09e6ba0..c22be9f 100644
--- a/libs/binder/include/private/binder/binder_module.h
+++ b/libs/binder/include/private/binder/binder_module.h
@@ -24,7 +24,7 @@
/* obtain structures and constants from the kernel header */
// TODO(b/31559095): bionic on host
-#ifdef __ANDROID_HOST__
+#ifndef __ANDROID__
#define __packed __attribute__((__packed__))
#endif
diff --git a/libs/ui/Android.bp b/libs/ui/Android.bp
index bb85acc..47137f1 100644
--- a/libs/ui/Android.bp
+++ b/libs/ui/Android.bp
@@ -47,6 +47,7 @@
"-Wno-padded",
"-Wno-switch-enum",
+ "-Wno-format-pedantic",
],
sanitize: {
diff --git a/libs/ui/include/ui/DisplayInfo.h b/libs/ui/include/ui/DisplayInfo.h
index 8976d2d..0772210 100644
--- a/libs/ui/include/ui/DisplayInfo.h
+++ b/libs/ui/include/ui/DisplayInfo.h
@@ -24,6 +24,8 @@
namespace android {
+constexpr uint32_t NO_LAYER_STACK = static_cast<uint32_t>(-1);
+
struct DisplayInfo {
uint32_t w{0};
uint32_t h{0};
@@ -37,6 +39,7 @@
nsecs_t presentationDeadline{0};
uint32_t viewportW{0};
uint32_t viewportH{0};
+ uint32_t layerStack{NO_LAYER_STACK};
};
/* Display orientations as defined in Surface.java and ISurfaceComposer.h. */
@@ -47,6 +50,6 @@
DISPLAY_ORIENTATION_270 = 3
};
-}; // namespace android
+} // namespace android
#endif // ANDROID_COMPOSER_DISPLAY_INFO_H
diff --git a/opengl/OWNERS b/opengl/OWNERS
index 881f1b8..b505712 100644
--- a/opengl/OWNERS
+++ b/opengl/OWNERS
@@ -1,16 +1,7 @@
-# alanward@google.com
-chiur@google.com
chrisforbes@google.com
cnorthrop@google.com
courtneygo@google.com
-hliatis@google.com
ianelliott@google.com
jessehall@google.com
lpy@google.com
-marissaw@google.com
-nduca@google.com
-pmuetschard@google.com
-timvp@google.com
-tobine@google.com
-vhau@google.com
zzyiwei@google.com
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 039462e..e161e8c 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -35,7 +35,7 @@
#define DEBUG_INJECTION 0
// Log debug messages about input focus tracking.
-#define DEBUG_FOCUS 0
+static constexpr bool DEBUG_FOCUS = false;
// Log debug messages about the app switch latency optimization.
#define DEBUG_APP_SWITCH 0
@@ -313,9 +313,9 @@
// If dispatching is frozen, do not process timeouts or try to deliver any new events.
if (mDispatchFrozen) {
-#if DEBUG_FOCUS
- ALOGD("Dispatch frozen. Waiting some more.");
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Dispatch frozen. Waiting some more.");
+ }
return;
}
@@ -1041,11 +1041,11 @@
if (connection != nullptr) {
prepareDispatchCycleLocked(currentTime, connection, eventEntry, &inputTarget);
} else {
-#if DEBUG_FOCUS
- ALOGD("Dropping event delivery to target with channel '%s' because it "
- "is no longer registered with the input dispatcher.",
- inputTarget.inputChannel->getName().c_str());
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Dropping event delivery to target with channel '%s' because it "
+ "is no longer registered with the input dispatcher.",
+ inputTarget.inputChannel->getName().c_str());
+ }
}
}
}
@@ -1056,9 +1056,9 @@
const sp<InputWindowHandle>& windowHandle, nsecs_t* nextWakeupTime, const char* reason) {
if (applicationHandle == nullptr && windowHandle == nullptr) {
if (mInputTargetWaitCause != INPUT_TARGET_WAIT_CAUSE_SYSTEM_NOT_READY) {
-#if DEBUG_FOCUS
- ALOGD("Waiting for system to become ready for input. Reason: %s", reason);
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Waiting for system to become ready for input. Reason: %s", reason);
+ }
mInputTargetWaitCause = INPUT_TARGET_WAIT_CAUSE_SYSTEM_NOT_READY;
mInputTargetWaitStartTime = currentTime;
mInputTargetWaitTimeoutTime = LONG_LONG_MAX;
@@ -1067,10 +1067,10 @@
}
} else {
if (mInputTargetWaitCause != INPUT_TARGET_WAIT_CAUSE_APPLICATION_NOT_READY) {
-#if DEBUG_FOCUS
- ALOGD("Waiting for application to become ready for input: %s. Reason: %s",
- getApplicationWindowLabel(applicationHandle, windowHandle).c_str(), reason);
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Waiting for application to become ready for input: %s. Reason: %s",
+ getApplicationWindowLabel(applicationHandle, windowHandle).c_str(), reason);
+ }
nsecs_t timeout;
if (windowHandle != nullptr) {
timeout = windowHandle->getDispatchingTimeout(DEFAULT_INPUT_DISPATCHING_TIMEOUT);
@@ -1159,9 +1159,9 @@
}
void InputDispatcher::resetANRTimeoutsLocked() {
-#if DEBUG_FOCUS
- ALOGD("Resetting ANR timeouts.");
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Resetting ANR timeouts.");
+ }
// Reset input target wait timeout.
mInputTargetWaitCause = INPUT_TARGET_WAIT_CAUSE_NONE;
@@ -1253,11 +1253,11 @@
Unresponsive:
nsecs_t timeSpentWaitingForApplication = getTimeSpentWaitingForApplicationLocked(currentTime);
updateDispatchStatistics(currentTime, entry, injectionResult, timeSpentWaitingForApplication);
-#if DEBUG_FOCUS
- ALOGD("findFocusedWindow finished: injectionResult=%d, "
- "timeSpentWaitingForApplication=%0.1fms",
- injectionResult, timeSpentWaitingForApplication / 1000000.0);
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("findFocusedWindow finished: injectionResult=%d, "
+ "timeSpentWaitingForApplication=%0.1fms",
+ injectionResult, timeSpentWaitingForApplication / 1000000.0);
+ }
return injectionResult;
}
@@ -1308,11 +1308,11 @@
if (newGesture) {
bool down = maskedAction == AMOTION_EVENT_ACTION_DOWN;
if (switchedDevice && mTempTouchState.down && !down && !isHoverAction) {
-#if DEBUG_FOCUS
- ALOGD("Dropping event because a pointer for a different device is already down "
- "in display %" PRId32,
- displayId);
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Dropping event because a pointer for a different device is already down "
+ "in display %" PRId32,
+ displayId);
+ }
// TODO: test multiple simultaneous input streams.
injectionResult = INPUT_EVENT_INJECTION_FAILED;
switchedDevice = false;
@@ -1326,11 +1326,11 @@
mTempTouchState.displayId = displayId;
isSplit = false;
} else if (switchedDevice && maskedAction == AMOTION_EVENT_ACTION_MOVE) {
-#if DEBUG_FOCUS
- ALOGI("Dropping move event because a pointer for a different device is already active "
- "in display %" PRId32,
- displayId);
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGI("Dropping move event because a pointer for a different device is already active "
+ "in display %" PRId32,
+ displayId);
+ }
// TODO: test multiple simultaneous input streams.
injectionResult = INPUT_EVENT_INJECTION_PERMISSION_DENIED;
switchedDevice = false;
@@ -1420,11 +1420,11 @@
// If the pointer is not currently down, then ignore the event.
if (!mTempTouchState.down) {
-#if DEBUG_FOCUS
- ALOGD("Dropping event because the pointer is not down or we previously "
- "dropped the pointer down event in display %" PRId32,
- displayId);
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Dropping event because the pointer is not down or we previously "
+ "dropped the pointer down event in display %" PRId32,
+ displayId);
+ }
injectionResult = INPUT_EVENT_INJECTION_FAILED;
goto Failed;
}
@@ -1441,11 +1441,11 @@
findTouchedWindowAtLocked(displayId, x, y);
if (oldTouchedWindowHandle != newTouchedWindowHandle &&
oldTouchedWindowHandle != nullptr && newTouchedWindowHandle != nullptr) {
-#if DEBUG_FOCUS
- ALOGD("Touch is slipping out of window %s into window %s in display %" PRId32,
- oldTouchedWindowHandle->getName().c_str(),
- newTouchedWindowHandle->getName().c_str(), displayId);
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Touch is slipping out of window %s into window %s in display %" PRId32,
+ oldTouchedWindowHandle->getName().c_str(),
+ newTouchedWindowHandle->getName().c_str(), displayId);
+ }
// Make a slippery exit from the old window.
mTempTouchState.addOrUpdateWindow(oldTouchedWindowHandle,
InputTarget::FLAG_DISPATCH_AS_SLIPPERY_EXIT,
@@ -1514,11 +1514,11 @@
}
bool hasGestureMonitor = !mTempTouchState.gestureMonitors.empty();
if (!haveForegroundWindow && !hasGestureMonitor) {
-#if DEBUG_FOCUS
- ALOGD("Dropping event because there is no touched foreground window in display %" PRId32
- " or gesture monitor to receive it.",
- displayId);
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Dropping event because there is no touched foreground window in display "
+ "%" PRId32 " or gesture monitor to receive it.",
+ displayId);
+ }
injectionResult = INPUT_EVENT_INJECTION_FAILED;
goto Failed;
}
@@ -1622,18 +1622,19 @@
if (injectionPermission == INJECTION_PERMISSION_GRANTED) {
if (!wrongDevice) {
if (switchedDevice) {
-#if DEBUG_FOCUS
- ALOGD("Conflicting pointer actions: Switched to a different device.");
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Conflicting pointer actions: Switched to a different device.");
+ }
*outConflictingPointerActions = true;
}
if (isHoverAction) {
// Started hovering, therefore no longer down.
if (oldState && oldState->down) {
-#if DEBUG_FOCUS
- ALOGD("Conflicting pointer actions: Hover received while pointer was down.");
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Conflicting pointer actions: Hover received while pointer was "
+ "down.");
+ }
*outConflictingPointerActions = true;
}
mTempTouchState.reset();
@@ -1650,9 +1651,9 @@
} else if (maskedAction == AMOTION_EVENT_ACTION_DOWN) {
// First pointer went down.
if (oldState && oldState->down) {
-#if DEBUG_FOCUS
- ALOGD("Conflicting pointer actions: Down received while already down.");
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Conflicting pointer actions: Down received while already down.");
+ }
*outConflictingPointerActions = true;
}
} else if (maskedAction == AMOTION_EVENT_ACTION_POINTER_UP) {
@@ -1693,9 +1694,9 @@
mLastHoverWindowHandle = newHoverWindowHandle;
}
} else {
-#if DEBUG_FOCUS
- ALOGD("Not updating touch focus because injection was denied.");
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Not updating touch focus because injection was denied.");
+ }
}
Unresponsive:
@@ -1704,11 +1705,11 @@
nsecs_t timeSpentWaitingForApplication = getTimeSpentWaitingForApplicationLocked(currentTime);
updateDispatchStatistics(currentTime, entry, injectionResult, timeSpentWaitingForApplication);
-#if DEBUG_FOCUS
- ALOGD("findTouchedWindow finished: injectionResult=%d, injectionPermission=%d, "
- "timeSpentWaitingForApplication=%0.1fms",
- injectionResult, injectionPermission, timeSpentWaitingForApplication / 1000000.0);
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("findTouchedWindow finished: injectionResult=%d, injectionPermission=%d, "
+ "timeSpentWaitingForApplication=%0.1fms",
+ injectionResult, injectionPermission, timeSpentWaitingForApplication / 1000000.0);
+ }
return injectionResult;
}
@@ -2007,10 +2008,11 @@
if (!splitMotionEntry) {
return; // split event was dropped
}
-#if DEBUG_FOCUS
- ALOGD("channel '%s' ~ Split motion event.", connection->getInputChannelName().c_str());
- logOutboundMotionDetails(" ", splitMotionEntry);
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("channel '%s' ~ Split motion event.",
+ connection->getInputChannelName().c_str());
+ logOutboundMotionDetails(" ", splitMotionEntry);
+ }
enqueueDispatchEntriesLocked(currentTime, connection, splitMotionEntry, inputTarget);
splitMotionEntry->release();
return;
@@ -3252,9 +3254,13 @@
void InputDispatcher::setInputWindows(const std::vector<sp<InputWindowHandle>>& inputWindowHandles,
int32_t displayId,
const sp<ISetInputWindowsListener>& setInputWindowsListener) {
-#if DEBUG_FOCUS
- ALOGD("setInputWindows displayId=%" PRId32, displayId);
-#endif
+ if (DEBUG_FOCUS) {
+ std::string windowList;
+ for (const sp<InputWindowHandle>& iwh : inputWindowHandles) {
+ windowList += iwh->getName() + " ";
+ }
+ ALOGD("setInputWindows displayId=%" PRId32 " %s", displayId, windowList.c_str());
+ }
{ // acquire lock
std::scoped_lock _l(mLock);
@@ -3286,10 +3292,10 @@
if (oldFocusedWindowHandle != newFocusedWindowHandle) {
if (oldFocusedWindowHandle != nullptr) {
-#if DEBUG_FOCUS
- ALOGD("Focus left window: %s in display %" PRId32,
- oldFocusedWindowHandle->getName().c_str(), displayId);
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Focus left window: %s in display %" PRId32,
+ oldFocusedWindowHandle->getName().c_str(), displayId);
+ }
sp<InputChannel> focusedInputChannel =
getInputChannelLocked(oldFocusedWindowHandle->getToken());
if (focusedInputChannel != nullptr) {
@@ -3300,10 +3306,10 @@
mFocusedWindowHandlesByDisplay.erase(displayId);
}
if (newFocusedWindowHandle != nullptr) {
-#if DEBUG_FOCUS
- ALOGD("Focus entered window: %s in display %" PRId32,
- newFocusedWindowHandle->getName().c_str(), displayId);
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Focus entered window: %s in display %" PRId32,
+ newFocusedWindowHandle->getName().c_str(), displayId);
+ }
mFocusedWindowHandlesByDisplay[displayId] = newFocusedWindowHandle;
}
@@ -3318,10 +3324,10 @@
for (size_t i = 0; i < state.windows.size();) {
TouchedWindow& touchedWindow = state.windows[i];
if (!hasWindowHandleLocked(touchedWindow.windowHandle)) {
-#if DEBUG_FOCUS
- ALOGD("Touched window was removed: %s in display %" PRId32,
- touchedWindow.windowHandle->getName().c_str(), displayId);
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Touched window was removed: %s in display %" PRId32,
+ touchedWindow.windowHandle->getName().c_str(), displayId);
+ }
sp<InputChannel> touchedInputChannel =
getInputChannelLocked(touchedWindow.windowHandle->getToken());
if (touchedInputChannel != nullptr) {
@@ -3343,9 +3349,9 @@
// which might not happen until the next GC.
for (const sp<InputWindowHandle>& oldWindowHandle : oldWindowHandles) {
if (!hasWindowHandleLocked(oldWindowHandle)) {
-#if DEBUG_FOCUS
- ALOGD("Window went away: %s", oldWindowHandle->getName().c_str());
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Window went away: %s", oldWindowHandle->getName().c_str());
+ }
oldWindowHandle->releaseChannel();
}
}
@@ -3361,9 +3367,10 @@
void InputDispatcher::setFocusedApplication(
int32_t displayId, const sp<InputApplicationHandle>& inputApplicationHandle) {
-#if DEBUG_FOCUS
- ALOGD("setFocusedApplication displayId=%" PRId32, displayId);
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("setFocusedApplication displayId=%" PRId32 " %s", displayId,
+ inputApplicationHandle ? inputApplicationHandle->getName().c_str() : "<nullptr>");
+ }
{ // acquire lock
std::scoped_lock _l(mLock);
@@ -3381,10 +3388,6 @@
oldFocusedApplicationHandle.clear();
mFocusedApplicationHandlesByDisplay.erase(displayId);
}
-
-#if DEBUG_FOCUS
- // logDispatchStateLocked();
-#endif
} // release lock
// Wake up poll loop since it may need to make new input dispatching choices.
@@ -3401,9 +3404,9 @@
* display. The display-specified events won't be affected.
*/
void InputDispatcher::setFocusedDisplay(int32_t displayId) {
-#if DEBUG_FOCUS
- ALOGD("setFocusedDisplay displayId=%" PRId32, displayId);
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("setFocusedDisplay displayId=%" PRId32, displayId);
+ }
{ // acquire lock
std::scoped_lock _l(mLock);
@@ -3442,9 +3445,9 @@
}
}
-#if DEBUG_FOCUS
- logDispatchStateLocked();
-#endif
+ if (DEBUG_FOCUS) {
+ logDispatchStateLocked();
+ }
} // release lock
// Wake up poll loop since it may need to make new input dispatching choices.
@@ -3452,9 +3455,9 @@
}
void InputDispatcher::setInputDispatchMode(bool enabled, bool frozen) {
-#if DEBUG_FOCUS
- ALOGD("setInputDispatchMode: enabled=%d, frozen=%d", enabled, frozen);
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("setInputDispatchMode: enabled=%d, frozen=%d", enabled, frozen);
+ }
bool changed;
{ // acquire lock
@@ -3476,9 +3479,9 @@
changed = false;
}
-#if DEBUG_FOCUS
- logDispatchStateLocked();
-#endif
+ if (DEBUG_FOCUS) {
+ logDispatchStateLocked();
+ }
} // release lock
if (changed) {
@@ -3488,9 +3491,9 @@
}
void InputDispatcher::setInputFilterEnabled(bool enabled) {
-#if DEBUG_FOCUS
- ALOGD("setInputFilterEnabled: enabled=%d", enabled);
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("setInputFilterEnabled: enabled=%d", enabled);
+ }
{ // acquire lock
std::scoped_lock _l(mLock);
@@ -3509,9 +3512,9 @@
bool InputDispatcher::transferTouchFocus(const sp<IBinder>& fromToken, const sp<IBinder>& toToken) {
if (fromToken == toToken) {
-#if DEBUG_FOCUS
- ALOGD("Trivial transfer to same window.");
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Trivial transfer to same window.");
+ }
return true;
}
@@ -3524,14 +3527,14 @@
ALOGW("Cannot transfer focus because from or to window not found.");
return false;
}
-#if DEBUG_FOCUS
- ALOGD("transferTouchFocus: fromWindowHandle=%s, toWindowHandle=%s",
- fromWindowHandle->getName().c_str(), toWindowHandle->getName().c_str());
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("transferTouchFocus: fromWindowHandle=%s, toWindowHandle=%s",
+ fromWindowHandle->getName().c_str(), toWindowHandle->getName().c_str());
+ }
if (fromWindowHandle->getInfo()->displayId != toWindowHandle->getInfo()->displayId) {
-#if DEBUG_FOCUS
- ALOGD("Cannot transfer focus because windows are on different displays.");
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Cannot transfer focus because windows are on different displays.");
+ }
return false;
}
@@ -3559,9 +3562,9 @@
Found:
if (!found) {
-#if DEBUG_FOCUS
- ALOGD("Focus transfer failed because from window did not have focus.");
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Focus transfer failed because from window did not have focus.");
+ }
return false;
}
@@ -3577,9 +3580,9 @@
synthesizeCancelationEventsForConnectionLocked(fromConnection, options);
}
-#if DEBUG_FOCUS
- logDispatchStateLocked();
-#endif
+ if (DEBUG_FOCUS) {
+ logDispatchStateLocked();
+ }
} // release lock
// Wake up poll loop since it may need to make new input dispatching choices.
@@ -3588,9 +3591,9 @@
}
void InputDispatcher::resetAndDropEverythingLocked(const char* reason) {
-#if DEBUG_FOCUS
- ALOGD("Resetting and dropping all events (%s).", reason);
-#endif
+ if (DEBUG_FOCUS) {
+ ALOGD("Resetting and dropping all events (%s).", reason);
+ }
CancelationOptions options(CancelationOptions::CANCEL_ALL_EVENTS, reason);
synthesizeCancelationEventsForAllConnectionsLocked(options);
diff --git a/services/inputflinger/reader/EventHub.cpp b/services/inputflinger/reader/EventHub.cpp
index c15ecfd..efe3809 100644
--- a/services/inputflinger/reader/EventHub.cpp
+++ b/services/inputflinger/reader/EventHub.cpp
@@ -271,9 +271,8 @@
ALOGI("Video device scanning disabled");
}
- struct epoll_event eventItem;
- memset(&eventItem, 0, sizeof(eventItem));
- eventItem.events = EPOLLIN;
+ struct epoll_event eventItem = {};
+ eventItem.events = EPOLLIN | EPOLLWAKEUP;
eventItem.data.fd = mINotifyFd;
int result = epoll_ctl(mEpollFd, EPOLL_CTL_ADD, mINotifyFd, &eventItem);
LOG_ALWAYS_FATAL_IF(result != 0, "Could not add INotify to epoll instance. errno=%d", errno);
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
index 6bd0ea9..34603b9 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
@@ -3621,9 +3621,9 @@
const float scaledX = x * mXScale;
const float scaledY = y * mYScale;
return x >= mRawPointerAxes.x.minValue && x <= mRawPointerAxes.x.maxValue &&
- scaledX >= mPhysicalLeft && scaledX <= mPhysicalLeft + mPhysicalWidth &&
+ scaledX >= mSurfaceLeft && scaledX <= mSurfaceLeft + mSurfaceWidth &&
y >= mRawPointerAxes.y.minValue && y <= mRawPointerAxes.y.maxValue &&
- scaledY >= mPhysicalTop && scaledY <= mPhysicalTop + mPhysicalHeight;
+ scaledY >= mSurfaceTop && scaledY <= mSurfaceTop + mSurfaceHeight;
}
const TouchInputMapper::VirtualKey* TouchInputMapper::findVirtualKeyHit(int32_t x, int32_t y) {
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index 2153108..31b1652 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -202,6 +202,20 @@
mConfig.setDisplayViewports(mViewports);
}
+ bool updateViewport(const DisplayViewport& viewport) {
+ size_t count = mViewports.size();
+ for (size_t i = 0; i < count; i++) {
+ const DisplayViewport& currentViewport = mViewports[i];
+ if (currentViewport.displayId == viewport.displayId) {
+ mViewports[i] = viewport;
+ mConfig.setDisplayViewports(mViewports);
+ return true;
+ }
+ }
+ // no viewport found.
+ return false;
+ }
+
void addExcludedDeviceName(const std::string& deviceName) {
mConfig.excludedDeviceNames.push_back(deviceName);
}
@@ -6593,4 +6607,30 @@
ASSERT_EQ(SECONDARY_DISPLAY_ID, args.displayId);
}
+/**
+ * Test touch should not work if outside of surface.
+ */
+TEST_F(MultiTouchInputMapperTest, Viewports_SurfaceRange) {
+ MultiTouchInputMapper* mapper = new MultiTouchInputMapper(mDevice);
+ addConfigurationProperty("touch.deviceType", "touchScreen");
+ prepareDisplay(DISPLAY_ORIENTATION_0);
+ // Let surface be different from physical display.
+ std::optional<DisplayViewport> internalViewport =
+ mFakePolicy->getDisplayViewportByType(ViewportType::VIEWPORT_INTERNAL);
+ internalViewport->logicalLeft = internalViewport->physicalTop + 20;
+ internalViewport->logicalTop = internalViewport->physicalRight + 20;
+ internalViewport->logicalRight = internalViewport->physicalRight - 20;
+ internalViewport->logicalBottom = internalViewport->physicalBottom - 20;
+ mFakePolicy->updateViewport(internalViewport.value());
+
+ prepareAxes(POSITION);
+ addMapperAndConfigure(mapper);
+
+ int32_t rawX = 10;
+ int32_t rawY = 10;
+ processPosition(mapper, rawX, rawY);
+ processSync(mapper);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled());
+}
+
} // namespace android
diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
index 2e45953..43ab87a 100644
--- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
@@ -288,6 +288,13 @@
const auto& profile = *mOutput.getDisplayColorProfile();
if (includeGeometry) {
+ // Clear the forceClientComposition flag before it is set for any
+ // reason. Note that since it can be set by some checks below when
+ // updating the geometry state, we only clear it when updating the
+ // geometry since those conditions for forcing client composition won't
+ // go away otherwise.
+ mState.forceClientComposition = false;
+
mState.displayFrame = calculateOutputDisplayFrame();
mState.sourceCrop = calculateOutputSourceCrop();
mState.bufferTransform =
diff --git a/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp b/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp
index 88cedfa..a1c156a 100644
--- a/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp
+++ b/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp
@@ -458,6 +458,7 @@
TEST_F(OutputLayerUpdateCompositionStateTest, setsStateNormally) {
mLayerFEState.isSecure = true;
mOutputState.isSecure = true;
+ mOutputLayer.editState().forceClientComposition = true;
setupGeometryChildCallValues();
@@ -520,13 +521,25 @@
}
TEST_F(OutputLayerUpdateCompositionStateTest, doesNotRecomputeGeometryIfNotRequested) {
+ mOutputLayer.editState().forceClientComposition = false;
+
mOutputLayer.updateCompositionState(false);
EXPECT_EQ(false, mOutputLayer.getState().forceClientComposition);
}
+TEST_F(OutputLayerUpdateCompositionStateTest,
+ doesNotClearForceClientCompositionIfNotDoingGeometry) {
+ mOutputLayer.editState().forceClientComposition = true;
+
+ mOutputLayer.updateCompositionState(false);
+
+ EXPECT_EQ(true, mOutputLayer.getState().forceClientComposition);
+}
+
TEST_F(OutputLayerUpdateCompositionStateTest, clientCompositionForcedFromFrontEndFlagAtAnyTime) {
mLayerFEState.forceClientComposition = true;
+ mOutputLayer.editState().forceClientComposition = false;
mOutputLayer.updateCompositionState(false);
@@ -535,6 +548,7 @@
TEST_F(OutputLayerUpdateCompositionStateTest,
clientCompositionForcedFromUnsupportedDataspaceAtAnyTime) {
+ mOutputLayer.editState().forceClientComposition = false;
EXPECT_CALL(mDisplayColorProfile, isDataspaceSupported(_)).WillRepeatedly(Return(false));
mOutputLayer.updateCompositionState(false);
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index 5277320..ce4e1e6 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -31,6 +31,7 @@
#include <math/mat4.h>
#include <renderengine/RenderEngine.h>
#include <system/window.h>
+#include <ui/DisplayInfo.h>
#include <ui/GraphicTypes.h>
#include <ui/HdrCapabilities.h>
#include <ui/Region.h>
@@ -65,10 +66,6 @@
constexpr static float sDefaultMinLumiance = 0.0;
constexpr static float sDefaultMaxLumiance = 500.0;
- enum {
- NO_LAYER_STACK = 0xFFFFFFFF,
- };
-
explicit DisplayDevice(DisplayDeviceCreationArgs&& args);
virtual ~DisplayDevice();
@@ -201,7 +198,7 @@
int32_t sequenceId = sNextSequenceId++;
std::optional<DisplayId> displayId;
sp<IGraphicBufferProducer> surface;
- uint32_t layerStack = DisplayDevice::NO_LAYER_STACK;
+ uint32_t layerStack = NO_LAYER_STACK;
Rect viewport;
Rect frame;
uint8_t orientation = 0;
diff --git a/services/surfaceflinger/Scheduler/DispSyncSource.h b/services/surfaceflinger/Scheduler/DispSyncSource.h
index 740c8c4..536464e 100644
--- a/services/surfaceflinger/Scheduler/DispSyncSource.h
+++ b/services/surfaceflinger/Scheduler/DispSyncSource.h
@@ -32,6 +32,7 @@
~DispSyncSource() override = default;
// The following methods are implementation of VSyncSource.
+ const char* getName() const override { return mName; }
void setVSyncEnabled(bool enable) override;
void setCallback(VSyncSource::Callback* callback) override;
void setPhaseOffset(nsecs_t phaseOffset) override;
diff --git a/services/surfaceflinger/Scheduler/EventThread.cpp b/services/surfaceflinger/Scheduler/EventThread.cpp
index 9d1f777..8d9adc8 100644
--- a/services/surfaceflinger/Scheduler/EventThread.cpp
+++ b/services/surfaceflinger/Scheduler/EventThread.cpp
@@ -154,23 +154,11 @@
namespace impl {
-EventThread::EventThread(std::unique_ptr<VSyncSource> src,
- InterceptVSyncsCallback interceptVSyncsCallback, const char* threadName)
- : EventThread(nullptr, std::move(src), std::move(interceptVSyncsCallback), threadName) {}
-
-EventThread::EventThread(VSyncSource* src, InterceptVSyncsCallback interceptVSyncsCallback,
- const char* threadName)
- : EventThread(src, nullptr, std::move(interceptVSyncsCallback), threadName) {}
-
-EventThread::EventThread(VSyncSource* src, std::unique_ptr<VSyncSource> uniqueSrc,
- InterceptVSyncsCallback interceptVSyncsCallback, const char* threadName)
- : mVSyncSource(src),
- mVSyncSourceUnique(std::move(uniqueSrc)),
+EventThread::EventThread(std::unique_ptr<VSyncSource> vsyncSource,
+ InterceptVSyncsCallback interceptVSyncsCallback)
+ : mVSyncSource(std::move(vsyncSource)),
mInterceptVSyncsCallback(std::move(interceptVSyncsCallback)),
- mThreadName(threadName) {
- if (src == nullptr) {
- mVSyncSource = mVSyncSourceUnique.get();
- }
+ mThreadName(mVSyncSource->getName()) {
mVSyncSource->setCallback(this);
mThread = std::thread([this]() NO_THREAD_SAFETY_ANALYSIS {
@@ -178,7 +166,7 @@
threadMain(lock);
});
- pthread_setname_np(mThread.native_handle(), threadName);
+ pthread_setname_np(mThread.native_handle(), mThreadName);
pid_t tid = pthread_gettid_np(mThread.native_handle());
diff --git a/services/surfaceflinger/Scheduler/EventThread.h b/services/surfaceflinger/Scheduler/EventThread.h
index dd23b88..a029586 100644
--- a/services/surfaceflinger/Scheduler/EventThread.h
+++ b/services/surfaceflinger/Scheduler/EventThread.h
@@ -62,6 +62,8 @@
};
virtual ~VSyncSource() {}
+
+ virtual const char* getName() const = 0;
virtual void setVSyncEnabled(bool enable) = 0;
virtual void setCallback(Callback* callback) = 0;
virtual void setPhaseOffset(nsecs_t phaseOffset) = 0;
@@ -126,9 +128,7 @@
public:
using InterceptVSyncsCallback = std::function<void(nsecs_t)>;
- // TODO(b/128863962): Once the Scheduler is complete this constructor will become obsolete.
- EventThread(VSyncSource*, InterceptVSyncsCallback, const char* threadName);
- EventThread(std::unique_ptr<VSyncSource>, InterceptVSyncsCallback, const char* threadName);
+ EventThread(std::unique_ptr<VSyncSource>, InterceptVSyncsCallback);
~EventThread();
sp<EventThreadConnection> createEventConnection(
@@ -157,10 +157,6 @@
using DisplayEventConsumers = std::vector<sp<EventThreadConnection>>;
- // TODO(b/128863962): Once the Scheduler is complete this constructor will become obsolete.
- EventThread(VSyncSource* src, std::unique_ptr<VSyncSource> uniqueSrc,
- InterceptVSyncsCallback interceptVSyncsCallback, const char* threadName);
-
void threadMain(std::unique_lock<std::mutex>& lock) REQUIRES(mMutex);
bool shouldConsumeEvent(const DisplayEventReceiver::Event& event,
@@ -174,9 +170,7 @@
// Implements VSyncSource::Callback
void onVSyncEvent(nsecs_t timestamp) override;
- // TODO(b/128863962): Once the Scheduler is complete this pointer will become obsolete.
- VSyncSource* mVSyncSource GUARDED_BY(mMutex) = nullptr;
- std::unique_ptr<VSyncSource> mVSyncSourceUnique GUARDED_BY(mMutex) = nullptr;
+ const std::unique_ptr<VSyncSource> mVSyncSource GUARDED_BY(mMutex);
const InterceptVSyncsCallback mInterceptVSyncsCallback;
const char* const mThreadName;
diff --git a/services/surfaceflinger/Scheduler/InjectVSyncSource.h b/services/surfaceflinger/Scheduler/InjectVSyncSource.h
index 90609af..6c502e6 100644
--- a/services/surfaceflinger/Scheduler/InjectVSyncSource.h
+++ b/services/surfaceflinger/Scheduler/InjectVSyncSource.h
@@ -42,6 +42,7 @@
}
}
+ const char* getName() const override { return "inject"; }
void setVSyncEnabled(bool) override {}
void setPhaseOffset(nsecs_t) override {}
void pauseVsyncCallback(bool) {}
@@ -51,4 +52,4 @@
VSyncSource::Callback* mCallback GUARDED_BY(mCallbackMutex) = nullptr;
};
-} // namespace android
\ No newline at end of file
+} // namespace android
diff --git a/services/surfaceflinger/Scheduler/MessageQueue.cpp b/services/surfaceflinger/Scheduler/MessageQueue.cpp
index fcb307f..5318b00 100644
--- a/services/surfaceflinger/Scheduler/MessageQueue.cpp
+++ b/services/surfaceflinger/Scheduler/MessageQueue.cpp
@@ -85,24 +85,6 @@
mHandler = new Handler(*this);
}
-void MessageQueue::setEventThread(android::EventThread* eventThread,
- ResyncCallback resyncCallback) {
- if (mEventThread == eventThread) {
- return;
- }
-
- if (mEventTube.getFd() >= 0) {
- mLooper->removeFd(mEventTube.getFd());
- }
-
- mEventThread = eventThread;
- mEvents = eventThread->createEventConnection(std::move(resyncCallback),
- ISurfaceComposer::eConfigChangedSuppress);
- mEvents->stealReceiveChannel(&mEventTube);
- mLooper->addFd(mEventTube.getFd(), 0, Looper::EVENT_INPUT, MessageQueue::cb_eventReceiver,
- this);
-}
-
void MessageQueue::setEventConnection(const sp<EventThreadConnection>& connection) {
if (mEventTube.getFd() >= 0) {
mLooper->removeFd(mEventTube.getFd());
diff --git a/services/surfaceflinger/Scheduler/MessageQueue.h b/services/surfaceflinger/Scheduler/MessageQueue.h
index 0b2206d..fcfc4aa 100644
--- a/services/surfaceflinger/Scheduler/MessageQueue.h
+++ b/services/surfaceflinger/Scheduler/MessageQueue.h
@@ -85,8 +85,6 @@
virtual ~MessageQueue();
virtual void init(const sp<SurfaceFlinger>& flinger) = 0;
- // TODO(b/128863962): Remove this function once everything is migrated to Scheduler.
- virtual void setEventThread(EventThread* events, ResyncCallback resyncCallback) = 0;
virtual void setEventConnection(const sp<EventThreadConnection>& connection) = 0;
virtual void waitMessage() = 0;
virtual status_t postMessage(const sp<MessageBase>& message, nsecs_t reltime = 0) = 0;
@@ -115,7 +113,6 @@
sp<SurfaceFlinger> mFlinger;
sp<Looper> mLooper;
- android::EventThread* mEventThread;
sp<EventThreadConnection> mEvents;
gui::BitTube mEventTube;
sp<Handler> mHandler;
@@ -126,7 +123,6 @@
public:
~MessageQueue() override = default;
void init(const sp<SurfaceFlinger>& flinger) override;
- void setEventThread(android::EventThread* events, ResyncCallback resyncCallback) override;
void setEventConnection(const sp<EventThreadConnection>& connection) override;
void waitMessage() override;
diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index add56fc..d60e101 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -41,6 +41,7 @@
#include "DispSyncSource.h"
#include "EventControlThread.h"
#include "EventThread.h"
+#include "InjectVSyncSource.h"
#include "OneShotTimer.h"
#include "SchedulerUtils.h"
#include "SurfaceFlingerProperties.h"
@@ -116,11 +117,20 @@
return *mPrimaryDispSync;
}
+std::unique_ptr<VSyncSource> Scheduler::makePrimaryDispSyncSource(
+ const char* name, nsecs_t phaseOffsetNs, nsecs_t offsetThresholdForNextVsync) {
+ return std::make_unique<DispSyncSource>(mPrimaryDispSync.get(), phaseOffsetNs,
+ offsetThresholdForNextVsync, true /* traceVsync */,
+ name);
+}
+
Scheduler::ConnectionHandle Scheduler::createConnection(
const char* connectionName, nsecs_t phaseOffsetNs, nsecs_t offsetThresholdForNextVsync,
impl::EventThread::InterceptVSyncsCallback interceptCallback) {
- auto eventThread = makeEventThread(connectionName, phaseOffsetNs, offsetThresholdForNextVsync,
- std::move(interceptCallback));
+ auto vsyncSource =
+ makePrimaryDispSyncSource(connectionName, phaseOffsetNs, offsetThresholdForNextVsync);
+ auto eventThread = std::make_unique<impl::EventThread>(std::move(vsyncSource),
+ std::move(interceptCallback));
return createConnection(std::move(eventThread));
}
@@ -135,16 +145,6 @@
return handle;
}
-std::unique_ptr<EventThread> Scheduler::makeEventThread(
- const char* connectionName, nsecs_t phaseOffsetNs, nsecs_t offsetThresholdForNextVsync,
- impl::EventThread::InterceptVSyncsCallback&& interceptCallback) {
- auto source = std::make_unique<DispSyncSource>(mPrimaryDispSync.get(), phaseOffsetNs,
- offsetThresholdForNextVsync,
- true /* traceVsync */, connectionName);
- return std::make_unique<impl::EventThread>(std::move(source), std::move(interceptCallback),
- connectionName);
-}
-
sp<EventThreadConnection> Scheduler::createConnectionInternal(
EventThread* eventThread, ISurfaceComposer::ConfigChanged configChanged) {
return eventThread->createEventConnection([&] { resync(); }, configChanged);
@@ -156,11 +156,6 @@
return createConnectionInternal(mConnections[handle].thread.get(), configChanged);
}
-EventThread* Scheduler::getEventThread(ConnectionHandle handle) {
- RETURN_IF_INVALID_HANDLE(handle, nullptr);
- return mConnections[handle].thread.get();
-}
-
sp<EventThreadConnection> Scheduler::getEventConnection(ConnectionHandle handle) {
RETURN_IF_INVALID_HANDLE(handle, nullptr);
return mConnections[handle].connection;
@@ -203,6 +198,37 @@
stats->vsyncPeriod = mPrimaryDispSync->getPeriod();
}
+Scheduler::ConnectionHandle Scheduler::enableVSyncInjection(bool enable) {
+ if (mInjectVSyncs == enable) {
+ return {};
+ }
+
+ ALOGV("%s VSYNC injection", enable ? "Enabling" : "Disabling");
+
+ if (!mInjectorConnectionHandle) {
+ auto vsyncSource = std::make_unique<InjectVSyncSource>();
+ mVSyncInjector = vsyncSource.get();
+
+ auto eventThread =
+ std::make_unique<impl::EventThread>(std::move(vsyncSource),
+ impl::EventThread::InterceptVSyncsCallback());
+
+ mInjectorConnectionHandle = createConnection(std::move(eventThread));
+ }
+
+ mInjectVSyncs = enable;
+ return mInjectorConnectionHandle;
+}
+
+bool Scheduler::injectVSync(nsecs_t when) {
+ if (!mInjectVSyncs || !mVSyncInjector) {
+ return false;
+ }
+
+ mVSyncInjector->onInjectSyncEvent(when);
+ return true;
+}
+
void Scheduler::enableHardwareVsync() {
std::lock_guard<std::mutex> lock(mHWVsyncLock);
if (!mPrimaryHWVsyncEnabled && mHWVsyncAvailable) {
diff --git a/services/surfaceflinger/Scheduler/Scheduler.h b/services/surfaceflinger/Scheduler/Scheduler.h
index 0c8c335..a5971fe 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.h
+++ b/services/surfaceflinger/Scheduler/Scheduler.h
@@ -36,6 +36,7 @@
class DispSync;
class FenceTime;
+class InjectVSyncSource;
struct DisplayStateInfo;
class Scheduler {
@@ -63,7 +64,6 @@
sp<IDisplayEventConnection> createDisplayEventConnection(ConnectionHandle,
ISurfaceComposer::ConfigChanged);
- EventThread* getEventThread(ConnectionHandle);
sp<EventThreadConnection> getEventConnection(ConnectionHandle);
void onHotplugReceived(ConnectionHandle, PhysicalDisplayId, bool connected);
@@ -77,6 +77,12 @@
void getDisplayStatInfo(DisplayStatInfo* stats);
+ // Returns injector handle if injection has toggled, or an invalid handle otherwise.
+ ConnectionHandle enableVSyncInjection(bool enable);
+
+ // Returns false if injection is disabled.
+ bool injectVSync(nsecs_t when);
+
void enableHardwareVsync();
void disableHardwareVsync(bool makeUnavailable);
@@ -138,12 +144,10 @@
Scheduler(std::unique_ptr<DispSync>, std::unique_ptr<EventControlThread>,
const scheduler::RefreshRateConfigs&);
- // Creates a connection on the given EventThread and forwards the given callbacks.
- std::unique_ptr<EventThread> makeEventThread(const char* connectionName, nsecs_t phaseOffsetNs,
- nsecs_t offsetThresholdForNextVsync,
- impl::EventThread::InterceptVSyncsCallback&&);
+ std::unique_ptr<VSyncSource> makePrimaryDispSyncSource(const char* name, nsecs_t phaseOffsetNs,
+ nsecs_t offsetThresholdForNextVsync);
- // Create a connection on the given EventThread and forward the resync callback.
+ // Create a connection on the given EventThread.
ConnectionHandle createConnection(std::unique_ptr<EventThread>);
sp<EventThreadConnection> createConnectionInternal(EventThread*,
ISurfaceComposer::ConfigChanged);
@@ -173,6 +177,10 @@
ConnectionHandle::Id mNextConnectionHandleId = 0;
std::unordered_map<ConnectionHandle, Connection> mConnections;
+ bool mInjectVSyncs = false;
+ InjectVSyncSource* mVSyncInjector = nullptr;
+ ConnectionHandle mInjectorConnectionHandle;
+
std::mutex mHWVsyncLock;
bool mPrimaryHWVsyncEnabled GUARDED_BY(mHWVsyncLock) = false;
bool mHWVsyncAvailable GUARDED_BY(mHWVsyncLock) = false;
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 83832b9..41afb5d 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -101,7 +101,6 @@
#include "Scheduler/DispSyncSource.h"
#include "Scheduler/EventControlThread.h"
#include "Scheduler/EventThread.h"
-#include "Scheduler/InjectVSyncSource.h"
#include "Scheduler/MessageQueue.h"
#include "Scheduler/PhaseOffsets.h"
#include "Scheduler/Scheduler.h"
@@ -814,11 +813,15 @@
info.viewportW = uint32_t(viewport.getWidth());
info.viewportH = uint32_t(viewport.getHeight());
}
+ info.layerStack = display->getLayerStack();
} else {
// TODO: where should this value come from?
static const int TV_DENSITY = 213;
info.density = TV_DENSITY / 160.0f;
info.orientation = 0;
+
+ const auto display = getDisplayDeviceLocked(displayToken);
+ info.layerStack = display->getLayerStack();
}
info.xdpi = xdpi;
@@ -1195,48 +1198,20 @@
status_t SurfaceFlinger::enableVSyncInjections(bool enable) {
postMessageSync(new LambdaMessage([&] {
- Mutex::Autolock _l(mStateLock);
+ Mutex::Autolock lock(mStateLock);
- if (mInjectVSyncs == enable) {
- return;
+ if (const auto handle = mScheduler->enableVSyncInjection(enable)) {
+ mEventQueue->setEventConnection(
+ mScheduler->getEventConnection(enable ? handle : mSfConnectionHandle));
}
-
- // TODO(b/128863962): Part of the Injector should be refactored, so that it
- // can be passed to Scheduler.
- if (enable) {
- ALOGV("VSync Injections enabled");
- if (mVSyncInjector.get() == nullptr) {
- mVSyncInjector = std::make_unique<InjectVSyncSource>();
- mInjectorEventThread = std::make_unique<
- impl::EventThread>(mVSyncInjector.get(),
- impl::EventThread::InterceptVSyncsCallback(),
- "injEventThread");
- }
- mEventQueue->setEventThread(mInjectorEventThread.get(), [&] { mScheduler->resync(); });
- } else {
- ALOGV("VSync Injections disabled");
- mEventQueue->setEventThread(mScheduler->getEventThread(mSfConnectionHandle),
- [&] { mScheduler->resync(); });
- }
-
- mInjectVSyncs = enable;
}));
return NO_ERROR;
}
status_t SurfaceFlinger::injectVSync(nsecs_t when) {
- Mutex::Autolock _l(mStateLock);
-
- if (!mInjectVSyncs) {
- ALOGE("VSync Injections not enabled");
- return BAD_VALUE;
- }
- if (mInjectVSyncs && mInjectorEventThread.get() != nullptr) {
- ALOGV("Injecting VSync inside SurfaceFlinger");
- mVSyncInjector->onInjectSyncEvent(when);
- }
- return NO_ERROR;
+ Mutex::Autolock lock(mStateLock);
+ return mScheduler->injectVSync(when) ? NO_ERROR : BAD_VALUE;
}
status_t SurfaceFlinger::getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const
@@ -4119,6 +4094,7 @@
const int32_t offscreenRootLayerId = INT32_MAX - 2;
rootProto->set_id(offscreenRootLayerId);
rootProto->set_name("Offscreen Root");
+ rootProto->set_parent(-1);
for (Layer* offscreenLayer : mOffscreenLayers) {
// Add layer as child of the fake root
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index c922f30..8c9b546 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -89,7 +89,6 @@
class HWComposer;
class IGraphicBufferProducer;
class IInputFlinger;
-class InjectVSyncSource;
class Layer;
class MessageBase;
class RefreshRateOverlay;
@@ -931,8 +930,6 @@
// constant members (no synchronization needed for access)
const nsecs_t mBootTime = systemTime();
bool mGpuToCpuSupported = false;
- std::unique_ptr<EventThread> mInjectorEventThread;
- std::unique_ptr<InjectVSyncSource> mVSyncInjector;
// Can only accessed from the main thread, these members
// don't need synchronization
@@ -1050,8 +1047,6 @@
* Feature prototyping
*/
- bool mInjectVSyncs = false;
-
// Static screen stats
bool mHasPoweredOff = false;
diff --git a/services/surfaceflinger/tests/unittests/EventThreadTest.cpp b/services/surfaceflinger/tests/unittests/EventThreadTest.cpp
index dbd9b84..2662f52 100644
--- a/services/surfaceflinger/tests/unittests/EventThreadTest.cpp
+++ b/services/surfaceflinger/tests/unittests/EventThreadTest.cpp
@@ -42,6 +42,8 @@
class MockVSyncSource : public VSyncSource {
public:
+ const char* getName() const override { return "test"; }
+
MOCK_METHOD1(setVSyncEnabled, void(bool));
MOCK_METHOD1(setCallback, void(VSyncSource::Callback*));
MOCK_METHOD1(setPhaseOffset, void(nsecs_t));
@@ -54,8 +56,7 @@
protected:
class MockEventThreadConnection : public EventThreadConnection {
public:
- MockEventThreadConnection(android::impl::EventThread* eventThread,
- ResyncCallback&& resyncCallback,
+ MockEventThreadConnection(impl::EventThread* eventThread, ResyncCallback&& resyncCallback,
ISurfaceComposer::ConfigChanged configChanged)
: EventThreadConnection(eventThread, std::move(resyncCallback), configChanged) {}
MOCK_METHOD1(postEvent, status_t(const DisplayEventReceiver::Event& event));
@@ -67,7 +68,7 @@
EventThreadTest();
~EventThreadTest() override;
- void createThread();
+ void createThread(std::unique_ptr<VSyncSource>);
sp<MockEventThreadConnection> createConnection(ConnectionEventRecorder& recorder,
ISurfaceComposer::ConfigChanged configChanged);
@@ -91,9 +92,9 @@
AsyncCallRecorder<void (*)(nsecs_t)> mInterceptVSyncCallRecorder;
ConnectionEventRecorder mConnectionEventCallRecorder{0};
- MockVSyncSource mVSyncSource;
+ MockVSyncSource* mVSyncSource;
VSyncSource::Callback* mCallback = nullptr;
- std::unique_ptr<android::impl::EventThread> mThread;
+ std::unique_ptr<impl::EventThread> mThread;
sp<MockEventThreadConnection> mConnection;
};
@@ -102,16 +103,19 @@
::testing::UnitTest::GetInstance()->current_test_info();
ALOGD("**** Setting up for %s.%s\n", test_info->test_case_name(), test_info->name());
- EXPECT_CALL(mVSyncSource, setVSyncEnabled(_))
+ auto vsyncSource = std::make_unique<MockVSyncSource>();
+ mVSyncSource = vsyncSource.get();
+
+ EXPECT_CALL(*mVSyncSource, setVSyncEnabled(_))
.WillRepeatedly(Invoke(mVSyncSetEnabledCallRecorder.getInvocable()));
- EXPECT_CALL(mVSyncSource, setCallback(_))
+ EXPECT_CALL(*mVSyncSource, setCallback(_))
.WillRepeatedly(Invoke(mVSyncSetCallbackCallRecorder.getInvocable()));
- EXPECT_CALL(mVSyncSource, setPhaseOffset(_))
+ EXPECT_CALL(*mVSyncSource, setPhaseOffset(_))
.WillRepeatedly(Invoke(mVSyncSetPhaseOffsetCallRecorder.getInvocable()));
- createThread();
+ createThread(std::move(vsyncSource));
mConnection = createConnection(mConnectionEventCallRecorder,
ISurfaceComposer::eConfigChangedDispatch);
@@ -129,11 +133,9 @@
EXPECT_TRUE(!mVSyncSetCallbackCallRecorder.waitForUnexpectedCall().has_value());
}
-void EventThreadTest::createThread() {
- mThread =
- std::make_unique<android::impl::EventThread>(&mVSyncSource,
- mInterceptVSyncCallRecorder.getInvocable(),
- "unit-test-event-thread");
+void EventThreadTest::createThread(std::unique_ptr<VSyncSource> source) {
+ mThread = std::make_unique<impl::EventThread>(std::move(source),
+ mInterceptVSyncCallRecorder.getInvocable());
// EventThread should register itself as VSyncSource callback.
mCallback = expectVSyncSetCallbackCallReceived();
diff --git a/services/surfaceflinger/tests/unittests/SchedulerTest.cpp b/services/surfaceflinger/tests/unittests/SchedulerTest.cpp
index bf53124..b4cc1e1 100644
--- a/services/surfaceflinger/tests/unittests/SchedulerTest.cpp
+++ b/services/surfaceflinger/tests/unittests/SchedulerTest.cpp
@@ -92,7 +92,6 @@
ISurfaceComposer::
eConfigChangedSuppress));
EXPECT_FALSE(connection);
- EXPECT_FALSE(mScheduler->getEventThread(handle));
EXPECT_FALSE(mScheduler->getEventConnection(handle));
// The EXPECT_CALLS make sure we don't call the functions on the subsequent event threads.
@@ -121,8 +120,6 @@
ISurfaceComposer::
eConfigChangedSuppress));
ASSERT_EQ(mEventThreadConnection, connection);
-
- EXPECT_TRUE(mScheduler->getEventThread(mConnectionHandle));
EXPECT_TRUE(mScheduler->getEventConnection(mConnectionHandle));
EXPECT_CALL(*mEventThread, onHotplugReceived(PHYSICAL_DISPLAY_ID, false)).Times(1);
diff --git a/services/surfaceflinger/tests/unittests/mock/MockMessageQueue.h b/services/surfaceflinger/tests/unittests/mock/MockMessageQueue.h
index 1b1c1a7..e781c0a 100644
--- a/services/surfaceflinger/tests/unittests/mock/MockMessageQueue.h
+++ b/services/surfaceflinger/tests/unittests/mock/MockMessageQueue.h
@@ -30,7 +30,6 @@
~MessageQueue() override;
MOCK_METHOD1(init, void(const sp<SurfaceFlinger>&));
- MOCK_METHOD2(setEventThread, void(android::EventThread*, ResyncCallback));
MOCK_METHOD1(setEventConnection, void(const sp<EventThreadConnection>& connection));
MOCK_METHOD0(waitMessage, void());
MOCK_METHOD2(postMessage, status_t(const sp<MessageBase>&, nsecs_t));
diff --git a/vulkan/libvulkan/Android.bp b/vulkan/libvulkan/Android.bp
index 83a5250..5686891 100644
--- a/vulkan/libvulkan/Android.bp
+++ b/vulkan/libvulkan/Android.bp
@@ -46,6 +46,7 @@
"-Wno-padded",
"-Wno-switch-enum",
"-Wno-undef",
+ "-Wno-format-pedantic",
// Have clang emit complete debug_info.
"-fstandalone-debug",
diff --git a/vulkan/libvulkan/driver.cpp b/vulkan/libvulkan/driver.cpp
index 9a670f6..b413ac9 100644
--- a/vulkan/libvulkan/driver.cpp
+++ b/vulkan/libvulkan/driver.cpp
@@ -1313,5 +1313,16 @@
return result;
}
+VKAPI_ATTR VkResult QueueSubmit(VkQueue queue,
+ uint32_t submitCount,
+ const VkSubmitInfo* pSubmits,
+ VkFence fence) {
+ ATRACE_CALL();
+
+ const auto& data = GetData(queue);
+
+ return data.driver.QueueSubmit(queue, submitCount, pSubmits, fence);
+}
+
} // namespace driver
} // namespace vulkan
diff --git a/vulkan/libvulkan/driver.h b/vulkan/libvulkan/driver.h
index 57c956d..f058c47 100644
--- a/vulkan/libvulkan/driver.h
+++ b/vulkan/libvulkan/driver.h
@@ -131,6 +131,7 @@
VKAPI_ATTR void GetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue* pQueue);
VKAPI_ATTR void GetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2* pQueueInfo, VkQueue* pQueue);
VKAPI_ATTR VkResult AllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo* pAllocateInfo, VkCommandBuffer* pCommandBuffers);
+VKAPI_ATTR VkResult QueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence);
// clang-format on
template <typename DispatchableType>
diff --git a/vulkan/libvulkan/driver_gen.cpp b/vulkan/libvulkan/driver_gen.cpp
index 3495861..d829e41 100644
--- a/vulkan/libvulkan/driver_gen.cpp
+++ b/vulkan/libvulkan/driver_gen.cpp
@@ -444,6 +444,13 @@
nullptr,
},
{
+ "vkQueueSubmit",
+ ProcHook::DEVICE,
+ ProcHook::EXTENSION_CORE,
+ reinterpret_cast<PFN_vkVoidFunction>(QueueSubmit),
+ nullptr,
+ },
+ {
"vkSetHdrMetadataEXT",
ProcHook::DEVICE,
ProcHook::EXT_hdr_metadata,
@@ -537,6 +544,7 @@
INIT_PROC(true, dev, GetDeviceProcAddr);
INIT_PROC(true, dev, DestroyDevice);
INIT_PROC(true, dev, GetDeviceQueue);
+ INIT_PROC(true, dev, QueueSubmit);
INIT_PROC(true, dev, CreateImage);
INIT_PROC(true, dev, DestroyImage);
INIT_PROC(true, dev, AllocateCommandBuffers);
@@ -544,9 +552,9 @@
INIT_PROC_EXT(KHR_bind_memory2, true, dev, BindImageMemory2KHR);
INIT_PROC(false, dev, GetDeviceQueue2);
INIT_PROC_EXT(ANDROID_native_buffer, false, dev, GetSwapchainGrallocUsageANDROID);
+ INIT_PROC_EXT(ANDROID_native_buffer, false, dev, GetSwapchainGrallocUsage2ANDROID);
INIT_PROC_EXT(ANDROID_native_buffer, true, dev, AcquireImageANDROID);
INIT_PROC_EXT(ANDROID_native_buffer, true, dev, QueueSignalReleaseImageANDROID);
- INIT_PROC_EXT(ANDROID_native_buffer, false, dev, GetSwapchainGrallocUsage2ANDROID);
// clang-format on
return success;
diff --git a/vulkan/libvulkan/driver_gen.h b/vulkan/libvulkan/driver_gen.h
index 79f070c..fb2f257 100644
--- a/vulkan/libvulkan/driver_gen.h
+++ b/vulkan/libvulkan/driver_gen.h
@@ -84,6 +84,7 @@
PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
PFN_vkDestroyDevice DestroyDevice;
PFN_vkGetDeviceQueue GetDeviceQueue;
+ PFN_vkQueueSubmit QueueSubmit;
PFN_vkCreateImage CreateImage;
PFN_vkDestroyImage DestroyImage;
PFN_vkAllocateCommandBuffers AllocateCommandBuffers;
@@ -91,9 +92,9 @@
PFN_vkBindImageMemory2KHR BindImageMemory2KHR;
PFN_vkGetDeviceQueue2 GetDeviceQueue2;
PFN_vkGetSwapchainGrallocUsageANDROID GetSwapchainGrallocUsageANDROID;
+ PFN_vkGetSwapchainGrallocUsage2ANDROID GetSwapchainGrallocUsage2ANDROID;
PFN_vkAcquireImageANDROID AcquireImageANDROID;
PFN_vkQueueSignalReleaseImageANDROID QueueSignalReleaseImageANDROID;
- PFN_vkGetSwapchainGrallocUsage2ANDROID GetSwapchainGrallocUsage2ANDROID;
// clang-format on
};
diff --git a/vulkan/nulldrv/null_driver_gen.cpp b/vulkan/nulldrv/null_driver_gen.cpp
index 7c9b0c0..b8d7d2b 100644
--- a/vulkan/nulldrv/null_driver_gen.cpp
+++ b/vulkan/nulldrv/null_driver_gen.cpp
@@ -16,10 +16,10 @@
// WARNING: This file is generated. See ../README.md for instructions.
-#include "null_driver_gen.h"
-
#include <algorithm>
+#include "null_driver_gen.h"
+
using namespace null_driver;
namespace {
diff --git a/vulkan/nulldrv/null_driver_gen.h b/vulkan/nulldrv/null_driver_gen.h
index 70ef340..668dc7d 100644
--- a/vulkan/nulldrv/null_driver_gen.h
+++ b/vulkan/nulldrv/null_driver_gen.h
@@ -204,9 +204,9 @@
VKAPI_ATTR void GetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2* pQueueInfo, VkQueue* pQueue);
VKAPI_ATTR void GetDescriptorSetLayoutSupport(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, VkDescriptorSetLayoutSupport* pSupport);
VKAPI_ATTR VkResult GetSwapchainGrallocUsageANDROID(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, int* grallocUsage);
+VKAPI_ATTR VkResult GetSwapchainGrallocUsage2ANDROID(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, VkSwapchainImageUsageFlagsANDROID swapchainImageUsage, uint64_t* grallocConsumerUsage, uint64_t* grallocProducerUsage);
VKAPI_ATTR VkResult AcquireImageANDROID(VkDevice device, VkImage image, int nativeFenceFd, VkSemaphore semaphore, VkFence fence);
VKAPI_ATTR VkResult QueueSignalReleaseImageANDROID(VkQueue queue, uint32_t waitSemaphoreCount, const VkSemaphore* pWaitSemaphores, VkImage image, int* pNativeFenceFd);
-VKAPI_ATTR VkResult GetSwapchainGrallocUsage2ANDROID(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, VkSwapchainImageUsageFlagsANDROID swapchainImageUsage, uint64_t* grallocConsumerUsage, uint64_t* grallocProducerUsage);
VKAPI_ATTR VkResult GetSwapchainGrallocUsageANDROID(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, int* grallocUsage);
VKAPI_ATTR VkResult AcquireImageANDROID(VkDevice device, VkImage image, int nativeFenceFd, VkSemaphore semaphore, VkFence fence);
VKAPI_ATTR VkResult QueueSignalReleaseImageANDROID(VkQueue queue, uint32_t waitSemaphoreCount, const VkSemaphore* pWaitSemaphores, VkImage image, int* pNativeFenceFd);
diff --git a/vulkan/scripts/driver_generator.py b/vulkan/scripts/driver_generator.py
index 04d9f23..ef36f8c 100644
--- a/vulkan/scripts/driver_generator.py
+++ b/vulkan/scripts/driver_generator.py
@@ -91,6 +91,8 @@
'vkGetInstanceProcAddr' : True,
'vkGetDeviceProcAddr' : True,
+ 'vkQueueSubmit' : True,
+
# VK_KHR_swapchain->VK_ANDROID_native_buffer translation
'vkCreateImage' : True,
'vkDestroyImage' : True,
@@ -191,6 +193,8 @@
'vkGetInstanceProcAddr' : True,
'vkGetDeviceProcAddr' : True,
+ 'vkQueueSubmit' : True,
+
# VK_KHR_swapchain v69 requirement
'vkBindImageMemory2' : True,
'vkBindImageMemory2KHR' : True
diff --git a/vulkan/scripts/generator_common.py b/vulkan/scripts/generator_common.py
index d9f97e1..fe9dab4 100644
--- a/vulkan/scripts/generator_common.py
+++ b/vulkan/scripts/generator_common.py
@@ -127,7 +127,7 @@
'VkCommandBuffer ' : 'Device'
}
- if len(paramDict[functionName])>0:
+ if len(paramDict[functionName]) > 0:
return switchCase.get(paramDict[functionName][0][0], 'Global')
return 'Global'
@@ -150,7 +150,7 @@
def clang_off(f, indent):
f.write (clang_off_spaces * indent + '// clang-format off\n')
-clang_off_spaces = ' '*4
+clang_off_spaces = ' ' * 4
parametersList = []
paramDict = {}
@@ -166,16 +166,13 @@
vulkan_registry = os.path.join(os.path.dirname(__file__),'..','..','..','..','external','vulkan-headers','registry','vk.xml')
tree = ET.parse(vulkan_registry)
root = tree.getroot()
- protoset = False
- fnName = ""
- fnType = ""
for commands in root.iter('commands'):
for command in commands:
if command.tag == 'command':
- if protoset == True:
- paramDict[fnName] = parametersList.copy()
parametersList.clear()
protoset = False
+ fnName = ""
+ fnType = ""
if command.get('alias') != None:
alias = command.get('alias')
fnName = command.get('name')
@@ -184,20 +181,20 @@
paramDict[fnName] = paramDict[alias].copy()
returnTypeDict[fnName] = returnTypeDict[alias]
for params in command:
- if(params.tag == 'param'):
+ if params.tag == 'param':
paramtype = ""
- if params.text!=None:
- paramtype = params.text
+ if params.text != None and params.text.strip() != '':
+ paramtype = params.text.strip() + ' '
typeval = params.find('type')
paramtype = paramtype + typeval.text
- if typeval.tail!=None:
- paramtype = paramtype + typeval.tail
+ if typeval.tail != None:
+ paramtype += typeval.tail.strip() + ' '
pname = params.find('name')
paramname = pname.text
- if pname.tail != None:
- parametersList.append((paramtype,paramname,pname.tail))
+ if pname.tail != None and pname.tail.strip() != '':
+ parametersList.append((paramtype, paramname, pname.tail.strip()))
else:
- parametersList.append((paramtype,paramname))
+ parametersList.append((paramtype, paramname))
if params.tag == 'proto':
for c in params:
if c.tag == 'type':
@@ -207,6 +204,8 @@
protoset = True
allCommandsList.append(fnName)
returnTypeDict[fnName] = fnType
+ if protoset == True:
+ paramDict[fnName] = parametersList.copy()
for exts in root.iter('extensions'):
for extension in exts:
@@ -214,7 +213,7 @@
if extension.tag == 'extension':
extname = extension.get('name')
for req in extension:
- if req.get('feature')!=None:
+ if req.get('feature') != None:
apiversion = req.get('feature')
for commands in req:
if commands.tag == 'command':
@@ -224,19 +223,6 @@
if apiversion != "":
versionDict[commandname] = apiversion
- # TODO(adsrini): http://b/136570819
- extensionsDict['vkGetSwapchainGrallocUsage2ANDROID'] = 'VK_ANDROID_native_buffer'
- allCommandsList.append('vkGetSwapchainGrallocUsage2ANDROID')
- returnTypeDict['vkGetSwapchainGrallocUsage2ANDROID'] = 'VkResult'
- paramDict['vkGetSwapchainGrallocUsage2ANDROID'] = [
- ('VkDevice ', 'device'),
- ('VkFormat ', 'format'),
- ('VkImageUsageFlags ', 'imageUsage'),
- ('VkSwapchainImageUsageFlagsANDROID ', 'swapchainImageUsage'),
- ('uint64_t* ', 'grallocConsumerUsage'),
- ('uint64_t* ', 'grallocProducerUsage')
- ]
-
for feature in root.iter('feature'):
apiversion = feature.get('name')
for req in feature: