This commit is contained in:
Rikka
2023-05-27 16:55:29 +08:00
parent 6922bdba0d
commit 48ea54fc3e
14 changed files with 336 additions and 300 deletions
+5
View File
@@ -5,6 +5,7 @@ from tools.helper import host, run
class Gapps(General):
id = ...
partition = "system"
dl_links = {
"11": {
@@ -97,6 +98,10 @@ class Gapps(General):
self.android_version = android_version
self.dl_link = self.dl_links[android_version][self.arch[0]][0]
self.act_md5 = self.dl_links[android_version][self.arch[0]][1]
if android_version=="11":
self.id = "OpenGapps"
else:
self.id = "MindTheGapps"
def copy(self):
if self.android_version == "11":
+14 -88
View File
@@ -4,8 +4,7 @@ import os
import shutil
import zipfile
import hashlib
from tools import images
from tools.helper import download_file, get_download_dir, host, upgrade
from tools.helper import download_file, get_download_dir, host
from tools import container
from tools.logger import Logger
@@ -55,7 +54,7 @@ class General:
os.remove(file)
def extract(self):
Logger.info("Extracting archive...")
Logger.info(f"Extracting {self.download_loc} to {self.extract_to}")
with zipfile.ZipFile(self.download_loc) as z:
z.extractall(self.extract_to)
@@ -100,48 +99,6 @@ class General:
with open("/var/lib/waydroid/waydroid.cfg", "w") as f:
cfg.write(f)
def mount(self):
img = os.path.join(images.get_image_dir(), self.partition+".img")
mount_point = ""
if self.partition == "system":
mount_point = os.path.join(self.copy_dir)
else:
mount_point = os.path.join(self.copy_dir, self.partition)
Logger.info("Mounting {} to {}".format(img, mount_point))
images.mount(img, mount_point)
def resize(self):
img = os.path.join(images.get_image_dir(), self.partition+".img")
img_size = int(os.path.getsize(img)/(1024*1024))
new_size = "{}M".format(img_size+500)
Logger.info("Resizing {} to {}".format(img, new_size))
images.resize(img, new_size)
def umount(self):
mount_point = ""
if self.partition == "system":
mount_point = os.path.join(self.copy_dir)
else:
mount_point = os.path.join(self.copy_dir, self.partition)
Logger.info("Umounting {}".format(mount_point))
images.umount(mount_point)
def stop(self):
if container.use_dbus():
self.session = container.get_session()
container.stop()
def start(self):
if container.use_dbus() and self.session:
container.start(self.session)
else:
container.start()
upgrade()
def restart(self):
self.stop()
self.start()
def copy(self):
pass
@@ -152,50 +109,19 @@ class General:
def extra2(self):
pass
def extra3(self):
pass
def install(self):
if container.use_overlayfs():
self.download()
if not self.skip_extract:
self.extract()
self.copy()
self.extra1()
if hasattr(self, "apply_props"):
self.add_props()
self.restart()
self.extra2()
else:
self.stop()
self.download()
if not self.skip_extract:
self.extract()
self.resize()
self.mount()
self.copy()
self.extra1()
if hasattr(self, "apply_props"):
self.add_props()
self.umount()
self.start()
self.extra2()
Logger.info("Installation finished")
self.download()
if not self.skip_extract:
self.extract()
self.copy()
self.extra1()
if hasattr(self, "apply_props"):
self.add_props()
Logger.info(f"{self.id} installation finished")
def uninstall(self):
if container.use_overlayfs():
self.remove()
if hasattr(self, "apply_props"):
self.remove_props()
self.extra3()
self.restart()
else:
self.stop()
self.mount()
self.remove()
if hasattr(self, "apply_props"):
self.remove_props()
self.extra3()
self.umount()
self.start()
self.remove()
if hasattr(self, "apply_props"):
self.remove_props()
self.extra2()
Logger.info("Uninstallation finished")
+19 -9
View File
@@ -2,20 +2,30 @@ import os
import shutil
from stuffs.general import General
class HideStatusBar(General):
dl_link = "https://github.com/ayasa520/hide-status-bar/releases/download/v0.0.1/app-release.apk"
id = "hide status bar"
dl_links = {"11": ["https://github.com/ayasa520/hide-status-bar/releases/download/v0.0.1/app-release.apk",
"ae6c4cc567d6f3de77068e54e43818e2"]}
partition = "system"
dl_file_name = "hidestatusbar.apk"
act_md5 = "ae6c4cc567d6f3de77068e54e43818e2"
dl_link = ...
act_md5 = ...
files = [
"product/overlay/"+dl_file_name
]
"product/overlay/"+dl_file_name
]
def __init__(self, android_version="11") -> None:
super().__init__()
self.dl_link = self.dl_links[android_version][0]
self.act_md5 = self.dl_links[android_version][1]
def copy(self):
rro_dir = os.path.join(self.copy_dir, self.partition, "product", "overlay")
rro_dir = os.path.join(
self.copy_dir, self.partition, "product", "overlay")
if not os.path.exists(rro_dir):
os.makedirs(rro_dir)
shutil.copyfile(self.download_loc, os.path.join(rro_dir, "hidestatusbar.apk"))
shutil.copyfile(self.download_loc, os.path.join(
rro_dir, "hidestatusbar.apk"))
def skip_extract(self):
return True
return True
+1
View File
@@ -7,6 +7,7 @@ from tools.logger import Logger
class Houdini(General):
id = "libhoudini"
partition = "system"
dl_links = {
"11": ["https://github.com/supremegamers/vendor_intel_proprietary_houdini/archive/81f2a51ef539a35aead396ab7fce2adf89f46e88.zip", "fbff756612b4144797fbc99eadcb6653"],
+2 -1
View File
@@ -8,6 +8,7 @@ from tools.logger import Logger
from tools import container
class Magisk(General):
id = "magisk delta"
partition = "system"
dl_link = "https://huskydg.github.io/magisk-files/app-debug.apk"
dl_file_name = "magisk.apk"
@@ -128,7 +129,7 @@ on property:init.svc.zygote=stopped
elif os.path.isfile(file) or os.path.exists(file):
os.remove(file)
def extra3(self):
def extra2(self):
self.extra1()
data_dir = get_data_dir()
files = [
+31 -1
View File
@@ -7,7 +7,23 @@ from tools.logger import Logger
class MicroG(General):
id = "MicroG"
partition = "system"
fdroid_repo_apks = {
"com.aurora.store_41.apk": "9e6c79aefde3f0bbfedf671a2d73d1be",
"com.etesync.syncadapter_20300.apk": "997d6de7d41c454d39fc22cd7d8fc3c2",
"com.aurora.adroid_8.apk": "0010bf93f02c2d18daf9e767035fefc5",
"org.fdroid.fdroid.privileged_2130.apk": "b04353155aceb36207a206d6dd14ba6a",
"org.microg.nlp.backend.ichnaea_20036.apk": "0b3cb65f8458d1a5802737c7392df903",
"org.microg.nlp.backend.nominatim_20042.apk": "88e7397cbb9e5c71c8687d3681a23383",
}
microg_apks= {
"com.google.android.gms-223616054.apk": "a945481ca5d33a03bc0f9418263c3228",
"com.google.android.gsf-8.apk": "b2b4ea3642df6158e14689a4b2a246d4",
"com.android.vending-22.apk": "6815d191433ffcd8fa65923d5b0b0573",
"org.microg.gms.droidguard-14.apk": "4734b41c1a6bc34a541053ddde7a0f8e"
}
priv_apps = ["com.google.android.gms", "com.android.vending"]
dl_links = {
"Standard": [
"https://github.com/ayasa520/MinMicroG/releases/download/latest/MinMicroG-Standard-2.11.1-20230429100529.zip",
@@ -35,7 +51,6 @@ class MicroG(General):
dl_file_name = ...
sdk = ...
extract_to = "/tmp/microg/extract"
copy_dir = "/var/lib/waydroid/overlay_rw/system"
arch = host()
rc_content = '''
on property:sys.boot_completed=1
@@ -94,6 +109,7 @@ service microg_service /system/bin/sh /system/bin/npem
super().__init__()
self.dl_link = self.dl_links[variant][0]
self.act_md5 = self.dl_links[variant][1]
self.id = self.id+f"-{variant}"
self.dl_file_name = f'MinMicroG-{variant}.zip'
if android_version == "11":
self.sdk = 30
@@ -176,3 +192,17 @@ service microg_service /system/bin/sh /system/bin/npem
with open(rc_dir, "w") as f:
f.write(self.rc_content)
self.set_permissions(rc_dir)
def extra2(self):
system_dir = os.path.join(self.copy_dir, self.partition)
files = [key.split("_")[0] for key in self.fdroid_repo_apks.keys()]
files += [key.split("-")[0] for key in self.microg_apks.keys()]
for f in files:
if f in self.priv_apps:
file = os.path.join(system_dir, "priv-app", f)
else:
file = os.path.join(system_dir, "app", f)
if os.path.isdir(file):
shutil.rmtree(file)
elif os.path.isfile(file):
os.remove(file)
+1
View File
@@ -6,6 +6,7 @@ from tools.logger import Logger
from tools.container import use_overlayfs
class Ndk(General):
id = "libndk"
partition = "system"
dl_link = "https://github.com/supremegamers/vendor_google_proprietary_ndk_translation-prebuilt/archive/181d9290a69309511185c4417ba3d890b3caaaa8.zip"
dl_file_name = "libndktranslation.zip"
+29 -15
View File
@@ -6,36 +6,50 @@ from tools.helper import run
from tools.logger import Logger
from tools import container
class Nodataperm(General):
dl_link = "https://github.com/ayasa520/hack_full_data_permission/archive/refs/heads/main.zip"
id = "nodataperm"
dl_links = {"11": ["https://github.com/ayasa520/hack_full_data_permission/archive/refs/heads/main.zip",
"eafd7b0986f3edaebaf1dd89f19d49bf"]}
dl_file_name = "nodataperm.zip"
extract_to = "/tmp/nodataperm"
act_md5 = "eafd7b0986f3edaebaf1dd89f19d49bf"
dl_link = ...
act_md5 = ...
partition = "system"
files = [
"etc/nodataperm.sh",
"etc/init/nodataperm.rc",
"framework/services.jar"
]
"etc/nodataperm.sh",
"etc/init/nodataperm.rc",
"framework/services.jar"
]
def __init__(self, android_version="11") -> None:
super().__init__()
self.dl_link = self.dl_links[android_version][0]
self.act_md5 = self.dl_links[android_version][1]
def copy(self):
extract_path = os.path.join(self.extract_to, "hack_full_data_permission-main")
extract_path = os.path.join(
self.extract_to, "hack_full_data_permission-main")
if not container.use_overlayfs():
services_jar = os.path.join(self.copy_dir, self.partition, "framework", "services.jar")
services_jar = os.path.join(
self.copy_dir, self.partition, "framework", "services.jar")
gz_filename = services_jar+".gz"
with gzip.open(gz_filename,'wb') as f_gz:
with gzip.open(gz_filename, 'wb') as f_gz:
with open(services_jar, "rb") as f:
f_gz.write(f.read())
os.chmod(os.path.join(extract_path, "framework", "services.jar"), 0o644)
os.chmod(os.path.join(extract_path, "etc", "nodataperm.sh"), 0o755)
os.chmod(os.path.join(extract_path, "etc", "init", "nodataperm.rc"), 0o755)
os.chmod(os.path.join(extract_path, "etc",
"init", "nodataperm.rc"), 0o755)
Logger.info("Copying widevine library files ...")
shutil.copytree(extract_path, os.path.join(self.copy_dir, self.partition), dirs_exist_ok=True)
shutil.copytree(extract_path, os.path.join(
self.copy_dir, self.partition), dirs_exist_ok=True)
def extra3(self):
if not container.use_overlayfs():
services_jar = os.path.join(self.copy_dir, self.partition, "framework", "services.jar")
gz_filename = services_jar+".gz"
def extra2(self):
if not container.use_overlayfs():
services_jar = os.path.join(
self.copy_dir, self.partition, "framework", "services.jar")
gz_filename = services_jar+".gz"
with gzip.GzipFile(gz_filename) as f_gz:
with open(services_jar, "wb") as f:
f.writelines(f_gz)
+15 -11
View File
@@ -6,6 +6,7 @@ from tools import container
from tools.helper import run
class Smartdock(General):
id = "smartdock"
dl_link = "https://github.com/ayasa520/smartdock/releases/download/v1.9.6/smartdock.zip"
partition = "system"
extract_to = "/tmp/smartdockunpack"
@@ -16,6 +17,15 @@ class Smartdock(General):
"etc/permissions/permissions_cu.axel.smartdock.xml",
"priv-app/SmartDock"
]
rc_content = '''
on property:sys.boot_completed=1
start set_home_activity
service set_home_activity /system/bin/sh -c "cmd package set-home-activity cu.axel.smartdock/.activities.LauncherActivity"
user root
group root
oneshot
'''
def copy(self):
if not os.path.exists(os.path.join(self.copy_dir, self.partition, "priv-app", "SmartDock")):
@@ -27,14 +37,8 @@ class Smartdock(General):
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 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)
if index != 0:
print()
run(["waydroid", "shell", "cmd", "package", "set-home-activity", "cu.axel.smartdock/.activities.LauncherActivity"])
rc_dir = os.path.join(self.copy_dir, self.partition, "etc/init/smartdock.rc")
if not os.path.exists(os.path.dirname(rc_dir)):
os.makedirs(os.path.dirname(rc_dir))
with open(rc_dir, "w") as f:
f.write(self.rc_content)
+1
View File
@@ -7,6 +7,7 @@ from tools.logger import Logger
class Widevine(General):
id = "widevine"
partition = "vendor"
dl_links = {
# "x86": ["https://github.com/supremegamers/vendor_google_proprietary_widevine-prebuilt/archive/94c9ee172e3d78fecc81863f50a59e3646f7a2bd.zip", "a31f325453c5d239c21ecab8cfdbd878"],