mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-24 10:56:50 +01:00
Lefun: Implement limited find phone support
This commit is contained in:
parent
b7abd328bb
commit
0dd44ae2d6
@ -40,6 +40,7 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.lefun.LefunConstants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.lefun.commands.FindPhoneCommand;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.lefun.commands.GetActivityDataCommand;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.lefun.commands.GetPpgDataCommand;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.lefun.commands.GetSleepDataCommand;
|
||||
@ -385,6 +386,8 @@ public class LefunDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
switch (commandId) {
|
||||
case LefunConstants.CMD_PPG_RESULT:
|
||||
return handleAsynchronousPpgResult(data);
|
||||
case LefunConstants.CMD_FIND_PHONE:
|
||||
return handleAntiLoss(data);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -401,6 +404,19 @@ public class LefunDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleAntiLoss(byte[] data) {
|
||||
try {
|
||||
FindPhoneCommand cmd = new FindPhoneCommand();
|
||||
cmd.deserialize(data);
|
||||
// TODO: actually pop something that makes sound
|
||||
GB.toast("Your device is trying to find your phone", Toast.LENGTH_LONG, GB.INFO);
|
||||
return true;
|
||||
} catch (IllegalArgumentException e) {
|
||||
LOG.error("Failed to handle anti-loss", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void completeInitialization() {
|
||||
gbDevice.setState(GBDevice.State.INITIALIZED);
|
||||
gbDevice.sendDeviceUpdateIntent(getContext());
|
||||
|
Loading…
Reference in New Issue
Block a user