Loading android/app/src/com/android/bluetooth/mcp/MediaControlGattService.java +3 −4 Original line number Diff line number Diff line Loading @@ -39,7 +39,6 @@ import android.bluetooth.BluetoothManager; import android.bluetooth.BluetoothProfile; import android.content.Context; import android.util.Log; import android.util.MathUtils; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -808,7 +807,7 @@ public class MediaControlGattService implements MediaControlGattServiceInterface } private void handlePlaybackSpeedRequest(int speed) { float floatingSpeed = MathUtils.pow(2, speed / 64); float floatingSpeed = (float) Math.pow(2, speed / 64); mCallbacks.onPlaybackSpeedSetRequest(floatingSpeed); } Loading Loading @@ -1312,11 +1311,11 @@ public class MediaControlGattService implements MediaControlGattServiceInterface speed = PLAY_SPEED_MAX; } return new Float(64 * MathUtils.log(speed) / MathUtils.log(2)).intValue(); return new Float(64 * Math.log(speed) / Math.log(2)).intValue(); } private static float CharacteristicSpeedIntValueToSpeedFloat(Integer speed) { return new Float(MathUtils.pow(2, (speed.floatValue() / 64.0f))); return new Float(Math.pow(2, (speed.floatValue() / 64.0f))); } @VisibleForTesting Loading android/app/tests/unit/src/com/android/bluetooth/mcp/MediaControlGattServiceTest.java +2 −3 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ import android.bluetooth.BluetoothGattDescriptor; import android.bluetooth.BluetoothGattService; import android.content.Context; import android.os.Looper; import android.util.MathUtils; import androidx.test.InstrumentationRegistry; import androidx.test.filters.MediumTest; Loading Loading @@ -548,7 +547,7 @@ public class MediaControlGattServiceTest { mCurrentDevice, 1, characteristic, false, true, 0, bb.array()); verify(mMockMcsCallbacks) .onPlaybackSpeedSetRequest(eq(MathUtils.pow(2, playback_speed / 64))); .onPlaybackSpeedSetRequest(eq((float) Math.pow(2, playback_speed / 64))); verify(mMockGattServer) .sendResponse(eq(mCurrentDevice), eq(1), eq(BluetoothGatt.GATT_SUCCESS), eq(0), Loading Loading @@ -955,7 +954,7 @@ public class MediaControlGattServiceTest { mCurrentDevice, 1, characteristic, false, true, 0, bb.array()); verify(mMockMcsCallbacks) .onPlaybackSpeedSetRequest(eq(MathUtils.pow(2, playback_speed / 64))); .onPlaybackSpeedSetRequest(eq((float) Math.pow(2, playback_speed / 64))); // Fake characteristic write - this is done by player status update characteristic.setValue(playback_speed, BluetoothGattCharacteristic.FORMAT_SINT8, 0); Loading Loading
android/app/src/com/android/bluetooth/mcp/MediaControlGattService.java +3 −4 Original line number Diff line number Diff line Loading @@ -39,7 +39,6 @@ import android.bluetooth.BluetoothManager; import android.bluetooth.BluetoothProfile; import android.content.Context; import android.util.Log; import android.util.MathUtils; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -808,7 +807,7 @@ public class MediaControlGattService implements MediaControlGattServiceInterface } private void handlePlaybackSpeedRequest(int speed) { float floatingSpeed = MathUtils.pow(2, speed / 64); float floatingSpeed = (float) Math.pow(2, speed / 64); mCallbacks.onPlaybackSpeedSetRequest(floatingSpeed); } Loading Loading @@ -1312,11 +1311,11 @@ public class MediaControlGattService implements MediaControlGattServiceInterface speed = PLAY_SPEED_MAX; } return new Float(64 * MathUtils.log(speed) / MathUtils.log(2)).intValue(); return new Float(64 * Math.log(speed) / Math.log(2)).intValue(); } private static float CharacteristicSpeedIntValueToSpeedFloat(Integer speed) { return new Float(MathUtils.pow(2, (speed.floatValue() / 64.0f))); return new Float(Math.pow(2, (speed.floatValue() / 64.0f))); } @VisibleForTesting Loading
android/app/tests/unit/src/com/android/bluetooth/mcp/MediaControlGattServiceTest.java +2 −3 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ import android.bluetooth.BluetoothGattDescriptor; import android.bluetooth.BluetoothGattService; import android.content.Context; import android.os.Looper; import android.util.MathUtils; import androidx.test.InstrumentationRegistry; import androidx.test.filters.MediumTest; Loading Loading @@ -548,7 +547,7 @@ public class MediaControlGattServiceTest { mCurrentDevice, 1, characteristic, false, true, 0, bb.array()); verify(mMockMcsCallbacks) .onPlaybackSpeedSetRequest(eq(MathUtils.pow(2, playback_speed / 64))); .onPlaybackSpeedSetRequest(eq((float) Math.pow(2, playback_speed / 64))); verify(mMockGattServer) .sendResponse(eq(mCurrentDevice), eq(1), eq(BluetoothGatt.GATT_SUCCESS), eq(0), Loading Loading @@ -955,7 +954,7 @@ public class MediaControlGattServiceTest { mCurrentDevice, 1, characteristic, false, true, 0, bb.array()); verify(mMockMcsCallbacks) .onPlaybackSpeedSetRequest(eq(MathUtils.pow(2, playback_speed / 64))); .onPlaybackSpeedSetRequest(eq((float) Math.pow(2, playback_speed / 64))); // Fake characteristic write - this is done by player status update characteristic.setValue(playback_speed, BluetoothGattCharacteristic.FORMAT_SINT8, 0); Loading