Script on Lockscreen enter

Solved
E
Eduard
wacker

Hello, I am trying to run a script for devices that are inactive, meaning the lockscreen is entered. Is there a way to run a script, if a device enters the lockscreen or even better if it is staying for a few minutes on the lockscreen? 

I could imagine that this would be possible with the Signal Policy, but there is no option for this.

Best, Eduard

2 years ago
Android Scripting
ANSWERS
MD
Matt Dermody Diamond Contributor
2 years ago

With the javascripting you can have a script verify what app is currently in the foreground. You could use this concept to have your script run, and let the script itself check to see if the lockdown is the app in the foreground as an indication of not being in use. You then could use something like a Task Scheduler Profile to run your script regularly on the device. So instead of having some criteria validated before your script is executed, run the script all the time but put the validation criteria within the script. 

If App in Foreground = Lockdown
- Then: rest of script
Else
-Exit

Solution
E
Eduard
2 years ago

Ok, thanks to pointing me to that. For someone that is searching the same, I use this script:

var foregroundActivities = mobicontrol.app.foregroundActivities;

if (foregroundActivities.length > 0) {

mobicontrol.log.info(foregroundActivities.length);

} else {

mobicontrol.log.info("No activity is in foreground. Device is unused.");

mobicontrol.log.info("Updating OS");

}

As you see in the code, I am trying to update the device, if the device is not used. However, I am trying to update via Zebra Lifeguard OTA. Is there a script command to instruct the device to execute the OTA Update? I only know the install_update /path/to/file, but I do not want to download the file like this.

Best,

Eduard

ZC
Zafer Cigdem
2 years ago

Hi Eduard,

What you can do is; inside of your JSON code you can insert creating a text file or .ini file on the devices and at the end of the day, you can use a custom data. As an example; let's say the condition is met, you created an .ini file on the device at %sdcard%/Download\your_file_name.ini. You can create a custom data and you can read this .ini file from webconsole by using a custom data. And after that you can relocate/move these devices to another folder, and trigger the OS upgrade or such.

Here is a similar method you can have a look: SOTI Discussion Forum

it's briefly below 3 line code:

var your_ini_file = new mobicontrol.io.File('/sdcard/Download/your_ini_file_for_custom_data.ini');
var ini_textContent= "[Section_name_here]\n any_custom_value_here=" ;
your_ini_file.writeText(ini_textContent);

I hope it helps. 

Zafer

E
Eduard
2 years ago

Thanks, this is an interesting approach.

However, "let's say the condition is met" is hard to do. How to know if there is an Lifeguard OTA update available?

Best,

Eduard

ZC
Zafer Cigdem
2 years ago

This is a different question but, what you can do as one of the alternative option is that, you can create a Virtual group and you can list devices whose OEM version is less than your requested version. And you can create a FileSync rule to only these devices to execute the JS script, so you can be sure that it's old OEM version or such. I hope it helps. Thanks 

Zafer

E
Eduard
2 years ago

Hi Matt, do you  have an update on this?

A
AMMOD@SOTI
2 years ago

Hi Eduard, 

Thank you, for engaging with SOTI Pulse. We appreciate your participation, Matt and Zafer, for providing responses to the post.

We are pleased to hear that you have found a solution to your query. "Thank you, Matt, for providing a solution to the customer's question. Your expertise and willingness to help are greatly appreciated!

If you have any additional questions or concerns, please don't hesitate to reach out. We're dedicated to providing assistance and support.

Kind regards,

Technical Support | SOTI Inc. |1.905.624.9828 | support@soti.net | www.soti.net |