1 /* 2 * Copyright (c) 2023 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_FACTORYRESET_CALLBACK_H 17 #define NET_FACTORYRESET_CALLBACK_H 18 19 #include <mutex> 20 #include <string> 21 #include <vector> 22 23 #include "singleton.h" 24 #include "refbase.h" 25 #include "ffrt.h" 26 #include "event_handler.h" 27 #include "i_net_factoryreset_callback.h" 28 29 namespace OHOS { 30 namespace NetManagerStandard { 31 class NetFactoryResetCallback : public RefBase { 32 33 public: 34 NetFactoryResetCallback(); ~NetFactoryResetCallback()35 ~NetFactoryResetCallback() {} 36 /** 37 * Register net factory reset callback. 38 * @param callback Interface type pointer. 39 * @return int32_t Returns 0 success. Otherwise fail, {@link NetConnResultCode}. 40 */ 41 int32_t RegisterNetFactoryResetCallbackAsync(const sptr<INetFactoryResetCallback> &callback); 42 43 /** 44 * Unregister net factory reset callback. 45 * @param callback Interface type pointer. 46 * @return int32_t Returns 0 success. Otherwise fail, {@link NetConnResultCode}. 47 */ 48 int32_t UnregisterNetFactoryResetCallbackAsync(const sptr<INetFactoryResetCallback> &callback); 49 50 /** 51 * Notify network factory reset. 52 * @return int32_t Returns 0 success. Otherwise fail, {@link NetConnResultCode}. 53 */ 54 int32_t NotifyNetFactoryResetAsync(); 55 56 private: 57 int32_t RegisterNetFactoryResetCallback(const sptr<INetFactoryResetCallback> &callback); 58 int32_t UnregisterNetFactoryResetCallback(const sptr<INetFactoryResetCallback> &callback); 59 int32_t NotifyNetFactoryReset(); 60 61 private: 62 std::vector<sptr<INetFactoryResetCallback>> callbacks_; 63 std::shared_ptr<ffrt::queue> factoryResetCallFfrtQueue_ = nullptr; 64 }; 65 } // namespace NetManagerStandard 66 } // namespace OHOS 67 #endif // NET_FACTORYRESET_CALLBACK_H 68