コード例 #1
0
  public int compareTo(AccessPointState other) {
    // This ranks the states for displaying in the AP list, not for
    // connecting to (wpa_supplicant does that using the WifiConfiguration's
    // priority field).

    // Clarity > efficiency, of this logic:
    int comparison;

    // Primary
    comparison = (other.primary ? 1 : 0) - (primary ? 1 : 0);
    if (comparison != 0) return comparison;

    // Currently seen (similar to, but not always the same as within range)
    comparison = (other.seen ? 1 : 0) - (seen ? 1 : 0);
    if (comparison != 0) return comparison;

    // Configured
    comparison = (other.configured ? 1 : 0) - (configured ? 1 : 0);
    if (comparison != 0) return comparison;

    if (!configured) {
      // Neither are configured

      // Open network
      comparison = (hasSecurity() ? 1 : 0) - (other.hasSecurity() ? 1 : 0);
      if (comparison != 0) return comparison;
    }

    // Signal strength
    comparison = (int) (other.signalForSorting - signalForSorting);
    if (comparison != 0) return comparison;

    // Alphabetical
    return ssid.compareToIgnoreCase(other.ssid);
  }
コード例 #2
0
 public AccessPointState createFromParcel(Parcel in) {
   AccessPointState state = new AccessPointState();
   state.bssid = in.readString();
   state.configured = in.readInt() == 1;
   state.ipAddress = in.readInt();
   state.linkSpeed = in.readInt();
   state.networkId = in.readInt();
   state.primary = in.readInt() == 1;
   state.priority = in.readInt();
   state.hiddenSsid = in.readInt() == 1;
   state.security = in.readString();
   state.seen = in.readInt() == 1;
   state.disabled = in.readInt() == 1;
   state.signal = in.readInt();
   state.ssid = in.readString();
   String statusStr = in.readString();
   if (statusStr != null) {
     state.status = NetworkInfo.DetailedState.valueOf(statusStr);
   }
   state.mPassword = in.readString();
   state.mConfigHadPassword = in.readInt() == 1;
   state.mWepPasswordType = in.readInt();
   return state;
 }