Commit Graph

3423 Commits

Author SHA1 Message Date
Dimitry Ivanov
029170ee2b Merge "Add isBundled argument to LoadedApk.makePaths call"
am: 0743d56e2b

Change-Id: I74deae8126109555bbbe57983ffd6a22ab50e303
2017-02-23 23:30:16 +00:00
Dimitry Ivanov
484fbe9273 Add isBundled argument to LoadedApk.makePaths call
There is a disconnect between the way webview created
classloader and the way makePaths decides if paths are
intended for bundled app.

This change moves decision making out of makePaths method
which allows WebViewZygote to pass correct argument and
have makePath omit java.library.path for libPaths

Bug: http://b/35426785
Test: manual
Change-Id: Iab5a18c0091d0193dafa750498eb00f378411ba0
(cherry picked from commit 638d810099)
2017-02-23 14:16:45 -08:00
Robert Sesek
8be4cfc638 Merge "Synchronize access to WebViewZygote." am: fd6f631de5 am: c8111e07d0
am: 2c3818158a

Change-Id: Ib6afc79a3905a68fa92d5ff9389752724a77d305
2017-01-05 09:43:53 +00:00
Robert Sesek
89cc5205b3 Synchronize access to WebViewZygote.
The onWebViewProviderChanged callback can be entered from a binder thread,
rather than the system_server main thread. This could lead to races when
managing the webview_zygote.

Test: m
Test: Turn on Multiprocess WebView, install a new WebView provider, then
      instantiate a new WebView. The new WebView should load (note that
      this is racy so may require multiple attempts to test).

Bug: 21643067
Change-Id: I28512906c38e073d4e3d39a2f2b30dcbb50c85ff
2017-01-03 19:31:44 -05:00
Robert Sesek
5c44250176 Merge "Add new hostingType for startProcessLocked() that selects using the WebViewZygote." am: eda1af611f am: bbcd9d26b1
am: 5806963539

Change-Id: Ic0e53ed482fb27dfab2bb8de52bfe8947beae866
2016-12-02 17:36:21 +00:00
Robert Sesek
c5f86647b1 Add new hostingType for startProcessLocked() that selects using the WebViewZygote.
Test: m
Test: angler boots
Test: Turn on Multiprocess WebView in Developer Options and launch the WebView
      Shell. The sandboxed_service parent process is the webview_zygote.

Bug: 21643067
Change-Id: I9dab548853372fd91f6bbe204cc8686ef2e94448
2016-11-29 11:08:49 -05:00
Torne (Richard Coles)
7e17c6b0f1 Merge "Precreate the classloader for the WebView." am: 566b1c80e4 am: 1feb782f01
am: 9565860b08

Change-Id: I070288a127cbaa08f05b49f66e23ea0ec298040b
2016-11-21 17:13:45 +00:00
Torne (Richard Coles)
3b6ca99b10 Precreate the classloader for the WebView.
We want to create the classloader for the WebView in advance in the
zygote so that it can preload Java and native code for its children, but
the zygote can't talk to the package manager (so doesn't have a
PackageInfo for the APK) and also doesn't have an ActivityThread, so
constructing a LoadedApk is difficult.

Instead, we use the fact that ApplicationLoaders contains a
process-global cache of classloaders for APKs, and prepopulate a cache
entry without constructing a LoadedApk. This requires making
ApplicationLoaders public. To calculate the correct library paths from
the information the zygote has, we reuse the logic in LoadedApk (which
is already public, and just needs a small change to allow a null
ActivityThread when checking for instrumentation).

The other parameters for classloader creation (target SDK, bundled app,
etc) are hardcoded to usable values for the WebView's case. WebView
never needs to use any system libraries that aren't public so claiming
it's not bundled is fine even when that isn't actually true, and WebView
will always target the current platform API level.

Once the classloader is created, look up the factory class and call
preloadInZygote on it to give it a chance to preload the native library
and do other shared initialisation.

Bug: 21643067
Test: enable multiprocess WebView, examine librank output to see sharing
Change-Id: I696ead637e3f7382bcc58cfaf61eac5921862015
2016-11-21 15:04:13 +00:00
Hui Shu
1eb8a07e1b Fix WebViewDatabase javadoc.
am: 68d2cc180f

Change-Id: I811966bc364697f5c172cd9b4153d963962d8db2
2016-11-15 20:15:17 +00:00
Hui Shu
68d2cc180f Fix WebViewDatabase javadoc.
BUG=30481165
Change-Id: Ibd14880aa25907234dd93c38b5d0f2c9e808340e
(cherry picked from commit 433fb93515)
2016-10-28 21:24:56 +00:00
Robert Sesek
ded2098436 Create the WebViewZygote and implement WebViewZygoteInit.
This adds a new init-spawned daemon, webview_zygote, that starts a JVM and
acts as a zygote process for WebView isolated_app services.

