DO NOT MERGE Fix for ThreadGroup CTS test.

Fixed the test for UncaughtExceptionHandler. This was actually
several tests in one. Each has been broken out. The ones that
were failing were a result of the CTS test runner executing as
an instrumented Android app. The default behavior (configured in
com.android.internal.os.RuntimeInit) is to kill an app if an
uncaught exception reaches the top-most handler. The solution
was to set an alternative default UncaughtExceptionHandler on
Thread to suppress this behavior for the duration of the test
by installing an alternative handler. This handler could also
then be used to confirm the ThreadGroup behavior of "if an
exception is handled by the ThreadGroup hierarchy, use the
Thread default UncaughtExceptionHandler".

The functionality changes are in:
1) setUp()/tearDown() - installing, uninstalling the handler and
removing a Thread.sleep(50).
2) test_uncaughtException_* methods split out. Additional tests
were added and one was removed.
3) Tidied up test_list(), which was relying on particular
thread names and would have used Thread.stop() (which is
unimplemented) if those threads were found.

The remaining changes were refactorings to pull out common code,
remove unneccessary newlines / comments / semi-colons, reformat
to 100 chars width, remove == true / == false  conditions, delete
dead code. All pure functions have been made static to make it
clearer they have no side-effects.

What remains is still not nice, but is improved and ~300 lines
shorter.

Bug: 13748422

(cherry picked from commit 071ba8eb49cc6ea63dc913aab145076dbeff0049)

Change-Id: I995553a909974cb0bb6b9521a6a39fd0d6014a3f
1 file changed