-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update operatingSystemVersion on MacOS/iOS to return system version i…
…nstead of kernel version Platform.operatingSystemVersion on MacOS/iOS returns the version of the kernel. It should instead returns system version. This cl will try to use recently added "kern.osproductversion" to get the system version. If it failed, try to read from "SystemVersion.plist". Falls back to original kernal version if none of them succeed. Bug: #41725 Change-Id: Ibbf78f10dc6d21b79d83d82fbcdacfd22ebc716d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151165 Reviewed-by: Zach Anderson <zra@google.com> Commit-Queue: Zichang Guo <zichangguo@google.com>
- Loading branch information
Showing
6 changed files
with
158 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
#ifndef RUNTIME_BIN_PLATFORM_MACOS_H_ | ||
#define RUNTIME_BIN_PLATFORM_MACOS_H_ | ||
|
||
#if !defined(RUNTIME_BIN_PLATFORM_H_) | ||
#error Do not include platform_macos.h directly; | ||
#error use platform.h instead. | ||
#endif | ||
|
||
namespace dart { | ||
namespace bin { | ||
|
||
// This function extracts OSVersion from SystemVersion.plist. | ||
// The format of input should be: | ||
// <key>ProductVersion</key> | ||
// <string>10.15.4</string> | ||
// Returns the string representation of OSVersion. For example, "10.15.4" will | ||
// be returned in the previous example. | ||
char* ExtractsOSVersionFromString(char* str); | ||
|
||
} // namespace bin | ||
} // namespace dart | ||
|
||
#endif // RUNTIME_BIN_PLATFORM_MACOS_H_ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
#if defined(HOST_OS_MACOS) | ||
#include "bin/platform.h" | ||
#include "vm/unit_test.h" | ||
|
||
namespace dart { | ||
|
||
TEST_CASE(Platform_ExtractsOSVersionFromString) { | ||
char str[] = | ||
"some overheads\n<key>ProductVersion</key>\nsome bytes<string>Fake " | ||
"version</string>"; | ||
char* result = bin::ExtractsOSVersionFromString(str); | ||
EXPECT(result != NULL); | ||
EXPECT_STREQ("Fake version", result); | ||
|
||
EXPECT(bin::ExtractsOSVersionFromString("<key>ProductVersion</key>") == NULL); | ||
|
||
// Incomplete file | ||
EXPECT(bin::ExtractsOSVersionFromString( | ||
"<key>ProductVersion</key><string>Fake version</string") != NULL); | ||
|
||
// A copy of actual SystemVersion.plist on mac. | ||
str = | ||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" | ||
"<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" " | ||
"\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" | ||
"<plist version=\"1.0\">\n" | ||
"<dict>\n" | ||
" <key>ProductBuildVersion</key>\n" | ||
" <string>19E287</string>\n" | ||
" <key>ProductCopyright</key>\n" | ||
" <string>1983-2020 Apple Inc.</string>\n" | ||
" <key>ProductName</key>\n" | ||
" <string>Mac OS X</string>\n" | ||
" <key>ProductUserVisibleVersion</key>\n" | ||
" <string>10.15.4</string>\n" | ||
" <key>ProductVersion</key>\n" | ||
" <string>10.15.4</string>\n" | ||
" <key>iOSSupportVersion</key>\n" | ||
" <string>13.4</string>\n" | ||
"</dict>\n" | ||
"</plist>" | ||
|
||
result = bin::ExtractsOSVersionFromString(str); | ||
EXPECT(result != NULL); | ||
EXPECT_STREQ("10.15.4", result); | ||
} | ||
|
||
} // namespace dart | ||
#endif // defined(HOST_OS_MACOS) |