1/*
2 * Copyright (C) 2006 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.internal.telephony.gsm;
18
19import com.android.internal.telephony.*;
20/**
21 * This class represents a apn setting for create PDP link
22 */
23public class ApnSetting {
24
25    String carrier;
26    String apn;
27    String proxy;
28    String port;
29    String mmsc;
30    String mmsProxy;
31    String mmsPort;
32    String user;
33    String password;
34    int authType;
35    String[] types;
36    int id;
37    String numeric;
38
39
40    ApnSetting(int id, String numeric, String carrier, String apn, String proxy, String port,
41            String mmsc, String mmsProxy, String mmsPort,
42            String user, String password, int authType, String[] types) {
43        this.id = id;
44        this.numeric = numeric;
45        this.carrier = carrier;
46        this.apn = apn;
47        this.proxy = proxy;
48        this.port = port;
49        this.mmsc = mmsc;
50        this.mmsProxy = mmsProxy;
51        this.mmsPort = mmsPort;
52        this.user = user;
53        this.password = password;
54        this.authType = authType;
55        this.types = types;
56    }
57
58    public String toString() {
59        StringBuilder sb = new StringBuilder();
60        sb.append(carrier)
61        .append(", ").append(id)
62        .append(", ").append(numeric)
63        .append(", ").append(apn)
64        .append(", ").append(proxy)
65        .append(", ").append(mmsc)
66        .append(", ").append(mmsProxy)
67        .append(", ").append(mmsPort)
68        .append(", ").append(port)
69        .append(", ").append(authType);
70        for (String t : types) {
71            sb.append(", ").append(t);
72        }
73        return sb.toString();
74    }
75
76    boolean canHandleType(String type) {
77        for (String t : types) {
78            // DEFAULT handles all, and HIPRI is handled by DEFAULT
79            if (t.equals(type) || t.equals(Phone.APN_TYPE_ALL) ||
80                    (t.equals(Phone.APN_TYPE_DEFAULT) &&
81                    type.equals(Phone.APN_TYPE_HIPRI))) {
82                return true;
83            }
84        }
85        return false;
86    }
87}
88