PasspointObjectFactory.java revision 87c6f1b149804685e46c18d2ad11262f611c9255
1/*
2 * Copyright (C) 2016 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
17package com.android.server.wifi.hotspot2;
18
19import android.net.wifi.hotspot2.PasspointConfiguration;
20
21import com.android.server.wifi.Clock;
22import com.android.server.wifi.SIMAccessor;
23import com.android.server.wifi.WifiKeyStore;
24import com.android.server.wifi.WifiNative;
25
26/**
27 * Factory class for creating Passpoint related objects. Useful for mocking object creations
28 * in the unit tests.
29 */
30public class PasspointObjectFactory{
31    /**
32     * Create a PasspointEventHandler instance.
33     *
34     * @param wifiNative Instance of {@link WifiNative}
35     * @param callbacks Instance of {@link PasspointEventHandler.Callbacks}
36     * @return {@link PasspointEventHandler}
37     */
38    public PasspointEventHandler makePasspointEventHandler(WifiNative wifiNative,
39            PasspointEventHandler.Callbacks callbacks) {
40        return new PasspointEventHandler(wifiNative, callbacks);
41    }
42
43    /**
44     * Create a PasspointProvider instance.
45     *
46     * @param keyStore Instance of {@link WifiKeyStore}
47     * @param config Configuration for the provider
48     * @param providerId Unique identifier for the provider
49     * @return {@link PasspointProvider}
50     */
51    public PasspointProvider makePasspointProvider(PasspointConfiguration config,
52            WifiKeyStore keyStore, SIMAccessor simAccessor, long providerId) {
53        return new PasspointProvider(config, keyStore, simAccessor, providerId);
54    }
55
56    /**
57     * Create a AnqpCache instance.
58     *
59     * @param clock Instance of {@link Clock}
60     * @return {@link AnqpCache}
61     */
62    public AnqpCache makeAnqpCache(Clock clock) {
63        return new AnqpCache(clock);
64    }
65}
66