Skip to content

Allow apps to block screen locking/screensaver #4534

Closed
@mbaklor

Description

Checklist

  • I have searched the issue tracker for open issues that relate to the same feature, before opening a new one.
  • This issue only relates to a single feature. I will open new issues for any other features.

Is your feature request related to a problem?

I was thinking of building a mobile monitoring app, and wanted the screen to remain on while the app is running.

I looked into it and there are simple native APIs for it.

On iOS you can call

[[NSOperationQueue mainQueue] addOperationWithBlock:^ {
    [UIApplication sharedApplication].idleTimerDisabled = YES;
}];

(Thanks Andy for finding this, I only found the Swift API)

On Android it's split into two options, either keep screen on or keep CPU running, not entirely sure we need the latter and the former doesn't require permissions:

public class MainActivity extends Activity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  }
}

https://developer.android.com/develop/background-work/background-tasks/scheduling/wakelock
It looks like there's also a C version of this code but I could only find mention of it and not the API itself.

Is it possible to construct a solution with the existing API?

No response

Describe the solution you'd like to see.

I think probably just add to the mobile driver API a method that calls the native APIs, preferably something that can be set and reset, so you can keep screen on for specific long lasting tasks and let it lock otherwise

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions