Uninstall function, microG installation and some hacks #70
@@ -1,3 +1,5 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
from logging import Logger
|
from logging import Logger
|
||||||
from stuffs.android_id import Android_id
|
from stuffs.android_id import Android_id
|
||||||
|
|||||||
+24
-34
@@ -4,8 +4,8 @@ import re
|
|||||||
import zipfile
|
import zipfile
|
||||||
import hashlib
|
import hashlib
|
||||||
from tools import images
|
from tools import images
|
||||||
from tools.helper import download_file, get_download_dir, run, upgrade
|
from tools.helper import download_file, get_download_dir
|
||||||
from tools.container import DBusContainerService
|
from tools import container
|
||||||
from tools.logger import Logger
|
from tools.logger import Logger
|
||||||
|
|
||||||
class General:
|
class General:
|
||||||
@@ -19,27 +19,11 @@ class General:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def copy_dir(self):
|
def copy_dir(self):
|
||||||
if self.use_overlayfs:
|
if container.use_overlayfs():
|
||||||
return "/var/lib/waydroid/overlay"
|
return "/var/lib/waydroid/overlay"
|
||||||
else:
|
else:
|
||||||
return "/tmp/waydroid"
|
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):
|
def download(self):
|
||||||
Logger.info("Downloading {} now to {} .....".format(self.dl_file_name, self.download_loc))
|
Logger.info("Downloading {} now to {} .....".format(self.dl_file_name, self.download_loc))
|
||||||
loc_md5 = ""
|
loc_md5 = ""
|
||||||
@@ -96,41 +80,46 @@ class General:
|
|||||||
images.umount(mount_point)
|
images.umount(mount_point)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
if self.use_dbus:
|
if container.use_dbus():
|
||||||
self.session = DBusContainerService().GetSession()
|
self.session = container.get_session()
|
||||||
if self.session:
|
container.stop()
|
||||||
DBusContainerService().Stop(False)
|
|
||||||
else:
|
|
||||||
run(["waydroid", "container", "stop"])
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
if self.use_dbus and self.session:
|
if container.use_dbus() and self.session:
|
||||||
DBusContainerService().Start(self.session)
|
container.start(self.session)
|
||||||
else:
|
else:
|
||||||
run(["systemctl", "restart", "waydroid-container.service"])
|
container.start()
|
||||||
upgrade()
|
|
||||||
|
|
||||||
def restart(self):
|
def restart(self):
|
||||||
self.stop()
|
self.stop()
|
||||||
self.start()
|
self.start()
|
||||||
upgrade()
|
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def extra(self):
|
def extra1(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def extra2(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# def install(self):
|
||||||
|
# if DBusContainerService().GetSession():
|
||||||
|
# print("running")
|
||||||
|
# else:
|
||||||
|
# print("stopped")
|
||||||
|
# run("waydroid session start".split())
|
||||||
def install(self):
|
def install(self):
|
||||||
if self.use_overlayfs:
|
if container.use_overlayfs():
|
||||||
self.download()
|
self.download()
|
||||||
if not self.skip_extract:
|
if not self.skip_extract:
|
||||||
self.extract()
|
self.extract()
|
||||||
self.copy()
|
self.copy()
|
||||||
self.extra()
|
self.extra1()
|
||||||
if hasattr(self, "apply_props"):
|
if hasattr(self, "apply_props"):
|
||||||
self.add_props()
|
self.add_props()
|
||||||
self.restart()
|
self.restart()
|
||||||
|
self.extra2()
|
||||||
else:
|
else:
|
||||||
self.stop()
|
self.stop()
|
||||||
self.download()
|
self.download()
|
||||||
@@ -139,9 +128,10 @@ class General:
|
|||||||
self.resize()
|
self.resize()
|
||||||
self.mount()
|
self.mount()
|
||||||
self.copy()
|
self.copy()
|
||||||
self.extra()
|
self.extra1()
|
||||||
if hasattr(self, "apply_props"):
|
if hasattr(self, "apply_props"):
|
||||||
self.add_props()
|
self.add_props()
|
||||||
self.umount()
|
self.umount()
|
||||||
self.start()
|
self.start()
|
||||||
|
self.extra2()
|
||||||
Logger.info("Installation finished")
|
Logger.info("Installation finished")
|
||||||
|
|||||||
+16
-2
@@ -1,6 +1,9 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
from time import sleep
|
||||||
from stuffs.general import General
|
from stuffs.general import General
|
||||||
|
from tools import container
|
||||||
|
from tools.helper import run
|
||||||
|
|
||||||
class Smartdock(General):
|
class Smartdock(General):
|
||||||
dl_link = "https://github.com/ayasa520/smartdock/releases/download/v1.9.6/smartdock.zip"
|
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"
|
extract_to = "/tmp/smartdockunpack"
|
||||||
dl_file_name = "smartdock.zip"
|
dl_file_name = "smartdock.zip"
|
||||||
act_md5 = "ad0cc5e023ac6ee97e7b013b9b0defee"
|
act_md5 = "ad0cc5e023ac6ee97e7b013b9b0defee"
|
||||||
|
apply_props = { "qemu.hw.mainkeys" : "1" }
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
if not os.path.exists(os.path.join(self.copy_dir, self.partition, "priv-app", "SmartDock")):
|
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"))
|
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"),
|
shutil.copyfile(os.path.join(self.extract_to, "app-release.apk"),
|
||||||
os.path.join(self.copy_dir, self.partition, "priv-app", "SmartDock", "smartdock.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"),
|
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"))
|
os.path.join(self.copy_dir, self.partition, "etc", "permissions", "permissions_cu.axel.smartdock.xml"))
|
||||||
|
|
||||||
def extra(self):
|
def extra2(self):
|
||||||
return super().extra()
|
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"])
|
||||||
|
|||||||
+45
-3
@@ -1,10 +1,52 @@
|
|||||||
try:
|
import re
|
||||||
import dbus
|
import dbus
|
||||||
except ModuleNotFoundError:
|
from tools.helper import run
|
||||||
pass
|
|
||||||
|
|
||||||
def DBusContainerService(object_path="/ContainerManager", intf="id.waydro.ContainerManager"):
|
def DBusContainerService(object_path="/ContainerManager", intf="id.waydro.ContainerManager"):
|
||||||
return dbus.Interface(dbus.SystemBus().get_object("id.waydro.Container", object_path), intf)
|
return dbus.Interface(dbus.SystemBus().get_object("id.waydro.Container", object_path), intf)
|
||||||
|
|
||||||
def DBusSessionService(object_path="/SessionManager", intf="id.waydro.SessionManager"):
|
def DBusSessionService(object_path="/SessionManager", intf="id.waydro.SessionManager"):
|
||||||
return dbus.Interface(dbus.SessionBus().get_object("id.waydro.Session", object_path), intf)
|
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()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user