Send intent command via skript

Solved Locked
R
Rafael Gold Contributor
Dänisches Bettenlager GmbH & Co. KG

Hi,

we are using Mobicontol and Zebra TC51.

I run a skript when a device is not connnected for 1 minute (lesser time seem not possible).

The skript is only showing an Messagebox every Minute.

This works fine but i want that the device makes noise too. Didn't found anything for that only the send intent in skript commands.

With this it should be able to set a timer but i don't know how to set the interval etc. can someone help me with that?

Found this: 

Create a timer

To create a countdown timer, use the ACTION_SET_TIMER action and specify timer details such as the duration using extras defined below.

Action
ACTION_SET_TIMER
Data URI
None
MIME Type
None
Extras
EXTRA_LENGTH
The length of the timer in seconds. (1)
EXTRA_MESSAGE
A custom message to identify the timer. ()
EXTRA_SKIP_UI
A boolean specifying whether the responding app should skip its UI when setting the timer. If true, the app should bypass any confirmation UI and simply start the specified timer. (true)

So i think it should be like this, but how to add the Extras?

sendintent -b "intent:#Intent;action=android.intent.action.SET_TIMER;?EXTRAS?;end;"

6 years ago
Android
ANSWERS
S
Scott Silver Contributor
6 years ago

A number of issues.

1. Refer to the MobiControl intent help doc.  While lots of MC docs are poor, this one is pretty good: IntentHelp

You have to prepend any extra data with the data type that the action is expecting.  In this case: i.EXTRA_LENGTH=10;S.EXTRA_MESSAGE=BLAH BLAH;B.EXTRA_SKIP_IU=true;

2. You are using the -b to perform a broadcast intent when the developer docs indicate that ACTION_SET_TIMER is an Activity Action, so you would need to use sendintent -a

3.  The developer docs also state: ACTION_SET_ALARM and ACTION_SET_TIMER Intents requires the permission com.android.alarm.permission.SET_ALARM

Sending the following to a device via Send Script:
sendintent -a "intent:#Intent;action=android.intent.action.SET_TIMER;i.EXTRA_LENGTH=10;S.EXTRA_MESSAGE=BLAH BLAH;B.EXTRA_SKIP_IU=true;end;"
will be sent but examining the device log will show:
2019-05-29 15:42:13.025|pool-1-thread-1|D|AP|[LegacyScriptExecutor][execute]script command: sendintent - begin|
2019-05-29 15:42:13.031|pool-1-thread-1|E|AP|[LegacyScriptExecutor][executeScriptCommand] Failed to exec script command: sendintent [-a, intent:#Intent;action=android.intent.action.SET_TIMER;i.EXTRA_LENGTH=10;S.EXTRA_MESSAGE=BLAH BLAH;B.EXTRA_SKIP_IU=true;end;]|java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.SET_TIMER flg=0x10800000 cmp=com.android.deskclock/.HandleApiCalls (has extras) } from ProcessRecord{a26c51f 10300:net.soti.mobicontrol.motorola/u0a168} (pid=10300, uid=10168) requires com.android.alarm.permission.SET_ALARM
 ...
2019-05-29 15:42:13.032|pool-1-thread-1|D|AP|[LegacyScriptExecutor][execute]script command: sendintent [-a, intent:#Intent;action=android.intent.action.SET_TIMER;i.EXTRA_LENGTH=10;S.EXTRA_MESSAGE=BLAH BLAH;B.EXTRA_SKIP_IU=true;end;], result: ScriptResult{description='FAILED', resultType=FAILED}|

I assume that the MobiControl agent did not request com.android.alarm.permission.SET_ALARM permission in its manifest.

Solution
L
LJMOD@SOTI
6 years ago

Hello Rafael,

       Thank you for requesting a response from SOTI Support Staff.

       We would like to know if you have enrolled this device as Android Plus or as Android Enterprise. 

       Not necessarily all the scripts which work for Android Plus will work for Android Enterprise.

R
Rafael Gold Contributor
6 years ago

If i see right, it's enrolled as Android Plus (see screenshot), bit i don't know why because the person who this for us here said that we have to use Android Enterprise. And he configured StageNow and the Android 8 Profile.

But i checked the profile we used and saw that there is used Android Plus instead of Android Enteprise, i will check that and come back when i have new information.

R
Rafael Gold Contributor
6 years ago

Regardless of Android Plus or Enterprise i only want to know how to define the "Extras" in intent script.

MD
Matt Dermody Diamond Contributor
6 years ago

Here is a sample Intent pulled from another forum post that include extras for reference:

sendintent -b "intent:#Intent;action=com.honeywell.tools.deviceconfig.enabledeviceconfig;S.deviceconfigfilepath=/sdcard/honeywell/persist/deviceconfig.xml;launchFlags=0x0000020;end"

R
Rafael Gold Contributor
6 years ago
R
Rafael Gold Contributor
6 years ago (edited 6 years ago)

Thanks a lot Scott. I will go into testing and look if we have to do some more actions to get this to work.

If someone has an idea how to let the device make noise (without writing a new app) i am thankfull.

The case is that we want to react if one of our devices lost connection to our W-LAN (=Mobicontrol), we see this case as steeling our device.

The profile Rule "Connection" -> "without Connection" works fine but can't make noise at the moment (the intent skript above seem not working, so Scott maybe right with because of less permissions).

It seem that in mobicontrol user-mode are not enough permissions for that but in administrator mode. Can this be set?

MD
Matt Dermody Diamond Contributor
6 years ago

If you do end up figuring this out, I think you're going to find a 1 minute timer for an Out of Contact policy is entirely too short for an audible alert. There will be other conditions that create 1+ minutes of disconnect in your environment other than users stealing devices that will likely result in a bunch of devices beeping and chirping unexpectedly. 

S
Scott Silver Contributor
6 years ago (edited 6 years ago)

Agree with Matt on the time value.  I work way too much with wireless to trust it. ;)

Unless your devices never roam between APs and/or you have no security model, you're going to have disconnects that will cause your devices to alarm all the time.  Additionally, if someone has stolen a device I expect they would just remove the battery to avoid any detection mechanisms.  If you don't have cell service with an IMEI that can be tracked then locating lost/stolen devices will likely end in futility.

That said, if you want to play a sound and you know of a sound file on the device then you can use this intent to do so:

sendintent -a "intent:file:///sdcard/DCIM/Siren.mp3#Intent;type=audio/mpeg;action=android.intent.action.VIEW;end;"

(assuming your file is /sdcard/DCIM/Siren.mp3)
No guarantees about the repeatability of this action as I haven't tested it.

Also, it's not an issue of Admin mode vs User mode.  The issue is that the MobiControl agent wasn't compiled to request the alarm permission so it won't work regardless of the agent mode.

RM
Rob Morrison
6 years ago (edited 6 years ago)

I use this command and it works great. We did have to install the Android Music Player (found it on F-Droid) and copy the alarm MP3 file to a location on the device. This example works on a Honeywell CT60.

sendintent -a "intent:file:///storage/emulated/0/alert.mp3#Intent;type=audio/mpeg;component=com.android.music/.AudioPreview;launchFlags=0x4000000;end”

Similar Discussions