mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-28 01:55:40 +02:00
Only start MusicPlaybackReceiver if device supports music info
Also block sending music info in HuamiSupport if device does not support it
This commit is contained in:
parent
774797ea09
commit
da58e22afe
@ -129,4 +129,9 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
||||
public boolean supportsActivityTracks() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsMusicInfo() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -248,4 +248,10 @@ public interface DeviceCoordinator {
|
||||
* making some sound or lighting up
|
||||
*/
|
||||
boolean supportsFindDevice();
|
||||
|
||||
/**
|
||||
* Indicates whether the device supports displaying music information
|
||||
* like artist, title, album, play state etc.
|
||||
*/
|
||||
boolean supportsMusicInfo();
|
||||
}
|
||||
|
@ -68,4 +68,9 @@ public class AmazfitCorCoordinator extends HuamiCoordinator {
|
||||
public boolean supportsWeather() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsMusicInfo() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -165,4 +165,9 @@ public class PebbleCoordinator extends AbstractDeviceCoordinator {
|
||||
public boolean supportsFindDevice() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsMusicInfo() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -132,6 +132,11 @@ public class ZeTimeCoordinator extends AbstractDeviceCoordinator {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsMusicInfo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBondingStyle(GBDevice device) {
|
||||
return BONDING_STYLE_NONE;
|
||||
|
@ -639,7 +639,7 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||
mPebbleReceiver = new PebbleReceiver();
|
||||
registerReceiver(mPebbleReceiver, new IntentFilter("com.getpebble.action.SEND_NOTIFICATION"));
|
||||
}
|
||||
if (mMusicPlaybackReceiver == null) {
|
||||
if (mMusicPlaybackReceiver == null && coordinator != null && coordinator.supportsMusicInfo()) {
|
||||
mMusicPlaybackReceiver = new MusicPlaybackReceiver();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
for (String action : mMusicActions) {
|
||||
|
@ -58,6 +58,7 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallContro
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.ActivateDisplayOnLift;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
||||
@ -114,6 +115,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.Ini
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.NotificationStrategy;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.RealtimeSamplesSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.NotificationUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
@ -732,16 +734,28 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
@Override
|
||||
public void onSetMusicState(MusicStateSpec stateSpec) {
|
||||
if (bufferMusicStateSpec != stateSpec)
|
||||
bufferMusicStateSpec = stateSpec;
|
||||
sendMusicStateToDevice();
|
||||
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(gbDevice);
|
||||
if (!coordinator.supportsMusicInfo()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (bufferMusicStateSpec != stateSpec) {
|
||||
bufferMusicStateSpec = stateSpec;
|
||||
}
|
||||
|
||||
sendMusicStateToDevice();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetMusicInfo(MusicSpec musicSpec) {
|
||||
if (bufferMusicSpec != musicSpec)
|
||||
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(gbDevice);
|
||||
if (!coordinator.supportsMusicInfo()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (bufferMusicSpec != musicSpec) {
|
||||
bufferMusicSpec = musicSpec;
|
||||
}
|
||||
|
||||
if (!isMusicAppStarted) {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user