Release SurfaceControl native resource when test finishes

By replacing factory methods, records all SurfaceControl and
Transaction objects created while test is running. Then release native
resources of those after test finishes. This will mitigate resource
presure while running WindowManagerService tests.

Bug: 116449554
Test: atest :presubmit in frameworks/base/services/core/java/com/android/server/wm
Change-Id: Iac99f80ee995bd64a82b965e4ea8a3135b0a5bd5
2 files changed