mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-07-08 22:51:37 +02:00
bf6abe9672
Incoming calls are no longer send as simple notifications but properly as incoming calls. The Pebble will vibrate until the call is taken or dismissed. It is not yet possible to dismiss the call using the Pebble button.
30 lines
1.3 KiB
Java
30 lines
1.3 KiB
Java
package nodomain.freeyourgadget.gadgetbridge;
|
|
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.telephony.TelephonyManager;
|
|
|
|
public class PhoneCallReceiver extends BroadcastReceiver {
|
|
|
|
@Override
|
|
public void onReceive(Context context, Intent intent) {
|
|
String phoneState = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
|
|
byte state = 0;
|
|
if (phoneState.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
|
|
state = PebbleProtocol.PHONECONTROL_INCOMINGCALL;
|
|
} else if (phoneState.equals(TelephonyManager.EXTRA_STATE_IDLE) || phoneState.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
|
|
state = PebbleProtocol.PHONECONTROL_END;
|
|
}
|
|
|
|
if (state != 0) {
|
|
String phoneNumber = intent.hasExtra(TelephonyManager.EXTRA_INCOMING_NUMBER) ? intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER) : "";
|
|
Intent startIntent = new Intent(context, BluetoothCommunicationService.class);
|
|
startIntent.setAction(BluetoothCommunicationService.ACTION_INCOMINGCALL);
|
|
startIntent.putExtra("incomingcall_phonenumber", phoneNumber);
|
|
startIntent.putExtra("incomingcall_state", state);
|
|
context.startService(startIntent);
|
|
}
|
|
}
|
|
}
|