summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Shrauner <shrauner@google.com>2013-02-15 16:13:29 -0800
committerJay Shrauner <shrauner@google.com>2013-02-25 11:09:02 -0800
commitdb9ae4b068589d2157c1c2d4c45c3873d9203ef0 (patch)
tree229f263a437d368adea9c40bac2c8c831d79c222
parent090e844bce774c78ca80d396a12f9bbd140642f6 (diff)
downloadandroid_external_sqlite-db9ae4b068589d2157c1c2d4c45c3873d9203ef0.tar.gz
android_external_sqlite-db9ae4b068589d2157c1c2d4c45c3873d9203ef0.tar.bz2
android_external_sqlite-db9ae4b068589d2157c1c2d4c45c3873d9203ef0.zip
Remove GET_PHONEBOOK_INDEX callback
Remove sqlite GET_PHONEBOOK_INDEX callback. Bug: Change-Id: I751bb4fdff89af1eccc4b21b67fddd0b802eeb61
-rw-r--r--android/Android.mk29
-rw-r--r--android/PhonebookIndex.cpp206
-rw-r--r--android/PhonebookIndex.h46
-rw-r--r--android/PhonebookIndexTest.cpp243
-rw-r--r--android/sqlite3_android.cpp58
5 files changed, 1 insertions, 581 deletions
diff --git a/android/Android.mk b/android/Android.mk
index 0bb78d3..9284903 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -3,14 +3,12 @@ LOCAL_PATH:= $(call my-dir)
libsqlite3_android_local_src_files := \
PhoneNumberUtils.cpp \
OldPhoneNumberUtils.cpp \
- PhonebookIndex.cpp \
sqlite3_android.cpp
libsqlite3_android_c_includes := \
external/sqlite/dist \
external/icu4c/i18n \
- external/icu4c/common \
- frameworks/native/include
+ external/icu4c/common
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= $(libsqlite3_android_local_src_files)
@@ -53,28 +51,3 @@ LOCAL_SRC_FILES := \
LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
-
-ifeq ($(WITH_HOST_DALVIK),true)
- include $(CLEAR_VARS)
-
- LOCAL_MODULE:= libsqlite3_phone_book_index_test
-
- LOCAL_SRC_FILES := \
- PhonebookIndex.cpp \
- PhonebookIndexTest.cpp
-
- LOCAL_C_INCLUDES := \
- external/icu4c/i18n \
- external/icu4c/common \
- frameworks/native/include
-
- LOCAL_MODULE_TAGS := optional
-
- LOCAL_SHARED_LIBRARIES := \
- libicui18n libicuuc
-
- LOCAL_STATIC_LIBRARIES := \
- libutils libcutils
-
- include $(BUILD_HOST_EXECUTABLE)
-endif
diff --git a/android/PhonebookIndex.cpp b/android/PhonebookIndex.cpp
deleted file mode 100644
index 68674f4..0000000
--- a/android/PhonebookIndex.cpp
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <stdio.h>
-
-#include <unicode/alphaindex.h>
-#include <unicode/ucol.h>
-#include <unicode/uiter.h>
-#include <unicode/ustring.h>
-#include <unicode/utypes.h>
-#include <unicode/uloc.h>
-#include <utils/Mutex.h>
-#include <utils/RefBase.h>
-
-#include "PhonebookIndex.h"
-
-#define MIN_OUTPUT_SIZE 6 // Minimum required size for the output buffer (in bytes)
-
-namespace android {
-
-// Wrapper class to enable using libutil SmartPointers with AlphabeticIndex.
-class AlphabeticIndexRef : public RefBase {
-public:
- AlphabeticIndexRef(const char *locale, UErrorCode &status) :
- m_index(locale, status), m_locale(NULL), m_isJapanese(false) {
- if (U_FAILURE(status)) {
- return;
- }
- m_locale = strdup(locale);
- if (m_locale == NULL) {
- status = U_MEMORY_ALLOCATION_ERROR;
- return;
- }
- char language[4];
- uloc_getLanguage(locale, language, sizeof(language), &status);
- if (U_FAILURE(status)) {
- return;
- }
- m_isJapanese = (strcmp(language, ULOC_JAPANESE) == 0);
- }
- virtual ~AlphabeticIndexRef() { free(m_locale); }
-
- AlphabeticIndex& operator*() { return m_index; }
- AlphabeticIndex* operator->() { return &m_index; }
-
- bool isLocale(const char *locale) const {
- return (locale != NULL && m_locale != NULL &&
- strcmp(m_locale, locale) == 0);
- }
- bool isJapanese() const { return m_isJapanese; }
- int32_t getLabel(int32_t bucketIndex, UChar *labelBuf, int32_t labelBufSize);
-
-private:
- AlphabeticIndex m_index;
- char *m_locale;
- bool m_isJapanese;
-};
-
-int32_t AlphabeticIndexRef::getLabel(int32_t bucketIndex, UChar *labelBuf,
- int32_t labelBufSize) {
- UErrorCode status = U_ZERO_ERROR;
- m_index.resetBucketIterator(status);
- if (U_FAILURE(status)) {
- return -1;
- }
- for(int i = 0; i <= bucketIndex; ++i) {
- if (!m_index.nextBucket(status) || U_FAILURE(status)) {
- return -1;
- }
- }
-
- int32_t len;
- if (m_index.getBucketLabelType() == U_ALPHAINDEX_NORMAL) {
- len = m_index.getBucketLabel().extract(labelBuf, labelBufSize, status);
- if (U_FAILURE(status)) {
- return -1;
- }
- } else {
- // Use no label for underflow/inflow/overflow buckets
- labelBuf[0] = '\0';
- len = 0;
- }
- return len;
-}
-
-static Mutex gIndexMutex;
-static sp<AlphabeticIndexRef> gIndex;
-
-/**
- * Returns TRUE if the character belongs to a Hanzi unicode block
- */
-static bool is_CJ(UChar32 c) {
- return (uscript_hasScript(c, USCRIPT_HAN) ||
- uscript_hasScript(c, USCRIPT_HIRAGANA) ||
- uscript_hasScript(c, USCRIPT_KATAKANA));
-}
-
-static bool initIndexForLocale(const char *locale) {
- if (locale == NULL) {
- return false;
- }
-
- if (gIndex != NULL && gIndex->isLocale(locale)) {
- return true;
- }
-
- UErrorCode status = U_ZERO_ERROR;
- sp<AlphabeticIndexRef> newIndex(new AlphabeticIndexRef(locale, status));
- if (newIndex == NULL || U_FAILURE(status)) {
- return false;
- }
- // Always create labels for Latin characters if not present in native set
- (*newIndex)->addLabels("en", status);
- if (U_FAILURE(status)) {
- return false;
- }
- if ((*newIndex)->getBucketCount(status) <= 0 || U_FAILURE(status)) {
- return false;
- }
-
- gIndex = newIndex;
- return true;
-}
-
-int32_t GetPhonebookIndex(UCharIterator *iter, const char *locale,
- UChar *out, int32_t size, UBool *isError)
-{
- if (size < MIN_OUTPUT_SIZE) {
- *isError = TRUE;
- return 0;
- }
-
- *isError = FALSE;
- out[0] = '\0';
- iter->move(iter, 0, UITER_ZERO);
- if (!iter->hasNext(iter)) { // Empty input string
- return 0;
- }
- UnicodeString ustr;
- bool prefixIsNonNumeric = false;
- bool prefixIsNumeric = false;
- while (iter->hasNext(iter)) {
- UChar32 ch = uiter_next32(iter);
- // Ignore standard phone number separators and identify any string
- // that otherwise starts with a number.
- if (!prefixIsNumeric && !prefixIsNonNumeric) {
- if (u_isdigit(ch)) {
- prefixIsNumeric = true;
- } else if (!u_isspace(ch) && ch != '+' && ch != '(' &&
- ch != ')' && ch != '.' && ch != '-' && ch != '#') {
- prefixIsNonNumeric = true;
- }
- }
- ustr.append(ch);
- }
- if (prefixIsNumeric) {
- out[0] = '#';
- return 1;
- }
-
- Mutex::Autolock autolock(gIndexMutex);
- if (!initIndexForLocale(locale)) {
- *isError = TRUE;
- return 0;
- }
-
- UErrorCode status = U_ZERO_ERROR;
- int32_t bucketIndex = (*gIndex)->getBucketIndex(ustr, status);
- if (U_FAILURE(status)) {
- *isError = TRUE;
- return 0;
- }
-
- int32_t len = gIndex->getLabel(bucketIndex, out, size);
- if (len < 0) {
- *isError = TRUE;
- return 0;
- }
-
- // For Japanese, label unclassified CJK ideographs with
- // Japanese word meaning "misc" or "other"
- if (gIndex->isJapanese() && len == 0 && is_CJ(ustr.char32At(0))) {
- out[0] = 0x4ED6;
- len = 1;
- }
-
- return len;
-}
-
-} // namespace android
diff --git a/android/PhonebookIndex.h b/android/PhonebookIndex.h
deleted file mode 100644
index 5bf14f3..0000000
--- a/android/PhonebookIndex.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-**
-** Copyright 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.
-*/
-
-#ifndef _ANDROID_PHONEBOOK_INDEX_H
-#define _ANDROID_PHONEBOOK_INDEX_H
-
-#include <unicode/uiter.h>
-#include <unicode/utypes.h>
-
-namespace android {
-
-/**
- * A character converter that takes a UNICODE character and produces the
- * phone book index for it in the specified locale. For example, "a" becomes "A"
- * and so does A with accents. Conversion rules differ from locale
- * locale, which is why this function takes locale as an argument.
- *
- * @param iter iterator if input characters
- * @param locale the string representation of the current locale, e.g. "ja"
- * @param out output buffer
- * @param size size of the output buffer in bytes. The buffer should be large enough
- * to hold the longest phone book index (e.g. a three-char word in Japan).
- * @param isError will be set to TRUE if an error occurs
- *
- * @return number of characters returned
- */
-int32_t GetPhonebookIndex(UCharIterator * iter, const char * locale, UChar * out, int32_t size,
- UBool * isError);
-
-} // namespace android
-
-#endif
diff --git a/android/PhonebookIndexTest.cpp b/android/PhonebookIndexTest.cpp
deleted file mode 100644
index 2f11dbe..0000000
--- a/android/PhonebookIndexTest.cpp
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-#include "PhonebookIndex.h"
-
-#include <unicode/unistr.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-using namespace android;
-
-class TestExecutor {
-public:
- TestExecutor() : m_total_count(0), m_success_count(0), m_success(true) {}
- bool DoAllTests();
-private:
- void DoOneTest(void (TestExecutor::*test)());
-
- void testGetIndex(const char *src, const char *locale,
- int32_t expected_len, UChar *expected_value);
- void testEnglish();
-
- // Note: When adding a test, do not forget to add it to DoOneTest().
-
- int m_total_count;
- int m_success_count;
-
- bool m_success;
-};
-
-
-bool TestExecutor::DoAllTests() {
- DoOneTest(&TestExecutor::testEnglish);
-
- printf("Test total: %d\nSuccess: %d\nFailure: %d\n",
- m_total_count, m_success_count, m_total_count - m_success_count);
-
- bool success = m_total_count == m_success_count;
- printf("\n%s\n", success ? "Success" : "Failure");
-
- return success;
-}
-
-void TestExecutor::DoOneTest(void (TestExecutor::*test)()) {
- m_success = true;
-
- (this->*test)();
-
- ++m_total_count;
- m_success_count += m_success ? 1 : 0;
-}
-
-#define BUFFER_SIZE 10
-
-static void printUTF8Str(const char *utf8_str) {
- printf("%s (", utf8_str);
- for(; *utf8_str != '\0'; ++utf8_str) {
- printf("\\x%02hhX", *utf8_str);
- }
- printf(")");
-}
-
-static void printUChars(const UChar *uc_str, int32_t len) {
- std::string utf8_str;
- UnicodeString(uc_str, len).toUTF8String(utf8_str);
- printf("%s (", utf8_str.c_str());
- for(int i=0; i<len; ++i) {
- printf("0x%02hx%s", uc_str[i], i < (len - 1) ? " " : "");
- }
- printf(")");
-}
-
-void TestExecutor::testGetIndex(
- const char *src, const char *locale,
- int32_t expected_len, UChar *expected_value) {
- UBool isError;
-
- UCharIterator iter;
- uiter_setUTF8(&iter, src, -1);
-
- UChar outBuf[BUFFER_SIZE];
-
- int32_t len = GetPhonebookIndex(&iter, locale, outBuf, sizeof(outBuf), &isError);
- if (isError) {
- printf("GetPhonebookIndex returned error (%s:%s)\n", locale, src);
- m_success = false;
- } else if (len != expected_len) {
- printf("len is unexpected value (src: [%s] %s, ", locale, src);
- printf("actual: %u (", len);
- printUChars(outBuf, len);
- printf("), expected: %u (", expected_len);
- printUChars(expected_value, expected_len);
- printf("))\n");
- m_success = false;
- } else {
- printf("[%s] %s: ", locale, src);
- printUChars(outBuf, len);
-
- if (memcmp(outBuf, expected_value, sizeof(UChar)*expected_len) != 0) {
- printf(", expected ");
- printUChars(expected_value, expected_len);
- m_success = false;
- }
- printf("\n");
- }
-}
-
-#define TEST_GET_UTF8STR_INDEX(src, locale, ...) \
- ({ \
- UChar uc_expected[] = {__VA_ARGS__}; \
- int32_t len = sizeof(uc_expected)/sizeof(UChar); \
- testGetIndex((src), (locale), len, uc_expected); \
- })
-
-#define TEST_GET_UCHAR_INDEX(src, locale, ...) \
- ({ \
- std::string utf8_str; \
- UnicodeString((UChar) (src)).toUTF8String(utf8_str); \
- TEST_GET_UTF8STR_INDEX(utf8_str.c_str(), (locale), __VA_ARGS__); \
- })
-
-void TestExecutor::testEnglish() {
- printf("testEnglish()\n");
-
- // English [A-Z]
- TEST_GET_UTF8STR_INDEX("Allen", "en", 'A');
- TEST_GET_UTF8STR_INDEX("allen", "en", 'A');
- TEST_GET_UTF8STR_INDEX("123456", "en", '#');
- TEST_GET_UTF8STR_INDEX("+1 (123) 456-7890", "en", '#');
- TEST_GET_UTF8STR_INDEX("(33) 44.55.66.08", "en", '#');
- TEST_GET_UTF8STR_INDEX("123 Jump", "en", '#');
- // Arabic numbers
- TEST_GET_UTF8STR_INDEX("\u0662\u0663\u0664\u0665\u0666", "en", '#');
-
- // Japanese
- // sorts hiragana/katakana, Kanji/Chinese, English, other
- // …, あ, か, さ, た, な, は, ま, や, ら, わ, …
- // hiragana "a"
- TEST_GET_UCHAR_INDEX(0x3041, "ja", 0x3042);
- // katakana "a"
- TEST_GET_UCHAR_INDEX(0x30A1, "ja", 0x3042);
-
- // Kanji (sorts to inflow section)
- TEST_GET_UCHAR_INDEX(0x65E5, "ja", 0x4ed6);
- // English
- TEST_GET_UTF8STR_INDEX("Smith", "ja", 'S');
- TEST_GET_UTF8STR_INDEX("234567", "ja", '#');
- // Chinese (sorts to inflow section)
- TEST_GET_UCHAR_INDEX(0x6c88 /* Shen/Chen */, "ja", 0x4ed6);
- // Korean Hangul (sorts to overflow section)
- TEST_GET_UCHAR_INDEX(0x1100, "ja", /* null */ );
-
- // Korean (sorts Korean, then English)
- // …, ᄀ, ᄂ, ᄃ, ᄅ, ᄆ, ᄇ, ᄉ, ᄋ, ᄌ, ᄎ, ᄏ, ᄐ, ᄑ, ᄒ, …
- TEST_GET_UCHAR_INDEX(0x1100, "ko", 0x1100);
- TEST_GET_UCHAR_INDEX(0x3131, "ko", 0x1100);
- TEST_GET_UCHAR_INDEX(0x1101, "ko", 0x1100);
- TEST_GET_UCHAR_INDEX(0x1161, "ko", 0x1112);
-
- // Czech
- // …, [A-C], Č,[D-H], CH, [I-R], Ř, S, Š, [T-Z], Ž, …
- TEST_GET_UTF8STR_INDEX("Cena", "cs", 'C');
- TEST_GET_UTF8STR_INDEX("Čáp", "cs", 0x010c);
- TEST_GET_UTF8STR_INDEX("Ruda", "cs", 'R');
- TEST_GET_UTF8STR_INDEX("Řada", "cs", 0x0158);
- TEST_GET_UTF8STR_INDEX("Selka", "cs", 'S');
- TEST_GET_UTF8STR_INDEX("Šála", "cs", 0x0160);
- TEST_GET_UTF8STR_INDEX("Zebra", "cs", 'Z');
- TEST_GET_UTF8STR_INDEX("Žába", "cs", 0x017d);
- TEST_GET_UTF8STR_INDEX("Chata", "cs", 'C', 'H');
-
- // French: [A-Z] (no accented chars)
- TEST_GET_UTF8STR_INDEX("Øfer", "fr", 'O');
- TEST_GET_UTF8STR_INDEX("Œster", "fr", 'O');
-
- // Danish: [A-Z], Æ, Ø, Å
- TEST_GET_UTF8STR_INDEX("Ænes", "da", 0xc6);
- TEST_GET_UTF8STR_INDEX("Øfer", "da", 0xd8);
- TEST_GET_UTF8STR_INDEX("Œster", "da", 0xd8);
- TEST_GET_UTF8STR_INDEX("Ågård", "da", 0xc5);
-
- // German: [A-Z] (no ß or umlauted characters in standard alphabet)
- TEST_GET_UTF8STR_INDEX("ßind", "de", 'S');
-
- // Simplified Chinese (default collator Pinyin): [A-Z]
- // Shen/Chen (simplified): should be, usually, 'S' for name collator and 'C' for apps/other
- TEST_GET_UCHAR_INDEX(0x6c88 /* Shen/Chen */, "zh_CN", 'C');
- // Shen/Chen (traditional)
- TEST_GET_UCHAR_INDEX(0x700b, "zh_CN", 'S');
- // Jia/Gu: should be, usually, 'J' for name collator and 'G' for apps/other
- TEST_GET_UCHAR_INDEX(0x8d3e /* Jia/Gu */, "zh_CN", 'J');
-
- // Traditional Chinese
- // …, 一, 丁, 丈, 不, 且, 丞, 串, 並, 亭, 乘, 乾, 傀, 亂, 僎, 僵, 儐, 償, 叢, 儳, 嚴, 儷, 儻, 囌, 囑, 廳, …
- TEST_GET_UCHAR_INDEX(0x6c88 /* Shen/Chen */, "zh_TW", 0x5080);
- TEST_GET_UCHAR_INDEX(0x700b /* Shen/Chen */, "zh_TW", 0x53e2);
- TEST_GET_UCHAR_INDEX(0x8d3e /* Jia/Gu */, "zh_TW", 0x5080);
-
- // Thai (sorts English then Thai)
- // …, ก, ข, ฃ, ค, ฅ, ฆ, ง, จ, ฉ, ช, ซ, ฌ, ญ, ฎ, ฏ, ฐ, ฑ, ฒ, ณ, ด, ต, ถ, ท, ธ, น, บ, ป, ผ, ฝ, พ, ฟ, ภ, ม, ย, ร, ฤ, ล, ฦ, ว, ศ, ษ, ส, ห, ฬ, อ, ฮ, …,
-
- TEST_GET_UTF8STR_INDEX("\u0e2d\u0e07\u0e04\u0e4c\u0e40\u0e25\u0e47\u0e01",
- "th", 0xe2d);
- TEST_GET_UTF8STR_INDEX("\u0e2a\u0e34\u0e07\u0e2b\u0e40\u0e2a\u0e19\u0e35",
- "th", 0xe2a);
- // Thai numbers ((02) 432-0281)
- TEST_GET_UTF8STR_INDEX("(\u0e50\u0e52) \u0e54\u0e53\u0e52-"
- "\u0e50\u0e52\u0e58\u0e51", "th", '#');
-
- // Arabic (sorts English then Arabic)
- // …, ا, ب, ت, ث, ج, ح, خ, د, ذ, ر, ز, س, ش, ص, ض, ط, ظ, ع, غ, ف, ق, ك, ل, م, ن, ه, و, ي, …
- TEST_GET_UTF8STR_INDEX("\u0646\u0648\u0631" /* Noor */, "ar", 0x646);
- // Arabic numbers (34567)
- TEST_GET_UTF8STR_INDEX("\u0662\u0663\u0664\u0665\u0666", "ar", '#');
-
- // Hebrew (sorts English then Hebrew)
- // …, א, ב, ג, ד, ה, ו, ז, ח, ט, י, כ, ל, מ, נ, ס, ע, פ, צ, ק, ר, ש, ת, …
- TEST_GET_UTF8STR_INDEX("\u05e4\u05e8\u05d9\u05d3\u05de\u05df", "he", 0x5e4);
-}
-
-int main() {
- TestExecutor executor;
- if(executor.DoAllTests()) {
- return 0;
- } else {
- return 1;
- }
-}
diff --git a/android/sqlite3_android.cpp b/android/sqlite3_android.cpp
index fe826fd..de8bb22 100644
--- a/android/sqlite3_android.cpp
+++ b/android/sqlite3_android.cpp
@@ -29,7 +29,6 @@
#include "sqlite3_android.h"
#include "PhoneNumberUtils.h"
-#include "PhonebookIndex.h"
#define ENABLE_ANDROID_LOG 0
#define SMALL_BUFFER_SIZE 10
@@ -74,53 +73,6 @@ static int collate8(void *p, int n1, const void *v1, int n2, const void *v2)
}
}
-/**
- * Obtains the first UNICODE letter from the supplied string, normalizes and returns it.
- */
-static void get_phonebook_index(
- sqlite3_context * context, int argc, sqlite3_value ** argv)
-{
- if (argc != 2) {
- sqlite3_result_null(context);
- return;
- }
-
- char const * src = (char const *)sqlite3_value_text(argv[0]);
- char const * locale = (char const *)sqlite3_value_text(argv[1]);
- if (src == NULL || src[0] == 0 || locale == NULL) {
- sqlite3_result_null(context);
- return;
- }
-
- UCharIterator iter;
- uiter_setUTF8(&iter, src, -1);
-
- UBool isError = FALSE;
- UChar index[SMALL_BUFFER_SIZE];
- uint32_t len = android::GetPhonebookIndex(&iter, locale, index, sizeof(index), &isError);
- if (isError) {
- sqlite3_result_null(context);
- return;
- }
-
- uint32_t outlen = 0;
- uint8_t out[SMALL_BUFFER_SIZE];
- for (uint32_t i = 0; i < len; i++) {
- U8_APPEND(out, outlen, sizeof(out), index[i], isError);
- if (isError) {
- sqlite3_result_null(context);
- return;
- }
- }
-
- if (outlen == 0) {
- sqlite3_result_null(context);
- return;
- }
-
- sqlite3_result_text(context, (const char*)out, outlen, SQLITE_TRANSIENT);
-}
-
static void phone_numbers_equal(sqlite3_context * context, int argc, sqlite3_value ** argv)
{
if (argc != 2 && argc != 3) {
@@ -599,16 +551,6 @@ extern "C" int register_android_functions(sqlite3 * handle, int utf16Storage)
}
#endif
- // Register the GET_PHONEBOOK_INDEX function
- err = sqlite3_create_function(handle,
- "GET_PHONEBOOK_INDEX",
- 2, SQLITE_UTF8, NULL,
- get_phonebook_index,
- NULL, NULL);
- if (err != SQLITE_OK) {
- return err;
- }
-
// Register the _PHONE_NUMBER_STRIPPED_REVERSED function, which imitates
// PhoneNumberUtils.getStrippedReversed. This function is not public API,
// it is only used for compatibility with Android 1.6 and earlier.