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 OHOS_NWEB_APP_FWK_UPDATE_CLIENT_H 17 #define OHOS_NWEB_APP_FWK_UPDATE_CLIENT_H 18 19 #include <condition_variable> 20 #include <functional> 21 #include <mutex> 22 #include <set> 23 #include <string> 24 25 #include "singleton.h" 26 27 #include "iapp_fwk_update_service.h" 28 29 namespace OHOS::NWeb { 30 class AppFwkUpdateClient { 31 public: 32 AppFwkUpdateClient(); 33 virtual ~AppFwkUpdateClient() = default; 34 static AppFwkUpdateClient& GetInstance(); 35 int VerifyPackageInstall(const std::string& bundleName, const std::string& hapPath); 36 void NotifyFWKAfterBmsStart(); 37 38 void OnLoadSystemAbilitySuccess(const sptr<IRemoteObject>& object); 39 void OnLoadSystemAbilityFail(); 40 void AppFwkUpdateOnRemoteDied(const wptr<IRemoteObject>& remoteObject); 41 42 private: 43 bool LoadFwkService(); 44 void SetFwkUpdate(const sptr<IRemoteObject>& remoteObject); 45 sptr<IAppFwkUpdateService> GetFwkUpdate(); 46 sptr<IAppFwkUpdateService> GetFwkUpdateProxy(); 47 class AppFwkUpdateDiedRecipient : public IRemoteObject::DeathRecipient { 48 public: 49 void OnRemoteDied(const wptr<IRemoteObject>& remote) override; 50 }; 51 52 private: 53 std::condition_variable loadSaCondition_; 54 std::mutex loadSaMutex_; 55 bool loadSaFinished_ { false }; 56 std::mutex mutex_; 57 sptr<IAppFwkUpdateService> fwkUpdateProxy_ = nullptr; 58 sptr<AppFwkUpdateDiedRecipient> appFwkUpdateDiedRecipient_ = nullptr; 59 DISALLOW_COPY_AND_MOVE(AppFwkUpdateClient); 60 }; 61 } // namespace OHOS::NWeb 62 #endif // OHOS_NWEB_APP_FWK_UPDATE_CLIENT_H 63