1 /* 2 * Copyright (c) 2025-2026 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 NETWORKSLICE_SERVICE_H 17 #define NETWORKSLICE_SERVICE_H 18 19 #include <cstdint> 20 #include <iosfwd> 21 #include <memory> 22 #include <string> 23 #include <vector> 24 25 #include "refbase.h" 26 #include "singleton.h" 27 #include "system_ability.h" 28 #include "datashare_helper.h" 29 #include "networkslice_stub.h" 30 #include "networkslicecommconfig.h" 31 32 namespace OHOS { 33 namespace NetManagerStandard { 34 35 class NetworkSliceService : public SystemAbility, 36 public NetworkSliceStub, 37 public std::enable_shared_from_this<NetworkSliceService> { 38 DECLARE_DELAYED_SINGLETON(NetworkSliceService) 39 DECLARE_SYSTEM_ABILITY(NetworkSliceService) 40 enum ServiceRunningState { 41 STATE_STOPPED = 0, 42 STATE_RUNNING, 43 }; 44 45 public: 46 static NetworkSliceService &GetInstance(); 47 int32_t SetNetworkSliceUePolicy(std::vector<uint8_t> buffer) override; 48 int32_t NetworkSliceAllowedNssaiRpt(std::vector<uint8_t> buffer) override; 49 int32_t NetworkSliceEhplmnRpt(std::vector<uint8_t> buffer) override; 50 int32_t GetRouteSelectionDescriptorByDNN(std::string dnn, std::string& snssai, uint8_t& sscMode) override; 51 int32_t GetRSDByNetCap(int32_t netcap, std::map<std::string, std::string>& networkSliceParas) override; 52 int32_t SetSaState(bool isSaState) override; 53 54 int32_t NetworkSliceGetRSDByAppDescriptor(std::shared_ptr<GetSlicePara>& getSlicePara); 55 int32_t RecvKernelData(void* rcvMsg, int32_t dataLen); 56 int GetBundleNameForUid(int32_t uid, std::string &bundleName); 57 int32_t BindToNetwork(std::map<std::string, std::string> buffer); 58 int32_t DelBindToNetwork(std::map<std::string, std::string> buffer); 59 int WriteNetworkSliceApnToDb(std::shared_ptr<DataShare::DataShareHelper> networksliceApnHelper, 60 std::string apntype); 61 bool UpdateNetworkSliceApn(); 62 int32_t NetworkSliceInitUePolicy() override; 63 int32_t GetUidByBundleName(const std::string& bundleName); 64 std::set<int32_t> GetUidsByBundleName(const std::string& bundleName); 65 protected: 66 void OnStart() override; 67 void OnStop() override; 68 69 private: 70 bool Init(); 71 void InitModule(); 72 bool isRegistered_; 73 ServiceRunningState state_; 74 static NetworkSliceService instance_; 75 }; 76 } // namespace NetManagerStandard 77 } // namespace OHOS 78 #endif // NETWORKSLICE_SERVICE_H 79