summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/SurfaceFlinger.cpp
diff options
context:
space:
mode:
author Kalle Raita <kraita@google.com> 2017-01-11 11:17:29 -0800
committer Kalle Raita <kraita@google.com> 2017-08-04 15:20:09 -0700
commita099a24c93bfa599fc5c36a647e946c26f68514f (patch)
treea28d284ac7ff816f6cd08a3710a65eb9fbe1e6ed /services/surfaceflinger/SurfaceFlinger.cpp
parentd9fd3caf92c541e1ba8120f1e95bfb855183b905 (diff)
Faked HWC for SurfaceFlinger testing
Infrastructure and initial port of transaction tests. Faking the HWC allows exercising the real path through the SurfaceFlinger, not relying on screen captures. Faked HWC also opens up the possibility of faking interactions like display hotplugs. The tests are verifying the composition rectangles instead of a set of select pixels. GLES rendering differences won't affect the results. Also, the test expectations become clearer. The ported transaction tests ran roughly twice as fast when compared with the original transaction test. This is mostly due to the thighter control over the vsyncs. Test: Running the test on Marlin Change-Id: I1c876cda78db94c1965498af957e64fdd23459ce
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp59
1 files changed, 56 insertions, 3 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index aaaafbfa9e..4154d6a87f 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -46,6 +46,7 @@
#include <gui/BufferQueue.h>
#include <gui/GuiConfig.h>
#include <gui/IDisplayEventConnection.h>
+#include <gui/LayerDebugInfo.h>
#include <gui/Surface.h>
#include <ui/GraphicBufferAllocator.h>
@@ -123,6 +124,21 @@ bool SurfaceFlinger::useVrFlinger;
int64_t SurfaceFlinger::maxFrameBufferAcquiredBuffers;
bool SurfaceFlinger::hasWideColorDisplay;
+
+std::string getHwcServiceName() {
+ char value[PROPERTY_VALUE_MAX] = {};
+ property_get("debug.sf.hwc_service_name", value, "default");
+ ALOGI("Using HWComposer service: '%s'", value);
+ return std::string(value);
+}
+
+bool useTrebleTestingOverride() {
+ char value[PROPERTY_VALUE_MAX] = {};
+ property_get("debug.sf.treble_testing_override", value, "false");
+ ALOGI("Treble testing override: '%s'", value);
+ return std::string(value) == "true";
+}
+
SurfaceFlinger::SurfaceFlinger()
: BnSurfaceComposer(),
mTransactionFlags(0),
@@ -134,6 +150,7 @@ SurfaceFlinger::SurfaceFlinger()
mHwc(nullptr),
mRealHwc(nullptr),
mVrHwc(nullptr),
+ mHwcServiceName(getHwcServiceName()),
mRenderEngine(nullptr),
mBootTime(systemTime()),
mBuiltinDisplays(),
@@ -233,6 +250,15 @@ SurfaceFlinger::SurfaceFlinger()
// but since /data may be encrypted, we need to wait until after vold
// comes online to attempt to read the property. The property is
// instead read after the boot animation
+
+ if (useTrebleTestingOverride()) {
+ // Without the override SurfaceFlinger cannot connect to HIDL
+ // services that are not listed in the manifests. Considered
+ // deriving the setting from the set service name, but it
+ // would be brittle if the name that's not 'default' is used
+ // for production purposes later on.
+ setenv("TREBLE_TESTING_OVERRIDE", "true", true);
+ }
}
void SurfaceFlinger::onFirstRef()
@@ -594,7 +620,7 @@ void SurfaceFlinger::init() {
// initialize the primary display.
LOG_ALWAYS_FATAL_IF(mVrFlingerRequestsDisplay,
"Starting with vr flinger active is not currently supported.");
- mRealHwc = new HWComposer(false);
+ mRealHwc = new HWComposer(mHwcServiceName);
mHwc = mRealHwc;
mHwc->setEventHandler(static_cast<HWComposer::EventHandler*>(this));
@@ -1055,6 +1081,33 @@ status_t SurfaceFlinger::injectVSync(nsecs_t when) {
return NO_ERROR;
}
+status_t SurfaceFlinger::getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const {
+ IPCThreadState* ipc = IPCThreadState::self();
+ const int pid = ipc->getCallingPid();
+ const int uid = ipc->getCallingUid();
+ if ((uid != AID_SHELL) &&
+ !PermissionCache::checkPermission(sDump, pid, uid)) {
+ ALOGE("Layer debug info permission denied for pid=%d, uid=%d", pid, uid);
+ return PERMISSION_DENIED;
+ }
+
+ // Try to acquire a lock for 1s, fail gracefully
+ const status_t err = mStateLock.timedLock(s2ns(1));
+ const bool locked = (err == NO_ERROR);
+ if (!locked) {
+ ALOGE("LayerDebugInfo: SurfaceFlinger unresponsive (%s [%d]) - exit", strerror(-err), err);
+ return TIMED_OUT;
+ }
+
+ outLayers->clear();
+ mCurrentState.traverseInZOrder([&](Layer* layer) {
+ outLayers->push_back(layer->getLayerDebugInfo());
+ });
+
+ mStateLock.unlock();
+ return NO_ERROR;
+}
+
// ----------------------------------------------------------------------------
sp<IDisplayEventConnection> SurfaceFlinger::createDisplayEventConnection(
@@ -1312,7 +1365,7 @@ void SurfaceFlinger::updateVrFlinger() {
if (vrFlingerRequestsDisplay && !mVrHwc) {
// Construct new HWComposer without holding any locks.
- mVrHwc = new HWComposer(true);
+ mVrHwc = new HWComposer("vr");
// Set up the event handlers. This step is neccessary to initialize the internal state of
// the hardware composer object properly. Our callbacks are designed such that if they are
@@ -3706,7 +3759,7 @@ void SurfaceFlinger::dumpAllLocked(const Vector<String16>& args, size_t& index,
result.appendFormat("Visible layers (count = %zu)\n", mNumLayers);
colorizer.reset(result);
mCurrentState.traverseInZOrder([&](Layer* layer) {
- layer->dump(result, colorizer);
+ result.append(to_string(layer->getLayerDebugInfo()).c_str());
});
/*