Merge "Use newly fetched PackageInfo for loading WebView code." into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
cdbf412f8e
@@ -141,17 +141,38 @@ public final class WebViewFactory {
|
|||||||
*/
|
*/
|
||||||
public static int loadWebViewNativeLibraryFromPackage(String packageName,
|
public static int loadWebViewNativeLibraryFromPackage(String packageName,
|
||||||
ClassLoader clazzLoader) {
|
ClassLoader clazzLoader) {
|
||||||
int ret = waitForProviderAndSetPackageInfo();
|
WebViewProviderResponse response = null;
|
||||||
if (ret != LIBLOAD_SUCCESS && ret != LIBLOAD_FAILED_WAITING_FOR_RELRO) {
|
try {
|
||||||
return ret;
|
response = getUpdateService().waitForAndGetProvider();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.e(LOGTAG, "error waiting for relro creation", e);
|
||||||
|
return LIBLOAD_FAILED_WAITING_FOR_WEBVIEW_REASON_UNKNOWN;
|
||||||
}
|
}
|
||||||
if (!sPackageInfo.packageName.equals(packageName))
|
|
||||||
|
|
||||||
|
if (response.status != LIBLOAD_SUCCESS
|
||||||
|
&& response.status != LIBLOAD_FAILED_WAITING_FOR_RELRO) {
|
||||||
|
return response.status;
|
||||||
|
}
|
||||||
|
if (!response.packageInfo.packageName.equals(packageName)) {
|
||||||
return LIBLOAD_WRONG_PACKAGE_NAME;
|
return LIBLOAD_WRONG_PACKAGE_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
PackageManager packageManager = AppGlobals.getInitialApplication().getPackageManager();
|
||||||
|
PackageInfo packageInfo;
|
||||||
|
try {
|
||||||
|
packageInfo = packageManager.getPackageInfo(packageName,
|
||||||
|
PackageManager.GET_META_DATA | PackageManager.MATCH_DEBUG_TRIAGED_MISSING);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
Log.e(LOGTAG, "Couldn't find package " + packageName);
|
||||||
|
return LIBLOAD_WRONG_PACKAGE_NAME;
|
||||||
|
}
|
||||||
|
sPackageInfo = packageInfo;
|
||||||
|
|
||||||
int loadNativeRet = loadNativeLibrary(clazzLoader);
|
int loadNativeRet = loadNativeLibrary(clazzLoader);
|
||||||
// If we failed waiting for relro we want to return that fact even if we successfully load
|
// If we failed waiting for relro we want to return that fact even if we successfully load
|
||||||
// the relro file.
|
// the relro file.
|
||||||
if (loadNativeRet == LIBLOAD_SUCCESS) return ret;
|
if (loadNativeRet == LIBLOAD_SUCCESS) return response.status;
|
||||||
return loadNativeRet;
|
return loadNativeRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,7 +309,7 @@ public final class WebViewFactory {
|
|||||||
Context webViewContext = initialApplication.createApplicationContext(
|
Context webViewContext = initialApplication.createApplicationContext(
|
||||||
newPackageInfo.applicationInfo,
|
newPackageInfo.applicationInfo,
|
||||||
Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
|
Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
|
||||||
sPackageInfo = response.packageInfo;
|
sPackageInfo = newPackageInfo;
|
||||||
return webViewContext;
|
return webViewContext;
|
||||||
} finally {
|
} finally {
|
||||||
Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
|
Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
|
||||||
@@ -599,22 +620,6 @@ public final class WebViewFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int waitForProviderAndSetPackageInfo() {
|
|
||||||
WebViewProviderResponse response = null;
|
|
||||||
try {
|
|
||||||
response =
|
|
||||||
getUpdateService().waitForAndGetProvider();
|
|
||||||
if (response.status == LIBLOAD_SUCCESS
|
|
||||||
|| response.status == LIBLOAD_FAILED_WAITING_FOR_RELRO) {
|
|
||||||
sPackageInfo = response.packageInfo;
|
|
||||||
}
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
Log.e(LOGTAG, "error waiting for relro creation", e);
|
|
||||||
return LIBLOAD_FAILED_WAITING_FOR_WEBVIEW_REASON_UNKNOWN;
|
|
||||||
}
|
|
||||||
return response.status;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assumes that we have waited for relro creation and set sPackageInfo
|
// Assumes that we have waited for relro creation and set sPackageInfo
|
||||||
private static int loadNativeLibrary(ClassLoader clazzLoader) {
|
private static int loadNativeLibrary(ClassLoader clazzLoader) {
|
||||||
if (!sAddressSpaceReserved) {
|
if (!sAddressSpaceReserved) {
|
||||||
|
|||||||
Reference in New Issue
Block a user