Merge "Fix shadow painting in layoutlib"
diff --git a/bridge/src/android/os/ServiceManager.java b/bridge/src/android/os/ServiceManager.java
index 549074d..3e1ec07 100644
--- a/bridge/src/android/os/ServiceManager.java
+++ b/bridge/src/android/os/ServiceManager.java
@@ -71,4 +71,18 @@
public static void initServiceCache(Map<String, IBinder> cache) {
// pass
}
+
+ /**
+ * Exception thrown when no service published for given name. This might be
+ * thrown early during boot before certain services have published
+ * themselves.
+ *
+ * @hide
+ */
+ public static class ServiceNotFoundException extends Exception {
+ // identical to the original implementation
+ public ServiceNotFoundException(String name) {
+ super("No service published for: " + name);
+ }
+ }
}
diff --git a/bridge/tests/src/com/android/layoutlib/bridge/intensive/ImageUtils.java b/bridge/tests/src/com/android/layoutlib/bridge/intensive/ImageUtils.java
index d81b4ba..d3f0f89 100644
--- a/bridge/tests/src/com/android/layoutlib/bridge/intensive/ImageUtils.java
+++ b/bridge/tests/src/com/android/layoutlib/bridge/intensive/ImageUtils.java
@@ -179,7 +179,7 @@
g.drawString("Actual", 2 * imageWidth + 10, 20);
}
- File output = new File(getTempDir(), "delta-" + imageName);
+ File output = new File(getFailureDir(), "delta-" + imageName);
if (output.exists()) {
boolean deleted = output.delete();
assertTrue(deleted);
@@ -302,15 +302,16 @@
}
/**
- * Temp directory where to write the thumbnails and deltas.
+ * Directory where to write the thumbnails and deltas.
*/
@NonNull
- private static File getTempDir() {
- if (System.getProperty("os.name").equals("Mac OS X")) {
- return new File("/tmp"); //$NON-NLS-1$
- }
+ private static File getFailureDir() {
+ String workingDirString = System.getProperty("user.dir");
+ File failureDir = new File(workingDirString, "out/failures");
- return new File(System.getProperty("java.io.tmpdir")); //$NON-NLS-1$
+ //noinspection ResultOfMethodCallIgnored
+ failureDir.mkdirs();
+ return failureDir; //$NON-NLS-1$
}
/**
@@ -319,7 +320,7 @@
@NonNull
private static String saveImageAndAppendMessage(@NonNull BufferedImage image,
@NonNull String initialMessage, @NonNull String relativePath) throws IOException {
- File output = new File(getTempDir(), getName(relativePath));
+ File output = new File(getFailureDir(), getName(relativePath));
if (output.exists()) {
boolean deleted = output.delete();
assertTrue(deleted);