mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-15 21:27:51 +01:00
Amazfit Bip: Implement support for rejecting calls
Taking calls does not work with recent Android versions, I guess we need to push the button in the notification :(
This commit is contained in:
parent
6b1ba4d161
commit
7108dd7b88
@ -16,6 +16,7 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.amazfitbip;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.NotificationStrategy;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.MiBand2Support;
|
||||
|
||||
@ -29,4 +30,21 @@ public class AmazfitBipSupport extends MiBand2Support {
|
||||
public void onFindDevice(boolean start) {
|
||||
// Prevent notification spamming from MiBand2Support for now
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleButtonPressed(byte[] value) {
|
||||
if (value == null || value.length != 1) {
|
||||
return;
|
||||
}
|
||||
GBDeviceEventCallControl callCmd = new GBDeviceEventCallControl();
|
||||
|
||||
if (value[0] == 0x07) {
|
||||
callCmd.event = GBDeviceEventCallControl.Event.REJECT;
|
||||
} else if (value[0] == 0x09) {
|
||||
callCmd.event = GBDeviceEventCallControl.Event.ACCEPT;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
evaluateGBDeviceEvent(callCmd);
|
||||
}
|
||||
}
|
@ -808,7 +808,7 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void handleButtonPressed(byte[] value) {
|
||||
public void handleButtonPressed(byte[] value) {
|
||||
LOG.info("Button pressed");
|
||||
logMessageContent(value);
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ public class GBCallControlReceiver extends BroadcastReceiver {
|
||||
GBDeviceEventCallControl.Event callCmd = GBDeviceEventCallControl.Event.values()[intent.getIntExtra("event", 0)];
|
||||
switch (callCmd) {
|
||||
case END:
|
||||
case REJECT:
|
||||
case START:
|
||||
try {
|
||||
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
@ -46,7 +47,7 @@ public class GBCallControlReceiver extends BroadcastReceiver {
|
||||
Method method = clazz.getDeclaredMethod("getITelephony");
|
||||
method.setAccessible(true);
|
||||
ITelephony telephonyService = (ITelephony) method.invoke(telephonyManager);
|
||||
if (callCmd == GBDeviceEventCallControl.Event.END) {
|
||||
if (callCmd == GBDeviceEventCallControl.Event.END || callCmd == GBDeviceEventCallControl.Event.REJECT) {
|
||||
telephonyService.endCall();
|
||||
} else {
|
||||
telephonyService.answerRingingCall();
|
||||
|
Loading…
Reference in New Issue
Block a user