Commit Graph

3460 Commits

Author SHA1 Message Date
Gustav Sennton
4cbfe71bba Update WebView.getCurrentWebViewPackage documentation.
Explain when a WebView implementation change can occur, and what happens
when it occurs.

Bug: 35764852
Test: None (java-doc change).
Change-Id: I2d2bcccc2f16bc911636373bb47c64d846f15b2d
2017-03-07 14:33:13 +00:00
Dimitry Ivanov
638d810099 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
2017-02-22 23:52:01 -08:00
Gustav Sennton
f9295bcc24 Merge "Make sure we cannot use packages targeting pre-O as WebView packages." 2017-02-02 14:34:04 +00:00
Gustav Sennton
564c2fd5db Make sure we cannot use packages targeting pre-O as WebView packages.
Using a WebView package targeting a release before O as WebView provider
on O will cause crashes (because of incompatibility issues), this CL
makes us interpret a package targeting a pre-O release as being invalid
on O.

Also remove the code that lets us fall back to loading the old
WebViewChromiumFactoryProvider (pre-O) class.

Bug: 34773740
Bug: 34180497
Test: Ensure WebView provider with targetSdkVersion="O" shows up in the
WebView Implementation Dev Setting, ensure targetSdkVersion=25 doesn't
show up.
Test: Add WVUS unit test to ensure a packages with targetSdkVersion < 26
are considered invalid, and > 26 are valid. Run WVUS unit tests.

Change-Id: I4d80d46019e2522bc3fc6068712d28eedb31fcce
2017-02-01 13:59:26 +00:00
Tao Bai
dd264f69ed WebView: Revise the behavior of crash handle API
To make backward compatible, kills application when render process
is killed by system.

Bug: 30824898
Test: No test, this is document revision.
Change-Id: I12862ee9ed1986ec274fe627782542e8d8414856
2017-01-31 11:02:08 -08:00
Richard Coles
2536cc6872 Merge "Expose isMultiProcessEnabled via WebViewDelegate." 2017-01-23 21:23:45 +00:00
TreeHugger Robot
eeb4e1d219 Merge "Change WebView fallback mechanism to consider all users' package states." 2017-01-23 20:20:15 +00:00
Torne (Richard Coles)
b26428b3c2 Expose isMultiProcessEnabled via WebViewDelegate.
Allow the WebView implementation to call isMultiProcessEnabled via the
delegate, so that it doesn't have to fetch and interpret the value of
the system setting itself.

Bug: 21643067
Test: manual (requires modifications to chromium to call)
Change-Id: I1ef2b7ea0054c606965040e02034c938d5e6464c
2017-01-23 15:09:55 +00:00
Gustav Sennton
364e160290 Change WebView fallback mechanism to consider all users' package states.
MultiProcess WebView will use a Service to start a separate process (the
renderer process). This Service can only be started if the WebView
package is enabled for the current user. To ensure that the current
WebView package is usable by all users on a single device we now only
use a WebView package as WebView implementation if that package is
enabled and installed for all user on the device. This also means that
the WebView-fallback mechanism will trigger when disabling the primary
WebView package for any user (not just the system user).

Also add multi-user unit tests to cover this new change.

Bug: 32894152
Test: run unit tests in WebViewUpdateServiceTest
Test: ensure the standalone WebView package becomes enabled (for all
device users) when disabling Chrome for a secondary user.
Test: load WebView (both using Monochrome, and using the standalone
WebView).

Change-Id: Iad3fc48aa50273062c2f29ae48a343c2dea38116
2017-01-23 09:30:11 +00:00
Tobias Sargeant
d10e4af098 WebView: Add the definition of the renderer importance API.
The renderer importance API is used to specify how important
out-of-process WebView renderer services are for the purposes of OOM
killing and scheduling with respect to the binding application.

This allows an application to - for example - specify that renderers can
be killed while the application is not in the foreground, thus cleaning
up additional resources.

