Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

Commit

Permalink
Restarts killed roll pulling service, fixes #103
Browse files Browse the repository at this point in the history
Uses `Service.setAutoRestartService()` to restart service when killed,
refs kivy/python-for-android#1374
  • Loading branch information
AndreMiras committed Sep 15, 2018
1 parent 35f47ea commit f4e48af
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/service/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from time import sleep

from kivy.storage.jsonstore import JsonStore
from kivy.utils import platform
from plyer import notification

from ethereum_utils import AccountUtils
Expand Down Expand Up @@ -31,6 +32,17 @@ def start(self):
self.pull_accounts_rolls()
sleep(PULL_FREQUENCY_SECONDS)

@staticmethod
def set_auto_restart_service(restart=True):
"""
Makes sure the service restarts automatically on Android when killed.
"""
if platform != 'android':
return
from jnius import autoclass
PythonService = autoclass('org.kivy.android.PythonService')
PythonService.mService.setAutoRestartService(restart)

@property
def pyetheroll(self):
"""
Expand Down Expand Up @@ -156,8 +168,10 @@ def do_notify(self, merged_logs):
notification.notify(**kwargs)



def main():
service = MonitorRollsService()
service.set_auto_restart_service()
service.start()


Expand Down

0 comments on commit f4e48af

Please sign in to comment.