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
diff --git a/api/current.txt b/api/current.txt
index 4370505..a936a53 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -7586,7 +7586,6 @@
 
   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 @@
   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);
   }
diff --git a/api/system-current.txt b/api/system-current.txt
index d801448..cbad725 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -7894,7 +7894,6 @@
 
   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 @@
   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);
   }
diff --git a/api/test-current.txt b/api/test-current.txt
index 084fb36..b9f50fb 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -7595,7 +7595,6 @@
 
   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 @@
   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);
   }
diff --git a/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java b/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java
index a9deb75..73fc133 100644
--- a/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java
+++ b/core/java/android/bluetooth/le/BluetoothLeAdvertiser.java
@@ -386,7 +386,7 @@
             }
 
             boolean supportPeriodic = mBluetoothAdapter.isLePeriodicAdvertisingSupported();
-            if (periodicParameters != null && periodicParameters.getEnable() && !supportPeriodic) {
+            if (periodicParameters != null && !supportPeriodic) {
                 throw new IllegalArgumentException(
                     "Controller does not support LE Periodic Advertising");
             }
diff --git a/core/java/android/bluetooth/le/PeriodicAdvertisingParameters.java b/core/java/android/bluetooth/le/PeriodicAdvertisingParameters.java
index 149540c..8891d2e 100644
--- a/core/java/android/bluetooth/le/PeriodicAdvertisingParameters.java
+++ b/core/java/android/bluetooth/le/PeriodicAdvertisingParameters.java
@@ -29,28 +29,20 @@
     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.
      */
     public boolean getIncludeTxPower() { return includeTxPower; }
@@ -68,7 +60,6 @@
 
     @Override
     public void writeToParcel(Parcel dest, int flags) {
-        dest.writeInt(enable ? 1 : 0);
         dest.writeInt(includeTxPower ? 1 : 0);
         dest.writeInt(interval);
     }
@@ -89,18 +80,9 @@
 
     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 @@
          * Build the {@link AdvertisingSetParameters} object.
          */
         public PeriodicAdvertisingParameters build() {
-            return new PeriodicAdvertisingParameters(enable, includeTxPower, interval);
+            return new PeriodicAdvertisingParameters(includeTxPower, interval);
         }
     }
 }