mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-24 16:21:16 +02:00
Mi Band 8: Find phone
This commit is contained in:
parent
b27c75c09a
commit
fd76c7b13b
@ -239,8 +239,7 @@ public class XiaomiSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
@Override
|
||||
public void onFindPhone(final boolean start) {
|
||||
// TODO possible to notify watch?
|
||||
super.onFindPhone(start);
|
||||
systemService.onFindPhone(start);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,6 +26,7 @@ import java.util.TimeZone;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdateDeviceInfo;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
|
||||
@ -43,6 +44,7 @@ public class XiaomiSystemService extends AbstractXiaomiService {
|
||||
public static final int CMD_BATTERY = 1;
|
||||
public static final int CMD_DEVICE_INFO = 2;
|
||||
public static final int CMD_CLOCK = 3;
|
||||
public static final int CMD_FIND_PHONE = 17;
|
||||
public static final int CMD_CHARGER = 79;
|
||||
|
||||
public XiaomiSystemService(final XiaomiSupport support) {
|
||||
@ -91,6 +93,15 @@ public class XiaomiSystemService extends AbstractXiaomiService {
|
||||
}
|
||||
getSupport().evaluateGBDeviceEvent(batteryInfo);
|
||||
return;
|
||||
case CMD_FIND_PHONE:
|
||||
final GBDeviceEventFindPhone findPhoneEvent = new GBDeviceEventFindPhone();
|
||||
if (cmd.getSystem().getFindDevice() == 0) {
|
||||
findPhoneEvent.event = GBDeviceEventFindPhone.Event.START;
|
||||
} else {
|
||||
findPhoneEvent.event = GBDeviceEventFindPhone.Event.STOP;
|
||||
}
|
||||
getSupport().evaluateGBDeviceEvent(findPhoneEvent);
|
||||
return;
|
||||
case CMD_CHARGER:
|
||||
// charger event, request battery state
|
||||
getSupport().sendCommand(
|
||||
@ -143,4 +154,18 @@ public class XiaomiSystemService extends AbstractXiaomiService {
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
public void onFindPhone(final boolean start) {
|
||||
if (!start) {
|
||||
// Stop on watch
|
||||
getSupport().sendCommand(
|
||||
"find phone stop",
|
||||
XiaomiProto.Command.newBuilder()
|
||||
.setType(COMMAND_TYPE)
|
||||
.setSubtype(CMD_FIND_PHONE)
|
||||
.setSystem(XiaomiProto.System.newBuilder().setFindDevice(1).build())
|
||||
.build()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user