update smartdock
This commit is contained in:
parent
59ad317684
commit
dbf630ba7e
4 changed files with 88 additions and 40 deletions
2
main.py
Normal file → Executable file
2
main.py
Normal file → Executable file
|
|
@ -1,3 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
from logging import Logger
|
||||
from stuffs.android_id import Android_id
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import re
|
|||
import zipfile
|
||||
import hashlib
|
||||
from tools import images
|
||||
from tools.helper import download_file, get_download_dir, run, upgrade
|
||||
from tools.container import DBusContainerService
|
||||
from tools.helper import download_file, get_download_dir
|
||||
from tools import container
|
||||
from tools.logger import Logger
|
||||
|
||||
class General:
|
||||
|
|
@ -19,27 +19,11 @@ class General:
|
|||
|
||||
@property
|
||||
def copy_dir(self):
|
||||
if self.use_overlayfs:
|
||||
if container.use_overlayfs():
|
||||
return "/var/lib/waydroid/overlay"
|
||||
else:
|
||||
return "/tmp/waydroid"
|
||||
|
||||
@property
|
||||
def use_dbus(self):
|
||||
try:
|
||||
DBusContainerService()
|
||||
except:
|
||||
return False
|
||||
return True
|
||||
|
||||
@property
|
||||
def use_overlayfs(self):
|
||||
with open("/var/lib/waydroid/waydroid.cfg") as f:
|
||||
cont=f.read()
|
||||
if re.search("mount_overlays[ \t]*=[ \t]*True", cont):
|
||||
return True
|
||||
return False
|
||||
|
||||
def download(self):
|
||||
Logger.info("Downloading {} now to {} .....".format(self.dl_file_name, self.download_loc))
|
||||
loc_md5 = ""
|
||||
|
|
@ -96,41 +80,46 @@ class General:
|
|||
images.umount(mount_point)
|
||||
|
||||
def stop(self):
|
||||
if self.use_dbus:
|
||||
self.session = DBusContainerService().GetSession()
|
||||
if self.session:
|
||||
DBusContainerService().Stop(False)
|
||||
else:
|
||||
run(["waydroid", "container", "stop"])
|
||||
if container.use_dbus():
|
||||
self.session = container.get_session()
|
||||
container.stop()
|
||||
|
||||
def start(self):
|
||||
if self.use_dbus and self.session:
|
||||
DBusContainerService().Start(self.session)
|
||||
if container.use_dbus() and self.session:
|
||||
container.start(self.session)
|
||||
else:
|
||||
run(["systemctl", "restart", "waydroid-container.service"])
|
||||
upgrade()
|
||||
container.start()
|
||||
|
||||
def restart(self):
|
||||
self.stop()
|
||||
self.start()
|
||||
upgrade()
|
||||
|
||||
def copy(self):
|
||||
pass
|
||||
|
||||
def extra(self):
|
||||
def extra1(self):
|
||||
pass
|
||||
|
||||
def extra2(self):
|
||||
pass
|
||||
|
||||
# def install(self):
|
||||
# if DBusContainerService().GetSession():
|
||||
# print("running")
|
||||
# else:
|
||||
# print("stopped")
|
||||
# run("waydroid session start".split())
|
||||
def install(self):
|
||||
if self.use_overlayfs:
|
||||
if container.use_overlayfs():
|
||||
self.download()
|
||||
if not self.skip_extract:
|
||||
self.extract()
|
||||
self.copy()
|
||||
self.extra()
|
||||
self.extra1()
|
||||
if hasattr(self, "apply_props"):
|
||||
self.add_props()
|
||||
self.restart()
|
||||
self.extra2()
|
||||
else:
|
||||
self.stop()
|
||||
self.download()
|
||||
|
|
@ -139,9 +128,10 @@ class General:
|
|||
self.resize()
|
||||
self.mount()
|
||||
self.copy()
|
||||
self.extra()
|
||||
self.extra1()
|
||||
if hasattr(self, "apply_props"):
|
||||
self.add_props()
|
||||
self.umount()
|
||||
self.start()
|
||||
self.extra2()
|
||||
Logger.info("Installation finished")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
import os
|
||||
import shutil
|
||||
from time import sleep
|
||||
from stuffs.general import General
|
||||
from tools import container
|
||||
from tools.helper import run
|
||||
|
||||
class Smartdock(General):
|
||||
dl_link = "https://github.com/ayasa520/smartdock/releases/download/v1.9.6/smartdock.zip"
|
||||
|
|
@ -8,14 +11,25 @@ class Smartdock(General):
|
|||
extract_to = "/tmp/smartdockunpack"
|
||||
dl_file_name = "smartdock.zip"
|
||||
act_md5 = "ad0cc5e023ac6ee97e7b013b9b0defee"
|
||||
apply_props = { "qemu.hw.mainkeys" : "1" }
|
||||
|
||||
def copy(self):
|
||||
if not os.path.exists(os.path.join(self.copy_dir, self.partition, "priv-app", "SmartDock")):
|
||||
os.makedirs(os.path.join(self.copy_dir, self.partition, "priv-app", "SmartDock"))
|
||||
if not os.path.exists(os.path.join(self.copy_dir, self.partition, "etc", "permissions")):
|
||||
os.makedirs(os.path.join(self.copy_dir, self.partition, "etc", "permissions"))
|
||||
shutil.copyfile(os.path.join(self.extract_to, "app-release.apk"),
|
||||
os.path.join(self.copy_dir, self.partition, "priv-app", "SmartDock", "smartdock.apk"))
|
||||
shutil.copyfile(os.path.join(self.extract_to, "permissions_cu.axel.smartdock.xml"),
|
||||
os.path.join(self.copy_dir, self.partition, "etc", "permissions", "permissions_cu.axel.smartdock.xml"))
|
||||
|
||||
def extra(self):
|
||||
return super().extra()
|
||||
def extra2(self):
|
||||
index = 0
|
||||
while not container.is_running():
|
||||
list = ["\\", "|", "/", "—"]
|
||||
sleep(0.5)
|
||||
print("\r\tPlease start WayDroid for further setup {}".format(list[index%4]), end="")
|
||||
index += 1
|
||||
sleep(5)
|
||||
print()
|
||||
run(["waydroid", "shell", "cmd", "package", "set-home-activity", "cu.axel.smartdock/.activities.LauncherActivity"])
|
||||
|
|
|
|||
|
|
@ -1,10 +1,52 @@
|
|||
try:
|
||||
import dbus
|
||||
except ModuleNotFoundError:
|
||||
pass
|
||||
import re
|
||||
import dbus
|
||||
from tools.helper import run
|
||||
|
||||
def DBusContainerService(object_path="/ContainerManager", intf="id.waydro.ContainerManager"):
|
||||
return dbus.Interface(dbus.SystemBus().get_object("id.waydro.Container", object_path), intf)
|
||||
|
||||
def DBusSessionService(object_path="/SessionManager", intf="id.waydro.SessionManager"):
|
||||
return dbus.Interface(dbus.SessionBus().get_object("id.waydro.Session", object_path), intf)
|
||||
|
||||
def use_dbus():
|
||||
try:
|
||||
DBusContainerService()
|
||||
except:
|
||||
return False
|
||||
return True
|
||||
|
||||
def use_overlayfs():
|
||||
# with open("/var/lib/waydroid/waydroid.cfg") as f:
|
||||
# cont=f.read()
|
||||
# if re.search("mount_overlays[ \t]*=[ \t]*True", cont):
|
||||
# return True
|
||||
# return False
|
||||
return False
|
||||
|
||||
def get_session():
|
||||
return DBusContainerService().GetSession()
|
||||
|
||||
def stop():
|
||||
if use_dbus():
|
||||
session = DBusContainerService().GetSession()
|
||||
if session:
|
||||
DBusContainerService().Stop(False)
|
||||
else:
|
||||
run(["waydroid", "container", "stop"])
|
||||
|
||||
def start(*session):
|
||||
if use_dbus() and session:
|
||||
DBusContainerService().Start(session[0])
|
||||
else:
|
||||
run(["systemctl", "restart", "waydroid-container.service"])
|
||||
|
||||
def is_running():
|
||||
if use_dbus():
|
||||
if DBusContainerService().GetSession():
|
||||
return True
|
||||
return False
|
||||
else:
|
||||
return "Session:\tRUNNING" in run(["waydroid", "status"]).stdout.decode()
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue