2 * Copyright (c) 2019-2020 Apple Inc. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * https://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #import "system_utilities.h"
18 #import <os/variant_private.h> // os_variant_has_internal_diagnostics
19 #import <TargetConditionals.h>
22 #import <UniformTypeIdentifiers/UniformTypeIdentifiersPriv.h>
23 #import <IOKit/platform/IOPlatformSupportPrivate.h>
24 #import <SoftLinking/WeakLinking.h>
25 #endif // TARGET_OS_OSX
27 bool IsAppleInternalBuild(void)
29 return (os_variant_has_internal_diagnostics("com.apple.mDNSResponder") != false);
33 WEAK_LINK_FORCE_IMPORT(_UTHardwareColorGetCurrentEnclosureColor);
35 static util_enclosure_color_t
36 _uti_get_enclosure_color_str(char * const out_str, uint8_t len, uint8_t *out_size)
38 util_enclosure_color_t color_type = util_enclosure_color_none;
39 if (@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)) {
40 if(_UTHardwareColorGetCurrentEnclosureColor) {
41 UTHardwareColor enclosureColor;
42 if (_UTHardwareColorGetCurrentEnclosureColor(&enclosureColor)) {
43 switch (enclosureColor.type) {
44 case UTHardwareColorTypeRGB: {
45 int size = snprintf(out_str, len, "%u,%u,%u",
46 enclosureColor.rgb.r, enclosureColor.rgb.g, enclosureColor.rgb.b);
47 if (size > 0 && size < len) {
48 color_type = util_enclosure_color_rgb;
53 case UTHardwareColorTypeIndexed: {
54 int size = snprintf(out_str, len, "%i", enclosureColor.index);
55 if (size > 0 && size < len) {
56 color_type = util_enclosure_color_index;
71 util_enclosure_color_t
72 util_get_enclosure_color_str(char * const out_str, uint8_t len, uint8_t *out_size)
74 util_enclosure_color_t color_type = _uti_get_enclosure_color_str(out_str, len, out_size);
75 if (color_type == util_enclosure_color_none) {
80 IOReturn rGetDeviceColor = IOPlatformGetDeviceColor(kIOPlatformDeviceEnclosureColorKey,
82 if (kIOReturnSuccess == rGetDeviceColor)
84 int size = snprintf(out_str, len, "%u,%u,%u", red, green, blue);
85 if (size > 0 && size < len) {
86 color_type = util_enclosure_color_rgb;
93 #else // TARGET_OS_OSX
94 util_enclosure_color_t
95 util_get_enclosure_color_str(char * const __unused out_str, uint8_t __unused len, uint8_t * __unused out_size)
97 return util_enclosure_color_none;
99 #endif // TARGET_OS_OSX