FrameworkFacade.java revision 8013a9b65375608d80606780e9e1b313576a0f80
1
2package com.android.server.wifi;
3
4import android.app.PendingIntent;
5import android.content.Context;
6import android.content.Intent;
7import android.net.TrafficStats;
8import android.net.ip.IpManager;
9import android.os.Handler;
10import android.os.IBinder;
11import android.os.ServiceManager;
12import android.provider.Settings;
13
14import com.android.internal.util.StateMachine;
15import com.android.server.wifi.hotspot2.SupplicantBridge;
16import com.android.server.wifi.hotspot2.omadm.MOManager;
17import com.android.server.wifi.hotspot2.osu.OSUManager;
18
19/**
20 * This class allows overriding objects with mocks to write unit tests
21 */
22public class FrameworkFacade {
23    public static final String TAG = "FrameworkFacade";
24
25    public BaseWifiLogger makeBaseLogger() {
26        return new BaseWifiLogger();
27    }
28
29    public BaseWifiLogger makeRealLogger(WifiStateMachine stateMachine, WifiNative wifiNative) {
30        return new WifiLogger(stateMachine, wifiNative);
31    }
32
33    public int getIntegerSetting(Context context, String name, int def) {
34        return Settings.Global.getInt(context.getContentResolver(), name, def);
35    }
36
37    public long getLongSetting(Context context, String name, long def) {
38        return Settings.Global.getLong(context.getContentResolver(), name, def);
39    }
40
41    public String getStringSetting(Context context, String name) {
42        return Settings.Global.getString(context.getContentResolver(), name);
43    }
44
45    public IBinder getService(String serviceName) {
46        return ServiceManager.getService(serviceName);
47    }
48
49    public PendingIntent getBroadcast(Context context, int requestCode, Intent intent, int flags) {
50        return PendingIntent.getBroadcast(context, requestCode, intent, flags);
51    }
52
53    public OSUManager makeOsuManager(WifiConfigStore wifiConfigStore, Context context,
54             SupplicantBridge supplicantBridge, MOManager moManager,
55             WifiStateMachine wifiStateMachine) {
56        return new OSUManager(wifiConfigStore, context,
57                supplicantBridge, moManager, wifiStateMachine);
58    }
59
60    public SupplicantStateTracker makeSupplicantStateTracker(Context context,
61             WifiStateMachine wifiStateMachine, WifiConfigStore configStore, Handler handler) {
62        return new SupplicantStateTracker(context, wifiStateMachine, configStore, handler);
63    }
64
65    public WifiApConfigStore makeApConfigStore(Context context) {
66        return new WifiApConfigStore(context);
67    }
68
69    public long getTxPackets(String iface) {
70        return TrafficStats.getTxPackets(iface);
71    }
72
73    public long getRxPackets(String iface) {
74        return TrafficStats.getRxPackets(iface);
75    }
76
77    public IpManager makeIpManager(
78            Context context, String iface, IpManager.Callback callback) {
79        return new IpManager(context, iface, callback);
80    }
81}
82
83