Merge "Allow NetworkFactories to match any network specifier on a request" into mm-wireless-dev
diff --git a/Android.mk b/Android.mk
index c6739e3..3bc33bf 100644
--- a/Android.mk
+++ b/Android.mk
@@ -405,10 +405,13 @@
telephony/java/com/android/internal/telephony/ISms.aidl \
telephony/java/com/android/internal/telephony/ISub.aidl \
telephony/java/com/android/internal/telephony/ITelephony.aidl \
+ telephony/java/com/android/internal/telephony/ITelephonyDebug.aidl \
telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl \
telephony/java/com/android/internal/telephony/IWapPushManager.aidl \
wifi/java/android/net/wifi/IWifiManager.aidl \
- wifi/java/android/net/wifi/passpoint/IWifiPasspointManager.aidl \
+ wifi/java/android/net/wifi/nan/IWifiNanEventListener.aidl \
+ wifi/java/android/net/wifi/nan/IWifiNanManager.aidl \
+ wifi/java/android/net/wifi/nan/IWifiNanSessionListener.aidl \
wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl \
wifi/java/android/net/wifi/IWifiScanner.aidl \
wifi/java/android/net/wifi/IRttManager.aidl \
@@ -475,6 +478,11 @@
frameworks/base/media/java/android/media/tv/TvTrackInfo.aidl \
frameworks/base/media/java/android/media/browse/MediaBrowser.aidl \
frameworks/base/wifi/java/android/net/wifi/ScanSettings.aidl \
+ frameworks/base/wifi/java/android/net/wifi/nan/ConfigRequest.aidl \
+ frameworks/base/wifi/java/android/net/wifi/nan/PublishData.aidl \
+ frameworks/base/wifi/java/android/net/wifi/nan/SubscribeData.aidl \
+ frameworks/base/wifi/java/android/net/wifi/nan/PublishSettings.aidl \
+ frameworks/base/wifi/java/android/net/wifi/nan/SubscribeSettings.aidl \
frameworks/base/wifi/java/android/net/wifi/p2p/WifiP2pInfo.aidl \
frameworks/base/wifi/java/android/net/wifi/p2p/WifiP2pDeviceList.aidl \
frameworks/base/wifi/java/android/net/wifi/p2p/WifiP2pConfig.aidl \
diff --git a/api/current.txt b/api/current.txt
index b0d0646..3691270 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -19218,6 +19218,7 @@
method public java.lang.String getAltSubjectMatch();
method public java.lang.String getAnonymousIdentity();
method public java.security.cert.X509Certificate getCaCertificate();
+ method public java.security.cert.X509Certificate[] getCaCertificates();
method public java.security.cert.X509Certificate getClientCertificate();
method public java.lang.String getDomainSuffixMatch();
method public int getEapMethod();
@@ -19230,6 +19231,7 @@
method public void setAltSubjectMatch(java.lang.String);
method public void setAnonymousIdentity(java.lang.String);
method public void setCaCertificate(java.security.cert.X509Certificate);
+ method public void setCaCertificates(java.security.cert.X509Certificate[]);
method public void setClientKeyEntry(java.security.PrivateKey, java.security.cert.X509Certificate);
method public void setDomainSuffixMatch(java.lang.String);
method public void setEapMethod(int);
@@ -30001,6 +30003,7 @@
method public static boolean hasProperty(int, int);
method public boolean hasProperty(int);
method public static java.lang.String propertiesToString(int);
+ field public static final int CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO = 4194304; // 0x400000
field public static final int CAPABILITY_CAN_PAUSE_VIDEO = 1048576; // 0x100000
field public static final int CAPABILITY_DISCONNECT_FROM_CONFERENCE = 8192; // 0x2000
field public static final int CAPABILITY_HOLD = 1; // 0x1
@@ -30140,6 +30143,7 @@
method public final void setVideoProvider(android.telecom.Connection.VideoProvider);
method public final void setVideoState(int);
method public static java.lang.String stateToString(int);
+ field public static final int CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO = 8388608; // 0x800000
field public static final int CAPABILITY_CAN_PAUSE_VIDEO = 1048576; // 0x100000
field public static final int CAPABILITY_CAN_UPGRADE_TO_VIDEO = 524288; // 0x80000
field public static final int CAPABILITY_DISCONNECT_FROM_CONFERENCE = 8192; // 0x2000
@@ -30334,6 +30338,7 @@
field public static final int CAPABILITY_PLACE_EMERGENCY_CALLS = 16; // 0x10
field public static final int CAPABILITY_SIM_SUBSCRIPTION = 4; // 0x4
field public static final int CAPABILITY_VIDEO_CALLING = 8; // 0x8
+ field public static final int CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE = 256; // 0x100
field public static final android.os.Parcelable.Creator<android.telecom.PhoneAccount> CREATOR;
field public static final int NO_HIGHLIGHT_COLOR = 0; // 0x0
field public static final int NO_RESOURCE_ID = -1; // 0xffffffff
@@ -30672,6 +30677,8 @@
public final class CellIdentityGsm implements android.os.Parcelable {
method public int describeContents();
+ method public int getArfcn();
+ method public int getBsic();
method public int getCid();
method public int getLac();
method public int getMcc();
@@ -30684,6 +30691,7 @@
public final class CellIdentityLte implements android.os.Parcelable {
method public int describeContents();
method public int getCi();
+ method public int getEarfcn();
method public int getMcc();
method public int getMnc();
method public int getPci();
@@ -30699,6 +30707,7 @@
method public int getMcc();
method public int getMnc();
method public int getPsc();
+ method public int getUarfcn();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityWcdma> CREATOR;
}
@@ -31120,10 +31129,15 @@
method public int getActiveSubscriptionInfoCountMax();
method public android.telephony.SubscriptionInfo getActiveSubscriptionInfoForSimSlotIndex(int);
method public java.util.List<android.telephony.SubscriptionInfo> getActiveSubscriptionInfoList();
+ method public static int getDefaultDataSubscriptionId();
+ method public static int getDefaultSmsSubscriptionId();
+ method public static int getDefaultSubscriptionId();
+ method public static int getDefaultVoiceSubscriptionId();
method public boolean isNetworkRoaming(int);
method public void removeOnSubscriptionsChangedListener(android.telephony.SubscriptionManager.OnSubscriptionsChangedListener);
field public static final int DATA_ROAMING_DISABLE = 0; // 0x0
field public static final int DATA_ROAMING_ENABLE = 1; // 0x1
+ field public static final int INVALID_SUBSCRIPTION_ID = -1; // 0xffffffff
}
public static class SubscriptionManager.OnSubscriptionsChangedListener {
@@ -31135,31 +31149,48 @@
method public boolean canChangeDtmfToneLength();
method public java.util.List<android.telephony.CellInfo> getAllCellInfo();
method public int getCallState();
+ method public int getCallState(int);
method public android.telephony.CellLocation getCellLocation();
method public int getDataActivity();
+ method public int getDataNetworkType(int);
method public int getDataState();
method public java.lang.String getDeviceId();
method public java.lang.String getDeviceId(int);
method public java.lang.String getDeviceSoftwareVersion();
method public java.lang.String getGroupIdLevel1();
+ method public java.lang.String getGroupIdLevel1(int);
+ method public java.lang.String getLine1AlphaTag(int);
method public java.lang.String getLine1Number();
+ method public java.lang.String getLine1Number(int);
method public java.lang.String getMmsUAProfUrl();
method public java.lang.String getMmsUserAgent();
method public deprecated java.util.List<android.telephony.NeighboringCellInfo> getNeighboringCellInfo();
method public java.lang.String getNetworkCountryIso();
+ method public java.lang.String getNetworkCountryIso(int);
method public java.lang.String getNetworkOperator();
+ method public java.lang.String getNetworkOperator(int);
method public java.lang.String getNetworkOperatorName();
+ method public java.lang.String getNetworkOperatorName(int);
method public int getNetworkType();
+ method public int getNetworkType(int);
method public int getPhoneCount();
method public int getPhoneType();
method public java.lang.String getSimCountryIso();
+ method public java.lang.String getSimCountryIso(int);
method public java.lang.String getSimOperator();
+ method public java.lang.String getSimOperator(int);
method public java.lang.String getSimOperatorName();
+ method public java.lang.String getSimOperatorName(int);
method public java.lang.String getSimSerialNumber();
+ method public java.lang.String getSimSerialNumber(int);
method public int getSimState();
method public java.lang.String getSubscriberId();
+ method public java.lang.String getSubscriberId(int);
method public java.lang.String getVoiceMailAlphaTag();
+ method public java.lang.String getVoiceMailAlphaTag(int);
method public java.lang.String getVoiceMailNumber();
+ method public java.lang.String getVoiceMailNumber(int);
+ method public int getVoiceNetworkType(int);
method public boolean hasCarrierPrivileges();
method public boolean hasIccCard();
method public boolean iccCloseLogicalChannel(int);
@@ -31169,6 +31200,7 @@
method public java.lang.String iccTransmitApduLogicalChannel(int, int, int, int, int, int, java.lang.String);
method public boolean isHearingAidCompatibilitySupported();
method public boolean isNetworkRoaming();
+ method public boolean isNetworkRoaming(int);
method public boolean isSmsCapable();
method public boolean isTtyModeSupported();
method public boolean isVoiceCapable();
@@ -31176,9 +31208,11 @@
method public void listen(android.telephony.PhoneStateListener, int);
method public java.lang.String sendEnvelopeWithStatus(java.lang.String);
method public boolean setLine1NumberForDisplay(java.lang.String, java.lang.String);
+ method public boolean setLine1NumberForDisplay(int, java.lang.String, java.lang.String);
method public boolean setOperatorBrandOverride(java.lang.String);
method public boolean setPreferredNetworkTypeToGlobal();
method public boolean setVoiceMailNumber(java.lang.String, java.lang.String);
+ method public boolean setVoiceMailNumber(int, java.lang.String, java.lang.String);
field public static final java.lang.String ACTION_CONFIGURE_VOICEMAIL = "android.telephony.action.CONFIGURE_VOICEMAIL";
field public static final java.lang.String ACTION_PHONE_STATE_CHANGED = "android.intent.action.PHONE_STATE";
field public static final java.lang.String ACTION_RESPOND_VIA_MESSAGE = "android.intent.action.RESPOND_VIA_MESSAGE";
diff --git a/api/system-current.txt b/api/system-current.txt
index 29044a1..b09a4a2 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -20994,6 +20994,7 @@
method public java.lang.String getAltSubjectMatch();
method public java.lang.String getAnonymousIdentity();
method public java.security.cert.X509Certificate getCaCertificate();
+ method public java.security.cert.X509Certificate[] getCaCertificates();
method public java.security.cert.X509Certificate getClientCertificate();
method public java.lang.String getDomainSuffixMatch();
method public int getEapMethod();
@@ -21006,6 +21007,7 @@
method public void setAltSubjectMatch(java.lang.String);
method public void setAnonymousIdentity(java.lang.String);
method public void setCaCertificate(java.security.cert.X509Certificate);
+ method public void setCaCertificates(java.security.cert.X509Certificate[]);
method public void setClientKeyEntry(java.security.PrivateKey, java.security.cert.X509Certificate);
method public void setDomainSuffixMatch(java.lang.String);
method public void setEapMethod(int);
@@ -21203,6 +21205,7 @@
field public static final int REASON_UNSPECIFIED = -1; // 0xffffffff
field public static final deprecated int REPORT_EVENT_AFTER_BUFFER_FULL = 0; // 0x0
field public static final int REPORT_EVENT_AFTER_EACH_SCAN = 1; // 0x1
+ field public static final int REPORT_EVENT_CONTEXT_HUB = 8; // 0x8
field public static final int REPORT_EVENT_FULL_SCAN_RESULT = 2; // 0x2
field public static final int REPORT_EVENT_NO_BATCH = 4; // 0x4
field public static final int WIFI_BAND_24_GHZ = 1; // 0x1
@@ -21283,7 +21286,6 @@
method public void writeToParcel(android.os.Parcel, int);
field public int band;
field public android.net.wifi.WifiScanner.ChannelSpec[] channels;
- field public int exponent;
field public int maxPeriodInMs;
field public int maxScansToCache;
field public int numBssidsPerScan;
@@ -25611,8 +25613,8 @@
ctor public UserHandle(android.os.Parcel);
method public int describeContents();
method public int getIdentifier();
- method public boolean isOwner();
- method public static int myUserId();
+ method public final boolean isOwner();
+ method public static final int myUserId();
method public static android.os.UserHandle readFromParcel(android.os.Parcel);
method public void writeToParcel(android.os.Parcel, int);
method public static void writeToParcel(android.os.UserHandle, android.os.Parcel);
@@ -32177,6 +32179,7 @@
method public static boolean hasProperty(int, int);
method public boolean hasProperty(int);
method public static java.lang.String propertiesToString(int);
+ field public static final int CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO = 4194304; // 0x400000
field public static final int CAPABILITY_CAN_PAUSE_VIDEO = 1048576; // 0x100000
field public static final int CAPABILITY_DISCONNECT_FROM_CONFERENCE = 8192; // 0x2000
field public static final int CAPABILITY_HOLD = 1; // 0x1
@@ -32327,6 +32330,7 @@
method public final void setVideoProvider(android.telecom.Connection.VideoProvider);
method public final void setVideoState(int);
method public static java.lang.String stateToString(int);
+ field public static final int CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO = 8388608; // 0x800000
field public static final int CAPABILITY_CAN_PAUSE_VIDEO = 1048576; // 0x100000
field public static final int CAPABILITY_CAN_UPGRADE_TO_VIDEO = 524288; // 0x80000
field public static final int CAPABILITY_DISCONNECT_FROM_CONFERENCE = 8192; // 0x2000
@@ -32546,6 +32550,7 @@
field public static final int CAPABILITY_PLACE_EMERGENCY_CALLS = 16; // 0x10
field public static final int CAPABILITY_SIM_SUBSCRIPTION = 4; // 0x4
field public static final int CAPABILITY_VIDEO_CALLING = 8; // 0x8
+ field public static final int CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE = 256; // 0x100
field public static final android.os.Parcelable.Creator<android.telecom.PhoneAccount> CREATOR;
field public static final int NO_HIGHLIGHT_COLOR = 0; // 0x0
field public static final int NO_RESOURCE_ID = -1; // 0xffffffff
@@ -32707,6 +32712,7 @@
public class TelecomManager {
method public void acceptRingingCall();
+ method public void acceptRingingCall(int);
method public void addNewIncomingCall(android.telecom.PhoneAccountHandle, android.os.Bundle);
method public void addNewUnknownCall(android.telecom.PhoneAccountHandle, android.os.Bundle);
method public void cancelMissedCallsNotification();
@@ -32918,6 +32924,8 @@
public final class CellIdentityGsm implements android.os.Parcelable {
method public int describeContents();
+ method public int getArfcn();
+ method public int getBsic();
method public int getCid();
method public int getLac();
method public int getMcc();
@@ -32930,6 +32938,7 @@
public final class CellIdentityLte implements android.os.Parcelable {
method public int describeContents();
method public int getCi();
+ method public int getEarfcn();
method public int getMcc();
method public int getMnc();
method public int getPci();
@@ -32945,6 +32954,7 @@
method public int getMcc();
method public int getMnc();
method public int getPsc();
+ method public int getUarfcn();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityWcdma> CREATOR;
}
@@ -33366,10 +33376,15 @@
method public int getActiveSubscriptionInfoCountMax();
method public android.telephony.SubscriptionInfo getActiveSubscriptionInfoForSimSlotIndex(int);
method public java.util.List<android.telephony.SubscriptionInfo> getActiveSubscriptionInfoList();
+ method public static int getDefaultDataSubscriptionId();
+ method public static int getDefaultSmsSubscriptionId();
+ method public static int getDefaultSubscriptionId();
+ method public static int getDefaultVoiceSubscriptionId();
method public boolean isNetworkRoaming(int);
method public void removeOnSubscriptionsChangedListener(android.telephony.SubscriptionManager.OnSubscriptionsChangedListener);
field public static final int DATA_ROAMING_DISABLE = 0; // 0x0
field public static final int DATA_ROAMING_ENABLE = 1; // 0x1
+ field public static final int INVALID_SUBSCRIPTION_ID = -1; // 0xffffffff
}
public static class SubscriptionManager.OnSubscriptionsChangedListener {
@@ -33390,6 +33405,7 @@
method public boolean endCall();
method public java.util.List<android.telephony.CellInfo> getAllCellInfo();
method public int getCallState();
+ method public int getCallState(int);
method public java.util.List<java.lang.String> getCarrierPackageNamesForIntent(android.content.Intent);
method public java.util.List<java.lang.String> getCarrierPackageNamesForIntentAndPhone(android.content.Intent, int);
method public java.lang.String getCdmaMdn();
@@ -33402,29 +33418,45 @@
method public int getDataActivity();
method public boolean getDataEnabled();
method public boolean getDataEnabled(int);
+ method public int getDataNetworkType(int);
method public int getDataState();
method public java.lang.String getDeviceId();
method public java.lang.String getDeviceId(int);
method public java.lang.String getDeviceSoftwareVersion();
method public java.lang.String getGroupIdLevel1();
+ method public java.lang.String getGroupIdLevel1(int);
+ method public java.lang.String getLine1AlphaTag(int);
method public java.lang.String getLine1Number();
+ method public java.lang.String getLine1Number(int);
method public java.lang.String getMmsUAProfUrl();
method public java.lang.String getMmsUserAgent();
method public deprecated java.util.List<android.telephony.NeighboringCellInfo> getNeighboringCellInfo();
method public java.lang.String getNetworkCountryIso();
+ method public java.lang.String getNetworkCountryIso(int);
method public java.lang.String getNetworkOperator();
+ method public java.lang.String getNetworkOperator(int);
method public java.lang.String getNetworkOperatorName();
+ method public java.lang.String getNetworkOperatorName(int);
method public int getNetworkType();
+ method public int getNetworkType(int);
method public int getPhoneCount();
method public int getPhoneType();
method public java.lang.String getSimCountryIso();
+ method public java.lang.String getSimCountryIso(int);
method public java.lang.String getSimOperator();
+ method public java.lang.String getSimOperator(int);
method public java.lang.String getSimOperatorName();
+ method public java.lang.String getSimOperatorName(int);
method public java.lang.String getSimSerialNumber();
+ method public java.lang.String getSimSerialNumber(int);
method public int getSimState();
method public java.lang.String getSubscriberId();
+ method public java.lang.String getSubscriberId(int);
method public java.lang.String getVoiceMailAlphaTag();
+ method public java.lang.String getVoiceMailAlphaTag(int);
method public java.lang.String getVoiceMailNumber();
+ method public java.lang.String getVoiceMailNumber(int);
+ method public int getVoiceNetworkType(int);
method public boolean handlePinMmi(java.lang.String);
method public boolean handlePinMmiForSubscriber(int, java.lang.String);
method public boolean hasCarrierPrivileges();
@@ -33438,6 +33470,7 @@
method public boolean isHearingAidCompatibilitySupported();
method public boolean isIdle();
method public boolean isNetworkRoaming();
+ method public boolean isNetworkRoaming(int);
method public boolean isOffhook();
method public boolean isRadioOn();
method public boolean isRinging();
@@ -33453,11 +33486,13 @@
method public void setDataEnabled(boolean);
method public void setDataEnabled(int, boolean);
method public boolean setLine1NumberForDisplay(java.lang.String, java.lang.String);
+ method public boolean setLine1NumberForDisplay(int, java.lang.String, java.lang.String);
method public boolean setOperatorBrandOverride(java.lang.String);
method public boolean setPreferredNetworkTypeToGlobal();
method public boolean setRadio(boolean);
method public boolean setRadioPower(boolean);
method public boolean setVoiceMailNumber(java.lang.String, java.lang.String);
+ method public boolean setVoiceMailNumber(int, java.lang.String, java.lang.String);
method public void silenceRinger();
method public boolean supplyPin(java.lang.String);
method public int[] supplyPinReportResult(java.lang.String);
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index 3d264c6..687fe4c 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -78,10 +78,10 @@
import android.net.wifi.RttManager;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiScanner;
+import android.net.wifi.nan.IWifiNanManager;
+import android.net.wifi.nan.WifiNanManager;
import android.net.wifi.p2p.IWifiP2pManager;
import android.net.wifi.p2p.WifiP2pManager;
-import android.net.wifi.passpoint.IWifiPasspointManager;
-import android.net.wifi.passpoint.WifiPasspointManager;
import android.nfc.NfcManager;
import android.os.BatteryManager;
import android.os.DropBoxManager;
@@ -481,15 +481,6 @@
return new WifiManager(ctx.getOuterContext(), service);
}});
- registerService(Context.WIFI_PASSPOINT_SERVICE, WifiPasspointManager.class,
- new CachedServiceFetcher<WifiPasspointManager>() {
- @Override
- public WifiPasspointManager createService(ContextImpl ctx) {
- IBinder b = ServiceManager.getService(Context.WIFI_PASSPOINT_SERVICE);
- IWifiPasspointManager service = IWifiPasspointManager.Stub.asInterface(b);
- return new WifiPasspointManager(ctx.getOuterContext(), service);
- }});
-
registerService(Context.WIFI_P2P_SERVICE, WifiP2pManager.class,
new StaticServiceFetcher<WifiP2pManager>() {
@Override
@@ -499,6 +490,18 @@
return new WifiP2pManager(service);
}});
+ registerService(Context.WIFI_NAN_SERVICE, WifiNanManager.class,
+ new StaticServiceFetcher<WifiNanManager>() {
+ @Override
+ public WifiNanManager createService() {
+ IBinder b = ServiceManager.getService(Context.WIFI_NAN_SERVICE);
+ IWifiNanManager service = IWifiNanManager.Stub.asInterface(b);
+ if (service == null) {
+ return null;
+ }
+ return new WifiNanManager(service);
+ }});
+
registerService(Context.WIFI_SCANNING_SERVICE, WifiScanner.class,
new CachedServiceFetcher<WifiScanner>() {
@Override
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 758b6ff..4d1705b 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -2460,7 +2460,7 @@
NETWORK_STATS_SERVICE,
//@hide: NETWORK_POLICY_SERVICE,
WIFI_SERVICE,
- WIFI_PASSPOINT_SERVICE,
+ WIFI_NAN_SERVICE,
WIFI_P2P_SERVICE,
WIFI_SCANNING_SERVICE,
//@hide: WIFI_RTT_SERVICE,
@@ -2902,17 +2902,6 @@
/**
* Use with {@link #getSystemService} to retrieve a {@link
- * android.net.wifi.passpoint.WifiPasspointManager} for handling management of
- * Wi-Fi passpoint access.
- *
- * @see #getSystemService
- * @see android.net.wifi.passpoint.WifiPasspointManager
- * @hide
- */
- public static final String WIFI_PASSPOINT_SERVICE = "wifipasspoint";
-
- /**
- * Use with {@link #getSystemService} to retrieve a {@link
* android.net.wifi.p2p.WifiP2pManager} for handling management of
* Wi-Fi peer-to-peer connections.
*
@@ -2922,6 +2911,17 @@
public static final String WIFI_P2P_SERVICE = "wifip2p";
/**
+ * Use with {@link #getSystemService} to retrieve a
+ * {@link android.net.wifi.nan.WifiNanManager} for handling management of
+ * Wi-Fi NAN discovery and connections.
+ *
+ * @see #getSystemService
+ * @see android.net.wifi.nan.WifiNanManager
+ * @hide PROPOSED_NAN_API
+ */
+ public static final String WIFI_NAN_SERVICE = "wifinan";
+
+ /**
* Use with {@link #getSystemService} to retrieve a {@link
* android.net.wifi.WifiScanner} for scanning the wifi universe
*
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index c8e9402..e674e62 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -1643,6 +1643,16 @@
/**
* Feature for {@link #getSystemAvailableFeatures} and
+ * {@link #hasSystemFeature}: The device supports Wi-Fi Aware (NAN)
+ * networking.
+ *
+ * @hide PROPOSED_NAN_API
+ */
+ @SdkConstant(SdkConstantType.FEATURE)
+ public static final String FEATURE_WIFI_NAN = "android.hardware.wifi.nan";
+
+ /**
+ * Feature for {@link #getSystemAvailableFeatures} and
* {@link #hasSystemFeature}: This is a device dedicated to showing UI
* on a vehicle headunit. A headunit here is defined to be inside a
* vehicle that may or may not be moving. A headunit uses either a
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index ad9058f..8e91d2e 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -1460,7 +1460,7 @@
if (b != null) {
try {
ITelephony it = ITelephony.Stub.asInterface(b);
- int subId = SubscriptionManager.getDefaultDataSubId();
+ int subId = SubscriptionManager.getDefaultDataSubscriptionId();
Log.d("ConnectivityManager", "getMobileDataEnabled()+ subId=" + subId);
boolean retVal = it.getDataEnabled(subId);
Log.d("ConnectivityManager", "getMobileDataEnabled()- subId=" + subId
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 8cb686a..24d2497 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -409,22 +409,29 @@
<!-- Boolean indicating whether or not wifi firmware debugging is enabled -->
<bool translatable="false" name="config_wifi_enable_wifi_firmware_debugging">true</bool>
+ <!-- Boolean indicating whether or not wifi should turn off when emergency call is made -->
+ <bool translatable="false" name="config_wifi_turn_off_during_emergency_call">false</bool>
+
<!-- Integer specifying the basic autojoin parameters -->
<integer translatable="false" name="config_wifi_framework_5GHz_preference_boost_threshold">-65</integer>
- <integer translatable="false" name="config_wifi_framework_5GHz_preference_boost_factor">5</integer>
+ <integer translatable="false" name="config_wifi_framework_5GHz_preference_boost_factor">40</integer>
<integer translatable="false" name="config_wifi_framework_current_association_hysteresis_high">16</integer>
<integer translatable="false" name="config_wifi_framework_current_association_hysteresis_low">10</integer>
<integer translatable="false" name="config_wifi_framework_5GHz_preference_penalty_threshold">-75</integer>
- <integer translatable="false" name="config_wifi_framework_5GHz_preference_penalty_factor">2</integer>
-
+ <integer translatable="false" name="config_wifi_framework_RSSI_SCORE_OFFSET">85</integer>
+ <integer translatable="false" name="config_wifi_framework_RSSI_SCORE_SLOPE">4</integer>
+ <integer translatable="false" name="config_wifi_framework_SAME_BSSID_AWARD">24</integer>
+ <integer translatable="false" name="config_wifi_framework_LAST_SELECTION_AWARD">480</integer>
+ <integer translatable="false" name="config_wifi_framework_PASSPOINT_SECURITY_AWARD">40</integer>
+ <integer translatable="false" name="config_wifi_framework_SECURITY_AWARD">80</integer>
<!-- Integer parameters of the wifi to cellular handover feature
wifi should not stick to bad networks -->
<integer translatable="false" name="config_wifi_framework_wifi_score_bad_rssi_threshold_5GHz">-82</integer>
- <integer translatable="false" name="config_wifi_framework_wifi_score_low_rssi_threshold_5GHz">-72</integer>
- <integer translatable="false" name="config_wifi_framework_wifi_score_good_rssi_threshold_5GHz">-60</integer>
- <integer translatable="false" name="config_wifi_framework_wifi_score_bad_rssi_threshold_24GHz">-87</integer>
- <integer translatable="false" name="config_wifi_framework_wifi_score_low_rssi_threshold_24GHz">-77</integer>
- <integer translatable="false" name="config_wifi_framework_wifi_score_good_rssi_threshold_24GHz">-65</integer>
+ <integer translatable="false" name="config_wifi_framework_wifi_score_low_rssi_threshold_5GHz">-70</integer>
+ <integer translatable="false" name="config_wifi_framework_wifi_score_good_rssi_threshold_5GHz">-57</integer>
+ <integer translatable="false" name="config_wifi_framework_wifi_score_bad_rssi_threshold_24GHz">-85</integer>
+ <integer translatable="false" name="config_wifi_framework_wifi_score_low_rssi_threshold_24GHz">-73</integer>
+ <integer translatable="false" name="config_wifi_framework_wifi_score_good_rssi_threshold_24GHz">-60</integer>
<integer translatable="false" name="config_wifi_framework_wifi_score_bad_link_speed_24">6</integer>
<integer translatable="false" name="config_wifi_framework_wifi_score_bad_link_speed_5">12</integer>
<integer translatable="false" name="config_wifi_framework_wifi_score_good_link_speed_24">24</integer>
@@ -498,7 +505,7 @@
<integer translatable="false" name="config_wifi_framework_network_black_list_min_time_milli">120000</integer>
<!-- Integer indicating RSSI boost given to current network -->
- <integer translatable="false" name="config_wifi_framework_current_network_boost">25</integer>
+ <integer translatable="false" name="config_wifi_framework_current_network_boost">16</integer>
<!-- Integer indicating how to handle beacons with uninitialized RSSI value of 0 -->
<integer translatable="false" name="config_wifi_framework_scan_result_rssi_level_patchup_value">-85</integer>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index ad3b889..3185ce7 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -308,6 +308,7 @@
<java-symbol type="bool" name="config_wifi_enable_5GHz_preference" />
<java-symbol type="bool" name="config_wifi_revert_country_code_on_cellular_loss" />
<java-symbol type="bool" name="config_wifi_enable_wifi_firmware_debugging" />
+ <java-symbol type="bool" name="config_wifi_turn_off_during_emergency_call" />
<java-symbol type="bool" name="config_supportMicNearUltrasound" />
<java-symbol type="bool" name="config_supportSpeakerNearUltrasound" />
<java-symbol type="integer" name="config_wifi_framework_5GHz_preference_boost_threshold" />
@@ -316,7 +317,12 @@
<java-symbol type="integer" name="config_wifi_framework_current_association_hysteresis_high" />
<java-symbol type="integer" name="config_wifi_framework_current_association_hysteresis_low" />
<java-symbol type="integer" name="config_wifi_framework_5GHz_preference_penalty_threshold" />
- <java-symbol type="integer" name="config_wifi_framework_5GHz_preference_penalty_factor" />
+ <java-symbol type="integer" name="config_wifi_framework_RSSI_SCORE_OFFSET" />
+ <java-symbol type="integer" name="config_wifi_framework_RSSI_SCORE_SLOPE" />
+ <java-symbol type="integer" name="config_wifi_framework_SAME_BSSID_AWARD" />
+ <java-symbol type="integer" name="config_wifi_framework_LAST_SELECTION_AWARD" />
+ <java-symbol type="integer" name="config_wifi_framework_PASSPOINT_SECURITY_AWARD" />
+ <java-symbol type="integer" name="config_wifi_framework_SECURITY_AWARD" />
<java-symbol type="integer" name="config_wifi_disconnected_short_scan_interval" />
<java-symbol type="integer" name="config_wifi_disconnected_long_scan_interval" />
<java-symbol type="integer" name="config_wifi_associated_short_scan_interval" />
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
index 632a867..ce393f1 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
@@ -234,10 +234,13 @@
}
public boolean matches(WifiConfiguration config) {
- if (config.isPasspoint() && mConfig != null && mConfig.isPasspoint())
+ if (config.isPasspoint() && mConfig != null && mConfig.isPasspoint()) {
return config.FQDN.equals(mConfig.providerFriendlyName);
- else
- return ssid.equals(removeDoubleQuotes(config.SSID)) && security == getSecurity(config);
+ } else {
+ return ssid.equals(removeDoubleQuotes(config.SSID))
+ && security == getSecurity(config)
+ && (mConfig == null || mConfig.shared == config.shared);
+ }
}
public WifiConfiguration getConfig() {
@@ -394,33 +397,20 @@
summary.append(String.format(format, mConfig.providerFriendlyName));
} else if (mConfig != null && mConfig.hasNoInternetAccess()) {
summary.append(mContext.getString(R.string.wifi_no_internet));
- } else if (mConfig != null && ((mConfig.status == WifiConfiguration.Status.DISABLED &&
- mConfig.disableReason != WifiConfiguration.DISABLED_UNKNOWN_REASON)
- || mConfig.autoJoinStatus
- >= WifiConfiguration.AUTO_JOIN_DISABLED_ON_AUTH_FAILURE)) {
- if (mConfig.autoJoinStatus
- >= WifiConfiguration.AUTO_JOIN_DISABLED_ON_AUTH_FAILURE) {
- if (mConfig.disableReason == WifiConfiguration.DISABLED_DHCP_FAILURE) {
- summary.append(mContext.getString(R.string.wifi_disabled_network_failure));
- } else if (mConfig.disableReason == WifiConfiguration.DISABLED_AUTH_FAILURE) {
+ } else if (mConfig != null && !mConfig.getNetworkSelectionStatus().isNetworkEnabled()) {
+ WifiConfiguration.NetworkSelectionStatus networkStatus =
+ mConfig.getNetworkSelectionStatus();
+ switch (networkStatus.getNetworkSelectionDisableReason()) {
+ case WifiConfiguration.NetworkSelectionStatus.DISABLED_AUTHENTICATION_FAILURE:
summary.append(mContext.getString(R.string.wifi_disabled_password_failure));
- } else {
- summary.append(mContext.getString(R.string.wifi_disabled_wifi_failure));
- }
- } else {
- switch (mConfig.disableReason) {
- case WifiConfiguration.DISABLED_AUTH_FAILURE:
- summary.append(mContext.getString(R.string.wifi_disabled_password_failure));
- break;
- case WifiConfiguration.DISABLED_DHCP_FAILURE:
- case WifiConfiguration.DISABLED_DNS_FAILURE:
- summary.append(mContext.getString(R.string.wifi_disabled_network_failure));
- break;
- case WifiConfiguration.DISABLED_UNKNOWN_REASON:
- case WifiConfiguration.DISABLED_ASSOCIATION_REJECT:
- summary.append(mContext.getString(R.string.wifi_disabled_generic));
- break;
- }
+ break;
+ case WifiConfiguration.NetworkSelectionStatus.DISABLED_DHCP_FAILURE:
+ case WifiConfiguration.NetworkSelectionStatus.DISABLED_DNS_FAILURE:
+ summary.append(mContext.getString(R.string.wifi_disabled_network_failure));
+ break;
+ case WifiConfiguration.NetworkSelectionStatus.DISABLED_ASSOCIATION_REJECTION:
+ summary.append(mContext.getString(R.string.wifi_disabled_generic));
+ break;
}
} else if (mRssi == Integer.MAX_VALUE) { // Wifi out of range
summary.append(mContext.getString(R.string.wifi_not_in_range));
@@ -437,11 +427,11 @@
summary.append(" f=" + Integer.toString(mInfo.getFrequency()));
}
summary.append(" " + getVisibilityStatus());
- if (mConfig != null && mConfig.autoJoinStatus > 0) {
- summary.append(" (" + mConfig.autoJoinStatus);
- if (mConfig.blackListTimestamp > 0) {
+ if (mConfig != null && !mConfig.getNetworkSelectionStatus().isNetworkEnabled()) {
+ summary.append(" (" + mConfig.getNetworkSelectionStatus().getNetworkStatusString());
+ if (mConfig.getNetworkSelectionStatus().getDisableTime() > 0) {
long now = System.currentTimeMillis();
- long diff = (now - mConfig.blackListTimestamp)/1000;
+ long diff = (now - mConfig.getNetworkSelectionStatus().getDisableTime()) / 1000;
long sec = diff%60; //seconds
long min = (diff/60)%60; //minutes
long hour = (min/60)%60; //hours
@@ -452,17 +442,19 @@
}
summary.append(")");
}
- if (mConfig != null && mConfig.numIpConfigFailures > 0) {
- summary.append(" ipf=").append(mConfig.numIpConfigFailures);
- }
- if (mConfig != null && mConfig.numConnectionFailures > 0) {
- summary.append(" cf=").append(mConfig.numConnectionFailures);
- }
- if (mConfig != null && mConfig.numAuthFailures > 0) {
- summary.append(" authf=").append(mConfig.numAuthFailures);
- }
- if (mConfig != null && mConfig.numNoInternetAccessReports > 0) {
- summary.append(" noInt=").append(mConfig.numNoInternetAccessReports);
+
+ if (mConfig != null) {
+ WifiConfiguration.NetworkSelectionStatus networkStatus =
+ mConfig.getNetworkSelectionStatus();
+ for (int index = WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLE;
+ index < WifiConfiguration.NetworkSelectionStatus
+ .NETWORK_SELECTION_DISABLED_MAX; index++) {
+ if (networkStatus.getDisableReasonCounter(index) != 0) {
+ summary.append(" " + WifiConfiguration.NetworkSelectionStatus
+ .getNetworkDisableReasonString(index) + "="
+ + networkStatus.getDisableReasonCounter(index));
+ }
+ }
}
}
return summary.toString();
@@ -508,10 +500,6 @@
Map<String, ScanResult> list = mScanResultCache.snapshot();
// TODO: sort list by RSSI or age
for (ScanResult result : list.values()) {
- if (result.seen == 0)
- continue;
-
- if (result.autoJoinStatus != ScanResult.ENABLED) numBlackListed++;
if (result.frequency >= LOWER_FREQ_5GHZ
&& result.frequency <= HIGHER_FREQ_5GHZ) {
@@ -525,8 +513,6 @@
num24 = num24 + 1;
}
- // Ignore results seen, older than 20 seconds
- if (now - result.seen > VISIBILITY_OUTDATED_AGE_IN_MILLI) continue;
if (result.frequency >= LOWER_FREQ_5GHZ
&& result.frequency <= HIGHER_FREQ_5GHZ) {
@@ -539,12 +525,6 @@
if (bssid != null && result.BSSID.equals(bssid)) scans5GHz.append("*");
scans5GHz.append("=").append(result.frequency);
scans5GHz.append(",").append(result.level);
- if (result.autoJoinStatus != 0) {
- scans5GHz.append(",st=").append(result.autoJoinStatus);
- }
- if (result.numIpConfigFailures != 0) {
- scans5GHz.append(",ipf=").append(result.numIpConfigFailures);
- }
scans5GHz.append("}");
n5++;
}
@@ -559,12 +539,6 @@
if (bssid != null && result.BSSID.equals(bssid)) scans24GHz.append("*");
scans24GHz.append("=").append(result.frequency);
scans24GHz.append(",").append(result.level);
- if (result.autoJoinStatus != 0) {
- scans24GHz.append(",st=").append(result.autoJoinStatus);
- }
- if (result.numIpConfigFailures != 0) {
- scans24GHz.append(",ipf=").append(result.numIpConfigFailures);
- }
scans24GHz.append("}");
n24++;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileDataControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileDataControllerImpl.java
index a7fdadc..942ba59 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileDataControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileDataControllerImpl.java
@@ -218,7 +218,7 @@
private static String getActiveSubscriberId(Context context) {
final TelephonyManager tele = TelephonyManager.from(context);
final String actualSubscriberId = tele.getSubscriberId(
- SubscriptionManager.getDefaultDataSubId());
+ SubscriptionManager.getDefaultDataSubscriptionId());
return actualSubscriberId;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
index 2996808..288fe72 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
@@ -811,11 +811,11 @@
public static class SubscriptionDefaults {
public int getDefaultVoiceSubId() {
- return SubscriptionManager.getDefaultVoiceSubId();
+ return SubscriptionManager.getDefaultVoiceSubscriptionId();
}
public int getDefaultDataSubId() {
- return SubscriptionManager.getDefaultDataSubId();
+ return SubscriptionManager.getDefaultDataSubscriptionId();
}
}
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index 19a4851..8083bf0 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -262,7 +262,8 @@
mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCHED, userHandle, 0));
} else if (action.equals(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED)) {
Integer newDefaultSubIdObj = new Integer(intent.getIntExtra(
- PhoneConstants.SUBSCRIPTION_KEY, SubscriptionManager.getDefaultSubId()));
+ PhoneConstants.SUBSCRIPTION_KEY,
+ SubscriptionManager.getDefaultSubscriptionId()));
int newDefaultPhoneId = intent.getIntExtra(PhoneConstants.SLOT_KEY,
SubscriptionManager.getPhoneId(mDefaultSubId));
if (DBG) {
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 0619d76..81c5a1a 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -130,6 +130,8 @@
"com.android.server.midi.MidiService$Lifecycle";
private static final String WIFI_SERVICE_CLASS =
"com.android.server.wifi.WifiService";
+ private static final String WIFI_NAN_SERVICE_CLASS =
+ "com.android.server.wifi.nan.WifiNanService";
private static final String WIFI_P2P_SERVICE_CLASS =
"com.android.server.wifi.p2p.WifiP2pService";
private static final String ETHERNET_SERVICE_CLASS =
@@ -727,6 +729,11 @@
}
Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
+ if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI_NAN)) {
+ mSystemServiceManager.startService(WIFI_NAN_SERVICE_CLASS);
+ } else {
+ Slog.i(TAG, "No Wi-Fi NAN Service (NAN support Not Present)");
+ }
mSystemServiceManager.startService(WIFI_P2P_SERVICE_CLASS);
mSystemServiceManager.startService(WIFI_SERVICE_CLASS);
mSystemServiceManager.startService(
diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java
index 6511705..270c8ce 100644
--- a/telecomm/java/android/telecom/Call.java
+++ b/telecomm/java/android/telecom/Call.java
@@ -24,7 +24,6 @@
import java.lang.String;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -210,7 +209,22 @@
* Call sends responses through connection.
* @hide
*/
- public static final int CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION = 0x00400000;
+ public static final int CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION = 0x00200000;
+
+ /**
+ * When set, prevents a video {@code Call} from being downgraded to an audio-only call.
+ * <p>
+ * Should be set when the VideoState has the {@link VideoProfile#STATE_TX_ENABLED} or
+ * {@link VideoProfile#STATE_RX_ENABLED} bits set to indicate that the connection cannot be
+ * downgraded from a video call back to a VideoState of
+ * {@link VideoProfile#STATE_AUDIO_ONLY}.
+ * <p>
+ * Intuitively, a call which can be downgraded to audio should also have local and remote
+ * video
+ * capabilities (see {@link #CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL} and
+ * {@link #CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL}).
+ */
+ public static final int CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO = 0x00400000;
//******************************************************************************************
// Next CAPABILITY value: 0x00800000
@@ -327,6 +341,9 @@
if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_TX)) {
builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_TX");
}
+ if (can(capabilities, CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO)) {
+ builder.append(" CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO");
+ }
if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL)) {
builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL");
}
diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java
index 4115756..c9fc51e 100644
--- a/telecomm/java/android/telecom/Connection.java
+++ b/telecomm/java/android/telecom/Connection.java
@@ -255,8 +255,23 @@
*/
public static final int CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION = 0x00400000;
+ /**
+ * When set, prevents a video call from being downgraded to an audio-only call.
+ * <p>
+ * Should be set when the VideoState has the {@link VideoProfile#STATE_TX_ENABLED} or
+ * {@link VideoProfile#STATE_RX_ENABLED} bits set to indicate that the connection cannot be
+ * downgraded from a video call back to a VideoState of
+ * {@link VideoProfile#STATE_AUDIO_ONLY}.
+ * <p>
+ * Intuitively, a call which can be downgraded to audio should also have local and remote
+ * video
+ * capabilities (see {@link #CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL} and
+ * {@link #CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL}).
+ */
+ public static final int CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO = 0x00800000;
+
//**********************************************************************************************
- // Next CAPABILITY value: 0x00800000
+ // Next CAPABILITY value: 0x01000000
//**********************************************************************************************
/**
@@ -371,6 +386,9 @@
if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL)) {
builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL");
}
+ if (can(capabilities, CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO)) {
+ builder.append(" CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO");
+ }
if (can(capabilities, CAPABILITY_HIGH_DEF_AUDIO)) {
builder.append(" CAPABILITY_HIGH_DEF_AUDIO");
}
diff --git a/telecomm/java/android/telecom/PhoneAccount.java b/telecomm/java/android/telecom/PhoneAccount.java
index b64043c..0b19c98d 100644
--- a/telecomm/java/android/telecom/PhoneAccount.java
+++ b/telecomm/java/android/telecom/PhoneAccount.java
@@ -129,6 +129,20 @@
public static final int CAPABILITY_EMERGENCY_CALLS_ONLY = 0x80;
/**
+ * Flag indicating that for this {@code PhoneAccount}, the ability to make a video call to a
+ * number relies on presence. Should only be set if the {@code PhoneAccount} also has
+ * {@link #CAPABILITY_VIDEO_CALLING}.
+ * <p>
+ * When set, the {@link ConnectionService} is responsible for toggling the
+ * {@link android.provider.ContactsContract.Data#CARRIER_PRESENCE_VT_CAPABLE} bit on the
+ * {@link android.provider.ContactsContract.Data#CARRIER_PRESENCE} column to indicate whether
+ * a contact's phone number supports video calling.
+ * <p>
+ * See {@link #getCapabilities}
+ */
+ public static final int CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE = 0x100;
+
+ /**
* URI scheme for telephone number URIs.
*/
public static final String SCHEME_TEL = "tel";
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index b07b018f..4916a66 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -1024,7 +1024,9 @@
* If there is a ringing incoming call, this method accepts the call on behalf of the user.
* TODO: L-release - need to convert all invocation of ITelecmmService#answerRingingCall to use
* this method (clockwork & gearhead).
- *
+ * If the incoming call is a video call, the call will be answered with the same video state as
+ * the incoming call requests. This means, for example, that an incoming call requesting
+ * {@link VideoProfile#STATE_BIDIRECTIONAL} will be answered, accepting that state.
* @hide
*/
@SystemApi
@@ -1039,6 +1041,24 @@
}
/**
+ * If there is a ringing incoming call, this method accepts the call on behalf of the user,
+ * with the specified video state.
+ *
+ * @param videoState The desired video state to answer the call with.
+ * @hide
+ */
+ @SystemApi
+ public void acceptRingingCall(int videoState) {
+ try {
+ if (isServiceConnected()) {
+ getTelecomService().acceptRingingCallWithVideoState(videoState);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelecomService#acceptRingingCallWithVideoState", e);
+ }
+ }
+
+ /**
* Silences the ringer if a ringing call exists.
*/
public void silenceRinger() {
diff --git a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
index 2e07759..856e210 100644
--- a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
+++ b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
@@ -178,6 +178,11 @@
void acceptRingingCall();
/**
+ * @see TelecomServiceImpl#acceptRingingCallWithVideoState(int)
+ */
+ void acceptRingingCallWithVideoState(int videoState);
+
+ /**
* @see TelecomServiceImpl#cancelMissedCallsNotification
*/
void cancelMissedCallsNotification(String callingPackage);
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index 3312792..581dfa2 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -341,6 +341,34 @@
public static final String KEY_ALWAYS_SHOW_EMERGENCY_ALERT_ONOFF_BOOL =
"always_show_emergency_alert_onoff_bool";
+ /**
+ * The data call APN retry configuration for default type APN.
+ * @hide
+ */
+ public static final String KEY_CARRIER_DATA_CALL_RETRY_CONFIG_DEFAULT_STRING =
+ "carrier_data_call_retry_config_default_string";
+
+ /**
+ * The data call APN retry configuration for other type APNs.
+ * @hide
+ */
+ public static final String KEY_CARRIER_DATA_CALL_RETRY_CONFIG_OTHERS_STRING =
+ "carrier_data_call_retry_config_others_string";
+
+ /**
+ * Delay between trying APN from the pool
+ * @hide
+ */
+ public static final String KEY_CARRIER_DATA_CALL_APN_DELAY_DEFAULT_LONG =
+ "carrier_data_call_apn_delay_default_long";
+
+ /**
+ * Faster delay between trying APN from the pool
+ * @hide
+ */
+ public static final String KEY_CARRIER_DATA_CALL_APN_DELAY_FASTER_LONG =
+ "carrier_data_call_apn_delay_faster_long";
+
/* The following 3 fields are related to carrier visual voicemail. */
/**
@@ -456,6 +484,13 @@
*/
public static final String KEY_ALLOW_ADDING_APNS_BOOL = "allow_adding_apns_bool";
+ /**
+ * Boolean indicating if intent for emergency call state changes should be broadcast
+ * @hide
+ */
+ public static final String KEY_BROADCAST_EMERGENCY_CALL_STATE_CHANGES_BOOL =
+ "broadcast_emergency_call_state_changes_bool";
+
// These variables are used by the MMS service and exposed through another API, {@link
// SmsManager}. The variable names and string values are copied from there.
public static final String KEY_MMS_ALIAS_ENABLED_BOOL = "aliasEnabled";
@@ -579,7 +614,15 @@
sDefaults.putString(KEY_CI_ACTION_ON_SYS_UPDATE_EXTRA_VAL_STRING, "");
sDefaults.putBoolean(KEY_CSP_ENABLED_BOOL, false);
sDefaults.putBoolean(KEY_ALLOW_ADDING_APNS_BOOL, true);
+ sDefaults.putBoolean(KEY_BROADCAST_EMERGENCY_CALL_STATE_CHANGES_BOOL, false);
sDefaults.putBoolean(KEY_ALWAYS_SHOW_EMERGENCY_ALERT_ONOFF_BOOL, false);
+ sDefaults.putString(KEY_CARRIER_DATA_CALL_RETRY_CONFIG_DEFAULT_STRING,
+ "default_randomization=2000,5000,10000,20000,40000,80000:5000,160000:5000,"
+ + "320000:5000,640000:5000,1280000:5000,1800000:5000");
+ sDefaults.putString(KEY_CARRIER_DATA_CALL_RETRY_CONFIG_OTHERS_STRING,
+ "max_retries=3, 5000, 5000, 5000");
+ sDefaults.putLong(KEY_CARRIER_DATA_CALL_APN_DELAY_DEFAULT_LONG, 20000);
+ sDefaults.putLong(KEY_CARRIER_DATA_CALL_APN_DELAY_FASTER_LONG, 3000);
sDefaults.putStringArray(KEY_GSM_ROAMING_NETWORKS_STRING_ARRAY, null);
sDefaults.putStringArray(KEY_GSM_NONROAMING_NETWORKS_STRING_ARRAY, null);
@@ -667,7 +710,7 @@
*/
@Nullable
public PersistableBundle getConfig() {
- return getConfigForSubId(SubscriptionManager.getDefaultSubId());
+ return getConfigForSubId(SubscriptionManager.getDefaultSubscriptionId());
}
/**
diff --git a/telephony/java/android/telephony/CellIdentityGsm.java b/telephony/java/android/telephony/CellIdentityGsm.java
index 90d2aa0..74f1171 100644
--- a/telephony/java/android/telephony/CellIdentityGsm.java
+++ b/telephony/java/android/telephony/CellIdentityGsm.java
@@ -38,6 +38,10 @@
private final int mLac;
// 16-bit GSM Cell Identity described in TS 27.007, 0..65535
private final int mCid;
+ // 16-bit GSM Absolute RF Channel Number
+ private final int mArfcn;
+ // 6-bit Base Station Identity Code
+ private final int mBsic;
/**
* @hide
@@ -47,6 +51,8 @@
mMnc = Integer.MAX_VALUE;
mLac = Integer.MAX_VALUE;
mCid = Integer.MAX_VALUE;
+ mArfcn = Integer.MAX_VALUE;
+ mBsic = Integer.MAX_VALUE;
}
/**
* public constructor
@@ -58,10 +64,27 @@
* @hide
*/
public CellIdentityGsm (int mcc, int mnc, int lac, int cid) {
+ this(mcc, mnc, lac, cid, Integer.MAX_VALUE, Integer.MAX_VALUE);
+ }
+
+ /**
+ * public constructor
+ * @param mcc 3-digit Mobile Country Code, 0..999
+ * @param mnc 2 or 3-digit Mobile Network Code, 0..999
+ * @param lac 16-bit Location Area Code, 0..65535
+ * @param cid 16-bit GSM Cell Identity or 28-bit UMTS Cell Identity
+ * @param arfcn 16-bit GSM Absolute RF Channel Number
+ * @param bsic 6-bit Base Station Identity Code
+ *
+ * @hide
+ */
+ public CellIdentityGsm (int mcc, int mnc, int lac, int cid, int arfcn, int bsic) {
mMcc = mcc;
mMnc = mnc;
mLac = lac;
mCid = cid;
+ mArfcn = arfcn;
+ mBsic = bsic;
}
private CellIdentityGsm(CellIdentityGsm cid) {
@@ -69,6 +92,8 @@
mMnc = cid.mMnc;
mLac = cid.mLac;
mCid = cid.mCid;
+ mArfcn = cid.mArfcn;
+ mBsic = cid.mBsic;
}
CellIdentityGsm copy() {
@@ -106,6 +131,21 @@
}
/**
+ * @return 16-bit GSM Absolute RF Channel Number, Integer.MAX_VALUE if unknown
+ */
+ public int getArfcn() {
+ return mArfcn;
+ }
+
+ /**
+ * @return 6-bit Base Station Identity Code, Integer.MAX_VALUE if unknown
+ */
+ public int getBsic() {
+ return mBsic;
+ }
+
+
+ /**
* @return Integer.MAX_VALUE, undefined for GSM
*/
@Deprecated
@@ -132,7 +172,9 @@
return mMcc == o.mMcc &&
mMnc == o.mMnc &&
mLac == o.mLac &&
- mCid == o.mCid;
+ mCid == o.mCid &&
+ mArfcn == o.mArfcn &&
+ mBsic == o.mBsic;
}
@Override
@@ -142,6 +184,8 @@
sb.append(" mMnc=").append(mMnc);
sb.append(" mLac=").append(mLac);
sb.append(" mCid=").append(mCid);
+ sb.append(" mArfcn=").append(mArfcn);
+ sb.append(" mBsic=").append("0x").append(Integer.toHexString(mBsic));
sb.append("}");
return sb.toString();
@@ -161,6 +205,8 @@
dest.writeInt(mMnc);
dest.writeInt(mLac);
dest.writeInt(mCid);
+ dest.writeInt(mArfcn);
+ dest.writeInt(mBsic);
}
/** Construct from Parcel, type has already been processed */
@@ -169,6 +215,8 @@
mMnc = in.readInt();
mLac = in.readInt();
mCid = in.readInt();
+ mArfcn = in.readInt();
+ mBsic = in.readInt();
if (DBG) log("CellIdentityGsm(Parcel): " + toString());
}
diff --git a/telephony/java/android/telephony/CellIdentityLte.java b/telephony/java/android/telephony/CellIdentityLte.java
index 1e7ac08..ce74383 100644
--- a/telephony/java/android/telephony/CellIdentityLte.java
+++ b/telephony/java/android/telephony/CellIdentityLte.java
@@ -40,6 +40,8 @@
private final int mPci;
// 16-bit tracking area code
private final int mTac;
+ // 18-bit Absolute RF Channel Number
+ private final int mEarfcn;
/**
* @hide
@@ -50,6 +52,7 @@
mCi = Integer.MAX_VALUE;
mPci = Integer.MAX_VALUE;
mTac = Integer.MAX_VALUE;
+ mEarfcn = Integer.MAX_VALUE;
}
/**
@@ -63,11 +66,27 @@
* @hide
*/
public CellIdentityLte (int mcc, int mnc, int ci, int pci, int tac) {
+ this(mcc, mnc, ci, pci, tac, Integer.MAX_VALUE);
+ }
+
+ /**
+ *
+ * @param mcc 3-digit Mobile Country Code, 0..999
+ * @param mnc 2 or 3-digit Mobile Network Code, 0..999
+ * @param ci 28-bit Cell Identity
+ * @param pci Physical Cell Id 0..503
+ * @param tac 16-bit Tracking Area Code
+ * @param earfcn 18-bit LTE Absolute RF Channel Number
+ *
+ * @hide
+ */
+ public CellIdentityLte (int mcc, int mnc, int ci, int pci, int tac, int earfcn) {
mMcc = mcc;
mMnc = mnc;
mCi = ci;
mPci = pci;
mTac = tac;
+ mEarfcn = earfcn;
}
private CellIdentityLte(CellIdentityLte cid) {
@@ -76,6 +95,7 @@
mCi = cid.mCi;
mPci = cid.mPci;
mTac = cid.mTac;
+ mEarfcn = cid.mEarfcn;
}
CellIdentityLte copy() {
@@ -117,6 +137,13 @@
return mTac;
}
+ /**
+ * @return 18-bit Absolute RF Channel Number, Integer.MAX_VALUE if unknown
+ */
+ public int getEarfcn() {
+ return mEarfcn;
+ }
+
@Override
public int hashCode() {
return Objects.hash(mMcc, mMnc, mCi, mPci, mTac);
@@ -137,7 +164,8 @@
mMnc == o.mMnc &&
mCi == o.mCi &&
mPci == o.mPci &&
- mTac == o.mTac;
+ mTac == o.mTac &&
+ mEarfcn == o.mEarfcn;
}
@Override
@@ -148,6 +176,7 @@
sb.append(" mCi="); sb.append(mCi);
sb.append(" mPci="); sb.append(mPci);
sb.append(" mTac="); sb.append(mTac);
+ sb.append(" mEarfcn="); sb.append(mEarfcn);
sb.append("}");
return sb.toString();
@@ -168,6 +197,7 @@
dest.writeInt(mCi);
dest.writeInt(mPci);
dest.writeInt(mTac);
+ dest.writeInt(mEarfcn);
}
/** Construct from Parcel, type has already been processed */
@@ -177,6 +207,7 @@
mCi = in.readInt();
mPci = in.readInt();
mTac = in.readInt();
+ mEarfcn = in.readInt();
if (DBG) log("CellIdentityLte(Parcel): " + toString());
}
diff --git a/telephony/java/android/telephony/CellIdentityWcdma.java b/telephony/java/android/telephony/CellIdentityWcdma.java
index 56ee8c9..0d13efd 100644
--- a/telephony/java/android/telephony/CellIdentityWcdma.java
+++ b/telephony/java/android/telephony/CellIdentityWcdma.java
@@ -40,6 +40,8 @@
private final int mCid;
// 9-bit UMTS Primary Scrambling Code described in TS 25.331, 0..511
private final int mPsc;
+ // 16-bit UMTS Absolute RF Channel Number
+ private final int mUarfcn;
/**
* @hide
@@ -50,6 +52,7 @@
mLac = Integer.MAX_VALUE;
mCid = Integer.MAX_VALUE;
mPsc = Integer.MAX_VALUE;
+ mUarfcn = Integer.MAX_VALUE;
}
/**
* public constructor
@@ -62,11 +65,27 @@
* @hide
*/
public CellIdentityWcdma (int mcc, int mnc, int lac, int cid, int psc) {
+ this(mcc, mnc, lac, cid, psc, Integer.MAX_VALUE);
+ }
+
+ /**
+ * public constructor
+ * @param mcc 3-digit Mobile Country Code, 0..999
+ * @param mnc 2 or 3-digit Mobile Network Code, 0..999
+ * @param lac 16-bit Location Area Code, 0..65535
+ * @param cid 28-bit UMTS Cell Identity
+ * @param psc 9-bit UMTS Primary Scrambling Code
+ * @param uarfcn 16-bit UMTS Absolute RF Channel Number
+ *
+ * @hide
+ */
+ public CellIdentityWcdma (int mcc, int mnc, int lac, int cid, int psc, int uarfcn) {
mMcc = mcc;
mMnc = mnc;
mLac = lac;
mCid = cid;
mPsc = psc;
+ mUarfcn = uarfcn;
}
private CellIdentityWcdma(CellIdentityWcdma cid) {
@@ -75,6 +94,7 @@
mLac = cid.mLac;
mCid = cid.mCid;
mPsc = cid.mPsc;
+ mUarfcn = cid.mUarfcn;
}
CellIdentityWcdma copy() {
@@ -123,6 +143,13 @@
return Objects.hash(mMcc, mMnc, mLac, mCid, mPsc);
}
+ /**
+ * @return 16-bit UMTS Absolute RF Channel Number, Integer.MAX_VALUE if unknown
+ */
+ public int getUarfcn() {
+ return mUarfcn;
+ }
+
@Override
public boolean equals(Object other) {
if (this == other) {
@@ -138,7 +165,8 @@
mMnc == o.mMnc &&
mLac == o.mLac &&
mCid == o.mCid &&
- mPsc == o.mPsc;
+ mPsc == o.mPsc &&
+ mUarfcn == o.mUarfcn;
}
@Override
@@ -149,6 +177,7 @@
sb.append(" mLac=").append(mLac);
sb.append(" mCid=").append(mCid);
sb.append(" mPsc=").append(mPsc);
+ sb.append(" mUarfcn=").append(mUarfcn);
sb.append("}");
return sb.toString();
@@ -169,6 +198,7 @@
dest.writeInt(mLac);
dest.writeInt(mCid);
dest.writeInt(mPsc);
+ dest.writeInt(mUarfcn);
}
/** Construct from Parcel, type has already been processed */
@@ -178,6 +208,7 @@
mLac = in.readInt();
mCid = in.readInt();
mPsc = in.readInt();
+ mUarfcn = in.readInt();
if (DBG) log("CellIdentityWcdma(Parcel): " + toString());
}
diff --git a/telephony/java/android/telephony/CellSignalStrengthGsm.java b/telephony/java/android/telephony/CellSignalStrengthGsm.java
index d27fcec..addf7ef 100644
--- a/telephony/java/android/telephony/CellSignalStrengthGsm.java
+++ b/telephony/java/android/telephony/CellSignalStrengthGsm.java
@@ -34,6 +34,7 @@
private int mSignalStrength; // Valid values are (0-31, 99) as defined in TS 27.007 8.5
private int mBitErrorRate; // bit error rate (0-7, 99) as defined in TS 27.007 8.5
+ private int mTimingAdvance;
/**
* Empty constructor
@@ -75,6 +76,22 @@
public void initialize(int ss, int ber) {
mSignalStrength = ss;
mBitErrorRate = ber;
+ mTimingAdvance = Integer.MAX_VALUE;
+ }
+
+ /**
+ * Initialize all the values
+ *
+ * @param ss SignalStrength as ASU value
+ * @param ber is Bit Error Rate
+ * @param ta timing advance
+ *
+ * @hide
+ */
+ public void initialize(int ss, int ber, int ta) {
+ mSignalStrength = ss;
+ mBitErrorRate = ber;
+ mTimingAdvance = ta;
}
/**
@@ -83,6 +100,7 @@
protected void copyFrom(CellSignalStrengthGsm s) {
mSignalStrength = s.mSignalStrength;
mBitErrorRate = s.mBitErrorRate;
+ mTimingAdvance = s.mTimingAdvance;
}
/**
@@ -98,6 +116,7 @@
public void setDefaultValues() {
mSignalStrength = Integer.MAX_VALUE;
mBitErrorRate = Integer.MAX_VALUE;
+ mTimingAdvance = Integer.MAX_VALUE;
}
/**
@@ -174,7 +193,8 @@
return false;
}
- return mSignalStrength == s.mSignalStrength && mBitErrorRate == s.mBitErrorRate;
+ return mSignalStrength == s.mSignalStrength && mBitErrorRate == s.mBitErrorRate &&
+ s.mTimingAdvance == mTimingAdvance;
}
/**
@@ -184,7 +204,8 @@
public String toString() {
return "CellSignalStrengthGsm:"
+ " ss=" + mSignalStrength
- + " ber=" + mBitErrorRate;
+ + " ber=" + mBitErrorRate
+ + " mTa=" + mTimingAdvance;
}
/** Implement the Parcelable interface */
@@ -193,6 +214,7 @@
if (DBG) log("writeToParcel(Parcel, int): " + toString());
dest.writeInt(mSignalStrength);
dest.writeInt(mBitErrorRate);
+ dest.writeInt(mTimingAdvance);
}
/**
@@ -202,6 +224,7 @@
private CellSignalStrengthGsm(Parcel in) {
mSignalStrength = in.readInt();
mBitErrorRate = in.readInt();
+ mTimingAdvance = in.readInt();
if (DBG) log("CellSignalStrengthGsm(Parcel): " + toString());
}
diff --git a/telephony/java/android/telephony/DataConnectionRealTimeInfo.java b/telephony/java/android/telephony/DataConnectionRealTimeInfo.java
index 96069213..f71f58d 100644
--- a/telephony/java/android/telephony/DataConnectionRealTimeInfo.java
+++ b/telephony/java/android/telephony/DataConnectionRealTimeInfo.java
@@ -28,10 +28,10 @@
public class DataConnectionRealTimeInfo implements Parcelable {
private long mTime; // Time the info was collected since boot in nanos;
- public static int DC_POWER_STATE_LOW = 1;
- public static int DC_POWER_STATE_MEDIUM = 2;
- public static int DC_POWER_STATE_HIGH = 3;
- public static int DC_POWER_STATE_UNKNOWN = Integer.MAX_VALUE;
+ public static final int DC_POWER_STATE_LOW = 1;
+ public static final int DC_POWER_STATE_MEDIUM = 2;
+ public static final int DC_POWER_STATE_HIGH = 3;
+ public static final int DC_POWER_STATE_UNKNOWN = Integer.MAX_VALUE;
private int mDcPowerState; // DC_POWER_STATE_[LOW | MEDIUM | HIGH | UNKNOWN]
diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java
index 553221d..962a600 100644
--- a/telephony/java/android/telephony/PhoneNumberUtils.java
+++ b/telephony/java/android/telephony/PhoneNumberUtils.java
@@ -1857,9 +1857,6 @@
// to the list.
number = extractNetworkPortionAlt(number);
- Rlog.d(LOG_TAG, "subId:" + subId + ", defaultCountryIso:" +
- ((defaultCountryIso == null) ? "NULL" : defaultCountryIso));
-
String emergencyNumbers = "";
int slotId = SubscriptionManager.getSlotId(subId);
@@ -1869,7 +1866,8 @@
emergencyNumbers = SystemProperties.get(ecclist, "");
- Rlog.d(LOG_TAG, "slotId:" + slotId + ", emergencyNumbers: " + emergencyNumbers);
+ Rlog.d(LOG_TAG, "slotId:" + slotId + " subId:" + subId + " country:"
+ + defaultCountryIso + " emergencyNumbers: " + emergencyNumbers);
if (TextUtils.isEmpty(emergencyNumbers)) {
// then read-only ecclist property since old RIL only uses this
@@ -2082,7 +2080,7 @@
* to read the VM number.
*/
public static boolean isVoiceMailNumber(String number) {
- return isVoiceMailNumber(SubscriptionManager.getDefaultSubId(), number);
+ return isVoiceMailNumber(SubscriptionManager.getDefaultSubscriptionId(), number);
}
/**
@@ -2977,7 +2975,7 @@
* Returns Default voice subscription Id.
*/
private static int getDefaultVoiceSubId() {
- return SubscriptionManager.getDefaultVoiceSubId();
+ return SubscriptionManager.getDefaultVoiceSubscriptionId();
}
//==== End of utility methods used only in compareStrictly() =====
}
diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java
index 8537f9c..ad007c6 100644
--- a/telephony/java/android/telephony/ServiceState.java
+++ b/telephony/java/android/telephony/ServiceState.java
@@ -37,6 +37,7 @@
static final String LOG_TAG = "PHONE";
static final boolean DBG = true;
+ static final boolean VDBG = false; // STOPSHIP if true
/**
* Normal operation condition, the phone is registered
@@ -153,6 +154,17 @@
* @hide
*/
public static final int RIL_RADIO_TECHNOLOGY_IWLAN = 18;
+
+ /** @hide */
+ public static final int RIL_RADIO_CDMA_TECHNOLOGY_BITMASK =
+ (1 << (RIL_RADIO_TECHNOLOGY_IS95A - 1))
+ | (1 << (RIL_RADIO_TECHNOLOGY_IS95B - 1))
+ | (1 << (RIL_RADIO_TECHNOLOGY_1xRTT - 1))
+ | (1 << (RIL_RADIO_TECHNOLOGY_EVDO_0 - 1))
+ | (1 << (RIL_RADIO_TECHNOLOGY_EVDO_A - 1))
+ | (1 << (RIL_RADIO_TECHNOLOGY_EVDO_B - 1))
+ | (1 << (RIL_RADIO_TECHNOLOGY_EHRPD - 1));
+
/**
* Available registration states for GSM, UMTS and CDMA.
*/
@@ -818,7 +830,7 @@
/** @hide */
public void setDataRegState(int state) {
mDataRegState = state;
- if (DBG) Rlog.d(LOG_TAG, "[ServiceState] setDataRegState=" + mDataRegState);
+ if (VDBG) Rlog.d(LOG_TAG, "[ServiceState] setDataRegState=" + mDataRegState);
}
public void setRoaming(boolean roaming) {
@@ -1006,7 +1018,8 @@
/** @hide */
public void setRilDataRadioTechnology(int rt) {
this.mRilDataRadioTechnology = rt;
- if (DBG) Rlog.d(LOG_TAG, "[ServiceState] setDataRadioTechnology=" + mRilDataRadioTechnology);
+ if (VDBG) Rlog.d(LOG_TAG, "[ServiceState] setRilDataRadioTechnology=" +
+ mRilDataRadioTechnology);
}
/** @hide */
@@ -1141,16 +1154,8 @@
}
/** @hide */
- public static boolean hasCdma(int radioTechnologyBitmask) {
- int cdmaBitmask = (RIL_RADIO_TECHNOLOGY_IS95A
- | RIL_RADIO_TECHNOLOGY_IS95B
- | RIL_RADIO_TECHNOLOGY_1xRTT
- | RIL_RADIO_TECHNOLOGY_EVDO_0
- | RIL_RADIO_TECHNOLOGY_EVDO_A
- | RIL_RADIO_TECHNOLOGY_EVDO_B
- | RIL_RADIO_TECHNOLOGY_EHRPD);
-
- return ((radioTechnologyBitmask & cdmaBitmask) != 0);
+ public static boolean bearerBitmapHasCdma(int radioTechnologyBitmap) {
+ return (RIL_RADIO_CDMA_TECHNOLOGY_BITMASK & radioTechnologyBitmap) != 0;
}
/** @hide */
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index 36407e1..ff8c71c 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -53,7 +53,6 @@
private static final boolean VDBG = false;
/** An invalid subscription identifier */
- /** @hide */
public static final int INVALID_SUBSCRIPTION_ID = -1;
/** Base value for Dummy SUBSCRIPTION_ID's. */
@@ -455,8 +454,9 @@
}
/**
- * Get the active SubscriptionInfo with the subId key
- * @param subId The unique SubscriptionInfo key in database
+ * Get the active SubscriptionInfo with the input subId.
+ *
+ * @param subId The unique SubscriptionInfo key in database.
* @return SubscriptionInfo, maybe null if its not active.
*/
public SubscriptionInfo getActiveSubscriptionInfo(int subId) {
@@ -898,12 +898,15 @@
}
/**
- * @return the "system" defaultSubId on a voice capable device this
- * will be getDefaultVoiceSubId() and on a data only device it will be
- * getDefaultDataSubId().
- * @hide
+ * Returns the system's default subscription id.
+ *
+ * For a voice capable device, it will return getDefaultVoiceSubscriptionId.
+ * For a data only device, it will return the getDefaultDataSubscriptionId.
+ * May return an INVALID_SUBSCRIPTION_ID on error.
+ *
+ * @return the "system" default subscription id.
*/
- public static int getDefaultSubId() {
+ public static int getDefaultSubscriptionId() {
int subId = INVALID_SUBSCRIPTION_ID;
try {
@@ -919,8 +922,14 @@
return subId;
}
- /** @hide */
- public static int getDefaultVoiceSubId() {
+ /**
+ * Returns the system's default voice subscription id.
+ *
+ * On a data only device or on error, will return INVALID_SUBSCRIPTION_ID.
+ *
+ * @return the default voice subscription Id.
+ */
+ public static int getDefaultVoiceSubscriptionId() {
int subId = INVALID_SUBSCRIPTION_ID;
try {
@@ -932,7 +941,7 @@
// ignore it
}
- if (VDBG) logd("getDefaultVoiceSubId, sub id = " + subId);
+ if (VDBG) logd("getDefaultVoiceSubscriptionId, sub id = " + subId);
return subId;
}
@@ -949,23 +958,31 @@
}
}
- /** @hide */
+ /**
+ * Return the SubscriptionInfo for default voice subscription.
+ *
+ * Will return null on data only devices, or on error.
+ *
+ * @return the SubscriptionInfo for the default voice subscription.
+ * @hide
+ */
public SubscriptionInfo getDefaultVoiceSubscriptionInfo() {
- return getActiveSubscriptionInfo(getDefaultVoiceSubId());
+ return getActiveSubscriptionInfo(getDefaultVoiceSubscriptionId());
}
/** @hide */
public static int getDefaultVoicePhoneId() {
- return getPhoneId(getDefaultVoiceSubId());
+ return getPhoneId(getDefaultVoiceSubscriptionId());
}
/**
- * @return subId of the DefaultSms subscription or
- * a value < 0 if an error.
+ * Returns the system's default SMS subscription id.
*
- * @hide
+ * On a data only device or on error, will return INVALID_SUBSCRIPTION_ID.
+ *
+ * @return the default SMS subscription Id.
*/
- public static int getDefaultSmsSubId() {
+ public static int getDefaultSmsSubscriptionId() {
int subId = INVALID_SUBSCRIPTION_ID;
try {
@@ -977,7 +994,7 @@
// ignore it
}
- if (VDBG) logd("getDefaultSmsSubId, sub id = " + subId);
+ if (VDBG) logd("getDefaultSmsSubscriptionId, sub id = " + subId);
return subId;
}
@@ -994,18 +1011,31 @@
}
}
- /** @hide */
+ /**
+ * Return the SubscriptionInfo for default voice subscription.
+ *
+ * Will return null on data only devices, or on error.
+ *
+ * @return the SubscriptionInfo for the default SMS subscription.
+ * @hide
+ */
public SubscriptionInfo getDefaultSmsSubscriptionInfo() {
- return getActiveSubscriptionInfo(getDefaultSmsSubId());
+ return getActiveSubscriptionInfo(getDefaultSmsSubscriptionId());
}
/** @hide */
public int getDefaultSmsPhoneId() {
- return getPhoneId(getDefaultSmsSubId());
+ return getPhoneId(getDefaultSmsSubscriptionId());
}
- /** @hide */
- public static int getDefaultDataSubId() {
+ /**
+ * Returns the system's default data subscription id.
+ *
+ * On a voice only device or on error, will return INVALID_SUBSCRIPTION_ID.
+ *
+ * @return the default data subscription Id.
+ */
+ public static int getDefaultDataSubscriptionId() {
int subId = INVALID_SUBSCRIPTION_ID;
try {
@@ -1017,7 +1047,7 @@
// ignore it
}
- if (VDBG) logd("getDefaultDataSubId, sub id = " + subId);
+ if (VDBG) logd("getDefaultDataSubscriptionId, sub id = " + subId);
return subId;
}
@@ -1034,14 +1064,21 @@
}
}
- /** @hide */
+ /**
+ * Return the SubscriptionInfo for default data subscription.
+ *
+ * Will return null on voice only devices, or on error.
+ *
+ * @return the SubscriptionInfo for the default data subscription.
+ * @hide
+ */
public SubscriptionInfo getDefaultDataSubscriptionInfo() {
- return getActiveSubscriptionInfo(getDefaultDataSubId());
+ return getActiveSubscriptionInfo(getDefaultDataSubscriptionId());
}
/** @hide */
public int getDefaultDataPhoneId() {
- return getPhoneId(getDefaultDataSubId());
+ return getPhoneId(getDefaultDataSubscriptionId());
}
/** @hide */
@@ -1061,13 +1098,13 @@
//FIXME this is vulnerable to race conditions
/** @hide */
public boolean allDefaultsSelected() {
- if (!isValidSubscriptionId(getDefaultDataSubId())) {
+ if (!isValidSubscriptionId(getDefaultDataSubscriptionId())) {
return false;
}
- if (!isValidSubscriptionId(getDefaultSmsSubId())) {
+ if (!isValidSubscriptionId(getDefaultSmsSubscriptionId())) {
return false;
}
- if (!isValidSubscriptionId(getDefaultVoiceSubId())) {
+ if (!isValidSubscriptionId(getDefaultVoiceSubscriptionId())) {
return false;
}
return true;
@@ -1207,7 +1244,7 @@
}
} catch (RemoteException ex) {
}
- logd("getSimStateForSubscriber: simState=" + simState + " slotIdx=" + slotIdx);
+
return simState;
}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 3b281e2..5e689f8 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -766,7 +766,7 @@
IPhoneSubInfo info = getSubscriberInfo();
if (info == null)
return null;
- return info.getDeviceIdForPhone(slotId);
+ return info.getDeviceIdForPhone(slotId, mContext.getOpPackageName());
} catch (RemoteException ex) {
return null;
} catch (NullPointerException ex) {
@@ -1230,7 +1230,6 @@
* on a CDMA network).
* @param subId
*/
- /** {@hide} */
public String getNetworkOperatorName(int subId) {
int phoneId = SubscriptionManager.getPhoneId(subId);
return getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_OPERATOR_ALPHA, "");
@@ -1257,8 +1256,7 @@
*
* @param subId
*/
- /** {@hide} */
- public String getNetworkOperatorForSubscription(int subId) {
+ public String getNetworkOperator(int subId) {
int phoneId = SubscriptionManager.getPhoneId(subId);
return getNetworkOperatorForPhone(phoneId);
}
@@ -1274,7 +1272,7 @@
* @param phoneId
* @hide
**/
- public String getNetworkOperatorForPhone(int phoneId) {
+ public String getNetworkOperatorForPhone(int phoneId) {
return getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, "");
}
@@ -1296,7 +1294,6 @@
*
* @param subId
*/
- /** {@hide} */
public boolean isNetworkRoaming(int subId) {
int phoneId = SubscriptionManager.getPhoneId(subId);
return Boolean.parseBoolean(getTelephonyProperty(phoneId,
@@ -1325,8 +1322,7 @@
*
* @param subId for which Network CountryIso is returned
*/
- /** {@hide} */
- public String getNetworkCountryIsoForSubscription(int subId) {
+ public String getNetworkCountryIso(int subId) {
int phoneId = SubscriptionManager.getPhoneId(subId);
return getNetworkCountryIsoForPhone(phoneId);
}
@@ -1434,7 +1430,6 @@
* Requires Permission:
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
*/
- /** {@hide} */
public int getNetworkType(int subId) {
try {
ITelephony telephony = getITelephony();
@@ -1495,7 +1490,6 @@
* Requires Permission:
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
*/
- /** {@hide} */
public int getDataNetworkType(int subId) {
try{
ITelephony telephony = getITelephony();
@@ -1533,7 +1527,6 @@
* Requires Permission:
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
*/
- /** {@hide} */
public int getVoiceNetworkType(int subId) {
try{
ITelephony telephony = getITelephony();
@@ -1802,10 +1795,9 @@
* @see #getSimState
*
* @param subId for which SimOperator is returned
- * @hide
*/
public String getSimOperator(int subId) {
- return getSimOperatorNumericForSubscription(subId);
+ return getSimOperatorNumeric(subId);
}
/**
@@ -1818,17 +1810,17 @@
* @hide
*/
public String getSimOperatorNumeric() {
- int subId = SubscriptionManager.getDefaultDataSubId();
+ int subId = SubscriptionManager.getDefaultDataSubscriptionId();
if (!SubscriptionManager.isUsableSubIdValue(subId)) {
- subId = SubscriptionManager.getDefaultSmsSubId();
+ subId = SubscriptionManager.getDefaultSmsSubscriptionId();
if (!SubscriptionManager.isUsableSubIdValue(subId)) {
- subId = SubscriptionManager.getDefaultVoiceSubId();
+ subId = SubscriptionManager.getDefaultVoiceSubscriptionId();
if (!SubscriptionManager.isUsableSubIdValue(subId)) {
- subId = SubscriptionManager.getDefaultSubId();
+ subId = SubscriptionManager.getDefaultSubscriptionId();
}
}
}
- return getSimOperatorNumericForSubscription(subId);
+ return getSimOperatorNumeric(subId);
}
/**
@@ -1842,7 +1834,7 @@
* @param subId for which SimOperator is returned
* @hide
*/
- public String getSimOperatorNumericForSubscription(int subId) {
+ public String getSimOperatorNumeric(int subId) {
int phoneId = SubscriptionManager.getPhoneId(subId);
return getSimOperatorNumericForPhone(phoneId);
}
@@ -1879,9 +1871,8 @@
* @see #getSimState
*
* @param subId for which SimOperatorName is returned
- * @hide
*/
- public String getSimOperatorNameForSubscription(int subId) {
+ public String getSimOperatorName(int subId) {
int phoneId = SubscriptionManager.getPhoneId(subId);
return getSimOperatorNameForPhone(phoneId);
}
@@ -1907,21 +1898,8 @@
* Returns the ISO country code equivalent for the SIM provider's country code.
*
* @param subId for which SimCountryIso is returned
- *
- * @hide
*/
public String getSimCountryIso(int subId) {
- return getSimCountryIsoForSubscription(subId);
- }
-
- /**
- * Returns the ISO country code equivalent for the SIM provider's country code.
- *
- * @param subId for which SimCountryIso is returned
- *
- * @hide
- */
- public String getSimCountryIsoForSubscription(int subId) {
int phoneId = SubscriptionManager.getPhoneId(subId);
return getSimCountryIsoForPhone(phoneId);
}
@@ -1955,7 +1933,6 @@
* Requires Permission:
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
*/
- /** {@hide} */
public String getSimSerialNumber(int subId) {
try {
IPhoneSubInfo info = getSubscriberInfo();
@@ -2044,7 +2021,6 @@
*
* @param subId whose subscriber id is returned
*/
- /** {@hide} */
public String getSubscriberId(int subId) {
try {
IPhoneSubInfo info = getSubscriberInfo();
@@ -2087,9 +2063,8 @@
* Requires Permission:
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
*
- * @param subscription whose subscriber id is returned
+ * @param subId whose subscriber id is returned
*/
- /** {@hide} */
public String getGroupIdLevel1(int subId) {
try {
IPhoneSubInfo info = getSubscriberInfo();
@@ -2116,7 +2091,7 @@
* The default SMS app can also use this.
*/
public String getLine1Number() {
- return getLine1NumberForSubscriber(getDefaultSubscription());
+ return getLine1Number(getDefaultSubscription());
}
/**
@@ -2132,8 +2107,7 @@
*
* @param subId whose phone number for line 1 is returned
*/
- /** {@hide} */
- public String getLine1NumberForSubscriber(int subId) {
+ public String getLine1Number(int subId) {
String number = null;
try {
ITelephony telephony = getITelephony();
@@ -2172,7 +2146,7 @@
* @return true if the operation was executed correctly.
*/
public boolean setLine1NumberForDisplay(String alphaTag, String number) {
- return setLine1NumberForDisplayForSubscriber(getDefaultSubscription(), alphaTag, number);
+ return setLine1NumberForDisplay(getDefaultSubscription(), alphaTag, number);
}
/**
@@ -2188,9 +2162,8 @@
* @param alphaTag alpha-tagging of the dailing nubmer
* @param number The dialing number
* @return true if the operation was executed correctly.
- * @hide
*/
- public boolean setLine1NumberForDisplayForSubscriber(int subId, String alphaTag, String number) {
+ public boolean setLine1NumberForDisplay(int subId, String alphaTag, String number) {
try {
ITelephony telephony = getITelephony();
if (telephony != null)
@@ -2211,7 +2184,7 @@
* nobody seems to call this.
*/
public String getLine1AlphaTag() {
- return getLine1AlphaTagForSubscriber(getDefaultSubscription());
+ return getLine1AlphaTag(getDefaultSubscription());
}
/**
@@ -2224,8 +2197,7 @@
* @param subId whose alphabetic identifier associated with line 1 is returned
* nobody seems to call this.
*/
- /** {@hide} */
- public String getLine1AlphaTagForSubscriber(int subId) {
+ public String getLine1AlphaTag(int subId) {
String alphaTag = null;
try {
ITelephony telephony = getITelephony();
@@ -2325,7 +2297,6 @@
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
* @param subId whose voice mail number is returned
*/
- /** {@hide} */
public String getVoiceMailNumber(int subId) {
try {
IPhoneSubInfo info = getSubscriberInfo();
@@ -2398,7 +2369,6 @@
* @param alphaTag The alpha tag to display.
* @param number The voicemail number.
*/
- /** {@hide} */
public boolean setVoiceMailNumber(int subId, String alphaTag, String number) {
try {
ITelephony telephony = getITelephony();
@@ -2464,7 +2434,6 @@
* @param subId whose alphabetic identifier associated with the
* voice mail number is returned
*/
- /** {@hide} */
public String getVoiceMailAlphaTag(int subId) {
try {
IPhoneSubInfo info = getSubscriberInfo();
@@ -2582,7 +2551,6 @@
*
* @param subId whose call state is returned
*/
- /** {@hide} */
public int getCallState(int subId) {
try {
ITelephony telephony = getITelephony();
@@ -3223,19 +3191,19 @@
* Returns Default subscription.
*/
private static int getDefaultSubscription() {
- return SubscriptionManager.getDefaultSubId();
+ return SubscriptionManager.getDefaultSubscriptionId();
}
/**
* Returns Default phone.
*/
private static int getDefaultPhone() {
- return SubscriptionManager.getPhoneId(SubscriptionManager.getDefaultSubId());
+ return SubscriptionManager.getPhoneId(SubscriptionManager.getDefaultSubscriptionId());
}
/** {@hide} */
public int getDefaultSim() {
- return SubscriptionManager.getSlotId(SubscriptionManager.getDefaultSubId());
+ return SubscriptionManager.getSlotId(SubscriptionManager.getDefaultSubscriptionId());
}
/**
@@ -4190,7 +4158,7 @@
/** @hide */
@SystemApi
public void setDataEnabled(boolean enable) {
- setDataEnabled(SubscriptionManager.getDefaultDataSubId(), enable);
+ setDataEnabled(SubscriptionManager.getDefaultDataSubscriptionId(), enable);
}
/** @hide */
@@ -4209,7 +4177,7 @@
/** @hide */
@SystemApi
public boolean getDataEnabled() {
- return getDataEnabled(SubscriptionManager.getDefaultDataSubId());
+ return getDataEnabled(SubscriptionManager.getDefaultDataSubscriptionId());
}
/** @hide */
@@ -4865,4 +4833,4 @@
}
return null;
}
-}
\ No newline at end of file
+}
diff --git a/telephony/java/com/android/internal/telephony/CallerInfo.java b/telephony/java/com/android/internal/telephony/CallerInfo.java
index be7e702..ee5a152 100644
--- a/telephony/java/com/android/internal/telephony/CallerInfo.java
+++ b/telephony/java/com/android/internal/telephony/CallerInfo.java
@@ -309,7 +309,7 @@
public static CallerInfo getCallerInfo(Context context, String number) {
if (VDBG) Rlog.v(TAG, "getCallerInfo() based on number...");
- int subId = SubscriptionManager.getDefaultSubId();
+ int subId = SubscriptionManager.getDefaultSubscriptionId();
return getCallerInfo(context, number, subId);
}
@@ -426,7 +426,7 @@
// string in the phone number field.
/* package */ CallerInfo markAsVoiceMail() {
- int subId = SubscriptionManager.getDefaultSubId();
+ int subId = SubscriptionManager.getDefaultSubscriptionId();
return markAsVoiceMail(subId);
}
diff --git a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java b/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java
index c754068..05cb31e 100644
--- a/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java
+++ b/telephony/java/com/android/internal/telephony/CallerInfoAsyncQuery.java
@@ -387,7 +387,7 @@
public static CallerInfoAsyncQuery startQuery(int token, Context context, String number,
OnQueryCompleteListener listener, Object cookie) {
- int subId = SubscriptionManager.getDefaultSubId();
+ int subId = SubscriptionManager.getDefaultSubscriptionId();
return startQuery(token, context, number, listener, cookie, subId);
}
diff --git a/telephony/java/com/android/internal/telephony/DctConstants.java b/telephony/java/com/android/internal/telephony/DctConstants.java
index a4e9486..fcb967f 100644
--- a/telephony/java/com/android/internal/telephony/DctConstants.java
+++ b/telephony/java/com/android/internal/telephony/DctConstants.java
@@ -44,7 +44,9 @@
CONNECTED,
DISCONNECTING,
FAILED,
- RETRYING
+ RETRYING // After moving retry manager to ApnContext, we'll never enter this state!
+ // Todo: Remove this state and other places that use this state and then
+ // rename SCANNING to RETRYING.
}
public enum Activity {
diff --git a/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl b/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl
index ed85392..dc2b297 100644
--- a/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl
+++ b/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl
@@ -36,7 +36,7 @@
* Retrieves the unique device ID of a phone for the device, e.g., IMEI
* for GSM phones.
*/
- String getDeviceIdForPhone(int phoneId);
+ String getDeviceIdForPhone(int phoneId, String callingPackage);
/**
* Retrieves the IMEI.
diff --git a/telephony/java/com/android/internal/telephony/ITelephonyDebug.aidl b/telephony/java/com/android/internal/telephony/ITelephonyDebug.aidl
new file mode 100644
index 0000000..5dffa28
--- /dev/null
+++ b/telephony/java/com/android/internal/telephony/ITelephonyDebug.aidl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.internal.telephony;
+
+import android.os.Bundle;
+
+
+/**
+ * Interface used to interact with the Telephony debug service.
+ *
+ * {@hide}
+ */
+interface ITelephonyDebug {
+
+ /**
+ * Write telephony event
+ * @param timestamp returned by System.currentTimeMillis()
+ * @param phoneId for which event is written
+ * @param tag constant defined in TelephonyEventLog
+ * @param param1 optional
+ * @param param2 optional
+ * @param data optional
+ */
+ void writeEvent(long timestamp, int phoneId, int tag, int param1, int param2, in Bundle data);
+}
diff --git a/telephony/java/com/android/internal/telephony/PhoneConstants.java b/telephony/java/com/android/internal/telephony/PhoneConstants.java
index a183de5..ecd89ed 100644
--- a/telephony/java/com/android/internal/telephony/PhoneConstants.java
+++ b/telephony/java/com/android/internal/telephony/PhoneConstants.java
@@ -35,17 +35,17 @@
IDLE, RINGING, OFFHOOK;
};
- /**
- * The state of a data connection.
- * <ul>
- * <li>CONNECTED = IP traffic should be available</li>
- * <li>CONNECTING = Currently setting up data connection</li>
- * <li>DISCONNECTED = IP not available</li>
- * <li>SUSPENDED = connection is created but IP traffic is
- * temperately not available. i.e. voice call is in place
- * in 2G network</li>
- * </ul>
- */
+ /**
+ * The state of a data connection.
+ * <ul>
+ * <li>CONNECTED = IP traffic should be available</li>
+ * <li>CONNECTING = Currently setting up data connection</li>
+ * <li>DISCONNECTED = IP not available</li>
+ * <li>SUSPENDED = connection is created but IP traffic is
+ * temperately not available. i.e. voice call is in place
+ * in 2G network</li>
+ * </ul>
+ */
public enum DataState {
CONNECTED, CONNECTING, DISCONNECTED, SUSPENDED;
};
@@ -89,6 +89,7 @@
public static final String NETWORK_UNAVAILABLE_KEY = "networkUnvailable";
public static final String DATA_NETWORK_ROAMING_KEY = "networkRoaming";
public static final String PHONE_IN_ECM_STATE = "phoneinECMState";
+ public static final String PHONE_IN_EMERGENCY_CALL = "phoneInEmergencyCall";
public static final String REASON_LINK_PROPERTIES_CHANGED = "linkPropertiesChanged";
diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java
index 3c4c04b..7d5645e 100644
--- a/telephony/java/com/android/internal/telephony/RILConstants.java
+++ b/telephony/java/com/android/internal/telephony/RILConstants.java
@@ -336,6 +336,8 @@
int RIL_REQUEST_PULL_LCEDATA = 134;
int RIL_REQUEST_GET_ACTIVITY_INFO = 135;
+ int RIL_RESPONSE_ACKNOWLEDGEMENT = 800;
+
int RIL_UNSOL_RESPONSE_BASE = 1000;
int RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED = 1000;
int RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED = 1001;
diff --git a/telephony/java/com/android/internal/telephony/TelephonyIntents.java b/telephony/java/com/android/internal/telephony/TelephonyIntents.java
index f563839..77b8a67 100644
--- a/telephony/java/com/android/internal/telephony/TelephonyIntents.java
+++ b/telephony/java/com/android/internal/telephony/TelephonyIntents.java
@@ -75,6 +75,7 @@
*/
public static final String ACTION_RADIO_TECHNOLOGY_CHANGED
= "android.intent.action.RADIO_TECHNOLOGY";
+
/**
* <p>Broadcast Action: The emergency callback mode is changed.
* <ul>
@@ -94,6 +95,28 @@
*/
public static final String ACTION_EMERGENCY_CALLBACK_MODE_CHANGED
= "android.intent.action.EMERGENCY_CALLBACK_MODE_CHANGED";
+
+ /**
+ * <p>Broadcast Action: The emergency call state is changed.
+ * <ul>
+ * <li><em>phoneInEmergencyCall</em> - A boolean value, true if phone in emergency call,
+ * false otherwise</li>
+ * </ul>
+ * <p class="note">
+ * You can <em>not</em> receive this through components declared
+ * in manifests, only by explicitly registering for it with
+ * {@link android.content.Context#registerReceiver(android.content.BroadcastReceiver,
+ * android.content.IntentFilter) Context.registerReceiver()}.
+ *
+ * <p class="note">
+ * Requires no permission.
+ *
+ * <p class="note">This is a protected intent that can only be sent
+ * by the system.
+ */
+ public static final String ACTION_EMERGENCY_CALL_STATE_CHANGED
+ = "android.intent.action.EMERGENCY_CALL_STATE_CHANGED";
+
/**
* Broadcast Action: The phone's signal strength has changed. The intent will have the
* following extra values:</p>
diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java
index dc329e2..c6354bd 100644
--- a/wifi/java/android/net/wifi/WifiConfiguration.java
+++ b/wifi/java/android/net/wifi/WifiConfiguration.java
@@ -24,15 +24,12 @@
import android.net.StaticIpConfiguration;
import android.os.Parcel;
import android.os.Parcelable;
+import android.os.UserHandle;
import android.text.TextUtils;
-import android.util.Log;
-import java.util.HashMap;
+import java.util.Arrays;
import java.util.BitSet;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
+import java.util.HashMap;
/**
* A class representing a configured Wi-Fi network, including the
@@ -182,19 +179,6 @@
}
/** @hide */
- public static final int DISABLED_UNKNOWN_REASON = 0;
- /** @hide */
- public static final int DISABLED_DNS_FAILURE = 1;
- /** @hide */
- public static final int DISABLED_DHCP_FAILURE = 2;
- /** @hide */
- public static final int DISABLED_AUTH_FAILURE = 3;
- /** @hide */
- public static final int DISABLED_ASSOCIATION_REJECT = 4;
- /** @hide */
- public static final int DISABLED_BY_WIFI_MANAGER = 5;
-
- /** @hide */
public static final int UNKNOWN_UID = -1;
/**
@@ -206,24 +190,12 @@
/**
* The current status of this network configuration entry.
+ * Fixme We need remove this field to use only Quality network selection status only
* @see Status
*/
public int status;
/**
- * The configuration needs to be written to networkHistory.txt
- * @hide
- */
- public boolean dirty;
-
- /**
- * The code referring to a reason for disabling the network
- * Valid when {@link #status} == Status.DISABLED
- * @hide
- */
- public int disableReason;
-
- /**
* The network's SSID. Can either be an ASCII string,
* which must be enclosed in double quotation marks
* (e.g., {@code "MyNetwork"}, or a string of
@@ -356,6 +328,13 @@
/**
* @hide
+ * This network configuration is visible to and usable by other users on the
+ * same device.
+ */
+ public boolean shared;
+
+ /**
+ * @hide
*/
private IpConfiguration mIpConfiguration;
@@ -421,12 +400,6 @@
/**
* @hide
- * Uid used by autoJoin
- */
- public String autoJoinBSSID;
-
- /**
- * @hide
* Status of user approval for connection
*/
public int userApproved = USER_UNSPECIFIED;
@@ -444,77 +417,6 @@
/** @hide **/
public static int INVALID_RSSI = -127;
- /** @hide **/
- public static int UNWANTED_BLACKLIST_SOFT_RSSI_24 = -80;
-
- /** @hide **/
- public static int UNWANTED_BLACKLIST_SOFT_RSSI_5 = -70;
-
- /** @hide **/
- public static int GOOD_RSSI_24 = -65;
-
- /** @hide **/
- public static int LOW_RSSI_24 = -77;
-
- /** @hide **/
- public static int BAD_RSSI_24 = -87;
-
- /** @hide **/
- public static int GOOD_RSSI_5 = -60;
-
- /** @hide **/
- public static int LOW_RSSI_5 = -72;
-
- /** @hide **/
- public static int BAD_RSSI_5 = -82;
-
- /** @hide **/
- public static int UNWANTED_BLACKLIST_SOFT_BUMP = 4;
-
- /** @hide **/
- public static int UNWANTED_BLACKLIST_HARD_BUMP = 8;
-
- /** @hide **/
- public static int UNBLACKLIST_THRESHOLD_24_SOFT = -77;
-
- /** @hide **/
- public static int UNBLACKLIST_THRESHOLD_24_HARD = -68;
-
- /** @hide **/
- public static int UNBLACKLIST_THRESHOLD_5_SOFT = -63;
-
- /** @hide **/
- public static int UNBLACKLIST_THRESHOLD_5_HARD = -56;
-
- /** @hide **/
- public static int INITIAL_AUTO_JOIN_ATTEMPT_MIN_24 = -80;
-
- /** @hide **/
- public static int INITIAL_AUTO_JOIN_ATTEMPT_MIN_5 = -70;
-
- /** @hide
- * 5GHz band is prefered low over 2.4 if the 5GHz RSSI is higher than this threshold */
- public static int A_BAND_PREFERENCE_RSSI_THRESHOLD = -65;
-
- /** @hide
- * 5GHz band is penalized if the 5GHz RSSI is lower than this threshold **/
- public static int G_BAND_PREFERENCE_RSSI_THRESHOLD = -75;
-
- /** @hide
- * Boost given to RSSI on a home network for the purpose of calculating the score
- * This adds stickiness to home networks, as defined by:
- * - less than 4 known BSSIDs
- * - PSK only
- * - TODO: add a test to verify that all BSSIDs are behind same gateway
- ***/
- public static int HOME_NETWORK_RSSI_BOOST = 5;
-
- /** @hide
- * RSSI boost for configuration which use autoJoinUseAggressiveJoinAttemptThreshold
- * To be more aggressive when initially attempting to auto join
- */
- public static int MAX_INITIAL_AUTO_JOIN_RSSI_BOOST = 8;
-
/**
* @hide
* A summary of the RSSI and Band status for that configuration
@@ -600,38 +502,6 @@
visibility = status;
}
- /** @hide */
- public static final int AUTO_JOIN_ENABLED = 0;
- /**
- * if this is set, the WifiConfiguration cannot use linkages so as to bump
- * it's relative priority.
- * - status between and 128 indicate various level of blacklisting depending
- * on the severity or frequency of the connection error
- * - deleted status indicates that the user is deleting the configuration, and so
- * although it may have been self added we will not re-self-add it, ignore it,
- * not return it to applications, and not connect to it
- * */
-
- /** @hide
- * network was temporary disabled due to bad connection, most likely due
- * to weak RSSI */
- public static final int AUTO_JOIN_TEMPORARY_DISABLED = 1;
- /** @hide
- * network was temporary disabled due to bad connection, which cant be attributed
- * to weak RSSI */
- public static final int AUTO_JOIN_TEMPORARY_DISABLED_LINK_ERRORS = 32;
- /** @hide */
- public static final int AUTO_JOIN_TEMPORARY_DISABLED_AT_SUPPLICANT = 64;
- /** @hide */
- public static final int AUTO_JOIN_DISABLED_ON_AUTH_FAILURE = 128;
- /** @hide */
- public static final int AUTO_JOIN_DISABLED_NO_CREDENTIALS = 160;
- /** @hide */
- public static final int AUTO_JOIN_DISABLED_USER_ACTION = 161;
-
- /** @hide */
- public static final int AUTO_JOIN_DELETED = 200;
-
// States for the userApproved field
/**
* @hide
@@ -656,29 +526,6 @@
/**
* @hide
- */
- public int autoJoinStatus;
-
- /**
- * @hide
- * Number of connection failures
- */
- public int numConnectionFailures;
-
- /**
- * @hide
- * Number of IP config failures
- */
- public int numIpConfigFailures;
-
- /**
- * @hide
- * Number of Auth failures
- */
- public int numAuthFailures;
-
- /**
- * @hide
* Number of reports indicating no Internet Access
*/
public int numNoInternetAccessReports;
@@ -715,12 +562,6 @@
/**
* @hide
- * Last time we blacklisted the configuration
- */
- public long blackListTimestamp;
-
- /**
- * @hide
* Last time the system was connected to this configuration.
*/
public long lastConnected;
@@ -795,18 +636,6 @@
/**
* @hide
- * Indicate that we didn't auto-join because rssi was too low
- */
- public boolean autoJoinBailedDueToLowRssi;
-
- /**
- * @hide
- * AutoJoin even though RSSI is 10dB below threshold
- */
- public int autoJoinUseAggressiveJoinAttemptThreshold;
-
- /**
- * @hide
* Number of time the scorer overrode a the priority based choice, when comparing two
* WifiConfigurations, note that since comparing WifiConfiguration happens very often
* potentially at every scan, this number might become very large, even on an idle
@@ -874,24 +703,526 @@
*/
public int numUserTriggeredJoinAttempts;
+ /** @hide
+ * Boost given to RSSI on a home network for the purpose of calculating the score
+ * This adds stickiness to home networks, as defined by:
+ * - less than 4 known BSSIDs
+ * - PSK only
+ * - TODO: add a test to verify that all BSSIDs are behind same gateway
+ ***/
+ public static final int HOME_NETWORK_RSSI_BOOST = 5;
+
/**
* @hide
- * Connect choices
- *
- * remember the keys identifying the known WifiConfiguration over which this configuration
- * was preferred by user or a "WiFi Network Management app", that is,
- * a WifiManager.CONNECT_NETWORK or SELECT_NETWORK was received while this configuration
- * was visible to the user:
- * configKey is : "SSID"-WEP-WPA_PSK-WPA_EAP
- *
- * The integer represents the configuration's RSSI at that time (useful?)
- *
- * The overall auto-join algorithm make use of past connect choice so as to sort configuration,
- * the exact algorithm still fluctuating as of 5/7/2014
- *
+ * This class is used to contain all the information and API used for quality network selection
*/
- public HashMap<String, Integer> connectChoices;
+ public static class NetworkSelectionStatus {
+ /**
+ * Quality Network Selection Status enable, temporary disabled, permanently disabled
+ */
+ /**
+ * This network is allowed to join Quality Network Selection
+ */
+ public static final int NETWORK_SELECTION_ENABLED = 0;
+ /**
+ * network was temporary disabled. Can be re-enabled after a time period expire
+ */
+ public static final int NETWORK_SELECTION_TEMPORARY_DISABLED = 1;
+ /**
+ * network was permanently disabled.
+ */
+ public static final int NETWORK_SELECTION_PERMANENTLY_DISABLED = 2;
+ /**
+ * Maximum Network selection status
+ */
+ public static final int NETWORK_SELECTION_STATUS_MAX = 3;
+ /**
+ * Quality network selection status String (for debug purpose). Use Quality network
+ * selection status value as index to extec the corresponding debug string
+ */
+ private static final String[] QUALITY_NETWORK_SELECTION_STATUS = {
+ "NETWORK_SELECTION_ENABLED",
+ "NETWORK_SELECTION_TEMPORARY_DISABLED",
+ "NETWORK_SELECTION_PERMANENTLY_DISABLED"};
+
+ //Quality Network disabled reasons
+ /**
+ * Default value. Means not disabled
+ */
+ public static final int NETWORK_SELECTION_ENABLE = 0;
+ /**
+ * This network is disabled because higher layer (>2) network is bad
+ */
+ public static final int DISABLED_BAD_LINK = 1;
+ /**
+ * This network is disabled because multiple association rejects
+ */
+ public static final int DISABLED_ASSOCIATION_REJECTION = 2;
+ /**
+ * This network is disabled because multiple authentication failure
+ */
+ public static final int DISABLED_AUTHENTICATION_FAILURE = 3;
+ /**
+ * This network is disabled because multiple DHCP failure
+ */
+ public static final int DISABLED_DHCP_FAILURE = 4;
+ /**
+ * This network is disabled because of security network but no credentials
+ */
+ public static final int DISABLED_DNS_FAILURE = 5;
+ /**
+ * This network is disabled because EAP-TLS failure
+ */
+ public static final int DISABLED_TLS_VERSION_MISMATCH = 6;
+ /**
+ * This network is disabled due to WifiManager disable it explicitly
+ */
+ public static final int DISABLED_AUTHENTICATION_NO_CREDENTIALS = 7;
+ /**
+ * This network is disabled because no Internet connected and user do not want
+ */
+ public static final int DISABLED_NO_INTERNET = 8;
+ /**
+ * This network is disabled due to WifiManager disable it explicitly
+ */
+ public static final int DISABLED_BY_WIFI_MANAGER = 9;
+ /**
+ * This Maximum disable reason value
+ */
+ public static final int NETWORK_SELECTION_DISABLED_MAX = 10;
+
+ /**
+ * Quality network selection disable reason String (for debug purpose)
+ */
+ private static final String[] QUALITY_NETWORK_SELECTION_DISABLE_REASON = {
+ "NETWORK_SELECTION_ENABLE",
+ "NETWORK_SELECTION_DISABLED_BAD_LINK",
+ "NETWORK_SELECTION_DISABLED_ASSOCIATION_REJECTION ",
+ "NETWORK_SELECTION_DISABLED_AUTHENTICATION_FAILURE",
+ "NETWORK_SELECTION_DISABLED_DHCP_FAILURE",
+ "NETWORK_SELECTION_DISABLED_DNS_FAILURE",
+ "NETWORK_SELECTION_DISABLED_TLS_VERSION",
+ "NETWORK_SELECTION_DISABLED_AUTHENTICATION_NO_CREDENTIALS",
+ "NETWORK_SELECTION_DISABLED_NO_INTERNET",
+ "NETWORK_SELECTION_DISABLED_BY_WIFI_MANAGER"};
+
+ /**
+ * Invalid time stamp for network selection disable
+ */
+ public static final long INVALID_NETWORK_SELECTION_DISABLE_TIMESTAMP = -1L;
+
+ /**
+ * This constant indicates the current configuration has connect choice set
+ */
+ private static final int CONNECT_CHOICE_EXISTS = 1;
+
+ /**
+ * This constant indicates the current configuration does not have connect choice set
+ */
+ private static final int CONNECT_CHOICE_NOT_EXISTS = -1;
+
+ // fields for QualityNetwork Selection
+ /**
+ * Network selection status, should be in one of three status: enable, temporaily disabled
+ * or permanently disabled
+ */
+ private int mStatus;
+
+ /**
+ * Reason for disable this network
+ */
+ private int mNetworkSelectionDisableReason;
+
+ /**
+ * Last time we temporarily disabled the configuration
+ */
+ private long mTemporarilyDisabledTimestamp = INVALID_NETWORK_SELECTION_DISABLE_TIMESTAMP;
+
+ /**
+ * counter for each Network selection disable reason
+ */
+ private int[] mNetworkSeclectionDisableCounter = new int[NETWORK_SELECTION_DISABLED_MAX];
+
+ /**
+ * Connect Choice over this configuration
+ *
+ * When current wifi configuration is visible to the user but user explicitly choose to
+ * connect to another network X, the another networks X's configure key will be stored here.
+ * We will consider user has a preference of X over this network. And in the future,
+ * network selection will always give X a higher preference over this configuration.
+ * configKey is : "SSID"-WEP-WPA_PSK-WPA_EAP
+ */
+ private String mConnectChoice;
+
+ /**
+ * The system timestamp when we records the connectChoice. This value is obtained from
+ * System.currentTimeMillis
+ */
+ private long mConnectChoiceTimestamp = INVALID_NETWORK_SELECTION_DISABLE_TIMESTAMP;
+
+ /**
+ * Used to cache the temporary candidate during the network selection procedure. It will be
+ * kept updating once a new scan result has a higher score than current one
+ */
+ private ScanResult mCandidate;
+
+ /**
+ * Used to cache the score of the current temporary candidate during the network
+ * selection procedure.
+ */
+ private int mCandidateScore;
+
+ /**
+ * Indicate whether this network is visible in latest Qualified Network Selection. This
+ * means there is scan result found related to this Configuration and meet the minimum
+ * requirement. The saved network need not join latest Qualified Network Selection. For
+ * example, it is disabled. True means network is visible in latest Qualified Network
+ * Selection and false means network is invisible
+ */
+ private boolean mSeenInLastQualifiedNetworkSelection;
+
+ /**
+ * set whether this network is visible in latest Qualified Network Selection
+ * @param seen value set to candidate
+ */
+ public void setSeenInLastQualifiedNetworkSelection(boolean seen) {
+ mSeenInLastQualifiedNetworkSelection = seen;
+ }
+
+ /**
+ * get whether this network is visible in latest Qualified Network Selection
+ * @return returns true -- network is visible in latest Qualified Network Selection
+ * false -- network is invisible in latest Qualified Network Selection
+ */
+ public boolean getSeenInLastQualifiedNetworkSelection() {
+ return mSeenInLastQualifiedNetworkSelection;
+ }
+ /**
+ * set the temporary candidate of current network selection procedure
+ * @param scanCandidate {@link ScanResult} the candidate set to mCandidate
+ */
+ public void setCandidate(ScanResult scanCandidate) {
+ mCandidate = scanCandidate;
+ }
+
+ /**
+ * get the temporary candidate of current network selection procedure
+ * @return returns {@link ScanResult} temporary candidate of current network selection
+ * procedure
+ */
+ public ScanResult getCandidate() {
+ return mCandidate;
+ }
+
+ /**
+ * set the score of the temporary candidate of current network selection procedure
+ * @param score value set to mCandidateScore
+ */
+ public void setCandidateScore(int score) {
+ mCandidateScore = score;
+ }
+
+ /**
+ * get the score of the temporary candidate of current network selection procedure
+ * @return returns score of the temporary candidate of current network selection procedure
+ */
+ public int getCandidateScore() {
+ return mCandidateScore;
+ }
+
+ /**
+ * get user preferred choice over this configuration
+ *@return returns configKey of user preferred choice over this configuration
+ */
+ public String getConnectChoice() {
+ return mConnectChoice;
+ }
+
+ /**
+ * set user preferred choice over this configuration
+ * @param newConnectChoice, the configKey of user preferred choice over this configuration
+ */
+ public void setConnectChoice(String newConnectChoice) {
+ mConnectChoice = newConnectChoice;
+ }
+
+ /**
+ * get the timeStamp when user select a choice over this configuration
+ * @return returns when current connectChoice is set (time from System.currentTimeMillis)
+ */
+ public long getConnectChoiceTimestamp() {
+ return mConnectChoiceTimestamp;
+ }
+
+ /**
+ * set the timeStamp when user select a choice over this configuration
+ * @param timeStamp, the timestamp set to connectChoiceTimestamp, expected timestamp should
+ * be obtained from System.currentTimeMillis
+ */
+ public void setConnectChoiceTimestamp(long timeStamp) {
+ mConnectChoiceTimestamp = timeStamp;
+ }
+
+ /**
+ * get current Quality network selection status
+ * @return returns current Quality network selection status in String (for debug purpose)
+ */
+ public String getNetworkStatusString() {
+ return QUALITY_NETWORK_SELECTION_STATUS[mStatus];
+ }
+
+ private NetworkSelectionStatus() {};
+
+ /**
+ * @param reason specific error reason
+ * @return corresponding network disable reason String (for debug purpose)
+ */
+ public static String getNetworkDisableReasonString(int reason) {
+ if (reason >= NETWORK_SELECTION_ENABLE && reason < NETWORK_SELECTION_DISABLED_MAX) {
+ return QUALITY_NETWORK_SELECTION_DISABLE_REASON[reason];
+ } else {
+ return null;
+ }
+ }
+ /**
+ * get current network disable reason
+ * @return current network disable reason in String (for debug purpose)
+ */
+ public String getNetworkDisableReasonString() {
+ return QUALITY_NETWORK_SELECTION_DISABLE_REASON[mNetworkSelectionDisableReason];
+ }
+
+ /**
+ * get current network network selection status
+ * @return return current network network selection status
+ */
+ public int getNetworkSelectionStatus() {
+ return mStatus;
+ }
+ /**
+ * @return whether current network is enabled to join network selection
+ */
+ public boolean isNetworkEnabled() {
+ return mStatus == NETWORK_SELECTION_ENABLED;
+ }
+
+ /**
+ * @return whether current network is temporary disabled
+ */
+ public boolean isNetworkTemporaryDisabled() {
+ return mStatus == NETWORK_SELECTION_TEMPORARY_DISABLED;
+ }
+
+ /**
+ * @return returns whether current network is permanently disabled
+ */
+ public boolean isNetworkPermanentlyDisabled() {
+ return mStatus == NETWORK_SELECTION_PERMANENTLY_DISABLED;
+ }
+
+ /**
+ * set current networ work selection status
+ * @param status network selection status to set
+ */
+ public void setNetworkSelectionStatus(int status) {
+ if (status >= 0 && status < NETWORK_SELECTION_STATUS_MAX) {
+ mStatus = status;
+ }
+ }
+
+ /**
+ * @return returns current network's disable reason
+ */
+ public int getNetworkSelectionDisableReason() {
+ return mNetworkSelectionDisableReason;
+ }
+
+ /**
+ * set Network disable reason
+ * @param reason Network disable reason
+ */
+ public void setNetworkSelectionDisableReason(int reason) {
+ if (reason >= 0 && reason < NETWORK_SELECTION_DISABLED_MAX) {
+ mNetworkSelectionDisableReason = reason;
+ } else {
+ throw new IllegalArgumentException("Illegal reason value: " + reason);
+ }
+ }
+
+ /**
+ * check whether network is disabled by this reason
+ * @param reason a specific disable reason
+ * @return true -- network is disabled for this reason
+ * false -- network is not disabled for this reason
+ */
+ public boolean isDisabledByReason(int reason) {
+ return mNetworkSelectionDisableReason == reason;
+ }
+
+ /**
+ * @param timeStamp Set when current network is disabled in millisecond since January 1,
+ * 1970 00:00:00.0 UTC
+ */
+ public void setDisableTime(long timeStamp) {
+ mTemporarilyDisabledTimestamp = timeStamp;
+ }
+
+ /**
+ * @return returns when current network is disabled in millisecond since January 1,
+ * 1970 00:00:00.0 UTC
+ */
+ public long getDisableTime() {
+ return mTemporarilyDisabledTimestamp;
+ }
+
+ /**
+ * get the disable counter of a specific reason
+ * @param reason specific failure reason
+ * @exception throw IllegalArgumentException for illegal input
+ * @return counter number for specific error reason.
+ */
+ public int getDisableReasonCounter(int reason) {
+ if (reason >= NETWORK_SELECTION_ENABLE && reason < NETWORK_SELECTION_DISABLED_MAX) {
+ return mNetworkSeclectionDisableCounter[reason];
+ } else {
+ throw new IllegalArgumentException("Illegal reason value: " + reason);
+ }
+ }
+
+ /**
+ * set the counter of a specific failure reason
+ * @param reason reason for disable error
+ * @param value the counter value for this specific reason
+ * @exception throw IllegalArgumentException for illegal input
+ */
+ public void setDisableReasonCounter(int reason, int value) {
+ if (reason >= NETWORK_SELECTION_ENABLE && reason < NETWORK_SELECTION_DISABLED_MAX) {
+ mNetworkSeclectionDisableCounter[reason] = value;
+ } else {
+ throw new IllegalArgumentException("Illegal reason value: " + reason);
+ }
+ }
+
+ /**
+ * increment the counter of a specific failure reason
+ * @param reason a specific failure reason
+ * @exception throw IllegalArgumentException for illegal input
+ */
+ public void incrementDisableReasonCounter(int reason) {
+ if (reason >= NETWORK_SELECTION_ENABLE && reason < NETWORK_SELECTION_DISABLED_MAX) {
+ mNetworkSeclectionDisableCounter[reason]++;
+ } else {
+ throw new IllegalArgumentException("Illegal reason value: " + reason);
+ }
+ }
+
+ /**
+ * clear the counter of a specific failure reason
+ * @hide
+ * @param reason a specific failure reason
+ * @exception throw IllegalArgumentException for illegal input
+ */
+ public void clearDisableReasonCounter(int reason) {
+ if (reason >= NETWORK_SELECTION_ENABLE && reason < NETWORK_SELECTION_DISABLED_MAX) {
+ mNetworkSeclectionDisableCounter[reason] = NETWORK_SELECTION_ENABLE;
+ } else {
+ throw new IllegalArgumentException("Illegal reason value: " + reason);
+ }
+ }
+
+ /**
+ * clear all the failure reason counters
+ */
+ public void clearDisableReasonCounter() {
+ Arrays.fill(mNetworkSeclectionDisableCounter, NETWORK_SELECTION_ENABLE);
+ }
+
+ /**
+ * BSSID for connection to this network (through network selection procedure)
+ */
+ private String mNetworkSelectionBSSID;
+
+ /**
+ * get current network Selection BSSID
+ * @return current network Selection BSSID
+ */
+ public String getNetworkSelectionBSSID() {
+ return mNetworkSelectionBSSID;
+ }
+
+ /**
+ * set network Selection BSSID
+ * @param bssid The target BSSID for assocaition
+ */
+ public void setNetworkSelectionBSSID(String bssid) {
+ mNetworkSelectionBSSID = bssid;
+ }
+
+ public void copy(NetworkSelectionStatus source) {
+ mStatus = source.mStatus;
+ mNetworkSelectionDisableReason = source.mNetworkSelectionDisableReason;
+ for (int index = NETWORK_SELECTION_ENABLE; index < NETWORK_SELECTION_DISABLED_MAX;
+ index++) {
+ mNetworkSeclectionDisableCounter[index] =
+ source.mNetworkSeclectionDisableCounter[index];
+ }
+ mTemporarilyDisabledTimestamp = source.mTemporarilyDisabledTimestamp;
+ mNetworkSelectionBSSID = source.mNetworkSelectionBSSID;
+ setConnectChoice(source.getConnectChoice());
+ setConnectChoiceTimestamp(source.getConnectChoiceTimestamp());
+ }
+
+ public void writeToParcel(Parcel dest) {
+ dest.writeInt(getNetworkSelectionStatus());
+ dest.writeInt(getNetworkSelectionDisableReason());
+ for (int index = NETWORK_SELECTION_ENABLE; index < NETWORK_SELECTION_DISABLED_MAX;
+ index++) {
+ dest.writeInt(getDisableReasonCounter(index));
+ }
+ dest.writeLong(getDisableTime());
+ dest.writeString(getNetworkSelectionBSSID());
+ if (getConnectChoice() != null) {
+ dest.writeInt(CONNECT_CHOICE_EXISTS);
+ dest.writeString(getConnectChoice());
+ dest.writeLong(getConnectChoiceTimestamp());
+ } else {
+ dest.writeInt(CONNECT_CHOICE_NOT_EXISTS);
+ }
+ }
+
+ public void readFromParcel(Parcel in) {
+ setNetworkSelectionStatus(in.readInt());
+ setNetworkSelectionDisableReason(in.readInt());
+ for (int index = NETWORK_SELECTION_ENABLE; index < NETWORK_SELECTION_DISABLED_MAX;
+ index++) {
+ setDisableReasonCounter(index, in.readInt());
+ }
+ setDisableTime(in.readLong());
+ setNetworkSelectionBSSID(in.readString());
+ if (in.readInt() == CONNECT_CHOICE_EXISTS) {
+ setConnectChoice(in.readString());
+ setConnectChoiceTimestamp(in.readLong());
+ } else {
+ setConnectChoice(null);
+ setConnectChoiceTimestamp(INVALID_NETWORK_SELECTION_DISABLE_TIMESTAMP);
+ }
+ }
+ }
+
+ /**
+ * @hide
+ * network selection related member
+ */
+ private final NetworkSelectionStatus mNetworkSelectionStatus = new NetworkSelectionStatus();
+
+ /**
+ * @hide
+ * @return network selection status
+ */
+ public NetworkSelectionStatus getNetworkSelectionStatus() {
+ return mNetworkSelectionStatus;
+ }
/**
* @hide
* Linked Configurations: represent the set of Wificonfigurations that are equivalent
@@ -910,7 +1241,6 @@
roamingConsortiumIds = new long[0];
priority = 0;
hiddenSSID = false;
- disableReason = DISABLED_UNKNOWN_REASON;
allowedKeyManagement = new BitSet();
allowedProtocols = new BitSet();
allowedAuthAlgorithms = new BitSet();
@@ -921,7 +1251,6 @@
wepKeys[i] = null;
}
enterpriseConfig = new WifiEnterpriseConfig();
- autoJoinStatus = AUTO_JOIN_ENABLED;
selfAdded = false;
didSelfAdd = false;
ephemeral = false;
@@ -929,6 +1258,7 @@
mIpConfiguration = new IpConfiguration();
lastUpdateUid = -1;
creatorUid = -1;
+ shared = true;
}
/**
@@ -946,10 +1276,12 @@
* @hide
*/
public boolean isLinked(WifiConfiguration config) {
- if (config.linkedConfigurations != null && linkedConfigurations != null) {
- if (config.linkedConfigurations.get(configKey()) != null
- && linkedConfigurations.get(config.configKey()) != null) {
- return true;
+ if (config != null) {
+ if (config.linkedConfigurations != null && linkedConfigurations != null) {
+ if (config.linkedConfigurations.get(configKey()) != null
+ && linkedConfigurations.get(config.configKey()) != null) {
+ return true;
+ }
}
}
return false;
@@ -964,20 +1296,6 @@
allowedKeyManagement.get(KeyMgmt.IEEE8021X);
}
- /** @hide **/
- public void setAutoJoinStatus(int status) {
- if (status < 0) status = 0;
- if (status == 0) {
- blackListTimestamp = 0;
- } else if (status > autoJoinStatus) {
- blackListTimestamp = System.currentTimeMillis();
- }
- if (status != autoJoinStatus) {
- autoJoinStatus = status;
- dirty = true;
- }
- }
-
@Override
public String toString() {
StringBuilder sbuf = new StringBuilder();
@@ -988,24 +1306,32 @@
}
sbuf.append("ID: ").append(this.networkId).append(" SSID: ").append(this.SSID).
append(" PROVIDER-NAME: ").append(this.providerFriendlyName).
- append(" BSSID: ").append(this.BSSID).append(" FQDN: ").append(this.FQDN).
- append(" PRIO: ").append(this.priority).
- append('\n');
- if (this.numConnectionFailures > 0) {
- sbuf.append(" numConnectFailures ").append(this.numConnectionFailures).append("\n");
+ append(" BSSID: ").append(this.BSSID).append(" FQDN: ").append(this.FQDN)
+ .append(" PRIO: ").append(this.priority)
+ .append('\n');
+
+
+ sbuf.append(" NetworkSelectionStatus ")
+ .append(mNetworkSelectionStatus.getNetworkStatusString() + "\n");
+ if (mNetworkSelectionStatus.getNetworkSelectionDisableReason() > 0) {
+ sbuf.append(" mNetworkSelectionDisableReason ")
+ .append(mNetworkSelectionStatus.getNetworkDisableReasonString() + "\n");
+
+ for (int index = mNetworkSelectionStatus.NETWORK_SELECTION_ENABLE;
+ index < mNetworkSelectionStatus.NETWORK_SELECTION_DISABLED_MAX; index++) {
+ if (mNetworkSelectionStatus.getDisableReasonCounter(index) != 0) {
+ sbuf.append(NetworkSelectionStatus.getNetworkDisableReasonString(index)
+ + " counter:" + mNetworkSelectionStatus.getDisableReasonCounter(index)
+ + "\n");
+ }
+ }
}
- if (this.numIpConfigFailures > 0) {
- sbuf.append(" numIpConfigFailures ").append(this.numIpConfigFailures).append("\n");
+ if (mNetworkSelectionStatus.getConnectChoice() != null) {
+ sbuf.append(" connect choice: ").append(mNetworkSelectionStatus.getConnectChoice());
+ sbuf.append(" connect choice set time: ").append(mNetworkSelectionStatus
+ .getConnectChoiceTimestamp());
}
- if (this.numAuthFailures > 0) {
- sbuf.append(" numAuthFailures ").append(this.numAuthFailures).append("\n");
- }
- if (this.autoJoinStatus > 0) {
- sbuf.append(" autoJoinStatus ").append(this.autoJoinStatus).append("\n");
- }
- if (this.disableReason > 0) {
- sbuf.append(" disableReason ").append(this.disableReason).append("\n");
- }
+
if (this.numAssociation > 0) {
sbuf.append(" numAssociation ").append(this.numAssociation).append("\n");
}
@@ -1094,11 +1420,15 @@
sbuf.append("IP config:\n");
sbuf.append(mIpConfiguration.toString());
- if (this.autoJoinBSSID != null) sbuf.append(" autoJoinBSSID=" + autoJoinBSSID);
+ if (mNetworkSelectionStatus.getNetworkSelectionBSSID() != null) {
+ sbuf.append(" networkSelectionBSSID="
+ + mNetworkSelectionStatus.getNetworkSelectionBSSID());
+ }
long now_ms = System.currentTimeMillis();
- if (this.blackListTimestamp != 0) {
+ if (mNetworkSelectionStatus.getDisableTime() != NetworkSelectionStatus
+ .INVALID_NETWORK_SELECTION_DISABLE_TIMESTAMP) {
sbuf.append('\n');
- long diff = now_ms - this.blackListTimestamp;
+ long diff = now_ms - mNetworkSelectionStatus.getDisableTime();
if (diff <= 0) {
sbuf.append(" blackListed since <incorrect>");
} else {
@@ -1152,16 +1482,7 @@
sbuf.append('\n');
}
}
- if (this.connectChoices != null) {
- for(String key : this.connectChoices.keySet()) {
- Integer choice = this.connectChoices.get(key);
- if (choice != null) {
- sbuf.append(" choice: ").append(key);
- sbuf.append(" = ").append(choice);
- sbuf.append('\n');
- }
- }
- }
+
sbuf.append("triggeredLow: ").append(this.numUserTriggeredWifiDisableLowRSSI);
sbuf.append(" triggeredBad: ").append(this.numUserTriggeredWifiDisableBadRSSI);
sbuf.append(" triggeredNotHigh: ").append(this.numUserTriggeredWifiDisableNotHighRSSI);
@@ -1172,11 +1493,6 @@
sbuf.append('\n');
sbuf.append("triggeredJoin: ").append(this.numUserTriggeredJoinAttempts);
sbuf.append('\n');
- sbuf.append("autoJoinBailedDueToLowRssi: ").append(this.autoJoinBailedDueToLowRssi);
- sbuf.append('\n');
- sbuf.append("autoJoinUseAggressiveJoinAttemptThreshold: ");
- sbuf.append(this.autoJoinUseAggressiveJoinAttemptThreshold);
- sbuf.append('\n');
return sbuf.toString();
}
@@ -1323,6 +1639,9 @@
key = mCachedConfigKey;
} else if (providerFriendlyName != null) {
key = FQDN + KeyMgmt.strings[KeyMgmt.WPA_EAP];
+ if (!shared) {
+ key += "-" + Integer.toString(UserHandle.getUserId(creatorUid));
+ }
} else {
if (allowedKeyManagement.get(KeyMgmt.WPA_PSK)) {
key = SSID + KeyMgmt.strings[KeyMgmt.WPA_PSK];
@@ -1334,6 +1653,9 @@
} else {
key = SSID + KeyMgmt.strings[KeyMgmt.NONE];
}
+ if (!shared) {
+ key += "-" + Integer.toString(UserHandle.getUserId(creatorUid));
+ }
mCachedConfigKey = key;
}
return key;
@@ -1346,27 +1668,6 @@
return configKey(false);
}
- /** @hide
- * return the config key string based on a scan result
- */
- static public String configKey(ScanResult result) {
- String key = "\"" + result.SSID + "\"";
-
- if (result.capabilities.contains("WEP")) {
- key = key + "-WEP";
- }
-
- if (result.capabilities.contains("PSK")) {
- key = key + "-" + KeyMgmt.strings[KeyMgmt.WPA_PSK];
- }
-
- if (result.capabilities.contains("EAP")) {
- key = key + "-" + KeyMgmt.strings[KeyMgmt.WPA_EAP];
- }
-
- return key;
- }
-
/** @hide */
public IpConfiguration getIpConfiguration() {
return mIpConfiguration;
@@ -1428,13 +1729,16 @@
return 0;
}
+ /** @hide */
+ public boolean isVisibleToUser(int userId) {
+ return shared || (UserHandle.getUserId(creatorUid) == userId);
+ }
+
/** copy constructor {@hide} */
public WifiConfiguration(WifiConfiguration source) {
if (source != null) {
networkId = source.networkId;
status = source.status;
- disableReason = source.disableReason;
- disableReason = source.disableReason;
SSID = source.SSID;
BSSID = source.BSSID;
FQDN = source.FQDN;
@@ -1442,6 +1746,7 @@
providerFriendlyName = source.providerFriendlyName;
preSharedKey = source.preSharedKey;
+ mNetworkSelectionStatus.copy(source.getNetworkSelectionStatus());
apBand = source.apBand;
apChannel = source.apChannel;
@@ -1458,25 +1763,18 @@
allowedAuthAlgorithms = (BitSet) source.allowedAuthAlgorithms.clone();
allowedPairwiseCiphers = (BitSet) source.allowedPairwiseCiphers.clone();
allowedGroupCiphers = (BitSet) source.allowedGroupCiphers.clone();
-
enterpriseConfig = new WifiEnterpriseConfig(source.enterpriseConfig);
defaultGwMacAddress = source.defaultGwMacAddress;
mIpConfiguration = new IpConfiguration(source.mIpConfiguration);
- if ((source.connectChoices != null) && (source.connectChoices.size() > 0)) {
- connectChoices = new HashMap<String, Integer>();
- connectChoices.putAll(source.connectChoices);
- }
-
if ((source.linkedConfigurations != null)
&& (source.linkedConfigurations.size() > 0)) {
linkedConfigurations = new HashMap<String, Integer>();
linkedConfigurations.putAll(source.linkedConfigurations);
}
mCachedConfigKey = null; //force null configKey
- autoJoinStatus = source.autoJoinStatus;
selfAdded = source.selfAdded;
validatedInternetAccess = source.validatedInternetAccess;
ephemeral = source.ephemeral;
@@ -1492,16 +1790,13 @@
creatorName = source.creatorName;
lastUpdateName = source.lastUpdateName;
peerWifiConfiguration = source.peerWifiConfiguration;
- blackListTimestamp = source.blackListTimestamp;
+
lastConnected = source.lastConnected;
lastDisconnected = source.lastDisconnected;
lastConnectionFailure = source.lastConnectionFailure;
lastRoamingFailure = source.lastRoamingFailure;
lastRoamingFailureReason = source.lastRoamingFailureReason;
roamingFailureBlackListTimeMilli = source.roamingFailureBlackListTimeMilli;
- numConnectionFailures = source.numConnectionFailures;
- numIpConfigFailures = source.numIpConfigFailures;
- numAuthFailures = source.numAuthFailures;
numScorerOverride = source.numScorerOverride;
numScorerOverrideAndSwitchedNetwork = source.numScorerOverrideAndSwitchedNetwork;
numAssociation = source.numAssociation;
@@ -1512,16 +1807,12 @@
numTicksAtBadRSSI = source.numTicksAtBadRSSI;
numTicksAtNotHighRSSI = source.numTicksAtNotHighRSSI;
numUserTriggeredJoinAttempts = source.numUserTriggeredJoinAttempts;
- autoJoinBSSID = source.autoJoinBSSID;
- autoJoinUseAggressiveJoinAttemptThreshold
- = source.autoJoinUseAggressiveJoinAttemptThreshold;
- autoJoinBailedDueToLowRssi = source.autoJoinBailedDueToLowRssi;
- dirty = source.dirty;
userApproved = source.userApproved;
numNoInternetAccessReports = source.numNoInternetAccessReports;
noInternetAccessExpected = source.noInternetAccessExpected;
creationTime = source.creationTime;
updateTime = source.updateTime;
+ shared = source.shared;
}
}
@@ -1535,12 +1826,11 @@
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(networkId);
dest.writeInt(status);
- dest.writeInt(disableReason);
+ mNetworkSelectionStatus.writeToParcel(dest);
dest.writeString(SSID);
dest.writeString(BSSID);
dest.writeInt(apBand);
dest.writeInt(apChannel);
- dest.writeString(autoJoinBSSID);
dest.writeString(FQDN);
dest.writeString(providerFriendlyName);
dest.writeInt(roamingConsortiumIds.length);
@@ -1568,7 +1858,6 @@
dest.writeParcelable(mIpConfiguration, flags);
dest.writeString(dhcpServer);
dest.writeString(defaultGwMacAddress);
- dest.writeInt(autoJoinStatus);
dest.writeInt(selfAdded ? 1 : 0);
dest.writeInt(didSelfAdd ? 1 : 0);
dest.writeInt(validatedInternetAccess ? 1 : 0);
@@ -1578,14 +1867,10 @@
dest.writeInt(lastUpdateUid);
dest.writeString(creatorName);
dest.writeString(lastUpdateName);
- dest.writeLong(blackListTimestamp);
dest.writeLong(lastConnectionFailure);
dest.writeLong(lastRoamingFailure);
dest.writeInt(lastRoamingFailureReason);
dest.writeLong(roamingFailureBlackListTimeMilli);
- dest.writeInt(numConnectionFailures);
- dest.writeInt(numIpConfigFailures);
- dest.writeInt(numAuthFailures);
dest.writeInt(numScorerOverride);
dest.writeInt(numScorerOverrideAndSwitchedNetwork);
dest.writeInt(numAssociation);
@@ -1596,11 +1881,10 @@
dest.writeInt(numTicksAtBadRSSI);
dest.writeInt(numTicksAtNotHighRSSI);
dest.writeInt(numUserTriggeredJoinAttempts);
- dest.writeInt(autoJoinUseAggressiveJoinAttemptThreshold);
- dest.writeInt(autoJoinBailedDueToLowRssi ? 1 : 0);
dest.writeInt(userApproved);
dest.writeInt(numNoInternetAccessReports);
dest.writeInt(noInternetAccessExpected ? 1 : 0);
+ dest.writeInt(shared ? 1 : 0);
}
/** Implement the Parcelable interface {@hide} */
@@ -1610,12 +1894,11 @@
WifiConfiguration config = new WifiConfiguration();
config.networkId = in.readInt();
config.status = in.readInt();
- config.disableReason = in.readInt();
+ config.mNetworkSelectionStatus.readFromParcel(in);
config.SSID = in.readString();
config.BSSID = in.readString();
config.apBand = in.readInt();
config.apChannel = in.readInt();
- config.autoJoinBSSID = in.readString();
config.FQDN = in.readString();
config.providerFriendlyName = in.readString();
int numRoamingConsortiumIds = in.readInt();
@@ -1640,11 +1923,9 @@
config.allowedGroupCiphers = readBitSet(in);
config.enterpriseConfig = in.readParcelable(null);
-
config.mIpConfiguration = in.readParcelable(null);
config.dhcpServer = in.readString();
config.defaultGwMacAddress = in.readString();
- config.autoJoinStatus = in.readInt();
config.selfAdded = in.readInt() != 0;
config.didSelfAdd = in.readInt() != 0;
config.validatedInternetAccess = in.readInt() != 0;
@@ -1654,14 +1935,10 @@
config.lastUpdateUid = in.readInt();
config.creatorName = in.readString();
config.lastUpdateName = in.readString();
- config.blackListTimestamp = in.readLong();
config.lastConnectionFailure = in.readLong();
config.lastRoamingFailure = in.readLong();
config.lastRoamingFailureReason = in.readInt();
config.roamingFailureBlackListTimeMilli = in.readLong();
- config.numConnectionFailures = in.readInt();
- config.numIpConfigFailures = in.readInt();
- config.numAuthFailures = in.readInt();
config.numScorerOverride = in.readInt();
config.numScorerOverrideAndSwitchedNetwork = in.readInt();
config.numAssociation = in.readInt();
@@ -1672,11 +1949,10 @@
config.numTicksAtBadRSSI = in.readInt();
config.numTicksAtNotHighRSSI = in.readInt();
config.numUserTriggeredJoinAttempts = in.readInt();
- config.autoJoinUseAggressiveJoinAttemptThreshold = in.readInt();
- config.autoJoinBailedDueToLowRssi = in.readInt() != 0;
config.userApproved = in.readInt();
config.numNoInternetAccessReports = in.readInt();
config.noInternetAccessExpected = in.readInt() != 0;
+ config.shared = in.readInt() != 0;
return config;
}
diff --git a/wifi/java/android/net/wifi/WifiEnterpriseConfig.java b/wifi/java/android/net/wifi/WifiEnterpriseConfig.java
index 59b22bd..53efe6c 100644
--- a/wifi/java/android/net/wifi/WifiEnterpriseConfig.java
+++ b/wifi/java/android/net/wifi/WifiEnterpriseConfig.java
@@ -15,12 +15,14 @@
*/
package android.net.wifi;
+import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
import android.security.Credentials;
import android.text.TextUtils;
import java.io.ByteArrayInputStream;
+import java.nio.charset.StandardCharsets;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
@@ -72,6 +74,13 @@
public static final String KEYSTORE_URI = "keystore://";
/**
+ * String representing the keystore URI used for wpa_supplicant,
+ * Unlike #KEYSTORE_URI, this supports a list of space-delimited aliases
+ * @hide
+ */
+ public static final String KEYSTORES_URI = "keystores://";
+
+ /**
* String to set the engine value to when it should be enabled.
* @hide
*/
@@ -103,6 +112,8 @@
public static final String PLMN_KEY = "plmn";
/** @hide */
public static final String PHASE1_KEY = "phase1";
+ /** @hide */
+ public static final String CA_CERT_ALIAS_DELIMITER = " ";
/** {@hide} */
public static final String ENABLE_TLS_1_2 = "\"tls_disable_tlsv1_2=0\"";
@@ -113,7 +124,7 @@
//By default, we enable TLS1.2. However, due to a known bug on some radius, we may disable it to
// fall back to TLS 1.1.
private boolean mTls12Enable = true;
- private X509Certificate mCaCert;
+ private X509Certificate[] mCaCerts;
private PrivateKey mClientPrivateKey;
private X509Certificate mClientCertificate;
@@ -145,7 +156,7 @@
dest.writeString(entry.getValue());
}
- writeCertificate(dest, mCaCert);
+ writeCertificates(dest, mCaCerts);
if (mClientPrivateKey != null) {
String algorithm = mClientPrivateKey.getAlgorithm();
@@ -161,6 +172,17 @@
dest.writeInt(mTls12Enable ? 1: 0);
}
+ private void writeCertificates(Parcel dest, X509Certificate[] cert) {
+ if (cert != null && cert.length != 0) {
+ dest.writeInt(cert.length);
+ for (int i = 0; i < cert.length; i++) {
+ writeCertificate(dest, cert[i]);
+ }
+ } else {
+ dest.writeInt(0);
+ }
+ }
+
private void writeCertificate(Parcel dest, X509Certificate cert) {
if (cert != null) {
try {
@@ -186,7 +208,7 @@
enterpriseConfig.mFields.put(key, value);
}
- enterpriseConfig.mCaCert = readCertificate(in);
+ enterpriseConfig.mCaCerts = readCertificates(in);
PrivateKey userKey = null;
int len = in.readInt();
@@ -210,6 +232,18 @@
return enterpriseConfig;
}
+ private X509Certificate[] readCertificates(Parcel in) {
+ X509Certificate[] certs = null;
+ int len = in.readInt();
+ if (len > 0) {
+ certs = new X509Certificate[len];
+ for (int i = 0; i < len; i++) {
+ certs[i] = readCertificate(in);
+ }
+ }
+ return certs;
+ }
+
private X509Certificate readCertificate(Parcel in) {
X509Certificate cert = null;
int len = in.readInt();
@@ -430,6 +464,36 @@
}
/**
+ * Encode a CA certificate alias so it does not contain illegal character.
+ * @hide
+ */
+ public static String encodeCaCertificateAlias(String alias) {
+ byte[] bytes = alias.getBytes(StandardCharsets.UTF_8);
+ StringBuilder sb = new StringBuilder(bytes.length * 2);
+ for (byte o : bytes) {
+ sb.append(String.format("%02x", o & 0xFF));
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Decode a previously-encoded CA certificate alias.
+ * @hide
+ */
+ public static String decodeCaCertificateAlias(String alias) {
+ byte[] data = new byte[alias.length() >> 1];
+ for (int n = 0, position = 0; n < alias.length(); n += 2, position++) {
+ data[position] = (byte) Integer.parseInt(alias.substring(n, n + 2), 16);
+ }
+ try {
+ return new String(data, StandardCharsets.UTF_8);
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ return alias;
+ }
+ }
+
+ /**
* Set CA certificate alias.
*
* <p> See the {@link android.security.KeyChain} for details on installing or choosing
@@ -443,6 +507,35 @@
}
/**
+ * Set CA certificate aliases. When creating installing the corresponding certificate to
+ * the keystore, please use alias encoded by {@link #encodeCaCertificateAlias(String)}.
+ *
+ * <p> See the {@link android.security.KeyChain} for details on installing or choosing
+ * a certificate.
+ * </p>
+ * @param aliases identifies the certificate
+ * @hide
+ */
+ public void setCaCertificateAliases(@Nullable String[] aliases) {
+ if (aliases == null) {
+ setFieldValue(CA_CERT_KEY, null, CA_CERT_PREFIX);
+ } else if (aliases.length == 1) {
+ // Backwards compatibility: use the original cert prefix if setting only one alias.
+ setCaCertificateAlias(aliases[0]);
+ } else {
+ // Use KEYSTORES_URI which supports multiple aliases.
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < aliases.length; i++) {
+ if (i > 0) {
+ sb.append(CA_CERT_ALIAS_DELIMITER);
+ }
+ sb.append(encodeCaCertificateAlias(Credentials.CA_CERTIFICATE + aliases[i]));
+ }
+ setFieldValue(CA_CERT_KEY, sb.toString(), KEYSTORES_URI);
+ }
+ }
+
+ /**
* Get CA certificate alias
* @return alias to the CA certificate
* @hide
@@ -452,6 +545,32 @@
}
/**
+ * Get CA certificate aliases
+ * @return alias to the CA certificate
+ * @hide
+ */
+ @Nullable public String[] getCaCertificateAliases() {
+ String value = getFieldValue(CA_CERT_KEY, "");
+ if (value.startsWith(CA_CERT_PREFIX)) {
+ // Backwards compatibility: parse the original alias prefix.
+ return new String[] {getFieldValue(CA_CERT_KEY, CA_CERT_PREFIX)};
+ } else if (value.startsWith(KEYSTORES_URI)) {
+ String values = value.substring(KEYSTORES_URI.length());
+
+ String[] aliases = TextUtils.split(values, CA_CERT_ALIAS_DELIMITER);
+ for (int i = 0; i < aliases.length; i++) {
+ aliases[i] = decodeCaCertificateAlias(aliases[i]);
+ if (aliases[i].startsWith(Credentials.CA_CERTIFICATE)) {
+ aliases[i] = aliases[i].substring(Credentials.CA_CERTIFICATE.length());
+ }
+ }
+ return aliases.length != 0 ? aliases : null;
+ } else {
+ return TextUtils.isEmpty(value) ? null : new String[] {value};
+ }
+ }
+
+ /**
* Specify a X.509 certificate that identifies the server.
*
* <p>A default name is automatically assigned to the certificate and used
@@ -462,31 +581,76 @@
* @param cert X.509 CA certificate
* @throws IllegalArgumentException if not a CA certificate
*/
- public void setCaCertificate(X509Certificate cert) {
+ public void setCaCertificate(@Nullable X509Certificate cert) {
if (cert != null) {
if (cert.getBasicConstraints() >= 0) {
- mCaCert = cert;
+ mCaCerts = new X509Certificate[] {cert};
} else {
throw new IllegalArgumentException("Not a CA certificate");
}
} else {
- mCaCert = null;
+ mCaCerts = null;
}
}
/**
- * Get CA certificate
+ * Get CA certificate. If multiple CA certificates are configured previously,
+ * return the first one.
* @return X.509 CA certificate
*/
- public X509Certificate getCaCertificate() {
- return mCaCert;
+ @Nullable public X509Certificate getCaCertificate() {
+ if (mCaCerts != null && mCaCerts.length > 0) {
+ return mCaCerts[0];
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Specify a list of X.509 certificates that identifies the server. The validation
+ * passes if the CA of server certificate matches one of the given certificates.
+
+ * <p>Default names are automatically assigned to the certificates and used
+ * with this configuration. The framework takes care of installing the
+ * certificates when the config is saved and removing the certificates when
+ * the config is removed.
+ *
+ * @param certs X.509 CA certificates
+ * @throws IllegalArgumentException if any of the provided certificates is
+ * not a CA certificate
+ */
+ public void setCaCertificates(@Nullable X509Certificate[] certs) {
+ if (certs != null) {
+ X509Certificate[] newCerts = new X509Certificate[certs.length];
+ for (int i = 0; i < certs.length; i++) {
+ if (certs[i].getBasicConstraints() >= 0) {
+ newCerts[i] = certs[i];
+ } else {
+ throw new IllegalArgumentException("Not a CA certificate");
+ }
+ }
+ mCaCerts = newCerts;
+ } else {
+ mCaCerts = null;
+ }
+ }
+
+ /**
+ * Get CA certificates.
+ */
+ @Nullable public X509Certificate[] getCaCertificates() {
+ if (mCaCerts != null || mCaCerts.length > 0) {
+ return mCaCerts;
+ } else {
+ return null;
+ }
}
/**
* @hide
*/
public void resetCaCertificate() {
- mCaCert = null;
+ mCaCerts = null;
}
/** Set Client certificate alias.
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index bd030e8..50f2cf0 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -999,7 +999,7 @@
/**
* @return true if this adapter supports Neighbour Awareness Network APIs
- * @hide
+ * @hide PROPOSED_NAN_API
*/
public boolean isNanSupported() {
return isFeatureSupported(WIFI_FEATURE_NAN);
diff --git a/wifi/java/android/net/wifi/WifiScanner.java b/wifi/java/android/net/wifi/WifiScanner.java
index 5534cad..44be671 100644
--- a/wifi/java/android/net/wifi/WifiScanner.java
+++ b/wifi/java/android/net/wifi/WifiScanner.java
@@ -136,17 +136,29 @@
}
}
- /** reports {@link ScanListener#onResults} when underlying buffers are full
+ /**
+ * reports {@link ScanListener#onResults} when underlying buffers are full
+ * this is simply the lack of the {@link #REPORT_EVENT_AFTER_EACH_SCAN} flag
* @deprecated
*/
@Deprecated
public static final int REPORT_EVENT_AFTER_BUFFER_FULL = 0;
- /** reports {@link ScanListener#onResults} after each scan */
- public static final int REPORT_EVENT_AFTER_EACH_SCAN = 1;
- /** reports {@link ScanListener#onFullResult} whenever each beacon is discovered */
- public static final int REPORT_EVENT_FULL_SCAN_RESULT = 2;
- /** do not batch */
- public static final int REPORT_EVENT_NO_BATCH = 4;
+ /**
+ * reports {@link ScanListener#onResults} after each scan
+ */
+ public static final int REPORT_EVENT_AFTER_EACH_SCAN = (1 << 0);
+ /**
+ * reports {@link ScanListener#onFullResult} whenever each beacon is discovered
+ */
+ public static final int REPORT_EVENT_FULL_SCAN_RESULT = (1 << 1);
+ /**
+ * Do not place scans in the chip's scan history buffer
+ */
+ public static final int REPORT_EVENT_NO_BATCH = (1 << 2);
+ /**
+ * report full scan results and completion event to the context hub
+ */
+ public static final int REPORT_EVENT_CONTEXT_HUB = (1 << 3);
/**
* scan configuration parameters to be sent to {@link #startBackgroundScan}
@@ -170,18 +182,14 @@
public int maxScansToCache;
/**
* if maxPeriodInMs is non zero or different than period, then this bucket is
- * an exponential backoff bucket and the scan period will grow exponentially
- * as per formula: actual_period(N) = period ^ (N/(step_count+1))
- * to a maximum period of max_period.
+ * a truncated binary exponential backoff bucket and the scan period will grow
+ * exponentially as per formula: actual_period(N) = period * (2 ^ (N/stepCount))
+ * to maxPeriodInMs
*/
public int maxPeriodInMs;
/**
- * for exponential back off bucket: multiplier: new_period=old_period*exponent
- */
- public int exponent;
- /**
- * for exponential back off bucket, number of scans performed at a given
- * period and until the exponent is applied
+ * for truncated binary exponential back off bucket, number of scans to perform
+ * for a given period
*/
public int stepCount;
@@ -198,7 +206,6 @@
dest.writeInt(numBssidsPerScan);
dest.writeInt(maxScansToCache);
dest.writeInt(maxPeriodInMs);
- dest.writeInt(exponent);
dest.writeInt(stepCount);
if (channels != null) {
@@ -226,7 +233,6 @@
settings.numBssidsPerScan = in.readInt();
settings.maxScansToCache = in.readInt();
settings.maxPeriodInMs = in.readInt();
- settings.exponent = in.readInt();
settings.stepCount = in.readInt();
int num_channels = in.readInt();
settings.channels = new ChannelSpec[num_channels];
diff --git a/wifi/java/android/net/wifi/WifiWakeReasonAndCounts.java b/wifi/java/android/net/wifi/WifiWakeReasonAndCounts.java
new file mode 100644
index 0000000..17cc29f
--- /dev/null
+++ b/wifi/java/android/net/wifi/WifiWakeReasonAndCounts.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.wifi;
+
+import android.os.Parcelable;
+import android.os.Parcel;
+
+/**
+ * A class representing wifi wake reason accounting.
+ */
+
+/** @hide */
+public class WifiWakeReasonAndCounts implements Parcelable {
+ private static final String TAG = "WifiWakeReasonAndCounts";
+ /**
+ * Wlan can wake host, only when it is cmd/event, local driver-fw
+ * functions(non-data, non cmd/event) and rx data.The first packet
+ * from wlan that woke up a sleep host is what is accounted here.
+ * Total wlan wake to application processor would be:
+ * [cmdEventWake + driverFwLocalWake + totalRxDataWake]
+ * A further classification is provided for identifying the reasons
+ * for wakeup.
+ */
+ public int totalCmdEventWake;
+ public int totalDriverFwLocalWake;
+ public int totalRxDataWake;
+
+ public int rxUnicast;
+ public int rxMulticast;
+ public int rxBroadcast;
+
+ public int icmp;
+ public int icmp6;
+ public int icmp6Ra;
+ public int icmp6Na;
+ public int icmp6Ns;
+
+ public int ipv4RxMulticast;
+ public int ipv6Multicast;
+ public int otherRxMulticast;
+
+ /* {@hide} */
+ public WifiWakeReasonAndCounts () {
+ }
+
+ @Override
+ /* {@hide} */
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(" totalCmdEventWake ").append(totalCmdEventWake);
+ sb.append(" totalDriverFwLocalWake ").append(totalDriverFwLocalWake);
+ sb.append(" totalRxDataWake ").append(totalRxDataWake);
+
+ sb.append(" rxUnicast ").append(rxUnicast);
+ sb.append(" rxMulticast ").append(rxMulticast);
+ sb.append(" rxBroadcast ").append(rxBroadcast);
+
+ sb.append(" icmp ").append(icmp);
+ sb.append(" icmp6 ").append(icmp6);
+ sb.append(" icmp6Ra ").append(icmp6Ra);
+ sb.append(" icmp6Na ").append(icmp6Na);
+ sb.append(" icmp6Ns ").append(icmp6Ns);
+
+ sb.append(" ipv4RxMulticast ").append(ipv4RxMulticast);
+ sb.append(" ipv6Multicast ").append(ipv6Multicast);
+ sb.append(" otherRxMulticast ").append(otherRxMulticast);
+ return sb.toString();
+ }
+
+ /* Implement the Parcelable interface
+ * {@hide}
+ */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /* Implement the Parcelable interface
+ * {@hide}
+ */
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(totalCmdEventWake);
+ dest.writeInt(totalDriverFwLocalWake);
+ dest.writeInt(totalRxDataWake);
+
+ dest.writeInt(rxUnicast);
+ dest.writeInt(rxMulticast);
+ dest.writeInt(rxBroadcast);
+
+ dest.writeInt(icmp);
+ dest.writeInt(icmp6);
+ dest.writeInt(icmp6Ra);
+ dest.writeInt(icmp6Na);
+ dest.writeInt(icmp6Ns);
+
+ dest.writeInt(ipv4RxMulticast);
+ dest.writeInt(ipv6Multicast);
+ dest.writeInt(otherRxMulticast);
+ }
+
+ /* Implement the Parcelable interface
+ * {@hide}
+ */
+ public static final Creator<WifiWakeReasonAndCounts> CREATOR =
+ new Creator<WifiWakeReasonAndCounts>() {
+ public WifiWakeReasonAndCounts createFromParcel(Parcel in) {
+ WifiWakeReasonAndCounts counts = new WifiWakeReasonAndCounts();
+ counts.totalCmdEventWake = in.readInt();
+ counts.totalDriverFwLocalWake = in.readInt();
+ counts.totalRxDataWake = in.readInt();
+
+ counts.rxUnicast = in.readInt();
+ counts.rxMulticast = in.readInt();
+ counts.rxBroadcast = in.readInt();
+
+ counts.icmp = in.readInt();
+ counts.icmp6 = in.readInt();
+ counts.icmp6Ra = in.readInt();
+ counts.icmp6Na = in.readInt();
+ counts.icmp6Ns = in.readInt();
+
+ counts.ipv4RxMulticast = in.readInt();
+ counts.ipv6Multicast = in.readInt();
+ counts.otherRxMulticast = in.readInt();
+ return counts;
+ }
+ /* Implement the Parcelable interface
+ * {@hide}
+ */
+ @Override
+ public WifiWakeReasonAndCounts[] newArray(int size) {
+ return new WifiWakeReasonAndCounts[size];
+ }
+ };
+}
diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.aidl b/wifi/java/android/net/wifi/nan/ConfigRequest.aidl
similarity index 74%
copy from wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.aidl
copy to wifi/java/android/net/wifi/nan/ConfigRequest.aidl
index 27f23bc..38dddc2 100644
--- a/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.aidl
+++ b/wifi/java/android/net/wifi/nan/ConfigRequest.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2014, The Android Open Source Project
+/*
+ * Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,6 +14,6 @@
* limitations under the License.
*/
-package android.net.wifi.passpoint;
+package android.net.wifi.nan;
-parcelable WifiPasspointInfo;
+parcelable ConfigRequest;
diff --git a/wifi/java/android/net/wifi/nan/ConfigRequest.java b/wifi/java/android/net/wifi/nan/ConfigRequest.java
new file mode 100644
index 0000000..23e3754
--- /dev/null
+++ b/wifi/java/android/net/wifi/nan/ConfigRequest.java
@@ -0,0 +1,262 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.wifi.nan;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Defines a request object to configure a Wi-Fi NAN network. Built using
+ * {@link ConfigRequest.Builder}. Configuration is requested using
+ * {@link WifiNanManager#requestConfig(ConfigRequest)}. Note that the actual
+ * achieved configuration may be different from the requested configuration -
+ * since multiple applications may request different configurations.
+ *
+ * @hide PROPOSED_NAN_API
+ */
+public class ConfigRequest implements Parcelable {
+ /**
+ * Lower range of possible cluster ID.
+ *
+ * @hide
+ */
+ public static final int CLUSTER_ID_MIN = 0;
+
+ /**
+ * Upper range of possible cluster ID.
+ *
+ * @hide
+ */
+ public static final int CLUSTER_ID_MAX = 0xFFFF;
+
+ /**
+ * Indicates whether 5G band support is requested.
+ *
+ * @hide
+ */
+ public final boolean mSupport5gBand;
+
+ /**
+ * Specifies the desired master preference.
+ *
+ * @hide
+ */
+ public final int mMasterPreference;
+
+ /**
+ * Specifies the desired lower range of the cluster ID. Must be lower then
+ * {@link ConfigRequest#mClusterHigh}.
+ *
+ * @hide
+ */
+ public final int mClusterLow;
+
+ /**
+ * Specifies the desired higher range of the cluster ID. Must be higher then
+ * {@link ConfigRequest#mClusterLow}.
+ *
+ * @hide
+ */
+ public final int mClusterHigh;
+
+ private ConfigRequest(boolean support5gBand, int masterPreference, int clusterLow,
+ int clusterHigh) {
+ mSupport5gBand = support5gBand;
+ mMasterPreference = masterPreference;
+ mClusterLow = clusterLow;
+ mClusterHigh = clusterHigh;
+ }
+
+ @Override
+ public String toString() {
+ return "ConfigRequest [mSupport5gBand=" + mSupport5gBand + ", mMasterPreference="
+ + mMasterPreference + ", mClusterLow=" + mClusterLow + ", mClusterHigh="
+ + mClusterHigh + "]";
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(mSupport5gBand ? 1 : 0);
+ dest.writeInt(mMasterPreference);
+ dest.writeInt(mClusterLow);
+ dest.writeInt(mClusterHigh);
+ }
+
+ public static final Creator<ConfigRequest> CREATOR = new Creator<ConfigRequest>() {
+ @Override
+ public ConfigRequest[] newArray(int size) {
+ return new ConfigRequest[size];
+ }
+
+ @Override
+ public ConfigRequest createFromParcel(Parcel in) {
+ boolean support5gBand = in.readInt() != 0;
+ int masterPreference = in.readInt();
+ int clusterLow = in.readInt();
+ int clusterHigh = in.readInt();
+ return new ConfigRequest(support5gBand, masterPreference, clusterLow, clusterHigh);
+ }
+ };
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (!(o instanceof ConfigRequest)) {
+ return false;
+ }
+
+ ConfigRequest lhs = (ConfigRequest) o;
+
+ return mSupport5gBand == lhs.mSupport5gBand && mMasterPreference == lhs.mMasterPreference
+ && mClusterLow == lhs.mClusterLow && mClusterHigh == lhs.mClusterHigh;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+
+ result = 31 * result + (mSupport5gBand ? 1 : 0);
+ result = 31 * result + mMasterPreference;
+ result = 31 * result + mClusterLow;
+ result = 31 * result + mClusterHigh;
+
+ return result;
+ }
+
+ /**
+ * Builder used to build {@link ConfigRequest} objects.
+ */
+ public static final class Builder {
+ private boolean mSupport5gBand;
+ private int mMasterPreference;
+ private int mClusterLow;
+ private int mClusterHigh;
+
+ /**
+ * Default constructor for the Builder.
+ */
+ public Builder() {
+ mSupport5gBand = false;
+ mMasterPreference = 0;
+ mClusterLow = 0;
+ mClusterHigh = CLUSTER_ID_MAX;
+ }
+
+ /**
+ * Specify whether 5G band support is required in this request.
+ *
+ * @param support5gBand Support for 5G band is required.
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setSupport5gBand(boolean support5gBand) {
+ mSupport5gBand = support5gBand;
+ return this;
+ }
+
+ /**
+ * Specify the Master Preference requested. The permitted range is 0 to
+ * 255 with 1 and 255 excluded (reserved).
+ *
+ * @param masterPreference The requested master preference
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setMasterPreference(int masterPreference) {
+ if (masterPreference < 0) {
+ throw new IllegalArgumentException(
+ "Master Preference specification must be non-negative");
+ }
+ if (masterPreference == 1 || masterPreference == 255 || masterPreference > 255) {
+ throw new IllegalArgumentException("Master Preference specification must not "
+ + "exceed 255 or use 1 or 255 (reserved values)");
+ }
+
+ mMasterPreference = masterPreference;
+ return this;
+ }
+
+ /**
+ * The Cluster ID is generated randomly for new NAN networks. Specify
+ * the lower range of the cluster ID. The upper range is specified using
+ * the {@link ConfigRequest.Builder#setClusterHigh(int)}. The permitted
+ * range is 0 to the value specified by
+ * {@link ConfigRequest.Builder#setClusterHigh(int)}. Equality is
+ * permitted which restricts the Cluster ID to the specified value.
+ *
+ * @param clusterLow The lower range of the generated cluster ID.
+ * @return The builder to facilitate chaining
+ * {@code builder.setClusterLow(..).setClusterHigh(..)}.
+ */
+ public Builder setClusterLow(int clusterLow) {
+ if (clusterLow < CLUSTER_ID_MIN) {
+ throw new IllegalArgumentException("Cluster specification must be non-negative");
+ }
+ if (clusterLow > CLUSTER_ID_MAX) {
+ throw new IllegalArgumentException("Cluster specification must not exceed 0xFFFF");
+ }
+
+ mClusterLow = clusterLow;
+ return this;
+ }
+
+ /**
+ * The Cluster ID is generated randomly for new NAN networks. Specify
+ * the lower upper of the cluster ID. The lower range is specified using
+ * the {@link ConfigRequest.Builder#setClusterLow(int)}. The permitted
+ * range is the value specified by
+ * {@link ConfigRequest.Builder#setClusterLow(int)} to 0xFFFF. Equality
+ * is permitted which restricts the Cluster ID to the specified value.
+ *
+ * @param clusterHigh The upper range of the generated cluster ID.
+ * @return The builder to facilitate chaining
+ * {@code builder.setClusterLow(..).setClusterHigh(..)}.
+ */
+ public Builder setClusterHigh(int clusterHigh) {
+ if (clusterHigh < CLUSTER_ID_MIN) {
+ throw new IllegalArgumentException("Cluster specification must be non-negative");
+ }
+ if (clusterHigh > CLUSTER_ID_MAX) {
+ throw new IllegalArgumentException("Cluster specification must not exceed 0xFFFF");
+ }
+
+ mClusterHigh = clusterHigh;
+ return this;
+ }
+
+ /**
+ * Build {@link ConfigRequest} given the current requests made on the
+ * builder.
+ */
+ public ConfigRequest build() {
+ if (mClusterLow > mClusterHigh) {
+ throw new IllegalArgumentException(
+ "Invalid argument combination - must have Cluster Low <= Cluster High");
+ }
+
+ return new ConfigRequest(mSupport5gBand, mMasterPreference, mClusterLow, mClusterHigh);
+ }
+ }
+}
diff --git a/wifi/java/android/net/wifi/nan/IWifiNanEventListener.aidl b/wifi/java/android/net/wifi/nan/IWifiNanEventListener.aidl
new file mode 100644
index 0000000..13efc36
--- /dev/null
+++ b/wifi/java/android/net/wifi/nan/IWifiNanEventListener.aidl
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2016, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.wifi.nan;
+
+import android.net.wifi.nan.ConfigRequest;
+
+/**
+ * Callback interface that WifiNanManager implements
+ *
+ * {@hide}
+ */
+oneway interface IWifiNanEventListener
+{
+ void onConfigCompleted(in ConfigRequest completedConfig);
+ void onConfigFailed(int reason);
+ void onNanDown(int reason);
+ void onIdentityChanged();
+}
diff --git a/wifi/java/android/net/wifi/nan/IWifiNanManager.aidl b/wifi/java/android/net/wifi/nan/IWifiNanManager.aidl
new file mode 100644
index 0000000..ff3d29f
--- /dev/null
+++ b/wifi/java/android/net/wifi/nan/IWifiNanManager.aidl
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2016, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.wifi.nan;
+
+import android.app.PendingIntent;
+
+import android.net.wifi.nan.ConfigRequest;
+import android.net.wifi.nan.IWifiNanEventListener;
+import android.net.wifi.nan.IWifiNanSessionListener;
+import android.net.wifi.nan.PublishData;
+import android.net.wifi.nan.PublishSettings;
+import android.net.wifi.nan.SubscribeData;
+import android.net.wifi.nan.SubscribeSettings;
+
+/**
+ * Interface that WifiNanService implements
+ *
+ * {@hide}
+ */
+interface IWifiNanManager
+{
+ // client API
+ void connect(in IBinder binder, in IWifiNanEventListener listener, int events);
+ void disconnect(in IBinder binder);
+ void requestConfig(in ConfigRequest configRequest);
+
+ // session API
+ int createSession(in IWifiNanSessionListener listener, int events);
+ void publish(int sessionId, in PublishData publishData, in PublishSettings publishSettings);
+ void subscribe(int sessionId, in SubscribeData subscribeData,
+ in SubscribeSettings subscribeSettings);
+ void sendMessage(int sessionId, int peerId, in byte[] message, int messageLength);
+ void stopSession(int sessionId);
+ void destroySession(int sessionId);
+}
diff --git a/wifi/java/android/net/wifi/nan/IWifiNanSessionListener.aidl b/wifi/java/android/net/wifi/nan/IWifiNanSessionListener.aidl
new file mode 100644
index 0000000..773f83b
--- /dev/null
+++ b/wifi/java/android/net/wifi/nan/IWifiNanSessionListener.aidl
@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2016, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.wifi.nan;
+
+/**
+ * Callback interface that WifiNanManager implements
+ *
+ * {@hide}
+ */
+oneway interface IWifiNanSessionListener
+{
+ void onPublishFail(int reason);
+ void onPublishTerminated(int reason);
+
+ void onSubscribeFail(int reason);
+ void onSubscribeTerminated(int reason);
+
+ void onMatch(int peerId, in byte[] serviceSpecificInfo,
+ int serviceSpecificInfoLength, in byte[] matchFilter, int matchFilterLength);
+
+ void onMessageSendSuccess();
+ void onMessageSendFail(int reason);
+ void onMessageReceived(int peerId, in byte[] message, int messageLength);
+}
diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.aidl b/wifi/java/android/net/wifi/nan/PublishData.aidl
similarity index 74%
copy from wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.aidl
copy to wifi/java/android/net/wifi/nan/PublishData.aidl
index 27f23bc..15e4ddf 100644
--- a/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.aidl
+++ b/wifi/java/android/net/wifi/nan/PublishData.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2014, The Android Open Source Project
+/*
+ * Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,6 +14,6 @@
* limitations under the License.
*/
-package android.net.wifi.passpoint;
+package android.net.wifi.nan;
-parcelable WifiPasspointInfo;
+parcelable PublishData;
diff --git a/wifi/java/android/net/wifi/nan/PublishData.java b/wifi/java/android/net/wifi/nan/PublishData.java
new file mode 100644
index 0000000..80119eb
--- /dev/null
+++ b/wifi/java/android/net/wifi/nan/PublishData.java
@@ -0,0 +1,343 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.wifi.nan;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Arrays;
+
+/**
+ * Defines the data for a NAN publish session. Built using
+ * {@link PublishData.Builder}. Publish is done using
+ * {@link WifiNanManager#publish(PublishData, PublishSettings, WifiNanSessionListener, int)}
+ * or {@link WifiNanPublishSession#publish(PublishData, PublishSettings)}.
+ * @hide PROPOSED_NAN_API
+ */
+public class PublishData implements Parcelable {
+ /**
+ * @hide
+ */
+ public final String mServiceName;
+
+ /**
+ * @hide
+ */
+ public final int mServiceSpecificInfoLength;
+
+ /**
+ * @hide
+ */
+ public final byte[] mServiceSpecificInfo;
+
+ /**
+ * @hide
+ */
+ public final int mTxFilterLength;
+
+ /**
+ * @hide
+ */
+ public final byte[] mTxFilter;
+
+ /**
+ * @hide
+ */
+ public final int mRxFilterLength;
+
+ /**
+ * @hide
+ */
+ public final byte[] mRxFilter;
+
+ private PublishData(String serviceName, byte[] serviceSpecificInfo,
+ int serviceSpecificInfoLength, byte[] txFilter, int txFilterLength, byte[] rxFilter,
+ int rxFilterLength) {
+ mServiceName = serviceName;
+ mServiceSpecificInfoLength = serviceSpecificInfoLength;
+ mServiceSpecificInfo = serviceSpecificInfo;
+ mTxFilterLength = txFilterLength;
+ mTxFilter = txFilter;
+ mRxFilterLength = rxFilterLength;
+ mRxFilter = rxFilter;
+ }
+
+ @Override
+ public String toString() {
+ return "PublishData [mServiceName='" + mServiceName + "', mServiceSpecificInfo='"
+ + (new String(mServiceSpecificInfo, 0, mServiceSpecificInfoLength))
+ + "', mTxFilter="
+ + (new TlvBufferUtils.TlvIterable(0, 1, mTxFilter, mTxFilterLength)).toString()
+ + ", mRxFilter="
+ + (new TlvBufferUtils.TlvIterable(0, 1, mRxFilter, mRxFilterLength)).toString()
+ + "']";
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeString(mServiceName);
+ dest.writeInt(mServiceSpecificInfoLength);
+ if (mServiceSpecificInfoLength != 0) {
+ dest.writeByteArray(mServiceSpecificInfo, 0, mServiceSpecificInfoLength);
+ }
+ dest.writeInt(mTxFilterLength);
+ if (mTxFilterLength != 0) {
+ dest.writeByteArray(mTxFilter, 0, mTxFilterLength);
+ }
+ dest.writeInt(mRxFilterLength);
+ if (mRxFilterLength != 0) {
+ dest.writeByteArray(mRxFilter, 0, mRxFilterLength);
+ }
+ }
+
+ public static final Creator<PublishData> CREATOR = new Creator<PublishData>() {
+ @Override
+ public PublishData[] newArray(int size) {
+ return new PublishData[size];
+ }
+
+ @Override
+ public PublishData createFromParcel(Parcel in) {
+ String serviceName = in.readString();
+ int ssiLength = in.readInt();
+ byte[] ssi = new byte[ssiLength];
+ if (ssiLength != 0) {
+ in.readByteArray(ssi);
+ }
+ int txFilterLength = in.readInt();
+ byte[] txFilter = new byte[txFilterLength];
+ if (txFilterLength != 0) {
+ in.readByteArray(txFilter);
+ }
+ int rxFilterLength = in.readInt();
+ byte[] rxFilter = new byte[rxFilterLength];
+ if (rxFilterLength != 0) {
+ in.readByteArray(rxFilter);
+ }
+
+ return new PublishData(serviceName, ssi, ssiLength, txFilter, txFilterLength, rxFilter,
+ rxFilterLength);
+ }
+ };
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (!(o instanceof PublishData)) {
+ return false;
+ }
+
+ PublishData lhs = (PublishData) o;
+
+ if (!mServiceName.equals(lhs.mServiceName)
+ || mServiceSpecificInfoLength != lhs.mServiceSpecificInfoLength
+ || mTxFilterLength != lhs.mTxFilterLength
+ || mRxFilterLength != lhs.mRxFilterLength) {
+ return false;
+ }
+
+ if (mServiceSpecificInfo != null && lhs.mServiceSpecificInfo != null) {
+ for (int i = 0; i < mServiceSpecificInfoLength; ++i) {
+ if (mServiceSpecificInfo[i] != lhs.mServiceSpecificInfo[i]) {
+ return false;
+ }
+ }
+ } else if (mServiceSpecificInfoLength != 0) {
+ return false; // invalid != invalid
+ }
+
+ if (mTxFilter != null && lhs.mTxFilter != null) {
+ for (int i = 0; i < mTxFilterLength; ++i) {
+ if (mTxFilter[i] != lhs.mTxFilter[i]) {
+ return false;
+ }
+ }
+ } else if (mTxFilterLength != 0) {
+ return false; // invalid != invalid
+ }
+
+ if (mRxFilter != null && lhs.mRxFilter != null) {
+ for (int i = 0; i < mRxFilterLength; ++i) {
+ if (mRxFilter[i] != lhs.mRxFilter[i]) {
+ return false;
+ }
+ }
+ } else if (mRxFilterLength != 0) {
+ return false; // invalid != invalid
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+
+ result = 31 * result + mServiceName.hashCode();
+ result = 31 * result + mServiceSpecificInfoLength;
+ result = 31 * result + Arrays.hashCode(mServiceSpecificInfo);
+ result = 31 * result + mTxFilterLength;
+ result = 31 * result + Arrays.hashCode(mTxFilter);
+ result = 31 * result + mRxFilterLength;
+ result = 31 * result + Arrays.hashCode(mRxFilter);
+
+ return result;
+ }
+
+ /**
+ * Builder used to build {@link PublishData} objects.
+ */
+ public static final class Builder {
+ private String mServiceName;
+ private int mServiceSpecificInfoLength;
+ private byte[] mServiceSpecificInfo = new byte[0];
+ private int mTxFilterLength;
+ private byte[] mTxFilter = new byte[0];
+ private int mRxFilterLength;
+ private byte[] mRxFilter = new byte[0];
+
+ /**
+ * Specify the service name of the publish session. The actual on-air
+ * value is a 6 byte hashed representation of this string.
+ *
+ * @param serviceName The service name for the publish session.
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setServiceName(String serviceName) {
+ mServiceName = serviceName;
+ return this;
+ }
+
+ /**
+ * Specify service specific information for the publish session. This is
+ * a free-form byte array available to the application to send
+ * additional information as part of the discovery operation - i.e. it
+ * will not be used to determine whether a publish/subscribe match
+ * occurs.
+ *
+ * @param serviceSpecificInfo A byte-array for the service-specific
+ * information field.
+ * @param serviceSpecificInfoLength The length of the byte-array to be
+ * used.
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setServiceSpecificInfo(byte[] serviceSpecificInfo,
+ int serviceSpecificInfoLength) {
+ if (serviceSpecificInfoLength != 0 && (serviceSpecificInfo == null
+ || serviceSpecificInfo.length < serviceSpecificInfoLength)) {
+ throw new IllegalArgumentException("Non-matching combination of "
+ + "serviceSpecificInfo and serviceSpecificInfoLength");
+ }
+ mServiceSpecificInfoLength = serviceSpecificInfoLength;
+ mServiceSpecificInfo = serviceSpecificInfo;
+ return this;
+ }
+
+ /**
+ * Specify service specific information for the publish session - same
+ * as {@link PublishData.Builder#setServiceSpecificInfo(byte[], int)}
+ * but obtaining the data from a String.
+ *
+ * @param serviceSpecificInfoStr The service specific information string
+ * to be included (as a byte array) in the publish
+ * information.
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setServiceSpecificInfo(String serviceSpecificInfoStr) {
+ mServiceSpecificInfoLength = serviceSpecificInfoStr.length();
+ mServiceSpecificInfo = serviceSpecificInfoStr.getBytes();
+ return this;
+ }
+
+ /**
+ * The transmit filter for an active publish session
+ * {@link PublishSettings.Builder#setPublishType(int)} and
+ * {@link PublishSettings#PUBLISH_TYPE_UNSOLICITED}. Included in
+ * transmitted publish packets and used by receivers (subscribers) to
+ * determine whether they match - in addition to just relying on the
+ * service name.
+ * <p>
+ * Format is an LV byte array - the {@link TlvBufferUtils} utility class
+ * is available to form and parse.
+ *
+ * @param txFilter The byte-array containing the LV formatted transmit
+ * filter.
+ * @param txFilterLength The number of bytes in the transmit filter
+ * argument.
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setTxFilter(byte[] txFilter, int txFilterLength) {
+ if (txFilterLength != 0 && (txFilter == null || txFilter.length < txFilterLength)) {
+ throw new IllegalArgumentException(
+ "Non-matching combination of txFilter and txFilterLength");
+ }
+ mTxFilter = txFilter;
+ mTxFilterLength = txFilterLength;
+ return this;
+ }
+
+ /**
+ * The transmit filter for a passive publish session
+ * {@link PublishSettings.Builder#setPublishType(int)} and
+ * {@link PublishSettings#PUBLISH_TYPE_SOLICITED}. Used by the publisher
+ * to determine whether they match transmitted subscriber packets
+ * (active subscribers) - in addition to just relying on the service
+ * name.
+ * <p>
+ * Format is an LV byte array - the {@link TlvBufferUtils} utility class
+ * is available to form and parse.
+ *
+ * @param rxFilter The byte-array containing the LV formatted receive
+ * filter.
+ * @param rxFilterLength The number of bytes in the receive filter
+ * argument.
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setRxFilter(byte[] rxFilter, int rxFilterLength) {
+ if (rxFilterLength != 0 && (rxFilter == null || rxFilter.length < rxFilterLength)) {
+ throw new IllegalArgumentException(
+ "Non-matching combination of rxFilter and rxFilterLength");
+ }
+ mRxFilter = rxFilter;
+ mRxFilterLength = rxFilterLength;
+ return this;
+ }
+
+ /**
+ * Build {@link PublishData} given the current requests made on the
+ * builder.
+ */
+ public PublishData build() {
+ return new PublishData(mServiceName, mServiceSpecificInfo, mServiceSpecificInfoLength,
+ mTxFilter, mTxFilterLength, mRxFilter, mRxFilterLength);
+ }
+ }
+}
diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.aidl b/wifi/java/android/net/wifi/nan/PublishSettings.aidl
similarity index 74%
copy from wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.aidl
copy to wifi/java/android/net/wifi/nan/PublishSettings.aidl
index 27f23bc..ff69293 100644
--- a/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.aidl
+++ b/wifi/java/android/net/wifi/nan/PublishSettings.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2014, The Android Open Source Project
+/*
+ * Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,6 +14,6 @@
* limitations under the License.
*/
-package android.net.wifi.passpoint;
+package android.net.wifi.nan;
-parcelable WifiPasspointInfo;
+parcelable PublishSettings;
diff --git a/wifi/java/android/net/wifi/nan/PublishSettings.java b/wifi/java/android/net/wifi/nan/PublishSettings.java
new file mode 100644
index 0000000..bbc5340
--- /dev/null
+++ b/wifi/java/android/net/wifi/nan/PublishSettings.java
@@ -0,0 +1,204 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.wifi.nan;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Defines the settings (configuration) for a NAN publish session. Built using
+ * {@link PublishSettings.Builder}. Publish is done using
+ * {@link WifiNanManager#publish(PublishData, PublishSettings, WifiNanSessionListener, int)}
+ * or {@link WifiNanPublishSession#publish(PublishData, PublishSettings)}.
+ *
+ * @hide PROPOSED_NAN_API
+ */
+public class PublishSettings implements Parcelable {
+
+ /**
+ * Defines an unsolicited publish session - i.e. a publish session where
+ * publish packets are transmitted over-the-air. Configuration is done using
+ * {@link PublishSettings.Builder#setPublishType(int)}.
+ */
+ public static final int PUBLISH_TYPE_UNSOLICITED = 0;
+
+ /**
+ * Defines a solicited publish session - i.e. a publish session where
+ * publish packets are not transmitted over-the-air and the device listens
+ * and matches to transmitted subscribe packets. Configuration is done using
+ * {@link PublishSettings.Builder#setPublishType(int)}.
+ */
+ public static final int PUBLISH_TYPE_SOLICITED = 1;
+
+ /**
+ * @hide
+ */
+ public final int mPublishType;
+
+ /**
+ * @hide
+ */
+ public final int mPublishCount;
+
+ /**
+ * @hide
+ */
+ public final int mTtlSec;
+
+ private PublishSettings(int publishType, int publichCount, int ttlSec) {
+ mPublishType = publishType;
+ mPublishCount = publichCount;
+ mTtlSec = ttlSec;
+ }
+
+ @Override
+ public String toString() {
+ return "PublishSettings [mPublishType=" + mPublishType + ", mPublishCount=" + mPublishCount
+ + ", mTtlSec=" + mTtlSec + "]";
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(mPublishType);
+ dest.writeInt(mPublishCount);
+ dest.writeInt(mTtlSec);
+ }
+
+ public static final Creator<PublishSettings> CREATOR = new Creator<PublishSettings>() {
+ @Override
+ public PublishSettings[] newArray(int size) {
+ return new PublishSettings[size];
+ }
+
+ @Override
+ public PublishSettings createFromParcel(Parcel in) {
+ int publishType = in.readInt();
+ int publishCount = in.readInt();
+ int ttlSec = in.readInt();
+ return new PublishSettings(publishType, publishCount, ttlSec);
+ }
+ };
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (!(o instanceof PublishSettings)) {
+ return false;
+ }
+
+ PublishSettings lhs = (PublishSettings) o;
+
+ return mPublishType == lhs.mPublishType && mPublishCount == lhs.mPublishCount
+ && mTtlSec == lhs.mTtlSec;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+
+ result = 31 * result + mPublishType;
+ result = 31 * result + mPublishCount;
+ result = 31 * result + mTtlSec;
+
+ return result;
+ }
+
+ /**
+ * Builder used to build {@link PublishSettings} objects.
+ */
+ public static final class Builder {
+ int mPublishType;
+ int mPublishCount;
+ int mTtlSec;
+
+ /**
+ * Sets the type of the publish session: solicited (aka active - publish
+ * packets are transmitted over-the-air), or unsolicited (aka passive -
+ * no publish packets are transmitted, a match is made against an active
+ * subscribe session whose packets are transmitted over-the-air).
+ *
+ * @param publishType Publish session type: solicited (
+ * {@link PublishSettings#PUBLISH_TYPE_SOLICITED}) or
+ * unsolicited (
+ * {@link PublishSettings#PUBLISH_TYPE_UNSOLICITED}).
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setPublishType(int publishType) {
+ if (publishType < PUBLISH_TYPE_UNSOLICITED || publishType > PUBLISH_TYPE_SOLICITED) {
+ throw new IllegalArgumentException("Invalid publishType - " + publishType);
+ }
+ mPublishType = publishType;
+ return this;
+ }
+
+ /**
+ * Sets the number of times a solicited (
+ * {@link PublishSettings.Builder#setPublishType(int)}) publish session
+ * will transmit a packet. When the count is reached an event will be
+ * generated for {@link WifiNanSessionListener#onPublishTerminated(int)}
+ * with reason={@link WifiNanSessionListener#TERMINATE_REASON_DONE}.
+ *
+ * @param publishCount Number of publish packets to transmit.
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setPublishCount(int publishCount) {
+ if (publishCount < 0) {
+ throw new IllegalArgumentException("Invalid publishCount - must be non-negative");
+ }
+ mPublishCount = publishCount;
+ return this;
+ }
+
+ /**
+ * Sets the time interval (in seconds) a solicited (
+ * {@link PublishSettings.Builder#setPublishCount(int)}) publish session
+ * will be alive - i.e. transmitting a packet. When the TTL is reached
+ * an event will be generated for
+ * {@link WifiNanSessionListener#onPublishTerminated(int)} with reason=
+ * {@link WifiNanSessionListener#TERMINATE_REASON_DONE}.
+ *
+ * @param ttlSec Lifetime of a publish session in seconds.
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setTtlSec(int ttlSec) {
+ if (ttlSec < 0) {
+ throw new IllegalArgumentException("Invalid ttlSec - must be non-negative");
+ }
+ mTtlSec = ttlSec;
+ return this;
+ }
+
+ /**
+ * Build {@link PublishSettings} given the current requests made on the
+ * builder.
+ */
+ public PublishSettings build() {
+ return new PublishSettings(mPublishType, mPublishCount, mTtlSec);
+ }
+ }
+}
diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.aidl b/wifi/java/android/net/wifi/nan/SubscribeData.aidl
similarity index 74%
copy from wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.aidl
copy to wifi/java/android/net/wifi/nan/SubscribeData.aidl
index 27f23bc..662fdb8 100644
--- a/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.aidl
+++ b/wifi/java/android/net/wifi/nan/SubscribeData.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2014, The Android Open Source Project
+/*
+ * Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,6 +14,6 @@
* limitations under the License.
*/
-package android.net.wifi.passpoint;
+package android.net.wifi.nan;
-parcelable WifiPasspointInfo;
+parcelable SubscribeData;
diff --git a/wifi/java/android/net/wifi/nan/SubscribeData.java b/wifi/java/android/net/wifi/nan/SubscribeData.java
new file mode 100644
index 0000000..cd6e918
--- /dev/null
+++ b/wifi/java/android/net/wifi/nan/SubscribeData.java
@@ -0,0 +1,329 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.wifi.nan;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Arrays;
+
+/**
+ * Defines the data for a NAN subscribe session. Built using
+ * {@link SubscribeData.Builder}. Subscribe is done using
+ * {@link WifiNanManager#subscribe(SubscribeData, SubscribeSettings, WifiNanSessionListener, int)}
+ * or
+ * {@link WifiNanSubscribeSession#subscribe(SubscribeData, SubscribeSettings)}.
+ * @hide PROPOSED_NAN_API
+ */
+public class SubscribeData implements Parcelable {
+ /**
+ * @hide
+ */
+ public final String mServiceName;
+
+ /**
+ * @hide
+ */
+ public final int mServiceSpecificInfoLength;
+
+ /**
+ * @hide
+ */
+ public final byte[] mServiceSpecificInfo;
+
+ /**
+ * @hide
+ */
+ public final int mTxFilterLength;
+
+ /**
+ * @hide
+ */
+ public final byte[] mTxFilter;
+
+ /**
+ * @hide
+ */
+ public final int mRxFilterLength;
+
+ /**
+ * @hide
+ */
+ public final byte[] mRxFilter;
+
+ private SubscribeData(String serviceName, byte[] serviceSpecificInfo,
+ int serviceSpecificInfoLength, byte[] txFilter, int txFilterLength, byte[] rxFilter,
+ int rxFilterLength) {
+ mServiceName = serviceName;
+ mServiceSpecificInfoLength = serviceSpecificInfoLength;
+ mServiceSpecificInfo = serviceSpecificInfo;
+ mTxFilterLength = txFilterLength;
+ mTxFilter = txFilter;
+ mRxFilterLength = rxFilterLength;
+ mRxFilter = rxFilter;
+ }
+
+ @Override
+ public String toString() {
+ return "SubscribeData [mServiceName='" + mServiceName + "', mServiceSpecificInfo='"
+ + (new String(mServiceSpecificInfo, 0, mServiceSpecificInfoLength))
+ + "', mTxFilter="
+ + (new TlvBufferUtils.TlvIterable(0, 1, mTxFilter, mTxFilterLength)).toString()
+ + ", mRxFilter="
+ + (new TlvBufferUtils.TlvIterable(0, 1, mRxFilter, mRxFilterLength)).toString()
+ + "']";
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeString(mServiceName);
+ dest.writeInt(mServiceSpecificInfoLength);
+ if (mServiceSpecificInfoLength != 0) {
+ dest.writeByteArray(mServiceSpecificInfo, 0, mServiceSpecificInfoLength);
+ }
+ dest.writeInt(mTxFilterLength);
+ if (mTxFilterLength != 0) {
+ dest.writeByteArray(mTxFilter, 0, mTxFilterLength);
+ }
+ dest.writeInt(mRxFilterLength);
+ if (mRxFilterLength != 0) {
+ dest.writeByteArray(mRxFilter, 0, mRxFilterLength);
+ }
+ }
+
+ public static final Creator<SubscribeData> CREATOR = new Creator<SubscribeData>() {
+ @Override
+ public SubscribeData[] newArray(int size) {
+ return new SubscribeData[size];
+ }
+
+ @Override
+ public SubscribeData createFromParcel(Parcel in) {
+ String serviceName = in.readString();
+ int ssiLength = in.readInt();
+ byte[] ssi = new byte[ssiLength];
+ if (ssiLength != 0) {
+ in.readByteArray(ssi);
+ }
+ int txFilterLength = in.readInt();
+ byte[] txFilter = new byte[txFilterLength];
+ if (txFilterLength != 0) {
+ in.readByteArray(txFilter);
+ }
+ int rxFilterLength = in.readInt();
+ byte[] rxFilter = new byte[rxFilterLength];
+ if (rxFilterLength != 0) {
+ in.readByteArray(rxFilter);
+ }
+
+ return new SubscribeData(serviceName, ssi, ssiLength, txFilter, txFilterLength,
+ rxFilter, rxFilterLength);
+ }
+ };
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (!(o instanceof SubscribeData)) {
+ return false;
+ }
+
+ SubscribeData lhs = (SubscribeData) o;
+
+ if (!mServiceName.equals(lhs.mServiceName)
+ || mServiceSpecificInfoLength != lhs.mServiceSpecificInfoLength
+ || mTxFilterLength != lhs.mTxFilterLength
+ || mRxFilterLength != lhs.mRxFilterLength) {
+ return false;
+ }
+
+ if (mServiceSpecificInfo != null && lhs.mServiceSpecificInfo != null) {
+ for (int i = 0; i < mServiceSpecificInfoLength; ++i) {
+ if (mServiceSpecificInfo[i] != lhs.mServiceSpecificInfo[i]) {
+ return false;
+ }
+ }
+ } else if (mServiceSpecificInfoLength != 0) {
+ return false; // invalid != invalid
+ }
+
+ if (mTxFilter != null && lhs.mTxFilter != null) {
+ for (int i = 0; i < mTxFilterLength; ++i) {
+ if (mTxFilter[i] != lhs.mTxFilter[i]) {
+ return false;
+ }
+ }
+ } else if (mTxFilterLength != 0) {
+ return false; // invalid != invalid
+ }
+
+ if (mRxFilter != null && lhs.mRxFilter != null) {
+ for (int i = 0; i < mRxFilterLength; ++i) {
+ if (mRxFilter[i] != lhs.mRxFilter[i]) {
+ return false;
+ }
+ }
+ } else if (mRxFilterLength != 0) {
+ return false; // invalid != invalid
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+
+ result = 31 * result + mServiceName.hashCode();
+ result = 31 * result + mServiceSpecificInfoLength;
+ result = 31 * result + Arrays.hashCode(mServiceSpecificInfo);
+ result = 31 * result + mTxFilterLength;
+ result = 31 * result + Arrays.hashCode(mTxFilter);
+ result = 31 * result + mRxFilterLength;
+ result = 31 * result + Arrays.hashCode(mRxFilter);
+
+ return result;
+ }
+
+ /**
+ * Builder used to build {@link SubscribeData} objects.
+ */
+ public static final class Builder {
+ private String mServiceName;
+ private int mServiceSpecificInfoLength;
+ private byte[] mServiceSpecificInfo = new byte[0];
+ private int mTxFilterLength;
+ private byte[] mTxFilter = new byte[0];
+ private int mRxFilterLength;
+ private byte[] mRxFilter = new byte[0];
+
+ /**
+ * Specify the service name of the subscribe session. The actual on-air
+ * value is a 6 byte hashed representation of this string.
+ *
+ * @param serviceName The service name for the subscribe session.
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setServiceName(String serviceName) {
+ mServiceName = serviceName;
+ return this;
+ }
+
+ /**
+ * Specify service specific information for the subscribe session. This
+ * is a free-form byte array available to the application to send
+ * additional information as part of the discovery operation - i.e. it
+ * will not be used to determine whether a publish/subscribe match
+ * occurs.
+ *
+ * @param serviceSpecificInfo A byte-array for the service-specific
+ * information field.
+ * @param serviceSpecificInfoLength The length of the byte-array to be
+ * used.
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setServiceSpecificInfo(byte[] serviceSpecificInfo,
+ int serviceSpecificInfoLength) {
+ mServiceSpecificInfoLength = serviceSpecificInfoLength;
+ mServiceSpecificInfo = serviceSpecificInfo;
+ return this;
+ }
+
+ /**
+ * Specify service specific information for the subscribe session - same
+ * as {@link SubscribeData.Builder#setServiceSpecificInfo(byte[], int)}
+ * but obtaining the data from a String.
+ *
+ * @param serviceSpecificInfoStr The service specific information string
+ * to be included (as a byte array) in the subscribe
+ * information.
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setServiceSpecificInfo(String serviceSpecificInfoStr) {
+ mServiceSpecificInfoLength = serviceSpecificInfoStr.length();
+ mServiceSpecificInfo = serviceSpecificInfoStr.getBytes();
+ return this;
+ }
+
+ /**
+ * The transmit filter for an active subscribe session
+ * {@link SubscribeSettings.Builder#setSubscribeType(int)} and
+ * {@link SubscribeSettings#SUBSCRIBE_TYPE_ACTIVE}. Included in
+ * transmitted subscribe packets and used by receivers (passive
+ * publishers) to determine whether they match - in addition to just
+ * relying on the service name.
+ * <p>
+ * Format is an LV byte array - the {@link TlvBufferUtils} utility class
+ * is available to form and parse.
+ *
+ * @param txFilter The byte-array containing the LV formatted transmit
+ * filter.
+ * @param txFilterLength The number of bytes in the transmit filter
+ * argument.
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setTxFilter(byte[] txFilter, int txFilterLength) {
+ mTxFilter = txFilter;
+ mTxFilterLength = txFilterLength;
+ return this;
+ }
+
+ /**
+ * The transmit filter for a passive subsribe session
+ * {@link SubscribeSettings.Builder#setSubscribeType(int)} and
+ * {@link SubscribeSettings#SUBSCRIBE_TYPE_PASSIVE}. Used by the
+ * subscriber to determine whether they match transmitted publish
+ * packets - in addition to just relying on the service name.
+ * <p>
+ * Format is an LV byte array - the {@link TlvBufferUtils} utility class
+ * is available to form and parse.
+ *
+ * @param rxFilter The byte-array containing the LV formatted receive
+ * filter.
+ * @param rxFilterLength The number of bytes in the receive filter
+ * argument.
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setRxFilter(byte[] rxFilter, int rxFilterLength) {
+ mRxFilter = rxFilter;
+ mRxFilterLength = rxFilterLength;
+ return this;
+ }
+
+ /**
+ * Build {@link SubscribeData} given the current requests made on the
+ * builder.
+ */
+ public SubscribeData build() {
+ return new SubscribeData(mServiceName, mServiceSpecificInfo, mServiceSpecificInfoLength,
+ mTxFilter, mTxFilterLength, mRxFilter, mRxFilterLength);
+ }
+ }
+}
diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.aidl b/wifi/java/android/net/wifi/nan/SubscribeSettings.aidl
similarity index 74%
rename from wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.aidl
rename to wifi/java/android/net/wifi/nan/SubscribeSettings.aidl
index 27f23bc..44849bc 100644
--- a/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.aidl
+++ b/wifi/java/android/net/wifi/nan/SubscribeSettings.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2014, The Android Open Source Project
+/*
+ * Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,6 +14,6 @@
* limitations under the License.
*/
-package android.net.wifi.passpoint;
+package android.net.wifi.nan;
-parcelable WifiPasspointInfo;
+parcelable SubscribeSettings;
diff --git a/wifi/java/android/net/wifi/nan/SubscribeSettings.java b/wifi/java/android/net/wifi/nan/SubscribeSettings.java
new file mode 100644
index 0000000..5c4f8fb
--- /dev/null
+++ b/wifi/java/android/net/wifi/nan/SubscribeSettings.java
@@ -0,0 +1,205 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.wifi.nan;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Defines the settings (configuration) for a NAN subscribe session. Built using
+ * {@link SubscribeSettings.Builder}. Subscribe is done using
+ * {@link WifiNanManager#subscribe(SubscribeData, SubscribeSettings, WifiNanSessionListener, int)}
+ * or {@link WifiNanSubscribeSession#subscribe(SubscribeData, SubscribeSettings)}.
+ *
+ * @hide PROPOSED_NAN_API
+ */
+public class SubscribeSettings implements Parcelable {
+
+ /**
+ * Defines a passive subscribe session - i.e. a subscribe session where
+ * subscribe packets are not transmitted over-the-air and the device listens
+ * and matches to transmitted publish packets. Configuration is done using
+ * {@link SubscribeSettings.Builder#setSubscribeType(int)}.
+ */
+ public static final int SUBSCRIBE_TYPE_PASSIVE = 0;
+
+ /**
+ * Defines an active subscribe session - i.e. a subscribe session where
+ * subscribe packets are transmitted over-the-air. Configuration is done
+ * using {@link SubscribeSettings.Builder#setSubscribeType(int)}.
+ */
+ public static final int SUBSCRIBE_TYPE_ACTIVE = 1;
+
+ /**
+ * @hide
+ */
+ public final int mSubscribeType;
+
+ /**
+ * @hide
+ */
+ public final int mSubscribeCount;
+
+ /**
+ * @hide
+ */
+ public final int mTtlSec;
+
+ private SubscribeSettings(int subscribeType, int publichCount, int ttlSec) {
+ mSubscribeType = subscribeType;
+ mSubscribeCount = publichCount;
+ mTtlSec = ttlSec;
+ }
+
+ @Override
+ public String toString() {
+ return "SubscribeSettings [mSubscribeType=" + mSubscribeType + ", mSubscribeCount="
+ + mSubscribeCount + ", mTtlSec=" + mTtlSec + "]";
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(mSubscribeType);
+ dest.writeInt(mSubscribeCount);
+ dest.writeInt(mTtlSec);
+ }
+
+ public static final Creator<SubscribeSettings> CREATOR = new Creator<SubscribeSettings>() {
+ @Override
+ public SubscribeSettings[] newArray(int size) {
+ return new SubscribeSettings[size];
+ }
+
+ @Override
+ public SubscribeSettings createFromParcel(Parcel in) {
+ int subscribeType = in.readInt();
+ int subscribeCount = in.readInt();
+ int ttlSec = in.readInt();
+ return new SubscribeSettings(subscribeType, subscribeCount, ttlSec);
+ }
+ };
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (!(o instanceof SubscribeSettings)) {
+ return false;
+ }
+
+ SubscribeSettings lhs = (SubscribeSettings) o;
+
+ return mSubscribeType == lhs.mSubscribeType && mSubscribeCount == lhs.mSubscribeCount
+ && mTtlSec == lhs.mTtlSec;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+
+ result = 31 * result + mSubscribeType;
+ result = 31 * result + mSubscribeCount;
+ result = 31 * result + mTtlSec;
+
+ return result;
+ }
+
+ /**
+ * Builder used to build {@link SubscribeSettings} objects.
+ */
+ public static final class Builder {
+ int mSubscribeType;
+ int mSubscribeCount;
+ int mTtlSec;
+
+ /**
+ * Sets the type of the subscribe session: active (subscribe packets are
+ * transmitted over-the-air), or passive (no subscribe packets are
+ * transmitted, a match is made against a solicited/active publish
+ * session whose packets are transmitted over-the-air).
+ *
+ * @param subscribeType Subscribe session type: active (
+ * {@link SubscribeSettings#SUBSCRIBE_TYPE_ACTIVE}) or
+ * passive ( {@link SubscribeSettings#SUBSCRIBE_TYPE_PASSIVE}
+ * ).
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setSubscribeType(int subscribeType) {
+ if (subscribeType < SUBSCRIBE_TYPE_PASSIVE || subscribeType > SUBSCRIBE_TYPE_ACTIVE) {
+ throw new IllegalArgumentException("Invalid subscribeType - " + subscribeType);
+ }
+ mSubscribeType = subscribeType;
+ return this;
+ }
+
+ /**
+ * Sets the number of times an active (
+ * {@link SubscribeSettings.Builder#setSubscribeType(int)}) subscribe
+ * session will transmit a packet. When the count is reached an event
+ * will be generated for
+ * {@link WifiNanSessionListener#onSubscribeTerminated(int)} with reason=
+ * {@link WifiNanSessionListener#TERMINATE_REASON_DONE}.
+ *
+ * @param subscribeCount Number of subscribe packets to transmit.
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setSubscribeCount(int subscribeCount) {
+ if (subscribeCount < 0) {
+ throw new IllegalArgumentException("Invalid subscribeCount - must be non-negative");
+ }
+ mSubscribeCount = subscribeCount;
+ return this;
+ }
+
+ /**
+ * Sets the time interval (in seconds) an active (
+ * {@link SubscribeSettings.Builder#setSubscribeType(int)}) subscribe
+ * session will be alive - i.e. transmitting a packet. When the TTL is
+ * reached an event will be generated for
+ * {@link WifiNanSessionListener#onSubscribeTerminated(int)} with reason=
+ * {@link WifiNanSessionListener#TERMINATE_REASON_DONE}.
+ *
+ * @param ttlSec Lifetime of a subscribe session in seconds.
+ * @return The builder to facilitate chaining
+ * {@code builder.setXXX(..).setXXX(..)}.
+ */
+ public Builder setTtlSec(int ttlSec) {
+ if (ttlSec < 0) {
+ throw new IllegalArgumentException("Invalid ttlSec - must be non-negative");
+ }
+ mTtlSec = ttlSec;
+ return this;
+ }
+
+ /**
+ * Build {@link SubscribeSettings} given the current requests made on
+ * the builder.
+ */
+ public SubscribeSettings build() {
+ return new SubscribeSettings(mSubscribeType, mSubscribeCount, mTtlSec);
+ }
+ }
+}
diff --git a/wifi/java/android/net/wifi/nan/TlvBufferUtils.java b/wifi/java/android/net/wifi/nan/TlvBufferUtils.java
new file mode 100644
index 0000000..ea8785a
--- /dev/null
+++ b/wifi/java/android/net/wifi/nan/TlvBufferUtils.java
@@ -0,0 +1,490 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.wifi.nan;
+
+import libcore.io.Memory;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteOrder;
+import java.util.Iterator;
+
+/**
+ * Utility class to construct and parse byte arrays using the TLV format -
+ * Type/Length/Value format. The utilities accept a configuration of the size of
+ * the Type field and the Length field. A Type field size of 0 is allowed -
+ * allowing usage for LV (no T) array formats.
+ *
+ * @hide PROPOSED_NAN_API
+ */
+public class TlvBufferUtils {
+ private TlvBufferUtils() {
+ // no reason to ever create this class
+ }
+
+ /**
+ * Utility class to construct byte arrays using the TLV format -
+ * Type/Length/Value.
+ * <p>
+ * A constructor is created specifying the size of the Type (T) and Length
+ * (L) fields. A specification of zero size T field is allowed - resulting
+ * in LV type format.
+ * <p>
+ * The byte array is either provided (using
+ * {@link TlvConstructor#wrap(byte[])}) or allocated (using
+ * {@link TlvConstructor#allocate(int)}).
+ * <p>
+ * Values are added to the structure using the {@code TlvConstructor.put*()}
+ * methods.
+ * <p>
+ * The final byte array is obtained using {@link TlvConstructor#getArray()}
+ * and {@link TlvConstructor#getActualLength()} methods.
+ */
+ public static class TlvConstructor {
+ private int mTypeSize;
+ private int mLengthSize;
+
+ private byte[] mArray;
+ private int mArrayLength;
+ private int mPosition;
+
+ /**
+ * Define a TLV constructor with the specified size of the Type (T) and
+ * Length (L) fields.
+ *
+ * @param typeSize Number of bytes used for the Type (T) field. Values
+ * of 0, 1, or 2 bytes are allowed. A specification of 0
+ * bytes implies that the field being constructed has the LV
+ * format rather than the TLV format.
+ * @param lengthSize Number of bytes used for the Length (L) field.
+ * Values of 1 or 2 bytes are allowed.
+ */
+ public TlvConstructor(int typeSize, int lengthSize) {
+ if (typeSize < 0 || typeSize > 2 || lengthSize <= 0 || lengthSize > 2) {
+ throw new IllegalArgumentException(
+ "Invalid sizes - typeSize=" + typeSize + ", lengthSize=" + lengthSize);
+ }
+ mTypeSize = typeSize;
+ mLengthSize = lengthSize;
+ }
+
+ /**
+ * Set the byte array to be used to construct the TLV.
+ *
+ * @param array Byte array to be formatted.
+ * @return The constructor to facilitate chaining
+ * {@code ctr.putXXX(..).putXXX(..)}.
+ */
+ public TlvConstructor wrap(byte[] array) {
+ mArray = array;
+ mArrayLength = array.length;
+ return this;
+ }
+
+ /**
+ * Allocates a new byte array to be used ot construct a TLV.
+ *
+ * @param capacity The size of the byte array to be allocated.
+ * @return The constructor to facilitate chaining
+ * {@code ctr.putXXX(..).putXXX(..)}.
+ */
+ public TlvConstructor allocate(int capacity) {
+ mArray = new byte[capacity];
+ mArrayLength = capacity;
+ return this;
+ }
+
+ /**
+ * Copies a byte into the TLV with the indicated type. For an LV
+ * formatted structure (i.e. typeLength=0 in {@link TlvConstructor
+ * TlvConstructor(int, int)} ) the type field is ignored.
+ *
+ * @param type The value to be placed into the Type field.
+ * @param b The byte to be inserted into the structure.
+ * @return The constructor to facilitate chaining
+ * {@code ctr.putXXX(..).putXXX(..)}.
+ */
+ public TlvConstructor putByte(int type, byte b) {
+ checkLength(1);
+ addHeader(type, 1);
+ mArray[mPosition++] = b;
+ return this;
+ }
+
+ /**
+ * Copies a byte array into the TLV with the indicated type. For an LV
+ * formatted structure (i.e. typeLength=0 in {@link TlvConstructor
+ * TlvConstructor(int, int)} ) the type field is ignored.
+ *
+ * @param type The value to be placed into the Type field.
+ * @param array The array to be copied into the TLV structure.
+ * @param offset Start copying from the array at the specified offset.
+ * @param length Copy the specified number (length) of bytes from the
+ * array.
+ * @return The constructor to facilitate chaining
+ * {@code ctr.putXXX(..).putXXX(..)}.
+ */
+ public TlvConstructor putByteArray(int type, byte[] array, int offset, int length) {
+ checkLength(length);
+ addHeader(type, length);
+ System.arraycopy(array, offset, mArray, mPosition, length);
+ mPosition += length;
+ return this;
+ }
+
+ /**
+ * Copies a byte array into the TLV with the indicated type. For an LV
+ * formatted structure (i.e. typeLength=0 in {@link TlvConstructor
+ * TlvConstructor(int, int)} ) the type field is ignored.
+ *
+ * @param type The value to be placed into the Type field.
+ * @param array The array to be copied (in full) into the TLV structure.
+ * @return The constructor to facilitate chaining
+ * {@code ctr.putXXX(..).putXXX(..)}.
+ */
+ public TlvConstructor putByteArray(int type, byte[] array) {
+ return putByteArray(type, array, 0, array.length);
+ }
+
+ /**
+ * Places a zero length element (i.e. Length field = 0) into the TLV.
+ * For an LV formatted structure (i.e. typeLength=0 in
+ * {@link TlvConstructor TlvConstructor(int, int)} ) the type field is
+ * ignored.
+ *
+ * @param type The value to be placed into the Type field.
+ * @return The constructor to facilitate chaining
+ * {@code ctr.putXXX(..).putXXX(..)}.
+ */
+ public TlvConstructor putZeroLengthElement(int type) {
+ checkLength(0);
+ addHeader(type, 0);
+ return this;
+ }
+
+ /**
+ * Copies short into the TLV with the indicated type. For an LV
+ * formatted structure (i.e. typeLength=0 in {@link TlvConstructor
+ * TlvConstructor(int, int)} ) the type field is ignored.
+ *
+ * @param type The value to be placed into the Type field.
+ * @param data The short to be inserted into the structure.
+ * @return The constructor to facilitate chaining
+ * {@code ctr.putXXX(..).putXXX(..)}.
+ */
+ public TlvConstructor putShort(int type, short data) {
+ checkLength(2);
+ addHeader(type, 2);
+ Memory.pokeShort(mArray, mPosition, data, ByteOrder.BIG_ENDIAN);
+ mPosition += 2;
+ return this;
+ }
+
+ /**
+ * Copies integer into the TLV with the indicated type. For an LV
+ * formatted structure (i.e. typeLength=0 in {@link TlvConstructor
+ * TlvConstructor(int, int)} ) the type field is ignored.
+ *
+ * @param type The value to be placed into the Type field.
+ * @param data The integer to be inserted into the structure.
+ * @return The constructor to facilitate chaining
+ * {@code ctr.putXXX(..).putXXX(..)}.
+ */
+ public TlvConstructor putInt(int type, int data) {
+ checkLength(4);
+ addHeader(type, 4);
+ Memory.pokeInt(mArray, mPosition, data, ByteOrder.BIG_ENDIAN);
+ mPosition += 4;
+ return this;
+ }
+
+ /**
+ * Copies a String's byte representation into the TLV with the indicated
+ * type. For an LV formatted structure (i.e. typeLength=0 in
+ * {@link TlvConstructor TlvConstructor(int, int)} ) the type field is
+ * ignored.
+ *
+ * @param type The value to be placed into the Type field.
+ * @param data The string whose bytes are to be inserted into the
+ * structure.
+ * @return The constructor to facilitate chaining
+ * {@code ctr.putXXX(..).putXXX(..)}.
+ */
+ public TlvConstructor putString(int type, String data) {
+ return putByteArray(type, data.getBytes(), 0, data.length());
+ }
+
+ /**
+ * Returns the constructed TLV formatted byte-array. Note that the
+ * returned array is the fully wrapped (
+ * {@link TlvConstructor#wrap(byte[])}) or allocated (
+ * {@link TlvConstructor#allocate(int)}) array - which isn't necessarily
+ * the actual size of the formatted data. Use
+ * {@link TlvConstructor#getActualLength()} to obtain the size of the
+ * formatted data.
+ *
+ * @return The byte array containing the TLV formatted structure.
+ */
+ public byte[] getArray() {
+ return mArray;
+ }
+
+ /**
+ * Returns the size of the TLV formatted portion of the wrapped or
+ * allocated byte array. The array itself is returned with
+ * {@link TlvConstructor#getArray()}.
+ *
+ * @return The size of the TLV formatted portion of the byte array.
+ */
+ public int getActualLength() {
+ return mPosition;
+ }
+
+ private void checkLength(int dataLength) {
+ if (mPosition + mTypeSize + mLengthSize + dataLength > mArrayLength) {
+ throw new BufferOverflowException();
+ }
+ }
+
+ private void addHeader(int type, int length) {
+ if (mTypeSize == 1) {
+ mArray[mPosition] = (byte) type;
+ } else if (mTypeSize == 2) {
+ Memory.pokeShort(mArray, mPosition, (short) type, ByteOrder.BIG_ENDIAN);
+ }
+ mPosition += mTypeSize;
+
+ if (mLengthSize == 1) {
+ mArray[mPosition] = (byte) length;
+ } else if (mLengthSize == 2) {
+ Memory.pokeShort(mArray, mPosition, (short) length, ByteOrder.BIG_ENDIAN);
+ }
+ mPosition += mLengthSize;
+ }
+ }
+
+ /**
+ * Utility class used when iterating over a TLV formatted byte-array. Use
+ * {@link TlvIterable} to iterate over array. A {@link TlvElement}
+ * represents each entry in a TLV formatted byte-array.
+ */
+ public static class TlvElement {
+ /**
+ * The Type (T) field of the current TLV element. Note that for LV
+ * formatted byte-arrays (i.e. TLV whose Type/T size is 0) the value of
+ * this field is undefined.
+ */
+ public int mType;
+
+ /**
+ * The Length (L) field of the current TLV element.
+ */
+ public int mLength;
+
+ /**
+ * The Value (V) field - a raw byte array representing the current TLV
+ * element where the entry starts at {@link TlvElement#mOffset}.
+ */
+ public byte[] mRefArray;
+
+ /**
+ * The offset to be used into {@link TlvElement#mRefArray} to access the
+ * raw data representing the current TLV element.
+ */
+ public int mOffset;
+
+ private TlvElement(int type, int length, byte[] refArray, int offset) {
+ mType = type;
+ mLength = length;
+ mRefArray = refArray;
+ mOffset = offset;
+ }
+
+ /**
+ * Utility function to return a byte representation of a TLV element of
+ * length 1. Note: an attempt to call this function on a TLV item whose
+ * {@link TlvElement#mLength} is != 1 will result in an exception.
+ *
+ * @return byte representation of current TLV element.
+ */
+ public byte getByte() {
+ if (mLength != 1) {
+ throw new IllegalArgumentException(
+ "Accesing a byte from a TLV element of length " + mLength);
+ }
+ return mRefArray[mOffset];
+ }
+
+ /**
+ * Utility function to return a short representation of a TLV element of
+ * length 2. Note: an attempt to call this function on a TLV item whose
+ * {@link TlvElement#mLength} is != 2 will result in an exception.
+ *
+ * @return short representation of current TLV element.
+ */
+ public short getShort() {
+ if (mLength != 2) {
+ throw new IllegalArgumentException(
+ "Accesing a short from a TLV element of length " + mLength);
+ }
+ return Memory.peekShort(mRefArray, mOffset, ByteOrder.BIG_ENDIAN);
+ }
+
+ /**
+ * Utility function to return an integer representation of a TLV element
+ * of length 4. Note: an attempt to call this function on a TLV item
+ * whose {@link TlvElement#mLength} is != 4 will result in an exception.
+ *
+ * @return integer representation of current TLV element.
+ */
+ public int getInt() {
+ if (mLength != 4) {
+ throw new IllegalArgumentException(
+ "Accesing an int from a TLV element of length " + mLength);
+ }
+ return Memory.peekInt(mRefArray, mOffset, ByteOrder.BIG_ENDIAN);
+ }
+
+ /**
+ * Utility function to return a String representation of a TLV element.
+ *
+ * @return String repersentation of the current TLV element.
+ */
+ public String getString() {
+ return new String(mRefArray, mOffset, mLength);
+ }
+ }
+
+ /**
+ * Utility class to iterate over a TLV formatted byte-array.
+ */
+ public static class TlvIterable implements Iterable<TlvElement> {
+ private int mTypeSize;
+ private int mLengthSize;
+ private byte[] mArray;
+ private int mArrayLength;
+
+ /**
+ * Constructs a TlvIterable object - specifying the format of the TLV
+ * (the sizes of the Type and Length fields), and the byte array whose
+ * data is to be parsed.
+ *
+ * @param typeSize Number of bytes used for the Type (T) field. Valid
+ * values are 0 (i.e. indicating the format is LV rather than
+ * TLV), 1, and 2 bytes.
+ * @param lengthSize Number of bytes sued for the Length (L) field.
+ * Values values are 1 or 2 bytes.
+ * @param array The TLV formatted byte-array to parse.
+ * @param length The number of bytes of the array to be used in the
+ * parsing.
+ */
+ public TlvIterable(int typeSize, int lengthSize, byte[] array, int length) {
+ if (typeSize < 0 || typeSize > 2 || lengthSize <= 0 || lengthSize > 2) {
+ throw new IllegalArgumentException(
+ "Invalid sizes - typeSize=" + typeSize + ", lengthSize=" + lengthSize);
+ }
+ mTypeSize = typeSize;
+ mLengthSize = lengthSize;
+ mArray = array;
+ mArrayLength = length;
+ }
+
+ /**
+ * Prints out a parsed representation of the TLV-formatted byte array.
+ * Whenever possible bytes, shorts, and integer are printed out (for
+ * fields whose length is 1, 2, or 4 respectively).
+ */
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+
+ builder.append("[");
+ boolean first = true;
+ for (TlvElement tlv : this) {
+ if (!first) {
+ builder.append(",");
+ }
+ first = false;
+ builder.append(" (");
+ if (mTypeSize != 0) {
+ builder.append("T=" + tlv.mType + ",");
+ }
+ builder.append("L=" + tlv.mLength + ") ");
+ if (tlv.mLength == 0) {
+ builder.append("<null>");
+ } else if (tlv.mLength == 1) {
+ builder.append(tlv.getByte());
+ } else if (tlv.mLength == 2) {
+ builder.append(tlv.getShort());
+ } else if (tlv.mLength == 4) {
+ builder.append(tlv.getInt());
+ } else {
+ builder.append("<bytes>");
+ }
+ if (tlv.mLength != 0) {
+ builder.append(" (S='" + tlv.getString() + "')");
+ }
+ }
+ builder.append("]");
+
+ return builder.toString();
+ }
+
+ /**
+ * Returns an iterator to step through a TLV formatted byte-array. The
+ * individual elements returned by the iterator are {@link TlvElement}.
+ */
+ @Override
+ public Iterator<TlvElement> iterator() {
+ return new Iterator<TlvElement>() {
+ private int mOffset = 0;
+
+ @Override
+ public boolean hasNext() {
+ return mOffset < mArrayLength;
+ }
+
+ @Override
+ public TlvElement next() {
+ int type = 0;
+ if (mTypeSize == 1) {
+ type = mArray[mOffset];
+ } else if (mTypeSize == 2) {
+ type = Memory.peekShort(mArray, mOffset, ByteOrder.BIG_ENDIAN);
+ }
+ mOffset += mTypeSize;
+
+ int length = 0;
+ if (mLengthSize == 1) {
+ length = mArray[mOffset];
+ } else if (mLengthSize == 2) {
+ length = Memory.peekShort(mArray, mOffset, ByteOrder.BIG_ENDIAN);
+ }
+ mOffset += mLengthSize;
+
+ TlvElement tlv = new TlvElement(type, length, mArray, mOffset);
+ mOffset += length;
+ return tlv;
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+ }
+}
diff --git a/wifi/java/android/net/wifi/nan/WifiNanEventListener.java b/wifi/java/android/net/wifi/nan/WifiNanEventListener.java
new file mode 100644
index 0000000..eae0a55
--- /dev/null
+++ b/wifi/java/android/net/wifi/nan/WifiNanEventListener.java
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.wifi.nan;
+
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+import android.util.Log;
+
+/**
+ * Base class for NAN events callbacks. Should be extended by applications
+ * wanting notifications. These are callbacks applying to the NAN connection as
+ * a whole - not to specific publish or subscribe sessions - for that see
+ * {@link WifiNanSessionListener}.
+ * <p>
+ * During registration specify which specific events are desired using a set of
+ * {@code NanEventListener.LISTEN_*} flags OR'd together. Only those events will
+ * be delivered to the registered listener. Override those callbacks
+ * {@code NanEventListener.on*} for the registered events.
+ *
+ * @hide PROPOSED_NAN_API
+ */
+public class WifiNanEventListener {
+ private static final String TAG = "WifiNanEventListener";
+ private static final boolean DBG = true;
+ private static final boolean VDBG = false; // STOPSHIP if true
+
+ /**
+ * Configuration completion callback event registration flag. Corresponding
+ * callback is {@link WifiNanEventListener#onConfigCompleted(ConfigRequest)}.
+ */
+ public static final int LISTEN_CONFIG_COMPLETED = 0x1 << 0;
+
+ /**
+ * Configuration failed callback event registration flag. Corresponding
+ * callback is {@link WifiNanEventListener#onConfigFailed(int)}.
+ */
+ public static final int LISTEN_CONFIG_FAILED = 0x1 << 1;
+
+ /**
+ * NAN cluster is down callback event registration flag. Corresponding
+ * callback is {@link WifiNanEventListener#onNanDown(int)}.
+ */
+ public static final int LISTEN_NAN_DOWN = 0x1 << 2;
+
+ /**
+ * NAN identity has changed event registration flag. This may be due to
+ * joining a cluster, starting a cluster, or discovery interface change. The
+ * implication is that peers you've been communicating with may no longer
+ * recognize you and you need to re-establish your identity. Corresponding
+ * callback is {@link WifiNanEventListener#onIdentityChanged()}.
+ */
+ public static final int LISTEN_IDENTITY_CHANGED = 0x1 << 3;
+
+ private final Handler mHandler;
+
+ /**
+ * Constructs a {@link WifiNanEventListener} using the looper of the current
+ * thread. I.e. all callbacks will be delivered on the current thread.
+ */
+ public WifiNanEventListener() {
+ this(Looper.myLooper());
+ }
+
+ /**
+ * Constructs a {@link WifiNanEventListener} using the specified looper. I.e.
+ * all callbacks will delivered on the thread of the specified looper.
+ *
+ * @param looper The looper on which to execute the callbacks.
+ */
+ public WifiNanEventListener(Looper looper) {
+ if (VDBG) Log.v(TAG, "ctor: looper=" + looper);
+ mHandler = new Handler(looper) {
+ @Override
+ public void handleMessage(Message msg) {
+ if (DBG) Log.d(TAG, "What=" + msg.what + ", msg=" + msg);
+ switch (msg.what) {
+ case LISTEN_CONFIG_COMPLETED:
+ WifiNanEventListener.this.onConfigCompleted((ConfigRequest) msg.obj);
+ break;
+ case LISTEN_CONFIG_FAILED:
+ WifiNanEventListener.this.onConfigFailed(msg.arg1);
+ break;
+ case LISTEN_NAN_DOWN:
+ WifiNanEventListener.this.onNanDown(msg.arg1);
+ break;
+ case LISTEN_IDENTITY_CHANGED:
+ WifiNanEventListener.this.onIdentityChanged();
+ break;
+ }
+ }
+ };
+ }
+
+ /**
+ * Called when NAN configuration is completed. Event will only be delivered
+ * if registered using {@link WifiNanEventListener#LISTEN_CONFIG_COMPLETED}. A
+ * dummy (empty implementation printing out a warning). Make sure to
+ * override if registered.
+ *
+ * @param completedConfig The actual configuration request which was
+ * completed. Note that it may be different from that requested
+ * by the application. The service combines configuration
+ * requests from all applications.
+ */
+ public void onConfigCompleted(ConfigRequest completedConfig) {
+ Log.w(TAG, "onConfigCompleted: called in stub - override if interested or disable");
+ }
+
+ /**
+ * Called when NAN configuration failed. Event will only be delivered if
+ * registered using {@link WifiNanEventListener#LISTEN_CONFIG_FAILED}. A dummy
+ * (empty implementation printing out a warning). Make sure to override if
+ * registered.
+ *
+ * @param reason Failure reason code, see {@code NanSessionListener.FAIL_*}.
+ */
+ public void onConfigFailed(int reason) {
+ Log.w(TAG, "onConfigFailed: called in stub - override if interested or disable");
+ }
+
+ /**
+ * Called when NAN cluster is down. Event will only be delivered if
+ * registered using {@link WifiNanEventListener#LISTEN_NAN_DOWN}. A dummy (empty
+ * implementation printing out a warning). Make sure to override if
+ * registered.
+ *
+ * @param reason Reason code for event, see {@code NanSessionListener.FAIL_*}.
+ */
+ public void onNanDown(int reason) {
+ Log.w(TAG, "onNanDown: called in stub - override if interested or disable");
+ }
+
+ /**
+ * Called when NAN identity has changed. This may be due to joining a
+ * cluster, starting a cluster, or discovery interface change. The
+ * implication is that peers you've been communicating with may no longer
+ * recognize you and you need to re-establish your identity. Event will only
+ * be delivered if registered using
+ * {@link WifiNanEventListener#LISTEN_IDENTITY_CHANGED}. A dummy (empty
+ * implementation printing out a warning). Make sure to override if
+ * registered.
+ */
+ public void onIdentityChanged() {
+ if (VDBG) Log.v(TAG, "onIdentityChanged: called in stub - override if interested");
+ }
+
+ /**
+ * {@hide}
+ */
+ public IWifiNanEventListener callback = new IWifiNanEventListener.Stub() {
+ @Override
+ public void onConfigCompleted(ConfigRequest completedConfig) {
+ if (VDBG) Log.v(TAG, "onConfigCompleted: configRequest=" + completedConfig);
+
+ Message msg = mHandler.obtainMessage(LISTEN_CONFIG_COMPLETED);
+ msg.obj = completedConfig;
+ mHandler.sendMessage(msg);
+ }
+
+ @Override
+ public void onConfigFailed(int reason) {
+ if (VDBG) Log.v(TAG, "onConfigFailed: reason=" + reason);
+
+ Message msg = mHandler.obtainMessage(LISTEN_CONFIG_FAILED);
+ msg.arg1 = reason;
+ mHandler.sendMessage(msg);
+ }
+
+ @Override
+ public void onNanDown(int reason) {
+ if (VDBG) Log.v(TAG, "onNanDown: reason=" + reason);
+
+ Message msg = mHandler.obtainMessage(LISTEN_NAN_DOWN);
+ msg.arg1 = reason;
+ mHandler.sendMessage(msg);
+ }
+
+ @Override
+ public void onIdentityChanged() {
+ if (VDBG) Log.v(TAG, "onIdentityChanged");
+
+ Message msg = mHandler.obtainMessage(LISTEN_IDENTITY_CHANGED);
+ mHandler.sendMessage(msg);
+ }
+ };
+}
diff --git a/wifi/java/android/net/wifi/nan/WifiNanManager.java b/wifi/java/android/net/wifi/nan/WifiNanManager.java
new file mode 100644
index 0000000..877f993
--- /dev/null
+++ b/wifi/java/android/net/wifi/nan/WifiNanManager.java
@@ -0,0 +1,333 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.wifi.nan;
+
+import android.os.Binder;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.util.Log;
+
+/**
+ * This class provides the primary API for managing Wi-Fi NAN operation:
+ * including discovery and data-links. Get an instance of this class by calling
+ * {@link android.content.Context#getSystemService(String)
+ * Context.getSystemService(Context.WIFI_NAN_SERVICE)}.
+ * <p>
+ * The class provides access to:
+ * <ul>
+ * <li>Configure a NAN connection and register for events.
+ * <li>Create publish and subscribe sessions.
+ * <li>Create NAN network specifier to be used to create a NAN network.
+ * </ul>
+ *
+ * @hide PROPOSED_NAN_API
+ */
+public class WifiNanManager {
+ private static final String TAG = "WifiNanManager";
+ private static final boolean DBG = true;
+ private static final boolean VDBG = false; // STOPSHIP if true
+
+ private IBinder mBinder;
+
+ private IWifiNanManager mService;
+
+ /**
+ * {@hide}
+ */
+ public WifiNanManager(IWifiNanManager service) {
+ mService = service;
+ }
+
+ /**
+ * Re-connect to the Wi-Fi NAN service - enabling the application to execute
+ * {@link WifiNanManager} APIs. Application don't normally need to call this
+ * API since it is executed in the constructor. However, applications which
+ * have explicitly {@link WifiNanManager#disconnect()} need to call this
+ * function to re-connect.
+ *
+ * @param listener A listener extended from {@link WifiNanEventListener}.
+ * @param events The set of events to be delivered to the {@code listener}.
+ * OR'd event flags from {@link WifiNanEventListener
+ * NanEventListener.LISTEN*}.
+ */
+ public void connect(WifiNanEventListener listener, int events) {
+ try {
+ if (VDBG) Log.v(TAG, "connect()");
+ if (listener == null) {
+ throw new IllegalArgumentException("Invalid listener - must not be null");
+ }
+ if (mBinder == null) {
+ mBinder = new Binder();
+ }
+ mService.connect(mBinder, listener.callback, events);
+ } catch (RemoteException e) {
+ Log.w(TAG, "connect RemoteException (FYI - ignoring): " + e);
+ }
+ }
+
+ /**
+ * Disconnect from the Wi-Fi NAN service and destroy all outstanding
+ * operations - i.e. all publish and subscribes are terminated, any
+ * outstanding data-link is shut-down, and all requested NAN configurations
+ * are cancelled.
+ * <p>
+ * An application may then re-connect using
+ * {@link WifiNanManager#connect(WifiNanEventListener, int)} .
+ */
+ public void disconnect() {
+ try {
+ if (VDBG) Log.v(TAG, "disconnect()");
+ mService.disconnect(mBinder);
+ mBinder = null;
+ } catch (RemoteException e) {
+ Log.w(TAG, "disconnect RemoteException (FYI - ignoring): " + e);
+ }
+ }
+
+ /**
+ * Requests a NAN configuration, specified by {@link ConfigRequest}. Note
+ * that NAN is a shared resource and the device can only be a member of a
+ * single cluster. Thus the service may merge configuration requests from
+ * multiple applications and configure NAN differently from individual
+ * requests.
+ * <p>
+ * The {@link WifiNanEventListener#onConfigCompleted(ConfigRequest)} will be
+ * called when configuration is completed (if a listener is registered for
+ * this specific event).
+ *
+ * @param configRequest The requested NAN configuration.
+ */
+ public void requestConfig(ConfigRequest configRequest) {
+ if (VDBG) Log.v(TAG, "requestConfig(): configRequest=" + configRequest);
+ try {
+ mService.requestConfig(configRequest);
+ } catch (RemoteException e) {
+ Log.w(TAG, "requestConfig RemoteException (FYI - ignoring): " + e);
+ }
+ }
+
+ /**
+ * Request a NAN publish session. The results of the publish session
+ * operation will result in callbacks to the indicated listener:
+ * {@link WifiNanSessionListener NanSessionListener.on*}.
+ *
+ * @param publishData The {@link PublishData} specifying the contents of the
+ * publish session.
+ * @param publishSettings The {@link PublishSettings} specifying the
+ * settings for the publish session.
+ * @param listener The {@link WifiNanSessionListener} derived objects to be used
+ * for the event callbacks specified by {@code events}.
+ * @param events The list of events to be delivered to the {@code listener}
+ * object. An OR'd value of {@link WifiNanSessionListener
+ * NanSessionListener.LISTEN_*}.
+ * @return The {@link WifiNanPublishSession} which can be used to further
+ * control the publish session.
+ */
+ public WifiNanPublishSession publish(PublishData publishData, PublishSettings publishSettings,
+ WifiNanSessionListener listener, int events) {
+ return publishRaw(publishData, publishSettings, listener,
+ events | WifiNanSessionListener.LISTEN_HIDDEN_FLAGS);
+ }
+
+ /**
+ * Same as publish(*) but does not modify the event flag
+ *
+ * @hide
+ */
+ public WifiNanPublishSession publishRaw(PublishData publishData,
+ PublishSettings publishSettings, WifiNanSessionListener listener, int events) {
+ if (VDBG) Log.v(TAG, "publish(): data='" + publishData + "', settings=" + publishSettings);
+
+ if (publishSettings.mPublishType == PublishSettings.PUBLISH_TYPE_UNSOLICITED
+ && publishData.mRxFilterLength != 0) {
+ throw new IllegalArgumentException("Invalid publish data & settings: UNSOLICITED "
+ + "publishes (active) can't have an Rx filter");
+ }
+ if (publishSettings.mPublishType == PublishSettings.PUBLISH_TYPE_SOLICITED
+ && publishData.mTxFilterLength != 0) {
+ throw new IllegalArgumentException("Invalid publish data & settings: SOLICITED "
+ + "publishes (passive) can't have a Tx filter");
+ }
+ if (listener == null) {
+ throw new IllegalArgumentException("Invalid listener - must not be null");
+ }
+
+ int sessionId;
+
+ try {
+ sessionId = mService.createSession(listener.callback, events);
+ if (DBG) Log.d(TAG, "publish: session created - sessionId=" + sessionId);
+ mService.publish(sessionId, publishData, publishSettings);
+ } catch (RemoteException e) {
+ Log.w(TAG, "createSession/publish RemoteException: " + e);
+ return null;
+ }
+
+ return new WifiNanPublishSession(this, sessionId);
+ }
+
+ /**
+ * {@hide}
+ */
+ public void publish(int sessionId, PublishData publishData, PublishSettings publishSettings) {
+ if (VDBG) Log.v(TAG, "publish(): data='" + publishData + "', settings=" + publishSettings);
+
+ if (publishSettings.mPublishType == PublishSettings.PUBLISH_TYPE_UNSOLICITED
+ && publishData.mRxFilterLength != 0) {
+ throw new IllegalArgumentException("Invalid publish data & settings: UNSOLICITED "
+ + "publishes (active) can't have an Rx filter");
+ }
+ if (publishSettings.mPublishType == PublishSettings.PUBLISH_TYPE_SOLICITED
+ && publishData.mTxFilterLength != 0) {
+ throw new IllegalArgumentException("Invalid publish data & settings: SOLICITED "
+ + "publishes (passive) can't have a Tx filter");
+ }
+
+ try {
+ mService.publish(sessionId, publishData, publishSettings);
+ } catch (RemoteException e) {
+ Log.w(TAG, "publish RemoteException: " + e);
+ }
+ }
+ /**
+ * Request a NAN subscribe session. The results of the subscribe session
+ * operation will result in callbacks to the indicated listener:
+ * {@link WifiNanSessionListener NanSessionListener.on*}.
+ *
+ * @param subscribeData The {@link SubscribeData} specifying the contents of
+ * the subscribe session.
+ * @param subscribeSettings The {@link SubscribeSettings} specifying the
+ * settings for the subscribe session.
+ * @param listener The {@link WifiNanSessionListener} derived objects to be used
+ * for the event callbacks specified by {@code events}.
+ * @param events The list of events to be delivered to the {@code listener}
+ * object. An OR'd value of {@link WifiNanSessionListener
+ * NanSessionListener.LISTEN_*}.
+ * @return The {@link WifiNanSubscribeSession} which can be used to further
+ * control the subscribe session.
+ */
+ public WifiNanSubscribeSession subscribe(SubscribeData subscribeData,
+ SubscribeSettings subscribeSettings,
+ WifiNanSessionListener listener, int events) {
+ return subscribeRaw(subscribeData, subscribeSettings, listener,
+ events | WifiNanSessionListener.LISTEN_HIDDEN_FLAGS);
+ }
+
+ /**
+ * Same as subscribe(*) but does not modify the event flag
+ *
+ * @hide
+ */
+ public WifiNanSubscribeSession subscribeRaw(SubscribeData subscribeData,
+ SubscribeSettings subscribeSettings, WifiNanSessionListener listener, int events) {
+ if (VDBG) {
+ Log.v(TAG, "subscribe(): data='" + subscribeData + "', settings=" + subscribeSettings);
+ }
+
+ if (subscribeSettings.mSubscribeType == SubscribeSettings.SUBSCRIBE_TYPE_ACTIVE
+ && subscribeData.mRxFilterLength != 0) {
+ throw new IllegalArgumentException(
+ "Invalid subscribe data & settings: ACTIVE subscribes can't have an Rx filter");
+ }
+ if (subscribeSettings.mSubscribeType == SubscribeSettings.SUBSCRIBE_TYPE_PASSIVE
+ && subscribeData.mTxFilterLength != 0) {
+ throw new IllegalArgumentException(
+ "Invalid subscribe data & settings: PASSIVE subscribes can't have a Tx filter");
+ }
+
+ int sessionId;
+
+ try {
+ sessionId = mService.createSession(listener.callback, events);
+ if (DBG) Log.d(TAG, "subscribe: session created - sessionId=" + sessionId);
+ mService.subscribe(sessionId, subscribeData, subscribeSettings);
+ } catch (RemoteException e) {
+ Log.w(TAG, "createSession/subscribe RemoteException: " + e);
+ return null;
+ }
+
+ return new WifiNanSubscribeSession(this, sessionId);
+ }
+
+ /**
+ * {@hide}
+ */
+ public void subscribe(int sessionId, SubscribeData subscribeData,
+ SubscribeSettings subscribeSettings) {
+ if (VDBG) {
+ Log.v(TAG, "subscribe(): data='" + subscribeData + "', settings=" + subscribeSettings);
+ }
+
+ if (subscribeSettings.mSubscribeType == SubscribeSettings.SUBSCRIBE_TYPE_ACTIVE
+ && subscribeData.mRxFilterLength != 0) {
+ throw new IllegalArgumentException(
+ "Invalid subscribe data & settings: ACTIVE subscribes can't have an Rx filter");
+ }
+ if (subscribeSettings.mSubscribeType == SubscribeSettings.SUBSCRIBE_TYPE_PASSIVE
+ && subscribeData.mTxFilterLength != 0) {
+ throw new IllegalArgumentException(
+ "Invalid subscribe data & settings: PASSIVE subscribes can't have a Tx filter");
+ }
+
+ try {
+ mService.subscribe(sessionId, subscribeData, subscribeSettings);
+ } catch (RemoteException e) {
+ Log.w(TAG, "subscribe RemoteException: " + e);
+ }
+ }
+
+ /**
+ * {@hide}
+ */
+ public void stopSession(int sessionId) {
+ if (DBG) Log.d(TAG, "Stop NAN session #" + sessionId);
+
+ try {
+ mService.stopSession(sessionId);
+ } catch (RemoteException e) {
+ Log.w(TAG, "stopSession RemoteException (FYI - ignoring): " + e);
+ }
+ }
+
+ /**
+ * {@hide}
+ */
+ public void destroySession(int sessionId) {
+ if (DBG) Log.d(TAG, "Destroy NAN session #" + sessionId);
+
+ try {
+ mService.destroySession(sessionId);
+ } catch (RemoteException e) {
+ Log.w(TAG, "destroySession RemoteException (FYI - ignoring): " + e);
+ }
+ }
+
+ /**
+ * {@hide}
+ */
+ public void sendMessage(int sessionId, int peerId, byte[] message, int messageLength) {
+ try {
+ if (VDBG) {
+ Log.v(TAG, "sendMessage(): sessionId=" + sessionId + ", peerId=" + peerId
+ + ", messageLength=" + messageLength);
+ }
+ mService.sendMessage(sessionId, peerId, message, messageLength);
+ } catch (RemoteException e) {
+ Log.w(TAG, "subscribe RemoteException (FYI - ignoring): " + e);
+ }
+ }
+}
diff --git a/wifi/java/android/net/wifi/nan/WifiNanPublishSession.java b/wifi/java/android/net/wifi/nan/WifiNanPublishSession.java
new file mode 100644
index 0000000..81b38f4
--- /dev/null
+++ b/wifi/java/android/net/wifi/nan/WifiNanPublishSession.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.wifi.nan;
+
+/**
+ * A representation of a NAN publish session. Created when
+ * {@link WifiNanManager#publish(PublishData, PublishSettings, WifiNanSessionListener, int)}
+ * is executed. The object can be used to stop and re-start (re-configure) the
+ * publish session.
+ *
+ * @hide PROPOSED_NAN_API
+ */
+public class WifiNanPublishSession extends WifiNanSession {
+ /**
+ * {@hide}
+ */
+ public WifiNanPublishSession(WifiNanManager manager, int sessionId) {
+ super(manager, sessionId);
+ }
+
+ /**
+ * Restart/re-configure the publish session. Note that the
+ * {@link WifiNanSessionListener} is not replaced - the same listener used at
+ * creation is still used.
+ *
+ * @param publishData The data ({@link PublishData}) to publish.
+ * @param publishSettings The settings ({@link PublishSettings}) of the
+ * publish session.
+ */
+ public void publish(PublishData publishData, PublishSettings publishSettings) {
+ mManager.publish(mSessionId, publishData, publishSettings);
+ }
+}
diff --git a/wifi/java/android/net/wifi/nan/WifiNanSession.java b/wifi/java/android/net/wifi/nan/WifiNanSession.java
new file mode 100644
index 0000000..c6b384e
--- /dev/null
+++ b/wifi/java/android/net/wifi/nan/WifiNanSession.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.wifi.nan;
+
+import android.util.Log;
+
+/**
+ * A representation of a single publish or subscribe NAN session. This object
+ * will not be created directly - only its child classes are available:
+ * {@link WifiNanPublishSession} and {@link WifiNanSubscribeSession}.
+ *
+ * @hide PROPOSED_NAN_API
+ */
+public class WifiNanSession {
+ private static final String TAG = "WifiNanSession";
+ private static final boolean DBG = true;
+ private static final boolean VDBG = false; // STOPSHIP if true
+
+ /**
+ * {@hide}
+ */
+ protected WifiNanManager mManager;
+
+ /**
+ * {@hide}
+ */
+ protected int mSessionId;
+
+ /**
+ * {@hide}
+ */
+ private boolean mDestroyed;
+
+ /**
+ * {@hide}
+ */
+ public WifiNanSession(WifiNanManager manager, int sessionId) {
+ if (VDBG) Log.v(TAG, "New client created: manager=" + manager + ", sessionId=" + sessionId);
+
+ mManager = manager;
+ mSessionId = sessionId;
+ mDestroyed = false;
+ }
+
+ /**
+ * Terminate the current publish or subscribe session - i.e. stop
+ * transmitting packet on-air (for an active session) or listening for
+ * matches (for a passive session). Note that the session may still receive
+ * incoming messages and may be re-configured/re-started at a later time.
+ */
+ public void stop() {
+ mManager.stopSession(mSessionId);
+ }
+
+ /**
+ * Destroy the current publish or subscribe session. Performs a
+ * {@link WifiNanSession#stop()} function but in addition destroys the session -
+ * it will not be able to receive any messages or to be restarted at a later
+ * time.
+ */
+ public void destroy() {
+ mManager.destroySession(mSessionId);
+ mDestroyed = true;
+ }
+
+ /**
+ * {@hide}
+ */
+ @Override
+ protected void finalize() throws Throwable {
+ if (!mDestroyed) {
+ Log.w(TAG, "WifiNanSession mSessionId=" + mSessionId
+ + " was not explicitly destroyed. The session may use resources until "
+ + "destroyed so step should be done explicitly");
+ }
+ destroy();
+ }
+
+ /**
+ * Sends a message to the specified destination. Message transmission is
+ * part of the current discovery session - i.e. executed subsequent to a
+ * publish/subscribe
+ * {@link WifiNanSessionListener#onMatch(int, byte[], int, byte[], int)}
+ * event.
+ *
+ * @param peerId The peer's ID for the message. Must be a result of an
+ * {@link WifiNanSessionListener#onMatch(int, byte[], int, byte[], int)}
+ * event.
+ * @param message The message to be transmitted.
+ * @param messageLength The number of bytes from the {@code message} to be
+ * transmitted.
+ */
+ public void sendMessage(int peerId, byte[] message, int messageLength) {
+ mManager.sendMessage(mSessionId, peerId, message, messageLength);
+ }
+}
diff --git a/wifi/java/android/net/wifi/nan/WifiNanSessionListener.java b/wifi/java/android/net/wifi/nan/WifiNanSessionListener.java
new file mode 100644
index 0000000..c9d08c7
--- /dev/null
+++ b/wifi/java/android/net/wifi/nan/WifiNanSessionListener.java
@@ -0,0 +1,437 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.wifi.nan;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+import android.util.Log;
+
+/**
+ * Base class for NAN session events callbacks. Should be extended by
+ * applications wanting notifications. The callbacks are registered when a
+ * publish or subscribe session is created using
+ * {@link WifiNanManager#publish(PublishData, PublishSettings, WifiNanSessionListener, int)}
+ * or
+ * {@link WifiNanManager#subscribe(SubscribeData, SubscribeSettings, WifiNanSessionListener, int)}
+ * . These are callbacks applying to a specific NAN session. Events
+ * corresponding to the NAN link are delivered using {@link WifiNanEventListener}.
+ * <p>
+ * A single listener is registered at session creation - it cannot be replaced.
+ * <p>
+ * During registration specify which specific events are desired using a set of
+ * {@code NanSessionListener.LISTEN_*} flags OR'd together. Only those events
+ * will be delivered to the registered listener. Override those callbacks
+ * {@code NanSessionListener.on*} for the registered events.
+ *
+ * @hide PROPOSED_NAN_API
+ */
+public class WifiNanSessionListener {
+ private static final String TAG = "WifiNanSessionListener";
+ private static final boolean DBG = true;
+ private static final boolean VDBG = false; // STOPSHIP if true
+
+ /**
+ * Publish fail callback event registration flag. Corresponding callback is
+ * {@link WifiNanSessionListener#onPublishFail(int)}.
+ *
+ * @hide
+ */
+ public static final int LISTEN_PUBLISH_FAIL = 0x1 << 0;
+
+ /**
+ * Publish terminated callback event registration flag. Corresponding
+ * callback is {@link WifiNanSessionListener#onPublishTerminated(int)}.
+ */
+ public static final int LISTEN_PUBLISH_TERMINATED = 0x1 << 1;
+
+ /**
+ * Subscribe fail callback event registration flag. Corresponding callback
+ * is {@link WifiNanSessionListener#onSubscribeFail(int)}.
+ *
+ * @hide
+ */
+ public static final int LISTEN_SUBSCRIBE_FAIL = 0x1 << 2;
+
+ /**
+ * Subscribe terminated callback event registration flag. Corresponding
+ * callback is {@link WifiNanSessionListener#onSubscribeTerminated(int)}.
+ */
+ public static final int LISTEN_SUBSCRIBE_TERMINATED = 0x1 << 3;
+
+ /**
+ * Match (discovery: publish or subscribe) callback event registration flag.
+ * Corresponding callback is
+ * {@link WifiNanSessionListener#onMatch(int, byte[], int, byte[], int)}.
+ *
+ * @hide
+ */
+ public static final int LISTEN_MATCH = 0x1 << 4;
+
+ /**
+ * Message sent successfully callback event registration flag. Corresponding
+ * callback is {@link WifiNanSessionListener#onMessageSendSuccess()}.
+ *
+ * @hide
+ */
+ public static final int LISTEN_MESSAGE_SEND_SUCCESS = 0x1 << 5;
+
+ /**
+ * Message sending failure callback event registration flag. Corresponding
+ * callback is {@link WifiNanSessionListener#onMessageSendFail(int)}.
+ *
+ * @hide
+ */
+ public static final int LISTEN_MESSAGE_SEND_FAIL = 0x1 << 6;
+
+ /**
+ * Message received callback event registration flag. Corresponding callback
+ * is {@link WifiNanSessionListener#onMessageReceived(int, byte[], int)}.
+ *
+ * @hide
+ */
+ public static final int LISTEN_MESSAGE_RECEIVED = 0x1 << 7;
+
+ /**
+ * List of hidden events: which are mandatory - i.e. they will be added to
+ * every request.
+ *
+ * @hide
+ */
+ public static final int LISTEN_HIDDEN_FLAGS = LISTEN_PUBLISH_FAIL | LISTEN_SUBSCRIBE_FAIL
+ | LISTEN_MATCH | LISTEN_MESSAGE_SEND_SUCCESS | LISTEN_MESSAGE_SEND_FAIL
+ | LISTEN_MESSAGE_RECEIVED;
+
+ /**
+ * Failure reason flag for {@link WifiNanEventListener} and
+ * {@link WifiNanSessionListener} callbacks. Indicates no resources to execute
+ * the requested operation.
+ */
+ public static final int FAIL_REASON_NO_RESOURCES = 0;
+
+ /**
+ * Failure reason flag for {@link WifiNanEventListener} and
+ * {@link WifiNanSessionListener} callbacks. Indicates invalid argument in the
+ * requested operation.
+ */
+ public static final int FAIL_REASON_INVALID_ARGS = 1;
+
+ /**
+ * Failure reason flag for {@link WifiNanEventListener} and
+ * {@link WifiNanSessionListener} callbacks. Indicates a message is transmitted
+ * without a match (i.e. a discovery) occurring first.
+ */
+ public static final int FAIL_REASON_NO_MATCH_SESSION = 2;
+
+ /**
+ * Failure reason flag for {@link WifiNanEventListener} and
+ * {@link WifiNanSessionListener} callbacks. Indicates an unspecified error
+ * occurred during the operation.
+ */
+ public static final int FAIL_REASON_OTHER = 3;
+
+ /**
+ * Failure reason flag for
+ * {@link WifiNanSessionListener#onPublishTerminated(int)} and
+ * {@link WifiNanSessionListener#onSubscribeTerminated(int)} callbacks.
+ * Indicates that publish or subscribe session is done - i.e. all the
+ * requested operations (per {@link PublishSettings} or
+ * {@link SubscribeSettings}) have been executed.
+ */
+ public static final int TERMINATE_REASON_DONE = 0;
+
+ /**
+ * Failure reason flag for
+ * {@link WifiNanSessionListener#onPublishTerminated(int)} and
+ * {@link WifiNanSessionListener#onSubscribeTerminated(int)} callbacks.
+ * Indicates that publish or subscribe session is terminated due to a
+ * failure.
+ */
+ public static final int TERMINATE_REASON_FAIL = 1;
+
+ private static final String MESSAGE_BUNDLE_KEY_PEER_ID = "peer_id";
+ private static final String MESSAGE_BUNDLE_KEY_MESSAGE = "message";
+ private static final String MESSAGE_BUNDLE_KEY_MESSAGE2 = "message2";
+
+ private final Handler mHandler;
+
+ /**
+ * Constructs a {@link WifiNanSessionListener} using the looper of the current
+ * thread. I.e. all callbacks will be delivered on the current thread.
+ */
+ public WifiNanSessionListener() {
+ this(Looper.myLooper());
+ }
+
+ /**
+ * Constructs a {@link WifiNanSessionListener} using the specified looper. I.e.
+ * all callbacks will delivered on the thread of the specified looper.
+ *
+ * @param looper The looper on which to execute the callbacks.
+ */
+ public WifiNanSessionListener(Looper looper) {
+ if (VDBG) Log.v(TAG, "ctor: looper=" + looper);
+ mHandler = new Handler(looper) {
+ @Override
+ public void handleMessage(Message msg) {
+ if (DBG) Log.d(TAG, "What=" + msg.what + ", msg=" + msg);
+ switch (msg.what) {
+ case LISTEN_PUBLISH_FAIL:
+ WifiNanSessionListener.this.onPublishFail(msg.arg1);
+ break;
+ case LISTEN_PUBLISH_TERMINATED:
+ WifiNanSessionListener.this.onPublishTerminated(msg.arg1);
+ break;
+ case LISTEN_SUBSCRIBE_FAIL:
+ WifiNanSessionListener.this.onSubscribeFail(msg.arg1);
+ break;
+ case LISTEN_SUBSCRIBE_TERMINATED:
+ WifiNanSessionListener.this.onSubscribeTerminated(msg.arg1);
+ break;
+ case LISTEN_MATCH:
+ WifiNanSessionListener.this.onMatch(
+ msg.getData().getInt(MESSAGE_BUNDLE_KEY_PEER_ID),
+ msg.getData().getByteArray(MESSAGE_BUNDLE_KEY_MESSAGE), msg.arg1,
+ msg.getData().getByteArray(MESSAGE_BUNDLE_KEY_MESSAGE2), msg.arg2);
+ break;
+ case LISTEN_MESSAGE_SEND_SUCCESS:
+ WifiNanSessionListener.this.onMessageSendSuccess();
+ break;
+ case LISTEN_MESSAGE_SEND_FAIL:
+ WifiNanSessionListener.this.onMessageSendFail(msg.arg1);
+ break;
+ case LISTEN_MESSAGE_RECEIVED:
+ WifiNanSessionListener.this.onMessageReceived(msg.arg2,
+ msg.getData().getByteArray(MESSAGE_BUNDLE_KEY_MESSAGE), msg.arg1);
+ break;
+ }
+ }
+ };
+ }
+
+ /**
+ * Called when a publish operation fails. It is dummy method (empty
+ * implementation printing out a log message). Override to implement your
+ * custom response.
+ *
+ * @param reason The failure reason using {@code NanSessionListener.FAIL_*}
+ * codes.
+ */
+ public void onPublishFail(int reason) {
+ if (VDBG) Log.v(TAG, "onPublishFail: called in stub - override if interested");
+ }
+
+ /**
+ * Called when a publish operation terminates. Event will only be delivered
+ * if registered using {@link WifiNanSessionListener#LISTEN_PUBLISH_TERMINATED}.
+ * A dummy (empty implementation printing out a warning). Make sure to
+ * override if registered.
+ *
+ * @param reason The termination reason using
+ * {@code NanSessionListener.TERMINATE_*} codes.
+ */
+ public void onPublishTerminated(int reason) {
+ Log.w(TAG, "onPublishTerminated: called in stub - override if interested or disable");
+ }
+
+ /**
+ * Called when a subscribe operation fails. It is dummy method (empty
+ * implementation printing out a log message). Override to implement your
+ * custom response.
+ *
+ * @param reason The failure reason using {@code NanSessionListener.FAIL_*}
+ * codes.
+ */
+ public void onSubscribeFail(int reason) {
+ if (VDBG) Log.v(TAG, "onSubscribeFail: called in stub - override if interested");
+ }
+
+ /**
+ * Called when a subscribe operation terminates. Event will only be
+ * delivered if registered using
+ * {@link WifiNanSessionListener#LISTEN_SUBSCRIBE_TERMINATED}. A dummy (empty
+ * implementation printing out a warning). Make sure to override if
+ * registered.
+ *
+ * @param reason The termination reason using
+ * {@code NanSessionListener.TERMINATE_*} codes.
+ */
+ public void onSubscribeTerminated(int reason) {
+ Log.w(TAG, "onSubscribeTerminated: called in stub - override if interested or disable");
+ }
+
+ /**
+ * Called when a discovery (publish or subscribe) operation results in a
+ * match - i.e. when a peer is discovered. It is dummy method (empty
+ * implementation printing out a log message). Override to implement your
+ * custom response.
+ *
+ * @param peerId The ID of the peer matching our discovery operation.
+ * @param serviceSpecificInfo The service specific information (arbitrary
+ * byte array) provided by the peer as part of its discovery
+ * packet.
+ * @param serviceSpecificInfoLength The length of the service specific
+ * information array.
+ * @param matchFilter The filter (Tx on advertiser and Rx on listener) which
+ * resulted in this match.
+ * @param matchFilterLength The length of the match filter array.
+ */
+ public void onMatch(int peerId, byte[] serviceSpecificInfo,
+ int serviceSpecificInfoLength, byte[] matchFilter, int matchFilterLength) {
+ if (VDBG) Log.v(TAG, "onMatch: called in stub - override if interested");
+ }
+
+ /**
+ * Called when a message is transmitted successfully - i.e. when we know
+ * that it was received successfully (corresponding to an ACK being
+ * received). It is dummy method (empty implementation printing out a log
+ * message). Override to implement your custom response.
+ * <p>
+ * Note that either this callback or
+ * {@link WifiNanSessionListener#onMessageSendFail(int)} will be received -
+ * never both.
+ */
+ public void onMessageSendSuccess() {
+ if (VDBG) Log.v(TAG, "onMessageSendSuccess: called in stub - override if interested");
+ }
+
+ /**
+ * Called when a message transmission fails - i.e. when no ACK is received.
+ * The hardware will usually attempt to re-transmit several times - this
+ * event is received after all retries are exhausted. There is a possibility
+ * that message was received by the destination successfully but the ACK was
+ * lost. It is dummy method (empty implementation printing out a log
+ * message). Override to implement your custom response.
+ * <p>
+ * Note that either this callback or
+ * {@link WifiNanSessionListener#onMessageSendSuccess()} will be received -
+ * never both
+ *
+ * @param reason The failure reason using {@code NanSessionListener.FAIL_*}
+ * codes.
+ */
+ public void onMessageSendFail(int reason) {
+ if (VDBG) Log.v(TAG, "onMessageSendFail: called in stub - override if interested");
+ }
+
+ /**
+ * Called when a message is received from a discovery session peer. It is
+ * dummy method (empty implementation printing out a log message). Override
+ * to implement your custom response.
+ *
+ * @param peerId The ID of the peer sending the message.
+ * @param message A byte array containing the message.
+ * @param messageLength The length of the byte array containing the relevant
+ * message bytes.
+ */
+ public void onMessageReceived(int peerId, byte[] message, int messageLength) {
+ if (VDBG) Log.v(TAG, "onMessageReceived: called in stub - override if interested");
+ }
+
+ /**
+ * {@hide}
+ */
+ public IWifiNanSessionListener callback = new IWifiNanSessionListener.Stub() {
+ @Override
+ public void onPublishFail(int reason) {
+ if (VDBG) Log.v(TAG, "onPublishFail: reason=" + reason);
+
+ Message msg = mHandler.obtainMessage(LISTEN_PUBLISH_FAIL);
+ msg.arg1 = reason;
+ mHandler.sendMessage(msg);
+ }
+
+ @Override
+ public void onPublishTerminated(int reason) {
+ if (VDBG) Log.v(TAG, "onPublishResponse: reason=" + reason);
+
+ Message msg = mHandler.obtainMessage(LISTEN_PUBLISH_TERMINATED);
+ msg.arg1 = reason;
+ mHandler.sendMessage(msg);
+ }
+
+ @Override
+ public void onSubscribeFail(int reason) {
+ if (VDBG) Log.v(TAG, "onSubscribeFail: reason=" + reason);
+
+ Message msg = mHandler.obtainMessage(LISTEN_SUBSCRIBE_FAIL);
+ msg.arg1 = reason;
+ mHandler.sendMessage(msg);
+ }
+
+ @Override
+ public void onSubscribeTerminated(int reason) {
+ if (VDBG) Log.v(TAG, "onSubscribeTerminated: reason=" + reason);
+
+ Message msg = mHandler.obtainMessage(LISTEN_SUBSCRIBE_TERMINATED);
+ msg.arg1 = reason;
+ mHandler.sendMessage(msg);
+ }
+
+ @Override
+ public void onMatch(int peerId, byte[] serviceSpecificInfo,
+ int serviceSpecificInfoLength, byte[] matchFilter, int matchFilterLength) {
+ if (VDBG) Log.v(TAG, "onMatch: peerId=" + peerId);
+
+ Bundle data = new Bundle();
+ data.putInt(MESSAGE_BUNDLE_KEY_PEER_ID, peerId);
+ data.putByteArray(MESSAGE_BUNDLE_KEY_MESSAGE, serviceSpecificInfo);
+ data.putByteArray(MESSAGE_BUNDLE_KEY_MESSAGE2, matchFilter);
+
+ Message msg = mHandler.obtainMessage(LISTEN_MATCH);
+ msg.arg1 = serviceSpecificInfoLength;
+ msg.arg2 = matchFilterLength;
+ msg.setData(data);
+ mHandler.sendMessage(msg);
+ }
+
+ @Override
+ public void onMessageSendSuccess() {
+ if (VDBG) Log.v(TAG, "onMessageSendSuccess");
+
+ Message msg = mHandler.obtainMessage(LISTEN_MESSAGE_SEND_SUCCESS);
+ mHandler.sendMessage(msg);
+ }
+
+ @Override
+ public void onMessageSendFail(int reason) {
+ if (VDBG) Log.v(TAG, "onMessageSendFail: reason=" + reason);
+
+ Message msg = mHandler.obtainMessage(LISTEN_MESSAGE_SEND_FAIL);
+ msg.arg1 = reason;
+ mHandler.sendMessage(msg);
+ }
+
+ @Override
+ public void onMessageReceived(int peerId, byte[] message, int messageLength) {
+ if (VDBG) {
+ Log.v(TAG, "onMessageReceived: peerId='" + peerId + "', messageLength="
+ + messageLength);
+ }
+
+ Bundle data = new Bundle();
+ data.putByteArray(MESSAGE_BUNDLE_KEY_MESSAGE, message);
+
+ Message msg = mHandler.obtainMessage(LISTEN_MESSAGE_RECEIVED);
+ msg.arg1 = messageLength;
+ msg.arg2 = peerId;
+ msg.setData(data);
+ mHandler.sendMessage(msg);
+ }
+ };
+}
diff --git a/wifi/java/android/net/wifi/nan/WifiNanSubscribeSession.java b/wifi/java/android/net/wifi/nan/WifiNanSubscribeSession.java
new file mode 100644
index 0000000..7dfdd32
--- /dev/null
+++ b/wifi/java/android/net/wifi/nan/WifiNanSubscribeSession.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.wifi.nan;
+
+/**
+ * A representation of a NAN subscribe session. Created when
+ * {@link WifiNanManager#subscribe(SubscribeData, SubscribeSettings, WifiNanSessionListener, int)}
+ * is executed. The object can be used to stop and re-start (re-configure) the
+ * subscribe session.
+ *
+ * @hide PROPOSED_NAN_API
+ */
+public class WifiNanSubscribeSession extends WifiNanSession {
+ /**
+ * {@hide}
+ */
+ public WifiNanSubscribeSession(WifiNanManager manager, int sessionId) {
+ super(manager, sessionId);
+ }
+
+ /**
+ * Restart/re-configure the subscribe session. Note that the
+ * {@link WifiNanSessionListener} is not replaced - the same listener used at
+ * creation is still used.
+ *
+ * @param subscribeData The data ({@link SubscribeData}) to subscribe.
+ * @param subscribeSettings The settings ({@link SubscribeSettings}) of the
+ * subscribe session.
+ */
+ public void subscribe(SubscribeData subscribeData, SubscribeSettings subscribeSettings) {
+ mManager.subscribe(mSessionId, subscribeData, subscribeSettings);
+ }
+}
diff --git a/wifi/java/android/net/wifi/passpoint/IWifiPasspointManager.aidl b/wifi/java/android/net/wifi/passpoint/IWifiPasspointManager.aidl
deleted file mode 100644
index 50bec33..0000000
--- a/wifi/java/android/net/wifi/passpoint/IWifiPasspointManager.aidl
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Copyright (c) 2014, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.wifi.passpoint;
-
-import android.net.wifi.ScanResult;
-import android.net.wifi.passpoint.WifiPasspointPolicy;
-import android.net.wifi.passpoint.WifiPasspointCredential;
-import android.os.Messenger;
-
-/**
- * Interface that allows controlling and querying Wifi Passpoint connectivity.
- *
- * {@hide}
- */
-interface IWifiPasspointManager
-{
- Messenger getMessenger();
-
- int getPasspointState();
-
- List<WifiPasspointPolicy> requestCredentialMatch(in List<ScanResult> requested);
-
- List<WifiPasspointCredential> getCredentials();
-
- boolean addCredential(in WifiPasspointCredential cred);
-
- boolean updateCredential(in WifiPasspointCredential cred);
-
- boolean removeCredential(in WifiPasspointCredential cred);
-}
-
diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointCredential.aidl b/wifi/java/android/net/wifi/passpoint/WifiPasspointCredential.aidl
deleted file mode 100644
index cfd3605..0000000
--- a/wifi/java/android/net/wifi/passpoint/WifiPasspointCredential.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Copyright (c) 2014, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.wifi.passpoint;
-
-parcelable WifiPasspointCredential;
diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointCredential.java b/wifi/java/android/net/wifi/passpoint/WifiPasspointCredential.java
deleted file mode 100644
index a100aed..0000000
--- a/wifi/java/android/net/wifi/passpoint/WifiPasspointCredential.java
+++ /dev/null
@@ -1,665 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.wifi.passpoint;
-
-import android.net.wifi.WifiEnterpriseConfig;
-import android.os.Parcelable;
-import android.os.Parcel;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-
-/**
- * A class representing a Wi-Fi Passpoint credential.
- * @hide
- */
-public class WifiPasspointCredential implements Parcelable {
-
- private final static String TAG = "PasspointCredential";
- private final static boolean DBG = true;
-
- /** Wi-Fi nodes**/
- private String mWifiSpFqdn;
-
- /** PerProviderSubscription nodes **/
- private String mCredentialName;
-
- /** SubscriptionUpdate nodes **/
- private String mSubscriptionUpdateInterval;
- private String mSubscriptionUpdateMethod;
- private String mSubscriptionUpdateRestriction;
- private String mSubscriptionUpdateURI;
- private String mSubscriptionUpdateUsername;
- private String mSubscriptionUpdatePassword;
-
- /** HomeSP nodes **/
- private String mHomeSpFqdn;
- private String mFriendlyName;
- private Collection<WifiPasspointDmTree.HomeOIList> mHomeOIList;
- private Collection<WifiPasspointDmTree.OtherHomePartners> mOtherHomePartnerList;
-
- /** SubscriptionParameters nodes**/
- private String mCreationDate;
- private String mExpirationDate;
-
- /** Credential nodes **/
- private String mType;
- private String mInnerMethod;
- private String mCertType;
- private String mCertSha256Fingerprint;
- private String mUpdateIdentifier;
- private String mUsername;
- private String mPasswd;
- private String mRealm;
- private String mImsi;
- private String mMcc;
- private String mMnc;
- private String mCaRootCert;
- private String mClientCert;
- private boolean mCheckAaaServerCertStatus;
-
- /** Policy nodes **/
- private String mPolicyUpdateUri;
- private String mPolicyUpdateInterval;
- private String mPolicyUpdateUsername;
- private String mPolicyUpdatePassword;
- private String mPolicyUpdateRestriction;
- private String mPolicyUpdateMethod;
- private Collection<WifiPasspointDmTree.PreferredRoamingPartnerList> mPreferredRoamingPartnerList;
- private Collection<WifiPasspointDmTree.MinBackhaulThresholdNetwork> mMinBackhaulThresholdNetwork;
- private Collection<WifiPasspointDmTree.SPExclusionList> mSpExclusionList;
- private Collection<WifiPasspointDmTree.RequiredProtoPortTuple> mRequiredProtoPortTuple;
- private String mMaxBssLoad;
-
- /** CrednetialPriority node **/
- private int mCrednetialPriority;
-
- /** AAAServerTrustRoot nodes **/
- private String mAaaCertUrl;
- private String mAaaSha256Fingerprint;
-
- /** Others **/
- private boolean mIsMachineRemediation;
- private boolean mUserPreferred = false;
- private String mWifiTreePath;
- private WifiEnterpriseConfig mEnterpriseConfig;
-
- /** @hide */
- public WifiPasspointCredential() {}
-
- /**
- * Constructor
- * @param realm Realm of the passpoint credential
- * @param fqdn Fully qualified domain name (FQDN) of the credential
- * @param config Enterprise config, must be either EAP-TLS or EAP-TTLS
- * @see WifiEnterpriseConfig
- */
- public WifiPasspointCredential(String realm, String fqdn, WifiEnterpriseConfig config) {
- mRealm = realm;
- switch (config.getEapMethod()) {
- case WifiEnterpriseConfig.Eap.TLS:
- case WifiEnterpriseConfig.Eap.TTLS:
- mEnterpriseConfig = new WifiEnterpriseConfig(config);
- break;
- default:
- // ignore
- }
- }
-
- /** @hide */
- public WifiPasspointCredential(String type,
- String caroot,
- String clientcert,
- String mcc,
- String mnc,
- WifiPasspointDmTree.SpFqdn sp,
- WifiPasspointDmTree.CredentialInfo credinfo) {
-
- if (credinfo == null) {
- return;
- }
-
- mType = type;
- mCaRootCert = caroot;
- mClientCert = clientcert;
-
- mWifiSpFqdn = sp.nodeName;
- mUpdateIdentifier = sp.perProviderSubscription.UpdateIdentifier;
-
- mCredentialName = credinfo.nodeName;
- mOtherHomePartnerList = credinfo.homeSP.otherHomePartners.values();
-
- Set set = credinfo.aAAServerTrustRoot.entrySet();
- Iterator i = set.iterator();
- if (i.hasNext()) {
- Map.Entry entry3 = (Map.Entry) i.next();
- WifiPasspointDmTree.AAAServerTrustRoot aaa = (WifiPasspointDmTree.AAAServerTrustRoot) entry3.getValue();
- mAaaCertUrl = aaa.CertURL;
- mAaaSha256Fingerprint = aaa.CertSHA256Fingerprint;
- }
-
- mCertType = credinfo.credential.digitalCertificate.CertificateType;
- mCertSha256Fingerprint = credinfo.credential.digitalCertificate.CertSHA256Fingerprint;
- mUsername = credinfo.credential.usernamePassword.Username;
- mPasswd = credinfo.credential.usernamePassword.Password;
- mIsMachineRemediation = credinfo.credential.usernamePassword.MachineManaged;
- mInnerMethod = credinfo.credential.usernamePassword.eAPMethod.InnerMethod;
- mImsi = credinfo.credential.sim.IMSI;
- mMcc = mcc;
- mMnc = mnc;
- mCreationDate = credinfo.credential.CreationDate;
- mExpirationDate = credinfo.credential.ExpirationDate;
- mRealm = credinfo.credential.Realm;
-
- if (credinfo.credentialPriority == null) {
- mCrednetialPriority = 128;
- } else {
- mCrednetialPriority = Integer.parseInt(credinfo.credentialPriority);
- }
-
- mHomeSpFqdn = credinfo.homeSP.FQDN;
-
- mSubscriptionUpdateInterval = credinfo.subscriptionUpdate.UpdateInterval;
- mSubscriptionUpdateMethod = credinfo.subscriptionUpdate.UpdateMethod;
- mSubscriptionUpdateRestriction = credinfo.subscriptionUpdate.Restriction;
- mSubscriptionUpdateURI = credinfo.subscriptionUpdate.URI;
- mSubscriptionUpdateUsername = credinfo.subscriptionUpdate.usernamePassword.Username;
- mSubscriptionUpdatePassword = credinfo.subscriptionUpdate.usernamePassword.Password;
-
- mPolicyUpdateUri = credinfo.policy.policyUpdate.URI;
- mPolicyUpdateInterval = credinfo.policy.policyUpdate.UpdateInterval;
- mPolicyUpdateUsername = credinfo.policy.policyUpdate.usernamePassword.Username;
- mPolicyUpdatePassword = credinfo.policy.policyUpdate.usernamePassword.Password;
- mPolicyUpdateRestriction = credinfo.policy.policyUpdate.Restriction;
- mPolicyUpdateMethod = credinfo.policy.policyUpdate.UpdateMethod;
- mPreferredRoamingPartnerList = credinfo.policy.preferredRoamingPartnerList.values();
- mMinBackhaulThresholdNetwork = credinfo.policy.minBackhaulThreshold.values();
- mRequiredProtoPortTuple = credinfo.policy.requiredProtoPortTuple.values();
- mMaxBssLoad = credinfo.policy.maximumBSSLoadValue;
- mSpExclusionList = credinfo.policy.sPExclusionList.values();
-
- mHomeOIList = credinfo.homeSP.homeOIList.values();
- mFriendlyName = credinfo.homeSP.FriendlyName;
- mCheckAaaServerCertStatus = credinfo.credential.CheckAAAServerCertStatus;
- }
-
- /** @hide */
- public String getUpdateIdentifier() {
- return mUpdateIdentifier;
- }
-
- /** @hide */
- public String getUpdateMethod() {
- return mSubscriptionUpdateMethod;
- }
-
- /** @hide */
- public void setUpdateMethod(String method) {
- mSubscriptionUpdateMethod = method;
- }
-
- /** @hide */
- public String getWifiSpFqdn() {
- return mWifiSpFqdn;
- }
-
- /** @hide */
- public String getCredName() {
- return mCredentialName;
- }
-
- /** @hide */
- public String getType() {
- return mType;
- }
-
- /**
- * Get enterprise config of this Passpoint credential.
- * @return Enterprise config
- * @see WifiEnterpriseConfig
- */
- public WifiEnterpriseConfig getEnterpriseConfig() {
- return new WifiEnterpriseConfig(mEnterpriseConfig);
- }
-
- /**
- * Set enterprise config of this Passpoint credential.
- * @param config Enterprise config, must be either EAP-TLS or EAP-TTLS
- * @see WifiEnterpriseConfig
- */
- public void setEnterpriseConfig(WifiEnterpriseConfig config) {
- // TODO
- }
-
- /** @hide */
- public String getCertType() {
- return mCertType;
- }
-
- /** @hide */
- public String getCertSha256Fingerprint() {
- return mCertSha256Fingerprint;
- }
-
- /** @hide */
- public String getUserName() {
- return mUsername;
- }
-
- /** @hide */
- public String getPassword() {
- // TODO: guarded by connectivity internal
- return mPasswd;
- }
-
- /** @hide */
- public String getImsi() {
- return mImsi;
- }
-
- /** @hide */
- public String getMcc() {
- return mMcc;
- }
-
- /** @hide */
- public String getMnc() {
- return mMnc;
- }
-
- /** @hide */
- public String getCaRootCertPath() {
- return mCaRootCert;
- }
-
- /** @hide */
- public String getClientCertPath() {
- return mClientCert;
- }
-
- /**
- * Get the realm of this Passpoint credential.
- * @return Realm
- */
- public String getRealm() {
- return mRealm;
- }
-
- /**
- * Set the ream of this Passpoint credential.
- * @param realm Realm
- */
- public void setRealm(String realm) {
- mRealm = realm;
- }
-
- /** @hide */
- public int getPriority() {
- if (mUserPreferred) {
- return 0;
- }
-
- return mCrednetialPriority;
- }
-
- /**
- * Get the fully qualified domain name (FQDN) of this Passpoint credential.
- * @return FQDN
- */
- public String getHomeSpFqdn() {
- return mHomeSpFqdn;
- }
-
- /**
- * Set the fully qualified domain name (FQDN) of this Passpoint credential.
- * @param fqdn FQDN
- */
- public void setHomeFqdn(String fqdn) {
- mHomeSpFqdn = fqdn;
- }
-
-
- /** @hide */
- public Collection<WifiPasspointDmTree.OtherHomePartners> getOtherHomePartnerList() {
- return mOtherHomePartnerList;
- }
-
- /** @hide */
- public String getSubscriptionUpdateUsername() {
- return mSubscriptionUpdateUsername;
- }
-
- /** @hide */
- public String getSubscriptionUpdatePassword() {
- return mSubscriptionUpdatePassword;
- }
-
- /** @hide */
- public String getPolicyUpdateUri() {
- return mPolicyUpdateUri;
- }
-
- /** @hide */
- public String getPolicyUpdateInterval() {
- return mPolicyUpdateInterval;
- }
-
- /** @hide */
- public String getPolicyUpdateUsername() {
- return mPolicyUpdateUsername;
- }
-
- /** @hide */
- public String getPolicyUpdatePassword() {
- return mPolicyUpdatePassword;
- }
-
- /** @hide */
- public String getPolicyUpdateRestriction() {
- return mPolicyUpdateRestriction;
- }
-
- /** @hide */
- public String getPolicyUpdateMethod() {
- return mPolicyUpdateMethod;
- }
-
- /** @hide */
- public String getCreationDate() {
- return mCreationDate;
- }
-
- /** @hide */
- public String getExpirationDate() {
- return mExpirationDate;
- }
-
- /** @hide */
- public void setExpirationDate(String expirationdate) {
- mExpirationDate = expirationdate;
- }
-
- /** @hide */
- public Collection<WifiPasspointDmTree.PreferredRoamingPartnerList> getPreferredRoamingPartnerList() {
- return mPreferredRoamingPartnerList;
- }
-
- /** @hide */
- public Collection<WifiPasspointDmTree.HomeOIList> getHomeOiList() {
- return mHomeOIList;
- }
-
- /** @hide */
- public Collection<WifiPasspointDmTree.MinBackhaulThresholdNetwork> getBackhaulThresholdList() {
- return mMinBackhaulThresholdNetwork;
- }
-
- /** @hide */
- public Collection<WifiPasspointDmTree.RequiredProtoPortTuple> getRequiredProtoPortList() {
- return mRequiredProtoPortTuple;
- }
-
- /** @hide */
- public Collection<WifiPasspointDmTree.SPExclusionList> getSPExclusionList() {
- return mSpExclusionList;
- }
-
- /** @hide */
- public boolean getIsMachineRemediation() {
- return mIsMachineRemediation;
- }
-
- /** @hide */
- public String getAaaCertUrl() {
- return mAaaCertUrl;
- }
-
- /** @hide */
- public String getAaaSha256Fingerprint() {
- return mAaaSha256Fingerprint;
- }
-
- /** @hide */
- public String getSubscriptionUpdateRestriction() {
- return mSubscriptionUpdateRestriction;
- }
-
- /** @hide */
- public String getSubscriptionUpdateURI() {
- return mSubscriptionUpdateURI;
- }
-
- /** @hide */
- public String getSubscriptionUpdateInterval() {
- return mSubscriptionUpdateInterval;
- }
-
- /** @hide */
- public String getFriendlyName() {
- return mFriendlyName;
- }
-
- /** @hide */
- public String getMaxBssLoad() {
- return mMaxBssLoad;
- }
-
- /** @hide */
- public boolean getUserPreference() {
- return mUserPreferred;
- }
-
- /** @hide */
- public boolean getCheckAaaServerCertStatus() {
- return mCheckAaaServerCertStatus;
- }
-
- /** @hide */
- public void setUserPreference(boolean value) {
- mUserPreferred = value;
- }
-
- @Override
- /** @hide */
- public boolean equals(Object obj) {
- boolean result = false;
- if (obj instanceof WifiPasspointCredential) {
- final WifiPasspointCredential other = (WifiPasspointCredential) obj;
- if (this.mType.equals(other.mType)) {
- if (this.mType.equals("TTLS")) {
- result = this.mUsername.equals(other.mUsername) &&
- this.mPasswd.equals(other.mPasswd) &&
- this.mRealm.equals(other.mRealm) &&
- this.mHomeSpFqdn.equals(other.mHomeSpFqdn);
- }
- if (this.mType.equals("TLS")) {
- result = this.mRealm.equals(other.mRealm) &&
- this.mHomeSpFqdn.equals(other.mHomeSpFqdn) &&
- this.mClientCert.equals(other.mClientCert);
- }
- if (this.mType.equals("SIM")) {
- result = this.mMcc.equals(other.mMcc) &&
- this.mMnc.equals(other.mMnc) &&
- this.mImsi.equals(other.mImsi) &&
- this.mHomeSpFqdn.equals(other.mHomeSpFqdn);
- }
- }
- }
- return result;
- }
-
- @Override
- /** @hide */
- public String toString() {
- StringBuffer sb = new StringBuffer();
- String none = "<none>";
-
- if (!DBG) {
- sb.append(none);
- } else {
- sb.append(", UpdateIdentifier: ")
- .append(mUpdateIdentifier == null ? none : mUpdateIdentifier)
- .append(", SubscriptionUpdateMethod: ")
- .append(mSubscriptionUpdateMethod == null ? none : mSubscriptionUpdateMethod)
- .append(", Type: ").append(mType == null ? none : mType)
- .append(", Username: ").append(mUsername == null ? none : mUsername)
- .append(", Passwd: ").append(mPasswd == null ? none : mPasswd)
- .append(", SubDMAccUsername: ")
- .append(mSubscriptionUpdateUsername == null ? none : mSubscriptionUpdateUsername)
- .append(", SubDMAccPassword: ")
- .append(mSubscriptionUpdatePassword == null ? none : mSubscriptionUpdatePassword)
- .append(", PolDMAccUsername: ")
- .append(mPolicyUpdateUsername == null ? none : mPolicyUpdateUsername)
- .append(", PolDMAccPassword: ")
- .append(mPolicyUpdatePassword == null ? none : mPolicyUpdatePassword)
- .append(", Imsi: ").append(mImsi == null ? none : mImsi)
- .append(", Mcc: ").append(mMcc == null ? none : mMcc)
- .append(", Mnc: ").append(mMnc == null ? none : mMnc)
- .append(", CaRootCert: ").append(mCaRootCert == null ? none : mCaRootCert)
- .append(", Realm: ").append(mRealm == null ? none : mRealm)
- .append(", Priority: ").append(mCrednetialPriority)
- .append(", Fqdn: ").append(mHomeSpFqdn == null ? none : mHomeSpFqdn)
- .append(", Otherhomepartners: ")
- .append(mOtherHomePartnerList == null ? none : mOtherHomePartnerList)
- .append(", ExpirationDate: ")
- .append(mExpirationDate == null ? none : mExpirationDate)
- .append(", MaxBssLoad: ").append(mMaxBssLoad == null ? none : mMaxBssLoad)
- .append(", SPExclusionList: ").append(mSpExclusionList);
-
- if (mPreferredRoamingPartnerList != null) {
- sb.append("PreferredRoamingPartnerList:");
- for (WifiPasspointDmTree.PreferredRoamingPartnerList prpListItem : mPreferredRoamingPartnerList) {
- sb.append("[fqdnmatch:").append(prpListItem.FQDN_Match).
- append(", priority:").append(prpListItem.Priority).
- append(", country:").append(prpListItem.Country).append("]");
- }
- }
-
- if (mHomeOIList != null) {
- sb.append("HomeOIList:");
- for (WifiPasspointDmTree.HomeOIList HomeOIListItem : mHomeOIList) {
- sb.append("[HomeOI:").append(HomeOIListItem.HomeOI).
- append(", HomeOIRequired:").append(HomeOIListItem.HomeOIRequired).
- append("]");
- }
- }
-
- if (mMinBackhaulThresholdNetwork != null) {
- sb.append("BackHaulThreshold:");
- for (WifiPasspointDmTree.MinBackhaulThresholdNetwork BhtListItem : mMinBackhaulThresholdNetwork) {
- sb.append("[networkType:").append(BhtListItem.NetworkType).
- append(", dlBandwidth:").append(BhtListItem.DLBandwidth).
- append(", ulBandwidth:").append(BhtListItem.ULBandwidth).
- append("]");
- }
- }
-
- if (mRequiredProtoPortTuple != null) {
- sb.append("WifiMORequiredProtoPortTupleList:");
- for (WifiPasspointDmTree.RequiredProtoPortTuple RpptListItem : mRequiredProtoPortTuple) {
- sb.append("[IPProtocol:").append(RpptListItem.IPProtocol).
- append(", PortNumber:").append(RpptListItem.PortNumber).
- append("]");
- }
- }
- }
- return sb.toString();
- }
-
- /** Implement the Parcelable interface {@hide} */
- public int describeContents() {
- return 0;
- }
-
- /** Implement the Parcelable interface {@hide} */
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeString(mWifiSpFqdn);
- dest.writeString(mCredentialName);
- dest.writeString(mType);
- dest.writeInt(mCrednetialPriority);
- dest.writeString(mHomeSpFqdn);
- dest.writeString(mRealm);
- }
-
- /** Implement the Parcelable interface {@hide} */
- public void readFromParcel(Parcel in) {
- mWifiSpFqdn = in.readString();
- mCredentialName = in.readString();
- mType = in.readString();
- mCrednetialPriority = in.readInt();
- mHomeSpFqdn = in.readString();
- mRealm = in.readString();
- }
-
- /** Implement the Parcelable interface {@hide} */
- public static final Creator<WifiPasspointCredential> CREATOR =
- new Creator<WifiPasspointCredential>() {
- public WifiPasspointCredential createFromParcel(Parcel in) {
- WifiPasspointCredential pc = new WifiPasspointCredential();
- pc.mWifiSpFqdn = in.readString();
- pc.mCredentialName = in.readString();
- pc.mType = in.readString();
- pc.mCrednetialPriority = in.readInt();
- pc.mHomeSpFqdn = in.readString();
- pc.mRealm = in.readString();
- return pc;
- }
-
- public WifiPasspointCredential[] newArray(int size) {
- return new WifiPasspointCredential[size];
- }
- };
-
- /** @hide */
- public int compareTo(WifiPasspointCredential another) {
-
- //The smaller the higher
- if (mCrednetialPriority < another.mCrednetialPriority) {
- return -1;
- } else if (mCrednetialPriority == another.mCrednetialPriority) {
- return this.mType.compareTo(another.mType);
- } else {
- return 1;
- }
- }
-
- @Override
- /** @hide */
- public int hashCode() {
- int hash = 208;
- if (mType != null) {
- hash += mType.hashCode();
- }
- if (mRealm != null) {
- hash += mRealm.hashCode();
- }
- if (mHomeSpFqdn != null) {
- hash += mHomeSpFqdn.hashCode();
- }
- if (mUsername != null) {
- hash += mUsername.hashCode();
- }
- if (mPasswd != null) {
- hash += mPasswd.hashCode();
- }
-
- return hash;
- }
-}
diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointDmTree.aidl b/wifi/java/android/net/wifi/passpoint/WifiPasspointDmTree.aidl
deleted file mode 100644
index 6a88b2e..0000000
--- a/wifi/java/android/net/wifi/passpoint/WifiPasspointDmTree.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Copyright (c) 2014, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.wifi.passpoint;
-
-parcelable WifiPasspointDmTree;
diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointDmTree.java b/wifi/java/android/net/wifi/passpoint/WifiPasspointDmTree.java
deleted file mode 100644
index 427c84c..0000000
--- a/wifi/java/android/net/wifi/passpoint/WifiPasspointDmTree.java
+++ /dev/null
@@ -1,1375 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.wifi.passpoint;
-
-import android.os.Parcelable;
-import android.os.Parcel;
-import java.util.HashMap;
-
-/**
- * Required Mobile Device Management Tree Structure
- *
- * +----------+
- * | ./(Root) |
- * +----+-----+
- * |
- * +---------+ | +---------+ +---------+
- * | DevInfo |-----------+---------| Wi-Fi |--|SP FQDN* |
- * +---------+ | +---------+ +---------+
- * +---------+ | |
- * |DevDetail|-----------+ +-----------------------+
- * +---------+ |PerproviderSubscription|--<X>+
- * +-----------------------+
- *
- * This class contains all nodes start from Wi-Fi
- * @hide
- **/
-public class WifiPasspointDmTree implements Parcelable {
- private final static String TAG = "WifiTree";
- public int PpsMoId;//plugfest used only
- public HashMap<String, SpFqdn> spFqdn = new HashMap<String, SpFqdn>();//Maps.newHashMap();
-
- public SpFqdn createSpFqdn(String name) {
- SpFqdn obj = new SpFqdn(name);
- spFqdn.put(name, obj);
- return obj;
- }
-
- public static class SpFqdn implements Parcelable {
- public String nodeName;
- public PerProviderSubscription perProviderSubscription = new PerProviderSubscription();
-
- public SpFqdn(String name) {
- nodeName = name;
- }
-
- public SpFqdn() {
- }
-
- public SpFqdn(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(nodeName);
- out.writeParcelable(perProviderSubscription, flags);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- nodeName = in.readString();
- perProviderSubscription = in.readParcelable(PerProviderSubscription.class
- .getClassLoader());
- }
- }
-
- public static final Parcelable.Creator<SpFqdn> CREATOR = new Parcelable.Creator<SpFqdn>() {
- public SpFqdn createFromParcel(Parcel in) {
- return new SpFqdn(in);
- }
-
- public SpFqdn[] newArray(int size) {
- return new SpFqdn[size];
- }
- };
- }
-
- /**
- * PerProviderSubscription
- **/
- public static class PerProviderSubscription implements Parcelable {
- /**
- * PerProviderSubscription/UpdateIdentifier
- **/
- public String UpdateIdentifier;
- public HashMap<String, CredentialInfo> credentialInfo = new HashMap<String, CredentialInfo>();
-
- public CredentialInfo createCredentialInfo(String name) {
- CredentialInfo obj = new CredentialInfo(name);
- credentialInfo.put(name, obj);
- return obj;
- }
-
- public PerProviderSubscription() {
- }
-
- public PerProviderSubscription(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(UpdateIdentifier);
- out.writeMap(credentialInfo);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- UpdateIdentifier = in.readString();
- in.readMap(credentialInfo, CredentialInfo.class.getClassLoader());
- }
- }
-
- public static final Parcelable.Creator<PerProviderSubscription> CREATOR = new Parcelable.Creator<PerProviderSubscription>() {
- public PerProviderSubscription createFromParcel(Parcel in) {
- return new PerProviderSubscription(in);
- }
-
- public PerProviderSubscription[] newArray(int size) {
- return new PerProviderSubscription[size];
- }
- };
-
- }
-
- /**
- * PerProviderSubscription/<X+>
- * This interior node contains the Home SP information, subscription policy, management and credential information.
- **/
- public static class CredentialInfo implements Parcelable {
- public String nodeName;
- public Policy policy = new Policy();
- public String credentialPriority;
- public HashMap<String, AAAServerTrustRoot> aAAServerTrustRoot = new HashMap<String, AAAServerTrustRoot>();
- public SubscriptionUpdate subscriptionUpdate = new SubscriptionUpdate();
- public HomeSP homeSP = new HomeSP();
- public SubscriptionParameters subscriptionParameters = new SubscriptionParameters();
- public Credential credential = new Credential();
- public Extension extension = new Extension();
-
- public CredentialInfo(String nn) {
- nodeName = nn;
- }
-
- public AAAServerTrustRoot createAAAServerTrustRoot(String name, String url, String fp) {
- AAAServerTrustRoot obj = new AAAServerTrustRoot(name, url, fp);
- aAAServerTrustRoot.put(name, obj);
- return obj;
- }
-
- public CredentialInfo() {
- }
-
- public CredentialInfo(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(nodeName);
- out.writeParcelable(policy, flags);
- out.writeString(credentialPriority);
- out.writeMap(aAAServerTrustRoot);
- out.writeParcelable(subscriptionUpdate, flags);
- out.writeParcelable(homeSP, flags);
- out.writeParcelable(subscriptionParameters, flags);
- out.writeParcelable(credential, flags);
- //out.writeParcelable(extension, flags);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- nodeName = in.readString();
- policy = in.readParcelable(Policy.class.getClassLoader());
- credentialPriority = in.readString();
- in.readMap(aAAServerTrustRoot, AAAServerTrustRoot.class.getClassLoader());
- subscriptionUpdate = in.readParcelable(SubscriptionUpdate.class.getClassLoader());
- homeSP = in.readParcelable(HomeSP.class.getClassLoader());
- subscriptionParameters = in.readParcelable(SubscriptionParameters.class
- .getClassLoader());
- credential = in.readParcelable(Credential.class.getClassLoader());
- //extension = in.readParcelable(Extension.class.getClassLoader());
- }
- }
-
- public static final Parcelable.Creator<CredentialInfo> CREATOR = new Parcelable.Creator<CredentialInfo>() {
- public CredentialInfo createFromParcel(Parcel in) {
- return new CredentialInfo(in);
- }
-
- public CredentialInfo[] newArray(int size) {
- return new CredentialInfo[size];
- }
- };
-
- }
-
- /**
- * PerProviderSubscription/<X+>/Policy
- **/
- public static class Policy implements Parcelable {
- public HashMap<String, PreferredRoamingPartnerList> preferredRoamingPartnerList = new HashMap<String, PreferredRoamingPartnerList>();
- public HashMap<String, MinBackhaulThresholdNetwork> minBackhaulThreshold = new HashMap<String, MinBackhaulThresholdNetwork>();
- public PolicyUpdate policyUpdate = new PolicyUpdate();
- public HashMap<String, SPExclusionList> sPExclusionList = new HashMap<String, SPExclusionList>();
- public HashMap<String, RequiredProtoPortTuple> requiredProtoPortTuple = new HashMap<String, RequiredProtoPortTuple>();
- public String maximumBSSLoadValue;
-
- public PreferredRoamingPartnerList createPreferredRoamingPartnerList(String name,
- String fqdn, String priority, String country) {
- PreferredRoamingPartnerList obj = new PreferredRoamingPartnerList(name, fqdn, priority,
- country);
- preferredRoamingPartnerList.put(name, obj);
- return obj;
- }
-
- public MinBackhaulThresholdNetwork createMinBackhaulThreshold(String name, String type,
- String dl, String ul) {
- MinBackhaulThresholdNetwork obj = new MinBackhaulThresholdNetwork(name, type, dl, ul);
- minBackhaulThreshold.put(name, obj);
- return obj;
- }
-
- public SPExclusionList createSPExclusionList(String name, String ssid) {
- SPExclusionList obj = new SPExclusionList(name, ssid);
- sPExclusionList.put(name, obj);
- return obj;
- }
-
- public RequiredProtoPortTuple createRequiredProtoPortTuple(String name, String proto,
- String port) {
- RequiredProtoPortTuple obj = new RequiredProtoPortTuple(name, proto, port);
- requiredProtoPortTuple.put(name, obj);
- return obj;
- }
-
- public Policy() {
- }
-
- public Policy(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeMap(preferredRoamingPartnerList);
- out.writeMap(minBackhaulThreshold);
- out.writeParcelable(policyUpdate, flags);
- out.writeMap(sPExclusionList);
- out.writeMap(requiredProtoPortTuple);
- out.writeString(maximumBSSLoadValue);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- in.readMap(preferredRoamingPartnerList,
- PreferredRoamingPartnerList.class.getClassLoader());
- in.readMap(minBackhaulThreshold, MinBackhaulThresholdNetwork.class.getClassLoader());
- policyUpdate = in.readParcelable(PolicyUpdate.class.getClassLoader());
- in.readMap(sPExclusionList, SPExclusionList.class.getClassLoader());
- in.readMap(requiredProtoPortTuple, RequiredProtoPortTuple.class.getClassLoader());
- maximumBSSLoadValue = in.readString();
-
- }
- }
-
- public static final Parcelable.Creator<Policy> CREATOR = new Parcelable.Creator<Policy>() {
- public Policy createFromParcel(Parcel in) {
- return new Policy(in);
- }
-
- public Policy[] newArray(int size) {
- return new Policy[size];
- }
- };
-
- }
-
- /**
- * PerProviderSubscription/<X+>/Policy/PreferredRoamingPartnerList/<X+>
- **/
- public static class PreferredRoamingPartnerList implements Parcelable {
- public String nodeName;
- public String FQDN_Match; //maximum 255 + ",includeSubdomains", equals 273
- public String Priority;
- public String Country; // maximum 600 octets
-
- public PreferredRoamingPartnerList(String nn, String f, String p, String c) {
- nodeName = nn;
- FQDN_Match = f;
- Priority = p;
- Country = c;
- }
-
- public PreferredRoamingPartnerList() {
- }
-
- public PreferredRoamingPartnerList(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(nodeName);
- out.writeString(FQDN_Match);
- out.writeString(Priority);
- out.writeString(Country);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- nodeName = in.readString();
- FQDN_Match = in.readString();
- Priority = in.readString();
- Country = in.readString();
- }
- }
-
- public static final Parcelable.Creator<PreferredRoamingPartnerList> CREATOR = new Parcelable.Creator<PreferredRoamingPartnerList>() {
- public PreferredRoamingPartnerList createFromParcel(Parcel in) {
- return new PreferredRoamingPartnerList(in);
- }
-
- public PreferredRoamingPartnerList[] newArray(int size) {
- return new PreferredRoamingPartnerList[size];
- }
- };
- }
-
- /**
- * PerProviderSubscription/<X+>/Policy/MinBackhaulThreshold
- **/
- public static class MinBackhaulThresholdNetwork implements Parcelable {
- public String nodeName;
- public String NetworkType;
- public String DLBandwidth;
- public String ULBandwidth;
-
- public MinBackhaulThresholdNetwork(String nn, String nt, String d, String u) {
- nodeName = nn;
- NetworkType = nt;
- DLBandwidth = d;
- ULBandwidth = u;
- }
-
- public MinBackhaulThresholdNetwork() {
- }
-
- public MinBackhaulThresholdNetwork(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(nodeName);
- out.writeString(NetworkType);
- out.writeString(DLBandwidth);
- out.writeString(ULBandwidth);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- nodeName = in.readString();
- NetworkType = in.readString();
- DLBandwidth = in.readString();
- ULBandwidth = in.readString();
- }
- }
-
- public static final Parcelable.Creator<MinBackhaulThresholdNetwork> CREATOR = new Parcelable.Creator<MinBackhaulThresholdNetwork>() {
- public MinBackhaulThresholdNetwork createFromParcel(Parcel in) {
- return new MinBackhaulThresholdNetwork(in);
- }
-
- public MinBackhaulThresholdNetwork[] newArray(int size) {
- return new MinBackhaulThresholdNetwork[size];
- }
- };
-
- }
-
- /**
- * PerProviderSubscription/<X+>/Policy/PolicyUpdate
- **/
- public static class PolicyUpdate implements Parcelable {
- public String UpdateInterval;
- public String UpdateMethod;
- public String Restriction;
- public String URI;
- public UsernamePassword usernamePassword = new UsernamePassword();
- public String Other;
- public TrustRoot trustRoot = new TrustRoot();
-
- public PolicyUpdate() {
- }
-
- public PolicyUpdate(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(UpdateInterval);
- out.writeString(UpdateMethod);
- out.writeString(Restriction);
- out.writeString(URI);
- out.writeParcelable(usernamePassword, flags);
- out.writeString(Other);
- out.writeParcelable(trustRoot, flags);
-
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- UpdateInterval = in.readString();
- UpdateMethod = in.readString();
- Restriction = in.readString();
- URI = in.readString();
- usernamePassword = in.readParcelable(UsernamePassword.class.getClassLoader());
- Other = in.readString();
- trustRoot = in.readParcelable(TrustRoot.class.getClassLoader());
- }
- }
-
- public static final Parcelable.Creator<PolicyUpdate> CREATOR = new Parcelable.Creator<PolicyUpdate>() {
- public PolicyUpdate createFromParcel(Parcel in) {
- return new PolicyUpdate(in);
- }
-
- public PolicyUpdate[] newArray(int size) {
- return new PolicyUpdate[size];
- }
- };
- }
-
- /**
- * PerProviderSubscription/<X+>/Policy/SPExclusionList
- **/
- public static class SPExclusionList implements Parcelable {
- public String nodeName;
- public String SSID;
-
- public SPExclusionList(String nn, String s) {
- nodeName = nn;
- SSID = s;
- }
-
- public SPExclusionList() {
- }
-
- public SPExclusionList(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(nodeName);
- out.writeString(SSID);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- nodeName = in.readString();
- SSID = in.readString();
- }
- }
-
- public static final Parcelable.Creator<SPExclusionList> CREATOR = new Parcelable.Creator<SPExclusionList>() {
- public SPExclusionList createFromParcel(Parcel in) {
- return new SPExclusionList(in);
- }
-
- public SPExclusionList[] newArray(int size) {
- return new SPExclusionList[size];
- }
- };
- }
-
- /**
- * PerProviderSubscription/<X+>/Policy/RequiredProtoPortTuple
- **/
- public static class RequiredProtoPortTuple implements Parcelable {
- public String nodeName;
- public String IPProtocol;
- public String PortNumber;
-
- public RequiredProtoPortTuple() {
- }
-
- public RequiredProtoPortTuple(String nn, String protocol, String port) {
- nodeName = nn;
- IPProtocol = protocol;
- PortNumber = port;
- }
-
- public RequiredProtoPortTuple(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(nodeName);
- out.writeString(IPProtocol);
- out.writeString(PortNumber);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- nodeName = in.readString();
- IPProtocol = in.readString();
- PortNumber = in.readString();
- }
- }
-
- public static final Parcelable.Creator<RequiredProtoPortTuple> CREATOR = new Parcelable.Creator<RequiredProtoPortTuple>() {
- public RequiredProtoPortTuple createFromParcel(Parcel in) {
- return new RequiredProtoPortTuple(in);
- }
-
- public RequiredProtoPortTuple[] newArray(int size) {
- return new RequiredProtoPortTuple[size];
- }
- };
- }
-
- /**
- * PerProviderSubscription/<X+>/AAAServerTrustRoot
- **/
- public static class AAAServerTrustRoot implements Parcelable {
- public String nodeName;
- public String CertURL;
- public String CertSHA256Fingerprint;
-
- public AAAServerTrustRoot(String nn, String url, String fp) {
- nodeName = nn;
- CertURL = url;
- CertSHA256Fingerprint = fp;
- }
-
- public AAAServerTrustRoot() {
- }
-
- public AAAServerTrustRoot(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(nodeName);
- out.writeString(CertURL);
- out.writeString(CertSHA256Fingerprint);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- nodeName = in.readString();
- CertURL = in.readString();
- CertSHA256Fingerprint = in.readString();
- }
- }
-
- public static final Parcelable.Creator<AAAServerTrustRoot> CREATOR = new Parcelable.Creator<AAAServerTrustRoot>() {
- public AAAServerTrustRoot createFromParcel(Parcel in) {
- return new AAAServerTrustRoot(in);
- }
-
- public AAAServerTrustRoot[] newArray(int size) {
- return new AAAServerTrustRoot[size];
- }
- };
- }
-
- /**
- * PerProviderSubscription/<X+>/SubscriptionUpdate
- **/
- public static class SubscriptionUpdate implements Parcelable {
- public String UpdateInterval;
- public String UpdateMethod;
- public String Restriction;
- public String URI;
- public UsernamePassword usernamePassword = new UsernamePassword();
- public String Other;
- public TrustRoot trustRoot = new TrustRoot();
-
- public SubscriptionUpdate() {
- }
-
- public SubscriptionUpdate(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(UpdateInterval);
- out.writeString(UpdateMethod);
- out.writeString(Restriction);
- out.writeString(URI);
- out.writeParcelable(usernamePassword, flags);
- out.writeString(Other);
- out.writeParcelable(trustRoot, flags);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- UpdateInterval = in.readString();
- UpdateMethod = in.readString();
- Restriction = in.readString();
- URI = in.readString();
- usernamePassword = in.readParcelable(UsernamePassword.class.getClassLoader());
- Other = in.readString();
- trustRoot = in.readParcelable(TrustRoot.class.getClassLoader());
- }
- }
-
- public static final Parcelable.Creator<SubscriptionUpdate> CREATOR = new Parcelable.Creator<SubscriptionUpdate>() {
- public SubscriptionUpdate createFromParcel(Parcel in) {
- return new SubscriptionUpdate(in);
- }
-
- public SubscriptionUpdate[] newArray(int size) {
- return new SubscriptionUpdate[size];
- }
- };
-
- }
-
- /**
- * PerProviderSubscription/<X+>/Policy/PolicyUpdate/TrustRoot
- * PerProviderSubscription/<X+>/SubscriptionUpdate/TrustRoot
- * PerProviderSubscription/<X+>/AAAServerTrustRoot/<X+>
- **/
- public static class TrustRoot implements Parcelable {
- public String CertURL;
- public String CertSHA256Fingerprint;
-
- public TrustRoot() {
- }
-
- public TrustRoot(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(CertURL);
- out.writeString(CertSHA256Fingerprint);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- CertURL = in.readString();
- CertSHA256Fingerprint = in.readString();
- }
- }
-
- public static final Parcelable.Creator<TrustRoot> CREATOR = new Parcelable.Creator<TrustRoot>() {
- public TrustRoot createFromParcel(Parcel in) {
- return new TrustRoot(in);
- }
-
- public TrustRoot[] newArray(int size) {
- return new TrustRoot[size];
- }
- };
- }
-
- /**
- * PerProviderSubscription/<X+>/Policy/PolicyUpdate/UsernamePassword
- * PerProviderSubscription/<X+>/SubscriptionUpdate/UsernamePassword
- * PerProviderSubscription/<X+>/Credential/UsernamePassword
- **/
- public static class UsernamePassword implements Parcelable {
- public String Username;
- public String Password;
- //following are Credential node used only
- public boolean MachineManaged;
- public String SoftTokenApp;
- public String AbleToShare;
- public EAPMethod eAPMethod = new EAPMethod();
-
- public UsernamePassword() {
- }
-
- public UsernamePassword(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(Username);
- out.writeString(Password);
- out.writeInt(MachineManaged ? 1 : 0);
- out.writeString(SoftTokenApp);
- out.writeString(AbleToShare);
- out.writeParcelable(eAPMethod, flags);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- Username = in.readString();
- Password = in.readString();
- MachineManaged = (in.readInt() == 1) ? true : false;
- SoftTokenApp = in.readString();
- AbleToShare = in.readString();
- eAPMethod = in.readParcelable(EAPMethod.class.getClassLoader());
- }
- }
-
- public static final Parcelable.Creator<UsernamePassword> CREATOR = new Parcelable.Creator<UsernamePassword>() {
- public UsernamePassword createFromParcel(Parcel in) {
- return new UsernamePassword(in);
- }
-
- public UsernamePassword[] newArray(int size) {
- return new UsernamePassword[size];
- }
- };
-
- }
-
- /**
- * PerProviderSubscription/<X+>/Credential/UsernamePassword/EAPMethod
- **/
- public static class EAPMethod implements Parcelable {
- public String EAPType;
- public String VendorId;
- public String VendorType;
- public String InnerEAPType;
- public String InnerVendorId;
- public String InnerVendorType;
- public String InnerMethod;
-
- public EAPMethod() {
- }
-
- public EAPMethod(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(EAPType);
- out.writeString(VendorId);
- out.writeString(VendorType);
- out.writeString(InnerEAPType);
- out.writeString(InnerVendorId);
- out.writeString(InnerVendorType);
- out.writeString(InnerMethod);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- EAPType = in.readString();
- VendorId = in.readString();
- VendorType = in.readString();
- InnerEAPType = in.readString();
- InnerVendorId = in.readString();
- InnerVendorType = in.readString();
- InnerMethod = in.readString();
- }
- }
-
- public static final Parcelable.Creator<EAPMethod> CREATOR = new Parcelable.Creator<EAPMethod>() {
- public EAPMethod createFromParcel(Parcel in) {
- return new EAPMethod(in);
- }
-
- public EAPMethod[] newArray(int size) {
- return new EAPMethod[size];
- }
- };
- }
-
- /**
- * PerProviderSubscription/<X+>/HomeSP
- **/
- public static class HomeSP implements Parcelable {
- public HashMap<String, NetworkID> networkID = new HashMap<String, NetworkID>();
- public String FriendlyName;
- public String IconURL;
- public String FQDN;
- public HashMap<String, HomeOIList> homeOIList = new HashMap<String, HomeOIList>();
- public HashMap<String, OtherHomePartners> otherHomePartners = new HashMap<String, OtherHomePartners>();
- public String RoamingConsortiumOI;
-
- public NetworkID createNetworkID(String name, String ssid, String hessid) {
- NetworkID obj = new NetworkID(name, ssid, hessid);
- networkID.put(name, obj);
- return obj;
- }
-
- public HomeOIList createHomeOIList(String name, String homeoi, boolean required) {
- HomeOIList obj = new HomeOIList(name, homeoi, required);
- homeOIList.put(name, obj);
- return obj;
- }
-
- public OtherHomePartners createOtherHomePartners(String name, String fqdn) {
- OtherHomePartners obj = new OtherHomePartners(name, fqdn);
- otherHomePartners.put(name, obj);
- return obj;
- }
-
- public HomeSP() {
- }
-
- public HomeSP(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeMap(networkID);
- out.writeString(FriendlyName);
- out.writeString(IconURL);
- out.writeString(FQDN);
- out.writeMap(homeOIList);
- out.writeMap(otherHomePartners);
- out.writeString(RoamingConsortiumOI);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- in.readMap(networkID, NetworkID.class.getClassLoader());
- FriendlyName = in.readString();
- IconURL = in.readString();
- FQDN = in.readString();
- in.readMap(homeOIList, HomeOIList.class.getClassLoader());
- in.readMap(otherHomePartners, OtherHomePartners.class.getClassLoader());
- RoamingConsortiumOI = in.readString();
- }
- }
-
- public static final Parcelable.Creator<HomeSP> CREATOR = new Parcelable.Creator<HomeSP>() {
- public HomeSP createFromParcel(Parcel in) {
- return new HomeSP(in);
- }
-
- public HomeSP[] newArray(int size) {
- return new HomeSP[size];
- }
- };
-
- }
-
- /**
- * PerProviderSubscription/<X+>/HomeSP/NetworkID
- **/
- public static class NetworkID implements Parcelable {
- public String nodeName;
- public String SSID;
- public String HESSID;
-
- public NetworkID(String nn, String s, String h) {
- nodeName = nn;
- SSID = s;
- HESSID = h;
- }
-
- public NetworkID() {
- }
-
- public NetworkID(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(nodeName);
- out.writeString(SSID);
- out.writeString(HESSID);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- nodeName = in.readString();
- SSID = in.readString();
- HESSID = in.readString();
- }
- }
-
- public static final Parcelable.Creator<NetworkID> CREATOR = new Parcelable.Creator<NetworkID>() {
- public NetworkID createFromParcel(Parcel in) {
- return new NetworkID(in);
- }
-
- public NetworkID[] newArray(int size) {
- return new NetworkID[size];
- }
- };
-
- }
-
- /**
- * PerProviderSubscription/<X+>/HomeSP/HomeOIList
- **/
- public static class HomeOIList implements Parcelable {
- public String nodeName;
- public String HomeOI;
- public boolean HomeOIRequired;
-
- public HomeOIList(String nn, String h, boolean r) {
- nodeName = nn;
- HomeOI = h;
- HomeOIRequired = r;
- }
-
- public HomeOIList() {
- }
-
- public HomeOIList(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(nodeName);
- out.writeString(HomeOI);
- out.writeInt(HomeOIRequired ? 1 : 0);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- nodeName = in.readString();
- HomeOI = in.readString();
- HomeOIRequired = (in.readInt() == 1) ? true : false;
- }
- }
-
- public static final Parcelable.Creator<HomeOIList> CREATOR = new Parcelable.Creator<HomeOIList>() {
- public HomeOIList createFromParcel(Parcel in) {
- return new HomeOIList(in);
- }
-
- public HomeOIList[] newArray(int size) {
- return new HomeOIList[size];
- }
- };
-
- }
-
- /**
- * PerProviderSubscription/<X+>/HomeSP/OtherHomePartners
- **/
- public static class OtherHomePartners implements Parcelable {
- public String nodeName;
- public String FQDN;
-
- public OtherHomePartners(String nn, String f) {
- nodeName = nn;
- FQDN = f;
- }
-
- public OtherHomePartners() {
- }
-
- public OtherHomePartners(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(nodeName);
- out.writeString(FQDN);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- nodeName = in.readString();
- FQDN = in.readString();
- }
- }
-
- public static final Parcelable.Creator<OtherHomePartners> CREATOR = new Parcelable.Creator<OtherHomePartners>() {
- public OtherHomePartners createFromParcel(Parcel in) {
- return new OtherHomePartners(in);
- }
-
- public OtherHomePartners[] newArray(int size) {
- return new OtherHomePartners[size];
- }
- };
-
- }
-
- /**
- * PerProviderSubscription/<X+>/SubscriptionParameters
- **/
- public static class SubscriptionParameters implements Parcelable {
- public String CreationDate;
- public String ExpirationDate;
- public String TypeOfSubscription;
- public UsageLimits usageLimits = new UsageLimits();
-
- public SubscriptionParameters() {
- }
-
- public SubscriptionParameters(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(CreationDate);
- out.writeString(ExpirationDate);
- out.writeString(TypeOfSubscription);
- out.writeParcelable(usageLimits, flags);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- CreationDate = in.readString();
- ExpirationDate = in.readString();
- TypeOfSubscription = in.readString();
- usageLimits = in.readParcelable(UsageLimits.class.getClassLoader());
- }
- }
-
- public static final Parcelable.Creator<SubscriptionParameters> CREATOR = new Parcelable.Creator<SubscriptionParameters>() {
- public SubscriptionParameters createFromParcel(Parcel in) {
- return new SubscriptionParameters(in);
- }
-
- public SubscriptionParameters[] newArray(int size) {
- return new SubscriptionParameters[size];
- }
- };
-
- }
-
- /**
- * PerProviderSubscription/<X+>/SubscriptionParameters/UsageLimits
- **/
- public static class UsageLimits implements Parcelable {
- public String DataLimit;
- public String StartDate;
- public String TimeLimit;
- public String UsageTimePeriod;
-
- public UsageLimits() {
- }
-
- public UsageLimits(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(DataLimit);
- out.writeString(StartDate);
- out.writeString(TimeLimit);
- out.writeString(UsageTimePeriod);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- DataLimit = in.readString();
- StartDate = in.readString();
- TimeLimit = in.readString();
- UsageTimePeriod = in.readString();
- }
- }
-
- public static final Parcelable.Creator<UsageLimits> CREATOR = new Parcelable.Creator<UsageLimits>() {
- public UsageLimits createFromParcel(Parcel in) {
- return new UsageLimits(in);
- }
-
- public UsageLimits[] newArray(int size) {
- return new UsageLimits[size];
- }
- };
- }
-
- /**
- * PerProviderSubscription/<X+>/Credential
- **/
- public static class Credential implements Parcelable {
- public String CreationDate;
- public String ExpirationDate;
- public UsernamePassword usernamePassword = new UsernamePassword();
- public DigitalCertificate digitalCertificate = new DigitalCertificate();
- public String Realm;
- public boolean CheckAAAServerCertStatus;
- public SIM sim = new SIM();
-
- public Credential() {
- }
-
- public Credential(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(CreationDate);
- out.writeString(ExpirationDate);
- out.writeParcelable(usernamePassword, flags);
- out.writeParcelable(digitalCertificate, flags);
- out.writeString(Realm);
- out.writeInt(CheckAAAServerCertStatus ? 1 : 0);
- out.writeParcelable(sim, flags);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- CreationDate = in.readString();
- ExpirationDate = in.readString();
- usernamePassword = in.readParcelable(UsernamePassword.class.getClassLoader());
- digitalCertificate = in.readParcelable(DigitalCertificate.class.getClassLoader());
- Realm = in.readString();
- CheckAAAServerCertStatus = (in.readInt() == 1) ? true : false;
- sim = in.readParcelable(SIM.class.getClassLoader());
- }
- }
-
- public static final Parcelable.Creator<Credential> CREATOR = new Parcelable.Creator<Credential>() {
- public Credential createFromParcel(Parcel in) {
- return new Credential(in);
- }
-
- public Credential[] newArray(int size) {
- return new Credential[size];
- }
- };
- }
-
- /**
- * PerProviderSubscription/<X+>/Credential/DigitalCertificate
- **/
- public static class DigitalCertificate implements Parcelable {
- public String CertificateType;
- public String CertSHA256Fingerprint;
-
- public DigitalCertificate() {
- }
-
- public DigitalCertificate(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(CertificateType);
- out.writeString(CertSHA256Fingerprint);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- CertificateType = in.readString();
- CertSHA256Fingerprint = in.readString();
- }
- }
-
- public static final Parcelable.Creator<DigitalCertificate> CREATOR = new Parcelable.Creator<DigitalCertificate>() {
- public DigitalCertificate createFromParcel(Parcel in) {
- return new DigitalCertificate(in);
- }
-
- public DigitalCertificate[] newArray(int size) {
- return new DigitalCertificate[size];
- }
- };
-
- }
-
- /**
- * PerProviderSubscription/<X+>/Credential/SIM
- **/
- public static class SIM implements Parcelable {
- public String IMSI;
- public String EAPType;
-
- public SIM() {
- }
-
- public SIM(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(IMSI);
- out.writeString(EAPType);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- IMSI = in.readString();
- EAPType = in.readString();
- }
- }
-
- public static final Parcelable.Creator<SIM> CREATOR = new Parcelable.Creator<SIM>() {
- public SIM createFromParcel(Parcel in) {
- return new SIM(in);
- }
-
- public SIM[] newArray(int size) {
- return new SIM[size];
- }
- };
-
- }
-
- /**
- * PerProviderSubscription/<X+>/Extension
- **/
- public static class Extension {
- public String empty;
- }
-
- public WifiPasspointDmTree() {
- }
-
- public WifiPasspointDmTree(Parcel in) {
- readFromParcel(in);
- }
-
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel out, int flags) {
- out.writeMap(spFqdn);
- }
-
- public void readFromParcel(Parcel in) {
- if (in == null) {
- //log here
- } else {
- in.readMap(spFqdn, SpFqdn.class.getClassLoader());
- }
- }
-
- public static final Parcelable.Creator<WifiPasspointDmTree> CREATOR = new Parcelable.Creator<WifiPasspointDmTree>() {
- public WifiPasspointDmTree createFromParcel(Parcel in) {
- return new WifiPasspointDmTree(in);
- }
-
- public WifiPasspointDmTree[] newArray(int size) {
- return new WifiPasspointDmTree[size];
- }
- };
-
-}
diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.java b/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.java
deleted file mode 100644
index 33db3f5..0000000
--- a/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.java
+++ /dev/null
@@ -1,559 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.wifi.passpoint;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/** @hide */
-public class WifiPasspointInfo implements Parcelable {
-
- /** TODO doc */
- public static final int ANQP_CAPABILITY = 1 << 0;
-
- /** TODO doc */
- public static final int VENUE_NAME = 1 << 1;
-
- /** TODO doc */
- public static final int NETWORK_AUTH_TYPE = 1 << 2;
-
- /** TODO doc */
- public static final int ROAMING_CONSORTIUM = 1 << 3;
-
- /** TODO doc */
- public static final int IP_ADDR_TYPE_AVAILABILITY = 1 << 4;
-
- /** TODO doc */
- public static final int NAI_REALM = 1 << 5;
-
- /** TODO doc */
- public static final int CELLULAR_NETWORK = 1 << 6;
-
- /** TODO doc */
- public static final int DOMAIN_NAME = 1 << 7;
-
- /** TODO doc */
- public static final int HOTSPOT_CAPABILITY = 1 << 8;
-
- /** TODO doc */
- public static final int OPERATOR_FRIENDLY_NAME = 1 << 9;
-
- /** TODO doc */
- public static final int WAN_METRICS = 1 << 10;
-
- /** TODO doc */
- public static final int CONNECTION_CAPABILITY = 1 << 11;
-
- /** TODO doc */
- public static final int OSU_PROVIDER = 1 << 12;
-
- /** TODO doc */
- public static final int PRESET_CRED_MATCH =
- ANQP_CAPABILITY |
- HOTSPOT_CAPABILITY |
- NAI_REALM |
- CELLULAR_NETWORK |
- DOMAIN_NAME;
-
- /** TODO doc */
- public static final int PRESET_ALL =
- ANQP_CAPABILITY |
- VENUE_NAME |
- NETWORK_AUTH_TYPE |
- ROAMING_CONSORTIUM |
- IP_ADDR_TYPE_AVAILABILITY |
- NAI_REALM |
- CELLULAR_NETWORK |
- DOMAIN_NAME |
- HOTSPOT_CAPABILITY |
- OPERATOR_FRIENDLY_NAME |
- WAN_METRICS |
- CONNECTION_CAPABILITY |
- OSU_PROVIDER;
-
-
- public static class WanMetrics {
- public static final int STATUS_RESERVED = 0;
- public static final int STATUS_UP = 1;
- public static final int STATUS_DOWN = 2;
- public static final int STATUS_TEST = 3;
-
- public int wanInfo;
- public long downlinkSpeed;
- public long uplinkSpeed;
- public int downlinkLoad;
- public int uplinkLoad;
- public int lmd;
-
- public int getLinkStatus() {
- return wanInfo & 0x3;
- }
-
- public boolean getSymmetricLink() {
- return (wanInfo & (1 << 2)) != 0;
- }
-
- public boolean getAtCapacity() {
- return (wanInfo & (1 << 3)) != 0;
- }
-
- @Override
- public String toString() {
- return wanInfo + "," + downlinkSpeed + "," + uplinkSpeed + "," +
- downlinkLoad + "," + uplinkLoad + "," + lmd;
- }
- }
-
- public static class IpProtoPort {
- public static final int STATUS_CLOSED = 0;
- public static final int STATUS_OPEN = 1;
- public static final int STATUS_UNKNOWN = 2;
-
- public int proto;
- public int port;
- public int status;
-
- @Override
- public String toString() {
- return proto + "," + port + "," + status;
- }
- }
-
- public static class NetworkAuthType {
- public static final int TYPE_TERMS_AND_CONDITION = 0;
- public static final int TYPE_ONLINE_ENROLLMENT = 1;
- public static final int TYPE_HTTP_REDIRECTION = 2;
- public static final int TYPE_DNS_REDIRECTION = 3;
-
- public int type;
- public String redirectUrl;
-
- @Override
- public String toString() {
- return type + "," + redirectUrl;
- }
- }
-
- public static class IpAddressType {
- public static final int IPV6_NOT_AVAILABLE = 0;
- public static final int IPV6_AVAILABLE = 1;
- public static final int IPV6_UNKNOWN = 2;
-
- public static final int IPV4_NOT_AVAILABLE = 0;
- public static final int IPV4_PUBLIC = 1;
- public static final int IPV4_PORT_RESTRICTED = 2;
- public static final int IPV4_SINGLE_NAT = 3;
- public static final int IPV4_DOUBLE_NAT = 4;
- public static final int IPV4_PORT_RESTRICTED_SINGLE_NAT = 5;
- public static final int IPV4_PORT_RESTRICTED_DOUBLE_NAT = 6;
- public static final int IPV4_PORT_UNKNOWN = 7;
-
- private static final int NULL_VALUE = -1;
-
- public int availability;
-
- public int getIpv6Availability() {
- return availability & 0x3;
- }
-
- public int getIpv4Availability() {
- return (availability & 0xFF) >> 2;
- }
-
- @Override
- public String toString() {
- return getIpv6Availability() + "," + getIpv4Availability();
- }
- }
-
- public static class NaiRealm {
- public static final int ENCODING_RFC4282 = 0;
- public static final int ENCODING_UTF8 = 1;
-
- public int encoding;
- public String realm;
-
- @Override
- public String toString() {
- return encoding + "," + realm;
- }
- }
-
- public static class CellularNetwork {
- public String mcc;
- public String mnc;
-
- @Override
- public String toString() {
- return mcc + "," + mnc;
- }
- }
-
- /** BSSID */
- public String bssid;
-
- /** venue name */
- public String venueName;
-
- /** list of network authentication types */
- public List<NetworkAuthType> networkAuthTypeList;
-
- /** list of roaming consortium OIs */
- public List<String> roamingConsortiumList;
-
- /** IP address availability */
- public IpAddressType ipAddrTypeAvailability;
-
- /** list of NAI realm */
- public List<NaiRealm> naiRealmList;
-
- /** list of 3GPP cellular network */
- public List<CellularNetwork> cellularNetworkList;
-
- /** list of fully qualified domain name (FQDN) */
- public List<String> domainNameList;
-
- /** HS 2.0 operator friendly name */
- public String operatorFriendlyName;
-
- /** HS 2.0 wan metrics */
- public WanMetrics wanMetrics;
-
- /** list of HS 2.0 IP proto port */
- public List<IpProtoPort> connectionCapabilityList;
-
- /** list of HS 2.0 OSU providers */
- public List<WifiPasspointOsuProvider> osuProviderList;
-
- /**
- * Convert mask to ANQP subtypes, for supplicant command use.
- *
- * @param mask The ANQP subtypes mask.
- * @return String of ANQP subtypes, good for supplicant command use
- * @hide
- */
- public static String toAnqpSubtypes(int mask) {
- StringBuilder sb = new StringBuilder();
- if ((mask & ANQP_CAPABILITY) != 0)
- sb.append("257,");
- if ((mask & VENUE_NAME) != 0)
- sb.append("258,");
- if ((mask & NETWORK_AUTH_TYPE) != 0)
- sb.append("260,");
- if ((mask & ROAMING_CONSORTIUM) != 0)
- sb.append("261,");
- if ((mask & IP_ADDR_TYPE_AVAILABILITY) != 0)
- sb.append("262,");
- if ((mask & NAI_REALM) != 0)
- sb.append("263,");
- if ((mask & CELLULAR_NETWORK) != 0)
- sb.append("264,");
- if ((mask & DOMAIN_NAME) != 0)
- sb.append("268,");
- if ((mask & HOTSPOT_CAPABILITY) != 0)
- sb.append("hs20:2,");
- if ((mask & OPERATOR_FRIENDLY_NAME) != 0)
- sb.append("hs20:3,");
- if ((mask & WAN_METRICS) != 0)
- sb.append("hs20:4,");
- if ((mask & CONNECTION_CAPABILITY) != 0)
- sb.append("hs20:5,");
- if ((mask & OSU_PROVIDER) != 0)
- sb.append("hs20:8,");
- if (sb.length() > 0)
- sb.deleteCharAt(sb.length() - 1);
- return sb.toString();
- }
-
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer();
-
- sb.append("BSSID: ").append("(").append(bssid).append(")");
-
- if (venueName != null)
- sb.append(" venueName: ").append("(")
- .append(venueName.replace("\n", "\\n")).append(")");
-
- if (networkAuthTypeList != null) {
- sb.append(" networkAuthType: ");
- for (NetworkAuthType auth : networkAuthTypeList)
- sb.append("(").append(auth.toString()).append(")");
- }
-
- if (roamingConsortiumList != null) {
- sb.append(" roamingConsortium: ");
- for (String oi : roamingConsortiumList)
- sb.append("(").append(oi).append(")");
- }
-
- if (ipAddrTypeAvailability != null) {
- sb.append(" ipAddrTypeAvaibility: ").append("(")
- .append(ipAddrTypeAvailability.toString()).append(")");
- }
-
- if (naiRealmList != null) {
- sb.append(" naiRealm: ");
- for (NaiRealm realm : naiRealmList)
- sb.append("(").append(realm.toString()).append(")");
- }
-
- if (cellularNetworkList != null) {
- sb.append(" cellularNetwork: ");
- for (CellularNetwork plmn : cellularNetworkList)
- sb.append("(").append(plmn.toString()).append(")");
- }
-
- if (domainNameList != null) {
- sb.append(" domainName: ");
- for (String fqdn : domainNameList)
- sb.append("(").append(fqdn).append(")");
- }
-
- if (operatorFriendlyName != null)
- sb.append(" operatorFriendlyName: ").append("(")
- .append(operatorFriendlyName).append(")");
-
- if (wanMetrics != null)
- sb.append(" wanMetrics: ").append("(")
- .append(wanMetrics.toString()).append(")");
-
- if (connectionCapabilityList != null) {
- sb.append(" connectionCapability: ");
- for (IpProtoPort ip : connectionCapabilityList)
- sb.append("(").append(ip.toString()).append(")");
- }
-
- if (osuProviderList != null) {
- sb.append(" osuProviderList: ");
- for (WifiPasspointOsuProvider osu : osuProviderList)
- sb.append("(").append(osu.toString()).append(")");
- }
-
- return sb.toString();
- }
-
- /** Implement the Parcelable interface {@hide} */
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(bssid);
- out.writeString(venueName);
-
- if (networkAuthTypeList == null) {
- out.writeInt(0);
- } else {
- out.writeInt(networkAuthTypeList.size());
- for (NetworkAuthType auth : networkAuthTypeList) {
- out.writeInt(auth.type);
- out.writeString(auth.redirectUrl);
- }
- }
-
- if (roamingConsortiumList == null) {
- out.writeInt(0);
- } else {
- out.writeInt(roamingConsortiumList.size());
- for (String oi : roamingConsortiumList)
- out.writeString(oi);
- }
-
- if (ipAddrTypeAvailability == null) {
- out.writeInt(IpAddressType.NULL_VALUE);
- } else {
- out.writeInt(ipAddrTypeAvailability.availability);
- }
-
- if (naiRealmList == null) {
- out.writeInt(0);
- } else {
- out.writeInt(naiRealmList.size());
- for (NaiRealm realm : naiRealmList) {
- out.writeInt(realm.encoding);
- out.writeString(realm.realm);
- }
- }
-
- if (cellularNetworkList == null) {
- out.writeInt(0);
- } else {
- out.writeInt(cellularNetworkList.size());
- for (CellularNetwork plmn : cellularNetworkList) {
- out.writeString(plmn.mcc);
- out.writeString(plmn.mnc);
- }
- }
-
-
- if (domainNameList == null) {
- out.writeInt(0);
- } else {
- out.writeInt(domainNameList.size());
- for (String fqdn : domainNameList)
- out.writeString(fqdn);
- }
-
- out.writeString(operatorFriendlyName);
-
- if (wanMetrics == null) {
- out.writeInt(0);
- } else {
- out.writeInt(1);
- out.writeInt(wanMetrics.wanInfo);
- out.writeLong(wanMetrics.downlinkSpeed);
- out.writeLong(wanMetrics.uplinkSpeed);
- out.writeInt(wanMetrics.downlinkLoad);
- out.writeInt(wanMetrics.uplinkLoad);
- out.writeInt(wanMetrics.lmd);
- }
-
- if (connectionCapabilityList == null) {
- out.writeInt(0);
- } else {
- out.writeInt(connectionCapabilityList.size());
- for (IpProtoPort ip : connectionCapabilityList) {
- out.writeInt(ip.proto);
- out.writeInt(ip.port);
- out.writeInt(ip.status);
- }
- }
-
- if (osuProviderList == null) {
- out.writeInt(0);
- } else {
- out.writeInt(osuProviderList.size());
- for (WifiPasspointOsuProvider osu : osuProviderList)
- osu.writeToParcel(out, flags);
- }
- }
-
- /** Implement the Parcelable interface {@hide} */
- @Override
- public int describeContents() {
- return 0;
- }
-
- /** Implement the Parcelable interface {@hide} */
- public static final Parcelable.Creator<WifiPasspointInfo> CREATOR =
- new Parcelable.Creator<WifiPasspointInfo>() {
- @Override
- public WifiPasspointInfo createFromParcel(Parcel in) {
- WifiPasspointInfo p = new WifiPasspointInfo();
- int n;
-
- p.bssid = in.readString();
- p.venueName = in.readString();
-
- n = in.readInt();
- if (n > 0) {
- p.networkAuthTypeList = new ArrayList<NetworkAuthType>();
- for (int i = 0; i < n; i++) {
- NetworkAuthType auth = new NetworkAuthType();
- auth.type = in.readInt();
- auth.redirectUrl = in.readString();
- p.networkAuthTypeList.add(auth);
- }
- }
-
- n = in.readInt();
- if (n > 0) {
- p.roamingConsortiumList = new ArrayList<String>();
- for (int i = 0; i < n; i++)
- p.roamingConsortiumList.add(in.readString());
- }
-
- n = in.readInt();
- if (n != IpAddressType.NULL_VALUE) {
- p.ipAddrTypeAvailability = new IpAddressType();
- p.ipAddrTypeAvailability.availability = n;
- }
-
- n = in.readInt();
- if (n > 0) {
- p.naiRealmList = new ArrayList<NaiRealm>();
- for (int i = 0; i < n; i++) {
- NaiRealm realm = new NaiRealm();
- realm.encoding = in.readInt();
- realm.realm = in.readString();
- p.naiRealmList.add(realm);
- }
- }
-
- n = in.readInt();
- if (n > 0) {
- p.cellularNetworkList = new ArrayList<CellularNetwork>();
- for (int i = 0; i < n; i++) {
- CellularNetwork plmn = new CellularNetwork();
- plmn.mcc = in.readString();
- plmn.mnc = in.readString();
- p.cellularNetworkList.add(plmn);
- }
- }
-
- n = in.readInt();
- if (n > 0) {
- p.domainNameList = new ArrayList<String>();
- for (int i = 0; i < n; i++)
- p.domainNameList.add(in.readString());
- }
-
- p.operatorFriendlyName = in.readString();
-
- n = in.readInt();
- if (n > 0) {
- p.wanMetrics = new WanMetrics();
- p.wanMetrics.wanInfo = in.readInt();
- p.wanMetrics.downlinkSpeed = in.readLong();
- p.wanMetrics.uplinkSpeed = in.readLong();
- p.wanMetrics.downlinkLoad = in.readInt();
- p.wanMetrics.uplinkLoad = in.readInt();
- p.wanMetrics.lmd = in.readInt();
- }
-
- n = in.readInt();
- if (n > 0) {
- p.connectionCapabilityList = new ArrayList<IpProtoPort>();
- for (int i = 0; i < n; i++) {
- IpProtoPort ip = new IpProtoPort();
- ip.proto = in.readInt();
- ip.port = in.readInt();
- ip.status = in.readInt();
- p.connectionCapabilityList.add(ip);
- }
- }
-
- n = in.readInt();
- if (n > 0) {
- p.osuProviderList = new ArrayList<WifiPasspointOsuProvider>();
- for (int i = 0; i < n; i++) {
- WifiPasspointOsuProvider osu = WifiPasspointOsuProvider.CREATOR
- .createFromParcel(in);
- p.osuProviderList.add(osu);
- }
- }
-
- return p;
- }
-
- @Override
- public WifiPasspointInfo[] newArray(int size) {
- return new WifiPasspointInfo[size];
- }
- };
-}
diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointManager.java b/wifi/java/android/net/wifi/passpoint/WifiPasspointManager.java
deleted file mode 100644
index 0245a3d..0000000
--- a/wifi/java/android/net/wifi/passpoint/WifiPasspointManager.java
+++ /dev/null
@@ -1,567 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.wifi.passpoint;
-
-import android.content.Context;
-import android.net.wifi.ScanResult;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.os.Messenger;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.os.RemoteException;
-import android.util.Log;
-
-import com.android.internal.util.AsyncChannel;
-import com.android.internal.util.Protocol;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Provides APIs for managing Wifi Passpoint credentials.
- * @hide
- */
-public class WifiPasspointManager {
-
- private static final String TAG = "PasspointManager";
-
- private static final boolean DBG = true;
-
- /* Passpoint states values */
-
- /** Passpoint is in an unknown state. This should only occur in boot time */
- public static final int PASSPOINT_STATE_UNKNOWN = 0;
-
- /** Passpoint is disabled. This occurs when wifi is disabled */
- public static final int PASSPOINT_STATE_DISABLED = 1;
-
- /** Passpoint is enabled and in discovery state */
- public static final int PASSPOINT_STATE_DISCOVERY = 2;
-
- /** Passpoint is enabled and in access state */
- public static final int PASSPOINT_STATE_ACCESS = 3;
-
- /** Passpoint is enabled and in provisioning state */
- public static final int PASSPOINT_STATE_PROVISION = 4;
-
- /* Passpoint callback error codes */
-
- /** Indicates that the operation failed due to an internal error */
- public static final int REASON_ERROR = 0;
-
- /** Indicates that the operation failed because wifi is disabled */
- public static final int REASON_WIFI_DISABLED = 1;
-
- /** Indicates that the operation failed because the framework is busy */
- public static final int REASON_BUSY = 2;
-
- /** Indicates that the operation failed because parameter is invalid */
- public static final int REASON_INVALID_PARAMETER = 3;
-
- /** Indicates that the operation failed because the server is not trusted */
- public static final int REASON_NOT_TRUSTED = 4;
-
- /**
- * protocol supported for Passpoint
- */
- public static final String PROTOCOL_DM = "OMA-DM-ClientInitiated";
-
- /**
- * protocol supported for Passpoint
- */
- public static final String PROTOCOL_SOAP = "SPP-ClientInitiated";
-
- /* Passpoint broadcasts */
-
- /**
- * Broadcast intent action indicating that the state of Passpoint
- * connectivity has changed
- */
- public static final String PASSPOINT_STATE_CHANGED_ACTION =
- "android.net.wifi.passpoint.STATE_CHANGE";
-
- /**
- * Broadcast intent action indicating that the saved Passpoint credential
- * list has changed
- */
- public static final String PASSPOINT_CRED_CHANGED_ACTION =
- "android.net.wifi.passpoint.CRED_CHANGE";
-
- /**
- * Broadcast intent action indicating that Passpoint online sign up is
- * avaiable.
- */
- public static final String PASSPOINT_OSU_AVAILABLE_ACTION =
- "android.net.wifi.passpoint.OSU_AVAILABLE";
-
- /**
- * Broadcast intent action indicating that user remediation is required
- */
- public static final String PASSPOINT_USER_REM_REQ_ACTION =
- "android.net.wifi.passpoint.USER_REM_REQ";
-
- /**
- * Interface for callback invocation when framework channel is lost
- */
- public interface ChannelListener {
- /**
- * The channel to the framework has been disconnected. Application could
- * try re-initializing using {@link #initialize}
- */
- public void onChannelDisconnected();
- }
-
- /**
- * Interface for callback invocation on an application action
- */
- public interface ActionListener {
- /** The operation succeeded */
- public void onSuccess();
-
- /**
- * The operation failed
- *
- * @param reason The reason for failure could be one of
- * {@link #WIFI_DISABLED}, {@link #ERROR} or {@link #BUSY}
- */
- public void onFailure(int reason);
- }
-
- /**
- * Interface for callback invocation when doing OSU or user remediation
- */
- public interface OsuRemListener {
- /** The operation succeeded */
- public void onSuccess();
-
- /**
- * The operation failed
- *
- * @param reason The reason for failure could be one of
- * {@link #WIFI_DISABLED}, {@link #ERROR} or {@link #BUSY}
- */
- public void onFailure(int reason);
-
- /**
- * Browser launch is requried for user interaction. When this callback
- * is called, app should launch browser / webview to the given URI.
- *
- * @param uri URI for browser launch
- */
- public void onBrowserLaunch(String uri);
-
- /**
- * When this is called, app should dismiss the previously lanched browser.
- */
- public void onBrowserDismiss();
- }
-
- /**
- * A channel that connects the application to the wifi passpoint framework.
- * Most passpoint operations require a Channel as an argument.
- * An instance of Channel is obtained by doing a call on {@link #initialize}
- */
- public static class Channel {
- private final static int INVALID_LISTENER_KEY = 0;
-
- private ChannelListener mChannelListener;
-
- private HashMap<Integer, Object> mListenerMap = new HashMap<Integer, Object>();
- private HashMap<Integer, Integer> mListenerMapCount = new HashMap<Integer, Integer>();
- private Object mListenerMapLock = new Object();
- private int mListenerKey = 0;
-
- private List<ScanResult> mAnqpRequest = new LinkedList<ScanResult>();
- private Object mAnqpRequestLock = new Object();
-
- private AsyncChannel mAsyncChannel;
- private PasspointHandler mHandler;
- Context mContext;
-
- Channel(Context context, Looper looper, ChannelListener l) {
- mAsyncChannel = new AsyncChannel();
- mHandler = new PasspointHandler(looper);
- mChannelListener = l;
- mContext = context;
- }
-
- private int putListener(Object listener) {
- return putListener(listener, 1);
- }
-
- private int putListener(Object listener, int count) {
- if (listener == null || count <= 0)
- return INVALID_LISTENER_KEY;
- int key;
- synchronized (mListenerMapLock) {
- do {
- key = mListenerKey++;
- } while (key == INVALID_LISTENER_KEY);
- mListenerMap.put(key, listener);
- mListenerMapCount.put(key, count);
- }
- return key;
- }
-
- private Object peekListener(int key) {
- Log.d(TAG, "peekListener() key=" + key);
- if (key == INVALID_LISTENER_KEY)
- return null;
- synchronized (mListenerMapLock) {
- return mListenerMap.get(key);
- }
- }
-
-
- private Object getListener(int key, boolean forceRemove) {
- Log.d(TAG, "getListener() key=" + key + " force=" + forceRemove);
- if (key == INVALID_LISTENER_KEY)
- return null;
- synchronized (mListenerMapLock) {
- if (!forceRemove) {
- int count = mListenerMapCount.get(key);
- Log.d(TAG, "count=" + count);
- mListenerMapCount.put(key, --count);
- if (count > 0)
- return null;
- }
- Log.d(TAG, "remove key");
- mListenerMapCount.remove(key);
- return mListenerMap.remove(key);
- }
- }
-
- private void anqpRequestStart(ScanResult sr) {
- Log.d(TAG, "anqpRequestStart sr.bssid=" + sr.BSSID);
- synchronized (mAnqpRequestLock) {
- mAnqpRequest.add(sr);
- }
- }
-
- private void anqpRequestFinish(WifiPasspointInfo result) {
- Log.d(TAG, "anqpRequestFinish pi.bssid=" + result.bssid);
- synchronized (mAnqpRequestLock) {
- for (ScanResult sr : mAnqpRequest)
- if (sr.BSSID.equals(result.bssid)) {
- Log.d(TAG, "find hit " + result.bssid);
- /* sr.passpoint = result; */
- mAnqpRequest.remove(sr);
- Log.d(TAG, "mAnqpRequest.len=" + mAnqpRequest.size());
- break;
- }
- }
- }
-
- private void anqpRequestFinish(ScanResult sr) {
- Log.d(TAG, "anqpRequestFinish sr.bssid=" + sr.BSSID);
- synchronized (mAnqpRequestLock) {
- for (ScanResult sr1 : mAnqpRequest)
- if (sr1.BSSID.equals(sr.BSSID)) {
- mAnqpRequest.remove(sr1);
- break;
- }
- }
- }
-
- class PasspointHandler extends Handler {
- PasspointHandler(Looper looper) {
- super(looper);
- }
-
- @Override
- public void handleMessage(Message message) {
- Object listener = null;
-
- switch (message.what) {
- case AsyncChannel.CMD_CHANNEL_DISCONNECTED:
- if (mChannelListener != null) {
- mChannelListener.onChannelDisconnected();
- mChannelListener = null;
- }
- break;
-
- case REQUEST_ANQP_INFO_SUCCEEDED:
- WifiPasspointInfo result = (WifiPasspointInfo) message.obj;
- anqpRequestFinish(result);
- listener = getListener(message.arg2, false);
- if (listener != null) {
- ((ActionListener) listener).onSuccess();
- }
- break;
-
- case REQUEST_ANQP_INFO_FAILED:
- anqpRequestFinish((ScanResult) message.obj);
- listener = getListener(message.arg2, false);
- if (listener == null)
- getListener(message.arg2, true);
- if (listener != null) {
- ((ActionListener) listener).onFailure(message.arg1);
- }
- break;
-
- case START_OSU_SUCCEEDED:
- listener = getListener(message.arg2, true);
- if (listener != null) {
- ((OsuRemListener) listener).onSuccess();
- }
- break;
-
- case START_OSU_FAILED:
- listener = getListener(message.arg2, true);
- if (listener != null) {
- ((OsuRemListener) listener).onFailure(message.arg1);
- }
- break;
-
- case START_OSU_BROWSER:
- listener = peekListener(message.arg2);
- if (listener != null) {
- ParcelableString str = (ParcelableString) message.obj;
- if (str == null || str.string == null)
- ((OsuRemListener) listener).onBrowserDismiss();
- else
- ((OsuRemListener) listener).onBrowserLaunch(str.string);
- }
- break;
-
- default:
- Log.d(TAG, "Ignored " + message);
- break;
- }
- }
- }
-
- }
-
- public static class ParcelableString implements Parcelable {
- public String string;
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(string);
- }
-
- public static final Parcelable.Creator<ParcelableString> CREATOR =
- new Parcelable.Creator<ParcelableString>() {
- @Override
- public ParcelableString createFromParcel(Parcel in) {
- ParcelableString ret = new ParcelableString();
- ret.string = in.readString();
- return ret;
- }
- @Override
- public ParcelableString[] newArray(int size) {
- return new ParcelableString[size];
- }
- };
- }
-
- private static final int BASE = Protocol.BASE_WIFI_PASSPOINT_MANAGER;
-
- public static final int REQUEST_ANQP_INFO = BASE + 1;
- public static final int REQUEST_ANQP_INFO_FAILED = BASE + 2;
- public static final int REQUEST_ANQP_INFO_SUCCEEDED = BASE + 3;
- public static final int REQUEST_OSU_ICON = BASE + 4;
- public static final int REQUEST_OSU_ICON_FAILED = BASE + 5;
- public static final int REQUEST_OSU_ICON_SUCCEEDED = BASE + 6;
- public static final int START_OSU = BASE + 7;
- public static final int START_OSU_BROWSER = BASE + 8;
- public static final int START_OSU_FAILED = BASE + 9;
- public static final int START_OSU_SUCCEEDED = BASE + 10;
-
- private Context mContext;
- IWifiPasspointManager mService;
-
- /**
- * TODO: doc
- * @param context
- * @param service
- */
- public WifiPasspointManager(Context context, IWifiPasspointManager service) {
- mContext = context;
- mService = service;
- }
-
- /**
- * Registers the application with the framework. This function must be the
- * first to be called before any async passpoint operations are performed.
- *
- * @param srcContext is the context of the source
- * @param srcLooper is the Looper on which the callbacks are receivied
- * @param listener for callback at loss of framework communication. Can be
- * null.
- * @return Channel instance that is necessary for performing any further
- * passpoint operations
- *
- */
- public Channel initialize(Context srcContext, Looper srcLooper, ChannelListener listener) {
- Messenger messenger = getMessenger();
- if (messenger == null)
- return null;
-
- Channel c = new Channel(srcContext, srcLooper, listener);
- if (c.mAsyncChannel.connectSync(srcContext, c.mHandler, messenger)
- == AsyncChannel.STATUS_SUCCESSFUL) {
- return c;
- } else {
- return null;
- }
- }
-
- /**
- * STOPSHIP: temp solution, should use supplicant manager instead, check
- * with b/13931972
- */
- public Messenger getMessenger() {
- try {
- return mService.getMessenger();
- } catch (RemoteException e) {
- return null;
- }
- }
-
- public int getPasspointState() {
- try {
- return mService.getPasspointState();
- } catch (RemoteException e) {
- return PASSPOINT_STATE_UNKNOWN;
- }
- }
-
- public void requestAnqpInfo(Channel c, List<ScanResult> requested, int mask,
- ActionListener listener) {
- Log.d(TAG, "requestAnqpInfo start");
- Log.d(TAG, "requested.size=" + requested.size());
- checkChannel(c);
- List<ScanResult> list = new ArrayList<ScanResult>();
- for (ScanResult sr : requested)
- if (sr.capabilities.contains("[HS20]")) {
- list.add(sr);
- c.anqpRequestStart(sr);
- Log.d(TAG, "adding " + sr.BSSID);
- }
- int count = list.size();
- Log.d(TAG, "after filter, count=" + count);
- if (count == 0) {
- if (DBG)
- Log.d(TAG, "ANQP info request contains no HS20 APs, skipped");
- listener.onSuccess();
- return;
- }
- int key = c.putListener(listener, count);
- for (ScanResult sr : list)
- c.mAsyncChannel.sendMessage(REQUEST_ANQP_INFO, mask, key, sr);
- Log.d(TAG, "requestAnqpInfo end");
- }
-
- public void requestOsuIcons(Channel c, List<WifiPasspointOsuProvider> requested,
- int resolution, ActionListener listener) {
- }
-
- public List<WifiPasspointPolicy> requestCredentialMatch(List<ScanResult> requested) {
- try {
- return mService.requestCredentialMatch(requested);
- } catch (RemoteException e) {
- return null;
- }
- }
-
- /**
- * Get a list of saved Passpoint credentials. Only those credentials owned
- * by the caller will be returned.
- *
- * @return The list of credentials
- */
- public List<WifiPasspointCredential> getCredentials() {
- try {
- return mService.getCredentials();
- } catch (RemoteException e) {
- return null;
- }
- }
-
- /**
- * Add a new Passpoint credential.
- *
- * @param cred The credential to be added
- * @return {@code true} if the operation succeeds, {@code false} otherwise
- */
- public boolean addCredential(WifiPasspointCredential cred) {
- try {
- return mService.addCredential(cred);
- } catch (RemoteException e) {
- return false;
- }
- }
-
- /**
- * Update an existing Passpoint credential. Only system or the owner of this
- * credential has the permission to do this.
- *
- * @param cred The credential to be updated
- * @return {@code true} if the operation succeeds, {@code false} otherwise
- */
- public boolean updateCredential(WifiPasspointCredential cred) {
- try {
- return mService.updateCredential(cred);
- } catch (RemoteException e) {
- return false;
- }
- }
-
- /**
- * Remove an existing Passpoint credential. Only system or the owner of this
- * credential has the permission to do this.
- *
- * @param cred The credential to be removed
- * @return {@code true} if the operation succeeds, {@code false} otherwise
- */
- public boolean removeCredential(WifiPasspointCredential cred) {
- try {
- return mService.removeCredential(cred);
- } catch (RemoteException e) {
- return false;
- }
- }
-
- public void startOsu(Channel c, WifiPasspointOsuProvider osu, OsuRemListener listener) {
- Log.d(TAG, "startOsu start");
- checkChannel(c);
- int key = c.putListener(listener);
- c.mAsyncChannel.sendMessage(START_OSU, 0, key, osu);
- Log.d(TAG, "startOsu end");
- }
-
- public void startRemediation(Channel c, OsuRemListener listener) {
- }
-
- public void connect(WifiPasspointPolicy policy) {
- }
-
- private static void checkChannel(Channel c) {
- if (c == null) throw new IllegalArgumentException("Channel needs to be initialized");
- }
-}
diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointOsuProvider.aidl b/wifi/java/android/net/wifi/passpoint/WifiPasspointOsuProvider.aidl
deleted file mode 100644
index 088136f..0000000
--- a/wifi/java/android/net/wifi/passpoint/WifiPasspointOsuProvider.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Copyright (c) 2014, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.wifi.passpoint;
-
-parcelable WifiPasspointOsuProvider;
diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointOsuProvider.java b/wifi/java/android/net/wifi/passpoint/WifiPasspointOsuProvider.java
deleted file mode 100644
index b54b70c..0000000
--- a/wifi/java/android/net/wifi/passpoint/WifiPasspointOsuProvider.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.wifi.passpoint;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/** @hide */
-public class WifiPasspointOsuProvider implements Parcelable {
-
- /** TODO: doc
- * @hide
- */
- public static final int OSU_METHOD_UNKNOWN = -1;
-
- /** TODO: doc
- * @hide
- */
- public static final int OSU_METHOD_OMADM = 0;
-
- /** TODO: doc
- * @hide
- */
- public static final int OSU_METHOD_SOAP = 1;
-
- /** TODO: doc */
- public String ssid;
-
- /** TODO: doc */
- public String friendlyName;
-
- /** TODO: doc
- * @hide
- */
- public String serverUri;
-
- /** TODO: doc
- * @hide
- */
- public int osuMethod = OSU_METHOD_UNKNOWN;
-
- /** TODO: doc */
- public int iconWidth;
-
- /** TODO: doc */
- public int iconHeight;
-
- /** TODO: doc */
- public String iconType;
-
- /** TODO: doc */
- public String iconFileName;
-
- /** TODO: doc */
- public Object icon; // TODO: should change to image format
-
- /** TODO: doc */
- public String osuNai;
-
- /** TODO: doc */
- public String osuService;
-
- /** default constructor @hide */
- public WifiPasspointOsuProvider() {
- // TODO
- }
-
- /** copy constructor @hide */
- public WifiPasspointOsuProvider(WifiPasspointOsuProvider source) {
- // TODO
- }
-
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append("SSID: ").append("<").append(ssid).append(">");
- if (friendlyName != null)
- sb.append(" friendlyName: ").append("<").append(friendlyName).append(">");
- if (serverUri != null)
- sb.append(" serverUri: ").append("<").append(serverUri).append(">");
- sb.append(" osuMethod: ").append("<").append(osuMethod).append(">");
- if (iconFileName != null) {
- sb.append(" icon: <").append(iconWidth).append("x")
- .append(iconHeight).append(" ")
- .append(iconType).append(" ")
- .append(iconFileName).append(">");
- }
- if (osuNai != null)
- sb.append(" osuNai: ").append("<").append(osuNai).append(">");
- if (osuService != null)
- sb.append(" osuService: ").append("<").append(osuService).append(">");
- return sb.toString();
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- out.writeString(ssid);
- out.writeString(friendlyName);
- out.writeString(serverUri);
- out.writeInt(osuMethod);
- out.writeInt(iconWidth);
- out.writeInt(iconHeight);
- out.writeString(iconType);
- out.writeString(iconFileName);
- out.writeString(osuNai);
- out.writeString(osuService);
- // TODO: icon image?
- }
-
- public static final Parcelable.Creator<WifiPasspointOsuProvider> CREATOR =
- new Parcelable.Creator<WifiPasspointOsuProvider>() {
- @Override
- public WifiPasspointOsuProvider createFromParcel(Parcel in) {
- WifiPasspointOsuProvider osu = new WifiPasspointOsuProvider();
- osu.ssid = in.readString();
- osu.friendlyName = in.readString();
- osu.serverUri = in.readString();
- osu.osuMethod = in.readInt();
- osu.iconWidth = in.readInt();
- osu.iconHeight = in.readInt();
- osu.iconType = in.readString();
- osu.iconFileName = in.readString();
- osu.osuNai = in.readString();
- osu.osuService = in.readString();
- return osu;
- }
-
- @Override
- public WifiPasspointOsuProvider[] newArray(int size) {
- return new WifiPasspointOsuProvider[size];
- }
- };
-}
diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointPolicy.aidl b/wifi/java/android/net/wifi/passpoint/WifiPasspointPolicy.aidl
deleted file mode 100644
index 1d61da0..0000000
--- a/wifi/java/android/net/wifi/passpoint/WifiPasspointPolicy.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Copyright (c) 2014, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.wifi.passpoint;
-
-parcelable WifiPasspointPolicy;
diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointPolicy.java b/wifi/java/android/net/wifi/passpoint/WifiPasspointPolicy.java
deleted file mode 100644
index c08877e..0000000
--- a/wifi/java/android/net/wifi/passpoint/WifiPasspointPolicy.java
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.net.wifi.passpoint;
-
-import android.net.wifi.WifiConfiguration;
-import android.os.Parcelable;
-import android.os.Parcel;
-import android.security.Credentials;
-import android.util.Log;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-
-/** @hide */
-public class WifiPasspointPolicy implements Parcelable {
-
- private final static String TAG = "PasspointPolicy";
-
- /** @hide */
- public static final int HOME_SP = 0;
-
- /** @hide */
- public static final int ROAMING_PARTNER = 1;
-
- /** @hide */
- public static final int UNRESTRICTED = 2;
-
- private String mName;
- private int mCredentialPriority;
- private int mRoamingPriority;
- private String mBssid;
- private String mSsid;
- private WifiPasspointCredential mCredential;
- private int mRestriction;// Permitted values are "HomeSP", "RoamingPartner", or "Unrestricted"
- private boolean mIsHomeSp;
-
- private final String INT_PRIVATE_KEY = "private_key";
- private final String INT_PHASE2 = "phase2";
- private final String INT_PASSWORD = "password";
- private final String INT_IDENTITY = "identity";
- private final String INT_EAP = "eap";
- private final String INT_CLIENT_CERT = "client_cert";
- private final String INT_CA_CERT = "ca_cert";
- private final String INT_ANONYMOUS_IDENTITY = "anonymous_identity";
- private final String INT_SIM_SLOT = "sim_slot";
- private final String INT_ENTERPRISEFIELD_NAME ="android.net.wifi.WifiConfiguration$EnterpriseField";
- private final String ISO8601DATEFORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
- private final String ENTERPRISE_PHASE2_MSCHAPV2 = "auth=MSCHAPV2";
- private final String ENTERPRISE_PHASE2_MSCHAP = "auth=MSCHAP";
-
- /** @hide */
- public WifiPasspointPolicy(String name, String ssid,
- String bssid, WifiPasspointCredential pc,
- int restriction, boolean ishomesp) {
- mName = name;
- if (pc != null) {
- mCredentialPriority = pc.getPriority();
- }
- //PerProviderSubscription/<X+>/Policy/PreferredRoamingPartnerList/<X+>/Priority
- mRoamingPriority = 128; //default priority value of 128
- mSsid = ssid;
- mCredential = pc;
- mBssid = bssid;
- mRestriction = restriction;
- mIsHomeSp = ishomesp;
- }
-
- public String getSsid() {
- return mSsid;
- }
-
- /** @hide */
- public void setBssid(String bssid) {
- mBssid = bssid;
- }
-
- public String getBssid() {
- return mBssid;
- }
-
- /** @hide */
- public void setRestriction(int r) {
- mRestriction = r;
- }
-
- /** @hide */
- public int getRestriction() {
- return mRestriction;
- }
-
- /** @hide */
- public void setHomeSp(boolean b) {
- mIsHomeSp = b;
- }
-
- /** @hide */
- public boolean isHomeSp() {
- return mIsHomeSp;
- }
-
- /** @hide */
- public void setCredential(WifiPasspointCredential newCredential) {
- mCredential = newCredential;
- }
-
- public WifiPasspointCredential getCredential() {
- // TODO: return a copy
- return mCredential;
- }
-
- /** @hide */
- public void setCredentialPriority(int priority) {
- mCredentialPriority = priority;
- }
-
- /** @hide */
- public void setRoamingPriority(int priority) {
- mRoamingPriority = priority;
- }
-
- public int getCredentialPriority() {
- return mCredentialPriority;
- }
-
- public int getRoamingPriority() {
- return mRoamingPriority;
- }
-
- public WifiConfiguration createWifiConfiguration() {
- WifiConfiguration wfg = new WifiConfiguration();
- if (mBssid != null) {
- Log.d(TAG, "create bssid:" + mBssid);
- wfg.BSSID = mBssid;
- }
-
- if (mSsid != null) {
- Log.d(TAG, "create ssid:" + mSsid);
- wfg.SSID = mSsid;
- }
- //TODO: 1. add pmf configuration
- // 2. add ocsp configuration
- // 3. add eap-sim configuration
- /*Key management*/
- wfg.status = WifiConfiguration.Status.ENABLED;
- wfg.allowedKeyManagement.clear();
- wfg.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
- wfg.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X);
-
- /*Group Ciphers*/
- wfg.allowedGroupCiphers.clear();
- wfg.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
- wfg.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
-
- /*Protocols*/
- wfg.allowedProtocols.clear();
- wfg.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
- wfg.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
-
- Class[] enterpriseFieldArray = WifiConfiguration.class.getClasses();
- Class<?> enterpriseFieldClass = null;
-
-
- for(Class<?> myClass : enterpriseFieldArray) {
- if(myClass.getName().equals(INT_ENTERPRISEFIELD_NAME)) {
- enterpriseFieldClass = myClass;
- break;
- }
- }
- Log.d(TAG, "class chosen " + enterpriseFieldClass.getName() );
-
-
- Field anonymousId = null, caCert = null, clientCert = null,
- eap = null, identity = null, password = null,
- phase2 = null, privateKey = null;
-
- Field[] fields = WifiConfiguration.class.getFields();
-
-
- for (Field tempField : fields) {
- if (tempField.getName().trim().equals(INT_ANONYMOUS_IDENTITY)) {
- anonymousId = tempField;
- Log.d(TAG, "field " + anonymousId.getName() );
- } else if (tempField.getName().trim().equals(INT_CA_CERT)) {
- caCert = tempField;
- } else if (tempField.getName().trim().equals(INT_CLIENT_CERT)) {
- clientCert = tempField;
- Log.d(TAG, "field " + clientCert.getName() );
- } else if (tempField.getName().trim().equals(INT_EAP)) {
- eap = tempField;
- Log.d(TAG, "field " + eap.getName() );
- } else if (tempField.getName().trim().equals(INT_IDENTITY)) {
- identity = tempField;
- Log.d(TAG, "field " + identity.getName() );
- } else if (tempField.getName().trim().equals(INT_PASSWORD)) {
- password = tempField;
- Log.d(TAG, "field " + password.getName() );
- } else if (tempField.getName().trim().equals(INT_PHASE2)) {
- phase2 = tempField;
- Log.d(TAG, "field " + phase2.getName() );
-
- } else if (tempField.getName().trim().equals(INT_PRIVATE_KEY)) {
- privateKey = tempField;
- }
- }
-
-
- Method setValue = null;
-
- for(Method m: enterpriseFieldClass.getMethods()) {
- if(m.getName().trim().equals("setValue")) {
- Log.d(TAG, "method " + m.getName() );
- setValue = m;
- break;
- }
- }
-
- try {
- // EAP
- String eapmethod = mCredential.getType();
- Log.d(TAG, "eapmethod:" + eapmethod);
- setValue.invoke(eap.get(wfg), eapmethod);
-
- // Username, password, EAP Phase 2
- if ("TTLS".equals(eapmethod)) {
- setValue.invoke(phase2.get(wfg), ENTERPRISE_PHASE2_MSCHAPV2);
- setValue.invoke(identity.get(wfg), mCredential.getUserName());
- setValue.invoke(password.get(wfg), mCredential.getPassword());
- setValue.invoke(anonymousId.get(wfg), "anonymous@" + mCredential.getRealm());
- }
-
- // EAP CA Certificate
- String cacertificate = null;
- String rootCA = mCredential.getCaRootCertPath();
- if (rootCA == null){
- cacertificate = null;
- } else {
- cacertificate = "keystore://" + Credentials.WIFI + "HS20" + Credentials.CA_CERTIFICATE + rootCA;
- }
- Log.d(TAG, "cacertificate:" + cacertificate);
- setValue.invoke(caCert.get(wfg), cacertificate);
-
- //User certificate
- if ("TLS".equals(eapmethod)) {
- String usercertificate = null;
- String privatekey = null;
- String clientCertPath = mCredential.getClientCertPath();
- if (clientCertPath != null){
- privatekey = "keystore://" + Credentials.WIFI + "HS20" + Credentials.USER_PRIVATE_KEY + clientCertPath;
- usercertificate = "keystore://" + Credentials.WIFI + "HS20" + Credentials.USER_CERTIFICATE + clientCertPath;
- }
- Log.d(TAG, "privatekey:" + privatekey);
- Log.d(TAG, "usercertificate:" + usercertificate);
- if (privatekey != null && usercertificate != null) {
- setValue.invoke(privateKey.get(wfg), privatekey);
- setValue.invoke(clientCert.get(wfg), usercertificate);
- }
- }
- } catch (Exception e) {
- Log.d(TAG, "createWifiConfiguration err:" + e);
- }
-
- return wfg;
- }
-
- /** {@inheritDoc} @hide */
- public int compareTo(WifiPasspointPolicy another) {
- Log.d(TAG, "this:" + this);
- Log.d(TAG, "another:" + another);
-
- if (another == null) {
- return -1;
- } else if (this.mIsHomeSp == true && another.isHomeSp() == false) {
- //home sp priority is higher then roaming
- Log.d(TAG, "compare HomeSP first, this is HomeSP, another isn't");
- return -1;
- } else if ((this.mIsHomeSp == true && another.isHomeSp() == true)) {
- Log.d(TAG, "both HomeSP");
- //if both home sp, compare credential priority
- if (this.mCredentialPriority < another.getCredentialPriority()) {
- Log.d(TAG, "this priority is higher");
- return -1;
- } else if (this.mCredentialPriority == another.getCredentialPriority()) {
- Log.d(TAG, "both priorities equal");
- //if priority still the same, compare name(ssid)
- if (this.mName.compareTo(another.mName) != 0) {
- Log.d(TAG, "compare mName return:" + this.mName.compareTo(another.mName));
- return this.mName.compareTo(another.mName);
- }
- /**
- *if name still the same, compare credential
- *the device may has two more credentials(TLS,SIM..etc)
- *it can associate to one AP(same ssid). so we should compare by credential
- */
- if (this.mCredential != null && another.mCredential != null) {
- if (this.mCredential.compareTo(another.mCredential) != 0) {
- Log.d(TAG,
- "compare mCredential return:" + this.mName.compareTo(another.mName));
- return this.mCredential.compareTo(another.mCredential);
- }
- }
- } else {
- return 1;
- }
- } else if ((this.mIsHomeSp == false && another.isHomeSp() == false)) {
- Log.d(TAG, "both RoamingSp");
- //if both roaming sp, compare roaming priority(preferredRoamingPartnerList/<X+>/priority)
- if (this.mRoamingPriority < another.getRoamingPriority()) {
- Log.d(TAG, "this priority is higher");
- return -1;
- } else if (this.mRoamingPriority == another.getRoamingPriority()) {//priority equals, compare name
- Log.d(TAG, "both priorities equal");
- //if priority still the same, compare name(ssid)
- if (this.mName.compareTo(another.mName) != 0) {
- Log.d(TAG, "compare mName return:" + this.mName.compareTo(another.mName));
- return this.mName.compareTo(another.mName);
- }
- //if name still the same, compare credential
- if (this.mCredential != null && another.mCredential != null) {
- if (this.mCredential.compareTo(another.mCredential) != 0) {
- Log.d(TAG,
- "compare mCredential return:"
- + this.mCredential.compareTo(another.mCredential));
- return this.mCredential.compareTo(another.mCredential);
- }
- }
- } else {
- return 1;
- }
- }
-
- Log.d(TAG, "both policies equal");
- return 0;
- }
-
- @Override
- /** @hide */
- public String toString() {
- return "PasspointPolicy: name=" + mName + " CredentialPriority=" + mCredentialPriority +
- " mRoamingPriority" + mRoamingPriority +
- " ssid=" + mSsid + " restriction=" + mRestriction +
- " ishomesp=" + mIsHomeSp + " Credential=" + mCredential;
- }
-
- /** Implement the Parcelable interface {@hide} */
- @Override
- public int describeContents() {
- return 0;
- }
-
- /** Implement the Parcelable interface {@hide} */
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- // TODO
- }
-
- /** Implement the Parcelable interface {@hide} */
- public static final Creator<WifiPasspointPolicy> CREATOR =
- new Creator<WifiPasspointPolicy>() {
- @Override
- public WifiPasspointPolicy createFromParcel(Parcel in) {
- return null;
- }
-
- @Override
- public WifiPasspointPolicy[] newArray(int size) {
- return new WifiPasspointPolicy[size];
- }
- };
-}