Test: m
Test: angler boots
Test: Turn on Settings>Developer>Multiprocess Webview. webview_zygote32 or
      webview_zygote64 start (requires dependent CLs).

Bug: 21643067
Change-Id: Ida98bd04b4d77736b672b03af651c4eb97ce88c1
2016-10-07 12:38:04 -04:00
Gustav Sennton
b088cb36b8 Use newly fetched PackageInfo for loading WebView code.
During a time window between the point at which a webview package
becomes updated and the WebViewUpdateService receiving an intent
declaring this action the WebViewUpdateService APIs will return a
PackageInfo pointing to an old and possibly removed WebView package.
This means that any paths that PackageInfo is referring to could have
been removed.

Currently, we set WebViewFactory.sPackageInfo using one of these APIs
and we might thus try to use deleted paths to to load WebView. This can
cause crashes, so instead fetch a fresh PackageInfo and assign
WebViewFactory.sPackageInfo to that.

Also early-out in loadWebViewNativeLibraryFromPackage if the current
package version doesn't match that of the one fetched from the
WebViewUpdateService.

Bug: 29381682
Change-Id: I2713ce2338a4a96c5317dcdbb363b424513088d5
2016-06-20 14:30:27 +01:00
Adam Lesinski
25f48886b2 ResourcesManager: Allow managed addition of library asset paths
This allows WebView to add itself to the ResourcesManager and
remain their even after configuration changes and multi-window
changes.

Bug:29112218
Change-Id: I2cb131ae2c61fb58c48babafdd46c1882be96aa9
2016-06-15 12:00:18 -07:00
Gustav Sennton
fd07efa44e Load WebView even if WebView relro creation times out.
There are cases in which the WebView Update Service can stop switching
WebView providers (if the update service is notified about relro
creations an incorrect number of times) and in those cases apps will
fail to load WebView.

In this CL we mitigate this problem by allowing apps to load WebView
even if the time-out is reached and we also decrease the time-out so
apps are less likely to ANR when waiting for the time-out.

This CL does not prevent the update service from ending up in a bad
state - so we will still end up crashing apps if the current WebView
implementation is uninstalled after relro creation fails.

Bug: 28860862
Change-Id: Ib6af3722e17a13db77ef34c37581a6a0e1d045bb
2016-05-23 17:49:05 +01:00
TreeHugger Robot
a1e4cbe211 Merge "Remove onUhandledInputEvent API." into nyc-dev 2016-05-16 15:18:20 +00:00
TreeHugger Robot
42791eca7d Merge "[WebView] Update ServiceWorker related documentation." into nyc-dev 2016-05-04 12:37:21 +00:00
Tim Volodine
b90f5389dd [WebView] Update ServiceWorker related documentation.
Add some clarifying documentation and usage example.

BUG: 28296205
Change-Id: Ib1695822e3d361b17fc4d8a9a3f24a14e34f40ec
2016-05-03 18:30:01 +00:00
Tim Volodine
b0e9798e52 [WebView] Add documentation regarding geolocation api on secure origins.
Update to javadoc comments saying that for apps targeting N and up
the geolocation api is only supported on secure origins.
On non-secure origins requests to geolocation api are automatically
denied without calling the corresponding
WebChromeClient#onGeolocationPermissionsShowPrompt method.

BUG: 28080869
Change-Id: I57726f7f3b3d38db0535f742b1f74c40c1f1ce8b
2016-04-29 12:59:27 +00:00
Bo Liu
08ca2e3a75 Merge "Revert "Expose setDrawGLFunctionDetachedCallback to webview"" into nyc-dev 2016-04-27 17:58:34 +00:00
Selim Gurun
9a5f9c2087 Merge "API Review: Add @IntDef and other annotations to Menu Item flags." into nyc-dev 2016-04-27 17:48:32 +00:00
Michael Wright
1ad3955a60 Remove onUhandledInputEvent API.
This callback was never used by WebView and anyone that overrides it
is going to just be broken since we never actually call into it from
the method that WebView does call. Furthermore, the WebView team has
decided that the API has too many complications to ever implement,
the most notable of which is that MotionEvents tend to come in
streams that would need to be buffered in order to detect the event
before it can be determined whether they were handled or not which
means that any uses of the API are inevitably going to be janky
experiences.

