Upgrade to Pro — share decks privately, control downloads, hide ads and more …

発熱から iPhone を守る

発熱から iPhone を守る

モバチキ 〜Mobile Tips 共有会〜 #2
https://cyberagent.connpass.com/event/297940/

Mitsuharu Emoto

November 01, 2023
Tweet

More Decks by Mitsuharu Emoto

Other Decks in Programming

Transcript

  1.  1SPDFTT*OGP w ར༻୺຤ͷ৘ใऔಘ͢Δ"1* w /PUJ fi DBUJPO$FOUFSͰൃ೤ঢ়ଶͷมԽΛݕ஌Ͱ͖Δ NotificationCenter.default.addObserver( self,

    selector: #selector(monitorState), name: ProcessInfo.thermalStateDidChangeNotification, object: nil ) 10
  2. 5IFSNBM4UBUF nominal 😀 ೤ঢ়ଶ͸ਖ਼ৗൣғ಺Ͱ͢ fair 😅 ೤ঢ়ଶ͸΍΍ߴΊͰ͢ serious 🥵 ೤ঢ়ଶ͸ߴΊͰ͢

    critical 🔥 ೤ঢ়ଶ͸γεςϜͷੑೳʹେ͖ͳӨڹΛٴ΅͓ͯ͠ΓɺσόΠεΛ ྫྷ٫͢Δඞཁ͕͋Γ·͢ IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPOGPVOEBUJPOQSPDFTTJOGPUIFSNBMTUBUF let state = ProcessInfo.processInfo.thermalState ˞ֆจࣈ͸ࢲ͕Πϝʔδͨ͠୺຤ͷൃ೤ঢ়ଶ 11
  3.  "7$BQUVSF%FWJDF w ϥΠϒϏϡʔͳͲ"7$IBQUVSF4FTTJPOͰར༻͞ΕΔ૷ஔ͔Βऔಘ͢Δ w ੲͳ͕Βͷ,70Ͱ஋มԽΛ؂ࢹ͢Δ @objc private dynamic var

    videoDeviceInput: AVCaptureDeviceInput! … videoDeviceInput = try AVCaptureDeviceInput(device: videoDevice!) observe(\.videoDeviceInput.device.systemPressureState, options:.new){ [weak self] object, change in guard let self, let state = change.newValue else { return } self.monitorSystemPressureState(systemPressureState: state) } 12
  4. 4ZTUFN1SFTTVSF4UBUF-FWFM nominal 😀 γεςϜѹྗ͸ਖ਼ৗͰ͢ fair 😅 γεςϜѹྗ͕Θ͔ͣʹ্ঢ͍ͯ͠Δ serious 🥵 γεςϜѹྗ͕ඇৗʹߴ͘ͳ͍ͬͯΔ

    critical 🔥 γεςϜѹྗ͕ஶ্͘͠ঢ͍ͯ͠Δ shutdown ☠ γεςϜѹྗ͕ݶքΛ௒͍͑ͯΔͨΊɺΩϟϓ νϟγεςϜ͸γϟοτμ΢ϯ͍ͯ͠Δ IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPOBWGPVOEBUJPOBWDBQUVSFEFWJDFTZTUFNQSFTTVSFTUBUFMFWFM let level = systemPressureState.level ˞ֆจࣈ͸ࢲ͕Πϝʔδͨ͠୺຤ͷൃ೤ঢ়ଶ 13 w ѹྗʢෛՙʣ͸ɺԹ౓΍ ిྗྔͳͲ༷ʑͳ֎෦ཁ Ҽʹࠨӈ͞ΕΔ w ిؾճ࿏ʹ͓͍ͯɺҰൠ తʹʮෛՙ೤ʯͱߟ͑ ͯ໰୊ͳ͍Ͱ͢
  5. 4ZTUFN1SFTTVSF4UBUF'BDUPST w ཁҼ͸ݸผʹऔಘͰ͖Δ w CJUNBTL 0QUJPO4FU Ͱ ఆٛ͞ΕΔͷͰɺෳ߹త ͳཁҼΛऔಘͰ͖Δ w

    1SPTTFTT*OGPʹ΋ཁҼ ͕ཉ͍͠ʂ // bitmask of values indicating the factors // contributing to the current system pressure level. let factors = systemPressureState.factors if (factors == [.systemTemperature]) { // γεςϜશମͷߴ೤ͳෛՙ } if (factors == [.peakPower]) { // γεςϜͷϐʔΫిྗཁ͕݅όοςϦʔͷిྲྀ༰ྔΛ௒ա } if (factors == [.depthModuleTemperature]) { // ਂ౓৘ใΛऔಘ͢ΔϞδϡʔϧ͕ߴԹͰಈ࡞ } if (factors == [.cameraTemperature]) { // ΧϝϥϞδϡʔϧ͕ߴԹͰಈ࡞ʢiOS 17 Ҏ্ͷΈʣ } 14 IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPOBWGPVOEBUJPO BWDBQUVSFEFWJDFTZTUFNQSFTTVSFTUBUFGBDUPST
  6. ʢ͓·͚ʣ௥Ճ"1*͔Βͷߟ࡯ w J04 WJTJPO04 ͔ΒཁҼʹDBNFSB5FNQFSBUVSF͕௥Ճ͞Εͨ w "QQMF7JTJPO1SPʹ޲͚ͨ४උʁͱ༧૝͍ͯ͠·͢ w ຊମਖ਼໘ͷΧϝϥɺ֎෇͚ͷόοςϦʔͱ෺ཧతʹ೤ݯ͕཭Εͨ w

    ൃ೤ࣄނ͕ىͬͨ͜Βେ໰୊ʢ௨ৗͰ΋໰୊͕ͩɺಛʹ7JTJPO1SP͸಄ ʹ૷ண͢ΔͷͰʣͳͷͰɺൃ೤ରࡦ͸ͱͯ΋େ੾ʂ w ಄ͷۙ͘ʹ೤ݯ͕͋Δͱ਎ମʹӨڹ͋Γͦ͏ͳͷͰ஫ҙ͠ͳ͍ͱ 17