Function to replace text in an Android file

FP

Hello, 

We have an costumer that is using an Android device, and the application has an configuration file which needs to be updated with the device name in SOTI. How can we solve this issue? 

7 years ago
Android
ANSWERS
RC
Raymond Chan Diamond Contributor
7 years ago (edited 7 years ago)

Hi Fredrich,

What device model(s) is/are you using?  Are you using generic Android or Android Plus or Android Enterprise device agent(s)? 

Also, where is that configuration file located?  What format is that configuration file in (e.g. binary/ascii?   ini, xml, or proprietary,  etc.)?  Is the configuration file "frequently" updated by the app client on the device (or by the app server remotely) when it is running, or is it a startup configuration file which stays quite stable/unchanged for weeks or even months?

FP
Fredrich Pekár
7 years ago

Hello, 

It's an Zebra TC56 (Android+), the file is stored directly under \sdcard\ (a normal .txt file) 

RC
Raymond Chan Diamond Contributor
7 years ago

Is the app a proprietary app you can ask the developer to make minor changes? or is it a black-box app you can only use?

Is the configuration file "frequently" updated by the app client on the device (or by the app server remotely) when it is running, or is it a startup configuration file which stays quite stable/unchanged for weeks or even months?

RC
Raymond Chan Diamond Contributor
7 years ago

Hi Fredrich,

As I haven't got further information related to your use case, I have to guess or make assumptions in order to suggest a solution.

It's good that your app configuration file is in a public directory read/write accessible by any apps/processes.  Also, a predefined attribute/macro, namely %MCDEVICENAME%, allows a device script/kiosk-menu  to reference  its own name last synchronized automatically from its MC server.  However, I think MobiControl script command set currently does not support smartly writing this macro value to any desirable position in your ASCII configuration file.

If you can have the app modified by its developer to read the device name from a 2nd file, say "device_name.txt" in the same directory as the app's original configuration file, then the simplest solution is to use one single MC file-sync rule to download corresponding"device_name.txt" with the right content for each targeted device.  Another way to modify the app is to make it accept the latest device name from the parameter of an Android's "intent", which is initiated by a "sendintent" command with a file-sync rule with proper sync options/schedule.

If the app is a black-box and cannot be modified, you then need a bridging app/background-service to get the above mentioned "device_name.txt" or "intent", and smartly write the device name into the right positon and format  of the app configuration file.