OSDN Git Service
Elliott Hughes [Tue, 17 Aug 2010 01:25:34 +0000 (18:25 -0700)]
Remove a bit more nio cruft.
Collapse the unused MemorySpy hierarchy, and remove some dead code.
I've left all the dead rangeCheck stuff in in case we ever need it, but
maybe that should go too.
Change-Id: Ibff4e99f27e235453ae2983483e54878a679db34
Elliott Hughes [Tue, 17 Aug 2010 00:00:10 +0000 (17:00 -0700)]
Fix build. (Forgot to --replace.)
Change-Id: Ide854318ba0bea43789d7773eb5923719b553169
Elliott Hughes [Mon, 16 Aug 2010 23:51:25 +0000 (16:51 -0700)]
Merge "Some nio tidying." into dalvik-dev
Elliott Hughes [Mon, 16 Aug 2010 23:10:53 +0000 (16:10 -0700)]
Some nio tidying.
Remove indirection on OSMemory, and use public ByteOrder and MapMode types
throughout the implementation, rather than adding our own duplication. Also
remove some unnecessary Java methods that just forwarded to identical native
methods, and an unnecessary factory class for MappedByteBuffer instances.
Also get rid of ICommonDataTypes, most of which was unused cruft.
Change-Id: I3240b02bcc19941b1b1cbba351ae7f7c1cdfc5b4
Brian Carlstrom [Mon, 16 Aug 2010 22:54:43 +0000 (15:54 -0700)]
am
bfc0713b: am
12e10c1c: b/
2914872: fix concurrent initialization problem with peer certificate chain fields
Merge commit '
bfc0713bb26ec11c2000ba64439b3abdcb72a0bf' into dalvik-dev
* commit '
bfc0713bb26ec11c2000ba64439b3abdcb72a0bf':
b/
2914872: fix concurrent initialization problem with peer certificate chain fields
Brian Carlstrom [Mon, 16 Aug 2010 22:51:57 +0000 (15:51 -0700)]
am
12e10c1c: b/
2914872: fix concurrent initialization problem with peer certificate chain fields
Merge commit '
12e10c1c6f9324693b1dad96ab57fada2b771f11'
* commit '
12e10c1c6f9324693b1dad96ab57fada2b771f11':
b/
2914872: fix concurrent initialization problem with peer certificate chain fields
Brian Carlstrom [Mon, 16 Aug 2010 22:28:32 +0000 (15:28 -0700)]
b/
2914872: fix concurrent initialization problem with peer certificate chain fields
Change-Id: Ib76dd826c8f3616d4a3aed608aef432a1b99f3d6
Elliott Hughes [Mon, 16 Aug 2010 19:42:09 +0000 (12:42 -0700)]
path.size() does _not_ include space for the trailing NUL.
We were getting this:
java.io.FileNotFoundException: /data/system/entropy.dat (No such file or directory
instead of this:
java.io.FileNotFoundException: /data/system/entropy.dat (No such file or directory)
D'oh!
Change-Id: I8545d157889fefe96934fdc1a01c785e42e84a2d
Elliott Hughes [Sat, 14 Aug 2010 01:44:26 +0000 (18:44 -0700)]
File names should match their contents.
Change-Id: I3440bb921c70834325dfe1b1177f81158186ec7b
Elliott Hughes [Sat, 14 Aug 2010 01:23:34 +0000 (18:23 -0700)]
Clean up more of our floating-point cruft.
There was a ton of unused stuff here. I was hoping to kill all our
C-style casts so I could turn -Wold-style-cast on, but it looks like
our header files are too full of C-style casts for that to be practical
in conjunction with -Werror.
I'll get rid of the remaining C-style casts in the more heavily maintained
files at some point, but I'm calling it a day on the floating-point stuff
for now.
Change-Id: I93ce1c4a9db27674f4db1f329d6e7fa27e81ad72
Elliott Hughes [Fri, 13 Aug 2010 23:58:27 +0000 (16:58 -0700)]
Move the floating-point parsing into one file.
This removes a little duplication, potentially makes it a little easier for us
to replace this at some point, and removes the embarrassing spelling mistake
in two files' names that's been annoying me since I joined.
Change-Id: Ifb428f073ff7c742f2807146ed99fc5740edd159
Elliott Hughes [Fri, 13 Aug 2010 23:20:07 +0000 (16:20 -0700)]
Merge "Fix last few uses of "type *id" to be "type* id"." into dalvik-dev
Elliott Hughes [Fri, 13 Aug 2010 23:15:22 +0000 (16:15 -0700)]
Merge "Fix the build now warnings are errors, and comment all the weirdness." into dalvik-dev
Elliott Hughes [Fri, 13 Aug 2010 23:14:21 +0000 (16:14 -0700)]
Fix last few uses of "type *id" to be "type* id".
We don't want anyone calling us unreformed C programmers...
Change-Id: I79b12245b206495ca747b4027b2bca423c27aec0
Elliott Hughes [Fri, 13 Aug 2010 23:12:20 +0000 (16:12 -0700)]
Fix the build now warnings are errors, and comment all the weirdness.
In short: "fdlibm.h" is disgustingly unhygienic.
Change-Id: Idcd98eae359c894cf66a6c588c7f39b14416ac72
Elliott Hughes [Fri, 13 Aug 2010 21:37:40 +0000 (14:37 -0700)]
Fix reading from an empty non-blocking pipe.
The active ingredient here is getting rid of the lines that threw
InterruptedIOException in "OSFileSystem.cpp". I don't think that code was ever
right, but until I rewrote Pipe it wasn't possible to exercise that code.
The other changes are cosmetic, made while understanding this code well enough
to find the bug, plus a new test for this behavior.
Bug:
2901552
Change-Id: Id9cd3cdd6a97b225bbf7c352a6e0c535e9f9da1d
Elliott Hughes [Fri, 13 Aug 2010 00:27:27 +0000 (17:27 -0700)]
Remove most of our C-style casts.
After being burned by an incorrect C-style cast that cast away const, I've been
keen to remove them all and turn on -Wold-style-cast. This patch doesn't get us
that far, but it does kill the majority of our C-style casts. In turn, the
majority of the casts that it removes are the ones from our tables of native
methods to be registered.
The new NATIVE_METHOD macro also _enforces_ our convention of using the
"Class_nativeMethod" style of naming. Mostly this works out fine. In some
cases (most notably ExpatParser and ExpatAttributes) I've had to un-overload
a few functions, but I don't like overloading anyway, and in the particular
case of a native method, where the stack trace doesn't show a line number,
overloading makes it one step harder to work out which native method you're
actually in. So good riddance to that. The only unfortunate case is
Math.copySign, where there are two overloads corresponding to copysign(3)
and copysignf(3). I had to add an extra layer of indirection there. In my
defense, we've never shipped these functions before, they're unlikely to
become anyone's hotspot, and the right fix is to be doing such trivial work
on the Java side anyway, with intrinsics making the conversion between
float/double and int/long cheap.
This patch also replaces other C-style casts, primarily in
"OSNetworkSystem.cpp".
This patch also removes unnecessary uses of the "struct" keyword.
This patch also fixes a "may be used uninitialized" warning (now error) in
the sim build for "ICU.cpp".
The remaining C-style casts are in the hairy float-parsing code. That stuff --
and turning on -Wold-style-cast -- will have to wait for another day.
Change-Id: I9b3ee14aefd4676f980f6a7ca757595d78d80e6a
Elliott Hughes [Thu, 12 Aug 2010 22:54:56 +0000 (15:54 -0700)]
Clean up our final native code warnings, and turn on -Werror.
Change-Id: I54bb29e357812b089e83f3a2a831c80f5114a27a
Elliott Hughes [Thu, 12 Aug 2010 21:17:48 +0000 (14:17 -0700)]
Replace createDatagramSocket and createStreamSocket with one call.
(Continuing our policy of having native methods' names correspond to the
underlying syscall, this one sadly gets the ugly name of "socket".)
Change-Id: Icf08e4e0637ee3ae9eab673d350860181f547250
Elliott Hughes [Thu, 12 Aug 2010 20:53:06 +0000 (13:53 -0700)]
Merge "Minor documentation improvements." into dalvik-dev
Elliott Hughes [Thu, 12 Aug 2010 18:30:50 +0000 (11:30 -0700)]
Minor documentation improvements.
Fix unqualified uses of SimpleDateFormat in TimeZone.java, explain how to use
getPercentageInstance (http://code.google.com/p/android/issues/detail?id=10333),
add an explicit test to make sure no-one accidentally "fixes" that
odd-but-correct behavior, and remove an example from the DecimalFormat
documentation that doesn't really clarify anything.
Bug: http://code.google.com/p/android/issues/detail?id=10333
Change-Id: I52f22d817c7c6c32ad38fb6953fbe909a76f8943
Elliott Hughes [Thu, 12 Aug 2010 17:43:59 +0000 (10:43 -0700)]
Merge "Remove createServerStreamSocket as a native special case." into dalvik-dev
Jesse Wilson [Thu, 12 Aug 2010 00:03:26 +0000 (17:03 -0700)]
Use the declaring class loader when resolving types for reflection.
Previously we were using the calling class loader, which was completely
unrelated to solving the problem at hand.
Also splitting the test for an issue unrelated to class loaders into
its own test.
Change-Id: I5fa9f34cac0d6a76db7fdf3e7bcbe19b57281971
Elliott Hughes [Wed, 11 Aug 2010 23:53:48 +0000 (16:53 -0700)]
Remove createServerStreamSocket as a native special case.
We can do everything in Java.
Change-Id: I7451319335a647fc25bd2d2403fa98bfc6b5c038
Elliott Hughes [Wed, 11 Aug 2010 23:09:37 +0000 (16:09 -0700)]
Clean up some dead/useless code.
(The DatagramPacketTest.java change is unrelated, but it's been lurking in my
repository for weeks now.)
Change-Id: I65d3ad53dd30709b2daed3c5787cc38c6081ffea
Jesse Wilson [Wed, 11 Aug 2010 22:21:19 +0000 (15:21 -0700)]
Sorting imports.
Change-Id: I8347bc625480a1c37a1ed9976193ddfedeb00bbc
Jesse Wilson [Wed, 11 Aug 2010 21:14:10 +0000 (14:14 -0700)]
Merge "Fixing ListOfTypes to not null-out its types." into dalvik-dev
Jesse Wilson [Wed, 11 Aug 2010 01:03:12 +0000 (18:03 -0700)]
Fixing ListOfTypes to not null-out its types.
http://code.google.com/p/android/issues/detail?id=6636
Change-Id: I164046e868fb72a76b8b2ad2729e97229129ea39
Elliott Hughes [Wed, 11 Aug 2010 18:12:20 +0000 (11:12 -0700)]
Merge "Improve the performance of TimeZone.getTimeZone." into dalvik-dev
Elliott Hughes [Tue, 10 Aug 2010 23:19:31 +0000 (16:19 -0700)]
Improve the performance of TimeZone.getTimeZone.
Rewrite the code that reads time zone data so that rather than opening,
reading, and closing the file each time, we just keep the file mapped.
This patch actually removes functionality: we no longer support reading
individual Unix time zone data files.
Also stop cloning guaranteed-new instances returned by ZoneInfoDB.
Before:
benchmark us logarithmic runtime
TimeZone_getDefault 9.85 =
TimeZone_getTimeZoneUTC 211.40 =====================
TimeZone_getTimeZone_America_Caracas 437.87 ==========================
TimeZone_getTimeZone_America_Santiago 783.29 ==============================
TimeZone_getTimeZone_GMT_plus_10 181.80 ====================
TimeZone_getTimeZone_default 194.78 ====================
After:
benchmark us logarithmic runtime
TimeZone_getDefault 10.8 =
TimeZone_getTimeZoneUTC 70.9 =============
TimeZone_getTimeZone_America_Caracas 118.9 =================
TimeZone_getTimeZone_America_Santiago 797.5 ==============================
TimeZone_getTimeZone_GMT_plus_10 57.8 ============
TimeZone_getTimeZone_default 72.2 =============
(Note that these have very different scales.)
Bug:
2870945
Change-Id: Iae5aa86153006d4de8e7278d30bcaeef6a9ccab7
Jesse Wilson [Wed, 11 Aug 2010 00:14:46 +0000 (17:14 -0700)]
Fix an obsolete test suppression
Change-Id: Id7cd798db349db1e25f7788c80a1bb0565d33468
Jesse Wilson [Tue, 10 Aug 2010 22:07:34 +0000 (15:07 -0700)]
Moving tests to be under the libcore.* package.
This is indended to make it easier to run on VMs that restrict the packages
from which application classes can be loaded. For example, on the RI you need
to use the bootclasspath to load these tests.
Change-Id: I52193f35c5fcca18b5a3e1d280505b1e29b388af
Elliott Hughes [Tue, 10 Aug 2010 21:35:43 +0000 (14:35 -0700)]
Merge "Minor TimeZone cleanup." into dalvik-dev
Jesse Wilson [Tue, 10 Aug 2010 21:33:54 +0000 (14:33 -0700)]
Merge "Adding a test for bug 10111 in getGenericSuperclass" into dalvik-dev
Elliott Hughes [Tue, 10 Aug 2010 20:41:52 +0000 (13:41 -0700)]
Minor TimeZone cleanup.
Getting ready to do some real work here, I thought I'd improve the
documentation and remove some cruft.
Bug:
2870945
Change-Id: I771badc8afa5c0a5f77880f64e1542d77672d984
Jesse Wilson [Tue, 10 Aug 2010 18:45:18 +0000 (11:45 -0700)]
Adding a test for bug 10111 in getGenericSuperclass
Change-Id: I0b9bc49482dd348d458eaef96b718209e5d90eb6
Elliott Hughes [Tue, 10 Aug 2010 01:39:07 +0000 (18:39 -0700)]
Merge "Make network I/O interruptible." into dalvik-dev
Elliott Hughes [Sat, 7 Aug 2010 01:12:14 +0000 (18:12 -0700)]
Make network I/O interruptible.
Every thread about to block on network I/O registers its thread id and
the fd it's going to block on. In close, we scan the list and signal
every thread that's blocked on the fd we're closing. They wake up with
EINTR, see that their java.io.FileDescriptor has been invalidated (by
the close code), and infer that this EINTR is not to be retried: this
EINTR implies that they should throw.
This patch also fixes a couple of bugs in accept. We were trying (and,
obviously, failing) to reset SO_RCVTIMEO on fd -1 if the accept failed,
and then throwing an exception relating to that rather than the failed
accept(2). We were also not treating timeouts as a special case of
failure and throwing the appropriate SocketTimeoutException. (One has
to suspect that there's an errno-to-Exception function that we could
write that would work for all this native code.)
This patch also cleans up connect a little more. I've inlined doConnect
into its single caller, I've removed the bogus use of 100ms polling,
and I've rewritten the checking for success/failure to be based on the
advice in Stevens' "Unix Network Programming".
Bug:
2823977
Change-Id: I4f0cbd95be9ba25368be166008855a80c5d30845
Jesse Wilson [Mon, 9 Aug 2010 22:15:29 +0000 (15:15 -0700)]
Merge "Test that InputStreamReader doesn't block unnecessarily." into dalvik-dev
Jesse Wilson [Mon, 9 Aug 2010 21:57:50 +0000 (14:57 -0700)]
Test that InputStreamReader doesn't block unnecessarily.
See http://code.google.com/p/android/issues/detail?id=10252
Change-Id: I05f68151a35eb16b5c9165ac4ae211c92ddaacf1
Mike Lockwood [Mon, 9 Aug 2010 18:44:36 +0000 (11:44 -0700)]
am
4ea56d66: Create new files with permissions 0666 instead of 0777
Merge commit '
4ea56d66e19d1450960ba26f60ca61a6804a3ba7' into dalvik-dev
* commit '
4ea56d66e19d1450960ba26f60ca61a6804a3ba7':
Create new files with permissions 0666 instead of 0777
Mike Lockwood [Mon, 9 Aug 2010 18:30:36 +0000 (14:30 -0400)]
Create new files with permissions 0666 instead of 0777
Change-Id: Ia37b12cac4baadd712dd29a1bc0692cb5163943e
Signed-off-by: Mike Lockwood <lockwood@android.com>
Jesse Wilson [Fri, 6 Aug 2010 00:57:32 +0000 (17:57 -0700)]
Support multihomed addresses in HttpURLConnection.
See http://b/
2876927
Change-Id: I13138109d3648cf8a86d07136337b820c94b500a
Elliott Hughes [Fri, 6 Aug 2010 21:32:24 +0000 (14:32 -0700)]
Merge "Rationalize and simplify our "connect" implementations." into dalvik-dev
Elliott Hughes [Thu, 5 Aug 2010 04:31:16 +0000 (21:31 -0700)]
Rationalize and simplify our "connect" implementations.
We don't need to copy a context structure back and forth between native code
and Java: it didn't contain anything but temporaries anyway. We don't need a
convenience method for a blocking connect with no timeout. We don't need a
separate codepath for datagram and stream sockets' connect calls.
There are further simplifications that could be made, I think. I think we
could implement "connect" in Java in terms of "connectNonBlocking" and
"isConnected" (since that's how our native implementation works anyway).
I also think we can fix the 100ms polling too, though I haven't investigated
and that may require that we fix the general "interrupt on close" problem.
Change-Id: Ib5989fa05f5dd7dd24b681fab70f856cd0bc5c56
Mike Lockwood [Fri, 6 Aug 2010 00:52:35 +0000 (17:52 -0700)]
am
787bd9e6: Fix random permissions being set for new files.
Merge commit '
787bd9e6c46da7e229db6450d94409d2c6da6c2b' into dalvik-dev
* commit '
787bd9e6c46da7e229db6450d94409d2c6da6c2b':
Fix random permissions being set for new files.
Mike Lockwood [Fri, 6 Aug 2010 00:33:05 +0000 (20:33 -0400)]
Fix random permissions being set for new files.
When creating new files, set permission to 0777 and let the
umask adjust it for us if necessary.
Change-Id: I85cb895200f5a6e85d61e38c992fb9e9acda568c
Signed-off-by: Mike Lockwood <lockwood@android.com>
Brian Carlstrom [Thu, 5 Aug 2010 19:17:43 +0000 (12:17 -0700)]
am
578c4cbb: am
753597d5: Merge remote branch \'goog/dalvik-dev\' into dalvik-dev-to-gingerbread
Merge commit '
578c4cbbda479989790f1075f1e8f63fde1e2a92' into dalvik-dev
* commit '
578c4cbbda479989790f1075f1e8f63fde1e2a92':
Mike Lockwood [Thu, 5 Aug 2010 19:11:12 +0000 (12:11 -0700)]
am
9b211124: Remove restricted permissions in file and directory creation
Merge commit '
9b211124283bfb808e902b91da4df3e291d9bb6c' into dalvik-dev
* commit '
9b211124283bfb808e902b91da4df3e291d9bb6c':
Remove restricted permissions in file and directory creation
Brian Carlstrom [Thu, 5 Aug 2010 19:10:29 +0000 (12:10 -0700)]
am
753597d5: Merge remote branch \'goog/dalvik-dev\' into dalvik-dev-to-gingerbread
Merge commit '
753597d51e673c914930659b52952618c335dc4b'
* commit '
753597d51e673c914930659b52952618c335dc4b':
Rewrite the nio Pipe to use a Unix pipe behind the scenes.
Stop GCC from outsmarting me.
Support for TLS Extensions enabled SSLSockets with fallback to vanila SSL
Remove "java.net.preferIPv4Stack" (which has been broken >= eclair).
Bring URLConnection.guessContentTypeFromName in line with Chrome.
Remove a bogus test that's been removed upstream.
Fix setTrafficClass.
Fix for poorly compiling documentation
Fix setSoLinger.
EnumMap.toString throws NPE
Mike Lockwood [Thu, 5 Aug 2010 15:23:26 +0000 (11:23 -0400)]
Remove restricted permissions in file and directory creation
This will allow us to use umask to control default permissions instead.
Since all application private files are created in a protected super-directory
this is now longer needed for the application security model.
BUG:
2856892
Change-Id: I8cce311016fdfacdb4bd8a28d1e674844aedb49a
Signed-off-by: Mike Lockwood <lockwood@android.com>
Brian Carlstrom [Wed, 4 Aug 2010 22:37:22 +0000 (15:37 -0700)]
Merge remote branch 'goog/dalvik-dev' into dalvik-dev-to-gingerbread
Elliott Hughes [Wed, 4 Aug 2010 18:54:05 +0000 (11:54 -0700)]
Add a comment I meant to include in PipeImpl.
Change-Id: I1e54c5b73fbc73fbc20f3782c207c04343849455
Elliott Hughes [Wed, 4 Aug 2010 17:44:16 +0000 (10:44 -0700)]
Rename setNonBlocking to setBlocking.
This makes the boolean argument less confusing.
Change-Id: Ic226f6d3c5afe8e15a95e74917656424f8a448fe
Elliott Hughes [Wed, 4 Aug 2010 01:52:29 +0000 (18:52 -0700)]
Merge "Rewrite the nio Pipe to use a Unix pipe behind the scenes." into dalvik-dev
Elliott Hughes [Wed, 4 Aug 2010 00:13:53 +0000 (17:13 -0700)]
Rewrite the nio Pipe to use a Unix pipe behind the scenes.
We were using an AF_INET or AF_INET6 socket to implement the nio Pipe, which
was causing trouble for people on systems where IPv6 wasn't working yet.
This patch switches over to pipe(2). My first implementation used socketpair(2)
and retained the SocketChannelImpls, but it still seemed a bit off to be asking
for a full-duplex pipe to implement a unidirectional channel, and it required
hacks in the networking code to cope with the AF_LOCAL family, and in the
BlockGuard for the isLingeringSocket test.
This implementation uses pipe(2) and FileChannelImpl. It breaks a few tests, but
the tests are wrong, and it actually brings us closer to the RI's behavior of
throwing IOException "broken pipe" when writing to a broken pipe.
Rather than keep throwing junk into the FileSystem/NetworkSystem classes, and
resolving the question of which of those setNonBlocking belonged in (answer:
neither; this is a false Windows-style dichotomy that isn't helpful here), I've
added a new IoUtils with a few generally useful methods. The remainder of this
patch switches over existing code. We could probably make
FileDescriptor.descriptor private now I've exposed accessors, but this change
is large enough already...
Bug:
2735373
Bug: http://code.google.com/p/android/issues/detail?id=9431
Change-Id: I6b6d1e50bdddd435e71c31105a73c9d4fd135d7e
Brian Carlstrom [Tue, 3 Aug 2010 18:24:23 +0000 (11:24 -0700)]
Merge "Support for TLS Extensions enabled SSLSockets with fallback to vanila SSL" into dalvik-dev
Elliott Hughes [Tue, 3 Aug 2010 17:58:48 +0000 (10:58 -0700)]
Merge "Stop GCC from outsmarting me." into dalvik-dev
Elliott Hughes [Tue, 3 Aug 2010 01:34:11 +0000 (18:34 -0700)]
Stop GCC from outsmarting me.
I accidentally wrote:
memcpy(&result, cast<const T*>(srcAddress), sizeof(T));
instead of:
memcpy(&result, cast<const void*>(srcAddress), sizeof(T));
And GCC decided that, since doubles must be 8-byte aligned on ARM, this could be
translated into the very code I was trying to avoid:
e9d2 0100 ldrd r0, r1, [r2]
Fixing the cast fixes the generated code to use the direct access if my
explicit test shows that the address is aligned, but uses memcpy otherwise:
0: f012 0f07 tst.w r2, #7 ; 0x7
4: b507 push {r0, r1, r2, lr}
6: d102 bne.n e <_ZL18OSMemory_getDoubleP7_JNIEnvP8_jobjecti+0xe>
8: e9d2 0100 ldrd r0, r1, [r2]
c: e006 b.n 1c <_ZL18OSMemory_getDoubleP7_JNIEnvP8_jobjecti+0x1c>
e: 4611 mov r1, r2
10: 4668 mov r0, sp
12: 2208 movs r2, #8
14: f7ff fffe bl 0 <memcpy>
18: e9dd 0100 ldrd r0, r1, [sp]
1c: b003 add sp, #12
1e: bd00 pop {pc}
Change-Id: Ic0ddaca8bb24bea76f967ecfe2a159d8b0fe1216
Elliott Hughes [Tue, 3 Aug 2010 17:25:04 +0000 (10:25 -0700)]
resolved conflicts for merge of
7b3ebefc to dalvik-dev
Change-Id: I7bb0341107f0b3f5b568d151f062e30f61e5ee14
Brian Carlstrom [Thu, 22 Jul 2010 23:33:48 +0000 (16:33 -0700)]
Support for TLS Extensions enabled SSLSockets with fallback to vanila SSL
See also b/
1569612
Summary:
- OpenSSlSocket support for SNI, session tickets, compression
- URLConnection mimics Chrome behavior of trying connection with these enabled,
falling back to SSL w/o encryption on failure
Details:
libcore
URLConnection https retry
Change HttpConnection.getSecureSocket to enable non-standard features on first
connection attempt. On second attempt, we back off to SSLv3 from
TLSv1, mimicking Chrome's behavior.
luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpConnection.java
Change HttpsEngine.connect to implement SSL reconnect
luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/HttpsURLConnectionImpl.java
OpenSSL SSLSocket implementation
OpenSSLSocketImpl and OpenSSLServerSocketImpl now have an array of
enabled compression methods interface and implementation to
parallel that of procotols and ciphersuites.
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLServerSocketImpl.java
OpenSSLSessionImpl now has a cache of the native
compressionMethod. Also replaced "gives" javadoc working with
"returns".
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSessionImpl.java
OpenSSLSocketImpl session caching now needs to skip cached
sessions with mismatched compression requirements.
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java
OpenSSLSocketImpl.startHandshake now uses NativeCrypto to support
our non-standard extensions.
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java
NativeCrypto changes
- Added declaration of SSL options for tickets and compression.
- Added general "compression methods" interface
paralleling "cipher suites" and "protocols" interfaces.
- Added SSL_set_tlsext_host_name to set SNI (Server Name Indication) value
- Added SSL_get_servername to read SNI (Server Name Indication) value
- Added SSL_SESSION_compress_meth read negotiated compression method
- SSL_new makes sure to default compression to off for compatibility
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/NativeCrypto.java
luni/src/main/native/NativeCrypto.cpp
Testing
Added URLConnectionTest.testConnectViaHttpsWithSSLFallback to make
sure we properly retry an https connection if the server
terminates unexpectedly. Fixed up
URLConnectionTest.testHttpsWithCustomTrustManager with new
expected certificate chain. Fixed a few mistaken
TestSSLContext.serverContext uses to clientContext
luni/src/test/java/java/net/URLConnectionTest.java
Added test_SSL_set_tlsext_host_name, test_SSL_get_servername,
test_SSL_SESSION_compress_meth. Added a number of missing fail()
calls in expected exception cases which caught one test with
mistaken expectations. Removed some unnecessary scopes. Fixed some
badly scoped catch blocks.
luni/src/test/java/org/apache/harmony/xnet/provider/jsse/NativeCryptoTest.java
Changed MockWebServer to support a new MockResponse propery of
disconnectAtStart, which immediately terminates the connection
support/src/test/java/tests/http/MockResponse.java
support/src/test/java/tests/http/MockWebServer.java
external/openssl
Restore -ZLIB to OpenSSL build. Note that NativeCrypto.SSL_new
disables compression by for default SSLSocket for compatibility.
android-config.mk
Force clean build with new CFLAGS
CleanSpec.mk
Change-Id: Iba6268f9096f2be43f0d30de151dd3fd0aea4a81
Elliott Hughes [Mon, 2 Aug 2010 20:35:47 +0000 (13:35 -0700)]
Use the existing mime-type/extension mapping from frameworks/base.
(An accompanying change to frameworks/base switches that over so that both
android.webkit.MimeTypeMap and java.net.URLConnection use the same data.)
Bug:
2422917
Bug: http://code.google.com/p/android/issues/detail?id=10100
Change-Id: I37f008a00093efcf7b336ea0c206e8977544b0bf
Elliott Hughes [Sat, 31 Jul 2010 01:16:45 +0000 (18:16 -0700)]
Remove "java.net.preferIPv4Stack" (which has been broken >= eclair).
Change-Id: I4733a0e266ff7c02c25033e79bcceff4d7357868
Brad Fitzpatrick [Sat, 31 Jul 2010 19:11:21 +0000 (12:11 -0700)]
am
2ceb1614: Merge commit \'
1a529c16\' into manualmerge
Merge commit '
2ceb16144eefd78537059f0b6ad97267e843ae57' into dalvik-dev
* commit '
2ceb16144eefd78537059f0b6ad97267e843ae57':
BlockGuard: don't complain about non-linger network close()
Brad Fitzpatrick [Sat, 31 Jul 2010 00:29:09 +0000 (17:29 -0700)]
Merge commit '
1a529c16' into manualmerge
Conflicts:
dalvik/src/main/java/dalvik/system/BlockGuard.java
Change-Id: I13e177da1f307c0f784f783c934fa4a08f6407e0
Brad Fitzpatrick [Sat, 31 Jul 2010 00:19:00 +0000 (17:19 -0700)]
am
20705dde: BlockGuard: don\'t complain about non-linger network close()
Merge commit '
20705dde359602364114b0cfb4135bc9fcf42038' into gingerbread-plus-aosp
* commit '
20705dde359602364114b0cfb4135bc9fcf42038':
BlockGuard: don't complain about non-linger network close()
Brad Fitzpatrick [Fri, 30 Jul 2010 23:00:10 +0000 (16:00 -0700)]
BlockGuard: don't complain about non-linger network close()
Change-Id: I4a5d6383f821d0c161206684ed14d7fd4781938b
Elliott Hughes [Fri, 30 Jul 2010 22:30:17 +0000 (15:30 -0700)]
Bring URLConnection.guessContentTypeFromName in line with Chrome.
Bug: http://code.google.com/p/android/issues/detail?id=10100
Change-Id: Ibd53f3450eda9c5dbad9e4b0b661cc98e8f578e4
Elliott Hughes [Fri, 30 Jul 2010 17:58:38 +0000 (10:58 -0700)]
Remove a bogus test that's been removed upstream.
Change-Id: Ib385a381944ee1a14c13e83ea6c9444c00c53982
Elliott Hughes [Thu, 29 Jul 2010 23:12:45 +0000 (16:12 -0700)]
Merge "Fix setTrafficClass." into dalvik-dev
Elliott Hughes [Thu, 29 Jul 2010 21:03:10 +0000 (14:03 -0700)]
Fix setTrafficClass.
Pass the traffic class setting down to the kernel, rather than trying to
fake it in Java and then not actually using it at all in the native code.
There are two ways to set traffic class (aka type of service, or TOS):
per-packet or per-socket. The Java API is for the per-socket style, but
the old implementation had each SocketImpl intercept calls to
SocketOptions.setOption for SocketOptions.IP_TOS, stash the traffic class
in one of the SocketImpl's private fields, skip calling native code, and
then pass the traffic class to each native method that would need it to
implement the per-packet style. Unfortunately, each of those methods was
just ignoring the traffic class.
I've removed all this interception, so we now pass the traffic class straight
to the kernel via setsockopt(2), and we don't need to pass anything to the
individual per-packet calls.
The motivation for going the per-packet route appears to have been to work
around a lack of support for the per-socket route in old versions of Linux
and other OSes. It all works now, though, so there's no point making our
lives harder (and doing more work at runtime) to work around bugs and
infelicities that no longer exist.
I tested the new code manually with tcpdump, for both IPv4 (radio) and
IPv6 (wifi), and in both cases it looks like it's doing the right thing now.
We also still pass all of our tests, though none of them are capable of
recognizing whether we're actually doing anything useful anyway...
Change-Id: Ice241e088d25037123c73733a3f2bfade976fb31
Ben Dodson [Thu, 29 Jul 2010 18:41:42 +0000 (11:41 -0700)]
Fix for poorly compiling documentation
Change-Id: I6077052df3cf6ba1f977aa312552ef8fe43bd56c
Elliott Hughes [Tue, 27 Jul 2010 01:08:32 +0000 (18:08 -0700)]
Fix setSoLinger.
The bizarre use of Boolean or Integer (rather than just using -1) comes
from the RI. Third-party SocketImpl implementations may expect the RI's
documented behavior, so we should probably do the same.
I've also changed SocketChannelImpl.SocketAdapter to reuse Socket's
implementation of all the socket option getting/setting code, mainly so
we don't have two copies of all the weirdness.
I've also fixed a bug in the native getSocketOption code which returned
a Boolean rather than an Integer for IP_TOS/IPV6_TCLASS, though that code
is actually never called at the moment.
I've removed support for passing Byte values to setSocketOption. The RI
only uses Boolean and Integer.
Change-Id: I80ba63745f4c4f3ac357dc3f0b7cbf254a291bce
Brian Carlstrom [Thu, 29 Jul 2010 15:55:59 +0000 (08:55 -0700)]
am
06f47d3e: Merge remote branch \'goog/dalvik-dev\' into dalvik-dev-to-master
Merge commit '
06f47d3e721e7032c97f80b3b2c7d25a8e6f2d21' into dalvik-dev
* commit '
06f47d3e721e7032c97f80b3b2c7d25a8e6f2d21':
Brian Carlstrom [Wed, 28 Jul 2010 23:23:02 +0000 (16:23 -0700)]
Merge remote branch 'goog/dalvik-dev' into dalvik-dev-to-master
Change-Id: I9687c2ef06dc2bd1ba573bf40ec00236c25e558f
Ben Dodson [Thu, 29 Jul 2010 00:33:18 +0000 (17:33 -0700)]
EnumMap.toString throws NPE
Fix for bug:
2787265
Change-Id: I56f9a2c7088f5263b26e93be1a3a28903c9e49cd
Elliott Hughes [Wed, 28 Jul 2010 18:24:09 +0000 (11:24 -0700)]
Remove the unnecessary "Impl" suffix from setFloatArray.
Change-Id: I2eea809c7b441ed3c596e2b945e7897ccc15c10c
Elliott Hughes [Wed, 28 Jul 2010 18:15:46 +0000 (11:15 -0700)]
resolved conflicts for merge of
01a18c74 to dalvik-dev
Change-Id: Ib569414191a6e7b0e7aebb804fe1f4d57c5184a9
Elliott Hughes [Wed, 28 Jul 2010 17:46:34 +0000 (10:46 -0700)]
resolved conflicts for merge of
fb4045a3 to master
Change-Id: I2100c70f6078108e7b646c393ac2e4b42ca8d066
Owen Lin [Wed, 28 Jul 2010 17:18:48 +0000 (10:18 -0700)]
am
bfb0099c: Improve putFloatArray performance
Merge commit '
bfb0099cc4c8eca744eeda0f20e5b3644f1a4cb9' into gingerbread-plus-aosp
* commit '
bfb0099cc4c8eca744eeda0f20e5b3644f1a4cb9':
Improve putFloatArray performance
Brian Carlstrom [Tue, 27 Jul 2010 01:13:20 +0000 (18:13 -0700)]
Fix SecureRandom default service
Further profiling revealed a bug in the early performance fix which
was always returning null because it the Services.getService interface
expected SecureRandom.<algorithm>, not just SecureRandom.
However, the basic idea of using the precomputed Services approach was
sound. Services.refresh now calculates the default SecureRandom
services as a special case.
Confirmed that the RI also has this apparently undocumented behavior
of defaulting the SecureRandom to the highest priority provider that
has an available implementation.a
Change-Id: Icf3be52e5d9113b0940cd38522857ba7e339a60f
Elliott Hughes [Mon, 26 Jul 2010 22:03:57 +0000 (15:03 -0700)]
Let the kernel handle network timeouts by setting SO_RCVTIMEO.
As far as I can tell, the reason other implementations use select(2)
instead of SO_RCVTIMEO is that traditionally the latter wasn't implemented.
Stevens is unusually unspecific about the portability of SO_RCVTIMEO, but
the web says that Linux didn't support it until 2.4, and Solaris was late
and buggy too. Modern versions of Linux, Mac OS, and Windows all support
SO_RCVTIMEO, though, so portability should not be a concern for us.
This patch causes a regression; several of the blocking network I/O methods
that used to be interruptible by virtue of their select(2)-based manual
implementation of timeouts are no longer interruptible. Making all network
I/O interruptible is work in progress, covered by http://b/
2823977.
Bug: http://b/
2512069
Change-Id: I0a2812ca1537bd171c4205343d6b3b526b72b2b2
Elliott Hughes [Mon, 26 Jul 2010 21:17:41 +0000 (14:17 -0700)]
Merge "Better detail messages for exceptions thrown when converting between byte[]/InetAddress." into dalvik-dev
Elliott Hughes [Mon, 26 Jul 2010 21:13:55 +0000 (14:13 -0700)]
Better detail messages for exceptions thrown when converting between byte[]/InetAddress.
Change-Id: I0e87b0ed6487f8434435027ee70ec294c98617e8
Brian Carlstrom [Sat, 24 Jul 2010 08:21:28 +0000 (01:21 -0700)]
SecureRandom constructor performance improvement
The SecureRandom constructor was iterating all service providers to
find an implementation (the providers are in priority order). Changed
to use Service.getService which respects the priority but is a hash
lookup instead of a linear search.
This problem was brought to light when the Harmony provider was moved
after the BouncyCastle provider, making the search take much longer.
b/
2748913
Change-Id: I44a4928bf80c81745d3bbbd510b48b3d0d6ad70e
Owen Lin [Fri, 11 Jun 2010 06:10:41 +0000 (14:10 +0800)]
Improve putFloatArray performance
Change-Id: I04b43a2be6409329408d74af7ff0f0b2b60cc96d
Elliott Hughes [Sat, 24 Jul 2010 00:17:27 +0000 (17:17 -0700)]
Fix available() to throw on a closed Socket's InputStream.
Change-Id: If9163301d18f7c0a11af08da6017840aa1bf4f38
Elliott Hughes [Fri, 23 Jul 2010 22:25:25 +0000 (15:25 -0700)]
Merge "Fix multicast TTL (and loopback)." into dalvik-dev
Jean-Baptiste Queru [Fri, 23 Jul 2010 22:09:48 +0000 (15:09 -0700)]
am
ee57aef0: resolved conflicts for merge of
67ca373a to master
Merge commit '
ee57aef0ce4d4460e1c4072f67014d68112528fe' into dalvik-dev
* commit '
ee57aef0ce4d4460e1c4072f67014d68112528fe':
Bugs when connecting a SocketChannel registered in a Selector
Elliott Hughes [Fri, 23 Jul 2010 22:04:14 +0000 (15:04 -0700)]
Fix multicast TTL (and loopback).
We generally create AF_INET6 sockets. These work for both IPv6 and IPv4
communication. Typically, we'll be using them for IPv4. Unfortunately,
if we've only set IPPROTO_IPV6 socket options, they won't be used for
IPv4 communication. We need to set the IPPROTO_IP equivalents too. This
patch fixes our behavior for IP_MULTICAST_TTL/IPV6_MULTICAST_HOPS and
IP_MULTICAST_LOOP/IPV6_MULTICAST_LOOP.
Also switch to consistently using AF_ constants with socket(2). Stevens
recommends we just pretend the PF_ constants don't exist.
Also remove the useless REUSEADDR_AND_REUSEPORT constant, and fix some
of the C++ constant names to match the Java constant names.
Bug: http://code.google.com/p/android/issues/detail?id=9813
Change-Id: I31664198824291f2a13a7d72a9d64f12621e3415
Jean-Baptiste Queru [Fri, 23 Jul 2010 19:44:48 +0000 (12:44 -0700)]
resolved conflicts for merge of
67ca373a to master
Change-Id: I01a4b6b0a73066e9a8119a66d07c43839079b4c9
Marc Petit-Huguenin [Fri, 23 Jul 2010 19:33:38 +0000 (12:33 -0700)]
am
b960e1a9: Bugs when connecting a SocketChannel registered in a Selector
Merge commit '
b960e1a9d80af9536f77172cbe3932c3afc7e7e4' into gingerbread-plus-aosp
* commit '
b960e1a9d80af9536f77172cbe3932c3afc7e7e4':
Bugs when connecting a SocketChannel registered in a Selector
Elliott Hughes [Fri, 23 Jul 2010 01:46:47 +0000 (18:46 -0700)]
Remove UCharacter's unnecessary layer of indirection.
Also fix this sim-eng build failure:
libcore/luni/src/main/native/org_apache_harmony_luni_platform_OSMemory.cpp: In function ‘jint OSMemory_flushImpl(JNIEnv*, _jobject*, jint, jlong)’:
libcore/luni/src/main/native/org_apache_harmony_luni_platform_OSMemory.cpp:334: error: invalid conversion from ‘const void*’ to ‘void*’
libcore/luni/src/main/native/org_apache_harmony_luni_platform_OSMemory.cpp:334: error: initializing argument 1 of ‘int msync(void*, size_t, int)’
Change-Id: Ia23c9af79c690254179139072b84bd0a35f17fba
Elliott Hughes [Fri, 23 Jul 2010 01:10:24 +0000 (18:10 -0700)]
Remove more of our C-style casts, fix more of our native method names.
Change-Id: I08d7915e22faf091489171240d2f9bf8b3acecca
Marc Petit-Huguenin [Fri, 16 Jul 2010 23:18:01 +0000 (16:18 -0700)]
Bugs when connecting a SocketChannel registered in a Selector
See http://code.google.com/p/android/issues/detail?id=6309
Bug fixed in org.apache.harmony.nio.internal.SelectorImpl by verifying
that there is a connection pending when adding a writable FD to the
internal list of readyKeys.
A unit test is also provided in java.nio.SelectorTest.
Change-Id: Icf47e81b3bcc299608d0672365daf797e44cdfdd
Elliott Hughes [Thu, 22 Jul 2010 22:06:54 +0000 (15:06 -0700)]
Consistently use POSIX O_NONBLOCK instead of FIONBIO.
Change-Id: I395012f0e51e1928e720d09d0f44b7d5085b01a3
Elliott Hughes [Thu, 22 Jul 2010 21:07:37 +0000 (14:07 -0700)]
Remove C-style casts from our expat JNI.
Also move more native methods' function names over to the predominant
"Class_methodName" orthography.
Change-Id: I12a7aa8c98726b478617b56a071196a38ada4e09
Elliott Hughes [Thu, 22 Jul 2010 18:32:38 +0000 (11:32 -0700)]
Merge "Remove many of our C-style casts." into dalvik-dev
Brian Carlstrom [Tue, 20 Jul 2010 21:28:07 +0000 (14:28 -0700)]
Bring SSLSocketImpl and SSLEngine in line with OpenSSLSocketImpl's cipher suites
Wrote an interoperability test between our OpenSSL and SSLEngine
based SSLSocket implementations. Used it to flush out problems between
the implementations, which mostly were in the non-native implementation.
Filling out the SSLEngine (and therefore non-native SSLSocket) support
led to the list of supported and default cipher suites now being the
same as out OpenSSL SSLSocket. Most of the work was making the the
NULL, RC4, and AES ciphers work with SSLEngine as well as some minor
bug fixes in related code.
Summary:
- changing test_SSLSocket_getSupportedCipherSuites_connect to try all
combinations of our two SSLContext/SSLSocket implementations
- fixed SSLEngine with *_WITH_NULL_* CipherSuites to use javax.crypto.NullCipher
- added *_AES_* cipher suites to SSLEngine (and therefore Java SSLSocketImpl)
- remove *_DH_* cipher suites which are not supported by the RI or our OpenSSL implementation
- fixed Java SSLSocket to not handshake on accept so will pass the basic SSLSocketTest
- added new KeyManagerFactoryTest while testing "DH_" cipher suite key types
This change depends on restoring bouncycastle's RC4 implementation (separate CL in external/bouncycastle)
Details:
Fixed SSLEngine with *_WITH_NULL_* CipherSuites by use javax.crypto.NullCipher
expectations/knownfailures.txt
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/ConnectionStateSSLv3.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/ConnectionStateTLS.java
Previously I had changed the string name of CipherSuites from
"TLS_..." to "SSL_..." where appropriate to match the RI. Since I was
doing maintenance on overall list, I renamed the CODE_TLS_... and
TLS_... static fields as well to match.
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/CipherSuite.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSessionImpl.java
Removed IDEA and RC2 CipherSuites to make it clear they are not
supported. While technically this happened as a side effect of the
assignment "supported = false" if the CipherSuite failed to load, we
truly intend not to support these. Also removed SSH_DH_* suites which
don't work with DSA keys and aren't supported by the RI or our OpenSSL
implementation.
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/CipherSuite.java
Old connection state code assumed that if a cipher was blocked, the
block size was 8 bytes. This is not true for the 16 byte AES ciphers.
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/ConnectionState.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/ConnectionStateSSLv3.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/ConnectionStateTLS.java
No wonder our OpenSSL implementation incorrect did a startHandshake
when accepting the socket... it got it from the Java implementation.
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLServerSocketImpl.java
Test for KeyManagerFactory (and KeyManager). TestKeyStore now creates
KeyManagers and TrustManagers from the keystore as a convenience for
KeyManagerFactoryTest (instead of having the code in the
TestSSLContext where we didn't keep a pointer to the created values).
luni/src/test/java/javax/net/ssl/KeyManagerFactoryTest.java
support/src/test/java/java/security/StandardNames.java
support/src/test/java/java/security/TestKeyStore.java
support/src/test/java/javax/net/ssl/TestSSLContext.java
Remove CIPHER_SUITES_SSLENGINE now that its the same as CIPHER_SUITES
luni/src/test/java/javax/net/ssl/SSLEngineTest.java
support/src/test/java/java/security/StandardNames.java
test_SSLSocket_getSupportedCipherSuites_connect now does
interoperability testing not just between the default SSLContext's
SSLSockets but between the four combinations of our two SSLContext. It
also now sends some test data bi-directionally between the client and
server.
luni/src/test/java/javax/net/ssl/SSLSocketTest.java
Changed TestSSLContext.create to allow a different Provider for the
client and server SSLContexts.
luni/src/test/java/javax/net/ssl/SSLEngineTest.java
luni/src/test/java/javax/net/ssl/SSLSocketTest.java
support/src/test/java/javax/net/ssl/TestSSLContext.java
RC4 is now available in bouncycastle for the non-OpenSSL SSLContext to
use for parity with the OpenSSL implementation.
support/src/test/java/java/security/StandardNames.java
Changed TestSSLSocketPair to use Futures like NativeCryptoTest so its
easier to choose between client and server errors while debuging.
support/src/test/java/javax/net/ssl/TestSSLSocketPair.java
Removed bogus import
luni/src/test/java/org/apache/harmony/xnet/provider/jsse/NativeCryptoTest.java
Change-Id: I080c0343a3f86f27b7c191a7b80b585b9ca52d93
Elliott Hughes [Thu, 22 Jul 2010 17:23:42 +0000 (10:23 -0700)]
Remove many of our C-style casts.
Also move more native methods' function names over to the predominant
"Class_methodName" orthography.
Change-Id: I8f7fa5fe1fdf323e0ed910a0850595a8e5426e05