mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-25 14:50:37 +01:00
Ask for power optimisation disabling on Android
This commit is contained in:
parent
cf8f704319
commit
f299e0c0ed
@ -29,7 +29,7 @@ android.presplash_color = #00000000
|
||||
orientation = portrait
|
||||
fullscreen = 0
|
||||
|
||||
android.permissions = INTERNET,POST_NOTIFICATIONS,WAKE_LOCK,FOREGROUND_SERVICE,CHANGE_WIFI_MULTICAST_STATE,BLUETOOTH_CONNECT,ACCESS_NETWORK_STATE,ACCESS_FINE_LOCATION,ACCESS_COARSE_LOCATION,MANAGE_EXTERNAL_STORAGE,ACCESS_BACKGROUND_LOCATION,RECORD_AUDIO
|
||||
android.permissions = INTERNET,POST_NOTIFICATIONS,WAKE_LOCK,FOREGROUND_SERVICE,CHANGE_WIFI_MULTICAST_STATE,BLUETOOTH_CONNECT,ACCESS_NETWORK_STATE,ACCESS_FINE_LOCATION,ACCESS_COARSE_LOCATION,MANAGE_EXTERNAL_STORAGE,ACCESS_BACKGROUND_LOCATION,RECORD_AUDIO,REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
|
||||
|
||||
android.api = 31
|
||||
android.minapi = 24
|
||||
|
@ -406,6 +406,20 @@ class SidebandApp(MDApp):
|
||||
else:
|
||||
self.open_conversations()
|
||||
|
||||
if RNS.vendor.platformutils.is_android():
|
||||
if self.sideband.getstate("android.power_restricted", allow_cache=False):
|
||||
RNS.log("Android power restrictions detected, background connectivity will not work. Asking for permissions.", RNS.LOG_DEBUG)
|
||||
def pm_job(dt):
|
||||
Settings = autoclass("android.provider.Settings")
|
||||
Intent = autoclass("android.content.Intent")
|
||||
Uri = autoclass("android.net.Uri")
|
||||
|
||||
requestIntent = Intent()
|
||||
requestIntent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
|
||||
requestIntent.setData(Uri.parse("package:io.unsigned.sideband"))
|
||||
mActivity.startActivity(requestIntent)
|
||||
Clock.schedule_once(pm_job, 1.5)
|
||||
|
||||
if not self.root.ids.screen_manager.has_screen("messages_screen"):
|
||||
self.messages_screen = Builder.load_string(messages_screen_kv)
|
||||
self.messages_screen.app = self
|
||||
|
Loading…
Reference in New Issue
Block a user