summaryrefslogtreecommitdiffstats
path: root/wifi/java
diff options
context:
space:
mode:
authorYuhao Zheng <yuhaozheng@google.com>2014-06-12 16:58:23 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-06-12 03:30:50 +0000
commit0811cbee480524521750f43ac2a608cf84dba8aa (patch)
tree6f735afceb497a2f782d69264aa69798a1a5b3c7 /wifi/java
parent3e136626daa184a8191808343c95be9c7313448b (diff)
parentef9ef71a77f9d9c9822205362e23c6171538e68d (diff)
downloadframeworks_base-0811cbee480524521750f43ac2a608cf84dba8aa.zip
frameworks_base-0811cbee480524521750f43ac2a608cf84dba8aa.tar.gz
frameworks_base-0811cbee480524521750f43ac2a608cf84dba8aa.tar.bz2
Merge "Wifi passpoint - linking APIs"
Diffstat (limited to 'wifi/java')
-rw-r--r--wifi/java/android/net/wifi/passpoint/IWifiPasspointManager.aidl3
-rw-r--r--wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.java5
-rw-r--r--wifi/java/android/net/wifi/passpoint/WifiPasspointManager.java165
-rw-r--r--wifi/java/android/net/wifi/passpoint/WifiPasspointOsuProvider.java12
4 files changed, 112 insertions, 73 deletions
diff --git a/wifi/java/android/net/wifi/passpoint/IWifiPasspointManager.aidl b/wifi/java/android/net/wifi/passpoint/IWifiPasspointManager.aidl
index 8375d09..61c2b8a 100644
--- a/wifi/java/android/net/wifi/passpoint/IWifiPasspointManager.aidl
+++ b/wifi/java/android/net/wifi/passpoint/IWifiPasspointManager.aidl
@@ -16,6 +16,8 @@
package android.net.wifi.passpoint;
+import android.net.wifi.ScanResult;
+import android.net.wifi.passpoint.WifiPasspointPolicy;
import android.os.Messenger;
/**
@@ -27,5 +29,6 @@ interface IWifiPasspointManager
{
Messenger getMessenger();
int getPasspointState();
+ List<WifiPasspointPolicy> requestCredentialMatch(in List<ScanResult> requested);
}
diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.java b/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.java
index 8ab5c1e..aec87976 100644
--- a/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.java
+++ b/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.java
@@ -286,10 +286,11 @@ public class WifiPasspointInfo implements Parcelable {
public String toString() {
StringBuffer sb = new StringBuffer();
- sb.append("BSSID: ").append(bssid);
+ sb.append("BSSID: ").append("(").append(bssid).append(")");
if (venueName != null)
- sb.append(" venueName: ").append(venueName.replace("\n", "\\n"));
+ sb.append(" venueName: ").append("(")
+ .append(venueName.replace("\n", "\\n")).append(")");
if (networkAuthType != null) {
sb.append(" networkAuthType: ");
diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointManager.java b/wifi/java/android/net/wifi/passpoint/WifiPasspointManager.java
index 55acbad..2f158c2 100644
--- a/wifi/java/android/net/wifi/passpoint/WifiPasspointManager.java
+++ b/wifi/java/android/net/wifi/passpoint/WifiPasspointManager.java
@@ -22,6 +22,8 @@ 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;
@@ -45,58 +47,53 @@ public class WifiPasspointManager {
/* Passpoint states values */
- /** Passpoint is in an known state. This should only occur in boot time @hide */
+ /** 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. @hide */
+ /** Passpoint is disabled. This occurs when wifi is disabled */
public static final int PASSPOINT_STATE_DISABLED = 1;
- /** Passpoint is enabled and in discovery state. @hide */
+ /** Passpoint is enabled and in discovery state */
public static final int PASSPOINT_STATE_DISCOVERY = 2;
- /** Passpoint is enabled and in access state. @hide */
+ /** Passpoint is enabled and in access state */
public static final int PASSPOINT_STATE_ACCESS = 3;
- /** Passpoint is enabled and in provisioning state. @hide */
+ /** 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 @hide */
- public static final int ERROR = 0;
+ /** 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 @hide */
- public static final int WIFI_DISABLED = 1;
+ /** 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 @hide */
- public static final int BUSY = 2;
+ /** 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
- * @hide
*/
public static final String PROTOCOL_DM = "OMA-DM-ClientInitiated";
/**
* protocol supported for Passpoint
- * @hide
*/
public static final String PROTOCOL_SOAP = "SPP-ClientInitiated";
/* Passpoint broadcasts */
/**
- * Broadcast intent action indicating that Passpoint online sign up is
- * avaiable.
- * @hide
- */
- public static final String PASSPOINT_OSU_AVAILABLE =
- "android.net.wifi.passpoint.OSU_AVAILABLE";
-
- /**
* Broadcast intent action indicating that the state of Passpoint
* connectivity has changed
- * @hide
*/
public static final String PASSPOINT_STATE_CHANGED_ACTION =
"android.net.wifi.passpoint.STATE_CHANGE";
@@ -104,7 +101,6 @@ public class WifiPasspointManager {
/**
* Broadcast intent action indicating that the saved Passpoint credential
* list has changed
- * @hide
*/
public static final String PASSPOINT_CRED_CHANGED_ACTION =
"android.net.wifi.passpoint.CRED_CHANGE";
@@ -112,21 +108,18 @@ public class WifiPasspointManager {
/**
* Broadcast intent action indicating that Passpoint online sign up is
* avaiable.
- * @hide
*/
public static final String PASSPOINT_OSU_AVAILABLE_ACTION =
"android.net.wifi.passpoint.OSU_AVAILABLE";
/**
* Broadcast intent action indicating that user remediation is required
- * @hide
*/
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
- * @hide
*/
public interface ChannelListener {
/**
@@ -138,14 +131,13 @@ public class WifiPasspointManager {
/**
* Interface for callback invocation on an application action
- * @hide
*/
public interface ActionListener {
/** The operation succeeded */
public void onSuccess();
/**
- * * The operation failed
+ * The operation failed
*
* @param reason The reason for failure could be one of
* {@link #WIFI_DISABLED}, {@link #ERROR} or {@link #BUSY}
@@ -155,7 +147,6 @@ public class WifiPasspointManager {
/**
* Interface for callback invocation when doing OSU or user remediation
- * @hide
*/
public interface OsuRemListener {
/** The operation succeeded */
@@ -171,11 +162,11 @@ public class WifiPasspointManager {
/**
* Browser launch is requried for user interaction. When this callback
- * is called, app should launch browser / webview to the given URL.
+ * is called, app should launch browser / webview to the given URI.
*
- * @param url URL for browser launch
+ * @param uri URI for browser launch
*/
- public void onBrowserLaunch(String url);
+ public void onBrowserLaunch(String uri);
/**
* When this is called, app should dismiss the previously lanched browser.
@@ -187,7 +178,6 @@ public class WifiPasspointManager {
* 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}
- * @hide
*/
public static class Channel {
private final static int INVALID_LISTENER_KEY = 0;
@@ -288,7 +278,8 @@ public class WifiPasspointManager {
@Override
public void handleMessage(Message message) {
- Object listener = getListener(message.arg2, false);
+ Object listener = null;
+
switch (message.what) {
case AsyncChannel.CMD_CHANNEL_DISCONNECTED:
if (mChannelListener != null) {
@@ -300,6 +291,7 @@ public class WifiPasspointManager {
case REQUEST_ANQP_INFO_SUCCEEDED:
WifiPasspointInfo result = (WifiPasspointInfo) message.obj;
anqpRequestFinish(result);
+ listener = getListener(message.arg2, false);
if (listener != null) {
((ActionListener) listener).onSuccess();
}
@@ -307,6 +299,7 @@ public class WifiPasspointManager {
case REQUEST_ANQP_INFO_FAILED:
anqpRequestFinish((ScanResult) message.obj);
+ listener = getListener(message.arg2, false);
if (listener == null)
getListener(message.arg2, true);
if (listener != null) {
@@ -314,6 +307,31 @@ public class WifiPasspointManager {
}
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 = getListener(message.arg2, true);
+ if (listener != null) {
+ ParcelableString str = (ParcelableString) message.obj;
+ if (str.string == null)
+ ((OsuRemListener) listener).onBrowserDismiss();
+ else
+ ((OsuRemListener) listener).onBrowserLaunch(str.string);
+ }
+ break;
+
default:
Log.d(TAG, "Ignored " + message);
break;
@@ -323,25 +341,46 @@ public class WifiPasspointManager {
}
- private static final int BASE = Protocol.BASE_WIFI_PASSPOINT_MANAGER;
-
- /** @hide */
- public static final int REQUEST_ANQP_INFO = BASE + 1;
+ public static class ParcelableString implements Parcelable {
+ public String string;
- /** @hide */
- public static final int REQUEST_ANQP_INFO_FAILED = BASE + 2;
+ @Override
+ public int describeContents() {
+ return 0;
+ }
- /** @hide */
- public static final int REQUEST_ANQP_INFO_SUCCEEDED = BASE + 3;
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeString(string);
+ }
- /** @hide */
- public static final int REQUEST_OSU_INFO = BASE + 4;
+ 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];
+ }
+ };
+ }
- /** @hide */
- public static final int REQUEST_OSU_INFO_FAILED = BASE + 5;
+ private static final int BASE = Protocol.BASE_WIFI_PASSPOINT_MANAGER;
- /** @hide */
- public static final int REQUEST_OSU_INFO_SUCCEEDED = BASE + 6;
+ 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;
@@ -350,7 +389,6 @@ public class WifiPasspointManager {
* TODO: doc
* @param context
* @param service
- * @hide
*/
public WifiPasspointManager(Context context, IWifiPasspointManager service) {
mContext = context;
@@ -368,7 +406,6 @@ public class WifiPasspointManager {
* @return Channel instance that is necessary for performing any further
* passpoint operations
*
- * @hide
*/
public Channel initialize(Context srcContext, Looper srcLooper, ChannelListener listener) {
Messenger messenger = getMessenger();
@@ -387,8 +424,6 @@ public class WifiPasspointManager {
/**
* STOPSHIP: temp solution, should use supplicant manager instead, check
* with b/13931972
- *
- * @hide
*/
public Messenger getMessenger() {
try {
@@ -398,7 +433,6 @@ public class WifiPasspointManager {
}
}
- /** @hide */
public int getPasspointState() {
try {
return mService.getPasspointState();
@@ -407,7 +441,6 @@ public class WifiPasspointManager {
}
}
- /** @hide */
public void requestAnqpInfo(Channel c, List<ScanResult> requested, int mask,
ActionListener listener) {
Log.d(TAG, "requestAnqpInfo start");
@@ -434,14 +467,16 @@ public class WifiPasspointManager {
Log.d(TAG, "requestAnqpInfo end");
}
- /** @hide */
public void requestOsuIcons(Channel c, List<WifiPasspointOsuProvider> requested,
int resolution, ActionListener listener) {
}
- /** @hide */
public List<WifiPasspointPolicy> requestCredentialMatch(List<ScanResult> requested) {
- return null;
+ try {
+ return mService.requestCredentialMatch(requested);
+ } catch (RemoteException e) {
+ return null;
+ }
}
/**
@@ -486,21 +521,21 @@ public class WifiPasspointManager {
return true;
}
- /** @hide */
- public void startOsu(Channel c, WifiPasspointOsuProvider selected, OsuRemListener listener) {
-
+ 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");
}
- /** @hide */
public void startUserRemediation(Channel c, OsuRemListener listener) {
}
- /** @hide */
- public void connect(WifiPasspointPolicy selected) {
+ public void connect(WifiPasspointPolicy policy) {
}
private static void checkChannel(Channel c) {
- if (c == null)
- throw new IllegalArgumentException("Channel needs to be initialized");
+ if (c == null) throw new IllegalArgumentException("Channel needs to be initialized");
}
}
diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointOsuProvider.java b/wifi/java/android/net/wifi/passpoint/WifiPasspointOsuProvider.java
index f40dc4f..b54b70c 100644
--- a/wifi/java/android/net/wifi/passpoint/WifiPasspointOsuProvider.java
+++ b/wifi/java/android/net/wifi/passpoint/WifiPasspointOsuProvider.java
@@ -87,12 +87,12 @@ public class WifiPasspointOsuProvider implements Parcelable {
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
- sb.append("SSID: ").append(ssid);
+ sb.append("SSID: ").append("<").append(ssid).append(">");
if (friendlyName != null)
- sb.append(" friendlyName: ").append(friendlyName);
+ sb.append(" friendlyName: ").append("<").append(friendlyName).append(">");
if (serverUri != null)
- sb.append(" serverUri: ").append(serverUri);
- sb.append(" osuMethod: ").append(osuMethod);
+ 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(" ")
@@ -100,9 +100,9 @@ public class WifiPasspointOsuProvider implements Parcelable {
.append(iconFileName).append(">");
}
if (osuNai != null)
- sb.append(" osuNai: ").append(osuNai);
+ sb.append(" osuNai: ").append("<").append(osuNai).append(">");
if (osuService != null)
- sb.append(" osuService: ").append(osuService);
+ sb.append(" osuService: ").append("<").append(osuService).append(">");
return sb.toString();
}