1 /* 2 * Copyright (c) 2024 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 16 #ifndef EL5_FILEKEY_MANAGER_CLIENT_H 17 #define EL5_FILEKEY_MANAGER_CLIENT_H 18 19 #include "el5_filekey_manager_interface.h" 20 21 #include <condition_variable> 22 23 namespace OHOS { 24 namespace Security { 25 namespace AccessToken { 26 class El5FilekeyManagerClient { 27 public: 28 static El5FilekeyManagerClient &GetInstance(); 29 ~El5FilekeyManagerClient(); 30 31 int32_t AcquireAccess(DataLockType type); 32 int32_t ReleaseAccess(DataLockType type); 33 int32_t GenerateAppKey(uint32_t uid, const std::string &bundleName, std::string &keyId); 34 int32_t DeleteAppKey(const std::string &bundleName, int32_t userId); 35 int32_t GetUserAppKey(int32_t userId, bool getAllFlag, std::vector<std::pair<int32_t, std::string>> &keyInfos); 36 int32_t ChangeUserAppkeysLoadInfo(int32_t userId, std::vector<std::pair<std::string, bool>> &loadInfos); 37 int32_t SetFilePathPolicy(); 38 int32_t RegisterCallback(const sptr<El5FilekeyCallbackInterface> &callback); 39 int32_t CallProxyWithRetry(const std::function<int32_t(sptr<El5FilekeyManagerInterface> &)> &func, 40 const char *funcName); 41 bool IsRequestNeedRetry(int32_t ret); 42 43 private: 44 El5FilekeyManagerClient(); 45 DISALLOW_COPY_AND_MOVE(El5FilekeyManagerClient); 46 std::mutex proxyMutex_; 47 sptr<El5FilekeyManagerInterface> GetProxy(); 48 }; 49 } // namespace AccessToken 50 } // namespace Security 51 } // namespace OHOS 52 #endif // EL5_FILEKEY_MANAGER_CLIENT_H 53