Merge "Revert "Load WebView from one out of a list of packages."" into mnc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1b48a6430a
@@ -96,49 +96,27 @@ public final class WebViewFactory {
|
|||||||
public MissingWebViewPackageException(Exception e) { super(e); }
|
public MissingWebViewPackageException(Exception e) { super(e); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public static String[] getWebViewPackageNames() {
|
|
||||||
return AppGlobals.getInitialApplication().getResources().getStringArray(
|
|
||||||
com.android.internal.R.array.config_webViewPackageNames);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO (gsennton) remove when committing webview xts test change
|
|
||||||
public static String getWebViewPackageName() {
|
public static String getWebViewPackageName() {
|
||||||
String[] webViewPackageNames = getWebViewPackageNames();
|
return AppGlobals.getInitialApplication().getString(
|
||||||
return webViewPackageNames[webViewPackageNames.length-1];
|
com.android.internal.R.string.config_webViewPackageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private static PackageInfo fetchPackageInfo() {
|
||||||
* Return the package info of the first package in the webview priority list that contains
|
|
||||||
* webview.
|
|
||||||
*
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
public static PackageInfo findPreferredWebViewPackage() {
|
|
||||||
PackageManager pm = AppGlobals.getInitialApplication().getPackageManager();
|
PackageManager pm = AppGlobals.getInitialApplication().getPackageManager();
|
||||||
|
try {
|
||||||
for (String packageName : getWebViewPackageNames()) {
|
return pm.getPackageInfo(getWebViewPackageName(), PackageManager.GET_META_DATA);
|
||||||
try {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
PackageInfo packageInfo = pm.getPackageInfo(packageName,
|
throw new MissingWebViewPackageException(e);
|
||||||
PackageManager.GET_META_DATA);
|
|
||||||
ApplicationInfo applicationInfo = packageInfo.applicationInfo;
|
|
||||||
|
|
||||||
// If the correct flag is set the package contains webview.
|
|
||||||
if (getWebViewLibrary(applicationInfo) != null) {
|
|
||||||
return packageInfo;
|
|
||||||
}
|
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
throw new MissingWebViewPackageException("Could not find a loadable WebView package");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// throws MissingWebViewPackageException
|
// throws MissingWebViewPackageException
|
||||||
private static ApplicationInfo getWebViewApplicationInfo() {
|
private static ApplicationInfo getWebViewApplicationInfo() {
|
||||||
if (sPackageInfo == null)
|
if (sPackageInfo == null) {
|
||||||
return findPreferredWebViewPackage().applicationInfo;
|
return fetchPackageInfo().applicationInfo;
|
||||||
else
|
} else {
|
||||||
return sPackageInfo.applicationInfo;
|
return sPackageInfo.applicationInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getWebViewLibrary(ApplicationInfo ai) {
|
private static String getWebViewLibrary(ApplicationInfo ai) {
|
||||||
@@ -153,10 +131,10 @@ public final class WebViewFactory {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the native library for the given package name iff that package
|
* Load the native library for the given package name iff that package
|
||||||
* name is the same as the one providing the current webview.
|
* name is the same as the one providing the webview.
|
||||||
*/
|
*/
|
||||||
public static int loadWebViewNativeLibraryFromPackage(String packageName) {
|
public static int loadWebViewNativeLibraryFromPackage(String packageName) {
|
||||||
sPackageInfo = findPreferredWebViewPackage();
|
sPackageInfo = fetchPackageInfo();
|
||||||
if (packageName != null && packageName.equals(sPackageInfo.packageName)) {
|
if (packageName != null && packageName.equals(sPackageInfo.packageName)) {
|
||||||
return loadNativeLibrary();
|
return loadNativeLibrary();
|
||||||
}
|
}
|
||||||
@@ -202,7 +180,7 @@ public final class WebViewFactory {
|
|||||||
private static Class<WebViewFactoryProvider> getProviderClass() {
|
private static Class<WebViewFactoryProvider> getProviderClass() {
|
||||||
try {
|
try {
|
||||||
// First fetch the package info so we can log the webview package version.
|
// First fetch the package info so we can log the webview package version.
|
||||||
sPackageInfo = findPreferredWebViewPackage();
|
sPackageInfo = fetchPackageInfo();
|
||||||
Log.i(LOGTAG, "Loading " + sPackageInfo.packageName + " version " +
|
Log.i(LOGTAG, "Loading " + sPackageInfo.packageName + " version " +
|
||||||
sPackageInfo.versionName + " (code " + sPackageInfo.versionCode + ")");
|
sPackageInfo.versionName + " (code " + sPackageInfo.versionCode + ")");
|
||||||
|
|
||||||
@@ -241,8 +219,8 @@ public final class WebViewFactory {
|
|||||||
try {
|
try {
|
||||||
// Construct a package context to load the Java code into the current app.
|
// Construct a package context to load the Java code into the current app.
|
||||||
Context webViewContext = initialApplication.createPackageContext(
|
Context webViewContext = initialApplication.createPackageContext(
|
||||||
sPackageInfo.packageName,
|
sPackageInfo.packageName,
|
||||||
Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
|
Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
|
||||||
initialApplication.getAssets().addAssetPath(
|
initialApplication.getAssets().addAssetPath(
|
||||||
webViewContext.getApplicationInfo().sourceDir);
|
webViewContext.getApplicationInfo().sourceDir);
|
||||||
ClassLoader clazzLoader = webViewContext.getClassLoader();
|
ClassLoader clazzLoader = webViewContext.getClassLoader();
|
||||||
|
|||||||
@@ -2031,10 +2031,8 @@
|
|||||||
string that's stored in 8-bit unpacked format) characters.-->
|
string that's stored in 8-bit unpacked format) characters.-->
|
||||||
<bool translatable="false" name="config_sms_decode_gsm_8bit_data">false</bool>
|
<bool translatable="false" name="config_sms_decode_gsm_8bit_data">false</bool>
|
||||||
|
|
||||||
<!-- List of package names (ordered by preference) providing WebView implementations. -->
|
<!-- Package name providing WebView implementation. -->
|
||||||
<string-array name="config_webViewPackageNames" translatable="false">
|
<string name="config_webViewPackageName" translatable="false">com.android.webview</string>
|
||||||
<item>com.android.webview</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<!-- If EMS is not supported, framework breaks down EMS into single segment SMS
|
<!-- If EMS is not supported, framework breaks down EMS into single segment SMS
|
||||||
and adds page info " x/y". This config is used to set which carrier doesn't
|
and adds page info " x/y". This config is used to set which carrier doesn't
|
||||||
|
|||||||
@@ -2018,7 +2018,7 @@
|
|||||||
<java-symbol type="attr" name="actionModeWebSearchDrawable" />
|
<java-symbol type="attr" name="actionModeWebSearchDrawable" />
|
||||||
<java-symbol type="string" name="websearch" />
|
<java-symbol type="string" name="websearch" />
|
||||||
<java-symbol type="drawable" name="ic_media_video_poster" />
|
<java-symbol type="drawable" name="ic_media_video_poster" />
|
||||||
<java-symbol type="array" name="config_webViewPackageNames" />
|
<java-symbol type="string" name="config_webViewPackageName" />
|
||||||
|
|
||||||
<!-- From SubtitleView -->
|
<!-- From SubtitleView -->
|
||||||
<java-symbol type="dimen" name="subtitle_corner_radius" />
|
<java-symbol type="dimen" name="subtitle_corner_radius" />
|
||||||
|
|||||||
@@ -40,8 +40,6 @@ public class WebViewUpdateService extends SystemService {
|
|||||||
private boolean mRelroReady32Bit = false;
|
private boolean mRelroReady32Bit = false;
|
||||||
private boolean mRelroReady64Bit = false;
|
private boolean mRelroReady64Bit = false;
|
||||||
|
|
||||||
private String oldWebViewPackageName = null;
|
|
||||||
|
|
||||||
private BroadcastReceiver mWebViewUpdatedReceiver;
|
private BroadcastReceiver mWebViewUpdatedReceiver;
|
||||||
|
|
||||||
public WebViewUpdateService(Context context) {
|
public WebViewUpdateService(Context context) {
|
||||||
@@ -53,22 +51,9 @@ public class WebViewUpdateService extends SystemService {
|
|||||||
mWebViewUpdatedReceiver = new BroadcastReceiver() {
|
mWebViewUpdatedReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
String webviewPackage = "package:" + WebViewFactory.getWebViewPackageName();
|
||||||
for (String packageName : WebViewFactory.getWebViewPackageNames()) {
|
if (webviewPackage.equals(intent.getDataString())) {
|
||||||
String webviewPackage = "package:" + packageName;
|
onWebViewUpdateInstalled();
|
||||||
|
|
||||||
if (webviewPackage.equals(intent.getDataString())) {
|
|
||||||
String usedPackageName =
|
|
||||||
WebViewFactory.findPreferredWebViewPackage().packageName;
|
|
||||||
// Only trigger update actions if the updated package is the one that
|
|
||||||
// will be used, or the one that was in use before the update.
|
|
||||||
if (packageName.equals(usedPackageName) ||
|
|
||||||
packageName.equals(oldWebViewPackageName)) {
|
|
||||||
onWebViewUpdateInstalled();
|
|
||||||
oldWebViewPackageName = usedPackageName;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user