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 "base/web/webview/sa/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 37 void OnLoadSystemAbilitySuccess(const sptr<IRemoteObject>& object); 38 void OnLoadSystemAbilityFail(); 39 void AppFwkUpdateOnRemoteDied(const wptr<IRemoteObject>& remoteObject); 40 41 private: 42 bool LoadFwkService(); 43 void SetFwkUpdate(const sptr<IRemoteObject>& remoteObject); 44 sptr<IAppFwkUpdateService> GetFwkUpdate(); 45 sptr<IAppFwkUpdateService> GetFwkUpdateProxy(); 46 class AppFwkUpdateDiedRecipient : public IRemoteObject::DeathRecipient { 47 public: 48 void OnRemoteDied(const wptr<IRemoteObject>& remote) override; 49 }; 50 51 private: 52 std::condition_variable loadSaCondition_; 53 std::mutex loadSaMutex_; 54 bool loadSaFinished_ { false }; 55 std::mutex mutex_; 56 sptr<IAppFwkUpdateService> fwkUpdateProxy_ = nullptr; 57 sptr<AppFwkUpdateDiedRecipient> appFwkUpdateDiedRecipient_ = nullptr; 58 DISALLOW_COPY_AND_MOVE(AppFwkUpdateClient); 59 }; 60 } // namespace OHOS::NWeb 61 #endif // OHOS_NWEB_APP_FWK_UPDATE_CLIENT_H