From b28503eb9a5d5aaba8798f2c45f277b476f0de10 Mon Sep 17 00:00:00 2001 From: d34d Date: Sat, 24 Jan 2015 11:05:40 -0800 Subject: Themes: Check common resource paths at java layer This solves two problems: 1. It won't try to attach common resources that do not exist 2. Avoids call down to the native layer if they don't exist Change-Id: I7b58b3f8a2540b6f62bd54feb21a3e33320c8e47 --- core/java/android/content/res/AssetManager.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'core/java/android/content/res') diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java index 421701a..ebbfd09 100644 --- a/core/java/android/content/res/AssetManager.java +++ b/core/java/android/content/res/AssetManager.java @@ -21,6 +21,7 @@ import android.util.Log; import android.util.SparseArray; import android.util.TypedValue; +import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -670,7 +671,11 @@ public final class AssetManager implements AutoCloseable { public final int addCommonOverlayPath(String themeApkPath, String resApkPath, String prefixPath) { synchronized (this) { - return addCommonOverlayPathNative(themeApkPath, resApkPath, prefixPath); + if ((new File(themeApkPath).exists()) && (new File(resApkPath).exists())) { + return addCommonOverlayPathNative(themeApkPath, resApkPath, prefixPath); + } + + return 0; } } -- cgit v1.1