mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-02-21 06:46:48 +01: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() {
|
public boolean supportsActivityTracks() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsMusicInfo() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,4 +248,10 @@ public interface DeviceCoordinator {
|
|||||||
* making some sound or lighting up
|
* making some sound or lighting up
|
||||||
*/
|
*/
|
||||||
boolean supportsFindDevice();
|
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() {
|
public boolean supportsWeather() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsMusicInfo() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,4 +165,9 @@ public class PebbleCoordinator extends AbstractDeviceCoordinator {
|
|||||||
public boolean supportsFindDevice() {
|
public boolean supportsFindDevice() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsMusicInfo() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,6 +132,11 @@ public class ZeTimeCoordinator extends AbstractDeviceCoordinator {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsMusicInfo() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBondingStyle(GBDevice device) {
|
public int getBondingStyle(GBDevice device) {
|
||||||
return BONDING_STYLE_NONE;
|
return BONDING_STYLE_NONE;
|
||||||
|
@ -639,7 +639,7 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
|||||||
mPebbleReceiver = new PebbleReceiver();
|
mPebbleReceiver = new PebbleReceiver();
|
||||||
registerReceiver(mPebbleReceiver, new IntentFilter("com.getpebble.action.SEND_NOTIFICATION"));
|
registerReceiver(mPebbleReceiver, new IntentFilter("com.getpebble.action.SEND_NOTIFICATION"));
|
||||||
}
|
}
|
||||||
if (mMusicPlaybackReceiver == null) {
|
if (mMusicPlaybackReceiver == null && coordinator != null && coordinator.supportsMusicInfo()) {
|
||||||
mMusicPlaybackReceiver = new MusicPlaybackReceiver();
|
mMusicPlaybackReceiver = new MusicPlaybackReceiver();
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
for (String action : mMusicActions) {
|
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.GBDeviceEventFindPhone;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.ActivateDisplayOnLift;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.ActivateDisplayOnLift;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
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.huami.operations.UpdateFirmwareOperation;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.NotificationStrategy;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.NotificationStrategy;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.RealtimeSamplesSupport;
|
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.GB;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.NotificationUtils;
|
import nodomain.freeyourgadget.gadgetbridge.util.NotificationUtils;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||||
@ -732,16 +734,28 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSetMusicState(MusicStateSpec stateSpec) {
|
public void onSetMusicState(MusicStateSpec stateSpec) {
|
||||||
if (bufferMusicStateSpec != stateSpec)
|
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(gbDevice);
|
||||||
bufferMusicStateSpec = stateSpec;
|
if (!coordinator.supportsMusicInfo()) {
|
||||||
sendMusicStateToDevice();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bufferMusicStateSpec != stateSpec) {
|
||||||
|
bufferMusicStateSpec = stateSpec;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendMusicStateToDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSetMusicInfo(MusicSpec musicSpec) {
|
public void onSetMusicInfo(MusicSpec musicSpec) {
|
||||||
if (bufferMusicSpec != musicSpec)
|
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(gbDevice);
|
||||||
|
if (!coordinator.supportsMusicInfo()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bufferMusicSpec != musicSpec) {
|
||||||
bufferMusicSpec = musicSpec;
|
bufferMusicSpec = musicSpec;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isMusicAppStarted) {
|
if (!isMusicAppStarted) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user