Merge "Make vCard code a separated static library."
This commit is contained in:
committed by
Android (Google) Code Review
commit
422017be68
@@ -1,5 +0,0 @@
|
||||
<HTML>
|
||||
<BODY>
|
||||
{@hide}
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,5 +0,0 @@
|
||||
<HTML>
|
||||
<BODY>
|
||||
{@hide}
|
||||
</BODY>
|
||||
</HTML>
|
||||
28
vcard/Android.mk
Normal file
28
vcard/Android.mk
Normal file
@@ -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))
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.pim.vcard;
|
||||
package com.android.vcard;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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 + "=?";
|
||||
@@ -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() {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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(
|
||||
@@ -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;
|
||||
|
||||
@@ -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>
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -13,17 +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.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;
|
||||
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;
|
||||
@@ -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.
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
try {
|
||||
bytes = builder.toString().getBytes(sourceCharset);
|
||||
} catch (UnsupportedEncodingException e1) {
|
||||
Log.e(LOG_TAG, "Failed to encode: charset=" + targetCharset);
|
||||
bytes = builder.toString().getBytes();
|
||||
|
||||
final String rawString = builder.toString();
|
||||
if (TextUtils.isEmpty(rawString)) {
|
||||
Log.w(LOG_TAG, "Given raw string is empty.");
|
||||
}
|
||||
|
||||
byte[] rawBytes = null;
|
||||
try {
|
||||
bytes = QuotedPrintableCodec.decodeQuotedPrintable(bytes);
|
||||
rawBytes = rawString.getBytes(sourceCharset);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
Log.w(LOG_TAG, "Failed to decode: " + sourceCharset);
|
||||
rawBytes = rawString.getBytes();
|
||||
}
|
||||
|
||||
byte[] decodedBytes = null;
|
||||
try {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
@@ -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 {
|
||||
/**
|
||||
@@ -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,
|
||||
@@ -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,
|
||||
@@ -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.
|
||||
@@ -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
|
||||
@@ -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.
|
||||
25
vcard/tests/Android.mk
Normal file
25
vcard/tests/Android.mk
Normal file
@@ -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)
|
||||
30
vcard/tests/AndroidManifest.xml
Normal file
30
vcard/tests/AndroidManifest.xml
Normal file
@@ -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>
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
@@ -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.
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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 {
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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(
|
||||
Reference in New Issue
Block a user