public class RssiCurve extends Object implements Parcelable
For each RSSI bucket, the score may be any byte. Scores have no absolute meaning and are only
considered relative to other scores assigned by the same scorer. Networks with no score are
treated equivalently to a network with score Byte.MIN_VALUE
, and will not be used.
For example, consider a curve starting at -110 dBm with a bucket width of 10 and the
following buckets: [-20, -10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]
.
This represents a linear curve between -110 dBm and 30 dBm. It scores progressively higher at
stronger signal strengths.
A network can be assigned a fixed score independent of RSSI by setting
rssiBuckets
to a one-byte array whose element is the fixed score. start
should be set to the lowest RSSI value at which this fixed score should apply, and
bucketWidth
should be set such that start + bucketWidth
is equal to the
highest RSSI value at which this fixed score should apply.
Note that RSSI values below -110 dBm or above 30 dBm are unlikely to cause any difference in connectivity behavior from those endpoints. That is, the connectivity framework will treat a network with a -120 dBm signal exactly as it would treat one with a -110 dBm signal. Therefore, graphs which specify scores outside this range may be truncated to this range by the system.
ScoredNetwork
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
int |
activeNetworkRssiBoost
The RSSI boost to give this network when active, in dBm.
|
int |
bucketWidth
The width of each RSSI bucket, in dBm.
|
static Parcelable.Creator<RssiCurve> |
CREATOR |
byte[] |
rssiBuckets
The score for each RSSI bucket.
|
int |
start
The starting dBm of the curve.
|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
RssiCurve(int start,
int bucketWidth,
byte[] rssiBuckets)
Construct a new
RssiCurve . |
RssiCurve(int start,
int bucketWidth,
byte[] rssiBuckets,
int activeNetworkRssiBoost)
Construct a new
RssiCurve . |
Modifier and Type | Method and Description |
---|---|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.
|
boolean |
equals(Object o)
Determine if two RSSI curves are defined in the same way.
|
int |
hashCode()
Returns a hash code value for the object.
|
byte |
lookupScore(int rssi)
Lookup the score for a given RSSI value.
|
byte |
lookupScore(int rssi,
boolean isActiveNetwork)
Lookup the score for a given RSSI value.
|
String |
toString()
Returns a string representation of the object.
|
void |
writeToParcel(Parcel out,
int flags)
Flatten this object in to a Parcel.
|
public final int start
public final int bucketWidth
public final byte[] rssiBuckets
public final int activeNetworkRssiBoost
When the system is connected to this network, it will pretend that the network has this much higher of an RSSI. This is to avoid switching networks when another network has only a slightly higher score.
public static final Parcelable.Creator<RssiCurve> CREATOR
public RssiCurve(int start, int bucketWidth, byte[] rssiBuckets)
RssiCurve
.start
- the starting dBm of the curve.bucketWidth
- the width of each RSSI bucket, in dBm.rssiBuckets
- the score for each RSSI bucket.public RssiCurve(int start, int bucketWidth, byte[] rssiBuckets, int activeNetworkRssiBoost)
RssiCurve
.start
- the starting dBm of the curve.bucketWidth
- the width of each RSSI bucket, in dBm.rssiBuckets
- the score for each RSSI bucket.activeNetworkRssiBoost
- the RSSI boost to apply when this network is active, in dBm.public int describeContents()
Parcelable
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel out, int flags)
Parcelable
writeToParcel
in interface Parcelable
out
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.public byte lookupScore(int rssi)
rssi
- The RSSI to lookup. If the RSSI falls below the start of the curve, the score at
the start of the curve will be returned. If it falls after the end of the curve, the
score at the end of the curve will be returned.public byte lookupScore(int rssi, boolean isActiveNetwork)
rssi
- The RSSI to lookup. If the RSSI falls below the start of the curve, the score at
the start of the curve will be returned. If it falls after the end of the curve, the
score at the end of the curve will be returned.isActiveNetwork
- Whether this network is currently active.public boolean equals(Object o)
Note that two curves can be equivalent but defined differently, e.g. if one bucket in one curve is split into two buckets in another. For the purpose of this method, these curves are not considered equal to each other.
equals
in class Object
o
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.Object.hashCode()
,
HashMap
public int hashCode()
Object
HashMap
.
The general contract of hashCode
is:
hashCode
method
must consistently return the same integer, provided no information
used in equals
comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode
method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode
method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object
does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
JavaTM programming language.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())