Commit Graph

3633 Commits

Author SHA1 Message Date
TreeHugger Robot
9845f75a33 Merge "WebView: add @NonNull annotation to API" 2018-03-01 20:42:35 +00:00
Nate Fischer
65e3be0255 WebView: add @NonNull annotation to API
No change to logic, only an annotation change.

startSafeBrowsing() should never receive a null Context. This adds
@NonNull to hint to developers not to pass null Contexts.

Test: N/A
Change-Id: I46d863047bf7563ea2a1adf592f3f381be95ca49
2018-03-01 00:55:35 -08:00
TreeHugger Robot
3cddd037f4 Merge "WebView: relax URLUtil#isFileUrl()" 2018-02-28 23:11:37 +00:00
Robert Sesek
ffc4dd720d Merge "Delay starting the webview_zygote until first use." am: 6d9d717ab7 am: 99440a0ab8
am: 92697692b3

Change-Id: I4f810427f083d9b7874df7d90fc00a33967d9323
2018-02-28 18:32:39 +00:00
Nate Fischer
d674b09af2 WebView: relax URLUtil#isFileUrl()
This relaxes URLUtil#isFileUrl() to accept a prefix of "file:" instead
of requiring "file://". Chromium treats "file:path" as if the user had
typed "file:///path". An app may incorrectly believe it's safe to load
anything that URLUtil#isFileUrl() rejects, intending to refuse all URLs
which point to the file system.

Bug: 72848579
Test: cts-tradefed run cts -m CtsWebkitTestCases -t android.webkit.cts.URLUtilTest#testIsFileUrl
Change-Id: I7b3bba961523d4bdda6169a0f50fe7f1d1579e38
2018-02-27 20:59:29 -08:00
TreeHugger Robot
837d2076ad Merge changes I7ce670f5,I0bd2de38
* changes:
  Preload with RELRO sharing in the WebView zygote.
  Make WebViewLibraryLoader interface more flexible.
2018-02-27 16:11:02 +00:00
Robert Sesek
b21dbc220f Delay starting the webview_zygote until first use.
During boot, WebViewZygote.setMultiprocessEnabled() is called by the
WebView initialization logic. Starting the WebViewZygote here causes a
slowdown in the system_server boot process, so delay launching the
zygote until it is needed.

Previously the webview_zygote was launched by init, and merely
connecting to it in the boot process didn't have significant overhead.

Bug: 73743583
Bug: 63749735
Test: Boot a device, verify that webview_zygote process is not running.
Test: Launch "Third-party licenses" activity from Settings, and it
      renders correctly via the WebView.

Change-Id: I1352a5df95e4a793ac64862c439ba2573ddd2d18
2018-02-26 16:59:48 -05:00
Torne (Richard Coles)
f4f647e2e0 Preload with RELRO sharing in the WebView zygote.
Now that the WebView zygote is a child of the system zygote it has the
smae address space layout and can use the existing WebView native
library RELRO file.

Preload the native library using the RELRO file in the zygote, to share
this data with applications which are using WebView. This can save up to
1-2MB of dirty memory, replacing it with clean pages that are shared
with more processes and thus have a smaller impact on PSS.

Bug: 63749735
Test: CtsWebkitTests
Change-Id: I7ce670f5fcddae9e98631e21329840ef3ad52f9a
2018-02-26 16:23:09 -05:00
TreeHugger Robot
6169417fd5 Merge "WebView: fix docs for setSafeBrowsingWhitelist" 2018-02-22 04:08:02 +00:00
Nate Fischer
5a6ae8c739 WebView: fix docs for setSafeBrowsingWhitelist
No change to logic, documentation change only.

This changes "URL" to "host" everywhere in this API documentation.
This API never accepted a list of URLs, it only ever accepted a list of
hosts (e.g. "www.google.com" is ok, "http://www.google.com/" is not).
The original documentation was misleading.

