OSThermalNotification.h (5396B) - Raw
1 /* 2 * Copyright (c) 2007 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24 #ifndef _OSTHERMALNOTIFICATION_H_ 25 #define _OSTHERMALNOTIFICATION_H_ 26 27 #include <_bounds.h> 28 #include <sys/cdefs.h> 29 #include <Availability.h> 30 #include <TargetConditionals.h> 31 32 _LIBC_SINGLE_BY_DEFAULT() 33 34 /* 35 ** OSThermalNotification.h 36 ** 37 ** Notification mechanism to alert registered tasks when device thermal conditions 38 ** reach certain thresholds. Notifications are triggered in both directions 39 ** so clients can manage their memory usage more and less aggressively. 40 ** 41 */ 42 43 __BEGIN_DECLS 44 45 /* Define pressure levels usable by OSThermalPressureLevel */ 46 typedef enum { 47 #if TARGET_OS_OSX || TARGET_OS_MACCATALYST 48 kOSThermalPressureLevelNominal = 0, 49 kOSThermalPressureLevelModerate, 50 kOSThermalPressureLevelHeavy, 51 kOSThermalPressureLevelTrapping, 52 kOSThermalPressureLevelSleeping 53 #else 54 kOSThermalPressureLevelNominal = 0, 55 kOSThermalPressureLevelLight = 10, 56 kOSThermalPressureLevelModerate = 20, 57 kOSThermalPressureLevelHeavy = 30, 58 kOSThermalPressureLevelTrapping = 40, 59 kOSThermalPressureLevelSleeping = 50 60 #endif 61 } OSThermalPressureLevel; 62 63 /* 64 ** External notify(3) string for thermal pressure level notification 65 */ 66 __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0) 67 extern const char * const kOSThermalNotificationPressureLevelName; 68 69 70 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && \ 71 __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_2_0 72 73 typedef enum { 74 OSThermalNotificationLevelAny = -1, 75 OSThermalNotificationLevelNormal = 0, 76 } OSThermalNotificationLevel; 77 78 extern OSThermalNotificationLevel _OSThermalNotificationLevelForBehavior(int) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_4_2); 79 extern void _OSThermalNotificationSetLevelForBehavior(int, int) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_4_2); 80 81 enum { 82 kOSThermalMitigationNone, 83 kOSThermalMitigation70PercentTorch, 84 kOSThermalMitigation70PercentBacklight, 85 kOSThermalMitigation50PercentTorch, 86 kOSThermalMitigation50PercentBacklight, 87 kOSThermalMitigationDisableTorch, 88 kOSThermalMitigation25PercentBacklight, 89 kOSThermalMitigationDisableMapsHalo, 90 kOSThermalMitigationAppTerminate, 91 kOSThermalMitigationDeviceRestart, 92 kOSThermalMitigationThermalTableReady, 93 kOSThermalMitigationCount 94 }; 95 96 #define OSThermalNotificationLevel70PercentTorch _OSThermalNotificationLevelForBehavior(kOSThermalMitigation70PercentTorch) 97 #define OSThermalNotificationLevel70PercentBacklight _OSThermalNotificationLevelForBehavior(kOSThermalMitigation70PercentBacklight) 98 #define OSThermalNotificationLevel50PercentTorch _OSThermalNotificationLevelForBehavior(kOSThermalMitigation50PercentTorch) 99 #define OSThermalNotificationLevel50PercentBacklight _OSThermalNotificationLevelForBehavior(kOSThermalMitigation50PercentBacklight) 100 #define OSThermalNotificationLevelDisableTorch _OSThermalNotificationLevelForBehavior(kOSThermalMitigationDisableTorch) 101 #define OSThermalNotificationLevel25PercentBacklight _OSThermalNotificationLevelForBehavior(kOSThermalMitigation25PercentBacklight) 102 #define OSThermalNotificationLevelDisableMapsHalo _OSThermalNotificationLevelForBehavior(kOSThermalMitigationDisableMapsHalo) 103 #define OSThermalNotificationLevelAppTerminate _OSThermalNotificationLevelForBehavior(kOSThermalMitigationAppTerminate) 104 #define OSThermalNotificationLevelDeviceRestart _OSThermalNotificationLevelForBehavior(kOSThermalMitigationDeviceRestart) 105 106 /* Backwards compatibility */ 107 #define OSThermalNotificationLevelWarning OSThermalNotificationLevel70PercentBacklight 108 #define OSThermalNotificationLevelUrgent OSThermalNotificationLevelAppTerminate 109 #define OSThermalNotificationLevelCritical OSThermalNotificationLevelDeviceRestart 110 111 /* 112 ** Simple polling interface to detect current thermal level 113 */ 114 __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_2_0) 115 extern OSThermalNotificationLevel OSThermalNotificationCurrentLevel(void); 116 117 /* 118 ** External notify(3) string for manual notification setup 119 */ 120 __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_2_0) 121 extern const char * const kOSThermalNotificationName; 122 123 /* 124 ** External notify(3) string for alerting user of a thermal condition 125 */ 126 __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_6_0) 127 extern const char * const kOSThermalNotificationAlert; 128 129 /* 130 ** External notify(3) string for notifying system the options taken to resolve thermal condition 131 */ 132 __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_6_0) 133 extern const char * const kOSThermalNotificationDecision; 134 135 #endif // __IPHONE_OS_VERSION_MIN_REQUIRED 136 137 __END_DECLS 138 139 #endif /* _OSTHERMALNOTIFICATION_H_ */