From d4ea5dfd44ea28ac7e91339583a8a5bd8bc271fc Mon Sep 17 00:00:00 2001 From: Johannes Tysiak Date: Wed, 5 Sep 2018 20:41:01 +0200 Subject: [PATCH] Fix caller ID for incoming calls on Android 9 Fixes #1252 --- app/src/main/AndroidManifest.xml | 1 + .../gadgetbridge/activities/ControlCenterv2.java | 2 ++ .../gadgetbridge/externalevents/PhoneCallReceiver.java | 8 +++++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e9d2fc015..c9ecb863a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,6 +8,7 @@ --> + diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenterv2.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenterv2.java index 6071254e0..9a796beb9 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenterv2.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenterv2.java @@ -297,6 +297,8 @@ public class ControlCenterv2 extends AppCompatActivity wantedPermissions.add(Manifest.permission.READ_CONTACTS); if (ContextCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) == PackageManager.PERMISSION_DENIED) wantedPermissions.add(Manifest.permission.CALL_PHONE); + if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CALL_LOG) == PackageManager.PERMISSION_DENIED) + wantedPermissions.add(Manifest.permission.READ_CALL_LOG); if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_DENIED) wantedPermissions.add(Manifest.permission.READ_PHONE_STATE); if (ContextCompat.checkSelfPermission(this, Manifest.permission.PROCESS_OUTGOING_CALLS) == PackageManager.PERMISSION_DENIED) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/PhoneCallReceiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/PhoneCallReceiver.java index e5252eda5..e5ae08672 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/PhoneCallReceiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/PhoneCallReceiver.java @@ -41,9 +41,11 @@ public class PhoneCallReceiver extends BroadcastReceiver { if (intent.getAction().equals("android.intent.action.NEW_OUTGOING_CALL")) { mSavedNumber = intent.getExtras().getString("android.intent.extra.PHONE_NUMBER"); } else { - String number = intent.getExtras().getString(TelephonyManager.EXTRA_INCOMING_NUMBER); - int state = tm.getCallState(); - onCallStateChanged(context, state, number); + if (intent.hasExtra(TelephonyManager.EXTRA_INCOMING_NUMBER)) { + String number = intent.getExtras().getString(TelephonyManager.EXTRA_INCOMING_NUMBER); + int state = tm.getCallState(); + onCallStateChanged(context, state, number); + } } }