OSDN Git Service

Log: increase visibility of Log.TerribleFailure
authormukesh agrawal <quiche@google.com>
Mon, 17 Apr 2017 21:26:40 +0000 (14:26 -0700)
committerMukesh Agrawal <quiche@google.com>
Wed, 26 Apr 2017 00:49:34 +0000 (00:49 +0000)
The Log.setWtfHandler() provides a way to override
the default TerribleFailureHandler, so that we can
test that a piece of code reports as terrible
failure as expected.

Unfortunately, we can't actual use setWtfHandler()
at the moment. The problem is as follows:
1. The Log.setWtfHandler() method requires a
   Log.TerribleFailureHandler instance.
2. The Log.TerribleFailureHandler interface requires
   subclasses to implement a onTerribleFailure()
   method. The method requires a Log.TerribleFailure
   argument.
3. Log.TerribleFailure is a private inner class.

Given the above, classes outside of Log can't create
an appropriate argument to pass to Log.setWtfHandler().

To resolve this, we update the visibility of
Log.TerribleFailure to be the same as that of
Log.setWtfHandler(), and Log.TerribleFailureHandler.

Test: m -j32
Bug: 37425059
Change-Id: Ie646b931869582398d61495e367e0d36e767a3e3

core/java/android/util/Log.java

index 5bc6c94..8054ff5 100644 (file)
@@ -89,8 +89,9 @@ public final class Log {
 
     /**
      * Exception class used to capture a stack trace in {@link #wtf}.
+     * @hide
      */
-    private static class TerribleFailure extends Exception {
+    public static class TerribleFailure extends Exception {
         TerribleFailure(String msg, Throwable cause) { super(msg, cause); }
     }