Test: make docs (manually verify)
Change-Id: I3b57a2a160ff00ba8f92b30f6e3b4399e55f2ea0
2018-02-21 15:27:01 -08:00
Torne (Richard Coles)
ec572f6a81 Make WebViewLibraryLoader interface more flexible.
Pass the library file name to WebViewLibraryLoader.loadNativeLibrary
instead of passing the ApplicationInfo, which was only used to look the
native library file name up. This will allow loadNativeLibrary to be
called from the webview zygote, which doesn't have the ApplicationInfo
available.

Bug: 63749735
Test: CtsWebkitTests
Change-Id: I0bd2de38cd1a0112bbeee6225563d4d0add048e7
2018-02-21 16:20:24 -05:00
Robert Sesek
f9bd606fba Merge "Reparent the webview_zygote to be a child of the main app_process zygote." am: 1c81aa6375 am: 486190f87b
am: 0dd7cf0bb3

Change-Id: I9468ec63053f35814ec45b18572966d8adc93f3e
2018-02-21 02:47:07 +00:00
Robert Sesek
602d1323ed Reparent the webview_zygote to be a child of the main app_process zygote.
This uses the new ZygoteProcess.startChildZygote() method to launch the
webview_zygote, rather than having init start it. This will share more
memory between the app_process and the webview_zygote, reducing the
overall system footprint.

Bug: 63749735
Test: m
Test: Launch "Third-party licenses" activity from Settings, and it
      renders correctly via the WebView.
Change-Id: I3e39cd8adb9c099c92ee34640428916d90cb2b8f
2018-02-20 17:00:41 -05:00
Torne (Richard Coles)
5bc14af5fa Consider shared libs when precreating WebView classloader.
The change to handling of the deprecated Apache HTTP library means that
the WebView implementation package might have a non-empty shared library
list. Make sure to fetch shared libraries when querying WebView
implementations, and take them into account when constructing both the
actual classpath to be used to precreate the classloader, and when
deciding what the cache key for the precreated classloader should be.

Change-Id: I5e1409358d935e1c9f325db434bc6d4ef8ead759
Merged-In: I5e1409358d935e1c9f325db434bc6d4ef8ead759
Fixes: 65574359
Test: launch anything that uses WebView
(cherry picked from commit 4fd8aa51e4)
2018-02-20 15:41:12 -05:00
Torne (Richard Coles)
9b73804cae Add OWNERS for webview directories in framework.
Bug: 73450992
Test: N/A
Change-Id: I20e186eca8b02fa4e2d0eb729b94df8a36983906
2018-02-20 10:48:51 -05:00
Tim Volodine
bfd30802f7 Merge "WebView Tracing API: address comments from the API council." 2018-02-16 15:00:27 +00:00
Tim Volodine
88604f2f8a WebView Tracing API: address comments from the API council.
Address comments from the API council regarding the WebView Tracing API.

android.webkit.TracingController:
 * start() throws IllegalStateException if the system is already tracing
   (this is instead of returning false)
 * stop uses Executor instead of Handler
 * removed stop() (the method w/o arguments)
 * renamed stopAndFlush to stop
 * use OutputStream instead of a custom callback interface TracingOutputStream
 * dropped requirement for UI threading
 * updated documentation

android.webkit.TracingFileOutputStream:
 * removed the TracingFileOutputStream file completely (functionality
   replaced by the existing FileOutputStream)

android.webkit.TracingConfig:
 * removed example with CATEGORIES_NONE and “-input,-gpu”.
 * customCategories are List<String> instead of String
 * updated documentation
 * added two more predefined categories: CATEGORIES_ALL,
   CATEGORIES_ANDROID_WEBVIEW
 * some refactoring, added a Builder class
 * ensure that only include category patterns can be specified
 * uniform addCategories interface for construction
 * predefined category sets are a bitmask now

