WebViewFactory.java revision 8b17926a78cc686504739730516c9b057d0672da
1/* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.webkit; 18 19import android.annotation.SystemApi; 20import android.app.ActivityManagerInternal; 21import android.app.AppGlobals; 22import android.app.Application; 23import android.content.Context; 24import android.content.Intent; 25import android.content.pm.ApplicationInfo; 26import android.content.pm.PackageInfo; 27import android.content.pm.PackageManager; 28import android.content.res.XmlResourceParser; 29import android.os.Build; 30import android.os.Process; 31import android.os.RemoteException; 32import android.os.ServiceManager; 33import android.os.StrictMode; 34import android.os.SystemProperties; 35import android.os.Trace; 36import android.provider.Settings; 37import android.provider.Settings.Secure; 38import android.text.TextUtils; 39import android.util.AndroidRuntimeException; 40import android.util.Log; 41 42import com.android.internal.util.XmlUtils; 43import com.android.server.LocalServices; 44 45import dalvik.system.VMRuntime; 46 47import java.io.File; 48import java.io.IOException; 49import java.util.ArrayList; 50import java.util.Arrays; 51import java.util.List; 52import java.util.zip.ZipEntry; 53import java.util.zip.ZipFile; 54 55import org.xmlpull.v1.XmlPullParserException; 56 57/** 58 * Top level factory, used creating all the main WebView implementation classes. 59 * 60 * @hide 61 */ 62@SystemApi 63public final class WebViewFactory { 64 65 private static final String CHROMIUM_WEBVIEW_FACTORY = 66 "com.android.webview.chromium.WebViewChromiumFactoryProvider"; 67 68 private static final String NULL_WEBVIEW_FACTORY = 69 "com.android.webview.nullwebview.NullWebViewFactoryProvider"; 70 71 private static final String CHROMIUM_WEBVIEW_NATIVE_RELRO_32 = 72 "/data/misc/shared_relro/libwebviewchromium32.relro"; 73 private static final String CHROMIUM_WEBVIEW_NATIVE_RELRO_64 = 74 "/data/misc/shared_relro/libwebviewchromium64.relro"; 75 76 public static final String CHROMIUM_WEBVIEW_VMSIZE_SIZE_PROPERTY = 77 "persist.sys.webview.vmsize"; 78 private static final long CHROMIUM_WEBVIEW_DEFAULT_VMSIZE_BYTES = 100 * 1024 * 1024; 79 80 private static final String LOGTAG = "WebViewFactory"; 81 82 private static final boolean DEBUG = false; 83 84 // Cache the factory both for efficiency, and ensure any one process gets all webviews from the 85 // same provider. 86 private static WebViewFactoryProvider sProviderInstance; 87 private static final Object sProviderLock = new Object(); 88 private static boolean sAddressSpaceReserved = false; 89 private static PackageInfo sPackageInfo; 90 91 // Error codes for loadWebViewNativeLibraryFromPackage 92 public static final int LIBLOAD_SUCCESS = 0; 93 public static final int LIBLOAD_WRONG_PACKAGE_NAME = 1; 94 public static final int LIBLOAD_ADDRESS_SPACE_NOT_RESERVED = 2; 95 96 // error codes for waiting for WebView preparation 97 public static final int LIBLOAD_FAILED_WAITING_FOR_RELRO = 3; 98 public static final int LIBLOAD_FAILED_LISTING_WEBVIEW_PACKAGES = 4; 99 100 // native relro loading error codes 101 public static final int LIBLOAD_FAILED_TO_OPEN_RELRO_FILE = 5; 102 public static final int LIBLOAD_FAILED_TO_LOAD_LIBRARY = 6; 103 public static final int LIBLOAD_FAILED_JNI_CALL = 7; 104 105 // more error codes for waiting for WebView preparation 106 public static final int LIBLOAD_WEBVIEW_BEING_REPLACED = 8; 107 public static final int LIBLOAD_FAILED_WAITING_FOR_WEBVIEW_REASON_UNKNOWN = 9; 108 109 // error for namespace lookup 110 public static final int LIBLOAD_FAILED_TO_FIND_NAMESPACE = 10; 111 112 private static String getWebViewPreparationErrorReason(int error) { 113 switch (error) { 114 case LIBLOAD_FAILED_WAITING_FOR_RELRO: 115 return "Time out waiting for Relro files being created"; 116 case LIBLOAD_FAILED_LISTING_WEBVIEW_PACKAGES: 117 return "No WebView installed"; 118 case LIBLOAD_WEBVIEW_BEING_REPLACED: 119 return "Time out waiting for WebView to be replaced"; 120 case LIBLOAD_FAILED_WAITING_FOR_WEBVIEW_REASON_UNKNOWN: 121 return "Crashed for unknown reason"; 122 } 123 return "Unknown"; 124 } 125 126 /** 127 * @hide 128 */ 129 public static class MissingWebViewPackageException extends AndroidRuntimeException { 130 public MissingWebViewPackageException(String message) { super(message); } 131 public MissingWebViewPackageException(Exception e) { super(e); } 132 } 133 134 // TODO (gsennton) remove when committing webview xts test change 135 public static String getWebViewPackageName() { 136 return null; 137 } 138 139 /** 140 * @hide 141 */ 142 public static String getWebViewLibrary(ApplicationInfo ai) { 143 if (ai.metaData != null) 144 return ai.metaData.getString("com.android.webview.WebViewLibrary"); 145 return null; 146 } 147 148 public static PackageInfo getLoadedPackageInfo() { 149 return sPackageInfo; 150 } 151 152 /** 153 * Load the native library for the given package name iff that package 154 * name is the same as the one providing the webview. 155 */ 156 public static int loadWebViewNativeLibraryFromPackage(String packageName, 157 ClassLoader clazzLoader) { 158 int ret = waitForProviderAndSetPackageInfo(); 159 if (ret != LIBLOAD_SUCCESS) { 160 return ret; 161 } 162 if (!sPackageInfo.packageName.equals(packageName)) 163 return LIBLOAD_WRONG_PACKAGE_NAME; 164 165 return loadNativeLibrary(clazzLoader); 166 } 167 168 static WebViewFactoryProvider getProvider() { 169 synchronized (sProviderLock) { 170 // For now the main purpose of this function (and the factory abstraction) is to keep 171 // us honest and minimize usage of WebView internals when binding the proxy. 172 if (sProviderInstance != null) return sProviderInstance; 173 174 final int uid = android.os.Process.myUid(); 175 if (uid == android.os.Process.ROOT_UID || uid == android.os.Process.SYSTEM_UID) { 176 throw new UnsupportedOperationException( 177 "For security reasons, WebView is not allowed in privileged processes"); 178 } 179 180 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); 181 Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.getProvider()"); 182 try { 183 Class<WebViewFactoryProvider> providerClass = getProviderClass(); 184 185 Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "providerClass.newInstance()"); 186 try { 187 sProviderInstance = providerClass.getConstructor(WebViewDelegate.class) 188 .newInstance(new WebViewDelegate()); 189 if (DEBUG) Log.v(LOGTAG, "Loaded provider: " + sProviderInstance); 190 return sProviderInstance; 191 } catch (Exception e) { 192 Log.e(LOGTAG, "error instantiating provider", e); 193 throw new AndroidRuntimeException(e); 194 } finally { 195 Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW); 196 } 197 } finally { 198 Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW); 199 StrictMode.setThreadPolicy(oldPolicy); 200 } 201 } 202 } 203 204 private static Class<WebViewFactoryProvider> getProviderClass() { 205 try { 206 Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, 207 "WebViewFactory.waitForProviderAndSetPackageInfo()"); 208 try { 209 // First fetch the package info so we can log the webview package version. 210 int res = waitForProviderAndSetPackageInfo(); 211 if (res != LIBLOAD_SUCCESS) { 212 throw new MissingWebViewPackageException( 213 "Failed to load WebView provider, error: " 214 + getWebViewPreparationErrorReason(res)); 215 } 216 } finally { 217 Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW); 218 } 219 Log.i(LOGTAG, "Loading " + sPackageInfo.packageName + " version " + 220 sPackageInfo.versionName + " (code " + sPackageInfo.versionCode + ")"); 221 222 Application initialApplication = AppGlobals.getInitialApplication(); 223 Context webViewContext = null; 224 Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "PackageManager.getApplicationInfo()"); 225 try { 226 // Construct a package context to load the Java code into the current app. 227 // This is done as early as possible since by constructing a package context we 228 // register the WebView package as a dependency for the current application so that 229 // when the WebView package is updated this application will be killed. 230 ApplicationInfo applicationInfo = 231 initialApplication.getPackageManager().getApplicationInfo( 232 sPackageInfo.packageName, PackageManager.GET_SHARED_LIBRARY_FILES 233 | PackageManager.MATCH_DEBUG_TRIAGED_MISSING 234 // make sure that we fetch the current provider even if its not installed 235 // for the current user 236 | PackageManager.MATCH_UNINSTALLED_PACKAGES); 237 Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, 238 "initialApplication.createApplicationContext"); 239 try { 240 webViewContext = initialApplication.createApplicationContext(applicationInfo, 241 Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY); 242 } finally { 243 Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW); 244 } 245 } catch (PackageManager.NameNotFoundException e) { 246 throw new MissingWebViewPackageException(e); 247 } finally { 248 Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW); 249 } 250 251 Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.getChromiumProviderClass()"); 252 try { 253 initialApplication.getAssets().addAssetPathAsSharedLibrary( 254 webViewContext.getApplicationInfo().sourceDir); 255 ClassLoader clazzLoader = webViewContext.getClassLoader(); 256 257 Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.loadNativeLibrary()"); 258 loadNativeLibrary(clazzLoader); 259 Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW); 260 261 Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "Class.forName()"); 262 try { 263 return (Class<WebViewFactoryProvider>) Class.forName(CHROMIUM_WEBVIEW_FACTORY, 264 true, clazzLoader); 265 } finally { 266 Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW); 267 } 268 } catch (ClassNotFoundException e) { 269 Log.e(LOGTAG, "error loading provider", e); 270 throw new AndroidRuntimeException(e); 271 } finally { 272 Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW); 273 } 274 } catch (MissingWebViewPackageException e) { 275 // If the package doesn't exist, then try loading the null WebView instead. 276 // If that succeeds, then this is a device without WebView support; if it fails then 277 // swallow the failure, complain that the real WebView is missing and rethrow the 278 // original exception. 279 try { 280 return (Class<WebViewFactoryProvider>) Class.forName(NULL_WEBVIEW_FACTORY); 281 } catch (ClassNotFoundException e2) { 282 // Ignore. 283 } 284 Log.e(LOGTAG, "Chromium WebView package does not exist", e); 285 throw new AndroidRuntimeException(e); 286 } 287 } 288 289 /** 290 * Perform any WebView loading preparations that must happen in the zygote. 291 * Currently, this means allocating address space to load the real JNI library later. 292 */ 293 public static void prepareWebViewInZygote() { 294 try { 295 System.loadLibrary("webviewchromium_loader"); 296 long addressSpaceToReserve = 297 SystemProperties.getLong(CHROMIUM_WEBVIEW_VMSIZE_SIZE_PROPERTY, 298 CHROMIUM_WEBVIEW_DEFAULT_VMSIZE_BYTES); 299 sAddressSpaceReserved = nativeReserveAddressSpace(addressSpaceToReserve); 300 301 if (sAddressSpaceReserved) { 302 if (DEBUG) { 303 Log.v(LOGTAG, "address space reserved: " + addressSpaceToReserve + " bytes"); 304 } 305 } else { 306 Log.e(LOGTAG, "reserving " + addressSpaceToReserve + 307 " bytes of address space failed"); 308 } 309 } catch (Throwable t) { 310 // Log and discard errors at this stage as we must not crash the zygote. 311 Log.e(LOGTAG, "error preparing native loader", t); 312 } 313 } 314 315 private static int prepareWebViewInSystemServer(String[] nativeLibraryPaths) { 316 if (DEBUG) Log.v(LOGTAG, "creating relro files"); 317 int numRelros = 0; 318 319 // We must always trigger createRelRo regardless of the value of nativeLibraryPaths. Any 320 // unexpected values will be handled there to ensure that we trigger notifying any process 321 // waiting on relro creation. 322 if (Build.SUPPORTED_32_BIT_ABIS.length > 0) { 323 if (DEBUG) Log.v(LOGTAG, "Create 32 bit relro"); 324 createRelroFile(false /* is64Bit */, nativeLibraryPaths); 325 numRelros++; 326 } 327 328 if (Build.SUPPORTED_64_BIT_ABIS.length > 0) { 329 if (DEBUG) Log.v(LOGTAG, "Create 64 bit relro"); 330 createRelroFile(true /* is64Bit */, nativeLibraryPaths); 331 numRelros++; 332 } 333 return numRelros; 334 } 335 336 /** 337 * @hide 338 */ 339 public static int onWebViewProviderChanged(PackageInfo packageInfo) { 340 String[] nativeLibs = null; 341 try { 342 nativeLibs = WebViewFactory.getWebViewNativeLibraryPaths(packageInfo); 343 if (nativeLibs != null) { 344 long newVmSize = 0L; 345 346 for (String path : nativeLibs) { 347 if (path == null || TextUtils.isEmpty(path)) continue; 348 if (DEBUG) Log.d(LOGTAG, "Checking file size of " + path); 349 File f = new File(path); 350 if (f.exists()) { 351 newVmSize = Math.max(newVmSize, f.length()); 352 continue; 353 } 354 if (path.contains("!/")) { 355 String[] split = TextUtils.split(path, "!/"); 356 if (split.length == 2) { 357 try (ZipFile z = new ZipFile(split[0])) { 358 ZipEntry e = z.getEntry(split[1]); 359 if (e != null && e.getMethod() == ZipEntry.STORED) { 360 newVmSize = Math.max(newVmSize, e.getSize()); 361 continue; 362 } 363 } 364 catch (IOException e) { 365 Log.e(LOGTAG, "error reading APK file " + split[0] + ", ", e); 366 } 367 } 368 } 369 Log.e(LOGTAG, "error sizing load for " + path); 370 } 371 372 if (DEBUG) { 373 Log.v(LOGTAG, "Based on library size, need " + newVmSize + 374 " bytes of address space."); 375 } 376 // The required memory can be larger than the file on disk (due to .bss), and an 377 // upgraded version of the library will likely be larger, so always attempt to 378 // reserve twice as much as we think to allow for the library to grow during this 379 // boot cycle. 380 newVmSize = Math.max(2 * newVmSize, CHROMIUM_WEBVIEW_DEFAULT_VMSIZE_BYTES); 381 Log.d(LOGTAG, "Setting new address space to " + newVmSize); 382 SystemProperties.set(CHROMIUM_WEBVIEW_VMSIZE_SIZE_PROPERTY, 383 Long.toString(newVmSize)); 384 } 385 } catch (Throwable t) { 386 // Log and discard errors at this stage as we must not crash the system server. 387 Log.e(LOGTAG, "error preparing webview native library", t); 388 } 389 return prepareWebViewInSystemServer(nativeLibs); 390 } 391 392 // throws MissingWebViewPackageException 393 private static String getLoadFromApkPath(String apkPath, 394 String[] abiList, 395 String nativeLibFileName) { 396 // Search the APK for a native library conforming to a listed ABI. 397 try (ZipFile z = new ZipFile(apkPath)) { 398 for (String abi : abiList) { 399 final String entry = "lib/" + abi + "/" + nativeLibFileName; 400 ZipEntry e = z.getEntry(entry); 401 if (e != null && e.getMethod() == ZipEntry.STORED) { 402 // Return a path formatted for dlopen() load from APK. 403 return apkPath + "!/" + entry; 404 } 405 } 406 } catch (IOException e) { 407 throw new MissingWebViewPackageException(e); 408 } 409 return ""; 410 } 411 412 // throws MissingWebViewPackageException 413 private static String[] getWebViewNativeLibraryPaths(PackageInfo packageInfo) { 414 ApplicationInfo ai = packageInfo.applicationInfo; 415 final String NATIVE_LIB_FILE_NAME = getWebViewLibrary(ai); 416 417 String path32; 418 String path64; 419 boolean primaryArchIs64bit = VMRuntime.is64BitAbi(ai.primaryCpuAbi); 420 if (!TextUtils.isEmpty(ai.secondaryCpuAbi)) { 421 // Multi-arch case. 422 if (primaryArchIs64bit) { 423 // Primary arch: 64-bit, secondary: 32-bit. 424 path64 = ai.nativeLibraryDir; 425 path32 = ai.secondaryNativeLibraryDir; 426 } else { 427 // Primary arch: 32-bit, secondary: 64-bit. 428 path64 = ai.secondaryNativeLibraryDir; 429 path32 = ai.nativeLibraryDir; 430 } 431 } else if (primaryArchIs64bit) { 432 // Single-arch 64-bit. 433 path64 = ai.nativeLibraryDir; 434 path32 = ""; 435 } else { 436 // Single-arch 32-bit. 437 path32 = ai.nativeLibraryDir; 438 path64 = ""; 439 } 440 441 // Form the full paths to the extracted native libraries. 442 // If libraries were not extracted, try load from APK paths instead. 443 if (!TextUtils.isEmpty(path32)) { 444 path32 += "/" + NATIVE_LIB_FILE_NAME; 445 File f = new File(path32); 446 if (!f.exists()) { 447 path32 = getLoadFromApkPath(ai.sourceDir, 448 Build.SUPPORTED_32_BIT_ABIS, 449 NATIVE_LIB_FILE_NAME); 450 } 451 } 452 if (!TextUtils.isEmpty(path64)) { 453 path64 += "/" + NATIVE_LIB_FILE_NAME; 454 File f = new File(path64); 455 if (!f.exists()) { 456 path64 = getLoadFromApkPath(ai.sourceDir, 457 Build.SUPPORTED_64_BIT_ABIS, 458 NATIVE_LIB_FILE_NAME); 459 } 460 } 461 462 if (DEBUG) Log.v(LOGTAG, "Native 32-bit lib: " + path32 + ", 64-bit lib: " + path64); 463 return new String[] { path32, path64 }; 464 } 465 466 private static void createRelroFile(final boolean is64Bit, String[] nativeLibraryPaths) { 467 final String abi = 468 is64Bit ? Build.SUPPORTED_64_BIT_ABIS[0] : Build.SUPPORTED_32_BIT_ABIS[0]; 469 470 // crashHandler is invoked by the ActivityManagerService when the isolated process crashes. 471 Runnable crashHandler = new Runnable() { 472 @Override 473 public void run() { 474 try { 475 Log.e(LOGTAG, "relro file creator for " + abi + " crashed. Proceeding without"); 476 getUpdateService().notifyRelroCreationCompleted(); 477 } catch (RemoteException e) { 478 Log.e(LOGTAG, "Cannot reach WebViewUpdateService. " + e.getMessage()); 479 } 480 } 481 }; 482 483 try { 484 if (nativeLibraryPaths == null 485 || nativeLibraryPaths[0] == null || nativeLibraryPaths[1] == null) { 486 throw new IllegalArgumentException( 487 "Native library paths to the WebView RelRo process must not be null!"); 488 } 489 int pid = LocalServices.getService(ActivityManagerInternal.class).startIsolatedProcess( 490 RelroFileCreator.class.getName(), nativeLibraryPaths, "WebViewLoader-" + abi, abi, 491 Process.SHARED_RELRO_UID, crashHandler); 492 if (pid <= 0) throw new Exception("Failed to start the relro file creator process"); 493 } catch (Throwable t) { 494 // Log and discard errors as we must not crash the system server. 495 Log.e(LOGTAG, "error starting relro file creator for abi " + abi, t); 496 crashHandler.run(); 497 } 498 } 499 500 private static class RelroFileCreator { 501 // Called in an unprivileged child process to create the relro file. 502 public static void main(String[] args) { 503 boolean result = false; 504 boolean is64Bit = VMRuntime.getRuntime().is64Bit(); 505 try{ 506 if (args.length != 2 || args[0] == null || args[1] == null) { 507 Log.e(LOGTAG, "Invalid RelroFileCreator args: " + Arrays.toString(args)); 508 return; 509 } 510 Log.v(LOGTAG, "RelroFileCreator (64bit = " + is64Bit + "), " + 511 " 32-bit lib: " + args[0] + ", 64-bit lib: " + args[1]); 512 if (!sAddressSpaceReserved) { 513 Log.e(LOGTAG, "can't create relro file; address space not reserved"); 514 return; 515 } 516 result = nativeCreateRelroFile(args[0] /* path32 */, 517 args[1] /* path64 */, 518 CHROMIUM_WEBVIEW_NATIVE_RELRO_32, 519 CHROMIUM_WEBVIEW_NATIVE_RELRO_64); 520 if (result && DEBUG) Log.v(LOGTAG, "created relro file"); 521 } finally { 522 // We must do our best to always notify the update service, even if something fails. 523 try { 524 getUpdateService().notifyRelroCreationCompleted(); 525 } catch (RemoteException e) { 526 Log.e(LOGTAG, "error notifying update service", e); 527 } 528 529 if (!result) Log.e(LOGTAG, "failed to create relro file"); 530 531 // Must explicitly exit or else this process will just sit around after we return. 532 System.exit(0); 533 } 534 } 535 } 536 537 private static int waitForProviderAndSetPackageInfo() { 538 WebViewProviderResponse response = null; 539 try { 540 response = 541 getUpdateService().waitForAndGetProvider(); 542 if (response.status == WebViewFactory.LIBLOAD_SUCCESS) 543 sPackageInfo = response.packageInfo; 544 } catch (RemoteException e) { 545 Log.e(LOGTAG, "error waiting for relro creation", e); 546 return LIBLOAD_FAILED_WAITING_FOR_WEBVIEW_REASON_UNKNOWN; 547 } 548 return response.status; 549 } 550 551 // Assumes that we have waited for relro creation and set sPackageInfo 552 private static int loadNativeLibrary(ClassLoader clazzLoader) { 553 if (!sAddressSpaceReserved) { 554 Log.e(LOGTAG, "can't load with relro file; address space not reserved"); 555 return LIBLOAD_ADDRESS_SPACE_NOT_RESERVED; 556 } 557 558 String[] args = getWebViewNativeLibraryPaths(sPackageInfo); 559 int result = nativeLoadWithRelroFile(args[0] /* path32 */, 560 args[1] /* path64 */, 561 CHROMIUM_WEBVIEW_NATIVE_RELRO_32, 562 CHROMIUM_WEBVIEW_NATIVE_RELRO_64, 563 clazzLoader); 564 if (result != LIBLOAD_SUCCESS) { 565 Log.w(LOGTAG, "failed to load with relro file, proceeding without"); 566 } else if (DEBUG) { 567 Log.v(LOGTAG, "loaded with relro file"); 568 } 569 return result; 570 } 571 572 /** 573 * Returns whether the entire package from an ACTION_PACKAGE_CHANGED intent was changed (rather 574 * than just one of its components). 575 * @hide 576 */ 577 public static boolean entirePackageChanged(Intent intent) { 578 String[] componentList = 579 intent.getStringArrayExtra(Intent.EXTRA_CHANGED_COMPONENT_NAME_LIST); 580 return Arrays.asList(componentList).contains( 581 intent.getDataString().substring("package:".length())); 582 } 583 584 private static IWebViewUpdateService getUpdateService() { 585 return IWebViewUpdateService.Stub.asInterface(ServiceManager.getService("webviewupdate")); 586 } 587 588 private static native boolean nativeReserveAddressSpace(long addressSpaceToReserve); 589 private static native boolean nativeCreateRelroFile(String lib32, String lib64, 590 String relro32, String relro64); 591 private static native int nativeLoadWithRelroFile(String lib32, String lib64, 592 String relro32, String relro64, 593 ClassLoader clazzLoader); 594} 595