Skip to content

Remove dependencies on commons-codec.jar and guava-r09.jar (to reduce java method count by ~7900 methods) #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed libs/commons-codec.jar
Binary file not shown.
Binary file removed libs/guava-r09.jar
Binary file not shown.
17 changes: 14 additions & 3 deletions src/net/sqlcipher/DatabaseUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.codec.binary.Hex;

import android.content.ContentValues;
import android.content.OperationApplicationException;
import android.os.Parcel;
Expand Down Expand Up @@ -323,10 +321,23 @@ public static String getCollationKey(String name) {
*/
public static String getHexCollationKey(String name) {
byte [] arr = getCollationKeyInBytes(name);
char[] keys = Hex.encodeHex(arr);
char[] keys = encodeHex(arr, HEX_DIGITS_LOWER);
return new String(keys, 0, getKeyLen(arr) * 2);
}

private static final char[] HEX_DIGITS_LOWER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};

private static char[] encodeHex(final byte[] data, final char[] toDigits) {
final int l = data.length;
final char[] out = new char[l << 1];
// two characters form the hex value.
for (int i = 0, j = 0; i < l; i++) {
out[j++] = toDigits[(0xF0 & data[i]) >>> 4];
out[j++] = toDigits[0x0F & data[i]];
}
return out;
}

private static int getKeyLen(byte[] arr) {
if (arr[arr.length - 1] != 0) {
return arr.length;
Expand Down
4 changes: 1 addition & 3 deletions src/net/sqlcipher/database/SQLiteDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
import android.util.Log;
import android.util.Pair;

import com.google.common.collect.Maps;

/**
* Exposes methods to manage a SQLite database.
* <p>SQLiteDatabase has methods to create, delete, execute SQL commands, and
Expand Down Expand Up @@ -320,7 +318,7 @@ public static void loadLibs (Context context, File workingDir)
* (@link setMaxCacheSize(int)}). its default is 0 - i.e., no caching by default because
* most of the apps don't use "?" syntax in their sql, caching is not useful for them.
*/
/* package */ Map<String, SQLiteCompiledSql> mCompiledQueries = Maps.newHashMap();
/* package */ Map<String, SQLiteCompiledSql> mCompiledQueries = new HashMap<String, SQLiteCompiledSql>();
/**
* @hide
*/
Expand Down