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 #ifndef SYSTEM_SOUND_MANAGER_UTILS_H 16 #define SYSTEM_SOUND_MANAGER_UTILS_H 17 18 #include <array> 19 #include "datashare_helper.h" 20 #include "uri.h" 21 #include "want.h" 22 #include "access_token.h" 23 #include <iostream> 24 25 #include "audio_system_manager.h" 26 #include "system_sound_manager.h" 27 28 namespace OHOS { 29 namespace Media { 30 31 class SystemSoundManagerUtils { 32 public: 33 static int32_t GetCurrentUserId(); 34 static std::shared_ptr<DataShare::DataShareHelper> CreateDataShareHelperUri(int32_t systemAbilityId); 35 static std::shared_ptr<DataShare::DataShareHelper> CreateDataShareHelper(int32_t systemAbilityId); 36 static bool VerifyCustomPath(const std::string &audioUri); 37 static bool IdExists(const std::string &ids, int32_t id); 38 static bool CheckCurrentUser(); 39 static bool GetScannerFirstParameter(const char* key, int32_t maxSize); 40 static int32_t GetTypeForSystemSoundUri(const std::string &audioUri); 41 static std::string GetErrorReason(const int32_t &errorCode); 42 }; 43 44 class __attribute__((visibility("default"))) MediaTrace : public NoCopyable { 45 public: 46 explicit MediaTrace(const std::string &funcName); 47 static void TraceBegin(const std::string &funcName, int32_t taskId); 48 static void TraceEnd(const std::string &funcName, int32_t taskId); 49 static void CounterTrace(const std::string &varName, int32_t val); 50 ~MediaTrace(); 51 private: 52 bool isSync_ = false; 53 }; 54 } // namespace Media 55 } // namespace OHOS 56 #endif // SYSTEM_SOUND_MANAGER_UTILS_H