• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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 com.android.settings.testutils.shadow;
18 
19 import static org.robolectric.RuntimeEnvironment.application;
20 
21 import android.net.wifi.WifiConfiguration;
22 import android.net.wifi.WifiManager;
23 
24 import org.robolectric.annotation.HiddenApi;
25 import org.robolectric.annotation.Implementation;
26 import org.robolectric.annotation.Implements;
27 import org.robolectric.shadow.api.Shadow;
28 
29 @Implements(WifiManager.class)
30 public class ShadowWifiManager extends org.robolectric.shadows.ShadowWifiManager {
31 
32     public WifiConfiguration savedWifiConfig;
33 
34     @HiddenApi // @SystemApi
35     @Implementation
connect(WifiConfiguration config, WifiManager.ActionListener listener)36     public void connect(WifiConfiguration config, WifiManager.ActionListener listener) {
37         savedWifiConfig = config;
38     }
39 
40     @HiddenApi
41     @Implementation
save(WifiConfiguration config, WifiManager.ActionListener listener)42     public void save(WifiConfiguration config, WifiManager.ActionListener listener) {
43         savedWifiConfig = config;
44     }
45 
get()46     public static ShadowWifiManager get() {
47         return Shadow.extract(application.getSystemService(WifiManager.class));
48     }
49 }
50