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

Commit 25ff1983 authored by Ivan Podogov's avatar Ivan Podogov
Browse files

Remove debug logging from report sending in HID Device mode.

When the app acts as a pointing device, it (according to the
specification) generates ~80 reports per second.
Removing 5 log lines per report makes logs shorter by 400 lines
per second.

Test: build, run, logcat
Change-Id: Ief2300294b7c7ed56cb67bcf1b77f70187291b8e
parent b17a08f3
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -347,8 +347,6 @@ static jboolean unregisterAppNative(JNIEnv* env, jobject thiz) {

static jboolean sendReportNative(JNIEnv* env, jobject thiz, jint id,
                                 jbyteArray data) {
  ALOGV("%s enter", __FUNCTION__);

  jboolean result = JNI_FALSE;
  jsize size;
  uint8_t* buf;
@@ -362,8 +360,6 @@ static jboolean sendReportNative(JNIEnv* env, jobject thiz, jint id,
    bt_status_t ret =
        sHiddIf->send_report(BTHD_REPORT_TYPE_INTRDATA, id, size, buf);

    ALOGV("%s: send_report() returned %d", __FUNCTION__, ret);

    if (ret == BT_STATUS_SUCCESS) {
      result = JNI_TRUE;
    }
@@ -371,8 +367,6 @@ static jboolean sendReportNative(JNIEnv* env, jobject thiz, jint id,
    free(buf);
  }

  ALOGV("%s done (%d)", __FUNCTION__, result);

  return result;
}

+169 −170
Original line number Diff line number Diff line
@@ -42,8 +42,7 @@ import java.util.NoSuchElementException;

/** @hide */
public class HidDevService extends ProfileService {

  private static final boolean DBG = true;
    private static final boolean DBG = false;

    private static final String TAG = HidDevService.class.getSimpleName();

@@ -67,19 +66,19 @@ public class HidDevService extends ProfileService {

    private BluetoothHidDeviceDeathRecipient mDeathRcpt;

  static { classInitNative(); }
    static {
        classInitNative();
    }

    private final Handler mHandler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
      if (DBG)
        Log.v(TAG, "handleMessage(): msg.what=" + msg.what);
            if (DBG) Log.v(TAG, "handleMessage(): msg.what=" + msg.what);

            switch (msg.what) {
                case MESSAGE_APPLICATION_STATE_CHANGED: {
        BluetoothDevice device =
            msg.obj != null ? getDevice((byte[])msg.obj) : null;
                    BluetoothDevice device = msg.obj != null ? getDevice((byte[]) msg.obj) : null;
                    boolean success = (msg.arg1 != 0);

                    if (success) {
@@ -99,8 +98,8 @@ public class HidDevService extends ProfileService {
                    }

                    if (success) {
          mDeathRcpt = new BluetoothHidDeviceDeathRecipient(HidDevService.this,
                                                            mAppConfig);
                        mDeathRcpt = new BluetoothHidDeviceDeathRecipient(
                                HidDevService.this, mAppConfig);
                        if (mCallback != null) {
                            IBinder binder = mCallback.asBinder();
                            try {
@@ -144,8 +143,7 @@ public class HidDevService extends ProfileService {
                    broadcastConnectionState(device, state);

                    try {
          if (mCallback != null)
            mCallback.onConnectionStateChanged(device, state);
                        if (mCallback != null) mCallback.onConnectionStateChanged(device, state);
                    } catch (RemoteException e) {
                        e.printStackTrace();
                    }
@@ -158,7 +156,8 @@ public class HidDevService extends ProfileService {
                    int bufferSize = msg.obj == null ? 0 : ((Integer) msg.obj).intValue();

                    try {
            if (mCallback != null) mCallback.onGetReport(mHidDevice, type, id, bufferSize);
                        if (mCallback != null)
                            mCallback.onGetReport(mHidDevice, type, id, bufferSize);
                    } catch (RemoteException e) {
                        e.printStackTrace();
                    }
@@ -170,7 +169,8 @@ public class HidDevService extends ProfileService {
                    byte[] data = ((ByteBuffer) msg.obj).array();

                    try {
            if (mCallback != null) mCallback.onSetReport(mHidDevice, reportType, reportId, data);
                        if (mCallback != null)
                            mCallback.onSetReport(mHidDevice, reportType, reportId, data);
                    } catch (RemoteException e) {
                        e.printStackTrace();
                    }
@@ -210,8 +210,7 @@ public class HidDevService extends ProfileService {
        }
    };

  private static class BluetoothHidDeviceDeathRecipient
      implements IBinder.DeathRecipient {
    private static class BluetoothHidDeviceDeathRecipient implements IBinder.DeathRecipient {
        private HidDevService mService;
        private BluetoothHidDeviceAppConfiguration mAppConfig;