diff options
author | Daisuke Miyakawa <dmiyakawa@google.com> | 2010-05-14 11:17:46 -0700 |
---|---|---|
committer | Daisuke Miyakawa <dmiyakawa@google.com> | 2010-05-20 11:25:37 -0700 |
commit | 64545a8ced5aa350e917ab1824a1c06a14a96532 (patch) | |
tree | 54d911229c87a45f815c0a350a8a093eff877034 | |
parent | ee714613e8f7743d21de164dfb4cd9bea4ae85f1 (diff) | |
download | frameworks_base-64545a8ced5aa350e917ab1824a1c06a14a96532.zip frameworks_base-64545a8ced5aa350e917ab1824a1c06a14a96532.tar.gz frameworks_base-64545a8ced5aa350e917ab1824a1c06a14a96532.tar.bz2 |
Make vCard code a separated static library.
- Move the library to a separate directory in framewokr/base, and rename its package from
android.pim.vcard to com.android.vcard.
- Move all tests for the library under the directory.
- Confirm all tests for vCard are successful.
It would be better for us to have this directory somewhere else (like external/).
But I'll submit this here now and move it to the right place as soon as possible.
From the view of build mechanism, we can do that immediately.
BUG: 2689523
Change-Id: I435e10571b7160bfcc029bed7c37aaac1c6fd69a
-rw-r--r-- | core/java/android/pim/vcard/exception/package.html | 5 | ||||
-rw-r--r-- | core/java/android/pim/vcard/package.html | 5 | ||||
-rw-r--r-- | vcard/Android.mk | 28 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/JapaneseUtils.java (renamed from core/java/android/pim/vcard/JapaneseUtils.java) | 2 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/VCardBuilder.java (renamed from core/java/android/pim/vcard/VCardBuilder.java) | 8 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/VCardComposer.java (renamed from core/java/android/pim/vcard/VCardComposer.java) | 6 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/VCardConfig.java (renamed from core/java/android/pim/vcard/VCardConfig.java) | 5 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/VCardConstants.java (renamed from core/java/android/pim/vcard/VCardConstants.java) | 2 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/VCardEntry.java (renamed from core/java/android/pim/vcard/VCardEntry.java) | 4 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/VCardEntryCommitter.java (renamed from core/java/android/pim/vcard/VCardEntryCommitter.java) | 2 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/VCardEntryConstructor.java (renamed from core/java/android/pim/vcard/VCardEntryConstructor.java) | 12 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/VCardEntryCounter.java (renamed from core/java/android/pim/vcard/VCardEntryCounter.java) | 2 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/VCardEntryHandler.java (renamed from core/java/android/pim/vcard/VCardEntryHandler.java) | 2 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/VCardInterpreter.java (renamed from core/java/android/pim/vcard/VCardInterpreter.java) | 2 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/VCardInterpreterCollection.java (renamed from core/java/android/pim/vcard/VCardInterpreterCollection.java) | 2 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/VCardParser.java (renamed from core/java/android/pim/vcard/VCardParser.java) | 4 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/VCardParserImpl_V21.java (renamed from core/java/android/pim/vcard/VCardParserImpl_V21.java) | 17 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/VCardParserImpl_V30.java (renamed from core/java/android/pim/vcard/VCardParserImpl_V30.java) | 9 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/VCardParser_V21.java (renamed from core/java/android/pim/vcard/VCardParser_V21.java) | 4 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/VCardParser_V30.java (renamed from core/java/android/pim/vcard/VCardParser_V30.java) | 4 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/VCardSourceDetector.java (renamed from core/java/android/pim/vcard/VCardSourceDetector.java) | 2 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/VCardUtils.java (renamed from core/java/android/pim/vcard/VCardUtils.java) | 39 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/exception/VCardAgentNotSupportedException.java (renamed from core/java/android/pim/vcard/exception/VCardAgentNotSupportedException.java) | 2 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/exception/VCardException.java (renamed from core/java/android/pim/vcard/exception/VCardException.java) | 2 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/exception/VCardInvalidCommentLineException.java (renamed from core/java/android/pim/vcard/exception/VCardInvalidCommentLineException.java) | 2 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/exception/VCardInvalidLineException.java (renamed from core/java/android/pim/vcard/exception/VCardInvalidLineException.java) | 3 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/exception/VCardNestedException.java (renamed from core/java/android/pim/vcard/exception/VCardNestedException.java) | 2 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/exception/VCardNotSupportedException.java (renamed from core/java/android/pim/vcard/exception/VCardNotSupportedException.java) | 2 | ||||
-rw-r--r-- | vcard/java/com/android/vcard/exception/VCardVersionException.java (renamed from core/java/android/pim/vcard/exception/VCardVersionException.java) | 3 | ||||
-rw-r--r-- | vcard/tests/Android.mk | 25 | ||||
-rw-r--r-- | vcard/tests/AndroidManifest.xml | 30 | ||||
-rw-r--r-- | vcard/tests/res/raw/v21_backslash.vcf (renamed from core/tests/coretests/res/raw/v21_backslash.vcf) | 0 | ||||
-rw-r--r-- | vcard/tests/res/raw/v21_complicated.vcf (renamed from core/tests/coretests/res/raw/v21_complicated.vcf) | 0 | ||||
-rw-r--r-- | vcard/tests/res/raw/v21_invalid_comment_line.vcf (renamed from core/tests/coretests/res/raw/v21_invalid_comment_line.vcf) | 0 | ||||
-rw-r--r-- | vcard/tests/res/raw/v21_japanese_1.vcf (renamed from core/tests/coretests/res/raw/v21_japanese_1.vcf) | 0 | ||||
-rw-r--r-- | vcard/tests/res/raw/v21_japanese_2.vcf (renamed from core/tests/coretests/res/raw/v21_japanese_2.vcf) | 0 | ||||
-rw-r--r-- | vcard/tests/res/raw/v21_multiple_entry.vcf (renamed from core/tests/coretests/res/raw/v21_multiple_entry.vcf) | 0 | ||||
-rw-r--r-- | vcard/tests/res/raw/v21_org_before_title.vcf (renamed from core/tests/coretests/res/raw/v21_org_before_title.vcf) | 0 | ||||
-rw-r--r-- | vcard/tests/res/raw/v21_pref_handling.vcf (renamed from core/tests/coretests/res/raw/v21_pref_handling.vcf) | 0 | ||||
-rw-r--r-- | vcard/tests/res/raw/v21_simple_1.vcf (renamed from core/tests/coretests/res/raw/v21_simple_1.vcf) | 0 | ||||
-rw-r--r-- | vcard/tests/res/raw/v21_simple_2.vcf (renamed from core/tests/coretests/res/raw/v21_simple_2.vcf) | 0 | ||||
-rw-r--r-- | vcard/tests/res/raw/v21_simple_3.vcf (renamed from core/tests/coretests/res/raw/v21_simple_3.vcf) | 0 | ||||
-rw-r--r-- | vcard/tests/res/raw/v21_title_before_org.vcf (renamed from core/tests/coretests/res/raw/v21_title_before_org.vcf) | 0 | ||||
-rw-r--r-- | vcard/tests/res/raw/v21_winmo_65.vcf (renamed from core/tests/coretests/res/raw/v21_winmo_65.vcf) | 0 | ||||
-rw-r--r-- | vcard/tests/res/raw/v30_comma_separated.vcf (renamed from core/tests/coretests/res/raw/v30_comma_separated.vcf) | 0 | ||||
-rw-r--r-- | vcard/tests/res/raw/v30_simple.vcf (renamed from core/tests/coretests/res/raw/v30_simple.vcf) | 0 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/VCardExporterTests.java (renamed from core/tests/coretests/src/android/pim/vcard/VCardExporterTests.java) | 10 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/VCardImporterTests.java (renamed from core/tests/coretests/src/android/pim/vcard/VCardImporterTests.java) | 10 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/VCardJapanizationTests.java (renamed from core/tests/coretests/src/android/pim/vcard/VCardJapanizationTests.java) | 13 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/VCardTestsBase.java (renamed from core/tests/coretests/src/android/pim/vcard/VCardTestsBase.java) | 7 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/VCardUtilsTests.java (renamed from core/tests/coretests/src/android/pim/vcard/VCardUtilsTests.java) | 5 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/test_utils/ContactEntry.java (renamed from core/tests/coretests/src/android/pim/vcard/test_utils/ContactEntry.java) | 2 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/test_utils/ContentValuesBuilder.java (renamed from core/tests/coretests/src/android/pim/vcard/test_utils/ContentValuesBuilder.java) | 2 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/test_utils/ContentValuesVerifier.java (renamed from core/tests/coretests/src/android/pim/vcard/test_utils/ContentValuesVerifier.java) | 19 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/test_utils/ContentValuesVerifierElem.java (renamed from core/tests/coretests/src/android/pim/vcard/test_utils/ContentValuesVerifierElem.java) | 21 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/test_utils/ExportTestProvider.java (renamed from core/tests/coretests/src/android/pim/vcard/test_utils/ExportTestProvider.java) | 5 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/test_utils/ExportTestResolver.java (renamed from core/tests/coretests/src/android/pim/vcard/test_utils/ExportTestResolver.java) | 5 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/test_utils/ImportTestProvider.java (renamed from core/tests/coretests/src/android/pim/vcard/test_utils/ImportTestProvider.java) | 10 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/test_utils/ImportTestResolver.java (renamed from core/tests/coretests/src/android/pim/vcard/test_utils/ImportTestResolver.java) | 2 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/test_utils/LineVerifier.java (renamed from core/tests/coretests/src/android/pim/vcard/test_utils/LineVerifier.java) | 5 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/test_utils/LineVerifierElem.java (renamed from core/tests/coretests/src/android/pim/vcard/test_utils/LineVerifierElem.java) | 5 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/test_utils/PropertyNode.java (renamed from core/tests/coretests/src/android/pim/vcard/test_utils/PropertyNode.java) | 5 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/test_utils/PropertyNodesVerifier.java (renamed from core/tests/coretests/src/android/pim/vcard/test_utils/PropertyNodesVerifier.java) | 13 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/test_utils/PropertyNodesVerifierElem.java (renamed from core/tests/coretests/src/android/pim/vcard/test_utils/PropertyNodesVerifierElem.java) | 2 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/test_utils/VCardVerifier.java (renamed from core/tests/coretests/src/android/pim/vcard/test_utils/VCardVerifier.java) | 21 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/test_utils/VNode.java (renamed from core/tests/coretests/src/android/pim/vcard/test_utils/VNode.java) | 2 | ||||
-rw-r--r-- | vcard/tests/src/com/android/vcard/tests/test_utils/VNodeBuilder.java (renamed from core/tests/coretests/src/android/pim/vcard/test_utils/VNodeBuilder.java) | 13 |
67 files changed, 256 insertions, 158 deletions
diff --git a/core/java/android/pim/vcard/exception/package.html b/core/java/android/pim/vcard/exception/package.html deleted file mode 100644 index 26b8a32..0000000 --- a/core/java/android/pim/vcard/exception/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<HTML> -<BODY> -{@hide} -</BODY> -</HTML>
\ No newline at end of file diff --git a/core/java/android/pim/vcard/package.html b/core/java/android/pim/vcard/package.html deleted file mode 100644 index 26b8a32..0000000 --- a/core/java/android/pim/vcard/package.html +++ /dev/null @@ -1,5 +0,0 @@ -<HTML> -<BODY> -{@hide} -</BODY> -</HTML>
\ No newline at end of file diff --git a/vcard/Android.mk b/vcard/Android.mk new file mode 100644 index 0000000..2bc17aa --- /dev/null +++ b/vcard/Android.mk @@ -0,0 +1,28 @@ +# Copyright (C) 2010 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE := com.android.vcard +LOCAL_SRC_FILES := $(call all-java-files-under, java) + +# Use google-common instead of android-common for using hidden code in telephony library. +# Use ext for using Quoted-Printable codec. +LOCAL_JAVA_LIBRARIES := google-common ext + +include $(BUILD_STATIC_JAVA_LIBRARY) + +# Build the test package. +include $(call all-makefiles-under, $(LOCAL_PATH)) diff --git a/core/java/android/pim/vcard/JapaneseUtils.java b/vcard/java/com/android/vcard/JapaneseUtils.java index dcfe980..5b44944 100644 --- a/core/java/android/pim/vcard/JapaneseUtils.java +++ b/vcard/java/com/android/vcard/JapaneseUtils.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package android.pim.vcard; +package com.android.vcard; import java.util.HashMap; import java.util.Map; diff --git a/core/java/android/pim/vcard/VCardBuilder.java b/vcard/java/com/android/vcard/VCardBuilder.java index 789b5f8..6ef9ada 100644 --- a/core/java/android/pim/vcard/VCardBuilder.java +++ b/vcard/java/com/android/vcard/VCardBuilder.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package android.pim.vcard; +package com.android.vcard; import android.content.ContentValues; import android.provider.ContactsContract.CommonDataKinds.Email; @@ -30,11 +30,10 @@ import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; import android.provider.ContactsContract.CommonDataKinds.Website; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; +import android.util.Base64; import android.util.CharsetUtils; import android.util.Log; -import org.apache.commons.codec.binary.Base64; - import java.io.UnsupportedEncodingException; import java.nio.charset.UnsupportedCharsetException; import java.util.ArrayList; @@ -1166,7 +1165,8 @@ public class VCardBuilder { Log.d(LOG_TAG, "Unknown photo type. Ignored."); continue; } - final String photoString = new String(Base64.encodeBase64(data)); + // TODO: check this works fine. + final String photoString = new String(Base64.encode(data, Base64.NO_WRAP)); if (!TextUtils.isEmpty(photoString)) { appendPhotoLine(photoString, photoType); } diff --git a/core/java/android/pim/vcard/VCardComposer.java b/vcard/java/com/android/vcard/VCardComposer.java index 170d6fa..7038955 100644 --- a/core/java/android/pim/vcard/VCardComposer.java +++ b/vcard/java/com/android/vcard/VCardComposer.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package android.pim.vcard; +package com.android.vcard; import android.content.ContentResolver; import android.content.ContentValues; @@ -24,7 +24,6 @@ import android.content.Entity.NamedContentValues; import android.database.Cursor; import android.database.sqlite.SQLiteException; import android.net.Uri; -import android.pim.vcard.exception.VCardException; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Data; import android.provider.ContactsContract.RawContacts; @@ -45,6 +44,8 @@ import android.text.TextUtils; import android.util.CharsetUtils; import android.util.Log; +import com.android.vcard.exception.VCardException; + import java.io.BufferedWriter; import java.io.FileOutputStream; import java.io.IOException; @@ -526,6 +527,7 @@ public class VCardComposer { EntityIterator entityIterator = null; try { final Uri uri = RawContactsEntity.CONTENT_URI.buildUpon() + // .appendQueryParameter("for_export_only", "1") .appendQueryParameter(Data.FOR_EXPORT_ONLY, "1") .build(); final String selection = Data.CONTACT_ID + "=?"; diff --git a/core/java/android/pim/vcard/VCardConfig.java b/vcard/java/com/android/vcard/VCardConfig.java index 80709f3..fc95922 100644 --- a/core/java/android/pim/vcard/VCardConfig.java +++ b/vcard/java/com/android/vcard/VCardConfig.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard; +package com.android.vcard; import android.telephony.PhoneNumberUtils; import android.util.Log; @@ -53,7 +53,6 @@ public class VCardConfig { * and it has 1 to 1 mapping in all 8bit characters. * If the assumption is not correct, this setting will cause some bug. * </p> - * @hide made public just for unit test */ public static final String DEFAULT_INTERMEDIATE_CHARSET = "ISO-8859-1"; @@ -476,4 +475,4 @@ public class VCardConfig { private VCardConfig() { } -} +}
\ No newline at end of file diff --git a/core/java/android/pim/vcard/VCardConstants.java b/vcard/java/com/android/vcard/VCardConstants.java index e11b1fd..862c9edc 100644 --- a/core/java/android/pim/vcard/VCardConstants.java +++ b/vcard/java/com/android/vcard/VCardConstants.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard; +package com.android.vcard; /** * Constants used in both exporter and importer code. diff --git a/core/java/android/pim/vcard/VCardEntry.java b/vcard/java/com/android/vcard/VCardEntry.java index 5b9cf17..624407a 100644 --- a/core/java/android/pim/vcard/VCardEntry.java +++ b/vcard/java/com/android/vcard/VCardEntry.java @@ -13,20 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard; +package com.android.vcard; import android.accounts.Account; import android.content.ContentProviderOperation; import android.content.ContentProviderResult; import android.content.ContentResolver; import android.content.OperationApplicationException; -import android.database.Cursor; import android.net.Uri; import android.os.RemoteException; import android.provider.ContactsContract; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Data; -import android.provider.ContactsContract.Groups; import android.provider.ContactsContract.RawContacts; import android.provider.ContactsContract.CommonDataKinds.Email; import android.provider.ContactsContract.CommonDataKinds.Event; diff --git a/core/java/android/pim/vcard/VCardEntryCommitter.java b/vcard/java/com/android/vcard/VCardEntryCommitter.java index a8c8057..7bd314e 100644 --- a/core/java/android/pim/vcard/VCardEntryCommitter.java +++ b/vcard/java/com/android/vcard/VCardEntryCommitter.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard; +package com.android.vcard; import android.content.ContentResolver; import android.net.Uri; diff --git a/core/java/android/pim/vcard/VCardEntryConstructor.java b/vcard/java/com/android/vcard/VCardEntryConstructor.java index a0abae8..2679e23 100644 --- a/core/java/android/pim/vcard/VCardEntryConstructor.java +++ b/vcard/java/com/android/vcard/VCardEntryConstructor.java @@ -13,15 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard; +package com.android.vcard; import android.accounts.Account; import android.text.TextUtils; +import android.util.Base64; import android.util.CharsetUtils; import android.util.Log; -import org.apache.commons.codec.binary.Base64; - import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.charset.Charset; @@ -190,9 +189,14 @@ public class VCardEntryConstructor implements VCardInterpreter { private String handleOneValue(String value, String sourceCharset, String targetCharset, String encoding) { + if (value == null) { + Log.w(LOG_TAG, "Null is given."); + value = ""; + } + if (encoding != null) { if (encoding.equals("BASE64") || encoding.equals("B")) { - mCurrentProperty.setPropertyBytes(Base64.decodeBase64(value.getBytes())); + mCurrentProperty.setPropertyBytes(Base64.decode(value.getBytes(), Base64.DEFAULT)); return value; } else if (encoding.equals("QUOTED-PRINTABLE")) { return VCardUtils.parseQuotedPrintable( diff --git a/core/java/android/pim/vcard/VCardEntryCounter.java b/vcard/java/com/android/vcard/VCardEntryCounter.java index 7bab50d..7bfe977 100644 --- a/core/java/android/pim/vcard/VCardEntryCounter.java +++ b/vcard/java/com/android/vcard/VCardEntryCounter.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard; +package com.android.vcard; import java.util.List; diff --git a/core/java/android/pim/vcard/VCardEntryHandler.java b/vcard/java/com/android/vcard/VCardEntryHandler.java index 56bf69d..ef35a20 100644 --- a/core/java/android/pim/vcard/VCardEntryHandler.java +++ b/vcard/java/com/android/vcard/VCardEntryHandler.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard; +package com.android.vcard; /** * <p> diff --git a/core/java/android/pim/vcard/VCardInterpreter.java b/vcard/java/com/android/vcard/VCardInterpreter.java index 03704a2..2d98764 100644 --- a/core/java/android/pim/vcard/VCardInterpreter.java +++ b/vcard/java/com/android/vcard/VCardInterpreter.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard; +package com.android.vcard; import java.util.List; diff --git a/core/java/android/pim/vcard/VCardInterpreterCollection.java b/vcard/java/com/android/vcard/VCardInterpreterCollection.java index 4952dc7..4a40d93 100644 --- a/core/java/android/pim/vcard/VCardInterpreterCollection.java +++ b/vcard/java/com/android/vcard/VCardInterpreterCollection.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard; +package com.android.vcard; import java.util.Collection; import java.util.List; diff --git a/core/java/android/pim/vcard/VCardParser.java b/vcard/java/com/android/vcard/VCardParser.java index 31b9369..b7b8291 100644 --- a/core/java/android/pim/vcard/VCardParser.java +++ b/vcard/java/com/android/vcard/VCardParser.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard; +package com.android.vcard; -import android.pim.vcard.exception.VCardException; +import com.android.vcard.exception.VCardException; import java.io.IOException; import java.io.InputStream; diff --git a/core/java/android/pim/vcard/VCardParserImpl_V21.java b/vcard/java/com/android/vcard/VCardParserImpl_V21.java index 7d294cc..00ae6c9 100644 --- a/core/java/android/pim/vcard/VCardParserImpl_V21.java +++ b/vcard/java/com/android/vcard/VCardParserImpl_V21.java @@ -13,17 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard; - -import android.pim.vcard.exception.VCardAgentNotSupportedException; -import android.pim.vcard.exception.VCardException; -import android.pim.vcard.exception.VCardInvalidCommentLineException; -import android.pim.vcard.exception.VCardInvalidLineException; -import android.pim.vcard.exception.VCardNestedException; -import android.pim.vcard.exception.VCardVersionException; +package com.android.vcard; + import android.text.TextUtils; import android.util.Log; +import com.android.vcard.exception.VCardAgentNotSupportedException; +import com.android.vcard.exception.VCardException; +import com.android.vcard.exception.VCardInvalidCommentLineException; +import com.android.vcard.exception.VCardInvalidLineException; +import com.android.vcard.exception.VCardNestedException; +import com.android.vcard.exception.VCardVersionException; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; diff --git a/core/java/android/pim/vcard/VCardParserImpl_V30.java b/vcard/java/com/android/vcard/VCardParserImpl_V30.java index a48a3b4..61d0455 100644 --- a/core/java/android/pim/vcard/VCardParserImpl_V30.java +++ b/vcard/java/com/android/vcard/VCardParserImpl_V30.java @@ -13,14 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard; +package com.android.vcard; + +import android.util.Log; + +import com.android.vcard.exception.VCardException; import java.io.IOException; import java.util.Set; -import android.pim.vcard.exception.VCardException; -import android.util.Log; - /** * <p> * Basic implementation achieving vCard 3.0 parsing. diff --git a/core/java/android/pim/vcard/VCardParser_V21.java b/vcard/java/com/android/vcard/VCardParser_V21.java index b625695..2a5e313 100644 --- a/core/java/android/pim/vcard/VCardParser_V21.java +++ b/vcard/java/com/android/vcard/VCardParser_V21.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard; +package com.android.vcard; -import android.pim.vcard.exception.VCardException; +import com.android.vcard.exception.VCardException; import java.io.IOException; import java.io.InputStream; diff --git a/core/java/android/pim/vcard/VCardParser_V30.java b/vcard/java/com/android/vcard/VCardParser_V30.java index 40792ab..179869b 100644 --- a/core/java/android/pim/vcard/VCardParser_V30.java +++ b/vcard/java/com/android/vcard/VCardParser_V30.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard; +package com.android.vcard; -import android.pim.vcard.exception.VCardException; +import com.android.vcard.exception.VCardException; import java.io.IOException; import java.io.InputStream; diff --git a/core/java/android/pim/vcard/VCardSourceDetector.java b/vcard/java/com/android/vcard/VCardSourceDetector.java index 291deca..e70d496 100644 --- a/core/java/android/pim/vcard/VCardSourceDetector.java +++ b/vcard/java/com/android/vcard/VCardSourceDetector.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard; +package com.android.vcard; import android.text.TextUtils; diff --git a/core/java/android/pim/vcard/VCardUtils.java b/vcard/java/com/android/vcard/VCardUtils.java index 680ef6f..fb0c2e7 100644 --- a/core/java/android/pim/vcard/VCardUtils.java +++ b/vcard/java/com/android/vcard/VCardUtils.java @@ -13,7 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard; +package com.android.vcard; + +import org.apache.commons.codec.DecoderException; +import org.apache.commons.codec.net.QuotedPrintableCodec; import android.content.ContentProviderOperation; import android.provider.ContactsContract.Data; @@ -24,9 +27,6 @@ import android.telephony.PhoneNumberUtils; import android.text.TextUtils; import android.util.Log; -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.net.QuotedPrintableCodec; - import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Arrays; @@ -39,7 +39,6 @@ import java.util.Set; /** * Utilities for VCard handling codes. - * @hide */ public class VCardUtils { private static final String LOG_TAG = "VCardUtils"; @@ -193,8 +192,7 @@ public class VCardUtils { // For backward compatibility. // Detail: Until Donut, there isn't TYPE_MOBILE for email while there is now. // To support mobile type at that time, this custom label had been used. - return (android.provider.Contacts.ContactMethodsColumns.MOBILE_EMAIL_TYPE_NAME.equals(label) - || sMobilePhoneLabelSet.contains(label)); + return ("_AUTO_CELL".equals(label) || sMobilePhoneLabelSet.contains(label)); } public static boolean isValidInV21ButUnknownToContactsPhoteType(final String label) { @@ -625,26 +623,33 @@ public class VCardUtils { } builder.append(line); } - byte[] bytes; + + final String rawString = builder.toString(); + if (TextUtils.isEmpty(rawString)) { + Log.w(LOG_TAG, "Given raw string is empty."); + } + + byte[] rawBytes = null; try { - bytes = builder.toString().getBytes(sourceCharset); - } catch (UnsupportedEncodingException e1) { - Log.e(LOG_TAG, "Failed to encode: charset=" + targetCharset); - bytes = builder.toString().getBytes(); + rawBytes = rawString.getBytes(sourceCharset); + } catch (UnsupportedEncodingException e) { + Log.w(LOG_TAG, "Failed to decode: " + sourceCharset); + rawBytes = rawString.getBytes(); } + byte[] decodedBytes = null; try { - bytes = QuotedPrintableCodec.decodeQuotedPrintable(bytes); + decodedBytes = QuotedPrintableCodec.decodeQuotedPrintable(rawBytes); } catch (DecoderException e) { - Log.e(LOG_TAG, "Failed to decode quoted-printable: " + e); - return ""; + Log.e(LOG_TAG, "DecoderException is thrown."); + decodedBytes = rawBytes; } try { - return new String(bytes, targetCharset); + return new String(decodedBytes, targetCharset); } catch (UnsupportedEncodingException e) { Log.e(LOG_TAG, "Failed to encode: charset=" + targetCharset); - return new String(bytes); + return new String(decodedBytes); } } diff --git a/core/java/android/pim/vcard/exception/VCardAgentNotSupportedException.java b/vcard/java/com/android/vcard/exception/VCardAgentNotSupportedException.java index e72c7df..c408716 100644 --- a/core/java/android/pim/vcard/exception/VCardAgentNotSupportedException.java +++ b/vcard/java/com/android/vcard/exception/VCardAgentNotSupportedException.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard.exception; +package com.android.vcard.exception; public class VCardAgentNotSupportedException extends VCardNotSupportedException { public VCardAgentNotSupportedException() { diff --git a/core/java/android/pim/vcard/exception/VCardException.java b/vcard/java/com/android/vcard/exception/VCardException.java index e557219..3ad7fd3 100644 --- a/core/java/android/pim/vcard/exception/VCardException.java +++ b/vcard/java/com/android/vcard/exception/VCardException.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard.exception; +package com.android.vcard.exception; public class VCardException extends java.lang.Exception { /** diff --git a/core/java/android/pim/vcard/exception/VCardInvalidCommentLineException.java b/vcard/java/com/android/vcard/exception/VCardInvalidCommentLineException.java index 67db62c..342769e 100644 --- a/core/java/android/pim/vcard/exception/VCardInvalidCommentLineException.java +++ b/vcard/java/com/android/vcard/exception/VCardInvalidCommentLineException.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package android.pim.vcard.exception; +package com.android.vcard.exception; /** * Thrown when the vCard has some line starting with '#'. In the specification, diff --git a/core/java/android/pim/vcard/exception/VCardInvalidLineException.java b/vcard/java/com/android/vcard/exception/VCardInvalidLineException.java index 330153e..5c2250f 100644 --- a/core/java/android/pim/vcard/exception/VCardInvalidLineException.java +++ b/vcard/java/com/android/vcard/exception/VCardInvalidLineException.java @@ -13,8 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -package android.pim.vcard.exception; +package com.android.vcard.exception; /** * Thrown when the vCard has some line starting with '#'. In the specification, diff --git a/core/java/android/pim/vcard/exception/VCardNestedException.java b/vcard/java/com/android/vcard/exception/VCardNestedException.java index 503c2fb..2b9b1ac 100644 --- a/core/java/android/pim/vcard/exception/VCardNestedException.java +++ b/vcard/java/com/android/vcard/exception/VCardNestedException.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package android.pim.vcard.exception; +package com.android.vcard.exception; /** * VCardException thrown when VCard is nested without VCardParser's being notified. diff --git a/core/java/android/pim/vcard/exception/VCardNotSupportedException.java b/vcard/java/com/android/vcard/exception/VCardNotSupportedException.java index 616aa77..61ff752 100644 --- a/core/java/android/pim/vcard/exception/VCardNotSupportedException.java +++ b/vcard/java/com/android/vcard/exception/VCardNotSupportedException.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard.exception; +package com.android.vcard.exception; /** * The exception which tells that the input VCard is probably valid from the view of diff --git a/core/java/android/pim/vcard/exception/VCardVersionException.java b/vcard/java/com/android/vcard/exception/VCardVersionException.java index 9fe8b7f..047c580 100644 --- a/core/java/android/pim/vcard/exception/VCardVersionException.java +++ b/vcard/java/com/android/vcard/exception/VCardVersionException.java @@ -13,8 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -package android.pim.vcard.exception; +package com.android.vcard.exception; /** * VCardException used only when the version of the vCard is different. diff --git a/vcard/tests/Android.mk b/vcard/tests/Android.mk new file mode 100644 index 0000000..853ee14 --- /dev/null +++ b/vcard/tests/Android.mk @@ -0,0 +1,25 @@ +# Copyright (C) 2010 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_CERTIFICATE := platform +LOCAL_MODULE_TAGS := tests +LOCAL_PACKAGE_NAME := AndroidVCardTests +LOCAL_SRC_FILES := $(call all-java-files-under, src) +LOCAL_JAVA_LIBRARIES := android.test.runner google-common +LOCAL_STATIC_JAVA_LIBRARIES := com.android.vcard + +include $(BUILD_PACKAGE) diff --git a/vcard/tests/AndroidManifest.xml b/vcard/tests/AndroidManifest.xml new file mode 100644 index 0000000..fcbf767 --- /dev/null +++ b/vcard/tests/AndroidManifest.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2010 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.vcard.tests" + android:sharedUserId="com.android.uid.test"> + + <application> + <uses-library android:name="android.test.runner" /> + </application> + + <!-- Run tests with "runtest common" --> + <instrumentation android:name="android.test.InstrumentationTestRunner" + android:targetPackage="com.android.vcard.tests" + android:label="Android vCard Library Tests" /> + +</manifest> diff --git a/core/tests/coretests/res/raw/v21_backslash.vcf b/vcard/tests/res/raw/v21_backslash.vcf index bd3002b..bd3002b 100644 --- a/core/tests/coretests/res/raw/v21_backslash.vcf +++ b/vcard/tests/res/raw/v21_backslash.vcf diff --git a/core/tests/coretests/res/raw/v21_complicated.vcf b/vcard/tests/res/raw/v21_complicated.vcf index de34e16..de34e16 100644 --- a/core/tests/coretests/res/raw/v21_complicated.vcf +++ b/vcard/tests/res/raw/v21_complicated.vcf diff --git a/core/tests/coretests/res/raw/v21_invalid_comment_line.vcf b/vcard/tests/res/raw/v21_invalid_comment_line.vcf index f910710..f910710 100644 --- a/core/tests/coretests/res/raw/v21_invalid_comment_line.vcf +++ b/vcard/tests/res/raw/v21_invalid_comment_line.vcf diff --git a/core/tests/coretests/res/raw/v21_japanese_1.vcf b/vcard/tests/res/raw/v21_japanese_1.vcf index d05e2ff..d05e2ff 100644 --- a/core/tests/coretests/res/raw/v21_japanese_1.vcf +++ b/vcard/tests/res/raw/v21_japanese_1.vcf diff --git a/core/tests/coretests/res/raw/v21_japanese_2.vcf b/vcard/tests/res/raw/v21_japanese_2.vcf index fa54acb..fa54acb 100644 --- a/core/tests/coretests/res/raw/v21_japanese_2.vcf +++ b/vcard/tests/res/raw/v21_japanese_2.vcf diff --git a/core/tests/coretests/res/raw/v21_multiple_entry.vcf b/vcard/tests/res/raw/v21_multiple_entry.vcf index ebbb19a..ebbb19a 100644 --- a/core/tests/coretests/res/raw/v21_multiple_entry.vcf +++ b/vcard/tests/res/raw/v21_multiple_entry.vcf diff --git a/core/tests/coretests/res/raw/v21_org_before_title.vcf b/vcard/tests/res/raw/v21_org_before_title.vcf index 8ff1190..8ff1190 100644 --- a/core/tests/coretests/res/raw/v21_org_before_title.vcf +++ b/vcard/tests/res/raw/v21_org_before_title.vcf diff --git a/core/tests/coretests/res/raw/v21_pref_handling.vcf b/vcard/tests/res/raw/v21_pref_handling.vcf index 5105310..5105310 100644 --- a/core/tests/coretests/res/raw/v21_pref_handling.vcf +++ b/vcard/tests/res/raw/v21_pref_handling.vcf diff --git a/core/tests/coretests/res/raw/v21_simple_1.vcf b/vcard/tests/res/raw/v21_simple_1.vcf index 6aabb4c..6aabb4c 100644 --- a/core/tests/coretests/res/raw/v21_simple_1.vcf +++ b/vcard/tests/res/raw/v21_simple_1.vcf diff --git a/core/tests/coretests/res/raw/v21_simple_2.vcf b/vcard/tests/res/raw/v21_simple_2.vcf index f0d5ab5..f0d5ab5 100644 --- a/core/tests/coretests/res/raw/v21_simple_2.vcf +++ b/vcard/tests/res/raw/v21_simple_2.vcf diff --git a/core/tests/coretests/res/raw/v21_simple_3.vcf b/vcard/tests/res/raw/v21_simple_3.vcf index beddabb..beddabb 100644 --- a/core/tests/coretests/res/raw/v21_simple_3.vcf +++ b/vcard/tests/res/raw/v21_simple_3.vcf diff --git a/core/tests/coretests/res/raw/v21_title_before_org.vcf b/vcard/tests/res/raw/v21_title_before_org.vcf index 9fdc738..9fdc738 100644 --- a/core/tests/coretests/res/raw/v21_title_before_org.vcf +++ b/vcard/tests/res/raw/v21_title_before_org.vcf diff --git a/core/tests/coretests/res/raw/v21_winmo_65.vcf b/vcard/tests/res/raw/v21_winmo_65.vcf index f380d0d..f380d0d 100644 --- a/core/tests/coretests/res/raw/v21_winmo_65.vcf +++ b/vcard/tests/res/raw/v21_winmo_65.vcf diff --git a/core/tests/coretests/res/raw/v30_comma_separated.vcf b/vcard/tests/res/raw/v30_comma_separated.vcf index 98a7f20..98a7f20 100644 --- a/core/tests/coretests/res/raw/v30_comma_separated.vcf +++ b/vcard/tests/res/raw/v30_comma_separated.vcf diff --git a/core/tests/coretests/res/raw/v30_simple.vcf b/vcard/tests/res/raw/v30_simple.vcf index 418661f..418661f 100644 --- a/core/tests/coretests/res/raw/v30_simple.vcf +++ b/vcard/tests/res/raw/v30_simple.vcf diff --git a/core/tests/coretests/src/android/pim/vcard/VCardExporterTests.java b/vcard/tests/src/com/android/vcard/tests/VCardExporterTests.java index 0820a68..b6419c3 100644 --- a/core/tests/coretests/src/android/pim/vcard/VCardExporterTests.java +++ b/vcard/tests/src/com/android/vcard/tests/VCardExporterTests.java @@ -14,12 +14,9 @@ * limitations under the License. */ -package android.pim.vcard; +package com.android.vcard.tests; import android.content.ContentValues; -import android.pim.vcard.test_utils.ContactEntry; -import android.pim.vcard.test_utils.PropertyNodesVerifierElem; -import android.pim.vcard.test_utils.PropertyNodesVerifierElem.TypeSet; import android.provider.ContactsContract.CommonDataKinds.Email; import android.provider.ContactsContract.CommonDataKinds.Event; import android.provider.ContactsContract.CommonDataKinds.Im; @@ -33,6 +30,11 @@ import android.provider.ContactsContract.CommonDataKinds.StructuredName; import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; import android.provider.ContactsContract.CommonDataKinds.Website; +import com.android.vcard.VCardConfig; +import com.android.vcard.tests.test_utils.ContactEntry; +import com.android.vcard.tests.test_utils.PropertyNodesVerifierElem; +import com.android.vcard.tests.test_utils.PropertyNodesVerifierElem.TypeSet; + import java.util.Arrays; /** diff --git a/core/tests/coretests/src/android/pim/vcard/VCardImporterTests.java b/vcard/tests/src/com/android/vcard/tests/VCardImporterTests.java index ea2ac6a..045c0d9 100644 --- a/core/tests/coretests/src/android/pim/vcard/VCardImporterTests.java +++ b/vcard/tests/src/com/android/vcard/tests/VCardImporterTests.java @@ -13,12 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard; +package com.android.vcard.tests; import android.content.ContentValues; -import android.pim.vcard.test_utils.ContentValuesVerifier; -import android.pim.vcard.test_utils.ContentValuesVerifierElem; -import android.pim.vcard.test_utils.PropertyNodesVerifierElem.TypeSet; import android.provider.ContactsContract.Data; import android.provider.ContactsContract.CommonDataKinds.Email; import android.provider.ContactsContract.CommonDataKinds.Event; @@ -30,7 +27,10 @@ import android.provider.ContactsContract.CommonDataKinds.StructuredName; import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; import android.provider.ContactsContract.CommonDataKinds.Website; -import com.android.frameworks.coretests.R; +import com.android.vcard.VCardConfig; +import com.android.vcard.tests.test_utils.ContentValuesVerifier; +import com.android.vcard.tests.test_utils.ContentValuesVerifierElem; +import com.android.vcard.tests.test_utils.PropertyNodesVerifierElem.TypeSet; import java.util.Arrays; diff --git a/core/tests/coretests/src/android/pim/vcard/VCardJapanizationTests.java b/vcard/tests/src/com/android/vcard/tests/VCardJapanizationTests.java index 17ee322..0d0b9f1 100644 --- a/core/tests/coretests/src/android/pim/vcard/VCardJapanizationTests.java +++ b/vcard/tests/src/com/android/vcard/tests/VCardJapanizationTests.java @@ -13,20 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -package android.pim.vcard; +package com.android.vcard.tests; import android.content.ContentValues; -import android.pim.vcard.test_utils.ContactEntry; -import android.pim.vcard.test_utils.ContentValuesBuilder; -import android.pim.vcard.test_utils.PropertyNodesVerifierElem; -import android.pim.vcard.test_utils.PropertyNodesVerifierElem.TypeSet; import android.provider.ContactsContract.CommonDataKinds.Nickname; import android.provider.ContactsContract.CommonDataKinds.Note; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.CommonDataKinds.StructuredName; import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; +import com.android.vcard.VCardConfig; +import com.android.vcard.tests.test_utils.ContactEntry; +import com.android.vcard.tests.test_utils.ContentValuesBuilder; +import com.android.vcard.tests.test_utils.PropertyNodesVerifierElem; +import com.android.vcard.tests.test_utils.PropertyNodesVerifierElem.TypeSet; + import java.util.Arrays; public class VCardJapanizationTests extends VCardTestsBase { diff --git a/core/tests/coretests/src/android/pim/vcard/VCardTestsBase.java b/vcard/tests/src/com/android/vcard/tests/VCardTestsBase.java index 383a9af..8998b3c 100644 --- a/core/tests/coretests/src/android/pim/vcard/VCardTestsBase.java +++ b/vcard/tests/src/com/android/vcard/tests/VCardTestsBase.java @@ -13,13 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -package android.pim.vcard; +package com.android.vcard.tests; import android.content.ContentValues; -import android.pim.vcard.test_utils.VCardVerifier; import android.test.AndroidTestCase; +import com.android.vcard.VCardConfig; +import com.android.vcard.tests.test_utils.VCardVerifier; + /** * BaseClass for vCard unit tests with utility classes. * Please do not add each unit test here. diff --git a/core/tests/coretests/src/android/pim/vcard/VCardUtilsTests.java b/vcard/tests/src/com/android/vcard/tests/VCardUtilsTests.java index 59299f9..732009a 100644 --- a/core/tests/coretests/src/android/pim/vcard/VCardUtilsTests.java +++ b/vcard/tests/src/com/android/vcard/tests/VCardUtilsTests.java @@ -13,10 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package com.android.vcard.tests; -package android.pim.vcard; - -import android.pim.vcard.VCardUtils; +import com.android.vcard.VCardUtils; import junit.framework.TestCase; diff --git a/core/tests/coretests/src/android/pim/vcard/test_utils/ContactEntry.java b/vcard/tests/src/com/android/vcard/tests/test_utils/ContactEntry.java index 843750e..dff1f05 100644 --- a/core/tests/coretests/src/android/pim/vcard/test_utils/ContactEntry.java +++ b/vcard/tests/src/com/android/vcard/tests/test_utils/ContactEntry.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package android.pim.vcard.test_utils; +package com.android.vcard.tests.test_utils; import android.content.ContentValues; import android.provider.ContactsContract.Data; diff --git a/core/tests/coretests/src/android/pim/vcard/test_utils/ContentValuesBuilder.java b/vcard/tests/src/com/android/vcard/tests/test_utils/ContentValuesBuilder.java index 5c24186..fb53b8f 100644 --- a/core/tests/coretests/src/android/pim/vcard/test_utils/ContentValuesBuilder.java +++ b/vcard/tests/src/com/android/vcard/tests/test_utils/ContentValuesBuilder.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard.test_utils; +package com.android.vcard.tests.test_utils; import android.content.ContentValues; diff --git a/core/tests/coretests/src/android/pim/vcard/test_utils/ContentValuesVerifier.java b/vcard/tests/src/com/android/vcard/tests/test_utils/ContentValuesVerifier.java index f2516ed..7d6db53 100644 --- a/core/tests/coretests/src/android/pim/vcard/test_utils/ContentValuesVerifier.java +++ b/vcard/tests/src/com/android/vcard/tests/test_utils/ContentValuesVerifier.java @@ -13,18 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard.test_utils; +package com.android.vcard.tests.test_utils; -import android.pim.vcard.VCardConfig; -import android.pim.vcard.VCardEntry; -import android.pim.vcard.VCardEntryConstructor; -import android.pim.vcard.VCardEntryHandler; -import android.pim.vcard.VCardParser; -import android.pim.vcard.VCardParser_V21; -import android.pim.vcard.VCardParser_V30; -import android.pim.vcard.exception.VCardException; import android.test.AndroidTestCase; +import com.android.vcard.VCardConfig; +import com.android.vcard.VCardEntry; +import com.android.vcard.VCardEntryConstructor; +import com.android.vcard.VCardEntryHandler; +import com.android.vcard.VCardParser; +import com.android.vcard.VCardParser_V21; +import com.android.vcard.VCardParser_V30; +import com.android.vcard.exception.VCardException; + import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; diff --git a/core/tests/coretests/src/android/pim/vcard/test_utils/ContentValuesVerifierElem.java b/vcard/tests/src/com/android/vcard/tests/test_utils/ContentValuesVerifierElem.java index 66d69b3..ecf4a2b 100644 --- a/core/tests/coretests/src/android/pim/vcard/test_utils/ContentValuesVerifierElem.java +++ b/vcard/tests/src/com/android/vcard/tests/test_utils/ContentValuesVerifierElem.java @@ -13,21 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard.test_utils; +package com.android.vcard.tests.test_utils; import android.content.ContentValues; -import android.pim.vcard.VCardConfig; -import android.pim.vcard.VCardEntry; -import android.pim.vcard.VCardEntryCommitter; -import android.pim.vcard.VCardEntryConstructor; -import android.pim.vcard.VCardEntryHandler; -import android.pim.vcard.VCardParser; -import android.pim.vcard.VCardParser_V21; -import android.pim.vcard.VCardParser_V30; -import android.pim.vcard.exception.VCardException; import android.provider.ContactsContract.Data; import android.test.AndroidTestCase; +import com.android.vcard.VCardConfig; +import com.android.vcard.VCardEntry; +import com.android.vcard.VCardEntryCommitter; +import com.android.vcard.VCardEntryConstructor; +import com.android.vcard.VCardEntryHandler; +import com.android.vcard.VCardParser; +import com.android.vcard.VCardParser_V21; +import com.android.vcard.VCardParser_V30; +import com.android.vcard.exception.VCardException; + import java.io.IOException; import java.io.InputStream; diff --git a/core/tests/coretests/src/android/pim/vcard/test_utils/ExportTestProvider.java b/vcard/tests/src/com/android/vcard/tests/test_utils/ExportTestProvider.java index 0fbd9bb..caedf9d 100644 --- a/core/tests/coretests/src/android/pim/vcard/test_utils/ExportTestProvider.java +++ b/vcard/tests/src/com/android/vcard/tests/test_utils/ExportTestProvider.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package android.pim.vcard.test_utils; +package com.android.vcard.tests.test_utils; import android.content.ContentResolver; import android.content.ContentValues; @@ -21,13 +21,14 @@ import android.content.Entity; import android.content.EntityIterator; import android.database.Cursor; import android.net.Uri; -import android.pim.vcard.VCardComposer; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Data; import android.provider.ContactsContract.RawContacts; import android.test.mock.MockContentProvider; import android.test.mock.MockCursor; +import com.android.vcard.VCardComposer; + import junit.framework.TestCase; import java.util.ArrayList; diff --git a/core/tests/coretests/src/android/pim/vcard/test_utils/ExportTestResolver.java b/vcard/tests/src/com/android/vcard/tests/test_utils/ExportTestResolver.java index 97e1e38..3cd014c 100644 --- a/core/tests/coretests/src/android/pim/vcard/test_utils/ExportTestResolver.java +++ b/vcard/tests/src/com/android/vcard/tests/test_utils/ExportTestResolver.java @@ -13,12 +13,13 @@ * License for the specific language governing permissions and limitations under * the License. */ -package android.pim.vcard.test_utils; +package com.android.vcard.tests.test_utils; -import android.pim.vcard.VCardComposer; import android.provider.ContactsContract.RawContacts; import android.test.mock.MockContentResolver; +import com.android.vcard.VCardComposer; + import junit.framework.TestCase; /* package */ class ExportTestResolver extends MockContentResolver { diff --git a/core/tests/coretests/src/android/pim/vcard/test_utils/ImportTestProvider.java b/vcard/tests/src/com/android/vcard/tests/test_utils/ImportTestProvider.java index ffbf95d..3d7cb60 100644 --- a/core/tests/coretests/src/android/pim/vcard/test_utils/ImportTestProvider.java +++ b/vcard/tests/src/com/android/vcard/tests/test_utils/ImportTestProvider.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard.test_utils; +package com.android.vcard.tests.test_utils; import android.content.ContentProviderOperation; import android.content.ContentProviderResult; @@ -36,6 +36,7 @@ import android.provider.ContactsContract.CommonDataKinds.StructuredPostal; import android.provider.ContactsContract.CommonDataKinds.Website; import android.test.mock.MockContentProvider; import android.text.TextUtils; +import android.util.Log; import junit.framework.TestCase; @@ -257,10 +258,15 @@ import java.util.Map.Entry; if (value instanceof byte[]) { Object actualValue = actual.get(key); if (!Arrays.equals((byte[])value, (byte[])actualValue)) { + byte[] e = (byte[])value; + byte[] a = (byte[])actualValue; + Log.d("@@@", "expected (len: " + e.length + "): " + Arrays.toString(e)); + Log.d("@@@", "actual (len: " + a.length + "): " + Arrays.toString(a)); return false; } } else if (!value.equals(actual.get(key))) { - return false; + Log.d("@@@", "different."); + return false; } } return true; diff --git a/core/tests/coretests/src/android/pim/vcard/test_utils/ImportTestResolver.java b/vcard/tests/src/com/android/vcard/tests/test_utils/ImportTestResolver.java index 29738c6..645e9db 100644 --- a/core/tests/coretests/src/android/pim/vcard/test_utils/ImportTestResolver.java +++ b/vcard/tests/src/com/android/vcard/tests/test_utils/ImportTestResolver.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard.test_utils; +package com.android.vcard.tests.test_utils; import android.content.ContentProviderOperation; import android.content.ContentProviderResult; diff --git a/core/tests/coretests/src/android/pim/vcard/test_utils/LineVerifier.java b/vcard/tests/src/com/android/vcard/tests/test_utils/LineVerifier.java index 3edec67..d8cfe5b 100644 --- a/core/tests/coretests/src/android/pim/vcard/test_utils/LineVerifier.java +++ b/vcard/tests/src/com/android/vcard/tests/test_utils/LineVerifier.java @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard.test_utils; +package com.android.vcard.tests.test_utils; + +import com.android.vcard.VCardComposer; import android.content.Context; -import android.pim.vcard.VCardComposer; import junit.framework.TestCase; diff --git a/core/tests/coretests/src/android/pim/vcard/test_utils/LineVerifierElem.java b/vcard/tests/src/com/android/vcard/tests/test_utils/LineVerifierElem.java index 4f7a9cf..3ec6ba3 100644 --- a/core/tests/coretests/src/android/pim/vcard/test_utils/LineVerifierElem.java +++ b/vcard/tests/src/com/android/vcard/tests/test_utils/LineVerifierElem.java @@ -13,11 +13,12 @@ * License for the specific language governing permissions and limitations under * the License. */ -package android.pim.vcard.test_utils; +package com.android.vcard.tests.test_utils; -import android.pim.vcard.VCardConfig; import android.text.TextUtils; +import com.android.vcard.VCardConfig; + import junit.framework.TestCase; import java.util.ArrayList; diff --git a/core/tests/coretests/src/android/pim/vcard/test_utils/PropertyNode.java b/vcard/tests/src/com/android/vcard/tests/test_utils/PropertyNode.java index de7ad8e..14c8d6c 100644 --- a/core/tests/coretests/src/android/pim/vcard/test_utils/PropertyNode.java +++ b/vcard/tests/src/com/android/vcard/tests/test_utils/PropertyNode.java @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard.test_utils; +package com.android.vcard.tests.test_utils; import android.content.ContentValues; -import android.pim.vcard.VCardEntry; + +import com.android.vcard.VCardEntry; import java.util.ArrayList; import java.util.Arrays; diff --git a/core/tests/coretests/src/android/pim/vcard/test_utils/PropertyNodesVerifier.java b/vcard/tests/src/com/android/vcard/tests/test_utils/PropertyNodesVerifier.java index 5c8215f..de33a36 100644 --- a/core/tests/coretests/src/android/pim/vcard/test_utils/PropertyNodesVerifier.java +++ b/vcard/tests/src/com/android/vcard/tests/test_utils/PropertyNodesVerifier.java @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard.test_utils; +package com.android.vcard.tests.test_utils; -import android.pim.vcard.VCardConfig; -import android.pim.vcard.VCardParser; -import android.pim.vcard.VCardParser_V21; -import android.pim.vcard.VCardParser_V30; -import android.pim.vcard.exception.VCardException; import android.test.AndroidTestCase; +import com.android.vcard.VCardConfig; +import com.android.vcard.VCardParser; +import com.android.vcard.VCardParser_V21; +import com.android.vcard.VCardParser_V30; +import com.android.vcard.exception.VCardException; + import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; diff --git a/core/tests/coretests/src/android/pim/vcard/test_utils/PropertyNodesVerifierElem.java b/vcard/tests/src/com/android/vcard/tests/test_utils/PropertyNodesVerifierElem.java index 8c6c734..6eb8498 100644 --- a/core/tests/coretests/src/android/pim/vcard/test_utils/PropertyNodesVerifierElem.java +++ b/vcard/tests/src/com/android/vcard/tests/test_utils/PropertyNodesVerifierElem.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard.test_utils; +package com.android.vcard.tests.test_utils; import android.content.ContentValues; diff --git a/core/tests/coretests/src/android/pim/vcard/test_utils/VCardVerifier.java b/vcard/tests/src/com/android/vcard/tests/test_utils/VCardVerifier.java index 5fb2942..87d82d2 100644 --- a/core/tests/coretests/src/android/pim/vcard/test_utils/VCardVerifier.java +++ b/vcard/tests/src/com/android/vcard/tests/test_utils/VCardVerifier.java @@ -13,26 +13,27 @@ * License for the specific language governing permissions and limitations under * the License. */ -package android.pim.vcard.test_utils; +package com.android.vcard.tests.test_utils; import android.content.ContentResolver; import android.content.Context; import android.content.EntityIterator; import android.net.Uri; -import android.pim.vcard.VCardComposer; -import android.pim.vcard.VCardConfig; -import android.pim.vcard.VCardEntryConstructor; -import android.pim.vcard.VCardInterpreter; -import android.pim.vcard.VCardInterpreterCollection; -import android.pim.vcard.VCardParser; -import android.pim.vcard.VCardParser_V21; -import android.pim.vcard.VCardParser_V30; -import android.pim.vcard.exception.VCardException; import android.test.AndroidTestCase; import android.test.mock.MockContext; import android.text.TextUtils; import android.util.Log; +import com.android.vcard.VCardComposer; +import com.android.vcard.VCardConfig; +import com.android.vcard.VCardEntryConstructor; +import com.android.vcard.VCardInterpreter; +import com.android.vcard.VCardInterpreterCollection; +import com.android.vcard.VCardParser; +import com.android.vcard.VCardParser_V21; +import com.android.vcard.VCardParser_V30; +import com.android.vcard.exception.VCardException; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; diff --git a/core/tests/coretests/src/android/pim/vcard/test_utils/VNode.java b/vcard/tests/src/com/android/vcard/tests/test_utils/VNode.java index b890e2c..2ca762b 100644 --- a/core/tests/coretests/src/android/pim/vcard/test_utils/VNode.java +++ b/vcard/tests/src/com/android/vcard/tests/test_utils/VNode.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard.test_utils; +package com.android.vcard.tests.test_utils; import java.util.ArrayList; diff --git a/core/tests/coretests/src/android/pim/vcard/test_utils/VNodeBuilder.java b/vcard/tests/src/com/android/vcard/tests/test_utils/VNodeBuilder.java index 25fb6ac..9b4fe83 100644 --- a/core/tests/coretests/src/android/pim/vcard/test_utils/VNodeBuilder.java +++ b/vcard/tests/src/com/android/vcard/tests/test_utils/VNodeBuilder.java @@ -13,16 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package android.pim.vcard.test_utils; +package com.android.vcard.tests.test_utils; import android.content.ContentValues; -import android.pim.vcard.VCardConfig; -import android.pim.vcard.VCardInterpreter; -import android.pim.vcard.VCardUtils; +import android.util.Base64; import android.util.CharsetUtils; import android.util.Log; -import org.apache.commons.codec.binary.Base64; +import com.android.vcard.VCardConfig; +import com.android.vcard.VCardInterpreter; +import com.android.vcard.VCardUtils; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; @@ -185,8 +185,7 @@ import java.util.List; encoding = encoding.toUpperCase(); if (encoding.equals("BASE64") || encoding.equals("B")) { // Assume BASE64 is used only when the number of values is 1. - mCurrentPropNode.propValue_bytes = - Base64.decodeBase64(value.getBytes()); + mCurrentPropNode.propValue_bytes = Base64.decode(value.getBytes(), Base64.NO_WRAP); return value; } else if (encoding.equals("QUOTED-PRINTABLE")) { return VCardUtils.parseQuotedPrintable( |