OSDN Git Service

android-x86/libcore.git
14 years agoam e595037c: resolved conflicts for merge of bc411e69 to gingerbread-plus-aosp
Jean-Baptiste Queru [Tue, 17 Aug 2010 23:01:05 +0000 (16:01 -0700)]
am e595037c: resolved conflicts for merge of bc411e69 to gingerbread-plus-aosp

Merge commit 'e595037cf49109e9e20b47e6e191eda45e414008'

* commit 'e595037cf49109e9e20b47e6e191eda45e414008':
  Fix compilation error: invalid conversion from 'const char*' to 'char*'.

14 years agoresolved conflicts for merge of bc411e69 to gingerbread-plus-aosp
Jean-Baptiste Queru [Tue, 17 Aug 2010 21:19:05 +0000 (14:19 -0700)]
resolved conflicts for merge of bc411e69 to gingerbread-plus-aosp

Change-Id: Idfbfcc757b8900f0268c34519a4819a667e3fff1

14 years agoFix compilation error: invalid conversion from 'const char*' to 'char*'.
Rene Bolldorf [Tue, 17 Aug 2010 17:05:07 +0000 (19:05 +0200)]
Fix compilation error: invalid conversion from 'const char*' to 'char*'.

Change-Id: Icf57929ab5973fc89e45639649239344375a597d

14 years agoam 12e10c1c: b/2914872: fix concurrent initialization problem with peer certificate...
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

14 years agob/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

14 years agoCreate 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>
14 years agoFix 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>
14 years agoam 753597d5: Merge remote branch \'goog/dalvik-dev\' into dalvik-dev-to-gingerbread
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

14 years agoRemove restricted permissions in file and directory creation
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>
14 years agoMerge remote branch 'goog/dalvik-dev' into dalvik-dev-to-gingerbread
Brian Carlstrom [Wed, 4 Aug 2010 22:37:22 +0000 (15:37 -0700)]
Merge remote branch 'goog/dalvik-dev' into dalvik-dev-to-gingerbread

14 years agoMerge "Rewrite the nio Pipe to use a Unix pipe behind the scenes." into dalvik-dev
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

14 years agoRewrite the nio Pipe to use a Unix pipe behind the scenes.
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

14 years agoMerge "Support for TLS Extensions enabled SSLSockets with fallback to vanila SSL...
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

14 years agoMerge "Stop GCC from outsmarting me." 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

14 years agoStop GCC from outsmarting me.
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

14 years agoresolved conflicts for merge of 7b3ebefc to dalvik-dev
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

14 years agoSupport for TLS Extensions enabled SSLSockets with fallback to vanila SSL
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

14 years agoUse the existing mime-type/extension mapping from frameworks/base.
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

14 years agoRemove "java.net.preferIPv4Stack" (which has been broken >= eclair).
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

14 years agoam 2ceb1614: Merge commit \'1a529c16\' into manualmerge
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()

14 years agoMerge commit '1a529c16' into manualmerge
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

14 years agoam 20705dde: BlockGuard: don\'t complain about non-linger network close()
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()

14 years agoBlockGuard: 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

14 years agoBring URLConnection.guessContentTypeFromName in line with Chrome.
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

14 years agoRemove a bogus test that's been removed upstream.
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

14 years agoMerge "Fix setTrafficClass." into dalvik-dev
Elliott Hughes [Thu, 29 Jul 2010 23:12:45 +0000 (16:12 -0700)]
Merge "Fix setTrafficClass." into dalvik-dev

14 years agoFix setTrafficClass.
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

14 years agoFix for poorly compiling documentation
Ben Dodson [Thu, 29 Jul 2010 18:41:42 +0000 (11:41 -0700)]
Fix for poorly compiling documentation

Change-Id: I6077052df3cf6ba1f977aa312552ef8fe43bd56c

14 years agoFix setSoLinger.
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

14 years agoam 06f47d3e: Merge remote branch \'goog/dalvik-dev\' into dalvik-dev-to-master
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':

14 years agoMerge remote branch 'goog/dalvik-dev' into dalvik-dev-to-master
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

14 years agoEnumMap.toString throws NPE
Ben Dodson [Thu, 29 Jul 2010 00:33:18 +0000 (17:33 -0700)]
EnumMap.toString throws NPE

Fix for bug: 2787265

Change-Id: I56f9a2c7088f5263b26e93be1a3a28903c9e49cd

14 years agoRemove the unnecessary "Impl" suffix from setFloatArray.
Elliott Hughes [Wed, 28 Jul 2010 18:24:09 +0000 (11:24 -0700)]
Remove the unnecessary "Impl" suffix from setFloatArray.

Change-Id: I2eea809c7b441ed3c596e2b945e7897ccc15c10c

14 years agoresolved conflicts for merge of 01a18c74 to dalvik-dev
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

14 years agoresolved conflicts for merge of fb4045a3 to master
Elliott Hughes [Wed, 28 Jul 2010 17:46:34 +0000 (10:46 -0700)]
resolved conflicts for merge of fb4045a3 to master

Change-Id: I2100c70f6078108e7b646c393ac2e4b42ca8d066

14 years agoam bfb0099c: Improve putFloatArray performance
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

14 years agoFix SecureRandom default service
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

14 years agoLet the kernel handle network timeouts by setting SO_RCVTIMEO.
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

14 years agoMerge "Better detail messages for exceptions thrown when converting between byte...
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

14 years agoBetter detail messages for exceptions thrown when converting between byte[]/InetAddress.
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

14 years agoSecureRandom constructor performance improvement
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

14 years agoImprove putFloatArray performance
Owen Lin [Fri, 11 Jun 2010 06:10:41 +0000 (14:10 +0800)]
Improve putFloatArray performance

Change-Id: I04b43a2be6409329408d74af7ff0f0b2b60cc96d

14 years agoFix available() to throw on a closed Socket's InputStream.
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

14 years agoMerge "Fix multicast TTL (and loopback)." into dalvik-dev
Elliott Hughes [Fri, 23 Jul 2010 22:25:25 +0000 (15:25 -0700)]
Merge "Fix multicast TTL (and loopback)." into dalvik-dev

14 years agoam ee57aef0: resolved conflicts for merge of 67ca373a to master
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

14 years agoFix multicast TTL (and loopback).
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

14 years agoresolved conflicts for merge of 67ca373a to master
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

14 years agoam b960e1a9: Bugs when connecting a SocketChannel registered in a Selector
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

14 years agoRemove UCharacter's unnecessary layer of indirection.
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

14 years agoRemove more of our C-style casts, fix more of our native method names.
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

14 years agoBugs when connecting a SocketChannel registered in a Selector
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

14 years agoConsistently use POSIX O_NONBLOCK instead of FIONBIO.
Elliott Hughes [Thu, 22 Jul 2010 22:06:54 +0000 (15:06 -0700)]
Consistently use POSIX O_NONBLOCK instead of FIONBIO.

Change-Id: I395012f0e51e1928e720d09d0f44b7d5085b01a3

14 years agoRemove C-style casts from our expat JNI.
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

14 years agoMerge "Remove many of our C-style casts." into dalvik-dev
Elliott Hughes [Thu, 22 Jul 2010 18:32:38 +0000 (11:32 -0700)]
Merge "Remove many of our C-style casts." into dalvik-dev

14 years agoBring SSLSocketImpl and SSLEngine in line with OpenSSLSocketImpl's cipher suites
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

14 years agoRemove many of our C-style casts.
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

14 years agoMerge "Remove File's cached UTF-8 byte[]." into dalvik-dev
Elliott Hughes [Thu, 22 Jul 2010 00:29:28 +0000 (17:29 -0700)]
Merge "Remove File's cached UTF-8 byte[]." into dalvik-dev

14 years agoRemove File's cached UTF-8 byte[].
Elliott Hughes [Wed, 21 Jul 2010 23:32:07 +0000 (16:32 -0700)]
Remove File's cached UTF-8 byte[].

This doesn't really improve File.getCanonicalPath and its helpers much, but it
improves everything else, and feels like a step in the right direction.

Benchmarking shows only a tiny difference in the uncommon case of a reused
File, and a significant increase in performance in the more likely case of
a single-use File.

Before:

      benchmark    us
         Exists 26.14
    ExistsReuse  5.08

After:

      benchmark    us
         Exists 13.90
    ExistsReuse  5.23

Bug: 2281992
Change-Id: Ibc6fd2581983ae8a57bf4b7f49196c76ad41169e

14 years agoAdding tests for HTTP connect and read timeouts.
Jesse Wilson [Wed, 21 Jul 2010 18:10:30 +0000 (11:10 -0700)]
Adding tests for HTTP connect and read timeouts.

Also a typo in an exception message in HttpURLConnectionImpl.

Change-Id: Ifa8b85e835eff6151a25c4a9ee83a7194de7656c

14 years agoMerge "Deduplicating HTTP tests with Harmony and get Harmony's tests passing." into...
Jesse Wilson [Wed, 21 Jul 2010 17:28:32 +0000 (10:28 -0700)]
Merge "Deduplicating HTTP tests with Harmony and get Harmony's tests passing." into dalvik-dev

14 years agoDeduplicating HTTP tests with Harmony and get Harmony's tests passing.
Jesse Wilson [Wed, 21 Jul 2010 02:08:36 +0000 (19:08 -0700)]
Deduplicating HTTP tests with Harmony and get Harmony's tests passing.

This fixes a behaviour problem where we were sending the response
headers to the response cache rather than the request headers. It
also fixes a bug in handling of null header names.

This also cleans up some of the worst names in HttpUrlConnectionImpl.
The similarity between reqHeader and resHeader may have been a reason
for the problem above.

See bug 2352649, which complains about how our duplicated-with-Harmony
test connects to news.yahoo.com, quite unreliably. The latest version
of their test uses a local jetty server, which is far more reliable.

Change-Id: I701b3a1c999c63ea8dd929d8bd020717403fb75c

14 years agoNew NativeCryptoTest, NativeCrypto.{SSL_set_client_CA_list, SSL_renegotiate}, fixes...
Brian Carlstrom [Mon, 19 Jul 2010 20:52:03 +0000 (13:52 -0700)]
New NativeCryptoTest, NativeCrypto.{SSL_set_client_CA_list, SSL_renegotiate}, fixes for other minor bugs exposed by test

Summary:
- New NativeCryptoTest covering NativeCrypto SSL APIs
- Added SSL_set_client_CA_list for server to specify acceptable client cert issues
- Added SSL_renegotiate for renegoiation testing
- Removed unneeded d2i_SSL_SESSION argument
- Added OpenSSLSocketImpl read/write bounds checking
- Added NULL checks on AppData to avoid native crashes on use of SSL before handshake

Details:
    Corrected NativeCrypto thrown exceptions based on
    NativeCryptoTest. Of note, we now throw NullPointerException
    instead of SSLException for simple null issues in NativeCrypto.cpp

luni/src/main/java/org/apache/harmony/xnet/provider/jsse/NativeCrypto.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSessionImpl.java
luni/src/main/native/NativeCrypto.cpp

    Created NativeCrypto.{encodeCertificates,encodeIssuerX509Principals} to
    factor out some code out of OpenSSLSocketImpl that any user of
    NativeCrypto.{SSL_use_certificate, SSL_set_client_CA_list} would
    find useful.

luni/src/main/java/org/apache/harmony/xnet/provider/jsse/NativeCrypto.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java

    Added SSL_set_client_CA_list to allow server to provide list of
    issuers acceptable for client certifcates.

luni/src/main/java/org/apache/harmony/xnet/provider/jsse/NativeCrypto.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java
luni/src/main/native/NativeCrypto.cpp

    Added SSL_renegotiate to allow unit testing of SSL renegoiation.

luni/src/main/java/org/apache/harmony/xnet/provider/jsse/NativeCrypto.java
luni/src/main/native/NativeCrypto.cpp

    Removed d2i_SSL_SESSION size argument since it should be same as length of other argument

luni/src/main/java/org/apache/harmony/xnet/provider/jsse/NativeCrypto.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSessionImpl.java
luni/src/main/native/NativeCrypto.cpp

    Added bounds checking to getInputStream.read(byte[], ...) and
    getOutputStream().write(byte[], ...)

luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java

    Added NULL checks on AppData to avoid native crashes.

luni/src/main/native/NativeCrypto.cpp

    New test of NativeCrypto SSL APIs

luni/src/test/java/org/apache/harmony/xnet/provider/jsse/NativeCryptoTest.java

Change-Id: I2fb7a40761e66320f73b02880e6e43def9594497

14 years agoCorrect cacerts directory naming convention
Brian Carlstrom [Mon, 19 Jul 2010 21:39:34 +0000 (14:39 -0700)]
Correct cacerts directory naming convention

Change-Id: I87cf5f213c63f3975bb1f76cfb59a161b8b8c2ab

14 years agoam 821886ea: am 3d667044: am 16b704e4: add meta-files about 3rd party projects
The Android Open Source Project [Mon, 19 Jul 2010 15:50:01 +0000 (08:50 -0700)]
am 821886ea: am 3d667044: am 16b704e4: add meta-files about 3rd party projects

Merge commit '821886eab89dd4c92e4b048dff1cb2c44a469df5' into dalvik-dev

* commit '821886eab89dd4c92e4b048dff1cb2c44a469df5':
  add meta-files about 3rd party projects

14 years agoFix a buffer overrun when trimming the byte array.
Elliott Hughes [Sat, 17 Jul 2010 03:35:39 +0000 (20:35 -0700)]
Fix a buffer overrun when trimming the byte array.

Also fix the test that GetByteArrayElements succeeded: we were testing the
wrong local.

Bug: 2838496
Change-Id: I0aa950861eebc1fe2cd109b8940268458b12caa0

14 years agoMerge "Fix a long-latent bug in the zip code, exposed by -Xjniopts:forcecopy." into...
Elliott Hughes [Sat, 17 Jul 2010 03:31:38 +0000 (20:31 -0700)]
Merge "Fix a long-latent bug in the zip code, exposed by -Xjniopts:forcecopy." into dalvik-dev

14 years agoFix a long-latent bug in the zip code, exposed by -Xjniopts:forcecopy.
Elliott Hughes [Sat, 17 Jul 2010 02:32:11 +0000 (19:32 -0700)]
Fix a long-latent bug in the zip code, exposed by -Xjniopts:forcecopy.

We were using ScopedByteArrayRO to access a byte[] read-write, and accidentally
relying on the fact that normally the VM will give us a pointer to the actual
array. A C-style cast that cast away const hid this obvious bug from the
compiler, so this patch also removes all the other C-style casts from the zip
code.

Change-Id: I15b2175af7d089ddc86448f54219abef2a9ef8cd

14 years agoMerge "Fix build (droiddoc @param error)." into dalvik-dev
Elliott Hughes [Fri, 16 Jul 2010 22:10:18 +0000 (15:10 -0700)]
Merge "Fix build (droiddoc @param error)." into dalvik-dev

14 years agoFix build (droiddoc @param error).
Elliott Hughes [Fri, 16 Jul 2010 22:07:05 +0000 (15:07 -0700)]
Fix build (droiddoc @param error).

Change-Id: I5996c9fd2c17e7b2fa8a44dd9b96beb65adc7ab1

14 years agoam 3d667044: am 16b704e4: add meta-files about 3rd party projects
The Android Open Source Project [Fri, 16 Jul 2010 18:56:18 +0000 (11:56 -0700)]
am 3d667044: am 16b704e4: add meta-files about 3rd party projects

Merge commit '3d66704483f1b8ea8b6eea1939f02508c551fd62'

* commit '3d66704483f1b8ea8b6eea1939f02508c551fd62':
  add meta-files about 3rd party projects

14 years agoam 16b704e4: add meta-files about 3rd party projects
The Android Open Source Project [Fri, 16 Jul 2010 18:53:03 +0000 (11:53 -0700)]
am 16b704e4: add meta-files about 3rd party projects

Merge commit '16b704e46cf2d32dffc70a27fc4b78b20fbf795f' into gingerbread-plus-aosp

* commit '16b704e46cf2d32dffc70a27fc4b78b20fbf795f':
  add meta-files about 3rd party projects

14 years agoadd meta-files about 3rd party projects
The Android Open Source Project [Fri, 16 Jul 2010 18:41:37 +0000 (11:41 -0700)]
add meta-files about 3rd party projects

Change-Id: Ib22265632a3be569eeab0320021365b2d80a805e

14 years agoFix PKCS12 and BKS KeyStore as well as SSL renegotiation
Brian Carlstrom [Wed, 14 Jul 2010 05:54:39 +0000 (22:54 -0700)]
Fix PKCS12 and BKS KeyStore as well as SSL renegotiation

Summary:
- Added KeyStoreTest and fixed PKCS and BKS keystores to be fully functional
- KeyStore and KeyStoreImpl improvements in libcore and bouncycastle for more RI-like behavior
- SSL Renegotiation fix for new implementation

Details:

external/bouncycastle

   TwoFish added back for BKS KeyStore. Like RC2, it not supported as
   a general cipher, but instead used internally for KeyStore
   implementation.

src/main/java/org/bouncycastle/crypto/engines/TwofishEngine.java
bouncycastle.config

    Added back PBEWITHSHAANDTWOFISH, PBEWITHSHAANDTWOFISH-CBC,
    PBEWITHSHA1ANDRC2-CBC, PBEWITHHMACSHA, PBEWITHHMACSHA1 to support
    PKCS12 and BKS KeyStore implementations (as determined by new
    KeyStoreTest)

src/main/java/org/bouncycastle/jce/provider/BouncyCastleProvider.java
src/main/java/org/bouncycastle/jce/provider/JCEBlockCipher.java
src/main/java/org/bouncycastle/jce/provider/JCEMac.java
src/main/java/org/bouncycastle/jce/provider/JCESecretKeyFactory.java

    Don't throw an error when deleting a non-existing KeyStore entry. The
    RI documentation (and behavior) says it throws an error when it fails
    to remove an entry, not when the entry does not exist.

src/main/java/org/bouncycastle/jce/provider/JDKKeyStore.java
src/main/java/org/bouncycastle/jce/provider/JDKPKCS12KeyStore.java

    Try to make BC's PKCS KeyStore have a more RI-like getCreationDate behavior

src/main/java/org/bouncycastle/jce/provider/JDKPKCS12KeyStore.java

    Make BC's PKCS KeyStore failfast on setting non-supported key,
    instead of failing later on get.

src/main/java/org/bouncycastle/jce/provider/JDKPKCS12KeyStore.java

    Make BC's PKCS KeyStore handle setting a PrivateKey with an emtpy chain.

src/main/java/org/bouncycastle/jce/provider/JDKPKCS12KeyStore.java

    Add more general avoidance of NullPointerExceptions on null aliases

src/main/java/org/bouncycastle/jce/provider/JDKPKCS12KeyStore.java

    Added notes about changes improvements

patches/README

    Regenerated patch with above changes

patches/android.patch

libcore

    KeyStore improvements based on KeyStoreTest

    - Fix UnrecoverableKeyException to be a subclass of
      UnrecoverableEntryException, which was keeping the new
      KeyStoreTest from compiling.

luni/src/main/java/java/security/UnrecoverableKeyException.java

    - Fix to not convert UnrecoverableKeyException to KeyStoreException,
      which was only being done because of the UnrecoverableKeyException
      superclass bug.

luni/src/main/java/java/security/KeyStoreSpi.java

    - Harmony KeyStore was being overly aggresive about throwing on null
      alias arguments in cases where the RI was happy to pass them to the
      KeyStoreSpi.

luni/src/main/java/java/security/KeyStore.java

    - New test after PKCS12 regresion. It enumerates and excercises
      all methods on all available KeyStore
      implementations. Unfortunately, the main varieties of KeyStores
      made this a lot more complicated than I was originally
      expecting. It does clarifiy the differences between the RI and
      BC KeyStore implementations, especially for PKCS12, where in
      some ways the RI is more feature complete (setting key via
      byte[]), but in other ways BC goes beyond some RI limitations
      (allowing storage of certificates).

luni/src/test/java/java/security/KeyStoreTest.java

   TestKeyStore improvements while writing KeyStoreTest
   - Renamed "keyStorePassword" working usages to clarify if it really
     means the "storePassword" on the whole KeyStore, or if it is a
     "keyPassword" on individual keys.
   - Moved TestKeyStore from javax.net.ssl to java.security

luni/src/test/java/javax/net/ssl/SSLContextTest.java
luni/src/test/java/javax/net/ssl/SSLEngineTest.java
luni/src/test/java/javax/net/ssl/SSLSessionTest.java
luni/src/test/java/javax/net/ssl/SSLSocketTest.java
support/src/test/java/java/security/StandardNames.java
support/src/test/java/java/security/TestKeyStore.java
support/src/test/java/javax/net/ssl/TestKeyStore.java
support/src/test/java/javax/net/ssl/TestSSLContext.java

    Fixing up SSL renegotiation support. Now that we are not trying to
    prevent renegotiation, make sure it is working correctly.

    - Remove SSL_VERIFY_CLIENT_ONCE to take the default behavior of
      re-requesting client certificate on renegotiation.

luni/src/main/java/org/apache/harmony/xnet/provider/jsse/NativeCrypto.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java

    - Updated comments to reflect renegotiation. Bug fix to not clear
      out callback reference on handshake complete, since we need it for
      renegotiation.

luni/src/main/native/NativeCrypto.cpp

   Updated for PKCS12 KeyStore support

support/src/test/java/java/security/StandardNames.java

   Added javadoc when writint KeyStoreTest

luni/src/test/java/java/security/ProviderTest.java

frameworks/base

    Tracking changes to UnrecoverableKeyException superclass

api/8.xml
api/current.xml

Change-Id: I6349dbfc02896417595b52e364ade8000b567615

14 years agoam 21710cc5: am 42660dc4: am dcaba04c: Few tweaks to BlockGuard\'s BlockGuardPolicyEx...
Brad Fitzpatrick [Fri, 16 Jul 2010 06:29:39 +0000 (23:29 -0700)]
am 21710cc5: am 42660dc4: am dcaba04c: Few tweaks to BlockGuard\'s BlockGuardPolicyException.

Merge commit '21710cc5a3a0c7e3bd40e3621c9c9f14e97bf809' into dalvik-dev

* commit '21710cc5a3a0c7e3bd40e3621c9c9f14e97bf809':
  Few tweaks to BlockGuard's BlockGuardPolicyException.

14 years agoam 48e324f2: am 21640c4b: (-s ours) am de1d2252: The ICU data is no longer compiled...
Joe Onorato [Fri, 16 Jul 2010 06:29:36 +0000 (23:29 -0700)]
am 48e324f2: am 21640c4b: (-s ours) am de1d2252: The ICU data is no longer compiled directly into the shared library.

Merge commit '48e324f2396af7b49c21c09d8f6cf7a5d7d9eeb5' into dalvik-dev

* commit '48e324f2396af7b49c21c09d8f6cf7a5d7d9eeb5':

14 years agoam 42660dc4: am dcaba04c: Few tweaks to BlockGuard\'s BlockGuardPolicyException.
Brad Fitzpatrick [Fri, 16 Jul 2010 06:20:51 +0000 (23:20 -0700)]
am 42660dc4: am dcaba04c: Few tweaks to BlockGuard\'s BlockGuardPolicyException.

Merge commit '42660dc4657a7b26014810843693e714324b4db5'

* commit '42660dc4657a7b26014810843693e714324b4db5':
  Few tweaks to BlockGuard's BlockGuardPolicyException.

14 years agoam 21640c4b: (-s ours) am de1d2252: The ICU data is no longer compiled directly into...
Joe Onorato [Fri, 16 Jul 2010 06:20:49 +0000 (23:20 -0700)]
am 21640c4b: (-s ours) am de1d2252: The ICU data is no longer compiled directly into the shared library.

Merge commit '21640c4bf1ecda0428f2dc408fd293bc2e314aea'

* commit '21640c4bf1ecda0428f2dc408fd293bc2e314aea':

14 years agoam dcaba04c: Few tweaks to BlockGuard\'s BlockGuardPolicyException.
Brad Fitzpatrick [Thu, 15 Jul 2010 21:12:30 +0000 (14:12 -0700)]
am dcaba04c: Few tweaks to BlockGuard\'s BlockGuardPolicyException.

Merge commit 'dcaba04c224cb5a5ed6af89251ac876ec2f48dfe' into gingerbread-plus-aosp

* commit 'dcaba04c224cb5a5ed6af89251ac876ec2f48dfe':
  Few tweaks to BlockGuard's BlockGuardPolicyException.

14 years agoFew tweaks to BlockGuard's BlockGuardPolicyException.
Brad Fitzpatrick [Thu, 15 Jul 2010 21:03:55 +0000 (14:03 -0700)]
Few tweaks to BlockGuard's BlockGuardPolicyException.

Needed for work on StrictMode across binder calls.  Will likely be
cleaned up more in the future, removing the magical stringification.
But this is currently needed at this stage.

Change-Id: I4b2b3e6a242ac62fa9847fc969749b4f2467bc71

14 years agoMerge "Improving the performance of Class.getName() and Class.getMethods()." into...
Jesse Wilson [Thu, 15 Jul 2010 19:02:04 +0000 (12:02 -0700)]
Merge "Improving the performance of Class.getName() and Class.getMethods()." into dalvik-dev

14 years agoImproving the performance of Class.getName() and Class.getMethods().
Jesse Wilson [Thu, 15 Jul 2010 01:10:04 +0000 (18:10 -0700)]
Improving the performance of Class.getName() and Class.getMethods().

Class.getName() was going to native code with every call. Caching
it in a field saves the native call and results in a large savings
in the new implementation of getAllMethods().

Class.getMethods() was allocating strings for every method as a hash
key for deduplicating overloads.

This table shows runtime with the optimization. The previous code
was hashing to deduplicate; the new code uses sorting.

            run     us linear runtime
        hashing 4126.5 ===============
hashing+getName 3131.8 ===========
        sorting 8062.4 ==============================
sorting+getName 2079.8 =======

Full details here, including some intermediate results:
http://microbenchmarks.appspot.com/run/jessewilson@google.com/java.lang.reflect.ReflectionBenchmark

Change-Id: I562785705847ab7af23dd57c98e593e7e0df284a

14 years agoSimplify the network send(2) interfaces.
Elliott Hughes [Thu, 15 Jul 2010 18:09:45 +0000 (11:09 -0700)]
Simplify the network send(2) interfaces.

Similar to the change for the recv(2) code.

Unrelatedly, I've pulled out our exception-throwing helpers for reuse. This
was meant to be in a separate change, but I accidentally mixed it in.

Bug: 2823977
Change-Id: I314a4337189277b6eff65f7ccf9e897b5d0b73f2

14 years agoam 3533ac4b: Resolved conflicts for merge of de1d2252 to master
Joe Onorato [Thu, 15 Jul 2010 18:36:56 +0000 (11:36 -0700)]
am 3533ac4b: Resolved conflicts for merge of de1d2252 to master

Merge commit '3533ac4b1edc4e863385a0f29c83cfbf49142924' into dalvik-dev

* commit '3533ac4b1edc4e863385a0f29c83cfbf49142924':
  The ICU data is no longer compiled directly into the shared library.

14 years agoResolved conflicts for merge of de1d2252 to master
Joe Onorato [Thu, 15 Jul 2010 18:24:40 +0000 (11:24 -0700)]
Resolved conflicts for merge of de1d2252 to master

Change-Id: If44e4cfa8df812bceb8f39d9343530824cbf3b7c

14 years agoam de1d2252: The ICU data is no longer compiled directly into the shared library.
Joe Onorato [Thu, 15 Jul 2010 18:12:40 +0000 (11:12 -0700)]
am de1d2252: The ICU data is no longer compiled directly into the shared library.

Merge commit 'de1d22525aaaa3eaafc2920acbeb8bd8ec013bcd' into gingerbread-plus-aosp

* commit 'de1d22525aaaa3eaafc2920acbeb8bd8ec013bcd':
  The ICU data is no longer compiled directly into the shared library.

14 years agoMatch the RI in the exception thrown by DatagramPacket's constructor.
Elliott Hughes [Thu, 15 Jul 2010 17:36:21 +0000 (10:36 -0700)]
Match the RI in the exception thrown by DatagramPacket's constructor.

We were failing an existing harmony test, so no new test necessary.

Change-Id: I056187225af52a2bc927da208f9d174f3249b5fa

14 years agoMake it possible to interrupt network reads.
Elliott Hughes [Wed, 14 Jul 2010 21:16:13 +0000 (14:16 -0700)]
Make it possible to interrupt network reads.

This patch simplifies the network I/O interface, in particular for read/recv.

The bounds checking from OSNetworkSystem.read goes, since the caller already
checks. (If we want that checking in native code, we should add it uniformly.)

We also remove supportsUrgentData (which was always returning true), and remove
the sole caller, so we just try the operation and report failures if they happen
rather than trying to predict the failure (as the original code seemed to want
to do, and which is never a good idea).

The native code gains logic to recognize when the FileDescriptor has been
closed from another thread, though this logic remains largely unused at this
point. (There's comment-out code in "close" that does a shutdown(2) to wake
us up so we can recognize this situation.) I've switched code over to using
the new NetFd class, but haven't ensured that we handle the wakeups correctly.
(The "read" implementation being the notable exception.) For now, with the
shutdown(2) commented out, this shouldn't have any visible behavioral changes.
(And our tests don't spot any.)

Code that was using malloc(3)/free(3) to allocate temporary buffers, and copying
to and from those buffers has been rewritten to use JNI-provided pointers onto
the heap, as part of the general "don't lie to the garbage collector" push.

The implementations for the various old forms of recv have been collapsed into
one.

Bug: 2823977
Change-Id: I05cf742c44827a24df3c1ff59727013ee4636233

14 years agoRemove the last few "Answer"/"Answers" from javadoc.
Elliott Hughes [Wed, 14 Jul 2010 21:44:05 +0000 (14:44 -0700)]
Remove the last few "Answer"/"Answers" from javadoc.

Change-Id: I753bd9bbfc1462d948929197f00668fa1e1237f2

14 years agoThe ICU data is no longer compiled directly into the shared library.
Joe Onorato [Wed, 14 Jul 2010 02:06:19 +0000 (19:06 -0700)]
The ICU data is no longer compiled directly into the shared library.

Change-Id: If295333e3bf2a2005494fe2a7757caa439ae8a31

14 years agoImproved client certificate and certificate chain support
Brian Carlstrom [Thu, 8 Jul 2010 21:44:44 +0000 (14:44 -0700)]
Improved client certificate and certificate chain support

Summary:
- openssl: add openssl support for specifying per key certificate chains
- libcore: properly implement client certificate request call back
- libcore: properly implement sending certificate chain
- libcore: properly implement retreiving local certificate chain
- libcore: added an SSLContext for non-OpenSSL SSLSocket creation

Details:

external/openssl

    Improve patch generate support by applying all other patches to
    baseline to remove cross polluting other patch changes into target
    patch. Move cleanup of ./Configure output to import script from
    openssl.config.

  import_openssl.sh
openssl.config

   Adding SSL_use_certificate_chain and SSL_get_certificate_chain to
   continue to finish most of remaining JSSE issues.

include/openssl/ssl.h
ssl/s3_both.c
ssl/ssl.h
ssl/ssl_locl.h
ssl/ssl_rsa.c

   Updated patch (and list of input files to patch)

patches/jsse.patch
openssl.config

libcore

    Restoring SSLContextImpl as provider of non-OpenSSL SSLSocketImpl
    instances for interoperability testing. OpenSSLContextImpl is the
    new subclass that provides OpenSSLSocketImpl. JSSEProvider
    provides the old style SSLContexts, OpenSSLProvider provides the
    OpenSSL SSLContext, which includes the "default" context. Changed
    to register SSLContexts without aliases to match the RI.

luni/src/main/java/org/apache/harmony/xnet/provider/jsse/JSSEProvider.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLProvider.java

luni/src/main/java/org/apache/harmony/xnet/provider/jsse/DefaultSSLContextImpl.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLContextImpl.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLContextImpl.java

    Native interface updates to support OpenSSLSocketImpl improvements
    - KEY_TYPES now expanded based on what we are being provided by OpenSSL.
      keyType function now maps key type values received from
      clientCertificateRequested callback.
    - Removed remaining uses of string PEM encoding, now using ASN1 DER consistently
      Includes SSL_SESSION_get_peer_cert_chain, verifyCertificateChain
    - Fixed clientCertificateRequested to properly include all key
      types supported by server, not just the one from the cipher
      suite. We also now properly include the list of supported CAs to
      help the client select a certificate to use.
    - Fixed NativeCrypto.SSL_use_certificate implementation to use new
      SSL_use_certificate_chain function from openssl to pass chain to
      OpenSSL.
    - Added error handling of all uses of sk_*_push which can fail due to out of memory
    - Fixed compile warning due to missing JNI_TRACE argument
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/NativeCrypto.java
luni/src/main/native/NativeCrypto.cpp
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java

    Pass this into chooseServerAlias call as well in significantly revamped choseClientAlias

luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java

    Minor code cleanup while reviewing diff between checkClientTrusted and checkServerTrusted

luni/src/main/java/org/apache/harmony/xnet/provider/jsse/TrustManagerImpl.java

   Improvements to SSL test support to go along with client
   certificate and certificate chain changes. TestSSLContext now has
   separate contexts for the client and server (as well as seperate
   key stores information). TestKeyStore now is more realistic by
   default, creating a CA, intermediate CA, and separate client and
   server certificates, as well as a client keystore that simply
   contains the CA and no certificates.

support/src/test/java/javax/net/ssl/TestKeyStore.java
support/src/test/java/javax/net/ssl/TestSSLContext.java

     Tests tracking API changes. Tests involving cert chains now now
     updated to use TestKeyStore.assertChainLength to avoid hardwiring
     expected chain length in tests. These tests also now use
     TestSSLContext.assertClientCertificateChain to validate that the
     chain is properly constructed and trusted by a trust manager.

luni/src/test/java/java/net/URLConnectionTest.java
luni/src/test/java/javax/net/ssl/SSLContextTest.java
luni/src/test/java/javax/net/ssl/SSLEngineTest.java
luni/src/test/java/javax/net/ssl/SSLSessionContextTest.java
luni/src/test/java/javax/net/ssl/SSLSessionTest.java
luni/src/test/java/javax/net/ssl/SSLSocketTest.java
support/src/test/java/java/security/StandardNames.java
support/src/test/java/javax/net/ssl/TestSSLEnginePair.java
support/src/test/java/javax/net/ssl/TestSSLSocketPair.java

frameworks/base

    Tracking change of SSLContextImpl to OpenSSLContextImpl

core/java/android/net/SSLCertificateSocketFactory.java
core/java/android/net/http/HttpsConnection.java
tests/CoreTests/android/core/SSLPerformanceTest.java
tests/CoreTests/android/core/SSLSocketTest.java

    Tracking changes to TestSSLContext

core/tests/coretests/src/android/net/http/HttpsThroughHttpProxyTest.java

Change-Id: Ie35ebce89966dfce62c316f7fe7252bf06935680

14 years agoMerge "Cleanup HTTP retries." into dalvik-dev
Jesse Wilson [Tue, 13 Jul 2010 22:27:18 +0000 (15:27 -0700)]
Merge "Cleanup HTTP retries." into dalvik-dev

14 years agoCleanup HTTP retries.
Jesse Wilson [Tue, 13 Jul 2010 02:10:03 +0000 (19:10 -0700)]
Cleanup HTTP retries.

We now do the right thing when redirects point us at a different
host or a different scheme.

Also...

Invert the parameter to AbstractHttpInputStream.endOfInput()
and HttpURLConnection.releaseSocket() to be positive 'reuse'
rather than negative 'close'. It makes the code in that method
read better.

Combine discardResponse() and endRequest(). The new method is
discardIntermediateResponse(). Cleanup how we handle intermediate
responses, and how those connections get recycled.

Remove HttpURLConnection's cached fields for proxy addresses.
Instead just update the proxy field when those fields change.
This attempts to make it clear that the names represent the
connected address and not the origin server's address. (This
is different when a proxy is in use.)

Document a consistent interpretation of the inherited protected
field 'connected'. Unfortunately it does not mean connected.

Change-Id: I8d4b65bffa5aeba353186b60cf951232f7762a18

14 years agoam 478f5f95: Allow heap dump requests with a FileDescriptor arg.
Andy McFadden [Tue, 13 Jul 2010 19:27:01 +0000 (12:27 -0700)]
am 478f5f95: Allow heap dump requests with a FileDescriptor arg.

Merge commit '478f5f9576c399c30288cf79d6bbf65ca5feedfd' into dalvik-dev

* commit '478f5f9576c399c30288cf79d6bbf65ca5feedfd':
  Allow heap dump requests with a FileDescriptor arg.

14 years agoFix Throwable.printStackTrace for exceptions without stack traces.
Elliott Hughes [Mon, 12 Jul 2010 21:01:25 +0000 (14:01 -0700)]
Fix Throwable.printStackTrace for exceptions without stack traces.

Also improve the documentation for fillInStackTrace.

Bug: http://code.google.com/p/android/issues/detail?id=9722
Change-Id: I9c539df136058e5300b33aa0d1104d567db71ad4

14 years agoAllow heap dump requests with a FileDescriptor arg.
Andy McFadden [Fri, 9 Jul 2010 23:49:05 +0000 (16:49 -0700)]
Allow heap dump requests with a FileDescriptor arg.

Part of a larger change to allow "am" to initiate hprof heap dumps.

Bug 2759474.

Change-Id: I33c41e6f2ce37d2c0348ea783ecaadc0eae33d36

14 years agoImproved System.getProperty documentation.
Elliott Hughes [Mon, 12 Jul 2010 19:02:22 +0000 (12:02 -0700)]
Improved System.getProperty documentation.

We were claiming to support properties we don't (and aren't required to), but
missing many that we do (and are required to).

Change-Id: I39e5c5beb2e341c690187557b4dd1bce369952da

14 years agoAdd null-pointer checking to ScopedPrimitiveArray.
Elliott Hughes [Mon, 12 Jul 2010 16:53:54 +0000 (09:53 -0700)]
Add null-pointer checking to ScopedPrimitiveArray.

This style worked well for ScopedUtfChars. It moves null-pointer checking
inside the class, thereby encouraging us to remember to check for the
unlikely out-of-memory failures too.

I've also broken up some tests that were trying to check multiple scoped
arrays at once. This idiom was broken because as soon as there's a pending
exception, it's a JNI error to even attempt to set up the next scoped
primitive array. In the absence of C++ exceptions, we have to check these
one by one.

Change-Id: I2f4b397ae2873597e309d86fcc5912f3fcf0f304

14 years agoUse 'dst' (or an even more appropriate name where possible) rather than 'dest'.
Elliott Hughes [Fri, 9 Jul 2010 23:39:48 +0000 (16:39 -0700)]
Use 'dst' (or an even more appropriate name where possible) rather than 'dest'.

(The ArrayIndexOutOfBoundsException for System.arraycopy already talks
about 'dst' and 'dstPos'.)

Change-Id: Iba9415dd4a9ec3b457938ea4469b4a0024bab6e4

14 years agoMerge "Stop Matcher from copying its input onto the native heap." into dalvik-dev
Elliott Hughes [Fri, 9 Jul 2010 21:12:09 +0000 (14:12 -0700)]
Merge "Stop Matcher from copying its input onto the native heap." into dalvik-dev

14 years agoAddress feedback from change 57066,
Jesse Wilson [Fri, 9 Jul 2010 18:15:03 +0000 (11:15 -0700)]
Address feedback from change 57066,
Rewrite the main request retry loop of HttpURLConnection.

Change-Id: I7e10e356614970971253f2e3f60d173a2e5433d4