1/*
2 * Copyright (C) 2014 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.mms.service.http;
18
19import org.apache.http.conn.ClientConnectionOperator;
20import org.apache.http.conn.scheme.SchemeRegistry;
21import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
22import org.apache.http.params.HttpParams;
23
24/**
25 * This is a subclass of {@link org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager}
26 * which allows us to specify a custom name resolver and the address type
27 */
28public class NetworkAwareThreadSafeClientConnManager extends ThreadSafeClientConnManager {
29    public NetworkAwareThreadSafeClientConnManager(HttpParams params,
30            SchemeRegistry schreg, NameResolver resolver, boolean shouldUseIpv6) {
31        super(params, schreg);
32        ((NetworkAwareClientConnectionOperator)connOperator).setNameResolver(resolver);
33        ((NetworkAwareClientConnectionOperator)connOperator).setShouldUseIpv6(shouldUseIpv6);
34    }
35
36    @Override
37    protected ClientConnectionOperator createConnectionOperator(SchemeRegistry schreg) {
38        return new NetworkAwareClientConnectionOperator(schreg);
39    }
40}
41