From 1b7d2b95670a6c94cb29e0f4b965cebdf6f65bda Mon Sep 17 00:00:00 2001 From: John Reck Date: Thu, 22 Sep 2011 14:59:33 -0700 Subject: Fix Resources.getIdentifier usage Bug: 5352337 Change-Id: If639cf6dec892f2952f8eb3fedbb267e4cc7c0ae --- src/com/android/browser/homepages/RequestHandler.java | 3 ++- src/com/android/browser/homepages/Template.java | 4 +++- src/com/android/browser/search/SearchEngineInfo.java | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src/com/android/browser') diff --git a/src/com/android/browser/homepages/RequestHandler.java b/src/com/android/browser/homepages/RequestHandler.java index 248bf53..e0a0eac 100644 --- a/src/com/android/browser/homepages/RequestHandler.java +++ b/src/com/android/browser/homepages/RequestHandler.java @@ -115,7 +115,8 @@ public class RequestHandler extends Thread { void writeResource(String fileName) throws IOException { Resources res = mContext.getResources(); - int id = res.getIdentifier(fileName, null, mContext.getPackageName()); + String packageName = R.class.getPackage().getName(); + int id = res.getIdentifier(fileName, null, packageName); if (id != 0) { InputStream in = res.openRawResource(id); byte[] buf = new byte[4096]; diff --git a/src/com/android/browser/homepages/Template.java b/src/com/android/browser/homepages/Template.java index c1a6b0e..e918b07 100644 --- a/src/com/android/browser/homepages/Template.java +++ b/src/com/android/browser/homepages/Template.java @@ -30,6 +30,8 @@ import android.content.res.Resources; import android.database.Cursor; import android.util.TypedValue; +import com.android.browser.R; + public class Template { private static HashMap sCachedTemplates = new HashMap(); @@ -234,7 +236,7 @@ public class Template { private static String replaceConsts(Context context, String template) { final Pattern pattern = Pattern.compile("<%@\\s*(\\w+/\\w+)\\s*%>"); final Resources res = context.getResources(); - final String packageName = context.getPackageName(); + final String packageName = R.class.getPackage().getName(); Matcher m = pattern.matcher(template); StringBuffer sb = new StringBuffer(); while (m.find()) { diff --git a/src/com/android/browser/search/SearchEngineInfo.java b/src/com/android/browser/search/SearchEngineInfo.java index af6fa70..ec304f6 100644 --- a/src/com/android/browser/search/SearchEngineInfo.java +++ b/src/com/android/browser/search/SearchEngineInfo.java @@ -21,6 +21,8 @@ import android.content.res.Resources.NotFoundException; import android.text.TextUtils; import android.util.Log; +import com.android.browser.R; + import java.net.URLEncoder; import java.util.Arrays; import java.util.Locale; @@ -61,7 +63,8 @@ public class SearchEngineInfo { mName = name; Resources res = context.getResources(); - int id_data = res.getIdentifier(name, "array", context.getPackageName()); + String packageName = R.class.getPackage().getName(); + int id_data = res.getIdentifier(name, "array", packageName); if (id_data == 0) { throw new IllegalArgumentException("No resources found for " + name); } -- cgit v1.1