Bug: 30824898
Test: Tests await Chromium change.
Change-Id: I6dca3d427d6cdb5cb7e0be6f7fb8ece64bd24af9
2017-01-22 18:59:12 +00:00
TreeHugger Robot
9ecde44945 Merge "Handle multiprocess flag in WebView update service." 2017-01-18 15:19:43 +00:00
Torne (Richard Coles)
1a4c4e3539 Handle multiprocess flag in WebView update service.
Instead of letting DevelopmentSettings manage the setting directly and
observing the changes from WebViewUpdateService, have the update service
manage the setting and just expose IPCs for the settings app to use to
get/set the setting. This means we can set a more flexible policy for
whether multiprocess is enabled by default and change it without
touching the settings code, though for now this CL does not change the
behaviour and is just a refactoring.

Bug: 21643067
Test: Toggle multiprocess WebView in developer settings
Change-Id: I3057c09d99f5f6f472a5195a8e14e9164ea5733a
2017-01-12 14:23:17 +00:00
Tao Bai
fe0c0e05be Merge "Load WebViewChromiumFactoryProviderForO" 2017-01-11 19:01:25 +00:00
Felipe Leme
6d553874be YAMAFFR - Yet Another Major AutoFill Framework Refactoring
- Explicitly split View methods into Assist and AutoFill methods, rather
  than use an overloaded method that takes flags.
- Simarly, renamed ASSIST_FLAG_SANITIZED_TEXT and
  ASSIST_FLAG_NON_SANITIZED_TEXT flags to
  AUTO_FILL_FLAG_TYPE_FILL and AUTO_FILL_FLAG_TYPE_SAVE respectively.
- Created a AutoFillUI class to host the auto-fill bar and other UI
  affordances.
- Moved the temporary notifications to AutoFillUI (eventually that
  class will host the real UI).
- Moved FillData to android.app.view.autofill package.
- Split IAutoFillCallback in 2 (IAutoFillAppCallback and
  IAutoFillServerCallback, residing at the app and system_server
  respectively), so service cannot fill the app directly (which lets
  the framework control the UI).
- Moved assist's IResultReceiver to AutoFillServiceImpl so
  system_server can act as a mediator between the AutoFillService
  implementation and the app being auto-filled.
- Replaced FillData and FillableInputFields by a bunch of new objects:
  - FillResponse contains a group of Datasets, each representing
  different values
    that can be used to auto-fill an activity (for example, different
    user accounts), optional id of fields the service is interested
    to save, and an optional bundle for service-side extras.
  - Dataset contains a name, Fields, and an optional bundle for
    service-side extras.
  - Fields contain an AutoFillId (parcelable) and a value (Bundle)
- Changed the temporary notifications to emulate the new workflow:
  - Initial notification requests the auto-fill data but do not
    auto-fill.
  - Once service calls back, a new notification is shown with the
    results.
  - Then if the user selects a dataset, the activity is auto-filled
    with it.
  - It also shows a notification to emulate what can be saved.
- Created an VirtualViewDelegate for views that uses a virtual
  hierarchy for assist data.
- Added new methods on ViewStructure to add children with virtual ids.
- Added 2 methods on View to support auto-fill:
  - autoFill(Bundle) to auto-fill the view.
  - getAutoFillType() to return how the view can be auto-filled.
- AutoFillType defines the input fields that support auto-fill:
  - Text fields (like EditText)
  - Toggle fields (like CheckBox)
  - Lists (like RadioGroup)
- AutoFillType can also have a sub-type representing its semantic (for
  now only text fields have it, and it's the same as getInputType()).
- etc :-)

Bug: 31001899
Test: manual verification
Change-Id: I2dd2fdedcb3ecd1e4403f9c32fa644cb914e186f
2017-01-10 12:50:47 -08:00
Tao Bai
755eded053 Load WebViewChromiumFactoryProviderForO
BUG: 34180497
Test: change the name of class to load.

Change-Id: I586e83242d380b1def88de605a4e9dee375c87b2
2017-01-10 11:07:18 -08:00
Robert Sesek
c99a9e0a45 Merge "Synchronize access to WebViewZygote." am: fd6f631de5 am: c8111e07d0 am: 2c3818158a
am: 8be4cfc638