Bug: 14279909
Change-Id: I068601ce947bccacabfe55b86b06005449b65bcf
2016-04-27 13:07:18 -04:00
TreeHugger Robot
e12d62bd79 Merge "WebView downgrade prevention logic" into nyc-dev 2016-04-26 09:31:57 +00:00
TreeHugger Robot
b698fc9d84 Merge "WebView doc: explain persist js across navigations" into nyc-dev 2016-04-25 18:39:47 +00:00
Bo Liu
e29d313e95 WebView doc: explain persist js across navigations
BUG: 28207652
Change-Id: Ib33f029c2cae6c1482c0c951075275e9f96ae73c
2016-04-25 09:38:06 -07:00
Bo Liu
d443f36957 Revert "Expose setDrawGLFunctionDetachedCallback to webview"
This reverts commit ee34ef1633.

This API is no longer needed by webview since 51.0.2704.22.
So remove this API. Note that this system API has never shipped
so it's ok to simply remove it.

Original description:
> Expose setDrawGLFunctionDetachedCallback to webview
>
> Add WebViewDelegate.setDrawGLFunctionDetachedCallback system API that's
> used for webview to receive the functor detach callback.
>
> BUG: 27709981
> Change-Id: Ie6b5e445c0090a181f94fcd2ec1ea77095c9cb03

BUG: 27709981
Change-Id: I9920dbedc6a280b4a19a8715832c4d2f64a7a7be
2016-04-22 13:32:23 -07:00
Adam Powell
31479e33e6 Remove dependencies on Activity from common Fragment superclasses
Allow common Fragments to be used in non-Activity hosts.

Bug 28337394

Change-Id: Id3baa3ef19ea41ff43ca76be89ced7530fbadfab
2016-04-22 12:11:28 -07:00
Hui Shu
b5f554a25d WebView downgrade prevention logic
Prevent *any* WebView provider packages to be downgraded lower than MonoChrome
Stable on the system image.

Assuming that all (and future) WebView provider packages follow the same
versionCode scheme, we can compare the subsection of Chromium versionCode that
contains branch number, which is done by ignoring the least significant 5
digits.

Note this CL is a follow-up to go/ag/895502.

BUG: 27469181
Change-Id: Iffe3c4b7f912d48c034f107079e065e54130713f
2016-04-22 10:56:55 -07:00
Hui Shu
539b077d42 API Review: Add @IntDef and other annotations to Menu Item flags.
BUG: 28296254
Change-Id: I11f77ae36b24f97948f55887d2ba111220afcf80
2016-04-21 11:35:28 -07:00
Bo Liu
439266bbb5 webview: canInvokeDrawGlFunctor should always return true
Now that invokeDrawGlFunctor doesn't use the View anymore, and just
calls a static method on ViewRootImpl. In particular this is required
since invokeDrwaGlFunctor need to still function for views that already
detached.

BUG: 27709981
Change-Id: I2c8c8f4a6943f7eec773265ca709349c5ce0be54
2016-04-20 09:03:53 -07:00
Bo Liu
e66471103a Expose DisplayListCanvas.drawGLFunctor to webview
BUG: 27709981
Change-Id: If3d2f57bfa50450e5f6834ef3ec2f48e26c294a6
2016-04-15 16:28:18 -07:00
Gustav Sennton
cd8f2737cc Verify WebView package info before loading WebView
To ensure that the package we are using to load WebView is a valid
provider we need to verify this before loading WebView - not only when
choosing what package to use.

Bug: 27900925
Change-Id: If57ca32a7a3fa08735a3b8ea9ed268c1bb1b8ede
2016-04-14 14:19:07 +01:00
Gustav Sennton
79fea48aec Create WebViewUpdateServiceImpl to move implementation there.
To make the WebViewUpdateService testable we create a new implementation
class that contains the implementation for the actual service. This
implementation can then be tested.

Bug: 27635535
Change-Id: I45c25c71375cc86a04c649a845016d2e7b105a7a
2016-04-07 16:03:44 +01:00
Bo Liu
2f1eb93354 Merge "Expose setDrawGLFunctionDetachedCallback to webview" into nyc-dev 2016-04-04 20:20:10 +00:00
Gustav Sennton
065b7e6ef5 Move more code from WebViewUpdateService to separate overridable class
Move more code from WebViewUpdateService to utility classes (methods
handling settings and uninstalling/enabling/disabling packages) to be
overridden during tests.

Also rename system utility class.

Bug: 27635535

Change-Id: If49999fba4fd0962f103f389898fa5ddf19365bd
2016-04-04 14:47:46 +01:00
Bo Liu
ee34ef1633 Expose setDrawGLFunctionDetachedCallback to webview
Add WebViewDelegate.setDrawGLFunctionDetachedCallback system API that's
used for webview to receive the functor detach callback.

