getodk / collect

ODK Collect is an Android app for filling out forms. It's been used to collect billions of data points in challenging environments around the world. Contribute and make the world a better place! ✨📋✨
https://docs.getodk.org/collect-intro
Other
717 stars 1.38k forks source link

The device's phone number can't be read #5482

Closed grzesiek2010 closed 1 year ago

grzesiek2010 commented 1 year ago

Problem description

The device's phone number can't be read. If we set the phone number in settings on our own it works well.

Steps to reproduce the problem

  1. Install a fresh version of ODK Collect

  2. Go to Settings -> User and device identity -> Form metadata

  3. Phone number should be displayed but we have Not available instead.

  4. Open the attached form: metadata.xlsx

  5. Phone number should be displayed in phonenumber question.

grzesiek2010 commented 1 year ago

I've discovered this issue working on https://github.com/getodk/collect/issues/4838 but it's not related (it doesn't have the same root cause).

seadowg commented 1 year ago

@grzesiek2010 is this broken across API levels?

grzesiek2010 commented 1 year ago

is this broken across API levels?

Yes, all devices and all android versions. I wonder how it is possible that no one had noticed that earlier.

seadowg commented 1 year ago

I'm thinking we should get this out as a hotfix then. Do you agree?

grzesiek2010 commented 1 year ago

I'm thinking we should get this out as a hotfix then. Do you agree?

Theoretically it's an obvious bug that should be fixed but it's not new, it's been like that for more than a year at least. So I'm not sure @lognaturel what do you think?

seadowg commented 1 year ago

From @grzesiek2010 in #5481:

Wow, I've tested it on emulators so everything was fine but I can confirm it's not always the case with real devices. One problem is that on newer devices an exception might be thrown which I could handle with the fix we already have in https://github.com/getodk/collect/pull/5483. But even if I do that an empty string is returned instead of the number I want. I've tried the current implementation with TelephonyManager, and also another one with SubscriptionManager and it's the same. Browsing StackOverflow I see that people claim there is no one perfect and reliable solution to read a phone number. Taking that into account and the fact that it has been broken for more than 2 years and no one has complained, maybe we should remove that at all and just let users enter their numbers manually? @lognaturel @seadowg what do you think?

Do we think getting the phone number has been broken on every device or will it have worked on some (with the existing implementation)?

grzesiek2010 commented 1 year ago

Do we think getting the phone number has been broken on every device or will it have worked on some (with the existing implementation)?

It has been broken on all devices. With my fix maybe it would work on some I don't know because we checked some real devices to no avail and it worked well only on emulators.

lognaturel commented 1 year ago

We've known automatically getting phone number was not consistently possible for some time so it makes sense to me that we didn't notice it was more broadly broken. As far as I know it has never been very broadly used and I think it's ok to explicitly remove ~, especially if it requires scary permissions~ .

lognaturel commented 1 year ago

I'm going to give this some more thought before we talk Tues.

lognaturel commented 1 year ago

We have decided to fully remove automatically getting phone numbers. We'll need to update some docs as well.