1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-24 19:06:53 +01:00

Merge pull request #1253 from skweee/android9callerid

Fix caller ID for incoming calls on Android 9
This commit is contained in:
Carsten Pfeiffer 2018-09-05 21:37:24 +02:00 committed by GitHub
commit 449184c591
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

View File

@ -8,6 +8,7 @@
-->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.CALL_PHONE" />

View File

@ -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)

View File

@ -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);
}
}
}