1 /*
2  * Copyright (C) 2020 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.server.wifi;
18 
19 import android.annotation.Nullable;
20 import android.net.wifi.WifiManager;
21 import android.os.WorkSource;
22 
23 import java.io.FileDescriptor;
24 import java.io.PrintWriter;
25 
26 /**
27  * This is used for creating a public {@link ClientModeManager} instance when wifi is off.
28  *
29  * Note: this class is currently a singleton as it has no state.
30  */
31 public class DefaultClientModeManager implements ClientModeManager, ClientModeDefaults {
32 
33     private static final long ID = -1;
34 
35     @Override
stop()36     public void stop() {
37         throw new IllegalStateException();
38     }
39 
40     @Override
getRole()41     @Nullable public ClientRole getRole() {
42         return null;
43     }
44 
45     @Override
getPreviousRole()46     @Nullable public ClientRole getPreviousRole() {
47         return null;
48     }
49 
50     @Override
getLastRoleChangeSinceBootMs()51     public long getLastRoleChangeSinceBootMs() {
52         return 0;
53     }
54 
55     @Override
getInterfaceName()56     public String getInterfaceName() {
57         return null;
58     }
59 
60     @Override
getRequestorWs()61     public WorkSource getRequestorWs() {
62         return null;
63     }
64 
65     @Override
dump(FileDescriptor fd, PrintWriter pw, String[] args)66     public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { }
67 
68     @Override
enableVerboseLogging(boolean verbose)69     public void enableVerboseLogging(boolean verbose) { }
70 
71     @Override
syncGetWifiState()72     public int syncGetWifiState() {
73         return WifiManager.WIFI_STATE_DISABLED;
74     }
75 
76     @Override
getId()77     public long getId() {
78         return ID;
79     }
80 
81     @Override
toString()82     public String toString() {
83         return "DefaultClientModeManager{id=" + getId()
84                 + " iface=" + getInterfaceName()
85                 + " role=" + getRole()
86                 + "}";
87     }
88 
89     @Override
getSupportedFeatures()90     public long getSupportedFeatures() {
91         return 0L;
92     }
93 
94     @Override
isWifiStandardSupported(int standard)95     public boolean isWifiStandardSupported(int standard) {
96         return false;
97     }
98 }
99