Skip to content

Permissions and files

Bench hardware only. Never connect TwiistOff to a pump that is attached to a person.

A pump app has to keep running when it is not on screen: the pump link, the status it receives and the REST bridge all stop if Android pauses the app. TwiistOff asks for the same Android permissions AndroidAPS asks for, and keeps its log and exports in one folder.

1. The permissions

Menu › Permissions & files lists each one, whether it is allowed, and a button that fixes it. The Connect page shows a Permissions missing card while any is missing, and the first start (after the disclaimer) asks once.

Permission Why the app needs it How it is fixed
Bluetooth Find the pump, bond with it and keep its link. Android 12+ BLUETOOTH_SCAN / BLUETOOTH_CONNECT; Android 9–11 location (for scanning only). Allow: Android's permission dialog.
Notifications Pump alarms, alerts and the app's status while it is not in front. Android 13+ POST_NOTIFICATIONS; before 13, the app's notification switch. Allow: Android's permission dialog (Android 13+), or the app's notification settings. Send a test notification checks it.
Ignore battery optimisation Keeps Android from pausing the app in the background (REQUEST_IGNORE_BATTERY_OPTIMIZATIONS). Without it, a phone can freeze the app for minutes while another app is in front: no REST answers, and the pump's status frames arrive late, all at once. Allow: one tap on Android's "Let app always run in background?" dialog.
Background use A user can restrict an app's background use (battery use Restricted). A restricted app is stopped in the background even when it ignores battery optimisation. Open settings: the app's page; set battery use to Unrestricted.
Alarms & reminders Exact alarms (SCHEDULE_EXACT_ALARM, Android 12+), so reminders and alarms ring on time. Android also allows them while the app ignores battery optimisation, so this shows allowed once that is on. Open settings: Android's "Alarms & reminders" page for the app.

A permission refused twice no longer shows its dialog; App settings under it opens the app's page in Android settings, where it can still be allowed.

GET /permissions reports the same list, and GET /status names what is missing in permissionsMissing (REST API). The REST bridge cannot grant anything: Android only lets the user do that.

On a phone nobody touches

A bench phone driven only over adb can be set up from a computer instead (app id com.infusionset.twiistoff):

adb shell dumpsys deviceidle whitelist +com.infusionset.twiistoff                 # ignore battery optimisation
adb shell cmd appops set com.infusionset.twiistoff RUN_ANY_IN_BACKGROUND allow   # background use not restricted
adb shell pm grant com.infusionset.twiistoff android.permission.POST_NOTIFICATIONS
adb shell cmd appops set com.infusionset.twiistoff SCHEDULE_EXACT_ALARM allow

Then check GET /permissions: missing should be empty.

2. The data folder

The app keeps its files in its own folder on the phone's shared storage:

/storage/emulated/0/Android/data/com.infusionset.twiistoff/files/
  logs/      twiistoff-YYYY-MM-DD.log   the app log, one file a day, the last 14 days (200 MB at most)
  exports/   session reports (twiistoff-session-…txt) and settings exports (twiistoff-settings-…json), newest 50
  • It needs no storage permission, and Android removes it with the app.
  • The log file has every line the in-app session log shows (BLE events, commands and responses with hex payloads), with a full timestamp, and keeps it after the app restarts.
  • Export session (Menu) saves its report here before the share sheet opens; the settings Export to file and Share save a copy here too.
  • On the phone, the Permissions & files page lists the files with a Share button for each. Android hides this folder from on-phone file managers (Android 11 and later); to see the files there, choose a folder to copy them to (below).
  • From a computer: adb pull /sdcard/Android/data/com.infusionset.twiistoff/files/, or GET /files and GET /files/get?path=logs/twiistoff-YYYY-MM-DD.log through the REST bridge.

A phone with no shared storage mounted gets the folder inside the app's private storage instead; the page and GET /files show which path is in use.

Copying to a folder you choose

As AndroidAPS does with its directory, you can pick a folder (for example Documents/TwiistOff) with Android's folder picker: Choose folder on the Permissions & files page. The app then copies logs/ and exports/ there, into subfolders of the same names, after each export and when you tap Copy now (or POST /files/copy). A file of the same name is replaced. The app keeps writing to its own folder; the chosen one is a copy a file manager or a sync app can see. Stop copying forgets the folder.