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 #endif // TARGET_OS_OSX
26 bool IsAppleInternalBuild(void)
28 return (os_variant_has_internal_diagnostics("com.apple.mDNSResponder") != false);
32 util_enclosure_color_t
33 util_get_enclosure_color_str(char * const out_str, uint8_t len, uint8_t *out_size)
35 util_enclosure_color_t color_type = util_enclosure_color_none;
36 if (@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)) {
37 UTHardwareColor enclosureColor;
38 if (_UTHardwareColorGetCurrentEnclosureColor(&enclosureColor)) {
39 switch (enclosureColor.type) {
40 case UTHardwareColorTypeRGB: {
41 int size = snprintf(out_str, len, "%u,%u,%u",
42 enclosureColor.rgb.r, enclosureColor.rgb.g, enclosureColor.rgb.b);
44 color_type = util_enclosure_color_rgb;
49 case UTHardwareColorTypeIndexed: {
50 int size = snprintf(out_str, len, "%i", enclosureColor.index);
52 color_type = util_enclosure_color_index;
67 IOReturn rGetDeviceColor = IOPlatformGetDeviceColor(kIOPlatformDeviceEnclosureColorKey,
69 if (kIOReturnSuccess == rGetDeviceColor)
71 int size = snprintf(out_str, len, "%u,%u,%u", red, green, blue);
73 color_type = util_enclosure_color_rgb;
80 #else // TARGET_OS_OSX
81 util_enclosure_color_t
82 util_get_enclosure_color_str(char * const __unused out_str, uint8_t __unused len, uint8_t * __unused out_size)
84 return util_enclosure_color_none;
86 #endif // TARGET_OS_OSX