We have clarified our Privacy Statement even further. Please have a look at our changes.
Browse Source

Merge remote-tracking branch 'github/pr/1523/ignore_call'

tags/0.34.0
Andreas Shimokawa 5 months ago
parent
commit
e066e0fae3
5 changed files with 30 additions and 1 deletions
  1. +1
    -0
      app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventCallControl.java
  2. +17
    -0
      app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/PhoneCallReceiver.java
  3. +7
    -0
      app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/AbstractDeviceSupport.java
  4. +1
    -0
      app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java
  5. +4
    -1
      app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casiogb6900/CasioGB6900DeviceSupport.java

+ 1
- 0
app/src/main/java/nodomain/freeyourgadget/gadgetbridge/deviceevents/GBDeviceEventCallControl.java View File

@@ -28,5 +28,6 @@ public class GBDeviceEventCallControl extends GBDeviceEvent {
OUTGOING,
REJECT,
START,
IGNORE,
}
}

+ 17
- 0
app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/PhoneCallReceiver.java View File

@@ -23,6 +23,7 @@ import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.telephony.TelephonyManager;

import nodomain.freeyourgadget.gadgetbridge.GBApplication;
@@ -34,12 +35,23 @@ public class PhoneCallReceiver extends BroadcastReceiver {

private static int mLastState = TelephonyManager.CALL_STATE_IDLE;
private static String mSavedNumber;
private boolean mRestoreMutedCall = false;
private int mLastRingerMode;

@Override
public void onReceive(Context context, Intent intent) {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Service.TELEPHONY_SERVICE);
if (intent.getAction().equals("android.intent.action.NEW_OUTGOING_CALL")) {
mSavedNumber = intent.getExtras().getString("android.intent.extra.PHONE_NUMBER");
} else if(intent.getAction().equals("nodomain.freeyourgadget.gadgetbridge.MUTE_CALL")) {
// Handle the mute request only if the phone is currently ringing
if(mLastState != TelephonyManager.CALL_STATE_RINGING)
return;

AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
mLastRingerMode = audioManager.getRingerMode();
audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
mRestoreMutedCall = true;
} else {
if (intent.hasExtra(TelephonyManager.EXTRA_INCOMING_NUMBER)) {
String number = intent.getExtras().getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
@@ -75,6 +87,11 @@ public class PhoneCallReceiver extends BroadcastReceiver {
} else {
callCommand = CallSpec.CALL_END;
}
if(mRestoreMutedCall) {
mRestoreMutedCall = false;
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audioManager.setRingerMode(mLastRingerMode);
}
break;
}
if (callCommand != CallSpec.CALL_UNDEFINED) {

+ 7
- 0
app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/AbstractDeviceSupport.java View File

@@ -198,6 +198,13 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
private void handleGBDeviceEvent(GBDeviceEventCallControl callEvent) {
Context context = getContext();
LOG.info("Got event for CALL_CONTROL");
if(callEvent.event == GBDeviceEventCallControl.Event.IGNORE) {
LOG.info("Sending intent for mute");
Intent broadcastIntent = new Intent("nodomain.freeyourgadget.gadgetbridge.MUTE_CALL");
broadcastIntent.setPackage(context.getPackageName());
context.sendBroadcast(broadcastIntent);
return;
}
Intent callIntent = new Intent(GBCallControlReceiver.ACTION_CALLCONTROL);
callIntent.putExtra("event", callEvent.event.ordinal());
callIntent.setPackage(context.getPackageName());

+ 1
- 0
app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java View File

@@ -686,6 +686,7 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
IntentFilter filter = new IntentFilter();
filter.addAction("android.intent.action.PHONE_STATE");
filter.addAction("android.intent.action.NEW_OUTGOING_CALL");
filter.addAction("nodomain.freeyourgadget.gadgetbridge.MUTE_CALL");
registerReceiver(mPhoneCallReceiver, filter);
}
if (mSMSReceiver == null) {

+ 4
- 1
app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casiogb6900/CasioGB6900DeviceSupport.java View File

@@ -35,6 +35,7 @@ import java.util.Calendar;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
import nodomain.freeyourgadget.gadgetbridge.devices.casiogb6900.CasioGB6900Constants;
@@ -437,7 +438,9 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
if(characteristicUUID.equals(CasioGB6900Constants.RINGER_CONTROL_POINT)) {
if(data[0] == 0x02)
{
LOG.info("Mute/ignore call event not yet supported by GB");
GBDeviceEventCallControl callControlEvent = new GBDeviceEventCallControl();
callControlEvent.event = GBDeviceEventCallControl.Event.IGNORE;
evaluateGBDeviceEvent(callControlEvent);
}
handled = true;
}

Loading…
Cancel
Save