Merge "Expose LE advertiser address for easier PTS tests (5/6)"
diff --git a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothLeAdvertisingSetFacade.java b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothLeAdvertisingSetFacade.java
index d22f969..a491001 100644
--- a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothLeAdvertisingSetFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothLeAdvertisingSetFacade.java
@@ -268,6 +268,17 @@
     }
 
     /**
+     * Get the address associated with this Advertising set. This method returns immediately,
+     * the operation result is delivered through callback.onOwnAddressRead().
+     * This is for PTS only.
+     */
+    @Rpc(description = "Get own address")
+    public void bleAdvSetGetOwnAddress(
+            @RpcParameter(name = "setIndex") Integer setIndex) throws Exception {
+        mAdvertisingSets.get(setIndex).getOwnAddress();
+    }
+
+    /**
      * Enables Advertising. This method returns immediately, the operation status is
      * delivered through callback.onAdvertisingEnabled().
      *
@@ -353,7 +364,7 @@
             if (advertisingSet != null) {
                 setIndex = ++sAdvertisingSetCount;
                 mAdvertisingSets.put(setIndex, advertisingSet);
-                results.putInt("set_id", setIndex);
+                results.putInt("setId", setIndex);
             } else {
                 mAdvertisingSetCallbacks.remove(index);
             }
@@ -407,6 +418,17 @@
             sendGeneric("onPeriodicAdvertisingEnabled", setIndex, status, enable);
         }
 
+        @Override
+        public void onOwnAddressRead(AdvertisingSet advertisingSet, int addressType,
+                String address) {
+            Log.d("onOwnAddressRead" + mEventType + " " + setIndex);
+            Bundle results = new Bundle();
+            results.putInt("setId", setIndex);
+            results.putInt("addressType", addressType);
+            results.putString("address", address);
+            mEventFacade.postEvent(mEventType + setIndex + "onOwnAddressRead", results);
+        }
+
         public void sendGeneric(String cb, int setIndex, int status) {
             sendGeneric(cb, setIndex, status, null);
         }
@@ -414,7 +436,7 @@
         public void sendGeneric(String cb, int setIndex, int status, Boolean enable) {
             Log.d(cb + mEventType + " " + index);
             Bundle results = new Bundle();
-            results.putInt("set_id", setIndex);
+            results.putInt("setId", setIndex);
             results.putInt("status", status);
             if (enable != null) results.putBoolean("enable", enable);
             mEventFacade.postEvent(mEventType + index + cb, results);