BUG: 27709981
Change-Id: Ie6b5e445c0090a181f94fcd2ec1ea77095c9cb03
2016-04-01 11:10:00 -07:00
Gustav Sennton
1c177d8dae Add system api to reach WebViewUpdateService Binder interface.
Instead of using reflection in XTS tests we add some system-apis to
enable fetching information about webview packages.

Bug: 26381867
Change-Id: If983a01b6855e4a4c08ef0b5873304918d499b76
2016-04-01 12:39:54 +01:00
John Reck
bbb4c2eb2e Merge "Add a callback for rendernode parentcount=0" into nyc-dev 2016-03-31 18:24:49 +00:00
John Reck
44b49f070a Add a callback for rendernode parentcount=0
Bug: 27709981
Fixes: 22565656

Change-Id: I1cb4461baf9069dc4e7ca6de10d5862578c107f4
2016-03-31 08:36:50 -07:00
Gustav Sennton
ef40c9acd5 Merge "Simplify WebViewProviderInfo - move its logic into WebViewUpdateService." into nyc-dev 2016-03-31 15:28:53 +00:00
Gustav Sennton
dbf5eb04e6 Simplify WebViewProviderInfo - move its logic into WebViewUpdateService.
The WebViewProviderInfo should now be ready to be added as an API to be
fetched from XTS tests (to avoid using reflection).

Move the logic for validation, signature checking and package info
fetching out of WebViewProviderInfo so that we can mock the coupling
between that logic and the system (e.g. the package manager).

Note: with this patch we stop caching valid webview packages in the
update service (we would still refetch them anyway when anything
important happened).

Bug: 27635535
Bug: 27736084

Change-Id: Ia455202d2fd5bc4e03dce0fd917d262bf942d1a3
2016-03-31 14:21:47 +01:00
Gustav Sennton
79f1216eb1 Remove the system api method WebViewFactory.getWebViewPackageName
We no longer user this method and it doesn't return any useful
information.

Bug: 27719581

Change-Id: Id282f1501cde9a7d7cc1fe66016cfb54956686c5
2016-03-29 13:36:02 +01:00
Gustav Sennton
79a23a093e Merge "Add utility interface for WebView preparation logic." into nyc-dev 2016-03-18 17:30:12 +00:00
Gustav Sennton
8b17926a78 Add utility interface for WebView preparation logic.
To make the WebView preparation mechanism testable we add a utility
interface that can be overridden during a test to avoid calling the
Android framework and to provide custom WebView packages.

With this change we also split some of the code from the WebViewFactory
(code unrelated to WebView loading) into a separate utility class.

Bug: 27635535
Change-Id: I265ecd42b24ad5383637e125b3654ff339c9df9c
2016-03-18 15:47:23 +00:00
Gustav Sennton
26c82fff09 Remove WebView-package-being-replaced logic from WebViewUpdateService.
The replacing-logic tries to handle packages being uninstalled while
being replaced. This can't be handled through listening to
package-replaced intents since those can be delivered long after the
actual problem occurs.

Bug: 27605997
Change-Id: Iba8e546a5bba1ceb6226d4edb71db088c81ae1a9
2016-03-17 20:29:43 +00:00
Selim Gurun
ed738393af Merge "Revert "Revert "Add some View methods overrides and WebViewDelegate interfaces.""" into nyc-dev 2016-03-17 18:27:54 +00:00
Selim Gurun
e319dadaa9 Revert "Revert "Add some View methods overrides and WebViewDelegate interfaces.""
This reverts commit 7ef5429637.

Change-Id: I03a27148a1df5baf12fb89bca77dcb55a47b6be2
2016-03-17 01:41:14 +00:00
Torne (Richard Coles)
1a904125a3 Load WebView library into the right classloader namespace.
Use the namespace corresponding to the WebView APK's classloader to load
the native library. This prevents the library from being loaded twice in
certain situations.

Bug: 27189432
Change-Id: Ia232bf13a2a04b18214af4fecde68fafc534983f
2016-03-14 14:04:30 +00:00
Gustav Sennton
5df5e2266c Allow disk reads during more parts of WebView loading.
Loading WebView should not cause any StrictMode violations since app
developers using WebView with StrictMode turned on would have to turn
off StrictMode violations at the point at which they create a new
WebView.

Bug: 27240115

Change-Id: Ia2f5565be6f36560bc9881624faf6645bc2c8575
2016-03-08 16:21:09 +00:00
Gustav Sennton
074d630f9e Merge "Add fallback packages to be enabled iff no webview packages are valid" into nyc-dev 2016-02-24 19:00:36 +00:00
Paul Miller
9aca9aecab Fix WebView Metrics opt out Javadoc formatting
BUG:27305383
Change-Id: I23afa271058479263abe714f1a3493562f0cfe9e
2016-02-23 13:39:19 -08:00