-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow end-users to override yielded number logic #156
base: master
Are you sure you want to change the base?
Allow end-users to override yielded number logic #156
Conversation
} else { | ||
try { | ||
Method method = telephonyManager.getClass().getMethod("getLine1NumberForSubscriber", int.class); | ||
return (String) method.invoke(telephonyManager, subId); | ||
String number = (String) method.invoke(telephonyManager, subId); | ||
return number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the only part I was a little sketchy on. In this implementation, the lib will still call getLine1NumberForSubscriber
rather than Utils.getMyPhoneNumber
How do you think we should handle this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used for dual SIM devices, and we don't want to lose this functionality. I would probably make some kind of condition here
- If the user has more than one SIM card, then use this original reflection. You can find how many sim cards the user has, by querying this method and getting the length of the array: https://developer.android.com/reference/android/telephony/SubscriptionManager.html#getActiveSubscriptionInfoList()
- If the user has not provided a custom override, then use this original reflection.
So, only use the new Utils.getMyPhoneNumber(context)
if the user has one SIM card and the implementing app has actually provided an override.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks Luke! will look to find some time this weekend to finish it off 🙂
coply |
In order to override how the lib finds the device's phone number, this PR allows end users to do this: