2323
2424/**
2525 * Describes the current global state of Wifi display connectivity, including the
26- * currently connected display and all known displays.
26+ * currently connected display and all available or remembered displays.
2727 * <p>
2828 * This object is immutable.
2929 * </p>
3030 *
3131 * @hide
3232 */
3333public final class WifiDisplayStatus implements Parcelable {
34- private final boolean mEnabled ;
34+ private final int mFeatureState ;
3535 private final int mScanState ;
3636 private final int mActiveDisplayState ;
3737 private final WifiDisplay mActiveDisplay ;
38- private final WifiDisplay [] mKnownDisplays ;
39-
38+ private final WifiDisplay [] mAvailableDisplays ;
39+ private final WifiDisplay [] mRememberedDisplays ;
40+
41+ /** Feature state: Wifi display is not available on this device. */
42+ public static final int FEATURE_STATE_UNAVAILABLE = 0 ;
43+ /** Feature state: Wifi display is disabled, probably because Wifi is disabled. */
44+ public static final int FEATURE_STATE_DISABLED = 1 ;
45+ /** Feature state: Wifi display is turned off in settings. */
46+ public static final int FEATURE_STATE_OFF = 2 ;
47+ /** Feature state: Wifi display is turned on in settings. */
48+ public static final int FEATURE_STATE_ON = 3 ;
49+
50+ /** Scan state: Not currently scanning. */
4051 public static final int SCAN_STATE_NOT_SCANNING = 0 ;
52+ /** Scan state: Currently scanning. */
4153 public static final int SCAN_STATE_SCANNING = 1 ;
4254
55+ /** Display state: Not connected. */
4356 public static final int DISPLAY_STATE_NOT_CONNECTED = 0 ;
57+ /** Display state: Connecting to active display. */
4458 public static final int DISPLAY_STATE_CONNECTING = 1 ;
59+ /** Display state: Connected to active display. */
4560 public static final int DISPLAY_STATE_CONNECTED = 2 ;
4661
4762 public static final Creator <WifiDisplayStatus > CREATOR = new Creator <WifiDisplayStatus >() {
4863 public WifiDisplayStatus createFromParcel (Parcel in ) {
49- boolean enabled = ( in .readInt () != 0 );
64+ int featureState = in .readInt ();
5065 int scanState = in .readInt ();
5166 int activeDisplayState = in .readInt ();
5267
@@ -55,13 +70,18 @@ public WifiDisplayStatus createFromParcel(Parcel in) {
5570 activeDisplay = WifiDisplay .CREATOR .createFromParcel (in );
5671 }
5772
58- WifiDisplay [] knownDisplays = WifiDisplay .CREATOR .newArray (in .readInt ());
59- for (int i = 0 ; i < knownDisplays .length ; i ++) {
60- knownDisplays [i ] = WifiDisplay .CREATOR .createFromParcel (in );
73+ WifiDisplay [] availableDisplays = WifiDisplay .CREATOR .newArray (in .readInt ());
74+ for (int i = 0 ; i < availableDisplays .length ; i ++) {
75+ availableDisplays [i ] = WifiDisplay .CREATOR .createFromParcel (in );
76+ }
77+
78+ WifiDisplay [] rememberedDisplays = WifiDisplay .CREATOR .newArray (in .readInt ());
79+ for (int i = 0 ; i < rememberedDisplays .length ; i ++) {
80+ rememberedDisplays [i ] = WifiDisplay .CREATOR .createFromParcel (in );
6181 }
6282
63- return new WifiDisplayStatus (enabled , scanState , activeDisplayState ,
64- activeDisplay , knownDisplays );
83+ return new WifiDisplayStatus (featureState , scanState , activeDisplayState ,
84+ activeDisplay , availableDisplays , rememberedDisplays );
6585 }
6686
6787 public WifiDisplayStatus [] newArray (int size ) {
@@ -70,33 +90,38 @@ public WifiDisplayStatus[] newArray(int size) {
7090 };
7191
7292 public WifiDisplayStatus () {
73- this (false , SCAN_STATE_NOT_SCANNING , DISPLAY_STATE_NOT_CONNECTED ,
74- null , WifiDisplay .EMPTY_ARRAY );
93+ this (FEATURE_STATE_UNAVAILABLE , SCAN_STATE_NOT_SCANNING , DISPLAY_STATE_NOT_CONNECTED ,
94+ null , WifiDisplay .EMPTY_ARRAY , WifiDisplay . EMPTY_ARRAY );
7595 }
7696
77- public WifiDisplayStatus (boolean enabled , int scanState , int activeDisplayState ,
78- WifiDisplay activeDisplay , WifiDisplay [] knownDisplays ) {
79- if (knownDisplays == null ) {
80- throw new IllegalArgumentException ("knownDisplays must not be null" );
97+ public WifiDisplayStatus (int featureState , int scanState ,
98+ int activeDisplayState , WifiDisplay activeDisplay ,
99+ WifiDisplay [] availableDisplays , WifiDisplay [] rememberedDisplays ) {
100+ if (availableDisplays == null ) {
101+ throw new IllegalArgumentException ("availableDisplays must not be null" );
102+ }
103+ if (rememberedDisplays == null ) {
104+ throw new IllegalArgumentException ("rememberedDisplays must not be null" );
81105 }
82106
83- mEnabled = enabled ;
107+ mFeatureState = featureState ;
84108 mScanState = scanState ;
85109 mActiveDisplayState = activeDisplayState ;
86110 mActiveDisplay = activeDisplay ;
87- mKnownDisplays = knownDisplays ;
111+ mAvailableDisplays = availableDisplays ;
112+ mRememberedDisplays = rememberedDisplays ;
88113 }
89114
90115 /**
91- * Returns true if the Wifi display feature is enabled and available for use .
116+ * Returns the state of the Wifi display feature on this device .
92117 * <p>
93- * The value of this property reflects whether Wifi and Wifi P2P functions
94- * are enabled. Enablement is not directly controllable by the user at this
95- * time, except indirectly such as by turning off Wifi altogether .
118+ * The value of this property reflects whether the device supports the Wifi display,
119+ * whether it has been enabled by the user and whether the prerequisites for
120+ * connecting to displays have been met .
96121 * </p>
97122 */
98- public boolean isEnabled () {
99- return mEnabled ;
123+ public int getFeatureState () {
124+ return mFeatureState ;
100125 }
101126
102127 /**
@@ -127,15 +152,29 @@ public WifiDisplay getActiveDisplay() {
127152 }
128153
129154 /**
130- * Gets the list of all known Wifi displays, never null.
155+ * Gets the list of all available Wifi displays as reported by the most recent
156+ * scan, never null.
157+ * <p>
158+ * Some of these displays may already be remembered, others may be unknown.
159+ * </p>
131160 */
132- public WifiDisplay [] getKnownDisplays () {
133- return mKnownDisplays ;
161+ public WifiDisplay [] getAvailableDisplays () {
162+ return mAvailableDisplays ;
163+ }
164+
165+ /**
166+ * Gets the list of all remembered Wifi displays, never null.
167+ * <p>
168+ * Not all remembered displays will necessarily be available.
169+ * </p>
170+ */
171+ public WifiDisplay [] getRememberedDisplays () {
172+ return mRememberedDisplays ;
134173 }
135174
136175 @ Override
137176 public void writeToParcel (Parcel dest , int flags ) {
138- dest .writeInt (mEnabled ? 1 : 0 );
177+ dest .writeInt (mFeatureState );
139178 dest .writeInt (mScanState );
140179 dest .writeInt (mActiveDisplayState );
141180
@@ -146,8 +185,13 @@ public void writeToParcel(Parcel dest, int flags) {
146185 dest .writeInt (0 );
147186 }
148187
149- dest .writeInt (mKnownDisplays .length );
150- for (WifiDisplay display : mKnownDisplays ) {
188+ dest .writeInt (mAvailableDisplays .length );
189+ for (WifiDisplay display : mAvailableDisplays ) {
190+ display .writeToParcel (dest , flags );
191+ }
192+
193+ dest .writeInt (mRememberedDisplays .length );
194+ for (WifiDisplay display : mRememberedDisplays ) {
151195 display .writeToParcel (dest , flags );
152196 }
153197 }
@@ -160,11 +204,12 @@ public int describeContents() {
160204 // For debugging purposes only.
161205 @ Override
162206 public String toString () {
163- return "WifiDisplayStatus{enabled =" + mEnabled
207+ return "WifiDisplayStatus{featureState =" + mFeatureState
164208 + ", scanState=" + mScanState
165209 + ", activeDisplayState=" + mActiveDisplayState
166210 + ", activeDisplay=" + mActiveDisplay
167- + ", knownDisplays=" + Arrays .toString (mKnownDisplays )
211+ + ", availableDisplays=" + Arrays .toString (mAvailableDisplays )
212+ + ", rememberedDisplays=" + Arrays .toString (mRememberedDisplays )
168213 + "}" ;
169214 }
170215}
0 commit comments