11b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey/* 21b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey * Copyright (C) 2011 The Android Open Source Project 31b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey * 41b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey * Licensed under the Apache License, Version 2.0 (the "License"); 51b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey * you may not use this file except in compliance with the License. 61b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey * You may obtain a copy of the License at 71b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey * 81b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey * http://www.apache.org/licenses/LICENSE-2.0 91b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey * 101b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey * Unless required by applicable law or agreed to in writing, software 111b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey * distributed under the License is distributed on an "AS IS" BASIS, 121b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey * See the License for the specific language governing permissions and 141b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey * limitations under the License. 151b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey */ 161b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 171b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkeypackage android.net; 181b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 1955a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkeyimport static android.net.ConnectivityManager.TYPE_BLUETOOTH; 2002e21d6a5b5117d494777a36783909854854f751Jeff Sharkeyimport static android.net.ConnectivityManager.TYPE_ETHERNET; 211b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkeyimport static android.net.ConnectivityManager.TYPE_WIFI; 223ca7481439c9b65a137d7705d0f4a16766529e75Jeff Sharkeyimport static android.net.ConnectivityManager.TYPE_WIFI_P2P; 231b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkeyimport static android.net.ConnectivityManager.TYPE_WIMAX; 24d4dd7716fb825f29a609c5c4cb31204eea78183aJeff Sharkeyimport static android.net.NetworkIdentity.COMBINE_SUBTYPE_ENABLED; 252e4dce0dd24aa89ca6adf6559f13d3e342ff8558Jeff Sharkeyimport static android.net.wifi.WifiInfo.removeDoubleQuotes; 261b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkeyimport static android.telephony.TelephonyManager.NETWORK_CLASS_2_G; 271b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkeyimport static android.telephony.TelephonyManager.NETWORK_CLASS_3_G; 281b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkeyimport static android.telephony.TelephonyManager.NETWORK_CLASS_4_G; 291b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkeyimport static android.telephony.TelephonyManager.NETWORK_CLASS_UNKNOWN; 301b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkeyimport static android.telephony.TelephonyManager.getNetworkClass; 31630a1712168f402653039e368259cb9480454fa8Jeff Sharkeyimport static com.android.internal.util.ArrayUtils.contains; 321b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 33630a1712168f402653039e368259cb9480454fa8Jeff Sharkeyimport android.content.res.Resources; 341b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkeyimport android.os.Parcel; 351b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkeyimport android.os.Parcelable; 361b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 378b2c3a14603d163d7564e6f60286995079687690Jeff Sharkeyimport com.android.internal.annotations.VisibleForTesting; 383256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkeyimport com.android.internal.util.ArrayUtils; 391b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 403256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkeyimport java.util.Arrays; 4155a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkeyimport java.util.Objects; 4255a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey 431b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey/** 441b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey * Template definition used to generically match {@link NetworkIdentity}, 451b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey * usually when collecting statistics. 461b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey * 471b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey * @hide 481b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey */ 491b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkeypublic class NetworkTemplate implements Parcelable { 501b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 514e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey public static final int MATCH_MOBILE_ALL = 1; 526973634ce61ab7d4c1d51c70be6d51725b89e7b9Jeff Sharkey @Deprecated 534e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey public static final int MATCH_MOBILE_3G_LOWER = 2; 546973634ce61ab7d4c1d51c70be6d51725b89e7b9Jeff Sharkey @Deprecated 554e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey public static final int MATCH_MOBILE_4G = 3; 564e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey public static final int MATCH_WIFI = 4; 574e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey public static final int MATCH_ETHERNET = 5; 58234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey public static final int MATCH_MOBILE_WILDCARD = 6; 59234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey public static final int MATCH_WIFI_WILDCARD = 7; 6055a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey public static final int MATCH_BLUETOOTH = 8; 614e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey 621b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey /** 63630a1712168f402653039e368259cb9480454fa8Jeff Sharkey * Set of {@link NetworkInfo#getType()} that reflect data usage. 64630a1712168f402653039e368259cb9480454fa8Jeff Sharkey */ 65630a1712168f402653039e368259cb9480454fa8Jeff Sharkey private static final int[] DATA_USAGE_NETWORK_TYPES; 66630a1712168f402653039e368259cb9480454fa8Jeff Sharkey 67630a1712168f402653039e368259cb9480454fa8Jeff Sharkey static { 68630a1712168f402653039e368259cb9480454fa8Jeff Sharkey DATA_USAGE_NETWORK_TYPES = Resources.getSystem().getIntArray( 69630a1712168f402653039e368259cb9480454fa8Jeff Sharkey com.android.internal.R.array.config_data_usage_network_types); 70630a1712168f402653039e368259cb9480454fa8Jeff Sharkey } 71630a1712168f402653039e368259cb9480454fa8Jeff Sharkey 7270c70530bd6793869736ec894498e4ebf5dc9b20Jeff Sharkey private static boolean sForceAllNetworkTypes = false; 7370c70530bd6793869736ec894498e4ebf5dc9b20Jeff Sharkey 748b2c3a14603d163d7564e6f60286995079687690Jeff Sharkey @VisibleForTesting 7570c70530bd6793869736ec894498e4ebf5dc9b20Jeff Sharkey public static void forceAllNetworkTypes() { 7670c70530bd6793869736ec894498e4ebf5dc9b20Jeff Sharkey sForceAllNetworkTypes = true; 7770c70530bd6793869736ec894498e4ebf5dc9b20Jeff Sharkey } 7870c70530bd6793869736ec894498e4ebf5dc9b20Jeff Sharkey 79630a1712168f402653039e368259cb9480454fa8Jeff Sharkey /** 808fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey * Template to match {@link ConnectivityManager#TYPE_MOBILE} networks with 818fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey * the given IMSI. 821b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey */ 834e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey public static NetworkTemplate buildTemplateMobileAll(String subscriberId) { 848fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey return new NetworkTemplate(MATCH_MOBILE_ALL, subscriberId, null); 854e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey } 861b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 871b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey /** 888fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey * Template to match {@link ConnectivityManager#TYPE_MOBILE} networks with 898fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey * the given IMSI that roughly meet a "3G" definition, or lower. 901b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey */ 918fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey @Deprecated 924e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey public static NetworkTemplate buildTemplateMobile3gLower(String subscriberId) { 938fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey return new NetworkTemplate(MATCH_MOBILE_3G_LOWER, subscriberId, null); 944e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey } 951b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 961b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey /** 978fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey * Template to match {@link ConnectivityManager#TYPE_MOBILE} networks with 988fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey * the given IMSI that roughly meet a "4G" definition. 991b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey */ 1008fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey @Deprecated 1014e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey public static NetworkTemplate buildTemplateMobile4g(String subscriberId) { 1028fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey return new NetworkTemplate(MATCH_MOBILE_4G, subscriberId, null); 1034e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey } 1041b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 1051b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey /** 106234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey * Template to match {@link ConnectivityManager#TYPE_MOBILE} networks, 107234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey * regardless of IMSI. 108234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey */ 109234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey public static NetworkTemplate buildTemplateMobileWildcard() { 110234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey return new NetworkTemplate(MATCH_MOBILE_WILDCARD, null, null); 111234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey } 112234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey 113234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey /** 1148fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey * Template to match all {@link ConnectivityManager#TYPE_WIFI} networks, 1158fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey * regardless of SSID. 1161b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey */ 1178fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey public static NetworkTemplate buildTemplateWifiWildcard() { 118234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey return new NetworkTemplate(MATCH_WIFI_WILDCARD, null, null); 1198fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey } 1208fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey 1218fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey @Deprecated 1224e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey public static NetworkTemplate buildTemplateWifi() { 1238fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey return buildTemplateWifiWildcard(); 1248fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey } 1258fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey 1268fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey /** 1278fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey * Template to match {@link ConnectivityManager#TYPE_WIFI} networks with the 1288fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey * given SSID. 1298fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey */ 1308fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey public static NetworkTemplate buildTemplateWifi(String networkId) { 1318fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey return new NetworkTemplate(MATCH_WIFI, null, networkId); 1324e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey } 1331b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 1344e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey /** 1354e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey * Template to combine all {@link ConnectivityManager#TYPE_ETHERNET} style 1364e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey * networks together. 1374e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey */ 1384e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey public static NetworkTemplate buildTemplateEthernet() { 1398fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey return new NetworkTemplate(MATCH_ETHERNET, null, null); 1404e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey } 1414e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey 14255a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey /** 14355a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey * Template to combine all {@link ConnectivityManager#TYPE_BLUETOOTH} style 14455a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey * networks together. 14555a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey */ 14655a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey public static NetworkTemplate buildTemplateBluetooth() { 14755a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey return new NetworkTemplate(MATCH_BLUETOOTH, null, null); 14855a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey } 14955a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey 1504e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey private final int mMatchRule; 1514e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey private final String mSubscriberId; 1523256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey 1533256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey /** 1543256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey * Ugh, templates are designed to target a single subscriber, but we might 1553256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey * need to match several "merged" subscribers. These are the subscribers 1563256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey * that should be considered to match this template. 1573256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey * <p> 1583256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey * Since the merge set is dynamic, it should <em>not</em> be persisted or 1593256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey * used for determining equality. 1603256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey */ 1613256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey private final String[] mMatchSubscriberIds; 1623256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey 1638fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey private final String mNetworkId; 1641b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 1658fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey public NetworkTemplate(int matchRule, String subscriberId, String networkId) { 1663256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey this(matchRule, subscriberId, new String[] { subscriberId }, networkId); 1673256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey } 1683256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey 1693256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey public NetworkTemplate(int matchRule, String subscriberId, String[] matchSubscriberIds, 1703256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey String networkId) { 1718fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey mMatchRule = matchRule; 1728fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey mSubscriberId = subscriberId; 1733256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey mMatchSubscriberIds = matchSubscriberIds; 1748fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey mNetworkId = networkId; 1751b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 1761b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 1774e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey private NetworkTemplate(Parcel in) { 1781b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey mMatchRule = in.readInt(); 1791b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey mSubscriberId = in.readString(); 1803256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey mMatchSubscriberIds = in.createStringArray(); 1818fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey mNetworkId = in.readString(); 1821b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 1831b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 1848fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey @Override 1851b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey public void writeToParcel(Parcel dest, int flags) { 1861b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey dest.writeInt(mMatchRule); 1871b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey dest.writeString(mSubscriberId); 1883256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey dest.writeStringArray(mMatchSubscriberIds); 1898fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey dest.writeString(mNetworkId); 1901b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 1911b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 1928fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey @Override 1931b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey public int describeContents() { 1941b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return 0; 1951b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 1961b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 1971b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey @Override 1981b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey public String toString() { 1998fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey final StringBuilder builder = new StringBuilder("NetworkTemplate: "); 2008fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey builder.append("matchRule=").append(getMatchRuleName(mMatchRule)); 2018fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey if (mSubscriberId != null) { 2023256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey builder.append(", subscriberId=").append( 2033256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey NetworkIdentity.scrubSubscriberId(mSubscriberId)); 2043256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey } 2053256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey if (mMatchSubscriberIds != null) { 2063256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey builder.append(", matchSubscriberIds=").append( 2073256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey Arrays.toString(NetworkIdentity.scrubSubscriberId(mMatchSubscriberIds))); 2088fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey } 2098fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey if (mNetworkId != null) { 2108fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey builder.append(", networkId=").append(mNetworkId); 2118fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey } 2128fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey return builder.toString(); 2131b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 2141b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 2151b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey @Override 2161b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey public int hashCode() { 217e6585b32ea586743258a5457e2184ffc087f2d2fKenny Root return Objects.hash(mMatchRule, mSubscriberId, mNetworkId); 2181b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 2191b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 2201b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey @Override 2211b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey public boolean equals(Object obj) { 2221b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey if (obj instanceof NetworkTemplate) { 2231b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey final NetworkTemplate other = (NetworkTemplate) obj; 2241b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return mMatchRule == other.mMatchRule 225e6585b32ea586743258a5457e2184ffc087f2d2fKenny Root && Objects.equals(mSubscriberId, other.mSubscriberId) 226e6585b32ea586743258a5457e2184ffc087f2d2fKenny Root && Objects.equals(mNetworkId, other.mNetworkId); 2271b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 2281b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return false; 2291b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 2301b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 2313256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey public boolean isMatchRuleMobile() { 2323256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey switch (mMatchRule) { 2333256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey case MATCH_MOBILE_3G_LOWER: 2343256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey case MATCH_MOBILE_4G: 2353256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey case MATCH_MOBILE_ALL: 2363256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey case MATCH_MOBILE_WILDCARD: 2373256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey return true; 2383256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey default: 2393256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey return false; 2403256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey } 2413256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey } 2423256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey 2431b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey public int getMatchRule() { 2441b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return mMatchRule; 2451b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 2461b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 2471b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey public String getSubscriberId() { 2481b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return mSubscriberId; 2491b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 2501b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 2518fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey public String getNetworkId() { 2528fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey return mNetworkId; 2538fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey } 2548fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey 2551b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey /** 256630a1712168f402653039e368259cb9480454fa8Jeff Sharkey * Test if given {@link NetworkIdentity} matches this template. 2571b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey */ 2581b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey public boolean matches(NetworkIdentity ident) { 2591b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey switch (mMatchRule) { 2601b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey case MATCH_MOBILE_ALL: 2611b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return matchesMobile(ident); 2621b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey case MATCH_MOBILE_3G_LOWER: 2631b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return matchesMobile3gLower(ident); 2641b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey case MATCH_MOBILE_4G: 2651b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return matchesMobile4g(ident); 2661b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey case MATCH_WIFI: 2671b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return matchesWifi(ident); 2684e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey case MATCH_ETHERNET: 2694e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey return matchesEthernet(ident); 270234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey case MATCH_MOBILE_WILDCARD: 271234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey return matchesMobileWildcard(ident); 272234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey case MATCH_WIFI_WILDCARD: 273234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey return matchesWifiWildcard(ident); 27455a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey case MATCH_BLUETOOTH: 27555a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey return matchesBluetooth(ident); 2761b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey default: 2771b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey throw new IllegalArgumentException("unknown network template"); 2781b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 2791b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 2801b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 2811b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey /** 282630a1712168f402653039e368259cb9480454fa8Jeff Sharkey * Check if mobile network with matching IMSI. 2831b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey */ 2841b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey private boolean matchesMobile(NetworkIdentity ident) { 285630a1712168f402653039e368259cb9480454fa8Jeff Sharkey if (ident.mType == TYPE_WIMAX) { 286630a1712168f402653039e368259cb9480454fa8Jeff Sharkey // TODO: consider matching against WiMAX subscriber identity 2871b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return true; 288630a1712168f402653039e368259cb9480454fa8Jeff Sharkey } else { 2893256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey final boolean matchesType = (sForceAllNetworkTypes 2903256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey || contains(DATA_USAGE_NETWORK_TYPES, ident.mType)); 2913256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey return matchesType && ArrayUtils.contains(mMatchSubscriberIds, ident.mSubscriberId); 2921b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 2931b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 2941b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 2951b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey /** 29602e21d6a5b5117d494777a36783909854854f751Jeff Sharkey * Check if mobile network classified 3G or lower with matching IMSI. 2971b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey */ 2986973634ce61ab7d4c1d51c70be6d51725b89e7b9Jeff Sharkey @Deprecated 2991b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey private boolean matchesMobile3gLower(NetworkIdentity ident) { 300d4dd7716fb825f29a609c5c4cb31204eea78183aJeff Sharkey ensureSubtypeAvailable(); 301630a1712168f402653039e368259cb9480454fa8Jeff Sharkey if (ident.mType == TYPE_WIMAX) { 302630a1712168f402653039e368259cb9480454fa8Jeff Sharkey return false; 303630a1712168f402653039e368259cb9480454fa8Jeff Sharkey } else if (matchesMobile(ident)) { 3041b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey switch (getNetworkClass(ident.mSubType)) { 3051b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey case NETWORK_CLASS_UNKNOWN: 3061b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey case NETWORK_CLASS_2_G: 3071b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey case NETWORK_CLASS_3_G: 3081b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return true; 3091b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 3101b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 3111b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return false; 3121b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 3131b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 3141b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey /** 315630a1712168f402653039e368259cb9480454fa8Jeff Sharkey * Check if mobile network classified 4G with matching IMSI. 3161b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey */ 3176973634ce61ab7d4c1d51c70be6d51725b89e7b9Jeff Sharkey @Deprecated 3181b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey private boolean matchesMobile4g(NetworkIdentity ident) { 319d4dd7716fb825f29a609c5c4cb31204eea78183aJeff Sharkey ensureSubtypeAvailable(); 320630a1712168f402653039e368259cb9480454fa8Jeff Sharkey if (ident.mType == TYPE_WIMAX) { 321630a1712168f402653039e368259cb9480454fa8Jeff Sharkey // TODO: consider matching against WiMAX subscriber identity 322630a1712168f402653039e368259cb9480454fa8Jeff Sharkey return true; 323630a1712168f402653039e368259cb9480454fa8Jeff Sharkey } else if (matchesMobile(ident)) { 3241b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey switch (getNetworkClass(ident.mSubType)) { 3251b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey case NETWORK_CLASS_4_G: 3261b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return true; 3271b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 3281b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 3291b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return false; 3301b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 3311b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 3321b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey /** 3331b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey * Check if matches Wi-Fi network template. 3341b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey */ 3351b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey private boolean matchesWifi(NetworkIdentity ident) { 3363ca7481439c9b65a137d7705d0f4a16766529e75Jeff Sharkey switch (ident.mType) { 3373ca7481439c9b65a137d7705d0f4a16766529e75Jeff Sharkey case TYPE_WIFI: 338e6585b32ea586743258a5457e2184ffc087f2d2fKenny Root return Objects.equals( 3392e4dce0dd24aa89ca6adf6559f13d3e342ff8558Jeff Sharkey removeDoubleQuotes(mNetworkId), removeDoubleQuotes(ident.mNetworkId)); 3403ca7481439c9b65a137d7705d0f4a16766529e75Jeff Sharkey default: 3413ca7481439c9b65a137d7705d0f4a16766529e75Jeff Sharkey return false; 3421b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 3431b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 3441b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 3454e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey /** 3464e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey * Check if matches Ethernet network template. 3474e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey */ 3484e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey private boolean matchesEthernet(NetworkIdentity ident) { 3494e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey if (ident.mType == TYPE_ETHERNET) { 3504e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey return true; 3514e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey } 3524e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey return false; 3534e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey } 3544e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey 355234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey private boolean matchesMobileWildcard(NetworkIdentity ident) { 356234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey if (ident.mType == TYPE_WIMAX) { 357234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey return true; 358234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey } else { 35970c70530bd6793869736ec894498e4ebf5dc9b20Jeff Sharkey return sForceAllNetworkTypes || contains(DATA_USAGE_NETWORK_TYPES, ident.mType); 360234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey } 361234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey } 362234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey 363234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey private boolean matchesWifiWildcard(NetworkIdentity ident) { 364234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey switch (ident.mType) { 365234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey case TYPE_WIFI: 366234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey case TYPE_WIFI_P2P: 367234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey return true; 368234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey default: 369234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey return false; 370234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey } 371234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey } 372234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey 37355a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey /** 37455a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey * Check if matches Bluetooth network template. 37555a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey */ 37655a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey private boolean matchesBluetooth(NetworkIdentity ident) { 37755a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey if (ident.mType == TYPE_BLUETOOTH) { 37855a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey return true; 37955a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey } 38055a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey return false; 38155a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey } 38255a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey 3834e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey private static String getMatchRuleName(int matchRule) { 3841b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey switch (matchRule) { 3851b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey case MATCH_MOBILE_3G_LOWER: 3861b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return "MOBILE_3G_LOWER"; 3871b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey case MATCH_MOBILE_4G: 3881b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return "MOBILE_4G"; 3891b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey case MATCH_MOBILE_ALL: 3901b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return "MOBILE_ALL"; 3911b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey case MATCH_WIFI: 3921b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return "WIFI"; 3934e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey case MATCH_ETHERNET: 3944e814c348ce205fcc1a273427f95ef1d100ed60cJeff Sharkey return "ETHERNET"; 395234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey case MATCH_MOBILE_WILDCARD: 396234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey return "MOBILE_WILDCARD"; 397234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey case MATCH_WIFI_WILDCARD: 398234766a36af6214644fa8205202287084ca9cf93Jeff Sharkey return "WIFI_WILDCARD"; 39955a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey case MATCH_BLUETOOTH: 40055a442e58262e253df965d652bd8219c8d1e72d3Jeff Sharkey return "BLUETOOTH"; 4011b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey default: 4021b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return "UNKNOWN"; 4031b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 4041b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 4051b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 406d4dd7716fb825f29a609c5c4cb31204eea78183aJeff Sharkey private static void ensureSubtypeAvailable() { 407d4dd7716fb825f29a609c5c4cb31204eea78183aJeff Sharkey if (COMBINE_SUBTYPE_ENABLED) { 408d4dd7716fb825f29a609c5c4cb31204eea78183aJeff Sharkey throw new IllegalArgumentException( 409d4dd7716fb825f29a609c5c4cb31204eea78183aJeff Sharkey "Unable to enforce 3G_LOWER template on combined data."); 410d4dd7716fb825f29a609c5c4cb31204eea78183aJeff Sharkey } 411d4dd7716fb825f29a609c5c4cb31204eea78183aJeff Sharkey } 412d4dd7716fb825f29a609c5c4cb31204eea78183aJeff Sharkey 4133256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey /** 4143256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey * Examine the given template and normalize if it refers to a "merged" 4153256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey * mobile subscriber. We pick the "lowest" merged subscriber as the primary 4163256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey * for key purposes, and expand the template to match all other merged 4173256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey * subscribers. 4183256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey * <p> 4193256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey * For example, given an incoming template matching B, and the currently 4203256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey * active merge set [A,B], we'd return a new template that primarily matches 4213256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey * A, but also matches B. 4223256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey */ 4233256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey public static NetworkTemplate normalize(NetworkTemplate template, String[] merged) { 4243256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey if (template.isMatchRuleMobile() && ArrayUtils.contains(merged, template.mSubscriberId)) { 4253256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey // Requested template subscriber is part of the merge group; return 4263256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey // a template that matches all merged subscribers. 4273256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey return new NetworkTemplate(template.mMatchRule, merged[0], merged, 4283256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey template.mNetworkId); 4293256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey } else { 4303256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey return template; 4313256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey } 4323256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey } 4333256601f5e4d94713f59e97b9d4912875c1bdcafJeff Sharkey 4341b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey public static final Creator<NetworkTemplate> CREATOR = new Creator<NetworkTemplate>() { 4358fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey @Override 4361b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey public NetworkTemplate createFromParcel(Parcel in) { 4371b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return new NetworkTemplate(in); 4381b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 4391b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey 4408fc27e8b87bd1def854a03d84009143b315d4176Jeff Sharkey @Override 4411b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey public NetworkTemplate[] newArray(int size) { 4421b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey return new NetworkTemplate[size]; 4431b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey } 4441b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey }; 4451b5a2a96f793211bfbd39aa29cc41031dfa23950Jeff Sharkey} 446