Gadgetbridge: Incoming calls show "Unknown" caller on Android 9

Created on 4 Sep 2018  路  2Comments  路  Source: Freeyourgadget/Gadgetbridge

Before opening an issue please confirm the following:

  • [X] I have read the wiki, and I didn't find a solution to my problem / an answer to my question.
  • [X] I have searched the issues, and I didn't find a solution to my problem / an answer to my question.
  • [X] If you upload an image or other content, please make sure you have read and understood the github policies and terms of services

Your issue is:

After the upgrade to Android 9.0 on my Pixel device, incoming calls do no longer show the caller on the wearable. Instead the caller is identified as "Unknown".

This is most likely due to a behavior change in Android 9.0 concerning privacy. See the section "Restricted access to phone numbers" right here:
https://developer.android.com/about/versions/pie/android-9.0-changes-all#privacy-changes-all

Restricted access to phone numbers

Apps running on Android 9 cannot read phone numbers or phone state without first acquiring the READ_CALL_LOG permission, in addition to the other permissions that your app's use cases require.

Phone numbers associated with incoming and outgoing calls are visible in the phone state broadcast, such as for incoming and outgoing calls and are accessible from the PhoneStateListener class. Without the READ_CALL_LOG permission, however, the phone number field that's provided in PHONE_STATE_CHANGED broadcasts and through PhoneStateListener is empty.

To read phone numbers from phone state, update your app to request the necessary permissions based on your use case:

  • To read numbers from the PHONE_STATE intent action, you need both the READ_CALL_LOG permission and the READ_PHONE_STATE permission.
  • To read numbers from onCallStateChanged(), you need the READ_CALL_LOG permission only. You don't need the READ_PHONE_STATE permission.

Your wearable device is:

Pebble 2 HR (silk, FW 4.3)

Your android version is:

Android 9.0

Your Gadgetbridge version is:

0.29.1

android integrationnotifications

Most helpful comment

I am working on a pull request to fix this issue. I had already identified and attempted the trivial change you suggested yesterday, but unfortunately it's not sufficient yet.

After adding the missing permission, the PhoneCallReceiver actually receives two broadcasts on incoming calls. Only one of these contains a not-null TelephonyManager.EXTRA_INCOMING_NUMBER. I am currently trying to figure out the correct way to handle this, especially without compromising the functionality in earlier versions of Android.

As soon as I find some time to come up with a working fix, I will submit a pull request, however I will need some help testing on earlier versions of Android.

All 2 comments

Would it be possible for you to compile from source to test? The change is trivial, just add two lines in https://github.com/Freeyourgadget/Gadgetbridge/blob/master/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenterv2.java#L289 , something like:

        if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CALL_LOG) == PackageManager.PERMISSION_DENIED)
            wantedPermissions.add(Manifest.permission.READ_CALL_LOG);

As you can see in that file, we already request the READ_PHONE_STATE permission, hence the other permission should be sufficient.

If you can perform the change and see that it works afterwards, feel free to submit a pull request with this change!
If you cannot perform the change, we can do it blindly but we will only discover if it works after releasing a new version.

I am working on a pull request to fix this issue. I had already identified and attempted the trivial change you suggested yesterday, but unfortunately it's not sufficient yet.

After adding the missing permission, the PhoneCallReceiver actually receives two broadcasts on incoming calls. Only one of these contains a not-null TelephonyManager.EXTRA_INCOMING_NUMBER. I am currently trying to figure out the correct way to handle this, especially without compromising the functionality in earlier versions of Android.

As soon as I find some time to come up with a working fix, I will submit a pull request, however I will need some help testing on earlier versions of Android.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cpfeiffer picture cpfeiffer  路  4Comments

wYhyzByH picture wYhyzByH  路  4Comments

robalvsan picture robalvsan  路  3Comments

ruimnetob picture ruimnetob  路  4Comments

gianlucapir picture gianlucapir  路  7Comments