• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #define MLOG_TAG "RingtoneCheckUtils"
16 
17 #include "ringtone_check_utils.h"
18 
19 #include <string>
20 
21 #include "ringtone_errno.h"
22 #include "ringtone_db_const.h"
23 
24 namespace OHOS {
25 namespace Media {
26 using namespace std;
27 
28 const std::string RINGTONE_CUSTOM_PATH_FIRST = "/storage/media/local/files";
29 const std::string RINGTONE_CUSTOM_PATH_SECOND = "/data/storage/el2/base/files";
30 
GetCustomRingtoneCurrentPath(const std::string & uri)31 std::string RingtoneCheckUtils::GetCustomRingtoneCurrentPath(const std::string &uri)
32 {
33     std::string uriCopy = uri;
34     if (uriCopy.compare(0, RINGTONE_CUSTOM_PATH_FIRST.size(), RINGTONE_CUSTOM_PATH_FIRST) == 0) {
35         uriCopy.replace(0, RINGTONE_CUSTOM_PATH_FIRST.size(), RINGTONE_CUSTOMIZED_BASE_PATH);
36         return uriCopy;
37     }
38     if (uriCopy.compare(0, RINGTONE_CUSTOM_PATH_SECOND.size(), RINGTONE_CUSTOM_PATH_SECOND) == 0) {
39         uriCopy.replace(0, RINGTONE_CUSTOM_PATH_SECOND.size(), RINGTONE_CUSTOMIZED_BASE_PATH);
40         return uriCopy;
41     }
42     return uriCopy;
43 }
44 } // namespace Media
45 } // namespace OHOS
46