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 ACCESS_FORM_MANAGER_ACCESS_CLIENT_H 17 #define ACCESS_FORM_MANAGER_ACCESS_CLIENT_H 18 19 #include <mutex> 20 #include <string> 21 22 #include "form_status_change_callback.h" 23 #include "form_manager_death_recipient.h" 24 #include "form_manager_access_proxy.h" 25 #include "nocopyable.h" 26 27 namespace OHOS { 28 namespace Security { 29 namespace AccessToken { 30 class FormManagerAccessClient final { 31 public: 32 static FormManagerAccessClient& GetInstance(); 33 virtual ~FormManagerAccessClient(); 34 35 int32_t RegisterAddObserver(const std::string &bundleName, const sptr<IRemoteObject> &callerToken); 36 int32_t RegisterRemoveObserver(const std::string &bundleName, const sptr<IRemoteObject> &callerToken); 37 bool HasFormVisible(const uint32_t tokenId); 38 void OnRemoteDiedHandle(); 39 40 private: 41 FormManagerAccessClient(); 42 DISALLOW_COPY_AND_MOVE(FormManagerAccessClient); 43 44 void InitProxy(); 45 sptr<IFormMgr> GetProxy(); 46 void ReleaseProxy(); 47 48 sptr<FormMgrDeathRecipient> serviceDeathObserver_ = nullptr; 49 std::mutex proxyMutex_; 50 sptr<IFormMgr> proxy_ = nullptr; 51 }; 52 } // namespace AccessToken 53 } // namespace Security 54 } // namespace OHOS 55 #endif // ACCESS_FORM_MANAGER_ACCESS_CLIENT_H 56 57