• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CLIENT_H
17 #define NETWORKSLICE_CLIENT_H
18 
19 #include <string>
20 
21 #include "i_networkslice_service.h"
22 #include "parcel.h"
23 #include "singleton.h"
24 
25 namespace OHOS {
26 namespace NetManagerStandard {
27 
28 class NetworkSliceClient {
29     DECLARE_DELAYED_SINGLETON(NetworkSliceClient)
30 
31 public:
32     int32_t SetNetworkSliceUePolicy(std::vector<uint8_t> buffer);
33     int32_t NetworkSliceInitUePolicy();
34     int32_t NetworkSliceAllowedNssaiRpt(std::vector<uint8_t> buffer);
35     int32_t NetworkSliceEhplmnRpt(std::vector<uint8_t> buffer);
36     int32_t GetRouteSelectionDescriptorByDNN(std::string dnn, std::string& snssai, uint8_t& sscMode);
37     int32_t GetRSDByNetCap(int32_t netcap, std::map<std::string, std::string>& networkSliceParas);
38     int32_t SetSaState(bool isSaState);
39 private:
40     class NetworkSliceDeathRecipient : public IRemoteObject::DeathRecipient {
41     public:
NetworkSliceDeathRecipient(NetworkSliceClient & client)42         explicit NetworkSliceDeathRecipient(NetworkSliceClient &client) : client_(client) {}
43         ~NetworkSliceDeathRecipient() override = default;
OnRemoteDied(const wptr<IRemoteObject> & remote)44         void OnRemoteDied(const wptr<IRemoteObject> &remote) override
45         {
46             client_.OnRemoteDied(remote);
47         }
48 
49     private:
50         NetworkSliceClient &client_;
51     };
52 
53 private:
54     sptr<INetworkSliceService> GetProxy();
55     void RecoverCallback();
56     void OnRemoteDied(const wptr<IRemoteObject> &remote);
57     void DlCloseRemoveDeathRecipient();
58 private:
59     std::mutex mutex_;
60     sptr<INetworkSliceService> networksliceService_;
61     sptr<IRemoteObject::DeathRecipient> deathRecipient_;
62 };
63 
64 } // namespace NetManagerStandard
65 } // namespace OHOS
66 #endif // NETWORKSLICE_CLIENT_H
67