13e5483f6Sopenharmony_ci/*
23e5483f6Sopenharmony_ci * Copyright (C) 2024 Huawei Device Co., Ltd.
33e5483f6Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
43e5483f6Sopenharmony_ci * you may not use this file except in compliance with the License.
53e5483f6Sopenharmony_ci * You may obtain a copy of the License at
63e5483f6Sopenharmony_ci *
73e5483f6Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
83e5483f6Sopenharmony_ci *
93e5483f6Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
103e5483f6Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
113e5483f6Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
123e5483f6Sopenharmony_ci * See the License for the specific language governing permissions and
133e5483f6Sopenharmony_ci * limitations under the License.
143e5483f6Sopenharmony_ci */
153e5483f6Sopenharmony_ci
163e5483f6Sopenharmony_ci#include "ringtone_rdb_callbacks.h"
173e5483f6Sopenharmony_ci
183e5483f6Sopenharmony_ci#include <sys/stat.h>
193e5483f6Sopenharmony_ci
203e5483f6Sopenharmony_ci#include "rdb_sql_utils.h"
213e5483f6Sopenharmony_ci#include "ringtone_errno.h"
223e5483f6Sopenharmony_ci#include "ringtone_log.h"
233e5483f6Sopenharmony_ci#include "ringtone_db_const.h"
243e5483f6Sopenharmony_ci#include "ringtone_file_utils.h"
253e5483f6Sopenharmony_ci#include "ringtone_mimetype_utils.h"
263e5483f6Sopenharmony_ci#include "ringtone_utils.h"
273e5483f6Sopenharmony_ci#include "result_set_utils.h"
283e5483f6Sopenharmony_ci#include "preferences_helper.h"
293e5483f6Sopenharmony_ci#include "dfx_const.h"
303e5483f6Sopenharmony_ci
313e5483f6Sopenharmony_cinamespace OHOS {
323e5483f6Sopenharmony_cinamespace Media {
333e5483f6Sopenharmony_ciusing namespace std;
343e5483f6Sopenharmony_ci
353e5483f6Sopenharmony_ciconst string DEFAULT_MIME_TYPE = "application/octet-stream";
363e5483f6Sopenharmony_cistatic const char RINGTONE_PARAMETER_SCANNER_COMPLETED_KEY[] = "ringtone.scanner.completed";
373e5483f6Sopenharmony_cistatic const int RINGTONE_PARAMETER_SCANNER_COMPLETED_FALSE = 0;
383e5483f6Sopenharmony_ci
393e5483f6Sopenharmony_ciconst std::string CREATE_RINGTONE_TABLE = "CREATE TABLE IF NOT EXISTS " + RINGTONE_TABLE + "(" +
403e5483f6Sopenharmony_ci    RINGTONE_COLUMN_TONE_ID                       + " INTEGER  PRIMARY KEY AUTOINCREMENT, " +
413e5483f6Sopenharmony_ci    RINGTONE_COLUMN_DATA                          + " TEXT              , " +
423e5483f6Sopenharmony_ci    RINGTONE_COLUMN_SIZE                          + " BIGINT   DEFAULT 0, " +
433e5483f6Sopenharmony_ci    RINGTONE_COLUMN_DISPLAY_NAME                  + " TEXT              , " +
443e5483f6Sopenharmony_ci    RINGTONE_COLUMN_TITLE                         + " TEXT              , " +
453e5483f6Sopenharmony_ci    RINGTONE_COLUMN_MEDIA_TYPE                    + " INT      DEFAULT 0, " +
463e5483f6Sopenharmony_ci    RINGTONE_COLUMN_TONE_TYPE                     + " INT      DEFAULT 0, " +
473e5483f6Sopenharmony_ci    RINGTONE_COLUMN_MIME_TYPE                     + " TEXT              , " +
483e5483f6Sopenharmony_ci    RINGTONE_COLUMN_SOURCE_TYPE                   + " INT      DEFAULT 0, " +
493e5483f6Sopenharmony_ci    RINGTONE_COLUMN_DATE_ADDED                    + " BIGINT   DEFAULT 0, " +
503e5483f6Sopenharmony_ci    RINGTONE_COLUMN_DATE_MODIFIED                 + " BIGINT   DEFAULT 0, " +
513e5483f6Sopenharmony_ci    RINGTONE_COLUMN_DATE_TAKEN                    + " BIGINT   DEFAULT 0, " +
523e5483f6Sopenharmony_ci    RINGTONE_COLUMN_DURATION                      + " INT      DEFAULT 0, " +
533e5483f6Sopenharmony_ci    RINGTONE_COLUMN_SHOT_TONE_TYPE                + " INT      DEFAULT 0, " +
543e5483f6Sopenharmony_ci    RINGTONE_COLUMN_SHOT_TONE_SOURCE_TYPE         + " INT      DEFAULT 0, " +
553e5483f6Sopenharmony_ci    RINGTONE_COLUMN_NOTIFICATION_TONE_TYPE        + " INT      DEFAULT 0, " +
563e5483f6Sopenharmony_ci    RINGTONE_COLUMN_NOTIFICATION_TONE_SOURCE_TYPE + " INT      DEFAULT 0, " +
573e5483f6Sopenharmony_ci    RINGTONE_COLUMN_RING_TONE_TYPE                + " INT      DEFAULT 0, " +
583e5483f6Sopenharmony_ci    RINGTONE_COLUMN_RING_TONE_SOURCE_TYPE         + " INT      DEFAULT 0, " +
593e5483f6Sopenharmony_ci    RINGTONE_COLUMN_ALARM_TONE_TYPE               + " INT      DEFAULT 0, " +
603e5483f6Sopenharmony_ci    RINGTONE_COLUMN_ALARM_TONE_SOURCE_TYPE        + " INT      DEFAULT 0, " +
613e5483f6Sopenharmony_ci    RINGTONE_COLUMN_DISPLAY_LANGUAGE_TYPE         + " TEXT                " + ")";
623e5483f6Sopenharmony_ci
633e5483f6Sopenharmony_ciconst std::string CREATE_SIMCARD_SETTING_TABLE = "CREATE TABLE IF NOT EXISTS " + SIMCARD_SETTING_TABLE + "(" +
643e5483f6Sopenharmony_ci    SIMCARD_SETTING_COLUMN_MODE                   + " INTEGER            ," +
653e5483f6Sopenharmony_ci    SIMCARD_SETTING_COLUMN_RINGTONE_TYPE          + " INTEGER            ," +
663e5483f6Sopenharmony_ci    SIMCARD_SETTING_COLUMN_TONE_FILE              + " TEXT               ," +
673e5483f6Sopenharmony_ci    SIMCARD_SETTING_COLUMN_VIBRATE_FILE           + " TEXT               ," +
683e5483f6Sopenharmony_ci    SIMCARD_SETTING_COLUMN_VIBRATE_MODE           + " INTEGER            ," +
693e5483f6Sopenharmony_ci    SIMCARD_SETTING_COLUMN_RING_MODE              + " INTEGER            ," +
703e5483f6Sopenharmony_ci    " PRIMARY KEY (" + SIMCARD_SETTING_COLUMN_MODE + ", " + SIMCARD_SETTING_COLUMN_RINGTONE_TYPE + "))";
713e5483f6Sopenharmony_ci
723e5483f6Sopenharmony_ciconst std::string INIT_SIMCARD_SETTING_TABLE = "INSERT OR IGNORE INTO " + SIMCARD_SETTING_TABLE + " (" +
733e5483f6Sopenharmony_ci    SIMCARD_SETTING_COLUMN_MODE                   + ", " +
743e5483f6Sopenharmony_ci    SIMCARD_SETTING_COLUMN_RINGTONE_TYPE          + ") VALUES (1, 0), (1, 1), (1, 2), (1, 3), \
753e5483f6Sopenharmony_ci                                                        (2, 0), (2, 1), (2, 2), (2, 3),        \
763e5483f6Sopenharmony_ci                                                        (3, 0), (3, 1), (3, 2), (3, 3);";
773e5483f6Sopenharmony_ci
783e5483f6Sopenharmony_ciconst std::string CREATE_VIBRATE_TABLE = "CREATE TABLE IF NOT EXISTS " + VIBRATE_TABLE + "(" +
793e5483f6Sopenharmony_ci    VIBRATE_COLUMN_VIBRATE_ID                     + " INTEGER  PRIMARY KEY AUTOINCREMENT, " +
803e5483f6Sopenharmony_ci    VIBRATE_COLUMN_DATA                           + " TEXT              , " +
813e5483f6Sopenharmony_ci    VIBRATE_COLUMN_SIZE                           + " BIGINT   DEFAULT 0, " +
823e5483f6Sopenharmony_ci    VIBRATE_COLUMN_DISPLAY_NAME                   + " TEXT              , " +
833e5483f6Sopenharmony_ci    VIBRATE_COLUMN_TITLE                          + " TEXT              , " +
843e5483f6Sopenharmony_ci    VIBRATE_COLUMN_DISPLAY_LANGUAGE               + " TEXT              , " +
853e5483f6Sopenharmony_ci    VIBRATE_COLUMN_VIBRATE_TYPE                   + " INT      DEFAULT 0, " +
863e5483f6Sopenharmony_ci    VIBRATE_COLUMN_SOURCE_TYPE                    + " INT      DEFAULT 0, " +
873e5483f6Sopenharmony_ci    VIBRATE_COLUMN_DATE_ADDED                     + " BIGINT   DEFAULT 0, " +
883e5483f6Sopenharmony_ci    VIBRATE_COLUMN_DATE_MODIFIED                  + " BIGINT   DEFAULT 0, " +
893e5483f6Sopenharmony_ci    VIBRATE_COLUMN_DATE_TAKEN                     + " BIGINT   DEFAULT 0, " +
903e5483f6Sopenharmony_ci    VIBRATE_COLUMN_PLAY_MODE                      + " INT      DEFAULT 0  " + ")";
913e5483f6Sopenharmony_ci
923e5483f6Sopenharmony_ciconst std::string CREATE_PRELOAD_CONF_TABLE = "CREATE TABLE IF NOT EXISTS " + PRELOAD_CONFIG_TABLE + "(" +
933e5483f6Sopenharmony_ci    PRELOAD_CONFIG_COLUMN_RING_TONE_TYPE          + " INTEGER  PRIMARY KEY," +
943e5483f6Sopenharmony_ci    PRELOAD_CONFIG_COLUMN_TONE_ID                 + " INTEGER             ," +
953e5483f6Sopenharmony_ci    PRELOAD_CONFIG_COLUMN_DISPLAY_NAME            + " TEXT                 " + ")";
963e5483f6Sopenharmony_ci
973e5483f6Sopenharmony_ciconst std::string INIT_PRELOAD_CONF_TABLE = "INSERT OR IGNORE INTO " + PRELOAD_CONFIG_TABLE + " (" +
983e5483f6Sopenharmony_ci    PRELOAD_CONFIG_COLUMN_RING_TONE_TYPE + ") VALUES (1), (2), (3), (4), (5), (6);";
993e5483f6Sopenharmony_ci
1003e5483f6Sopenharmony_cistatic const vector<string> g_initSqls = {
1013e5483f6Sopenharmony_ci    CREATE_RINGTONE_TABLE,
1023e5483f6Sopenharmony_ci    CREATE_VIBRATE_TABLE,
1033e5483f6Sopenharmony_ci    CREATE_SIMCARD_SETTING_TABLE,
1043e5483f6Sopenharmony_ci    INIT_SIMCARD_SETTING_TABLE,
1053e5483f6Sopenharmony_ci    CREATE_PRELOAD_CONF_TABLE,
1063e5483f6Sopenharmony_ci    INIT_PRELOAD_CONF_TABLE,
1073e5483f6Sopenharmony_ci};
1083e5483f6Sopenharmony_ci
1093e5483f6Sopenharmony_ciRingtoneDataCallBack::RingtoneDataCallBack(void)
1103e5483f6Sopenharmony_ci{
1113e5483f6Sopenharmony_ci}
1123e5483f6Sopenharmony_ci
1133e5483f6Sopenharmony_ciRingtoneDataCallBack::~RingtoneDataCallBack(void)
1143e5483f6Sopenharmony_ci{
1153e5483f6Sopenharmony_ci}
1163e5483f6Sopenharmony_ci
1173e5483f6Sopenharmony_ciint32_t RingtoneDataCallBack::InitSql(NativeRdb::RdbStore &store)
1183e5483f6Sopenharmony_ci{
1193e5483f6Sopenharmony_ci    for (const string &sqlStr : g_initSqls) {
1203e5483f6Sopenharmony_ci        if (store.ExecuteSql(sqlStr) != NativeRdb::E_OK) {
1213e5483f6Sopenharmony_ci            RINGTONE_ERR_LOG("Failed to execute sql");
1223e5483f6Sopenharmony_ci            return NativeRdb::E_ERROR;
1233e5483f6Sopenharmony_ci        }
1243e5483f6Sopenharmony_ci    }
1253e5483f6Sopenharmony_ci    return NativeRdb::E_OK;
1263e5483f6Sopenharmony_ci}
1273e5483f6Sopenharmony_ci
1283e5483f6Sopenharmony_ciint32_t RingtoneDataCallBack::OnCreate(NativeRdb::RdbStore &store)
1293e5483f6Sopenharmony_ci{
1303e5483f6Sopenharmony_ci    if (InitSql(store) != NativeRdb::E_OK) {
1313e5483f6Sopenharmony_ci        RINGTONE_DEBUG_LOG("Failed to init sql");
1323e5483f6Sopenharmony_ci        return NativeRdb::E_ERROR;
1333e5483f6Sopenharmony_ci    }
1343e5483f6Sopenharmony_ci
1353e5483f6Sopenharmony_ci    RingtoneFileUtils::CreateRingtoneDir();
1363e5483f6Sopenharmony_ci    return NativeRdb::E_OK;
1373e5483f6Sopenharmony_ci}
1383e5483f6Sopenharmony_ci
1393e5483f6Sopenharmony_cistatic void ExecSqls(const vector<string> &sqls, NativeRdb::RdbStore &store)
1403e5483f6Sopenharmony_ci{
1413e5483f6Sopenharmony_ci    int32_t err = NativeRdb::E_OK;
1423e5483f6Sopenharmony_ci    for (const auto &sql : sqls) {
1433e5483f6Sopenharmony_ci        err = store.ExecuteSql(sql);
1443e5483f6Sopenharmony_ci        if (err != NativeRdb::E_OK) {
1453e5483f6Sopenharmony_ci            RINGTONE_ERR_LOG("Failed to exec: %{private}s", sql.c_str());
1463e5483f6Sopenharmony_ci            continue;
1473e5483f6Sopenharmony_ci        }
1483e5483f6Sopenharmony_ci    }
1493e5483f6Sopenharmony_ci}
1503e5483f6Sopenharmony_ci
1513e5483f6Sopenharmony_cistatic void AddDisplayLanguageColumn(NativeRdb::RdbStore &store)
1523e5483f6Sopenharmony_ci{
1533e5483f6Sopenharmony_ci    const vector<string> sqls = {
1543e5483f6Sopenharmony_ci        "ALTER TABLE " + RINGTONE_TABLE + " ADD COLUMN " + RINGTONE_COLUMN_DISPLAY_LANGUAGE_TYPE + " TEXT",
1553e5483f6Sopenharmony_ci    };
1563e5483f6Sopenharmony_ci    RINGTONE_INFO_LOG("Add display language column");
1573e5483f6Sopenharmony_ci    ExecSqls(sqls, store);
1583e5483f6Sopenharmony_ci}
1593e5483f6Sopenharmony_ci
1603e5483f6Sopenharmony_cistatic void AddVibrateTable(NativeRdb::RdbStore &store)
1613e5483f6Sopenharmony_ci{
1623e5483f6Sopenharmony_ci    const vector<string> sqls = {
1633e5483f6Sopenharmony_ci        CREATE_VIBRATE_TABLE,
1643e5483f6Sopenharmony_ci        CREATE_SIMCARD_SETTING_TABLE,
1653e5483f6Sopenharmony_ci        INIT_SIMCARD_SETTING_TABLE,
1663e5483f6Sopenharmony_ci    };
1673e5483f6Sopenharmony_ci    int32_t errCode;
1683e5483f6Sopenharmony_ci    shared_ptr<NativePreferences::Preferences> prefs =
1693e5483f6Sopenharmony_ci        NativePreferences::PreferencesHelper::GetPreferences(COMMON_XML_EL1, errCode);
1703e5483f6Sopenharmony_ci    if (!prefs) {
1713e5483f6Sopenharmony_ci        RINGTONE_ERR_LOG("AddVibrateTable: update faild errCode=%{public}d", errCode);
1723e5483f6Sopenharmony_ci    } else {
1733e5483f6Sopenharmony_ci        prefs->PutInt(RINGTONE_PARAMETER_SCANNER_COMPLETED_KEY, RINGTONE_PARAMETER_SCANNER_COMPLETED_FALSE);
1743e5483f6Sopenharmony_ci        prefs->FlushSync();
1753e5483f6Sopenharmony_ci    }
1763e5483f6Sopenharmony_ci
1773e5483f6Sopenharmony_ci    RINGTONE_INFO_LOG("Add vibrate table");
1783e5483f6Sopenharmony_ci    ExecSqls(sqls, store);
1793e5483f6Sopenharmony_ci}
1803e5483f6Sopenharmony_ci
1813e5483f6Sopenharmony_cistatic void UpdateMimeType(NativeRdb::RdbStore &store)
1823e5483f6Sopenharmony_ci{
1833e5483f6Sopenharmony_ci    RINGTONE_INFO_LOG("Update MimeType Begin");
1843e5483f6Sopenharmony_ci    RingtoneMimeTypeUtils::InitMimeTypeMap();
1853e5483f6Sopenharmony_ci    const string sql = "SELECT * FROM " + RINGTONE_TABLE;
1863e5483f6Sopenharmony_ci    auto resultSet = store.QuerySql(sql);
1873e5483f6Sopenharmony_ci    if (resultSet == nullptr) {
1883e5483f6Sopenharmony_ci        RINGTONE_ERR_LOG("error query sql %{public}s", sql.c_str());
1893e5483f6Sopenharmony_ci        return;
1903e5483f6Sopenharmony_ci    }
1913e5483f6Sopenharmony_ci    while (resultSet->GoToNextRow() == NativeRdb::E_OK) {
1923e5483f6Sopenharmony_ci        std::string mimeType = GetStringVal(RINGTONE_COLUMN_MIME_TYPE, resultSet);
1933e5483f6Sopenharmony_ci        if (mimeType != DEFAULT_MIME_TYPE) {
1943e5483f6Sopenharmony_ci            continue;
1953e5483f6Sopenharmony_ci        }
1963e5483f6Sopenharmony_ci        string displayName = GetStringVal(RINGTONE_COLUMN_DISPLAY_NAME, resultSet);
1973e5483f6Sopenharmony_ci        int32_t toneid = GetInt32Val(RINGTONE_COLUMN_TONE_ID, resultSet);
1983e5483f6Sopenharmony_ci        std::string extension = RingtoneFileUtils::GetFileExtension(displayName);
1993e5483f6Sopenharmony_ci        mimeType = RingtoneMimeTypeUtils::GetMimeTypeFromExtension(extension);
2003e5483f6Sopenharmony_ci        int32_t mime = RingtoneMimeTypeUtils::GetMediaTypeFromMimeType(mimeType);
2013e5483f6Sopenharmony_ci        RINGTONE_INFO_LOG("extension: %{public}s, mimeType: %{public}s, toneid: %{public}d mime: %{public}d",
2023e5483f6Sopenharmony_ci            extension.c_str(), mimeType.c_str(), toneid, mime);
2033e5483f6Sopenharmony_ci
2043e5483f6Sopenharmony_ci        NativeRdb::ValuesBucket values;
2053e5483f6Sopenharmony_ci        values.PutString(RINGTONE_COLUMN_MIME_TYPE, mimeType);
2063e5483f6Sopenharmony_ci        values.PutInt(RINGTONE_COLUMN_MEDIA_TYPE, mime);
2073e5483f6Sopenharmony_ci        NativeRdb::AbsRdbPredicates absRdbPredicates(RINGTONE_TABLE);
2083e5483f6Sopenharmony_ci        absRdbPredicates.EqualTo(RINGTONE_COLUMN_TONE_ID, toneid);
2093e5483f6Sopenharmony_ci        int32_t changedRows;
2103e5483f6Sopenharmony_ci        int32_t result = store.Update(changedRows, values, absRdbPredicates);
2113e5483f6Sopenharmony_ci        if (result != E_OK || changedRows <= 0) {
2123e5483f6Sopenharmony_ci            RINGTONE_ERR_LOG("Update operation failed. Result %{public}d. Updated %{public}d", result, changedRows);
2133e5483f6Sopenharmony_ci        }
2143e5483f6Sopenharmony_ci    }
2153e5483f6Sopenharmony_ci    resultSet->Close();
2163e5483f6Sopenharmony_ci}
2173e5483f6Sopenharmony_ci
2183e5483f6Sopenharmony_cistatic void AddPreloadConfTable(NativeRdb::RdbStore &store)
2193e5483f6Sopenharmony_ci{
2203e5483f6Sopenharmony_ci    const vector<string> sqls = {
2213e5483f6Sopenharmony_ci        CREATE_PRELOAD_CONF_TABLE,
2223e5483f6Sopenharmony_ci        INIT_PRELOAD_CONF_TABLE
2233e5483f6Sopenharmony_ci    };
2243e5483f6Sopenharmony_ci    RINGTONE_INFO_LOG("Add preload config table");
2253e5483f6Sopenharmony_ci    ExecSqls(sqls, store);
2263e5483f6Sopenharmony_ci}
2273e5483f6Sopenharmony_ci
2283e5483f6Sopenharmony_cistatic void UpdateDefaultSystemTone(NativeRdb::RdbStore &store)
2293e5483f6Sopenharmony_ci{
2303e5483f6Sopenharmony_ci    RINGTONE_INFO_LOG("setting system tone begin");
2313e5483f6Sopenharmony_ci    auto infos = RingtoneUtils::GetDefaultSystemtoneInfo();
2323e5483f6Sopenharmony_ci    for (auto info : infos) {
2333e5483f6Sopenharmony_ci        const string querySql = "SELECT tone_id FROM ToneFiles WHERE display_name = "s + "\"" + info.second + "\"";
2343e5483f6Sopenharmony_ci        auto resultSet = store.QuerySql(querySql);
2353e5483f6Sopenharmony_ci        if (resultSet == nullptr || resultSet->GoToFirstRow() != NativeRdb::E_OK) {
2363e5483f6Sopenharmony_ci            RINGTONE_ERR_LOG("Update operation failed. no resultSet");
2373e5483f6Sopenharmony_ci            continue;
2383e5483f6Sopenharmony_ci        }
2393e5483f6Sopenharmony_ci
2403e5483f6Sopenharmony_ci        int32_t tone_id = GetInt32Val("tone_id", resultSet);
2413e5483f6Sopenharmony_ci        NativeRdb::ValuesBucket values;
2423e5483f6Sopenharmony_ci        values.PutString(PRELOAD_CONFIG_COLUMN_DISPLAY_NAME, info.second);
2433e5483f6Sopenharmony_ci        values.PutInt(PRELOAD_CONFIG_COLUMN_TONE_ID, tone_id);
2443e5483f6Sopenharmony_ci        NativeRdb::AbsRdbPredicates absRdbPredicates(PRELOAD_CONFIG_TABLE);
2453e5483f6Sopenharmony_ci        absRdbPredicates.EqualTo(PRELOAD_CONFIG_COLUMN_RING_TONE_TYPE, std::to_string(info.first));
2463e5483f6Sopenharmony_ci        int32_t changedRows = 0;
2473e5483f6Sopenharmony_ci        int32_t result = store.Update(changedRows, values, absRdbPredicates);
2483e5483f6Sopenharmony_ci        if (result != E_OK || changedRows <= 0) {
2493e5483f6Sopenharmony_ci            RINGTONE_ERR_LOG("Update operation failed. Result %{public}d. Updated %{public}d", result, changedRows);
2503e5483f6Sopenharmony_ci        }
2513e5483f6Sopenharmony_ci    }
2523e5483f6Sopenharmony_ci}
2533e5483f6Sopenharmony_ci
2543e5483f6Sopenharmony_cistatic void UpgradeExtension(NativeRdb::RdbStore &store, int32_t oldVersion)
2553e5483f6Sopenharmony_ci{
2563e5483f6Sopenharmony_ci    if (oldVersion < VERSION_ADD_DISPLAY_LANGUAGE_COLUMN) {
2573e5483f6Sopenharmony_ci        AddDisplayLanguageColumn(store);
2583e5483f6Sopenharmony_ci    }
2593e5483f6Sopenharmony_ci    if (oldVersion < VERSION_ADD_VIBRATE_TABLE) {
2603e5483f6Sopenharmony_ci        AddVibrateTable(store);
2613e5483f6Sopenharmony_ci    }
2623e5483f6Sopenharmony_ci    if (oldVersion < VERSION_UPDATE_MIME_TYPE) {
2633e5483f6Sopenharmony_ci        UpdateMimeType(store);
2643e5483f6Sopenharmony_ci    }
2653e5483f6Sopenharmony_ci    if (oldVersion < VERSION_ADD_PRELOAD_CONF_TABLE) {
2663e5483f6Sopenharmony_ci        AddPreloadConfTable(store);
2673e5483f6Sopenharmony_ci        UpdateDefaultSystemTone(store);
2683e5483f6Sopenharmony_ci    }
2693e5483f6Sopenharmony_ci}
2703e5483f6Sopenharmony_ci
2713e5483f6Sopenharmony_ciint32_t RingtoneDataCallBack::OnUpgrade(NativeRdb::RdbStore &store, int32_t oldVersion, int32_t newVersion)
2723e5483f6Sopenharmony_ci{
2733e5483f6Sopenharmony_ci    RINGTONE_INFO_LOG("OnUpgrade old:%d, new:%d", oldVersion, newVersion);
2743e5483f6Sopenharmony_ci    UpgradeExtension(store, oldVersion);
2753e5483f6Sopenharmony_ci    return NativeRdb::E_OK;
2763e5483f6Sopenharmony_ci}
2773e5483f6Sopenharmony_ci} // namespace Media
2783e5483f6Sopenharmony_ci} // namespace OHOS
279