1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.net.wifi.sharedconnectivity.service.cts;
18 
19 import android.net.wifi.sharedconnectivity.app.HotspotNetwork;
20 import android.net.wifi.sharedconnectivity.app.KnownNetwork;
21 import android.net.wifi.sharedconnectivity.service.SharedConnectivityService;
22 import android.util.Log;
23 
24 public class TestSharedConnectivityService extends SharedConnectivityService {
25     private static final String TAG = "TestSharedConnectivityService";
26 
27     /**
28      * Service object is saved to a static attribute so that the instance can be accessed from the
29      * CTS test. Service is initialized by Context.
30      */
31     private static TestSharedConnectivityService sService = null;
32 
getInstance()33     public static TestSharedConnectivityService getInstance() {
34         return TestSharedConnectivityService.sService;
35     }
36 
37     private HotspotNetwork mConnectHotspotNetwork;
38     private HotspotNetwork mDisconnectHotspotNetwork;
39     private KnownNetwork mConnectKnownNetwork;
40     private KnownNetwork mForgetKnownNetwork;
41 
42     @Override
onBind()43     public void onBind() {
44         TestSharedConnectivityService.sService = this;
45     }
46 
47     @Override
onConnectHotspotNetwork(HotspotNetwork network)48     public void onConnectHotspotNetwork(HotspotNetwork network) {
49         Log.i(TAG, "onConnectHotspotNetwork");
50         mConnectHotspotNetwork = network;
51     }
52 
53     @Override
onDisconnectHotspotNetwork(HotspotNetwork network)54     public void onDisconnectHotspotNetwork(HotspotNetwork network) {
55         Log.i(TAG, "onDisconnectHotspotNetwork");
56         mDisconnectHotspotNetwork = network;
57     }
58 
59     @Override
onConnectKnownNetwork(KnownNetwork network)60     public void onConnectKnownNetwork(KnownNetwork network) {
61         Log.i(TAG, "onConnectKnownNetwork");
62         mConnectKnownNetwork = network;
63     }
64 
65     @Override
onForgetKnownNetwork(KnownNetwork network)66     public void onForgetKnownNetwork(KnownNetwork network) {
67         Log.i(TAG, "onForgetKnownNetwork");
68         mForgetKnownNetwork = network;
69     }
70 
getConnectHotspotNetwork()71     public HotspotNetwork getConnectHotspotNetwork() {
72         return mConnectHotspotNetwork;
73     }
74 
getDisconnectHotspotNetwork()75     public HotspotNetwork getDisconnectHotspotNetwork() {
76         return mDisconnectHotspotNetwork;
77     }
78 
getConnectKnownNetwork()79     public KnownNetwork getConnectKnownNetwork() {
80         return mConnectKnownNetwork;
81     }
82 
getForgetKnownNetwork()83     public KnownNetwork getForgetKnownNetwork() {
84         return mForgetKnownNetwork;
85     }
86 
87 }
88