1 /* 2 * Copyright (c) 2025 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_STATS_TRAFFICLIMIT_DIALOG_H 17 #define NET_STATS_TRAFFICLIMIT_DIALOG_H 18 19 #include <mutex> 20 #include <iostream> 21 22 #include "ability_connect_callback_interface.h" 23 #include "ability_connect_callback_stub.h" 24 25 #include "parameter.h" 26 #include "timer.h" 27 28 namespace OHOS { 29 namespace NetManagerStandard { 30 class TrafficLimitDialog { 31 public: 32 TrafficLimitDialog(); 33 ~TrafficLimitDialog(); 34 bool PopUpTrafficLimitDialog(); 35 bool DismissTrafficLimitDialog(); 36 37 private: 38 DISALLOW_COPY_AND_MOVE(TrafficLimitDialog); 39 class TrafficLimitAbilityConn : public OHOS::AAFwk::AbilityConnectionStub { 40 void OnAbilityConnectDone(const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, 41 int32_t resultCode) override; 42 void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int32_t resultCode) override; 43 public: 44 void CloseDialog(); 45 private: 46 sptr<IRemoteObject> remoteObject_ = nullptr; 47 }; 48 bool ShowTrafficLimitDialog(); 49 bool UnShowTrafficLimitDialog(); 50 sptr<TrafficLimitAbilityConn> trafficlimitAbilityConn_ = nullptr; 51 std::mutex opMutex_; 52 bool isDialogOpen_ = false; 53 }; 54 } // namespace NetManagerStandard 55 } // namespace OHOS 56 57 #endif 58