Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 808591b3 authored by William Escande's avatar William Escande
Browse files

AvrcpController: Delete unused code

Bug: 295237486
Test: atest AvrcpControllerServiceTest
Test: atest AvrcpControllerStateMachineTest
Change-Id: Ife45505aa6ec4ec5a05a1dd8295a2e0a5b57b5be
parent 00d346c0
Loading
Loading
Loading
Loading
+5 −88
Original line number Diff line number Diff line
@@ -24,10 +24,7 @@
#include <shared_mutex>

namespace android {
static jmethodID method_handlePassthroughRsp;
static jmethodID method_onConnectionStateChanged;
static jmethodID method_getRcFeatures;
static jmethodID method_setplayerappsettingrsp;
static jmethodID method_handleplayerappsetting;
static jmethodID method_handleplayerappsettingchanged;
static jmethodID method_handleSetAbsVolume;
@@ -37,7 +34,6 @@ static jmethodID method_handleplaypositionchanged;
static jmethodID method_handleplaystatuschanged;
static jmethodID method_handleGetFolderItemsRsp;
static jmethodID method_handleGetPlayerItemsRsp;
static jmethodID method_handleGroupNavigationRsp;
static jmethodID method_createFromNativeMediaItem;
static jmethodID method_createFromNativeFolderItem;
static jmethodID method_createFromNativePlayerItem;
@@ -58,40 +54,11 @@ static std::shared_timed_mutex sCallbacks_mutex;

static void btavrcp_passthrough_response_callback(const RawAddress& bd_addr,
                                                  int id, int pressed) {
  ALOGI("%s: id: %d, pressed: %d", __func__, id, pressed);
  std::shared_lock<std::shared_timed_mutex> lock(sCallbacks_mutex);
  CallbackEnv sCallbackEnv(__func__);
  if (!sCallbackEnv.valid()) return;
  if (!sCallbacksObj) {
    ALOGE("%s: sCallbacksObj is null", __func__);
    return;
  }

  ScopedLocalRef<jbyteArray> addr(
      sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
  if (!addr.get()) {
    ALOGE("%s: Failed to allocate a new byte array", __func__);
    return;
  }

  sCallbackEnv->SetByteArrayRegion(addr.get(), 0, sizeof(RawAddress),
                                   (jbyte*)&bd_addr.address);
  sCallbackEnv->CallVoidMethod(sCallbacksObj, method_handlePassthroughRsp,
                               (jint)id, (jint)pressed, addr.get());
  ALOGV("%s: id: %d, pressed: %d --- Not implemented", __func__, id, pressed);
}

static void btavrcp_groupnavigation_response_callback(int id, int pressed) {
  ALOGV("%s", __func__);
  std::shared_lock<std::shared_timed_mutex> lock(sCallbacks_mutex);
  CallbackEnv sCallbackEnv(__func__);
  if (!sCallbackEnv.valid()) return;
  if (!sCallbacksObj) {
    ALOGE("%s: sCallbacksObj is null", __func__);
    return;
  }

  sCallbackEnv->CallVoidMethod(sCallbacksObj, method_handleGroupNavigationRsp,
                               (jint)id, (jint)pressed);
  ALOGV("%s: id: %d, pressed: %d --- Not implemented", __func__, id, pressed);
}

static void btavrcp_connection_state_callback(bool rc_connect, bool br_connect,
@@ -121,50 +88,11 @@ static void btavrcp_connection_state_callback(bool rc_connect, bool br_connect,

static void btavrcp_get_rcfeatures_callback(const RawAddress& bd_addr,
                                            int features) {
  ALOGV("%s", __func__);
  std::shared_lock<std::shared_timed_mutex> lock(sCallbacks_mutex);
  CallbackEnv sCallbackEnv(__func__);
  if (!sCallbackEnv.valid()) return;
  if (!sCallbacksObj) {
    ALOGE("%s: sCallbacksObj is null", __func__);
    return;
  ALOGV("%s --- Not implemented", __func__);
}

  ScopedLocalRef<jbyteArray> addr(
      sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
  if (!addr.get()) {
    ALOGE("%s: Failed to allocate a new byte array", __func__);
    return;
  }

  sCallbackEnv->SetByteArrayRegion(addr.get(), 0, sizeof(RawAddress),
                                   (jbyte*)&bd_addr.address);
  sCallbackEnv->CallVoidMethod(sCallbacksObj, method_getRcFeatures, addr.get(),
                               (jint)features);
}

static void btavrcp_setplayerapplicationsetting_rsp_callback(
    const RawAddress& bd_addr, uint8_t accepted) {
  ALOGV("%s", __func__);
  std::shared_lock<std::shared_timed_mutex> lock(sCallbacks_mutex);
  CallbackEnv sCallbackEnv(__func__);
  if (!sCallbackEnv.valid()) return;
  if (!sCallbacksObj) {
    ALOGE("%s: sCallbacksObj is null", __func__);
    return;
  }

  ScopedLocalRef<jbyteArray> addr(
      sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
  if (!addr.get()) {
    ALOGE("%s: Failed to allocate a new byte array", __func__);
    return;
  }

  sCallbackEnv->SetByteArrayRegion(addr.get(), 0, sizeof(RawAddress),
                                   (jbyte*)&bd_addr.address);
  sCallbackEnv->CallVoidMethod(sCallbacksObj, method_setplayerappsettingrsp,
                               addr.get(), (jint)accepted);
  ALOGV("%s --- Not implemented", __func__);
}

static void btavrcp_playerapplicationsetting_callback(
@@ -791,22 +719,11 @@ static btrc_ctrl_callbacks_t sBluetoothAvrcpCallbacks = {
    btavrcp_get_rcpsm_callback};

static void classInitNative(JNIEnv* env, jclass clazz) {
  method_handlePassthroughRsp =
      env->GetMethodID(clazz, "handlePassthroughRsp", "(II[B)V");

  method_handleGroupNavigationRsp =
      env->GetMethodID(clazz, "handleGroupNavigationRsp", "(II)V");

  method_onConnectionStateChanged =
      env->GetMethodID(clazz, "onConnectionStateChanged", "(ZZ[B)V");

  method_getRcFeatures = env->GetMethodID(clazz, "getRcFeatures", "([BI)V");

  method_getRcPsm = env->GetMethodID(clazz, "getRcPsm", "([BI)V");

  method_setplayerappsettingrsp =
      env->GetMethodID(clazz, "setPlayerAppSettingRsp", "([BB)V");

  method_handleplayerappsetting =
      env->GetMethodID(clazz, "handlePlayerAppSetting", "([B[BI)V");

@@ -1312,4 +1229,4 @@ int register_com_android_bluetooth_avrcp_controller(JNIEnv* env) {
      "com/android/bluetooth/avrcpcontroller/AvrcpControllerNativeInterface",
      sMethods, NELEM(sMethods));
}
}
}  // namespace android
+0 −35
Original line number Diff line number Diff line
@@ -128,28 +128,6 @@ public class AvrcpControllerNativeInterface {
    /*********************************** callbacks from native ************************************/
    /**********************************************************************************************/

    // Called by JNI when a passthrough key was received.
    void handlePassthroughRsp(int id, int keyState, byte[] address) {
        if (DBG) {
            Log.d(
                    TAG,
                    "handlePassthroughRsp: passthrough response received as:"
                            + (" key=" + id)
                            + (" state=" + keyState)
                            + (" address=" + Arrays.toString(address)));
        }
    }

    void handleGroupNavigationRsp(int id, int keyState) {
        if (DBG) {
            Log.d(
                    TAG,
                    "handleGroupNavigationRsp: group navigation response received as:"
                            + (" key=" + id)
                            + (" state=" + keyState));
        }
    }

    // Called by JNI when a device has connected or disconnected.
    void onConnectionStateChanged(
            boolean remoteControlConnected, boolean browsingConnected, byte[] address) {
@@ -167,12 +145,6 @@ public class AvrcpControllerNativeInterface {
                remoteControlConnected, browsingConnected, device);
    }

    // Called by JNI to notify Avrcp of features supported by the Remote device.
    void getRcFeatures(byte[] address, int features) {
        /* Do Nothing. */
        // TODO DELETE
    }

    // Called by JNI to notify Avrcp of a remote device's Cover Art PSM
    @VisibleForTesting
    void getRcPsm(byte[] address, int psm) {
@@ -184,13 +156,6 @@ public class AvrcpControllerNativeInterface {
        mAvrcpController.getRcPsm(device, psm);
    }

    // Called by JNI
    @VisibleForTesting
    void setPlayerAppSettingRsp(byte[] address, byte accepted) {
        /* Do Nothing. */
        // TODO DELETE
    }

    // Called by JNI to report remote Player's capabilities
    void handlePlayerAppSetting(byte[] address, byte[] playerAttribRsp, int rspLen) {
        BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address);
+0 −9
Original line number Diff line number Diff line
@@ -379,15 +379,6 @@ public class AvrcpControllerServiceTest {
        verify(mStateMachine).nowPlayingContentChanged();
    }

    @Test
    public void JniApisWithNoBehaviors_doNotCrash() {
        // TODO Delete this
        // mService.handlePassthroughRsp(1, 2, new byte[0]);
        // mService.handleGroupNavigationRsp(1, 2);
        // mService.getRcFeatures(new byte[0], 1);
        // mService.setPlayerAppSettingRsp(new byte[0], (byte) 0);
    }

    @Test
    public void onConnectionStateChanged_connectCase() {
        boolean remoteControlConnected = true;