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, int creatorUid) {
53        return new PasspointProvider(config, keyStore, simAccessor, providerId, creatorUid);
54    }
55
56    /**
57     * Create a {@link PasspointConfigStoreData} instance.
58     *
59     * @param keyStore Instance of {@link WifiKeyStore}
60     * @param simAccessor Instance of {@link SIMAccessor}
61     * @param dataSource Passpoint configuration data source
62     * @return {@link PasspointConfigStoreData}
63     */
64    public PasspointConfigStoreData makePasspointConfigStoreData(WifiKeyStore keyStore,
65            SIMAccessor simAccessor, PasspointConfigStoreData.DataSource dataSource) {
66        return new PasspointConfigStoreData(keyStore, simAccessor, dataSource);
67    }
68
69    /**
70     * Create a AnqpCache instance.
71     *
72     * @param clock Instance of {@link Clock}
73     * @return {@link AnqpCache}
74     */
75    public AnqpCache makeAnqpCache(Clock clock) {
76        return new AnqpCache(clock);
77    }
78
79    /**
80     * Create an instance of {@link ANQPRequestManager}.
81     *
82     * @param handler Instance of {@link PasspointEventHandler}
83     * @param clock Instance of {@link Clock}
84     * @return {@link ANQPRequestManager}
85     */
86    public ANQPRequestManager makeANQPRequestManager(PasspointEventHandler handler, Clock clock) {
87        return new ANQPRequestManager(handler, clock);
88    }
89
90    /**
91     * Create an instance of {@link CertificateVerifier}.
92     *
93     * @return {@link CertificateVerifier}
94     */
95    public CertificateVerifier makeCertificateVerifier() {
96        return new CertificateVerifier();
97    }
98}
99