Skip to content

Commit

Permalink
iOS: disable idle timer when running
Browse files Browse the repository at this point in the history
Resolves #1217
  • Loading branch information
osy committed Dec 29, 2020
1 parent a8d02d5 commit 53f5df0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Platform/iOS/Display/VMDisplayViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ - (BOOL)runInBackground {
return [self boolForSetting:@"RunInBackground"];
}

- (BOOL)disableIdleTimer {
return [self boolForSetting:@"DisableIdleTimer"];
}

#pragma mark - View handling

- (void)viewDidLoad {
Expand Down Expand Up @@ -166,6 +170,7 @@ - (void)virtualMachine:(UTMVirtualMachine *)vm transitionToState:(UTMVMState)sta
self.drivesButton.enabled = NO;
[self.pauseResumeButton setImage:[UIImage imageNamed:@"Toolbar Start"] forState:UIControlStateNormal];
[self.powerExitButton setImage:[UIImage imageNamed:@"Toolbar Exit"] forState:UIControlStateNormal];
[UIApplication sharedApplication].idleTimerDisabled = NO;
break;
}
case kVMPausing:
Expand Down Expand Up @@ -197,6 +202,7 @@ - (void)virtualMachine:(UTMVirtualMachine *)vm transitionToState:(UTMVMState)sta
self.drivesButton.enabled = YES;
[self.pauseResumeButton setImage:[UIImage imageNamed:@"Toolbar Pause"] forState:UIControlStateNormal];
[self.powerExitButton setImage:[UIImage imageNamed:@"Toolbar Power"] forState:UIControlStateNormal];
[UIApplication sharedApplication].idleTimerDisabled = self.disableIdleTimer;
break;
}
}
Expand Down
16 changes: 16 additions & 0 deletions Platform/iOS/Settings.bundle/Root.plist
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@
<key>DefaultValue</key>
<true/>
</dict>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>Idle</string>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Disable screen dimming when idle</string>
<key>Key</key>
<string>DisableIdleTimer</string>
<key>DefaultValue</key>
<false/>
</dict>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
Expand Down

0 comments on commit 53f5df0

Please sign in to comment.