Script to "unlock" or emulate swipe up on Android Device?

CR
Chris R.
SkyBitz - End User

Hi,

I was looking to see if anyone was aware of a script for Android that would essentially unlock the device or perform the same thing as a swipe up on the device? 

The reason for this script is I'm writing some javascript that will check if a particular application is running in the foreground and then perform an update if it is not running.  When the device screen times out and goes black, the script can no longer return what is in the foreground.  We don't have passwords/PINs on the devices, so the screen timeout is activating and just requires a home button and swipe up (page up in remote) to get back into the device.

If anyone knows of a better way to go about doing this in general, I'm all ears.  For context, my Javascript looks like below:

var ABC = 'com.abc';
var foregroundActivities = mobicontrol.app.foregroundActivities;
if (foregroundActivities != null) {
    foregroundActivities.forEach(function (activity) {
        if (activity.packageName = ABC) {mobicontrol.log.info("App is running, not upgrading automatically.  Perform update manually.")}
        if (activity.packageName != ABC) {
            mobicontrol.log.info("App is not running, upgrading.")
            mobicontrol.app.stop('com.abc');
            mobicontrol.packages.install('/mnt/sdcard/MobiControl/Packages/LatestRelease.pcg');
        }
    });
}

function onFinish(result) {
    if (result.isSuccessful) {
        mobicontrol.app.start('com.abc');
        mobicontrol.log.info("App has been updated.")
    }
}

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

For starters, SOTI should really offer this sort of capability as a native feature. Only updating an app when it is not in use is such a common need that it should just be a function of a Profile Assignment. 

Given that it is not a native feature, I applaud your effort to try and achieve this functionality through scripting. The general problem that you're trying to solve is only updating a given end user application if the device (and the app in question) are not actively in use. In thinking about the problem, if the device has timed out enough for the screen to have gone black, wouldn't that likely indicate that the device is not actively in use? Meaning, does it matter at that point what application is in the foreground if you've essentially verified that the device is not actively in use due to it being in a timed out state? 

CR
Chris R.
3 years ago

I agree with that statement.

Our devices are in heavy duty trucks across the US so a screen timeout could just be they are driving or between stops and don't need to access the dispatching platform.  Our app runs off of a sqlite database and an application upgrade could mean database schema changes, etc... which will cause transactional data loss if they are actively logged into the application.  It's pretty imperative that our application not be in use. 

It's hard for us because a lot of times these vehicles run 24/7 and are only down during shift changes.  I wish there was another way to trigger the update on the device side (device boot or similar) but the only thing I can come up with is javascript as part of a profile with a scheduled task running the script on intervals.

We used to run on Windows CE devices.  It was easy there as we could load the updated version in 2577 and it would install on the next device boot.

G
GKMOD@SOTI
3 years ago

Hello Chris,


Thanks for your post!


We have legacy script for unlock only. https://www.soti.net/mc/help/javascriptapi/en/index.html which we can send via MC javascript. anything outside of that is out of our scope.

If this resolves your query, please mark this post as the solution. Also, feel free to reach out if you need clarification or have any questions.

Regards,

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