Added ability to start Sideband at device boot on Android
This commit is contained in:
parent
ca2ef3ca37
commit
0de6b2d1d0
6 changed files with 65 additions and 7 deletions
|
|
@ -29,7 +29,7 @@ android.presplash_color = #00000000
|
||||||
orientation = portrait
|
orientation = portrait
|
||||||
fullscreen = 0
|
fullscreen = 0
|
||||||
|
|
||||||
android.permissions = INTERNET,POST_NOTIFICATIONS,WAKE_LOCK,FOREGROUND_SERVICE,CHANGE_WIFI_MULTICAST_STATE,BLUETOOTH_SCAN,BLUETOOTH_ADVERTISE,BLUETOOTH_CONNECT,ACCESS_NETWORK_STATE,ACCESS_FINE_LOCATION,ACCESS_COARSE_LOCATION,MANAGE_EXTERNAL_STORAGE,ACCESS_BACKGROUND_LOCATION,RECORD_AUDIO,REQUEST_IGNORE_BATTERY_OPTIMIZATIONS,FOREGROUND_SERVICE_CONNECTED_DEVICE,MODIFY_AUDIO_SETTINGS
|
android.permissions = INTERNET,POST_NOTIFICATIONS,WAKE_LOCK,FOREGROUND_SERVICE,CHANGE_WIFI_MULTICAST_STATE,BLUETOOTH_SCAN,BLUETOOTH_ADVERTISE,BLUETOOTH_CONNECT,ACCESS_NETWORK_STATE,ACCESS_FINE_LOCATION,ACCESS_COARSE_LOCATION,MANAGE_EXTERNAL_STORAGE,ACCESS_BACKGROUND_LOCATION,RECORD_AUDIO,REQUEST_IGNORE_BATTERY_OPTIMIZATIONS,FOREGROUND_SERVICE_CONNECTED_DEVICE,MODIFY_AUDIO_SETTINGS,RECEIVE_BOOT_COMPLETED
|
||||||
|
|
||||||
android.api = 33
|
android.api = 33
|
||||||
android.minapi = 24
|
android.minapi = 24
|
||||||
|
|
|
||||||
|
|
@ -3592,6 +3592,10 @@ class SidebandApp(MDApp):
|
||||||
self.sideband.start_voice()
|
self.sideband.start_voice()
|
||||||
else: self.sideband.stop_voice()
|
else: self.sideband.stop_voice()
|
||||||
|
|
||||||
|
def save_start_at_boot(sender=None, event=None):
|
||||||
|
self.sideband.config["start_at_boot"] = self.settings_screen.ids.settings_start_at_boot.active
|
||||||
|
self.sideband.save_configuration()
|
||||||
|
|
||||||
def save_print_command(sender=None, event=None):
|
def save_print_command(sender=None, event=None):
|
||||||
if not sender.focus:
|
if not sender.focus:
|
||||||
in_cmd = self.settings_screen.ids.settings_print_command.text
|
in_cmd = self.settings_screen.ids.settings_print_command.text
|
||||||
|
|
@ -3671,11 +3675,10 @@ class SidebandApp(MDApp):
|
||||||
else:
|
else:
|
||||||
self.settings_screen.ids.settings_print_command.text = self.sideband.config["print_command"]
|
self.settings_screen.ids.settings_print_command.text = self.sideband.config["print_command"]
|
||||||
self.settings_screen.ids.settings_print_command.bind(focus=save_print_command)
|
self.settings_screen.ids.settings_print_command.bind(focus=save_print_command)
|
||||||
|
self.settings_screen.ids.settings_start_at_boot.disabled = True
|
||||||
|
|
||||||
if self.sideband.config["lxmf_propagation_node"] == None:
|
if self.sideband.config["lxmf_propagation_node"] == None: prop_node_addr = ""
|
||||||
prop_node_addr = ""
|
else: prop_node_addr = RNS.hexrep(self.sideband.config["lxmf_propagation_node"], delimit=False)
|
||||||
else:
|
|
||||||
prop_node_addr = RNS.hexrep(self.sideband.config["lxmf_propagation_node"], delimit=False)
|
|
||||||
|
|
||||||
self.settings_screen.ids.settings_propagation_node_address.text = prop_node_addr
|
self.settings_screen.ids.settings_propagation_node_address.text = prop_node_addr
|
||||||
self.settings_screen.ids.settings_propagation_node_address.bind(focus=save_prop_addr)
|
self.settings_screen.ids.settings_propagation_node_address.bind(focus=save_prop_addr)
|
||||||
|
|
@ -3705,6 +3708,9 @@ class SidebandApp(MDApp):
|
||||||
self.settings_screen.ids.settings_advanced_statistics.active = self.sideband.config["advanced_stats"]
|
self.settings_screen.ids.settings_advanced_statistics.active = self.sideband.config["advanced_stats"]
|
||||||
self.settings_screen.ids.settings_advanced_statistics.bind(active=save_advanced_stats)
|
self.settings_screen.ids.settings_advanced_statistics.bind(active=save_advanced_stats)
|
||||||
|
|
||||||
|
self.settings_screen.ids.settings_start_at_boot.active = self.sideband.config["start_at_boot"]
|
||||||
|
self.settings_screen.ids.settings_start_at_boot.bind(active=save_start_at_boot)
|
||||||
|
|
||||||
self.settings_screen.ids.settings_start_announce.active = self.sideband.config["start_announce"]
|
self.settings_screen.ids.settings_start_announce.active = self.sideband.config["start_announce"]
|
||||||
self.settings_screen.ids.settings_start_announce.bind(active=save_start_announce)
|
self.settings_screen.ids.settings_start_announce.bind(active=save_start_announce)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,12 @@
|
||||||
<service android:name="{{ name }}" />
|
<service android:name="{{ name }}" />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
<receiver android:name="{{ args.service_class_name }}$ServiceBootReceiver" android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
|
||||||
{% if args.billing_pubkey %}
|
{% if args.billing_pubkey %}
|
||||||
<service android:name="org.kivy.android.billing.BillingReceiver"
|
<service android:name="org.kivy.android.billing.BillingReceiver"
|
||||||
android:process=":pythonbilling" />
|
android:process=":pythonbilling" />
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,32 @@ import android.graphics.drawable.Icon;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.net.wifi.WifiManager.MulticastLock;
|
import android.net.wifi.WifiManager.MulticastLock;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
|
||||||
|
import io.unsigned.sideband.ServiceSidebandservice;
|
||||||
|
|
||||||
public class PythonService extends Service implements Runnable {
|
public class PythonService extends Service implements Runnable {
|
||||||
|
|
||||||
|
public static class ServiceBootReceiver extends BroadcastReceiver {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
try {
|
||||||
|
if (Objects.equals(intent.getAction(), "android.intent.action.BOOT_COMPLETED")) {
|
||||||
|
boolean should_start = false;
|
||||||
|
String app_dir = context.getFilesDir().getParentFile().getParent();
|
||||||
|
String toggle_path = context.getFilesDir()+"/app_storage/";
|
||||||
|
File file = new File(toggle_path, "boot_toggle");
|
||||||
|
if (file.exists()) { should_start = true; }
|
||||||
|
if (should_start) {
|
||||||
|
ServiceSidebandservice svc = new ServiceSidebandservice();
|
||||||
|
svc.start(context, app_dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) { Log.e("sidebandservice", "Could not start Sideband service at boot: "+e); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Thread for Python code
|
// Thread for Python code
|
||||||
private Thread pythonThread = null;
|
private Thread pythonThread = null;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -623,6 +623,7 @@ class SidebandCore():
|
||||||
if not "debug" in self.config: self.config["debug"] = False
|
if not "debug" in self.config: self.config["debug"] = False
|
||||||
if not "dark_ui" in self.config: self.config["dark_ui"] = True
|
if not "dark_ui" in self.config: self.config["dark_ui"] = True
|
||||||
if not "advanced_stats" in self.config: self.config["advanced_stats"] = True
|
if not "advanced_stats" in self.config: self.config["advanced_stats"] = True
|
||||||
|
if not "start_at_boot" in self.config: self.config["start_at_boot"] = False
|
||||||
if not "lxmf_periodic_sync" in self.config: self.config["lxmf_periodic_sync"] = False
|
if not "lxmf_periodic_sync" in self.config: self.config["lxmf_periodic_sync"] = False
|
||||||
if not "lxmf_ignore_unknown" in self.config: self.config["lxmf_ignore_unknown"] = False
|
if not "lxmf_ignore_unknown" in self.config: self.config["lxmf_ignore_unknown"] = False
|
||||||
if not "lxmf_sync_interval" in self.config: self.config["lxmf_sync_interval"] = 43200
|
if not "lxmf_sync_interval" in self.config: self.config["lxmf_sync_interval"] = 43200
|
||||||
|
|
@ -807,9 +808,15 @@ class SidebandCore():
|
||||||
time.sleep(0.15)
|
time.sleep(0.15)
|
||||||
try:
|
try:
|
||||||
self.saving_configuration = True
|
self.saving_configuration = True
|
||||||
with open(self.config_path, "wb") as config_file:
|
with open(self.config_path, "wb") as config_file: config_file.write(msgpack.packb(self.config))
|
||||||
config_file.write(msgpack.packb(self.config))
|
|
||||||
self.saving_configuration = False
|
self.saving_configuration = False
|
||||||
|
if RNS.vendor.platformutils.is_android():
|
||||||
|
boot_toggle_path = self.app_dir+"/app_storage/boot_toggle"
|
||||||
|
boot_toggle_exists = os.path.isfile(boot_toggle_path)
|
||||||
|
if self.config["start_at_boot"] == True and not boot_toggle_exists:
|
||||||
|
with open(boot_toggle_path, "w") as f: f.write("true")
|
||||||
|
elif self.config["start_at_boot"] == False and boot_toggle_exists:
|
||||||
|
os.unlink(boot_toggle_path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.saving_configuration = False
|
self.saving_configuration = False
|
||||||
RNS.log("Error while saving Sideband configuration: "+str(e), RNS.LOG_ERROR)
|
RNS.log("Error while saving Sideband configuration: "+str(e), RNS.LOG_ERROR)
|
||||||
|
|
|
||||||
|
|
@ -1666,6 +1666,21 @@ MDScreen:
|
||||||
pos_hint: {"center_y": 0.3}
|
pos_hint: {"center_y": 0.3}
|
||||||
active: False
|
active: False
|
||||||
|
|
||||||
|
MDBoxLayout:
|
||||||
|
orientation: "horizontal"
|
||||||
|
size_hint_y: None
|
||||||
|
padding: [0,0,dp(24),dp(0)]
|
||||||
|
height: dp(48)
|
||||||
|
|
||||||
|
MDLabel:
|
||||||
|
text: "Start at boot"
|
||||||
|
font_style: "H6"
|
||||||
|
|
||||||
|
MDSwitch:
|
||||||
|
id: settings_start_at_boot
|
||||||
|
pos_hint: {"center_y": 0.3}
|
||||||
|
active: False
|
||||||
|
|
||||||
MDLabel:
|
MDLabel:
|
||||||
text: "•"
|
text: "•"
|
||||||
font_style: "H6"
|
font_style: "H6"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue