• Home
  • History
  • Annotate
  • only in /libcore/luni/src/main/native/
History log of /libcore/luni/src/main/native/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
9ae30e796640d1fe4141050ea8a9ed7b2b86b0ce 16-May-2016 Narayan Kamath <narayan@google.com> Add Libcore.os.realpath.

bug: 28740848
Change-Id: I6a965ace64d82cded67882e91860f4fb298a9a51
ibcore_io_Posix.cpp
7e24853d3179344f120677df0ed68fd89b447c8f 25-Apr-2016 TreeHugger Robot <treehugger-gerrit@google.com> Merge "CharsetEncoder/Decoder: Use NativeAllocationRegistry." into nyc-dev
1bdc6bc1c72b033ed860360e69fc9f1f1121579b 22-Apr-2016 Narayan Kamath <narayan@google.com> CharsetEncoder/Decoder: Use NativeAllocationRegistry.

Works around issues with finalizer ordering.

bug: 26076560

(cherry picked from commit c672ce800bbc27cb79f78d9204a51ec06ef1ec3d)

Change-Id: I434842966fe2cda70aa955250162c562ce0f8991
ibcore_icu_NativeConverter.cpp
5b53b8c56fb2aba6fffc5c467d092d9dcaf45f34 22-Apr-2016 Hans Boehm <hboehm@google.com> Convert Pattern and Matcher to use NativeAllocationRegistry

Avoid finalizer use, since already finalized objects may still
be accessed by other finalizers, causing native memory
corruption.

This should also improve memory tracking and deallocation
performance a bit.

Bug: 27887091
Change-Id: Ib1df6bcdacaf8eba622b67c10ac9ceb675067884
(cherry picked from commit d9e764ece41000c87d12d82a50eab6444ba02a8e)
ava_util_regex_Matcher.cpp
ava_util_regex_Pattern.cpp
fb34431c917d206542a3eeb42338f8fb42fc40a9 30-Mar-2016 Przemyslaw Szczepaniak <pszczepaniak@google.com> Handle recvfrom() returning 0.

According to the Linux man page, recvfrom() can return 0 when the peer has performed an orderly shutdown. This also happens when other thread uses a shutdown function on a socket file descriptor.

libcore.io.Posix#recvfrom was treating this case as a success and
was trying to interpret unpopulated sockaddr structure, throwing
IllegalArgumentException in result.

DatagramChannel#receive in same case would return
last previously seen SocketAddress.

This change makes sure that libcore.io.Posix#recvfrom and
java.nio.channels.DatagramChannel handle this case correctly.

Bug: 27294715
Bug: 27233089
Change-Id: I1ec58327efbe9ea6b8d36716756a02987e3b9897
(cherry picked from commit 6e888e9390649a9ab2557da5b28bb75be39e1b74)
ibcore_io_Posix.cpp
4866b39e1898088e318e2a899cf98db9ab57d8be 18-Mar-2016 Alex Klyubin <klyubin@google.com> Expose MAP_POPULATE via OsConstants.

This constant can be provided to Os.mmap to "prefault" mmap'd pages,
which is a useful optimization in some scenarios.

Bug: 27613575

(cherry picked from commit 6a625c66309e07174a0b5899f1eeaf5a0ca4a321)

Change-Id: I2f2fc2e0a90fb9971f9f74da7c24a85b1079023c
ndroid_system_OsConstants.cpp
f0bbd898c9cf4c8977da077b703ff1e8286821dd 08-Feb-2016 Przemyslaw Szczepaniak <pszczepaniak@google.com> Remove public InetAddress#getAddressInternal()

This method shouldn't be public + can be replaced by
the #getAddress method

Bug: 26689841
Change-Id: Ic18eecd53ac73c44b5d8acd062c7f1c65c48fb23
(cherry picked from commit 5858bc7e19fde536d55d9c1ffa6a60d617b328af)
etworkUtilities.cpp
8fbe7d8a9df5f464da59a2938acaf211845b89da 26-Jan-2016 Yi Kong <yikong@google.com> Check for exceptions before calling NewObject

JNI functions while an exception is pending is not allowed.

Bug: 26763262
Change-Id: I679961961a0063f8657558cc4f0728571db336fd
ibcore_icu_NativeConverter.cpp
80bc6eda2a56b50b58995a99bd34144a44d82464 22-Jan-2016 pauljensen <pauljensen@google.com> Add ETH_P_ALL to OsConstants.java

Change-Id: I08ebb0c0932ae110e5be721b209710e5eddd2038
ndroid_system_OsConstants.cpp
33fc9556dfda6298fcd7c119f68a7375e13cbed9 28-Dec-2015 Richard Uhler <ruhler@google.com> Introduce NativeAllocationRegistry API.

The NativeAllocationRegistry API provides a way to associate native
allocations with Java objects. The native allocations will
automatically be freed when the correspondong Java object becomes
unreachable.

Use NativeAllocationRegistry for BigInt.

Bug: 23130675
Change-Id: If89dc03f0668afdecf1086280d16d2803e07a62a
egister.cpp
ava_math_NativeBN.cpp
ibcore_util_NativeAllocationRegistry.cpp
ub.mk
eab063d2211f806872c695f545b8cb6aa44e34bc 19-Dec-2015 Nick Kralevich <nnk@google.com> Separate java stdio from native stdio

base/core/java/com/android/internal/os/RuntimeInit.java redirectLogStreams()
is closing file descriptors for STDOUT and STDERR, and they're getting replaced
by inappropriate FDs.

hammerhead:/ # ps | grep systemui
u0_a24 1176 206 1118388 95684 sys_epoll_ b60f2b14 S com.android.systemui
hammerhead:/ # ls -la /proc/1176/fd/[012]
lrwx------ 1 u0_a24 u0_a24 64 1970-09-12 10:42 /proc/1176/fd/0 -> /dev/null
lrwx------ 1 u0_a24 u0_a24 64 1970-09-12 10:42 /proc/1176/fd/1 -> /dev/binder
lrwx------ 1 u0_a24 u0_a24 64 1970-09-12 10:42 /proc/1176/fd/2 -> anon_inode:[eventfd]

Don't directly expose STDIN/STDOUT/STDERR to java. Instead, operate
on a copy of the FDs.

Change-Id: I466605758e3bbd117d943799506de1f21eb2fd19
ndroid_system_OsConstants.cpp
59cd43352e5fd4907303d06f9b92f01c943375f7 18-Dec-2015 Narayan Kamath <narayan@google.com> Remove unused collation and formatting code.

Change-Id: I154d59e4ccff1d899530aebf27cf444f15f674ab
egister.cpp
ibcore_icu_NativeCollation.cpp
ibcore_icu_NativeDecimalFormat.cpp
ub.mk
72a46b24e87902908d544c4ba0bdd218368a280e 18-Dec-2015 Narayan Kamath <narayan@google.com> Remove unused luni native code.

Change-Id: I26b8fd7f64f24a8d3bc8fa98e6eddf8cbb0fa245
ava_io_File.cpp
ava_io_FileDescriptor.cpp
ava_io_ObjectStreamClass.cpp
ava_lang_Character.cpp
ava_lang_Double.cpp
ava_lang_Float.cpp
ava_lang_Math.cpp
ava_lang_ProcessManager.cpp
ava_lang_RealToString.cpp
ava_lang_StrictMath.cpp
ava_lang_System.cpp
ava_util_zip_Adler32.cpp
ava_util_zip_CRC32.cpp
ava_util_zip_Deflater.cpp
ava_util_zip_Inflater.cpp
583eb0e4738456f0547014a4857a14456be267ee 16-Dec-2015 Przemyslaw Szczepaniak <pszczepaniak@google.com> Move enso net code to use AsynchronousCloseMonitor

- Moved AsynchronousCloseMonitor to the libnativehelper,
it manages shared linked list of IO blocked threads shared
by both libopenjdk and libjavacore
- linux_close.c no longer allocates a table of RLIMIT_NOFILE
size.
- linux_close.c became linux_close.cpp so it can use
AsynchronousCloseMonitor for close signal detection.

Bug: 26127752
Change-Id: If8e71d3d3a04b0a723c7a8bd0398a36542ae7864
synchronousCloseMonitor.cpp
synchronousCloseMonitor.h
ub.mk
fd43ada428d2f3d219a949c81ff75b0c33b76f27 08-Dec-2015 Tom Cherry <tomcherry@google.com> Merge "Remove ANDROID_PROPERTY_WORKSPACE" am: 3f83f1ca8f am: da0ea36c5c
am: 5310a98fcb

* commit '5310a98fcba72f0b32bb866eb293a342df5f9e70':
Remove ANDROID_PROPERTY_WORKSPACE
3f83f1ca8ffdfc99b6e7c8bf5faec26b0f18bd33 08-Dec-2015 Tom Cherry <tomcherry@google.com> Merge "Remove ANDROID_PROPERTY_WORKSPACE"
f640e11f2a796db071428f97a12ef84888e8ef4d 03-Nov-2015 Przemyslaw Szczepaniak <pszczepaniak@google.com> Move StrictJarFile to framework/core

Since StrictJarFile is derived from harmony code,
and not used in the libcore itself, we're moving
it to framework/base code.

Bug: 25337946
Change-Id: I477b7934fb3abfb0c7660e23dd46db216c504e73
(cherrypicked from 8996a40bc2d5caa031992765d642021252c4c810)
egister.cpp
ava_util_jar_StrictJarFile.cpp
ub.mk
70b617fe562806bc3e15452a2792fec4355bd54f 20-Nov-2015 Przemyslaw Szczepaniak <pszczepaniak@google.com> Merge mnc-dr-enso-dev into master

OpenJDK adjustments for master.
- Restored removed libcore.icu.* classes (needed
by the openjdk java.text.* classes). This will be
undone in short future.
- Adjusted java.lang.* and java.lang.reflect.* classes
for native reflection and other changes in master.

Bug: 25758743
Change-Id: Ifbbe5b1e8661138fc32ad24127f76f711dd585b7
4cb97fe003dcf14ccd8f6e381cd172020248efae 08-Oct-2015 Narayan Kamath <narayan@google.com> InetSocketAddress: Read the address & port correctly in native code.

Change-Id: I4d5dc0c065cba671518e75c10e44e5ce3db56ea4
ibcore_io_Posix.cpp
c26548ca3432e64754dc9c380783cdc0c6d7be00 28-Sep-2015 Przemyslaw Szczepaniak <pszczepaniak@google.com> Track renaming of StructPollFd member.

Change-Id: I35edeb6e7b0b53b3c1c231d0abbee308193a653d
ibcore_io_Posix.cpp
1a9ca631d5e2d44f39b556132af3a3cb4e34a966 28-Sep-2015 Przemyslaw Szczepaniak <pszczepaniak@google.com> Update StrictJarFile.

Also add a hidden ZipEntry constructor that this code expects.

Change-Id: I30c437b016bbbfcebe5a81bad4af3b31ee2317f3
ava_util_jar_StrictJarFile.cpp
bf07204bff37fa34dbdb32e0a9d790d97ef46a81 12-Nov-2015 Narayan Kamath <narayan@google.com> Merge lmp changes into mnc.

Change-Id: I8f49c58f39dc5f4268c6b5718cab18ed26ac930a
4fff8bb49a15d2b55e3aa8ffe98446f7f475285e 03-Aug-2015 Narayan Kamath <narayan@google.com> Use android's regex implementation.

Preserve ICU semantics.

Change-Id: Ic98b49c4f64f0b5525297bb96026154885eb111d
egister.cpp
ub.mk
21eb91f8079d5ec067f92792dbc65bae9b0a4f99 01-Jun-2015 Neil Fuller <nfuller@google.com> Configure ICU4C without relying on build-time flags

The presence of the build-time flags appears to cause ICU4C
to open the .dat file again as a fallback if it fails to
find a config value. This is even though the .dat file is
explicitly mapped using udata_setCommonData().

Bug: 19960867
Bug: 19961406
(cherry-picked from commit 79fdcc64ea2d9234f258dac57f04b1017a573311)

(cherry picked from commit d2a3075106f700f229750c228de989b789b7dacd)

Change-Id: I6aea7b2be483cc9c8a0ecbb3311bdf1d272ccfb6
ibcore_icu_ICU.cpp
02b43bf44cb8bf8653baf8d951943a907310c3a2 02-Mar-2015 Neil Fuller <nfuller@google.com> Changes to enable timezone data overrides for ICU and libcore

Bug: 19941636

(cherry picked from commit 317d6e12782e069e4fde06ed0f9a976a7c49f580)

Change-Id: Ie6ac94ea8b819bed7b95585dd63267b21a5c6f53
ibcore_icu_ICU.cpp
4ffbb30e1418b4e9b10dc0b519e5c4a65cc0339c 23-Mar-2015 Narayan Kamath <narayan@google.com> Use compiler pragmas instead of flags.

This lets us turn off warnings for a small segment of the code
instead of the entire project.

bug: 19823499

(cherry picked from commit 8046f4dbe122ac5f362693550360b54cd6943a4b)

Change-Id: I6459cd2038751ccad7aae3e494cd27bfee6f0888
ibcore_icu_NativeIDN.cpp
0a15327f9568f6a8d6b296a0d5fdc0676052898b 09-Jul-2015 Przemyslaw Szczepaniak <pszczepaniak@google.com> Use CaseMapper for String.toUpper/LowerCase

Fixes libcore.java.lang.StringTest#testCaseMapping_el test.

+ bugfix for StringToReal removal.

Change-Id: I204c9bf056086ddacc70d01c89005781e208e80e
egister.cpp
ea544eccd7c78b693804d763dabbd8f7247dc802 02-Jun-2015 Piotr Jastrzebski <haaawk@google.com> Update JNI fillInetSocketAddress.

Update it to reflect OpenJdk's class layout. Also make sure
that the holder is always created.

Change-Id: I7f9f012d8079dc3de9e83a21360215d67c0e2175
ibcore_io_Posix.cpp
ba7cc9f5357c323a1006119a20ce025fd4c57fd2 19-May-2015 Piotr Jastrzebski <haaawk@google.com> Rename FileDescriptor field.

fd -> descriptor.

Change-Id: I0b11214f45c5bc6ca6b9b8ab27d03b41055324ea
ibcore_io_Posix.cpp
133892a64c416abdb5d19c77ec3194aeb789b34f 19-May-2015 Piotr Jastrzebski <haaawk@google.com> Use OpenJdk implenentation of Charset{Encoder,Decoder}.

Use libcore's NativeConverter directly and also hardcode
the default charset to UTF-8.

Change-Id: Iafe84d94e1169721de943638aedd43b3f0af65e6
egister.cpp
ub.mk
46e3649f898305d185fc40bae2542e933a16b619 06-May-2015 Piotr Jastrzebski <haaawk@google.com> Use OpenJdk implementation of java.lang.* [part 1]

- Changes to String hashing.
- Change StringCoding.isTrusted.
- For boxed primitive types, change how TYPE is derived (use the
array equivalents component type).
- System: the security manager is now always null. Also, port over
changes to make system properties read only.
- StrictMath : Use our existing fdlibm and remove references to
jdflibm.h.

Change-Id: I221692836b9320cade9074b122fbc25c8e72cf99
egister.cpp
ibcore_icu_ICU.cpp
ub.mk
alueOf.cpp
f7ab2bc37debba91864bfec6572a3e7bbe994c58 06-May-2015 Piotr Jastrzebski <haaawk@google.com> Use OpenJdk implementation of java.net.*

- Add FileURLConnection.
- NetworkUtilities : Update field names in JNI.
- Suppress a few libcore tests that rely on internal implementation
details.
- Remove code that loads the net library (not needed on android).
- DatagramSocket : Add setNetworkInterface method.
- HttpCookie : make parse & field public
- Inet4Address / Inet6Address : Add getAddressInternal.
- InetAddress : Add methods required by frameworks/base, particularly
those required to deal with net-ids and scope ids.
- URI : Add UriCodec static members for AUTHORITY_ENCODER and friends.
- URL : Add toUriLenient
- URLStreamHandler : Add a toExternalForm variant that optionally
escapes illegal chars.
- Inet4AddressImpl.c : Unconditionally define HAS_GLIBC_GETHOSTBY_R

Change-Id: Ic51f863941f5d954ed6cf86309cc610e711d54bd
etworkUtilities.cpp
8d05e88f57c1ea5543d4012687c70cd64efcada0 06-May-2015 Piotr Jastrzebski <haaawk@google.com> Use OpenJdk implementations for java.io.* [part 2]

Covers most of the serialization classes.

- ObjectInputStream / ObjectStream{Class,Field} : Use VMStack methods
wherever appropriate.
- RandomAccessFile : Reimplement in terms of IoBridge.

Change-Id: I4a57e14ec7fe30f42f6060daf37eb16329636117
egister.cpp
ub.mk
648446e24ad82c2c660e158be8f32faabf082420 05-May-2015 Piotr Jastrzebski <haaawk@google.com> Use OpenJdk implementation of java.nio.*

- Unsafe: add more supporting methods.
- NIOAccess / NIOUtils : Track OpenJdk implementation.
- Bits : Initialize byte-order inline.
- Buffer : Add elementSizeShift.
- ByteBuffer : Add stub implementations of setAccessible and
isAccessible for use by the frameworks.

Change-Id: I07da77a7b8b9a2edd0410118fb697e5d3aa46fde
egister.cpp
3d43823e17818b3c5f45831f830884917b181454 05-May-2015 Piotr Jastrzebski <haaawk@google.com> Use OpenJdk implementation of java.nio.channels.{spi}.*

- Unsafe : Add supporting methods (addressSize, pageSize,
allocateMemory, freeMemory, setMemory and various getters
equivalent to the existing libcore Memory classes).
- NioUtils : Rewrite nioutils methods in terms of OpenJdk classes.
- DeleteOnExitHook : Access java.lang.Shutdown directly.
- FileDescriptor : Add getInt$, setInt$ and setSocket.
- NativeBuffers : Copy byte-by-byte instead of using Unsafe.copyMemory.
- FileInputStream : Add a custom implementation of available() instead
of using IO_Available.

General : Switch JNI code to explicit registration rather than
implicit registration.

General : Track renaming of Unsafe methods (to add the $ suffix). This
might be unnecessary and will be reverted in a future change.

Change-Id: I7e63340d266dbd4b1c425b13710c05dce1086d4b
egister.cpp
ub.mk
9a9f76d1e161f37b3d83d2db94ea63298d221bdf 28-Apr-2015 Piotr Jastrzebski <haaawk@google.com> Use OpenJdk Implementations of java.nio.charset.*

- PrehashedMap : Add a custom hash function instead of calling
hashCode().
- Add a few missing files in sun.nio.cs.
- Charset: Add an internal method that's equivalent to forName but
throws only UEEs.

Change-Id: Ica1f14d4784549c0a3642b61d325f1fb09526125
egister.cpp
ub.mk
a8ed084745590c5e4a0e8559b5821809d60fe242 21-Apr-2015 Piotr Jastrzebski <haaawk@google.com> Use OpenJdk implementation of java.util.zip.*

- Move some of the internal implementation details of libcore's
zipfile into StrictJarFile.
- TODO: Adler32 continues to use old native code from libcore, this
must be switched over.
- InflaterInputStream: |closed| becomes protected.
- ZipFile : Always use mmap.
- ZipEntry : Add a long dataOffset.
- Switch all native code over to explicit registration.

Change-Id: Id5519b4548ea1eb22fd182edfbd2c804dc6f3bb5
egister.cpp
ava_util_jar_StrictJarFile.cpp
ub.mk
865b9d2c38284a486fc8608d3193f5b846822595 15-Apr-2015 Piotr Jastrzebski <haaawk@google.com> Use OpenJdk implementation of java.util.regex.*

Change-Id: I046bb48e645a717c8404d9fad7657157f716d49a
egister.cpp
ub.mk
9c853c5b9ebbb0ef60a013ae10ee411d70dfa832 18-Feb-2015 Piotr Jastrzebski <haaawk@google.com> Use OpenJdk implementations of java.text.*

- LocaleInternalsTest has been disabled since it depends on
internal implementation details.
- Collator: Use libcore's RuleBasedCollatorICU to fetch collator
rules instead of sun.misc.resources.LocaleData & friends.
- DateFormat: Add support for set24HourTimePref (not wired up
yet).
- DateFormatSymbols : Use libcore's LocaleData & TimeZoneNames
classes internally.
- NumberFormat: Use libcore's LocaleData.
- Drop support for SCIENTIFICSTYLE (we should re-enable this at
some point ?).
- SimpleDateFormat : Don't reject the format specifiers for
standalone weekday and friends. We'll need to switch over to
using ICU4J formatters at some point.
- Calendar : Use GregorianCalendar only.
- TimeZone : Use TimeZoneNames to access time zone names.

Change-Id: I4a2866904d4f2f39f0793154d9aad7f109da3b5a
egister.cpp
ava_text_Bidi.cpp
ibcore_icu_NativeDecimalFormat.cpp
ub.mk
c38ff12c5075887f394efa2d5f42f604ccfa6b6d 23-Oct-2015 Erik Kline <ek@google.com> Add an IP_RECVTOS OsConstant

Change-Id: I70f5b8c0755448c498e8c3bc9e07003bcd23b8b8
ndroid_system_OsConstants.cpp
922cc2ab00c681b59a6e2b17a6533477f174f2f5 22-Sep-2015 Tom Cherry <tomcherry@google.com> Remove ANDROID_PROPERTY_WORKSPACE

Bug 23290008

Change-Id: Iee1614fc3501e7af12cc6099cbb67a141a2dfd82
ava_lang_ProcessManager.cpp
f13aa2ce1850c90e5705298bc5a21095b82c7eb8 04-Sep-2015 Neil Fuller <nfuller@google.com> am b8fcb81f: Merge "Revert "Revert "Migrate Collator classes to use ICU4J."""

* commit 'b8fcb81f03613bd18c6a64ff17ef01f17dbe3c57':
Revert "Revert "Migrate Collator classes to use ICU4J.""
3df3bfcbad6f4da20964424c4772985d1b1586a1 26-Aug-2015 Rayhaan Jaufeerally <rayhaan@google.com> Revert "Revert "Migrate Collator classes to use ICU4J.""

The SDK build is now fixed by adding icu4j as a dependency of docs.

This reverts commit 5fc822e7ef47448adccd73ca2ebbd28a068f5136.

Change-Id: Ibac9b40189a83323e5175e8ea26c973eb07bc34f
egister.cpp
ibcore_icu_NativeCollation.cpp
ub.mk
8c36c45d9746cf2143d9d708103bbf3fbb0062e8 18-Aug-2015 Neil Fuller <nfuller@google.com> am 4fd38444: Merge "Revert "Migrate Collator classes to use ICU4J.""

* commit '4fd38444c4cc0fb0b529d4e9e3d7fd05e8edfac6':
Revert "Migrate Collator classes to use ICU4J."
4fd38444c4cc0fb0b529d4e9e3d7fd05e8edfac6 18-Aug-2015 Neil Fuller <nfuller@google.com> Merge "Revert "Migrate Collator classes to use ICU4J.""
5fc822e7ef47448adccd73ca2ebbd28a068f5136 18-Aug-2015 Neil Fuller <nfuller@google.com> Revert "Migrate Collator classes to use ICU4J."

This reverts commit bf7bbff3a512b3350911d129aba5503dcfde9311.

Change-Id: I5e3d3481d1df11d31871d63fd1575cbf46698dee
egister.cpp
ibcore_icu_NativeCollation.cpp
ub.mk
94141ea47ec0d3ebec492933cc9149452e3b9ed8 18-Aug-2015 Neil Fuller <nfuller@google.com> am 0340f95b: Merge "Change the Bidi class over to ICU4J."

* commit '0340f95b122ed18aebb4991b1f8bcddde64effce':
Change the Bidi class over to ICU4J.
8ada31a6212ab1974134d5f8a190ed9f8518646d 18-Aug-2015 Neil Fuller <nfuller@google.com> am 1a48afbe: Merge "Migrate Collator classes to use ICU4J."

* commit '1a48afbeed4601ab60845a20f985800474db16a0':
Migrate Collator classes to use ICU4J.
0340f95b122ed18aebb4991b1f8bcddde64effce 18-Aug-2015 Neil Fuller <nfuller@google.com> Merge "Change the Bidi class over to ICU4J."
bf7bbff3a512b3350911d129aba5503dcfde9311 23-Jul-2015 Rayhaan Jaufeerally <rayhaan@google.com> Migrate Collator classes to use ICU4J.

The following benchmarks have been run and show the performance
gains from calling ICU4J.

----- ICU4J -----
benchmark us linear runtime
CollatorIdentical 6.90 ==============================
CollatorPrimary 3.20 =============
CollatorSecondary 3.79 ================
CollatorTertiary 4.28 ==================
vm: app_process

----- ICU4C -----
benchmark us linear runtime
CollatorIdentical 11.75 ==============================
CollatorPrimary 10.01 =========================
CollatorSecondary 9.88 =========================
CollatorTertiary 10.26 ==========================
vm: app_process

All tests relating to Collation pass after this change.

With respect to CJK character loading time, tests were done on a
Nexus 6 running this change, in the US locale and TRADITIONAL_CHINESE
locale.

In EN-US:
Time to load Traditional Chinese collator after boot: 76ms, 76ms
Time to load again: (39ms, 36ms, 36ms), (36ms, 36ms, 48ms)
In ZH-TW:
Time to load Traditional Chinese collator after boot: 37ms, 36ms
Time to load again: (36ms, 36ms, 36ms), (35ms, 37ms, 35ms)

This seems to indicate the system is creating a Collator on boot meaning
that ICU is caching it after the first creation. So if a device is in the
Traditional Chinese locale, the cost of creating Traditional Chinese
collators should have been absorbed at boot time.

Loading up the CJK ideographs uses up around ~500k of memory. From the
above findings, if the device is in a language requiring those characters
then they should be loaded up on boot in the Zygote, which may mean the
memory is shared across processes wishing to use the data.

Change-Id: I98a1c32c8f58e03d16d694b8a4fca4ced961af8e
egister.cpp
ibcore_icu_NativeCollation.cpp
ub.mk
660d0bea759fc97c34eb0cadfdd353f882820c62 14-Aug-2015 Rayhaan Jaufeerally <rayhaan@google.com> Change the Bidi class over to ICU4J.

The Harmony BidiTest passes before and after this change.

This change requires a corresponding change in libnativehelper
to remove the reference to java_text_bidi.cpp.

After this change (ICU4J):

benchmark us linear runtime
_complicatedOverrideBidi 18.64 =========================
_createBidiFromCharArray 14.28 ===================
_createBidiFromIter 11.54 ===============
_createBidiFromString 11.08 ===============
_hebrewBidi 21.92 ==============================
_reorderVisually 2.41 ===
_requiresBidi 1.37 =
vm: app_process
trial: 0

Before this change (ICU4C):
benchmark us linear runtime
_complicatedOverrideBidi 66.94 ======================
_createBidiFromCharArray 44.25 ==============
_createBidiFromIter 21.76 =======
_createBidiFromString 20.23 ======
_hebrewBidi 89.72 ==============================
_reorderVisually 7.10 ==
_requiresBidi 29.02 =========
vm: app_process
trial: 0

Change-Id: I733ac3f9983b8285883dee70958c5cf8054d334d
egister.cpp
ava_text_Bidi.cpp
ub.mk
18df9cacc1f2e3dec1a61de5165d9be2bae0870d 12-Aug-2015 Lorenzo Colitti <lorenzo@google.com> am 65633b2b: Merge "Properly restore errno if NET_FAILURE_RETRY fails."

* commit '65633b2b8e3b2a56c6a50ed782d852c13ce19602':
Properly restore errno if NET_FAILURE_RETRY fails.
65633b2b8e3b2a56c6a50ed782d852c13ce19602 12-Aug-2015 Lorenzo Colitti <lorenzo@google.com> Merge "Properly restore errno if NET_FAILURE_RETRY fails."
b4af0b52e1190846edde87f352ca722a7d9e0259 11-Aug-2015 Lorenzo Colitti <lorenzo@google.com> Properly restore errno if NET_FAILURE_RETRY fails.

If NET_FAILURE_RETRY fails, it throws an exception. In all but
one codepath, that exception ends up being passed back to Java
land immediately, so it doesn't matter what errno is set to.

However, in the case where we need to retry the socket call with
a sockaddr_in (i.e., NET_IPV4_FALLBACK), we clear the exception
and march on. This means that if errno is touched by
throwErrnoException (strace showed this happening, for example,
if futex() returns EAGAIN), we don't retry the socket call and
instead return the previous EAFNOSUPPORT error to the caller.

Also modify IO_FAILURE_RETRY for consistency.

Bug: 23088314
Change-Id: Ib92771ba2001c2696f83f61f48bd137a7a91a880
ibcore_io_Posix.cpp
d596f01c1431deaf028aa168de6492dc670c5aac 11-Aug-2015 Neil Fuller <nfuller@google.com> am a53c58dd: Merge "Migrate IDNA2003 implementation to ICU4J."

* commit 'a53c58dded9dd21716f2e3c66a8991aba00772f5':
Migrate IDNA2003 implementation to ICU4J.
654ec92a7bcd53944f7ebca64bf3e6bef855ebe5 11-Aug-2015 Neil Fuller <nfuller@google.com> am 001231c8: Merge "Remove libcore AlphabeticIndex and references. This has been replaced by ICU4J\'s library."

* commit '001231c8d362437f7b6c014b1097663eed5ef500':
Remove libcore AlphabeticIndex and references. This has been replaced by ICU4J's library.
a53c58dded9dd21716f2e3c66a8991aba00772f5 11-Aug-2015 Neil Fuller <nfuller@google.com> Merge "Migrate IDNA2003 implementation to ICU4J."
001231c8d362437f7b6c014b1097663eed5ef500 11-Aug-2015 Neil Fuller <nfuller@google.com> Merge "Remove libcore AlphabeticIndex and references. This has been replaced by ICU4J's library."
40574561d805f5cd66d6052228f81d4968bb2808 07-Aug-2015 Elliott Hughes <enh@google.com> am 3e2ce4c7: Merge "Clean up some dead code."

* commit '3e2ce4c71ee13a16f2c7bf58d3a990687e4e5531':
Clean up some dead code.
efe42934a8523f2b051a351e5eceebf6216454ae 06-Aug-2015 Elliott Hughes <enh@google.com> Clean up some dead code.

...so it's harder for it to rise from the dead.

This removes a lot of __APPLE__ cruft and also some unused/untested
big-endian support.

Change-Id: I3296923f96250b6fde60761e9f19e28ad7b847d8
synchronousCloseMonitor.cpp
ortability.h
ndroid_system_OsConstants.cpp
bigint.cpp
ava_lang_ProcessManager.cpp
ava_lang_System.cpp
ibcore_io_Posix.cpp
0517aff14a14236d4714634d9affe4f5b320984d 06-Aug-2015 Craig Cornelius <ccornelius@google.com> Remove libcore AlphabeticIndex and references. This has
been replaced by ICU4J's library.

Change-Id: I1365a18609b3d5bf45ae8341792a01f4e995f5bb
egister.cpp
ibcore_icu_AlphabeticIndex.cpp
ub.mk
9dcac8229f1efd676f3e3b7e8a2f9a2c3eda04d2 30-Jul-2015 Rayhaan Jaufeerally <rayhaan@google.com> Migrate IDNA2003 implementation to ICU4J.

Although this migration uses the deprecated methods in ICU4J's
IDNA implementation, this has to be done to maintain complete
compatibility with the current implementation. This is because
the android API is explicitly documented as implementing the
IDNA2003 standard.

UTS46 is a new standard which aims to ease the transition to
IDNA2008 which is the latest specification for internationalized
domain names. Unfortunately this standard cannot be used in this
instance and will need to be introduced as part of another API.

The following benchmarks show the change in performance this
CL will cause. This seems acceptable for a string conversion.

--- Java ---
benchmark us linear runtime
ToAscii 804 ==============================
ToUnicode 323 ============
vm: app_process

--- Native ---
benchmark us linear runtime
ToAscii 134.0 ==============================
ToUnicode 89.5 ====================
vm: app_process

Change-Id: I96440d338ceeaea63eec490f49e9a35cfa5dc1f2
egister.cpp
ibcore_icu_NativeIDN.cpp
ub.mk
802f8393640db9889fb18faf3a0ea47d82157742 31-Jul-2015 Narayan Kamath <narayan@google.com> am 14c118f9: Merge "Remove Transliterator wrapper class."

* commit '14c118f904655ce63533cc34382946aa07a2109a':
Remove Transliterator wrapper class.
17552b6592aeaaa564725a07e10e8c4b1c8163cb 14-Jul-2015 Rayhaan Jaufeerally <rayhaan@google.com> Remove Transliterator wrapper class.

This change removes the wrapper class in Java which was used for
proxying requests to ICU4c. Now ICU4J is called directly at the
call sites. See: https://android-review.googlesource.com/#/c/162002/

This is done by replacing instantiations of the old Transliterator
class with calls to a static factory in ICU4J which returns a cached
transliterator if available, otherwise creates it on demand.

This change requires that the transliterator resource directories
and source files are added to our java libraries, which increases
the size of core-libart.jar from 2.289 MB to 2.332 MB. Maybe it's
possible to wait until dependencies on ICU4c have been removed to
see if we can save space there.

Change-Id: I2b2f84a051ba9815ba6d346dfe7fb764e39032c4
egister.cpp
ibcore_icu_Transliterator.cpp
ub.mk
e3ea6eb74aa6a1e9bb667f57fdb9ab69050517c1 30-Jul-2015 Elliott Hughes <enh@google.com> am 3fd52b67: Merge "Use __ANDROID__ instead of HAVE_ANDROID_OS."

* commit '3fd52b6723df4903c3f821bd9c2ca5538a516f6c':
Use __ANDROID__ instead of HAVE_ANDROID_OS.
2664be0232a806b056e6654bf386f374b6d72969 30-Jul-2015 Elliott Hughes <enh@google.com> Use __ANDROID__ instead of HAVE_ANDROID_OS.

Change-Id: I3ede85c49332ea5d1525c1c4c0254413f50d6979
ava_lang_System.cpp
2b2745ef12b61d9f959a4f9e787130bcfda038b3 24-Jul-2015 Narayan Kamath <narayan@google.com> am 03fcecb1: Merge "Revert "Convert IDN to use ICU4j instead of ICU4c.""

* commit '03fcecb113010cd8963353de25ac2d6c0efbc153':
Revert "Convert IDN to use ICU4j instead of ICU4c."
2bb6745a5d77cc873fa4bb71deb0315ce445cbad 24-Jul-2015 Narayan Kamath <narayan@google.com> am 0409b675: Merge "Convert IDN to use ICU4j instead of ICU4c."

* commit '0409b675acc48309f8b20f2eeca345d5f5e22ac6':
Convert IDN to use ICU4j instead of ICU4c.
8d7307aed3c02fc9549c15f4bf14ad0a9587cd9d 24-Jul-2015 Narayan Kamath <narayan@google.com> Revert "Convert IDN to use ICU4j instead of ICU4c."

This reverts commit 9fe44362752f86af1d34eed6dca2b6a27ffa7ad8.

Change-Id: I22bd7819c20817be6444ccd11b903ae68f8e7745
egister.cpp
ibcore_icu_NativeIDN.cpp
ub.mk
9fe44362752f86af1d34eed6dca2b6a27ffa7ad8 16-Jul-2015 Rayhaan Jaufeerally <rayhaan@google.com> Convert IDN to use ICU4j instead of ICU4c.

Apache harmony tests still pass after this change, and
new tests have been added to verify that this meets the
specification defined in http://unicode.org/reports/tr46/.

The benchmarks below show the performance penalty from not doing
this natively.
benchmark us linear runtime
JavaToAscii 59.6 =========================
JavaToUnicode 68.9 ==============================
NativeToAscii 11.2 ====
NativeToUnicode 13.8 ======

Change-Id: Ie3fd1d439d9fc2651f5f1773676d12409c430c83
egister.cpp
ibcore_icu_NativeIDN.cpp
ub.mk
c40ab79a5099bd9723b0798ff2881b5657b6cc1e 21-Jul-2015 Narayan Kamath <narayan@google.com> am 83b2235f: Merge "Remove NativePluralRules since we are using ICU4J directly."

* commit '83b2235fb8ecd33af368b0f3948dbdb8455f2358':
Remove NativePluralRules since we are using ICU4J directly.
32b081777608bfb8eee96efc268819495000376a 21-Jul-2015 Narayan Kamath <narayan@google.com> am adcee61e: Merge "Use O_DSYNC instead of O_SYNC when opening a file with mode="rwd"."

* commit 'adcee61e90099981a01306d3d12afdc232b741b1':
Use O_DSYNC instead of O_SYNC when opening a file with mode="rwd".
011e5d211ac55099709bdf34bf3eae069b6e9e8e 21-Jul-2015 Narayan Kamath <narayan@google.com> am eed9cb15: Merge "Transition the Normalizer class to call ICU4j."

* commit 'eed9cb152b69d6e0b7c6fb892187af656bb6a955':
Transition the Normalizer class to call ICU4j.
32563bc5c9df70a52cfb5c2a9d6ab865e8200092 14-Jul-2015 Rayhaan Jaufeerally <rayhaan@google.com> Remove NativePluralRules since we are using ICU4J directly.

The following benchmark shows the time taken for ICU4C to
run quantityForInt(5) on the US locale as _native, and _java
shows the time taken for the ICU4J PluralRules.select(5)
method to be run on the US locale.

benchmark us linear runtime
_java 2.27 ==============================
_native 1.89 =========================
vm: app_process

Change-Id: I2ca9a6636ea48bf922eceedce1cf3ef357cc4b99
egister.cpp
ibcore_icu_NativePluralRules.cpp
ub.mk
49bd5fad754ebf395cae71822fcfc7783e7a3b78 03-Jul-2015 Philippe Longepe <philippe.longepe@intel.com> Use O_DSYNC instead of O_SYNC when opening a file with mode="rwd".

It distinguishes O_DSYNC and O_SYNC since Linux 2.6.33 which gives
more options to user space applications. The perfomance
RandomAccessFile will get benefit from this. And it makes the
implementation of "rwd" complied with the spec.

Change-Id: Ic8bf88cf449ba46abe21a44abf50d0bbc62e4bb0
Signed-off-by: Philippe Longepe <philippe.longepe@intel.com>
Signed-off-by: zhongjie <zhongjie.shi@intel.com>
Tracked-On: https://jira01.devtools.intel.com/browse/GMINL-12476
ndroid_system_OsConstants.cpp
37dd239f099f1d1b2aca030a2fe458669718cd78 14-Jul-2015 Rayhaan Jaufeerally <rayhaan@google.com> Transition the Normalizer class to call ICU4j.

The following benchmarks were obtained by running parts of NormalizerTest
through caliper.
benchmark us linear runtime
ICU4cIsNormalized 5.09 ======
ICU4jIsNormalized 5.22 ======
ICU4cNormalize 22.56 ==============================
ICU4jNormalize 21.97 =============================

NormalizerTest still passes after this change on Shamu. This change also
removes the JNI calls and their associated C++ wrappers.

Change-Id: I9081c899a76fdb3a341ca5ecd54c32cd6e6a0387
egister.cpp
ibcore_icu_NativeNormalizer.cpp
ub.mk
da7c55646893668176e49344685199e9d6cb3283 13-Jul-2015 Neil Fuller <nfuller@google.com> am 3ac95481: Merge "Fix sockaddr_un length calculation"

* commit '3ac9548103b09c043ba534b4c27207e0d1994149':
Fix sockaddr_un length calculation
3ac9548103b09c043ba534b4c27207e0d1994149 13-Jul-2015 Neil Fuller <nfuller@google.com> Merge "Fix sockaddr_un length calculation"
60306d7e0b2be98cdcf76a56965f87befde5b2f1 11-Jul-2015 Elliott Hughes <enh@google.com> am 47556a37: Merge "libcore: libexpat now exports its headers."

* commit '47556a37c33456761caa01dbe4af203ce61e1b8c':
libcore: libexpat now exports its headers.
b63760e6c13575531616e9201780a92247c0e7d5 10-Jul-2015 Elliott Hughes <enh@google.com> libcore: libexpat now exports its headers.

Change-Id: I000a85c858b75ea1bf0892abc721c032065556aa
rg_apache_harmony_xml_ExpatParser.cpp
2550a252387631b49a00d2ee5587717cd2a6dda3 09-Jul-2015 Neil Fuller <nfuller@google.com> Fix sockaddr_un length calculation

The previous commit 0ab1a26ca767ae36fbbe27b62893670b208fa494
contained a mistake that would break interoperability between
AF_UNIX sockets bound via libcore.io.Posix and (for example)
socket_make_sockaddr_un in socket_local_client.c.

Added a test to confirm the expected sun_path is used and
fixed copyright and toString() in UnixSocketAddress.

Bug: 3106438
Change-Id: I42539a3580abc5ab6445669309e1b1d784cd3bc4
ibcore_io_Posix.cpp
8ccce6c06fbd0342dc27c962a79ede91dea37ea4 10-Jul-2015 Neil Fuller <nfuller@google.com> am ba956108: Merge "Add Os.unlink"

* commit 'ba956108c05b923b20d6b31b4d491c9263fa1231':
Add Os.unlink
ba956108c05b923b20d6b31b4d491c9263fa1231 10-Jul-2015 Neil Fuller <nfuller@google.com> Merge "Add Os.unlink"
abc39ad1b0e9b1714c5d943702be152c923e116b 09-Jul-2015 Narayan Kamath <narayan@google.com> am 495081c7: Merge "Add EUSERS to OsConstants."

* commit '495081c7ed601dc37904961f544704f7d20cd77c':
Add EUSERS to OsConstants.
cfef2bbbfedc208b282f3fbd580c894691240806 07-Jul-2015 Lazar Trsic <Lazar.Trsic@imgtec.com> Add EUSERS to OsConstants.

Required by Camera framework code.

Change-Id: I8bcac8f1ced50c76614f566a6e624967a18a25e1
ndroid_system_OsConstants.cpp
b3697ef2fcef7f054e8468b2f009ae9781f7450a 09-Jul-2015 Neil Fuller <nfuller@google.com> am d30aac6c: Merge "Rearrange how AF_UNIX sockets are handled for accept()"

* commit 'd30aac6cafe07baaa84efcf82f9c5108e7a5c0b7':
Rearrange how AF_UNIX sockets are handled for accept()
5e8f82f2592498e75ac4685ccd0d31d601d37bdc 09-Jul-2015 Neil Fuller <nfuller@google.com> Add Os.unlink

Add the unlink method to Os/Posix.

Bug: 3106438
Change-Id: I86f2d7b6aa98e355ec3220b6a1230033b79f0176
ibcore_io_Posix.cpp
0ab1a26ca767ae36fbbe27b62893670b208fa494 07-Jul-2015 Neil Fuller <nfuller@google.com> Rearrange how AF_UNIX sockets are handled for accept()

Contains the following changes:
1) Introduction of UnixSocketAddress / removal of InetUnixAddress.
2) Os/Posix classes now take SocketAddress instead of InetSocketAddress.
3) Removal of native code that dealt with InetUnixAddress.
4) Introduction of OsConstants.UNIX_PATH_MAX to hold the maximum sun_path
size.
5) Update tests.

Bug: 3106438
Change-Id: I47a3618387f21599bfbfd0dc9a821839bf47b39b
etworkUtilities.cpp
etworkUtilities.h
ndroid_system_OsConstants.cpp
ibcore_io_Posix.cpp
4c1a4a30822756276f043eefb666e9a0adac3331 06-Jul-2015 Neil Fuller <nfuller@google.com> am bfa4c455: Merge "Add OsConstants.TIOCOUTQ"

* commit 'bfa4c45506e9db20be6cfc58bf3ae5d2837c21bb':
Add OsConstants.TIOCOUTQ
bfa4c45506e9db20be6cfc58bf3ae5d2837c21bb 06-Jul-2015 Neil Fuller <nfuller@google.com> Merge "Add OsConstants.TIOCOUTQ"
bfeb65cf8d8dedb0291d4ae216d477f66b9de944 03-Jul-2015 Neil Fuller <nfuller@google.com> Add OsConstants.TIOCOUTQ

Bug: 3106438
Change-Id: I768337cf46c302d9dc5aec614346b3c51ef9c963
ndroid_system_OsConstants.cpp
90246a0ae7117d780e077c9e84cdb73ff5b44af7 02-Jul-2015 Jeff Sharkey <jsharkey@android.com> Add getxattr/setxattr/removexattr syscalls.

Bug: 20275572

(cherry picked from commit 82d076b51f6fe7c1cbd1f37414be36eaaa9b0e56)

Change-Id: Ifb808e69dddb88eba253ddf4273013828eab16f6
ndroid_system_OsConstants.cpp
ibcore_io_Posix.cpp
f6634641d7f1889e902d6b71c8c993e2880fa20f 02-Jul-2015 Jeff Sharkey <jsharkey@android.com> am be80d883: Merge "Add getxattr/setxattr/removexattr syscalls." into mnc-dev

* commit 'be80d8833a8058eba9e510a29b84dfac711cf5db':
Add getxattr/setxattr/removexattr syscalls.
82d076b51f6fe7c1cbd1f37414be36eaaa9b0e56 02-Jul-2015 Jeff Sharkey <jsharkey@android.com> Add getxattr/setxattr/removexattr syscalls.

Bug: 20275572
Change-Id: I958056f757f095ad6278624e293a5583d9cee822
ndroid_system_OsConstants.cpp
ibcore_io_Posix.cpp
d83541c42befc7024922f4797f48869f19605c2d 29-Jun-2015 Yusuke Sato <yusukes@google.com> am 82ce6726: Merge "Rename ZipEntryName to ZipString"

* commit '82ce67260fb0113fd9566264097c13a984e7ac7b':
Rename ZipEntryName to ZipString
29e82853a6ba484db9e03aef7a859c1b561a9677 25-Jun-2015 Yusuke Sato <yusukes@google.com> Rename ZipEntryName to ZipString

Also add a 4th parameter to StartIteration(). This is for
https://android-review.googlesource.com/#/c/156771/.

Bug: 21957428
Change-Id: I9c724b3c6657bad6b7288008c485e1b22f0b2b29
ava_util_jar_StrictJarFile.cpp
bfa687ff9d7aa6cef970804cd1d82c042f15ff28 18-Jun-2015 Erik Kline <ek@google.com> Add ENONET to OsConstants

Bug: 19537384
Change-Id: I155f3db741bdac96f1ecb1ccb15b31faab85e819
(cherry picked from commit 959a23e37abdfa26059e3770eacfe36dea8fc01c)
ndroid_system_OsConstants.cpp
3089cca907ff248d81643960a88cdb12568a4cfa 19-Jun-2015 Erik Kline <ek@google.com> am 6b7f0d72: Merge "Add ENONET to OsConstants"

* commit '6b7f0d7258692481041c2a9b1405edf826b4c730':
Add ENONET to OsConstants
959a23e37abdfa26059e3770eacfe36dea8fc01c 18-Jun-2015 Erik Kline <ek@google.com> Add ENONET to OsConstants

Change-Id: I155f3db741bdac96f1ecb1ccb15b31faab85e819
ndroid_system_OsConstants.cpp
bb81c1422b1a2f5f055bafbbf32ab3e13c957345 09-Jun-2015 Andreas Gampe <agampe@google.com> am 5c92a51a: Merge "Implemented ceil and floor in StrictMath"

* commit '5c92a51a3077d01bcce41038157c294089ecb297':
Implemented ceil and floor in StrictMath
5dc9ac81424bce11e8fa917c96d7f1689c83472e 02-Jun-2015 agicsaki <agicsaki@google.com> Implemented ceil and floor in StrictMath

Translated the ceiling and floor methods from the fdlibm library into Java
to remove transition to native code for these functions. Also updated the test
cases to include corner cases such as +infinity, -infinity, NaN, and interesting
values covering all lines of code found by random testing. Additionally updated
benchmarks to cover several interesting values for both functions.

Running the new benchmarks (for each function, taking the average of several calls
with differing values that ensure full line coverage) showed improved performance.

Ceiling before = 140.91 ns
Ceiling after = 86.55 ns

Floor before = 137.33 ns
Floor after = 86.64 ns

Bug: 21594029
Change-Id: I337c47daa2ae599bd0c0e7f11af4e457f96f9f9f
ava_lang_StrictMath.cpp
d2a3075106f700f229750c228de989b789b7dacd 01-Jun-2015 Neil Fuller <nfuller@google.com> Configure ICU4C without relying on build-time flags

The presence of the build-time flags appears to cause ICU4C
to open the .dat file again as a fallback if it fails to
find a config value. This is even though the .dat file is
explicitly mapped using udata_setCommonData().

Bug: 19960867
Bug: 19961406
(cherry-picked from commit 79fdcc64ea2d9234f258dac57f04b1017a573311)

Change-Id: I03f0f2d661dd2de2b0db085519159f7deb60816d
ibcore_icu_ICU.cpp
7074d6b010b142f606c27f34b40df0ce8812d322 03-Jun-2015 Neil Fuller <nfuller@google.com> am 811586f0: Merge "Configure ICU4C without relying on build-time flags"

* commit '811586f02f914e6b201f13b166609184e05ffa78':
Configure ICU4C without relying on build-time flags
79fdcc64ea2d9234f258dac57f04b1017a573311 01-Jun-2015 Neil Fuller <nfuller@google.com> Configure ICU4C without relying on build-time flags

The presence of the build-time flags appears to cause ICU4C
to open the .dat file again as a fallback if it fails to
find a config value. This is even though the .dat file is
explicitly mapped using udata_setCommonData().

Bug: 19960867
Bug: 19961406
Change-Id: I2b311747b3dc2a6d3e76169b926c8b45f3a7a0d6
ibcore_icu_ICU.cpp
0fe8702f1ea73ca65460fcf4a32332fee3e1cfee 19-May-2015 Narayan Kamath <narayan@google.com> am 7217bcc6: Merge "Remove support for big endian native orders."

* commit '7217bcc6d9e2b88990b84c700c549389b078d853':
Remove support for big endian native orders.
fc0a7474f3922e2ef087e1d225ce56f52edaf7aa 18-May-2015 Narayan Kamath <narayan@google.com> Remove support for big endian native orders.

We assume Android == LITTLE_ENDIAN in several places already.

bug: 20957523

Change-Id: Iff96c95c587c866285e0c35075dd014c8973bb92
egister.cpp
ava_nio_ByteOrder.cpp
ub.mk
3476de58b33f3d57784d8f69b2e7fc9c6a15ac69 11-May-2015 Narayan Kamath <narayan@google.com> Fix file descriptor leak when opening invalid archives.

bug: https://code.google.com/p/android/issues/detail?id=171099
Change-Id: I8425d8289839579f1122c61a61ea403f3a7c49fb
ava_util_jar_StrictJarFile.cpp
43debffa2465891d6b25d63274eb00a5902b13b5 28-Apr-2015 Narayan Kamath <narayan@google.com> Remove libcore_util_CharsetUtils.cpp

For some reason, this was made empty but not removed in
83c7414449bc406b.

Change-Id: I9a2b613d2281db450e46aa824ce3a6a865fddb8c
ibcore_util_CharsetUtils.cpp
39f72b16952fbe4aff5c2e080ce9f7f6dbb1b93d 28-Apr-2015 Jeff Hao <jeffhao@google.com> Merge "Removed offset and value from String and added StringFactory."
83c7414449bc406b581f0cb81ae06e7bce91403c 15-Jan-2014 Jeff Hao <jeffhao@google.com> Removed offset and value from String and added StringFactory.

Change-Id: I55314ceb906d0bf7e78545dcd9bc3489a5baf03f
egister.cpp
ibcore_util_CharsetUtils.cpp
ub.mk
92d6ba31a225d55ab65a0ede80310d91f3f52c30 17-Apr-2015 Dan Albert <danalbert@google.com> Ensure proper integer promotion for bit shifts.

Previously this was a 32-bit value being shifted up to 63 bits, which
is undefined behavior.

Change-Id: I99bb38508937f7a33d5c2c841b7cc32d5f374ef9
ava_lang_RealToString.cpp
3f7c674bd1d220d1a8c149b5658145171c28094f 22-Apr-2015 Narayan Kamath <narayan@google.com> Move java.nio.Charsets to libcore.util.

This isn't public API, and isn't related to NIO. It's only ever
used by java.lang.String.

bug: 10898787
Change-Id: I4e194406746b88ba7268c2553e467e7e05400b40
egister.cpp
ava_nio_charset_Charsets.cpp
ibcore_util_CharsetUtils.cpp
ub.mk
91b872537645a0bf307cc4ee73cc4591f749fd4c 16-Apr-2015 Elliott Hughes <enh@google.com> Implement mapLibraryName in Java.

No need for native code here.

Change-Id: Iaeb0369b5638a6681fd94fd999641801719aaea2
ava_lang_System.cpp
f7d3d845d1db889060262cfb7a9f73a2c4fdb7f3 07-Apr-2015 Travis Keep <rocketman@google.com> Switch DateIntervalFormat/RelativeDateTimeFormatter to ICU4J

Information below from the existing benchmarks on a hammerhead. All
times given in microseconds. Note that the new version is slower,
but this is a small difference in absolute terms and means less
maintenance for libcore.

The ICU team is rewriting some of the underlying code in ICU4J
for a future ICU release which may alter performance.

ICU4C + JNI
DateIntervalFormat_formatDateRange_DATE 67.8
DateIntervalFormat_formatDateRange_DATE_TIME 76.0
DateIntervalFormat_formatDateRange_TIME 54.8
ICU4J
DateIntervalFormat_formatDateRange_DATE 179
DateIntervalFormat_formatDateRange_DATE_TIME 181
DateIntervalFormat_formatDateRange_TIME 167

ICU4C + JNI
RelativeDateTimeFormatter_getRelativeDateTimeString 151.6
RelativeDateTimeFormatter_getRelativeDateTimeString_ABBREV 169.0
RelativeDateTimeFormatter_getRelativeTimeSpanString 27.8
RelativeDateTimeFormatter_getRelativeTimeSpanString_ABBREV 27.7
ICU4J
RelativeDateTimeFormatter_getRelativeDateTimeString 366.5
RelativeDateTimeFormatter_getRelativeDateTimeString_ABBREV 377.6
RelativeDateTimeFormatter_getRelativeTimeSpanString 23.2
RelativeDateTimeFormatter_getRelativeTimeSpanString_ABBREV 22.9

Bug: 20127691
Change-Id: I1ebc08fd9c974743026ae1e6c848fb4de8aa0e48
egister.cpp
ibcore_icu_DateIntervalFormat.cpp
ibcore_icu_RelativeDateTimeFormatter.cpp
ub.mk
345d118df6eef599a1ad0ea18022ad1f74633f10 07-Apr-2015 Neil Fuller <nfuller@google.com> Merge "Changes to enable timezone data overrides for ICU and libcore"
d0ef6d8b070d2892caf59d1f7501ff05667be6cc 27-Mar-2015 Narayan Kamath <narayan@google.com> Implement BreakIterator in terms of icu4j.

Note that we need manual range checks in our wrapper because
the ICU4J implementation will clamp offsets to either end of
the input text.

benchmark results :

text benchmark us linear runtime
LIPSUM BreakIterator 326.02 =====
LIPSUM IcuBreakIterator 333.47 ======
LONGPARA BreakIterator 227.67 ====
LONGPARA IcuBreakIterator 228.68 ====
GERMAN BreakIterator 79.09 =
GERMAN IcuBreakIterator 81.30 =
THAI BreakIterator 1654.11 ==============================
THAI IcuBreakIterator 1646.75 =============================
THAI2 BreakIterator 44.28 =
THAI2 IcuBreakIterator 42.67 =
TABS BreakIterator 12.79 =
TABS IcuBreakIterator 12.53 =
ACCENT BreakIterator 16.26 =
ACCENT IcuBreakIterator 15.37 =
EMOJI BreakIterator 17.71 =
EMOJI IcuBreakIterator 18.34 =
SPACES BreakIterator 16.86 =
SPACES IcuBreakIterator 15.78 =
EMPTY BreakIterator 9.22 =
EMPTY IcuBreakIterator 9.96 =
NEWLINE BreakIterator 11.08 =
NEWLINE IcuBreakIterator 9.96 =
BIDI BreakIterator 19.54 =
BIDI IcuBreakIterator 18.96 =

Change-Id: I72023dd605da8e33974aa3181506f0d9c7bc180e
egister.cpp
ibcore_icu_NativeBreakIterator.cpp
ub.mk
cf14cc4ee0de8c3e4f9a1dab7a5a91d09264dee9 27-Mar-2015 Neil Fuller <nfuller@google.com> Add a test to confirm that TZ data is in sync

Android has two sources of timezone data: one used by
bionic / libcore code, and one used by ICU.

When ICU4J is added more tests can be added to confirm
that ICU4C and ICU4J agree on time zone and other sources
of data like CLDR and the ICU version itself.

Bug: 19941636
Change-Id: I614392a876e19a55e362489f142eec71beaf5547
ibcore_icu_ICU.cpp
317d6e12782e069e4fde06ed0f9a976a7c49f580 02-Mar-2015 Neil Fuller <nfuller@google.com> Changes to enable timezone data overrides for ICU and libcore

Bug: 19941636
Change-Id: Id587be99f645978c2e1067c9f8eef26d6d63ec27
ibcore_icu_ICU.cpp
00cbc7bc0d9900fbbefeb8602bd7f808381c462b 24-Mar-2015 Christopher Ferris <cferris@google.com> Merge "Remove forced alignment code."
08d97aee56db51f718544562f5b74671be34dfaf 15-Mar-2015 Christopher Ferris <cferris@google.com> Remove forced alignment code.

The move from to gcc 4.8 to gcc 4.9 for arm32 introduced a bug in this
code. The original code is trying to out smart the compiler by arch, but
we got caught. Running benchmarks, the amount of time we save by doing this
is in the nanosecond range, so just let the compiler figure things out on
it's own.

It turns out for aarch64, x86, x86_64, two of the functions produce exactly
the same code. For swapLongs, x86/x86_64 produces slightly different code
but is about the same performance.

For arm32, letting the compiler optimize also leads to about the same
performance.

Adding unit tests and benchmark code for these.

Bug: 19692084

Change-Id: I858eb3147ef1e9e2c1894ddb226cdddcc0baf933
ibcore_io_Memory.cpp
8046f4dbe122ac5f362693550360b54cd6943a4b 23-Mar-2015 Narayan Kamath <narayan@google.com> Use compiler pragmas instead of flags.

This lets us turn off warnings for a small segment of the code
instead of the entire project.

bug: 19823499
Change-Id: I9309e9a33bddc33e8c100a49416e95b2a56e2385
ibcore_icu_NativeIDN.cpp
ub.mk
2254ea8858e26ed402a297f4c97448abb76fdabd 19-Mar-2015 Narayan Kamath <narayan@google.com> Merge "Set -Wno-deprecated-declarations to access deprecated IDNA2003 API."
7417225fe4bdec82cc1cd1c2c8a48077a9c99b95 19-Mar-2015 Lorenzo Colitti <lorenzo@google.com> Merge "Fix an ntohs/htons issue."
1b9b1c8e53a4610438d597fc21d8a147092d05fd 18-Mar-2015 Fredrik Roubert <roubert@google.com> Set -Wno-deprecated-declarations to access deprecated IDNA2003 API.

In libcore_icu_NativeIDN.cpp there are calls to the deprecated IDNA2003
API which means that this code as of ICU55 no longer will compile
without specifying the -Wno-deprecated-declarations compiler flag.

bug: 19823499
Change-Id: Id5cd5da0d6c3ce62a5c642c99364d29eaebe7709
ub.mk
e0273519773d7b14680fe0aa8bc180836042f245 17-Mar-2015 Lorenzo Colitti <lorenzo@google.com> Fix an ntohs/htons issue.

When converting between sockaddr_ll and PacketSocketAddress, we
use ntohs in both directions. Converting from sockaddr_ll to
PacketSocketAddress should use ntohs instead.

This doesn't actually affect anything, because ntohs and htons
identical, but it is conceptually wrong.

Change-Id: Idd3cfcc11c4d6b7fed0c4b75a7935547f67eda12
ibcore_io_Posix.cpp
cca38d9d5bf6b1364cc22caad336851ed8058443 17-Mar-2015 Narayan Kamath <narayan@google.com> Remove executable permissions from java_lang_StringToReal.cpp

Change-Id: I0e36d41a822db1b9607543a9033f190eed5363c8
ava_lang_StringToReal.cpp
f5fc4ade3ab082f545e2aafdb1942c1f14e0df5d 13-Mar-2015 Lorenzo Colitti <lorenzo@google.com> Also support IPv4 fallback in the SocketAddress version of sendto.

Change-Id: I90bbc9661b0a48bb19c9c1c5aa4cd493f4dff2fa
ibcore_io_Posix.cpp
00bb2a5e5d619cbfd172793ca9bf7130192765eb 12-Mar-2015 Lorenzo Colitti <lorenzo@google.com> Support packet sockets in libcore.

Bug: 19704592
Change-Id: Ic424e4c36f6de028df4a3095f57a08b68da78033
ndroid_system_OsConstants.cpp
ibcore_io_Posix.cpp
a8b7587c5001db3489c64ac1d16c254a683f76bd 11-Mar-2015 Lorenzo Colitti <lorenzo@google.com> Add a version of sendto that takes a SocketAddress.

Only the byte[] version for now. The ByteBuffer version will be
added later.

Bug: 19704592
Change-Id: I35c5f305b5828ff3315e42aae72aa4b01839e2fc
ibcore_io_Posix.cpp
b2a9923fa2006e384013734d3e1c6a7fbe3d9074 16-Jan-2015 Lorenzo Colitti <lorenzo@google.com> Make it possible to use AF_INET sockets created by libcore.

Currently, it's possible to create AF_INET sockets using:

Libcore.os.socket(AF_INET, ...

but such sockets can't be used for anything, because os.bind()
and os.connect() automatically convert IPv4 addresses to
IPv4-mapped addresses (e.g., 192.0.2.1 to ::ffff:192.0.2.1),
and passing a sockaddr_in6 to a system call on an AF_INET socket
causes the kernel to return EAFNOSUPPORT.

When this happens, retry using an unmapped IPv4 address. We
could also call getsockopt(SOL_SOCKET, SO_DOMAIN) before every
system call and pass in the appropriate socket address
structure, but that would cause these socket functions to make
two system calls instead of one and would probably halve the
performance of sendto(). This way, there's only one system call
for most sockets (including all AF_INET6 sockets created in
Java), and two system calls only in the rare case of a socket
that's explicitly created as AF_INET.

Bug: 18558481
Bug: 19704592
Change-Id: I71b3728b6a72b742e156d4c60db65e88b9a9e51e
ibcore_io_Posix.cpp
4a308520182e7c87ef5a1fb0814a16638d8cd427 10-Mar-2015 Fredrik Roubert <roubert@google.com> Replace work-around with proper DecimalFormatSymbols helper function.

The helper function createWithLastResortData() was introduced in ICU 4.8
and eliminates the need to call the private default constructor:

http://bugs.icu-project.org/trac/ticket/7392

Change-Id: I6d615b23c28c449442aeab6d37b7d92e844a7ae8
ibcore_icu_NativeDecimalFormat.cpp
2882e51204fdf7cc38c04adf1fc1b3b38c2a9f43 10-Mar-2015 Erik Kline <ek@google.com> Merge "Add support for netlink sockets and addresses."
8f5b46d72e5c1b1b1dd4357580c4fb5a60e3f4de 26-Jan-2015 Erik Kline <ek@google.com> Add support for netlink sockets and addresses.

Additionally:
- support bind and connect calls with SocketAddresses
- getsockname and getpeername can return a NetlinkSocketAddress

Developed in conjunction with:
https://android-review.googlesource.com/135490

Bug: 18581716
Change-Id: I760a06cdb9bdb26c734fb02cf668a94de982e2b6
ndroid_system_OsConstants.cpp
ibcore_io_Posix.cpp
a04b5c3d39232c7616591883ee2124520e3ab622 06-Mar-2015 Elliott Hughes <enh@google.com> Explicitly specify the icu:: namespace.

Bug: 15350832
Change-Id: I8d84f3e50b643806ccf01190797c69ce6445b539
cuUtilities.cpp
cuUtilities.h
ava_util_regex_Matcher.cpp
ava_util_regex_Pattern.cpp
ibcore_icu_AlphabeticIndex.cpp
ibcore_icu_DateIntervalFormat.cpp
ibcore_icu_ICU.cpp
ibcore_icu_NativeBreakIterator.cpp
ibcore_icu_NativeConverter.cpp
ibcore_icu_NativeDecimalFormat.cpp
ibcore_icu_NativeNormalizer.cpp
ibcore_icu_NativePluralRules.cpp
ibcore_icu_RelativeDateTimeFormatter.cpp
ibcore_icu_TimeZoneNames.cpp
ibcore_icu_Transliterator.cpp
rg_apache_harmony_xml_ExpatParser.cpp
b86b5104cb218849c1adeb38fa20c8a9110cadb7 26-Feb-2015 Nick Kralevich <nnk@google.com> Add ST_* constants to OsConstants

Expose ST_* constants via OsConstants. Without these constants being
exposed, it's impossible to meaningfully use StructStatVfs.f_flag
returned from the Os.statvfs() call.

For now, @hide the new constants.

Change-Id: I82536521972e9e87a1936dd712b9e8153d120cc1
ndroid_system_OsConstants.cpp
7bcff480531c1aa18de118c6f36dd397d5e1ad86 07-Feb-2015 Tao Bao <tbao@google.com> Use ICU for relative time formatting

Rewrite the DateUtils' relative time formatting APIs
(getRelativeTimeSpanString, getRelativeDateTimeString) to use ICU ones.
Two APIs that take withPreposition parameter are not changed. Because
(a) ICU doesn't provide functionality to format preposition; (b) They
are not really computing relative time but instead calling
formatDateRange() to get the absolute time/date string.

Benchmark results on aosp_hammerhead-userdebug:

before:
benchmark us linear runtime
DateUtils_getRelativeDateTimeString 127.1 ==========================
DateUtils_getRelativeDateTimeString_ABBREV 145.0 ==============================
DateUtils_getRelativeTimeSpanString 28.0 =====
DateUtils_getRelativeTimeSpanString_ABBREV 27.9 =====

now:
benchmark us linear runtime
RelativeDateTimeFormatter_getRelativeDateTimeString 119.2 ==========================
RelativeDateTimeFormatter_getRelativeDateTimeString_ABBREV 133.8 ==============================
RelativeDateTimeFormatter_getRelativeTimeSpanString 24.6 =====
RelativeDateTimeFormatter_getRelativeTimeSpanString_ABBREV 24.7 =====

Bug: 19146457
Bug: 5252772
Change-Id: Ief74608354964a17e42191d7b1a58964f3a9acfd
egister.cpp
ibcore_icu_RelativeDateTimeFormatter.cpp
ub.mk
5ccb2b3621f633708eb3ae1fd0f27f88bdb32a9d 29-Jan-2015 Narayan Kamath <narayan@google.com> Fix deflater in / out counts for inputs > 4G.

The underlying inflate & deflate can process any amount of data
correctly, since the protocol is chunk based (the size of each
chunk is limited to 32 bits, usually) and there is no limit to
the number of chunks.

On LP32, the stream counters are limited to 32 bit counts and
the manual recommends that the caller maintain their own counters
to support larger counts.

<quote>
Note however that the strm.total_in and strm_total_out counters may be
limited to 4 GB. These counters are provided as a convenience and are
not used internally by inflate() or deflate(). The application can
easily set up its own counters updated after each call of inflate()
or deflate() to count beyond 4 GB.
</quote>

Change-Id: I066e1141935154773360c1b9f94c56bd604f8474
ipUtilities.cpp
ipUtilities.h
ava_util_zip_Deflater.cpp
ava_util_zip_Inflater.cpp
4ea6715f1cb6edbce3cbbc4c50e1a712ec70d565 30-Jan-2015 Narayan Kamath <narayan@google.com> Merge "Work around 32 bit glibc bug."
8702d65450d23f8d624782dfe7f98d920c4add8f 29-Jan-2015 Narayan Kamath <narayan@google.com> Work around 32 bit glibc bug.

Don't allow glibc's TEMP_FAILURE_RETRY on 32 bit hosts, it will
truncate 64 bit return types such as from lsee64, sendfile etc.

Change-Id: I009510a69ec80d42a17192bf960b056456bd88f5
ortability.h
8b24781abd1d49963e5a52a48b85ab5191991ff3 19-Jan-2015 Jingwei Zhang <jingwei.zhang@intel.com> Fix the infinite loop issue of the conversion from string to double

This patch provide the additional check for “z”.
The “if” statement checks whether the double precision value z, is at the end of a binade
(a term used to describe the set of numbers in a binary IEEE 754 floating-point format that
all have the same exponent, i.e., a binade is the interval [2n, 2n+1) for some value of n.)
If so, it needs to adjust for the change of ulp (unit of least precision is the spacing
between two consecutive floating-point numbers, i.e., the value the least significant digit
represents if it is 1). The adjustment is done by the “simpleShiftLeftHighPrecision” routine.
This is all necessary, except when z is close to denormal (i.e. DOUBLE_TO_LONGBITS(z)==DOUBLE_NORMAL_MASK)
where no adjustment is needed since the ulp should remain the same once z becomes denormal.

This means we can remove the old hack that counted how many times we'd
incremented or decremented, so this patch removes the DECREMENT_DOUBLE
and INCREMENT_DOUBLE macros.

This patch also contains the float equivalent of everything mentioned above,
plus some new tests.

Finally, this patch removes the USE_LL conditional compilation because it
was always true.

Bug: 18087920
Change-Id: I4a9112f012dfd9eeb8db89f0652528b6c02e8f1e
Signed-off-by: Jingwei Zhang <jingwei.zhang@intel.com>
Signed-off-by: Mingwei Shi <mingwei.shi@intel.com>
ava_lang_StringToReal.cpp
30c669166d86d0bd133edfb67909665fb41d29b6 16-Jan-2015 Narayan Kamath <narayan@google.com> Remove fcntlLong, use fcntlInt for F_SETFD instead.

fcntlLong works too, but only because of the syscall conventions
happen to place the lower 32 bits of our jlong in the right register.

This change also gets rid of fcntlLong because there aren't any
documented fcntl calls that take a 64 bit integer argument.

Change-Id: I8d187d5b906195fc663675a07a5f116dcd210d16
ibcore_io_Posix.cpp
9169032f055cb8f007fcb9df979518177e22c833 19-Jan-2015 Narayan Kamath <narayan@google.com> Merge "Add fcntlInt."
c8d9ea662de6f4856b28907b4119087cfc5a44d2 16-Jan-2015 Narayan Kamath <narayan@google.com> Add fcntlInt.

Hidden for now, for use from the frameworks.

Change-Id: I30d95b28ecbc422aaa5bf28fb2f288c3ca026493
ibcore_io_Posix.cpp
791bd64d1d5d369fa21ecc1b276d918255916d54 16-Jan-2015 Narayan Kamath <narayan@google.com> Merge "Cache class and field lookups in StrictJarFile."
3a1658cb79ccc96e81eca64966de4ada725a2e54 08-Jan-2015 Elliott Hughes <enh@google.com> Fix and clean up FileDescriptor.isSocket.

The original logic was accidentally inverted. This prevented sockets
from being untagged, which would result in cancelled requests stalling
out with sub-optimal TCP ZeroWindow detection instead of sending RST
packets.

Add a comment explaining how this works.

Switch from SO_ERROR (which has a side-effect) to SO_DEBUG (which doesn't).

Add a unit test.

Bug: 18706592

(cherry picked from commit 4f263fdfcc0c9e3ebadeaa6717e93a130c09320c)

Change-Id: I6746f4e0e5a6c9788cdcf35f74ccca5aa9a0e8b4
ava_io_FileDescriptor.cpp
4f263fdfcc0c9e3ebadeaa6717e93a130c09320c 08-Jan-2015 Elliott Hughes <enh@google.com> Fix and clean up FileDescriptor.isSocket.

The original logic was accidentally inverted. This prevented sockets
from being untagged, which would result in cancelled requests stalling
out with sub-optimal TCP ZeroWindow detection instead of sending RST
packets.

Add a comment explaining how this works.

Switch from SO_ERROR (which has a side-effect) to SO_DEBUG (which doesn't).

Add a unit test.

Bug: 18706592
Change-Id: Ib822a9727668908e04f87a6deb104dcebf333f05
ava_io_FileDescriptor.cpp
59059202e212a6f593d324a824a71d909e1ee8c9 08-Jan-2015 Narayan Kamath <narayan@google.com> Cache class and field lookups in StrictJarFile.

Iterating over a list of ZipEntries might otherwise do more
work than necessary and create unnecessary garbage. Also, this
is the idiom for such JNI code.

Change-Id: I869289a32e0822bab9ca0345cdc3fc5aaa8adc7e
ava_util_jar_StrictJarFile.cpp
8f0f2ac7fcd8f366a78cc51181d065ab93385e46 17-Dec-2014 Elliott Hughes <enh@google.com> Add various system calls needed by the zygote.

Bug: 18719692
Change-Id: I91a943369bc3b331e7e06e758f729b008c3c041c
ibcore_io_Posix.cpp
564312855784c9ae57e2af73affc48b0807b13ee 17-Dec-2014 Elliott Hughes <enh@google.com> Don't TEMP_FAILURE_RETRY calls that can't fail.

It turns out that while GCC doesn't care, clang is unhappy with us
because it notices that we're comparing an unsigned value (like a uid_t)
against -1:

libcore/luni/src/main/native/libcore_io_Posix.cpp:727:12: error: comparison
of integers of different signs: 'typeof (getegid())' (aka 'unsigned int')
and 'int' [-Werror,-Wsign-compare]
return TEMP_FAILURE_RETRY(getegid());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Bug: 18759467
Change-Id: If71b11cbdd0cda2b8efcc1706eb49856c3770bb8
ibcore_io_Posix.cpp
fa542091e45db699a937c5ac0191194405107827 16-Dec-2014 Elliott Hughes <enh@google.com> Fix poll to never return EINTR.

Bug: 18759467
Change-Id: Ia5b97a55318b5990ad6b80d15641223aa4fb06f5
ibcore_io_Posix.cpp
fc0498f0dd9af3c86b67d0536fceaf9ed04781fb 16-Dec-2014 Elliott Hughes <enh@google.com> Remove unnecessary include directives.

These are all picked up by virtue of the libraries that we use.

Change-Id: Ib5e86c65d53f3448d5f1d0c0d24f0f63ef5f1868
ub.mk
f2ea64c866ffe95885e928b6c8967f74810c5558 13-Dec-2014 Elliott Hughes <enh@google.com> Fix Mac build (control reaches end of non-void function).

Change-Id: I94d85f1848db7c787f423ca9e7f7695ffd754a56
ibcore_io_Posix.cpp
4538be5358f41f4844621fb3bc47c21e7b171477 13-Dec-2014 Elliott Hughes <enh@google.com> Merge "Fix Mac build (unused parameter)."
5e92aa60a8a7103c71a4607ac05880e536f4195e 13-Dec-2014 Elliott Hughes <enh@google.com> Fix Mac build (unused parameter).

Change-Id: I164eb9083cc17f858dcbb0da046184440881395d
ibcore_io_Posix.cpp
500b6aca6b649021d462b861f49ffb10473ba79d 13-Dec-2014 Elliott Hughes <enh@google.com> Remove dependency on AndroidConfig.h.

Change-Id: Ia21083b0392cc5acf5b1bbd7637a0cd0dd1fb01b
ava_lang_System.cpp
62eda73d52868b259e7543723739656680b89caa 13-Dec-2014 Elliott Hughes <enh@google.com> Fix Mac build.

Change-Id: I827c6a8abf37ae181af959b4fd721e2092519fbf
ibcore_io_Posix.cpp
75781e7ed9373d97f5959b5b20e7343b8f7e1417 12-Dec-2014 Elliott Hughes <enh@google.com> Fix native registration.

I thought I'd tested my previous change but hadn't.

Change-Id: Ie121b571cc2f767dd4bbe10291a56fe31496e6cc
ibcore_io_Posix.cpp
0d8b5c3692c36837d22c4e7d9c4d7d95f6a10235 12-Dec-2014 Elliott Hughes <enh@google.com> Add pipe2 and O_CLOEXEC to the libcore POSIX API.

@hide right now, but we should expose these at some point.

Bug: 18719692
Change-Id: I0a73606cf089ed307d1ab2916a7df28b3c45aaf0
ndroid_system_OsConstants.cpp
ibcore_io_Posix.cpp
cc4bdc5a64270237c1514b6d56dabaf376bc3e36 11-Dec-2014 Elliott Hughes <enh@google.com> Remove a workaround for an icu4c header file hack.

The hack has been removed.

Change-Id: Ia70f0cf05a47c68351e97d77b0675cbef67891d0
cuUtilities.h
c544b580a1a5535c2d653b58f3843ef61c21d646 11-Dec-2014 Elliott Hughes <enh@google.com> Don't include private bionic headers.

Change-Id: I25691f095e1b6b2009c01b6e990fffb84b12f7f2
ortability.h
ibcore_io_Posix.cpp
db12621f7603e011ce47759877d34181905e8a64 03-Dec-2014 Narayan Kamath <narayan@google.com> StrictJarFile: Fix CheckJNI crashes due to invalid UTF-8 bytes.

Use the java.lang.String(byte[]) constructor instead of NewStringUTF
since the former replaces malformed and unmappable characters instead
of faulting on them. This also gives us some degree of consistency
when it comes to how these names are handled.

From StrictJarFile's perspective, the entry name is only used by the
JarVerifier for two things :

(1) keeping track of entries it has seen - this only requires the entry
name to be stable.

(2) looking up entry attributes in the manifest - this will continue
to work if the same bogus encoding is used in the manifest. If the
manifest uses valid UTF-8, the attribute lookup will fail and we'll
return no certificates for the entry (this is a good thing).

Finding an entry by name remains unaffacted because (as before) we
require byte by byte equality with the input.

The longer term fix is to disallow non-UTF entry names altogether but
that needs a bit more advance notice.

bug: 18584205
Change-Id: I7bb3e5bb09962d768a28aca4a6ece4dd54aa3473
ava_util_jar_StrictJarFile.cpp
99a0c82619a88c6aea038757cf14090f5d33afeb 27-Nov-2014 Neil Fuller <nfuller@google.com> Fix crash in selector.wakeup() with closed selector

Selector.wakeup() can throw an undeclared IOException
(from native code).

This is not compatible with the signature of wakeup(). In prior
Android releases no exception is thrown in this case.

This change reverts the behavior to the same as prior Android
releases.

Many thanks to diddysbestbud@ for the report.

Bug: https://code.google.com/p/android/issues/detail?id=80785
Bug: 18548071
(cherry picked from commit 1791f6be1bd2733babb0c862ad8509f4c847b48f)

Change-Id: I19ee879dcd783655d8a402e12855a5fa1f1eb90c
ibcore_io_Posix.cpp
1791f6be1bd2733babb0c862ad8509f4c847b48f 27-Nov-2014 Neil Fuller <nfuller@google.com> Fix crash in selector.wakeup() with closed selector

Selector.wakeup() can throw an undeclared IOException
(from native code).

This is not compatible with the signature of wakeup(). In prior
Android releases no exception is thrown in this case.

This change reverts the behavior to the same as prior Android
releases.

Many thanks to diddysbestbud@ for the report.

Bug: https://code.google.com/p/android/issues/detail?id=80785
Bug: 18548071
Change-Id: I5421e8a0ae1fdf2cde9cb635dae56b4fd02b6ac4
ibcore_io_Posix.cpp
d4fba3b8c91e0961758152fb3f1413c07b869800 26-Nov-2014 Elliott Hughes <enh@google.com> Only the Mac doesn't have POSIX clocks.

Change-Id: I7e1dd9759bf3c0ed2964b5cfa5cffab1e5b2cb05
ava_lang_System.cpp
a5e1285a6d5ef8e6602f39cf33277cde2f6bccbf 05-Nov-2014 Ian Rogers <irogers@google.com> resolved conflicts for merge of f9a3c05f to stage-aosp-master

Change-Id: Id4220cfc2f845d04b32404171cde1fd144fe1585
b3aacde3d8af759ee4a7b395c636ea360547d92d 05-Nov-2014 Ian Rogers <irogers@google.com> Move from UniquePtr to std::unique_ptr.

Switch from stlport to libcxx as stlport lacks std::unique_ptr.

Change-Id: I45a3588a8ecf4689521f1df6654ed279a6d0669e
cuUtilities.cpp
ipUtilities.cpp
ipUtilities.h
ava_math_NativeBN.cpp
ava_text_Bidi.cpp
ava_util_jar_StrictJarFile.cpp
ava_util_regex_Matcher.cpp
ava_util_zip_Deflater.cpp
ava_util_zip_Inflater.cpp
ibcore_icu_DateIntervalFormat.cpp
ibcore_icu_ICU.cpp
ibcore_icu_NativeCollation.cpp
ibcore_icu_NativeConverter.cpp
ibcore_icu_NativeDecimalFormat.cpp
ibcore_icu_TimeZoneNames.cpp
ibcore_io_Memory.cpp
ibcore_io_Posix.cpp
rg_apache_harmony_xml_ExpatParser.cpp
e411af9e493e6fcb246fa64e1017a7396e00b735 05-Nov-2014 Ian Rogers <irogers@google.com> am ef4d1341: Merge "Don\'t define DISALLOW_COPY_AND_ASSIGN."

* commit 'ef4d1341e70d2683d5d9f2a8892535ae90eb184c':
Don't define DISALLOW_COPY_AND_ASSIGN.
b4cf28b0406be6b7210328acf5ee4548c5da2bc5 04-Nov-2014 Ian Rogers <irogers@google.com> Don't define DISALLOW_COPY_AND_ASSIGN.

Definition picked up from libnativehelper. Depends upon:
https://android-review.googlesource.com/#/c/113053/

Change-Id: I23a7ba48dcd406c62a440e6c732b95d9780eeb3b
ibcore_icu_ICU.cpp
fa1ab1d7aaa558994815d217d4eeca7e07ff57b3 09-Oct-2014 Elliott Hughes <enh@google.com> Support DecimalFormatSymbols' percent symbol being a string.

Bug: 15476051

(cherry picked from commit a68116c0d8ff9cd517d6b765bf2b8930ed9a3e12)

Change-Id: I70ff647dd20b263596685598186ee2f55e1ef8fa
ibcore_icu_ICU.cpp
ibcore_icu_NativeDecimalFormat.cpp
fcc19aa354bd202f1c7064b8ceb5e56f30c12162 09-Oct-2014 Elliott Hughes <enh@google.com> am a96d6871: Merge "Support DecimalFormatSymbols\' percent symbol being a string."

* commit 'a96d6871503966e8589ee8d929acc68ee1e4d59c':
Support DecimalFormatSymbols' percent symbol being a string.
a68116c0d8ff9cd517d6b765bf2b8930ed9a3e12 09-Oct-2014 Elliott Hughes <enh@google.com> Support DecimalFormatSymbols' percent symbol being a string.

Bug: 15476051
Change-Id: I75514c497f18366b2e1320ea6a62df025a50114f
ibcore_icu_ICU.cpp
ibcore_icu_NativeDecimalFormat.cpp
7ec61c00cdf5f8358a758583d6126faffd10b4f7 24-Sep-2014 Elliott Hughes <enh@google.com> am 352ffc52: Merge "Make libcore compile with BoringSSL."

* commit '352ffc52af68c7f37dc6848f158d66253c11379d':
Make libcore compile with BoringSSL.
352ffc52af68c7f37dc6848f158d66253c11379d 24-Sep-2014 Elliott Hughes <enh@google.com> Merge "Make libcore compile with BoringSSL."
76f599b161f52e331f26a7da950fbb3931713f8e 23-Sep-2014 Elliott Hughes <enh@google.com> am c65e2912: Merge "Revert "Implements some StrictMath functions for improved performance.""

* commit 'c65e2912c305acf0078979ebde6126c0abf5a482':
Revert "Implements some StrictMath functions for improved performance."
130893bd0f3ca148fea10e09d92f27c98dbbf49d 23-Sep-2014 Elliott Hughes <enh@google.com> Revert "Implements some StrictMath functions for improved performance."

This reverts commit 165e2b4075dadb99afc0856ab3c698809a6355a2.
ava_lang_StrictMath.cpp
8383f343119f7a98cbe3b4a5bddc89038ac5c166 04-Sep-2014 Adam Langley <agl@google.com> Make libcore compile with BoringSSL.

NativeBN_putULongInt was cleaned up because of a slightly worrying mix
of signed and unsigned ints, and because of an unneeded preprocessor
test. However, as I look down the rest of the file, there's a lot of it
but I didn't get to fixing it all up.

Bug: 17409664
Change-Id: If0adde83bebf04e7e3be163c1b30ebef75a67d05
Signed-off-by: Adam Langley <agl@google.com>
ava_lang_System.cpp
ava_math_NativeBN.cpp
8f3b150cd86c2eb35229806fda6928501da27cac 26-Aug-2014 Elliott Hughes <enh@google.com> Keep qtaguid quiet by not trying to untag non-sockets.

(cherry-pick of f6cf9efb212e572dcd2e902ca461af6323793dbf.)

Bug: 17203955
Change-Id: I0999fc0ff295986b92e31568d96e321b9e7ffb2c
egister.cpp
ava_io_FileDescriptor.cpp
ub.mk
36111b0acfacaff4d391392e7ddc60274d377fcd 03-Sep-2014 Elliott Hughes <enh@google.com> am 3c4eb717: am 2086177b: Merge "Keep qtaguid quiet by not trying to untag non-sockets." into lmp-dev

* commit '3c4eb717a8dabae361477f613223feb0d3dfaaf6':
Keep qtaguid quiet by not trying to untag non-sockets.
f6cf9efb212e572dcd2e902ca461af6323793dbf 26-Aug-2014 Elliott Hughes <enh@google.com> Keep qtaguid quiet by not trying to untag non-sockets.

Bug: 17203955
Change-Id: I0999fc0ff295986b92e31568d96e321b9e7ffb2c
egister.cpp
ava_io_FileDescriptor.cpp
ub.mk
17cfd09990c2918b2caacac39cdec4d6786913b4 22-Aug-2014 Elliott Hughes <enh@google.com> am 2d6b952b: am 014531bf: Merge "Support narrow am/pm markers in LocaleData." into lmp-dev

* commit '2d6b952b2a8fbc3f2637bd6b8ede1f3e931b2e1a':
Support narrow am/pm markers in LocaleData.
b799123bc221b926a9f189107f2a3619a4da8874 22-Aug-2014 Elliott Hughes <enh@google.com> Support narrow am/pm markers in LocaleData.

(cherry-pick of ebe417d7808ac5bce5bc14d36d6af4c31218326d.)

Bug: 16938600
Change-Id: I7334c1ea57ea0593b3e0bd7943f8a5208c704881
ibcore_icu_ICU.cpp
ebe417d7808ac5bce5bc14d36d6af4c31218326d 22-Aug-2014 Elliott Hughes <enh@google.com> Support narrow am/pm markers in LocaleData.

Bug: 16938600
Change-Id: I7334c1ea57ea0593b3e0bd7943f8a5208c704881
ibcore_icu_ICU.cpp
ae1d4c6df9cc0dee1d1f172d1f71125dc943f35c 20-Aug-2014 Elliott Hughes <enh@google.com> am b45d8a14: Merge "bionic has always had gettid."

* commit 'b45d8a149cf5c85ceb84d8fae0194529a4514adb':
bionic has always had gettid.
bb684af352deca3c885f30dba8fa68f95f873c7c 18-Aug-2014 Piotr Jastrzebski <haaawk@google.com> am 7dac4d28: Merge "Update ziparchive usage to the new API."

* commit '7dac4d2883ccce4ec47e86d8681a942ff1262932':
Update ziparchive usage to the new API.
11592afbbb0b91624cdf4039782d14994b9f5162 20-Aug-2014 Elliott Hughes <enh@google.com> bionic has always had gettid.

Bug: 17049821
Change-Id: I309ecfad7e38cf664518a92d6812ffbd90060b79
ibcore_io_Posix.cpp
dfca713d6fc4e888a498482592d06b99f6c0120e 15-Aug-2014 Piotr Jastrzebski <haaawk@google.com> Update ziparchive usage to the new API.

Bug: 16162465
Change-Id: Iea4d39e1bb74be7ad9041aa3dbb5809d53f63faf
ava_util_jar_StrictJarFile.cpp
f3d5d74d97845437eef2958297280b7b63223c45 12-Aug-2014 Jeff Hao <jeffhao@google.com> am 5fc90ef3: Merge "Implements some StrictMath functions for improved performance."

* commit '5fc90ef30f7c5c5864dae47a8c9f2ac557e62b0d':
Implements some StrictMath functions for improved performance.
165e2b4075dadb99afc0856ab3c698809a6355a2 09-Aug-2014 Emma Meersman <emeersman@google.com> Implements some StrictMath functions for improved performance.

The functions ceil, floor, hypot, IEEEremainder, nextafter, and rint
have all been implemented in Java to save the native call. Benchmarking
numbers to show this performance improvement are included:

Native call (before change):
benchmark=Ceil: 97.40 ns; σ=0.02 ns @ 3 trials
benchmark=Floor: 98.73 ns; σ=0.02 ns @ 3 trials
benchmark=Hypot: 714.62 ns; σ=0.44 ns @ 3 trials
benchmark=IEEEremainder: 180.31 ns; σ=0.08 ns @ 3 trials
benchmark=NextAfterD: 110.47 ns; σ=0.02 ns @ 3 trials
benchmark=NextAfterF: 96.20 ns; σ=0.01 ns @ 3 trials
benchmark=Rint: 92.21 ns; σ=0.02 ns @ 3 trials

Java implementation (after change):
benchmark=Ceil: 47.32 ns; σ=0.01 ns @ 3 trials
benchmark=Floor: 42.03 ns; σ=0.00 ns @ 3 trials
benchmark=Hypot: 69.42 ns; σ=0.37 ns @ 3 trials
benchmark=IEEEremainder: 49.64 ns; σ=0.04 ns @ 3 trials
benchmark=NextAfterD: 63.32 ns; σ=0.17 ns @ 3 trials
benchmark=NextAfterF: 64.67 ns; σ=0.12 ns @ 3 trials
benchmark=Rint: 31.10 ns; σ=0.41 ns @ 10 trials

Change-Id: I9ee926514c0661cdb7a1e6ae3acfe5c31a4b9f20
ava_lang_StrictMath.cpp
aac54fee63127eee2b72ebbbe9db812c726d0dab 11-Aug-2014 Piotr Jastrzebski <haaawk@google.com> am 7f436ca4: Merge "Stop keeping iteration prefix around."

* commit '7f436ca4c733886303685a78f57684c081afe640':
Stop keeping iteration prefix around.
47de3c0211f396910b89f5d4cfa2a7abb985778f 11-Aug-2014 Piotr Jastrzebski <haaawk@google.com> am 597c2557: Merge "Remove memory leak."

* commit '597c2557b0eccb298c66442a5e432ad1b4a90acc':
Remove memory leak.
01dc548e40d242636223d457b0e48845d7027f34 08-Aug-2014 Jeff Hao <jeffhao@google.com> am cf521925: Merge "Implements some math functions for faster performance"

* commit 'cf5219256c9a44e9b215ac645c1823238ebd31d7':
Implements some math functions for faster performance
cf5219256c9a44e9b215ac645c1823238ebd31d7 08-Aug-2014 Jeff Hao <jeffhao@google.com> Merge "Implements some math functions for faster performance"
3544ec2598d2e9fde608d4c23720dfe2f2c18711 08-Aug-2014 Piotr Jastrzebski <haaawk@google.com> am b00b6b6e: Merge "Remove nameLength field from ZipEntry."

* commit 'b00b6b6ee612e57097cf878dd7b41fbeece11b58':
Remove nameLength field from ZipEntry.
8c585e912ae4fd7b0b6f5a2e2ddabed6c70289cf 07-Aug-2014 Piotr Jastrzebski <haaawk@google.com> Remove nameLength field from ZipEntry.

It seems that this field is never used outside the internal constructor so it
can be a local variable instead.

Change-Id: I2aa26fb3fd13c571224a9aee14c7eea93e5c9591
ava_util_jar_StrictJarFile.cpp
8157e6a43292925d7ef4eef0280256bf482bb4ae 07-Aug-2014 Narayan Kamath <narayan@google.com> am 16e0e17c: Merge "Revert "Remove nameLength field from ZipEntry.""

* commit '16e0e17c53f24e694314bec7a658f650d206da58':
Revert "Remove nameLength field from ZipEntry."
63395c66f533eb891a94baf7a984d616829ac340 08-Aug-2014 Piotr Jastrzebski <haaawk@google.com> Stop keeping iteration prefix around.

zip archive makes a copy of a prefix and maintains it's lifecycle now.

Change-Id: I55adc4c9eefee96b80038fb7dbb95dbe498d5a73
ava_util_jar_StrictJarFile.cpp
e1319c51b44045c37dad120a688b2888b29bbc17 08-Aug-2014 Piotr Jastrzebski <haaawk@google.com> Remove memory leak.

Call EndIteration in IterationHandle destructor. This will free the
memory allocated for cookie in StartIteration.

Change-Id: I12c861c7da2437113c669a0c7f41b5585ed94c72
ava_util_jar_StrictJarFile.cpp
c48199457bc0ed96404414ba4d4ad15e4f0fd6bb 07-Aug-2014 Narayan Kamath <narayan@google.com> Revert "Remove nameLength field from ZipEntry."

This reverts commit c4da34ca5792e0c73577f868249fdfe8a11a01f6.

Change-Id: I1b93ecfcb8a867a670af717eb25c7076b7097d5c
ava_util_jar_StrictJarFile.cpp
73d2f49f1f8377ab02cee4e051afc6019bdaed1a 07-Aug-2014 Piotr Jastrzebski <haaawk@google.com> am 11940e20: Merge "Remove nameLength field from ZipEntry."

* commit '11940e20d7967330b369c4d7317294fd45339e59':
Remove nameLength field from ZipEntry.
c4da34ca5792e0c73577f868249fdfe8a11a01f6 07-Aug-2014 Piotr Jastrzebski <haaawk@google.com> Remove nameLength field from ZipEntry.

It seems that this field is never used outside the internal constructor so it
can be a local variable instead.

Change-Id: Icd9e009a24ae22da8f5dfd18b9f0ab80913129d4
ava_util_jar_StrictJarFile.cpp
426c1801d4ac7b2c09b30d165902e6d3b33b01f8 01-Aug-2014 Narayan Kamath <narayan@google.com> am c4cddc7c: Merge "Don\'t account buffer.arrayOffset() twice."

* commit 'c4cddc7cfdd8793ee8bf7d4754917456427ea486':
Don't account buffer.arrayOffset() twice.
8684097cde8c92658a65a4f22c2bb21ab7badb5d 30-Jul-2014 Elliott Hughes <enh@google.com> am d343e355: Merge "Remove an obsolete Pacific/Apia hack."

* commit 'd343e35535a99bad32eea0defc8a3e9c23c9967f':
Remove an obsolete Pacific/Apia hack.
77a1f19296d34e6ab74f044f56fa8a0aaa0e6619 30-Jul-2014 Elliott Hughes <enh@google.com> Remove an obsolete Pacific/Apia hack.

Bug: 7955614
Change-Id: Iecdd939f25579f882c11d2957c2a5667d2f7fd3a
ibcore_icu_TimeZoneNames.cpp
4e4b93ffe988b0a597835d852489573b57e0f3fe 30-Jul-2014 Narayan Kamath <narayan@google.com> Don't account buffer.arrayOffset() twice.

data[OUTPUT_OFFSET] from the perspective of native
code must always be the offset from the start of the
buffer passed in to it.

Change-Id: I4a5c9595aebd105c57ce2239dc95cf85d5bd6256
ibcore_icu_NativeConverter.cpp
599d7b789d5a72f61589c3b0f98da57179128684 30-Jul-2014 Elliott Hughes <enh@google.com> am fd094c48: Merge "Fix Character.getDirectionality."

* commit 'fd094c48fce10bf12593ed057ebc11ef56969df5':
Fix Character.getDirectionality.
2c4a09f2af911621b415e84ee028b768ee0a3fcb 29-Jul-2014 Elliott Hughes <enh@google.com> Fix Character.getDirectionality.

Previously we'd throw ArrayIndexOutOfBoundsException for U+2066..U+2069.
Now we'll return DIRECTIONALITY_UNDEFINED. I've exposed (via @hide) the
underlying icu4c implementation so that frameworks code at least can work
with the new explicit bidi formatting characters.

Bug: 15492712
Change-Id: I96583c7e1c6be26d3f1a857615a1042d58e9feaf
ava_lang_Character.cpp
562ef053263cf7efccb6640c027b9d015956741e 12-Jul-2014 Michael Chen <themichaelchen@google.com> Implements some math functions for faster performance

Changes cosh, exp, expm1, log, log10, sinh, cbrt,
asin, acos, atan, tanh, log1p
These functions are now implemnted in java to
save the overhead of a jni call

Change-Id: I4d3b70dd1693378af5b04cbbe0fecd95d97c1cff
ava_lang_StrictMath.cpp
d354134d15ec9deae6517ea1a0ea8773baf3d6ae 24-Jul-2014 Nick Kralevich <nnk@google.com> OsConstants: add PR_GET_DUMPABLE / PR_SET_DUMPABLE

Expose PR_GET_DUMPABLE and PR_SET_DUMPABLE via java.

This is a cherrypick of two commits from internal master:
* 1fc6b04adc87e752aa35bedb7617b5145d835d7c
* 514b1d21f66caff9f26fcf042882c5115b5431c4

Change-Id: Ibb60ed1d00c3a84fa77a34d0acc56cb995d14e1c
ndroid_system_OsConstants.cpp
514b1d21f66caff9f26fcf042882c5115b5431c4 24-Jul-2014 Nick Kralevich <nnk@google.com> OsConstants: fix mac build

host C++: libjavacore_32 <= libcore/luni/src/main/native/cbigint.cpp
libcore/luni/src/main/native/android_system_OsConstants.cpp:385:45: error: use of undeclared identifier 'PR_GET_DUMPABLE'
initConstant(env, c, "PR_GET_DUMPABLE", PR_GET_DUMPABLE);
^
host C++: libjavacore_32 <= libcore/luni/src/main/native/java_io_File.cpp
libcore/luni/src/main/native/android_system_OsConstants.cpp:386:45: error: use of undeclared identifier 'PR_SET_DUMPABLE'
initConstant(env, c, "PR_SET_DUMPABLE", PR_SET_DUMPABLE);
^
2 errors generated.

Change-Id: I2086795f9dcefdbe264c8c53b0df3149001c66ae
ndroid_system_OsConstants.cpp
a7d1afa5f8ff5714b8c44f27aab793122fe2155f 24-Jul-2014 Nick Kralevich <nnk@google.com> Merge "OsConstants: add PR_GET_DUMPABLE / PR_SET_DUMPABLE" into lmp-dev
1fc6b04adc87e752aa35bedb7617b5145d835d7c 24-Jul-2014 Nick Kralevich <nnk@google.com> OsConstants: add PR_GET_DUMPABLE / PR_SET_DUMPABLE

Expose PR_GET_DUMPABLE and PR_SET_DUMPABLE via java.

Change-Id: Ibb60ed1d00c3a84fa77a34d0acc56cb995d14e1c
ndroid_system_OsConstants.cpp
df624c1cc36dc17e4051d1100a3400aeb4252511 25-Jun-2014 Narayan Kamath <narayan@google.com> Fix handling of invalid locales in Date/DecimalFormatSymbols.

For locales whose language code is "und" we use Locale.ROOT
instead. This also fixes two other corner cases :

- We were using the wrong locale to fetch timezone strings
when the input locale was null. we now use the same locale
throughout by making sure we don't perform any subsititutions
in LocaleData.get.

- Adds a clearer comment about the broken serialization
behaviour.

bug: 15849709

(cherry picked from commit 043a1424a4e3bbb5abc9d9e11c9c088b20f4ca7d)

Change-Id: I716fb421fb8643dedebb3a7797a76ed1dd86c548
ibcore_icu_ICU.cpp
ac89b307fd132d44ac55b9109833730cbc2e86fc 21-Jul-2014 Narayan Kamath <narayan@google.com> Implement Locale.forLanguageTag in java.

This prevents us from having to parse ICU locale IDs
or construct them in java. Note that the changes to
LocaleTest bring us in line with the spec (some of the
previous tests demonstrated wonky ICU4C behaviour we
didn't want).

This change includes a minor fix to unicode extension
parsing, we now accept keywords with empty values which
the spec allows.

bug: 15661724
bug: 15849709

(cherry picked from commit bf098bb6345b0917d645d809f4d703e6a0c904f4)

Change-Id: I9b5417dd32bd758655085a484db071959edb774e
ibcore_icu_ICU.cpp
5c0472fd7c53464e526bb833707551d85dbafec1 25-Jun-2014 Narayan Kamath <narayan@google.com> Fix handling of invalid locales in Date/DecimalFormatSymbols.

For locales whose language code is "und" we use Locale.ROOT
instead. This also fixes two other corner cases :

- We were using the wrong locale to fetch timezone strings
when the input locale was null. we now use the same locale
throughout by making sure we don't perform any subsititutions
in LocaleData.get.

- Adds a clearer comment about the broken serialization
behaviour.

bug: 15849709

Change-Id: I95e7eb0ccb7458711038ce9b1c76b3279acda9d6
ibcore_icu_ICU.cpp
bf098bb6345b0917d645d809f4d703e6a0c904f4 21-Jul-2014 Narayan Kamath <narayan@google.com> Implement Locale.forLanguageTag in java.

This prevents us from having to parse ICU locale IDs
or construct them in java. Note that the changes to
LocaleTest bring us in line with the spec (some of the
previous tests demonstrated wonky ICU4C behaviour we
didn't want).

This change includes a minor fix to unicode extension
parsing, we now accept keywords with empty values which
the spec allows.

bug: 15661724
bug: 15849709

Change-Id: If9417ab4cb545fdb8b9a0a47a7eade6ebbe33ba8
ibcore_icu_ICU.cpp
6f685a5321576cfd1cdd5267492676fe9b1deab4 10-Jul-2014 Elliott Hughes <enh@google.com> am 82efa5dd: am dde7a735: Merge "Switch libcore to the new icu."

* commit '82efa5dddfdb3318b2c9bbf47471001607afb5e1':
Switch libcore to the new icu.
e390c9157503c045c7924474fb2f75405e5d6e65 10-Jul-2014 Elliott Hughes <enh@google.com> Switch libcore to the new icu.

Change-Id: I58ec1fafdf5524538ac14c52d561bf93d5a6c946
ub.mk
ee3b18bf309096da1987b31567e2b9d7934b37df 25-Jun-2014 Ian Rogers <irogers@google.com> am ca6fa02b: am 236f03fd: Merge "Don\'t return NULL as a jint."

* commit 'ca6fa02b3f2bd5d9d30143e9318601258846097e':
Don't return NULL as a jint.
fec498e588633a019ea7c93e3a8cca12bb1b3f02 25-Jun-2014 Ian Rogers <irogers@google.com> Don't return NULL as a jint.

Build fix.

Change-Id: I49a566c3c34d2040e092689e52b0039c8195de03
ibcore_io_Posix.cpp
40987596c5ddf87b2b8cddaa8f4bd3c4c28d4bac 23-Jun-2014 Neil Fuller <nfuller@google.com> am 3a47dee2: am cb821758: Merge "Build fix: Remove reference to deleted java_io_Console function"

* commit '3a47dee23bc298f8814089b9590e59c46ad6b347':
Build fix: Remove reference to deleted java_io_Console function
f53e9d6701c6bd9730acb7c6f960a84461e95e4a 23-Jun-2014 Neil Fuller <nfuller@google.com> am 3568b562: am c477bf9e: Merge "Unimplement Console.readPassword and remove test"

* commit '3568b5622585cdde1f15503784971653710fc2aa':
Unimplement Console.readPassword and remove test
55845eab3f391a30b50e1c186479935b14fa44da 23-Jun-2014 Neil Fuller <nfuller@google.com> Build fix: Remove reference to deleted java_io_Console function

The function was deleted by
1f3014901704f3ae81538773b8a0b382945adc8d

Bug: 12491103
Change-Id: If75f1f05d6a72cac7b7a86b7616bae870615452e
egister.cpp
1f3014901704f3ae81538773b8a0b382945adc8d 20-Jun-2014 Neil Fuller <nfuller@google.com> Unimplement Console.readPassword and remove test

ConsoleTest.test_readPassword* fails CTS tests.

Context: Under standard Android applications the
System.console() method will return null.

The Console.readPassword() method must turn off echo.

Under automated tests the ConsoleTest is exercising
a Console object with fake stdout / stdin streams to
get around the absence of a System.console().

setEcho() is hardcoded to use stdin / stdout in
the native code. Under the test runners stdin / stdout
are not connected to a TTY leading to a ENOTTY.

Under Android readPassword is unimportant. Rather than leaving
untested security-related code the password methods are being
unimplemented. It is unlikely this code has ever been used on
Android given the absence of a System Console instance.

Bug: 12491103
Change-Id: I755c014e6b53236f5bef0535be137dd721918b44
ava_io_Console.cpp
ub.mk
a1eb5e8aa202df11f7b43d4b3dea74a9cc18229d 18-Jun-2014 Narayan Kamath <narayan@google.com> am 9f4d9667: am cac5dab2: Merge "Fix getISO3Country and getISO3Language."

* commit '9f4d966767bdf4fba4735aacc72d32cbb07fd4fd':
Fix getISO3Country and getISO3Language.
ca6c2dfd21fef61f179223fb710db791802068d5 18-Jun-2014 Narayan Kamath <narayan@google.com> Fix getISO3Country and getISO3Language.

For backward compatibility, locales constructed with 3 letter
countries and languages must return those languages and countries
from these methods. With our strict language tag interpretation, these
were being omitted or transformed to und.

We fix this by passing only the language code (or the country code
with a fixed language) down to ICU, which will then deal with it
correctly.

bug: 15638049

Change-Id: I517a82496a2a4c36b1ae9234f7d2d4eb89b34ffe
ibcore_icu_ICU.cpp
324bf991656e86dce9a58c82123d4b0390a393b5 16-Jun-2014 Narayan Kamath <narayan@google.com> am 9e8e91cd: am 67831d38: Merge "Pass BCP-47 tags and not Locale.toString results to ICU."

* commit '9e8e91cd9808d4d5d959743bcd96d2c30b9e9ef4':
Pass BCP-47 tags and not Locale.toString results to ICU.
4cf6f6b5b639d2415ff48c1cb04ca6c8d71f5e33 16-Jun-2014 Narayan Kamath <narayan@google.com> am 5ee062c0: am 92908994: Merge "Fix bogus define checks and a typo."

* commit '5ee062c07d3c83cf520209a3f859fbf09ded1fdc':
Fix bogus define checks and a typo.
cf72e81434e362e266eda34d2836bb2c0cff2cec 12-Jun-2014 Ying Wang <wangying@google.com> Merge "Fix Mac build."
05b8ecaaf828f1657720f8a1b5ae10e22dff6fd7 12-Jun-2014 Ying Wang <wangying@google.com> Fix Mac build.

Change-Id: Id2d480e76e6fae403a5b1dd1c7572ff97b5f066f
ortability.h
807240dec338efb3931793b2ec415d9b36bef245 12-Jun-2014 Narayan Kamath <narayan@google.com> am 1a3be41c: am f577d759: Merge "Remove unnecessary loop in uloc_forLanguageTag."

* commit '1a3be41c5642dcac3f5d1ce795e52b5e0cdea26b':
Remove unnecessary loop in uloc_forLanguageTag.
159973cc791d457defee8538008283277977f23c 12-Jun-2014 Narayan Kamath <narayan@google.com> am 9cf8ea5c: am 92bd303d: Merge "Implement Locale.toLanguageTag without ICU support."

* commit '9cf8ea5cb1870b84de6e77d000ae53d54c828f68':
Implement Locale.toLanguageTag without ICU support.
15229913a41c5a543ce356230c9919ab14557f27 11-Jun-2014 Ian Rogers <irogers@google.com> am 209d4528: am 0a58ece3: Merge "Fix Mac build."

* commit '209d452845cb371854a940455e60496b029ac422':
Fix Mac build.
07faf03b116fc5ce7b03a4f5404b20f54da73540 11-Jun-2014 Ian Rogers <irogers@google.com> am cc6d37df: am 4aa9da3f: Merge "Build fix."

* commit 'cc6d37df1373291d98718f7c93dbb5cd65d4c0bb':
Build fix.
e47efca0c45d284f372c5e5618c3b51bf2a07e29 11-Jun-2014 Ian Rogers <irogers@google.com> am a97fc534: am a3f1cb68: Merge "Remove deprecated WITH_HOST_DALVIK."

* commit 'a97fc53412f89f211433406d86e5674def6d3314':
Remove deprecated WITH_HOST_DALVIK.
efae3837b3eb79dea3400735fdcdd5a39020e0b0 11-Jun-2014 Ian Rogers <irogers@google.com> Fix Mac build.

Change-Id: I32fdb9dabbc87d49e0be82ea39c2eea6f452fd6f
ibcore_io_Posix.cpp
67831d38a1c4ea5419f3c61bf4cbcef3704a96d9 16-Jun-2014 Narayan Kamath <narayan@google.com> Merge "Pass BCP-47 tags and not Locale.toString results to ICU."
a94266074c7b82720fd2cecfb37ab8da85f1b296 30-May-2014 Elliott Hughes <enh@google.com> Pass BCP-47 tags and not Locale.toString results to ICU.

ICU can't handle the new toString forms for scripts etc.
and it's also guaranteed to deal with BCP-47 tags correctly.

Most of the changes in this patch are required to keep
backwards compatibility for getDisplayCountry string etc. in
the face of the transformations toLanguageTag performs.

A few tests were changed, but for the better.

The tagalog -> filipino charlie foxtrot will be dealt with
in a follow up change.

Co-Authored-By: Narayan Kamath <narayan@google.com>

Change-Id: Ia7f26d92a0e38c4bbb1d839c0fbd8ad16a473bf5
cuUtilities.cpp
cuUtilities.h
ibcore_icu_AlphabeticIndex.cpp
ibcore_icu_DateIntervalFormat.cpp
ibcore_icu_ICU.cpp
ibcore_icu_NativeBreakIterator.cpp
ibcore_icu_NativeCollation.cpp
ibcore_icu_TimeZoneNames.cpp
857e3a0f4f1f0d381a06d69c8facac5d59d6461e 13-Jun-2014 Narayan Kamath <narayan@google.com> Fix bogus define checks and a typo.

RT_* constants are enum members in the UAPI so we can't
use #define checks for them. Also fix a typo in the define
check for an IFA_ constant.

More generally, we should get rid of all these conditional
checks for target builds because we know what version of the
UAPI we have in bionic. We should move these conditional
checks under #if HOST_BUILD or something similar.

bug: 15602893

Change-Id: I3affc10773ade4dac68c176f79962ca8ad312579
ndroid_system_OsConstants.cpp
5133494975abc1ab7e9afc779dfda18cf46be079 11-Jun-2014 Narayan Kamath <narayan@google.com> Remove unnecessary loop in uloc_forLanguageTag.

When uloc_forLanguageTag fails with a
U_STRING_NOT_TERMINATED_WARNING or with a
U_BUFFER_OVERFLOW_EXCEPTION, we know precisely
how many characters we need to allocate to make the
call succeed.

Change-Id: Ie761b9c7279d3c6f6d432285155a7087fab6d066
ibcore_icu_ICU.cpp
12ca8820818b604c6fc30f025857ec443c83d4a3 11-Jun-2014 Narayan Kamath <narayan@google.com> Implement Locale.toLanguageTag without ICU support.

This is the first part of an effort to avoid having
to construct and parse ICU locale IDs and to instead
use language tags as inputs to all ICU APIs.

Only one minor unit test adjustment was required, and
that change brings the test closer in line with the
spec.

Change-Id: I8abc0e3b868dd73e4fb9e36b6db19853eb99e6ac
ibcore_icu_ICU.cpp
37dd0ac5767197bf7e3e90f1a5d4e54c8f1fe93d 10-Jun-2014 Ian Rogers <irogers@google.com> Build fix.

Change-Id: I52559cfcc806dfe0d8682be50a6078cb678e4169
ibcore_io_Posix.cpp
3deabd220cf7b1ca0824987e90b8ecc07087f05a 24-May-2014 Ian Rogers <irogers@google.com> Remove deprecated WITH_HOST_DALVIK.

Bug: 13751317
Fix the Mac host build:
- conditionally define constants using pre-existing pattern,
- make Posix calls that the Mac doesn't support throw
UnsupportedOperationException.

Change-Id: Ib68887cbe36ab167d042eb96c7834bce0651b078
ortability.h
ndroid_system_OsConstants.cpp
ibcore_io_Posix.cpp
a87d87cd6e6c10e7a7b7f6db25390038a882d37d 04-Jun-2014 Neil Fuller <nfuller@google.com> am 1163499c: am 1c4ee545: Merge "Add interruptibility/wake on close to FileChannel.lock()"

* commit '1163499ceae64096abc0a87a6e7cb9c83412dad9':
Add interruptibility/wake on close to FileChannel.lock()
8add3229ceb13f2aa5d15b84cc59f5ecc6b90214 17-Apr-2014 Neil Fuller <nfuller@google.com> Add interruptibility/wake on close to FileChannel.lock()

There is no obvious way of automated testing given the test
would have to spawn a separate process to lock a file (and
flock is not available on devices). It has been tested
manually with multiple processes on host and a device.

Bug: 13927110
Change-Id: Ie2e565d4965e7aa6392b0eb32e55cdf50d7f61c5
ibcore_io_Posix.cpp
d0670ff3daabc31b06e21039964e848b957a978c 21-May-2014 Neil Fuller <nfuller@google.com> am 1ebe5eaf: am 4447d4ae: am 8e34bfb3: Merge "Ensure NET_FAILURE_RETRY return -1 in case of an error"

* commit '1ebe5eaf1fe0b8cc761ed089e2f318d678388e80':
Ensure NET_FAILURE_RETRY return -1 in case of an error
5d7c0a378be3f7f505b30e634e7aabf072c4edd0 15-May-2014 Serguei Katkov <serguei.i.katkov@intel.com> Ensure NET_FAILURE_RETRY return -1 in case of an error

According to contract NET_FAILURE_RETRY / IO_FAILURE_RETRY
should return -1 and set pending exception in case of an
error. Not setting -1 was leading callers to assume a
success.

Change-Id: I995fa97f8ee8993a379f21582a14567818ea64bd
Signed-off-by: Serguei Katkov <serguei.i.katkov@intel.com>
ibcore_io_Posix.cpp
3e58734d651080009c9190c7062837fca5c7cf4e 13-May-2014 Paul Jensen <pauljensen@google.com> Add support for network-specific host name resolution.

For now all such support is hidden.

Change-Id: I932f73158a8f6e3ccc36c319d138180dff2aa070
ortability.h
ibcore_io_Posix.cpp
5c1acb43c314a7048341f1ab36799fb6675505f4 10-May-2014 Elliott Hughes <enh@google.com> Merge "Add android.system.Os.link for link(2)."
04428d61d7000e17ab21d08a1d672c34eb68f6e2 10-May-2014 Elliott Hughes <enh@google.com> Add android.system.Os.link for link(2).

Bug: 14683762
Change-Id: Ieeba1d2d0c5e9c05e85c6ffbaeb5a7febc69238c
ibcore_io_Posix.cpp
1ff70d59a9ac0cafce11c9b1e6e98785dabc8979 09-May-2014 Elliott Hughes <enh@google.com> Add missing 'const'.

Change-Id: I20311836b80bc655a5ae389ef2f49b2a09f79744
ibcore_icu_ICU.cpp
3879b91e1baee17ecd51c653200ebdafc011020c 08-May-2014 Elliott Hughes <enh@google.com> Ensure consistent (backwards-compatible) capitalization for yesterday/today/tomorrow.

Bug: 14493853
Change-Id: I971ffc2d47534aef67df951725fcd16802ea6d54
ibcore_icu_ICU.cpp
6bc20cd8fc6784a75158d8f1db27802a12b28f94 28-Apr-2014 Serguei Katkov <serguei.i.katkov@intel.com> Fix BN to use correct size of array

NativeBN_litEndInts2bn uses len as a size of the generated array
while it should be wlen for 64-bit.

This will fix the following BigIntegerTest cases:
- BigIntegerTest#test_Constructor_ILjava_util_Random
- BigIntegerTest#test_hashCode

Change-Id: Ife98d11cf94cd5568e55163f98fc4fe3de9d3918
Signed-off-by: Serguei Katkov <serguei.i.katkov@intel.com>
Reported-by: Marcus Oakland <marcus.oakland@arm.com>
ava_math_NativeBN.cpp
ce28fdcf0dd0b8072f7463b7488632cb31cf0fa6 30-Apr-2014 Elliott Hughes <enh@google.com> Merge "Use __SIGRTMIN so bionic can hide our signal from causal passers-by."
6c2959598d8eb91c75718d0777e666dd8f1bfb11 30-Apr-2014 Elliott Hughes <enh@google.com> Use __SIGRTMIN so bionic can hide our signal from causal passers-by.

Change-Id: Ib16b048bb8d849ee6f54251d0c8cc7f782121452
synchronousCloseMonitor.cpp
5215e4c0db7530519981f1e505e6db82401802f2 25-Apr-2014 Nick Kralevich <nnk@google.com> add prctl / PR_SET_NO_NEW_PRIVS

Add java wrappers for prctl and PR_SET_NO_NEW_PRIVS.

Change-Id: I649a755ea9354b0290b25292bc65901b1528c1d5
ndroid_system_OsConstants.cpp
ibcore_io_Posix.cpp
ad85992a32668bdd5230e884b424ee813178340a 29-Apr-2014 Elliott Hughes <enh@google.com> libcore.io.OsConstants is dead; long live android.system.OsConstants!

Change-Id: I3951c1349842adf7dfbb7458c76c982646804ccb
egister.cpp
ndroid_system_OsConstants.cpp
ibcore_io_OsConstants.cpp
ub.mk
5d930cadc8f62aee5f18e7921296fe66a54f18ab 24-Apr-2014 Elliott Hughes <enh@google.com> Groundwork towards making the Libcore.os functionality public.

Change-Id: Ie700aa16d91fba53fc5eb2555829cb74d84b12ad
ibcore_io_Posix.cpp
f0d40d662d9dfdb04215c718961765837d2cf00c 11-Apr-2014 Neil Fuller <nfuller@google.com> libcore changes to support asynchronous close interruption

Previously AsynchronousSocketCloseMonitor was used to handle
socket interruption on close. To support the same for
FileChannel it has been renamed to AsynchronousCloseMonitor.
The Java class was already called this.

FileInputStream, FileOutputStream, RandomAccessFile will
now throw IOException if a connection is closed by another
thread during read. Thread.interrupt() continues to have no effect
on streams.

FileChannel will now throw AsynchronousCloseException during
reads and writes if the file is closed, per the documentation.

FileChannel will now throw ClosedByInterruptException during
reads and writes if the thread reading/writing is interrupted.

Note: FileChannel.lock() will probably still not not throw
AsynchronousCloseException, though it probably should.

This change also has impact on external/conscrypt and
frameworks/base.

Change-Id: I37de3e7d1a005a73821221e6156d10b95c595d7a
Bug: 13927110
synchronousCloseMonitor.cpp
synchronousCloseMonitor.h
synchronousSocketCloseMonitor.cpp
synchronousSocketCloseMonitor.h
ibcore_io_AsynchronousCloseMonitor.cpp
ibcore_io_Posix.cpp
ub.mk
0d18ebc5a68d096ce2aa5b5af09bb38453007d7c 22-Apr-2014 Neil Fuller <nfuller@google.com> Merge "Change DecimalFormat.setRoundingMode() behavior to stay in spec"
09adf7b54b3ce9959a588a6bec99e2468cded924 16-Apr-2014 ccornelius <ccornelius@google.com> Remove include of private ICU include and set constant size for buffer in
libcore_icu_NativeCollation.cpp

Change-Id: I31ae75707b7036ab5b509c88915648fbaf7d76a5
ibcore_icu_NativeCollation.cpp
c96651d01dc87a20aa718d60feaff6611451852e 09-Apr-2014 Neil Fuller <nfuller@google.com> Change DecimalFormat.setRoundingMode() behavior to stay in spec

The serialization tests revealed that some DecimalFormat instances
could not be round-tripped. The reason is that the setRoundingMode()
method was setting a non-zero rounding increment, which cannot
be persisted, and also creates patterns that are outside of the
DecimalFormat spec.

Addressed the fact that ICU4C appears to support
RoundingMode.UNNECESSARY now by deleting special-case code.

Changed SerializationStressTest to use canonical DecimalFormat
patterns:

The ones chosen had a couple things that were not ideal:
1) Putting '-' in quotes causes ICU (for non-obvious reasons)
treat the negative pattern prefix as not being default. Default
in this case means "the positive prefix with a preceding '-'.
Removing the quotes meant it would recognize the pattern as
not needing everything after ;., so the pattern would be shrunk.
2) The positive pattern was also not one ICU could deal with
fully. ICU changed "#.#" to "#0.#" at parse time (which can be
corrected with a setMinimumIntegerDigits(0)). It's not clear why
ICU cannot deal with parsing "#.#" when it can produce it, but
there is a long comment in decimfmt.cc suggesting it is
intentional and to avoid format producing empty strings.

The pattern has been changed to one that ICU can handle and would
choose when the various serialized fields are read back. This is
necessary because NativeDecimalFormat compares the patterns and
not just the serialized fields. Leaving the pattern check part of
equals() means that two non-spec patterns will not be considered
equal(), which is important while Android allows non-spec patterns.
Restricting support in DecimalFormat to the documented subset of
characters is not worth the effort and may cause problems
elsewhere.

Change-Id: I2de588458b86619733c0dc1692d526f179059910
Bug: 11668227
cuUtilities.cpp
de0eb683370d789e7bb25673b350b8dbf2ba5d69 11-Apr-2014 Narayan Kamath <narayan@google.com> Set ICU's default locale from Locale.getDefault.

bug: 2541757
Change-Id: I5de58be7e8a701f2c40182ea54bceff85ec1aad2
ibcore_icu_ICU.cpp
1bc030b6c8a52e1911efcd58d6fbc7f982649167 04-Apr-2014 Elliott Hughes <enh@google.com> Finish moving away from LD_LIBRARY_PATH on Android.

We'll still use LD_LIBRARY_PATH if it's set, for testing or for the
host, but we now ask the dynamic linker what to do.

Bug: 12585421
Change-Id: I1457a63ead89fa8f8aeabc002c0b9038295b886e
ava_lang_System.cpp
1d6c936ab01da702aab6c7e578e2c74cdc90b8a4 18-Mar-2014 Kenny Root <kroot@google.com> NativeBN: use bn_correct_top on negative BN

If you use BN_bin2bn, it will call bn_correct_top for you. However,
since this code is poking into the structure of the BIGNUM itself
without using API, we must call it ourselves.

Before the test_negativeValues_superfluousZeroes would fail with this
confusing error:

libcore.java.math.BigIntegerTest#test_negativeValues_superfluousZeros
junit.framework.AssertionFailedError: expected -1374707309 but was -1374707309
at junit.framework.Assert.assertEquals(Assert.java:99)
at libcore.java.math.BigIntegerTest.test_negativeValues_superfluousZeros(BigIntegerTest.java:171)

Bug: 12761797
Change-Id: I724c1313e4febca8ce2bda9d10f9b5ebde96a6b1
ava_math_NativeBN.cpp
4f3bca749bdc8be8abf7555b315f308a2c8c14a7 13-Mar-2014 Narayan Kamath <narayan@google.com> Don't assume minusSign is a single char.

Locales like arabic have a multi char minusSign in
their locale data.

The only difficulty here is presented by DecimalFormatSymbols,
which is a public API and expects the minus sign to be
a single codepoint. The API has been changed to return the
first character of the minusSign string for getMinusSign, which
seems like the least bad option at this point.

This change also removes a workaround for cases where ICU
parsed (2445-) as (-2445) for RTL locales. ICU-52 doesn't do
this anymore.

The serialized form hasn't been modified either, since it's
public API as well and it isn't easy to expand to a String
without awkward semantics.

bug: 13410257

Change-Id: I0e575b7eea0fd811ccb9fb5dc04e20d2e0fa13bf
ibcore_icu_ICU.cpp
ibcore_icu_NativeDecimalFormat.cpp
11c1f6f38955e0ec20d86ca70891f30bf5f5e4bb 13-Mar-2014 Narayan Kamath <narayan@google.com> Fix ICU glue for uloc_toLanguageTag.

There were several issues :
- ICU does not set the output param UErrorCode* to U_ZERO_ERROR
when an API call is successful, so we need to clear it before every
API call.
- ICU sets the error code to U_BUFFER_OVERFLOW_ERROR (and sets the
output length to the required size) if the input buffer is too
small.
- ICU sets the error code to U_STRING_NOT_TERMINATED_WARNING when
the input buffer is one character too short.

bug: 13414549
bug: 13412659
Change-Id: I3e23ea507a540f37ab1c14a60afe801bca286554
ibcore_icu_ICU.cpp
5a692fa8cdeec7eee42482f78187bb76be5a87db 11-Mar-2014 Neil Fuller <nfuller@google.com> Merge "Add Currency.getNumericCode()"
d627bd4525e41b0503f94c2887c3e01618c73105 10-Mar-2014 Neil Fuller <nfuller@google.com> Add Currency.getNumericCode()

getNumericCode() was added in Java 1.7. It returns the ISO 4217
numeric code for a currency.

Change-Id: I8404703e749b3324bbcb89ecf6d8d64b95a030a3
ibcore_icu_ICU.cpp
df29508a7aa622f265aaebdc472eb7d679185ebb 30-Jan-2014 Neil Fuller <nfuller@google.com> Implementation of MulticastChannel.

Note: ProtocolFamily / StandardProtocolFamily /
DatagramChannel.open(ProtocolFamily) have not been
implemented.

There is a related change to libnativehelper that
must be merged at the same time to avoid
build breakage. See
https://android-review.googlesource.com/#/c/81371/

Bug: 12464155
Change-Id: I07fc049b429a2d373e9bd7b07149632f5cd69f9d
etworkUtilities.h
ibcore_io_OsConstants.cpp
ibcore_io_Posix.cpp
a961d0b42b313aae32f340d9bf7de18e638da2cb 25-Jan-2014 Colin Cross <ccross@android.com> Update BN to work when sizeof(BN_ULONG) != 4.

Change-Id: Ifc1cdf17c7198624c217afc82c43819b71660d53
ava_math_NativeBN.cpp
b717644f67c8bba023e581a54cdd99e5c2ec7e28 21-Feb-2014 Elliott Hughes <enh@google.com> Fix NativeBreakIterator_cloneImpl return type.

Change-Id: I44e36a0312973de83a2ee7d09483ad911e167604
ibcore_icu_NativeBreakIterator.cpp
e43ee5033562120d6d47bd805df769167b62ab51 06-Feb-2014 Narayan Kamath <narayan@google.com> Fix JNI issues in NativeCollation.

We need to make sure the jchar array (and the corresponding
input string) are valid throughout the iteration, not just
during the JNI call that creates the iterator.

bug: 12817544
Change-Id: I8dda0a7238a743da0d0e2b4c956ec0806ce3555b
ibcore_icu_NativeCollation.cpp
d0432cdf9f1ee54efc7f8a8248cc27ac687f9647 06-Feb-2014 Elliott Hughes <enh@google.com> Only offer the CAP_* constants on bionic.

It's too hard and insufficiently worthwhile to bother with glibc.

Change-Id: Ic2d1c5242c20a197b713becbcdce09993abe0f5c
ortability.h
ava_lang_ProcessManager.cpp
ibcore_io_OsConstants.cpp
8107b206cd72c51ffaeac1f7fcfdf4ea0728e34c 05-Feb-2014 Elliott Hughes <enh@google.com> Revert "Revert "ExpatParser LP64 fixes.""

This reverts commit d88231f770f7459dc174aa970e305aa5f16f9f04.

Change-Id: Iac6b50221aa1e4cfe8514ea693a4289d74e118de
rg_apache_harmony_xml_ExpatParser.cpp
d88231f770f7459dc174aa970e305aa5f16f9f04 05-Feb-2014 Elliott Hughes <enh@google.com> Revert "ExpatParser LP64 fixes."

This reverts commit a8a1e201e415abfd6b5ae4fed98c8aa491e15af9.

This causes YouTube to crash on launch. Reverting to give myself more time to investigate.

Change-Id: I9ee107383a4f206ca83dd267baad77445eba3fce
rg_apache_harmony_xml_ExpatParser.cpp
a8a1e201e415abfd6b5ae4fed98c8aa491e15af9 04-Feb-2014 Elliott Hughes <enh@google.com> ExpatParser LP64 fixes.

Change-Id: I17ba32b6147b048f3cace0b2d7283b1c9d74f776
Signed-off-by: Stuart Monteith <Stuart.Monteith@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
Signed-off-by: Matteo Franchin <matteo.franchin@arm.com>
rg_apache_harmony_xml_ExpatParser.cpp
183f85fcd74cf4cd6e17cb900c93f09435dd7bf9 04-Feb-2014 Elliott Hughes <enh@google.com> Add aarch64 to the architectures without alignment restrictions.

Change-Id: I1ebc76b7ed08e177e97cd1e4d866347b7600057b
ibcore_io_Memory.cpp
9adba4445bbdf563752c2aebd16ded5d0d1099aa 04-Feb-2014 Elliott Hughes <enh@google.com> NativeBreakIterator LP64 fixes.

Change-Id: I8886d73d9a83babca0f440177a9f3fd3eb70e38f
Signed-off-by: Stuart Monteith <Stuart.Monteith@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
Signed-off-by: Matteo Franchin <matteo.franchin@arm.com>
ibcore_icu_NativeBreakIterator.cpp
df40b4ad7268a13dff0852f70451a48b59149221 04-Feb-2014 Elliott Hughes <enh@google.com> NativeCollation LP64 fixes.

Change-Id: Idf5100fdfd1915439029f5d42cf4b84d64f457a0
Signed-off-by: Stuart Monteith <Stuart.Monteith@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
Signed-off-by: Matteo Franchin <matteo.franchin@arm.com>
ibcore_icu_NativeCollation.cpp
11f07d30d2e344b48f132ec6ed105d85423052c2 04-Feb-2014 Elliott Hughes <enh@google.com> Add posix_fallocate to Libcore.os.

(The Java API takes longs for the off_t arguments, and uses posix_fallocate64
behind the scenes.)

Bug: 5287571
Change-Id: I48566d8720c6b41ab42a402eeb322d054d2029ea
ibcore_io_Posix.cpp
0b6b3e10459fc3a3f4dd280dab8d4a145f7bf2f0 01-Feb-2014 Elliott Hughes <enh@google.com> Move the hidden File.readlink into Libcore.os.

Change-Id: Ia983909e62d3806027dff870f0148dd07c31bf01
ava_io_File.cpp
ibcore_io_Posix.cpp
081c0de9231d6fc2aa5e24bdcc21b5cde8a30f2b 31-Jan-2014 Elliott Hughes <enh@google.com> Rename our 'realpath' because it isn't the same as realpath(3).

Change-Id: I7b830d485c1ff769993233b7ea69e36b354f3259
anonicalize_path.cpp
ava_io_File.cpp
ealpath.cpp
ub.mk
c5b1eb191102a20bc0626aea955aba417e337fbc 10-Jan-2014 Narayan Kamath <narayan@google.com> java7: Implement new Locale APIs.

Most validation and sanity checking is performed entirely
in java. We use ICU only for converting back and forth
between Locale objects and BCP-47 language tags
(toLanguageTag & forLanguageTag).

The new APIs also add support for script subtags and
manipulation of unicode locale extensions.

Note that we do not implement
IllformedLocaleException.getErrorIndex. If anyone complains
or if it proves useful somehow, we could plumb the information
through from ICU if required.

bug: 8992787
Change-Id: I9b2d7f8d17f970d1b57111dcfe92c16e68b0fa67
ibcore_icu_ICU.cpp
48819fe0b9130618a430ec52b3f8526c4c0a5f8a 09-Jan-2014 Narayan Kamath <narayan@google.com> java7: Implement Character.UnicodeScript

Implemented in terms of u_getPropertyValueEnum(UCHAR_SCRIPT,)
and uscript_getScript from ICU4C.

Since the Java 7 API specifies a subset of scripts known to
ICU4C, we map scripts not specified in the API to
UnicodeScript.UNKNOWN.

Like the UnicodeBlock API, our matching is far more lenient than
the RI.

Change-Id: I5247baddb2dde42d6a2042609370daeb616fe419
ava_lang_Character.cpp
0c1869ed7f46baf764f9daf4e64c77cd7fbd3516 29-Nov-2013 Narayan Kamath <narayan@google.com> Add a JNI wrapper over libziparchive.

All functions delegate directly to the native code. We
do not perform any sort of central directory or local file
related lookups in the java layer.

For each entry, libziparchive gives us an offset to the start
of data for the entry and the compressed size. We use a
RandomAccessFile to seek to that offset and then construct an
InputStream that's bounded between [offset, offset + compressed_size).

We reuse existing code (JarVerifier / Manifest) for certificate
validation & collection.

bug: 10193060

Change-Id: I21eb4e6dc6aa8749e3f63830f9799e1f621d26e6
egister.cpp
ava_util_jar_StrictJarFile.cpp
ub.mk
d6fcc6c62ec28f590dc8baaadc9a5035bf95b407 28-Nov-2013 Lorenzo Colitti <lorenzo@google.com> Add RT_SCOPE_* to OsConstants.

These are defined in RFC 3549 (netlink) and will be used, for
example, to determine whether an IP address has global scope.

Bug: 9180552
Change-Id: I7e712cdd0bcb0dd7b24eb2e46b4205ad96b42164
ibcore_io_OsConstants.cpp
466cd23668f659aa859921e3475fe09f3f6a0789 27-Nov-2013 Narayan Kamath <narayan@google.com> Merge "Fix an ASCIICharsetEncoderTest testcase."
bd024cc687470a008999d96fd3af4a1261413d55 26-Nov-2013 Narayan Kamath <narayan@google.com> Fix several decoder bugs.

- NativeConverter should report unterminated character
sequences to managed code.
- CharsetDecoderIcu should report those errors correctly
from flush()
- InputStreamReader should check the return value of
flush() and not ignore it altogether.

bug: 11665359
bug: 10729779

Change-Id: Ic678a645a4ef2b3fe70e2c900c0cd393679f1037
ibcore_icu_NativeConverter.cpp
f15b280ac1c2e32f7becdb314440c2999dc8d204 26-Nov-2013 Narayan Kamath <narayan@google.com> Fix an ASCIICharsetEncoderTest testcase.

Deal with truncated char sequences correctly.

bug: 10729779
Change-Id: I232b0ec899084270a6d621e6c7292ef8b94f8f7d
ibcore_icu_NativeConverter.cpp
972940b14c0b189584c2128e54313214bfd9d1b0 15-Nov-2013 Lorenzo Colitti <lorenzo@google.com> am 4bb8f69f: am dbdee7a8: Merge "Add IFA_F_* constants for use in LinkAddress"

* commit '4bb8f69fe9a8ed13bc7d46eff114af11e377c2b1':
Add IFA_F_* constants for use in LinkAddress
638c455b29d06642724528c59d311a1bcb4f2359 15-Nov-2013 Lorenzo Colitti <lorenzo@google.com> Add IFA_F_* constants for use in LinkAddress

Some of these are needed so that LinkAddress can tell if an
IP address is duplicate, tentative, etc. or if it usable. While
we're at it, add all the ones that are defined in the kernel
headers.

Bug: 9180552
Change-Id: I5fc77cacf5df2249bcf08071430675204624916f
ibcore_io_OsConstants.cpp
f91d9219daac2811794fccd99d2372bafd07d35c 14-Nov-2013 Elliott Hughes <enh@google.com> am 2de42459: am 288bd71b: Merge "Fix NumberFormat.parse(null)."

* commit '2de424599eccfff0de832f98bdd0f17ec9a2952a':
Fix NumberFormat.parse(null).
3909f6dba0812caee25a8779dcbf4c50ce9b19c7 14-Nov-2013 Elliott Hughes <enh@google.com> Fix NumberFormat.parse(null).

Bug: https://code.google.com/p/android/issues/detail?id=62269
Change-Id: If6685cf60dcbbeda06dad086a6a6012488d700cc
ibcore_icu_NativeDecimalFormat.cpp
1707e28f1f97ebb4944a9eec1e654c2eaaf424cb 26-Oct-2013 Ian Rogers <irogers@google.com> Mark System currentTimeMillis and nanoTime as fast.

(cherry picked from commit 8ac8f1dd19ffa2847c69f82336ee81b40fad3638)

Change-Id: Idb4714570acd8c2af22df87799e2e1becde5e596
ava_lang_System.cpp
329af9cb39b3cd325a6ac6d1bc906af8877eff9f 31-Oct-2013 Vladimir Marko <vmarko@google.com> Rewrite Memory peek/poke to swap bytes in Java.

Rewrite single memory access (non-array) peek/poke methods
in libcore.io.Memory to swap bytes on the Java side and do
only the memory access in JNI.

This causes a small performance hit. However, that will be
more than compensated for in ART by implementing intrinsics
for the new memory access helper methods.

(cherry picked from commit ad02363555dce245e1e5f547d73925f61d336dcf)

Change-Id: Iaf679c21319b3241c7cf4142e0616e91a591c20f
ibcore_io_Memory.cpp
2b8fda6969b139ba7635a6409cc05e8626e4e9e7 22-Apr-2012 Elliott Hughes <enh@google.com> Various Mac OS fixes.

(cherry-picked from commit 4b145f6a94b2d4bca6870650fbc7279e6ccc093e)

Change-Id: I9b4b60b7d74ed82ee55971c62b4e05a3644e2901
ava_lang_Float.cpp
ava_lang_ProcessManager.cpp
ibcore_io_Memory.cpp
ibcore_io_OsConstants.cpp
ibcore_io_Posix.cpp
0b10fe2c299ec69c64877c2dcc1fe991009495f6 21-Jan-2012 Elliott Hughes <enh@google.com> Fix libcore to build on Mac OS.

The Posix and RawSocket classes are just preprocessored away, and OsConstants
is largely gutted (even though there's an obvious mechanical workaround that
might even be usable), but the rest are (I believe) production-quality fixes.

(cherry picked from commit a0c6e6e3bf936c3912db6df2346916d5f6130f1a)

Change-Id: Ib3dd1151a2896d9a85a50d528ee8378dfda0e5b8
ava_lang_Float.cpp
ava_lang_ProcessManager.cpp
ava_lang_System.cpp
ibcore_io_Memory.cpp
ibcore_io_OsConstants.cpp
ibcore_io_Posix.cpp
c3cfad989c612f749ea24ed641a64e619cc5bb9d 14-Jul-2011 Elliott Hughes <enh@google.com> Make libjavacore (libcore's JNI library) use JNI_OnLoad.

One other change here is that I've removed ExpatParser's dependency on
libcutils, switching the relevant code to use ICU instead.

(cherry picked from commit ab4b6905b5b100f251818bcfc68192ff736af7b7)

Change-Id: Id3758b31c3c76043ee1923223a243116188196c3
egister.cpp
ava_lang_Double.cpp
ava_lang_Float.cpp
ava_lang_Math.cpp
ub.mk
bbd614097092aab00a97813fa0bdaa10cd3b3f2b 01-Aug-2012 Ian Rogers <irogers@google.com> Move (double|float)To(Long|Int)Bits into Java code.

(cherry picked from commit e6b64228bbced53d952ba64a3f6ce95f69ce0368)

Change-Id: I8685fcac437a38df4a2105244b8482f84cd746d1
ava_lang_Double.cpp
ava_lang_Float.cpp
0fd776f4dbf7c1940c080003f0c7a02d35374ab9 31-Oct-2013 Elliott Hughes <enh@google.com> Add a cache to ICU.getBestDateTimePattern.

Brings the time down from 7ms to 7us for a cache hit on Nexus 4.

Bug: 11447043
Change-Id: I7cfc055c264ce49dadc72b5acdc2f2b0b339a5a1
ibcore_icu_ICU.cpp
bf6f2afa0a56b417ef3e49a5aa3d6df937be6449 07-Oct-2013 Elliott Hughes <enh@google.com> Stop using deprecated ucol_safeClone placement functionality.

Change-Id: I2e8e659f72caf95d92638254226b78cf29bd0ca5
ibcore_icu_NativeCollation.cpp
670023f161f2be66c285f5ce1556aeb219571a61 26-Sep-2013 Michael Wright <michaelwr@google.com> Merge "Add CAP_BLOCK_SUSPEND to OS constants"
d87d88312ba187a71ee02f18eb1c48a434ebcd15 26-Sep-2013 Michael Wright <michaelwr@google.com> Add CAP_BLOCK_SUSPEND to OS constants

Bug: 10901016
Change-Id: I162bde82bce9fca8eabc7168a172d3d8365e1578
ortability.h
ibcore_io_OsConstants.cpp
5b5e8e70b52dd4fca159fb39f9ee555d31699dec 12-Sep-2013 Elliott Hughes <enh@google.com> Remove RawSocket, which is no longer used.

Change-Id: Ia44a9ffd4d36da408c6b411c90d59ce7db30a36f
egister.cpp
ibcore_net_RawSocket.cpp
ub.mk
15c1945bb1810d061ea2d5b07a11e3ecc5ec8536 10-Sep-2013 Ruben Brunk <rubenbrunk@google.com> Remove dependency on JNIHelp header side effects.

(cherrypick of cc5305a004afc334842a4afadca9530c2ea0c8ff.)

Bug: 10680559
Change-Id: I49ad58dea61a0e558bebfbd76019e7e0730cab52
niException.cpp
egister.cpp
ava_lang_Character.cpp
ibcore_io_Posix.cpp
ibcore_net_RawSocket.cpp
fd1d5e92b2eaf785cb18aa295b7b846cfc5e29af 11-Sep-2013 Elliott Hughes <enh@google.com> icu4c DateIntervalFormat objects are expensive enough that we need to cache them.

It takes ~1ms to create a DateIntervalFormat on a z620, and around 8ms on a
current mobile device (Nexus 4). Add a small cache of recently-used formatters,
using a big lock rather than per-thread caches since this typically only
happens on the UI thread anyway, and because all the other frameworks date/time
formatting is behind a single lock too.

Bug: 10696944
Change-Id: I8ccbe0b31b722a95a08fbc5a119173b7a0f44807
ibcore_icu_DateIntervalFormat.cpp
383b6c74eb7088c545841357e482c4fd6218cb9d 11-Sep-2013 Elliott Hughes <enh@google.com> Add API to get a time zone's localized exemplar location from CLDR.

Bug: 8145760
Bug: 10179879
Change-Id: Idafa81402c8d89cc2756ab1d57c0f8b1b3401df7
ibcore_icu_TimeZoneNames.cpp
55c4a2d6d69636840512eaaa009d22ebecc605e6 07-Sep-2013 Elliott Hughes <enh@google.com> Remove StaticAssert.h.

The switch to C++11 means we have static_assert now.

Change-Id: Iaa39af8c4fa7143fc83fda550543eb3270f9f161
ava_math_NativeBN.cpp
ibcore_io_Posix.cpp
8c80e6bbbe48bc1a3a2c0c0a2eed252e1c04ea2c 05-Sep-2013 Elliott Hughes <enh@google.com> Only use public API for icu4c's FieldPositionIterator.

Change-Id: I247f7c644537b8e9f67f4f27360ce1449fa04300
cuUtilities.h
ibcore_icu_NativeDecimalFormat.cpp
364324db9cf267b0a770238536a18da719f9295b 02-Sep-2013 Carton He <carton.he@marvell.com> Fix memory leak when using DateTimePatternGenerator

Instance created by DateTimePatternGenerator::createInstance() needs to
be deleted

Change-Id: I3e6058f717e56dbc06ffaca35ff6ae06059b689d
Signed-off-by: Carton He <carton.he@marvell.com>
ibcore_icu_ICU.cpp
783112d47e2236b6a7e2315c2e50166d755422a7 04-Sep-2013 Elliott Hughes <enh@google.com> Remove some unnecessary native code for LocaleData.

We already have a more general implementation, exposed as public
API >= jb-mr2.

Change-Id: I917465f6bac4afec40e3685dccffad920d050c85
ibcore_icu_ICU.cpp
8a491f87e3c35d08888676ac8c3e66b7fe1fafdd 04-Sep-2013 Elliott Hughes <enh@google.com> Use getLocale more consistently.

Change-Id: I64d9e651aba3b2872a23e4d4b1b7c32c34f86d90
ibcore_icu_ICU.cpp
922ce2301f54eb3a9e8879d73aec5a14ed27d066 31-Aug-2013 Elliott Hughes <enh@google.com> Merge "Fix harmony java.text test failures."
74473971cc9d960376295fbcc430320c9ed62991 29-Aug-2013 Elliott Hughes <enh@google.com> Fix harmony java.text test failures.

There were plenty of bad tests here, but there were some real bugs too.

* DecimalFormat was only handling RoundingMode.UNNECESSARY for double
formatting.

* DecimalFormat was not ensuring that it's superclass' fields were
being correctly updated.

* NumberFormat was throwing NPE for a null object because of an
improved detail message, despite being specified to throw IAE.

* We weren't mapping NumberFormat.Field instances to the corresponding icu4c
UNUM_x_FIELD constant, so we weren't actually setting FieldPosition
objects correctly.

* SimpleDateFormat was not formatting milliseconds correctly with 'S'.

* NativeDecimalFormat wasn't handling JNI NewString OOME correctly.

Bug: 2528220
Bug: 3056865
Bug: 3057080
Bug: 3057090
Change-Id: Iac11f902f2e9649e596e7e7b7bc501b13e956fca
ibcore_icu_NativeDecimalFormat.cpp
ba07db54a902e6741cd085901264e4e45c9c844e 29-Aug-2013 Kenny Root <kroot@google.com> Move conscrypt out libjavacore and split tests

To make the situation with testing a little better and enable building
core libraries totally independent of conscrypt, move the native
registration to a JNI_OnLoad scheme. Also, since we want to separate the
testing, make conscrypt build its own tests library.

Change-Id: I9f2831839059c1c012ec7bdeab2f90b4e2f44bfd
egister.cpp
3020db601855fda8e33c870510204750b2386f3d 27-Aug-2013 Elliott Hughes <enh@google.com> Reduce the upper bound on TimeZoneNames memory usage.

The cache had mistakenly been sized based on the number of time zones,
despite the fact that the keys are locales. We now have a lot of locales,
but the cache was still large enough to hold all of them, which wasn't
really the intent. I pulled the number 5 out of my ass.

I've also removed the "one big intern table" and now just do per-locale
deduplication. That avoids another potentially very large leak in an
ill-behaved program.

Also handle OOME in the native code better.

Change-Id: I9a07ad210469f064acde80f7d10ffb4b3a8f6443
ibcore_icu_TimeZoneNames.cpp
783a57a7ece339bc246925e328bc82b50cae427a 26-Aug-2013 Elliott Hughes <enh@google.com> Fix the Charset alias generation to use the correct icu4c API.

Bug: 10492721
Change-Id: Ie81b8aca9d7531d0fd8476ccab78653b0aa68755
cuUtilities.cpp
cuUtilities.h
ibcore_icu_ICU.cpp
ibcore_icu_NativeConverter.cpp
ibcore_icu_Transliterator.cpp
2e6a64542c52490d89476bfd1b10b1938a8a0e99 22-Aug-2013 Kenny Root <kroot@google.com> Better error messages for zlib errors

Most of the zlib inflater errors had a really descriptive name like
"data error," but more descriptive errors are put into the "msg" field
of the z_stream structure. Use that for error messages instead so we get
the underlying cause of the data error.

Additionally split out the code for ZipUtilities from the header into a
separate source file so things using NativeZipStream don't have to
forward declare.

Change-Id: Ifc12645b37f7aabc700e6a0766dee55b4c3609a0
ipUtilities.cpp
ipUtilities.h
ava_util_zip_Deflater.cpp
ava_util_zip_Inflater.cpp
ub.mk
ea1caf4ccc5c2255f384c0774aa9e055763a6a41 16-Aug-2013 Elliott Hughes <enh@google.com> Fix a bunch of Charset tests.

The isRegistered test is still failing. The problem is that icu4c's
convrtrs.txt has names like "windows-1252" that are both the canonical
name for one charset and an alias for another legacy charset. I need
to work out how to resolve that.

Bug: 10210999
Change-Id: If3425321c814622e4f54b2efca95a767bd16c080
ibcore_icu_NativeConverter.cpp
5ec6bf8d033754e06a463adb091d2c0afd0755ac 08-Aug-2013 Elliott Hughes <enh@google.com> Fix various Charset tests, clean up the implementation.

Bug: 10211558
Bug: 10211378
Change-Id: Ib3f97430f62163c0459c53e0c282ae0ca840e0af
ibcore_icu_NativeConverter.cpp
507e7789a5aace0f30d85dab8862151b1eba693a 01-Aug-2013 Elliott Hughes <enh@google.com> Fix DateIntervalFormat to take time zone into account.

Bug: 10089890
Change-Id: I91e61429108abb16810701d6d9feb6d1ad431740
ibcore_icu_DateIntervalFormat.cpp
069525a39125c203b658c805685b6045a7d4dfeb 30-Jul-2013 Elliott Hughes <enh@google.com> Add gettid.

Change-Id: Ie18095d696ebeb8f056fb7f5b7cfbc452cdf8206
ibcore_io_Posix.cpp
283305e2eabd3b250e26ec5a8a56c18ae5161867 30-Jul-2013 Elliott Hughes <enh@google.com> Make UnicodeString::toUTF8String(std::string&) available.

Handy for debugging.

Bug: 9276605
Change-Id: Ia3235026d4e659df4202b1fecaa2873ef646a341
cuUtilities.h
f001abe6478c2ece3d86138f649a5459de85a50a 25-Jul-2013 Elliott Hughes <enh@google.com> Fix LocaleNameIterator.

The intention -- as stated in the comment -- is that we should iterate all the
way up to the root locale, but we were missing that out. Some locales (such as
'ne' currently) actually inherit data from the root. (Yes, this is probably a
bad sign as to their completeness.)

Change-Id: I9033c7a0ba477ae9c7523a6c707dafd664394603
ibcore_icu_ICU.cpp
480537d9d51add98bffe6d9a9ef3b1022b959336 03-May-2013 Elliott Hughes <enh@google.com> Add an icu4c-based DateIntervalFormat.

This will be used to replace DateUtils.formatDateRange's implementation.

Bug: 7289514
Change-Id: I5588c79a9d0a5cbed3b4600389c545e83fc26967
egister.cpp
ibcore_icu_DateIntervalFormat.cpp
ibcore_icu_ICU.cpp
ub.mk
ba22290197a6d5f462b6e181515303c4ea4a3280 18-Jul-2013 Elliott Hughes <enh@google.com> resolved conflicts for merge of a6ca7a95 to stage-aosp-master

Change-Id: Icc74574f5e99d9b2076b3a1ae0136f8fdf944ee5
0ef9944d1968207ae8501aca5f904809320c520e 19-Jun-2013 Elliott Hughes <enh@google.com> Fixes for icu4c 51.

Change getYesterdayTodayAndTomorrow to cope with the new data layout.

Extend getDateFormatOrder to cope with 'G' in fa's preferred yyyyMMdd
pattern.

Fix a few tests to correspond to data changes.

Change-Id: I2478ae960ff6ec0b9a95290132c0ae0d5d8eff5a
ibcore_icu_ICU.cpp
029b00d62b71747b2a700788066f92a7dd8579e2 10-Jul-2013 Elliott Hughes <enh@google.com> am ec618403: Merge "Switch libcore from statfs to statvfs."

* commit 'ec618403efee992f232f017fbff1afff6cfa0de3':
Switch libcore from statfs to statvfs.
721ceca2a52a3c27aa751476c8562e1e68088e15 09-Jul-2013 Elliott Hughes <enh@google.com> Switch libcore from statfs to statvfs.

Change-Id: I5115b9203ce6b11c37c0eb41fbc84fa5962ce196
ortability.h
ibcore_io_Posix.cpp
7381513bfbaf8fa431e1e661cafd7558b2a298ee 03-Jul-2013 Elliott Hughes <enh@google.com> am fee8ca27: Merge "Add a definition for IPPROTO_ICMPV6."

* commit 'fee8ca277b2621aea0729426af66356001e3b463':
Add a definition for IPPROTO_ICMPV6.
dca34b591430a1f1c1aabab1beb5cd6e5bd4d2f8 03-Jul-2013 Lorenzo Colitti <lorenzo@google.com> Add a definition for IPPROTO_ICMPV6.

This will allow us to write a CTS test for ICMPv6 datagram
socket support.

Bug: 9469865
Change-Id: I3da0918fa0797e7319f8b2f71856f455858bdc18
ibcore_io_OsConstants.cpp
9cb861facc2f70d7876de79a8ef83a82133c25d9 02-Jul-2013 Elliott Hughes <enh@google.com> am b6e8336a: Merge "Implement Character.isAlphabetic and Character.isIdeographic."

* commit 'b6e8336a21b18213c4729658d25f4735c514eb17':
Implement Character.isAlphabetic and Character.isIdeographic.
2d99feb311425dda5e5e2223626d30eb5a0ae95a 02-Jul-2013 Elliott Hughes <enh@google.com> Implement Character.isAlphabetic and Character.isIdeographic.

Bug: 3484927
Change-Id: I0360fca2adf366009a5c2ae0e6a18f4e975c481a
ava_lang_Character.cpp
18a8b91a5ee97b7a6e8c0849b542ea765dc738a5 21-Jun-2013 Elliott Hughes <enh@google.com> am 61abfba7: Merge "Revert "Use CLOCK_MONOTONIC_RAW for System.nanoTime.""

* commit '61abfba7767a4ceb09ba69b03f42ef3bc3828e37':
Revert "Use CLOCK_MONOTONIC_RAW for System.nanoTime."
508bf13ba75610c75c4f40811dde0ec7e401f4c1 21-Jun-2013 Elliott Hughes <enh@google.com> Revert "Use CLOCK_MONOTONIC_RAW for System.nanoTime."

This reverts commit 7757924895a28a43ab9f7c3931cc9f972e870ddc.

Further investigation suggests this is a worse clock for our purposes, not the better one it would appear to be from the man page. It looks more like it should have been called CLOCK_TSC.

Change-Id: I6bf7fe4dac19272f145d240917129b4d5ab5ade1
ava_lang_System.cpp
7ce2f38cb64f5a5ef3bf31f7ce539b74c9c1b10e 21-Jun-2013 Elliott Hughes <enh@google.com> am 7bd5cc7f: Merge "Use CLOCK_MONOTONIC_RAW for System.nanoTime."

* commit '7bd5cc7f252dc16ab434cb1440abe5152e28f9c1':
Use CLOCK_MONOTONIC_RAW for System.nanoTime.
7757924895a28a43ab9f7c3931cc9f972e870ddc 21-Jun-2013 Elliott Hughes <enh@google.com> Use CLOCK_MONOTONIC_RAW for System.nanoTime.

We still need to use CLOCK_MONOTONIC on Darwin.

Bug: 9511688
Change-Id: Ieb1091e24ad5cd3bab79a4de1b1494cc64eef3d4
ava_lang_System.cpp
8a48ae9737cf7b78c3cfd304b8c975fe644cc310 08-Jun-2013 Brian Carlstrom <bdc@google.com> am f47f0bdf: Merge "Offer default implementations of various dalvik intrinsics in the library."

* commit 'f47f0bdff8807ff419fb3553e510abaa36a3f98b':
Offer default implementations of various dalvik intrinsics in the library.
f47f0bdff8807ff419fb3553e510abaa36a3f98b 08-Jun-2013 Brian Carlstrom <bdc@google.com> Merge "Offer default implementations of various dalvik intrinsics in the library."
3443a5e4e7ea9fa3fdc3495a1f2c44bea97ac100 07-Jul-2011 Elliott Hughes <enh@google.com> Offer default implementations of various dalvik intrinsics in the library.

(cherry-picked from commit 2f95766aac3df74c6c641232eec4791b2330c9df)

Change-Id: I1005ee22ed8a017bb536bfd76df2173c7e8dcf64
egister.cpp
ava_lang_Double.cpp
ava_lang_Float.cpp
ava_lang_Math.cpp
ub.mk
81c8c23a51a88cd023723cd3d01c1a6cc04ca51b 08-Jun-2013 Elliott Hughes <enh@google.com> am 30abb0bd: Merge "Fix memory leaks in org_apache_harmony_xml_ExpatParser"

* commit '30abb0bd592702a4b8c26ee18565c3c7625220c8':
Fix memory leaks in org_apache_harmony_xml_ExpatParser
30abb0bd592702a4b8c26ee18565c3c7625220c8 08-Jun-2013 Elliott Hughes <enh@google.com> Merge "Fix memory leaks in org_apache_harmony_xml_ExpatParser"
b80a454a3f5db8977a0faf4637b25e9e209bfa89 07-Jun-2013 Brian Carlstrom <bdc@google.com> am 98ed9ca9: Merge "Move System.currentTimeMillis, nanoTime, and mapLibraryName into the library."

* commit '98ed9ca970a1b283bcfccbf3dbbd4d968458d452':
Move System.currentTimeMillis, nanoTime, and mapLibraryName into the library.
22ccdd01e2fabc37d858be32291a854ff72f1840 31-Aug-2011 Elliott Hughes <enh@google.com> Move System.currentTimeMillis, nanoTime, and mapLibraryName into the library.

(cherry-picked from commit 37d6cc06f62b2029663137a1b8c18242152c1e97)

Change-Id: I3b3aa3f508b9c6f43b27022cd8bc9aa82e630e01
ava_lang_System.cpp
08bfdd7d88c929964873bb0e311bcae0edb5ebc2 14-May-2013 Mikael Gullstrand <mikael.gullstrand@sonymobile.com> Fix memory leaks in org_apache_harmony_xml_ExpatParser

The method expandInternedStringBucket(...) creates a new bucket
but the old bucket is never freed, even though the function doc
claims that it does. To solve this problem the old bucket is
freed when the new one has been created successfully.

Also this commit fixes two possible memory leaks when a
jniThrowOutOfMemoryError is thrown, where the internedString
also needs to be freed.

Change-Id: Ic80a35a2b4ec8f93ddc006aca5609a5ffe74d659
rg_apache_harmony_xml_ExpatParser.cpp
ddc587229ab27692e8e6ffb812b5378f4e23a86f 30-May-2013 Brian Carlstrom <bdc@google.com> am c1340c3b: Merge "Use correct signature for NativeBN_BN_is_prime_ex"

* commit 'c1340c3bff5d02f75f24ab4ebe13cb81c7171b20':
Use correct signature for NativeBN_BN_is_prime_ex
0a08bbe70ef43ed29cba241e95aa5c338349b021 30-May-2013 Chris Dearman <chris.dearman@imgtec.com> Use correct signature for NativeBN_BN_is_prime_ex

Change-Id: Ic08c4142542c5bd28e964a22270beed13297b9d6
ava_math_NativeBN.cpp
098e1979977dd6d6cebbf4f3e702f9fdabc8c24a 15-May-2013 Elliott Hughes <enh@google.com> am 3e224157: Merge "Remove a workaround for a bionic bug that\'s been fixed."

* commit '3e2241571780114108b94a76e08ddb69d578e606':
Remove a workaround for a bionic bug that's been fixed.
ea2badecf96c9ff011f71fabb8566fef46c102cc 15-May-2013 Elliott Hughes <enh@google.com> Remove a workaround for a bionic bug that's been fixed.

d35106fd557e054d1ffe388df6a3b3cb51cc5021 fixed bionic. glibc was always
correct.

Change-Id: I26c6567bbc0895fc447b249cb029768bae6e4ab5
ibcore_io_Posix.cpp
44da51ed349e813864c6d0dff152f3b53e2cd363 10-May-2013 Brian Carlstrom <bdc@google.com> am 6a4ab0ab: Merge "Remove duplicate JNIHelp.h import"

* commit '6a4ab0ab16fe5462389ba61b7331da860a2d32f2':
Remove duplicate JNIHelp.h import
a4666f7d430fa347302f5e0e0893aa3fdd32bf96 10-May-2013 Brian Carlstrom <bdc@google.com> am 77afd784: Merge "Ensure array_ is initialized."

* commit '77afd7842ccfb2e126a28c8410d5388ebaa8fd67':
Ensure array_ is initialized.
f0fff273e34206832e7b9255b579b7eef5f598d0 10-May-2013 Brian Carlstrom <bdc@google.com> Remove duplicate JNIHelp.h import

Change-Id: Ib119fd7c5c7cb5f682aab08c7916806c95a73d2b
ava_lang_ProcessManager.cpp
620bd0d151abcc1bd45d176878ca3e2a12de0ae0 07-Feb-2013 Ian Rogers <irogers@google.com> Ensure array_ is initialized.

Always read in destructor.

(cherry picked from commit 5c4fb07217923c70b368b058f5337e4d9217cc1f)

Change-Id: I6ac68373750c3c864e9e401fa85f6336e93df435
xecStrings.cpp
d4f2f951b5c72dd26c2f65ba446e3ef256d27b08 10-May-2013 Brian Carlstrom <bdc@google.com> am d9f9db27: Merge changes Ie07e5901,I8a154f8b

* commit 'd9f9db273afab35baee1db4d22a65ae819e72b74':
resolved conflicts for merge of f78109f6 to dalvik-dev
Some of our helpers have moved into libnativehelpers.
ad9208affa02f92a6b85354a33123d51d80febe1 06-Feb-2013 Elliott Hughes <enh@google.com> resolved conflicts for merge of f78109f6 to dalvik-dev

(git cherry-pick -m 1 8a6e388c11d8ee72a0af23e6091239e2f58bc968)

Change-Id: Ie07e5901d5a127b6d6840b05da5dfd5c2b967048
xecStrings.cpp
xecStrings.h
ava_lang_ProcessManager.cpp
ibcore_io_Posix.cpp
ub.mk
7cad2d4e4e00bb152b726541b62840708d1cbcb1 20-Jul-2011 Elliott Hughes <enh@google.com> Some of our helpers have moved into libnativehelpers.

(cherry picked from commit 4b5012a6cd5f7f32f33a776c9e2c94ca3f3eb1d5)

Change-Id: I8a154f8b6e39b8ed0a633fab9ba31d557b545bb5
niConstants.cpp
niConstants.h
egister.cpp
ub.mk
oStringArray.cpp
oStringArray.h
484b496181e8f3e2626e2a78873f784420baf534 08-May-2013 Elliott Hughes <enh@google.com> am 7def6439: Merge "Improve ProcessManager."

* commit '7def64396da00e93a06e359497d6aaa781fe610f':
Improve ProcessManager.
fd6fca42f9be9cf158cd6dd2e4c426f20d0e426f 07-May-2013 Elliott Hughes <enh@google.com> Improve ProcessManager.

Previously we'd leave zombies around if chdir(2) or execvp(2) failed.
We also used to unnecessarily make 32Ki close(2) calls for every child.

This patch fixes both problems and makes the tests less meaningless.

Bug: https://code.google.com/p/android/issues/detail?id=55017
Change-Id: I23ecc84aedd6650dbe6df19b4b0c2e6429578e50
ava_lang_ProcessManager.cpp
e25956bbcde52ef20af58eb588cb1512ff5eccdf 02-May-2013 Elliott Hughes <enh@google.com> am 2b2224dd: Merge "Fix ScopedStringChars to behave like ScopedUtfChars."

* commit '2b2224dd923153293fcfa165931a774520317b47':
Fix ScopedStringChars to behave like ScopedUtfChars.
60b1855c2229c2b87d2e392061df55b065d2a70e 02-May-2013 Elliott Hughes <enh@google.com> Fix ScopedStringChars to behave like ScopedUtfChars.

Also reformat in Google C++ style and remove a couple of unnecessary #includes.

Bug: https://code.google.com/p/android/issues/detail?id=45724
Change-Id: I6d1a78b3b1f72e7015baba64811d9749f330fba7
ibcore_icu_AlphabeticIndex.cpp
ibcore_icu_Transliterator.cpp
033c85712e2d91657e2f5df8743d2fd0ddbf5a2d 30-Apr-2013 Kenny Root <kroot@google.com> am 0800e47a: Merge "Move JSSE to new package"

* commit '0800e47a2e19f185b7a62f1d26a74748db0cc047':
Move JSSE to new package
38375a4d0b3d34e2babbd2f6a013976c7c439696 24-Apr-2013 Kenny Root <kroot@google.com> Move JSSE to new package

To help with shipping the JSSE with apps that want to bundle it, move
it to a new package so that the tangles in other parts of the library
can be untangled.

Change-Id: I810b6861388635301e28aee5b9b47b8e6b35b430
egister.cpp
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
ub.mk
9e138bfa136407f00ad181c25e23c9d4166ab40b 24-Apr-2013 Elliott Hughes <enh@google.com> am 62669dfa: Merge "Simplify NativeBN error handling."

* commit '62669dfa390239adb1534cccf05a3917be3837dd':
Simplify NativeBN error handling.
66e740b765384686ce87003608412e940ab5d489 24-Apr-2013 Elliott Hughes <enh@google.com> Simplify NativeBN error handling.

Change-Id: I150459cf71da6a3232c281d82c1ef7cbf1b2a2bc
ava_math_NativeBN.cpp
7136112095f720a2e5075c61d27e6ead20967184 23-Apr-2013 Alex Klyubin <klyubin@google.com> am a8abf674: Merge "Add kernel CAP_ constants to libcore.io.OsConstants."

* commit 'a8abf674b008de7a0d85046c5d99757ecbba9989':
Add kernel CAP_ constants to libcore.io.OsConstants.
a8abf674b008de7a0d85046c5d99757ecbba9989 23-Apr-2013 Alex Klyubin <klyubin@google.com> Merge "Add kernel CAP_ constants to libcore.io.OsConstants."
63be5872f6dd0b7c4100a759605878181f133649 23-Apr-2013 Elliott Hughes <enh@google.com> am 0451730f: Merge "More 64-bit fixes for libcore native code."

* commit '0451730faea2642b759d22134a6f35dc394aa555':
More 64-bit fixes for libcore native code.
d4a4f0dc5f5645316428e7f1cfde2efb2c8b7db0 23-Apr-2013 Elliott Hughes <enh@google.com> am 60d77a52: Merge "64-bit fixes for BigInteger."

* commit '60d77a525c05c0d0a5d70d2a903ab3a9029dd58d':
64-bit fixes for BigInteger.
0451730faea2642b759d22134a6f35dc394aa555 23-Apr-2013 Elliott Hughes <enh@google.com> Merge "More 64-bit fixes for libcore native code."
1e5d730e58d94c3bfa14b7dde5ab3981fe5a170b 23-Apr-2013 Elliott Hughes <enh@google.com> More 64-bit fixes for libcore native code.

Change-Id: Id296613590f7ccfc7b5880b27418fe3f5d511974
ibcore_icu_NativeBreakIterator.cpp
ibcore_icu_NativeCollation.cpp
ibcore_icu_NativeDecimalFormat.cpp
ibcore_icu_NativePluralRules.cpp
a125dded8ab0490d05e2fa9ec2e821ef1ae6facd 23-Apr-2013 Elliott Hughes <enh@google.com> 64-bit fixes for BigInteger.

I fear this is just the start for this code. There seem to be a lot
of assumptions about the types used by OpenSSL that may not hold for
a 64-bit build.

Change-Id: I05c276ff06adc66c1e7878196ce1afd5fba290d9
ava_math_NativeBN.cpp
9e0ca15905414dd4cbfe73844b0266df6eb15250 19-Apr-2013 Alex Klyubin <klyubin@google.com> Add kernel CAP_ constants to libcore.io.OsConstants.

Change-Id: I8fecdc55b2cf0041ceed643eb48df53d22ecd600
ibcore_io_OsConstants.cpp
3a8fcb3874de904b2f09eebb1911b9be9c3244f6 17-Apr-2013 Elliott Hughes <enh@google.com> am 42425720: Merge "Fix Hebrew/Indonesian/Yiddish plural rules."

* commit '42425720d022955a996560e850c797587492e431':
Fix Hebrew/Indonesian/Yiddish plural rules.
d4f2bbad3cf3b479e76f4913241e2d45010fbb60 17-Apr-2013 Elliott Hughes <enh@google.com> Fix Hebrew/Indonesian/Yiddish plural rules.

icu4c doesn't translate the deprecated language codes Java uses back into
the current language codes, so we need to do that ourselves.

Bug: 8619221
Change-Id: I241c33e10547d2858ac08e303d5f0327912a89ff
ibcore_icu_NativePluralRules.cpp
0ee9913e40a1aaa38fc4d4f31bd43ab44271e771 05-Apr-2013 Kenny Root <kroot@google.com> am 18ce54dd: Merge "NativeCrypto: catch another RSA error"

* commit '18ce54dd09e46f348dd8abc218a4eb83c2a00404':
NativeCrypto: catch another RSA error
f04fc33c88d2ad1f06d58d50a0734c0ef511c5b9 05-Apr-2013 Kenny Root <kroot@google.com> NativeCrypto: catch another RSA error

Also add a generic fallback for certificate verification when the specific
type of error is unknown.

Bug: 8550441
Change-Id: Iee44be55c698a4a33450b569c12199747fdbcc49
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
019544f81ec14ea6be7b384393eafdb2fd622cb9 01-Apr-2013 Kenny Root <kroot@google.com> NativeCrypto: add missing native function

This should be covered by NativeCryptoTest as well but there was a missing
native function that caused
tests.security.cert.CertificateCertificateRepTest#testReadResolve
to fail.

There was also a missing OpenSSL error catch that made the same test
fail.

(cherry picked from commit 40875857eb5fe3434cbab6fc4517c6ffa52fdc24)

Bug: 8488314
Change-Id: Ib9cafe486228bae1634de275302876098353ec10
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
325ce8a74236f16db63c1971a99aeabf55e61a57 01-Apr-2013 Kenny Root <kroot@google.com> NativeCrypto: adjust thrown exceptions

Should be throwing CertificateException when InputStream is null.

Sometimes OpenSSL doesn't push an error onto the list when PEM encoding
fails. This can be seen with the call to PEM_read_bio_X509 with
hyts_badpem.cer Throw a generic RuntimeException instead.

(cherry picked from commit d14eedd3c70f67a0d7af71b56dcf7b8e4f030bdd)

Bug: 8488314
Change-Id: I716c089c00ab477b4803bdd774681e52384eb95d
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
40875857eb5fe3434cbab6fc4517c6ffa52fdc24 01-Apr-2013 Kenny Root <kroot@google.com> NativeCrypto: add missing native function

This should be covered by NativeCryptoTest as well but there was a missing
native function that caused
tests.security.cert.CertificateCertificateRepTest#testReadResolve
to fail.

There was also a missing OpenSSL error catch that made the same test
fail.

Bug: 8488314
Change-Id: Ic8bca86ab221a478e303c8e94662f28d279c19b6
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
d14eedd3c70f67a0d7af71b56dcf7b8e4f030bdd 01-Apr-2013 Kenny Root <kroot@google.com> NativeCrypto: adjust thrown exceptions

Should be throwing CertificateException when InputStream is null.

Sometimes OpenSSL doesn't push an error onto the list when PEM encoding
fails. This can be seen with the call to PEM_read_bio_X509 with
hyts_badpem.cer Throw a generic RuntimeException instead.

Bug: 8488314
Change-Id: Iee3b240e3def076f67e15980897be87ff3bf5e6c
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
39143413c9a4ccb11f0c16b50bdbf07cca79f19c 01-Apr-2013 Kenny Root <kroot@google.com> NativeCrypto: adjust BasicConstraints check

OpenSSL checks KeyUsage for "Certificate Signing" when checking for a
CA, but Java just specifies that the getBasicConstraints call only looks
at the BasicConstraints itself.

(cherry picked from commit cd59afd3e34cb6b3645babdace22c03882e0ec19)

Bug: 8488314
Change-Id: I72f8d6679169480960630bd73745ebf4c55b383c
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
cd59afd3e34cb6b3645babdace22c03882e0ec19 01-Apr-2013 Kenny Root <kroot@google.com> NativeCrypto: adjust BasicConstraints check

OpenSSL checks KeyUsage for "Certificate Signing" when checking for a
CA, but Java just specifies that the getBasicConstraints call only looks
at the BasicConstraints itself.

Bug: 8488314
Change-Id: I072cd2e9f1a9295a717f7587817149200113c65f
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
d961888f0666ccd4b797205aaeb60889688a9cb8 29-Mar-2013 Alex Klyubin <klyubin@google.com> Switch OpenSSLECDHKeyAgreement to KeyFactory.translateKey.

OpenSSL KeyFactory.translateKey encapsulates all the functionality
for translating arbitrary Key instances to OpenSSL-backed Key
instances. Thus, there's no need to replicate that functionality
elsewhere.

(cherry picked from commit 0469e3a6a9b5e854b8b985039de8ba4f6e6037bd)

Change-Id: I4caa0021e51a83be6932617117275fd033b6d5f7
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
0469e3a6a9b5e854b8b985039de8ba4f6e6037bd 29-Mar-2013 Alex Klyubin <klyubin@google.com> Switch OpenSSLECDHKeyAgreement to KeyFactory.translateKey.

OpenSSL KeyFactory.translateKey encapsulates all the functionality
for translating arbitrary Key instances to OpenSSL-backed Key
instances. Thus, there's no need to replicate that functionality
elsewhere.

Change-Id: I4caa0021e51a83be6932617117275fd033b6d5f7
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
0fa4d2c52c874ac710e5195978ec0b833c5050ae 29-Mar-2013 Elliott Hughes <enh@google.com> am 236ab1f1: am 589d6f45: Merge "Use longs instead of ints to store pointers in NIO buffers."

* commit '236ab1f11ae3beaa9fee4c01e8f541429cd0bf62':
Use longs instead of ints to store pointers in NIO buffers.
0121106d9dc1ba713b53822886355e4d9339e852 28-Feb-2013 Joel Dice <joel.dice@gmail.com> Use longs instead of ints to store pointers in NIO buffers.

This allows the code to be used on 64-bit VMs.

Change-Id: I4d01bfcd0ffea528c6179687771d047fdcb4d18a
ibcore_io_Memory.cpp
0e8970748c8c78c7efd70cd642881dd99a8adeb3 29-Mar-2013 Elliott Hughes <enh@google.com> am 02b995fe: am 79ad9308: Merge "Add strsignal(3) to Libcore.os."

* commit '02b995fe022262734629fe130fae9e5918eda265':
Add strsignal(3) to Libcore.os.
763f8ed6195707d0c30bfae1ca8a3bb886b746cc 29-Mar-2013 Elliott Hughes <enh@google.com> Add strsignal(3) to Libcore.os.

Bug: 8322568
Change-Id: Iab9a782181a663719b88f090f474b66d24b69258
ibcore_io_Posix.cpp
e1160af2ea30d42d6fabf2f987c1f634c0d31ba8 22-Mar-2013 Elliott Hughes <enh@google.com> am 8223a7f0: am ee41b1df: Merge "Fix libcore translation of AF_UNSPEC InetAddress instances."

* commit '8223a7f0c4dd1119d05199f48fe70d854cd8b558':
Fix libcore translation of AF_UNSPEC InetAddress instances.
d52f91aad5c154c72906f62336fd9ef0a7df127d 22-Mar-2013 Elliott Hughes <enh@google.com> Fix libcore translation of AF_UNSPEC InetAddress instances.

An AF_UNSPEC sockaddr may not have any data, but it does have two bytes
of ss_family.

Change-Id: Ia2423989db1a4094fc9bbfdb5565ee2074743747
etworkUtilities.cpp
48394b6e85c73211974ef3acad27b85aad22dc8d 22-Mar-2013 Elliott Hughes <enh@google.com> am 9ec78ca6: am ad5dc53f: Merge "Remove EWOULDBLOCK from libcore."

* commit '9ec78ca6374af9e405c0545683f0d2a644e0f7bf':
Remove EWOULDBLOCK from libcore.
f4a4259d8a548ab172ca98b702feafcd0ceb1411 22-Mar-2013 Elliott Hughes <enh@google.com> Remove EWOULDBLOCK from libcore.

On Linux, EWOULDBLOCK == EAGAIN, and having a synonym is just confusing.

Change-Id: If53c4ba6d82eed2236dec12003c4c9512c4ecbee
ibcore_io_OsConstants.cpp
84b242b7b943dd953c359469a8776a74c026f7cf 21-Mar-2013 Brian Carlstrom <bdc@google.com> am 58008844: am beed8981: Merge "Throw a more detailed exception on failure in NativeCrypto_SSL_CTX_new"

* commit '58008844ecca312f86c62877220fc3b4ee890df9':
Throw a more detailed exception on failure in NativeCrypto_SSL_CTX_new
e94dde5369da5f3983f13004fa492a48a7eae540 21-Mar-2013 Brian Carlstrom <bdc@google.com> Throw a more detailed exception on failure in NativeCrypto_SSL_CTX_new

Bug: 8172001
Change-Id: I39ca6d7480ad0c4dc6628c412e73fc2b5bf01689
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
0fde03fc4507c6e17cf511c8a1c5a4f96a9cf958 21-Mar-2013 Elliott Hughes <enh@google.com> am 933cb9ea: am 0f7e3bb4: Merge "Add support for Unix domain sockets."

* commit '933cb9eaab75744547d55f57045a685b76c69bd0':
Add support for Unix domain sockets.
482a3fc5635ac431b8a7476d7fe3397af4c2e8ec 21-Mar-2013 Elliott Hughes <enh@google.com> Add support for Unix domain sockets.

Bug: 6513075
Change-Id: I0b0166f59745ac8175b39d7796c093041b2df4fd
niConstants.cpp
niConstants.h
etworkUtilities.cpp
etworkUtilities.h
ibcore_io_OsConstants.cpp
ibcore_io_Posix.cpp
cb47643377b744db334453a0237e8774a3acb91d 19-Mar-2013 Kenny Root <kroot@google.com> am bb7b75b9: am e699186e: Merge "NativeCrypto: throw exception on invalid DNS altname"

* commit 'bb7b75b9dccf471f3f52cdb088b0c665cf6ded76':
NativeCrypto: throw exception on invalid DNS altname
348b7f8b5b147fcba5c120d9070d8f751f4d8df8 18-Mar-2013 Jay Shrauner <shrauner@google.com> Wrap AlphabeticIndex get/setMaxLabelCount

Add JNI wrappers for AlphabeticIndex::get/setMaxLabelCount. ICU 51 default
maxLabelCount is 99; need to be able to increase this to support labeling
secondary languages.

Bug:5356921
Change-Id: I8819e8e1fa080ba4aa06bf616722d059c8a6f9ae
ibcore_icu_AlphabeticIndex.cpp
223319e62fb4e34b2e82c0d72b3b8af8cb18b68b 18-Mar-2013 Kenny Root <kroot@google.com> NativeCrypto: throw exception on invalid DNS altname

When we receive an invalid DNS alt name (e.g., contains characters
outside of the ASCII printable range), we should throw an exception to
match the previous behavior. This is not validated this against the RI
since the tests currently don't work, but it brings the behavior back to
what it was previously.

Also amend the previous ASN.1 string check to use
ASN1_PRINTABLE_type(...) which actually scans the string to check its
contents. This is what was meant in the last patch.

Bug: 8398461
Change-Id: I260f045a2e144fb9ded7e1d3aa46592da8f63272
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
51cf1b49bca54ec0229a51df400ad1bee580b1bb 16-Mar-2013 Brian Carlstrom <bdc@google.com> Assorted socket fixes related to test_SSLSocket_setSoWriteTimeout failure investigation

1.) Fixed the failure of libcore.javax.net.ssl.SSLSocketTest's
test_SSLSocket_setSoWriteTimeout by setting send/recv buffer sizes earlier (b/8272932)
2.) Fixed javadoc bug in java.net.Socket
3.) Fixed implementation bug in IoBridge affecting reading SO_RCVBUF
4.) Fixed bug where we would leave unsent bytes in OpenSSL write buffer after SSLSocket write
possible cause of b/6693087

Bug: 8272932
Bug: 6693087
Change-Id: I54e084e58e8b10583a6ac3051d5e05e519139d64
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
3661cb8bb53356560bd4616f5c615f8fbbacf587 15-Mar-2013 Kenny Root <kroot@google.com> Merge "NativeCrypto: reject non-IA5String altnames"
e4502a9efb6461e37784cac58235944ef0d0c0cb 15-Mar-2013 Kenny Root <kroot@google.com> NativeCrypto: reject non-IA5String altnames

Certificates with rfc822Name, dNSName, or uniformResourceLocator must be
an IA5String, but OpenSSL doesn't enforce that during parsing. Return
NULL for those entries that don't comply.

Change-Id: I26727007196980648955f861df1d1cc013506911
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
dad6760aedf4c6b29b47dea6352d88fc3df9b2e5 15-Mar-2013 Elliott Hughes <enh@google.com> Return Olson ids from TimeZoneNames.forLocale in zone.tab order.

Bug: 8391426
Change-Id: I7b1335a8d8e0c804d68c85b18b1c4891ec269c1d
ibcore_icu_TimeZoneNames.cpp
61ed0bc3c921bba9ebfd89931d4d09c06c15390e 12-Mar-2013 Kenny Root <kroot@google.com> NativeCrypto: switch throw mappings to switch

The OpenSSL error to Exception mapping is growing, so just move to using
switch statement so we can add more mapping easily.

Change-Id: I223959e4252c1d764ebdf83d9ab143ff291dec1a
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
e741559fd878ee6e3deca9102f7c27e1c1ca70d0 11-Mar-2013 Alex Klyubin <klyubin@google.com> Add support for ECDH KeyAgreement to OpenSSLProvider.

Change-Id: I07d369de0199505d22f2809c815cc2852388a7b7
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
a19da4ff6f832e2f559e470402dfa7e3a615e340 08-Mar-2013 Kenny Root <kroot@google.com> NativeCrypto: make all DSA errors the same

All the reason codes for DSA to fail are invalid key errors, so make
them all throw InvalidKeyException.

Change-Id: Ifcde4be47ba55411b3693ab7d4d43f4c09e85517
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
e6de385bae91943cae91d88ad8e1bfdd951930f4 08-Mar-2013 Kenny Root <kroot@google.com> NativeCrypto: various fixes

* JNI_TRACE debug messages were misleading in some cases.

* MD object reference was being passed as a jint

* kusage wasn't being checked for null

Change-Id: I15bcba4d8b7291dc232ea20671917bb0848c3180
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
21e34921c8ae93bb5da361167ec02dae3c9b4a62 08-Mar-2013 Kenny Root <kroot@google.com> Merge changes I8475e328,Ie0e35777

* changes:
NativeCrypto: add CertPath encoding PkiPath
NativeCrypto: add CertPath support with PKCS7
15cfd91abf3e6d6f905d572fe70cf2b3b4cfee60 08-Mar-2013 Kenny Root <kroot@google.com> NativeCrypto: add CertPath encoding PkiPath

Set the default encoding to be PkiPath to conform to other
implementations. This now passes all the tests.

Change-Id: I8475e328e8440aa3ecccd88c34e2aba6bc169be5
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
52055836ff1f8c235a558b3754b3f3dd25f5d38c 08-Mar-2013 Kenny Root <kroot@google.com> NativeCrypto: add CertPath support with PKCS7

Add support for generating CertPath with the
OpenSSLX509CertificateFactory implementation.

This only will encode withrPKCS7 currently. This means it fails the
CertPath serialization test because the serialization and
de-serialization code only uses a provider's default serialization
format. Since this provider is not the default provider and the
default provider uses PkiPath as its default format, the
OpenSSLX509CertPath still fails the tests.

This seems like a problem with the way CertPath is serialized. The
impact of this seems to be that a CertPath implementation must have
"PkiPath" as its default encoding.

Change-Id: Ie0e3577746345108301b02e7a1d4e8ea189f2bda
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
78af00c336f82170d6497741688b0cbe032b7911 07-Mar-2013 Jay Shrauner <shrauner@google.com> Add JNI wrappers for ImmutableIndex

Add JNI wrappers for AlphabeticIndex.ImmutableIndex from ICU 51.

(cherry-pick of 57ff266fa4bfe233c99ac97479bfbd82c977371f.)

Change-Id: I6fd2fd4d1fe33cfac8d932ad7ba080ebe42a45dc
ibcore_icu_AlphabeticIndex.cpp
75dc9601af8ab3c65114e3c8c57d29ce5ac64125 19-Dec-2012 Kenny Root <kroot@google.com> NativeCrypto: add OpenSSL X.509 certificate/CRLs

Initial implementation of parsing X.509 certificates and certificate
revocation lists (CRLs). This lacks support for generating CertPath
objects, but that will be added at a later time.

This currently isn't the default provider so anything that doesn't
explicitly request this provider will not get this implementation.

Change-Id: I07ae9f333763087cb6ce47e20e12ceeed750920d
niConstants.cpp
niConstants.h
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
3655d9f527b3c84f1d5abe949b5d7075735b7c7d 05-Mar-2013 Elliott Hughes <enh@google.com> Merge "use longs instead of ints to store pointers in regex classes"
c1f6588cf2400b3118bb4fcc65f695491110a4f3 04-Mar-2013 Kenny Root <kroot@google.com> NativeCrypto: add OpenSSLBIOInputStream

Any APIs that deal with potentially unbounded input data need a better
way of reading in data than byte arrays. This provides a building block
to implement those APIs with OpenSSL.

Change-Id: I58fef4388dc2731cc004ec5cb9ccc805acc55888
niConstants.cpp
niConstants.h
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
d1309c1248ab3004cc78d2fb79b5b84505aca87b 05-Mar-2013 Kenny Root <kroot@google.com> NativeCrypto: fix 64-bit pointer

EVP_CIPHER_iv_length had used a 32-bit pointer.

change-Id: I2f6f9a244b989665e751fe520c6c2aba8cf1bd25
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
8acd6134dc84b387608746fbf2054c6d7dcd4f52 28-Feb-2013 Joel Dice <joel.dice@gmail.com> use longs instead of ints to store pointers in OpenSSL binding

This allows the code to be used on 64-bit VMs.

Change-Id: I6c0ef28c55160186c7d59e88ef6fcde4f4a41907
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
09bcea1fd2a0bade07ab034352fde6c6ff6e01a6 01-Mar-2013 Elliott Hughes <enh@google.com> Add Unsafe.allocateInstance.

At the moment, mockers are writing dalvik-specific code that pokes
around with our internals and breaks when we change stuff. They're
also supporting Unsafe so they can run on the RI. Everyone's better
off if we just implement the missing Unsafe call.

Bug: 8297640
Change-Id: Ib647e27d920be548009f26ced3b74bad7400a590
egister.cpp
ub.mk
un_misc_Unsafe.cpp
ad616f2163d1986f095fc0910f2c94a2c564497c 28-Feb-2013 Joel Dice <joel.dice@gmail.com> use longs instead of ints to store pointers in regex classes

This allows the code to be used on 64-bit VMs.

Change-Id: I27be2026e4eea6ea9063aa669e1c41d0e2f0cb04
ava_util_regex_Matcher.cpp
ava_util_regex_Pattern.cpp
60b997f1a60b754cfa15f7b6ea7f1c3dadfaf43e 28-Feb-2013 Joel Dice <joel.dice@gmail.com> use longs instead of ints to store pointers in NativeDecimalFormat

This allows the class to be used on 64-bit VMs.

Change-Id: Ie32d72f2f3c80d34a3da0fa08fcd96ed45793473
ibcore_icu_NativeDecimalFormat.cpp
0b00d81d3c9e9a2df4635cd6a55e291cce303658 28-Feb-2013 Joel Dice <joel.dice@gmail.com> use longs instead of ints to store pointers in ExpatParser

This allows the class to be used on 64-bit VMs. I've also changed
ExpatAttributes to match.

Change-Id: I4340040085b517b6f713623755f4647e190a68a9
rg_apache_harmony_xml_ExpatParser.cpp
a40dc9f768eb02dcfd7b1a659333757b148f7bec 27-Feb-2013 Joel Dice <joel.dice@gmail.com> use longs instead of ints to store pointers in ObjectStreamClass

This allows the class to be used on 64-bit VMs.

Change-Id: Ie8dc3a7b3849c94e5cf37cf5c5e0c3231f5af26f
ava_io_ObjectStreamClass.cpp
15d82808bab24f399a034d086f587d5fab32522e 27-Feb-2013 Elliott Hughes <enh@google.com> Make the CLDR version available.

Change-Id: I745b0153ae1dd9eb24dc02b19ac5ab34638a07e3
ibcore_icu_ICU.cpp
ac7cf58962995825464af08ae6fa5e006c94f3fa 27-Feb-2013 Elliott Hughes <enh@google.com> Switch to using icu4c 50's TimeZoneNames API.

This takes us down from ~330ms/locale on prime to ~70ms/locale.

This also fixes a bug in DateFormatSymbols.getZoneStrings and adds a test
so we don't regress.

Change-Id: I13663a659666c0a7d87a299235b75fa4e9fef69d
niConstants.cpp
niConstants.h
egister.cpp
ibcore_icu_TimeZoneNames.cpp
ibcore_icu_TimeZones.cpp
ub.mk
e8c6258cefbba8d01ce4b97f21e53266b73d5d36 21-Feb-2013 andrey yusipov <andrey.yusipov@sonymobile.com> Memory leak in StringStack::push detected in ExpatParser_initialize

array pointer becomes loose.
Need to delete it before array = NewArray
rg_apache_harmony_xml_ExpatParser.cpp
1c025319e6fea7b68817a59f0a103dcf02672c8d 16-Feb-2013 Jay Shrauner <shrauner@google.com> Persist Transliterator objects with JNI wrappers

Hold a reference to created Transliterator objects.

(cherry-pick of f273ce458c68f5f2b468927392aededc52b8d814.)

Change-Id: I8d68280be0ffb84f3039338eb8b52b07e23296f1
ibcore_icu_Transliterator.cpp
72484cceb306ec3e197a8aba11374a6b24e9bfae 14-Feb-2013 Jay Shrauner <shrauner@google.com> Add additional AlphabeticIndex methods

Wrap AlphabeticIndex getBucketCount and addLabels(UnicodeSet) methods.

(cherry-pick of a7eab938026a211a8065b5c695080a6cdd7055a1.)

Change-Id: I02d89aac3345548441f81e505138f921f6fcbd94
ibcore_icu_AlphabeticIndex.cpp
a812f61dc1102c8089c1acd48c24b36829ce2482 06-Feb-2013 Kenny Root <kroot@google.com> NativeCrypto: fix more DSA/ECDSA key generation

* Add hidden API to pass along the EC curve name in ECParameterSpec.
The lack of name passing made KeyFactory2Test fail because the
reconstructed ECDSA key had explicit curve parameters instead of an
OID naming the curve.

* Fix some mixing of PKCS8/X509EncodedKeySpec in DSA/ECDSA KeyFactory
implementations.

* Fix the KeyFactory2Test to output more useful error messages.

* Remove known failure which is no longer happening.

* Change EC_GROUP_get_curve_name to return the "shortName" string
which matches the EC_GROUP_new_by_curve_name

Bug: 3483365
Change-Id: I0a80be88bef728b2177f3593cc3421fa47b79470
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
798f855f67b74d481346d9dc2293ba0eedd8daf9 05-Feb-2013 Nick Kralevich <nnk@google.com> Add support for Libcore.os.exec*()

Add Libcore support for execv() and execve().
This allows java programs to execute other programs
without having to write jni wrappers.

Change-Id: I82ddc069b5812ebd40f06b7f65ce173d496e0597
ava_lang_ProcessManager.cpp
ibcore_io_Posix.cpp
oStringArray.cpp
oStringArray.h
58d66640cb62cec2fee9aa6c3f534565d415eb8e 05-Feb-2013 Elliott Hughes <enh@google.com> Merge "Add libcore.icu.AlphabeticIndex."
860b3c5989a8dd9de73639d8057443aa12fe7b16 05-Feb-2013 Elliott Hughes <enh@google.com> Add libcore.icu.AlphabeticIndex.

Change-Id: I06a634199ff2c8dcf0a8b6e4774da4cdbfb0d774
egister.cpp
ibcore_icu_AlphabeticIndex.cpp
ibcore_icu_Transliterator.cpp
ub.mk
fc5480d13eb8b32c325ba79ba4221df2145727b7 05-Feb-2013 Kenny Root <kroot@google.com> NativeCrypto: DSA keys do not always have parameters

DSA keys do not always have parameters. When validating a certificate
chain, the DSA key will inherit parameters from the next DSA key up the
chain if DSAPublicKey#getParams() returns "null".

Change-Id: I052b42219829157ebdf148abb53048044cc83f8d
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
3aac4ddc4d17c07fa8b4908069d23d5401a77993 05-Feb-2013 Elliott Hughes <enh@google.com> Add icu4c-backed transliteration.

Change-Id: I4194810646a2a0661331aaf941fb5f99ce7758b1
cuUtilities.cpp
cuUtilities.h
niException.cpp
niException.h
egister.cpp
ipUtilities.h
ava_text_Bidi.cpp
ava_util_regex_Matcher.cpp
ava_util_regex_Pattern.cpp
ava_util_zip_Deflater.cpp
ava_util_zip_Inflater.cpp
ibcore_icu_ICU.cpp
ibcore_icu_NativeBreakIterator.cpp
ibcore_icu_NativeCollation.cpp
ibcore_icu_NativeConverter.cpp
ibcore_icu_NativeDecimalFormat.cpp
ibcore_icu_NativeNormalizer.cpp
ibcore_icu_NativePluralRules.cpp
ibcore_icu_TimeZones.cpp
ibcore_icu_Transliterator.cpp
ub.mk
ip.h
cd8a6ed093ef3746451c18538b193f55320c5368 29-Jan-2013 Elliott Hughes <enh@google.com> Don't rely on fallback time zone names starting "GMT".

I can't think of a way to say what I actually want to say here, so let's
just wait for icu4c 50 and hope we can rewrite all this code with the new
TimeZoneNames API. Until then, various locales -- those whose gmtFormat
doesn't start "GMT" -- still have the bugs that the previous change fixes
for the majority of locales.

Also switch from "Samoa Summer Time" to "Samoa Daylight Time" because that's
what CLDR is proposing to go with.

Change-Id: I47e2fc413ccde6af59f51e5ec79e664a1dc8be82
ibcore_icu_TimeZones.cpp
6914efca8fe737a753d234d7e91222da6a8cdabe 28-Jan-2013 Kenny Root <kroot@google.com> NativeCrypto: add test base for OpenSSL ENGINEs

This sets up some of the testing infrastructure to allow us to test all
the ENGINE-related test paths in the NativeCrypto code.

Change-Id: I21f3dbebbaa90327d48a99020ae3a3e90624cc75
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
778d993a4af1077e38e3d9f8afc07c47594f9714 26-Jan-2013 Kenny Root <kroot@google.com> Merge "OpenSSLKey: easier creation and use of OpenSSL keys"
6c1e5f4ad36c1f51687aa2b059e998a7c2db2e36 26-Jan-2013 Elliott Hughes <enh@google.com> Manually update the libcore native code.

Cherry-picking all the individual tiny cleanups from the internal branch was
too hard.

Change-Id: Ib97643d3502295685390854c9edd97c93c4c2ecf
synchronousSocketCloseMonitor.cpp
ortability.h
bigint.cpp
ava_io_File.cpp
ava_lang_ProcessManager.cpp
ava_lang_StrictMath.cpp
ava_lang_StringToReal.cpp
ava_text_Bidi.cpp
ibcore_icu_NativeConverter.cpp
ibcore_io_AsynchronousCloseMonitor.cpp
ibcore_io_Memory.cpp
ibcore_io_OsConstants.cpp
ibcore_io_Posix.cpp
rg_apache_harmony_xml_ExpatParser.cpp
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
0731d6d00c5e30c05e035d3ae96327029d07a606 22-Jan-2013 Kenny Root <kroot@google.com> OpenSSLKey: easier creation and use of OpenSSL keys

For some future changes, it will be easier to convert OpenSSL objects to
real objects and back from native pointers. Make it easier to add new
EVP_PKEY types without adding them in if/else statements everywhere.

Change-Id: I19095bfc5f00835a266f572bc62e2e8d0a8cd544
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
bd21f73daf5081d5b98f93922b59f407249616a5 19-Jan-2013 Elliott Hughes <enh@google.com> Merge "Don't call GetMethodID with a pending exception."
c1cee0db58ec7bc61d5caac79915d744862cbe75 19-Jan-2013 Elliott Hughes <enh@google.com> Don't call GetMethodID with a pending exception.

Why has no-one been hitting this? Because you'd need your first
getaddrinfo(3) failure to be an EAI_SYSTEM kind of failure, and
you'd need CheckJNI on. So only developers could hit this, and
they'd have to be really unlucky. Like the guy sitting next to me.

Change-Id: I6d2808722eaa50a96ebfa92b996803783601e429
ibcore_io_Posix.cpp
4b88b3ded5c026282bf3a38cc006dc5f764603a1 19-Jan-2013 Brian Carlstrom <bdc@google.com> Merge "Add support for TLS Channel ID to OpenSSL-backed sockets."
7e5832d1a709558fca80ecb25fdd0626b2d4312d 19-Jan-2013 Kenny Root <kroot@google.com> Merge changes Idfb18017,Ifbba9fdf

* changes:
OpenSSLMac: fix initialization with new key
HarmonyJSSE: convert byte correctly in padding check
0d4ee1f9b8c37fb33cd74da4efac5905ba138e45 19-Jan-2013 Kenny Root <kroot@google.com> OpenSSLMac: fix initialization with new key

If an OpenSSLMac instance was re-initialized with a new key, it wouldn't
produce correct results. Make sure to re-initialize the EVP_MD_CTX as
well.

Change-Id: Idfb18017407ff65866ae7e6f6fca3d646a970803
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
ca8e030149675a1767203b64b886253e337abcb9 18-Jan-2013 Elliott Hughes <enh@google.com> Merge "Improve our time zone name collection."
f20e96718a936499da309766da7f36f123b43d93 18-Jan-2013 Elliott Hughes <enh@google.com> Improve our time zone name collection.

A variety of bugs here. We weren't using dates in the current year,
we were assuming that icu4c has correct time zone transition data (it
usually doesn't), and in the fallback code (which we'd previously
never hit) we weren't honoring the caller's request for standard/daylight
time.

This patch fixes:

Africa/Tripoli: long='Eastern European Standard Time' short='Eastern European Standard Time'!
America/Araguaina: long='Brasilia Standard Time' short='Brasilia Standard Time'!
America/Campo_Grande: long='Amazon Standard Time' short='Amazon Standard Time'!
America/Cuiaba: long='Amazon Standard Time' short='Amazon Standard Time'!
America/Havana: long='Cuba Standard Time' short='Cuba Standard Time'!
America/Santiago: long='Chile Standard Time' short='Chile Standard Time'!
America/Sao_Paulo: long='Brasilia Standard Time' short='Brasilia Standard Time'!
Antarctica/Palmer: long='Chile Standard Time' short='Chile Standard Time'!
Asia/Jerusalem: long='Israel Standard Time' short='Israel Standard Time'!
Asia/Tehran: long='Iran Standard Time' short='Iran Standard Time'!
Asia/Tel_Aviv: long='Israel Standard Time' short='Israel Standard Time'!
Brazil/East: long='Brasilia Standard Time' short='Brasilia Standard Time'!
Chile/Continental: long='Chile Standard Time' short='Chile Standard Time'!
Chile/EasterIsland: long='Easter Island Standard Time' short='Easter Island Standard Time'!
Cuba: long='Cuba Standard Time' short='Cuba Standard Time'!
Iran: long='Iran Standard Time' short='Iran Standard Time'!
Israel: long='Israel Standard Time' short='Israel Standard Time'!
Libya: long='Eastern European Standard Time' short='Eastern European Standard Time'!
Pacific/Apia: long='Samoa Standard Time' short='Samoa Standard Time'!
Pacific/Easter: long='Easter Island Standard Time' short='Easter Island Standard Time'!
Pacific/Fiji: long='Fiji Standard Time' short='Fiji Standard Time'!

It also fixes Pacific/Fakaofo, which was confused between GMT+14:00 and
GMT+13:00.

We need a special case for Pacific/Apia because icu4c 4.9 doesn't believe
Samoa has ever used daylight time.

I've also added a test to keep us out of mischief in the face of future
upgrades to the Olson tzdata and/or icu4c.

Bug: 7955614
Bug: 8026776
Change-Id: I7ed551a691f29e26dd71456d492493d2a4fce945
ibcore_icu_TimeZones.cpp
de30700ecd96af43e2f3ee2e03f398896f5bb1e9 17-Jan-2013 Alex Klyubin <klyubin@google.com> Add support for TLS Channel ID to OpenSSL-backed sockets.

On the client, TLS Channel ID is enabled by passing an ECDSA P-256
private key to OpenSSLSocketImpl via the new setChannelIdPrivateKey
method.

On the server, TLS Channel ID is enabled via the new method
OpenSSLServerSocketImpl.setChannelIdEnabled. After the TLS/SSL
handshake, the Channel ID can be obtained via the new method
getChannelId.

See http://tools.ietf.org/html/draft-balfanz-tls-channelid-00.

Change-Id: I035e86d36678ae5956e6c1837afefcd668b3d750
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
65de5c409f566322178f7b890e4e47c656702810 18-Jan-2013 Kenny Root <kroot@google.com> Merge "NativeCrypto: output named curves when possible"
c9acbf1c80d90952f7a4bce83e37c2540e42f6fc 17-Jan-2013 Kenny Root <kroot@google.com> NativeCrypto: output named curves when possible

When converting to ASN.1 format from a named curve, try to make sure we
can output those named curves whenever possible instead of all the
parameters.

Also make sure we output in uncompressed point format for compatibility
with other implementations.

Change-Id: I3f370be694ac709f02e3043a2c1152ad4838ef41
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
0617166064042db795122e2109a17f4e7d4a936b 17-Jan-2013 Brian Carlstrom <bdc@google.com> Move from Android SSL_MODE_SMALL_BUFFERS to OpenSSL v1.0.1 SSL_MODE_RELEASE_BUFFERS

Change-Id: I10962481d365ac0a9bb77f9fb5302faf2bc8ddec
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
e849e49a1c76cfdd33daafd1b14dfa1f250d9240 15-Jan-2013 Kenny Root <kroot@android.com> Merge "Revert "NativeCrypto: RSA fields cannot be NULL""
2a8257953abca66df1e38c0a9ddb1f46bba9ff31 15-Jan-2013 Kenny Root <kroot@android.com> Revert "NativeCrypto: RSA fields cannot be NULL"

This reverts commit 1496f006676166c1835ac859d5c4ffeb6357b4d0

Change-Id: I5869083fe6cb5f3f3de71233b466d0b1ac702e82
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
4f32b7933626e100fca505484f8b4636f3342e5e 14-Jan-2013 Elliott Hughes <enh@google.com> Make CLDR's 12- and 24-hour time formats available.

Bug: 7924970
Change-Id: I392e8110885f662f32caae46d961ca6e9e4301d7
ibcore_icu_ICU.cpp
1496f006676166c1835ac859d5c4ffeb6357b4d0 27-Dec-2012 Kenny Root <kroot@google.com> NativeCrypto: RSA fields cannot be NULL

If an RSA field is left NULL, it will not be represented in the ASN.1
output of the RSAPrivateKey. This leads to problems trying to recreate
the key since it does not emit the NULL fields and the fields are not
numbered.

Bug: 7920357
Change-Id: I144302925f9b080a2152a6d12f77981b3aad9495
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
982fdeca4be03a7e1e1ce2b20bb3b09ec9c40d35 22-Dec-2012 Kenny Root <kroot@google.com> NativeCrypto: templatize ASN1 to jbyteArray

Templatize all the OpenSSL ASN.1 type conversions to jbyteArray. Further
changes will need to use more i2d_<type> and it's all boiler-plate code.

Change-Id: Ib9c715c5c9d8b69eca6950c03e925d7e1d625cdb
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
039f7599559fd7e48c354b99dcb94ff391f53349 15-Dec-2012 Elliott Hughes <enh@google.com> Add tcsendbreak(3).

Change-Id: I12821c1ef41100ee83a13fd79c14d9eb16b6adca
ibcore_io_Posix.cpp
0ebd342f96a7dc74a1e9e015ddca1484ee0890c4 09-Oct-2012 Craig Cornelius <ccornelius@google.com> Track changes caused by the ICU 49.2 upgrade.

(cherry-pick of 0e996f766f975305a484b40809b6b720c0046980.)

Change-Id: I503be2cebe8664a624de7b84f655b646db6e86f7
rg_apache_harmony_xml_ExpatParser.cpp
f2d36fd3243e703464b1be537e059e2c0728ad32 06-Nov-2012 Elliott Hughes <enh@google.com> am 10a09486: Merge "Add setenv(3) and unsetenv(3) to Libcore.os."

* commit '10a094863eaf4d822f6b76be28f86a4905ebae51':
Add setenv(3) and unsetenv(3) to Libcore.os.
895a613aa2aec6aa6d03b29755cf2fea584909ad 06-Nov-2012 Elliott Hughes <enh@google.com> Add setenv(3) and unsetenv(3) to Libcore.os.

Change-Id: Ic1c667cda3203afecb3eb9b4183ec6a4013988cc
ibcore_io_Posix.cpp
0edc098f55770e79668ce3598c562c23b062fadb 02-Nov-2012 Elliott Hughes <enh@google.com> am 2ba4f42e: Merge "Don\'t create as many temporary icu4c Locale objects."

* commit '2ba4f42e6e1f7e0fb1289c2ff408e1ae153270d9':
Don't create as many temporary icu4c Locale objects.
007776e50b6305e2c4551f8ace682fffab412202 02-Nov-2012 Elliott Hughes <enh@google.com> Don't create as many temporary icu4c Locale objects.

Change-Id: I70c7c178d98958633db8341e1d66931ce037c6c7
ibcore_icu_ICU.cpp
390866a4396229ff489e8eafa57f643da07fd9e8 30-Oct-2012 Elliott Hughes <enh@google.com> am 7071a500: Merge "Fix libcore\'s usage of readdir_r(3)."

* commit '7071a500b68799657813aaf842db00b8a317f963':
Fix libcore's usage of readdir_r(3).
46cbaab8c210ff9d48c82640b508ced3e929b25c 27-Oct-2012 Elliott Hughes <enh@google.com> Fix libcore's usage of readdir_r(3).

Change-Id: I8dec83e77236fd9f37074b07ef0e404bf7ae05ab
ava_io_File.cpp
a51183e3bc41840a33b75eb5c7266b93c7a6fdb9 19-Oct-2012 Elliott Hughes <enh@google.com> am 42dac9f1: Merge "Fix the pt_PT currency symbol (€ rather than ¤)."

* commit '42dac9f1555c348823bebe91dba0ea06eaa4584d':
Fix the pt_PT currency symbol (€ rather than ¤).
a49a1e8c20b3cf9435ed422379f63e33e5c2eaf2 19-Oct-2012 Elliott Hughes <enh@google.com> Fix the pt_PT currency symbol (€ rather than ¤).

Bug: http://code.google.com/p/android/issues/detail?id=38622
Change-Id: I70bcf1d994e8467a32bdbdaa410067c6775fe889
ibcore_icu_ICU.cpp
c323184c9221d119b8b06a1fff6731f5119a64c0 16-Oct-2012 Kenny Root <kroot@google.com> am 196687f6: Merge "Use OpenSSL to convert from OID to name"

* commit '196687f6ed88a0935813efec5ca49c86fd536bf2':
Use OpenSSL to convert from OID to name
4a8388aeb988c5ed88f1105f9fa66a5ebd2ffbe3 15-Oct-2012 Kenny Root <kroot@google.com> Use OpenSSL to convert from OID to name

OpenSSL has a large database of OID mappings, so fall back to it if the
built-in Harmony database doesn't find it.

Change-Id: I72daa0b4f697d406a0d3f8285ce20d4e9ec04d27
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
b762206996492843be768a7ae061bbc85b5491da 15-Oct-2012 Kenny Root <kroot@google.com> am 70798f65: Merge "OpenSSLCipher: add ARC4 support"

* commit '70798f652c21e9bec770d0b965130311a84d5959':
OpenSSLCipher: add ARC4 support
edefa57a822c27f3e9def050fd50e375c5908551 02-Oct-2012 Kenny Root <kroot@google.com> OpenSSLCipher: add ARC4 support

Change-Id: Iccdd76260af1afab0855816b3ccdd34fbc52295b
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
a802453d3ef880efdec52c38913ecfacacd87d4e 12-Oct-2012 Kenny Root <kroot@google.com> NativeCrypto: add third argument for bad merge

Need a third argument on this branch!

Change-Id: If193abd5cfa825d26292da2275a24af5fa674d0e
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
9679c42bd37a2539b7306891cba53731c7a8b91b 12-Oct-2012 Kenny Root <kroot@google.com> am d5d84f6c: Merge "NativeCrypto: add EC key pairs"

* commit 'd5d84f6c657b9d130b4d34c77f151f425ae70ff4':
NativeCrypto: add EC key pairs
9d2fb535e5d43ad34af09195d490da18a7694a48 11-Oct-2012 Kenny Root <kroot@google.com> NativeCrypto: add EC key pairs

Change-Id: I8240df5ff12e38dd935258def099aed4663955ea
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
46d6243e9e39a2b68b985bfd534cc891e52df274 09-Oct-2012 Brian Carlstrom <bdc@google.com> Change OpenSSLCipherRSA.{engineGetBlockSize,engineGetOutputSize} to return result based on key size

Includes cherry-pick of 847f22adbd0e829b84491d7202dcbed5bf67a98c

Bug: 7192453
Change-Id: Ib5fa1e313d942d2c1034e8e7831af285ad24d71d
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
d18737386ae603e4cbecd6beb667832d41b9299a 11-Oct-2012 Kenny Root <kroot@google.com> am b37c70ea: Merge "NativeCrypto: const correctness for bignumToArray"

* commit 'b37c70ea18a828b6213c612f09ff216d51692203':
NativeCrypto: const correctness for bignumToArray
d8cf93db8bfddef6a012164dd5a2304afa3ead37 11-Oct-2012 Kenny Root <kroot@google.com> NativeCrypto: const correctness for bignumToArray

Change-Id: I9a57372416c265ea2374e9d25c5c0e39ef887333
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
32c042582b6fc5da2b86db1ca8920c5420edd2be 09-Oct-2012 Elliott Hughes <enh@google.com> am 23719174: Merge "Rewrite NativeBreakIterator to use refreshInputText."

* commit '2371917431e4571c6e6c2ca719f2c00682a566d4':
Rewrite NativeBreakIterator to use refreshInputText.
015843683630bd8e8f060c052ecd2e5a804a8396 08-Oct-2012 Elliott Hughes <enh@google.com> Rewrite NativeBreakIterator to use refreshInputText.

Requires icu4c >= 4.9, or a backport of the fix to icu4c bug
http://bugs.icu-project.org/trac/ticket/8490.

(cherry-pick of db1a2e3641d679faf34ce6532c487ab0236550a1.)

Bug: 7288264
Bug: 7307154
Change-Id: Ic8e5be2d345e2b2aa2873ab9bf35b1273199d227
ava_util_regex_Matcher.cpp
ibcore_icu_NativeBreakIterator.cpp
9e8deb110a6cf9c500aa874f9e1703e298e30d08 08-Oct-2012 Kenny Root <kroot@google.com> am 5f7d4a57: am 34907e20: Merge "NativeCrypto: scope output byte array"

* commit '5f7d4a5770668fddb3ecceae05d9c2f3b6663b18':
NativeCrypto: scope output byte array
34907e204918c8b46266fb93b6840960ab0fd5bc 08-Oct-2012 Kenny Root <kroot@google.com> Merge "NativeCrypto: scope output byte array"
fc86c6d5dd179d32a41943f4b803e45c00c816a4 06-Oct-2012 Kenny Root <kroot@google.com> am 39d248f9: am 99f69762: Merge "NativeCrypto: clear errors for key verification"

* commit '39d248f9cc03f18755167e576d610185388933aa':
NativeCrypto: clear errors for key verification
99f69762b673ac6faec4e6aa1bf087dc0aa74b00 06-Oct-2012 Kenny Root <kroot@google.com> Merge "NativeCrypto: clear errors for key verification"
912d5102b2986e3cdedb311784a43c7fe68db790 06-Oct-2012 Kenny Root <kroot@google.com> NativeCrypto: clear errors for key verification

It appears that OpenSSL has a bug where any DSA key verification
operation that fails will push an error on the OpenSSL error stack. This
change will clear the error state whenever a key verification is
performed.

Change-Id: I48e608aabb34974c5a55b3adf54d7c9059c69b90
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
b0eb691a277994658a42de372280d0a6970bd113 05-Oct-2012 Kenny Root <kroot@google.com> am e3247e4f: am e4008c91: Merge "NativeCrypto: add tests for DSA and RSA keys"

* commit 'e3247e4f91a266f4daa210193ee681084b227872':
NativeCrypto: add tests for DSA and RSA keys
ede9d4c017a464f611e753361fdf398ee8f3f7e9 05-Oct-2012 Kenny Root <kroot@google.com> am 4f241f36: am 6521bf07: Merge "NativeCrypto: add test for EVP_SignInit"

* commit '4f241f36f46ea522142e58f0b38da33e7cdad79a':
NativeCrypto: add test for EVP_SignInit
a8e0ac07166ba25fa50e83773cd18ac9f36bf18e 05-Oct-2012 Kenny Root <kroot@google.com> am f2c8382b: am 5a1225cc: Merge "NativeCrypto: add assertions for no OpenSSL errors"

* commit 'f2c8382b0aa0fca4b79601cb21a9136b862996c2':
NativeCrypto: add assertions for no OpenSSL errors
890d2ef4a8bdfb8e17a0269c72cbf17e22492813 05-Oct-2012 Kenny Root <kroot@google.com> NativeCrypto: scope output byte array

Make sure the allocated array is scoped so, if there is an error, it
will be freed.

Change-Id: Idafd24ea3705f13c1058269bef6656c26aa4ffb3
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
6ebc3d8b37c743980aabba8f5118f16dde7b6117 05-Oct-2012 Kenny Root <kroot@google.com> NativeCrypto: add tests for DSA and RSA keys

Change-Id: I75c924fe67e24948ba26640e99fcc1748671ddf5
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
714c74d8fad0ea9657520b3597156067f466c124 05-Oct-2012 Kenny Root <kroot@google.com> NativeCrypto: add test for EVP_SignInit

EVP_SignInit was not clearing OpenSSL errors when it encountered a bad
algorithm name.

Change-Id: I1b2a18ce51c784e0e9a3fb37574b34180c6f8719
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
008e8a74088c7508b49d8ea2323deef40c5076a7 05-Oct-2012 Kenny Root <kroot@google.com> NativeCrypto: add assertions for no OpenSSL errors

Some calls in NativeCrypto appear to be not clearing error states. Add
an assertion at the end of each test to make sure this doesn't happen.

Change-Id: I9030891a8dc9e7715e65071fe949a11d7a560e56
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
3843577d57f6d02883e43ca1172c5e4b11db8d80 05-Oct-2012 Elliott Hughes <enh@google.com> am cb178015: am 7dd2a254: Merge "Remove unnecessary #include."

* commit 'cb1780159888892ef0c2d6164482576181d442d0':
Remove unnecessary #include.
7dd2a254b93ef7a917264738a3c8bdcd6ebc5dc1 05-Oct-2012 Elliott Hughes <enh@google.com> Merge "Remove unnecessary #include."
f5df21ec7d504bed329d5d682981021363424338 05-Oct-2012 Elliott Hughes <enh@google.com> Remove unnecessary #include.

Change-Id: Ie95f39627ed068818b323e03bdbe7765285409d2
ibcore_icu_ICU.cpp
7842ba5ddb88f17c180bba8bfc32f2ef7270b382 05-Oct-2012 Kenny Root <kroot@google.com> am 080cda4a: am 7ae5f93f: Merge "OpenSSLMac: new OpenSSL HMAC connector"

* commit '080cda4ad77052269b3ac9a7db48cec05c49f3b4':
OpenSSLMac: new OpenSSL HMAC connector
7ae5f93f03f60b349f611122c4944634cfba4f39 05-Oct-2012 Kenny Root <kroot@google.com> Merge "OpenSSLMac: new OpenSSL HMAC connector"
a9a21fc20ac86e723c141bc145f582a2ab83268a 04-Oct-2012 Kenny Root <kroot@google.com> OpenSSLMac: new OpenSSL HMAC connector

Change-Id: I6a6a9cbdcdc490a0bc1c313bbaf045a4fd99555e
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
130e5d6b0281470f03abf810eb38aaa5aa1ca746 05-Oct-2012 Kenny Root <kroot@google.com> am a0592d4e: am d0670a67: Merge "OpenSSLCipher: use OpenSSL buf_len data"

* commit 'a0592d4ed7c71d5c1269d4e71611f10627fff8e7':
OpenSSLCipher: use OpenSSL buf_len data
81508e23428cffc070132f461c1166077910e836 05-Oct-2012 Kenny Root <kroot@google.com> OpenSSLCipher: use OpenSSL buf_len data

This allows us to exactly match other implementation outputs for the
same input values. What we were doing before was technically to the
API's documented behavior, but broke some other things.

Change-Id: I7e95dab4a7be8d737e862f6b6ddb04f6bbcd0dbe
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
5f727a9f94689b1003a80b6e464c9eb6971475ec 04-Oct-2012 Elliott Hughes <enh@google.com> am 26b29f3d: am 9a2a441a: Merge "Add ICU.getBestDateTimePattern."

* commit '26b29f3dc9aaadd0647c28a61156badfd6d96042':
Add ICU.getBestDateTimePattern.
f3cf8f7daed90edec16c9c1582d60fc21723eeb6 04-Oct-2012 Kenny Root <kroot@google.com> am a8969127: am 77be92fe: Merge "OpenSSLCipher: don\'t explode during null decrypt"

* commit 'a8969127cda9984754f758e1e3f839a83c5719f6':
OpenSSLCipher: don't explode during null decrypt
9a2a441ae372167dc122defbdde062076802b490 04-Oct-2012 Elliott Hughes <enh@google.com> Merge "Add ICU.getBestDateTimePattern."
fac659c013ec9c2783f60afce39e83eb107f117d 04-Oct-2012 Kenny Root <kroot@google.com> OpenSSLCipher: don't explode during null decrypt

Other Cipher implementations return "null" when calling "doFinal()"
during decrypt mode without having ever called .update(...)
Change OpenSSLCipher to do the same.

Change-Id: I76e22702a446912df125af0ff518fb123d62f5a3
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
cb1b9026b8aa993785c4d54f686905522b7959b9 04-Oct-2012 Elliott Hughes <enh@google.com> Add ICU.getBestDateTimePattern.

Bug: 7204705
Change-Id: I0c65745178182f992d1d0ba0f0d56768194e2084
ibcore_icu_ICU.cpp
d5db85f89e11e1ad4f78686b86d27ad26cb1c938 04-Oct-2012 Brian Carlstrom <bdc@google.com> am d26da2f6: am 9ac72760: Merge "OpenSSLCipher: remove buffer for partial blocks"

* commit 'd26da2f66c9139280a7fbd434980b3bd8349b612':
OpenSSLCipher: remove buffer for partial blocks
5189c980ebdc842e0e5ca7d6794b4880aa0b6cd5 04-Oct-2012 Kenny Root <kroot@google.com> OpenSSLCipher: remove buffer for partial blocks

Some block ciphers buffer the first block used. We weren't accounting
for this so we started failing with DES3. This led to another issue that
OpenSSL can sometimes keep things in its internal buffer. Instead of
having multiple levels of buffering, just rely on OpenSSL to do the
buffering.

Change-Id: I40a6c7e92e70d3c9ae530f35e8a4234f62e8d225
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
5db76d31870b0ef3ced3b0f01584118b4b9a3e3d 03-Oct-2012 Kenny Root <kroot@google.com> am ed07842e: am db3690a2: Merge "Fix some failing unit tests"

* commit 'ed07842e67e28e57c0ef596e2e1e4772d54926da':
Fix some failing unit tests
1fe411ff4e4aa4f24158effb6dbfd786bb30048a 03-Oct-2012 Kenny Root <kroot@google.com> Fix some failing unit tests

evpCipher can be null to handle re-initialization of CIPHER_CTX
instances.

Make the constructor of OpenSSLCipherContext public so it can be used in
testing.

Fix all of the things hidden by JNI_DEBUG that were not correct.

Throw a BadPaddingException when a decrypt fails. This particular error
is returned by OpenSSL in evp_enc.c from EVP_DecryptFinal_ex when the
padding check fails.

Change-Id: I77cad024db52986fe726443cd9b3ff52430a30dd
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
c2f3e11588854db37f609f60cea8ef946211a02f 03-Oct-2012 Kenny Root <kroot@google.com> am f8dac9e9: am d85dfd8d: Merge changes I81f1bec8,I4aa6e3a2

* commit 'f8dac9e9410705895e64187fd8ad75431e147957':
OpenSSLCipher: Add DESede support
Add Cipher support for AES through OpenSSL
13cf08b2f06e1f5f0278c449072898f5e147db49 24-Sep-2012 Kenny Root <kroot@google.com> Add Cipher support for AES through OpenSSL

Timings using encrypt with 256-bit key in CTR mode and PKCS5Padding:

implementation inputSize us linear runtime
OpenSSL 16 11.4 =
OpenSSL 32 12.1 =
OpenSSL 64 13.2 =
OpenSSL 128 15.1 =
OpenSSL 1024 44.0 =
OpenSSL 8192 275.0 ===
BouncyCastle 16 11.5 =
BouncyCastle 32 15.9 =
BouncyCastle 64 24.6 =
BouncyCastle 128 41.5 =
BouncyCastle 1024 277.2 ===
BouncyCastle 8192 2196.9 ==============================

Change-Id: I4aa6e3a2ca2b368fab2c602733b4f97e740d04fd
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
22455939ab3b61e3b3c48c0d70ced2a8ded83d98 01-Oct-2012 Brian Carlstrom <bdc@google.com> am 77b20888: Merge "NativeCryptoTest#test_SSL_do_handshake_clientCertificateRequested_throws_after_renegotiate failure" into jb-mr1-dev

* commit '77b2088858b199e60002bfb2acb7a883c6aba82a':
NativeCryptoTest#test_SSL_do_handshake_clientCertificateRequested_throws_after_renegotiate failure
fd6fb0f5974f8854d85c2b174a0b506ab6047b88 01-Oct-2012 Brian Carlstrom <bdc@google.com> am 51de62cf: Fix flaky NativeCryptoTest.test_SSL_do_handshake_client_timeout

* commit '51de62cf77a070e2a45ae397c391832b9a781d91':
Fix flaky NativeCryptoTest.test_SSL_do_handshake_client_timeout
025809f0a06ac8218e7c6b519936855f4d2a9686 01-Oct-2012 Elliott Hughes <enh@google.com> am 1fe7285c: am 4b606b12: Merge "Posix_umask: throw IllegalArgumentException on malformed mask"

* commit '1fe7285cdbe0625119bf3f2452c5811ef82039c5':
Posix_umask: throw IllegalArgumentException on malformed mask
c79d3ef4dcd25f0e264bf957861e2632da93e62d 27-Sep-2012 Nick Kralevich <nnk@google.com> Posix_umask: throw IllegalArgumentException on malformed mask

If we see an invalid umask, throw an IllegalArgumentException.
This prevents a native crash when FORTIFY_SOURCE is enabled and
the java umask method is used improperly.

Change-Id: I21aae48500df5e7081b63601123dd40070b4ff05
ibcore_io_Posix.cpp
77b2088858b199e60002bfb2acb7a883c6aba82a 01-Oct-2012 Brian Carlstrom <bdc@google.com> Merge "NativeCryptoTest#test_SSL_do_handshake_clientCertificateRequested_throws_after_renegotiate failure" into jb-mr1-dev
51de62cf77a070e2a45ae397c391832b9a781d91 30-Sep-2012 Brian Carlstrom <bdc@google.com> Fix flaky NativeCryptoTest.test_SSL_do_handshake_client_timeout

Fix similar issue in test_SSL_do_handshake_server_timeout

Bug: 6229479
Change-Id: If2cf7d7dfe468843285a531f4b8b42941996a3ed
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
db611c5813f623ee0403aedd156bb15780ed6e69 30-Sep-2012 Brian Carlstrom <bdc@google.com> NativeCryptoTest#test_SSL_do_handshake_clientCertificateRequested_throws_after_renegotiate failure

Bug: 6964910
Change-Id: I13bed4e5ed104241025fbb1d5e28427ec16d7a80
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
bc049016ee71735211cf0d3e4ac34a531e8fe5ba 29-Sep-2012 Elliott Hughes <enh@google.com> am 05d71b4b: am 1235166d: Merge "Rewrite NIO Pipe to use socketpair(2)."

* commit '05d71b4bb57bd741214b15ea838770adb5ff688b':
Rewrite NIO Pipe to use socketpair(2).
3218082325b6b8713a8ac15731482e3da86a7df9 29-Sep-2012 Elliott Hughes <enh@google.com> Rewrite NIO Pipe to use socketpair(2).

Our Pipe originally used socket(2) to create AF_INET/AF_INET6
sockets. This was clearly a bad idea.

I rewrote it to use socketpair(2) and AF_UNIX, but this was
before the big "expose POSIX" rewrite, so it required a bunch
of hacks in the native code, so I went with pipe(2) instead.

The trouble with pipe(2) is that we end up using FileChannel
to implement the Pipe.SinkChannel and Pipe.SourceChannel, but
the kernel won't wake a read(2) on a pipe if another thread
calls close(2) on it, so we started failing interrupt tests.

This (final?) rewrite is hopefully the best of all worlds:
we don't have any INTERNET permission needs, the code is as
simple as the pipe(2) code, and interruption works.

Bug: 7084342
Bug: 2735373
Bug: http://code.google.com/p/android/issues/detail?id=9431
Change-Id: If3f052c9d3f5aa1c099f5a069ace9a8d6ce3ca3a
ibcore_io_Posix.cpp
03c772cadc72ca8cbcde78b266a347dbc6e68ad4 24-Sep-2012 Elliott Hughes <enh@google.com> Fix umask.

(cherry-pick of acba45cc4b1f98f67fcdeda2f7c13ed57659b92a.)

Bug: 7094213
Change-Id: I0c5cbfbfcd937e2393b30f3f50edea40586278cb
ibcore_io_Posix.cpp
acba45cc4b1f98f67fcdeda2f7c13ed57659b92a 24-Sep-2012 Elliott Hughes <enh@google.com> Fix umask.

Bug: 7094213
Change-Id: I81979e6f050912cdc4cde8084765d09ec64c0689
ibcore_io_Posix.cpp
615225a35dbd838210270b282d1196deff643b51 22-Sep-2012 Brian Carlstrom <bdc@google.com> Add OpenSSLSocketImpl.setSoWriteTimeout to allow SO_SNDTIMEO to be specified

Bug: 6693087
Change-Id: Ie6903168ca0ada4516c55dfab5f7194baf965b4c
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
abfee56fa51ed8533a822b0e5c8ecae1333d9abe 21-Sep-2012 Elliott Hughes <enh@google.com> am 2682316c: am c87dc489: Merge "Add setsid."

* commit '2682316ccbfb1e154fd9d14d5813c805e78be885':
Add setsid.
6c9b5377550a9649ed1532d1fcdfeba116c74ead 21-Sep-2012 Elliott Hughes <enh@google.com> Add setsid.

See "Monkey not handling SIGHUP signal" (https://android-review.googlesource.com/43053).

Change-Id: Ib327702caefa8eb8d044723c270acfe4685c7551
ibcore_io_Posix.cpp
1c55af74baacee33ae662f65c07c1d9598a76524 18-Sep-2012 Kenny Root <kroot@google.com> am 0101812e: am e2f9b2c6: Merge "OsConstants: add O_NOFOLLOW"

* commit '0101812e9af94e69ac3aecbee949742796d00fd3':
OsConstants: add O_NOFOLLOW
dd538c3bbd85d14ccae83ab3b384b2ebcc4a4c13 18-Sep-2012 Kenny Root <kroot@google.com> OsConstants: add O_NOFOLLOW

Change-Id: I91619191d83ca8e0a13d30588f761e4defefc30d
ibcore_io_OsConstants.cpp
f0993272562ebc6e8d77024b985c45fae9f92ed4 12-Sep-2012 Brian Carlstrom <bdc@google.com> am a1359997: am 9f519e17: Merge "Add OpenSSLProvider support for Cipher.RSA/None/PKCS1Padding"

* commit 'a1359997a83e4d1aefdb7ae23f73b61420d37964':
Add OpenSSLProvider support for Cipher.RSA/None/PKCS1Padding
0a156e0126e8015f2791e9a7dd48bbdaeae0c335 12-Sep-2012 Brian Carlstrom <bdc@google.com> Add OpenSSLProvider support for Cipher.RSA/None/PKCS1Padding

Summary:
- Add OpenSSLProvider support for Cipher.RSA/None/PKCS1Padding
Added NativeCrypto.RSA_private_decrypt and NativeCrypto.RSA_public_encrypt
- Changed OpenSSLSignatureRawRSA to use new Cipher.RSA/None/PKCS1Padding
Removed now obsoleted NativeCrypto APIs for
RSA_padding_add_PKCS1_type_1 and RSA_padding_check_PKCS1_type_1
- added wrap/unwrap support OpenSSLCipherRSA
Needed for SSLEngine (and fallback SSLSocket implementation)
which are now picking up the new Cipher.RSA/None/PKCS1Padding
- expanded CipherTest to sanity test all algorithms and PKCS1 padding

Change-Id: I03566cc86ffce07d44d5e0094fa82c9c24587c26
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
0715b5fb5c9c06d7c8d4f2008b7b38a4b9e21bc3 10-Sep-2012 Elliott Hughes <enh@google.com> am f8cc0581: am c71eceac: Merge "Get expat header files from the approved location."

* commit 'f8cc0581010db8a31aff744fb1a86b1b9e2896dc':
Get expat header files from the approved location.
44d737281c6a6c9be6ea1eb58cf678f43643650a 09-Sep-2012 Elliott Hughes <enh@google.com> Get expat header files from the approved location.

Change-Id: Ie896d616b21ba2e1db33d39a721150e4e4d59d21
rg_apache_harmony_xml_ExpatParser.cpp
ub.mk
e25cfef797c4428bb7a3b9b64a5a09591ed1a55a 05-Sep-2012 Elliott Hughes <enh@google.com> am ab991b57: am 43211dce: Merge "Make FileDescriptor.sync() work on ttys"

* commit 'ab991b570d8cd3b1c36fe6dfc8af883eaad9a74f':
Make FileDescriptor.sync() work on ttys
c44b3f5d857d0d3f4d3668de905cdac5080ede3b 01-Sep-2012 Kenny Root <kroot@google.com> Better OpenSSL key comparison

Use native code to compare OpenSSL keys instead of converting them to
Java BigIntegers first.

Change-Id: If795c9c26e41174755cdab34ff70e01c7487c9bd
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
bb5816aa1626eb2f6263bd21479600b114c8a1bd 10-Jan-2012 Johan Redestig <johan.redestig@sonymobile.com> Make FileDescriptor.sync() work on ttys

fsync on Linux fails on tty file descriptors. This change
adds the capability to make sure all data was written to the
terminal device descriptor to java.io.FileDescriptor.sync()
implementation.

Also fixed the return value from Posix_isatty. isatty
returns 1 if an fd is a tty and 0 otherwise.

Change-Id: I6cc65db83f523b4c31b67b48d7534e18af0989e8
ibcore_io_Posix.cpp
c455ce42ebb3742c888fcd0fc7db94a6dfc36fe3 05-Sep-2012 Elliott Hughes <enh@google.com> am 2c417207: am f26e2ed8: Merge "Fix date parsing for RTL languages such as Arabic."

* commit '2c4172071923e0d6066a84874517d702c9d3d261':
Fix date parsing for RTL languages such as Arabic.
f26e2ed8981895aab395cf14ef25fb54a208614b 05-Sep-2012 Elliott Hughes <enh@google.com> Merge "Fix date parsing for RTL languages such as Arabic."
9596d75ebf937d47a2de195b09584e88c91eb6f6 30-Aug-2012 Elliott Hughes <enh@google.com> Fix date parsing for RTL languages such as Arabic.

(The cleanup of the native code is an irrelevant target of opportunity.)

Bug: http://code.google.com/p/android/issues/detail?id=36689
Change-Id: I6d9f0bbbd6e8f99421072102e0d785bc3429cc14
ibcore_icu_NativeDecimalFormat.cpp
69b153ae940a53e278e1f0d6a63d09fbfa32a484 04-Sep-2012 Brian Carlstrom <bdc@google.com> am 7488cc51: am bc87d13f: Merge "Fix NativeCrypto.d2i_SSL_SESSION to initialize SSL_SESSION\'s cipher field"

* commit '7488cc51a72272f6c4bb2ed40d34b98297f48c6f':
Fix NativeCrypto.d2i_SSL_SESSION to initialize SSL_SESSION's cipher field
bc87d13fbeec94738349841f0f3769241756d881 04-Sep-2012 Brian Carlstrom <bdc@google.com> Merge "Fix NativeCrypto.d2i_SSL_SESSION to initialize SSL_SESSION's cipher field"
8b43d6de8df989711dd0779d689e1a1c1f9df68e 31-Aug-2012 Brian Carlstrom <bdc@google.com> Fix NativeCrypto.d2i_SSL_SESSION to initialize SSL_SESSION's cipher field

Bug: 7091840
Change-Id: I9dee0e39bae6aba28c7ea768242e64c9443d9e49
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
528dfcb6715f99873f87d9145d07ea47bba7e8d9 31-Aug-2012 Kenny Root <kroot@google.com> am 065d4f55: am 3836bd5f: Merge "Clear errors after failed ENGINE_add"

* commit '065d4f5581b2faf340778fba1604614964320867':
Clear errors after failed ENGINE_add
3836bd5f9feb06c0d1049fa54f4ba568aafb7b43 31-Aug-2012 Kenny Root <kroot@google.com> Merge "Clear errors after failed ENGINE_add"
c590a497ee88ed1a0ee59f35619ae7804b1d3715 30-Aug-2012 Brian Carlstrom <bdc@google.com> am d027b65d: am 36bd86c1: Merge "Disable SSL compression"

* commit 'd027b65de7150569f4f65f8c90113eac850b52f0':
Disable SSL compression
7695a9b3261bfee3a810e0829bd8082fe1fcb6a4 30-Aug-2012 Brian Carlstrom <bdc@google.com> Disable SSL compression

Bug: 7079965

Change-Id: I8e060a827613e212bbcced66507fbf124bb04543
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
4cf204e549692f17e3974cef7c5854157df4ca3a 29-Aug-2012 Elliott Hughes <enh@google.com> am 3a50f0e9: am e2b3ac2c: Merge "Fix two unused variable warnings, and tidy up NET_FAILURE_RETRY."

* commit '3a50f0e9a8c5c3687abe47bf3e6a0cb532259a64':
Fix two unused variable warnings, and tidy up NET_FAILURE_RETRY.
1124a814d698ed6fd68ac501f5dddfa103d656fd 29-Aug-2012 Elliott Hughes <enh@google.com> Fix two unused variable warnings, and tidy up NET_FAILURE_RETRY.

Despite being the original author, every time I look at NET_FAILURE_RETRY
I think the uninitialized "int fd;" is a bug. So let's kill that. Potentially
we could offer even more complete exception detail messages now, but I've
left that as a possible TODO.

Change-Id: I3a175c659dd6bdeb111938e2547710bb4880cc02
ibcore_io_Posix.cpp
8751386c57d1d0d8d8f0db1660214925fb248a10 28-Aug-2012 Brian Carlstrom <bdc@google.com> am 768ddc93: am f323efde: Merge "Avoid variable-length non-POD element array"

* commit '768ddc938af06155fdc890e39a1cf1926a2f5c3a':
Avoid variable-length non-POD element array
f323efde04096c6f1c4fa482fc82fbdca99ab732 28-Aug-2012 Brian Carlstrom <bdc@google.com> Merge "Avoid variable-length non-POD element array"
882ff343913f54cd02478fed2e9c41dfccd78a45 11-Jun-2012 Edwin Vane <edwin.vane@intel.com> Avoid variable-length non-POD element array

Clang doesn't like variable-length arrays of non-POD types. Added new
X509Vector to hold the OpenSSL X509* references and preserve the RAII
style.

Change-Id: I85d61d6c26ff06fb7da8091376394b8438fb1fea
Reviewed-by: Kevin P Schoedel <kevin.p.schoedel@intel.com>
Author: Edwin Vane <edwin.vane@intel.com>
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
495da2cf7aab956f6e0a2beea9843d5d7a5ecf59 28-Aug-2012 Elliott Hughes <enh@google.com> am e3b35a67: am 1fc312d0: Merge "[MIPS] Fix implementation of optimised bswap_2x16"

* commit 'e3b35a670d6baa9f1e2fe80982800cee01c2734c':
[MIPS] Fix implementation of optimised bswap_2x16
7ba6c51277526eb66b328657abdaa85c05791826 24-Aug-2012 Chris Dearman <chris@mips.com> [MIPS] Fix implementation of optimised bswap_2x16

Change-Id: I21e8304e4568d120dfb746cab8dd7d8ab2d53f44
ibcore_io_Memory.cpp
4efbf2b6dfcbdacbc580ebbf35d39883bd7ec562 17-Aug-2012 Kenny Root <kroot@google.com> Clear errors after failed ENGINE_add

Change-Id: I2f9c39717db9419c7924031fc30b7cc069c19d2e
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
642b1841c441a0934def4ebbb6cb48d77178d671 16-Aug-2012 Elliott Hughes <enh@google.com> am fbcdc979: am 2b79aeb6: Merge "Add chown, fchmod, fchown, lchown, and umask."

* commit 'fbcdc979f257076a7ad2f90451af43fb68691f7e':
Add chown, fchmod, fchown, lchown, and umask.
44f7875f2985d7944c5afecc8394ad9f2219c806 16-Aug-2012 Elliott Hughes <enh@google.com> Add chown, fchmod, fchown, lchown, and umask.

Bug: 6141031
Bug: 3107501
Change-Id: I3f514f615b397f57340066f26d43320fb3c219fa
ibcore_io_Posix.cpp
0a2b7e2cb49df43822c613cd4a2da527951fa77f 16-Aug-2012 Kenny Root <kroot@google.com> am 4a4db1e2: am cdad5434: Merge "Call ENGINE_add to prevent ENGINEs from unloading"

* commit '4a4db1e290536e8155f8f8dcd273b647462842a5':
Call ENGINE_add to prevent ENGINEs from unloading
cdad5434dff71f87b4e85c6faf6e0c30a80672d7 16-Aug-2012 Kenny Root <kroot@google.com> Merge "Call ENGINE_add to prevent ENGINEs from unloading"
106a8928fb4249f2f3d4dba1dddbe73ca5cb3d61 16-Aug-2012 Kenny Root <kroot@google.com> Call ENGINE_add to prevent ENGINEs from unloading

The only user of the OpenSSLEngine interface is a dynamic engine (loaded
from eng_dyn.c), so it will unload the .so when references to it
decrease to zero.

Calling ENGINE_add will add the loaded engine to the list of loaded
engines. The next time ENGINE_by_id is called, it will just use the one
from the list instead of loading the .so again.

You can still control whether the engine is ref-counted or copied with
ENGINE_set_flags(ret, ENGINE_FLAGS_BY_ID_COPY) in the engine
initialization method.

Change-Id: Ic005e9ea22a3c6027e3a5aab2adf41fb7995c1f0
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
53ba318cfbee06bc9c9cee7c80b0e51050d81010 16-Aug-2012 Elliott Hughes <enh@google.com> am 4c7387bc: am 287d61b0: Merge "Remove an obsolete hack for ps and ps_AF."

* commit '4c7387bc388908c77d3720b4c86a0a92c2c8b47b':
Remove an obsolete hack for ps and ps_AF.
680b1e27caf10e3c41ec9f022054ab53d3a6bf7a 16-Aug-2012 Elliott Hughes <enh@google.com> Remove an obsolete hack for ps and ps_AF.

Made obsolete by external/icu4c change 6384944cabfb536f4ec5d584e26927405f150770.

Change-Id: Iefecb23ef87335e9f7f659f54dcdc3b36d5b4c62
ibcore_icu_ICU.cpp
1f1da73f69bb11631a984b9c0ac1e8574c3dd1a8 15-Aug-2012 Elliott Hughes <enh@google.com> am 21bb3a0e: am f5e25724: Merge "Revert "Revert "Add support for returning the CLDR "Yesterday", "Today", and "Tomorrow" strings."""

* commit '21bb3a0e1891afe49f68a929ad7e293f51b146bb':
Revert "Revert "Add support for returning the CLDR "Yesterday", "Today", and "Tomorrow" strings.""
c4e0797a4dd028d23e788da15c3055f83f6f37d5 15-Aug-2012 Elliott Hughes <enh@google.com> Revert "Revert "Add support for returning the CLDR "Yesterday", "Today", and "Tomorrow" strings.""

This reverts commit 73dc486a74a67ce375e3d90dcfaa6b5255b7c0da

I've added code to handle falling back to parent locales to find relative
day names.

Change-Id: Iec2eebb62c0cbb5f6ce625365de514d80ddc05f7
ibcore_icu_ICU.cpp
93984e77c0e86fd46fd543586b414b382e6e9e30 15-Aug-2012 Elliott Hughes <enh@google.com> am 4745f251: am cf7d9f30: Merge "Revert "Add support for returning the CLDR "Yesterday", "Today", and "Tomorrow" strings.""

* commit '4745f2518e8fe993ec9fd8aa4c37d09f4f94efa6':
Revert "Add support for returning the CLDR "Yesterday", "Today", and "Tomorrow" strings."
73dc486a74a67ce375e3d90dcfaa6b5255b7c0da 15-Aug-2012 Elliott Hughes <enh@google.com> Revert "Add support for returning the CLDR "Yesterday", "Today", and "Tomorrow" strings."

This reverts commit 774294d74fe02e2b5040fcc2feb9f9d0913a4c77

This patch didn't work for locales that didn't explicitly specify values (and relied on fallback), and caused hard failures in those cases.

Change-Id: I7e3a45cc4d39317c8e523c2ee951c49e0aa8e811
ibcore_icu_ICU.cpp
38b5c6b314b811a5e7e2b1f8924cc66da73b8e9f 15-Aug-2012 Elliott Hughes <enh@google.com> am 132d978e: am 49578873: Merge "Add support for returning the CLDR "Yesterday", "Today", and "Tomorrow" strings."

* commit '132d978eda3e7e0017a208aa7b329e0f78454ffa':
Add support for returning the CLDR "Yesterday", "Today", and "Tomorrow" strings.
774294d74fe02e2b5040fcc2feb9f9d0913a4c77 15-Aug-2012 Elliott Hughes <enh@google.com> Add support for returning the CLDR "Yesterday", "Today", and "Tomorrow" strings.

This will let us remove a little more of the duplicate (and unmaintained)
CLDR data from frameworks/base.

Change-Id: Idbdb755e8469bb46e7597775ed2139c47de24b39
ibcore_icu_ICU.cpp
694677f69b14ed61ca62473a04d52ac1659b8dd2 08-Aug-2012 Kenny Root <kroot@google.com> Exit early from client_cert_cb when appropriate

Under error conditions, return -1 from client_cert_cb to cause the SSL
connection to exit early. If there is a pending Java exception that needs
to percolate up to the JVM, this should be brought up as soon as
possible.

(cherry-picked from 914e7c1a4c7fd45d7398f43cf28e5689d1422936)

Change-Id: Ie7b7865a8025e90b54ee16525e5856a6ca598d6d
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
ba24b28aeea21c94208ffdb3f1df1b733c99b6ca 08-Aug-2012 Kenny Root <kroot@google.com> Merge "Exit early from client_cert_cb when appropriate" into jb-mr1-dev
914e7c1a4c7fd45d7398f43cf28e5689d1422936 08-Aug-2012 Kenny Root <kroot@google.com> Exit early from client_cert_cb when appropriate

Under error conditions, return -1 from client_cert_cb to cause the SSL
connection to exit early. If there is a pending Java exception that needs
to percolate up to the JVM, this should be brought up as soon as
possible.

Change-Id: Ifb3f908b027f80507ba549757f0cd6e1891d8bdd
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
1b6a07f5dce7d2d2c9ebafd2eec5dd2ce1634213 06-Aug-2012 Elliott Hughes <enh@google.com> am a10a95ad: am 678205c9: Merge "Offer "J" in addition to "January" and "Jan"."

* commit 'a10a95ad7988eb4b9778e7ad5bcdc5f0eb964489':
Offer "J" in addition to "January" and "Jan".
ad66a888b2e48b1a185de1b3c73fd01383a1fd04 06-Aug-2012 Elliott Hughes <enh@google.com> Offer "J" in addition to "January" and "Jan".

The frameworks/base XML had out-of-date copies of this CLDR data, which
isn't accessible via SimpleDateFormat. Offer the strings direct from icu4c
so we can use them in frameworks/base.

Change-Id: If97dac05bcbb36542b209b19ae590e8b30aedb7b
ibcore_icu_ICU.cpp
7c10bc697cfee271a4cc9561c86be388a85edcd5 03-Aug-2012 Brian Carlstrom <bdc@google.com> Merge "Add raw RSA signature support"
7501e29e0182accf28cc317870a3bbe1e25f4bfa 31-Jul-2012 Kenny Root <kroot@google.com> Add raw RSA signature support

With the new Keystore changes, this is the only way you can get raw RSA
signatures which a lot of native code expects to be able to do.

(cherry-picked from c531f5f402b4cedcc35a0b7f0b540dc84c545106)

Bug: 6787078
Change-Id: I1c5ddd5287be1ab71347eedc864a41c24e156cb4
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
c531f5f402b4cedcc35a0b7f0b540dc84c545106 31-Jul-2012 Kenny Root <kroot@google.com> Add raw RSA signature support

With the new Keystore changes, this is the only way you can get raw RSA
signatures which a lot of native code expects to be able to do.

Bug: 6787078
Change-Id: I1c5ddd5287be1ab71347eedc864a41c24e156cb4
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
a40fcc07b281313cb0ad125d8a1a2d6adec8e867 19-Jul-2012 Narayan Kamath <narayan@google.com> Add NPN related logging to native crypto

Also fixes a compilation error when logging macros
are expanded.

(cherry-picked from 8a545afcbad15fdd805b9b7790d3d1aa6323fd9e)

Change-Id: I1e422917cdb6fec56398344ee096eb50ab519668
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
46aabcb28b0e3b807f6db8c33173962d6f2cb71f 12-Jun-2012 Kenny Root <kroot@google.com> Add OpenSSL provider for SHA1PRNG

(cherry-pick of 4718b07e482ccb083ce3dfff228d0615b96a8dd2 and 84fb77d814b0ad04d70addb04847797925acf805.)

Change-Id: Ib45c646a8596bf5ea0629408d6057d3828a1ac94
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
9634b569a92841f32268907c88c408f22cb00486 18-May-2012 Elliott Hughes <enh@google.com> Stop using -fvisibility=hidden.

It breaks backtraces, and backtraces are useful. (The debugger uses
the ELF debug info, so it doesn't care, but backtracing just uses the
symbols.)

(cherry-pick of da2fb9754a9ccfa954c1b554982f06e7cf7d680a.)

Bug: 6447213
Change-Id: I957df0e935b61bcf5fefc0e506ecdaa862bc7d07
ibcore_io_Posix.cpp
ibcore_net_RawSocket.cpp
1328e0fe754aeda3b1896a0ef1f02291aad1be1a 01-Aug-2012 Brian Carlstrom <bdc@google.com> am 989bedd4: am 1f9fe21b: Increment OpenSSLKey EVP_PKEY reference when it is selected for use with SSL_use_PrivateKey

* commit '989bedd47eaa82007d6b702936efe75c7ecefc52':
Increment OpenSSLKey EVP_PKEY reference when it is selected for use with SSL_use_PrivateKey
989bedd47eaa82007d6b702936efe75c7ecefc52 01-Aug-2012 Brian Carlstrom <bdc@google.com> am 1f9fe21b: Increment OpenSSLKey EVP_PKEY reference when it is selected for use with SSL_use_PrivateKey

* commit '1f9fe21b93f1d1ee44a325629a05ee4f476e5f6a':
Increment OpenSSLKey EVP_PKEY reference when it is selected for use with SSL_use_PrivateKey
f4439e56aa3c88da66d2c6c969f9cb6b73cfa0ec 01-Aug-2012 Brian Carlstrom <bdc@google.com> Increment OpenSSLKey EVP_PKEY reference when it is selected for use with SSL_use_PrivateKey

Bug: 6866852
Bug: http://code.google.com/p/android/issues/detail?id=35326

(cherry-picked from 1f9fe21b93f1d1ee44a325629a05ee4f476e5f6a)

Change-Id: I4e995de38414a7841bca0e0bba7d15b01c3bffd9
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
1f9fe21b93f1d1ee44a325629a05ee4f476e5f6a 01-Aug-2012 Brian Carlstrom <bdc@google.com> Increment OpenSSLKey EVP_PKEY reference when it is selected for use with SSL_use_PrivateKey

Bug: 6866852
Bug: http://code.google.com/p/android/issues/detail?id=35326

Change-Id: If14b9866dc15fe284130393534ae3ed66977d72f
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
bf37bc94d9c56dc47b0b42dc657aad1331d0ec92 24-Jul-2012 Brian Carlstrom <bdc@google.com> am 165b9dc5: am fe1daea1: Merge "Fix OpenSSLSocketImpl.close race"

* commit '165b9dc50bc50f69eef05395edb6e70cdaa85225':
Fix OpenSSLSocketImpl.close race
f35af87005578cd704a4912c381e731b64dfa560 24-Jul-2012 Elliott Hughes <enh@google.com> am 65c7df1b: am d44e8b8b: Merge "Clean up ICU error reporting."

* commit '65c7df1be540e232ebf3038664bc1587331adb72':
Clean up ICU error reporting.
fe1daea160b11cbb422e64ad7fc34a7caea32ab5 24-Jul-2012 Brian Carlstrom <bdc@google.com> Merge "Fix OpenSSLSocketImpl.close race"
df9f5967a3b8dc2f61183d155791393b67980511 24-Jul-2012 Brian Carlstrom <bdc@google.com> Fix OpenSSLSocketImpl.close race

Move the NativeCrypto.SSL_interrupt call within the close
synchronization. Otherwise there can be problems if
NativeCrypto_SSL_interrupt tries to use the SSL* and another thread
has called NativeCrypto_SSL_free.

Bug: 6707288
Change-Id: Id8b0311b10124f2a08f8e0f24595a6ee46805c33
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
5ec69b20ab9b3e2dcbe225d548168b09afbbbac2 24-Jul-2012 Elliott Hughes <enh@google.com> Clean up ICU error reporting.

Throw all ICU exceptions from the native side, and include the name of the
function that failed.

Bug: 5037042
Change-Id: I49b5493a7e7365226d612479294b5b8f47ec4e8c
niException.cpp
niException.h
ava_text_Bidi.cpp
ava_util_regex_Matcher.cpp
ibcore_icu_ICU.cpp
ibcore_icu_NativeBreakIterator.cpp
ibcore_icu_NativeCollation.cpp
ibcore_icu_NativeConverter.cpp
ibcore_icu_NativeDecimalFormat.cpp
ibcore_icu_NativeNormalizer.cpp
ibcore_icu_NativePluralRules.cpp
ibcore_icu_TimeZones.cpp
8a545afcbad15fdd805b9b7790d3d1aa6323fd9e 19-Jul-2012 Narayan Kamath <narayan@google.com> Add NPN related logging to native crypto

Also fixes a compilation error when logging macros
are expanded.

Change-Id: I1e422917cdb6fec56398344ee096eb50ab519668
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
4718b07e482ccb083ce3dfff228d0615b96a8dd2 12-Jun-2012 Kenny Root <kroot@google.com> Add OpenSSL provider for SHA1PRNG

Change-Id: I45a3c1c0089aa439629e4645f15b16bd35aa6f55
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
da2fb9754a9ccfa954c1b554982f06e7cf7d680a 18-May-2012 Elliott Hughes <enh@google.com> Stop using -fvisibility=hidden.

It breaks backtraces, and backtraces are useful. (The debugger uses
the ELF debug info, so it doesn't care, but backtracing just uses the
symbols.)

Bug: 6447213
Change-Id: I2893191d7cec57a04bf7b3f4eea54e699df10507
ibcore_io_Posix.cpp
ibcore_net_RawSocket.cpp
d8a1521a6188e1c0b942d85578d03cc5c48cbd21 16-May-2012 Jesse Wilson <jessewilson@google.com> am b4265071: am dea827db: Merge "Only use SSL CUTTHROUGH (False Start) if the server supports NPN." into jb-dev

* commit 'b4265071320d3202147e47fdb99e8995ef072e94':
Only use SSL CUTTHROUGH (False Start) if the server supports NPN.
b4265071320d3202147e47fdb99e8995ef072e94 16-May-2012 Jesse Wilson <jessewilson@google.com> am dea827db: Merge "Only use SSL CUTTHROUGH (False Start) if the server supports NPN." into jb-dev

* commit 'dea827db3bfa399cdb539e9bba228ba0eeda25c5':
Only use SSL CUTTHROUGH (False Start) if the server supports NPN.
679ac55c3c037887edfc6ce6f42a23cd7c11cd12 12-May-2012 Jesse Wilson <jessewilson@google.com> Only use SSL CUTTHROUGH (False Start) if the server supports NPN.

We enable cutthrough on the client if the server supports NPN.
We never enable cutthrough on the server because most relevant
protocols (ie. HTTP) are client-speaks-first and those don't
benefit from cutthrough on the server.

I verified this by enabling NPN on both client and server and
checking that the client's Application Data was sent before the
server's Change Cipher Spec. To increase the likelihood of this
otherwise racy situation I put the server in SSL debug mode
after it receiving next_protos_advertised_callback. OpenSSL's
debug mode adds a 1-second sleep before each read and write.

Bug: http://b/6331035

Change-Id: I879b5fb26dc237392a36fe0585c8a6519c0e5220
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
17e2f4bad4068a1a6c7fbe338fa1fa1b6131bb9e 12-May-2012 Elliott Hughes <enh@google.com> Explain a #include of private zlib API.

Change-Id: Ifa6130bdbd91c02eb663cbad25db344eab873943
ip.h
f7fd48891a4d3c9a5a7a0715983eec364b936c1a 05-May-2012 Elliott Hughes <enh@google.com> am 7cd6760f: Make libjavacore independent of libnativehelper for the PDK.

* commit '7cd6760f7045d771faae8080a8c6150bf678f679':
Make libjavacore independent of libnativehelper for the PDK.
7cd6760f7045d771faae8080a8c6150bf678f679 04-May-2012 Elliott Hughes <enh@google.com> Make libjavacore independent of libnativehelper for the PDK.

Bug: 6369821
Change-Id: Ie038571a5dac1f301c0c3c6fb84df432e67b62c0
egister.cpp
ava_io_Console.cpp
ava_io_File.cpp
ava_io_ObjectStreamClass.cpp
ava_lang_Character.cpp
ava_lang_Math.cpp
ava_lang_ProcessManager.cpp
ava_lang_RealToString.cpp
ava_lang_StrictMath.cpp
ava_lang_StringToReal.cpp
ava_lang_System.cpp
ava_math_NativeBN.cpp
ava_nio_ByteOrder.cpp
ava_nio_charset_Charsets.cpp
ava_text_Bidi.cpp
ava_util_regex_Matcher.cpp
ava_util_regex_Pattern.cpp
ava_util_zip_Adler32.cpp
ava_util_zip_CRC32.cpp
ava_util_zip_Deflater.cpp
ava_util_zip_Inflater.cpp
ibcore_icu_ICU.cpp
ibcore_icu_NativeBreakIterator.cpp
ibcore_icu_NativeCollation.cpp
ibcore_icu_NativeConverter.cpp
ibcore_icu_NativeDecimalFormat.cpp
ibcore_icu_NativeIDN.cpp
ibcore_icu_NativeNormalizer.cpp
ibcore_icu_NativePluralRules.cpp
ibcore_icu_TimeZones.cpp
ibcore_io_AsynchronousCloseMonitor.cpp
ibcore_io_Memory.cpp
ibcore_io_OsConstants.cpp
ibcore_io_Posix.cpp
ibcore_net_RawSocket.cpp
rg_apache_harmony_xml_ExpatParser.cpp
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
ub.mk
a8e6286be3c650f0078e560ab6f2dd169550902c 03-May-2012 Elliott Hughes <enh@google.com> am 47d9600b: am 31e127f9: Merge "[MIPS] Add MIPS Architecture support"

* commit '47d9600b5c908b171811ca2893cdef3261589def':
[MIPS] Add MIPS Architecture support
b7e0772d25499ddf5435e53a90cf1a6d753786d7 02-May-2012 Chris Dearman <chris@mips.com> [MIPS] Add MIPS Architecture support

Change-Id: Idce58bad54a3f25dbe984c580cb6a48cc906ba76
Signed-off-by: Chris Dearman <chris@mips.com>
ibcore_io_Memory.cpp
ibcore_io_OsConstants.cpp
88f3ec9ebfd60998eb321f8c182009dace9bf983 01-May-2012 Brian Carlstrom <bdc@google.com> NativeCrypto should honor timeout less than one second

Bug: http://code.google.com/p/android/issues/detail?id=29680
Change-Id: I4507a1e9fe37b1c095f7bb4d3e3a55d6d738f7ad
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
d3990f07b1523c74d201d5971c7c2451fbe92a33 18-Apr-2012 Elliott Hughes <enh@google.com> Fix a buffer overrun found by CTS (and pinpointed by valgrind).

CTS crashed because a sockaddr_in6 (28 bytes) had been allocated at the end of
page, and the next page wasn't mapped. sockaddr_storage is 128 bytes (because
it isn't just big enough for sockaddr_in and sockaddr_in6, it's big enough for
any kind of socket).

Bug: 6293344
Change-Id: I9bec5d4ddbb89969337d6978c8a45323a792a005
etworkUtilities.cpp
ebe87d125b8cc83238914f84f5f7aa799c0d83bd 15-Apr-2012 Brian Carlstrom <bdc@google.com> Use SSL_CTX_set_session_id_context in ServerSessionContext

Without this, OpenSSL with fail when SSLSessions are reused on an
SSLServerSocket when client certificates are requested.

Bug: 6329719
Change-Id: I9b14b32cccee1e5aba1215cebf81eb05a788d63b
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
e94066148d64ede858a8c003bdbe4310795c2d2e 17-Apr-2012 Elliott Hughes <enh@google.com> Fix File.listImpl's error checking.

We were only checking the opendir(3), not each readdir(3).

Bug: 6345713
Change-Id: I33be8dfcbc067a657154a7d2ecbdff6e6e2fba8c
ava_io_File.cpp
087043baca7e2de81bd10c7955f73f8597d7bb83 26-Mar-2012 Kenny Root <kroot@google.com> Merge "More support for ENGINE-based keys"
beac31ef5949d994a7096f20f12fcf929b06884d 26-Mar-2012 Kenny Root <kroot@google.com> More support for ENGINE-based keys

Tweak some of the parameters for RSA and DSA keys to allow ENGINE-based
keys to exist without needing to define private key material.

Change-Id: Ide2884d6d97636ae2178f8e789eaeec1babd9650
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
600dc4949de6bf5608e5f5a5214cde59299b683a 26-Mar-2012 Jesse Wilson <jessewilson@google.com> Don't use the SSL_CTX prefix for a method that takes an SSL.

The implementation is asymmetric: enabling NPN is per-context, but
actually looking up the negotiated protocol is per-SSL. This caused
me to screw up in following the SSL_CTX naming scheme; I applied it
in too many places.

Change-Id: I5bd1be334d513f220086c901527d0b8416f2ba3f
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
0348f58cf3bd2c3cbac65f785df1197fc626f6fa 26-Mar-2012 Brian Carlstrom <bdc@google.com> Fix phone boot

(cherry picked from commit a8ef467e8e6be1681d63fe692ecce3b301801faa)

Change-Id: I650d1fc98277b64f127204cae408acb69db354e9
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
25977e422febea04dac9fb9c35d7271d55d3b6b8 23-Mar-2012 Jesse Wilson <jessewilson@google.com> Expose NPN in OpenSSL.

This is derived from costin's change Ib18da136cb628515d6909c438cd0809452d7058a.
It moves the protocols data to the AppData's callbacks so the memory can be
released when the handshake completes.

Change-Id: Id61feaa6f28250e393f5c8093688b099e92dce9c
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
3e6dd45baa0d7f9b4fa06f4ade76e088b59cc7bf 16-Mar-2012 Brian Carlstrom <bdc@google.com> Tracking openssl-1.0.1

Bug: 6168278

Change-Id: I240d2cbc91f616fd486efc5203e2221c9896d90f
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
41e34229c07e8d05090560ff80558fa222623769 09-Mar-2012 Kenny Root <kroot@google.com> Add support for OpenSSL engines

This allows OpenSSL ENGINE to be used for RSA and DSA private key
operations.

Also add in support for directly passing an OpenSSLKey to the
OpenSSLSocketImpl in case we are using ENGINEs.

Change-Id: Ia31735109052a13e421900b69ba5de13bbce0f6f
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
796f0d5a4e7b83c3efc5e587b6766977dc20b0c3 16-Feb-2012 Elliott Hughes <enh@google.com> Fix asynchronous interruption of Socket.connect with a timeout.

Turns out there was one connect variant I hadn't properly addressed.

Bug: http://code.google.com/p/android/issues/detail?id=24318
Change-Id: I7af697bdf6ea17ad1f8ea904d7d8a051ffb970d2
ibcore_io_Posix.cpp
5313aaf64335ca4e9768c66de697f0ce8f7e2227 16-Feb-2012 Kenny Root <kroot@google.com> Fix JNI yet again to have same return types

Newer compiler complains on return type mismatch. Change the error
return from NULL -> 0 to please the compiler.

Change-Id: Ib3e5f4a0e3e2507009cb309bb7965efbb968b7cb
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
b0b6096fa27cb303db1ee9452ef102608c7d813d 16-Feb-2012 Kenny Root <kroot@google.com> Merge "OpenSSL block ciphers, part 1"
68dc9c0f9ea2913a627aa3df81f4956efa48a980 06-Feb-2012 Kenny Root <kroot@google.com> OpenSSL block ciphers, part 1

This implements the NativeCrypto piece necessary to do basic block
cipher operations. More work will need to be done to enable useful
modes.

This gives us the ability to replace BouncyCastle's ECB mode that it
bases the higher level CBC, CTR, etc modes on. However, calling through
JNI to OpenSSL for 16-byte blocks for AES ends up being the same speed
as the Java implementation.

Further enhancements to use large blocks during the JNI call should show
marked improvements in speed.

Change-Id: I594a6d13ce5101a1ef2877b84edaa5e5b65e1e71
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
75cf14944d476670f6f915e5efd849e238a16250 16-Feb-2012 Elliott Hughes <enh@google.com> Throw SecurityException for DNS without INTERNET permission.

When GoogleTV had to work around this for glibc, I realized that maybe I was
the problem, not the C library...

Bug: http://code.google.com/p/android/issues/detail?id=15722
Change-Id: Ia3fbf2f4578ad60d84e538819660c181248f1e1c
ibcore_io_Posix.cpp
82ad6d54c7c1ccc03aed976cbf3ad19fa208564f 04-Feb-2012 Kenny Root <kroot@google.com> Change return type to match function

Change-Id: Ie4edc0ecc45cef924743e6c1b2f66832a2cf71c7
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
e50519aa549f6032b61e7d5b03f26510b10a8350 03-Feb-2012 Kenny Root <kroot@google.com> Fix up some JNI nits

Some of the existing JNI functions were implicitly casting jint to
pointers. Explicitly do this.

Also make sure we're checking for errors when we should.

Unique_... classes don't throw a NPE, so we have to throw exceptions
when they end up being NULL when we don't expect them to.

Change-Id: I12044446777eb02e407a03b0f0ecad5189c17602
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
0e1edea41b8747edd1a3e3237e82d1e48c31ae58 03-Feb-2012 Kenny Root <kroot@google.com> Fix return types so the compiler is happy

The newer compiler is throwing errors of the type:
error: converting to non-pointer type 'int' from NULL [-Werror=conversion-null]

Change-Id: I5bea50f760a1a9d747b39f9459dab2fbe7fdf7a7
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
746a236e2be5dee62c482e27f4c682496d071d8b 01-Feb-2012 Kenny Root <kroot@google.com> Add OpenSSL KeyPairGenerator and KeyFactory

Refactor the way OpenSSL keys are handled so we can generate OpenSSL
keys with the KeyPairGenerator and KeyFactory and pass them around
without keeping the context in the OpenSSLSignature where it originated.

Change-Id: Ib66bd1914e241a240cd97b1ea37e8526998107d9
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
1dfb8aa653d52268087f450e9b5a865e08b56d98 31-Jan-2012 Kenny Root <kroot@google.com> Add signature generation to OpenSSLSignature

Change-Id: I1203516d95a937edb48959146bbec64b338e4f1e
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
5f0ed6ed5798a3e6ad642bcd5382b864796cdcb8 25-Jan-2012 Irfan Sheriff <isheriff@google.com> Add support for ARP on RawSocket

Merged from the changes contributed from googletv folks

Change-Id: Ie4c40c96950becbed28fd68cb482d8b3dbebc001
ibcore_net_RawSocket.cpp
5b7b7fe6a817fdf058eefd9a716cc58a3283eb05 12-Jan-2012 claireho <chinglanho@gmail.com> Libcore changes for ICU4.8.1.1 upgrade.

This CL includes:
1. Change libcore_icu_ICU.cpp and LocaleData.java to support locale data structures in ICU4.8.1.1.
The new libcore_icu_ICU instantiates ICU objects instead of reading the ICU resource files
directly. This could avoid the code change for future ICU upgrade.
2. Change the libcore tests data caused the test failures from ICU locale data change.

Change-Id: Ia3dfb0a8e5c4ccc2ad110a1ff4211ff97fe5b2ad
ibcore_icu_ICU.cpp
679cf68b607e9b4a3beb8bcdee06868ae583386f 08-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/#/c/157220

Bug: 5449033
Change-Id: I3deb0b1b71cf4ec6d82921a2e0015c3a7b397cbf
synchronousSocketCloseMonitor.cpp
niConstants.cpp
egister.cpp
ava_lang_ProcessManager.cpp
ava_lang_System.cpp
ibcore_icu_ICU.cpp
ibcore_io_Posix.cpp
ibcore_net_RawSocket.cpp
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
06f039b4c39bee1b0618f40d4d4af0d0f2bef2fa 06-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGW(_IF) to (IF_)ALOGW(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/157065

Bug: 5449033
Change-Id: Ia340ff04d8e9c6344df07a9f921147d06f367bfe
ibcore_icu_ICU.cpp
ce1396eb6e63e3dd785f5052dd77aab1a2d4af7c 20-Dec-2011 Steve Block <steveblock@google.com> Rename (IF_)LOGD(_IF) to (IF_)ALOGD(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/156016

Bug: 5449033
Change-Id: If68c0a933417163908aa05cebffd2863b581d7c8
ava_math_NativeBN.cpp
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
f3c9acbc3ebd72090221f1781f7f48c0390c1c44 20-Oct-2011 Steve Block <steveblock@google.com> Rename LOGV(_IF) to ALOGV(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/#/c/143865

Bug: 5449033
Change-Id: Ifc8ada20e2b316bb24aa4ba3483e2fcbb9439669
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
39fd5e164f93ab821841aa4d1fac09055c102b8b 14-Aug-2011 Elliott Hughes <enh@google.com> Don't try to access a long field as an int field.

I've raised a bug to enhance CheckJNI. For now, this was caught by a
setSoTimeout test.

Bug: 5159133
Change-Id: If28e81b97c2fdd870ebbcd36d9d0bc01be9d8cf1
ibcore_io_Posix.cpp
487c58a9ff0cb4c6e074b2f5d99a0c3efa54fa37 16-Jul-2011 Brian Carlstrom <bdc@google.com> Replace NativeCrypto.verifySignature with OpenSSLSignature

Bug: http://code.google.com/p/android/issues/detail?id=18458
Bug: 5037994
Change-Id: Ie9521df80b3b50e69b5cf9e6f8eb861845b4d30e
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
f69534383cbc13946e7b8260693683c395237dfa 07-Jul-2011 Elliott Hughes <enh@google.com> Fix DecimalFormat's use of DecimalFormatSymbols' zero digit.

Bug: 4984181
Change-Id: Id6775bbad03e114c337400c2f6424256e20af9c0
ibcore_icu_NativeDecimalFormat.cpp
638000042da777f6d628d88dadde957c52597710 29-Jun-2011 Brian Carlstrom <bdc@google.com> Add ExceptionCheck after all places we setCallbackState

Also remove byte versions of SSL_read and SSL_write matching rest of
libcore to avoid making the change in even more places.

Note that testing this change required improving SSL_renegotiate which
is only used for testing.

Change-Id: If425764da3a36508a6c65d90eb3d36c5a018fd18
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
f08498e4998c3b7197cb31a9fc44910bfd4eeecc 25-Jun-2011 Doug Kwan <dougkwan@google.com> Fix gcc-4.6 compiler warnings about conversion between pointer and integer.

Change-Id: I2b8827d5110144a972eb9f3bf1e1f4621afef683
ibcore_icu_NativeBreakIterator.cpp
ibcore_icu_NativeCollation.cpp
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
d8cec780b3b5177b5c1e500ea606f731a67fb53c 21-Jun-2011 Elliott Hughes <enh@google.com> Add a couple more missing calls to DeleteLocalRef.

Change-Id: I84176e57d775cf5e433078b726be9cda3c6d4934
etworkUtilities.cpp
ava_nio_charset_Charsets.cpp
d2dd676be7b9fc0ac49c90a9d0acc437d0010a6e 16-Jun-2011 Fabrice Di Meglio <fdimeglio@google.com> am 4c94a612: Add ICU.getScript()

* commit '4c94a6128d1fcfaa75539b36c9f50d0c75df6144':
Add ICU.getScript()
4c94a6128d1fcfaa75539b36c9f50d0c75df6144 16-Jun-2011 Fabrice Di Meglio <fdimeglio@google.com> Add ICU.getScript()

- needed for RTL support

Change-Id: I03796c25b965403432b79f21ef8ce2f3a4f5566a
ibcore_icu_ICU.cpp
b58926d92208c77554935e6eb3ac11cf2498f909 15-Jun-2011 Elliott Hughes <enh@google.com> Don't leak a JNI local reference every time findClass is called.

Change-Id: I6ad975cfa861f0f71d949bd2676bb92842743e95
niConstants.cpp
9a6483c7b662de1e02b0788214c13f87fc86a2ea 15-Jun-2011 Fabrice Di Meglio <fdimeglio@google.com> am 0452e9ad: Add addLikelySubtags() to ICU

* commit '0452e9adf6fb133b6d3e59ebae2135aa90ad0d5e':
Add addLikelySubtags() to ICU
e2377cdd707b830d07a5708216834f7ac76ee3e1 15-Jun-2011 Elliott Hughes <enh@google.com> Remove the LocaleData.digit field.

ICU 4.6 no longer supports this, which always had the constant value '#'.

Also ensure that we cache all the locale data (not just the zone strings)
for the root locale, en_US, and the user's locale when the Zygote starts
up.

Also improve the ICU JNI code's local reference usage somewhat.

Change-Id: I28692d9484aecc29820c201b08b8bedd3f26df83
ibcore_icu_ICU.cpp
0452e9adf6fb133b6d3e59ebae2135aa90ad0d5e 08-Jun-2011 Fabrice Di Meglio <fdimeglio@google.com> Add addLikelySubtags() to ICU

Change-Id: Ied6149b68452db879c902b544b5b69802e35ff8e
ibcore_icu_ICU.cpp
adac9168696a95f8ab13e333f85621833a54f034 14-Jun-2011 Elliott Hughes <enh@google.com> Annotate those methods that don't need a JNIEnv*.

(This is just the methods that inherently don't need one; I haven't
included methods whose current implementation just happens not to
need one.)

Bug: 3069458
Change-Id: I517b8d89e1989e0b232e065fda977d9f335c06d5
ava_lang_Character.cpp
ava_lang_Math.cpp
ava_lang_StrictMath.cpp
ava_nio_ByteOrder.cpp
ibcore_io_Memory.cpp
fb2316ae2477e30908bd4b68f48ad576778af186 13-Jun-2011 claireho <chinglanho@gmail.com> am eda291fb: Merge "Libcore changes corresponding to ICU4.6 upgrade."

* commit 'eda291fb13114022525fb7687eb6b33206c02f5f':
Libcore changes corresponding to ICU4.6 upgrade.
eda291fb13114022525fb7687eb6b33206c02f5f 13-Jun-2011 claireho <chinglanho@gmail.com> Merge "Libcore changes corresponding to ICU4.6 upgrade."
e3b6fa2bf357f2712ab2ee9e8487f157595ea0c7 10-Jun-2011 Elliott Hughes <enh@google.com> Expose pread and pwrite.

And fix FileChannel to use them.

Bug: 4183719
Bug: 3107501
Change-Id: I51114a16522b93bf959b5953bec658e6889054c6
ibcore_io_Posix.cpp
3be1277a4644a149c158f99febbab890fc7b708f 09-Jun-2011 claireho <chinglanho@gmail.com> Libcore changes corresponding to ICU4.6 upgrade.

1. libcore_icu_ICU.cpp: ICU resource files format change.
2. OldCharset_SingleByte_ISO_8859_11.java : charset alias name change.
3. CollatorTest.java : Collation key value change.
4. Pattern2Test.java : character property change - pick another char with Me property.

Change-Id: Iff80c6098f5fd7c82b07e41b4532548d98448ad7
ibcore_icu_ICU.cpp
2b5dbde360bc285e16d2e63a9b02ac776699d71e 09-Jun-2011 Elliott Hughes <enh@google.com> am 90dd65c0: am bbd3aa01: am bad60996: Merge "correct erroneous double free"

* commit '90dd65c086d26cc8f11a8e3d2d2ad27fe0a29374':
correct erroneous double free
90dd65c086d26cc8f11a8e3d2d2ad27fe0a29374 09-Jun-2011 Elliott Hughes <enh@google.com> am bbd3aa01: am bad60996: Merge "correct erroneous double free"

* commit 'bbd3aa01292e8fad8ad3e1a3f026a56061411618':
correct erroneous double free
8545b837c61c3eaea2b8433b6791aa401f37e5f7 09-Jun-2011 Elliott Hughes <enh@google.com> Tidy a few includes.

Change-Id: I8a46fcea81b9bd354fa1cd5c3dd49b5b29015739
ava_lang_ProcessManager.cpp
ava_lang_System.cpp
ibcore_net_RawSocket.cpp
rg_apache_harmony_xml_ExpatParser.cpp
bbd3aa01292e8fad8ad3e1a3f026a56061411618 07-Jun-2011 Elliott Hughes <enh@google.com> am bad60996: Merge "correct erroneous double free"

* commit 'bad609967800da161417f9767fc0d1814a2d0259':
correct erroneous double free
1a577c958a277329ab2eeb23903d9f8b08e1d35e 07-Jun-2011 Elliott Hughes <enh@google.com> Check that the result of UniquePtr::release is always used.

(And silence the warnings in those cases where it isn't because we're working
around OpenSSL API lossage.)

Change-Id: Ibc7958373e7a899a6cd03a0177f97bf3a73c0e15
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
fc041ff241f9a7556e72236f130de0215ecd17db 03-Jun-2011 Elliott Hughes <enh@google.com> Remove support for deprecated IPv4 address formats.

Bug: 4539262
Change-Id: Ic42173b7b06e8536e8c4331087720d7df1e1681a
ibcore_io_Posix.cpp
4fcee338f8d6e302219ca775e63327ffe61c3446 02-Jun-2011 Robert CH Chou <Robert_CH_Chou@acer.com.tw> correct erroneous double free

Change-Id: I5906579118f1b23cb2090788bb5ca0c909d86a5a
rg_apache_harmony_luni_util_FloatingPointParser.cpp
9b510df35b57946d843ffc34cf23fdcfc84c5220 28-May-2011 Elliott Hughes <enh@google.com> Make ErrnoException a checked exception.

Bug: 4486011
Change-Id: I1877ce593d441653f75ab14884aa2d85f52652ad
ibcore_io_Posix.cpp
8ecbb3f6a89983adb1a085469befc70488f4f04f 27-May-2011 Elliott Hughes <enh@google.com> Don't use mapped IPv4 addresses with MCAST_JOIN_GROUP.

This change is really a one-liner, but I did some cleanup too. This fixes most
of the Harmony multicast tests.

Change-Id: I37ff9c6ee6ee64de0500ef4b51638b3d3a6417ff
etworkUtilities.cpp
etworkUtilities.h
ibcore_io_Posix.cpp
dc915c69ba2495dd2cf965d16058d0b13762142c 20-May-2011 Elliott Hughes <enh@google.com> Move the floating-point parsing code, and tidy up some documentation.

Change-Id: Ibdc1716847f4c6a85a7c24766feffc8768819cef
egister.cpp
ava_lang_StringToReal.cpp
rg_apache_harmony_luni_util_FloatingPointParser.cpp
ub.mk
9e67ca71d3d4a489a157abadc5ba519ced7a0b50 20-May-2011 Elliott Hughes <enh@google.com> Expose waitpid(2).

This lets us move the process reaper up into Java. I've rearranged the code a
bit for the benefit of those looking at stack traces: it's now much clearer
when we're idle because there are no children to wait on, which previously
looked like we were blocked trying trying to report the exit of a child.

Bug: 3107501
Change-Id: I8c5c2952cbdbf9b5a6d8954b4964011d052a90a3
ava_lang_ProcessManager.cpp
ibcore_io_Posix.cpp
553d98af897f7202de5e5a776287de0b5ca8fe39 19-May-2011 Elliott Hughes <enh@google.com> Expose accept(2).

The implementation of PlainSocketImpl.accept is made ugly by the fact that the
SocketImpl we mutate may share its FileDescriptor with a SocketChannel, so we
need to mutate the FileDescriptor itself, and can't simply swap in a new one.
I've raised http://b/4452981 to see if we can integrate the nio and io socket
classes more closely, to avoid this kind of mess.

Bug: 3107501
Change-Id: I4964b64c25e936a44d1e4c22504ca29bba247ab6
egister.cpp
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
ub.mk
4728a015bcd3f432e000d1547c668e804015dc04 19-May-2011 Elliott Hughes <enh@google.com> More IPv6 sin6_scope_id fixes.

My earlier patch fixed the Java-to-native direction. This fixes the
native-to-Java direction, which didn't occur to us at the time.

I've also fixed the documentation so that public methods don't
define themselves in terms of a private method (that ought to
exist in the public API, but doesn't).

Change-Id: Ib16a5952bb69b0b96a66775304947f2a120a1dcf
etworkUtilities.cpp
23ec09188303a874b3b391f96ae0a29af002bff9 19-May-2011 Elliott Hughes <enh@google.com> Implement recvfrom(2).

This one's a little bit hairy because of multiple return values.

Bug: 3107501
Change-Id: I3bd35647d94bb6bc2192d6f31a39ecca07a3926e
niConstants.cpp
niConstants.h
etworkUtilities.cpp
etworkUtilities.h
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
90d96a4f168b7e56cff54dc94dca2f3cde60ebcd 17-May-2011 Elliott Hughes <enh@google.com> Add sendto(2) and reimplement all network writes in terms of it.

Note that this doesn't fix http://b/4182806.

Bug: 3107501
Change-Id: I9b56eae226389a63a12b4c0499d40d5a54a462e2
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
e27d02044ec399884bfd4343d513bf270b9b9b11 16-May-2011 Elliott Hughes <enh@google.com> Remove OSNetworkSystem.close.

For now I'm keeping AsynchronousCloseMonitor as a special case in native code.
We can see about doing something more general-purpose in a later pass.

Bug: 3107501
Change-Id: Ib79b9fc0bebfafc2d14896d957bd8591ae8e6e97
egister.cpp
ibcore_io_AsynchronousCloseMonitor.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
rg_apache_harmony_luni_util_FloatingPointParser.cpp
ub.mk
d4419fce71d11ec8494525eca65e54d1aab51de6 13-May-2011 Elliott Hughes <enh@google.com> Add getpwnam(3) and getpwuid(3).

Bug: 3107501
Change-Id: I727029758fd495471a9103f6ba259f0a5410b0ab
niConstants.cpp
niConstants.h
ibcore_io_Posix.cpp
396a9c666da353b910b515d12eb1c43adfddb0c8 13-May-2011 Elliott Hughes <enh@google.com> Expose getpid(2) and a bunch of its friends.

Bug: 3107501
Change-Id: I71127752373abab67eea339b9afbea03148bece0
ibcore_io_Posix.cpp
2bad9bff258de6275bd3847e5e9f3169b0a93c61 12-May-2011 Elliott Hughes <enh@google.com> Reimplement OSNetworkSystem.isConnected in Java.

We can do this in Java now we've exposed poll(2).

Change-Id: I9f2700d09134198c1cd2681e3814fb482e8e271c
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
98b23d4d9894d21be1eacf498f48aeb707ca1e41 12-May-2011 Elliott Hughes <enh@google.com> Fix use of NULL references in poll.

The first loop works out how many array elements are actually valid, but the
second loop was going through the entire array, trying to copy from outside
our allocation.

This was introduced by a last-minute "harmless" change; previously the array
was always exactly the right size by accident.

Change-Id: I483299fd51b5758d0a998358106ee1e9a21c53b7
ibcore_io_Posix.cpp
70c820401677ca251ad09ac64cc23c760764e75d 12-May-2011 Elliott Hughes <enh@google.com> Expose poll(2) and reimplement java.nio.channels.Selector.

This also adds UnsafeArrayList<T>, which is like ArrayList but lets you access
the underlying array (as opposed to ArrayList.toArray which creates a copy).

Bug: 3107501
Change-Id: I8dc570a9fd7951b1435047017ea7aa19f8f8fc53
niConstants.cpp
niConstants.h
ibcore_io_OsConstants.cpp
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
e9f12043a1e2a29c60779cdb55c58eb156963570 11-May-2011 Elliott Hughes <enh@google.com> Add missing ScopedLocalRef usages.

The one in RealToString is strictly unnecessary, but the other missing ones
should have been there, and this seems like another instance of the "optional
braces" anti-pattern: you should need a specific reason _not_ to have a
ScopedLocalRef, and currently only our iovec code has such a reason (and it
was already explicitly manipulating its local frame correctly).

Change-Id: I24d4766a37bd9677db43da55b94da036a263c0c8
etworkUtilities.cpp
ava_lang_ProcessManager.cpp
ava_lang_RealToString.cpp
ibcore_io_OsConstants.cpp
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
a7bb29434692e01aed843b88cd042628bab74a23 11-May-2011 Elliott Hughes <enh@google.com> Clean up the select(2) implementation.

I wasn't planning on touching this code (since I want to replace it), but the
purported "fix" for http://code.google.com/p/android/issues/detail?id=6309 was
actually a regression. The supplied test fails on the RI. This patch replaces
the bogus test with new tests, and reverts the old "fix".

This was found while trying to work out what "true" and "false" return values
from OSNetworkSystem.select are supposed to mean. This patch also switches to
a more traditional int return value.

Bug: 3107501
Change-Id: Iddce55e081d440b7eb3ddcf94db7d0739dc89c70
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
32b0fa4d1a31ef07bc4297c615f0fe50e9aa7c21 11-May-2011 Elliott Hughes <enh@google.com> DatagramSocket.disconnect is really a connect(2) of an AF_UNSPEC sockaddr.

Bug: 3107501
Change-Id: Ib04369b9ca63ff3fe7eb87dcbf2926fe704813e3
etworkUtilities.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
996bf79565ac88402920bd826d6f85952c83be20 10-May-2011 Elliott Hughes <enh@google.com> Expose connect(2).

The new NET_FAILURE_RETRY in Posix.cpp is intended to replace the legacy one
in NetFd.h, but during the transition we need both. The new one also takes care
of the asynchronous Socket.close semantics, and changes the behavior when the
FileDescriptor is invalid on entry: that is now reported as EBADF; it's only
reported as "Socket closed" when we've been round the loop at least once,
giving us reason to believe the socket was ever open. Having had to debug this
distinction, I think the new semantics are less confusing.

Bug: 3107501
Change-Id: I243dc4fa2eddde7ba40e9b66ec8fc555bc4e80f9
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
da15009528cc8300a6251f1d0931ac8657c9fc31 09-May-2011 Elliott Hughes <enh@google.com> Expose bind(2).

I've renamed the java.net.InetAddress to struct sockaddr conversion functions
too, after initially screwing up this patch by copy & pasting a usage of the
one that only one caller actually wants. Now the name's so ugly no-one will
be likely to use it by accident.

Bug: 3107501
Change-Id: I869a8d27fc40e462505e02bf25a67e771a403e92
etworkUtilities.cpp
etworkUtilities.h
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
4664da5cfc3f22a633ca2c7013a97c08a42e6ba7 07-May-2011 Elliott Hughes <enh@google.com> Simplify our AF_INET/AF_INET6 address situation.

Looks like there's just one special case (presentation to the user) where we
want an Inet4Address to be an AF_INET sockaddr_in rather than an IPv4-mapped
AF_INET6 sockaddr_in6.

Change-Id: Ib3bcc9b69a0fc27c7348b97cc81fb326ba1d5d9d
etworkUtilities.cpp
etworkUtilities.h
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
49ff8b8582bca20a1adbda1d957220526332a8ca 06-May-2011 Elliott Hughes <enh@google.com> More networking cleanup.

Move a bit more work into Java.

Change-Id: I656ec6e3c792ce9baed32662d65c45d75af1d371
etworkUtilities.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
c06e5e270b958aeb8060cd7f2576c0f1e6ac415e 05-May-2011 Elliott Hughes <enh@google.com> Set the sin6_scope_id field when translating an Inet6Address to a sockaddr.

This basically means link-local IPv6 addresses have never worked on Android.

Change-Id: I343493cbbde1e4441385487f054c4bdad5dcef52
niConstants.cpp
niConstants.h
etworkUtilities.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
1c039d71d3879f39e3a75b8788e656f7b4f88f08 05-May-2011 Elliott Hughes <enh@google.com> Add getaddrinfo(2).

This only supports the "node" side of getaddrinfo(2), not the "service" side.
There's also no support for AI_CANONNAME, so we currently return InetAddress[]
rather than anything equivalent to C's linked list of struct addrinfo.

Bug: 3107501
Change-Id: I8cf6baa3027a0fa05ac6e2f8fcc1dd8b576ff8c4
niConstants.cpp
niConstants.h
etworkUtilities.cpp
etworkUtilities.h
egister.cpp
ava_net_InetAddress.cpp
ibcore_io_OsConstants.cpp
ibcore_io_Posix.cpp
ub.mk
d6ecf9222ec65a08e99f15fcc4ec024f0fffd13a 04-May-2011 Elliott Hughes <enh@google.com> Fix non-blocking connects.

The key change here is reintroducing the boolean return value, which we need
as long as the native code treats EINPROGRESS as a special case which doesn't
throw.

The rest is just drive-by incremental cleanup of the code.

Change-Id: I761b052adbb14e912c3853a35327f8a589cd4023
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
220c0af1763283b75617226efe3919c3e3b044c8 30-Apr-2011 Elliott Hughes <enh@google.com> Rewrite blocking connects in terms of the non-blocking primitives.

This simplifies OSNetworkSystem, getting us closer to replacing the
connect(2)-related bits with our new POSIX interface. It also lets
us remove cruft on the Java side that was resetting the socket's
blocking/non-blocking state (which should never have been touched),
which in turn fixes bug 4193212.

Detail messages for socket timeouts get better too, now we're throwing
on the Java side.

The only thing that's worse is that we used to get away with throwing
a checked exception from native code, which simplified our "throws"
clauses. Now we actually have to jump through a few hoops to make javac
happy. (Especially awkward because SocketTimeoutException isn't a
SocketException.) Stupid checked exceptions.

Bug: 4193212
Bug: 3107501
Change-Id: I00695d22094e6d785458dfbb7050fbaecf2db89f
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
92e33d7e684469ef294d5517e65a631b369c8e28 29-Apr-2011 Elliott Hughes <enh@google.com> Better regular expression exception detail messages.

Before:
Caused by: java.util.regex.PatternSyntaxException: Syntax error U_REGEX_MISSING_CLOSE_BRACKET near index 6:
hello[
^
at java.util.regex.Pattern.compileImpl(Native Method)
at java.util.regex.Pattern.compile(Pattern.java:400)
at java.util.regex.Pattern.<init>(Pattern.java:383)
at java.util.regex.Pattern.compile(Pattern.java:374)

After:
Caused by: java.util.regex.PatternSyntaxException: Missing closing bracket in character class near index 6:
hello[
^
at java.util.regex.Pattern.compileImpl(Native Method)
at java.util.regex.Pattern.compile(Pattern.java:400)
at java.util.regex.Pattern.<init>(Pattern.java:383)
at java.util.regex.Pattern.compile(Pattern.java:374)

Some of the messages might still want some tuning, but we can improve them
over time.

Bug: 2974820
Change-Id: I4f41582030168847d22c5323125fde6928d0fc40
ava_util_regex_Pattern.cpp
a5fb706fe4a6dbeaaf4cb1f8bbc2c68b0a2a3f3c 29-Apr-2011 Elliott Hughes <enh@google.com> Add kill(2) to Libcore.os.

Also kick the tires of ProcessManager, since we'll probably have to do some
unrelated work in here soon.

Bug: 3107501
Change-Id: I132c1e09d21ffcf0d5ea4aab93f04a36c1b30eaf
ava_lang_ProcessManager.cpp
ibcore_io_OsConstants.cpp
ibcore_io_Posix.cpp
8dc754726bb5303c25e2c48decdf76d9323ee231 26-Apr-2011 Elliott Hughes <enh@google.com> Switch readv/writev over to ScopedBytes.

Bug: 4343257
Change-Id: Ie966a07ce1e9eb73b71b5e5d9a6a54c201e91e48
ibcore_io_Posix.cpp
0568a63ba1086a78ffb4cff68dd2eac4f9908e13 26-Apr-2011 Elliott Hughes <enh@google.com> Fix ByteBuffer.put(ByteBuffer).

To do this tastefully required some cunning in the native code. The new
ScopedBytesRO/ScopedBytesRW classes let us paper over the differences
between byte[] and DirectByteBuffer, which in turn lets us paper over the
differences between the various kinds of ByteBuffer.

I've also rewritten Posix.read/Posix.readDirectBuffer and
Posix.write/Posix.writeDirectBuffer to use the same idea. I haven't rewritten
readv and writev, but can do and probably should.

Bug: http://code.google.com/p/android/issues/detail?id=16184
Change-Id: Ia30d2f2fe1b1716a8f068187df2218b407a55aae
ibcore_io_Memory.cpp
ibcore_io_Posix.cpp
52467225e3b1ff2386ed5bf630e97e5345469260 23-Apr-2011 Elliott Hughes <enh@google.com> Move JNIHelp's implementation to C++.

Change-Id: I110615696e8348e0dc3cf4a53726a5e0595f5d7e
egister.cpp
a88fa2e69ca3faaf6bc2030cde46a957cedc35a1 23-Apr-2011 Elliott Hughes <enh@google.com> Remove an unnecessary #include.

Change-Id: Ib8344583d08430b1abc45635bfe24e1fe319aaf5
ava_util_regex_Matcher.cpp
aa96cbdcf3a0e303a16bad785c71e2efe417eea0 23-Apr-2011 Elliott Hughes <enh@google.com> Fix java.text.BreakIterator.

BreakIterator was making invalid assumptions about pointer validity. ICU4C's
API is broken, so we have to work around that by pinning for now.

Bug: 4330159
Change-Id: Ie7454d54240c10096f94462027d07ea258b483b6
ibcore_icu_NativeBreakIterator.cpp
fe711d61cafbb878d1d6a5e223fcd2201f2e829a 23-Apr-2011 Elliott Hughes <enh@google.com> Don't use ScopedJavaUnicodeString where ScopedStringChars will do.

Plus a few other random bits of tidying. (This is the detritus from a more
significant change that will need to be cherry-picked. I'm keeping this
separate from the active ingredients of the change.)

Change-Id: I0ae90e8835cba888596efd33b540eb31c784682f
ibcore_icu_NativeCollation.cpp
ibcore_icu_NativeDecimalFormat.cpp
ibcore_icu_NativeIDN.cpp
rg_apache_harmony_xml_ExpatParser.cpp
a37e971343883bb582a93ffbd9f0ba84f10e55ba 21-Apr-2011 Elliott Hughes <enh@google.com> Rewrite NetworkInterface.

This is part of the POSIX work, but also fixes a bug that asked for down
interfaces to be returned. Additionally, I found a few bugs while rewriting
this code. Most notably, we used to return a bogus broadcast address for
the loopback interface. The only difference I notice between us and the RI
when running on the host is that the RI claims that 127.0.0.1 has a prefix
length of 0 rather than 8. I believe that we are correct on this issue.

Bug: 4082343, 3107501
Change-Id: I677e0698e3a86676b4332b5d56fe514a99c3ddc0
niConstants.cpp
niConstants.h
egister.cpp
faddrs-android.cpp
faddrs-android.h
ava_io_File.cpp
ava_net_NetworkInterface.cpp
ibcore_io_OsConstants.cpp
ibcore_io_Posix.cpp
ub.mk
649dc484cf46bf9712be9047adfa9bff9a3cb1ad 20-Apr-2011 Elliott Hughes <enh@google.com> Clean up some of the getaddrinfo(3) callers.

Preparatory to exposing getaddrinfo(3) and moving the logic into Java.

Change-Id: Icbfb5a173b6364f7b2586a7080bb02f7a80a9835
ava_net_InetAddress.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
4f11ebea266eada830d507b8f011e811a8e5d7bc 20-Apr-2011 Elliott Hughes <enh@google.com> Add getnameinfo(3) (and gai_strerror(3)).

There's quite a large corresponding change to InetAddress, plus I've changed
the documentation for all the Permission classes to match the handful that
we'd already documented as legacy cruft.

Bug: http://b/3107501
Change-Id: Ia67aba79f0ab13e64085bd4a2df20ad0776bcc5b
niConstants.cpp
niConstants.h
etworkUtilities.cpp
etworkUtilities.h
ava_net_InetAddress.cpp
ibcore_io_OsConstants.cpp
ibcore_io_Posix.cpp
bef9ec33e1368f57c731fce63b6a8c61628c64b0 19-Apr-2011 Elliott Hughes <enh@google.com> Clean up ICU exception throwing.

Change-Id: Ifce086e1fb20b7cb99673f4d38c8c56144328295
rrorCode.cpp
rrorCode.h
niException.cpp
niException.h
ava_text_Bidi.cpp
ava_util_regex_Matcher.cpp
ava_util_regex_Pattern.cpp
ibcore_icu_ICU.cpp
ibcore_icu_NativeBreakIterator.cpp
ibcore_icu_NativeCollation.cpp
ibcore_icu_NativeConverter.cpp
ibcore_icu_NativeDecimalFormat.cpp
ibcore_icu_NativeIDN.cpp
ibcore_icu_NativeNormalizer.cpp
ibcore_icu_NativePluralRules.cpp
ibcore_icu_TimeZones.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
ub.mk
ab8e01674e2f3cd6b6ff890e9353cb49fa158906 09-Apr-2011 Elliott Hughes <enh@google.com> am 51236bf3: Use jniThrowExceptionFmt.

* commit '51236bf3f42f234359ccbf1d09b41f7e09396889':
Use jniThrowExceptionFmt.
51236bf3f42f234359ccbf1d09b41f7e09396889 09-Apr-2011 Elliott Hughes <enh@google.com> Use jniThrowExceptionFmt.

There were a couple of places where we were doing this manually.

Change-Id: Iea6201815e8b52e4caba13b789abedc0e173df79
etworkUtilities.cpp
ava_net_InetAddress.cpp
b974666d79ebc392b37ec1ae83aae57ae6331c08 06-Apr-2011 Elliott Hughes <enh@google.com> Finish setsockopt(2).

Bug: 3107501
Change-Id: I8f026dcba78acb555834bdcc594e114238f3cc52
ibcore_io_OsConstants.cpp
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
438cb9e440d250c8aa5daf4fae0c400dce8b1499 02-Apr-2011 Elliott Hughes <enh@google.com> Add MCAST_JOIN_GROUP/MCAST_LEAVE_GROUP setsockopt(2).

Bug: 3107501
Change-Id: I576f45f8c67b6172888bc0541e3d3a462bfa311a
niConstants.cpp
niConstants.h
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
c63f0d4e80a9fd3bdf99cd438d108b750226736a 02-Apr-2011 Elliott Hughes <enh@google.com> Add more of setsockopt(2).

This covers all the easy cases. I'll do the awkward ones separately.

Bug: 3107501
Change-Id: Ie424290e0bef76516d0c57e9c077cb1c202381ad
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
c84000159bb1770972c308da924e9c90db4024a0 01-Apr-2011 Elliott Hughes <enh@google.com> Remove hacks for non-dual-stack situations.

There's also a behavioral change here in code that previously said TODO.
Our current intention is that we always set both IPv4 and IPv6 options (when
coming via the java.net interfaces, which don't allow you to differentiate),
always return the IPv6 options (since it can't matter). If you need greater
control (which was never possible before), you'll be able to use the new
APIs soon.

The SocketOptions.IP_MULTICAST_IF (IPv4) and SocketOptions.IP_MULTICAST_IF2
(IPv6) distinction remains, because that's exposed java.net API.

CompatibleSocketAddress gets a lot simpler, but it looks like the kernel
still doesn't like an IN_ANY bind(2) on a dual-stack AF_INET6 socket. This
is unfortunate because it means callers have a decision to make, preventing
us from moving that code into inetAddressToSocketAddress.

Bug: 3107501
Change-Id: Ifa694d936a81af143a40f404b12470045e644fa8
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
5c42f5792a0ad4159d30e7fd18958a21bf8b327f 01-Apr-2011 Brian Carlstrom <bdc@google.com> Cleanup diagnosing HandshakeCompletedEventTest.testClientAuth

Change-Id: I9f71a2578c6e9d01e1b8cffcfc344f5116ad5db5
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
8398239b31c6f6fb9b19788d0a4b9ff16a59caf7 01-Apr-2011 Elliott Hughes <enh@google.com> Make inetAddressToSocketAddress more available.

I should probably rename the NetworkUtilities.h methods to say something like
SockaddrStorage instead of SocketAddress, to avoid confusion with
java.net.SocketAddress, but that can come later.

Change-Id: Id878c2b865c284bb4a14f3db1eb15b3fa9ccc9e9
etworkUtilities.cpp
etworkUtilities.h
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
0ade5524d972b9dfd69b0126aa4c35319c1b7fa4 31-Mar-2011 Elliott Hughes <enh@google.com> Fix an error in Posix.statfs and make sure we have test coverage.

Bug: 3107501
Change-Id: Ib0ad8585d91ae4a440aec95fcd135c7f672d2367
ibcore_io_Posix.cpp
0a9d1ee45a9884a9616624d747172e18734e8fe0 31-Mar-2011 Elliott Hughes <enh@google.com> Add getsockname(2) and getsockopt(2).

Bug: 3107501
Change-Id: Ibb0d5a576ecb46e51dbda6051776145eec9e7fe1
niConstants.cpp
niConstants.h
etworkUtilities.cpp
etworkUtilities.h
ibcore_io_OsConstants.cpp
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
462bdac45c10f43d88d8f07f6994e272a27c14a2 30-Mar-2011 Elliott Hughes <enh@google.com> Add close(2).

This is sufficient for non-socket fds, but may need to change to support the
asynchronous socket close monitor. (Hopefully not; I'd rather lift that into
Java.)

I've also changed the semantics of IoUtils.close to match those desired by
all callers: ignore null/invalid FileDescriptors.

Bug: 3107501
Change-Id: Iad5c31c8f0f34d2a5ab1ed4581509b46af28bd1f
egister.cpp
ibcore_io_IoUtils.cpp
ibcore_io_Posix.cpp
ub.mk
454a95f6a28855aa3c88d168b15a45bf315efc99 30-Mar-2011 Elliott Hughes <enh@google.com> Add socket(2) and start adding setsockopt(2).

I've added just enough setsockopt to keep the hack from our old socket
creation code. More later (but not necessarily right away).

Bug: 3107501
Change-Id: Id57bdd3c760bc58ed79d675b268c55493cbc24c8
ibcore_io_IoUtils.cpp
ibcore_io_OsConstants.cpp
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
8b15dcc5890963edad4dfcf558cc16027c7985e5 29-Mar-2011 Elliott Hughes <enh@google.com> Add sendfile(2).

This patch marks the end of OSFileSystem.

Having to support a Java "long*" for sendfile(2) gave me an opportunity to go
back and improve my ioctl(2) to use a corresponding "int*" equivalent, instead
of its previous special-case hack.

Bug: 3107501
Change-Id: I9fde4777700552263fab4fe9aeb556174163e3dc
niConstants.cpp
niConstants.h
egister.cpp
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
ub.mk
bbac92e691de7d570928ddfba639067978e55b06 29-Mar-2011 Elliott Hughes <enh@google.com> Add readv(2)/writev(2).

The old implementation would cheat if it was given non-direct buffers, copying
them into newly-allocated direct buffers. (The network Channel implementations
are worse: they copy all the data into a single buffer, and then read/write
that. I'll get to them eventually.)

Bug: 3107501
Change-Id: I1655bacb042e7ebcde7e5bc5cf2c71e7ce5e30af
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
461d0d860814c68154d8dd06d24f94118f33d28a 29-Mar-2011 Elliott Hughes <enh@google.com> Add ioctl(2) for int*.

I'm not adding the "struct ifreq" stuff yet because that's really hairy and I
plan on rewriting the NetworkInterface implementation anyway, so it'll mainly
be based on /proc. With any luck, we won't even need those other ioctls then.

I'm not sure _this_ ioctl is a good idea, but it does seem like a slight
improvement on the old code, and we can always move it back out if/when these
APIs become more public.

Bug: 3107501
Change-Id: Iceac15e4a107c33bfc8795976a747c2ffa59a183
ibcore_io_OsConstants.cpp
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
78c7cc547101002b9f9043cf3845970719d1bda8 26-Mar-2011 Elliott Hughes <enh@google.com> Add write(2).

Note that this is a functional change, because the old code was wrong: it
assumed that short writes don't happen. I thought we'd (I'd) cleaned this
up just recently, but it looks like I must have only gone through the network
code. Embarrassing.

This also cleans up the previous read change a bit, factoring out a bit more
duplication, and taking advantage of the fact that we now get decent
exceptions thrown from invalid FileDescriptors (meaning we can remove explicit
checks).

Bug: 3107501
Change-Id: I8bd5324836c9d151dceaef5b84ec523a67391b64
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
26c7025a7a919044771fb89031161bd26fe03032 26-Mar-2011 Elliott Hughes <enh@google.com> Add read(2).

For both byte[]s and ByteBuffers.

Bug: 3107501
Change-Id: I93b781069ade4507371c8fe8c5fda0163fbb2dbb
ava_lang_System.cpp
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
fc549a0b0388987b26dea524894d75a63d14783b 25-Mar-2011 Elliott Hughes <enh@google.com> Add fcntl(2).

I initially used overloading, but that actually decreases safety in practice
because which overload you need is (uniquely) determined by the specific
command you're issuing. Forcing callers to explicitly state what they're
doing works around this. As it was, I had to use strace(1) to find my bug.

Bug: 3107501
Change-Id: Ia54b72dd6453372922f01b22f382eb93ac91aaa7
niConstants.cpp
niConstants.h
ibcore_io_IoUtils.cpp
ibcore_io_OsConstants.cpp
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
7341b9ed7157a1e37a3e69a0974676da358b735a 24-Mar-2011 Elliott Hughes <enh@google.com> Add uname(2).

This replaces InetAddress's use of gethostname(2), and System's hard-coded use
of uname(2) itself.

Bug: 3107501
Change-Id: I7e808177eece1e38428fea18a96c65628d51d93e
niConstants.cpp
niConstants.h
ava_lang_System.cpp
ava_net_InetAddress.cpp
ibcore_io_Posix.cpp
e1502d64e937001636fca3d62b2552ef2a34d05f 24-Mar-2011 Elliott Hughes <enh@google.com> Add listen(2).

Bug: 3107501
Change-Id: I3677bb4ddb3f3d0e58a6833165504f47bb309630
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
59e4744d27231f260271dbbca406e0cc39768116 24-Mar-2011 Elliott Hughes <enh@google.com> Add shutdown(2).

Bug: 3107501
Change-Id: I30354c4cc6e86a4e7b0e3f84e95719539db1d297
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
41f0605d2c809bd9bc1c0fb68d86b49a0f59b6c5 24-Mar-2011 Elliott Hughes <enh@google.com> Add pipe(2).

This lets us kill quite a bit of IoUtils.

Bug: 3107501
Change-Id: Ic8a297b29cc53a17841cc77e266cd8dc3910c521
niConstants.cpp
niConstants.h
ibcore_io_IoUtils.cpp
ibcore_io_Posix.cpp
c7fa20701d5e9398c38f4615ed293acfce1c0cf6 24-Mar-2011 Elliott Hughes <enh@google.com> Add mkdir(2) and remove(2).

Bug: 3107501
Change-Id: Ia4ca50b957d6015fa49076806273054563d25b63
ava_io_File.cpp
ibcore_io_Posix.cpp
b7190190e0ef8de883c952efb319ce7748831faa 24-Mar-2011 Elliott Hughes <enh@google.com> Add chmod(2).

Bug: 3107501
Change-Id: If3a0639634a90f607b8c6035f25b03d23e7261e0
ava_io_File.cpp
ibcore_io_Posix.cpp
8fcfe950127b0542df4b2415cdda0c5ce77f47ba 24-Mar-2011 Elliott Hughes <enh@google.com> Fix an initialization.

Bug: 3107501
Change-Id: I4d52107bb21a36ac0f160bdbb84213aa6fa89399
niConstants.cpp
59fa7163774d6930a174bc038414a4b780581957 23-Mar-2011 Elliott Hughes <enh@google.com> Add statfs(2).

Bionic doesn't support statvfs(2), so we'll have to use statfs(2) in the
meantime. We should fix this before making this API public, though.

Bug: 3107501
Change-Id: I1af8a473261586321543dd1554e1f6079a84f384
niConstants.cpp
niConstants.h
ava_io_File.cpp
ibcore_io_Posix.cpp
a20cc6fca30d18e05db67ceeb0403b7b58ffd364 23-Mar-2011 Elliott Hughes <enh@google.com> Add rename(2) and symlink(2).

And use them too.

Bug: 3107501
Change-Id: I83b512a2553bfc2501d02c251a4649f8e670774e
ava_io_File.cpp
ibcore_io_Posix.cpp
2ffce92141c0b2a5f0543229f3ded34b0ee79ba1 23-Mar-2011 Elliott Hughes <enh@google.com> Move File.createNewFile into Java.

Also add improved tests.

Bug: 3107501
Change-Id: Ibea9bd71adf1e1230c14072fb4597ad5bd9c214b
ava_io_File.cpp
0ac77ac8e915bff1a863e371f9b363033f9cf759 23-Mar-2011 Elliott Hughes <enh@google.com> Add open(2).

Bug: 3107501
Change-Id: I404030b4c678862465d04f723a6a324663e0af25
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
0f746ff511162add42eeabaf14ba70ace874c6f4 23-Mar-2011 Elliott Hughes <enh@google.com> Add mincore(2).

Bug: 3107501
Change-Id: Ibb288b0889ff47612f77870239f51928b35754a9
ibcore_io_Memory.cpp
ibcore_io_Posix.cpp
7e13c0f05ac9e7c55682d10e953dd4cbd5e6107c 19-Mar-2011 Elliott Hughes <enh@google.com> Add mlock(2) and munlock(2).

Bug: 3107501
Change-Id: I7e4cad36370196d990c709bfa33f89d7568aa453
ibcore_io_Memory.cpp
ibcore_io_Posix.cpp
7e25eff38a191d9c19e45093f4fde5102fb09d78 19-Mar-2011 Elliott Hughes <enh@google.com> Add mmap(2), msync(2), and munmap(2).

Bug: 3107501
Change-Id: I6a7c4147ec27bab9ded280476bad1157ce03fab8
ibcore_io_Memory.cpp
ibcore_io_Posix.cpp
9a3f363523000704205df288f8b6f2f48c0d8563 19-Mar-2011 Elliott Hughes <enh@google.com> Add isatty(2).

Bug: 3107501
Change-Id: I67e4a4ceeba945095419d176e7de5edb7da8a440
ava_io_Console.cpp
ibcore_io_Posix.cpp
dedaccdfa07c370a58cba08b096133ad9eec0ec3 18-Mar-2011 Elliott Hughes <enh@google.com> Add lseek(2).

Bug: 3107501
Change-Id: Ie27e2ae1c7d37de5f02b1d81ee2005182339f881
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
f5333fd2094bdac4d6506177b1964b79afa64d77 18-Mar-2011 Elliott Hughes <enh@google.com> Add ftruncate(2).

The claim that "the port library" modifies the file offset appears to only ever
have been true of Harmony's Win32 implementation. Certainly, this is not the
behavior of ftruncate(2), so we can lose the cruft.

Bug: 3107501
Change-Id: I35092fd986296b78c4847c7215765f9997339f37
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
44fa6764d0f235032cc64fb4ecd7018140a2d5d8 18-Jan-2011 Brian Carlstrom <bdc@google.com> DO NOT MERGE: Ensure sslSelect is non-blocking

This was cherry-picked back from Honeycomb 41e32e5a6b091b2f8682f525bae47deb395be4b1

sslSelect had a comment explaining why its blocking read from a pipe
would never block. However, there is repeatable evidence to the
contrary. Attaching gdb to a process with SSLSocket blocked in both
read and write showed that the writer was waiting in sslSelect trying
to acquire the AppData::mutex while the reader was holding the mutex
and blocked in read(2).

This change makes the file descriptor of the pipe non-blocking.
Callers of sslSelect select already repeat their attempt to handshake,
read, or write as necessary when waking up from select, so now if the
code is woken up by the pipe, it continues regardless of the read
status.

Bug: 3332268
Change-Id: I75fb094e168d89a8e2752a6e12ee79f9adadc013
ativeCrypto.cpp
6fc1a0e1e68dc2e0d12341548e58fa7f1c5dafc4 18-Mar-2011 Elliott Hughes <enh@google.com> Add sysconf(3).

This gives us a getpagesize(3) replacement right now, and will let us implement
Runtime.availableProcessors here rather than in the VM in a later change.

Bug: 3107501
Change-Id: I6fc1f83d36b026fbe8d37eca525550479677f2de
ibcore_io_OsConstants.cpp
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
47cb338d43f75dd998b29caaaa9446c5705217d1 18-Mar-2011 Elliott Hughes <enh@google.com> Add fstat(2), lstat(2), and stat(2).

Bug: 3107501
Change-Id: Ic36f9ffd03446d6e0189470f42abdadde57327df
niConstants.cpp
niConstants.h
ava_io_File.cpp
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
bdb717ae237f4bb9b14b61a2d24150106ac8e6c7 18-Mar-2011 Elliott Hughes <enh@google.com> Simplify the constant initialization.

Bug: 3107501
Change-Id: I07b035482de00cb39c735e3acd9387fcbc22b30a
ava_io_File.cpp
ava_lang_System.cpp
ibcore_io_OsConstants.cpp
oStringArray.cpp
52724d3ebd4ccaaa4b9f5576e329d4272cde8ea9 17-Mar-2011 Elliott Hughes <enh@google.com> Add fsync(2) and fdatasync(2).

Interesting parts to this change:
* first BlockGuard support (and general delegation support).
* first rethrowing of ErrnoException as IOException.
* switching FileChannelImpl from int to FileDescriptor.

The special case in FileDescriptor.sync has been removed. Testing with the RI
showed that it doesn't treat syncing a FileDescriptor that corresponds to a
socket as a special case --- it throws SyncFailedException just like normal.

Bug: 3107501
Change-Id: I99faf120bd802aec0397a79772ed38c5e1542fed
egister.cpp
ava_io_FileDescriptor.cpp
ibcore_io_Posix.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
ub.mk
ddfdbb9d172fe9b72e08e8d7deab0aa3b8acf044 17-Mar-2011 Elliott Hughes <enh@google.com> Add access(2), strerror(3) and access to environ.

Update java.io.File and java.lang.System to use the new functionality
rather than brewing their own.

Bug: 3107501
Change-Id: I5fa63190d240d638f44a911401143ffb2af9d395
niConstants.cpp
niConstants.h
ava_io_File.cpp
ava_lang_System.cpp
ibcore_io_Posix.cpp
oStringArray.h
ec617e2cb4a374f0fd8fbda4a633214cf23a59a9 17-Mar-2011 Elliott Hughes <enh@google.com> Move the getenv(3) native code out of System as a demo.

This is a fairly trivial patch, just to show the general structure.

Bug: 3107501
Change-Id: I547df621ccb8b8874e5f74c4d0bcf84ccaef97c3
egister.cpp
ava_lang_System.cpp
ibcore_io_Posix.cpp
ub.mk
2822a84736c46282ee3a12983340f594e38eac5a 16-Mar-2011 Elliott Hughes <enh@google.com> More POSIX constants.

This covers <errno.h>, <netinet/in.h>, <stdlib.h>, <sys/mman.h> (minus some
POSIX constants missing in bionic), <sys/socket.h> (minus the
getsockopt/setsockopt constants), <sys/stat.h>, <sys/wait.h>, and <unistd.h>.

Bug: 3107501
Change-Id: I83d5beeb74cce31f3fbac1e1b350d73df7cb4b9d
ibcore_io_OsConstants.cpp
cdf7a1f942469221bcfd63d9cdf71851b011eaf0 16-Mar-2011 Elliott Hughes <enh@google.com> Expose POSIX constants.

And use them, too. This patch is a little confusing because we already had
constants in Java that were using the POSIX names but that didn't actually
correspond to the constants whose names they'd stolen. Ugh.

Bug: 3107501
Change-Id: Ib64a109c9340b0ecdf80bec91074206c001f455a
egister.cpp
ibcore_io_OsConstants.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
ub.mk
f934c3d2c8dd9e6bc5299cef41adace2a671637d 15-Mar-2011 Elliott Hughes <enh@google.com> Make OSMemory the semi-supported libcore.io.Memory.

Looks like we're not going to bother with a separate libcore.os package,
when libcore.io will do.

Change-Id: I2806c59349ed4b6410d768c4207c384ced973c54
egister.cpp
ibcore_io_Memory.cpp
rg_apache_harmony_luni_platform_OSMemory.cpp
ub.mk
2f03ccad590827233fcba84a8b6eafcd414e5fe7 08-Mar-2011 Elliott Hughes <enh@google.com> Use -fvisibility and clean up a little.

The visibility change isn't obviously useful, but it's a good excuse to clean
up some of our networking code a little.

Change-Id: I165b32b9c76a3707c512e07de07992f63673ab4f
ibcore_net_RawSocket.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
alueOf.cpp
alueOf.h
52b310afcffe8b6aed6fa0c1e9e8b0ade6f0a672 04-Mar-2011 Elliott Hughes <enh@google.com> Git threw away my changes to a file that had been renamed.

Manually patch the ICU.cpp changes into libcore_icu_ICU.cpp. Also remove the
whole sentence from the class documentation, since it looks rather odd without
the bit that would refer to @hidden API.

Bug: 3484927
Change-Id: I1ea046e18949ad5bfa7f4512df1f481c81a94310
ibcore_icu_ICU.cpp
4cddda58f9e5eaeb244ad4cef26049f9be142fd6 04-Mar-2011 Elliott Hughes <enh@google.com> Merge "Add new java.util.Currency functionality." into dalvik-dev
0ad1c14261c4db0731503770ec6a027e90cc6e38 04-Mar-2011 Elliott Hughes <enh@google.com> Add new java.util.Currency functionality.

Also clean up the implementation a bit, fix a long-standing
serialization bug, and improve the documentation.

Bug: 3484927
Change-Id: I5e5270b1b1cdac69b6d7f51b8460896692040a12
CU.cpp
oStringArray.h
57d0a10f4fa6cae6d5c63b4f799e048e83c5d11e 03-Mar-2011 Elliott Hughes <enh@google.com> Make all filenames match their classes.

Change-Id: I2c9f95a27ee3881fc609e3e4f1468205c701215d
CU.cpp
ativeBN.cpp
ativeBreakIterator.cpp
ativeCollation.cpp
ativeConverter.cpp
ativeCrypto.cpp
ativeDecimalFormat.cpp
ativeIDN.cpp
ativeNormalizer.cpp
ativePluralRules.cpp
imeZones.cpp
ava_math_NativeBN.cpp
ibcore_icu_ICU.cpp
ibcore_icu_NativeBreakIterator.cpp
ibcore_icu_NativeCollation.cpp
ibcore_icu_NativeConverter.cpp
ibcore_icu_NativeDecimalFormat.cpp
ibcore_icu_NativeIDN.cpp
ibcore_icu_NativeNormalizer.cpp
ibcore_icu_NativePluralRules.cpp
ibcore_icu_TimeZones.cpp
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
ub.mk
504826511d908b4ad56ed3dc3df09d471390f103 02-Mar-2011 Elliott Hughes <enh@google.com> Work around icu4c's excessive file system activity.

There's still a lot of redundant work going on, but this suppresses much of it
for very little effort. The cost of getting all the zone strings for en_US goes
down from 1540ms to 1005ms on stingray.

Bug: 3443476
Change-Id: Ibc425988fd75012236d5f6778cd9edbbe93bca12
CU.cpp
4f5a696869e0348cf21dad9050d59b20849aff96 26-Feb-2011 Elliott Hughes <enh@google.com> Add new java.lang.Character functionality.

Bug: 3484927
Change-Id: I561c927bbd0ef2e801d38d9c3a6250b1d3f65b0d
ava_lang_Character.cpp
50da6c117a7590f70bd6bcad62041824adef19cc 25-Feb-2011 Elliott Hughes <enh@google.com> Fix parsing of UTC.

ICU doesn't seem to recognize UTC, preferring GMT+00:00 instead. Work
around that, cleaning up our zone strings which helps both formatting and
parsing. In particular, it means we don't throw when asked to parse a
string whose time zone is "UTC".

Bug: http://code.google.com/p/android/issues/detail?id=14963
Change-Id: Idfae91ca8664e426f8defcf05c9d4f5f31c00a94
imeZones.cpp
b0d456ffc2e52eda8330343cb8624a5355b9c6ed 24-Feb-2011 Elliott Hughes <enh@google.com> Don't use TEMP_FAILURE_RETRY for close(2).

Linus says no.

Change-Id: I8c0a2934ad25b5d4d4648d6706a26b04a2fc51d3
ibcore_io_IoUtils.cpp
a7ef55258ac71153487357b861c7639d627df82f 22-Feb-2011 Elliott Hughes <enh@google.com> Simplify internal libcore logging.

Expose LOGE and friends for use from Java. This is handy because it lets me use
printf debugging even when I've broken String or CharsetEncoder or something
equally critical. It also lets us remove internal use of java.util.logging,
which is slow and ugly.

I've also changed Thread.suspend/resume/stop to actually throw
UnsupportedOperationException rather than just logging one and otherwise
doing nothing.

Bug: 3477960
Change-Id: I0c3f804b1a978bf9911cb4a9bfd90b2466f8798f
ava_lang_System.cpp
9f557fae5a751ba8de8c0bc9ba689ab23ad405f6 22-Feb-2011 Elliott Hughes <enh@google.com> Don't log anything if ICU initialization goes well.

(By ensuring that we log everything you'd need if something goes wrong.)

Change-Id: I371647046341ea5f782c63eddb1646c20d8a54bc
CU.cpp
ddafeb1d73cfe504720d10a2634b5858fc4cc413 19-Feb-2011 Elliott Hughes <enh@google.com> Rationalize our various native conversions to java.lang.String[].

We could probably get away with even fewer, but this seems an appropriate
amount of effort for now...

Change-Id: Ieef83250295324bab222fe529913d8f4e93817f4
CU.cpp
ativeConverter.cpp
ava_io_File.cpp
ava_lang_System.cpp
ub.mk
oStringArray.cpp
oStringArray.h
2ef68714ff84d43705f57f724fbcb1a28ebd954d 18-Feb-2011 Elliott Hughes <enh@google.com> More system properties work.

This patch moves the last of dalvikvm's property setting (other than the
command-line -D stuff, which is inherently the VM's job) into libcore. It
also adds a couple of new properties giving the openssl and zlib library
versions.

Change-Id: I4569b65fad0585c3878ad5eaa0234ed95768b1f9
ava_lang_System.cpp
bb1c04167bdff1939e9e71ed04c57337d4951008 17-Feb-2011 Elliott Hughes <enh@google.com> Tidy up the bidi code a little.

If we do ever use this, we should probably kill the run class completely; we
don't expose it to callers, and we could easily cope with a simple int[]
internally.

Change-Id: Ic03fbf7e56251a35b5db31509fbca15ab6d6f01a
niConstants.cpp
ativeBidi.cpp
egister.cpp
ava_text_Bidi.cpp
ub.mk
cc06c7a4d6e3578dbe1d425d4c57ef792df398db 17-Feb-2011 Elliott Hughes <enh@google.com> Remove header files that are no longer used.

Change-Id: I83fc78b6f9b8953ad953f8cc3a230c949d3b24d4
ava_lang_Double.h
ava_lang_Float.h
ava_lang_StrictMath.cpp
08343a4ef77616fc420e51d1095c0d6a266041ba 16-Feb-2011 Elliott Hughes <enh@google.com> Remove our implementations of inline natives.

It turns out that our String.equals was getting used. Making dalvikvm's inline
natives be native methods ensures that doesn't happen.

I've also added a test to ensure we explicitly test both variants.

Change-Id: Ie2a4b5289092da5ffca4a4273692f1048ab3b841
egister.cpp
ava_lang_Double.cpp
ava_lang_Float.cpp
ava_lang_Math.cpp
ava_lang_StrictMath.cpp
rg_apache_harmony_luni_platform_OSMemory.cpp
ub.mk
566bbb1d5a0ffadfc07fa58176587d4bd0d0be13 12-Feb-2011 Elliott Hughes <enh@google.com> Various time zone strings improvements.

* Added a cache -- really a memo table -- to libcore.icu.TimeZones. I've also
made the intern table global across all locales, for the common case where one
language has many corresponding country codes (and thus locales) for which the
strings are all the same. (I.e. this gives us deduplication across locales
where before we only had it within locales.) We also eagerly populate the cache
with both the default locale *and* en_US in the zygote, which should provide
better behavior for everyone whose default locale isn't en_US.

* Switched from linear search to binary search when pulling a row out of the
zone strings table. We could hash these, but I currently have no reason to
think we'd gain much speed for the space.

* Removed the special-case hack I had to ask ICU for a single string. The new
code largely removes the need for this, though one can imagine a theoretical
app that will behave worse under the new regime, all plausible ones will
benefit.

* Switch ICU over to using an mmap(2)ed copy of its .dat file and tell it never
to look for stuff on the file system. This doesn't actually work in any current
version of ICU, though it is slightly faster by virtue of no longer looking for
individual .res files (it still keeps looking for the same .dat file over and
over). I'll work on fixing ICU later. This change takes us from about
1.1s/locale to 0.8s/locale. My current ICU hack takes that down to 0.3s/locale,
which is still obscene, but it's another step in the right direction.

* Fixed the "unambiguous abbrevations" logic in TimeZones.cpp so that all users
of (say) CET to mean "Central European Time" get it, not just first. We really
just wanted to avoid the situation where there's a "Central Excellent Time" or
whatever, whose CET would *conflict* with the first one we learned about.
Multiple references to the same time zone are not conflicts.

* Moved clone2dStringArray to the only place it's really needed.

* Slightly better documentation for Comparator.

* More tests, including the one for CET formatting that I should have added
when I fixed CET parsing, which would have shown me the error of my old ways.

Bug: 3443476
Change-Id: If1d50e6273fc98a38139f14445265ce0be5e09dd
CU.cpp
imeZones.cpp
296b43d6f6fc96b0b4cf16956bebed8347953a6f 11-Feb-2011 Elliott Hughes <enh@google.com> Remove the obsolete TouchDex code.

Apparently, this is how we did the first-boot dexing before we had a
package manager.

Change-Id: I6fce0fb30ab9dc2e7ebb0c4177540e92677c92b9
egister.cpp
e0e567287e4392bebc5f5826b8ef3b1bd8ca166e 11-Feb-2011 Elliott Hughes <enh@google.com> Add system properties that report our ICU4C and Unicode versions.

Bug: 3413364
Change-Id: Ibbc4ab3564bc3329275a1a828f86750aa6beb200
CU.cpp
3664d8839f0ba794f428119ee7f7304a66861da5 08-Feb-2011 Elliott Hughes <enh@google.com> Clean up the CharsetDecoder/CharsetEncoder implementation a bit more.

Moving CharsetEncoderICU into java.nio.charset lets us use a cleaner workaround
for the constructor-calling-abstract method API bug.

Change-Id: I2312580b2c27711e9d4c88fe4dc057eec13c12e0
niConstants.cpp
37871fb106b08055ad56d7f04d4faccdd163e1af 08-Feb-2011 Elliott Hughes <enh@google.com> Clean up the CharsetDecoder/CharsetEncoder implementation a bit more.

This removes the duplicated error-checking in the ICU classes that started
this investigation, but also cleans up a bunch of other stuff. There shouldn't
be any other behavioral differences, just clearer code.

Bug: 3418769
Change-Id: I4da4d2a5b2fce1b152e527909b7c76a6db76c5c0
ativeConverter.cpp
2981b5e8cf7c19dfd85b2088b18b7a6146825317 03-Feb-2011 Elliott Hughes <enh@google.com> Improve CharsetDecoder's quality of implementation, like CharsetEncoder.

As I suspected, CharsetDecoder doesn't cope with a character's bytes being
split across multiple writes any more than CharsetEncoder could cope with
halves of a surrogate pair being split across multiple writes. This seems
much more likely to have harmed applications than CharsetEncoder (since
surrogates are rare).

Anyway, ICU does the right thing here too, so the fix is basically the same.

I've also gone through the decoder/encoder code a bit to bring them more
in line with each other.

Bug: 3410124
Change-Id: I151d043e474161e324361cddfc73188ba73fd59c
ativeConverter.cpp
8c20515fc3a6152a4e5bdee57f2d136f82e5f625 02-Feb-2011 Elliott Hughes <enh@google.com> Merge "Bring CharsetDecoderICU more in line with CharsetEncoderICU." into dalvik-dev
dbf863488607fbb16a3d28c09f772d9581bd64ad 02-Feb-2011 Elliott Hughes <enh@google.com> Bring CharsetDecoderICU more in line with CharsetEncoderICU.

There's no need for separate 'flush' native code here either.

I've also explicitly set inEnd to 0 in CharsetEncoderICU which was
an oversight before; I've added a failing test. (Existing
tests for CharsetDecoder failed without the corresponding line.)

I've also made a comment in InputStreamReader match the equivalent comment
in OutputStreamWriter.

I'll make more invasive changes (looking at the INPUT_HELD stuff) when I've
written some tests for CharsetDecoder.

Change-Id: I39a3b2c017da1f991bdff33ebc8c226fc56841ba
ativeConverter.cpp
efb32502d686b06ddf60828d9abe3d4e0577e5dc 02-Feb-2011 Brian Carlstrom <bdc@google.com> am 4155a249: Performance improvements to NativeCrypto based MessageDigest API

* commit '4155a2498a57fb09e92815f8993a70c216ddc5ec':
Performance improvements to NativeCrypto based MessageDigest API
4155a2498a57fb09e92815f8993a70c216ddc5ec 02-Feb-2011 Brian Carlstrom <bdc@google.com> Performance improvements to NativeCrypto based MessageDigest API

NativeCrypto API improvements:
- Move to using EVP_MD related native methods, some of which are derived
from the EVP_MD_CTX versions with similar name. The new
EVP_get_digestbyname allows one time lookup of the EVP_MD from the
string name, avoiding doing it on every call to EVP_DigestInit.
- EVP_MD_CTX_create is now removed, it is just done as part of
EVP_DigestInit and EVP_VerifyInit to an extra JNI call.
- EVP_DigestFinal now destroys the EVP_MD_CTX to avoid needing to make
another call JNI call to EVP_MD_CTX_destroy. EVP_MD_CTX_destroy is
kept for cases when EVP_DigestFinal is never called.

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

In addition to the improved NativeCrypto API to allow better
performance for callers, the implementations use of
throwExceptionIfNecessary was made conditional based on the status
code from various operations, which had a noticeable impact on
performance compared to android.security.MessageDigest

luni/src/main/native/NativeCrypto.cpp

Updated MessageDigest.getInstance default implementation to use new
NativeCrypto API. An EVP_MD instance is looked up at class load time
for a specific digest type and then used to call
NativeCrypto.EVP_DigestInit as needed, avoiding a lookup of EVP_MD for
each new digest. The EVP_MD is also for a one-time lookup the digest
output size in bytes, to avoid native calls for
engineGetDigestLength. Finally, the creation of the EVP_MD_CTX is now
lazy, only created when needed, avoiding unnecessarily create/free in
reset cases such as engineDigest. See also external/bouncycastle's
OpenSSLDigest implementation which had similar optimizations.

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

OpenSSLSignature also used EVP_MD_CTX_create, and its EVP_VerifyInit
was changed similar to EVP_DigestInit to internally allocate the
EVP_MD_CTX on the call to init.

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

Fix test to work with arbitrary provider order

luni/src/test/java/org/apache/harmony/security/tests/java/security/MessageDigest2Test.java

Fix CloseGuard warnings

luni/src/test/java/tests/security/MessageDigestTest.java

Bug: 3392028
Change-Id: Idb266ebc0918ffd5550e0f457784256400cd2ff0
ativeCrypto.cpp
33604713c5c70f9e6cad61dee6eb628db666bb22 01-Feb-2011 Elliott Hughes <enh@google.com> Improve CharsetEncoder to handle surrogates gracefully.

Behave like ICU rather than the RI, and transparently handle surrogate pairs
split across buffers. This fixes callers who were unaware of the bad design,
and shouldn't harm those callers who try to work around it (since they'll
never find themselves in the bad state).

Bug: 3408061
Change-Id: I6b5675196a14b15efdaa7084a82a483d8d2c47ad
ativeConverter.cpp
909a18fd6628cee6718865a7b7bf2534ea25f5ec 28-Jan-2011 Elliott Hughes <enh@google.com> Use the standard zlib options everyone else uses.

Change-Id: I000b39553aa6499ff1ebe615439d4e52745a7833
ava_util_zip_Deflater.cpp
cf988a1dfb7f4a13bd797ce3a424242474b7c152 26-Jan-2011 Elliott Hughes <enh@google.com> Fix time zone formatting for custom SimpleTimeZone instances.

Rather than return null for unknown time zones, as our code assumed, ICU
unhelpfully pretends unknown time zones are GMT. We need to check whether
we got what we asked for, which is a bit of a pain.

Bug: 3049014

Change-Id: Ie7f0043b8da622767538ed537a9e2d927652215e
imeZones.cpp
be57694064c2271ffceb96d13875e34019e73348 25-Jan-2011 Owen Lin <owenlin@google.com> resolved conflicts for merge of 21b8960a to dalvik-dev

Change-Id: Ide01710e59fc6028f4b2443afee85204815dc775
eb05c75f33355d9549834d843911ba836d051d52 24-Jan-2011 Owen Lin <owenlin@google.com> Merge "Skip bytes by reading if the file is not seekable." into honeycomb
0f524004b71b732c888d10eab57008bc65d8a3e0 20-Jan-2011 Owen Lin <owenlin@google.com> Skip bytes by reading if the file is not seekable.

And also add unit test for FileInputStream.skip() for a pipe.

bug: 3298498

Change-Id: Iceecdd42654700e00f15b53759a3761e1c4da943
rg_apache_harmony_luni_platform_OSFileSystem.cpp
b682342aec1fbfae8d762e1c8b6ce5b61386a1f5 20-Jan-2011 Brian Carlstrom <bdc@google.com> am 16e3bfbc: am 5a17d9e6: am a1529268: Clarify sslSelect comment

* commit '16e3bfbccdc6d6b3a6fe80d67a15b0970570cb72':
Clarify sslSelect comment
a152926829a78a1c2552d4ee0e6abd21f072a0f8 18-Jan-2011 Brian Carlstrom <bdc@google.com> Clarify sslSelect comment

Forgot to upload with last change

Bug: 3332268
Change-Id: Ibb3cfd9241f9c1a400c6f230a5b0dbb91638e318
ativeCrypto.cpp
c8f6c7ff8b2620b86180adab5de053b1813cc765 20-Jan-2011 Brian Carlstrom <bdc@google.com> am a49f89c2: am 9592e26e: am 3da5a289: Merge "Ensure sslSelect is non-blocking" into honeycomb

* commit 'a49f89c26e1187280a574f605c45babe40671d6e':
Ensure sslSelect is non-blocking
41e32e5a6b091b2f8682f525bae47deb395be4b1 18-Jan-2011 Brian Carlstrom <bdc@google.com> Ensure sslSelect is non-blocking

sslSelect had a comment explaining why its blocking read from a pipe
would never block. However, there is repeatable evidence to the
contrary. Attaching gdb to a process with SSLSocket blocked in both
read and write showed that the writer was waiting in sslSelect trying
to acquire the AppData::mutex while the reader was holding the mutex
and blocked in read(2).

This change makes the file descriptor of the pipe non-blocking.
Callers of sslSelect select already repeat their attempt to handshake,
read, or write as necessary when waking up from select, so now if the
code is woken up by the pipe, it continues regardless of the read
status.

Bug: 3332268
Change-Id: I5fb9024357719dde4712c98f3ee4910acc1e914e
ativeCrypto.cpp
fb85a3a834a5b5d9058686b99991416b0681589e 17-Jan-2011 Elliott Hughes <enh@google.com> Use jniThrowOutOfMemoryError everywhere.

Change-Id: I63f8481bfb760118fb1d6dcbb9d02fdf14678fb3
ava_io_File.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
rg_apache_harmony_luni_util_FloatingPointParser.cpp
rg_apache_harmony_xml_ExpatParser.cpp
8324278fa95470a42c01dc7678c36627d15d5007 17-Jan-2011 Elliott Hughes <enh@google.com> Slight cleanup of the TimeZones code.

Move the allocation down into JNI, since -- despite what the ancient
comment claimed -- it makes no difference. The de-duplication stays
in Java so we don't have to think about overflowing the local reference
table.

I did experiment with moving that down into native code, so we could
avoid the allocations in the first place, but it didn't make any
convincing difference.

Change-Id: I6cad52e83f1300c331cdb95544faa0be1efbfc08
niConstants.cpp
niConstants.h
imeZones.cpp
4ab15b795072beb75debd2e8456010dacb8e6f67 16-Jan-2011 Elliott Hughes <enh@google.com> Include more time zone abbreviations.

Time zone abbreviations are inherently ambiguous. Everywhere has a center, for
example, so there a large number of "CST"s. This code allows us to use
less-common abbreviations (such as "CET" for Central European Time in en_US),
provided they don't conflict with common abbreviations. When there are multiple
identical uncommon abbreviations, we take the first one we come across. (It's
possible we'll have to come back and change this so we only take the globally
unambiguous set, but I'm starting off optimistic.)

Sensible people are already using numeric offsets -- or better still Zulu
time -- so they won't be affected by this.

Bug: http://code.google.com/p/android/issues/detail?id=13420
Change-Id: I90ab9f9c23cd2616d55e470555754eb922cf917f
imeZones.cpp
b2097e76ab184a863838017ac442b744e7bf7c23 11-Jan-2011 Elliott Hughes <enh@google.com> am 66d9e787: am cbe26f42: am c8dde40c: Merge "Get memory for direct byte buffers from the Java heap rather than the native heap." into honeycomb

* commit '66d9e787af999d3c6b26cfd46e10e0750a5f3e6e':
Get memory for direct byte buffers from the Java heap rather than the native heap.
3676bd288bce270a51b1c51f1052b76e83e71412 11-Jan-2011 Elliott Hughes <enh@google.com> Get memory for direct byte buffers from the Java heap rather than the native heap.

Since the removal of tracked external allocations, there's been no accounting
of direct byte buffers. This fixes that, and moves us to a much simpler
situation where the GC is responsible for this memory too. It also means that
we don't need finalizers: now only memory-mapped blocks need finalizers (to call
munmap(3)).

Change-Id: I6b43f74074e496eeb2a36b620af19e4926ceb8cf
rg_apache_harmony_luni_platform_OSMemory.cpp
139545096c077c172af9e8dd7122b56172715ce9 09-Jan-2011 Elliott Hughes <enh@google.com> am 2c9f1e5b: am 90a81872: am 3a9a00ad: Fix getifaddrs(3).

* commit '2c9f1e5b63c624793d01038a2b0c72e853c017df':
Fix getifaddrs(3).
3a9a00ad1f166a8e5ea810099b057522f9aecb48 08-Jan-2011 Elliott Hughes <enh@google.com> Fix getifaddrs(3).

Originally, we pulled out the IFA_ADDRESS messages and used them. That didn't
work with sholes' ppp interface, where we'd report the *destination* address
rather than the local address. We switched to the logical-sounding IFA_LOCAL
messages instead: for IPv4 you always get both IFA_ADDRESS and IFA_LOCAL, and
they're either the same, or you want IFA_LOCAL. It turns out that you don't
get IFA_LOCAL addresses for IPv6 unless they differ from the corresponding
IFA_ADDRESS. So what we have to do is use the IFA_ADDRESS but let IFA_LOCAL
override it, if it appears.

This code was getting way too large, so I've ripped the implementation out of
the header file and given it its own file. I've also switched to UniquePtr
now it exists, and removed a few unnecessary #includes of "LocalArray.h".

I've also added a unit test to help guard against breaking this again.

Bug: http://code.google.com/p/android/issues/detail?id=13784
Change-Id: I5a7d29b8e9bf652160eca043802363feb91421a2
ativeCrypto.cpp
faddrs-android.cpp
faddrs-android.h
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
ub.mk
c3d30bfb532fc1e609a67a324d6bfb9776f88778 08-Jan-2011 Elliott Hughes <enh@google.com> Tell editors that these are Makefiles (or fragments thereof).

Change-Id: I0c5e29ac750b9605b1e8f823d6998d31a933b7a4
ub.mk
27c11c7c7b1fc023cb6464bd551aceef300e39b6 06-Jan-2011 Elliott Hughes <enh@google.com> Remove the last vestiges of the external allocation cruft.

"Missed a bit". The underlying code has gone (though the
interface is still there for now, backed by a do-nothing implementation).

Bug: 2604080
Change-Id: Iba64d1c193819560423285334dc08015fbc105b1
niConstants.cpp
niConstants.h
rg_apache_harmony_luni_platform_OSMemory.cpp
b8f9285f7e67812c435bc429e07683d6b9039b0a 22-Dec-2010 Jesse Wilson <jessewilson@google.com> Revert "Remove inline natives for an unused performance test." (libcore)

Change-Id: I7ea69f84c008c5bdbdf8af6134fb81d80f0a958e
egister.cpp
2c549add8659c3f53a4b7306d3a01262434383e9 22-Dec-2010 Jesse Wilson <jessewilson@google.com> Remove native targets for unused performance tests.

Change-Id: Ia61172cd52de031290a811c3ec73edb929f40c10
egister.cpp
1ad1fe9aa7fa705ce4441e90f46cf790ad0f758a 22-Dec-2010 Ben Cheng <bccheng@android.com> Revert "Remove native targets for unused performance tests."

This reverts commit 272a383283a974a4c32a94469b8a8b021d93a480.
egister.cpp
272a383283a974a4c32a94469b8a8b021d93a480 21-Dec-2010 Jesse Wilson <jessewilson@google.com> Remove native targets for unused performance tests.

See also change I5a252e31.

Change-Id: I3880a81f1f7e90247ce12860b5a2f597037123a7
egister.cpp
65f61b75a2429a619299e1050a1f605e7bd4f3f2 17-Dec-2010 Elliott Hughes <enh@google.com> Use ftruncate64.

This fixes the last (known) 32-bit file offset bug in libcore.

Bug: 3107933
Change-Id: Ic13b719092c529a2533268d79ad92e3bb683f4ac
rg_apache_harmony_luni_platform_OSFileSystem.cpp
d7486d534a580b745c20f7f63401f8595c9ced42 17-Dec-2010 Elliott Hughes <enh@google.com> Fix File.length for sparse files.

Bug: 3219696
Change-Id: I74534471dcbcc216f183e72dff8d3f9dc5c7b546
ava_io_File.cpp
6523532145f06d8c208ed7a9374d3ab6d8132e66 14-Dec-2010 Elliott Hughes <enh@google.com> More serialization performance improvements.

Cache more work and don't use a Map of Integers for a range of
integers that's defined to be dense, just because they don't start at 0.

Bug: http://code.google.com/p/android/issues/detail?id=13138
Change-Id: Ie73d0bb946892f86165fca78da10bbcf64322570
egister.cpp
ava_io_ObjectInputStream.cpp
ava_io_ObjectStreamClass.cpp
ub.mk
1294cc5f777bce3fbc88e65d8c67cdf9b8d433c1 10-Dec-2010 Stan Chesnutt <chesnutt@google.com> DatagramSocket.setNetworkInterface() allows a socket to be bound to a
network interface using the SO_BINDTODEVICE socket option.

Change-Id: I9598981f0d8f633de0b591db858960b1fea2e4e8
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
975dc421bdf9f207ed88b3fbedbba558f0f62c3c 10-Dec-2010 Stan Chesnutt <chesnutt@google.com> Adds new RawSocket class (and underlying jni implementation). This is a
utility class for an experimental Java implementation of dhcp. The client
DHCP implementation needs to construct, send, receive, and parse raw L2
packets before the network interface is configured with an IP address. Current
Java networking classes do not work with unconfigured network interfaces.

Change-Id: I4dd0133868da5b84bd2a471c33173d4c056c34e8
egister.cpp
ibcore_net_RawSocket.cpp
ub.mk
fa5cdaa79ff491dd5c05d72baad27f931cf2d08e 08-Dec-2010 Elliott Hughes <enh@google.com> Make Deflater.cpp more like Inflater.cpp.

I didn't have a bug as motivation for this (Z_NEED_DICT isn't relevant
for deflation), but I want the deflation code to look at least as sane
as the inflation code. This still passes our tests, boots, and seems
to work okay. I think the "!= Z_FINISH" test was just a premature
optimization rather than anything meaningful.

Change-Id: I8db567605712a079aaf9e18cf8836c8d5673edb1
ava_util_zip_Deflater.cpp
b7f0ced490fa5c5ad389c58b8584def84391f591 08-Dec-2010 Elliott Hughes <enh@google.com> Remove an unnecessary check and clarify some weird code in Deflater.cpp.

More java.util.zip cleanup. We throw the IllegalStateException in Java.
Strictly, that's racy, and we might want to move all this checking into
toNativeZipStream, but we haven't made such arrangements in general,
and I'll do that as a follow-up if desired; this patch just ensures that
we're consistent.

Change-Id: I86e47461117b3747e6fad9fe344cd68029bb78b1
ava_util_zip_Deflater.cpp
f275cbd60bd57e7bccefb521685c2f05c0dafbb4 08-Dec-2010 Elliott Hughes <enh@google.com> Minor cleanup of java.lang.Character.

Change-Id: Ib010ae1e125583738ac4985c94f65d4e223db41b
ava_lang_Character.cpp
2ff37ac3a15fde7d47cd8cf3b8ee6946dd24eeb3 07-Dec-2010 Elliott Hughes <enh@google.com> Targeted backport of a java.util.Inflater fix.

This has been causing trouble for Gmail. The original fix cleaned up large
parts of the java.util.zip code; this just contains the active ingredient.

(I've excluded the error-handling change to this same function because
that hasn't been tested in the real world yet.)

Bug: 3220923
Change-Id: Ib4bc585a45061ef55c29f09f2bd650c772aab64d
ava_util_zip_Inflater.cpp
7bf1b45888a5e48919abc720942be648ea3c6b1a 03-Dec-2010 Elliott Hughes <enh@google.com> Merge "Slight cleanup of java.util.zip code, plus a bug fix." into dalvik-dev
2d9c5fa8ce0182cd8c14736241b709fd50cab6f8 23-Nov-2010 Elliott Hughes <enh@google.com> Slight cleanup of java.util.zip code, plus a bug fix.

The key fix is switching to zstream's next_in and next_out fields (the
pointers into the input and output buffers) rather than relying on the
integer "accounting" fields. If turns out in the Z_NEED_DICT case that
the accounting goes slightly awry. (We shouldn't have been using the
accounting anyway, because we were silently coercing longs to ints.)
The new code is simpler, clearer, and doesn't need a special case for
Z_NEED_DICT at all.

I've also removed yet another hand-written UTF-8 encoder, made Inflater
throw ArrayIndexOutOfBoundsExceptions with useful detail messages (factored
out into Arrays so we can make this change more widely), and
rewritten the Inflater and Deflater documentation.

The unit test reproduces the problem (and tests as many other cases as
it can too). Critical for testing this bug is that we needed to limit
the size of the input buffer so that zlib has to ask us for more input.

Bug: 3220923
Change-Id: I39e5456620eaa7f75d12d885db279f009ee3e8ef
ava_util_zip_Deflater.cpp
ava_util_zip_Inflater.cpp
ip.h
025bf7708b496b09f330e794536589c06e35c09c 01-Dec-2010 Elliott Hughes <enh@google.com> Fix IoUtils.close in cases where close(2) fails.

You can't call JNI functions with an exception pending.

Bug: 3222087
Change-Id: If949d3a9b2335928d8d30f4d0e78b74067cddaba
ibcore_io_IoUtils.cpp
4ae3fd787741bfe1b808f447dcb0785250024119 19-Nov-2010 Brian Carlstrom <bdc@google.com> Elliptic Crypto support for OpenSSLSocketImpl

Summary:
- Enable Elliptic Crypto support for OpenSSL based SSLSocket instances
- More RI compliant usage of key types, client auth types, and server auth types
- Steps toward TLS_EMPTY_RENEGOTIATION_INFO_SCSV support, currently test updates

Details:

Elliptic Curve changes

CipherSuite updates for EC
- Adding KEY_EXCHANGE_EC* and corresponding CipherSuites Updated
isAnonymous, getKeyType (now renamed getServerKeyType) to handle
new EC cases. Added new getAuthType for use by
checkServerTrusted callers.
- Restructured code to handle two SUITES_BY_CODE_* arrays
- Remove KEY_EXCHANGE_DH_* definitions which unused because the
corresponding CipherSuites were previously disabled.
- Changed AES CipherSuites definitions to use "_CBC" to match other definitions.
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/CipherSuite.java

openssl EC
- NativeCrypto now registers TLS_EC_* cipher suites and has update default list
- Improved auth type arguments to checkClientTrusted/checkServerTrusted
- NativeCrypto support for emphemeral EC keys
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

non-openssl SSL/TLS cleanups

- cleanup around code trying to cope with DiffieHellman vs DH since either should work.
- changed client to use new CipherSuite.getAuthType shared with NativeCrypto implementation
- changed server to use CipherSuite.getKeyType
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/ClientHandshakeImpl.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/HandshakeProtocol.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/KeyManagerImpl.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/ServerHandshakeImpl.java

Consolidate CertificateRequestType code into CipherSuite so that its
shared between java and openssl implementations. This includes the
KEY_TYPE_ string constants, TLS_CT_* byte constants and the 'String
keyType(byte)' (now renamed getClientKeyType) code that depends on them.

luni/src/main/java/org/apache/harmony/xnet/provider/jsse/CertificateRequest.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/CipherSuite.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/ClientHandshakeImpl.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/NativeCrypto.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLServerSocketImpl.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/ServerHandshakeImpl.java

Tests

Differentiate between supported list of cipher suites openssl-based
SSLSocket and SSLEngine based, since the SSLEngine code does not support EC.

luni/src/test/java/libcore/javax/net/ssl/SSLEngineTest.java
luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java

Added testing for expected default cipher suites. Before we just ensured the values were valid.
luni/src/test/java/libcore/javax/net/ssl/SSLSocketFactoryTest.java
support/src/test/java/libcore/java/security/StandardNames.java

Updated to handle new EC cipher suites codes. Added test for new getClientKeyType.
luni/src/test/java/org/apache/harmony/xnet/provider/jsse/CipherSuiteTest.java

Better use of "standard names" particularly to correctly deal with
the subtle differences between key types, client auth types, and
server auth types. TestKeyManager and TestTrustManager now verify
the values they are passed are acceptable.

support/src/test/java/libcore/java/security/StandardNames.java
support/src/test/java/libcore/javax/net/ssl/TestKeyManager.java
support/src/test/java/libcore/javax/net/ssl/TestTrustManager.java

Changed to timeout after 30 seconds and to log to reveal both client and server issues.
support/src/test/java/libcore/javax/net/ssl/TestSSLSocketPair.java

Bug: 3058375
Change-Id: I14d1d0285d591c99cc211324f3595a5be682cab1
ativeCrypto.cpp
1ad66855723b45a66c083af8acea9849d521ee8f 18-Nov-2010 Olivier Bailly <olivier@google.com> am 26e0cc02: Fix pointer vs integer mismatch in several return statements.

* commit '26e0cc02e3ddd5e77e5c99984e7b50de6f5a4aad':
Fix pointer vs integer mismatch in several return statements.
26e0cc02e3ddd5e77e5c99984e7b50de6f5a4aad 17-Nov-2010 Olivier Bailly <olivier@google.com> Fix pointer vs integer mismatch in several return statements.

Change-Id: Id2a754cf0a58d55e38c72e998920f219c5342d3d
ativeCrypto.cpp
ava_lang_Character.cpp
rg_apache_harmony_xml_ExpatParser.cpp
3825a7f63f6bf49d55e742f19f9b76cc9adc5e6f 05-Nov-2010 Brian Carlstrom <bdc@google.com> Propagate pending exception from cert_client_cb

There can be a pending exception in the cert_client_cb if the server
certificate failed verification and the server requested a client
certificate. Since the handshake is going to be terminated, just
return from client_cert_cb immediately indicating no client cert will be
provided, allowing the existing exception to propagate.

Bug: 3149826
git cherry-pick 30a77f316c03906ca59d6ebe5b6c7f0ff734aadb

Bug: 3184701
Change-Id: I58b038267f66d6b5f80e9f3d81ff1c0f8052ef27
ativeCrypto.cpp
fbc39aedfce3521b61a8cdaa4e6170ea87d1aad9 16-Nov-2010 Elliott Hughes <enh@google.com> Merge "Switch ObjectInputStream over to reflection." into dalvik-dev
de8ebcab83d48d4edc28fced9d0a8382f1ef1436 16-Nov-2010 Brian Carlstrom <bdc@google.com> am 8a720cce: TrustManager should include PrivateKeyEntry CAs, OpenSSLSocketImpl close fix, and debugging improvements

* commit '8a720cceee7ce319d647738dfeda3f302879f370':
TrustManager should include PrivateKeyEntry CAs, OpenSSLSocketImpl close fix, and debugging improvements
8a720cceee7ce319d647738dfeda3f302879f370 16-Nov-2010 Brian Carlstrom <bdc@google.com> TrustManager should include PrivateKeyEntry CAs, OpenSSLSocketImpl close fix, and debugging improvements

Revert to older behavior of creating TrustAnchors from both
PrivateKeyEntry and TrustedCertificateEntry values from the
KeyStore. Added tests to better ensure this slighlt different
behavior from PKIXParameters. Also create the acceptedIssuers
proactively since the real memory cost is the X509Certificates
which are already found in the params.

luni/src/main/java/org/apache/harmony/xnet/provider/jsse/TrustManagerImpl.java
luni/src/test/java/libcore/javax/net/ssl/TrustManagerFactoryTest.java
luni/src/test/java/libcore/java/security/cert/PKIXParametersTest.java

Don't just free native state on issue with startHandshake, close
the SSLSocket. While the former addressed a CloseGuard issue, the
latter make sure that checkOpen throws SocketExceptions and we don't
leak a NullPointerException from NativeCrypto.

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

Debugging improvements including minor refinements to recently
added NativeCrypto logging, more verbose TestKeyStore.dump output,
and a new TestTrustManager proxy class for logging X509TrustManager
behavior.

luni/src/main/native/NativeCrypto.cpp
support/src/test/java/libcore/java/security/TestKeyStore.java
support/src/test/java/libcore/javax/net/ssl/TestTrustManager.java

Change-Id: I317e1ca34d8e20c77e5cb9c5a5a58cb4ae98d829
ativeCrypto.cpp
b854a55df2475a4e9acc96c271cd88da7559f019 16-Nov-2010 Elliott Hughes <enh@google.com> Switch ObjectInputStream over to reflection.

Reduces the amount of (native) code, and improves perfromance.

We can't entirely remove the native code this time because we
rely on the ability to create an instance of one class while
calling a constructor from another, which we can't do via
reflection.

Bug: 3158451
Change-Id: I896e23a6ffd7b7f1a016ff9d30cea0b2b9df7574
ava_io_ObjectInputStream.cpp
7d0d108593ac30e19b8f2a5a157f697f3f46c041 13-Nov-2010 Elliott Hughes <enh@google.com> Switch ObjectOutputStream over to reflection.

Reduces the amount of (native) code, and improves performance. I've also
improved some of the detail messages from the reflection code (to help in
my own debugging).

I'll do ObjectInputStream next...

Bug: 3158451
Change-Id: Icf06a17507f9d011d120f2d704e084a103a400c7
egister.cpp
ava_io_ObjectOutputStream.cpp
ub.mk
dabcbd61269aa4de2cdff91ac524ed2a0adccdfe 11-Nov-2010 Jesse Wilson <jessewilson@google.com> Fix an Expat comment to make it clear that the specified encoding is used.

Change-Id: Ia8662bad784784c8ddd2c5c9d904f9e050a5fded
http://b/2719016
rg_apache_harmony_xml_ExpatParser.cpp
6f4fd32bd9e838240c25cfc4fa0e3f47dc0d5da3 10-Nov-2010 Brian Carlstrom <bdc@google.com> resolved conflicts for merge of eb21e9c0 to dalvik-dev

Change-Id: Ibee64a66bc9a8064114544e52a09aaa661a589ad
3900e2685046fa78f9f9e5a07a7db5c4eecfbd1d 10-Nov-2010 Brian Carlstrom <bdc@google.com> Move from MAX/MIN to std::max/std::min

Change-Id: I2296a39ab1fb9c02575702476170a2f68d7de02f
ativeCrypto.cpp
9251b528199e31658b48d90e8944267e780bd863 10-Nov-2010 Brian Carlstrom <bdc@google.com> am a667cc22: Merge "Add WITH_JNI_TRACE_DATA to allow tracing of SSLSocket data"

* commit 'a667cc22e79a25d0aebdfe28b30ee9e81289c85a':
Add WITH_JNI_TRACE_DATA to allow tracing of SSLSocket data
0cbd33d4f85c0407faaad7e1d26294aa1f5d683d 10-Nov-2010 Brian Carlstrom <bdc@google.com> Add WITH_JNI_TRACE_DATA to allow tracing of SSLSocket data

Bug: 3167208
Change-Id: I99f110d5418901ac02589dfa629cd26605da7990
ativeCrypto.cpp
298dad0ae05e97287b566de9bc9f8134b3b74666 09-Nov-2010 Elliott Hughes <enh@google.com> Document that I've investigated a TODO.

Nothing to be done, so document that the API is broken by design.

Bug: 2281992
Change-Id: Ia26f25fe3ed3364092a378d7d7544f4d81b982f7
ava_io_File.cpp
744af09bbda66a2b918a2d6b82abc8b72790f5d8 09-Nov-2010 Elliott Hughes <enh@google.com> Merge "Rewrite File.getCanonicalPath." into dalvik-dev
95101d3d5a3417755c88fded1600e039fb363019 05-Nov-2010 Elliott Hughes <enh@google.com> Rewrite File.getCanonicalPath.

My original plan was to just rely on the fixed realpath(3), but it turns out
that Java's behavior is quite different from the C library's in cases where
path elements don't exist. I also wasn't particularly excited about introducing
a fixed-length buffer. To that end, I've added a native implementation of
getCanonicalPath.

I've also improved the getAbsolutePath and getCanonicalPath documentation.

This patch also makes File.absolutePath transient, a regression in gingerbread
which uselessly bloated File's serialized form.

Bug: 2281992
Change-Id: Iff94eee07fe574251c1188b2b2eb71f585c81c6a
ava_io_File.cpp
eadlink.cpp
eadlink.h
ealpath.cpp
ub.mk
30a77f316c03906ca59d6ebe5b6c7f0ff734aadb 05-Nov-2010 Brian Carlstrom <bdc@google.com> Propagate pending exception from cert_client_cb

There can be a pending exception in the cert_client_cb if the server
certificate failed verification and the server requested a client
certificate. Since the handshake is going to be terminated, just
return from client_cert_cb immediately indicating no client cert will be
provided, allowing the existing exception to propagate.

Bug: 3149826
Change-Id: If95db36fc296ec9945c052a6c839e70dcd083d7b
ativeCrypto.cpp
0d93c38cc3c7a5001aece8a18cafc6d1fc7551f3 04-Nov-2010 Elliott Hughes <enh@google.com> Add a public @hide InetAddress.isNumeric.

Some frameworks/base callers want to know whether they can call
getAllByName/getByName without incurring a DNS lookup. Rather than have them
write their own JNI to do the AI_NUMERICHOST getaddrinfo(3) call, let's just
offer them ours.

Why don't I fully expose getaddrinfo(3)? Because it doesn't map to Java API
very well, and no-one needs that yet. So for now, let's take the easy way out.

Also improve some misleading javadoc.

Bug: 3073384
Change-Id: Ia1990313306254598a4e1480cae356f68ceaaf22
ava_net_InetAddress.cpp
4d55cfd185778f5ad1155406c634191415ddcb16 03-Nov-2010 Elliott Hughes <enh@google.com> Merge "Let ICU extract country codes from locales." into dalvik-dev
7ff7010c01a090dcbf992c7223fbc8fde54b3018 03-Nov-2010 Elliott Hughes <enh@google.com> Let ICU extract country codes from locales.

This wasn't a bug, but it was ugly and unnecessary code.

Bug: 3157134
Change-Id: Id407e1632c5bd1e1e150e3827598d1a93865314e
CU.cpp
a82c60e73ddfc3dd6dc694385ddaf720e70b9427 03-Nov-2010 Brian Carlstrom <bdc@google.com> am 7847d338: Move NativeCrypto dependencies on openssl internals to jsse.patch

* commit '7847d338d8a8dea7d01fa72c948d4138e5243e0a':
Move NativeCrypto dependencies on openssl internals to jsse.patch
7847d338d8a8dea7d01fa72c948d4138e5243e0a 03-Nov-2010 Brian Carlstrom <bdc@google.com> Move NativeCrypto dependencies on openssl internals to jsse.patch

Change-Id: I97d328ddacc5d234f6a5b426123a9e7925f2b382
ativeCrypto.cpp
b5bde2fd72189192b52e726a2d606d70c3c8a34b 02-Nov-2010 Elliott Hughes <enh@google.com> More shift removal.

A few more customers for OSMemory's peek/poke abilities, and a bunch of shifts
that should have been multiplications.

Bug: 3032515
Change-Id: Ic518fd8f7565d67523ea10e3f5afca3a9c8501b8
rg_apache_harmony_xml_ExpatParser.cpp
fbbae9740d65620b417b85576aa0d6c7daf4ba34 28-Oct-2010 Elliott Hughes <enh@google.com> Improve UnknownHostException detail messages.

Bug: 2542766
Change-Id: I7de3c8326508294fb5d9f17f65b3f36c8fa856fa
ava_net_InetAddress.cpp
aba7ce6b0e9a20f5df480d2f187297a624d4c633 19-Oct-2010 Elliott Hughes <enh@google.com> Add and use STATIC_ASSERT for compile-time asserts, and remove some 32-bit limits.

This started with the question "are the fields in struct statfs really 64-bit?",
but grew a bit. I'll need ftruncate64 in bionic before we can kill
offsetTooLarge completely.

Change-Id: Ia1dcda49e2c93c3cb0f9efe61a70c667c1415bee
ativeBN.cpp
ava_io_File.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
9efa300c26865520498c0ed132ff9ebe499e7d84 18-Oct-2010 Elliott Hughes <enh@google.com> Remove more tabs.

Missed these in the big cleanup because they didn't look like code we were maintaining. The
xalan/xpath/et cetera stuff is all still tab-filled, and there are a few package.html files
too (for which I've raised http://b/3107546).

Change-Id: I7ad956f3c410701fec13731c9affbcedd24a4a9a
ativeConverter.cpp
bigint.cpp
1f07ea29bc2d334c55c16227582a7795b8c117c1 18-Oct-2010 Elliott Hughes <enh@google.com> Give every NumberFormatException a useful detail message.

Bug: 3095335
Change-Id: If0409c6328c2fa2a35e5027e20b4786fe87e693b
rg_apache_harmony_luni_util_FloatingPointParser.cpp
cfa6ffebf3a63db7a125c4d9abe7e661fac5cc1f 04-Oct-2010 Elliott Hughes <enh@google.com> More package-jiggling for our ICU-related code.

Bug: 3045778
Change-Id: Ia9b29b28512deca6bd9dad806468238f8db2a8b9
ativeCollation.cpp
egister.cpp
c27a366a89e470690e99374b15270e7b9169ade1 02-Oct-2010 Elliott Hughes <enh@google.com> More icu4jni reshuffling.

Bug: 3045778
Change-Id: Iafb367f97d1fb169c6106adad0525cfcc0e10f25
CU.cpp
niConstants.cpp
ativeBreakIterator.cpp
ativeConverter.cpp
ativeDecimalFormat.cpp
egister.cpp
8f898c05a260de523d783877d31ec4d9e62a8e9d 02-Oct-2010 Elliott Hughes <enh@google.com> Merge "Start moving icu4jni classes into libcore.icu." into dalvik-dev
82281cde1eaec8f299cc7d4f383f716cf9e6fe71 02-Oct-2010 Brian Carlstrom <bdc@google.com> am dc825fef: am 9583c700: am cd68630d: Merge "SSL* AppData should not hold onto JNI global references" into gingerbread

Merge commit 'dc825fef1519d4a65abf374e31d985cb2faf9d4a' into dalvik-dev

* commit 'dc825fef1519d4a65abf374e31d985cb2faf9d4a':
SSL* AppData should not hold onto JNI global references
644ccb2c3d69ee6f3a69996ca7651b84d409fe41 02-Oct-2010 Elliott Hughes <enh@google.com> Start moving icu4jni classes into libcore.icu.

Bug: 3045778
Change-Id: I8d87c31d36b441a69e6d3259e700b7133dfdc803
niConstants.cpp
ativeConverter.cpp
dc825fef1519d4a65abf374e31d985cb2faf9d4a 02-Oct-2010 Brian Carlstrom <bdc@google.com> am 9583c700: am cd68630d: Merge "SSL* AppData should not hold onto JNI global references" into gingerbread

Merge commit '9583c70042da95219941b430d51a9994334e49f0'

* commit '9583c70042da95219941b430d51a9994334e49f0':
SSL* AppData should not hold onto JNI global references
265832468be5927029ac6473022e261bbc97ce71 01-Oct-2010 Elliott Hughes <enh@google.com> Work around using "struct group_req" in a 32-bit binary talking to a 64-bit kernel.

Fixes all the MulticastSocket tests in host mode.

Bug: 3035987
Change-Id: Ie21ea2c5dffb3f9da3ff85bb7a452afab8d188d8
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
df9c090e85c4d052cdd17b5f981819be86a56737 01-Oct-2010 Brian Carlstrom <bdc@google.com> SSL* AppData should not hold onto JNI global references

Summary:

NativeCrypto.SSL_do_handshake stored JNI global references in its
AppData instance for use in upcalls from OpenSSL that invoke Java
callbacks. However, one of the references was to the
SSLHandshakeCallbacks which in the common case of OpenSSLSocketImpl is
the OpenSSLSocketImpl instance itself. This meant that if code dropped
the OpenSSLSocketImpl without closing (such as Apache HTTP Client),
the instances would never be collected, and perhaps more importantly,
file descriptors would not be closed.

The fix is to pass in the objects required during a callback in all
downcalls to SSL_* methods that could result in a callback and clear
them on return. The existing code already did this for the JNIEnv*, so
that code was expanded to handle setting the jobjects as well.

Details:

In the native code used to extract the FileDescriptor object from a
Socket on the call to NativeCrypto.SSL_do_handshake. However, since we
need this for every read and write operations, we now do this in Java
to avoid the repeated overhead. NativeCrypto.SSL_do_handshake now
takes a FileDescriptor, which it extracted from the Socket the
convenience function using NativeCrypto.getFileDescriptor(Socket)

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

In addition to tracking changes to pass FileDescriptor and
SSLHandshakeCallbacks, removed final uses of getFieldId since the
code no longer needs to extract FileDescriptors itself

luni/src/main/native/NativeCrypto.cpp

The Socket field used to be non-null in the wrapper case and null in
the non-wrapper case. To simplify things a bit, "socket == this" in
the non-wrapper case. The socket field is now also final and joined by
a final FileDescriptor field.

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

Updated NativeCryptoTest to track FileDescriptor and
SSLHandshakeCallbacks by expanding the Hooks.afterHandshake to provide
them. Also changed to add a 5 second timeout to many test cases.

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

Bug: 2989218

Change-Id: Iccef92b59475f3c1929e990893579493ece9d442
ativeCrypto.cpp
2f85e921e4753cf4e87696014754278eda5f95ef 01-Oct-2010 Elliott Hughes <enh@google.com> Lose our inline assembler for bswap_16 and bswap_32 now it's pushed down into bionic.

(The downside is that we need to rely on bionic not regressing... We need a
performance continuous build.)

Bug: 2935622
Change-Id: Iafe3ba0d7adbc3fcdce4624ac7490d92afa99800
rg_apache_harmony_luni_platform_OSMemory.cpp
45b43c20d8a5c217001cd5ec5bb342533b5b72eb 01-Oct-2010 Elliott Hughes <enh@google.com> Use fdatasync(2) now we have it in bionic.

Bug: 2667481
Change-Id: I3ca7031efe3301b08fc4f16c8c9b2b38d91107f5
rg_apache_harmony_luni_platform_OSFileSystem.cpp
4865d2823056d4171cefabf33973ccf98060d87b 30-Sep-2010 Elliott Hughes <enh@google.com> am 72b26111: am 56b04b03: Fix IP_MULTICAST_IF getsockopt.

Merge commit '72b261119f0c3a50357decb48ef849c259c1ad08'

* commit '72b261119f0c3a50357decb48ef849c259c1ad08':
Fix IP_MULTICAST_IF getsockopt.
56b04b03d8fcf7151d3124f472e27e2b8eb3dfe8 29-Sep-2010 Elliott Hughes <enh@google.com> Fix IP_MULTICAST_IF getsockopt.

Also clean out test cruft so we can run on the RI, and remove
SecurityManager cruft so we can run more tests. Our failures
now match the RI's (but I'm not planning on fixing the tests
right now, nor have I checked the upstream tests).

Bug: 3045865
Change-Id: I326fff9753faa88eacb20a04ffd2f2e84e76259a
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
a3160c78b635408fc9979e2984a377a3cc5aac04 27-Sep-2010 Elliott Hughes <enh@google.com> am 793d8b21: am 3c6ca778: Don\'t wrap select(2) in TEMP_FAILURE_RETRY.

Merge commit '793d8b21ea137aeca9c3e4317605a4110d7dbfd0'

* commit '793d8b21ea137aeca9c3e4317605a4110d7dbfd0':
Don't wrap select(2) in TEMP_FAILURE_RETRY.
3c6ca77845ce5f0e80c4dc49617601918023c1ed 27-Sep-2010 Elliott Hughes <enh@google.com> Don't wrap select(2) in TEMP_FAILURE_RETRY.

Luckily, since the caller has to cope with us saying "we're not connected yet,
try again", we can just go that route.

I've also added another plausible possible exception to one of the tests, seen
once when testing on a host dalvikvm.

Bug: 3022824
Change-Id: Ia155f86f9f7b9b0a54e58c55f668faaebcbda55e
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
90f90c49d653e4d843b1de2f76627cf1e68597ea 25-Sep-2010 Elliott Hughes <enh@google.com> am 69b59f75: am 91575314: Throw SocketTimeoutException rather than SocketException if connect times out.

Merge commit '69b59f75f21b2e1f0a633a0dfc430e2cd6e83ad1'

* commit '69b59f75f21b2e1f0a633a0dfc430e2cd6e83ad1':
Throw SocketTimeoutException rather than SocketException if connect times out.
9f50955d692b7a2617ad10ab2da9fbfe40db1bd6 24-Sep-2010 Brian Carlstrom <bdc@google.com> Should only use "rev" instructions if __ARM_ARCH__ >= 6

Change-Id: If1a8724561354877275784461a84b4732d2a32ca
rg_apache_harmony_luni_platform_OSMemory.cpp
915753146bdd4551fe2aa2655a40adf58d7aafa6 24-Sep-2010 Elliott Hughes <enh@google.com> Throw SocketTimeoutException rather than SocketException if connect times out.

Bug: 3032900
Change-Id: I5da70fc55f2366a504b2492f2bc7f2269a57ef14
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
4c2d6f8a2553462415da6331113c252e958a0f3e 22-Sep-2010 Brian Carlstrom <bdc@google.com> Merge commit '3ca8646e36c5fb78141c8a524e22c6721d3c79d3' into dalvik-dev

Change-Id: I9679f9870bba9a34b9b983dfbaadec28476aca60
3ca8646e36c5fb78141c8a524e22c6721d3c79d3 23-Sep-2010 Mike Lockwood <lockwood@android.com> Squashed commit of three reverts related to permissions of new files and directories:

Revert "Create new files with permissions 0666 instead of 0777"

This reverts commit 4ea56d66e19d1450960ba26f60ca61a6804a3ba7.

Revert "Fix random permissions being set for new files."

This reverts commit 787bd9e6c46da7e229db6450d94409d2c6da6c2b.

Revert "Remove restricted permissions in file and directory creation"

This reverts commit 9b211124283bfb808e902b91da4df3e291d9bb6c.

BUG: 3028408
ava_io_File.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
dd1fb4b885b182e73c337aec1ecad1fb0673374d 22-Sep-2010 Brian Carlstrom <bdc@google.com> am dbdfcaf7: am 127c978e: am f62b503f: NativeCrypto_EVP_PKEY_new_RSA native NULL pointer reference WITH_JNI_TRACE

Merge commit 'dbdfcaf70aa5216fb008b1981bef646bc9c76643' into dalvik-dev

* commit 'dbdfcaf70aa5216fb008b1981bef646bc9c76643':
NativeCrypto_EVP_PKEY_new_RSA native NULL pointer reference WITH_JNI_TRACE
f62b503fea825444a698c3c2ddaabc6dabb089f5 22-Sep-2010 Brian Carlstrom <bdc@google.com> NativeCrypto_EVP_PKEY_new_RSA native NULL pointer reference WITH_JNI_TRACE

Device would not boot when WITH_JNI_TRACE was enabled because
RSA_check_key was called with NULL arguments.

Change-Id: I766cc027bab3f05f6b4956120002c572a5791af3
ativeCrypto.cpp
2550478eb3ff8283ebac6ba2a683fd7bbb23e3ee 22-Sep-2010 Brian Carlstrom <bdc@google.com> am 7452795a: am f8f14c30: am 1be19cf6: Tracking external/bouncycastle OpenSSLDigest

Merge commit '7452795a3d40cac126b21f85316b36b035950371' into dalvik-dev

* commit '7452795a3d40cac126b21f85316b36b035950371':
Tracking external/bouncycastle OpenSSLDigest
1be19cf6a06834e97608dffd87c30d604b02196a 22-Sep-2010 Brian Carlstrom <bdc@google.com> Tracking external/bouncycastle OpenSSLDigest

Making OpenSSLMessageDigestJDK final to match OpenSSLDigest version
Fixing WITH_JNI_TRACE used for debugging OpenSSLDigest

Bug: 3024499
Change-Id: I919749348e531d074a25e16ab13315cede4f88e5
ativeCrypto.cpp
6ed1d582f2ac1c70cb04005ef420289a114c872c 22-Sep-2010 Elliott Hughes <enh@google.com> Fix new FileInputStream(".") to throw.

Unlike Posix, Java disallows opening a directory for _reading_ too.

Bug: 2224954
Change-Id: I1414978c4fc530378937a250dea03aa647c6c1ed
rg_apache_harmony_luni_platform_OSFileSystem.cpp
55c33125cee1d701780a93155c2f0f8261d8790b 21-Sep-2010 Brian Carlstrom <bdc@google.com> am 4440425d: am 1f3ade1d: am 84f16126: Make SSL network I/O interruptible

Merge commit '4440425d12b528a9ff9a7a51a40029898d7c1148' into dalvik-dev

* commit '4440425d12b528a9ff9a7a51a40029898d7c1148':
Make SSL network I/O interruptible
84f161268b8ae93a9046c40ca8381aa92148f2f6 21-Sep-2010 Brian Carlstrom <bdc@google.com> Make SSL network I/O interruptible

- Changed NativeCrypto code to hold onto java.io.FileDescriptor so it
can see observe when another thread calls Socket.close and sets the
FileDescriptor's fd to -1. Changed AppData::setEnv to check
NetFd::isClosed, it was already being used before each SSL I/O
operation.

- Changed sslSelect to no longer take an int fd, it now uses the
AppData to get access the FileDescriptor. Within sslSelect, the
select call is now protected with AsynchronousSocketCloseMonitor.
The select call is now retried on EINTR, checking for socket close
similar to NET_FAILURE_RETRY. sslSelect now returns
THROWN_SOCKETEXCEPTION to indicate that NetFd::isClosed has already
thrown.

- sslRead and sslWrite now similarly returns THROWN_SOCKETEXCEPTION to
indicate that Net::isClosed detected a closed FileDescriptor.

luni/src/main/native/NativeCrypto.cpp

Moved NetFd from OSNetworkSystem.cpp to new NetFd.h for reuse by NativeCrypto

luni/src/main/native/NetFd.h
luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp

Added test of 4 Socket/SSLSocket interrupt cases

1.) read Socket / close Socket (redundant with AsynchronousCloseExceptionTest)
2.) read Socket / close SSLSocket
3.) read SSLSocket / close Socket
4.) read SSLSocket / close SSLSocket

luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java

Bug: 2973020
Change-Id: I9037738dd1d1c09c03c99e3403e086366aa25109
ativeCrypto.cpp
etFd.h
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
8fbc397fc09158bee0bc0cb231c609c4c6e9fc15 18-Sep-2010 Elliott Hughes <enh@google.com> Optimize non-direct (heap) buffer bulk put.

I've also factored out the bounds checking, even though the JIT can't yet
inline it back. I'm unwilling to duplicate all that code again.

This patch also fixes bugs in the previous checkin relating to offsets
and positions. In real life (and, seemingly, in all our tests) these tend
to be 0, making it rare that anyone trips over these bugs. (The first nio
change I made was fixing just such a bug.) I've improved the test I added
last time so that it covers more of these cases.

Here are the "after" performance figures for heap buffer bulk copies:

CharBuffer_getCharArray 5797
CharBuffer_putCharArray 5818
DoubleBuffer_getDoubleArray 13053
DoubleBuffer_putDoubleArray 13026
FloatBuffer_getFloatArray 8216
FloatBuffer_putFloatArray 8283
IntBuffer_getIntArray 8253
IntBuffer_putIntArray 8371
LongBuffer_getLongArray 13053
LongBuffer_putLongArray 13020
ShortBuffer_getShortArray 5796
ShortBuffer_putShortArray 5864

This compares well with with direct buffer performance (just gets shown here):

CharBuffer_getCharArray 4412
DoubleBuffer_getDoubleArray 11594
FloatBuffer_getFloatArray 6787
IntBuffer_getIntArray 6791
LongBuffer_getLongArray 11672
ShortBuffer_getShortArray 4430

Bug: 2985452
Change-Id: I37307f9b304c87a87af5313790444dcdf6174ff1
rg_apache_harmony_luni_platform_OSMemory.cpp
6944bea4a129dc2d4be687c72f2a9f228ec532bc 17-Sep-2010 Elliott Hughes <enh@google.com> Make nio heap (non-direct) buffer bulk get orders of magnitude faster.

Bug: 2985452
Change-Id: I8bd210d1a623e434121f30eca6e2555e1aea11cd
rg_apache_harmony_luni_platform_OSMemory.cpp
fe20355288377b2d80ce5eb3aaaa548b0af04c8e 17-Sep-2010 Brian Carlstrom <bdc@google.com> am e3babe52: am 69a153da: am 760b683e: Restore OpenSSLMessageDigestJDK.digest reset behavior

Merge commit 'e3babe523df804f88d2371645c2c7e1731411ac2' into dalvik-dev

* commit 'e3babe523df804f88d2371645c2c7e1731411ac2':
Restore OpenSSLMessageDigestJDK.digest reset behavior
760b683ed34f2e62fc4ab1d483988bee515af03e 17-Sep-2010 Brian Carlstrom <bdc@google.com> Restore OpenSSLMessageDigestJDK.digest reset behavior

SSLEngine tests started failing due to the recent incorrect change to
OpenSSLMessageDigestJDK.digest() that removed the reset of
MessageDigest state on call to digest(). The problem was not that the
digest was resetting, but that it was resetting to use a SHA-0
algorithm. See recent change c38b8476e7e4bd4b091d9f0e8fe8b2b972e7bc81.

Change-Id: I40ef4e18a1b546eac5a487cb8a808d4897b301b0
ativeCrypto.cpp
e4b3e32f13c54ed5b2162bb06785f283939ba2ec 17-Sep-2010 Elliott Hughes <enh@google.com> am a836d89d: am 16cfcf36: am 34eb0408: Use DecimalFormatSymbols.getExponentSeparator in DecimalFormat.

Merge commit 'a836d89da3bc10c1bcce0ed00c447012faf504aa' into dalvik-dev

* commit 'a836d89da3bc10c1bcce0ed00c447012faf504aa':
Use DecimalFormatSymbols.getExponentSeparator in DecimalFormat.
c0dfbb79aae4876aeb1648168d6861dfa7972670 17-Sep-2010 Elliott Hughes <enh@google.com> am ea200493: am 4618c9b2: am 46cb23aa: Return char[] instead of String from NativeDecimalFormat.

Merge commit 'ea200493f20f61a2fdcf8528aba36ded1292fa9f' into dalvik-dev

* commit 'ea200493f20f61a2fdcf8528aba36ded1292fa9f':
Return char[] instead of String from NativeDecimalFormat.
f8fd3aced841e19bf3552fe81289297302a4f3a5 17-Sep-2010 Brian Carlstrom <bdc@google.com> am e6b59c28: am 9e8d51c7: am a3de55dd: Implement OpenSSLMessageDigestJDK.clone and fix OpenSSLMessageDigestJDK.digest

Merge commit 'e6b59c287ed3007d76167dd9741dc683f440ed2d' into dalvik-dev

* commit 'e6b59c287ed3007d76167dd9741dc683f440ed2d':
Implement OpenSSLMessageDigestJDK.clone and fix OpenSSLMessageDigestJDK.digest
2475f997ca2cf2f55de755ab9d23cf694d5306eb 17-Sep-2010 Brian Carlstrom <bdc@google.com> am c7478415: am 0c12bc50: am 44e4b13e: Add negative argument bounds checking to OpenSSLMessageDigest.update

Merge commit 'c747841520ce128c1db4541bdf6ba838b5bcf700' into dalvik-dev

* commit 'c747841520ce128c1db4541bdf6ba838b5bcf700':
Add negative argument bounds checking to OpenSSLMessageDigest.update
613ca127bc16ed52be21c4635b1e7fd52e2fb8f1 17-Sep-2010 Elliott Hughes <enh@google.com> Merge "Explode early when ICU's .dat file isn't available." into dalvik-dev
972d9be2dbbf6d467728b8ad44625f6574068bf8 17-Sep-2010 Elliott Hughes <enh@google.com> Explode early when ICU's .dat file isn't available.

Also make it generally more obvious (and more obvious who's to blame) when
libcore's native code fails to initialize.

Bug: 3005342
Change-Id: I75496bb0c15391d7f32ba50b9c488ea0480e3e42
CU.cpp
egister.cpp
34eb0408ff03c10b8f5842d328457aeeabac17a7 17-Sep-2010 Elliott Hughes <enh@google.com> Use DecimalFormatSymbols.getExponentSeparator in DecimalFormat.

A last-minute bit of Java 6 work...

Bug: 3008411
Change-Id: Ic197de8ddc92afcaa661875a2c99c8352237642a
ativeDecimalFormat.cpp
46cb23aaaba1b0553d02d32713abad97bd4b0428 16-Sep-2010 Elliott Hughes <enh@google.com> Return char[] instead of String from NativeDecimalFormat.

One last little speedup for Formatter %f before I call it a day for now...

Bug: 2934304
Change-Id: I9edd02d1ba8dc40a2b28fea34d7bccf95eeb56ab
ativeDecimalFormat.cpp
a3de55ddf81f95c7c0fc1b8767ccb1ecfa251c83 16-Sep-2010 Brian Carlstrom <bdc@google.com> Implement OpenSSLMessageDigestJDK.clone and fix OpenSSLMessageDigestJDK.digest

DigestInputStream2Test.test_onZ was failing because OpenSSLMessageDigestJDK did not implement Clonable
- Implementing Clonable required a new NativeCrypto.EVP_MD_CTX_copy method
- While adding NativeCrypto.EVP_MD_CTX_copy, noticed other methods
were not properly named in NativeCrypto.EVP_MD_CTX_* convention.
- Converted rest of NativeCrypto.cpp to JNI_TRACE logging while debugging

DigestOutputStreamTest.test_onZ was failing because OpenSSLMessageDigestJDK.digest did an engineReset
- Removing the engineReset revealed that digest() could not be called
repeatedly on an OpenSSLMessageDigestJDK. Problem was that
EVP_DigestFinal can only be called once per digest.
- Changed engineDigest implementation to use new EVP_MD_CTX_copy to
create a temp EVP_MD_CTX which can be used to retreive the digest
and then discarded.

Bug: 2997405
Change-Id: Ie97c22be245911300d2e729e451a9c4afdb27937
ativeCrypto.cpp
44e4b13e9a75f12b9267a8b563730f3687062aa6 15-Sep-2010 Brian Carlstrom <bdc@google.com> Add negative argument bounds checking to OpenSSLMessageDigest.update

Add bounds checking to match RI behavior. Note the checking is done
within the subclasses MessageDigest.engineUpdate implementation and
not the MessageDigest.update class, which was fixed earlier in
HARMONY-1120 https://issues.apache.org/jira/browse/HARMONY-1120

luni/src/main/native/NativeCrypto.cpp

Fix test to pass on RI

luni/src/test/java/org/apache/harmony/security/tests/java/security/MessageDigest1Test.java

Bug: 2997412
Change-Id: Ied0754ac0a35f1fe0be998b8bc350aa21e69ebdd
ativeCrypto.cpp
6cab4071580a4b216d943b337af118533c65e495 15-Sep-2010 Brian Carlstrom <bdc@google.com> resolved conflicts for merge of 4b60175b to dalvik-dev

Change-Id: I63d0c5949be0984dcd7939205463eefabde8af05
df349b3eaf4d1fa0643ab722173bc3bf20a266f5 14-Sep-2010 Brian Carlstrom <bdc@google.com> Fix HttpsURLConnectionTest failures

Focusing on HttpsURLConnectionTest.test_doOutput found a number of
unrelated issues, all of which are addressed by this change:
- {HttpURLConnection,HttpsURLConnection}.connect not ignored on subsequent calls
- OpenSSLSessionImpl.{getPeerCertificates,getPeerCertificateChain} did not include client certificate
- OpenSSLSocketImpl.getSession did not skip handshake when SSLSession was already available
- Fix 3 test issues in HttpsURLConnectionTest
- Fix 2 test issues in NativeCryptoTest

Details:

HttpsURLConnectionTest tests (such as test_doOutput) that
tried to call URLConnection.connect() at the end of the test
were raising exception. The RI URLConnection.connect
documentation says calls on connected URLConnections should be ignored.

Use "connected" instead of "connection != null" as reason to ignore "connect"

luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java
luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/HttpsURLConnectionImpl.java

Converted one caller of getPeerCertificateChain to
getPeerCertificates which is the new fast path. Track
OpenSSLSessionImpl change to take "java" vs "javax" certificates.

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

Move SSL_SESSION_get_peer_cert_chain to be SSL_get_peer_cert_chain
(similar to SSL_get_certificate). The problem was that
SSL_SESSION_get_peer_cert_chain used SSL_get_peer_cert_chain which
in the server case did not include the client cert itself, which
required a call to SSL_get_peer_certificate, which needed the
SSL instance pointer.

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

Improved NativeCrypto_SSL_set_verify tracing

luni/src/main/native/NativeCrypto.cpp

As a side effect of the move to
NativeCrypto.SSL_get_peer_certificate, it no longer made sense to
lazily create the peer certificate chain since the SSLSession
should not depend on a particular SSL instance. The peer chain is
now passed in as part of the constructor and the peerCertifcates
in the OpenSSLSession can be final (also made localCertificates
final). Since peerCertifcates is the newew (java not javax) API
and more commonly used, it is what is created from the native
code, and peerCertificateChain is not derived from peerCertifcates
instead of vice versa.

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

Factored out code to used to create local certificate chain to
from array of DER byte arrays into createCertChain so it can be
reused to create peer certificate chain.

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

Fix OpenSSLSocketImpl.getSession to check for existing sslSession
to and skip handshake, which was causing an exception if the
connection had already been closed.

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

Fix test issues: Removed PrintStream wrapper of System.out which
was causing vogar to lose output. Added null check in closeSocket,
which can happen in timeout case. Removed use of
InputStream.available which in OpenSSLSocket case returned 0,
causing test to fail incorrectly.

luni/src/test/java/org/apache/harmony/luni/tests/internal/net/www/protocol/https/HttpsURLConnectionTest.java

Updating to track change to SSL_get_peer_cert_chain. Also fixed
some other unrelated test failures caused by IOException on
shutdown and false start (aka SSL_MODE_HANDSHAKE_CUTTHROUGH)
causing clientCallback.handshakeCompleted to be false.

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

Bug: b/2981767
Change-Id: Id083beb6496558296c2f74f51ab0970e158b23a9
ativeCrypto.cpp
7d5299b162863ea898dd863004afe79f7a93fbce 13-Sep-2010 Elliott Hughes <enh@google.com> Optimize byte-swapped accesses.

Brings the performance of byte-swapped accesses way down from about 3x to
less than 2x worst-case (char/short) and 20% best-case (long/double). The
main active ingredients are switching to a single-pass swapped-copy (rather
than copy in one pass, swap in a second pass), and ensuring we use ARM's
REV and REV16 instructions.

Because the array get/put methods were getting complicated again, I've
factored the implementations out using a couple of macros.

I've also removed the obsolete misaligned access workarounds for <= 32-bit
types, leaving only the code for misaligned 64-bit accesses.

Bug: 2935622
Change-Id: I5a2365c2bcf35e05dbea9ebc3463c73ef17e33d0
rg_apache_harmony_luni_platform_OSMemory.cpp
961da1e7487bdb8ad8ac226d4f2789d003aa87b9 11-Sep-2010 Elliott Hughes <enh@google.com> Optimize bulk get of char[], double[], float[], long[], and short[].

I optimized int[] the other day, and byte[] has always been optimized.
This now makes our get performance equivalent to our put performance,
rather than orders of magnitude worse.

Before:

ByteBuffer_getByteArray 2041 ==========
ByteBuffer_putByteArray 1983 =========
CharBuffer_getCharArray 705152 ============================
CharBuffer_putCharArray 4375 ============
DoubleBuffer_getDoubleArray 860884 =============================
DoubleBuffer_putDoubleArray 11591 ===============
FloatBuffer_getFloatArray 839085 =============================
FloatBuffer_putFloatArray 6690 =============
IntBuffer_getIntArray 6814 =============
IntBuffer_putIntArray 6775 =============
LongBuffer_getLongArray 668171 ============================
LongBuffer_putLongArray 11585 ===============
ShortBuffer_getShortArray 620122 ============================
ShortBuffer_putShortArray 4350 ============

After:

ByteBuffer_getByteArray 2028 ===========
ByteBuffer_putByteArray 1948 ===========
CharBuffer_getCharArray 4376 =================
CharBuffer_putCharArray 4342 =================
DoubleBuffer_getDoubleArray 11616 =======================
DoubleBuffer_putDoubleArray 11540 =======================
FloatBuffer_getFloatArray 6827 ====================
FloatBuffer_putFloatArray 6747 ====================
IntBuffer_getIntArray 6824 ====================
IntBuffer_putIntArray 6733 ====================
LongBuffer_getLongArray 11597 =======================
LongBuffer_putLongArray 11489 =======================
ShortBuffer_getShortArray 4392 =================
ShortBuffer_putShortArray 4329 =================

(All times in microseconds. The relatively large amount of noise visibile from
the code that didn't change is because I told caliper I wanted results quickly,
since it was order of magnitude I cared about, not tens of microseconds. That
is, the scales on the two graphs are completely different, and it's only the
shapes of the graphs that you can usefully compare: after is less spiky,
because I've filled in the performance potholes.)

Bug: 2935622
Change-Id: Ia5a36e641ef67648fcdbda092fab36111613b1c2
rg_apache_harmony_luni_platform_OSMemory.cpp
692222b08ff88eb92b523bf4780d7ea17a23aa80 10-Sep-2010 Elliott Hughes <enh@google.com> Fast-path nio put for char[], double[], long[], nio get for int[].

The other vector puts were already special-cased.

int[] is the first get to be accelerated; I'll come back and do the others.
I don't know how used vector gets are, but our nio unit tests go from ~4minutes
to ~15s after these changes, and all but the last five seconds of that is
from the get(int[]) part of this change.

Bug: 2935622
Change-Id: I1f5afb77e0fc7abcb661f861fa435cbec4b3f348
rg_apache_harmony_luni_platform_OSMemory.cpp
5222146ecad7f6b5f1230f75bea7107eb2a59291 08-Sep-2010 Elliott Hughes <enh@google.com> Socket.close doesn't throw if the socket is already closed.

In gingerbread, most (but not all) types of socket have Java code to prevent us
getting this far. Post-gingerbread we've rationalized everything and do the
work in one place, so we need to suppress NetFd's usual inclination to throw
SocketException "Socket closed" when operating on a closed socket.

I already checked the test for this in in gingerbread.

Bug: 2980559
Change-Id: I8552030e4c625b8ed5a0cac9d886d2b9d8073e7c
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
4d68282a79fb0417f43efdef41b9a920385bdded 03-Sep-2010 Elliott Hughes <enh@google.com> Kill PlatformAddressFactory, and remove/simplify some other code.

Now we create one PlatformAddress per direct byte buffer (or mapped byte
buffer), there's no need for object pooling.

Bug: 2935622
Change-Id: I84ef9d0b77774e1d2d80921b95b2f30383a0ab68
rg_apache_harmony_luni_platform_OSMemory.cpp
10a17e23b22dc0ff6363d15bce67d668b6d44dd0 27-Aug-2010 Elliott Hughes <enh@google.com> Speed up Float.toString (and Double.toString).

The special cases (NaN, infinities, and zeros) go from 30us to 1us.

There are basically three other paths through the code, depending on the value:

The small case goes from 60us to 30us.
The medium case goes from 70us to 31us.
The large case goes from 100us to 50us.

There's way less garbage produced, and now we're using StringBuilder, we're
in a position to take advantage of future optimization of
StringBuilder.append(int).

[cherry-pick of 2164031488f9788e5ee9ad2545b3aec34b65e06c from dalvik-dev to gingerbread]

Bug: 2934304
niConstants.cpp
niConstants.h
ava_lang_RealToString.cpp
706de1164836051ab31cc69eb77a6bba1a723896 27-Aug-2010 Elliott Hughes <enh@google.com> Minor tidy-up of Float.toString and Double.toString.

This patch looks larger than it is. I've moved duplicated constants out of
Math and StrictMath and into Float and Double where they belong. I've also
moved a table out of BigDecimal so I can reuse it in NumberConverter, which
I've renamed to RealToString.

The main active ingredient here is that there's no longer StringBuilder usage
to prepend '-'. This actually brings us down from 74ns to 62ns for an easy
case like 123.45f.

[cherry-pick of 910106e29fe98f14b2c36312a7498287273ba826 from dalvik-dev to gingerbread; plus build fix]

Bug: 2934304
Change-Id: Id79a6fb0d739e673b7428d240fc48bdae9b8bb43
egister.cpp
ava_lang_RealToString.cpp
rg_apache_harmony_luni_util_NumberConvert.cpp
ub.mk
d16c314465f7f5905fe8852eaa09d4e7e14ec835 25-Aug-2010 Elliott Hughes <enh@google.com> Faster implementations of Math/StrictMath's copySign methods.

These are only faster than the old native implementations now we have
intrinsics for float/int and double/long conversion, but given those,
they're about 4x faster.

We were already using Java for getExponent, the other obvious candidate
for an all-Java implementation.

[cherry-pick of a61c63c54ba46bb8a1dcbd888e3b29d6cedfb1ff from dalvik-dev to gingerbread]

Bug: 2935622
ava_lang_Math.cpp
2164031488f9788e5ee9ad2545b3aec34b65e06c 27-Aug-2010 Elliott Hughes <enh@google.com> Speed up Float.toString (and Double.toString).

The special cases (NaN, infinities, and zeros) go from 30us to 1us.

There are basically three other paths through the code, depending on the value:

The small case goes from 60us to 30us.
The medium case goes from 70us to 31us.
The large case goes from 100us to 50us.

There's way less garbage produced, and now we're using StringBuilder, we're
in a position to take advantage of future optimization of
StringBuilder.append(int).

Bug: 2934304
Change-Id: Ib7441e064557973dd0c6247a149275d6367d55ea
niConstants.cpp
niConstants.h
ava_lang_RealToString.cpp
910106e29fe98f14b2c36312a7498287273ba826 27-Aug-2010 Elliott Hughes <enh@google.com> Minor tidy-up of Float.toString and Double.toString.

This patch looks larger than it is. I've moved duplicated constants out of
Math and StrictMath and into Float and Double where they belong. I've also
moved a table out of BigDecimal so I can reuse it in NumberConverter, which
I've renamed to RealToString.

The main active ingredient here is that there's no longer StringBuilder usage
to prepend '-'. This actually brings us down from 74ns to 62ns for an easy
case like 123.45f.

Bug: 2934304
Change-Id: I65461753247eeb9ff890ffe66b0bc79d66d2ec9c
egister.cpp
ava_lang_RealToString.cpp
rg_apache_harmony_luni_util_NumberConvert.cpp
ub.mk
6116e6265924a0983bb462e3441c8c4a0bb7e47e 26-Aug-2010 Elliott Hughes <enh@google.com> Specialize on size rather than type in OSMemory.

I'm working towards intrinsics for this stuff, so I want to minimize the number
I have to support. There are 7 types (byte, char, double, float, int, long,
and short) but only 4 sizes (1, 2, 4, and 8 bytes).

I've also finally benchmarked whether the "inlined memcpy"s really gain us
anything, and they do, so I've rewritten the sole remaining caller of the
templates (long) to have its own inlined memcpy too.

Plus a final tranche of naming consistency.

Bug: 2935622
Change-Id: Ieffd9723d0479aec6179b888d1c3b3496032e57a
rg_apache_harmony_luni_platform_OSMemory.cpp
71961a4957d24f62f7adc5f0549e236018589631 26-Aug-2010 Elliott Hughes <enh@google.com> More consistent naming of the nio vector primitives.

Just name changes here.

Change-Id: I050b33ce836270435310041dd179ceaa98d789fa
rg_apache_harmony_luni_platform_OSMemory.cpp
6dd179b93e08a8ee21df216c710f749062a92f35 25-Aug-2010 Elliott Hughes <enh@google.com> am ec4016aa: am 574a2129: am d5a7f1e6: Fix a typo and remove a little cruft.

Merge commit 'ec4016aa2be38b1552af28ae96c0def02943b2b5' into dalvik-dev

* commit 'ec4016aa2be38b1552af28ae96c0def02943b2b5':
Fix a typo and remove a little cruft.
ac725b746a178bc915859c77bd33367a948b9da5 25-Aug-2010 Elliott Hughes <enh@google.com> am 64255ed2: am c64816eb: am 758570a6: Remove fdlibm.h-related hacks now I\'ve cleaned the header file.

Merge commit '64255ed2e51e233181b82891342974e5839ff558' into dalvik-dev

* commit '64255ed2e51e233181b82891342974e5839ff558':
Remove fdlibm.h-related hacks now I've cleaned the header file.
d5a7f1e61a6a7d6fcfabaa3e1d072c7f29bf922f 25-Aug-2010 Elliott Hughes <enh@google.com> Fix a typo and remove a little cruft.

Change-Id: I5afe174ac1ad3b1321f61d6eb19f44dd96779131
rg_apache_harmony_luni_util_FloatingPointParser.cpp
rg_apache_harmony_luni_util_NumberConvert.cpp
758570a632c3651635f3e477585c636836f38ff2 25-Aug-2010 Elliott Hughes <enh@google.com> Remove fdlibm.h-related hacks now I've cleaned the header file.

Change-Id: I2f5bec5346c1e8476bb13631e9a5fa3526a34d32
See: https://android-git.corp.google.com/g/62885
ava_lang_StrictMath.cpp
a1e211ac2a244f7cc663d36d63a10bec1b981013 25-Aug-2010 Elliott Hughes <enh@google.com> Merge "Faster implementations of Math/StrictMath's copySign methods." into dalvik-dev
a61c63c54ba46bb8a1dcbd888e3b29d6cedfb1ff 25-Aug-2010 Elliott Hughes <enh@google.com> Faster implementations of Math/StrictMath's copySign methods.

These are only faster than the old native implementations now we have
intrinsics for float/int and double/long conversion, but given those,
they're about 4x faster.

We were already using Java for getExponent, the other obvious candidate
for an all-Java implementation.

Bug: 2935622
Change-Id: I77549c88b7448b6087a67b37f8c317579b4f92b8
ava_lang_Math.cpp
73035021c50c1450ec7c27d3bba63b6495f0c858 24-Aug-2010 Jesse Wilson <jessewilson@google.com> Relying on fdlibm's build to set the version type to IEEE.

Change-Id: I6d54c3059ddcdcf66aaff93ad01daed40009a760
ava_lang_StrictMath.cpp
e4942c596da75834e133a9cb45c317dbc2e44ed4 23-Aug-2010 Jesse Wilson <jessewilson@google.com> Relying on fdlibm's build to set the version type to IEEE.

Change-Id: I21a2c38b07c3779488bb09d4f62722928bb974b0
ava_lang_StrictMath.cpp
1b9018762e87e3dda69020248817011efd5a40dc 20-Aug-2010 Elliott Hughes <enh@google.com> Minor nio speedups (scalar operations only).

This patch speeds up nio scalar operations for all types larger than byte.
Basically just by trimming fat, pushing any byte-swapping down into Java,
and adding a boolean field to ByteOrder that basically caches the "do we
need byte swapping?" comparison.

For the worst case, byte-swapped doubles, this patch gives a 2x speedup.
At the other end of the spectrum, for native-order chars and shorts, this
patch gives a 20% speedup. Still, that's not bad for quite a reduction in
code.

Now I've tidied this up a bit, I have more of a plan. This is just the warmup.

Bug: 2935622

Change-Id: I3cfc4e61b12ea7a8f32fc497106ddc66474efe01
ava_lang_Double.cpp
ava_lang_Double.h
ava_lang_Float.cpp
ava_lang_Float.h
ava_lang_StrictMath.cpp
rg_apache_harmony_luni_platform_OSMemory.cpp
0b29a1fecc601de2f642ded891726ac3e460d74b 18-Aug-2010 Elliott Hughes <enh@google.com> Multicast cleanup.

This doesn't fix any bugs, but it does get rid of a lot of code. This is how
Stevens' book tells us we should be doing things.

Bug: 1610553
Change-Id: I00a79a6c34084ba018fb69c7f1123300a2698ce9
niConstants.cpp
niConstants.h
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
4940ff34c242c7907f548e6eb7b1680d7d53fbc7 17-Aug-2010 Elliott Hughes <enh@google.com> 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
rg_apache_harmony_luni_platform_OSMemory.cpp
8510524dab13e0acc1babf22cbc55002fb122777 17-Aug-2010 Elliott Hughes <enh@google.com> 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
egister.cpp
ava_nio_ByteOrder.cpp
rg_apache_harmony_luni_platform_OSMemory.cpp
ub.mk
610fa2ee3ad913c8247e78c81dfbfa11f4bb9379 16-Aug-2010 Elliott Hughes <enh@google.com> 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
rg_apache_harmony_luni_platform_OSFileSystem.cpp
539081f7286edf0576b02e9c5fb7ca4d617c46ff 14-Aug-2010 Elliott Hughes <enh@google.com> File names should match their contents.

Change-Id: I3440bb921c70834325dfe1b1177f81158186ec7b
rg_apache_harmony_luni_util_FloatingPointParser.cpp
rg_apache_harmony_luni_util_fltparse.cpp
ub.mk
a63f0d99978c3d6e6fcde1f2562295070f8d7e14 14-Aug-2010 Elliott Hughes <enh@google.com> 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
bigint.cpp
bigint.h
ltconst.h
rg_apache_harmony_luni_util_NumberConvert.cpp
rg_apache_harmony_luni_util_fltparse.cpp
6bdcc32b57431c0beca7656765eaadbdaedc6416 14-Aug-2010 Elliott Hughes <enh@google.com> 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
ommonDblParce.cpp
ommonDblParce.h
rg_apache_harmony_luni_util_fltparse.cpp
ub.mk
2fee9da56d25681d590ffb00716fde2eea24c0f3 14-Aug-2010 Elliott Hughes <enh@google.com> Merge "Fix last few uses of "type *id" to be "type* id"." into dalvik-dev
35bac6cd80d1bf07c85e6960b03ce6baed929ede 14-Aug-2010 Elliott Hughes <enh@google.com> Merge "Fix the build now warnings are errors, and comment all the weirdness." into dalvik-dev
acce5ff29455054faa08a10e1486a156b9d1553e 14-Aug-2010 Elliott Hughes <enh@google.com> Fix last few uses of "type *id" to be "type* id".

We don't want anyone calling us unreformed C programmers...

Change-Id: I79b12245b206495ca747b4027b2bca423c27aec0
rrorCode.cpp
rrorCode.h
ativeBN.cpp
ativeCollation.cpp
ativeConverter.cpp
ativeCrypto.cpp
ativeDecimalFormat.cpp
etworkUtilities.cpp
bigint.cpp
ommonDblParce.cpp
ommonDblParce.h
ava_net_InetAddress.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
rg_apache_harmony_luni_util_NumberConvert.cpp
rg_apache_harmony_luni_util_fltparse.cpp
5cfa018c1d6c1fc2771abc4df63ab38cdb6e193f 14-Aug-2010 Elliott Hughes <enh@google.com> Fix the build now warnings are errors, and comment all the weirdness.

In short: "fdlibm.h" is disgustingly unhygienic.

Change-Id: Idcd98eae359c894cf66a6c588c7f39b14416ac72
ava_lang_StrictMath.cpp
60a0a96f334f159418763cab17c48a09c97cbd2f 13-Aug-2010 Elliott Hughes <enh@google.com> 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
rg_apache_harmony_luni_platform_OSFileSystem.cpp
e22935d3c7040c22b48d53bd18878844f381287c 13-Aug-2010 Elliott Hughes <enh@google.com> 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
CU.cpp
niConstants.h
ativeBN.cpp
ativeBidi.cpp
ativeBreakIterator.cpp
ativeCollation.cpp
ativeConverter.cpp
ativeCrypto.cpp
ativeDecimalFormat.cpp
ativeIDN.cpp
ativeNormalizer.cpp
ativePluralRules.cpp
imeZones.cpp
ava_io_Console.cpp
ava_io_File.cpp
ava_io_FileDescriptor.cpp
ava_io_ObjectInputStream.cpp
ava_io_ObjectOutputStream.cpp
ava_io_ObjectStreamClass.cpp
ava_lang_Character.cpp
ava_lang_Double.cpp
ava_lang_Float.cpp
ava_lang_Math.cpp
ava_lang_ProcessManager.cpp
ava_lang_StrictMath.cpp
ava_lang_System.cpp
ava_net_InetAddress.cpp
ava_net_NetworkInterface.cpp
ava_nio_charset_Charsets.cpp
ava_util_regex_Matcher.cpp
ava_util_regex_Pattern.cpp
ava_util_zip_Adler32.cpp
ava_util_zip_CRC32.cpp
ava_util_zip_Deflater.cpp
ava_util_zip_Inflater.cpp
ibcore_io_IoUtils.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
rg_apache_harmony_luni_platform_OSMemory.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
rg_apache_harmony_luni_util_NumberConvert.cpp
rg_apache_harmony_luni_util_fltparse.cpp
rg_apache_harmony_xml_ExpatParser.cpp
24144d482dcd5deac58a5dca7042379c05b56b5e 13-Aug-2010 Elliott Hughes <enh@google.com> Clean up our final native code warnings, and turn on -Werror.

Change-Id: I54bb29e357812b089e83f3a2a831c80f5114a27a
rg_apache_harmony_luni_platform_OSFileSystem.cpp
rg_apache_harmony_luni_util_NumberConvert.cpp
a92f883cda9e483c64f78dbba0031e6e43cd00ab 12-Aug-2010 Elliott Hughes <enh@google.com> 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
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
7738141c52b931e103efe7ad62d32a12785bf6b1 12-Aug-2010 Elliott Hughes <enh@google.com> Remove createServerStreamSocket as a native special case.

We can do everything in Java.

Change-Id: I7451319335a647fc25bd2d2403fa98bfc6b5c038
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
29f8e5ccde645e05d244c6dd94eaa377251dab2c 10-Aug-2010 Elliott Hughes <enh@google.com> Merge "Make network I/O interruptible." into dalvik-dev
9f2b1b1c3bf9de560f29f257c855c7c85b405c0f 07-Aug-2010 Elliott Hughes <enh@google.com> 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
synchronousSocketCloseMonitor.cpp
synchronousSocketCloseMonitor.h
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
ub.mk
cf682b15e22d3e3404465ee61ca1a6c27128774c 09-Aug-2010 Mike Lockwood <lockwood@android.com> 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
4ea56d66e19d1450960ba26f60ca61a6804a3ba7 09-Aug-2010 Mike Lockwood <lockwood@android.com> Create new files with permissions 0666 instead of 0777

Change-Id: Ia37b12cac4baadd712dd29a1bc0692cb5163943e
Signed-off-by: Mike Lockwood <lockwood@android.com>
ava_io_File.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
22dda9e0ecfe848aa870474da50a02246ca6f376 06-Aug-2010 Elliott Hughes <enh@google.com> Merge "Rationalize and simplify our "connect" implementations." into dalvik-dev
036ffc75d2b7ece42bcd97f290c026e215868ba9 05-Aug-2010 Elliott Hughes <enh@google.com> 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
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
e5307adb7b7f6386c8105e441e6a26e087535650 06-Aug-2010 Mike Lockwood <lockwood@android.com> 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.
787bd9e6c46da7e229db6450d94409d2c6da6c2b 06-Aug-2010 Mike Lockwood <lockwood@android.com> 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>
ava_io_File.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
0bb50c52aee8a987dd05d122a440ec9c2b79824d 05-Aug-2010 Mike Lockwood <lockwood@android.com> 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
578c4cbbda479989790f1075f1e8f63fde1e2a92 05-Aug-2010 Brian Carlstrom <bdc@google.com> 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
9b211124283bfb808e902b91da4df3e291d9bb6c 05-Aug-2010 Mike Lockwood <lockwood@android.com> 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>
ava_io_File.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
440ba565fa5384bc23255fbc412f7b97fcbdccd9 04-Aug-2010 Elliott Hughes <enh@google.com> Rename setNonBlocking to setBlocking.

This makes the boolean argument less confusing.

Change-Id: Ic226f6d3c5afe8e15a95e74917656424f8a448fe
ativeCrypto.cpp
etworkUtilities.cpp
etworkUtilities.h
ibcore_io_IoUtils.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
31496e770af085ce6ee439a1a58db39a1ade7e8e 04-Aug-2010 Elliott Hughes <enh@google.com> Merge "Rewrite the nio Pipe to use a Unix pipe behind the scenes." into dalvik-dev
99a89dd6f0a0e1396aa9b3feebf15ea31f703d3a 04-Aug-2010 Elliott Hughes <enh@google.com> 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
egister.cpp
ava_lang_ProcessManager.cpp
ibcore_io_IoUtils.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
ub.mk
2c040b9b2fae389983339ed2bcba4c7568825575 03-Aug-2010 Brian Carlstrom <bdc@google.com> Merge "Support for TLS Extensions enabled SSLSockets with fallback to vanila SSL" into dalvik-dev
556eb85baedf3851afaf8be7b8067a7dc44dd845 03-Aug-2010 Elliott Hughes <enh@google.com> 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
rg_apache_harmony_luni_platform_OSMemory.cpp
4559b1d37edcb5d7f1da086cf2e3290388d74f46 23-Jul-2010 Brian Carlstrom <bdc@google.com> 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
ativeCrypto.cpp
4fe378672d700aaae3a50db956b693b3ed599c7d 31-Jul-2010 Elliott Hughes <enh@google.com> Remove "java.net.preferIPv4Stack" (which has been broken >= eclair).

Change-Id: I4733a0e266ff7c02c25033e79bcceff4d7357868
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
2cd82d7111f68ff63145ef7c393bf1479ff06223 29-Jul-2010 Elliott Hughes <enh@google.com> 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
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
0371d85fa3ecb5f162d107cdbff0a99cd987fdcc 27-Jul-2010 Elliott Hughes <enh@google.com> 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
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
bb3db740b0a79f42fa32cb7a16e729e3a6e04a9b 28-Jul-2010 Elliott Hughes <enh@google.com> Remove the unnecessary "Impl" suffix from setFloatArray.

Change-Id: I2eea809c7b441ed3c596e2b945e7897ccc15c10c
rg_apache_harmony_luni_platform_OSMemory.cpp
623978ac0a3f9e4e2d1111aee41b64195d9ac64c 28-Jul-2010 Elliott Hughes <enh@google.com> resolved conflicts for merge of 01a18c74 to dalvik-dev

Change-Id: Ib569414191a6e7b0e7aebb804fe1f4d57c5184a9
01a18c74534e68f19c90912e8f87e856f9901dfb 28-Jul-2010 Elliott Hughes <enh@google.com> resolved conflicts for merge of fb4045a3 to master

Change-Id: I2100c70f6078108e7b646c393ac2e4b42ca8d066
4e4000ed98f9056639fba0713a3fd3caacf9746c 27-Jul-2010 Elliott Hughes <enh@google.com> 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
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
91ad12a4e7c9eeb19b48fa296b4ed87d6c7b612b 26-Jul-2010 Elliott Hughes <enh@google.com> Better detail messages for exceptions thrown when converting between byte[]/InetAddress.

Change-Id: I0e87b0ed6487f8434435027ee70ec294c98617e8
etworkUtilities.cpp
bfb0099cc4c8eca744eeda0f20e5b3644f1a4cb9 11-Jun-2010 Owen Lin <owenlin@google.com> Improve putFloatArray performance

Change-Id: I04b43a2be6409329408d74af7ff0f0b2b60cc96d
rg_apache_harmony_luni_platform_OSMemory.cpp
f3afb1b6a4ace33bd60e5801bdb2fcb2e935d486 24-Jul-2010 Elliott Hughes <enh@google.com> 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
faddrs-android.h
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
dbbdffce5ac97a0e93ef495adaacca3660b9ab21 23-Jul-2010 Elliott Hughes <enh@google.com> 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
CU.cpp
egister.cpp
Character.cpp
ava_lang_Character.cpp
rg_apache_harmony_luni_platform_OSMemory.cpp
ub.mk
034db7d210969f6e516d347810695633d063eb4b 23-Jul-2010 Elliott Hughes <enh@google.com> Remove more of our C-style casts, fix more of our native method names.

Change-Id: I08d7915e22faf091489171240d2f9bf8b3acecca
ativeBreakIterator.cpp
ativeCollation.cpp
ativeDecimalFormat.cpp
ava_io_Console.cpp
ava_lang_Math.cpp
ava_lang_ProcessManager.cpp
ava_net_NetworkInterface.cpp
ava_util_regex_Matcher.cpp
ava_util_regex_Pattern.cpp
rg_apache_harmony_luni_platform_OSMemory.cpp
3b0a5b910110625c50dae6baa94d9adaf58ed46e 23-Jul-2010 Elliott Hughes <enh@google.com> Consistently use POSIX O_NONBLOCK instead of FIONBIO.

Change-Id: I395012f0e51e1928e720d09d0f44b7d5085b01a3
ativeCrypto.cpp
etworkUtilities.cpp
etworkUtilities.h
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
2edc04d70355a99fc4088ec8f78aa79d33b3fb54 22-Jul-2010 Elliott Hughes <enh@google.com> 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
rg_apache_harmony_xml_ExpatParser.cpp
583ce47780cae3a014ca46534e08f5c2adc8fa88 22-Jul-2010 Elliott Hughes <enh@google.com> Remove many of our C-style casts.

Also move more native methods' function names over to the predominant
"Class_methodName" orthography.

Change-Id: I8f7fa5fe1fdf323e0ed910a0850595a8e5426e05
ativeBN.cpp
ativeConverter.cpp
ativeCrypto.cpp
ava_lang_Double.cpp
ava_lang_Float.cpp
ava_lang_ProcessManager.cpp
ava_lang_StrictMath.cpp
aaacdb095b10293286adbfd94af2fd83b8dae3a8 22-Jul-2010 Elliott Hughes <enh@google.com> 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
ava_io_File.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
ef628d1464e57552403ad43366e153c1ef50b926 19-Jul-2010 Brian Carlstrom <bdc@google.com> 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
ativeCrypto.cpp
634584cdbbd84bdd4570929ef32b501a9767b0f6 17-Jul-2010 Elliott Hughes <enh@google.com> 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
ava_nio_charset_Charsets.cpp
b03209abeee65acbb6aff2059af61174d9930ba0 17-Jul-2010 Elliott Hughes <enh@google.com> Merge "Fix a long-latent bug in the zip code, exposed by -Xjniopts:forcecopy." into dalvik-dev
0adb7b318dd5d67559d5b31b1ef3280dd72e1f5f 17-Jul-2010 Elliott Hughes <enh@google.com> 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
ava_util_zip_Adler32.cpp
ava_util_zip_CRC32.cpp
ava_util_zip_Deflater.cpp
ava_util_zip_Inflater.cpp
ip.h
e3a187163504f00c98bd75cbd8bcbdde123ae2cd 14-Jul-2010 Brian Carlstrom <bdc@google.com> 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
ativeCrypto.cpp
221d0ccb4cc23ee0bf0646e9abe471fb48b3a1a8 15-Jul-2010 Elliott Hughes <enh@google.com> 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
niException.cpp
niException.h
ativeCrypto.cpp
ava_net_NetworkInterface.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
ub.mk
ip.h
aa0bfd1390a437020d2bc80ebb22a7a65f2c5c76 15-Jul-2010 Joe Onorato <joeo@android.com> 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.
3533ac4b1edc4e863385a0f29c83cfbf49142924 15-Jul-2010 Joe Onorato <joeo@android.com> Resolved conflicts for merge of de1d2252 to master

Change-Id: If44e4cfa8df812bceb8f39d9343530824cbf3b7c
79ff4e73fd689dae6667a8137ee57137962ff13a 14-Jul-2010 Elliott Hughes <enh@google.com> 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
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
059dbc04218144f985b20a228bbe98139d400d0c 08-Jul-2010 Brian Carlstrom <bdc@google.com> 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
ativeCrypto.cpp
64101124267c6a0a9a12dc854bdec39cbc506259 12-Jul-2010 Elliott Hughes <enh@google.com> 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
ativeBN.cpp
ativeBidi.cpp
ativeConverter.cpp
ativeCrypto.cpp
ativeDecimalFormat.cpp
ava_io_File.cpp
ava_util_regex_Matcher.cpp
ava_util_zip_Adler32.cpp
ava_util_zip_CRC32.cpp
ava_util_zip_Inflater.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
rg_apache_harmony_luni_util_NumberConvert.cpp
rg_apache_harmony_xml_ExpatParser.cpp
ccbe3404e0691dab506d017550658e8e5974c83e 10-Jul-2010 Elliott Hughes <enh@google.com> 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
ativeCrypto.cpp
99a8c7aecaaa5eb4278ef2b839f7c1648a8c8ad7 09-Jul-2010 Elliott Hughes <enh@google.com> Merge "Stop Matcher from copying its input onto the native heap." into dalvik-dev
0120b34f823a06763ef7b708249abf3c4bef40ed 08-Jul-2010 Elliott Hughes <enh@google.com> Remove dead code/unused variables from OSNetworkSystem.

This has never done anything, and we've no idea what -- if anything -- it was
meant to do, and it doesn't do anything upstream either, so out it goes...

Change-Id: I33a738700fd4811fe47089f0d0373ce9f0d525de
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
a233bbfcc80149b472c978ded50f9420936226fb 08-Jul-2010 Elliott Hughes <enh@google.com> Clean up OSFileSystem.

I accidentally opened this file instead of OSNetworkSystem, but took the
opportunity to move null pointer checking down into the JNI, where it doubles
as OOM checking. I've also added missing null checks to the JNI.

(Strictly, ScopedPrimitiveArray doesn't yet do the right thing in all cases,
it's ScopedUtfChars that does. An improved ScopedPrimitiveArray will be along
shortly...)

Also some cosmetic tidying.

Change-Id: Ie4d3a217332dae67a12db370246c7d87fe7edae4
rg_apache_harmony_luni_platform_OSFileSystem.cpp
aecd669ba84f758222c374027df1cc6849d37eed 02-Jul-2010 Elliott Hughes <enh@google.com> Stop Matcher from copying its input onto the native heap.

This uses ICU 4.6 API that we've manually backported to Android's ICU 4.4.

Bug: 2777924
Change-Id: I799b3e621a8c87d560495bc3d7b48f2e11de9c60
ava_util_regex_Matcher.cpp
c69b7729a116a25309d598a542050d50b8611ba5 02-Jul-2010 Elliott Hughes <enh@google.com> Fix another couple of bugs in my native UTF-8 code.

If the initial allocation failed, we could still upset -Xcheck:jni by releasing
NULL. Also, if the length of the input was 0, we'd incorrectly never leave the
initial state of not having a byte[] allocated, and return the null array rather
than the empty array.

Change-Id: I316b63666c659f0190bad1e8c33856de31b1a10f
ava_nio_charset_Charsets.cpp
187f018ab1effc5e33f06ae4af55f875bb850246 02-Jul-2010 Elliott Hughes <enh@google.com> Fix a JNI abuse caught by -Xcheckjni.

Unlike delete and free(3) and just about every API new or old, JNI doesn't
actually let you free NULL.

Change-Id: Idc79071a1b49735118e9a28d382f19b9b9d42b42
ava_nio_charset_Charsets.cpp
79dc3f01f6a2d63a02f7d43c54917749a42eaafb 01-Jul-2010 Elliott Hughes <enh@google.com> Fix sim build (missing #include <string.h> for memcpy).

Change-Id: I0526f17796bc98e2099c4ba0576d00819418a0bb
ava_nio_charset_Charsets.cpp
5cd6df2f627e06f9b7f714181d70d3148a3d6c60 01-Jul-2010 Elliott Hughes <enh@google.com> Part 2 of the "new String"/String.getBytes performance work.

I didn't plan on a part 2, but my benchmark was bogus. I'd failed to take into
account the fact that the ICU code (which I was comparing against) has a higher
intercept but lower slope than the Java I replaced it with. This new code
offers the best of both worlds: low intercept (start-up cost) and low slope
(per-byte/char cost).

The bad news is that this means I'm adding more native code. In addition to the
improved benchmark, I'll commit a benchmark that contains the pure Java
implementations so we can see when the JIT advances to the point that we can
retire this native code.

Change-Id: Ibac24c2e3deed216bd492acf2fac7554d3f96d85
egister.cpp
ava_nio_charset_Charsets.cpp
ub.mk
12cd1f00c2fa1a7f37bf644cecdf7588bdc0b0a9 23-Jun-2010 Brian Carlstrom <bdc@google.com> Remove libcore's dependency on bouncycastle

external/bouncycastle
- Change to be the primary build for bouncycastle sources (as opposed to part of libcore)
- Moved OpenSSLMessageDigest from libcore to OpenSSLDigest
It uses NativeCrypto API from core, but implements a bouncycastle specific interface
- restored registration of bouncycastle MessageDigests for SHA-1, SHA-256, MD5
OpenSSLProvider versions take precedence, but explicit provider of "BC" allows choice
- enabled native versions of SHA-384 and SHA-512
- pruned MD4 implementation

frameworks/base
- frameworks and CoreTests modules now depend on bouncycastle
- update preloades classes for NativeBN package change
- moved CryptoTest to libcore

libcore
- core now builds without bouncycastle sources
- core-tests, core-tests-support, core-tests-supportlib now depend on bouncycastle
- removed libcore/openssl directory, moving NativeBN to java/math
- minor cleanup of Provider, Security, Services style while working on ProviderTest
- added new OpenSSLProvider registered as first provider to have
priority over the others to ensure our native implementations are used
- moved BouncyCastle to have priority as a provider over Harmony
- JarVerifier and JarUtils now implicitly use OpenSSLMessageDigest
- Cleanedup OpenSSLSignature, implementation needs to be finished to move to OpenSSLProvider
- To avoid using PEMWriter from BouncyCastle, NativeCrypto now takes binary encoded certs and keys
This is more efficient as well avoiding the base64 decode/encode of the binary data
- removed SHA-224 to match the RI

packages/apps/CertInstaller
- CertificateInstaller module now depends on bouncycastle
this is the only app to depend on bouncycastle

system/core
- updated BOOTCLASSPATH

Change-Id: I6205366b12baec4331b4a76e2c85d8324bf64b2c
ativeBN.cpp
ativeCrypto.cpp
egister.cpp
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
ub.mk
e377c5a424823bacf28e8ffb2a2f02bfe46d4a2b 26-Jun-2010 Elliott Hughes <enh@google.com> Rewrite java.util.regex to use ICU's C++ API.

I've also removed a bunch of dead code and changed the interface to reduce the
number of JNI transitions. Error checking is more uniform, various special
cases have been removed, and we pass all the tests referenced by
libcore/luni/src/test/java/tests/regex/AllTests.java for the first time.

This should also be a stepping-stone to fixing http://b/2777924, removing the
need to copy the input string to the native heap.

Bug: 2587040
Change-Id: I62685a2384db441cd02df159e117187f3175e10d
ativeRegEx.cpp
egister.cpp
ava_util_regex_Matcher.cpp
ava_util_regex_Pattern.cpp
ub.mk
21557bb6a8f35a2f9889adba449cac950c9d41b9 23-Jun-2010 Elliott Hughes <enh@google.com> Add TimeZones.forLocale, plus some tidying.

The new feature here is TimeZones.forLocale and the accompanying JNI. I've also
taken the liberty of pulling the time zone stuff out of ICU.java and ICU.cpp,
and I've moved some of the ICU-related code I've written recently (NativeIDN,
NativeNormalizer, and NativePluralRules) into a new libcore.icu package.

I've also renamed various things so the implementation details use the same
terminology as the thing they're implementing.

Bug: 2790386
Change-Id: Ie39a2f5f7023e8e29864de15790be8a660f5cba6
CU.cpp
ativeIDN.cpp
ativeNormalizer.cpp
ativePluralRules.cpp
egister.cpp
imeZones.cpp
ub.mk
4e3714f7fe8ac7f6b20896038e491d378f4e6464 22-Jun-2010 Elliott Hughes <enh@google.com> Stop using GetStringChars/ReleaseStringChars.

Also fix unused variable warnings in "ExpatParser.cpp".

This fixes one actual bug in the regular expression code where we weren't
returning after throwing an exception from JNI, in a case where executing
the remaining code in the native method would cause a crash.

Change-Id: Ib5ce7ea9a3b6476cf47bda2384d5ba43579c785a
CU.cpp
ativeBreakIterator.cpp
ativeDecimalFormat.cpp
ativeRegEx.cpp
rg_apache_harmony_xml_ExpatParser.cpp
fc5d7aa05bfc96d89a47b0d92fa3180dc18d6c2b 22-Jun-2010 Elliott Hughes <enh@google.com> Make valgrind stack traces more readable by using better names.

Change-Id: I91e79a07207bb8cc4ae1a58f9d1c28af2bb56a22
ativeRegEx.cpp
91499048b3322f6de5e5f823ccc8a83f0ed87b71 22-Jun-2010 Elliott Hughes <enh@google.com> Fix build.

libcore/luni/src/main/native/org_apache_harmony_xml_ExpatParser.cpp: In function 'char* cloneStrings(const char**, int)':
libcore/luni/src/main/native/org_apache_harmony_xml_ExpatParser.cpp:1237: error: 'env' was not declared in this scope

While I'm here, I've inlined cloneStrings into its sole caller (where,
conveniently, 'env' is available).

Change-Id: I9cc5b5946e7ad636cf8ff938cac77411f21f3b99
rg_apache_harmony_xml_ExpatParser.cpp
4eafbcc36e530ad09e0d6617d50e74e635e63f2e 22-Jun-2010 Elliott Hughes <enh@google.com> Simplify resource management in ExpatParser's JNI.

valgrind complained about calling free(3) on a pointer allocated by new.
Tidy this code up to be a little more C++-like. valgrind appears happy now,
but there shouldn't be any functional changes.

Bug: 2785827
Change-Id: Ibbb79d52c7707ff6f86cc7444e00115c1b89b687
rg_apache_harmony_xml_ExpatParser.cpp
7775409378596fd980dbd576f9738d337bd8a76d 18-Jun-2010 Elliott Hughes <enh@google.com> Add support for ICU's PluralRules.

Note that this doesn't address the original submitter's complaint: ICU agrees
that zero isn't a special case in English. What this does is allow us to fix
getQuantityString to work with languages other than English and Czech (which
currently have hard-coded implementations in frameworks/base).

Bug: 2663392
Change-Id: I4cf80a61cd5183636381511d6b860d2059f788ee
ativePluralRules.cpp
egister.cpp
ub.mk
f10b2437ae5ec073f8c4118f7235022ba83667c4 18-Jun-2010 Elliott Hughes <enh@google.com> Minor bidi tidying.

Fix the bidi code to consistently use finally blocks to ensure we can't
leak native UBidi objects. Rename BidiWrapper to NativeBidi since it isn't
a class with a finalizer that wraps a UBidi: it's just a namespace for static
native methods.

Also remove the useless public constructor from NativeCollation.

Bug: 2772065
Change-Id: I441ff4811bb66c37daf270d74d5403b9848cce90
idiWrapper.cpp
ativeBidi.cpp
egister.cpp
ub.mk
74c50755c30b3afd4852e006aeedeb25232ca757 17-Jun-2010 Elliott Hughes <enh@google.com> Rewrite FileDescriptor and ProcessManager's JNI in terms of JNIHelp.h's API.

This lets us remove JniConstants::fileDescriptorClass and rely on the cached
jclass in JNIHelp.c.

Change-Id: Ie9b067113050e95413c28befe0143a8bbf2113de
niConstants.cpp
niConstants.h
egister.cpp
ava_io_FileDescriptor.c
ava_io_FileDescriptor.cpp
ava_lang_ProcessManager.cpp
ub.mk
a9f5c16a864ff63ba63f810410f8a27c086d5d52 17-Jun-2010 Elliott Hughes <enh@google.com> Remove dynamic calls to FindClass.

Initially, I was just fixing a threading bug in NativeDecimalFormat.cpp where
we were bypassing GCC's built-in static initializer thread safety. This led me
to the question of how expensive FindClass is, which led me to creating a new
canonical cache of jclasses.

Here's the motivating benchmark, showing the cost of calling an empty regular
(non-native) method, an empty native method, a native method that calls
FindClass, a native method that calls FindClass and GetFieldID, and a native
method that calls FindClass and GetMethodID:

benchmark ns logarithmic runtime
NoArgsRegular 74 ||||||||||||||
NoArgsNative 428 XX|||||||||||||||||||
FindClass 3064 XXXXXXXXXXXXXXXX|||||||||||
FindClassGetField 3654 XXXXXXXXXXXXXXXXXXX|||||||||
FindClassGetMethod 5634 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Change-Id: I41ab2b347895f043a7e21d8fa19e4541e198c3fc
idiWrapper.cpp
CU.cpp
niConstants.cpp
niConstants.h
ativeConverter.cpp
ativeDecimalFormat.cpp
ativeRegEx.cpp
etworkUtilities.cpp
egister.cpp
ava_io_File.cpp
ava_io_FileDescriptor.c
ava_io_ObjectStreamClass.cpp
ava_lang_ProcessManager.cpp
ava_net_InetAddress.cpp
ava_net_NetworkInterface.cpp
ava_util_zip_Deflater.cpp
ava_util_zip_Inflater.cpp
rg_apache_harmony_luni_platform_OSMemory.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
rg_apache_harmony_xml_ExpatParser.cpp
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
ub.mk
alueOf.cpp
94782d07dd2d65b1a37fddca68eb9a9ac81ada4a 16-Jun-2010 Elliott Hughes <enh@google.com> Use Integer.valueOf rather than "new Integer" (et cetera) from JNI.

Also factor it out rather than keep duplicating it.

Change-Id: I6349668f4676f1e0a7dd6fdc101dd1784c5465fb
CU.cpp
ativeDecimalFormat.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
ub.mk
alueOf.cpp
alueOf.h
2375e98761ddc54d0a30a6c06a835a2f723dc748 11-Jun-2010 Elliott Hughes <enh@google.com> Merge "Support stand-alone month and weekday names in SimpleDateFormat." into dalvik-dev
143e8c9cf91cfc01c3c91c8e93cad661ec7554ee 11-Jun-2010 Elliott Hughes <enh@google.com> Support stand-alone month and weekday names in SimpleDateFormat.

Also rewrite the SimpleDateFormat documentation.

Bug: 2633414
Change-Id: I8fcc3b1f73dd6f264dd292852a8ab0c5a2742f5b
CU.cpp
6969125ec1a8073ca1142df2d663cf9c052bfb6c 11-Jun-2010 Elliott Hughes <enh@google.com> www.ietf.org is the canonical home for RFCs.

Change-Id: Ib83ff61230649757917346645f6cf47d9df3f348
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
6decf73f7142017e514bb1beb8aa4076848b968f 07-Jun-2010 Elliott Hughes <enh@google.com> am c7787cfa: Merge "ICU4.4.1 upgrade 1. Replaced the temp Android patch for BigDecimal support with ICU APIs. 2. Changed ICU.cpp for resource re-structure in ICU4.4 release. 3. Fixed the test data for NumberFormat test caused by the locale data changes."

Merge commit 'c7787cfacfb9800f57c4506db1ba773460335af2' into dalvik-dev

* commit 'c7787cfacfb9800f57c4506db1ba773460335af2':
ICU4.4.1 upgrade
c7787cfacfb9800f57c4506db1ba773460335af2 07-Jun-2010 Elliott Hughes <enh@google.com> Merge "ICU4.4.1 upgrade 1. Replaced the temp Android patch for BigDecimal support with ICU APIs. 2. Changed ICU.cpp for resource re-structure in ICU4.4 release. 3. Fixed the test data for NumberFormat test caused by the locale data changes."
947eeb80f985827209c9500851e288504d58ec2e 03-Jun-2010 claireho <chinglanho@gmail.com> ICU4.4.1 upgrade
1. Replaced the temp Android patch for BigDecimal support
with ICU APIs.
2. Changed ICU.cpp for resource re-structure in ICU4.4 release.
3. Fixed the test data for NumberFormat test caused by the locale
data changes.

Change-Id: I307e798f1a135a5024a693d23363733d020ed22f
CU.cpp
ativeDecimalFormat.cpp
abf945fb9ce99d8c2769ac5b2691b2732fa59887 04-Jun-2010 Elliott Hughes <enh@google.com> Bullet-proof the lseek/read in Inflater.setFileInput.

Also document why that non-API method exists, and that we don't have
benchmarks to support the claimed optimization.

Also be more consistent about setting LOG_TAG, and fix a few old-school
copyright headers.

Change-Id: If9fdc4583eaf91275ed44e2dc56174819d1913d0
etworkUtilities.cpp
ava_io_Console.cpp
ava_io_File.cpp
ava_io_ObjectInputStream.cpp
ava_io_ObjectOutputStream.cpp
ava_io_ObjectStreamClass.cpp
ava_lang_Double.cpp
ava_lang_Float.cpp
ava_lang_Math.cpp
ava_lang_StrictMath.cpp
ava_lang_System.cpp
ava_net_NetworkInterface.cpp
ava_util_zip_Adler32.cpp
ava_util_zip_CRC32.cpp
ava_util_zip_Deflater.cpp
ava_util_zip_Inflater.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
rg_apache_harmony_luni_util_NumberConvert.cpp
ip.h
9b4866d3438f42fb2c0df788989261afe72bf713 04-Jun-2010 Elliott Hughes <enh@google.com> Simplify our use of ucnv_close.

ucnv_close -- like most modern "free" APIs -- ignores NULL. It also calls each
callback giving it a convenient opportunity to clean up, which lets us get rid
of some particularly nasty code that was trying to do the cleanup forcibly from
outside.

Change-Id: I77ccf37235a222f38d897516d1226a026d8cc50b
ativeConverter.cpp
466b89ce07ef0ce77504f45690dba56cf933fd41 03-Jun-2010 Elliott Hughes <enh@google.com> Merge remote branch 'goog/dalvik-dev' into mm

Change-Id: I6905802cfe7cda73bb6f52fe0cc79767b4645e82
f27475b3c3fc4c95569b9a4045cae1d6e846354a 03-Jun-2010 Jesse Wilson <jessewilson@google.com> Fixing a bug in inflate where refilling a file doesn't update the zip stream.

See bug http://b/issue?id=2734751

Change-Id: Iff5f7e564518805151a60f56d6f19a584c9e0b44
ava_util_zip_Inflater.cpp
753dcd862b31e85766225590d90ba0b9f481176f 02-Jun-2010 Elliott Hughes <enh@google.com> Refactor some of the OSNetworkSystem stuff to more appropriate homes.

Also rewrite PlainDatagramSocketImpl.peek in terms of existing primitives
rather than requiring its own. I still don't see how it can get called, but
at least now it doesn't require its own native code.

Bug: 2686833

Change-Id: I0453add66dab4c7095ee2a3f51a49efbd1205598
etworkUtilities.cpp
etworkUtilities.h
ava_net_InetAddress.cpp
ava_net_NetworkInterface.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
ub.mk
7d52d787302b862019da41aa753646d88d43fd61 01-Jun-2010 Elliott Hughes <enh@google.com> Rewrite Charset.contains to push the UConverter allocation/deallocation down to C++.

This also fixes the resource management so we can't leak decoders/encoders if
a constructor throws. (I thought I had a bug for fixing all classes with
finalizers in this way, but I can't find it.)

Bug: 2726958
Change-Id: I169242786cbbe8665aad151ca8f3946bc8c61603
ativeConverter.cpp
bf87c56b39383f6b11c36c3cdc93df4b03fed914 28-May-2010 Brian Carlstrom <bdc@google.com> Merge remote branch 'goog/dalvik-dev' into dalvik-dev-to-master

Conflicts:
JavaLibrary.mk
luni/src/main/java/java/lang/System.java
luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java
luni/src/test/java/java/net/URLConnectionTest.java
support/src/test/java/tests/TestSuiteFactory.java
x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp

Change-Id: I1038f749c8c9bd640aae7ca96627810936454883
05960876dff6a5b686821eed8f7ae7cef5af4f50 27-May-2010 Elliott Hughes <enh@google.com> Enhance ScopedUtfChars to include the null check most callers were missing.

Also switch most non-users over to ScopedUtfChars.

Also ensure all users check that ScopedUtfChars was successful in getting the
chars.

Also rewrite ObjectInputStream and ObjectOutputStream without duplication.

Change-Id: I929d00fe3ff50b303cba4a2cf2269355e9fef5f9
CU.cpp
ativeBreakIterator.cpp
ativeCollation.cpp
ativeConverter.cpp
Character.cpp
ava_io_ObjectInputStream.cpp
ava_io_ObjectOutputStream.cpp
ava_lang_System.cpp
ava_net_InetAddress.cpp
rg_apache_harmony_luni_util_fltparse.cpp
rg_apache_harmony_xml_ExpatParser.cpp
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
0c131a2ca38465b7d1df4eaee63ac73ce4d5986d 21-May-2010 Brian Carlstrom <bdc@google.com> RI 6 support for javax.net.ssl

Summary:
- RI 6 support for javax.net.ssl
- SSLEngine fixes based on new SSLEngineTest
- fix Cipher.checkMode bug recently introduced in dalvik-dev

Details:

Fix Cipher.checkMode that was preventing most javax.net.ssl tests from working

luni/src/main/java/javax/crypto/Cipher.java

RI 6 has introduced the concept of a "Default" SSLContext. This is
accessed via SSLContext.getDefault() and also
SSLContext.getInstance("Default"). Harmony had its own
DefaultSSLContext but it was not created via an SSLContextSpi. It also
was a single shared instance whereas the new RI6 Default SSLContext
shares internal SSLSessionContext instances between different Default
SSLContexts.

Refactored the old code into an SSLContextImpl subclass that
allows it to be created via SSLContext.getInstance. SSLContextImpl
ensures that we only ever create one set of SSLSessionContext
instances for the Default context.

luni/src/main/java/javax/net/ssl/DefaultSSLContext.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/DefaultSSLContextImpl.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLContextImpl.java

Added SSLContext.getDefault and SSLContext.setDefault

luni/src/main/java/javax/net/ssl/SSLContext.java

Replace dependencies of old DefaultSSLContext with use of SSLContext.getDefault

luni/src/main/java/javax/net/ssl/SSLServerSocketFactory.java
luni/src/main/java/javax/net/ssl/SSLSocketFactory.java

Register "SSLContext.Default" as DefaultSSLContextImpl class for SSLContext.getInstance()

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

Added constant for new "Default" standard name and added it to
SSL_CONTEXT_PROTOCOLS. New tests based on SSL_CONTEXT_PROTOCOLS
made it clear that neither Android or RI support SSLv2 so removed
it from SSL_CONTEXT_PROTOCOLS and SSL_SOCKET_PROTOCOLS. Added
constant for TLS as well which was previously scattered all over
tests. Remove SSLv2Hello from SSL_SOCKET_PROTOCOLS for Android
since with OpenSSL disablign SSLv2 means you can not use
SSLv2Hello either.

support/src/test/java/javax/net/ssl/StandardNames.java

Added tests for SSLContext.getDefault and
SSLContext.setDefault. Changed existing tests to work on all
protocols including new "Default".

luni/src/test/java/javax/net/ssl/SSLContextTest.java

RI 6 has introduced the notion of SSLParameters which encapsulate SSL
the handshake parameters of desired cipher suites, protocols, and
client authentication requirements.

The main new class SSLParameters is basically just a bag of fields
with accessors and a couple simple constructors. The only things
of note are that it clones all String arrays on input and output
and the setters for the two boolean fields ensure that only one is
true at a time.

luni/src/main/java/javax/net/ssl/SSLParameters.java

Added SSLContext.getDefaultSSLParameters and
SSLContext.getSupportedSSLParameters which simply delegate to the
SSLContextSpi.

luni/src/main/java/javax/net/ssl/SSLContext.java

Added abstract SSLContextSpi.engineGetDefaultSSLParameters and
SSLContext.engineGetSupportedSSLParameters.

luni/src/main/java/javax/net/ssl/SSLContextSpi.java

Added engineGetDefaultSSLParameters and
engineGetSupportedSSLParameters implementation. The RI documents
in SSLContextSpi that these are implemented by default by creating
a socket via the SSLContext's SocketFactory and asking for the
enabled/supported cipher suites and protocols respectively, so
that is what is done. The doc mentions throwing
UnsupportedOperationException if there is a problem, so we do that
as well.

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

Added {SSLEngine,SSLSocket}.{getSSLParameters,setSSLParameters}
which are analogous.

luni/src/main/java/javax/net/ssl/SSLEngine.java
luni/src/main/java/javax/net/ssl/SSLSocket.java

Added SSLParametersTest

luni/src/test/java/javax/net/ssl/SSLParametersTest.java
luni/src/test/java/javax/net/ssl/AllTests.java

Added SSLContext.get{Default,Supported}SSLParameters tests

luni/src/test/java/javax/net/ssl/SSLContextTest.java

Added SSLSocket.{getSSLParameters,setSSLParameters} tests and added
some extra asserts to test_SSLSocketPair_create based on experience
with test_SSLEnginePair_create.

luni/src/test/java/javax/net/ssl/SSLSocketTest.java

Dummy implementation of new SSLContextSpi for test classes.

support/src/test/java/org/apache/harmony/security/tests/support/MySSLContextSpi.java
support/src/test/java/org/apache/harmony/xnet/tests/support/MySSLContextSpi.java

Other minor RI 6 API changes:

RI 6 removed Serializable from HandshakeCompletedEvent and SSLSessionBindingEvent

luni/src/main/java/javax/net/ssl/HandshakeCompletedEvent.java
luni/src/main/java/javax/net/ssl/SSLSessionBindingEvent.java

RI 6 added generic types to the KeyStoreBuilderParameters List
constructor and accessor as well as to
SSLSessionContext.getIds. Fixed tests to compile with generic types.

luni/src/main/java/javax/net/ssl/KeyStoreBuilderParameters.java
luni/src/main/java/javax/net/ssl/SSLSessionContext.java
luni/src/test/java/tests/api/javax/net/ssl/KeyStoreBuilderParametersTest.java

SSLEngine improvements. Since I was changing SSLEngine, I wrote an
SSLEngineTest based on my SSLSocketTest to do some simply sanity
checking. It expose a number of issues. I've fixed the small ones,
marked the rest as known failures.

Renamed some TLS_ cipher suites to SSL_ to match JSSE standard
names. These were all old suites no longer supported by RI or
OpenSSL which is why they were missed in an earlier cleanup of this
type in this class. Also fixed SSLEngine supported cipher suites
list not to include SSL_NULL_WITH_NULL_NULL which is not a valid
suite to negotiate.

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

SSLEngine instances can have null host values, which caused a
NullPointerException in the ClientSessionContext implementation.

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

SSLEngine tests were failing because SSLParameters was throwing
NullPointerException instead of IllegalArgument exception on null
element values. Fixed null pointer message style while I was here.

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

Fixed SSLEngine instances to default to server mode like RI

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

Fixed KEY_TYPES based on SSLEngine implementation. Removed dead
code NativeCrypto.getEnabledProtocols which was recently made
obsolete. Cleaned up null exception messages to follow our convention.

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

Added SSLEngineTest which parallels SSLSocketTest in its
coverage. Similarly added TestSSLEnginePair which loosely parallels
TestSSLSocketPair.

luni/src/test/java/javax/net/ssl/SSLEngineTest.java
luni/src/test/java/javax/net/ssl/AllTests.java
support/src/test/java/javax/net/ssl/TestSSLEnginePair.java

SSLEngineTest betters exposed the differences between SSLSocket and
SSLEngine supported cipher suites. StandardNames now has an
CIPHER_SUITES_SSLENGINE definition which denotes what is missing
and what is extra and why in the SSLEngine implementation.

support/src/test/java/javax/net/ssl/StandardNames.java

Created StandardNames.assert{Valid,Supported}{CipherSuites,Protocols}
to factor out some code test code that is also used by new tests.

support/src/test/java/javax/net/ssl/StandardNames.java
luni/src/test/java/javax/net/ssl/SSLSocketFactoryTest.java
luni/src/test/java/javax/net/ssl/SSLSocketTest.java

Remove SSLSocketTest known failure and add new SSLEngineTest known failures

expectations/knownfailures.txt

SSL_OP_NO_TICKET change was recently merged from master which required some fixes.

For the moment, sslServerSocketSupportsSessionTickets always returns false.

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

Fixed flakey test_SSLSocket_HandshakeCompletedListener which had a
race because the client thread look in the server session context
for an session by id potentially before the server thread had a
chance to store its session. Made noticable because of
SSL_OP_NO_TICKET recently merged from master (before this code
path was host only, not device)

luni/src/test/java/javax/net/ssl/SSLSocketTest.java

Fix checkjni issue where we need to check for pending exception in
OpenSSL callback. Possibly introduced by recent merge of
SSL_OP_NO_TICKET from master.

luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp

Expectation updates

Remove SSLSocketTest known failure and add new SSLEngineTest known failures

expectations/knownfailures.txt

Tag test_SSLSocket_getSupportedCipherSuites_connect as large

expectations/taggedtests.txt

Misc changes:

opening brace on wrong line

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

Long line cleanup while debugging

luni/src/main/java/org/apache/harmony/xnet/provider/jsse/HandshakeProtocol.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLServerSocketFactoryImpl.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketFactoryImpl.java
support/src/test/java/javax/net/ssl/TestKeyStore.java

Removed bogus import

luni/src/test/java/javax/net/ssl/SSLSessionContextTest.java

Comment clarify while debugging

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

Ctor -> Constructor in comment

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

Fixed naming of SocketTest_Test_create to TestSocketPair_Create to match renamed classes

luni/src/test/java/javax/net/ssl/SSLSocketTest.java

Change-Id: I99505e97d6047eeabe4a0b93202075a0b2d486ec
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
f7b8b35bcc93523ef224039b009608b1ea3b81f3 22-May-2010 Brian Carlstrom <bdc@google.com> Manual recreation of dalvik change 720d1e962e248a30f81c1493081ff4c01e35c839 in libcore

Disable SSL Session Ticket extension for OpenSSLSocket

Due to compatability issues with some sites, disable this SSL extension which wasn't present in Eclair. See also:

b/2682876 Some ssl sites cause "A secure connection could not be established" error

Change-Id: Ife94f65a063011f09553877a9fb71f42ecc76f5e
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
ac0ccbb85b4a96ba79b4e770f5b71687bf8f25e9 21-May-2010 Elliott Hughes <enh@google.com> Finish removing Get/Release Critical, tidying up "NativeConverter.cpp".

Use our new abstractions to finally let the code show through the cruft.

Bug: 2663177
Change-Id: I872e8fea11ae77d5059181374cb2ff7e7d73573e
ativeConverter.cpp
ebca53a204302c5e559b5c2c9014b48048faf4d4 21-May-2010 Elliott Hughes <enh@google.com> Add write-back ScopedPrimitiveArrays (and use them).

I've left the remaining Get/Release Critical calls in "NativeConverter.cpp"
for the next patch, even though getting into position to fix them is part of
the point of this patch.

Change-Id: I99e15a3cf3919008343ae4dc856c86ced233e07a
idiWrapper.cpp
ativeConverter.cpp
ativeRegEx.cpp
ava_io_File.cpp
ava_util_zip_Adler32.cpp
ava_util_zip_CRC32.cpp
ava_util_zip_Deflater.cpp
ava_util_zip_Inflater.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
rg_apache_harmony_luni_util_NumberConvert.cpp
rg_apache_harmony_xml_ExpatParser.cpp
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
40679a19b5de44363aa3f68d77cc13a74b41ffd6 21-May-2010 Elliott Hughes <enh@google.com> Merge "Fix more Charset/CharsetDecoder/CharsetEncoder bugs." into dalvik-dev
c60bc1815dca549f3fb4e572f6aac749d7fa9fc6 21-May-2010 Elliott Hughes <enh@google.com> Fix more Charset/CharsetDecoder/CharsetEncoder bugs.

Another round of Get/Release Critical removal led me to some code that couldn't
possibly be right, and wasn't. This patch fixes a large number of our
Charset-related bugs, including ones that previous hacks were added to paper
over. With this patch, we have three failures, all "new", but all there since
the start, and relating to the fact that our UTF-16 and UTF-32 encoders don't
write big-endian output on little-endian devices (for which I've raised
http://b/2702411).

Bug: 2663177
Change-Id: I70dfa55f88a3f635528be3ad27b2a5fc1bfb70fc
ativeConverter.cpp
aacf6f9741dea0f12fbff5e7696e53f251177280 20-May-2010 Brian Carlstrom <bdc@google.com> Enable Diffie-Hellman cipher suites

Enable Diffie-Hellman cipher suites in NativeCrypto (and in
StandardNames to match for testing). This means we now have the same
default cipher suite list as RI 5.

luni/src/main/java/org/apache/harmony/xnet/provider/jsse/NativeCrypto.java
support/src/test/java/javax/net/ssl/StandardNames.java

Enabling DH made it obvious that the RI check for enable cipher suites
on SSLServerSocket.accept was not as stringent as first
thought. Apparently they don't care if all enabled cipher suites have
certificates/keys, just that at least one of them will work, even if
its anonymous. Factored out the logic to check this into
checkEnabledCipherSuites for clarity along with the supporting
checkForPrivateKey. Also only check if the socket is in server mode,
since its fine to have nothing configured for server acting as a
client for handshake purposes.

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

The real work to enable Diffie-Hellman was to use
SSL_CTX_set_tmp_dh_callback to set a callback to get DH
parameters. There are two ways to create the parameters. The first is
to use DH_generate_parameters_ex which is very slow (minutes) as is
recommended as install time option. The second is to use
DSA_generate_parameters_ex followed by DSA_dup_DH, which is faster for
a single call, but must be done every time, so slower overall. We
currently take the second approach to just have DH working.

luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp

Changed ephemeral RSA keys to be stored per SSL in AppData, not in a static global.

luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp

Fix LS_ to TLS_ typo in commented out constant. Removed easy to miss wrapping in array definition.

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

Renamed CipherSuites defaultPretendant to defaultCipherSuites which
led to renaming the CipherSuites constants to follow the coding style.

luni/src/main/java/org/apache/harmony/xnet/provider/jsse/CipherSuite.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/ClientHandshakeImpl.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/DigitalSignature.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLServerSocketImpl.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLParameters.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/ServerHandshakeImpl.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/ServerKeyExchange.java

Change-Id: Ia38de48cabb699b24fe6e341ba79f34e3da8b543
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
c76d7a5dcf2170400e49f7870a2733ca58e06569 20-May-2010 Brian Carlstrom <bdc@google.com> Merge "Add RSA ephemeral callback for SSL_RSA_EXPORT_WITH_RC4_40_MD5 support (and move to UniquePtr)" into dalvik-dev
b5b39e448a80d3bfacbc56afd769855e77f0fb7f 20-May-2010 Brian Carlstrom <bdc@google.com> Add RSA ephemeral callback for SSL_RSA_EXPORT_WITH_RC4_40_MD5 support (and move to UniquePtr)

Summary:

Used SSL_CTX_set_tmp_rsa_callback to provide a callback for supplying
ephemeral RSA key for export cipher SSL_RSA_EXPORT_WITH_RC4_40_MD5
(aka EXP-RC4-MD5)

As part of this added rsaGenerateKey and while doing that started
adding UniquePtr deleters for BN and RSA and then just decided to do
the rest of the file.

Details:

Added tmp_rsa_callback to provide emphemeral RSA keys

luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp

Removed last KnownFailure in my JSSE tests.

luni/src/test/java/javax/net/ssl/SSLSocketTest.java

Switching to UniquePtr to manage SSL types.
Found a couple places not error checking along the way.
Removed LOGE from throw* methods since jniThrowException does that.

luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp

Change-Id: I27413c0073cd2cc405c83d35a0772c7901ce25c6
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
cf6c3a752da274cc5025191d3bcd62e6222f4a4c 19-May-2010 Elliott Hughes <enh@google.com> Fix CharsetEncoder.replaceWith, and simplify our implementation.

All I wanted to do was remove some more Get/Release Critical calls,
but I stumbled across some code that couldn't possibly be right.

Bug: 2663177
Change-Id: I82e240fe27ff9fcfe7f036c2d7708a9e55afa3ee
ativeConverter.cpp
f3f7cc7cb8650bed3b3e6c94104c79e20ef565dd 19-May-2010 Brian Carlstrom <bdc@google.com> SSLSocket.startHandshake should throw SSLProtocolException on handshake protocol error

Added throwSSLProtocolExceptionStr and used it in the SSL_ERROR_SSL case.
Also replaced 0 with SSL_ERROR_NONE in throwSSLExceptionWithSslErrors calls for clarity.
Improved throwSSLExceptionWithSslErrors to show ERR_get_error information in SSL_ERROR_NONE case.

luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp

Removed penultimate KnownFailure. Updated comment to use more official Kerberos reference URL.

luni/src/test/java/javax/net/ssl/SSLSocketTest.java

Change-Id: I2fb847ba92a3464029d1103fadf05ec16126bda9
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
3b0c7720d994c203f85b3093615f268a260bdec0 19-May-2010 Elliott Hughes <enh@google.com> Fix BidiWrapper to not ask for arrays it's used read-only to be written back to the Java heap.

Bug: 2663177
Change-Id: Id77df49a1839ce1daa25ba9998be25342c4c8b06
idiWrapper.cpp
6df6339ecd4662d351c622a59533cbbe9f275ffd 18-May-2010 Brian Carlstrom <bdc@google.com> Client certificates should only be set on request from server

Client certificates should only be set into the SSL* when requested by
the server so that after the handshake is completed the client can
inspect its SSLSession to see what certificate if any was
requested. Previously the value was always non-null even if the server
didn't request the certificate.

- Created RAND_seed and RAND_load_file out of the NativeCrypto.SSL_new
- NativeCrypto.SSL_new now simply performs SSL_new and does not
deal with certificates, private keys, or random seeds.
- Removed helper version of NativeCrypto.SSL_new
Moved code to OpenSSLSocketImpl.setCertificate
- Created SSL_use_certificate, SSL_use_PrivateKey, SSL_check_private_key from SSL_new.
These are used not just on server handshake but also via clientCertificateRequested callback.
- Merged CertificateChainVerifier and HandshakeCompletedCallback into new SSLHandshakeCallbacks
while adding new clientCertificateRequested callback from OpenSSL C code to Java
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/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp

In addition to supporting NativeCrypto.java changes, also changed
to_SSL_CTX and to_SSL_SESSION to allow null checking and throwing
NullPointerException. Changed these and to_SSL to log exception on
JNITrace, taking these logs out of individual functions. There
were a lot of null checks missing previously, mostly in
to_SSL_SESSION cases.

luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp

All KnownFailures now fixed.

luni/src/test/java/javax/net/ssl/SSLSessionTest.java

Three more KnownFailures now fixed.

luni/src/test/java/javax/net/ssl/SSLSocketTest.java

Change-Id: Iddcd5512e8395d947d3b894f03e3a059e63afe8a
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
8044bf6b446c93cd29c5753544246316f269064f 18-May-2010 Elliott Hughes <enh@google.com> Make ScopedLocalRef more convenient, and use it more widely.

Even though every reference type is a jobject, it's useful to be able to use
more specific types.

Change-Id: Id8056d0e18380675c90f08c4173a8b34b4d5d983
CU.cpp
ativeConverter.cpp
ava_io_File.cpp
ava_net_InetAddress.cpp
rg_apache_harmony_xml_ExpatParser.cpp
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
99c59bfa432e36933a7a5033fba8b89209f737bc 18-May-2010 Elliott Hughes <enh@google.com> Expand upon the old ScopedByteArray, and start removing some of the Get/ReleaseCritical calls.

This adds Scoped*Array classes for all primitive types, and switches all
read-only users of arrays over. At the same time, all read-only users of
Get/ReleaseCritical get switched to non-critical access.

Bug: 2663177
Change-Id: I5542cea3e24faa987ced463fcb695b9598da94af
idiWrapper.cpp
ativeConverter.cpp
ava_io_File.cpp
ava_util_zip_Adler32.cpp
ava_util_zip_CRC32.cpp
ava_util_zip_Deflater.cpp
ava_util_zip_Inflater.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
rg_apache_harmony_xml_ExpatParser.cpp
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
204cab3c22b4d75c866c95e2d2eec42e14cbd924 18-May-2010 Brian Carlstrom <bdc@google.com> Supported cipher suites improvements

Added new test_SSLSocket_getSupportedCipherSuites_connect to make sure
all cipher suites we claim work actually do. It clearly exposed that
although a large number of cipher suites are supported by libssl.so,
they are not properly wired up into the OpenSSL JSSE
implementation. In particular Elliptic Curve has been disabled in our
version Bouncy Castle does not work. In addition Diffie-Hellman does
not work because we need to further integration work with OpenSSL via
SSL_set_tmp_dh_callback or SSL_set_tmp_dh. Finally,
SSL_RSA_EXPORT_WITH_RC4_40_MD5 doesn't work but that is being left as
KnownFailure for more immediate cleanup based on ServerHandshakeImpl's
handling of KeyExchange_RSA_EXPORT as part of having OpenSSL call us
back for certificates dynamically.

luni/src/test/java/javax/net/ssl/SSLSocketTest.java

Refactored TestSSLContext.createKeyStore to create TestKeyStore which
now factors out TestSSLContext.createKeys from the old createKeyStore
method, which allows createKeys to be called multiple times for
different key algorithms (for example DSA in addition to RSA). Also
added a reusable singleton instance to cut down on test execution
time.

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

Removed publicAlias/privateAlias from TestSSLContext since we now
include both RSA and DSA key pairs in they KeyStore by default. Added
TestSSLContext.assertCertificateInKeyStore methods to help tests the
previously used the alias fields fields. TestSSLContext.create API
changed as well since the alias names are no longer
required. TestSSLContext.createClient now needs to iterate over all
server certificates when setting up its TrustManager instead of just
grabbing one by alias name.

support/src/test/java/javax/net/ssl/TestSSLContext.java
luni/src/test/java/javax/net/ssl/SSLContextTest.java
luni/src/test/java/javax/net/ssl/SSLSessionTest.java
luni/src/test/java/javax/net/ssl/SSLSocketTest.java

TestSSLSocketPair.connect now allows optional inclusion of server
cipher suite list.

support/src/test/java/javax/net/ssl/TestSSLSocketPair.java
luni/src/test/java/javax/net/ssl/SSLSessionContextTest.java

Turning off Elliptic Curve and Diffie-Hellman which are not currently
working. Updating test expectations to match.

luni/src/main/java/org/apache/harmony/xnet/provider/jsse/NativeCrypto.java
support/src/test/java/javax/net/ssl/StandardNames.java

Turn on registration of ECDSA and DSA since this part is currently
functional (and excercised by TestKeyStore.create())

luni/src/main/java/org/bouncycastle/x509/X509Util.java

Improve logging by including SSL pointer in error messages, which
makes it easier to relate these errors to JNI_TRACE messages.

luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp

Change-Id: I014d001a6a21a46c360678a346d3a3c8232f4d53
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
c1e74f07ebf5ee1db99bb5ac717fb1c0ffd7969e 15-May-2010 Brian Carlstrom <bdc@google.com> Merge "Remove ScopedGlobalRef (and other cleanups)" into dalvik-dev
3534c7cb3d4c67e3a4f2925fc7ecec43aeed879a 15-May-2010 Brian Carlstrom <bdc@google.com> Remove ScopedGlobalRef (and other cleanups)

ScopedGlobalRef caused more trouble that it was worth. Rather than
trying to fix it to require updating of the JNIEnv, remove it to
remove the temptation for others to use it.

Also update SSL_set_ciphers_lists to use ScopedLocalRef and add HTML
anchors to Standard names javadoc JSEE references.

Change-Id: Ic3ed1bae3f29ee971d4461de31395b78c4949090
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
f554229f9293b078b77205f37e679105115a7056 15-May-2010 Elliott Hughes <enh@google.com> More cleanup of "hycomp.h".

This makes sure we ask the system whether it's big- or little-endian, and
doesn't make assumptions about the sizes of built-in types.

This fixes a regression I introduced last week with the previous cleanup,
affecting the double/string conversions. We still fail some of those tests,
but now we're back to only failing the ones we've always failed...

Change-Id: I343c363b01fc34b32a4d5afbc153bfe4c0161137
bigint.cpp
bigint.h
ommonDblParce.cpp
ommonDblParce.h
ltconst.h
ycomp.h
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
rg_apache_harmony_luni_util_NumberConvert.cpp
rg_apache_harmony_luni_util_fltparse.cpp
d7119eb12622a4187553e68a32aafa61999d7162 15-May-2010 Elliott Hughes <enh@google.com> Merge "Fix getInetAddress/getPort/getLocalAddress/getLocalPort." into dalvik-dev
8cc54e9f098c4f299d2b88bb2b9110ce44354ed7 14-May-2010 Elliott Hughes <enh@google.com> Fix getInetAddress/getPort/getLocalAddress/getLocalPort.

Responsibility is split between Socket, SocketImpl, PlainSocketImpl,
SocketChannel, SocketChannelImpl, and SocketChannelImpl.SocketAdapter, and
we need to keep them synchronized. Our hands are somewhat tied by the fact
that the RI exposed way too much. I think, now I understand the relationships
a bit better, that we can probably rewrite this cluster of classes to be
simpler, but I don't want to bite off more than I can chew right now, and
this does fix the known problems.

This patch also makes us more compatible with the RI by making getLocalAddress
after the socket has been closed return the address we used.

By strange coincidence, harmony addressed this at the same time I was looking
at it (see http://svn.apache.org/viewvc?rev=944119&view=rev) but I feel they're
going in the wrong direction and making the relationships even more complicated.
I have run their new tests in addition to my own, though.

Bug: 1952042
Bug: http://code.google.com/p/android/issues/detail?id=1933
Bug: http://code.google.com/p/android/issues/detail?id=3123
Change-Id: Icb7793fb5d868e0d1f1b8b3d5da88c32fb973744
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
9acacc36bafda869c6e9cc63786cdddd995ca96a 14-May-2010 Brian Carlstrom <bdc@google.com> Use JSSE cipher suite names and restore JSSE SSLSessionContext semantics

Summary:
- Switch to using JSSE cipher suite names
- SSLSessionContext implementation cleanup
- Updated tests

Details:

Switch to using JSSE cipher suite names
- We maintain backward compatability for enabling cipher suites using
OpenSSL names for old code that did so without checking for the
presence of the names in the supported list.
- We now have a well defined list of the supported cipher suites which
are sorted in priority order as specified in JSSE documentation so
that callers doing:
s.setEnabledCipherSuites(s.getSupportedCipherSuites())
will get something reasonable.
- We now have a default cipher suite list that is chose to match RI
behavior and priority, not based on OpenSSLs default and priorities.

Details:
- Added NativeCrypto OPENSSL_TO_STANDARD and STANDARD_TO_OPENSSL
mapping between naming conventions. STANDARD_TO_OPENSSL is a
LinkedHashMap so enumerating it gives the proper order for
SUPPORTED_CIPHER_SUITES.
- SSL_get_ciphers and SSL_set_cipher_list are removed, we now use
our own SSL_set_cipher_lists (defined seperately in
external/openssl/patches/jsse.patch) to set the set and order of
cipher suites. SSL_CTX_get_ciphers is also removed because we no
longer rely on the OpenSSL for the default cipher suites
behavior.

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

Add cipherSuite and protocol field caches for native values,
mapping the cipherSuite to a JSSE name from the OpenSSL name
returned by SSL_SESSION_cipher.

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

Fixed a long standing bug where we reused sessions found in the
client host/port cache even if the old protocol and cipher suite
where no longer compatible with what was specified by
setEnabledCipherSuites and setProtocols. Also fixed a recently
introduced bug where lastAccessedTime was being set on a cached
session even if it was not reused, found by fixed the above.

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

Move most of SSLSessionContext implementation from subclasses to
AbstractSessionContext. This was primarily to align the
implementations of how different sessions id for the same host and
port were handled for RI compatability. client subclasses now focuses
on handling its host/port based cache and both deal with their own
persistent cache details.

luni/src/main/java/org/apache/harmony/xnet/provider/jsse/AbstractSessionContext.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/ClientSessionContext.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/ServerSessionContext.java

Tests

Added some variants of assertSSLSessionContextSize to simplify tests code.
Broke test_SSLSessionContext_setSessionCacheSize_oneConnect out of
test_SSLSessionContext_setSessionCacheSize_dynamic. Renamed
test_SSLSessionContext_setSessionCacheSize_basic to
test_SSLSessionContext_setSessionCacheSize_noConnect to match name
of _oneConnect. _dynamic was cleaned up a bit as getting it working
was the only goal of this change list. Fixed to filter
SSL_RSA_EXPORT_ ciphers since our test certificate key length is
too long for those. Lower test requirement to 3 unique cipher suites.

luni/src/test/java/javax/net/ssl/SSLSessionContextTest.java

Added checks that cipher suites and protocols have standard names.

luni/src/test/java/javax/net/ssl/SSLSessionTest.java

Removing known failures related to cipher suite naming. Fixed bug
of using assertNotNull instead of assertTrue. Added extra
size/length check which would have found the
assertNotNull/assertTrue issue.

luni/src/test/java/javax/net/ssl/SSLSocketFactoryTest.java
luni/src/test/java/javax/net/ssl/SSLSocketTest.java

Fixing test the explicitly worked around broken cipher suite naming.

luni/src/test/java/tests/api/javax/net/ssl/SSLSessionTest.java

Updated standard cipher suites to RI 6 list, which also now
specifies ordering, which we now align with.

support/src/test/java/javax/net/ssl/StandardNames.java

Unrelated

Remove more now obsolete jars from the test classpath

run-core-tests

Change-Id: I45c274a9327c9a1aeeccb39ecaf5a3fbe2903c8f
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
a008cf079f1cb812ec42a4fcc941fe170cc9b40d 13-May-2010 Elliott Hughes <enh@google.com> Minor file system changes.

Use fstat(2) instead of three seek(2)s to get the length of a file.

Java's readv should return -1 at EOF rather than 0.

The size() == 0 check in FileChannelImpl was (apparently) bogus.

(These changes are basically the same as harmony changes, and fix existing
harmony tests, so no new tests.)

Change-Id: I302611f777e91571b95654e03d0a3a41e1f97968
rg_apache_harmony_luni_platform_OSFileSystem.cpp
f281667712baf8e0721ceb2cc60e7eef19c2d859 12-May-2010 Elliott Hughes <enh@google.com> Reduced the amount of memory used by the TimeZone display names.

Bug: 2672057
Change-Id: I2f31ff3b5fbbf5cf8e16c89ef78a5246c6c3733a
CU.cpp
259d900b126b15c348fb90b0abddffed292e50ce 08-May-2010 Brian Carlstrom <bdc@google.com> Add missing include needed for simulator build

Change-Id: Ie457e719020d31a52ae3557db645a85b2f3b2f08
ommonDblParce.cpp
cbf7b8c25c557421c38f613e9fabab926f6469dc 08-May-2010 Brian Carlstrom <bdc@google.com> Merge "Moving most libcore .c files to .cpp" into dalvik-dev
ec2f5930802944b7e418bb97849071f538b2523c 08-May-2010 Brian Carlstrom <bdc@google.com> Moving most libcore .c files to .cpp

This change moves most of the libcore .c files to .cpp enough for them
to compile. This was largely motivated by the desire to avoid using
things like __attribute__ ((unused)) in .c files to supress warnings
in a recent change.

Change-Id: Ib967d9e16764ff805764e81362f945332080a06c
egister.cpp
bigint.c
bigint.cpp
ommonDblParce.c
ommonDblParce.cpp
ava_io_ObjectInputStream.c
ava_io_ObjectInputStream.cpp
ava_io_ObjectOutputStream.c
ava_io_ObjectOutputStream.cpp
ava_io_ObjectStreamClass.c
ava_io_ObjectStreamClass.cpp
ava_lang_Double.c
ava_lang_Double.cpp
ava_lang_Float.c
ava_lang_Float.cpp
ava_lang_Math.c
ava_lang_Math.cpp
ava_lang_StrictMath.c
ava_lang_StrictMath.cpp
rg_apache_harmony_luni_util_NumberConvert.c
rg_apache_harmony_luni_util_NumberConvert.cpp
rg_apache_harmony_luni_util_fltparse.c
rg_apache_harmony_luni_util_fltparse.cpp
ub.mk
edc2dae4345ea305f092ade00419685d77c8eee9 08-May-2010 Elliott Hughes <enh@google.com> Trivia.

Remove unused parameters from NetworkInterface's native methods.

Remove commented-out static initializers.

Fix FileChannel.force so that force(true) doesn't do _less_ than force(false).
Note that force(true) still doesn't do _more_ than force(false) because bionic
doesn't implement fdatasync(2). I've raised a bug against bionic about that.

Change-Id: Ia5e827638606a7919e3bcf324810747ee6bcbb9a
ava_net_NetworkInterface.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
0356c447b30e092bdc12a4b7288c08f5ef87534c 08-May-2010 Elliott Hughes <enh@google.com> Fix sim build, remove static initalizers from Deflater/Inflater.

Change-Id: I56a453a1382559cdcf9f22c6a185db7178fbe098
ava_io_ObjectStreamClass.c
ava_util_zip_Deflater.cpp
ava_util_zip_Inflater.cpp
44e0e560c92338110953ce806df475fedcdf926e 07-May-2010 Brian Carlstrom <bdc@google.com> Enable -Wall -Wextra for libcore and cleanup all but one warning

Change-Id: Ied76662c470ba878cec61189acf29f5cbbd4ccd4
idiWrapper.cpp
CU.cpp
ativeBreakIterator.cpp
ativeCollation.cpp
ativeConverter.cpp
ativeDecimalFormat.cpp
ativeRegEx.cpp
ommonDblParce.c
faddrs-android.h
ava_io_Console.cpp
ava_io_File.cpp
ava_io_ObjectInputStream.c
ava_io_ObjectOutputStream.c
ava_io_ObjectStreamClass.c
ava_lang_Double.c
ava_lang_Float.c
ava_lang_Math.c
ava_lang_ProcessManager.cpp
ava_lang_StrictMath.c
ava_net_InetAddress.cpp
ava_util_zip_Adler32.cpp
ava_util_zip_CRC32.cpp
ava_util_zip_Deflater.cpp
ava_util_zip_Inflater.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
rg_apache_harmony_luni_platform_OSMemory.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
rg_apache_harmony_luni_util_fltparse.c
rg_apache_harmony_xml_ExpatParser.cpp
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
0f840f7eadd6f14a00bf18199fede8325a3536fc 07-May-2010 Elliott Hughes <enh@google.com> Merge "Clean up the zlib-related native code." into dalvik-dev
74c05e2a892f236c8648af7f4cfb2bcb483f267b 07-May-2010 Elliott Hughes <enh@google.com> Clean up the zlib-related native code.

All the dude wanted was to get rid of Get/Release*Critical... First, though I
needed to switch the C files over to C++, and getting them to compile with a
stricter compiler made me realize how much of this stuff is unnecessary junk.
Eventually, I managed to get rid of all the "hy" and "sieb" crap, and you can
actually see what's going on now.

As usual, this reduces duplication and fixes leaks. I've also fixed a bug where
we'd never update inCap, meaning that we'd always allocate a new buffer and
never reuse the existing one even if it was large enough.

Bug: 2663177
Change-Id: I71fcbf9ff958ebf71ef3063d50ea34c28c30dd26
ativeConverter.cpp
egister.cpp
Character.cpp
bigint.h
ltconst.h
y2sie.h
ycomp.h
ymutex.h
yport.h
ava_lang_StrictMath.c
ava_util_zip_Adler32.c
ava_util_zip_Adler32.cpp
ava_util_zip_CRC32.c
ava_util_zip_CRC32.cpp
ava_util_zip_Deflater.c
ava_util_zip_Deflater.cpp
ava_util_zip_Inflater.c
ava_util_zip_Inflater.cpp
ieb.c
ieb.h
ub.mk
ip.c
ip.h
ipalloc.c
ipsup.c
ipsup.h
2def26b3562f5fdb3a5c99f866d2aa2ee3fb361e 07-May-2010 Kenny Root <kroot@google.com> Move ScopedJavaUnicodeString to include/

Change-Id: I51a2cdd80e910996f3143a7b699c3d4b408d105a
copedJavaUnicodeString.h
3e24c53ecc31b840e51869c295785d5a2f8b31eb 06-May-2010 Brian Carlstrom <bdc@google.com> Moving OpenSSLSocketImpl native code to NativeCrypto (and other clearnup)

Summary:
- Finished consolidating OpenSSL native code into NativeCrypto
- fixing local vs global ref bug with AppData
Added new ScopedGlobalRef as part of this fix
- fixed many historical memory leaks identified during code review
- fixed lack of error checking on allcoation with OpenSSL *_new routines
- Added to_SSL_CTX and to_SSL_SESSION to match to_SSL (renamed from getSslPointer)
- Replaced most uses of GetByteArrayElements with ScopedByteArray
(including cases where we we using ReleaseByteArrayElements(..,...,0) instead of JNI_ABORT)
- Replaced uses of GetStringUTFChars with ScopedUtfChars

Details:

Finished consolidating OpenSSL native code into NativeCrypto

OpenSSLSocketImpl NativeCrypto
---------------------------------------
nativeread SSL_read_byte
nativeread SSL_read
nativewrite SSL_write_byte
nativewrite SSL_write
nativeinterrupt SSL_interrupt
nativeclose SSL_shutdown
nativeverifysignature verifysignature

Also removed dead code that was wrapping SSL_get1_session

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/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp

Fixed NativeCrypto_SSL_write and NativeCrypto_d2i_SSL_SESSION to use
JNI_ABORT on release to avoid copy back of unchanged data (via ScopedByteArray).

luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp

While running the usual tests:
adb shell run-core-tests tests.xnet.AllTests javax.net.ssl.AllTests
there was an abort from the JNI checking because in the recent
handshaking change, local refs were kept in AppData and then reused in
later calls. Added new ScopedGlobalRef to handle the book keeping of this.

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

Fixed various leaks on old error paths spotted by reviewer.

luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp

Tracking move of verifySignature, a non-SSL bit of code that was lurking in OpenSSLSocketImpl

luni/src/main/java/org/apache/harmony/security/provider/cert/X509CertImpl.java

Change-Id: If1e409782bc99dc684039cfe3f53f8244e29346e
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
f002bdddce924e2145a4a2b60592b7a40f4112f6 05-May-2010 Brian Carlstrom <bdc@google.com> Moving OpenSSLSessionImpl native code to NativeCrypto

OpenSSLSessionImpl NativeCrypto
-------------------------------------------------------
getId SSL_SESSION_session_id
getPeerCertificatesImpl SSL_SESSION_get_peer_cert_chain
getCreationTime SSL_SESSION_get_time
getProtocol SSL_SESSION_get_version
getCipherSuite SSL_SESSION_cipher
freeImpl SSL_SESSION_free
getEncoded i2d_SSL_SESSION
initializeNativeImpl d2i_SSL_SESSION

Change-Id: I4538df52280266711986a577b14868af3ea0ed62
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
7b18e4c9b11150a9492a779a69412ac78b6d51be 05-May-2010 Elliott Hughes <enh@google.com> Merge "Remove use of non-errno error codes in OSNetworkSystem." into dalvik-dev
02d23a69dfd7d425153293d7d3ac64b5a611ba72 05-May-2010 Brian Carlstrom <bdc@google.com> Remove unnecessary NativeCrypto "OpenSSL error" warning

The following errors were noticed running tests.AllTests:

D/NativeCrypto( 507): OpenSSL error 168235011: error:0A071003:dsa routines:DSA_do_verify:BN lib
D/NativeCrypto( 507): OpenSSL error 168235011: error:0A071003:dsa routines:DSA_do_verify:BN lib
D/NativeCrypto( 507): OpenSSL error 168235011: error:0A071003:dsa routines:DSA_do_verify:BN lib
D/NativeCrypto( 507): OpenSSL error 168235011: error:0A071003:dsa routines:DSA_do_verify:BN lib
D/NativeCrypto( 507): OpenSSL error 168235011: error:0A071003:dsa routines:DSA_do_verify:BN lib

D/NativeCrypto( 507): OpenSSL error 168235011: error:0A071003:dsa routines:DSA_do_verify:BN lib
D/NativeCrypto( 507): OpenSSL error 168235011: error:0A071003:dsa routines:DSA_do_verify:BN lib

I tracked these down to the following tests respectively:

org.apache.harmony.archive.tests.java.util.jar.JarFileTest.test_JarFile_Modified_SF_EntryAttributes
org.apache.harmony.archive.tests.java.util.jar.JarFileTest.test_JarFile_Modified_SF_EntryAttributes
org.apache.harmony.archive.tests.java.util.jar.JarFileTest.test_JarFile_Modified_SF_EntryAttributes
org.apache.harmony.archive.tests.java.util.jar.JarFileTest.test_JarFile_Modified_SF_EntryAttributes
org.apache.harmony.archive.tests.java.util.jar.JarFileTest.test_JarFile_Modified_SF_EntryAttributes

org.apache.harmony.archive.tests.java.util.jar.JarInputStreamTest.test_JarInputStream_Modified_SF_EntryAttributes_getNextEntry
org.apache.harmony.archive.tests.java.util.jar.JarInputStreamTest.test_JarInputStream_Modified_SF_EntryAttributes_read

However, these errors are just because of expected SecurityException
because jar files are being modified and the signatures are no longer
valid.

Commented out the warning, leaving it for future debugging if
needed. In addition passed context in for use in message for
disambiguating source of error.

libcore/luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp

Change-Id: I3e41994a30c19a859a1eaed4ef80eb25b9670f52
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
b375c0ce8372b1343cfd9aa27698df1227c0b4e5 05-May-2010 Elliott Hughes <enh@google.com> Remove use of non-errno error codes in OSNetworkSystem.

This code's confusing enough without being so idiosyncratic. I've also changed
the native method so it returns a boolean rather leaking errno values in Java.

Where the original code used ENOTCONN, I've reverted to the native API's
EINPROGRESS for clarity. I've also used TEMP_FAILURE_RETRY to avoid manually
messing about with EINTR.

While I was here, I fixed a TODO about not needlessly passing a
sockaddr_storage by value, and removed a dead part of the old getsockopt code
I'd forgotten to remove.

Change-Id: I3c62fb80e33747619961ff39a0867422769126c4
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
e688a4123f165ed2905878e312b074b8c825d119 05-May-2010 Brian Carlstrom <bdc@google.com> Addressing post-submit comments regarding OpenSSL handhake changes

Following up on feedback from earlier change https://android-git.corp.google.com/g/50435

Added new test_SSLSocket_startHandshake_noClientCertificate to
make sure handshaking works when no client certificates are
present after issues raised by hwu during code review.

luni/src/test/java/javax/net/ssl/SSLSocketTest.java

Improve TestSSLContext.create* options
- added javadoc comments to help distinguish different versions
- fixed bug of not passing in keyStorePassword in create()
- added new createClient(server) method to create a TestSSLContext
that trusts the provided server TestSSLContext's certificate for
use by test_SSLSocket_startHandshake_noClientCertificate
- made createKeyStore optionally create a more minimal keystore if
aliases are not present
support/src/test/java/javax/net/ssl/TestSSLContext.java

Fixed argument names in SSL_*_mode methods names as pointed out by hwu

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

Added comment to explain purpose of OpenSSLSessionImpl.resetId.

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

Two changes to OpenSocketImpl
- Added logging on runtime exception catch around
HandshakeCompletedListener execution to closely mirror RI
behavior.
- Cleaned up peerCertificate check to not just be on the client path.

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

Addressed enh's comments about using clearEnv and when to delete AppData

luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp

Change-Id: I34f54e3e41a5d53d81fdc22aa34ca4de4ee9826f
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
6b811c5daec1b28e6f63b57f98a032236f2c3cf7 03-May-2010 Peter Hallam <peterhal@google.com> Merge awt-kernel, icu, luni-kernel, prefs, security-kernel, x-net into luni
Merge xml except xmlpull and kxml into luni
idiWrapper.cpp
rrorCode.cpp
rrorCode.h
CU.cpp
ativeBreakIterator.cpp
ativeCollation.cpp
ativeConverter.cpp
ativeDecimalFormat.cpp
ativeIDN.cpp
ativeNormalizer.cpp
ativeRegEx.cpp
egister.cpp
copedJavaUnicodeString.h
Character.cpp
ava_lang_ProcessManager.cpp
ava_lang_System.cpp
rg_apache_harmony_xml_ExpatParser.cpp
rg_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
ub.mk
4401c75ac7d85da33472d0398d8166df6ce4beb5 04-May-2010 Elliott Hughes <enh@google.com> Fix IPv6 multicast TTLs.

There's a Linux kernel bug we need to work-around for now. This patch adds that
workaround and tidies up the getSocketOption implementation.

This also fixes a bug I introduced in the last patch where setSocketOption
would reject InetAddress parameters.

Change-Id: Ie309b693520fed8306d346d5b4492c42e8967721
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
4d8e9333e494ceedff074def3b6e44f523f3830e 03-May-2010 Elliott Hughes <enh@google.com> Fix MulticastSocket.setTTL.

Fixes two jtreg failures. I assumed the problem was with the native code, so I
simplified that until I'd convinced myself it was now correct. Then I found a
sign-extension bug in the Java side.

Change-Id: I398cecbe8e9245cb45c27f35eff3a0cd2995394e
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
cec4dd4b1d33f78997603d0f89c0d0e56e64dbcd 26-Apr-2010 Peter Hallam <peterhal@google.com> merge more modules into luni
y2sie.h
ymutex.h
yport.h
ava_util_zip_Adler32.c
ava_util_zip_CRC32.c
ava_util_zip_Deflater.c
ava_util_zip_Inflater.c
ieb.c
ieb.h
ub.mk
ip.c
ip.h
ipalloc.c
ipsup.c
ipsup.h
18f8a70220a14cfa15681c3efc650a69317454c4 26-Apr-2010 Elliott Hughes <enh@google.com> Fix =/== bug.

Change-Id: I42c1ede0289334b7837d468763fecc61fc4a8bea
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
92c33a9254ec1e239a0447386a0a2eb35474d02b 21-Apr-2010 Elliott Hughes <enh@google.com> am 3825d34f: am d4b6f6aa: am 1dd42bb9: Fix NetworkInterface on sholes/ppp.

Merge commit '3825d34f9cd5057504ced60962638ffb54f14e38' into dalvik-dev

* commit '3825d34f9cd5057504ced60962638ffb54f14e38':
Fix NetworkInterface on sholes/ppp.
a5fd116a82413e73c9af51b9e9bdbfc6afa74762 21-Apr-2010 Elliott Hughes <enh@google.com> Fix NetworkInterface on sholes/ppp.

We need to use IFA_LOCAL to get the interface addresses; IFA_ADDRESS is the
remote address (which is usually the same as IFA_LOCAL, but not in the ppp
case).

Tested on sholes, where it fixes the test used in the bug; also tested on
passion, where it doesn't break the already-working test.

Bug: 2575983
Change-Id: Ib334a002dc099daeeb05cbc341fe233d4d11d2f7
faddrs-android.h
50f04c0a0a4f73b774c67aca45d1a59e4aacdb02 17-Apr-2010 Elliott Hughes <enh@google.com> Remove two dead files.

java_lang_Character.cpp has long been dead; I killed AndroidSystemNatives.h
this afternoon. I'm not sure how their "git rm"s didn't get included in my
earlier patch.

Change-Id: Iaa73935846a474dbd25792ed0176ccea092e9f7c
ava_lang_Character.cpp
c08f9fb2a3be82bb1a3f477ca1524ddcf7a1d4b8 17-Apr-2010 Elliott Hughes <enh@google.com> Move the libcore registration out of libnativehelpers and into libcore.

Bug: 754114
Change-Id: Iaa03def509c10cbaa12fd2128584b93d4be4a6b7
ava_io_Console.cpp
ava_io_File.cpp
ava_io_FileDescriptor.c
ava_io_ObjectInputStream.c
ava_io_ObjectOutputStream.c
ava_io_ObjectStreamClass.c
ava_lang_Double.c
ava_lang_Float.c
ava_lang_Math.c
ava_lang_StrictMath.c
ava_net_InetAddress.cpp
ava_net_NetworkInterface.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
rg_apache_harmony_luni_platform_OSMemory.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
rg_apache_harmony_luni_util_NumberConvert.c
rg_apache_harmony_luni_util_fltparse.c
de816ccf0d96c9fd9a042f4f8beaafee86ca02e7 01-Apr-2010 Elliott Hughes <enh@google.com> Fix an off-by-one error in fd range checking.

Change-Id: I15f932bc246ebc7fec9471a873bef8bd58ef15fc
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
97144c87ada735a82221d7cdf65555b8f063a05a 30-Mar-2010 Elliott Hughes <enh@google.com> Trivial tidying up of networking code.

Removing cruft and renaming things.

Change-Id: I317726c40a1addf3a1ad9d905239438424082549
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
7ca6fd0dca02f7abdd8808db78357743bbdd23a5 30-Mar-2010 Elliott Hughes <enh@google.com> Fix a bug, and protect against an unrelated class of bugs.

If the Java array allocation in InetAddress.cpp failed, we'd free NULL instead of the
previously-allocated structure. This is a new bug in froyo, but only happens in out of
memory situations, so doesn't seem worth fixing there.

Unrelatedly, let's disallow assignment and copying of all our RAII classes. This isn't
a mistake I've seen made, but it's easy to protect against, so we may as well do so
consistently.

Change-Id: I2433b31ff983d388788b09e59e08d661f1725ecd
faddrs-android.h
ava_io_File.cpp
ava_net_InetAddress.cpp
ava_net_NetworkInterface.cpp
abd91e389e4462208eb004b38d378f67d9676ec1 30-Mar-2010 Elliott Hughes <enh@google.com> Fix build.

Rather than try to be clever with header files (which didn't work with glibc
for the sim build) let's make Math.copySign have the StrictMath behavior,
and have StrictMath call Math. (The other way round, though it might seem
more logical, wouldn't solve the problem. We already have numerous cases of
StrictMath calling Math anyway.)

Change-Id: Ifff065ddc8fbd5d5f8d4d5b67bc9ac07a719eb00
ava_lang_Math.c
ava_lang_StrictMath.c
ace7e6ff6285c073a80aaad68321b17bdcd09a4b 27-Mar-2010 Elliott Hughes <enh@google.com> Fix StrictMath.copySign's behavior with NaN.

StrictMath's copySign method is defined to treat all NaNs as positive, regardless
of their sign bit. Rather than add yet more code on the Java side (which already
called down to native code three times), let's just make one call to native code.

This change fixes failures in already-committed StrictMath tests.

The only other potential instances of this class of error were in the
max and min methods, but they all handle NaNs before calling
(double|float)To(Raw)?LongBits, so the choice there really is arbitrary.

Change-Id: I439dbdff9068cb420b78a6330cde9d7d0d12c0ef
ava_lang_Math.c
ava_lang_StrictMath.c
705aafd104f0bd1a11de90afd85144de098f91c4 17-Mar-2010 Elliott Hughes <enh@google.com> Merge "Add Java 6's java.io.Console." into dalvik-dev
f7fb59f46848901875d317fdaa1008b63fd74ad2 17-Mar-2010 Elliott Hughes <enh@google.com> Add Java 6's java.io.Console.

This is actually functional, if you're in the mood to "adb shell".

The implementation is based on harmony's, but with the initialization and
native code rewritten, with readPassword responsible for echoing a newline (so
we don't have to play silly tricks with the ECHONL flag), and a vastly
simplified ConsoleReader class. I've also rewritten the documentation.

Change-Id: I902b47fb27a8fdb2d6f067bb905ee02c6a10e454
ava_io_Console.cpp
ub.mk
6c75e0a78abc87441acfc8725acd90b1c2bb2f1c 17-Mar-2010 Carl Shapiro <cshapiro@google.com> am 288de8e6: Merge "Replace a use of index with strchr."

Merge commit '288de8e67b5a2c2e6a19372a2b99f17ca17de2fa' into dalvik-dev

* commit '288de8e67b5a2c2e6a19372a2b99f17ca17de2fa':
Replace a use of index with strchr.
22ff07e22ee4e9628c091fddcf72fc6fa6746ba9 16-Mar-2010 Carl Shapiro <cshapiro@google.com> Replace a use of index with strchr.

Change-Id: I2c1238bc1bd0945533712d0d74a761721b8408a3
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
d9d263010b4b3fb039ecb88bddbc565414d82c63 16-Mar-2010 Elliott Hughes <enh@google.com> Remove dead fields, constants, and redundant pass-through methods.

(This is just preliminary to what I really want to do, which is vastly
reduce the number of near-duplicate methods we have: all the send/recv
variants, for example.)

Change-Id: Ib03653820a18f55aea6c5b876c397afd281a98dc
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
ec4c445afc6d3449d901ec03f1a2973db01f66e1 13-Mar-2010 Elliott Hughes <enh@google.com> Merge "Remove dead obfuscatory code." into dalvik-dev
fdd13e86ec613e46b68376f90d2c89c2ac33b4b5 13-Mar-2010 Elliott Hughes <enh@google.com> Remove dead obfuscatory code.

Bug: 2509206
Change-Id: I72a34e1f80fd6936d255b94daf5683cc2a0f2327
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
08ec8fd5c950cb94e12aefa08c89d78762acf18a 12-Mar-2010 Elliott Hughes <enh@google.com> Java 6 java.io.File changes.

IOError and IOException are just copied from harmony. The native code
is all our own, and the File code is rewritten to match our earlier
changes. FileTest gains more tests for the new methods' behavior with
File("").

We still can't test most of this stuff directly because we run our tests
as root. Manual inspection looks good, though, and I've raised a bug
for switching our tests over to run as a non-root user.

I've removed all the Java 6 exceptions from expectations.txt because
we plan on fixing them all, and almost all of the ones mentioned there
are already addressed anyway.

Bug: 2497395
Change-Id: I517cd2d871bff64d63b2f4eb80fda4cfd6d19cd8
ava_io_File.cpp
49e79cdc1aadb2922178e8905a7907df0bdaf7b3 12-Mar-2010 Elliott Hughes <enh@google.com> Use ioctl(FIONREAD) rather than recv(MSG_PEEK) to implement Socket.available.

As well as avoiding unnecessary work, this also means we can reuse the native
code we already have for ioctl(FIONREAD), though we need to change the
interface to take FileDescriptor rather than int, and extract the int on the
native side.

Change-Id: I4c6d9e4e72e514e3e7872c7f882bda5441059915
rg_apache_harmony_luni_platform_OSFileSystem.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
b051ce59d776b63ed2cebde8c2fa338ebd2d0786 09-Mar-2010 Elliott Hughes <enh@google.com> Fix build (missing #include in sim build).

Change-Id: I8691db582f2d2d926da308a813d9f1864bedcd6d
ava_net_NetworkInterface.cpp
bf5d76daa288a111dcaa33b084a099948c52d200 09-Mar-2010 Elliott Hughes <enh@google.com> Merge "Implement the Java 6 NetworkInterface/InterfaceAddress functionality." into dalvik-dev
d2af45a6fd008ceb958ac74e5a50e582b8419e9c 05-Mar-2010 Elliott Hughes <enh@google.com> Implement the Java 6 NetworkInterface/InterfaceAddress functionality.

The Java bits are based on harmony's code (though only the bit that pulls
out the sub-interfaces is copied verbatim), but the native side is new
code, continuing our previous plan of (a) doing the least possible work
on the native side and (b) using the BSD getifaddrs(3) interface as our
portability layer.

This patch also updates our NetworkInterfaceTest to be the latest code
from harmony's java6 branch.

We pass all the harmony and jtreg tests, and visual inspection shows that
the untested (and hard to test) bits -- such as prefix length and hardware
address -- are correct.
faddrs-android.h
ava_net_NetworkInterface.cpp
722a27ebf869dfd475dea15de3a5966a18a56b62 06-Mar-2010 Elliott Hughes <enh@google.com> Support IPv4-compatible IPv6 addresses on IPv4 sockets.

Bug: 2194581
Change-Id: I825835280e9d7d88a4db3fa817dfb4234fc19039
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
b1268c6e3dd23ee5af7255e2da64363f6aa0bb72 12-Feb-2010 Dan Bornstein <danfuzz@android.com> Use HAVE_ANDROID_OS to conditionally include files on a device target.
ava_net_NetworkInterface.cpp
0a807e587935a92811a2f3703caab87115363030 03-Feb-2010 Elliott Hughes <enh@google.com> Fix two compiler warnings.

Signed/unsigned comparison in "File.cpp", and && and || without parentheses
in "OpenSSLSocketImpl.cpp". There's another signed/unsigned comparison in
"ifaddrs-android.h" but that isn't fixable (http://b/2417132), which is
going to stand in the way of turning on -Werror.
ava_io_File.cpp
da4f31de172364cfb3a20caed1784fa23b0510ca 28-Jan-2010 Elliott Hughes <enh@google.com> Fix jniThrowRuntimeException for C callers, add jniThrowNullPointerException.

...and switch all NPE throwers over to the helper.
ava_net_InetAddress.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
4c5cbf2953ada194c4dc9d7b387615b1c6fe3e63 20-Jan-2010 Elliott Hughes <enh@google.com> One true way to query "java.net.preferIPv6Addresses".

Also stop querying and passing this boolean to code that doesn't care. (We
sort our InetAddress[]s appropriately, so most code doesn't need to worry
about this.)

Bug: http://code.google.com/p/android/issues/detail?id=5903
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
048303b64df9c987ae2f57b6bf88ff5ac1b5cca0 16-Jan-2010 Elliott Hughes <enh@google.com> Rewrite InetAddress' DNS cache.

Replace harmony's two 5-element linked lists with a single 512-element
LinkedHashMap. Greatly reduce the time we spend under locks (and no network
I/O is done under a lock any more!). Take advantage of various properties
of how the cache is used to avoid having to do much explicit work to handle
expiry.

I've also optimized the usual no-SecurityManager/no custom system properties
configuring cache TTLs case (without making the slow path much slower than it
already was).

I've also updated the native method names to correspond to the C functions
they're really wrapping (rather than completely different IPv4-only ones
they probably used to wrap long ago).

I've also improved the InetAddress documentation.

Bug: 2320435
ava_net_InetAddress.cpp
f226fd4060db45a0738cbbc1bb49bebe5963ac11 10-Dec-2009 Elliott Hughes <enh@google.com> More java.io.File cleanup.

Make File.list (and friends) cost one JNI call instead of four,
and move the conversion of UTF-8 byte sequences into the JNI, so
it returns String[] instead of byte[][].

Switch to readdir_r(3) so we don't need the JNI to be "static
synchronized".

Remove fixed-length buffers from the native code.

Fix leaks by introducing a "proper" native container (similar to
std::forward_list). We should still investigate either using
std::vector or passing in an ArrayList<String> and using JNI to
call ArrayList.add, but this is a step forward from the old
code anyway.

Bug: 2281992
ava_io_File.cpp
d385bfc328b9d85901eec969a55afb28125f2b51 09-Dec-2009 Elliott Hughes <enh@google.com> Improve the FileNotFoundExceptions thrown by OSFileSystem.open.

When I improved the internals of java.io.File, I failed to keep
OSFileSystem.open (which uses the internals of java.io.File) in
sync, leading to misleading error reporting. java.io.File's
internals now include a trailing NUL, which is useful for the
native code but confuses Java if it tries to decode the byte[]
as a UTF-8 sequence.

This patch fixes the bug and also improves OSFileSystem.open's
error reporting to include the reason for the failure.

Bug: 2313271
ava_io_File.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
93a4b2a6cc35a72aa5a58027025f3e18c0ec2e64 05-Dec-2009 Elliott Hughes <enh@google.com> More java.io.File cleanup.

Two changes:

1. Change the createNewFile JNI to match the Java interface, so we can lose the
glue. (Also make the Java/JNI names match, and sort the table of native method
names alphabetically.)

2. Fix the caching of the path byte sequence so we're caching the exact byte
sequence we want to hand to JNI. Also switch to caching the byte[] at
construction time, rather than hiding it behind an accessor.

There's a deliberate functional change here too: previously we were inconsistent
about which encoding was in use. Sometimes it was explicitly UTF-8, other times
the default platform encoding (which happens to be UTF-8 on Android). Now we
always use UTF-8. (But note that the File.list methods, which I haven't got to
yet, still return a mix of UTF-8 and platform-encoded strings.)

Bug: 2281992
ava_io_File.cpp
c5c9c667028146ab5f5e446c44f911c2fdd7dd30 30-Nov-2009 Elliott Hughes <enh@google.com> More java.io.File improvements.

Three themes to this change: not making unnecessary native calls (like the
pointless "exists" check in canWrite), being consistent in our
treatment of the empty path, and removing unnecessary cruft from the native
code.

I'm sure there must be a better implementation for handling the empty
path (the few methods for which it *isn't* invalid should be the special
cases, not every single method), but in this patch I'm just interested
in correctness.

With this patch, we pass the jtreg empty path test (which we previously
failed) and we pass my more complete test (added to FileTest.java in this
patch).

Bug: 2281992
ava_io_File.cpp
87415b1521402398d4470aecbef7c126a6948290 26-Nov-2009 Elliott Hughes <enh@google.com> Fix File.isHidden and File.listRoots.

Not only were the old implementations of these methods over-complicated, they
were both incorrect. We now pass all our existing tests plus the jtreg tests.

Bug: 2281992
ava_io_File.cpp
fb917ba71e0440774660ba18a6725612c7ed79c5 24-Nov-2009 Android (Google) Code Review <android-gerrit@google.com> Merge change I9189bd9d

* changes:
Fix java.io.File's JNI's fixed-length buffers.
1326cfc6f105f6c8fd5ffd83793223e1a797409d 21-Nov-2009 Elliott Hughes <enh@google.com> Fix java.io.File's JNI's fixed-length buffers.

I've also removed most of the duplication, simplified a lot of the
implementation, and added loads of TODOs now it's possible to see
what's going on under all the obfuscation. (The native code is
roughly half its previous size, but more functional.)

I want to stop here rather than start fixing any of the TODOs
because this change is already large enough and the history will
be clearer if unrelated changes are kept separate (easy though many
of them are).

Strictly speaking, I haven't removed all the fixed-length buffers:
the File.list implementation still uses fixed-length buffers, but
as the new TODOs point out, I think we want to rewrite that code
to better match its callers, and doing so will make the fixed-length
buffers go away. There's no point polishing code that's already
scheduled for deletion.

Add a couple of basic tests, one that assumes that if Path copes
with long paths in a couple of File's methods, it works in all of
them; another that singles out our readlink(2) wrapper because
that's the only place so far where we cope with arbitrary-length
paths moving in the opposite direction (from kernel to JNI to Java).
ava_io_File.cpp
5c74ff3a04ee08a96b068ecbf921a019d830d3ae 24-Nov-2009 Android (Google) Code Review <android-gerrit@google.com> Merge change Iff90b1aa

* changes:
Explicitly ignore non-IPv4/IPv6 addresses from IFA_ADDRESS.
b6317957298897761758aa10b74bf58a853cc307 23-Nov-2009 Elliott Hughes <enh@google.com> Add a comment.
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
e097295a8f8ce56d02bdf4fc93b4694ba0c7848e 23-Nov-2009 Elliott Hughes <enh@google.com> Explicitly ignore non-IPv4/IPv6 addresses from IFA_ADDRESS.

I don't think this can happen (some other calls return hardware addresses too,
but I've never seen a hardware address in an IFA_ADDRESS message), but netlink
is badly documented, and it's better to be safe than sorry.
faddrs-android.h
d2c1275661bbebbbb3fae30b6359f71f2628c4b3 21-Nov-2009 Android (Google) Code Review <android-gerrit@google.com> Merge change I9fa3ef2c

* changes:
Rewrite NetworkInterface's JNI for IPv6.
5e1a00946a6d3119b3db272e747529528021a4af 21-Nov-2009 Elliott Hughes <enh@google.com> Switch java_io_File.c over to C++.
ava_io_File.c
ava_io_File.cpp
ub.mk
b5fc5ecd3fe5315fc2756c0c25adc458cc8c8d91 20-Nov-2009 Elliott Hughes <enh@google.com> Rewrite NetworkInterface's JNI for IPv6.

The old ioctl SIOCGIFCONF implementation of getNetworkInterfaces only returns
IPv4 addresses. Now we've switched everything over to IPv6, that's not good
enough. This change (a) implements glibc/BSD-like getifaddrs(3)/freeifaddrs(3)
for Android, and (b) rewrites our getNetworkInterfaces to use that method. Of
particular note is that we now do more of the work in Java. The JNI hands back
a Java equivalent of getifaddrs(3)'s linked list of ifaddrs structs. The new
package-private java.net.InterfaceAddress class serves as Java's "struct
ifaddrs".

The old implementation was also broken: SIOCGIFCONF doesn't actually return
interface indexes from the kernel as the old code believed, so we were
pulling the address family out of the IPv4 address it returned, leading
us to assign the index 2 to all network interfaces. This caused all kinds of
weird behavior later.

I also had to fix GenericIPMreq so that its interface index field is actually
set. The native code gets passed one of these objects when setNetworkInterface
is called, so it's kind of important that the object identify which interface
it's supposed to correspond to.

I've also added missing copyright headers.

This fixes all of the harmony tests on the simulator and on the device. It
fixes several but not all of the jtreg MulticastSocket and IPv6 tests.
faddrs-android.h
ava_net_NetworkInterface.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
845ce3cbfd6972542b275c95eddfbb6e94469737 14-Nov-2009 Elliott Hughes <enh@google.com> Don't allocate arbitrary-length buffers on the stack.

A new LocalArray C++ class lets us specify a "reasonable" amount of stack to
use, but transparently fall back to using the heap if we need more space.

The three places I've chosen to use LocalArray in this patch are fairly
random; all they have in common is that they're the places where we call
GetStringUTFRegion. There are more places LocalArray will be useful: the
java.io.File JNI in particular.

Bug: 2257819
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
7861ea9a813b337a4abd0378584baae9cc177896 12-Nov-2009 Elliott Hughes <enh@google.com> Remove OSNetworkSystem.oneTimeInitialization.

Do this work at JNI registration time, as we do for almost everything else.
(I did this to rule out a warning from the dalvikvm deadlock prediction
code, which doesn't like the unusual lock ordering at initialization time,
and although it didn't make any difference to that, I prefer to have a
defined static order of initialization.)
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
c00b8a475a82b7d9bee7388f218fcca2c30532f1 12-Nov-2009 Elliott Hughes <enh@google.com> Fix a buffer overrun in OSNetworkSystem.

Given an IPv6 address in a non-standard (Java-specific) form, we used to
overrun an on-stack buffer that was assuming the standard (shorter) form.
Make the buffer large enough for both forms, and reject anything that's
still too large.

Found by Inet6AddressTest.
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
ba563a4578c970b0c750464c7efe7ec5dc0ad2c1 05-Nov-2009 Elliott Hughes <enh@google.com> More OSNetworkSystem cleanup.

Handle select(2) errors by throwing exceptions from native code (which is
simpler and provides more useful detail messages).

Factor out exception throwing commonality. This is probably ready for JNIHelp.h
now.

Remove sockSelect. Simplify selectWait by observing that it's only ever called
with a "read" fdset.

Remove a little more SOCKERR_* cruft.

Remove a few unused #defines.
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
f5eafc5c866dcdd29fc9ccd98ff48385227c3ee6 05-Nov-2009 Elliott Hughes <enh@google.com> More OSNetworkSystem cleanup.

Fix danfuzz's BSD woes by removing uses of non-standard s6_addr32,
replace isMappedAddress with IN6_IS_ADDR_V4MAPPED, and change
convertMappedToIpv4 to reduce duplication in its callers.

Remove the TODO suggesting we consider inet_ntop instead of
getnameinfo; Ulrich Drepper says there's never any reason to
do that: http://people.redhat.com/drepper/userapi-ipv6.html

Remove our last use of sockaddr_in in favor of sockaddr_storage,
so we never have to wonder "is that big enough?" again.

Explain why we convert IPv4-mapped addresses to IPv4 addresses
when there's no obvious reason to do so.

Fix another user of the SOCKERR_* cruft.

Address the FD_ISSET and what-exception-to-throw-on-BSD comments
from danfuzz's last patch.
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
fef8875140527cfc6a6f5779ce0ee4b25ca70383 05-Nov-2009 Dan Bornstein <danfuzz@android.com> Only compile in multicast support on Linux, for the time being.

The calls and structs provided by the underlying platform for
multicast aren't yet exactly well-established POSIX standards, and the
current Linux code is still not considered to be super-robust, and as
such it isn't a good idea to try to duplicate its functionality for
other platforms. We will revisit the issue once the Linux side has
matured a bit.

Change-Id: I630086e22f6980726fd4523cb60dfc8c9fb9b011
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
7a9ac957a68063610d8a98e5cddfbecacabf5f74 04-Nov-2009 Dan Bornstein <danfuzz@android.com> Another couple of tweaks to deal with the ragged end of standardization.

Change-Id: I6b080ffcc1832a902e21f5137f42e4d860c407f0
ava_net_NetworkInterface.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
21d6937a70c255b47b707a995c1f9e76a5460fa4 03-Nov-2009 Elliott Hughes <enh@google.com> Kill OSNetworkSystem.inheritedChannelImpl.

This code is broken (and more broken than upstream), and not obviously relevant
to our platform. Let's make it clear that all this currently does is return
null.

The changes in the Java side bring us back in sync with upstream.
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
033edddb3277659e203cb959cf8e8d50dd058f6e 29-Oct-2009 Dan Bornstein <danfuzz@android.com> Some more adjustments to deal with building for a BSD(-like) target.

Change-Id: I5e33c3db160ae3af6e324492e0b6a7a0dfb9719b
ava_net_NetworkInterface.cpp
rg_apache_harmony_luni_platform_OSFileSystem.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
a9a57f2581773484d13e160fd3407692e825971a 31-Oct-2009 Elliott Hughes <enh@google.com> More OSNetworkSystem cleanup.

valgrind didn't like what we were doing here, specifically the way we
were setting ss_family to AF_INET if getsockopt IP_MULTICAST_IF didn't
return an AF_INET address, and ignoring the fact that the rest of
the sockaddr_storage doesn't necessarily correspond to an AF_INET address.
Linux seems to return an AF_UNSPEC address (rather than INADDR_ANY) if we
haven't set a multicast interface, so we have to do the conversion ourselves.

More disturbingly (and unfixed by this patch) we sometimes see ss_family
come back as 127 (when AF_MAX is 32 on our system). My guess is that the
kernel is just handing back bad data we gave it earlier, but I'll come back
to see about fixing multicast properly later.

I've inlined socketAddressToString into osNetworkSystem_byteArrayToIpString,
its only caller, because it's clearer that way now we've simplified the
division of error handling between the two.

I've brought getSocketLocalAddressImpl and getSocketLocalPortImpl in line
with each other and changed them to at least log errors. I've also added
a new test that fails, to demonstrate that this implementation is broken
as designed.

I've changed the name of JAVASOCKOPT_IP_MULTICAST_IF to match the Java
constant.

I've fixed the exception we throw if we're asked to convert a bad address
family's address from code that can't throw IOException --- AssertionError
doesn't have a String constructor. Really, we need to kill this code, so
I've added a TODO.

I've also made a real push to get rid of most of the SOCKERR_*-based error
reporting. (I had a transient failure with a meaningless error message
that sent me to the source to work out which errno it was actually
trying to report.)

I've changed setTTL to call setTimeToLive, and change the implementation
of the latter to pass Integer rather than Byte to the native implementation,
since that's what the native code needs anyway and native Byte support was
only for TTL.

Bug: 2225748
ava_net_NetworkInterface.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
d9179c4701153caeb821cf3da639b28465317508 27-Oct-2009 Elliott Hughes <enh@google.com> Remove OSNetworkSystem.sendStream and all use of ErrorCodeException.

Removing OSNetworkSystem.sendStream brings us in line with harmony. I've
also rewritten writeSocketImpl to not make a temporary copy of the data it's
going to send.

The weird code in writeSocketDirectImpl that threw ErrorCodeException turns out
to be a very awkward way of returning zero to the only two callers that are
paying attention. (Harmony actually calls the equivalent of this code every
time it throws SocketException from native code, but these two callers were
the only places that checked for the special case.)
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
31ba233988135e90b3e98548d9e40452639cf00c 27-Oct-2009 Dan Bornstein <danfuzz@android.com> The officially sanctioned way to get memcpy() is to #include <string.h>.

Change-Id: Ie157d9305df5f9b86a09ea2224666fd2c054cda4
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
954754fc999fb5fb747f7928302639d16dd3ac7e 23-Oct-2009 Android (Google) Code Review <android-gerrit@google.com> Merge change I3628c655

* changes:
OSMemorySystem.mmap fixes.
3c6ff817ba94b64cf24014acff7201859410fb13 23-Oct-2009 Elliott Hughes <enh@google.com> OSMemorySystem.mmap fixes.

Stop silently truncating the arguments to mmap. Check they're actually valid.

Fix mmap to actually throw IOException on error, as it claimed to do.

Correct parameter name 'alignment' to 'offset'.

Remove dead code (getPageSize).
rg_apache_harmony_luni_platform_OSMemory.cpp
70882923fb227de7a54a9b1a2a4dd2c6ec8b51ae 22-Oct-2009 Elliott Hughes <enh@google.com> Remove OSNetworkSystem.receiveStream.

Harmony removed this some time ago, and -- if we change our read/readDirect
implementations slightly -- we can too.

I've also added some bounds checking in the Java so we don't ask native code
to perform a buffer overrun for us.

I've also rewritten the native readSocketImpl to use GetByteArrayElements and
ReleaseByteArrayElements rather than its own custom stack/heap allocation and
arbitrary 64KiB limit. (As far as I can tell from the harmony history, the
limit dates from when they always read into an on-stack buffer, and was never
removed.)

I've also brought us in line with harmony so we only pass 'address' to
readDirect, rather than 'address' and 'offset'.

I've changed SocketTest to match upstream and -- since they pulled out some
of the tests into a new file -- I've added their UnixSocketTest so we don't
miss out. Our old SocketTest's test_getInputStream is the only test my new
code doesn't pass, but I think the old SocketTest was broken and the new
SocketTest/UnixSocketTest is correct.

I've also brought us back into line with harmony's MulticastSocketTest. With
the up-to-date tests, the new code behaves the same as the old code. (With
our old tests, the new code fails the joinGroup test with a
NullPointerException instead of a junit comparison failure.)
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
947a0148818f9a51ed0c1711b5bf69ef10b5c1e6 21-Oct-2009 Android (Google) Code Review <android-gerrit@google.com> Merge change Id434c469

* changes:
More OSNetworkSystem cleanup.
b150dcd6a072b41df6b010a60977a1657a7bdfa5 21-Oct-2009 Elliott Hughes <enh@google.com> More OSNetworkSystem cleanup.

Rewrite OSNetworkSystem.connect in terms of connectStreamWithTimeoutSocketImpl
in Java rather than in native code. Remove OSNetworkSystem.connectSocketImpl.
Make INetworkSystem.connect void, since the return value is always 0.

Use TEMP_FAILURE_RETRY rather than explicit do loops to retry interrupted
system calls.

Fix peekDatagramImpl to actually update the byte[] in the passed-in
InetAddress.

Stop pulling the int fd out of the FileDescriptor each time round the loop
in sendStreamImpl and sendDatagramImpl2.

More tiny steps towards eliminating the SOCKERR_ nonsense in favor of errno.

Prefer sizeof(variable) to sizeof(type).

Remove a few more superfluous "struct" keywords.
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
eaf9fbf42f0b028e4e74503b60c8f8570d263c65 21-Oct-2009 Elliott Hughes <enh@google.com> Expose the portable "strerror_r" used by jniThrowIOException.

Also add one example caller I used to test this, and update the
libnativehelper README file.
ava_net_NetworkInterface.cpp
24912e004b8456800ac22b05a7ffeda11dbf44b8 20-Oct-2009 Elliott Hughes <enh@google.com> Fix OSNetworkSystem.acceptImpl error handling; additional clean-up.

The main reason for this patch is that acceptImpl was checking the wrong
return code.

I've also removed the BADSOCKET and UNKNOWNSOCKET errors because they were
being used interchangeably with the BADDESC error and weren't genuinely
meaningful.

I've also removed the bogus checks for 0 as a file descriptor, which is
perfectly valid (if unlikely).

I've factored this common snippet out.
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
388ae438a01d2de1e0f9c6a95ab5ad71e5e21f60 19-Oct-2009 Android (Google) Code Review <android-gerrit@google.com> Merge change I1f575e9e

* changes:
Improve error handling in InetAddress native code.
fc354fea0c535ceef679e8856a73dd05be8351df 17-Oct-2009 Elliott Hughes <enh@google.com> Improve error handling in InetAddress native code.

Fix a bug where we changed the return values of functions such
as byteArrayToSocketAddress without changing the logic in the
callers that's supposed to distinguish success and failure.
For simplicity, I've switch all of these functions over to
returning bool, and I've gone through all the callers to ensure
we're using the right check now. (This is the majority of the
diff.)

Also switch to throwing IllegalArgumentException instead of SocketException
when we find ourselves with a bad byte[] --- before we were throwing
a checked exception we weren't allowed to (from native code, which
can't actually be checked statically) and then trying to cover up
in Java.

I've also simply removed one case where we were trying to mask an
OutOfMemoryError with a SocketException.

I also removed dead code in socketAddressToString: this function's
sole caller always passed false for withPort. This makes the
temporary variable and the copying (which was unsafe) unnecessary.

In instances where I was already changing the code, I've removed
bogus "handle == 0" failures, but I'll come back and remove all
the other instances in another patch.

Since I was in connectSocketImpl, I've removed the dead second half
of that method.
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
7e0428d38865ee4f2ac55d9283a5dc53686ce617 16-Oct-2009 Elliott Hughes <enh@google.com> Fix Float.valueOf(String) OutOfMemoryExceptions.

Apply http://issues.apache.org/jira/browse/HARMONY-6261, which was missed in
our recent luni merge.

Bug: 1957904
rg_apache_harmony_luni_util_fltparse.c
5839b909d9528b7726e678a4b696ed37df15d897 10-Oct-2009 Jesse Wilson <jessewilson@google.com> Udating luni to Harmony r823222.

Highlights:
- InputStream.skip concurrency issue
- "better" messages in bound exceptions for streams and arrays
- prefer fewer writes to underlying streams (using byte[] buffers)
- Rename subclasses to not reuse names from their superclasses
- PlatformAddressFactory.allocMap bugfix

Plus some spelling fixes, style fixes, serial version UIDs and other
boilerplate improvements.
bigint.c
ltconst.h
rg_apache_harmony_luni_util_fltparse.c
8d3886e66cc8e30ba0fcb5e8122860cd158e967d 10-Oct-2009 Android (Google) Code Review <android-gerrit@google.com> Merge change Ic98d470a

* changes:
Remove the intermediate representation in getNetworkInterfaces.
61b25e6f488dacc5cfb419106f233f1bf072637c 07-Oct-2009 Elliott Hughes <enh@google.com> Remove duplication between readv and writev.

This also means we don't pin the three int arrays for the duration
of the syscall.
rg_apache_harmony_luni_platform_OSFileSystem.cpp
8752768df468b55d4ef6ee009aee70553a2d34c4 06-Oct-2009 Elliott Hughes <enh@google.com> Don't use GetPrimitiveArrayCritical around network operations.

This code seems to have been using GetPrimitiveArrayCritical to
work around the fact that it was supply JNI_ABORT on release,
where it really wanted GetByteArrayElements and to keep its
changes (since the whole point of the byte[] was to keep state
between calls).
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
7795bcef32bde2039bd6399c069abbc40538a510 06-Oct-2009 Elliott Hughes <enh@google.com> Remove the intermediate representation in getNetworkInterfaces.

This gets rid of a lot of unnecessary complexity by going straight from
the kernel's representation to the Java representation, without the useless
C structs in between.
ava_net_NetworkInterface.cpp
c83e55b794fc3052c6cd18529ddf1c3cfe271706 06-Oct-2009 Elliott Hughes <enh@google.com> Remove dead code.
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
bd5b03c2a1a88e95af6c72ae0f88a2db9dded0b2 06-Oct-2009 Android (Google) Code Review <android-gerrit@google.com> Merge change I7aabd791

* changes:
Refactor java_net_NetworkInterface.cpp for clarity.
5be11d7b7cace35b473c84dc75efb8fd1c7f0981 03-Oct-2009 Elliott Hughes <enh@google.com> Refactor java_net_NetworkInterface.cpp for clarity.

All I wanted to do was remove the SOCKERR_ mess, but things got out of hand.
There's still plenty of stuff that could be cleaned up, but nothing that can't
wait. I'm only doing this to make things easier for the IPv6 changes.

This patch:
* removes the SOCKERR_ mess which was causing vague "Operation failed"
IOExceptions; we now use the actual errno value of whatever caused the failure.
* simplifies memory management so we don't have to do lots of cleanup on
every exit from each function.
* simplified fd management for the same reason.
* reduces the use of the intermediate structure, going straight to Java objects
in places. (This is the unfinished work: we should get rid of the intermediate
representation. It's not useful.)
* replaces structInToJavaAddress and structInToInetAddress with a call to the
better socketAddressToInetAddress from OSNetworkSystem.cpp.
* uses more intention-revealing variable and function names.
* removes attempts to throw exceptions when perfectly good exceptions have
already been thrown.
* removes filtering of interfaces that aren't up. The RI doesn't do this
filtering, there's no reason to do it, and it's always going to be a race
condition anyway.
* removes untrue comments.
* removes a lot of inexplicably empty lines.
ava_net_NetworkInterface.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
ab9e695e6049d597c95dc32459c316b75b542239 05-Oct-2009 Elliott Hughes <enh@google.com> Switch to TEMP_FAILURE_RETRY now it's moved to bionic.

(The same EINTR_RETRY macro that used to be here has moved to <unistd.h>, so
we don't need another copy. EINTR_RETRY is a nicer name, I think, but
TEMP_FAILURE_RETRY is the GNU-compatible name.)
rg_apache_harmony_luni_platform_OSFileSystem.cpp
6dbbfbdd8bbc6fd14db672edb6684879d22dea66 02-Oct-2009 Lorenzo Colitti <lorenzo@google.com> Make sure res is NULL if getaddrinfo fails.
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
e9bb15aeae0988610aff5edecc8e1e212ee40db5 30-Sep-2009 Elliott Hughes <enh@google.com> Remove adb networking support from dalvik/libcore.

There's more to be removed from other projects, but this should probably
come out first.

Bug: 1122968
ava_net_InetAddress.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
e73f40b484788e8c1f89a24307dc4be58da5edb2 02-Oct-2009 Elliott Hughes <enh@google.com> Switch java_net_NetworkInterface.c to C++.

(I have a bigger change to make to this file, but the web claims that it's
best to keep renames in minimally small patches so git doesn't get confused.)
ava_net_NetworkInterface.c
ava_net_NetworkInterface.cpp
ub.mk
4d26d908fc812a30683ff5b831f6ae77a2bedd30 01-Oct-2009 Lorenzo Colitti <lorenzo@google.com> am 1507c7ce: am f94c5d77: More multicast fixes.

Merge commit '1507c7ce4fc88f7bdf5e89ba10839809693eeefb'

* commit '1507c7ce4fc88f7bdf5e89ba10839809693eeefb':
More multicast fixes.
12ee3ae4b1b803cdf9f9293fb8d5bd35956aeb88 01-Oct-2009 Lorenzo Colitti <lorenzo@google.com> am 003d7f8d: am e851c562: Merge change Iea75a523 into eclair

Merge commit '003d7f8da66ec53b5dbece36308197dc7a932e3e'

* commit '003d7f8da66ec53b5dbece36308197dc7a932e3e':
Fixes for socket options on multicast sockets.
738f95037e3e00ec5ccb8686f7c4c5c2cc16e06a 01-Oct-2009 Elliott Hughes <enh@google.com> Use jniThrowException instead of FindClass/ThrowNew.

Always use our best-of-breed code for throwing exceptions. The remaining
callers of Throw have good reason, and the only caller of ThrowNew is
now JNIHelp.c (jniThrowException) itself.
ava_net_InetAddress.cpp
ava_net_NetworkInterface.c
beeef8aef21e383d32d362a688b5d5bf0b0428b4 01-Oct-2009 Lorenzo Colitti <lorenzo@google.com> More multicast fixes.

1. Make native code properly set network interface indexes that are used for
new-style multicast socket options.
2. For IP_MULTICAST_IF, check that the address is IPv4, not the socket.
3. Remove a @KnownFailure annotation for a test that now passes.

This removes one test error and changes it into a more benign failure. The
remaining test failures seem to be due to Linux bening permissive about which
interfaces you can receive multicast traffic on, which is probably good enough
for now.

Change-Id: Id1fddee338addcfce821672b983485c7dd4983d4
ava_net_NetworkInterface.c
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
e325918715987b5efc5cbb80271be467878aeebd 01-Oct-2009 Lorenzo Colitti <lorenzo@google.com> Fixes for socket options on multicast sockets.

1. Properly pass get/setsockopt the pointer to the socket option instead of the
pointer to the pointer to the option. This was not caught at compile time
because it's a void *.
2. Handle IPv4 multicast addresses on IPv6 sockets. This is important because
current devices create IPv6 sockets by default.
3. Use the proper options for IPv6 multicast (i.e., IPV6_{ADD,DROP}_MEMBERSHIP
instead of IP_{ADD,DROP}_MEMBERSHIP)
4. Use integers instead of bytes when getting or setting the multicast TTL
because that's what the Linux kernel uses.

These fix 10 of the 11 MulticastSocketTest failures. Also, minor changes:

1. Add ifdefd-out logging functions for get/setsockopt.
2. Change all instances of IPPROTO_{IP,IPv6} to SOL_{IP,IPV6} in get/setsockopt
calls. Even though the values are the same (so the code worked), this way is
more correct.

Change-Id: Iea75a523d7e71f0b361a42c0e39d3ef075dc7ff4
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
109fc1115e7afd2907544b805eaa2cc8a0e2635f 01-Oct-2009 Elliott Hughes <enh@google.com> Simplify FileInputStream.skip to match the RI.

The RI throws IOException on any non-seekable stream, including stdin.
This patch removes harmony's special-case hack for stdin, and the native
cruft that wasn't even necessary if you did want a special hack for
stdin.

Bug: 1542253
rg_apache_harmony_luni_platform_OSFileSystem.cpp
74b78ff194b4bfa98c319dfd75e18b42c6780d0f 30-Sep-2009 Elliott Hughes <enh@google.com> Fix build (don't rely on transitive #include).

The sim-eng build wasn't picking up <string.h> for memcpy(3).
rg_apache_harmony_luni_platform_OSFileSystem.cpp
3d478ad9fefa9c90b5c644f5e3d9437828537ed9 27-Sep-2009 Elliott Hughes <enh@google.com> Throw meaningful IOException instances from native code.

The Java side of OSFileSystem was throwing IOExceptions with no detail
message. If we throw from the native side instead, we can supply
meaningful explanations. This turned up a couple of bugs:

* read, readDirect, readv, writev, and ttyRead would only throw IOException
if they returned < -1, which is impossible. (writev was probably a copy & paste
from readv, and the reads were probably confused by the impedence mismatch
between Unix's use of 0 to mean end of file and -1 to mean error, and Java's
use of -1 for end of file.)

* inconsistent checking for null byte[]s passed in.

* read and write would retry on EINTR, but readDirect and writeDirect wouldn't.

* we'd silently truncate seek/lock/truncate offsets that didn't fit in 32 bits;
we now throw an IOException instead.

It also means a few native functions become "void" because errors are now
reported by throwing exceptions, and the Java functions that used to call them
are no longer needed.

Also change ProcessManager to use jniThrowIOException, remove the unused
throwIOExceptionStr from OSNetworkSystem.cpp, and remove the KnownFailure from
FileTest's test_delete, now we have a fixed version of yaffs that won't
rmdir(2) non-empty directories.

Bug: 1542253
rg_apache_harmony_luni_platform_OSFileSystem.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
e8596906d75fd8ccda31600d71ad56391cd7cd3a 19-Sep-2009 Lorenzo Colitti <lorenzo@google.com> Manual merge of change I3665f82b into master.
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
7356e5631e05b8b31d22a7e303bdef8b1221b065 19-Sep-2009 Lorenzo Colitti <lorenzo@google.com> Use native code to convert strings to IP addresses.

1. Add an ipStringToByteArray method to the OSNetworkSystem interface and
provide a native implementation for it.
2. Change InetAddress to use the new method.
3. Remove a mid-sized chunk of Inet6Util, which is now redundant.
4. Remove the KnownFailure annotations from the InetAddress, InetAddress and
Inet6Address tests that expected 1.2.3, 1.3 and 3 to be valid IPv4
addresses. These tests now pass again.
5. Removed an unused native method.
6. Added a comment to the top of the native socket implementation to the effect
that the file is significantly different from harmony.

Change-Id: I3665f82b00ebc089e9133cc6166dda5a99fa10e4
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
511ab05f7731dffa3480cbd0b79836b231f77ef6 19-Sep-2009 Lorenzo Colitti <lorenzo@google.com> Manual merge of eclair change I26548922 into master.
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
ec67773c5d9bbdbff7e846ef28816a3870d4cac2 18-Sep-2009 Lorenzo Colitti <lorenzo@google.com> Use native code to convert IP addresses to strings.

- Add a byteArrayToIpString method to the INetworkSystem interface and implement
it in native code
- Fix the native code so it does better error reporting
- Change InetAddress's getHostAddress, getHostName and getCanonicalHostName
methods to use it and remove the IPv4-only Java implementations
- Remove Inet6Util.createIPAddrStringFromByteArray
- Fix InetAddress so getByAddress(null) throws UnknownHostException instead of
NullPointerException for compatibility with the RI.

Change-Id: I26548922e9eed63b295173456183c4ab3ce20718
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
42d8ce7a37c6c2245fa619843e9c240c1d2f3e46 18-Sep-2009 Elliott Hughes <enh@google.com> Fix heap corruption in nio select(2) code.

The active ingredient in this change is that we now test that the fd isn't -1,
used to represent an invalid fd. There's a race condition where a socket can be
closed between SelectorImpl.prepareChannels and the native code. This caused us
to write to the -1th element of a heap-allocated structure, leading to SIGSEGV.

I've also removed the check for an empty fd_set. It was broken before and will
never have fired, but I don't think it makes sense to fix it, given this race
condition.

The race can't be fixed because the implementation is documented to close the
socket channel and *then* cancel the selection key.

This patch also removes various dead functions and tidies up timeval usage.

Bug: 2093094
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
422328ca3a419c43be6dce0572380564fcbaead8 17-Sep-2009 Lorenzo Colitti <lorenzo@google.com> am 120051b4: am b257c944: Report the cause of name lookup failures to Java land. The Java code already uses the exception thrown by getallbyname() as a chained exception.

Merge commit '120051b4744da2888756d901f9351ebd8e5ae467'

* commit '120051b4744da2888756d901f9351ebd8e5ae467':
Report the cause of name lookup failures to Java land. The Java code already
ac00580c6651b27366d6e6962971e936d417dae3 17-Sep-2009 Lorenzo Colitti <lorenzo@google.com> am a28e7d1a: am 1cf3dbce: Merge change 25160 into eclair

Merge commit 'a28e7d1a32d3883b5b279f5ddc8473e6bcbf6760'

* commit 'a28e7d1a32d3883b5b279f5ddc8473e6bcbf6760':
Make getHostByAddr and getHostByName return the proper object type.
88e341d4cbfd085e2f16659e810c95ba88bd608d 16-Sep-2009 Lorenzo Colitti <lorenzo@google.com> Report the cause of name lookup failures to Java land. The Java code already
uses the exception thrown by getallbyname() as a chained exception.

Change-Id: Ifc0d34102412ce0bf34715c9852bf751b420fb40
ava_net_InetAddress.cpp
b406800f8463936bc70f47e53746ef0e60ea5046 16-Sep-2009 Lorenzo Colitti <lorenzo@google.com> Make getHostByAddr and getHostByName return the proper object type.

Change-Id: I51c75205095b7fe093ccb4451bbf7cc6a287bc49
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
70397adb8f185ad50e131f050103dc99110fe818 15-Sep-2009 Android (Google) Code Review <android-gerrit@google.com> Merge change 24794

* changes:
Fix the final [mis]uses of iscopy.
8c55bea0dc81b154be04ab8d1bf46e47e1fdb416 12-Sep-2009 Elliott Hughes <enh@google.com> Fix the final [mis]uses of iscopy.

I finally got round to going through all the dalvik/libcore/ calls to the
following routines, in cases where the final argument ("iscopy") is non-NULL:

Get*ArrayElements
GetStringChars
GetStringUTFChars
GetStringCritical
Get*ArrayCritical

The calls in sqlite_jni.c were neither assuming that setting "iscopy" requests
a copy (a bug we've seen elsewhere), nor were they making use of the result.
I've changed these to pass NULL to make their lack of interest explicit. I've
also fixed a compiler warning (signed/unsigned comparison).

The ones in org_apache_harmony_luni_platform_OSFileSystem.cpp were genuine
errors. The author was under the misapprehension that iscopy == JNI_FALSE
implies that you do not need to call the corresponding "Release" function.
I've fixed those. (I haven't addressed the fact that readvImpl and writevImpl
differ by just one token, nor have I addressed the fact that -- in theory
though not with our current GC -- any of the GetIntArrayElements could fail.)
rg_apache_harmony_luni_platform_OSFileSystem.cpp
821f8b65f01cdc0b0ef427a7b4a3314ca2b2e575 15-Sep-2009 Lorenzo Colitti <lorenzo@google.com> am 08211fc1: am 1e49340a: Merge change 24320 into eclair

Merge commit '08211fc192db0bd48e78103678a902c32d67480d'

* commit '08211fc192db0bd48e78103678a902c32d67480d':
Simplify networking code initialization using static structures instead of code.
17ae753d638df37e7e0b66ea0435212c2f2b682d 11-Sep-2009 Android (Google) Code Review <android-gerrit@google.com> Merge change 24610

* changes:
Several small native code fixes.
1790dd309f7c520182ac8553309cc4faf670ae89 09-Sep-2009 Lorenzo Colitti <lorenzo@google.com> Simplify networking code initialization using static structures instead of code.
Fix an uninitialized variable.

Change-Id: Id9064a185525bfe072b244ea3d2acb56e5e185cd
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
9ee0ceadae7cc5cdedf675f515b653cd626af132 11-Sep-2009 Elliott Hughes <enh@google.com> Several small native code fixes.

* Don't throw OutOfMemoryError manually in Adler32/CRC32: the VM does that for
us if GetPrimitiveArrayCritical needs, but fails, to allocate memory.

* Don't use anything but NULL for the "iscopy" argument to Get*ArrayElements.
The other users of this argument (removed earlier this week) were under the
mistaken impression that it's an "in" parameter rather than an "out" parameter,
and since these remaining callers aren't actually using the result, let's
remove the cruft.

* Move the null check in harmony_io_openImpl for "path" to come *before* the
first dereference.

* Make harmony_io_ttyReadImpl just delegate to harmony_io_readImpl since,
apart from the zero-length read check, they were identical.

* Remove the dead function throwIOExceptionStr from the OpenSSLSessionImpl
native code.

Tested on sapphire-eng.
rg_apache_harmony_luni_platform_OSFileSystem.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
de2d83fd6a976a586e99d74018ac53fadc179aec 10-Sep-2009 Elliott Hughes <enh@google.com> Fix unnecessary GetPrimitiveArrayCritical users.

Tested on sapphire-eng.

Bug: 1639287
rg_apache_harmony_luni_platform_OSMemory.cpp
44550df73a4aff18af123c65c5fbc69c02cbb1bd 09-Sep-2009 Elliott Hughes <enh@google.com> Use Get*ArrayRegion/Set*ArrayRegion instead of Get*ArrayElements.

This fixes all instances in the networking code, but doesn't address similar
patterns, nor non-networking code. This seemed like a reasonably-sized
meaningful chunk. Tested on sapphire-eng.

Bug: 1639287
ava_net_InetAddress.cpp
ava_net_NetworkInterface.c
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
2d97a2b8ca7cd4993f9f917bdffd83d19e1e4f6c 04-Sep-2009 Lorenzo Colitti <lorenzo@google.com> Document that createSocketFileDescriptor throws an exception on failure.

Change-Id: Ic002b4dc8c40d798316afbab7a14bd81593e2541
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
66e35e840560275e03eb957f5a7fc8c1103009e2 04-Sep-2009 Lorenzo Colitti <lorenzo@google.com> If an error occurs when creating a socket, don't call any more JNI methods
(thus causing a segfault) but return immediately.

Change-Id: I7d05997e38e631200542f85eba16b854d488d584
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
aa479388328a164ecf9b26613cb7e79f29cf60a3 27-Aug-2009 Lorenzo Colitti <lorenzo@google.com> More InetAddress fixes.

1. Make sure getHostByAddrImpl actually throws UnknownHostException: set
NI_NAMEREQD when calling getnameinfo to ensure it will fail if the IP
address looked up does not have a name associated with it, and pass this
exception back to the Java code. That way, the UnknownHostException passed
back to the Java code has information on what went wrong.
2. Remove superfluous logging on reverse lookups in the C code.

Change-Id: Ie195ce1f12e7b43fbf75f494002804f9db68fd8c
ava_net_InetAddress.cpp
e6fafc650ef9236ade1da5953ab5684cac2aded3 03-Sep-2009 Android (Google) Code Review <android-gerrit@google.com> Merge change 22771 into eclair

* changes:
Don't mutate input in OSMemory.setIntArray/setShortArray.
02936f39bc3d3e73f031620e03b6791a73368f7f 02-Sep-2009 Lorenzo Colitti <lorenzo@google.com> Unbreak Dalvik VM initialization due to a native method that expects to be able
to call an InetAddress no-args constructor. This constructor was package-private
and was recently removed. This method is horribly complex and should go away (it
probably doesn't even work, due to it attempting to find a class known as
"java/io/FielDescriptor"), but it needs to be fixed for now.

Change-Id: I56b1e0e07f4c97af82e0a4f14dfd2d8af16f6b82
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
558383f61c19c594bdc475dc54216af6b12b142c 26-Aug-2009 Elliott Hughes <enh@google.com> Don't mutate input in OSMemory.setIntArray/setShortArray.

We now take a copy and then swap bytes in the copy if necessary,
rather than swapping the input, copying, and swapping the input
back.

I've switched to GetShortArrayRegion/GetIntArrayRegion instead
of GetPrimitiveArrayCritical because the latter makes life
unnecessarily hard for the VM/GC, and requires a second JNI call
to undo.

I've also renamed the native functions to match the Java methods
they implement.

(Tested by running the nio tests on the emulator, with added
logging to check that all four variants are called.)

Bug: 2019584
rg_apache_harmony_luni_platform_OSMemory.cpp
723edb3d255972ca93314a580e7a8bcb0a0ee2d5 19-Aug-2009 Lorenzo Colitti <lorenzo@google.com> Enable IPv6.

If the system has IPv6 connectivity, query the DNS for IPv6 addresses as well
as IPv4 addresses. If IPv6 addresses are returned, prefer them by default.

Impact of this change:

- If the device is on a network with IPv6 configured, is using wifi, and has
obtained an IPv6 address using autoconfiguration, the network stack will
request IPv6 addresses as well as IPv4 addresses when making DNS queries. This
allows the device to connect to websites and services that declare themselves
to be reachable over IPv6. If an IPv6 connection fails, the stack will fall
back to IPv4. This is what Windows Vista, Mac OS 10.4 and above, and most
Linux distributions do by default.
- If the device is not on a network that supports IPv6, or is using 3G/EVDO,
nothing will change.

I have been testing this change on self-compiled builds of master and eclair on
Dream and Sholes for several weeks with no breakage that I can see.
ava_net_InetAddress.cpp
a389b4a499f40379b0b204d7ba1c2057663d95c0 11-Aug-2009 Jesse Wilson <jessewilson@google.com> Update Luni to Harmony r802921.

Notable changes:
- replaced StringBuffer with StringBuilder in several places
- fixed a problem with BufferedInputStream's newline characters (EBCDIC)
- cleanup Timer's finalizer helper object
- new cache for the canonical path of a file
- fixed concurrency issue with ArrayList
- floating point parsing now trims length for very small numbers
- encoding specified "UTF-8" when converting some byte[]s to strings (JarURLConnection, Util, OSFileSystem)
- Harmony now implements floor and ceil in Java. We continue to use native code.
bigint.c
4181e0fcd5383eadf9cddadf3230fab383782ca0 30-Jul-2009 Jesse Wilson <jessewilson@google.com> am bd79e449: Fix an issue where we\'re adding 4x the intended offset.

Merge commit 'bd79e4498465381117f2cbc6399a256061f1d144'

* commit 'bd79e4498465381117f2cbc6399a256061f1d144':
Fix an issue where we're adding 4x the intended offset.
a2ef9a8dc12d949639c62eab7e5acc88080e059d 29-Jul-2009 Jesse Wilson <jessewilson@google.com> Fix an issue where we're adding 4x the intended offset.

We were doing pointer arithmetic of mixed types (jint* and jint),
and the type conversion ended up causing the offset to be converted
an extra time.
rg_apache_harmony_luni_platform_OSMemory.cpp
f5597e626ecf7949d249dea08c1a2964d890ec11 25-Jul-2009 Jesse Wilson <jessewilson@google.com> Integrate luni module (but not tests) to Harmony r772995.

Notable changes
- Stripped "@since Android 1.0" from many files. Most files
are now 100% the same in Dalvik and Harmony.
- AbstractStringBuilder.reverse() supports surrogates
- AbstractStringBuilder shares less to waste less memory
- Bitset optimized
- BufferedInputStream changed to support unsynchronized close()
- BufferedOutputStream does flushInternal
- BufferedReader supports EBCDIC NEL
- Collections.synchronizedList().indexOf() does a copy for more concurrency
- Classes in nio module changed: DatagramChannelImpl, SocketChannelImpl
and ServerSocketChannelImpl (these depend on internal APIs changed in
this update)
- DataInputStream/DataOutputStream now use a small buffer to limit the
number of times the underlying stream is accessed
- Date now has a minutes offset, more efficient toString()
- ExposedByteArrayInputStream: new internal class
- DeleteOnExit moved to top-level class
- FileDescriptor.isValid() now non-native
- Float, Double lessThan optimized (fix for compare(-0.0F, 0.0F) still pending)
- FileURLConnection now guesses content types from streams
- HashMap iterator changes
- Hashtable iterator changes
- INetworkSystem
- removes bind2(), createMulticastSocket, sendStream(),
- renames createSocket to createStreamSocket
- JarURLConnection rewritten
- LinkedHashMap: new iterator
- Locale, Currency, TimeZone: now use ICU in Harmony, plain Java in Dalvik
- ObjectInputStream: Accessor objects in Harmony, direct native in Dalvik
- ProxyClassFile - many changes
- String - optimized ascii for toLowerCase, toUpperCase, compare
- Timer - rewritten
- TreeMap - rewritten
- URLClassLoader - new
- URLConnection - new guessContentTypeFromStream(), uses org.apache.harmony.awt.www.content
to lookup content type handlers
bigint.c
ava_io_FileDescriptor.c
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
rg_apache_harmony_luni_util_fltparse.c
5f327be03e6d79f9625585520c2c6117787204af 04-Jun-2009 Andy McFadden <fadden@android.com> "External allocation" tracking for direct buffers.

The native memory allocated for ByteBuffer.allocateDirect was not being
tracked by the VM's "external allocation" mechanism. This adds the
necessary calls to the Harmony OSMemory allocator, which is what
actually calls malloc().

The external alloc stuff just takes size values, so we tuck a copy of
the allocation size into the allocated block, and pull it out when it's
time to free the memory.

(Includes in a couple of other changes that I had to commit somewhere so
I could sync.)
rg_apache_harmony_luni_platform_OSMemory.cpp
c0ff7798890bef00c074fdc3b16ecf7bdd72c4fe 12-Jun-2009 Lorenzo Colitti <lorenzo@google.com> Use RFC3493-conformant IPv6 headers.
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
a929f07ee21030889144b6f7deb399454560d768 16-Jun-2009 Lorenzo Colitti <lorenzo@google.com> Don't throw away the return value of connect().
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
dcfdc985b3450d8036e011c83f982f765ae1ecdd 15-Jun-2009 Lorenzo Colitti <lorenzo@google.com> Define wrappers for connect() and bind() to support IPv6.
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
d4c4383ba2587bd5009da8da3ba0141bb2928c08 15-Jun-2009 Lorenzo Colitti <lorenzo@google.com> am 593d6c7c: Copy the correct number of bytes for IPv6 addresses in InetAddress_gethostbyaddr

Merge commit '593d6c7c4c08c82b361dcc08c20a0120aaaacf49'

* commit '593d6c7c4c08c82b361dcc08c20a0120aaaacf49':
Copy the correct number of bytes for IPv6 addresses in InetAddress_gethostbyaddr
4b071429092bf8d710252a3109d53992beb1f85c 13-Jun-2009 Lorenzo Colitti <lorenzo@google.com> Copy the correct number of bytes for IPv6 addresses in InetAddress_gethostbyaddr
ava_net_InetAddress.cpp
9591b6d47a768cfe9c698323660e08b337a63cc1 06-Jun-2009 Mathias Agopian <mathias@google.com> remove all references to LogSocket.h
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
e35dd5201aca58dbfb2409817bcea63657a8bd88 05-Jun-2009 Lorenzo Colitti <lorenzo@google.com> Fix the sim build on systems that have old versions of the glibc headers.
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
a0d72ad284b88a403ed400cb897edfc39b29d199 04-Jun-2009 Lorenzo Colitti <lorenzo@google.com> Unbreak sim build.
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
3e22a7144b91ef6eb2ffea115382d506c9ddd26d 03-Jun-2009 Android (Google) Code Review <android-gerrit@google.com> Merge change 2920

* changes:
Make native socket code address-independent in preparation for IPv6 support.
65663e133c343184fde49412cbb310180384e0f9 27-May-2009 Lorenzo Colitti <lorenzo@google.com> Make native socket code address-independent in preparation for IPv6 support.
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
a99a8be076d13f5f9da8b23b8e8a914697b71dca 02-Jun-2009 Android (Google) Code Review <android-gerrit@google.com> am 744ab6b4: Merge change 2619 into donut

Merge commit '744ab6b47555dab886c90dbc720e207e1edefdc0'

* commit '744ab6b47555dab886c90dbc720e207e1edefdc0':
InetAddress: Stop logging DNS lookups to logcat.
b63989adf60002945f688104c850bb3fe788dd6d 28-May-2009 Mike Lockwood <lockwood@android.com> InetAddress: Stop logging DNS lookups to logcat.

Logging all DNS lookups system wide raises privacy concerns to me
and might make people less likely to include logs in their bug reports.

Signed-off-by: Mike Lockwood <lockwood@android.com>
ava_net_InetAddress.cpp
3aacf35a23458a16c0f7da7161275e3e749432ac 29-Apr-2009 Urs Grob <ursg@google.com> am f2931ca: Fix for excessive GREF use in gethostbyaddr.

Merge commit 'f2931ca22c6307a8740f2ec61795f7cfa6971262'

* commit 'f2931ca22c6307a8740f2ec61795f7cfa6971262':
Fix for excessive GREF use in gethostbyaddr.
64c59d08c125b04d766d4af0c2af8fe2a74919b5 27-Apr-2009 Urs Grob <ursg@google.com> Fix for excessive GREF use in gethostbyaddr.

Each call to gethostbyaddr in java_net_InetAddress.cpp increases the
GREF by one. After calling the method around 1800 times the vm
crashes because of excessive global references.
ava_net_InetAddress.cpp
224d80c8d9dd3339a2bd277cf0a32941d53a849f 25-Mar-2009 Mike Wakerly <> Automated import from //branches/donutburger/...@140825,140825
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
7076abb104167138ccfede6571ac40ef5cd1bdb4 25-Mar-2009 Mike Wakerly <> Automated import from //branches/master/...@140826,140826
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
5d287a9d9768195f53e244414b465ec4a6f72625 19-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import //branches/master/...@140412
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
adc854b798c1cfe3bfd4c27d68d5cee38ca617da 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
bigint.c
bigint.h
ommonDblParce.c
ommonDblParce.h
ltconst.h
ycomp.h
ava_io_File.c
ava_io_FileDescriptor.c
ava_io_ObjectInputStream.c
ava_io_ObjectOutputStream.c
ava_io_ObjectStreamClass.c
ava_lang_Character.cpp
ava_lang_Double.c
ava_lang_Float.c
ava_lang_Math.c
ava_lang_StrictMath.c
ava_net_InetAddress.cpp
ava_net_NetworkInterface.c
rg_apache_harmony_luni_platform_OSFileSystem.cpp
rg_apache_harmony_luni_platform_OSMemory.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
rg_apache_harmony_luni_util_NumberConvert.c
rg_apache_harmony_luni_util_fltparse.c
ub.mk
1c0fed63c71ddb230f3b304aac12caffbedf2f21 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
bigint.c
bigint.h
ommonDblParce.c
ommonDblParce.h
ltconst.h
ycomp.h
ava_io_File.c
ava_io_FileDescriptor.c
ava_io_ObjectInputStream.c
ava_io_ObjectOutputStream.c
ava_io_ObjectStreamClass.c
ava_lang_Character.cpp
ava_lang_Double.c
ava_lang_Float.c
ava_lang_Math.c
ava_lang_StrictMath.c
ava_net_InetAddress.cpp
ava_net_NetworkInterface.c
rg_apache_harmony_luni_platform_OSFileSystem.cpp
rg_apache_harmony_luni_platform_OSMemory.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
rg_apache_harmony_luni_util_NumberConvert.c
rg_apache_harmony_luni_util_fltparse.c
ub.mk
ac4f307115a738b0206030fe0d127f7c7f035b03 19-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@132276
ava_net_InetAddress.cpp
b7926325a1c1a370c84c81db80372f59af240a53 11-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@130745
ava_net_InetAddress.cpp
4351da844f9132d2d801d1a10ccc195091e31a8a 20-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@127101
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
a0881d052ee72e3f7e773374e9b1aa75fbd6be4c 10-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@125939
ava_net_InetAddress.cpp
dd828f42a5c83b4270d4fbf6fce2da1878f1e84a 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
bigint.h
ommonDblParce.c
xceptions.c
xceptions.h
ava_io_File.c
ava_lang_reflect_Proxy.c
ava_net_InetAddress.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
rg_apache_harmony_luni_util_fltparse.c
ub.mk
fdb2704414a9ed92394ada0d1395e4db86889465 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution
bigint.c
bigint.h
ommonDblParce.c
ommonDblParce.h
xceptions.c
xceptions.h
ltconst.h
ycomp.h
ava_io_File.c
ava_io_FileDescriptor.c
ava_io_ObjectInputStream.c
ava_io_ObjectOutputStream.c
ava_io_ObjectStreamClass.c
ava_lang_Character.cpp
ava_lang_Double.c
ava_lang_Float.c
ava_lang_Math.c
ava_lang_StrictMath.c
ava_lang_reflect_Proxy.c
ava_net_InetAddress.cpp
ava_net_NetworkInterface.c
rg_apache_harmony_luni_platform_OSFileSystem.cpp
rg_apache_harmony_luni_platform_OSMemory.cpp
rg_apache_harmony_luni_platform_OSNetworkSystem.cpp
rg_apache_harmony_luni_util_NumberConvert.c
rg_apache_harmony_luni_util_fltparse.c
ub.mk