`push.listSubscriptionsImpl` method not respecting params
# Introduction
Users may decide to list push subscriptions by clientId **or** deviceId. In ably-java, this is currently not possible, and a request to listSubscriptions by clientId or deviceId **will return a list of both**. 


# Implementation/ bug
In `PushChannel.java`, A user has the option to pass in `params`  into all methods related to listing subscriptions, such as `listSubscriptions` and `listSubscriptionsAsync`. They may choose to add `deviceId: "some device id"` as a param, or leave device ID blank. Unfortunately, all these params are completely ignored/ forgotten about in `listSubscriptionsImpl`. It will reset the `deviceId` in params, even if it were not set. This results in all subscriptions being listed and sent back to the device.

# Proposed solution
If params are passed in, they should be respected, if no deviceID is added, ably-java should not add deviceId to the params sent in the HTTP request. 

Optionally, we could add a convenience method, listSubscriptions() with no arguments which returns all subscriptions by the device or client ID.



┆Issue is synchronized with this [Jira Bug](https://ably.atlassian.net/browse/SDK-1153) by [Unito](https://www.unito.io)

diff --git a/.github/workflows/emulate.yml b/.github/workflows/emulate.yml
index 91da25c5..fe8363c9 100644
--- a/.github/workflows/emulate.yml
+++ b/.github/workflows/emulate.yml
@@ -13,4 +13,5 @@ jobs:
       - uses: reactivecircus/android-emulator-runner@v2
         with:
           api-level: 24
+          emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim
           script: ./gradlew :android:connectedAndroidTest
diff --git a/android/src/androidTest/java/io/ably/lib/test/android/AndroidPushTest.java b/android/src/androidTest/java/io/ably/lib/test/android/AndroidPushTest.java
index 8884c5e2..86f029bb 100644
--- a/android/src/androidTest/java/io/ably/lib/test/android/AndroidPushTest.java
+++ b/android/src/androidTest/java/io/ably/lib/test/android/AndroidPushTest.java
@@ -5,11 +5,11 @@ import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.preference.PreferenceManager;
-
 import android.support.test.runner.AndroidJUnit4;
 import android.util.Log;
 import androidx.localbroadcastmanager.content.LocalBroadcastManager;
 import com.google.gson.JsonObject;
+import io.ably.lib.debug.DebugOptions;
 import io.ably.lib.http.HttpCore;
 import io.ably.lib.push.ActivationContext;
 import io.ably.lib.push.ActivationStateMachine;
@@ -25,41 +25,33 @@ import io.ably.lib.push.ActivationStateMachine.GotPushDeviceDetails;
 import io.ably.lib.push.ActivationStateMachine.NotActivated;
 import io.ably.lib.push.ActivationStateMachine.RegistrationSynced;
 import io.ably.lib.push.ActivationStateMachine.State;
+import io.ably.lib.push.ActivationStateMachine.SyncRegistrationFailed;
 import io.ably.lib.push.ActivationStateMachine.WaitingForDeregistration;
 import io.ably.lib.push.ActivationStateMachine.WaitingForDeviceRegistration;
 import io.ably.lib.push.ActivationStateMachine.WaitingForNewPushDeviceDetails;
 import io.ably.lib.push.ActivationStateMachine.WaitingForPushDeviceDetails;
 import io.ably.lib.push.ActivationStateMachine.WaitingForRegistrationSync;
-import io.ably.lib.push.ActivationStateMachine.SyncRegistrationFailed;
 import io.ably.lib.push.LocalDevice;
 import io.ably.lib.push.Push;
 import io.ably.lib.push.PushBase;
 import io.ably.lib.push.PushChannel;
-import io.ably.lib.rest.DeviceDetails;
-import io.ably.lib.types.AblyException;
-import io.ably.lib.types.Callback;
-import io.ably.lib.types.ClientOptions;
-import io.ably.lib.types.ErrorInfo;
-import io.ably.lib.types.Param;
-import io.ably.lib.types.RegistrationToken;
-import io.ably.lib.util.Base64Coder;
-
-import java.util.ArrayList;
-import java.util.UUID;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.TimeUnit;
-
-import io.ably.lib.debug.DebugOptions;
 import io.ably.lib.realtime.AblyRealtime;
 import io.ably.lib.rest.AblyRest;
 import io.ably.lib.rest.Auth;
 import io.ably.lib.rest.Channel;
+import io.ably.lib.rest.DeviceDetails;
 import io.ably.lib.test.common.Helpers;
 import io.ably.lib.test.common.Helpers.AsyncWaiter;
 import io.ably.lib.test.common.Helpers.CompletionWaiter;
 import io.ably.lib.test.common.Setup;
 import io.ably.lib.test.util.TestCases;
+import io.ably.lib.types.AblyException;
+import io.ably.lib.types.Callback;
+import io.ably.lib.types.ClientOptions;
+import io.ably.lib.types.ErrorInfo;
+import io.ably.lib.types.Param;
+import io.ably.lib.types.RegistrationToken;
+import io.ably.lib.util.Base64Coder;
 import io.ably.lib.util.IntentUtils;
 import io.ably.lib.util.JsonUtils;
 import io.ably.lib.util.Serialisation;
@@ -68,6 +60,12 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import java.util.ArrayList;
+import java.util.UUID;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.TimeUnit;
+
 import static android.support.test.InstrumentationRegistry.getContext;
 import static io.ably.lib.test.common.Helpers.assertArrayUnorderedEquals;
 import static io.ably.lib.test.common.Helpers.assertInstanceOf;
@@ -1352,8 +1350,11 @@ public class AndroidPushTest {
             @Override
             public void run() throws Exception {
                 testActivation = new TestActivation();
+
+                final String testClientId = "testClient";
+                final String testChannel = "pushenabled:foo";
+
                 if (useClientId) {
-                    final String testClientId = "testClient";
                     testActivation.rest.auth.setClientId(testClientId);
                     testActivation.rest.auth.authorize(new Auth.TokenParams() {{ clientId = testClientId; }}, null);
                 } else {
@@ -1375,12 +1376,12 @@ public class AndroidPushTest {
                 String deviceId = testActivation.rest.push.getLocalDevice().id;
 
                 Push.ChannelSubscription[] fixtures = new Push.ChannelSubscription[] {
-                    PushBase.ChannelSubscription.forDevice("pushenabled:foo", deviceId),
-                    PushBase.ChannelSubscription.forDevice("pushenabled:foo", "other"),
+                    PushBase.ChannelSubscription.forDevice(testChannel, deviceId),
+                    PushBase.ChannelSubscription.forDevice(testChannel, "other"),
                     PushBase.ChannelSubscription.forDevice("pushenabled:bar", deviceId),
-                    PushBase.ChannelSubscription.forClientId("pushenabled:foo", "testClient"),
-                    PushBase.ChannelSubscription.forClientId("pushenabled:foo", "otherClient"),
-                    PushBase.ChannelSubscription.forClientId("pushenabled:bar", "testClient"),
+                    PushBase.ChannelSubscription.forClientId(testChannel, testClientId),
+                    PushBase.ChannelSubscription.forClientId(testChannel, "otherClient"),
+                    PushBase.ChannelSubscription.forClientId("pushenabled:bar", testClientId),
                 };
 
                 try {
@@ -1390,12 +1391,20 @@ public class AndroidPushTest {
                         testActivation.adminRest.push.admin.channelSubscriptions.save(sub);
                     }
 
-                    Push.ChannelSubscription[] got = testActivation.rest.channels.get("pushenabled:foo").push.listSubscriptions().items();
+                    Param[] params = Param.array(new Param("deviceId", deviceId));
+                    params = Param.set(params, "channel", testChannel);
+
+                    if(useClientId) {
+                        params = Param.set(params, "clientId", testClientId);
+                    }
+
+                    Push.ChannelSubscription[] got = testActivation.rest.channels.get(testChannel)
+                        .push.listSubscriptions(params).items();
 
                     ArrayList<Push.ChannelSubscription> expected = new ArrayList<>(2);
-                    expected.add(PushBase.ChannelSubscription.forDevice("pushenabled:foo", deviceId));
+                    expected.add(PushBase.ChannelSubscription.forDevice(testChannel, deviceId));
                     if (useClientId) {
-                        expected.add(PushBase.ChannelSubscription.forClientId("pushenabled:foo", "testClient"));
+                        expected.add(PushBase.ChannelSubscription.forClientId(testChannel, testClientId));
                     }
 
                     assertArrayUnorderedEquals(expected.toArray(), got);
diff --git a/android/src/main/java/io/ably/lib/push/PushChannel.java b/android/src/main/java/io/ably/lib/push/PushChannel.java
index 919b74db..865a85c6 100644
--- a/android/src/main/java/io/ably/lib/push/PushChannel.java
+++ b/android/src/main/java/io/ably/lib/push/PushChannel.java
@@ -140,16 +140,6 @@ public class PushChannel {
     }
 
     protected BasePaginatedQuery.ResultRequest<Push.ChannelSubscription> listSubscriptionsImpl(Param[] params) {
-        try {
-            params = Param.set(params, "deviceId", getDevice().id);
-        } catch(AblyException e) {
-            return new BasePaginatedQuery.ResultRequest.Failed(e);
-        }
-        params = Param.set(params, "channel", channel.name);
-        String clientId = rest.auth.clientId;
-        if (clientId != null) {
-            params = Param.set(params, "clientId", clientId);
-        }
         params = Param.set(params, "concatFilters", "true");
 
         return new BasePaginatedQuery<Push.ChannelSubscription>(rest.http, "/push/channelSubscriptions", rest.push.pushRequestHeaders(true), params, Push.ChannelSubscription.httpBodyHandler).get();
['android/src/androidTest/java/io/ably/lib/test/android/AndroidPushTest.java', '.github/workflows/emulate.yml', 'android/src/main/java/io/ably/lib/push/PushChannel.java']