diff options
author | 2024-12-30 17:53:03 -0800 | |
---|---|---|
committer | 2025-01-03 13:52:34 -0800 | |
commit | da6c6feab224bfb05080031fc6586e44a421c253 (patch) | |
tree | 7cd643cdd9c27dafe36f674d75eae0fa18ff698f | |
parent | af6a5266128e40ad6dbcbb1144ae3e3de0c71abc (diff) |
Fix crash when checking null surfaces
Test: atest PerformanceHintNativeTestCases
Bug: none
Flag: EXEMPT bugfix
Change-Id: Ie5520a33107187484a15eeb0b536de2ea6c1872e
-rw-r--r-- | native/android/performance_hint.cpp | 2 | ||||
-rw-r--r-- | native/android/tests/performance_hint/PerformanceHintNativeTest.cpp | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/native/android/performance_hint.cpp b/native/android/performance_hint.cpp index 68c1983825a2..1e6a7b7f2810 100644 --- a/native/android/performance_hint.cpp +++ b/native/android/performance_hint.cpp @@ -859,7 +859,7 @@ void APerformanceHintManager::layersFromNativeSurfaces(ANativeWindow** windows, std::vector<ANativeWindow*> windowVec(windows, windows + numWindows); for (auto&& window : windowVec) { Surface* surface = static_cast<Surface*>(window); - if (Surface::isValid(surface)) { + if (surface != nullptr) { const sp<IBinder>& handle = surface->getSurfaceControlHandle(); if (handle != nullptr) { out.push_back(handle); diff --git a/native/android/tests/performance_hint/PerformanceHintNativeTest.cpp b/native/android/tests/performance_hint/PerformanceHintNativeTest.cpp index f68fa1a89540..477d60b8972a 100644 --- a/native/android/tests/performance_hint/PerformanceHintNativeTest.cpp +++ b/native/android/tests/performance_hint/PerformanceHintNativeTest.cpp @@ -602,6 +602,15 @@ TEST_F(PerformanceHintTest, TestASessionCreationConfig) { ASSERT_NE(config, nullptr); } +TEST_F(PerformanceHintTest, TestSessionCreationWithNullLayers) { + EXPECT_CALL(*mMockIHintManager, createHintSessionWithConfig(_, _, _, _, _)).Times(1); + auto&& config = configFromCreator( + {.tids = mTids, .nativeWindows = {nullptr}, .surfaceControls = {nullptr}}); + APerformanceHintManager* manager = createManager(); + auto&& session = createSessionUsingConfig(manager, config); + ASSERT_TRUE(session); +} + TEST_F(PerformanceHintTest, TestSupportObject) { // Disable GPU and Power Efficiency support to test partial enabling mClientData.supportInfo.sessionModes &= ~(1 << (int)hal::SessionMode::AUTO_GPU); |