-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(core): Utils.isSimulatorOrEmulator #9065
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
base: main
Are you sure you want to change the base?
Conversation
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.
@triniwiz and I will add some extra security detections in this as well. Thanks @alexziskind1 👏
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.
Why add this? Shouldn't simulator be just !isRealDevice()
why add extra bloat to the framework for a unneeded helper function?
Second, even if we really wanted the "helper" function isSimulatorOrEmulator
shouldn't it just be return !isRealDevice()
so all actual detection code is contained in one function rather than split into two places that could need changes in the future?
Are you sure that test is enough on android ? I have something like more complex https://github.com/nativescript-community/extendedinfo/blob/master/src/extendedinfo.android.ts#L4 And to.me that name is far too long :) we don't really care about the fact that iios and android don't use the se name convention |
Hi, I think that @farfromrefug is a better solution, in fact I've adopted solution from flutter: |
@mapo80 your link was wrong here is the good link https://github.com/flutter/plugins/blob/master/packages/device_info/device_info/android/src/main/java/io/flutter/plugins/deviceinfo/MethodCallHandlerImpl.java |
Fixed, thanks! |
This is the wrong fix, isRealDevice should be fixed as all places it is being used is a truthy value and the .d.ts shows it is supposed to return a boolean, so the isRealDevice should be fixed not an additional unneeded helper.
This comment was marked as abuse.
This comment was marked as abuse.
@NathanaelA The reason behind the new function implementation is that it does not present a breaking change. If isRealDevice is fixed then it can lead to breaking changes, since other framework functions (and potentially many client apps) use the result of this call incorrectly. In other words, on iOS when the device is real, it returns paths, which are being used elsewhere - removing this would result in a breaking change. |
@farfromrefug perhaps there may be a style guide that states how long function names can be and how specific they need to be, but for now, I don't think there is one. Renaming this is fine as long as it is clear what the function does. Calling the function |
This comment was marked as abuse.
This comment was marked as abuse.
@NathanaelA totally agree with you that |
This comment was marked as abuse.
This comment was marked as abuse.
@NathanaelA fair point. However, |
This comment was marked as abuse.
This comment was marked as abuse.
I for one did not even know it was there! I doubt many apps/ plugins use it today |
testing |
PR Checklist
What is the current behavior?
No function currently exists to allow a check for a simulator or emulator
What is the new behavior?
The new Util function
isSimulatorOrEmulator
handles thisFixes/Implements/Closes #9064 .