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
(cherry picked from commit e6c453d828fec3df82708d2b0c3bb00bd0a0dbf8)
diff --git a/api/current.txt b/api/current.txt
index cfcdb7d..54800eb 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -8056,7 +8056,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);
@@ -8066,7 +8065,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 df8d49a..0230eb7 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -8527,7 +8527,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);
@@ -8537,7 +8536,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 a8060d8..923389d 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -8086,7 +8086,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);
@@ -8096,7 +8095,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);
         }
     }
 }