BUG: 71584598,71584599,63750258
Test: CTS
Change-Id: I615ef5f43d26968329182b09e7c26178f1f85ecc
2018-02-15 13:26:39 +00:00
Torne (Richard Coles)
de956b7f9b Improve docs for WebView data dir methods.
Update the javadoc for the WebView data directory methods to make it
more clear in what cases these APIs should be used, and what limitations
apply to applications with multiple data directories.

Bug: 63748219
Test: n/a
Change-Id: I98f49c7a75df00aedf2472731b915c3e30e6ba13
2018-01-30 11:41:35 -05:00
TreeHugger Robot
854211d15b Merge "Store WebView package signatures as Signatures instead of Strings" 2018-01-25 22:58:49 +00:00
TreeHugger Robot
04d0d0031a Merge "WebView: document Safe Browsing as 'on' by default" 2018-01-25 16:00:00 +00:00
TreeHugger Robot
88ffa32cad Merge "WebView: fix docs for setAllow*AccessFromFileUrls" 2018-01-25 15:23:27 +00:00
Gustav Sennton
0167369990 Add an API to fetch the WebView thread.
Some WebView APIs contain checks ensuring apps only use WebView APIs
from one single thread. The WebView Support Library should perform
similar thread checks. To do so we publish an API to get the WebView
thread, so that the support library knows which thread to check against.

Test: Ran the corresponding CTS tests.
Bug: 38220806
Change-Id: Ibab878e211d9594df6d39f99ce130e28fac7f019
2018-01-24 14:39:45 +00:00
Nate Fischer
8cc15366cb WebView: fix docs for setAllow*AccessFromFileUrls
No change to behavior, only docs change.

