15490a39dSopenharmony_ci/* 25490a39dSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 35490a39dSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 45490a39dSopenharmony_ci * you may not use this file except in compliance with the License. 55490a39dSopenharmony_ci * You may obtain a copy of the License at 65490a39dSopenharmony_ci * 75490a39dSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 85490a39dSopenharmony_ci * 95490a39dSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 105490a39dSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 115490a39dSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 125490a39dSopenharmony_ci * See the License for the specific language governing permissions and 135490a39dSopenharmony_ci * limitations under the License. 145490a39dSopenharmony_ci */ 155490a39dSopenharmony_ci#ifndef INTELL_VOICE_UTIL_H 165490a39dSopenharmony_ci#define INTELL_VOICE_UTIL_H 175490a39dSopenharmony_ci#include <cstdint> 185490a39dSopenharmony_ci#include <string> 195490a39dSopenharmony_ci#include <vector> 205490a39dSopenharmony_ci#include <memory> 215490a39dSopenharmony_ci#include <map> 225490a39dSopenharmony_ci 235490a39dSopenharmony_cinamespace OHOS { 245490a39dSopenharmony_cinamespace IntellVoiceUtils { 255490a39dSopenharmony_ciconst std::string OHOS_MICROPHONE_PERMISSION = "ohos.permission.MICROPHONE"; 265490a39dSopenharmony_ci 275490a39dSopenharmony_cienum IntellVoicePermissionState { 285490a39dSopenharmony_ci INTELL_VOICE_PERMISSION_START = 0, 295490a39dSopenharmony_ci INTELL_VOICE_PERMISSION_STOP = 1, 305490a39dSopenharmony_ci}; 315490a39dSopenharmony_ci 325490a39dSopenharmony_ciclass IntellVoiceUtil final { 335490a39dSopenharmony_cipublic: 345490a39dSopenharmony_ci static uint32_t GetHdiVersionId(uint32_t majorVer, uint32_t minorVer); 355490a39dSopenharmony_ci static bool DeinterleaveAudioData(const int16_t *buffer, uint32_t size, int32_t channelCnt, 365490a39dSopenharmony_ci std::vector<std::vector<uint8_t>> &audioData); 375490a39dSopenharmony_ci static int32_t VerifySystemPermission(const std::string &permissionName); 385490a39dSopenharmony_ci static bool ReadFile(const std::string &filePath, std::shared_ptr<uint8_t> &buffer, uint32_t &size); 395490a39dSopenharmony_ci static void SplitStringToKVPair(const std::string &inputStr, std::map<std::string, std::string> &kvpairs); 405490a39dSopenharmony_ci static bool IsFileExist(const std::string &filePath); 415490a39dSopenharmony_ci static bool RecordPermissionPrivacy(const std::string &permissionName, uint32_t targetTokenId, 425490a39dSopenharmony_ci IntellVoicePermissionState state); 435490a39dSopenharmony_ci 445490a39dSopenharmony_ciprivate: 455490a39dSopenharmony_ci static bool VerifyClientPermission(const std::string &permissionName); 465490a39dSopenharmony_ci static bool CheckIsSystemApp(); 475490a39dSopenharmony_ci}; 485490a39dSopenharmony_ci} 495490a39dSopenharmony_ci} 505490a39dSopenharmony_ci#endif 51