mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-02-04 04:54:10 +01: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
|
@Override
|
||||||
public void onFindPhone(final boolean start) {
|
public void onFindPhone(final boolean start) {
|
||||||
// TODO possible to notify watch?
|
systemService.onFindPhone(start);
|
||||||
super.onFindPhone(start);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,6 +26,7 @@ import java.util.TimeZone;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdateDeviceInfo;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdateDeviceInfo;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
|
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_BATTERY = 1;
|
||||||
public static final int CMD_DEVICE_INFO = 2;
|
public static final int CMD_DEVICE_INFO = 2;
|
||||||
public static final int CMD_CLOCK = 3;
|
public static final int CMD_CLOCK = 3;
|
||||||
|
public static final int CMD_FIND_PHONE = 17;
|
||||||
public static final int CMD_CHARGER = 79;
|
public static final int CMD_CHARGER = 79;
|
||||||
|
|
||||||
public XiaomiSystemService(final XiaomiSupport support) {
|
public XiaomiSystemService(final XiaomiSupport support) {
|
||||||
@ -91,6 +93,15 @@ public class XiaomiSystemService extends AbstractXiaomiService {
|
|||||||
}
|
}
|
||||||
getSupport().evaluateGBDeviceEvent(batteryInfo);
|
getSupport().evaluateGBDeviceEvent(batteryInfo);
|
||||||
return;
|
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:
|
case CMD_CHARGER:
|
||||||
// charger event, request battery state
|
// charger event, request battery state
|
||||||
getSupport().sendCommand(
|
getSupport().sendCommand(
|
||||||
@ -143,4 +154,18 @@ public class XiaomiSystemService extends AbstractXiaomiService {
|
|||||||
.build()
|
.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