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 NET_ACCESS_POLICY_DIALOG_IMPL_H 17 #define NET_ACCESS_POLICY_DIALOG_IMPL_H 18 19 #include "net_access_policy_dialog.h" 20 21 #include <mutex> 22 #include <iostream> 23 24 25 #include "ability_connect_callback_interface.h" 26 #include "ability_connect_callback_stub.h" 27 28 namespace OHOS { 29 namespace NetManagerStandard { 30 class NetAccessPolicyDialogImpl : public INetAccessPolicyDialog { 31 public: 32 NetAccessPolicyDialogImpl(); 33 ~NetAccessPolicyDialogImpl(); 34 bool ConnectSystemUi(uint32_t uid) override; GetBundleName()35 static std::string GetBundleName() 36 { 37 return bundleName_; 38 } 39 GetAbilityName()40 static std::string GetAbilityName() 41 { 42 return abilityName_; 43 } 44 GetUiExtensionType()45 static std::string GetUiExtensionType() 46 { 47 return uiExtensionType_; 48 } 49 private: 50 class DialogAbilityConnection : public OHOS::AAFwk::AbilityConnectionStub { 51 public: 52 void OnAbilityConnectDone(const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, 53 int resultCode) override; 54 void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) override; 55 56 private: 57 std::mutex mutex_; 58 }; 59 60 sptr<OHOS::AAFwk::IAbilityConnection> dialogConnectionCallback_{nullptr}; 61 static std::string bundleName_; 62 static std::string abilityName_; 63 static std::string uiExtensionType_; 64 }; 65 66 extern "C" __attribute__((visibility("default"))) INetAccessPolicyDialog *GetNetAccessPolicyDialog(); 67 } // namespace NetManagerStandard 68 } // namespace OHOS 69 70 #endif // NET_ACCESS_POLICY_DIALOG_IMPL_H 71