Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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 | |
| 17 | package android.net; |
| 18 | |
Jeff Sharkey | 02e21d6 | 2011-07-17 15:53:33 -0700 | [diff] [blame] | 19 | import static android.net.ConnectivityManager.TYPE_ETHERNET; |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 20 | import static android.net.ConnectivityManager.TYPE_WIFI; |
Jeff Sharkey | 3ca7481 | 2012-01-24 15:37:07 -0800 | [diff] [blame] | 21 | import static android.net.ConnectivityManager.TYPE_WIFI_P2P; |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 22 | import static android.net.ConnectivityManager.TYPE_WIMAX; |
Jeff Sharkey | d4dd771 | 2012-03-16 11:11:54 -0700 | [diff] [blame] | 23 | import static android.net.NetworkIdentity.COMBINE_SUBTYPE_ENABLED; |
Jeff Sharkey | 02e21d6 | 2011-07-17 15:53:33 -0700 | [diff] [blame] | 24 | import static android.net.NetworkIdentity.scrubSubscriberId; |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 25 | import static android.telephony.TelephonyManager.NETWORK_CLASS_2_G; |
| 26 | import static android.telephony.TelephonyManager.NETWORK_CLASS_3_G; |
| 27 | import static android.telephony.TelephonyManager.NETWORK_CLASS_4_G; |
| 28 | import static android.telephony.TelephonyManager.NETWORK_CLASS_UNKNOWN; |
| 29 | import static android.telephony.TelephonyManager.getNetworkClass; |
Jeff Sharkey | 630a171 | 2011-09-26 10:47:10 -0700 | [diff] [blame] | 30 | import static com.android.internal.util.ArrayUtils.contains; |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 31 | |
Jeff Sharkey | 630a171 | 2011-09-26 10:47:10 -0700 | [diff] [blame] | 32 | import android.content.res.Resources; |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 33 | import android.os.Parcel; |
| 34 | import android.os.Parcelable; |
| 35 | |
| 36 | import com.android.internal.util.Objects; |
| 37 | |
| 38 | /** |
| 39 | * Template definition used to generically match {@link NetworkIdentity}, |
| 40 | * usually when collecting statistics. |
| 41 | * |
| 42 | * @hide |
| 43 | */ |
| 44 | public class NetworkTemplate implements Parcelable { |
| 45 | |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 46 | public static final int MATCH_MOBILE_ALL = 1; |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 47 | public static final int MATCH_MOBILE_3G_LOWER = 2; |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 48 | public static final int MATCH_MOBILE_4G = 3; |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 49 | public static final int MATCH_WIFI = 4; |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 50 | public static final int MATCH_ETHERNET = 5; |
| 51 | |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 52 | /** |
Jeff Sharkey | 630a171 | 2011-09-26 10:47:10 -0700 | [diff] [blame] | 53 | * Set of {@link NetworkInfo#getType()} that reflect data usage. |
| 54 | */ |
| 55 | private static final int[] DATA_USAGE_NETWORK_TYPES; |
| 56 | |
| 57 | static { |
| 58 | DATA_USAGE_NETWORK_TYPES = Resources.getSystem().getIntArray( |
| 59 | com.android.internal.R.array.config_data_usage_network_types); |
| 60 | } |
| 61 | |
| 62 | /** |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 63 | * Template to match {@link ConnectivityManager#TYPE_MOBILE} networks with |
| 64 | * the given IMSI. |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 65 | */ |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 66 | public static NetworkTemplate buildTemplateMobileAll(String subscriberId) { |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 67 | return new NetworkTemplate(MATCH_MOBILE_ALL, subscriberId, null); |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 68 | } |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 69 | |
| 70 | /** |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 71 | * Template to match {@link ConnectivityManager#TYPE_MOBILE} networks with |
| 72 | * the given IMSI that roughly meet a "3G" definition, or lower. |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 73 | */ |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 74 | @Deprecated |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 75 | public static NetworkTemplate buildTemplateMobile3gLower(String subscriberId) { |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 76 | return new NetworkTemplate(MATCH_MOBILE_3G_LOWER, subscriberId, null); |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 77 | } |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 78 | |
| 79 | /** |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 80 | * Template to match {@link ConnectivityManager#TYPE_MOBILE} networks with |
| 81 | * the given IMSI that roughly meet a "4G" definition. |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 82 | */ |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 83 | @Deprecated |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 84 | public static NetworkTemplate buildTemplateMobile4g(String subscriberId) { |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 85 | return new NetworkTemplate(MATCH_MOBILE_4G, subscriberId, null); |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 86 | } |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 87 | |
| 88 | /** |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 89 | * Template to match all {@link ConnectivityManager#TYPE_WIFI} networks, |
| 90 | * regardless of SSID. |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 91 | */ |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 92 | public static NetworkTemplate buildTemplateWifiWildcard() { |
| 93 | return new NetworkTemplate(MATCH_WIFI, null, null); |
| 94 | } |
| 95 | |
| 96 | @Deprecated |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 97 | public static NetworkTemplate buildTemplateWifi() { |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 98 | return buildTemplateWifiWildcard(); |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Template to match {@link ConnectivityManager#TYPE_WIFI} networks with the |
| 103 | * given SSID. |
| 104 | */ |
| 105 | public static NetworkTemplate buildTemplateWifi(String networkId) { |
| 106 | return new NetworkTemplate(MATCH_WIFI, null, networkId); |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 107 | } |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 108 | |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 109 | /** |
| 110 | * Template to combine all {@link ConnectivityManager#TYPE_ETHERNET} style |
| 111 | * networks together. |
| 112 | */ |
| 113 | public static NetworkTemplate buildTemplateEthernet() { |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 114 | return new NetworkTemplate(MATCH_ETHERNET, null, null); |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 115 | } |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 116 | |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 117 | private final int mMatchRule; |
| 118 | private final String mSubscriberId; |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 119 | private final String mNetworkId; |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 120 | |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 121 | public NetworkTemplate(int matchRule, String subscriberId, String networkId) { |
| 122 | mMatchRule = matchRule; |
| 123 | mSubscriberId = subscriberId; |
| 124 | mNetworkId = networkId; |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 125 | } |
| 126 | |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 127 | private NetworkTemplate(Parcel in) { |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 128 | mMatchRule = in.readInt(); |
| 129 | mSubscriberId = in.readString(); |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 130 | mNetworkId = in.readString(); |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 131 | } |
| 132 | |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 133 | @Override |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 134 | public void writeToParcel(Parcel dest, int flags) { |
| 135 | dest.writeInt(mMatchRule); |
| 136 | dest.writeString(mSubscriberId); |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 137 | dest.writeString(mNetworkId); |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 138 | } |
| 139 | |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 140 | @Override |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 141 | public int describeContents() { |
| 142 | return 0; |
| 143 | } |
| 144 | |
| 145 | @Override |
| 146 | public String toString() { |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 147 | final StringBuilder builder = new StringBuilder("NetworkTemplate: "); |
| 148 | builder.append("matchRule=").append(getMatchRuleName(mMatchRule)); |
| 149 | if (mSubscriberId != null) { |
| 150 | builder.append(", subscriberId=").append(scrubSubscriberId(mSubscriberId)); |
| 151 | } |
| 152 | if (mNetworkId != null) { |
| 153 | builder.append(", networkId=").append(mNetworkId); |
| 154 | } |
| 155 | return builder.toString(); |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | @Override |
| 159 | public int hashCode() { |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 160 | return Objects.hashCode(mMatchRule, mSubscriberId, mNetworkId); |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | @Override |
| 164 | public boolean equals(Object obj) { |
| 165 | if (obj instanceof NetworkTemplate) { |
| 166 | final NetworkTemplate other = (NetworkTemplate) obj; |
| 167 | return mMatchRule == other.mMatchRule |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 168 | && Objects.equal(mSubscriberId, other.mSubscriberId) |
| 169 | && Objects.equal(mNetworkId, other.mNetworkId); |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 170 | } |
| 171 | return false; |
| 172 | } |
| 173 | |
| 174 | public int getMatchRule() { |
| 175 | return mMatchRule; |
| 176 | } |
| 177 | |
| 178 | public String getSubscriberId() { |
| 179 | return mSubscriberId; |
| 180 | } |
| 181 | |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 182 | public String getNetworkId() { |
| 183 | return mNetworkId; |
| 184 | } |
| 185 | |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 186 | /** |
Jeff Sharkey | 630a171 | 2011-09-26 10:47:10 -0700 | [diff] [blame] | 187 | * Test if given {@link NetworkIdentity} matches this template. |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 188 | */ |
| 189 | public boolean matches(NetworkIdentity ident) { |
| 190 | switch (mMatchRule) { |
| 191 | case MATCH_MOBILE_ALL: |
| 192 | return matchesMobile(ident); |
| 193 | case MATCH_MOBILE_3G_LOWER: |
| 194 | return matchesMobile3gLower(ident); |
| 195 | case MATCH_MOBILE_4G: |
| 196 | return matchesMobile4g(ident); |
| 197 | case MATCH_WIFI: |
| 198 | return matchesWifi(ident); |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 199 | case MATCH_ETHERNET: |
| 200 | return matchesEthernet(ident); |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 201 | default: |
| 202 | throw new IllegalArgumentException("unknown network template"); |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | /** |
Jeff Sharkey | 630a171 | 2011-09-26 10:47:10 -0700 | [diff] [blame] | 207 | * Check if mobile network with matching IMSI. |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 208 | */ |
| 209 | private boolean matchesMobile(NetworkIdentity ident) { |
Jeff Sharkey | 630a171 | 2011-09-26 10:47:10 -0700 | [diff] [blame] | 210 | if (ident.mType == TYPE_WIMAX) { |
| 211 | // TODO: consider matching against WiMAX subscriber identity |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 212 | return true; |
Jeff Sharkey | 630a171 | 2011-09-26 10:47:10 -0700 | [diff] [blame] | 213 | } else { |
| 214 | return (contains(DATA_USAGE_NETWORK_TYPES, ident.mType) |
| 215 | && Objects.equal(mSubscriberId, ident.mSubscriberId)); |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 216 | } |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | /** |
Jeff Sharkey | 02e21d6 | 2011-07-17 15:53:33 -0700 | [diff] [blame] | 220 | * Check if mobile network classified 3G or lower with matching IMSI. |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 221 | */ |
| 222 | private boolean matchesMobile3gLower(NetworkIdentity ident) { |
Jeff Sharkey | d4dd771 | 2012-03-16 11:11:54 -0700 | [diff] [blame] | 223 | ensureSubtypeAvailable(); |
Jeff Sharkey | 630a171 | 2011-09-26 10:47:10 -0700 | [diff] [blame] | 224 | if (ident.mType == TYPE_WIMAX) { |
| 225 | return false; |
| 226 | } else if (matchesMobile(ident)) { |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 227 | switch (getNetworkClass(ident.mSubType)) { |
| 228 | case NETWORK_CLASS_UNKNOWN: |
| 229 | case NETWORK_CLASS_2_G: |
| 230 | case NETWORK_CLASS_3_G: |
| 231 | return true; |
| 232 | } |
| 233 | } |
| 234 | return false; |
| 235 | } |
| 236 | |
| 237 | /** |
Jeff Sharkey | 630a171 | 2011-09-26 10:47:10 -0700 | [diff] [blame] | 238 | * Check if mobile network classified 4G with matching IMSI. |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 239 | */ |
| 240 | private boolean matchesMobile4g(NetworkIdentity ident) { |
Jeff Sharkey | d4dd771 | 2012-03-16 11:11:54 -0700 | [diff] [blame] | 241 | ensureSubtypeAvailable(); |
Jeff Sharkey | 630a171 | 2011-09-26 10:47:10 -0700 | [diff] [blame] | 242 | if (ident.mType == TYPE_WIMAX) { |
| 243 | // TODO: consider matching against WiMAX subscriber identity |
| 244 | return true; |
| 245 | } else if (matchesMobile(ident)) { |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 246 | switch (getNetworkClass(ident.mSubType)) { |
| 247 | case NETWORK_CLASS_4_G: |
| 248 | return true; |
| 249 | } |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 250 | } |
| 251 | return false; |
| 252 | } |
| 253 | |
| 254 | /** |
| 255 | * Check if matches Wi-Fi network template. |
| 256 | */ |
| 257 | private boolean matchesWifi(NetworkIdentity ident) { |
Jeff Sharkey | 3ca7481 | 2012-01-24 15:37:07 -0800 | [diff] [blame] | 258 | switch (ident.mType) { |
| 259 | case TYPE_WIFI: |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 260 | if (mNetworkId == null) { |
| 261 | return true; |
| 262 | } else { |
| 263 | return Objects.equal(mNetworkId, ident.mNetworkId); |
| 264 | } |
Jeff Sharkey | 3ca7481 | 2012-01-24 15:37:07 -0800 | [diff] [blame] | 265 | case TYPE_WIFI_P2P: |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 266 | return mNetworkId == null; |
Jeff Sharkey | 3ca7481 | 2012-01-24 15:37:07 -0800 | [diff] [blame] | 267 | default: |
| 268 | return false; |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 269 | } |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 270 | } |
| 271 | |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 272 | /** |
| 273 | * Check if matches Ethernet network template. |
| 274 | */ |
| 275 | private boolean matchesEthernet(NetworkIdentity ident) { |
| 276 | if (ident.mType == TYPE_ETHERNET) { |
| 277 | return true; |
| 278 | } |
| 279 | return false; |
| 280 | } |
| 281 | |
| 282 | private static String getMatchRuleName(int matchRule) { |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 283 | switch (matchRule) { |
| 284 | case MATCH_MOBILE_3G_LOWER: |
| 285 | return "MOBILE_3G_LOWER"; |
| 286 | case MATCH_MOBILE_4G: |
| 287 | return "MOBILE_4G"; |
| 288 | case MATCH_MOBILE_ALL: |
| 289 | return "MOBILE_ALL"; |
| 290 | case MATCH_WIFI: |
| 291 | return "WIFI"; |
Jeff Sharkey | 4e814c3 | 2011-07-14 20:37:37 -0700 | [diff] [blame] | 292 | case MATCH_ETHERNET: |
| 293 | return "ETHERNET"; |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 294 | default: |
| 295 | return "UNKNOWN"; |
| 296 | } |
| 297 | } |
| 298 | |
Jeff Sharkey | d4dd771 | 2012-03-16 11:11:54 -0700 | [diff] [blame] | 299 | private static void ensureSubtypeAvailable() { |
| 300 | if (COMBINE_SUBTYPE_ENABLED) { |
| 301 | throw new IllegalArgumentException( |
| 302 | "Unable to enforce 3G_LOWER template on combined data."); |
| 303 | } |
| 304 | } |
| 305 | |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 306 | public static final Creator<NetworkTemplate> CREATOR = new Creator<NetworkTemplate>() { |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 307 | @Override |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 308 | public NetworkTemplate createFromParcel(Parcel in) { |
| 309 | return new NetworkTemplate(in); |
| 310 | } |
| 311 | |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame^] | 312 | @Override |
Jeff Sharkey | 1b5a2a9 | 2011-06-18 18:34:16 -0700 | [diff] [blame] | 313 | public NetworkTemplate[] newArray(int size) { |
| 314 | return new NetworkTemplate[size]; |
| 315 | } |
| 316 | }; |
| 317 | } |