• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 #include "devattest_network_callback.h"
17 
18 #include "cstdint"
19 
20 #include "net_conn_client.h"
21 #include "net_conn_constants.h"
22 
23 #include "devattest_log.h"
24 #include "devattest_errno.h"
25 #include "attest_entry.h"
26 
27 namespace OHOS {
28 namespace DevAttest {
NetCapabilitiesChange(sptr<NetHandle> & netHandle,const sptr<NetAllCapabilities> & netAllCap)29 int32_t DevAttestNetworkCallback::NetCapabilitiesChange(
30     sptr<NetHandle> &netHandle, const sptr<NetAllCapabilities> &netAllCap)
31 {
32     if (netHandle == nullptr || netAllCap == nullptr) {
33         HILOGI("[NetCapabilitiesChange] invalid parameter");
34         return DEVATTEST_SUCCESS;
35     }
36     int32_t ret = DEVATTEST_SUCCESS;
37     for (auto netCap : netAllCap->netCaps_) {
38         switch (netCap) {
39             case NET_CAPABILITY_MMS:
40                 HILOGI("[NetCapabilitiesChange] NET_CAPABILITY_MMS start");
41                 break;
42             case NET_CAPABILITY_NOT_METERED:
43                 HILOGI("[NetCapabilitiesChange] NET_CAPABILITY_NOT_METERED start");
44                 break;
45             case NET_CAPABILITY_INTERNET:
46                 HILOGI("[NetCapabilitiesChange] NET_CAPABILITY_INTERNET start");
47                 ret = AttestTask();
48                 HILOGI("DevAttestService test success, ret = %{public}d", ret);
49                 break;
50             case NET_CAPABILITY_NOT_VPN:
51                 HILOGI("[NetCapabilitiesChange] NET_CAPABILITY_NOT_VPN start");
52                 break;
53             case NET_CAPABILITY_VALIDATED:
54                 HILOGI("[NetCapabilitiesChange] NET_CAPABILITY_VALIDATED start");
55                 break;
56             case NET_CAPABILITY_CAPTIVE_PORTAL:
57                 HILOGI("[NetCapabilitiesChange] NET_CAPABILITY_CAPTIVE_PORTAL start");
58                 break;
59             default:
60                 HILOGI("[NetCapabilitiesChange] default start");
61                 break;
62         }
63     }
64     return DEVATTEST_SUCCESS;
65 }
66 } // DevAttest
67 } // OHOS
68 
69