2 * Copyright (C) 2006 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.internal.telephony.gsm;
19 import com.android.internal.telephony.*;
21 * This class represents a apn setting for create PDP link
23 public class ApnSetting {
35 public String[] types;
40 public 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) {
44 this.numeric = numeric;
45 this.carrier = carrier;
50 this.mmsProxy = mmsProxy;
51 this.mmsPort = mmsPort;
53 this.password = password;
54 this.authType = authType;
71 // data[13] = first type...
72 public static ApnSetting fromString(String data) {
73 if (data == null) return null;
74 String[] a = data.split("\\s*,\\s*");
75 if (a.length < 14) return null;
78 authType = Integer.parseInt(a[12]);
79 } catch (Exception e) {
81 String[] typeArray = new String[a.length - 13];
82 System.arraycopy(a, 13, typeArray, 0, a.length - 13);
83 return new ApnSetting(-1,a[10]+a[11],a[0],a[1],a[2],a[3],a[7],a[8],
84 a[9],a[4],a[5],authType,typeArray);
87 public String toString() {
88 StringBuilder sb = new StringBuilder();
90 .append(", ").append(id)
91 .append(", ").append(numeric)
92 .append(", ").append(apn)
93 .append(", ").append(proxy)
94 .append(", ").append(mmsc)
95 .append(", ").append(mmsProxy)
96 .append(", ").append(mmsPort)
97 .append(", ").append(port)
98 .append(", ").append(authType);
99 for (String t : types) {
100 sb.append(", ").append(t);
102 return sb.toString();
105 public boolean canHandleType(String type) {
106 for (String t : types) {
107 // DEFAULT handles all, and HIPRI is handled by DEFAULT
108 if (t.equals(type) || t.equals(Phone.APN_TYPE_ALL) ||
109 (t.equals(Phone.APN_TYPE_DEFAULT) &&
110 type.equals(Phone.APN_TYPE_HIPRI))) {