This repository was archived by the owner on Mar 13, 2026. It is now read-only.
Allow end-users to override yielded number logic - #156
Open
hhff wants to merge 3 commits into
Open
Conversation
hhff
commented
Jun 2, 2019
| Method method = telephonyManager.getClass().getMethod("getLine1NumberForSubscriber", int.class); | ||
| return (String) method.invoke(telephonyManager, subId); | ||
| String number = (String) method.invoke(telephonyManager, subId); | ||
| return number; |
Author
There was a problem hiding this comment.
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?
Collaborator
There was a problem hiding this comment.
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.
Author
There was a problem hiding this comment.
thanks Luke! will look to find some time this weekend to finish it off 🙂
|
coply |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In order to override how the lib finds the device's phone number, this PR allows end users to do this: