Cleanups for unbundling

* android.security is hidden.  Use java.security.MessageDigest instead.
* Remove android-common from makefile (we no longer use it)
* Add LOCAL_SDK_VERSION to makefile and comment it out

Change-Id: I7f9a021387d5c4e47ade1adb0bb75bec82ba0dd8
This commit is contained in:
Makoto Onuki 2010-09-09 10:43:18 -07:00
parent ffee97985c
commit 697f98aea5
3 changed files with 13 additions and 4 deletions

View File

@ -24,7 +24,8 @@ LOCAL_SRC_FILES += \
src/com/android/email/service/IEmailServiceCallback.aidl
# EXCHANGE-REMOVE-SECTION-END
LOCAL_STATIC_JAVA_LIBRARIES := android-common
# Revive this when the app is unbundled.
# LOCAL_SDK_VERSION := current
LOCAL_PACKAGE_NAME := Email

View File

@ -43,7 +43,6 @@ import android.os.AsyncTask;
import android.os.Environment;
import android.os.Parcel;
import android.os.Parcelable;
import android.security.MessageDigest;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Base64;
@ -62,6 +61,7 @@ import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collection;
@ -631,13 +631,17 @@ public class Utility {
Log.d(Email.LOG_TAG, "Error in TelephonyManager.getDeviceId(): " + e.getMessage());
return null;
}
return getSmallHash(deviceId);
}
/* package */ static String getSmallHash(final String value) {
final MessageDigest sha;
try {
sha = MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException impossible) {
return null;
}
sha.update(Utility.toUtf8(deviceId));
sha.update(Utility.toUtf8(value));
final int hash = getSmallHashFromSha1(sha.digest());
return Integer.toString(hash);
}

View File

@ -17,7 +17,6 @@
package com.android.email;
import com.android.email.Utility.NewFileCreator;
import com.android.email.provider.EmailContent.Account;
import com.android.email.provider.EmailContent.Mailbox;
import android.content.Context;
@ -207,6 +206,11 @@ public class UtilityUnitTests extends AndroidTestCase {
assertEquals(deviceId, deviceId2);
}
public void testGetSmallHash() {
assertEquals("1438642069", Utility.getSmallHash(""));
assertEquals("1354919068", Utility.getSmallHash("abc"));
}
public void testGetSmallSha1() {
byte[] sha1 = new byte[20];