Package com.aurelienpierre.sioul
Class StepService
java.lang.Object
android.content.Context
android.content.ContextWrapper
android.app.Service
com.aurelienpierre.sioul.StepService
- All Implemented Interfaces:
ComponentCallbacks,ComponentCallbacks2
Sioul in the background: it keeps your devices in step while Sioul is
closed (crates/sioul-app/src/steps.rs; docs/android.md, "In the
background"). A foreground service in a process of its own (":steps"):
Qt's activity ends its whole process when it closes (System.exit in
QtActivityBase.onDestroy), which would end a service living there too. It
holds Sioul's library without Qt's window, and one quiet notification.
- An alarm through Doze (exact while allowed, else inexact) asks Rust for
a step: the other devices' news read (Sioul's own pull from the server
while it works, else the sync app asked to look, then a quick exchange),
do-not-disturb asked of Sioul's own process when it changed
(DndReceiver), mail at its rhythm; Rust says when to look next.
- A watch on the sharing folder: another device's file written by the
sync app brings a step three seconds later, without waiting for the alarm
(Rust leaves it out when its pull brought that file already).
- The phone is kept awake only while a step runs: a step asked for later
(a folder's, a message's) comes by an exact alarm of its own (`later`).
- While Sioul's window is on the screen, it exchanges by itself: the steps
wait.
- While this phone screens calls (Calls.java), its notification offers "Let
every call through", for an hour or until turned off, and "Screen calls
again"; each step keeps the calls' table in step too.
Rust's questions come through call(verb, json) (android/main.cpp), also
from Sioul's own process: starting and stopping the service, the stars of
the list's people (DndContacts), the battery's exemption, the alarm of
do-not-disturb's next end (DndReceiver).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classA step asked for later: its reason, and when it comes (elapsed realtime, milliseconds).Nested classes/interfaces inherited from class android.content.Context
Context.BindServiceFlags -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate PowerManager.WakeLockprivate static final longA step holds the phone awake this long at most.private StringThe calls screened, as Rust words them at each step: {screening, through, line, hour, off, again} (crates/sioul-app/src/calls.rs, `step`); empty while this phone does not screen calls.(package private) static final String"Let every call through" pressed on the notification (StepReceiver): extras "on", "minutes".private static final Stringprivate String(package private) static final StringA press of the switch heard in Sioul's own process (DndReceiver, the tile): sent at once (StepReceiver).private static final String(package private) static final StringThe alarm of a step asked for later (`later`): a folder's, a message's.private StringIts text: do-not-disturb on or off, the calls screened or ringing (Rust's `steps::note`).private static final int(package private) static final StringThe notification's words, as Rust says them after each apply in Sioul's own process (StepReceiver): extra "words".private Stringprivate booleanA step asked while one runs: the phone stays awake for it.private static StepServiceprivate longWhen the words shown were made (Unix milliseconds, Rust's clock): older ones are left aside.private static final longThe sync app's writing settles this long before a step reads it.(package private) static final StringA message's line written for your computers by the listener (AppNotes, `soon`): a step soon shares it.private static final longHow long a step asked by `SOON` waits: the messages that follow go with it.(package private) static final String(package private) static final Stringprivate HandlerThreadprivate StringIts title: what now is for, until when; Sioul's words for the service before Rust gave any.private static final longSeconds between two steps when Rust gave no answer.private StepService.LaterThe step asked for later, waiting for its alarm (`later`); none: null.private FileObserverprivate Stringprivate static final String[][]private HandlerThe names of the other devices' files the sync app wrote since the last step, for Rust ("folder:").Fields inherited from class android.app.Service
START_CONTINUATION_MASK, START_FLAG_REDELIVERY, START_FLAG_RETRY, START_NOT_STICKY, START_REDELIVER_INTENT, START_STICKY, START_STICKY_COMPATIBILITY, STOP_FOREGROUND_DETACH, STOP_FOREGROUND_LEGACY, STOP_FOREGROUND_REMOVEFields inherited from class android.content.Context
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ADVANCED_PROTECTION_SERVICE, ALARM_SERVICE, APP_FUNCTION_SERVICE, APP_OPS_SERVICE, APP_SEARCH_SERVICE, APPWIDGET_SERVICE, AUDIO_SERVICE, BATTERY_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_ACTIVITY_STARTS, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_EXTERNAL_SERVICE, BIND_EXTERNAL_SERVICE_LONG, BIND_IMPORTANT, BIND_INCLUDE_CAPABILITIES, BIND_NOT_FOREGROUND, BIND_NOT_PERCEPTIBLE, BIND_PACKAGE_ISOLATED_PROCESS, BIND_SHARED_ISOLATED_PROCESS, BIND_WAIVE_PRIORITY, BIOMETRIC_SERVICE, BLOB_STORE_SERVICE, BLUETOOTH_SERVICE, BUGREPORT_SERVICE, CAMERA_SERVICE, CAPTIONING_SERVICE, CARRIER_CONFIG_SERVICE, CLIPBOARD_SERVICE, COMPANION_DEVICE_SERVICE, CONNECTIVITY_DIAGNOSTICS_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTACT_KEYS_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, CREDENTIAL_SERVICE, CROSS_PROFILE_APPS_SERVICE, DEVICE_ID_DEFAULT, DEVICE_ID_INVALID, DEVICE_LOCK_SERVICE, DEVICE_POLICY_SERVICE, DISPLAY_HASH_SERVICE, DISPLAY_SERVICE, DOMAIN_VERIFICATION_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, EUICC_SERVICE, FILE_INTEGRITY_SERVICE, FINGERPRINT_SERVICE, GAME_SERVICE, GRAMMATICAL_INFLECTION_SERVICE, HARDWARE_PROPERTIES_SERVICE, HEALTHCONNECT_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, IPSEC_SERVICE, JOB_SCHEDULER_SERVICE, KEYGUARD_SERVICE, KEYSTORE_SERVICE, LAUNCHER_APPS_SERVICE, LAYOUT_INFLATER_SERVICE, LOCALE_SERVICE, LOCATION_SERVICE, MEDIA_COMMUNICATION_SERVICE, MEDIA_METRICS_SERVICE, MEDIA_PROJECTION_SERVICE, MEDIA_QUALITY_SERVICE, MEDIA_ROUTER_SERVICE, MEDIA_SESSION_SERVICE, MIDI_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_NO_LOCALIZED_COLLATORS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NETWORK_STATS_SERVICE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, OVERLAY_SERVICE, PEOPLE_SERVICE, PERFORMANCE_HINT_SERVICE, PERSISTENT_DATA_BLOCK_SERVICE, POWER_SERVICE, PRINT_SERVICE, PROFILING_SERVICE, RECEIVER_EXPORTED, RECEIVER_NOT_EXPORTED, RECEIVER_VISIBLE_TO_INSTANT_APPS, RESTRICTIONS_SERVICE, ROLE_SERVICE, SATELLITE_SERVICE, SEARCH_SERVICE, SECURITY_STATE_SERVICE, SENSOR_SERVICE, SHORTCUT_SERVICE, STATUS_BAR_SERVICE, STORAGE_SERVICE, STORAGE_STATS_SERVICE, SYSTEM_HEALTH_SERVICE, TELECOM_SERVICE, TELEPHONY_IMS_SERVICE, TELEPHONY_SERVICE, TELEPHONY_SUBSCRIPTION_SERVICE, TETHERING_SERVICE, TEXT_CLASSIFICATION_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, TV_AD_SERVICE, TV_INPUT_SERVICE, TV_INTERACTIVE_APP_SERVICE, UI_MODE_SERVICE, USAGE_STATS_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_MANAGER_SERVICE, VIBRATOR_SERVICE, VIRTUAL_DEVICE_SERVICE, VPN_MANAGEMENT_SERVICE, WALLPAPER_SERVICE, WIFI_AWARE_SERVICE, WIFI_P2P_SERVICE, WIFI_RTT_RANGING_SERVICE, WIFI_SERVICE, WINDOW_SERVICEFields inherited from interface android.content.ComponentCallbacks2
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Notification.ActionOne of the notification's buttons for the calls: on for `minutes` (0: until turned off), or off.(package private) static voidAn alarm's step (StepReceiver): to the service running, else it starts (an exact alarm allows it).(package private) static voidaskBattery(Context context) Android's question to let Sioul run in the background; else its list.(package private) static StringRust's question (android/main.cpp), from either process.(package private) static voidcallsPressed(Context context, boolean on, int minutes) Expecting a call (once "Let every call through") pressed on the notification (StepReceiver, in this process): kept for the screening at once (Calls.press(android.content.Context, boolean, int)), then a step, in which Rust shares it with your other devices and words the notification again.private JSONObjectprivate static voidprivate static voidcancelLater(Context context) The alarm of a step asked for later, taken away: a step now does its work.(package private) static booleanWhether Android lets Sioul run in the background, battery optimisation aside.private voidThe service in the foreground with its notification: at each start, as Android asks.(package private) static voidA press of the switch made in Sioul's own process (StepReceiver): a step at once, which sends it.(package private) static booleanWhether the service runs in this very process (its own, ":steps").private static SharedPreferencesWhether it runs and its words, written by Sioul's own process and read by the service's: read again from the file when it changed (both processes use it, rarely).private voidA step asked for later, as `Later.of` joins it to the one waiting: its exact alarm set, or moved (one alarm at a time).(package private) static voidThe alarm of the step asked for later (StepReceiver, in this process): it runs now; the service started again if Android had stopped it.private static PendingIntentlaterPending(Context context) (package private) static voidTells Rust it runs in the service's process: it never touches Android's modes from here.(package private) static StringnativeStep(String reason) One step, on the worker thread: {next (seconds), folder, own, line, title, channel, stop}.private Notificationnote()One quiet notification: the lowest importance, no sound, no badge, hidden on the lock screen.(package private) static booleanThe notification's words, {title, text, calls}, told by Rust after each apply in Sioul's own process: to the service running in this process, else to its process (StepReceiver), only while it runs.voidonCreate()voidintonStartCommand(Intent intent, int flags, int startId) private static PendingIntentA tap: Sioul, as by its icon.(package private) static booleanothersFile(String name, String own) Another device's file, by its name in the sharing folder's top: hidden names are files being written; this device's own are its own steps.private static PendingIntentprivate voidrefresh()Its notification changed in place: new words, the do-not-disturb line.(package private) static voidAt the phone's restart or after an update (StepReceiver): started again if it was on.private void(package private) static booleanrunningHere(Context context) Whether the service runs, asked from either process.private voidsaid(JSONObject answer) The notification's words from Rust ({at, title, text, channel, calls}): shown again when one changed; words made before those shown (`at`, Unix milliseconds: a step's, finished after a press told newer ones) are left aside.(package private) static voidThe next step's alarm, `seconds` on: exact through Doze while allowed, else inexact.(package private) static voidA line written for your computers, from the listener's process: a step soon, while the service runs (else the window's own exchanges, or the next start, send it).(package private) static voidsoonHere()`SOON` heard (StepReceiver, in this process): a step `SOON_MS` on, or the one waiting for its alarm then, which shares the line too (`Later.of`); none when a step is about to run.(package private) static booleanstart(Context context, JSONObject words) The service started, or told new words: {title, channel}.(package private) voidA step: now, on the worker thread, the phone kept awake while it waits there and runs (one asked meanwhile replaces one not started; the one waiting for its alarm goes, this one does its work); or `delay` milliseconds on, by an exact alarm of its own, the phone left to sleep meanwhile (`later`).(package private) static voidStopped, and not started again at the phone's restart.private StringThe names written since the last step, "/" between them, forgotten here (any step reads the folder).(package private) static voidThe words told (StepReceiver, in this process): the notification changed in place at once when they differ.private voidwatchFolder(String folder) The sharing folder watched: another device's file written there brings a step.private booleanWhether Sioul's window is on the screen (its own process in the foreground).private static Stringword(int which) private voidNew words, kept and shown at once when they changed: on the caller's thread, never behind a step, which may wait for the sync app or for mail on the worker's.Methods inherited from class android.app.Service
attachBaseContext, dump, getApplication, getForegroundServiceType, onConfigurationChanged, onLowMemory, onRebind, onStart, onTaskRemoved, onTimeout, onTimeout, onTrimMemory, onUnbind, startForeground, startForeground, stopForeground, stopForeground, stopSelf, stopSelf, stopSelfResultMethods inherited from class android.content.ContextWrapper
bindIsolatedService, bindService, bindService, bindService, bindService, bindServiceAsUser, bindServiceAsUser, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingOrSelfUriPermissions, checkCallingPermission, checkCallingUriPermission, checkCallingUriPermissions, checkContentUriPermissionFull, checkPermission, checkSelfPermission, checkUriPermission, checkUriPermission, checkUriPermissions, clearWallpaper, createAttributionContext, createConfigurationContext, createContext, createContextForSplit, createDeviceContext, createDeviceProtectedStorageContext, createDisplayContext, createPackageContext, createWindowContext, createWindowContext, databaseList, deleteDatabase, deleteFile, deleteSharedPreferences, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getAttributionSource, getAttributionTag, getBaseContext, getCacheDir, getClassLoader, getCodeCacheDir, getContentResolver, getDatabasePath, getDataDir, getDeviceId, getDir, getDisplay, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getFileStreamPath, getMainExecutor, getMainLooper, getNoBackupFilesDir, getObbDir, getObbDirs, getOpPackageName, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getParams, getResources, getSharedPreferences, getSystemService, getSystemServiceName, getTheme, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isDeviceProtectedStorage, isRestricted, isUiContext, moveDatabaseFrom, moveSharedPreferencesFrom, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerComponentCallbacks, registerDeviceIdChangeListener, registerReceiver, registerReceiver, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeSelfPermissionsOnKill, revokeUriPermission, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setTheme, setWallpaper, setWallpaper, startActivities, startActivities, startActivity, startActivity, startForegroundService, startInstrumentation, startIntentSender, startIntentSender, startService, stopService, unbindService, unregisterComponentCallbacks, unregisterDeviceIdChangeListener, unregisterReceiver, updateServiceGroupMethods inherited from class android.content.Context
bindIsolatedService, getColor, getColorStateList, getDrawable, getString, getString, getSystemService, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, revokeSelfPermissionOnKill, sendBroadcastWithMultiplePermissions
-
Field Details
-
TAG
- See Also:
-
STEP
- See Also:
-
CALLS
"Let every call through" pressed on the notification (StepReceiver): extras "on", "minutes".- See Also:
-
HEARD
A press of the switch heard in Sioul's own process (DndReceiver, the tile): sent at once (StepReceiver).- See Also:
-
NOTE_WORDS
The notification's words, as Rust says them after each apply in Sioul's own process (StepReceiver): extra "words".- See Also:
-
SOON
A message's line written for your computers by the listener (AppNotes, `soon`): a step soon shares it.- See Also:
-
LATER
The alarm of a step asked for later (`later`): a folder's, a message's.- See Also:
-
SOON_MS
How long a step asked by `SOON` waits: the messages that follow go with it.- See Also:
-
CHANNEL
- See Also:
-
NOTE
- See Also:
-
KEPT
- See Also:
-
USUAL_S
Seconds between two steps when Rust gave no answer.- See Also:
-
AWAKE_MS
A step holds the phone awake this long at most.- See Also:
-
SETTLE_MS
The sync app's writing settles this long before a step reads it.- See Also:
-
running
-
thread
-
worker
-
awake
-
watch
-
watched
-
own
-
line
Its text: do-not-disturb on or off, the calls screened or ringing (Rust's `steps::note`). -
title
Its title: what now is for, until when; Sioul's words for the service before Rust gave any. -
channelName
-
calls
The calls screened, as Rust words them at each step: {screening, through, line, hour, off, again} (crates/sioul-app/src/calls.rs, `step`); empty while this phone does not screen calls. -
posted
A step asked while one runs: the phone stays awake for it. -
waiting
The step asked for later, waiting for its alarm (`later`); none: null. -
written
The names of the other devices' files the sync app wrote since the last step, for Rust ("folder:"). -
saidAt
When the words shown were made (Unix milliseconds, Rust's clock): older ones are left aside. -
WORDS
-
-
Constructor Details
-
StepService
public StepService()
-
-
Method Details
-
nativeStep
One step, on the worker thread: {next (seconds), folder, own, line, title, channel, stop}. -
nativeService
Tells Rust it runs in the service's process: it never touches Android's modes from here. -
call
Rust's question (android/main.cpp), from either process. Any thread. -
kept
Whether it runs and its words, written by Sioul's own process and read by the service's: read again from the file when it changed (both processes use it, rarely). -
start
The service started, or told new words: {title, channel}. Kept, so that a restart of the phone starts it again with them. False when Android refused (Sioul in the background on Android 12 and later). -
stop
Stopped, and not started again at the phone's restart. -
restart
At the phone's restart or after an update (StepReceiver): started again if it was on. -
alarm
An alarm's step (StepReceiver): to the service running, else it starts (an exact alarm allows it). -
inThisProcess
Whether the service runs in this very process (its own, ":steps"). -
runningHere
Whether the service runs, asked from either process. -
exempt
Whether Android lets Sioul run in the background, battery optimisation aside. -
askBattery
Android's question to let Sioul run in the background; else its list. -
onCreate
-
onStartCommand
- Overrides:
onStartCommandin classService
-
onDestroy
-
onBind
-
foreground
The service in the foreground with its notification: at each start, as Android asks. -
refresh
Its notification changed in place: new words, the do-not-disturb line. -
note
One quiet notification: the lowest importance, no sound, no badge, hidden on the lock screen. -
callsWords
-
action
private static Notification.Action action(Context context, int code, String title, boolean on, int minutes) One of the notification's buttons for the calls: on for `minutes` (0: until turned off), or off. -
note
The notification's words, {title, text, calls}, told by Rust after each apply in Sioul's own process: to the service running in this process, else to its process (StepReceiver), only while it runs. True when told. -
told
The words told (StepReceiver, in this process): the notification changed in place at once when they differ. -
words
New words, kept and shown at once when they changed: on the caller's thread, never behind a step, which may wait for the sync app or for mail on the worker's. -
said
The notification's words from Rust ({at, title, text, channel, calls}): shown again when one changed; words made before those shown (`at`, Unix milliseconds: a step's, finished after a press told newer ones) are left aside. -
soon
A line written for your computers, from the listener's process: a step soon, while the service runs (else the window's own exchanges, or the next start, send it). -
soonHere
`SOON` heard (StepReceiver, in this process): a step `SOON_MS` on, or the one waiting for its alarm then, which shares the line too (`Later.of`); none when a step is about to run. -
laterHere
The alarm of the step asked for later (StepReceiver, in this process): it runs now; the service started again if Android had stopped it. -
heard
A press of the switch made in Sioul's own process (StepReceiver): a step at once, which sends it. -
callsPressed
Expecting a call (once "Let every call through") pressed on the notification (StepReceiver, in this process): kept for the screening at once (Calls.press(android.content.Context, boolean, int)), then a step, in which Rust shares it with your other devices and words the notification again. -
open
A tap: Sioul, as by its icon. -
step
A step: now, on the worker thread, the phone kept awake while it waits there and runs (one asked meanwhile replaces one not started; the one waiting for its alarm goes, this one does its work); or `delay` milliseconds on, by an exact alarm of its own, the phone left to sleep meanwhile (`later`). -
later
A step asked for later, as `Later.of` joins it to the one waiting: its exact alarm set, or moved (one alarm at a time). Through Doze too (allow-while-idle); Android brings an alarm five seconds on at the soonest. -
run
-
windowShown
Whether Sioul's window is on the screen (its own process in the foreground). -
watchFolder
The sharing folder watched: another device's file written there brings a step. -
othersFile
Another device's file, by its name in the sharing folder's top: hidden names are files being written; this device's own are its own steps. Pure: android/jvm-checks/StepsCheck.java. -
takeWritten
The names written since the last step, "/" between them, forgotten here (any step reads the folder). -
schedule
The next step's alarm, `seconds` on: exact through Doze while allowed, else inexact. -
cancel
-
cancelLater
The alarm of a step asked for later, taken away: a step now does its work. -
laterPending
-
pending
-
word
-