diff options
author | Jeff Brown <jeffbrown@google.com> | 2012-09-08 23:15:00 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2012-09-08 23:15:00 -0700 |
commit | 180bbc71810496e280e9993177bfeddb3ad1f558 (patch) | |
tree | 62a8223a7236beebb5857ac180c08dbaa270e1a9 /core/java/android/hardware | |
parent | 8e810132315ba6ce2e1f3dca5e91fd34e42a44d8 (diff) | |
download | frameworks_base-180bbc71810496e280e9993177bfeddb3ad1f558.zip frameworks_base-180bbc71810496e280e9993177bfeddb3ad1f558.tar.gz frameworks_base-180bbc71810496e280e9993177bfeddb3ad1f558.tar.bz2 |
Improve Wifi display discovery API.
Change-Id: I4d46503e5413f52da16f79bbc9c631cc5ae9c178
Diffstat (limited to 'core/java/android/hardware')
-rw-r--r-- | core/java/android/hardware/display/WifiDisplayStatus.java | 85 |
1 files changed, 48 insertions, 37 deletions
diff --git a/core/java/android/hardware/display/WifiDisplayStatus.java b/core/java/android/hardware/display/WifiDisplayStatus.java index 542d1b3..d5fe45d 100644 --- a/core/java/android/hardware/display/WifiDisplayStatus.java +++ b/core/java/android/hardware/display/WifiDisplayStatus.java @@ -32,18 +32,27 @@ import java.util.Arrays; */ public final class WifiDisplayStatus implements Parcelable { private final boolean mEnabled; - private final WifiDisplay mConnectedDisplay; + private final int mScanState; + private final int mActiveDisplayState; + private final WifiDisplay mActiveDisplay; private final WifiDisplay[] mKnownDisplays; - private final boolean mScanInProgress; - private final boolean mConnectionInProgress; + + public static final int SCAN_STATE_NOT_SCANNING = 0; + public static final int SCAN_STATE_SCANNING = 1; + + public static final int DISPLAY_STATE_NOT_CONNECTED = 0; + public static final int DISPLAY_STATE_CONNECTING = 1; + public static final int DISPLAY_STATE_CONNECTED = 2; public static final Creator<WifiDisplayStatus> CREATOR = new Creator<WifiDisplayStatus>() { public WifiDisplayStatus createFromParcel(Parcel in) { boolean enabled = (in.readInt() != 0); + int scanState = in.readInt(); + int activeDisplayState= in.readInt(); - WifiDisplay connectedDisplay = null; + WifiDisplay activeDisplay = null; if (in.readInt() != 0) { - connectedDisplay = WifiDisplay.CREATOR.createFromParcel(in); + activeDisplay = WifiDisplay.CREATOR.createFromParcel(in); } WifiDisplay[] knownDisplays = WifiDisplay.CREATOR.newArray(in.readInt()); @@ -51,11 +60,8 @@ public final class WifiDisplayStatus implements Parcelable { knownDisplays[i] = WifiDisplay.CREATOR.createFromParcel(in); } - boolean scanInProgress = (in.readInt() != 0); - boolean connectionInProgress = (in.readInt() != 0); - - return new WifiDisplayStatus(enabled, connectedDisplay, knownDisplays, - scanInProgress, connectionInProgress); + return new WifiDisplayStatus(enabled, scanState, activeDisplayState, + activeDisplay, knownDisplays); } public WifiDisplayStatus[] newArray(int size) { @@ -64,21 +70,21 @@ public final class WifiDisplayStatus implements Parcelable { }; public WifiDisplayStatus() { - this(false, null, WifiDisplay.EMPTY_ARRAY, false, false); + this(false, SCAN_STATE_NOT_SCANNING, DISPLAY_STATE_NOT_CONNECTED, + null, WifiDisplay.EMPTY_ARRAY); } - public WifiDisplayStatus(boolean enabled, - WifiDisplay connectedDisplay, WifiDisplay[] knownDisplays, - boolean scanInProgress, boolean connectionInProgress) { + public WifiDisplayStatus(boolean enabled, int scanState, int activeDisplayState, + WifiDisplay activeDisplay, WifiDisplay[] knownDisplays) { if (knownDisplays == null) { throw new IllegalArgumentException("knownDisplays must not be null"); } mEnabled = enabled; - mConnectedDisplay = connectedDisplay; + mScanState = scanState; + mActiveDisplayState = activeDisplayState; + mActiveDisplay = activeDisplay; mKnownDisplays = knownDisplays; - mScanInProgress = scanInProgress; - mConnectionInProgress = connectionInProgress; } /** @@ -94,40 +100,48 @@ public final class WifiDisplayStatus implements Parcelable { } /** - * Gets the currently connected Wifi display or null if none. + * Returns the current state of the Wifi display scan. + * + * @return One of: {@link #SCAN_STATE_NOT_SCANNING} or {@link #SCAN_STATE_SCANNING}. */ - public WifiDisplay getConnectedDisplay() { - return mConnectedDisplay; + public int getScanState() { + return mScanState; } /** - * Gets the list of all known Wifi displays, never null. + * Get the state of the currently active display. + * + * @return One of: {@link #DISPLAY_STATE_NOT_CONNECTED}, {@link #DISPLAY_STATE_CONNECTING}, + * or {@link #DISPLAY_STATE_CONNECTED}. */ - public WifiDisplay[] getKnownDisplays() { - return mKnownDisplays; + public int getActiveDisplayState() { + return mActiveDisplayState; } /** - * Returns true if there is currently a Wifi display scan in progress. + * Gets the Wifi display that is currently active. It may be connecting or + * connected. */ - public boolean isScanInProgress() { - return mScanInProgress; + public WifiDisplay getActiveDisplay() { + return mActiveDisplay; } /** - * Returns true if there is currently a Wifi display connection in progress. + * Gets the list of all known Wifi displays, never null. */ - public boolean isConnectionInProgress() { - return mConnectionInProgress; + public WifiDisplay[] getKnownDisplays() { + return mKnownDisplays; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mEnabled ? 1 : 0); + dest.writeInt(mScanState); + dest.writeInt(mActiveDisplayState); - if (mConnectedDisplay != null) { + if (mActiveDisplay != null) { dest.writeInt(1); - mConnectedDisplay.writeToParcel(dest, flags); + mActiveDisplay.writeToParcel(dest, flags); } else { dest.writeInt(0); } @@ -136,9 +150,6 @@ public final class WifiDisplayStatus implements Parcelable { for (WifiDisplay display : mKnownDisplays) { display.writeToParcel(dest, flags); } - - dest.writeInt(mScanInProgress ? 1 : 0); - dest.writeInt(mConnectionInProgress ? 1 : 0); } @Override @@ -150,10 +161,10 @@ public final class WifiDisplayStatus implements Parcelable { @Override public String toString() { return "WifiDisplayStatus{enabled=" + mEnabled - + ", connectedDisplay=" + mConnectedDisplay + + ", scanState=" + mScanState + + ", activeDisplayState=" + mActiveDisplayState + + ", activeDisplay=" + mActiveDisplay + ", knownDisplays=" + Arrays.toString(mKnownDisplays) - + ", scanInProgress=" + mScanInProgress - + ", connectionInProgress=" + mConnectionInProgress + "}"; } } |