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#ifndef RINGTONE_PERMISSION_UTILS_H 163e5483f6Sopenharmony_ci#define RINGTONE_PERMISSION_UTILS_H 173e5483f6Sopenharmony_ci 183e5483f6Sopenharmony_ci#include "bundle_mgr_interface.h" 193e5483f6Sopenharmony_ci 203e5483f6Sopenharmony_cinamespace OHOS { 213e5483f6Sopenharmony_cinamespace Media { 223e5483f6Sopenharmony_ci#define EXPORT __attribute__ ((visibility ("default"))) 233e5483f6Sopenharmony_ciconst std::string PERM_WRITE_RINGTONE = "ohos.permission.WRITE_RINGTONE"; 243e5483f6Sopenharmony_ci 253e5483f6Sopenharmony_ciclass RingtonePermissionUtils { 263e5483f6Sopenharmony_cipublic: 273e5483f6Sopenharmony_ci EXPORT static bool CheckCallerPermission(const std::string &permission); 283e5483f6Sopenharmony_ci EXPORT static bool CheckCallerPermission(const std::vector<std::string> &permsVec); 293e5483f6Sopenharmony_ci EXPORT static bool CheckHasPermission(const std::vector<std::string> &permsVec); 303e5483f6Sopenharmony_ci EXPORT static void GetClientBundle(const int uid, std::string &bundleName); 313e5483f6Sopenharmony_ci EXPORT static uint32_t GetTokenId(); 323e5483f6Sopenharmony_ci EXPORT static bool CheckIsSystemAppByUid(); 333e5483f6Sopenharmony_ci EXPORT static bool IsSystemApp(); 343e5483f6Sopenharmony_ci EXPORT static bool IsNativeSAApp(); 353e5483f6Sopenharmony_ci EXPORT static std::string GetPackageNameByBundleName(const std::string &bundleName); 363e5483f6Sopenharmony_ci 373e5483f6Sopenharmony_ciprivate: 383e5483f6Sopenharmony_ci static sptr<AppExecFwk::IBundleMgr> GetSysBundleManager(); 393e5483f6Sopenharmony_ci __attribute__ ((visibility ("hidden"))) static sptr<AppExecFwk::IBundleMgr> bundleManager_; 403e5483f6Sopenharmony_ci __attribute__ ((visibility ("hidden"))) static std::mutex bundleManagerMutex_; 413e5483f6Sopenharmony_ci}; 423e5483f6Sopenharmony_ci} // namespace Media 433e5483f6Sopenharmony_ci} // namespace OHOS 443e5483f6Sopenharmony_ci#endif // RINGTONE_PERMISSION_UTILS_H 45