Loading flags/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ aconfig_declarations { "telecom_bluetoothdevicemanager_flags.aconfig", "telecom_non_critical_security_flags.aconfig", "telecom_headless_system_user_mode.aconfig", "telecom_session_flags.aconfig", "telecom_metrics_flags.aconfig", ], } flags/telecom_session_flags.aconfig 0 → 100644 +13 −0 Original line number Diff line number Diff line package: "com.android.server.telecom.flags" container: "system" # OWNER=breadley TARGET=25Q1 flag { name: "end_session_improvements" namespace: "telecom" description: "Ensure that ending a session doesnt cause a stack overflow" bug: "370349160" metadata { purpose: PURPOSE_BUGFIX } } No newline at end of file tests/src/com/android/server/telecom/tests/SessionManagerTest.java +33 −0 Original line number Diff line number Diff line Loading @@ -21,10 +21,14 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import android.telecom.Log; import android.telecom.Logging.Session; import android.telecom.Logging.SessionManager; import com.android.server.telecom.flags.Flags; import androidx.test.filters.SmallTest; import org.junit.After; Loading Loading @@ -411,4 +415,33 @@ public class SessionManagerTest extends TelecomTestCase { assertTrue(mTestSessionManager.mSessionMapper.isEmpty()); assertNull(sessionRef.get()); } /** * If Telecom gets into a situation where there are MANY sub-sessions created in a deep tree, * ensure that cleanup still happens properly. */ @SmallTest @Test public void testManySubsessionCleanupStress() { // This test will mostly likely fail with recursion due to stack overflow if (!Flags.endSessionImprovements()) return; Log.setIsExtendedLoggingEnabled(false); mTestSessionManager.mCurrentThreadId = () -> TEST_PARENT_THREAD_ID; mTestSessionManager.startSession(TEST_PARENT_NAME, null); Session parentSession = mTestSessionManager.mSessionMapper.get(TEST_PARENT_THREAD_ID); Session subsession; try { for (int i = 0; i < 10000; i++) { subsession = mTestSessionManager.createSubsession(); mTestSessionManager.endSession(); mTestSessionManager.continueSession(subsession, TEST_CHILD_NAME + i); } mTestSessionManager.endSession(); } catch (Exception e) { fail("Exception: " + e); } assertTrue(mTestSessionManager.mSessionMapper.isEmpty()); assertTrue(parentSession.isSessionCompleted()); assertTrue(parentSession.getChildSessions().isEmpty()); } } tests/src/com/android/server/telecom/tests/SessionTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -269,6 +269,6 @@ public class SessionTest extends TelecomTestCase { } private Session createTestSession(String name, String methodName) { return new Session(name, methodName, 0, false, null); return new Session(name, methodName, 0, false, false ,null); } } Loading
flags/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ aconfig_declarations { "telecom_bluetoothdevicemanager_flags.aconfig", "telecom_non_critical_security_flags.aconfig", "telecom_headless_system_user_mode.aconfig", "telecom_session_flags.aconfig", "telecom_metrics_flags.aconfig", ], }
flags/telecom_session_flags.aconfig 0 → 100644 +13 −0 Original line number Diff line number Diff line package: "com.android.server.telecom.flags" container: "system" # OWNER=breadley TARGET=25Q1 flag { name: "end_session_improvements" namespace: "telecom" description: "Ensure that ending a session doesnt cause a stack overflow" bug: "370349160" metadata { purpose: PURPOSE_BUGFIX } } No newline at end of file
tests/src/com/android/server/telecom/tests/SessionManagerTest.java +33 −0 Original line number Diff line number Diff line Loading @@ -21,10 +21,14 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import android.telecom.Log; import android.telecom.Logging.Session; import android.telecom.Logging.SessionManager; import com.android.server.telecom.flags.Flags; import androidx.test.filters.SmallTest; import org.junit.After; Loading Loading @@ -411,4 +415,33 @@ public class SessionManagerTest extends TelecomTestCase { assertTrue(mTestSessionManager.mSessionMapper.isEmpty()); assertNull(sessionRef.get()); } /** * If Telecom gets into a situation where there are MANY sub-sessions created in a deep tree, * ensure that cleanup still happens properly. */ @SmallTest @Test public void testManySubsessionCleanupStress() { // This test will mostly likely fail with recursion due to stack overflow if (!Flags.endSessionImprovements()) return; Log.setIsExtendedLoggingEnabled(false); mTestSessionManager.mCurrentThreadId = () -> TEST_PARENT_THREAD_ID; mTestSessionManager.startSession(TEST_PARENT_NAME, null); Session parentSession = mTestSessionManager.mSessionMapper.get(TEST_PARENT_THREAD_ID); Session subsession; try { for (int i = 0; i < 10000; i++) { subsession = mTestSessionManager.createSubsession(); mTestSessionManager.endSession(); mTestSessionManager.continueSession(subsession, TEST_CHILD_NAME + i); } mTestSessionManager.endSession(); } catch (Exception e) { fail("Exception: " + e); } assertTrue(mTestSessionManager.mSessionMapper.isEmpty()); assertTrue(parentSession.isSessionCompleted()); assertTrue(parentSession.getChildSessions().isEmpty()); } }
tests/src/com/android/server/telecom/tests/SessionTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -269,6 +269,6 @@ public class SessionTest extends TelecomTestCase { } private Session createTestSession(String name, String methodName) { return new Session(name, methodName, 0, false, null); return new Session(name, methodName, 0, false, false ,null); } }