From 80ea4ead5bdf2a86aa63f70c6afeebbd5c0ec6d6 Mon Sep 17 00:00:00 2001 From: "Torne (Richard Coles)" Date: Thu, 18 Sep 2014 13:59:18 +0100 Subject: Cherry-pick: Fix resource rewriting in apps with other shared libs. The resource rewriter was inadvertantly rewriting the resources for the first shared library it found in the current application whether that was the WebView or not due to a copy and paste oversight. Actually check the name of the package before rewriting its resources. This is the name of the package as the R class sees it, which is always com.android.webview even when the manifest package name has been changed. Also remove unused imports. BUG=17539974 Change-Id: I6c35451748ee9c32011b9a8b885f7c9b0b2e915d --- .../android/webview/chromium/ResourceRewriter.java | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'chromium/java/com/android/webview') diff --git a/chromium/java/com/android/webview/chromium/ResourceRewriter.java b/chromium/java/com/android/webview/chromium/ResourceRewriter.java index 99fa46f..683277a 100644 --- a/chromium/java/com/android/webview/chromium/ResourceRewriter.java +++ b/chromium/java/com/android/webview/chromium/ResourceRewriter.java @@ -19,9 +19,6 @@ package com.android.webview.chromium; import android.content.Context; import android.util.SparseArray; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; - /** * Helper class used to fix up resource ids. * This is mostly a copy of the code in frameworks/base/core/java/android/app/LoadedApk.java. @@ -31,25 +28,28 @@ import java.lang.reflect.Modifier; class ResourceRewriter { public static void rewriteRValues(Context ctx) { - // Rewrite the R 'constants' for all library apks. + // Rewrite the R 'constants' for the WebView library apk. SparseArray packageIdentifiers = ctx.getResources().getAssets() .getAssignedPackageIdentifiers(); final int N = packageIdentifiers.size(); for (int i = 0; i < N; i++) { - final int id = packageIdentifiers.keyAt(i); - if (id == 0x01 || id == 0x7f) { - continue; - } + final String name = packageIdentifiers.valueAt(i); - // TODO: We should use jarjar to remove the redundant R classes here, but due - // to a bug in jarjar it's not possible to rename classes with '$' in their name. - // See b/15684775. - com.android.webview.chromium.R.onResourcesLoaded(id); - org.chromium.ui.R.onResourcesLoaded(id); - org.chromium.content.R.onResourcesLoaded(id); + // The resources are always called com.android.webview even if the manifest has had the + // package renamed. + if ("com.android.webview".equals(name)) { + final int id = packageIdentifiers.keyAt(i); - break; + // TODO: We should use jarjar to remove the redundant R classes here, but due + // to a bug in jarjar it's not possible to rename classes with '$' in their name. + // See b/15684775. + com.android.webview.chromium.R.onResourcesLoaded(id); + org.chromium.ui.R.onResourcesLoaded(id); + org.chromium.content.R.onResourcesLoaded(id); + + break; + } } } } -- cgit v1.2.3 From 9ba9bb83eb4f11281bb62118b347561b9c7e3231 Mon Sep 17 00:00:00 2001 From: Marcin Kosiba Date: Fri, 10 Oct 2014 17:19:17 +0100 Subject: Match removal of config_webSettingsDefaultTextEncoding. This is to match http://ag/565166 which removes the resource. Change-Id: Id064af59410ac5d031af0c26817a5a15ea320906 (cherry picked from commit 53dc1aa95198e9cf7020ec848f3b27cbee50b35e) --- .../com/android/webview/chromium/WebViewChromiumFactoryProvider.java | 2 -- 1 file changed, 2 deletions(-) (limited to 'chromium/java/com/android/webview') diff --git a/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java b/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java index 5a947e8..1b10971 100644 --- a/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java +++ b/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java @@ -303,8 +303,6 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { AwResource.setResources(ctx.getResources()); AwResource.setErrorPageResources(android.R.raw.loaderror, android.R.raw.nodomain); - AwResource.setDefaultTextEncoding( - android.R.string.config_webSettingsDefaultTextEncoding); AwResource.setConfigKeySystemUuidMapping( android.R.array.config_keySystemUuidMapping); } -- cgit v1.2.3