Pass correct window type and app id to hw composer.
1. Set -1 as default value for window type and app id.
2. When send layer information to hal, layers inherit type and app id from parent node when
parent node has valid type/appId.
3. Add window type and app id to SurfaceFlinger dumpsys.
Bug: 74622357
Test: Manual test. Several things verified:
1. Android settings layer, status bar layer, nav bar layer have valid window type and appId
when start android settings.
2. Layers without buffer have window type -1 and app id -1.
3. When send layers to hal, Chrome SurfaceView layer inherit type and app id from
its parent (MainActivity layer).
Change-Id: I8d6ad274ca18b61d1bbf6b28f7def5160b55b1e7
Merged-In: I8d6ad274ca18b61d1bbf6b28f7def5160b55b1e7
diff --git a/services/surfaceflinger/Client.cpp b/services/surfaceflinger/Client.cpp
index 0c9f0e2..c90024b 100644
--- a/services/surfaceflinger/Client.cpp
+++ b/services/surfaceflinger/Client.cpp
@@ -143,7 +143,7 @@
status_t Client::createSurface(
const String8& name,
uint32_t w, uint32_t h, PixelFormat format, uint32_t flags,
- const sp<IBinder>& parentHandle, uint32_t windowType, uint32_t ownerUid,
+ const sp<IBinder>& parentHandle, int32_t windowType, int32_t ownerUid,
sp<IBinder>* handle,
sp<IGraphicBufferProducer>* gbp)
{
@@ -180,13 +180,13 @@
PixelFormat format;
uint32_t flags;
sp<Layer>* parent;
- uint32_t windowType;
- uint32_t ownerUid;
+ int32_t windowType;
+ int32_t ownerUid;
public:
MessageCreateLayer(SurfaceFlinger* flinger,
const String8& name, Client* client,
uint32_t w, uint32_t h, PixelFormat format, uint32_t flags,
- sp<IBinder>* handle, uint32_t windowType, uint32_t ownerUid,
+ sp<IBinder>* handle, int32_t windowType, int32_t ownerUid,
sp<IGraphicBufferProducer>* gbp,
sp<Layer>* parent)
: flinger(flinger), client(client),
diff --git a/services/surfaceflinger/Client.h b/services/surfaceflinger/Client.h
index 2aab28f..c7df9f7 100644
--- a/services/surfaceflinger/Client.h
+++ b/services/surfaceflinger/Client.h
@@ -58,7 +58,7 @@
virtual status_t createSurface(
const String8& name,
uint32_t w, uint32_t h,PixelFormat format, uint32_t flags,
- const sp<IBinder>& parent, uint32_t windowType, uint32_t ownerUid,
+ const sp<IBinder>& parent, int32_t windowType, int32_t ownerUid,
sp<IBinder>* handle,
sp<IGraphicBufferProducer>* gbp);
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 44e60ed..6bd187f 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -587,8 +587,10 @@
sp<Layer> parent = mDrawingParent.promote();
if (parent.get()) {
auto& parentState = parent->getDrawingState();
- type = parentState.type;
- appId = parentState.appId;
+ if (parentState.type >= 0 || parentState.appId >= 0) {
+ type = parentState.type;
+ appId = parentState.appId;
+ }
}
error = hwcLayer->setInfo(type, appId);
@@ -1313,7 +1315,7 @@
return true;
}
-void Layer::setInfo(uint32_t type, uint32_t appId) {
+void Layer::setInfo(int32_t type, int32_t appId) {
mCurrentState.appId = appId;
mCurrentState.type = type;
mCurrentState.modified = true;
@@ -1919,6 +1921,8 @@
layerInfo->set_queued_frames(getQueuedFrameCount());
layerInfo->set_refresh_pending(isBufferLatched());
+ layerInfo->set_window_type(state.type);
+ layerInfo->set_app_id(state.appId);
}
// ---------------------------------------------------------------------------
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 996d686..f2fa5b9 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -203,8 +203,8 @@
Region requestedTransparentRegion;
android_dataspace dataSpace;
- uint32_t appId;
- uint32_t type;
+ int32_t appId;
+ int32_t type;
// If non-null, a Surface this Surface's Z-order is interpreted relative to.
wp<Layer> zOrderRelativeOf;
@@ -285,7 +285,7 @@
void deferTransactionUntil(const sp<IBinder>& barrierHandle, uint64_t frameNumber);
void deferTransactionUntil(const sp<Layer>& barrierLayer, uint64_t frameNumber);
bool setOverrideScalingMode(int32_t overrideScalingMode);
- void setInfo(uint32_t type, uint32_t appId);
+ void setInfo(int32_t type, int32_t appId);
bool reparentChildren(const sp<IBinder>& layer);
void reparentChildrenForDrawing(const sp<Layer>& layer);
bool reparent(const sp<IBinder>& newParentHandle);
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index a6e0a9e..472e45f 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -3318,7 +3318,7 @@
const String8& name,
const sp<Client>& client,
uint32_t w, uint32_t h, PixelFormat format, uint32_t flags,
- uint32_t windowType, uint32_t ownerUid, sp<IBinder>* handle,
+ int32_t windowType, int32_t ownerUid, sp<IBinder>* handle,
sp<IGraphicBufferProducer>* gbp, sp<Layer>* parent)
{
if (int32_t(w|h) < 0) {
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 51001e5..333dcbc 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -485,7 +485,7 @@
*/
status_t createLayer(const String8& name, const sp<Client>& client,
uint32_t w, uint32_t h, PixelFormat format, uint32_t flags,
- uint32_t windowType, uint32_t ownerUid, sp<IBinder>* handle,
+ int32_t windowType, int32_t ownerUid, sp<IBinder>* handle,
sp<IGraphicBufferProducer>* gbp, sp<Layer>* parent);
status_t createBufferLayer(const sp<Client>& client, const String8& name,
diff --git a/services/surfaceflinger/layerproto/LayerProtoParser.cpp b/services/surfaceflinger/layerproto/LayerProtoParser.cpp
index c9b7fe5..47e5d1f 100644
--- a/services/surfaceflinger/layerproto/LayerProtoParser.cpp
+++ b/services/surfaceflinger/layerproto/LayerProtoParser.cpp
@@ -106,6 +106,8 @@
layer->activeBuffer = generateActiveBuffer(layerProto.active_buffer());
layer->queuedFrames = layerProto.queued_frames();
layer->refreshPending = layerProto.refresh_pending();
+ layer->windowType = layerProto.window_type();
+ layer->appId = layerProto.app_id();
return layer;
}
@@ -281,7 +283,8 @@
StringAppendF(&result, " zOrderRelativeOf=%s\n",
zOrderRelativeOf == nullptr ? "none" : zOrderRelativeOf->name.c_str());
StringAppendF(&result, " activeBuffer=%s,", activeBuffer.to_string().c_str());
- StringAppendF(&result, " queued-frames=%d, mRefreshPending=%d", queuedFrames, refreshPending);
+ StringAppendF(&result, " queued-frames=%d, mRefreshPending=%d,", queuedFrames, refreshPending);
+ StringAppendF(&result, " windowType=%d, appId=%d", windowType, appId);
return result;
}
diff --git a/services/surfaceflinger/layerproto/include/layerproto/LayerProtoParser.h b/services/surfaceflinger/layerproto/include/layerproto/LayerProtoParser.h
index b81a959..b56a6fb 100644
--- a/services/surfaceflinger/layerproto/include/layerproto/LayerProtoParser.h
+++ b/services/surfaceflinger/layerproto/include/layerproto/LayerProtoParser.h
@@ -96,6 +96,8 @@
LayerProtoParser::ActiveBuffer activeBuffer;
int32_t queuedFrames;
bool refreshPending;
+ int32_t windowType;
+ int32_t appId;
std::string to_string() const;
};
diff --git a/services/surfaceflinger/layerproto/layers.proto b/services/surfaceflinger/layerproto/layers.proto
index d27dc9b..f18386b 100644
--- a/services/surfaceflinger/layerproto/layers.proto
+++ b/services/surfaceflinger/layerproto/layers.proto
@@ -64,6 +64,8 @@
// The number of frames available.
optional int32 queued_frames = 28;
optional bool refresh_pending = 29;
+ optional int32 window_type = 30;
+ optional int32 app_id = 31;
}
message PositionProto {