diff options
| -rw-r--r-- | include/android/input.h | 13 | ||||
| -rw-r--r-- | libs/binder/IPCThreadState.cpp | 18 | ||||
| -rw-r--r-- | libs/binder/include/binder/IPCThreadState.h | 8 | ||||
| -rw-r--r-- | libs/binder/tests/binderLibTest.cpp | 12 | ||||
| -rw-r--r-- | libs/gui/BLASTBufferQueue.cpp | 19 | ||||
| -rw-r--r-- | libs/gui/Surface.cpp | 10 | ||||
| -rw-r--r-- | libs/gui/include/gui/Surface.h | 3 |
7 files changed, 43 insertions, 40 deletions
diff --git a/include/android/input.h b/include/android/input.h index bb98beb41a..76422154f1 100644 --- a/include/android/input.h +++ b/include/android/input.h @@ -947,9 +947,10 @@ int32_t AInputEvent_getSource(const AInputEvent* event); * and {@link AMotionEvent_fromJava()}. * After returning, the specified AInputEvent* object becomes invalid and should no longer be used. * The underlying Java object remains valid and does not change its state. + * + * Available since API level 31. */ - -void AInputEvent_release(const AInputEvent* event); +void AInputEvent_release(const AInputEvent* event) __INTRODUCED_IN(31); /*** Accessors for key events only. ***/ @@ -1001,8 +1002,10 @@ int64_t AKeyEvent_getEventTime(const AInputEvent* key_event); * Creates a native AInputEvent* object that is a copy of the specified Java android.view.KeyEvent. * The result may be used with generic and KeyEvent-specific AInputEvent_* functions. The object * returned by this function must be disposed using {@link AInputEvent_release()}. + * + * Available since API level 31. */ -const AInputEvent* AKeyEvent_fromJava(JNIEnv* env, jobject keyEvent); +const AInputEvent* AKeyEvent_fromJava(JNIEnv* env, jobject keyEvent) __INTRODUCED_IN(31); /*** Accessors for motion events only. ***/ @@ -1324,8 +1327,10 @@ float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event, * android.view.MotionEvent. The result may be used with generic and MotionEvent-specific * AInputEvent_* functions. The object returned by this function must be disposed using * {@link AInputEvent_release()}. + * + * Available since API level 31. */ -const AInputEvent* AMotionEvent_fromJava(JNIEnv* env, jobject motionEvent); +const AInputEvent* AMotionEvent_fromJava(JNIEnv* env, jobject motionEvent) __INTRODUCED_IN(31); struct AInputQueue; /** diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp index 9e04ffeb11..55d3d70bd4 100644 --- a/libs/binder/IPCThreadState.cpp +++ b/libs/binder/IPCThreadState.cpp @@ -1410,23 +1410,6 @@ void IPCThreadState::threadDestructor(void *st) } } -status_t IPCThreadState::getProcessFreezeInfo(pid_t pid, bool *sync_received, bool *async_received) -{ - int ret = 0; - binder_frozen_status_info info; - info.pid = pid; - -#if defined(__ANDROID__) - if (ioctl(self()->mProcess->mDriverFD, BINDER_GET_FROZEN_INFO, &info) < 0) - ret = -errno; -#endif - *sync_received = info.sync_recv; - *async_received = info.async_recv; - - return ret; -} - -#ifndef __ANDROID_VNDK__ status_t IPCThreadState::getProcessFreezeInfo(pid_t pid, uint32_t *sync_received, uint32_t *async_received) { @@ -1443,7 +1426,6 @@ status_t IPCThreadState::getProcessFreezeInfo(pid_t pid, uint32_t *sync_received return ret; } -#endif status_t IPCThreadState::freeze(pid_t pid, bool enable, uint32_t timeout_ms) { struct binder_freeze_info info; diff --git a/libs/binder/include/binder/IPCThreadState.h b/libs/binder/include/binder/IPCThreadState.h index 065e6e3b1d..82bebc95f4 100644 --- a/libs/binder/include/binder/IPCThreadState.h +++ b/libs/binder/include/binder/IPCThreadState.h @@ -51,17 +51,11 @@ public: static status_t freeze(pid_t pid, bool enabled, uint32_t timeout_ms); // Provide information about the state of a frozen process - static status_t getProcessFreezeInfo(pid_t pid, bool *sync_received, - bool *async_received); - - // TODO: Remove the above legacy duplicated function in next version -#ifndef __ANDROID_VNDK__ static status_t getProcessFreezeInfo(pid_t pid, uint32_t *sync_received, uint32_t *async_received); -#endif sp<ProcessState> process(); - + status_t clearLastError(); /** diff --git a/libs/binder/tests/binderLibTest.cpp b/libs/binder/tests/binderLibTest.cpp index 639876ffe3..c69203be2d 100644 --- a/libs/binder/tests/binderLibTest.cpp +++ b/libs/binder/tests/binderLibTest.cpp @@ -491,7 +491,7 @@ TEST_F(BinderLibTest, Freeze) { EXPECT_EQ(NO_ERROR, IPCThreadState::self()->freeze(pid, true, 1000)); EXPECT_EQ(FAILED_TRANSACTION, m_server->transact(BINDER_LIB_TEST_NOP_TRANSACTION, data, &reply)); - bool sync_received, async_received; + uint32_t sync_received, async_received; EXPECT_EQ(NO_ERROR, IPCThreadState::self()->getProcessFreezeInfo(pid, &sync_received, &async_received)); @@ -499,15 +499,7 @@ TEST_F(BinderLibTest, Freeze) { EXPECT_EQ(sync_received, 1); EXPECT_EQ(async_received, 0); - uint32_t sync_received2, async_received2; - - EXPECT_EQ(NO_ERROR, IPCThreadState::self()->getProcessFreezeInfo(pid, &sync_received2, - &async_received2)); - - EXPECT_EQ(sync_received2, 1); - EXPECT_EQ(async_received2, 0); - - EXPECT_EQ(NO_ERROR, IPCThreadState::self()->freeze(pid, 0, 0)); + EXPECT_EQ(NO_ERROR, IPCThreadState::self()->freeze(pid, false, 0)); EXPECT_EQ(NO_ERROR, m_server->transact(BINDER_LIB_TEST_NOP_TRANSACTION, data, &reply)); } diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp index 56a9683773..f7ec8ef40e 100644 --- a/libs/gui/BLASTBufferQueue.cpp +++ b/libs/gui/BLASTBufferQueue.cpp @@ -630,7 +630,10 @@ bool BLASTBufferQueue::maxBuffersAcquired(bool includeExtraAcquire) const { class BBQSurface : public Surface { private: + std::mutex mMutex; sp<BLASTBufferQueue> mBbq; + bool mDestroyed = false; + public: BBQSurface(const sp<IGraphicBufferProducer>& igbp, bool controlledByApp, const sp<IBinder>& scHandle, const sp<BLASTBufferQueue>& bbq) @@ -650,6 +653,10 @@ public: status_t setFrameRate(float frameRate, int8_t compatibility, int8_t changeFrameRateStrategy) override { + std::unique_lock _lock{mMutex}; + if (mDestroyed) { + return DEAD_OBJECT; + } if (!ValidateFrameRate(frameRate, compatibility, changeFrameRateStrategy, "BBQSurface::setFrameRate")) { return BAD_VALUE; @@ -658,8 +665,20 @@ public: } status_t setFrameTimelineInfo(const FrameTimelineInfo& frameTimelineInfo) override { + std::unique_lock _lock{mMutex}; + if (mDestroyed) { + return DEAD_OBJECT; + } return mBbq->setFrameTimelineInfo(frameTimelineInfo); } + + void destroy() override { + Surface::destroy(); + + std::unique_lock _lock{mMutex}; + mDestroyed = true; + mBbq = nullptr; + } }; // TODO: Can we coalesce this with frame updates? Need to confirm diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp index 2edb4e4ba4..353a91d062 100644 --- a/libs/gui/Surface.cpp +++ b/libs/gui/Surface.cpp @@ -2622,4 +2622,14 @@ status_t Surface::setFrameTimelineInfo(const FrameTimelineInfo& frameTimelineInf return composerService()->setFrameTimelineInfo(mGraphicBufferProducer, frameTimelineInfo); } +sp<IBinder> Surface::getSurfaceControlHandle() const { + Mutex::Autolock lock(mMutex); + return mSurfaceControlHandle; +} + +void Surface::destroy() { + Mutex::Autolock lock(mMutex); + mSurfaceControlHandle = nullptr; +} + }; // namespace android diff --git a/libs/gui/include/gui/Surface.h b/libs/gui/include/gui/Surface.h index 7e4143b1f3..e5403512a9 100644 --- a/libs/gui/include/gui/Surface.h +++ b/libs/gui/include/gui/Surface.h @@ -99,7 +99,7 @@ public: */ sp<IGraphicBufferProducer> getIGraphicBufferProducer() const; - sp<IBinder> getSurfaceControlHandle() const { return mSurfaceControlHandle; } + sp<IBinder> getSurfaceControlHandle() const; /* convenience function to check that the given surface is non NULL as * well as its IGraphicBufferProducer */ @@ -333,6 +333,7 @@ public: virtual int connect( int api, bool reportBufferRemoval, const sp<SurfaceListener>& sListener); + virtual void destroy(); // When client connects to Surface with reportBufferRemoval set to true, any buffers removed // from this Surface will be collected and returned here. Once this method returns, these |