Migrate ISurfaceComposerClient to AIDL
Migrate and clean up ISurfaceComposerClient to aidl, removed the deprecated createWithParent method, removed non used parameters.
Bug: 172002646
Test: atest libgui_test
Change-Id: I8ceb7cd90104f2ad9ca72c8025f6298de1fb1ba0
diff --git a/libs/binder/include/binder/IInterface.h b/libs/binder/include/binder/IInterface.h
index 7067830..1576c94 100644
--- a/libs/binder/include/binder/IInterface.h
+++ b/libs/binder/include/binder/IInterface.h
@@ -219,80 +219,79 @@
namespace internal {
constexpr const char* const kManualInterfaces[] = {
- "android.app.IActivityManager",
- "android.app.IUidObserver",
- "android.drm.IDrm",
- "android.dvr.IVsyncCallback",
- "android.dvr.IVsyncService",
- "android.gfx.tests.ICallback",
- "android.gfx.tests.IIPCTest",
- "android.gfx.tests.ISafeInterfaceTest",
- "android.graphicsenv.IGpuService",
- "android.gui.IConsumerListener",
- "android.gui.IGraphicBufferConsumer",
- "android.gui.ITransactionComposerListener",
- "android.gui.SensorEventConnection",
- "android.gui.SensorServer",
- "android.hardware.ICamera",
- "android.hardware.ICameraClient",
- "android.hardware.ICameraRecordingProxy",
- "android.hardware.ICameraRecordingProxyListener",
- "android.hardware.ICrypto",
- "android.hardware.IOMXObserver",
- "android.hardware.IStreamListener",
- "android.hardware.IStreamSource",
- "android.media.IAudioService",
- "android.media.IDataSource",
- "android.media.IDrmClient",
- "android.media.IMediaCodecList",
- "android.media.IMediaDrmService",
- "android.media.IMediaExtractor",
- "android.media.IMediaExtractorService",
- "android.media.IMediaHTTPConnection",
- "android.media.IMediaHTTPService",
- "android.media.IMediaLogService",
- "android.media.IMediaMetadataRetriever",
- "android.media.IMediaMetricsService",
- "android.media.IMediaPlayer",
- "android.media.IMediaPlayerClient",
- "android.media.IMediaPlayerService",
- "android.media.IMediaRecorder",
- "android.media.IMediaRecorderClient",
- "android.media.IMediaResourceMonitor",
- "android.media.IMediaSource",
- "android.media.IRemoteDisplay",
- "android.media.IRemoteDisplayClient",
- "android.media.IResourceManagerClient",
- "android.media.IResourceManagerService",
- "android.os.IComplexTypeInterface",
- "android.os.IPermissionController",
- "android.os.IPingResponder",
- "android.os.IProcessInfoService",
- "android.os.ISchedulingPolicyService",
- "android.os.IStringConstants",
- "android.os.storage.IObbActionListener",
- "android.os.storage.IStorageEventListener",
- "android.os.storage.IStorageManager",
- "android.os.storage.IStorageShutdownObserver",
- "android.service.vr.IPersistentVrStateCallbacks",
- "android.service.vr.IVrManager",
- "android.service.vr.IVrStateCallbacks",
- "android.ui.ISurfaceComposer",
- "android.ui.ISurfaceComposerClient",
- "android.utils.IMemory",
- "android.utils.IMemoryHeap",
- "com.android.car.procfsinspector.IProcfsInspector",
- "com.android.internal.app.IAppOpsCallback",
- "com.android.internal.app.IAppOpsService",
- "com.android.internal.app.IBatteryStats",
- "com.android.internal.os.IResultReceiver",
- "com.android.internal.os.IShellCallback",
- "drm.IDrmManagerService",
- "drm.IDrmServiceListener",
- "IAAudioClient",
- "IAAudioService",
- "VtsFuzzer",
- nullptr,
+ "android.app.IActivityManager",
+ "android.app.IUidObserver",
+ "android.drm.IDrm",
+ "android.dvr.IVsyncCallback",
+ "android.dvr.IVsyncService",
+ "android.gfx.tests.ICallback",
+ "android.gfx.tests.IIPCTest",
+ "android.gfx.tests.ISafeInterfaceTest",
+ "android.graphicsenv.IGpuService",
+ "android.gui.IConsumerListener",
+ "android.gui.IGraphicBufferConsumer",
+ "android.gui.ITransactionComposerListener",
+ "android.gui.SensorEventConnection",
+ "android.gui.SensorServer",
+ "android.hardware.ICamera",
+ "android.hardware.ICameraClient",
+ "android.hardware.ICameraRecordingProxy",
+ "android.hardware.ICameraRecordingProxyListener",
+ "android.hardware.ICrypto",
+ "android.hardware.IOMXObserver",
+ "android.hardware.IStreamListener",
+ "android.hardware.IStreamSource",
+ "android.media.IAudioService",
+ "android.media.IDataSource",
+ "android.media.IDrmClient",
+ "android.media.IMediaCodecList",
+ "android.media.IMediaDrmService",
+ "android.media.IMediaExtractor",
+ "android.media.IMediaExtractorService",
+ "android.media.IMediaHTTPConnection",
+ "android.media.IMediaHTTPService",
+ "android.media.IMediaLogService",
+ "android.media.IMediaMetadataRetriever",
+ "android.media.IMediaMetricsService",
+ "android.media.IMediaPlayer",
+ "android.media.IMediaPlayerClient",
+ "android.media.IMediaPlayerService",
+ "android.media.IMediaRecorder",
+ "android.media.IMediaRecorderClient",
+ "android.media.IMediaResourceMonitor",
+ "android.media.IMediaSource",
+ "android.media.IRemoteDisplay",
+ "android.media.IRemoteDisplayClient",
+ "android.media.IResourceManagerClient",
+ "android.media.IResourceManagerService",
+ "android.os.IComplexTypeInterface",
+ "android.os.IPermissionController",
+ "android.os.IPingResponder",
+ "android.os.IProcessInfoService",
+ "android.os.ISchedulingPolicyService",
+ "android.os.IStringConstants",
+ "android.os.storage.IObbActionListener",
+ "android.os.storage.IStorageEventListener",
+ "android.os.storage.IStorageManager",
+ "android.os.storage.IStorageShutdownObserver",
+ "android.service.vr.IPersistentVrStateCallbacks",
+ "android.service.vr.IVrManager",
+ "android.service.vr.IVrStateCallbacks",
+ "android.ui.ISurfaceComposer",
+ "android.utils.IMemory",
+ "android.utils.IMemoryHeap",
+ "com.android.car.procfsinspector.IProcfsInspector",
+ "com.android.internal.app.IAppOpsCallback",
+ "com.android.internal.app.IAppOpsService",
+ "com.android.internal.app.IBatteryStats",
+ "com.android.internal.os.IResultReceiver",
+ "com.android.internal.os.IShellCallback",
+ "drm.IDrmManagerService",
+ "drm.IDrmServiceListener",
+ "IAAudioClient",
+ "IAAudioService",
+ "VtsFuzzer",
+ nullptr,
};
constexpr const char* const kDownstreamManualInterfaces[] = {
diff --git a/libs/gui/Android.bp b/libs/gui/Android.bp
index a3f5a06..648bcc3 100644
--- a/libs/gui/Android.bp
+++ b/libs/gui/Android.bp
@@ -204,7 +204,6 @@
"IGraphicBufferProducer.cpp",
"IProducerListener.cpp",
"ISurfaceComposer.cpp",
- "ISurfaceComposerClient.cpp",
"ITransactionCompletedListener.cpp",
"LayerDebugInfo.cpp",
"LayerMetadata.cpp",
diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp
index bba7387..ccb901c 100644
--- a/libs/gui/BLASTBufferQueue.cpp
+++ b/libs/gui/BLASTBufferQueue.cpp
@@ -551,7 +551,7 @@
if (dequeueTime != mDequeueTimestamps.end()) {
Parcel p;
p.writeInt64(dequeueTime->second);
- t->setMetadata(mSurfaceControl, METADATA_DEQUEUE_TIME, p);
+ t->setMetadata(mSurfaceControl, gui::METADATA_DEQUEUE_TIME, p);
mDequeueTimestamps.erase(dequeueTime);
}
}
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index 80e5123..54e50b5 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -25,7 +25,6 @@
#include <binder/Parcel.h>
#include <gui/IGraphicBufferProducer.h>
#include <gui/ISurfaceComposer.h>
-#include <gui/ISurfaceComposerClient.h>
#include <gui/LayerState.h>
#include <private/gui/ParcelUtils.h>
#include <stdint.h>
@@ -61,14 +60,6 @@
virtual ~BpSurfaceComposer();
- virtual sp<ISurfaceComposerClient> createConnection()
- {
- Parcel data, reply;
- data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
- remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply);
- return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder());
- }
-
status_t setTransactionState(const FrameTimelineInfo& frameTimelineInfo,
const Vector<ComposerState>& state,
const Vector<DisplayState>& displays, uint32_t flags,
@@ -159,13 +150,7 @@
status_t BnSurfaceComposer::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
- switch(code) {
- case CREATE_CONNECTION: {
- CHECK_INTERFACE(ISurfaceComposer, data, reply);
- sp<IBinder> b = IInterface::asBinder(createConnection());
- reply->writeStrongBinder(b);
- return NO_ERROR;
- }
+ switch (code) {
case SET_TRANSACTION_STATE: {
CHECK_INTERFACE(ISurfaceComposer, data, reply);
diff --git a/libs/gui/ISurfaceComposerClient.cpp b/libs/gui/ISurfaceComposerClient.cpp
deleted file mode 100644
index 5e7a7ec..0000000
--- a/libs/gui/ISurfaceComposerClient.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// tag as surfaceflinger
-#define LOG_TAG "SurfaceFlinger"
-
-#include <gui/ISurfaceComposerClient.h>
-
-#include <gui/IGraphicBufferProducer.h>
-
-#include <binder/SafeInterface.h>
-
-#include <ui/FrameStats.h>
-
-namespace android {
-
-namespace { // Anonymous
-
-enum class Tag : uint32_t {
- CREATE_SURFACE = IBinder::FIRST_CALL_TRANSACTION,
- CREATE_WITH_SURFACE_PARENT,
- CLEAR_LAYER_FRAME_STATS,
- GET_LAYER_FRAME_STATS,
- MIRROR_SURFACE,
- LAST = MIRROR_SURFACE,
-};
-
-} // Anonymous namespace
-
-class BpSurfaceComposerClient : public SafeBpInterface<ISurfaceComposerClient> {
-public:
- explicit BpSurfaceComposerClient(const sp<IBinder>& impl)
- : SafeBpInterface<ISurfaceComposerClient>(impl, "BpSurfaceComposerClient") {}
-
- ~BpSurfaceComposerClient() override;
-
- status_t createSurface(const String8& name, uint32_t width, uint32_t height, PixelFormat format,
- uint32_t flags, const sp<IBinder>& parent, LayerMetadata metadata,
- sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp,
- int32_t* outLayerId, uint32_t* outTransformHint) override {
- return callRemote<decltype(&ISurfaceComposerClient::createSurface)>(Tag::CREATE_SURFACE,
- name, width, height,
- format, flags, parent,
- std::move(metadata),
- handle, gbp, outLayerId,
- outTransformHint);
- }
-
- status_t createWithSurfaceParent(const String8& name, uint32_t width, uint32_t height,
- PixelFormat format, uint32_t flags,
- const sp<IGraphicBufferProducer>& parent,
- LayerMetadata metadata, sp<IBinder>* handle,
- sp<IGraphicBufferProducer>* gbp, int32_t* outLayerId,
- uint32_t* outTransformHint) override {
- return callRemote<decltype(
- &ISurfaceComposerClient::createWithSurfaceParent)>(Tag::CREATE_WITH_SURFACE_PARENT,
- name, width, height, format,
- flags, parent,
- std::move(metadata), handle, gbp,
- outLayerId, outTransformHint);
- }
-
- status_t clearLayerFrameStats(const sp<IBinder>& handle) const override {
- return callRemote<decltype(
- &ISurfaceComposerClient::clearLayerFrameStats)>(Tag::CLEAR_LAYER_FRAME_STATS,
- handle);
- }
-
- status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const override {
- return callRemote<decltype(
- &ISurfaceComposerClient::getLayerFrameStats)>(Tag::GET_LAYER_FRAME_STATS, handle,
- outStats);
- }
-
- status_t mirrorSurface(const sp<IBinder>& mirrorFromHandle, sp<IBinder>* outHandle,
- int32_t* outLayerId) override {
- return callRemote<decltype(&ISurfaceComposerClient::mirrorSurface)>(Tag::MIRROR_SURFACE,
- mirrorFromHandle,
- outHandle, outLayerId);
- }
-};
-
-// Out-of-line virtual method definition to trigger vtable emission in this
-// translation unit (see clang warning -Wweak-vtables)
-BpSurfaceComposerClient::~BpSurfaceComposerClient() {}
-
-IMPLEMENT_META_INTERFACE(SurfaceComposerClient, "android.ui.ISurfaceComposerClient");
-
-// ----------------------------------------------------------------------
-
-status_t BnSurfaceComposerClient::onTransact(uint32_t code, const Parcel& data, Parcel* reply,
- uint32_t flags) {
- if (code < IBinder::FIRST_CALL_TRANSACTION || code > static_cast<uint32_t>(Tag::LAST)) {
- return BBinder::onTransact(code, data, reply, flags);
- }
- auto tag = static_cast<Tag>(code);
- switch (tag) {
- case Tag::CREATE_SURFACE:
- return callLocal(data, reply, &ISurfaceComposerClient::createSurface);
- case Tag::CREATE_WITH_SURFACE_PARENT:
- return callLocal(data, reply, &ISurfaceComposerClient::createWithSurfaceParent);
- case Tag::CLEAR_LAYER_FRAME_STATS:
- return callLocal(data, reply, &ISurfaceComposerClient::clearLayerFrameStats);
- case Tag::GET_LAYER_FRAME_STATS:
- return callLocal(data, reply, &ISurfaceComposerClient::getLayerFrameStats);
- case Tag::MIRROR_SURFACE:
- return callLocal(data, reply, &ISurfaceComposerClient::mirrorSurface);
- }
-}
-
-} // namespace android
diff --git a/libs/gui/LayerMetadata.cpp b/libs/gui/LayerMetadata.cpp
index 189d51a..4e12fd3 100644
--- a/libs/gui/LayerMetadata.cpp
+++ b/libs/gui/LayerMetadata.cpp
@@ -23,7 +23,7 @@
using android::base::StringPrintf;
-namespace android {
+namespace android::gui {
LayerMetadata::LayerMetadata() = default;
@@ -144,4 +144,4 @@
}
}
-} // namespace android
+} // namespace android::gui
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index 502031c..3ab9e97 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -19,10 +19,10 @@
#include <cinttypes>
#include <cmath>
+#include <android/gui/ISurfaceComposerClient.h>
#include <android/native_window.h>
#include <binder/Parcel.h>
#include <gui/IGraphicBufferProducer.h>
-#include <gui/ISurfaceComposerClient.h>
#include <gui/LayerState.h>
#include <private/gui/ParcelUtils.h>
#include <system/window.h>
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 065deb6..035aac9 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -20,6 +20,7 @@
#include <sys/types.h>
#include <android/gui/DisplayState.h>
+#include <android/gui/ISurfaceComposerClient.h>
#include <android/gui/IWindowInfosListener.h>
#include <android/os/IInputConstants.h>
#include <utils/Errors.h>
@@ -39,7 +40,6 @@
#include <gui/CpuConsumer.h>
#include <gui/IGraphicBufferProducer.h>
#include <gui/ISurfaceComposer.h>
-#include <gui/ISurfaceComposerClient.h>
#include <gui/LayerState.h>
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>
@@ -2004,11 +2004,11 @@
: mStatus(NO_ERROR), mClient(client) {}
void SurfaceComposerClient::onFirstRef() {
- sp<ISurfaceComposer> sf(ComposerService::getComposerService());
+ sp<gui::ISurfaceComposer> sf(ComposerServiceAIDL::getComposerService());
if (sf != nullptr && mStatus == NO_INIT) {
sp<ISurfaceComposerClient> conn;
- conn = sf->createConnection();
- if (conn != nullptr) {
+ binder::Status status = sf->createConnection(&conn);
+ if (status.isOk() && conn != nullptr) {
mClient = conn;
mStatus = NO_ERROR;
}
@@ -2046,7 +2046,7 @@
}
sp<SurfaceControl> SurfaceComposerClient::createSurface(const String8& name, uint32_t w, uint32_t h,
- PixelFormat format, uint32_t flags,
+ PixelFormat format, int32_t flags,
const sp<IBinder>& parentHandle,
LayerMetadata metadata,
uint32_t* outTransformHint) {
@@ -2056,38 +2056,9 @@
return s;
}
-sp<SurfaceControl> SurfaceComposerClient::createWithSurfaceParent(const String8& name, uint32_t w,
- uint32_t h, PixelFormat format,
- uint32_t flags, Surface* parent,
- LayerMetadata metadata,
- uint32_t* outTransformHint) {
- sp<SurfaceControl> sur;
- status_t err = mStatus;
-
- if (mStatus == NO_ERROR) {
- sp<IBinder> handle;
- sp<IGraphicBufferProducer> parentGbp = parent->getIGraphicBufferProducer();
- sp<IGraphicBufferProducer> gbp;
-
- uint32_t transformHint = 0;
- int32_t id = -1;
- err = mClient->createWithSurfaceParent(name, w, h, format, flags, parentGbp,
- std::move(metadata), &handle, &gbp, &id,
- &transformHint);
- if (outTransformHint) {
- *outTransformHint = transformHint;
- }
- ALOGE_IF(err, "SurfaceComposerClient::createWithSurfaceParent error %s", strerror(-err));
- if (err == NO_ERROR) {
- return new SurfaceControl(this, handle, gbp, id, transformHint);
- }
- }
- return nullptr;
-}
-
status_t SurfaceComposerClient::createSurfaceChecked(const String8& name, uint32_t w, uint32_t h,
PixelFormat format,
- sp<SurfaceControl>* outSurface, uint32_t flags,
+ sp<SurfaceControl>* outSurface, int32_t flags,
const sp<IBinder>& parentHandle,
LayerMetadata metadata,
uint32_t* outTransformHint) {
@@ -2095,21 +2066,17 @@
status_t err = mStatus;
if (mStatus == NO_ERROR) {
- sp<IBinder> handle;
- sp<IGraphicBufferProducer> gbp;
-
- uint32_t transformHint = 0;
- int32_t id = -1;
- err = mClient->createSurface(name, w, h, format, flags, parentHandle, std::move(metadata),
- &handle, &gbp, &id, &transformHint);
-
+ gui::CreateSurfaceResult result;
+ binder::Status status = mClient->createSurface(std::string(name.string()), flags,
+ parentHandle, std::move(metadata), &result);
+ err = statusTFromBinderStatus(status);
if (outTransformHint) {
- *outTransformHint = transformHint;
+ *outTransformHint = result.transformHint;
}
ALOGE_IF(err, "SurfaceComposerClient::createSurface error %s", strerror(-err));
if (err == NO_ERROR) {
- *outSurface =
- new SurfaceControl(this, handle, gbp, id, w, h, format, transformHint, flags);
+ *outSurface = new SurfaceControl(this, result.handle, result.layerId, w, h, format,
+ result.transformHint, flags);
}
}
return err;
@@ -2120,12 +2087,12 @@
return nullptr;
}
- sp<IBinder> handle;
sp<IBinder> mirrorFromHandle = mirrorFromSurface->getHandle();
- int32_t layer_id = -1;
- status_t err = mClient->mirrorSurface(mirrorFromHandle, &handle, &layer_id);
+ gui::MirrorSurfaceResult result;
+ const binder::Status status = mClient->mirrorSurface(mirrorFromHandle, &result);
+ const status_t err = statusTFromBinderStatus(status);
if (err == NO_ERROR) {
- return new SurfaceControl(this, handle, nullptr, layer_id, true /* owned */);
+ return new SurfaceControl(this, result.handle, result.layerId);
}
return nullptr;
}
@@ -2134,7 +2101,8 @@
if (mStatus != NO_ERROR) {
return mStatus;
}
- return mClient->clearLayerFrameStats(token);
+ const binder::Status status = mClient->clearLayerFrameStats(token);
+ return statusTFromBinderStatus(status);
}
status_t SurfaceComposerClient::getLayerFrameStats(const sp<IBinder>& token,
@@ -2142,7 +2110,24 @@
if (mStatus != NO_ERROR) {
return mStatus;
}
- return mClient->getLayerFrameStats(token, outStats);
+ gui::FrameStats stats;
+ const binder::Status status = mClient->getLayerFrameStats(token, &stats);
+ if (status.isOk()) {
+ outStats->refreshPeriodNano = stats.refreshPeriodNano;
+ outStats->desiredPresentTimesNano.setCapacity(stats.desiredPresentTimesNano.size());
+ for (const auto& t : stats.desiredPresentTimesNano) {
+ outStats->desiredPresentTimesNano.add(t);
+ }
+ outStats->actualPresentTimesNano.setCapacity(stats.actualPresentTimesNano.size());
+ for (const auto& t : stats.actualPresentTimesNano) {
+ outStats->actualPresentTimesNano.add(t);
+ }
+ outStats->frameReadyTimesNano.setCapacity(stats.frameReadyTimesNano.size());
+ for (const auto& t : stats.frameReadyTimesNano) {
+ outStats->frameReadyTimesNano.add(t);
+ }
+ }
+ return statusTFromBinderStatus(status);
}
// ----------------------------------------------------------------------------
diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp
index 654fb33..84257de 100644
--- a/libs/gui/SurfaceControl.cpp
+++ b/libs/gui/SurfaceControl.cpp
@@ -49,12 +49,10 @@
// ============================================================================
SurfaceControl::SurfaceControl(const sp<SurfaceComposerClient>& client, const sp<IBinder>& handle,
- const sp<IGraphicBufferProducer>& gbp, int32_t layerId,
- uint32_t w, uint32_t h, PixelFormat format, uint32_t transform,
- uint32_t flags)
+ int32_t layerId, uint32_t w, uint32_t h, PixelFormat format,
+ uint32_t transform, uint32_t flags)
: mClient(client),
mHandle(handle),
- mGraphicBufferProducer(gbp),
mLayerId(layerId),
mTransformHint(transform),
mWidth(w),
@@ -65,7 +63,6 @@
SurfaceControl::SurfaceControl(const sp<SurfaceControl>& other) {
mClient = other->mClient;
mHandle = other->mHandle;
- mGraphicBufferProducer = other->mGraphicBufferProducer;
mTransformHint = other->mTransformHint;
mLayerId = other->mLayerId;
mWidth = other->mWidth;
@@ -165,11 +162,11 @@
void SurfaceControl::updateDefaultBufferSize(uint32_t width, uint32_t height) {
Mutex::Autolock _l(mLock);
- mWidth = width; mHeight = height;
+ mWidth = width;
+ mHeight = height;
if (mBbq) {
mBbq->update(mBbqChild, width, height, mFormat);
}
-
}
sp<IBinder> SurfaceControl::getLayerStateHandle() const
@@ -245,9 +242,7 @@
*outSurfaceControl =
new SurfaceControl(new SurfaceComposerClient(
interface_cast<ISurfaceComposerClient>(client)),
- handle.get(), nullptr, layerId,
- width, height, format,
- transformHint);
+ handle.get(), layerId, width, height, format, transformHint);
return NO_ERROR;
}
diff --git a/libs/gui/aidl/android/gui/CreateSurfaceResult.aidl b/libs/gui/aidl/android/gui/CreateSurfaceResult.aidl
new file mode 100644
index 0000000..39e4916
--- /dev/null
+++ b/libs/gui/aidl/android/gui/CreateSurfaceResult.aidl
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.gui;
+
+/** @hide */
+parcelable CreateSurfaceResult {
+ IBinder handle;
+ int layerId;
+ int transformHint;
+}
diff --git a/libs/gui/aidl/android/gui/ISurfaceComposer.aidl b/libs/gui/aidl/android/gui/ISurfaceComposer.aidl
index 6ec6f76..26b4e81 100644
--- a/libs/gui/aidl/android/gui/ISurfaceComposer.aidl
+++ b/libs/gui/aidl/android/gui/ISurfaceComposer.aidl
@@ -34,6 +34,7 @@
import android.gui.IHdrLayerInfoListener;
import android.gui.IRegionSamplingListener;
import android.gui.IScreenCaptureListener;
+import android.gui.ISurfaceComposerClient;
import android.gui.ITransactionTraceListener;
import android.gui.ITunnelModeEnabledListener;
import android.gui.IWindowInfosListener;
@@ -45,6 +46,12 @@
/** @hide */
interface ISurfaceComposer {
+
+ /**
+ * Create a connection with SurfaceFlinger.
+ */
+ @nullable ISurfaceComposerClient createConnection();
+
/**
* Create a virtual display
* requires ACCESS_SURFACE_FLINGER permission.
diff --git a/libs/gui/aidl/android/gui/ISurfaceComposerClient.aidl b/libs/gui/aidl/android/gui/ISurfaceComposerClient.aidl
new file mode 100644
index 0000000..71933aa
--- /dev/null
+++ b/libs/gui/aidl/android/gui/ISurfaceComposerClient.aidl
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.gui;
+
+import android.gui.CreateSurfaceResult;
+import android.gui.FrameStats;
+import android.gui.LayerMetadata;
+import android.gui.MirrorSurfaceResult;
+
+/** @hide */
+interface ISurfaceComposerClient {
+
+ // flags for createSurface()
+ // (keep in sync with SurfaceControl.java)
+ const int eHidden = 0x00000004;
+ const int eDestroyBackbuffer = 0x00000020;
+ const int eSkipScreenshot = 0x00000040;
+ const int eSecure = 0x00000080;
+ const int eNonPremultiplied = 0x00000100;
+ const int eOpaque = 0x00000400;
+ const int eProtectedByApp = 0x00000800;
+ const int eProtectedByDRM = 0x00001000;
+ const int eCursorWindow = 0x00002000;
+ const int eNoColorFill = 0x00004000;
+
+ const int eFXSurfaceBufferQueue = 0x00000000;
+ const int eFXSurfaceEffect = 0x00020000;
+ const int eFXSurfaceBufferState = 0x00040000;
+ const int eFXSurfaceContainer = 0x00080000;
+ const int eFXSurfaceMask = 0x000F0000;
+
+ /**
+ * Requires ACCESS_SURFACE_FLINGER permission
+ */
+ CreateSurfaceResult createSurface(@utf8InCpp String name, int flags, @nullable IBinder parent, in LayerMetadata metadata);
+
+ /**
+ * Requires ACCESS_SURFACE_FLINGER permission
+ */
+ void clearLayerFrameStats(IBinder handle);
+
+ /**
+ * Requires ACCESS_SURFACE_FLINGER permission
+ */
+ FrameStats getLayerFrameStats(IBinder handle);
+
+ MirrorSurfaceResult mirrorSurface(IBinder mirrorFromHandle);
+}
diff --git a/libs/gui/aidl/android/gui/LayerMetadata.aidl b/libs/gui/aidl/android/gui/LayerMetadata.aidl
new file mode 100644
index 0000000..1368ac5
--- /dev/null
+++ b/libs/gui/aidl/android/gui/LayerMetadata.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.gui;
+
+parcelable LayerMetadata cpp_header "gui/LayerMetadata.h";
diff --git a/libs/gui/aidl/android/gui/MirrorSurfaceResult.aidl b/libs/gui/aidl/android/gui/MirrorSurfaceResult.aidl
new file mode 100644
index 0000000..9fac3e8
--- /dev/null
+++ b/libs/gui/aidl/android/gui/MirrorSurfaceResult.aidl
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.gui;
+
+/** @hide */
+parcelable MirrorSurfaceResult {
+ IBinder handle;
+ int layerId;
+}
diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h
index 8f75d29..7139e1b 100644
--- a/libs/gui/include/gui/ISurfaceComposer.h
+++ b/libs/gui/include/gui/ISurfaceComposer.h
@@ -62,8 +62,6 @@
struct DisplayState;
struct InputWindowCommands;
class HdrCapabilities;
-class IGraphicBufferProducer;
-class ISurfaceComposerClient;
class Rect;
using gui::FrameTimelineInfo;
@@ -127,11 +125,6 @@
using EventRegistrationFlags = ftl::Flags<EventRegistration>;
- /*
- * Create a connection with SurfaceFlinger.
- */
- virtual sp<ISurfaceComposerClient> createConnection() = 0;
-
/* return an IDisplayEventConnection */
virtual sp<IDisplayEventConnection> createDisplayEventConnection(
VsyncSource vsyncSource = eVsyncSourceApp,
@@ -159,7 +152,7 @@
// Note: BOOT_FINISHED must remain this value, it is called from
// Java by ActivityManagerService.
BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,
- CREATE_CONNECTION,
+ CREATE_CONNECTION, // Deprecated. Autogenerated by .aidl now.
GET_STATIC_DISPLAY_INFO, // Deprecated. Autogenerated by .aidl now.
CREATE_DISPLAY_EVENT_CONNECTION,
CREATE_DISPLAY, // Deprecated. Autogenerated by .aidl now.
diff --git a/libs/gui/include/gui/ISurfaceComposerClient.h b/libs/gui/include/gui/ISurfaceComposerClient.h
deleted file mode 100644
index 9e9e191..0000000
--- a/libs/gui/include/gui/ISurfaceComposerClient.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <binder/IInterface.h>
-#include <binder/SafeInterface.h>
-#include <gui/LayerMetadata.h>
-#include <ui/PixelFormat.h>
-
-#include <unordered_map>
-
-namespace android {
-
-class FrameStats;
-class IGraphicBufferProducer;
-
-class ISurfaceComposerClient : public IInterface {
-public:
- DECLARE_META_INTERFACE(SurfaceComposerClient)
-
- // flags for createSurface()
- enum { // (keep in sync with SurfaceControl.java)
- eHidden = 0x00000004,
- eDestroyBackbuffer = 0x00000020,
- eSkipScreenshot = 0x00000040,
- eSecure = 0x00000080,
- eNonPremultiplied = 0x00000100,
- eOpaque = 0x00000400,
- eProtectedByApp = 0x00000800,
- eProtectedByDRM = 0x00001000,
- eCursorWindow = 0x00002000,
- eNoColorFill = 0x00004000,
-
- eFXSurfaceBufferQueue = 0x00000000,
- eFXSurfaceEffect = 0x00020000,
- eFXSurfaceBufferState = 0x00040000,
- eFXSurfaceContainer = 0x00080000,
- eFXSurfaceMask = 0x000F0000,
- };
-
- // TODO(b/172002646): Clean up the Surface Creation Arguments
- /*
- * Requires ACCESS_SURFACE_FLINGER permission
- */
- virtual status_t createSurface(const String8& name, uint32_t w, uint32_t h, PixelFormat format,
- uint32_t flags, const sp<IBinder>& parent,
- LayerMetadata metadata, sp<IBinder>* handle,
- sp<IGraphicBufferProducer>* gbp, int32_t* outLayerId,
- uint32_t* outTransformHint) = 0;
-
- /*
- * Requires ACCESS_SURFACE_FLINGER permission
- */
- virtual status_t createWithSurfaceParent(const String8& name, uint32_t w, uint32_t h,
- PixelFormat format, uint32_t flags,
- const sp<IGraphicBufferProducer>& parent,
- LayerMetadata metadata, sp<IBinder>* handle,
- sp<IGraphicBufferProducer>* gbp, int32_t* outLayerId,
- uint32_t* outTransformHint) = 0;
-
- /*
- * Requires ACCESS_SURFACE_FLINGER permission
- */
- virtual status_t clearLayerFrameStats(const sp<IBinder>& handle) const = 0;
-
- /*
- * Requires ACCESS_SURFACE_FLINGER permission
- */
- virtual status_t getLayerFrameStats(const sp<IBinder>& handle, FrameStats* outStats) const = 0;
-
- virtual status_t mirrorSurface(const sp<IBinder>& mirrorFromHandle, sp<IBinder>* outHandle,
- int32_t* outLayerId) = 0;
-};
-
-class BnSurfaceComposerClient : public SafeBnInterface<ISurfaceComposerClient> {
-public:
- BnSurfaceComposerClient()
- : SafeBnInterface<ISurfaceComposerClient>("BnSurfaceComposerClient") {}
-
- status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) override;
-};
-
-} // namespace android
diff --git a/libs/gui/include/gui/LayerMetadata.h b/libs/gui/include/gui/LayerMetadata.h
index 27f4d37..5af5989 100644
--- a/libs/gui/include/gui/LayerMetadata.h
+++ b/libs/gui/include/gui/LayerMetadata.h
@@ -20,7 +20,7 @@
#include <unordered_map>
-namespace android {
+namespace android::gui {
enum {
METADATA_OWNER_UID = 1,
@@ -69,4 +69,13 @@
ftl_last = Battery
};
-} // namespace android
+} // namespace android::gui
+
+using android::gui::METADATA_ACCESSIBILITY_ID;
+using android::gui::METADATA_DEQUEUE_TIME;
+using android::gui::METADATA_GAME_MODE;
+using android::gui::METADATA_MOUSE_CURSOR;
+using android::gui::METADATA_OWNER_PID;
+using android::gui::METADATA_OWNER_UID;
+using android::gui::METADATA_TASK_ID;
+using android::gui::METADATA_WINDOW_TYPE;
diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h
index 0a9b75a..4cd9a56 100644
--- a/libs/gui/include/gui/LayerState.h
+++ b/libs/gui/include/gui/LayerState.h
@@ -51,7 +51,9 @@
namespace android {
class Parcel;
-class ISurfaceComposerClient;
+
+using gui::ISurfaceComposerClient;
+using gui::LayerMetadata;
struct client_cache_t {
wp<IBinder> token = nullptr;
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index 8569a27..dc96242 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -40,6 +40,8 @@
#include <ui/Rotation.h>
#include <ui/StaticDisplayInfo.h>
+#include <android/gui/ISurfaceComposerClient.h>
+
#include <gui/CpuConsumer.h>
#include <gui/ISurfaceComposer.h>
#include <gui/ITransactionCompletedListener.h>
@@ -53,14 +55,15 @@
namespace android {
class HdrCapabilities;
-class ISurfaceComposerClient;
class IGraphicBufferProducer;
class ITunnelModeEnabledListener;
class Region;
using gui::DisplayCaptureArgs;
using gui::IRegionSamplingListener;
+using gui::ISurfaceComposerClient;
using gui::LayerCaptureArgs;
+using gui::LayerMetadata;
struct SurfaceControlStats {
SurfaceControlStats(const sp<SurfaceControl>& sc, nsecs_t latchTime,
@@ -312,7 +315,7 @@
uint32_t w, // width in pixel
uint32_t h, // height in pixel
PixelFormat format, // pixel-format desired
- uint32_t flags = 0, // usage flags
+ int32_t flags = 0, // usage flags
const sp<IBinder>& parentHandle = nullptr, // parentHandle
LayerMetadata metadata = LayerMetadata(), // metadata
uint32_t* outTransformHint = nullptr);
@@ -322,21 +325,11 @@
uint32_t h, // height in pixel
PixelFormat format, // pixel-format desired
sp<SurfaceControl>* outSurface,
- uint32_t flags = 0, // usage flags
+ int32_t flags = 0, // usage flags
const sp<IBinder>& parentHandle = nullptr, // parentHandle
LayerMetadata metadata = LayerMetadata(), // metadata
uint32_t* outTransformHint = nullptr);
- //! Create a surface
- sp<SurfaceControl> createWithSurfaceParent(const String8& name, // name of the surface
- uint32_t w, // width in pixel
- uint32_t h, // height in pixel
- PixelFormat format, // pixel-format desired
- uint32_t flags = 0, // usage flags
- Surface* parent = nullptr, // parent
- LayerMetadata metadata = LayerMetadata(), // metadata
- uint32_t* outTransformHint = nullptr);
-
// Creates a mirrored hierarchy for the mirrorFromSurface. This returns a SurfaceControl
// which is a parent of the root of the mirrored hierarchy.
//
diff --git a/libs/gui/include/gui/SurfaceControl.h b/libs/gui/include/gui/SurfaceControl.h
index b72cf83..e4a1350 100644
--- a/libs/gui/include/gui/SurfaceControl.h
+++ b/libs/gui/include/gui/SurfaceControl.h
@@ -24,11 +24,12 @@
#include <utils/RefBase.h>
#include <utils/threads.h>
+#include <android/gui/ISurfaceComposerClient.h>
+
#include <ui/FrameStats.h>
#include <ui/PixelFormat.h>
#include <ui/Region.h>
-#include <gui/ISurfaceComposerClient.h>
#include <math/vec3.h>
namespace android {
@@ -93,8 +94,7 @@
explicit SurfaceControl(const sp<SurfaceControl>& other);
SurfaceControl(const sp<SurfaceComposerClient>& client, const sp<IBinder>& handle,
- const sp<IGraphicBufferProducer>& gbp, int32_t layerId,
- uint32_t width = 0, uint32_t height = 0, PixelFormat format = 0,
+ int32_t layerId, uint32_t width = 0, uint32_t height = 0, PixelFormat format = 0,
uint32_t transformHint = 0, uint32_t flags = 0);
sp<SurfaceControl> getParentingLayer();
@@ -115,8 +115,7 @@
status_t validate() const;
sp<SurfaceComposerClient> mClient;
- sp<IBinder> mHandle;
- sp<IGraphicBufferProducer> mGraphicBufferProducer;
+ sp<IBinder> mHandle;
mutable Mutex mLock;
mutable sp<Surface> mSurfaceData;
mutable sp<BLASTBufferQueue> mBbq;
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index a9d8436..4ab380c 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -692,7 +692,6 @@
mSupportsPresent = supportsPresent;
}
- sp<ISurfaceComposerClient> createConnection() override { return nullptr; }
sp<IDisplayEventConnection> createDisplayEventConnection(
ISurfaceComposer::VsyncSource, ISurfaceComposer::EventRegistrationFlags) override {
return nullptr;
@@ -725,6 +724,11 @@
void setSupportsPresent(bool supportsPresent) { mSupportsPresent = supportsPresent; }
+ binder::Status createConnection(sp<gui::ISurfaceComposerClient>* outClient) override {
+ *outClient = nullptr;
+ return binder::Status::ok();
+ }
+
binder::Status createDisplay(const std::string& /*displayName*/, bool /*secure*/,
sp<IBinder>* /*outDisplay*/) override {
return binder::Status::ok();