mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-25 09:57:32 +09:00
Issue #1905 - Part 1 - Implement detection of Monterey (12.x), Intel emulation and fix required OS version check.
This commit is contained in:
parent
9fa9622d5b
commit
8cee7f2b18
3 changed files with 45 additions and 3 deletions
|
|
@ -89,7 +89,7 @@ NS_IMETHODIMP nsNativeAppSupportCocoa::Start(bool *_retval)
|
||||||
// alert here. But the alert's message and buttons would require custom
|
// alert here. But the alert's message and buttons would require custom
|
||||||
// localization. So (for now at least) we just log an English message
|
// localization. So (for now at least) we just log an English message
|
||||||
// to the console before quitting.
|
// to the console before quitting.
|
||||||
if (major < 10 || minor < 6) {
|
if (major < 10 || (major == 10 && minor < 7)) {
|
||||||
NSLog(@"Minimum OS version requirement not met!");
|
NSLog(@"Minimum OS version requirement not met!");
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,12 @@ public:
|
||||||
static bool OnMojaveOrLater();
|
static bool OnMojaveOrLater();
|
||||||
static bool OnCatalinaOrLater();
|
static bool OnCatalinaOrLater();
|
||||||
static bool OnBigSurOrLater();
|
static bool OnBigSurOrLater();
|
||||||
|
static bool OnMontereyOrLater();
|
||||||
|
|
||||||
static bool IsAtLeastVersion(int32_t aMajor, int32_t aMinor, int32_t aBugFix=0);
|
static bool IsAtLeastVersion(int32_t aMajor, int32_t aMinor, int32_t aBugFix=0);
|
||||||
|
|
||||||
|
static bool ProcessIsRosettaTranslated();
|
||||||
|
|
||||||
// These are utilities that do not change or depend on the value of mOSXVersion
|
// These are utilities that do not change or depend on the value of mOSXVersion
|
||||||
// and instead just encapsulate the encoding algorithm. Note that GetVersion
|
// and instead just encapsulate the encoding algorithm. Note that GetVersion
|
||||||
// actually adjusts to the lowest supported OS, so it will always return
|
// actually adjusts to the lowest supported OS, so it will always return
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#define MACOS_VERSION_10_15_HEX 0x000A0F00
|
#define MACOS_VERSION_10_15_HEX 0x000A0F00
|
||||||
#define MACOS_VERSION_10_16_HEX 0x000A1000
|
#define MACOS_VERSION_10_16_HEX 0x000A1000
|
||||||
#define MACOS_VERSION_11_0_HEX 0x000B0000
|
#define MACOS_VERSION_11_0_HEX 0x000B0000
|
||||||
|
#define MACOS_VERSION_12_0_HEX 0x000C0000
|
||||||
|
|
||||||
#include "nsCocoaFeatures.h"
|
#include "nsCocoaFeatures.h"
|
||||||
#include "nsCocoaUtils.h"
|
#include "nsCocoaUtils.h"
|
||||||
|
|
@ -33,6 +34,7 @@
|
||||||
#include "nsObjCExceptions.h"
|
#include "nsObjCExceptions.h"
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
int32_t nsCocoaFeatures::mOSVersion = 0;
|
int32_t nsCocoaFeatures::mOSVersion = 0;
|
||||||
|
|
||||||
|
|
@ -196,14 +198,51 @@ nsCocoaFeatures::OnCatalinaOrLater()
|
||||||
/* static */ bool
|
/* static */ bool
|
||||||
nsCocoaFeatures::OnBigSurOrLater()
|
nsCocoaFeatures::OnBigSurOrLater()
|
||||||
{
|
{
|
||||||
// Account for the version being 10.16 (which occurs when the
|
// Account for the version being 10.16 or 11.0 on Big Sur.
|
||||||
// application is linked with an older SDK) or 11.0 on Big Sur.
|
// The version is reported as 10.16 if SYSTEM_VERSION_COMPAT is set to 1,
|
||||||
|
// or if SYSTEM_VERSION_COMPAT is not set and the application is linked
|
||||||
|
// with a pre-Big Sur SDK.
|
||||||
|
// We should set SYSTEM_VERSION_COMPAT to 0 in its Info.plist, so it'll
|
||||||
|
// usually see the correct 11.* version, despite being linked against an
|
||||||
|
// old SDK. However, it still sees the 10.16 compatibility version when
|
||||||
|
// launched from the command line, see bug 1727624. (This only applies to
|
||||||
|
// the Intel build - the arm64 build is linked against a Big Sur SDK and
|
||||||
|
// always sees the correct version.)
|
||||||
return ((macOSVersion() >= MACOS_VERSION_10_16_HEX) ||
|
return ((macOSVersion() >= MACOS_VERSION_10_16_HEX) ||
|
||||||
(macOSVersion() >= MACOS_VERSION_11_0_HEX));
|
(macOSVersion() >= MACOS_VERSION_11_0_HEX));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */ bool nsCocoaFeatures::OnMontereyOrLater()
|
||||||
|
{
|
||||||
|
// Monterey pretends to be 10.16 and is indistinguishable from Big Sur.
|
||||||
|
// In practice, this means that an Intel build can return false
|
||||||
|
// from this function if it's launched from the command line, see bug 1727624.
|
||||||
|
// This will not be an issue anymore once we link against the Big Sur SDK.
|
||||||
|
return (macOSVersion() >= MACOS_VERSION_12_0_HEX);
|
||||||
|
}
|
||||||
|
|
||||||
/* static */ bool
|
/* static */ bool
|
||||||
nsCocoaFeatures::IsAtLeastVersion(int32_t aMajor, int32_t aMinor, int32_t aBugFix)
|
nsCocoaFeatures::IsAtLeastVersion(int32_t aMajor, int32_t aMinor, int32_t aBugFix)
|
||||||
{
|
{
|
||||||
return macOSVersion() >= GetVersion(aMajor, aMinor, aBugFix);
|
return macOSVersion() >= GetVersion(aMajor, aMinor, aBugFix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns true if the process is running under Rosetta translation. Returns
|
||||||
|
* false if running natively or if an error was encountered. We use the
|
||||||
|
* `sysctl.proc_translated` sysctl which is documented by Apple to be used
|
||||||
|
* for this purpose. Note: using this in a sandboxed process requires allowing
|
||||||
|
* the sysctl in the sandbox policy.
|
||||||
|
*/
|
||||||
|
/* static */ bool nsCocoaFeatures::ProcessIsRosettaTranslated()
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
size_t size = sizeof(ret);
|
||||||
|
if (sysctlbyname("sysctl.proc_translated", &ret, &size, NULL, 0) == -1) {
|
||||||
|
if (errno != ENOENT) {
|
||||||
|
fprintf(stderr, "Failed to check for translation environment\n");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return (ret == 1);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue