diff options
author | 2025-01-06 12:50:14 -0800 | |
---|---|---|
committer | 2025-01-06 12:50:14 -0800 | |
commit | 706add335bee51d509e2162acf637f0009e1a343 (patch) | |
tree | 91098b1ec1335342e96828d75435bc7d72ddc108 | |
parent | ccc683d6647ed65cf34673043c67c62e395f5e53 (diff) | |
parent | da6c6feab224bfb05080031fc6586e44a421c253 (diff) |
Merge "Fix crash when checking null surfaces" into main
-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 3b34fa335cec..0fa92eab4c0a 100644 --- a/native/android/tests/performance_hint/PerformanceHintNativeTest.cpp +++ b/native/android/tests/performance_hint/PerformanceHintNativeTest.cpp @@ -605,6 +605,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); |