From 3bdd327f8532a79b83f575cc62e8eb09a1f93f3d Mon Sep 17 00:00:00 2001 From: Narayan Kamath Date: Thu, 27 Nov 2014 18:17:35 +0000 Subject: Move apache specific portions of android.net.http to external/apache-http. We continue to compile external/apache-http into ext.jar. This contains a few changes apart fom the classes moving around : - Makefile changes to build docs and api-stubs for now. A future change will revert these changes and remove these classes from stubs and docs. - Hardcode event IDs in legacyerrorstrings to avoid a dependency between the frameworks and apache. These strings are on their way out and will never change anyway. - Remove imports due to {@link} tags and use {@code} instead. - Remove an accidental(?) dependency on apache commons code that's a part of apache-http. bug: 18027885 Change-Id: I51cd038d846ec7d02c283a4541b10a6a9cf62ecf --- core/java/android/database/DatabaseUtils.java | 28 +++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'core/java/android/database/DatabaseUtils.java') diff --git a/core/java/android/database/DatabaseUtils.java b/core/java/android/database/DatabaseUtils.java index c125544..e61664c 100644 --- a/core/java/android/database/DatabaseUtils.java +++ b/core/java/android/database/DatabaseUtils.java @@ -16,8 +16,6 @@ package android.database; -import org.apache.commons.codec.binary.Hex; - import android.content.ContentValues; import android.content.Context; import android.content.OperationApplicationException; @@ -416,11 +414,33 @@ public class DatabaseUtils { * @return the collation key in hex format */ public static String getHexCollationKey(String name) { - byte [] arr = getCollationKeyInBytes(name); - char[] keys = Hex.encodeHex(arr); + byte[] arr = getCollationKeyInBytes(name); + char[] keys = encodeHex(arr); return new String(keys, 0, getKeyLen(arr) * 2); } + + /** + * Used building output as Hex + */ + private static final char[] DIGITS = { + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' + }; + + private static char[] encodeHex(byte[] input) { + int l = input.length; + char[] out = new char[l << 1]; + + // two characters form the hex value. + for (int i = 0, j = 0; i < l; i++) { + out[j++] = DIGITS[(0xF0 & input[i]) >>> 4 ]; + out[j++] = DIGITS[ 0x0F & input[i] ]; + } + + return out; + } + private static int getKeyLen(byte[] arr) { if (arr[arr.length - 1] != 0) { return arr.length; -- cgit v1.1