Change-Id: I31e7f0e75173e79e42ec9ce8703e7fd40f39c31a
2017-01-05 09:50:05 +00: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
Tao Bai
2bb0099b0a Merge "WebView: Add the definition of crash API." 2017-01-04 18:08:28 +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
Tao Bai
c53fae1001 WebView: Add the definition of crash API.
Bug: 30824898
Test: There is no test yet, this patch just add the defintion of API,
 and make it easy to work on chromium side.

Change-Id: I7fdaf894f18cc8bad8e84465e4a0390b22f8bba8
2016-12-16 10:33:37 -08:00
Felipe Leme
1ca634a544 AutoFill Framework refactoring.
The AutoFill Framework uses the same AssitStructure provided by the Assist API
and so far it was using the same methods as well, both internally and externally
(public API).

Sharing that internal code internally is fine, but the public APIs must distinguish between the 2 cases so they can fill the assist structures accordingly (although the initial implementation still shares the same logic).

This CL also splits the original 'auto-fill' request in 2 types of requests,
which are set by View flags:

- ASSIST_FLAG_SANITIZED_TEXT
- ASSIST_FLAG_NON_SANITIZED_TEXT

It also added new methods and callbacks to handle save requests.

Bug: 31001899
Test: manual verification

Change-Id:  I4eb09099dc19a43cb7e053e64d939aed3704b410
2016-12-12 18:22:45 -08:00
Robert Sesek
e4ddf44967 Merge "Add new hostingType for startProcessLocked() that selects using the WebViewZygote." am: eda1af611f am: bbcd9d26b1 am: 5806963539
am: 5c44250176

Change-Id: Ia1a819697d7144073f824a98dd8a315eb60c779b
2016-12-02 17:43:56 +00: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)
2c0dc3e094 Merge "Precreate the classloader for the WebView." am: 566b1c80e4 am: 1feb782f01 am: 9565860b08
am: 7e17c6b0f1

Change-Id: Ie512327827e48319b3244a8d3041cb78538109d3
2016-11-21 17:18:55 +00: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
Sudheer Shanka
dc589ac82b Update usage of ActivityManagerNative.
- Remove references to ActivityManagerProxy.
- Add isSystemReady to ActivityManager.

Bug: 30977067
Test: cts/hostsidetests/services/activityandwindowmanager/util/run-test android.server.cts
      adb shell am instrument -e class com.android.server.am.ActivityManagerTest,com.android.server.am.TaskStackChangedListenerTest \
          -w com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Change-Id: I07390b6124fb1515821f5c0b37baf6ae74adc8fa
2016-11-14 11:27:12 -08: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
02bf0b6dbc Merge "Create the WebViewZygote and implement WebViewZygoteInit." am: 8be2850546 am: f80fab010a
am: aa544e975e

Change-Id: I561fff0f56bdbfdeb6c92c11c3fce12cf3fe28be
2016-10-22 03:22:50 +00:00
Selim Gurun
c92080bd78 Update the documentation for onCreateInputConnection
Update the documentation to clarify that WebView calls methods of the
InputConnection on a separate thread than the UI thread. This is,
in some sense, similar to shouldInterceptRequest. The methods
that override InputConnection methods should be careful about thread
restrictions and concurrency when calling other methods or accessing
shared members.

Test: Document update. Verified manually.
Change-Id: Ida76cd5dcc683092c05947c3044d848d0a249547
2016-10-20 13:48:08 -07:00
Gustav Sennton
bf683e07c3 Add an API for retrieving information about the current WebView package.
Now that WebView can be loaded from one out of a set of packages we
provide an API for fetching information about this package.
Such API is especially useful for debugging crashes.

Bug: 30597460

Change-Id: I13dd746f7efcf2917b517053010b73ea35241325
2016-10-17 07:26:37 +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
Nate Fischer
6e585844a0 Add APIs to get WebViewClient and WebChromeClient
Add getWebViewClient and getWebChromeClient to WebView and WebViewProvider.
These APIs both return null if the client is not yet set.