The docs for setAllow(File|Universal)AccessFromFileUrls were previously
wrong. They implied that:

 * Default value is 'false' when SDK_INT > Jellybean
 * APIs were added in Jellybean (so they can't be called pre-Jellybean)
 * Therefore, setAllow*AccessFromFileUrls(false) is always a NOOP

Actually, WebView examines targetSdk, not SDK_INT. So apps should call
setAllow*AccessFromFileUrls(false) when targeting ICE_CREAM_SANDWICH_MR1
and below.

The docs previously had mixed use of ICE_CREAM_SANDWICH and
ICE_CREAM_SANDWICH_MR1. This corrects the docs to use the right one
(ICE_CREAM_SANDWICH_MR1).

Lastly, this fixes a minor grammar mistake (misplaced comma).

Test: make docs (manually verify)
Change-Id: I206dff54a8c342ae7b47bd40d69d0b01dbad3cc6
2018-01-23 16:51:30 -08:00
Gustav Sennton
265afdb14e Add a method for fetching the WebView classloader.
The WebView Support Library needs a way to hook into the WebView APK,
this new method returns a classloader that can be used to load internal
WebView classes.
The idea is to have this classloader be provided by the WebView APK
itself, so that the classes accessed from the classloader can be
filtered to avoid apps accidentally adding dependencies on internal
details of the WebView APK.

Test: N/A - cannot add CTS tests until we drop a WebView APK containing
the implementation for this API.
Bug: 38220806
Change-Id: If744a740ff0b1728d2d4674e73697bc6a5e27dde
2018-01-22 22:13:57 +00:00
Nate Fischer
fb92ee1348 WebView: document Safe Browsing as 'on' by default
WebView Safe Browsing will be on by default. While previously it was
opt-in (applications needed to enable via manifest or API), now it is an
opt-out feature.

This CL updates documentation to mention that the feature is on by
default and provides steps for applications to opt-out if necessary.

This also makes the case of "Safe Browsing" consistent across
documentation.

Bug: 69579509
Test: make docs (manually verify)
Change-Id: I77683a684cd79d2e3cd313ddbff8c52fe510b72b
2018-01-18 12:01:19 -08:00
TreeHugger Robot
38e2249aa8 Merge "Reenable Strictmode disk reads checks in WebViewFactory." 2018-01-16 17:42:18 +00:00
Gustav Sennton
90b38a9e38 Reenable Strictmode disk reads checks in WebViewFactory.
In an earlier release we had to allow disk reads during a part of
WebView initialization, now that this fault is fixed we can remove that
allowance.

Bug: 63324842
Test: Manual: ensure calling new WebView() doesn't cause StrictMode disk
read violation.
Test: run WebViewHostSideStartupTest.testStrictMode()

Change-Id: If7b4ad790c67469806c255427d86e5fd28d19f35
2018-01-15 18:15:19 +00:00
Toby Sargeant
13e0861efa Merge "Add a Java FindAddress implentation." am: 9ea410a6f8 am: da4e3b68fb
am: ef5218836d

Change-Id: Ic896c9f805330c28e9e0c3ca583f28e80bc47184
2018-01-09 00:12:33 +00:00
TreeHugger Robot
25d2bf9c6a Merge "WebView: clarify docs regarding base64 encoding" 2018-01-05 20:55:02 +00:00
Tobias Sargeant
f4d85d806e Add a Java FindAddress implentation.
This stops calling findAddress (possibly indirectly via Linkify) from
loading webview native code, resulting in a performance and memory
improvement for those apps that call WebView#findAddress but do not
otherwise use WebView.

Bug: 22362008
Test: Existing WebView CTS test.
Change-Id: I5fcab725ceaf0d6a00e931d3b6cd2f3799d68391
2018-01-05 14:44:10 +00:00
Nate Fischer
867d10944d WebView: clarify docs regarding base64 encoding
Docs change only, no change to logic.

This CL provides a better loadData() example, using base64 encoding.
This uses the Base64 class already provided by Android to automatically
handle the encoding.

This also changes the percent-encoding docs to:

 * Link to the official RFC
 * No longer provide examples of characters to encode (one example was
   incorrect, '\' is not %27)

Bug: 70555565
Test: make docs (manually verify things look good)
Test: I built a sample app and tested Base64#encodetoString to make sure the flags are correct
Change-Id: If9f810e6b568efdc5d1ad84ac64f2abf3788f40b
2018-01-04 21:57:33 -08:00
Gustav Sennton
74473597dc Store WebView package signatures as Signatures instead of Strings
We are currently storing WebView package signatures as Strings in
WebViewProviderInfo, represent these as Signatures instead.

Bug: 62429931
Test: start WebView app + run WebViewTest GTS tests + WVUS tests
Change-Id: I910db133cd147b44b4b1c63921308d82db44e5b3
2018-01-03 18:30:41 +00:00
Shimi Zhang
295c5a1372 Switch to WebViewChromiumFactoryProviderForP
Bug: 70688155
Test: Flash device to make sure WebView providers are in developer options.
Change-Id: I6fbaa0bd7769da4a83b42a378cb80cf3497294a2
2017-12-21 16:05:16 -08:00
TreeHugger Robot
8ca1e41a0f Merge "Make WebView data directory configurable." 2017-12-19 10:06:29 +00:00
Sudheer Shanka
b430d8ff06 Merge "Start processes asynchronously in AMS." 2017-12-16 18:36:48 +00:00
Sudheer Shanka
f6690100be Start processes asynchronously in AMS.
Currently, process start is initiated in ActivityManagerService
holding the main lock and this takes ~40ms to complete. As seen
in some of the issues in previous releases, this is one of the
contributors of the lock contention in system_server. This change
tries to address this issue by moving the process start outside
the locked section.

When a process start is required, instead of doing it synchronously,
this request will be posted on a handler thread. On the handler thread,
this process start request will be completed without holding a lock.
If for some reason, we decide the process is not needed anymore before
it is actually started or being started, then AMS does everything as
usual removing the references to the process from internal state except
actually killing the process which will be handled on the handler
thread.

Bug: 68775202
Test: Ran app startup perf tests using forrest, will update the bug with results.
Test: https://docs.google.com/spreadsheets/d/1cW81guRALZXKsN-WZsKyQiCSY-RgkJ2m_M9IfqIquz8
Test: cts-tradefed run singleCommand cts-dev -m CtsActivityManagerDeviceTestCases
Test: cts-tradefed run singleCommand cts-dev -m CtsWindowManagerDeviceTestCases
Test: cts-tradefed run singleCommand cts-dev -m CtsAppTestCases
Test: cts-tradefed run singleCommand cts-dev -m CtsMultiUserHostTestCases
Test: adb shell am instrument -e package com.android.server.am -w \
      com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Test: adb shell am instrument -e class com.android.server.pm.UserManagerTest -w \
      com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Test: adb shell am instrument -e package android.content -w \
      com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Test: cts-tradefed run singleCommand cts-dev -m CtsProviderTestCases
Test: cts-tradefed run singleCommand cts-dev -m CtsContentTestCases -t \
      android.content.cts.ContentResolverTest
Test: cts-tradefed run singleCommand cts-dev -m CtsContentTestCases -t \
      android.content.cts.ContentProviderTest
Test: cts-tradefed run singleCommand cts-dev -m CtsWebkitTestCases
Test: cts-tradefed run singleCommand cts-dev -m CtsHostsideWebViewTests
Test: cts-tradefed run singleCommand cts-dev -m CtsAssistTestCases
Test: make WebViewLoadingTests && make tradefed-all && tradefed.sh \
      run template/local_min --template:map test=WebViewLoadingTests
Test: adb shell setprop wrap.com.google.android.apps.maps \
      '"LIBC_DEBUG_MALLOC_OPTIONS=backtrace logwrapper"'
      && adb shell dumpsys meminfo --unreachable <PID_OF_APP>
      && check ppid of <APP> is logwrapper's pid.
Test: cts-tradefed run singleCommand cts-dev -m CtsWrapWrapNoDebugTestCases
Test: cts-tradefed run singleCommand cts-dev -m CtsWrapWrapDebugTestCases
Test: cts-tradefed run singleCommand cts-dev -m CtsWrapNoWrapTestCases
Test: cts-tradefed run singleCommand cts-dev -m CtsWrapWrapDebugMallocDebugTestCases
Test: manual

Change-Id: I1fe7ce48cd5a4aadccaf6b3d6fdb5cad3304f1d3
2017-12-15 12:23:12 -08:00
James Wallace-Lee
10adc35582 Merge "WebView: Clarify documentation about mimeTypes" 2017-12-14 18:40:12 +00:00
TreeHugger Robot
ccb2aa8b26 Merge "Add WebView Tracing API." 2017-12-14 15:07:24 +00:00
Jeff Sharkey
ce8db99114 Add more IntDef prefixes for auto-documenting.
Test: builds, boots
Bug: 70177949
Exempt-From-Owner-Approval: annotation-only changes
Change-Id: I76dde6054e06f52240bd4b1a0f196dcb74623608
2017-12-13 20:05:36 -07:00
Tim Volodine
c809542c30 Add WebView Tracing API.
Add classes/interfaces necessary for the support of tracing API
in WebView.

In particular:
- TracingController: singleton class for starting and stopping
  tracing and inspecting tracing status.
- TracingConfig: holds tracing configuration, such as categories
  to filter and the tracing mode.
- TracingOutputStream: interface for capturing tracing data.
- TracingFileOutputStream: supporting class for capturing tracing
  data to a file.

BUG: 63750258
Test: in progress

Change-Id: I7decd486788766fc8dfa766ae027c02f9d4c6f80
2017-12-13 15:27:54 +00:00
Torne (Richard Coles)
12f64daddc Make WebView data directory configurable.
Add WebView.setDataDirectory(String suffix) and WebView.disableWebView()
interfaces. These will enable applications to better control the use of
WebView when running multiple processes, since it's not safe for more
than one process in an app to use the same data directory.

disableWebView is completely implemented in this change;
setDataDirectory will require WebView-side implementation changes to be
functional.

Bug: 63748219
Test: cts android.webkit.cts.WebViewDataDirTest
Change-Id: Ieff225dc99b6b3ca5f223c35f7a854f0c53692df
2017-12-12 15:30:24 -05:00
James Wallace-Lee
d38c2e3f34 WebView: Clarify documentation about mimeTypes
This change edits the WebView documentation to specify that the mimeType
parameter to loadData and loadDataWithBaseUrl should be a valid mimeType
and the data will be downloaded if it is not.

Test: manual - this only changes documentation
Bug: 70528830
Change-Id: I58ca4655673c6ccfe7547572579ef86a14a259ed
2017-12-12 12:27:30 -08:00
Dianne Hackborn
3accca05dd Add major version code to platform.
It turns the version code into almost a 64-bit integer, with the
new major part being the upper 32 bits.

The only tricky part about this is the backup manager, since it
stored 32-bit version codes in its backup data sets.  This is dealt
with by, when the major version code is not 0, writing MIN_INT as
the version code and following that by the full long version code,
which we can detect when reading.  Note that this makes backup sets
containing apps with major version codes incompatible with older
versions of the platform.

Bug: 64459786
Test: Added in Change-Id: Iab8a682b62103babd6c16a56b8dc1e97d7078658
Change-Id: Ibfffe235bbfcf358b3741abd3f7197fdb063d3f3
2017-12-04 13:02:10 -08:00
TreeHugger Robot
b1b1141ee4 Merge "WebView: linkify ClientCertRequest method names" 2017-11-29 22:41:19 +00:00
Nate Fischer
da0f1b4694 WebView: linkify ClientCertRequest method names
No change to behavior, only docs changes. No change to wording.

This linkifies ClientCertRequest method names in the docs for
WebViewClient#onReceivedClientCertRequest.

Test: make docs (looks good, no errors)
Change-Id: I1de855e8cdf91b3aace3a188aafaa9ac9f90ed2a
2017-11-29 12:18:54 -08:00
Felipe Leme
f485f89a3b Added Privacy section to AutofillService documentation.
Test: mmm frameworks/base/:doc-comment-check-docs
Bug: 69417986

Change-Id: I526e0a0df21744ac0a90ff932aaa65e07905183d
2017-11-22 12:23:45 -08:00
Gustav Sennton
d7e5d09a9e Merge "Fix WebViewUpdateService test expectation to match reality." 2017-11-21 12:00:00 +00:00
Gustav Sennton
e5468f7554 Fix WebViewUpdateService test expectation to match reality.
Update testTargetSdkVersionValidity to use the same minimum sdk as the
actual code it's testing.

Bug: 69554263
Test: run com.android.server.webkit.WebViewUpdateServiceTest tests.

Change-Id: Ide04ede774072a10b84a9726bdff536bfef12712
2017-11-20 19:49:27 +00:00
Nate Fischer
4ea9240adb WebView: misc docs changes for WebSettings
No change to logic, only docs changes.

This is mostly just formatting changes to documentation. Changes fall
into a few categories:

 * Linkify ({@link}) or codify ({@code})
 * Spelling errors

Test: make docs (looks better)
Change-Id: Ibcd762ab06e51451a53bbce5860cc137bee22ccf
2017-11-17 18:51:51 -08:00
Ian Lake
0a1feb8192 Deprecate framework Fragments and Loaders
Redirect developers to use the Support Library
versions of Fragments and Loaders to ensure that
they get consistent behavior across versions of
Android and all devices as well as access to
Lifecycle improvements.

Test: Confirmed APIs deprecated in current.txt
BUG: 68381801
Change-Id: I58ec599e557fc93c8547c45ba7c9ced96b0c8616
2017-11-13 10:55:59 -08:00