Merge "Add setScannable to AdvertisingSetParameters (1/2)"
am: 7f14b8f095
Change-Id: I26846383be5c0fe88501ffd1011b27f39896a74a
This commit is contained in:
@@ -7544,6 +7544,7 @@ package android.bluetooth.le {
|
|||||||
method public boolean isAnonymous();
|
method public boolean isAnonymous();
|
||||||
method public boolean isConnectable();
|
method public boolean isConnectable();
|
||||||
method public boolean isLegacy();
|
method public boolean isLegacy();
|
||||||
|
method public boolean isScannable();
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
method public void writeToParcel(android.os.Parcel, int);
|
||||||
field public static final android.os.Parcelable.Creator<android.bluetooth.le.AdvertisingSetParameters> CREATOR;
|
field public static final android.os.Parcelable.Creator<android.bluetooth.le.AdvertisingSetParameters> CREATOR;
|
||||||
field public static final int INTERVAL_HIGH = 160; // 0xa0
|
field public static final int INTERVAL_HIGH = 160; // 0xa0
|
||||||
@@ -7571,6 +7572,7 @@ package android.bluetooth.le {
|
|||||||
method public android.bluetooth.le.AdvertisingSetParameters.Builder setInterval(int);
|
method public android.bluetooth.le.AdvertisingSetParameters.Builder setInterval(int);
|
||||||
method public android.bluetooth.le.AdvertisingSetParameters.Builder setLegacyMode(boolean);
|
method public android.bluetooth.le.AdvertisingSetParameters.Builder setLegacyMode(boolean);
|
||||||
method public android.bluetooth.le.AdvertisingSetParameters.Builder setPrimaryPhy(int);
|
method public android.bluetooth.le.AdvertisingSetParameters.Builder setPrimaryPhy(int);
|
||||||
|
method public android.bluetooth.le.AdvertisingSetParameters.Builder setScannable(boolean);
|
||||||
method public android.bluetooth.le.AdvertisingSetParameters.Builder setSecondaryPhy(int);
|
method public android.bluetooth.le.AdvertisingSetParameters.Builder setSecondaryPhy(int);
|
||||||
method public android.bluetooth.le.AdvertisingSetParameters.Builder setTxPowerLevel(int);
|
method public android.bluetooth.le.AdvertisingSetParameters.Builder setTxPowerLevel(int);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7848,6 +7848,7 @@ package android.bluetooth.le {
|
|||||||
method public boolean isAnonymous();
|
method public boolean isAnonymous();
|
||||||
method public boolean isConnectable();
|
method public boolean isConnectable();
|
||||||
method public boolean isLegacy();
|
method public boolean isLegacy();
|
||||||
|
method public boolean isScannable();
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
method public void writeToParcel(android.os.Parcel, int);
|
||||||
field public static final android.os.Parcelable.Creator<android.bluetooth.le.AdvertisingSetParameters> CREATOR;
|
field public static final android.os.Parcelable.Creator<android.bluetooth.le.AdvertisingSetParameters> CREATOR;
|
||||||
field public static final int INTERVAL_HIGH = 160; // 0xa0
|
field public static final int INTERVAL_HIGH = 160; // 0xa0
|
||||||
@@ -7875,6 +7876,7 @@ package android.bluetooth.le {
|
|||||||
method public android.bluetooth.le.AdvertisingSetParameters.Builder setInterval(int);
|
method public android.bluetooth.le.AdvertisingSetParameters.Builder setInterval(int);
|
||||||
method public android.bluetooth.le.AdvertisingSetParameters.Builder setLegacyMode(boolean);
|
method public android.bluetooth.le.AdvertisingSetParameters.Builder setLegacyMode(boolean);
|
||||||
method public android.bluetooth.le.AdvertisingSetParameters.Builder setPrimaryPhy(int);
|
method public android.bluetooth.le.AdvertisingSetParameters.Builder setPrimaryPhy(int);
|
||||||
|
method public android.bluetooth.le.AdvertisingSetParameters.Builder setScannable(boolean);
|
||||||
method public android.bluetooth.le.AdvertisingSetParameters.Builder setSecondaryPhy(int);
|
method public android.bluetooth.le.AdvertisingSetParameters.Builder setSecondaryPhy(int);
|
||||||
method public android.bluetooth.le.AdvertisingSetParameters.Builder setTxPowerLevel(int);
|
method public android.bluetooth.le.AdvertisingSetParameters.Builder setTxPowerLevel(int);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7553,6 +7553,7 @@ package android.bluetooth.le {
|
|||||||
method public boolean isAnonymous();
|
method public boolean isAnonymous();
|
||||||
method public boolean isConnectable();
|
method public boolean isConnectable();
|
||||||
method public boolean isLegacy();
|
method public boolean isLegacy();
|
||||||
|
method public boolean isScannable();
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
method public void writeToParcel(android.os.Parcel, int);
|
||||||
field public static final android.os.Parcelable.Creator<android.bluetooth.le.AdvertisingSetParameters> CREATOR;
|
field public static final android.os.Parcelable.Creator<android.bluetooth.le.AdvertisingSetParameters> CREATOR;
|
||||||
field public static final int INTERVAL_HIGH = 160; // 0xa0
|
field public static final int INTERVAL_HIGH = 160; // 0xa0
|
||||||
@@ -7580,6 +7581,7 @@ package android.bluetooth.le {
|
|||||||
method public android.bluetooth.le.AdvertisingSetParameters.Builder setInterval(int);
|
method public android.bluetooth.le.AdvertisingSetParameters.Builder setInterval(int);
|
||||||
method public android.bluetooth.le.AdvertisingSetParameters.Builder setLegacyMode(boolean);
|
method public android.bluetooth.le.AdvertisingSetParameters.Builder setLegacyMode(boolean);
|
||||||
method public android.bluetooth.le.AdvertisingSetParameters.Builder setPrimaryPhy(int);
|
method public android.bluetooth.le.AdvertisingSetParameters.Builder setPrimaryPhy(int);
|
||||||
|
method public android.bluetooth.le.AdvertisingSetParameters.Builder setScannable(boolean);
|
||||||
method public android.bluetooth.le.AdvertisingSetParameters.Builder setSecondaryPhy(int);
|
method public android.bluetooth.le.AdvertisingSetParameters.Builder setSecondaryPhy(int);
|
||||||
method public android.bluetooth.le.AdvertisingSetParameters.Builder setTxPowerLevel(int);
|
method public android.bluetooth.le.AdvertisingSetParameters.Builder setTxPowerLevel(int);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,14 +116,16 @@ public final class AdvertisingSetParameters implements Parcelable {
|
|||||||
private final int primaryPhy;
|
private final int primaryPhy;
|
||||||
private final int secondaryPhy;
|
private final int secondaryPhy;
|
||||||
private final boolean connectable;
|
private final boolean connectable;
|
||||||
|
private final boolean scannable;
|
||||||
private final int interval;
|
private final int interval;
|
||||||
private final int txPowerLevel;
|
private final int txPowerLevel;
|
||||||
|
|
||||||
private AdvertisingSetParameters(boolean connectable, boolean isLegacy,
|
private AdvertisingSetParameters(boolean connectable, boolean scannable, boolean isLegacy,
|
||||||
boolean isAnonymous, boolean includeTxPower,
|
boolean isAnonymous, boolean includeTxPower,
|
||||||
int primaryPhy, int secondaryPhy,
|
int primaryPhy, int secondaryPhy,
|
||||||
int interval, int txPowerLevel) {
|
int interval, int txPowerLevel) {
|
||||||
this.connectable = connectable;
|
this.connectable = connectable;
|
||||||
|
this.scannable = scannable;
|
||||||
this.isLegacy = isLegacy;
|
this.isLegacy = isLegacy;
|
||||||
this.isAnonymous = isAnonymous;
|
this.isAnonymous = isAnonymous;
|
||||||
this.includeTxPower = includeTxPower;
|
this.includeTxPower = includeTxPower;
|
||||||
@@ -135,6 +137,7 @@ public final class AdvertisingSetParameters implements Parcelable {
|
|||||||
|
|
||||||
private AdvertisingSetParameters(Parcel in) {
|
private AdvertisingSetParameters(Parcel in) {
|
||||||
connectable = in.readInt() != 0 ? true : false;
|
connectable = in.readInt() != 0 ? true : false;
|
||||||
|
scannable = in.readInt() != 0 ? true : false;
|
||||||
isLegacy = in.readInt() != 0 ? true : false;
|
isLegacy = in.readInt() != 0 ? true : false;
|
||||||
isAnonymous = in.readInt() != 0 ? true : false;
|
isAnonymous = in.readInt() != 0 ? true : false;
|
||||||
includeTxPower = in.readInt() != 0 ? true : false;
|
includeTxPower = in.readInt() != 0 ? true : false;
|
||||||
@@ -149,6 +152,11 @@ public final class AdvertisingSetParameters implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
public boolean isConnectable() { return connectable; }
|
public boolean isConnectable() { return connectable; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the advertisement will be scannable.
|
||||||
|
*/
|
||||||
|
public boolean isScannable() { return scannable; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the legacy advertisement will be used.
|
* Returns whether the legacy advertisement will be used.
|
||||||
*/
|
*/
|
||||||
@@ -204,6 +212,7 @@ public final class AdvertisingSetParameters implements Parcelable {
|
|||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
dest.writeInt(connectable ? 1 : 0);
|
dest.writeInt(connectable ? 1 : 0);
|
||||||
|
dest.writeInt(scannable ? 1 : 0);
|
||||||
dest.writeInt(isLegacy ? 1 : 0);
|
dest.writeInt(isLegacy ? 1 : 0);
|
||||||
dest.writeInt(isAnonymous ? 1 : 0);
|
dest.writeInt(isAnonymous ? 1 : 0);
|
||||||
dest.writeInt(includeTxPower ? 1 : 0);
|
dest.writeInt(includeTxPower ? 1 : 0);
|
||||||
@@ -232,6 +241,7 @@ public final class AdvertisingSetParameters implements Parcelable {
|
|||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
|
|
||||||
private boolean connectable = true;
|
private boolean connectable = true;
|
||||||
|
private boolean scannable = true;
|
||||||
private boolean isLegacy = false;
|
private boolean isLegacy = false;
|
||||||
private boolean isAnonymous = false;
|
private boolean isAnonymous = false;
|
||||||
private boolean includeTxPower = false;
|
private boolean includeTxPower = false;
|
||||||
@@ -253,6 +263,18 @@ public final class AdvertisingSetParameters implements Parcelable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether the advertisement type should be scannable
|
||||||
|
* Legacy advertisements can be both connectable and scannable. Other
|
||||||
|
* advertisements can be scannable only if not connectable.
|
||||||
|
* @param scannable Controls whether the advertisment type will be
|
||||||
|
* scannable (true) or non-scannable (false).
|
||||||
|
*/
|
||||||
|
public Builder setScannable(boolean scannable) {
|
||||||
|
this.scannable = scannable;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When set to true, advertising set will advertise 4.x Spec compliant
|
* When set to true, advertising set will advertise 4.x Spec compliant
|
||||||
* advertisements.
|
* advertisements.
|
||||||
@@ -371,7 +393,7 @@ public final class AdvertisingSetParameters implements Parcelable {
|
|||||||
* Build the {@link AdvertisingSetParameters} object.
|
* Build the {@link AdvertisingSetParameters} object.
|
||||||
*/
|
*/
|
||||||
public AdvertisingSetParameters build() {
|
public AdvertisingSetParameters build() {
|
||||||
return new AdvertisingSetParameters(connectable, isLegacy, isAnonymous,
|
return new AdvertisingSetParameters(connectable, scannable, isLegacy, isAnonymous,
|
||||||
includeTxPower, primaryPhy,
|
includeTxPower, primaryPhy,
|
||||||
secondaryPhy, interval, txPowerLevel);
|
secondaryPhy, interval, txPowerLevel);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ public final class BluetoothLeAdvertiser {
|
|||||||
AdvertisingSetParameters.Builder parameters = new AdvertisingSetParameters.Builder();
|
AdvertisingSetParameters.Builder parameters = new AdvertisingSetParameters.Builder();
|
||||||
parameters.setLegacyMode(true);
|
parameters.setLegacyMode(true);
|
||||||
parameters.setConnectable(isConnectable);
|
parameters.setConnectable(isConnectable);
|
||||||
|
parameters.setScannable(true); // legacy advertisements we support are always scannable
|
||||||
if (settings.getMode() == AdvertiseSettings.ADVERTISE_MODE_LOW_POWER) {
|
if (settings.getMode() == AdvertiseSettings.ADVERTISE_MODE_LOW_POWER) {
|
||||||
parameters.setInterval(1600); // 1s
|
parameters.setInterval(1600); // 1s
|
||||||
} else if (settings.getMode() == AdvertiseSettings.ADVERTISE_MODE_BALANCED) {
|
} else if (settings.getMode() == AdvertiseSettings.ADVERTISE_MODE_BALANCED) {
|
||||||
|
|||||||
Reference in New Issue
Block a user