Remove enable from PeriodicAdvertisingPariameters (1/2)
Instead of setting enable to true, one can just pass null PeriodicAdvertisingParameters and achieve same result when starting the set. Passing the "enable" when updating the parameters make no sense, and might be confusing. Experience with "timeout" field, which was a part of AdvertiseSettings show that merging fields that go into different HCI commands can cause problems during processing, so keep enable as separate field. Test: manual Bug: 30622771 Change-Id: Ida02c59eb8433537179b4d22202fe745f8b4bb3e
This commit is contained in:
@@ -7586,7 +7586,6 @@ package android.bluetooth.le {
|
||||
|
||||
public final class PeriodicAdvertisingParameters implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public boolean getEnable();
|
||||
method public boolean getIncludeTxPower();
|
||||
method public int getInterval();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
@@ -7596,7 +7595,6 @@ package android.bluetooth.le {
|
||||
public static final class PeriodicAdvertisingParameters.Builder {
|
||||
ctor public PeriodicAdvertisingParameters.Builder();
|
||||
method public android.bluetooth.le.PeriodicAdvertisingParameters build();
|
||||
method public android.bluetooth.le.PeriodicAdvertisingParameters.Builder setEnable(boolean);
|
||||
method public android.bluetooth.le.PeriodicAdvertisingParameters.Builder setIncludeTxPower(boolean);
|
||||
method public android.bluetooth.le.PeriodicAdvertisingParameters.Builder setInterval(int);
|
||||
}
|
||||
|
||||
@@ -7894,7 +7894,6 @@ package android.bluetooth.le {
|
||||
|
||||
public final class PeriodicAdvertisingParameters implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public boolean getEnable();
|
||||
method public boolean getIncludeTxPower();
|
||||
method public int getInterval();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
@@ -7904,7 +7903,6 @@ package android.bluetooth.le {
|
||||
public static final class PeriodicAdvertisingParameters.Builder {
|
||||
ctor public PeriodicAdvertisingParameters.Builder();
|
||||
method public android.bluetooth.le.PeriodicAdvertisingParameters build();
|
||||
method public android.bluetooth.le.PeriodicAdvertisingParameters.Builder setEnable(boolean);
|
||||
method public android.bluetooth.le.PeriodicAdvertisingParameters.Builder setIncludeTxPower(boolean);
|
||||
method public android.bluetooth.le.PeriodicAdvertisingParameters.Builder setInterval(int);
|
||||
}
|
||||
|
||||
@@ -7595,7 +7595,6 @@ package android.bluetooth.le {
|
||||
|
||||
public final class PeriodicAdvertisingParameters implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public boolean getEnable();
|
||||
method public boolean getIncludeTxPower();
|
||||
method public int getInterval();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
@@ -7605,7 +7604,6 @@ package android.bluetooth.le {
|
||||
public static final class PeriodicAdvertisingParameters.Builder {
|
||||
ctor public PeriodicAdvertisingParameters.Builder();
|
||||
method public android.bluetooth.le.PeriodicAdvertisingParameters build();
|
||||
method public android.bluetooth.le.PeriodicAdvertisingParameters.Builder setEnable(boolean);
|
||||
method public android.bluetooth.le.PeriodicAdvertisingParameters.Builder setIncludeTxPower(boolean);
|
||||
method public android.bluetooth.le.PeriodicAdvertisingParameters.Builder setInterval(int);
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ public final class BluetoothLeAdvertiser {
|
||||
}
|
||||
|
||||
boolean supportPeriodic = mBluetoothAdapter.isLePeriodicAdvertisingSupported();
|
||||
if (periodicParameters != null && periodicParameters.getEnable() && !supportPeriodic) {
|
||||
if (periodicParameters != null && !supportPeriodic) {
|
||||
throw new IllegalArgumentException(
|
||||
"Controller does not support LE Periodic Advertising");
|
||||
}
|
||||
|
||||
@@ -29,27 +29,19 @@ public final class PeriodicAdvertisingParameters implements Parcelable {
|
||||
private static final int INTERVAL_MAX = 80;
|
||||
private static final int INTERVAL_MIN = 65519;
|
||||
|
||||
private final boolean enable;
|
||||
private final boolean includeTxPower;
|
||||
private final int interval;
|
||||
|
||||
private PeriodicAdvertisingParameters(boolean enable, boolean includeTxPower, int interval) {
|
||||
this.enable = enable;
|
||||
private PeriodicAdvertisingParameters(boolean includeTxPower, int interval) {
|
||||
this.includeTxPower = includeTxPower;
|
||||
this.interval = interval;
|
||||
}
|
||||
|
||||
private PeriodicAdvertisingParameters(Parcel in) {
|
||||
enable = in.readInt() != 0 ? true : false;
|
||||
includeTxPower = in.readInt() != 0 ? true : false;
|
||||
interval = in.readInt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the periodic advertising shall be enabled.
|
||||
*/
|
||||
public boolean getEnable() { return enable; }
|
||||
|
||||
/**
|
||||
* Returns whether the TX Power will be included.
|
||||
*/
|
||||
@@ -68,7 +60,6 @@ public final class PeriodicAdvertisingParameters implements Parcelable {
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(enable ? 1 : 0);
|
||||
dest.writeInt(includeTxPower ? 1 : 0);
|
||||
dest.writeInt(interval);
|
||||
}
|
||||
@@ -89,17 +80,8 @@ public final class PeriodicAdvertisingParameters implements Parcelable {
|
||||
|
||||
public static final class Builder {
|
||||
private boolean includeTxPower = false;
|
||||
private boolean enable = false;
|
||||
private int interval = INTERVAL_MAX;
|
||||
|
||||
/**
|
||||
* Set whether the Periodic Advertising should be enabled for this set.
|
||||
*/
|
||||
public Builder setEnable(boolean enable) {
|
||||
this.enable = enable;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the transmission power level should be included in the periodic
|
||||
* packet.
|
||||
@@ -128,7 +110,7 @@ public final class PeriodicAdvertisingParameters implements Parcelable {
|
||||
* Build the {@link AdvertisingSetParameters} object.
|
||||
*/
|
||||
public PeriodicAdvertisingParameters build() {
|
||||
return new PeriodicAdvertisingParameters(enable, includeTxPower, interval);
|
||||
return new PeriodicAdvertisingParameters(includeTxPower, interval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user