Change-Id: I22044713a43ab09a9a5a63138247bfecb60f2522
Test: N/A
Bug: 31843416
2016-10-04 11:12:47 -07:00
Nate Fischer
2cab2fd3ff Merge "Deprecate WebView#{get,set}HttpAuthUsernamePassword" 2016-09-26 23:14:42 +00:00
Nate Fischer
c7edfb02bd Deprecate WebView#{get,set}HttpAuthUsernamePassword
Deprecate these methods and move them to WebViewDatabase.

BUG: 31318603
Test: N/A
Change-Id: Ie4613e8de9c6120fa1d21263b15ef2467c6ccdef
2016-09-26 13:45:09 -07:00
Nate Fischer
ffb81c4a77 Fix spelling errors
Fix various spelling errors, change spellings/capitalizations to be more
consistent with the rest of the documentation, and delete extra words.

Change-Id: I63eb85c0594d53d9e91836507209771094ff0f33
Test: N/A
2016-09-26 12:35:47 -07:00
Hui Shu
433fb93515 Fix WebViewDatabase javadoc.
BUG=30481165
Change-Id: Ibd14880aa25907234dd93c38b5d0f2c9e808340e
2016-09-06 11:28:34 -07:00
Bo Liu
4827385ae7 WebView: Use static factory method to create provider
This gives the implementation the flexibility to choose different
provider instances. Fallback to constructor if static initializer
factory method doesn't exist.

Change-Id: I72fa0c51c64d0dbdeb6234a0ab4fdd0a389b09fc
2016-08-20 16:13:25 -07:00
Selim Gurun
32c3516369 Fix document format
The document is all one single paragraph making it hard to read. fix it.

Change-Id: Iadcfe6e55a813d7599ebdd4b160ed544c5296c16
2016-07-27 15:44:54 -07:00
Torne (Richard Coles)
59375a015a Remove synchronized from static methods in WebView.
ART uses the class object's embedded monitor to protect class
initialization - the same monitor used by "synchronized" applied to
static methods. This can cause deadlock in extremely rare cases of
preemption during WebView code loading.

Remove synchronized from all static methods in WebView, to avoid this
deadlock. In most cases the synchronized is simply unnecessary in the
Chromium-based WebView implementation; in CookieSyncManager we instead
use a separately allocated Lock object to preserve thread safety.

Bug: 27417671
Change-Id: I13049f23fc984b77a3f4c203a5c698858c64abfe
2016-07-18 18:45:24 +01:00
Gustav Sennton
4f113f47df Merge \\\"Use newly fetched PackageInfo for loading WebView code.\\\" into nyc-dev am: cdbf412f8e am: deac870fd1
am: 90888027d8

Change-Id: Ib9853fb2dfa5629a1917f333a80661e8676936d3
2016-06-20 18:52:02 +00: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
02e68a1619 Merge \\\"ResourcesManager: Allow managed addition of library asset paths\\\" into nyc-dev am: 464bda8a2b am: c3ab1b7c0a
am: f4152a9c7e

Change-Id: I2b3190f567f62bfaeed54ec6047cfd42bcd246e8
2016-06-15 23:14:51 +00: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
Aurimas Liutikas
514c5ef8d5 Add missing @Deprecated annotations.
Add missing @Deprecated annotations for methods with @deprecated tag
in javadoc.

Change-Id: I35b78ccb97832d86b914c21a300444ba29e33844
2016-05-24 15:22:55 -07:00
Gustav Sennton
c4446568cc resolve merge conflicts of 00b735a to master
Change-Id: Ief4ed37cf8de3e2d4279a1267717dd6a54702b7c
2016-05-24 12:54:11 +01: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
Michael Wright
9f8c39a8e3 Merge "Remove onUhandledInputEvent API." into nyc-dev am: a1e4cbe211 am: 9e0ff89010
am: 56ef817f1e

* commit '56ef817f1e8805b6da304067a60a06b4fa86f995':
  Remove onUhandledInputEvent API.

Change-Id: Ic0a52c81f611719e5bd8d51a141b48fa62ea8222
2016-05-16 15:31:12 +00:00