Loading libs/binder/Parcel.cpp +39 −0 Original line number Diff line number Diff line Loading @@ -599,17 +599,53 @@ bool Parcel::hasFileDescriptors() const return mHasFds; } void Parcel::updateWorkSourceRequestHeaderPosition() const { // Only update the request headers once. We only want to point // to the first headers read/written. if (!mRequestHeaderPresent) { mWorkSourceRequestHeaderPosition = dataPosition(); mRequestHeaderPresent = true; } } // Write RPC headers. (previously just the interface token) status_t Parcel::writeInterfaceToken(const String16& interface) { const IPCThreadState* threadState = IPCThreadState::self(); writeInt32(threadState->getStrictModePolicy() | STRICT_MODE_PENALTY_GATHER); updateWorkSourceRequestHeaderPosition(); writeInt32(threadState->shouldPropagateWorkSource() ? threadState->getCallingWorkSourceUid() : IPCThreadState::kUnsetWorkSource); // currently the interface identification token is just its name as a string return writeString16(interface); } bool Parcel::replaceCallingWorkSourceUid(uid_t uid) { if (!mRequestHeaderPresent) { return false; } const size_t initialPosition = dataPosition(); setDataPosition(mWorkSourceRequestHeaderPosition); status_t err = writeInt32(uid); setDataPosition(initialPosition); return err == NO_ERROR; } uid_t Parcel::readCallingWorkSourceUid() { if (!mRequestHeaderPresent) { return IPCThreadState::kUnsetWorkSource; } const size_t initialPosition = dataPosition(); setDataPosition(mWorkSourceRequestHeaderPosition); uid_t uid = readInt32(); setDataPosition(initialPosition); return uid; } bool Parcel::checkInterface(IBinder* binder) const { return enforceInterface(binder->getInterfaceDescriptor()); Loading @@ -634,6 +670,7 @@ bool Parcel::enforceInterface(const String16& interface, threadState->setStrictModePolicy(strictPolicy); } // WorkSource. updateWorkSourceRequestHeaderPosition(); int32_t workSource = readInt32(); threadState->setCallingWorkSourceUidWithoutPropagation(workSource); // Interface descriptor. Loading Loading @@ -2889,6 +2926,8 @@ void Parcel::initState() mAllowFds = true; mOwner = nullptr; mOpenAshmemSize = 0; mWorkSourceRequestHeaderPosition = 0; mRequestHeaderPresent = false; // racing multiple init leads only to multiple identical write if (gMaxFds == 0) { Loading libs/binder/include/binder/Parcel.h +10 −0 Original line number Diff line number Diff line Loading @@ -395,6 +395,12 @@ public: static size_t getGlobalAllocSize(); static size_t getGlobalAllocCount(); bool replaceCallingWorkSourceUid(uid_t uid); // Returns the work source provided by the caller. This can only be trusted for trusted calling // uid. uid_t readCallingWorkSourceUid(); void readRequestHeaders() const; private: typedef void (*release_func)(Parcel* parcel, const uint8_t* data, size_t dataSize, Loading Loading @@ -429,6 +435,7 @@ private: void initState(); void scanForFds() const; status_t validateReadData(size_t len) const; void updateWorkSourceRequestHeaderPosition() const; template<class T> status_t readAligned(T *pArg) const; Loading Loading @@ -477,6 +484,9 @@ private: mutable size_t mNextObjectHint; mutable bool mObjectsSorted; mutable bool mRequestHeaderPresent; mutable size_t mWorkSourceRequestHeaderPosition; mutable bool mFdsKnown; mutable bool mHasFds; bool mAllowFds; Loading libs/gui/LayerState.cpp +9 −11 Original line number Diff line number Diff line Loading @@ -98,8 +98,8 @@ status_t layer_state_t::write(Parcel& output) const output.writeInt32(cachedBuffer.bufferId); output.writeParcelable(metadata); output.writeFloat(colorAlpha); output.writeUint32(static_cast<uint32_t>(colorDataspace)); output.writeFloat(bgColorAlpha); output.writeUint32(static_cast<uint32_t>(bgColorDataspace)); return NO_ERROR; } Loading Loading @@ -175,8 +175,8 @@ status_t layer_state_t::read(const Parcel& input) cachedBuffer.bufferId = input.readInt32(); input.readParcelable(&metadata); colorAlpha = input.readFloat(); colorDataspace = static_cast<ui::Dataspace>(input.readUint32()); bgColorAlpha = input.readFloat(); bgColorDataspace = static_cast<ui::Dataspace>(input.readUint32()); return NO_ERROR; } Loading Loading @@ -390,13 +390,11 @@ void layer_state_t::merge(const layer_state_t& other) { what |= eCachedBufferChanged; cachedBuffer = other.cachedBuffer; } if (other.what & eColorAlphaChanged) { what |= eColorAlphaChanged; colorAlpha = other.colorAlpha; } if (other.what & eColorDataspaceChanged) { what |= eColorDataspaceChanged; colorDataspace = other.colorDataspace; if (other.what & eBackgroundColorChanged) { what |= eBackgroundColorChanged; color = other.color; bgColorAlpha = other.bgColorAlpha; bgColorDataspace = other.bgColorDataspace; } if (other.what & eMetadataChanged) { what |= eMetadataChanged; Loading libs/gui/SurfaceComposerClient.cpp +6 −19 Original line number Diff line number Diff line Loading @@ -678,31 +678,18 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setColor return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setColorAlpha( const sp<SurfaceControl>& sc, float alpha) { layer_state_t* s = getLayerState(sc); if (!s) { mStatus = BAD_INDEX; return *this; } s->what |= layer_state_t::eColorAlphaChanged; s->colorAlpha = alpha; registerSurfaceControlForCallback(sc); return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setColorDataspace( const sp<SurfaceControl>& sc, ui::Dataspace dataspace) { SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBackgroundColor( const sp<SurfaceControl>& sc, const half3& color, float alpha, ui::Dataspace dataspace) { layer_state_t* s = getLayerState(sc); if (!s) { mStatus = BAD_INDEX; return *this; } s->what |= layer_state_t::eColorDataspaceChanged; s->colorDataspace = dataspace; s->what |= layer_state_t::eBackgroundColorChanged; s->color = color; s->bgColorAlpha = alpha; s->bgColorDataspace = dataspace; registerSurfaceControlForCallback(sc); return *this; Loading libs/gui/include/gui/LayerState.h +9 −8 Original line number Diff line number Diff line Loading @@ -86,9 +86,8 @@ struct layer_state_t { eCornerRadiusChanged = 0x80000000, eFrameChanged = 0x1'00000000, eCachedBufferChanged = 0x2'00000000, eColorAlphaChanged = 0x4'00000000, eColorDataspaceChanged = 0x8'00000000, eMetadataChanged = 0x10'00000000, eBackgroundColorChanged = 0x4'00000000, eMetadataChanged = 0x8'00000000, }; layer_state_t() Loading @@ -115,8 +114,8 @@ struct layer_state_t { surfaceDamageRegion(), api(-1), colorTransform(mat4()), colorAlpha(0), colorDataspace(ui::Dataspace::UNKNOWN) { bgColorAlpha(0), bgColorDataspace(ui::Dataspace::UNKNOWN) { matrix.dsdx = matrix.dtdy = 1.0f; matrix.dsdy = matrix.dtdx = 0.0f; hdrMetadata.validTypes = 0; Loading Loading @@ -187,10 +186,12 @@ struct layer_state_t { cached_buffer_t cachedBuffer; float colorAlpha; ui::Dataspace colorDataspace; LayerMetadata metadata; // The following refer to the alpha, and dataspace, respectively of // the background color layer float bgColorAlpha; ui::Dataspace bgColorDataspace; }; struct ComposerState { Loading Loading
libs/binder/Parcel.cpp +39 −0 Original line number Diff line number Diff line Loading @@ -599,17 +599,53 @@ bool Parcel::hasFileDescriptors() const return mHasFds; } void Parcel::updateWorkSourceRequestHeaderPosition() const { // Only update the request headers once. We only want to point // to the first headers read/written. if (!mRequestHeaderPresent) { mWorkSourceRequestHeaderPosition = dataPosition(); mRequestHeaderPresent = true; } } // Write RPC headers. (previously just the interface token) status_t Parcel::writeInterfaceToken(const String16& interface) { const IPCThreadState* threadState = IPCThreadState::self(); writeInt32(threadState->getStrictModePolicy() | STRICT_MODE_PENALTY_GATHER); updateWorkSourceRequestHeaderPosition(); writeInt32(threadState->shouldPropagateWorkSource() ? threadState->getCallingWorkSourceUid() : IPCThreadState::kUnsetWorkSource); // currently the interface identification token is just its name as a string return writeString16(interface); } bool Parcel::replaceCallingWorkSourceUid(uid_t uid) { if (!mRequestHeaderPresent) { return false; } const size_t initialPosition = dataPosition(); setDataPosition(mWorkSourceRequestHeaderPosition); status_t err = writeInt32(uid); setDataPosition(initialPosition); return err == NO_ERROR; } uid_t Parcel::readCallingWorkSourceUid() { if (!mRequestHeaderPresent) { return IPCThreadState::kUnsetWorkSource; } const size_t initialPosition = dataPosition(); setDataPosition(mWorkSourceRequestHeaderPosition); uid_t uid = readInt32(); setDataPosition(initialPosition); return uid; } bool Parcel::checkInterface(IBinder* binder) const { return enforceInterface(binder->getInterfaceDescriptor()); Loading @@ -634,6 +670,7 @@ bool Parcel::enforceInterface(const String16& interface, threadState->setStrictModePolicy(strictPolicy); } // WorkSource. updateWorkSourceRequestHeaderPosition(); int32_t workSource = readInt32(); threadState->setCallingWorkSourceUidWithoutPropagation(workSource); // Interface descriptor. Loading Loading @@ -2889,6 +2926,8 @@ void Parcel::initState() mAllowFds = true; mOwner = nullptr; mOpenAshmemSize = 0; mWorkSourceRequestHeaderPosition = 0; mRequestHeaderPresent = false; // racing multiple init leads only to multiple identical write if (gMaxFds == 0) { Loading
libs/binder/include/binder/Parcel.h +10 −0 Original line number Diff line number Diff line Loading @@ -395,6 +395,12 @@ public: static size_t getGlobalAllocSize(); static size_t getGlobalAllocCount(); bool replaceCallingWorkSourceUid(uid_t uid); // Returns the work source provided by the caller. This can only be trusted for trusted calling // uid. uid_t readCallingWorkSourceUid(); void readRequestHeaders() const; private: typedef void (*release_func)(Parcel* parcel, const uint8_t* data, size_t dataSize, Loading Loading @@ -429,6 +435,7 @@ private: void initState(); void scanForFds() const; status_t validateReadData(size_t len) const; void updateWorkSourceRequestHeaderPosition() const; template<class T> status_t readAligned(T *pArg) const; Loading Loading @@ -477,6 +484,9 @@ private: mutable size_t mNextObjectHint; mutable bool mObjectsSorted; mutable bool mRequestHeaderPresent; mutable size_t mWorkSourceRequestHeaderPosition; mutable bool mFdsKnown; mutable bool mHasFds; bool mAllowFds; Loading
libs/gui/LayerState.cpp +9 −11 Original line number Diff line number Diff line Loading @@ -98,8 +98,8 @@ status_t layer_state_t::write(Parcel& output) const output.writeInt32(cachedBuffer.bufferId); output.writeParcelable(metadata); output.writeFloat(colorAlpha); output.writeUint32(static_cast<uint32_t>(colorDataspace)); output.writeFloat(bgColorAlpha); output.writeUint32(static_cast<uint32_t>(bgColorDataspace)); return NO_ERROR; } Loading Loading @@ -175,8 +175,8 @@ status_t layer_state_t::read(const Parcel& input) cachedBuffer.bufferId = input.readInt32(); input.readParcelable(&metadata); colorAlpha = input.readFloat(); colorDataspace = static_cast<ui::Dataspace>(input.readUint32()); bgColorAlpha = input.readFloat(); bgColorDataspace = static_cast<ui::Dataspace>(input.readUint32()); return NO_ERROR; } Loading Loading @@ -390,13 +390,11 @@ void layer_state_t::merge(const layer_state_t& other) { what |= eCachedBufferChanged; cachedBuffer = other.cachedBuffer; } if (other.what & eColorAlphaChanged) { what |= eColorAlphaChanged; colorAlpha = other.colorAlpha; } if (other.what & eColorDataspaceChanged) { what |= eColorDataspaceChanged; colorDataspace = other.colorDataspace; if (other.what & eBackgroundColorChanged) { what |= eBackgroundColorChanged; color = other.color; bgColorAlpha = other.bgColorAlpha; bgColorDataspace = other.bgColorDataspace; } if (other.what & eMetadataChanged) { what |= eMetadataChanged; Loading
libs/gui/SurfaceComposerClient.cpp +6 −19 Original line number Diff line number Diff line Loading @@ -678,31 +678,18 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setColor return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setColorAlpha( const sp<SurfaceControl>& sc, float alpha) { layer_state_t* s = getLayerState(sc); if (!s) { mStatus = BAD_INDEX; return *this; } s->what |= layer_state_t::eColorAlphaChanged; s->colorAlpha = alpha; registerSurfaceControlForCallback(sc); return *this; } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setColorDataspace( const sp<SurfaceControl>& sc, ui::Dataspace dataspace) { SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBackgroundColor( const sp<SurfaceControl>& sc, const half3& color, float alpha, ui::Dataspace dataspace) { layer_state_t* s = getLayerState(sc); if (!s) { mStatus = BAD_INDEX; return *this; } s->what |= layer_state_t::eColorDataspaceChanged; s->colorDataspace = dataspace; s->what |= layer_state_t::eBackgroundColorChanged; s->color = color; s->bgColorAlpha = alpha; s->bgColorDataspace = dataspace; registerSurfaceControlForCallback(sc); return *this; Loading
libs/gui/include/gui/LayerState.h +9 −8 Original line number Diff line number Diff line Loading @@ -86,9 +86,8 @@ struct layer_state_t { eCornerRadiusChanged = 0x80000000, eFrameChanged = 0x1'00000000, eCachedBufferChanged = 0x2'00000000, eColorAlphaChanged = 0x4'00000000, eColorDataspaceChanged = 0x8'00000000, eMetadataChanged = 0x10'00000000, eBackgroundColorChanged = 0x4'00000000, eMetadataChanged = 0x8'00000000, }; layer_state_t() Loading @@ -115,8 +114,8 @@ struct layer_state_t { surfaceDamageRegion(), api(-1), colorTransform(mat4()), colorAlpha(0), colorDataspace(ui::Dataspace::UNKNOWN) { bgColorAlpha(0), bgColorDataspace(ui::Dataspace::UNKNOWN) { matrix.dsdx = matrix.dtdy = 1.0f; matrix.dsdy = matrix.dtdx = 0.0f; hdrMetadata.validTypes = 0; Loading Loading @@ -187,10 +186,12 @@ struct layer_state_t { cached_buffer_t cachedBuffer; float colorAlpha; ui::Dataspace colorDataspace; LayerMetadata metadata; // The following refer to the alpha, and dataspace, respectively of // the background color layer float bgColorAlpha; ui::Dataspace bgColorDataspace; }; struct ComposerState { Loading