Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
246 views
in Technique[技术] by (71.8m points)

android - How can you programmatically lock a Chromebook?

I have a Chrome OS device, and I want to programmatically lock the screen when a timer has expired (when a child has used up their available screen time). The Chromebook supports Android apps, but I can't find much information about how to do this specific to Chrome OS. I have found information about using the DevicePolicyManager LockNow Android function, which I really thought would do it - but it doesn't. It locks my Android phone just fine, but when I deploy it to my Chromebook (an Acer R 13), the line hits, continues without issue, but does nothing. I get the proper security prompt the first time to set the app as a device admin, but the LockNow code appears to do absolutely nothing despite working perfectly on my Samsung Note 9.

Does anyone know of some documentation or able to point me in the right direction? Thanks

question from:https://stackoverflow.com/questions/65649896/how-can-you-programmatically-lock-a-chromebook

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you are using Chrome OS Enterprise, you can set a device policy for locking the screen via the ScreenLockDelay policy. From the documentation :

Specifies the length of time without user input after which the screen is locked when running on AC power or battery.

When the length of time is set to a value greater than zero, it represents the length of time that the user must remain idle before Google Chrome OS locks the screen.

After further reading your question, it seems that you actually want to lock the screen after an arbitrary amount of time from when the user has logged in. Based on that information, I would look at the Chrome OS Extensions API. If your user is primarily using the web browser, you can redirect to a web page after a set amount of time via an extension. If the user is also using Android apps, then you may want to ask the Chrome team to add in a enterprise policy to allow locking the device after a set amount of time by logging a bug.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...