This commit is contained in:
Rikka 2023-04-29 23:00:42 +08:00
parent 6922bdba0d
commit 48ea54fc3e
No known key found for this signature in database
GPG key ID: CD36B07FA9F7D2AA
14 changed files with 336 additions and 300 deletions

339
main.py
View file

@ -1,9 +1,11 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import argparse import argparse
from logging import Logger import os
from typing import List
from stuffs.android_id import AndroidId from stuffs.android_id import AndroidId
from stuffs.gapps import Gapps from stuffs.gapps import Gapps
from stuffs.general import General
from stuffs.hidestatusbar import HideStatusBar from stuffs.hidestatusbar import HideStatusBar
from stuffs.houdini import Houdini from stuffs.houdini import Houdini
from stuffs.magisk import Magisk from stuffs.magisk import Magisk
@ -13,159 +15,203 @@ from stuffs.nodataperm import Nodataperm
from stuffs.smartdock import Smartdock from stuffs.smartdock import Smartdock
from stuffs.widevine import Widevine from stuffs.widevine import Widevine
import tools.helper as helper import tools.helper as helper
from tools import container
from tools import images
import argparse import argparse
# def main(): from tools.logger import Logger
# def get_certified():
# print("Calling android_get_certified function")
# def install_app(app_name):
# print(f"Installing {app_name}")
# def remove_app(app_name):
# print(f"Removing {app_name}")
# def hack_option(option_name):
# print(f"Enabling {option_name}")
# parser = argparse.ArgumentParser(description='''
# Does stuff like installing Gapps, installing Magisk, installing NDK Translation and getting Android ID for device registration.
# Use -h flag for help!''')
# subparsers = parser.add_subparsers(dest='command')
# # android command
# certified = subparsers.add_parser('certified', help='Get device ID to obtain Play Store certification')
# certified.set_defaults(func=get_certified)
# install_choices=["gapps", "microg", "libndk", "libhoudini", "magisk", "smartdock", "widevine"],
# hack_choices = ["nodataperm", "hidestatusbar"]
# remove_choices=install_choices
# arg_template = {
# "dest": "app",
# "type": str,
# "nargs": '+',
# "metavar":"",
# }
# install_help = """
# gapps: Install Open GApps (Android 11) or MindTheGapps (Android 13)
# microg: Add microG, Aurora Store and Aurora Droid to WayDriod
# libndk: Add libndk arm translation, better for AMD CPUs
# libhoudini: Add libhoudini arm translation, better for Intel CPUs
# magisk: Install Magisk Delta to WayDroid
# smartdock: A desktop mode launcher for Android
# widevine: Add support for widevine DRM L3
# """
# # install and its aliases
# install_parser = subparsers.add_parser('install', aliases=['-i'], formatter_class=argparse.RawTextHelpFormatter, help='Install an app')
# install_parser.add_argument(**arg_template, help=install_help)
# install_parser.set_defaults(func=install_app)
# # remove and its aliases
# remove_parser = subparsers.add_parser('remove', aliases=['-r'], help='Remove an app')
# remove_parser.add_argument(**arg_template, help='Name of app to remove')
# remove_parser.set_defaults(func=remove_app)
# # hack and its aliases
# hack_parser = subparsers.add_parser('hack', aliases=['-h'], help='Hack the system')
# hack_parser.add_argument('option_name', choices=["nodataperm", "hidestatus"], help='Name of hack option')
# hack_parser.set_defaults(func=hack_option)
# args = parser.parse_args()
# if hasattr(args, 'func'):
# args_dict = vars(args)
# if 'app_name' in args_dict:
# args.func(args_dict['app_name'])
# else:
# args.func(args_dict['option_name'])
# else:
# parser.print_help()
def get_certified():
AndroidId.get_id()
def mount(partition, copy_dir):
img = os.path.join(images.get_image_dir(), partition+".img")
mount_point = ""
if partition == "system":
mount_point = os.path.join(copy_dir)
else:
mount_point = os.path.join(copy_dir, partition)
Logger.info("Mounting {} to {}".format(img, mount_point))
images.mount(img, mount_point)
def install(args):
app = args.app
if "gapps" in app:
Gapps(args.android_version).install()
if "libndk" in app and "houdini" not in app:
arch = helper.host()[0]
if arch == "x86_64":
Ndk(args.android_version).install()
else:
Logger.warn("libndk is not supported on your CPU")
if "libhoudini" in app and "ndk" not in app:
arch = helper.host()[0]
if arch == "x86_64":
Houdini(args.android_version).install()
else:
Logger.warn("libhoudini is not supported on your CPU")
if "magisk" in app:
Magisk().install()
if "widevine" in app:
Widevine(args.android_version).install()
if "smartdock" in app:
Smartdock().install()
if "nodataperm" in app:
Nodataperm().install()
if "microg" in app:
MicroG().install()
if "hidestatus" in app:
HideStatusBar().install()
def uninstall(args): def resize(partition):
app = args.app img = os.path.join(images.get_image_dir(), partition+".img")
if "gapps" in app: img_size = int(os.path.getsize(img)/(1024*1024))
Gapps(args.android_version).uninstall() new_size = "{}M".format(img_size+500)
if "libndk" in app: Logger.info("Resizing {} to {}".format(img, new_size))
Ndk(args.android_version).uninstall() images.resize(img, new_size)
if "libhoudini" in app:
Houdini(args.android_version).uninstall()
if "magisk" in app: def umount(partition, copy_dir):
Magisk().uninstall() mount_point = ""
if "widevine" in app: if partition == "system":
Widevine(args.android_version).uninstall() mount_point = os.path.join(copy_dir)
if "smartdock" in app: else:
Smartdock().uninstall() mount_point = os.path.join(copy_dir, partition)
if "nodataperm" in app: Logger.info("Umounting {}".format(mount_point))
Nodataperm().uninstall() images.umount(mount_point)
if "microg" in app:
MicroG().uninstall()
if "hidestatus" in app:
HideStatusBar().uninstall()
def main(): def main():
about = """
WayDroid Helper script v0.3
Does stuff like installing Gapps, installing Magisk, installing NDK Translation and getting Android ID for device registration.
Use -h flag for help!
"""
helper.check_root()
parser = argparse.ArgumentParser(prog=about) def install_app(args):
parser.set_defaults(app="") install_list: List[General] = []
app = args.app
if "gapps" in app:
install_list.append(Gapps(args.android_version))
if "libndk" in app and "houdini" not in app:
arch = helper.host()[0]
if arch == "x86_64":
install_list.append(Ndk(args.android_version))
else:
Logger.warn("libndk is not supported on your CPU")
if "libhoudini" in app and "ndk" not in app:
arch = helper.host()[0]
if arch == "x86_64":
install_list.append(Houdini(args.android_version))
else:
Logger.warn("libhoudini is not supported on your CPU")
if "magisk" in app:
install_list.append(Magisk())
if "widevine" in app:
install_list.append(Widevine(args.android_version))
if "smartdock" in app:
install_list.append(Smartdock())
if "microg" in app:
install_list.append(MicroG(args.android_version))
if not container.use_overlayfs():
copy_dir = "/tmp/waydroid"
container.stop()
resize_system, resize_vendor = False, False
for item in install_list:
if item.partition == "system":
resize_system = True
elif item.partition == "vendor":
resize_vendor = True
if resize_system:
resize("system")
if resize_vendor:
resize("vendor")
mount("system", copy_dir)
mount("vendor", copy_dir)
for item in install_list:
item.install()
if not container.use_overlayfs():
umount("vendor", copy_dir)
umount("system", copy_dir)
container.upgrade()
def remove_app(args):
remove_list: List[General] = []
app = args.app
if "gapps" in app:
remove_list.append(Gapps(args.android_version))
if "libndk" in app and "houdini" not in app:
remove_list.append(Ndk(args.android_version))
if "libhoudini" in app and "ndk" not in app:
remove_list.append(Houdini(args.android_version))
if "magisk" in app:
remove_list.append(Magisk())
if "widevine" in app:
remove_list.append(Widevine(args.android_version))
if "smartdock" in app:
remove_list.append(Smartdock())
if "microg" in app:
remove_list.append(MicroG(args.android_version))
if "nodataperm" in app:
remove_list.append(Nodataperm(args.android_version))
if "hidestatusbar" in app:
remove_list.append(HideStatusBar())
if not container.use_overlayfs():
copy_dir = "/tmp/waydroid"
container.stop()
for item in remove_list:
item.uninstall()
if not container.use_overlayfs():
umount("vendor", copy_dir)
umount("system", copy_dir)
container.upgrade()
def hack_option(args):
Logger.warning("If these hacks cause any problems, run `sudo python main.py remove <hack_option>` to remove")
hack_list: List[General] = []
options = args.option_name
if "nodataperm" in options:
hack_list.append(Nodataperm())
if "hidestatusbar" in options:
hack_list.append(HideStatusBar())
if not container.use_overlayfs():
copy_dir = "/tmp/waydroid"
container.stop()
resize_system, resize_vendor = False, False
for item in hack_list:
if item.partition == "system":
resize_system = True
elif item.partition == "vendor":
resize_vendor = True
if resize_system:
resize("system")
if resize_vendor:
resize("vendor")
mount("system", copy_dir)
mount("vendor", copy_dir)
for item in hack_list:
item.install()
if not container.use_overlayfs():
umount("vendor", copy_dir)
umount("system", copy_dir)
container.upgrade()
parser = argparse.ArgumentParser(description='''
Does stuff like installing Gapps, installing Magisk, installing NDK Translation and getting Android ID for device registration.
Use -h flag for help!''')
subparsers = parser.add_subparsers(title="coomand", dest='command')
parser.add_argument('-a', '--android-version', parser.add_argument('-a', '--android-version',
dest='android_version', dest='android_version',
help='Specify the Android version', help='Specify the Android version',
default="11", default="11",
choices=["11","13"]) choices=["11", "13"])
subparsers = parser.add_subparsers(title="subcommands", help="operations")
google_id_parser=subparsers.add_parser('google', # android command
help='grab device id for unblocking Google Apps') certified = subparsers.add_parser(
google_id_parser.set_defaults(func=AndroidId().get_id) 'certified', help='Get device ID to obtain Play Store certification')
# create the parser for the "a" command certified.set_defaults(func=get_certified)
install_choices = ["gapps", "microg", "libndk",
"libhoudini", "magisk", "smartdock", "widevine"]
hack_choices = ["nodataperm", "hidestatusbar"]
micrg_variants = ["Standard", "NoGoolag", "UNLP", "Minimal", "MinimalIAP"]
remove_choices = install_choices
arg_template = { arg_template = {
"dest": "app", "dest": "app",
"type": str, "type": str,
"nargs": '+', "nargs": '+',
"metavar":"", # "metavar":"",
} }
install_help = """ install_help = """
@ -177,22 +223,33 @@ magisk: Install Magisk Delta to WayDroid
smartdock: A desktop mode launcher for Android smartdock: A desktop mode launcher for Android
widevine: Add support for widevine DRM L3 widevine: Add support for widevine DRM L3
""" """
# install and its aliases
install_parser = subparsers.add_parser(
'install', formatter_class=argparse.RawTextHelpFormatter, help='Install an app')
install_parser.add_argument(
**arg_template, choices=install_choices, help=install_help)
install_parser.set_defaults(func=install_app)
install_parser = subparsers.add_parser("install",formatter_class=argparse.RawTextHelpFormatter, help='install something') # remove and its aliases
install_parser.set_defaults(func=install) remove_parser = subparsers.add_parser('remove',aliases=["uninstall"], help='Remove an app')
install_parser.add_argument(**arg_template,help=install_help) remove_parser.add_argument(
**arg_template, choices=[*remove_choices,* hack_choices], help='Name of app to remove')
remove_parser.set_defaults(func=remove_app)
uninstall_parser = subparsers.add_parser("uninstall", help='uninstall something') # hack and its aliases
uninstall_parser.set_defaults(func=uninstall) hack_parser = subparsers.add_parser('hack', help='Hack the system')
uninstall_parser.add_argument(**arg_template) hack_parser.add_argument(
'option_name',nargs="+" , choices=hack_choices, help='Name of hack option')
hack_parser.set_defaults(func=hack_option)
args = parser.parse_args() args = parser.parse_args()
if args.app: if hasattr(args, 'func'):
args_dict = vars(args)
helper.check_root()
args.func(args) args.func(args)
else: else:
args.func() parser.print_help()
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View file

@ -1,4 +1,3 @@
tqdm tqdm
requests requests
InquirerPy InquirerPy
dbus-python==1.2.18

View file

@ -5,6 +5,7 @@ from tools.helper import host, run
class Gapps(General): class Gapps(General):
id = ...
partition = "system" partition = "system"
dl_links = { dl_links = {
"11": { "11": {
@ -97,6 +98,10 @@ class Gapps(General):
self.android_version = android_version self.android_version = android_version
self.dl_link = self.dl_links[android_version][self.arch[0]][0] self.dl_link = self.dl_links[android_version][self.arch[0]][0]
self.act_md5 = self.dl_links[android_version][self.arch[0]][1] 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): def copy(self):
if self.android_version == "11": if self.android_version == "11":

View file

@ -4,8 +4,7 @@ import os
import shutil import shutil
import zipfile import zipfile
import hashlib import hashlib
from tools import images from tools.helper import download_file, get_download_dir, host
from tools.helper import download_file, get_download_dir, host, upgrade
from tools import container from tools import container
from tools.logger import Logger from tools.logger import Logger
@ -55,7 +54,7 @@ class General:
os.remove(file) os.remove(file)
def extract(self): 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: with zipfile.ZipFile(self.download_loc) as z:
z.extractall(self.extract_to) z.extractall(self.extract_to)
@ -100,48 +99,6 @@ class General:
with open("/var/lib/waydroid/waydroid.cfg", "w") as f: with open("/var/lib/waydroid/waydroid.cfg", "w") as f:
cfg.write(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): def copy(self):
pass pass
@ -152,50 +109,19 @@ class General:
def extra2(self): def extra2(self):
pass pass
def extra3(self):
pass
def install(self): def install(self):
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.extra1()
self.extra1() if hasattr(self, "apply_props"):
if hasattr(self, "apply_props"): self.add_props()
self.add_props() Logger.info(f"{self.id} installation finished")
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")
def uninstall(self): def uninstall(self):
if container.use_overlayfs(): self.remove()
self.remove() if hasattr(self, "apply_props"):
if hasattr(self, "apply_props"): self.remove_props()
self.remove_props() self.extra2()
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()
Logger.info("Uninstallation finished") Logger.info("Uninstallation finished")

View file

@ -2,20 +2,30 @@ import os
import shutil import shutil
from stuffs.general import General from stuffs.general import General
class HideStatusBar(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" partition = "system"
dl_file_name = "hidestatusbar.apk" dl_file_name = "hidestatusbar.apk"
act_md5 = "ae6c4cc567d6f3de77068e54e43818e2" dl_link = ...
act_md5 = ...
files = [ 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): 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): if not os.path.exists(rro_dir):
os.makedirs(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): def skip_extract(self):
return True return True

View file

@ -7,6 +7,7 @@ from tools.logger import Logger
class Houdini(General): class Houdini(General):
id = "libhoudini"
partition = "system" partition = "system"
dl_links = { dl_links = {
"11": ["https://github.com/supremegamers/vendor_intel_proprietary_houdini/archive/81f2a51ef539a35aead396ab7fce2adf89f46e88.zip", "fbff756612b4144797fbc99eadcb6653"], "11": ["https://github.com/supremegamers/vendor_intel_proprietary_houdini/archive/81f2a51ef539a35aead396ab7fce2adf89f46e88.zip", "fbff756612b4144797fbc99eadcb6653"],

View file

@ -8,6 +8,7 @@ from tools.logger import Logger
from tools import container from tools import container
class Magisk(General): class Magisk(General):
id = "magisk delta"
partition = "system" partition = "system"
dl_link = "https://huskydg.github.io/magisk-files/app-debug.apk" dl_link = "https://huskydg.github.io/magisk-files/app-debug.apk"
dl_file_name = "magisk.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): elif os.path.isfile(file) or os.path.exists(file):
os.remove(file) os.remove(file)
def extra3(self): def extra2(self):
self.extra1() self.extra1()
data_dir = get_data_dir() data_dir = get_data_dir()
files = [ files = [

View file

@ -7,7 +7,23 @@ from tools.logger import Logger
class MicroG(General): class MicroG(General):
id = "MicroG"
partition = "system" 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 = { dl_links = {
"Standard": [ "Standard": [
"https://github.com/ayasa520/MinMicroG/releases/download/latest/MinMicroG-Standard-2.11.1-20230429100529.zip", "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 = ... dl_file_name = ...
sdk = ... sdk = ...
extract_to = "/tmp/microg/extract" extract_to = "/tmp/microg/extract"
copy_dir = "/var/lib/waydroid/overlay_rw/system"
arch = host() arch = host()
rc_content = ''' rc_content = '''
on property:sys.boot_completed=1 on property:sys.boot_completed=1
@ -94,6 +109,7 @@ service microg_service /system/bin/sh /system/bin/npem
super().__init__() super().__init__()
self.dl_link = self.dl_links[variant][0] self.dl_link = self.dl_links[variant][0]
self.act_md5 = self.dl_links[variant][1] self.act_md5 = self.dl_links[variant][1]
self.id = self.id+f"-{variant}"
self.dl_file_name = f'MinMicroG-{variant}.zip' self.dl_file_name = f'MinMicroG-{variant}.zip'
if android_version == "11": if android_version == "11":
self.sdk = 30 self.sdk = 30
@ -176,3 +192,17 @@ service microg_service /system/bin/sh /system/bin/npem
with open(rc_dir, "w") as f: with open(rc_dir, "w") as f:
f.write(self.rc_content) f.write(self.rc_content)
self.set_permissions(rc_dir) 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)

View file

@ -6,6 +6,7 @@ from tools.logger import Logger
from tools.container import use_overlayfs from tools.container import use_overlayfs
class Ndk(General): class Ndk(General):
id = "libndk"
partition = "system" partition = "system"
dl_link = "https://github.com/supremegamers/vendor_google_proprietary_ndk_translation-prebuilt/archive/181d9290a69309511185c4417ba3d890b3caaaa8.zip" dl_link = "https://github.com/supremegamers/vendor_google_proprietary_ndk_translation-prebuilt/archive/181d9290a69309511185c4417ba3d890b3caaaa8.zip"
dl_file_name = "libndktranslation.zip" dl_file_name = "libndktranslation.zip"

View file

@ -6,36 +6,50 @@ from tools.helper import run
from tools.logger import Logger from tools.logger import Logger
from tools import container from tools import container
class Nodataperm(General): 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" dl_file_name = "nodataperm.zip"
extract_to = "/tmp/nodataperm" extract_to = "/tmp/nodataperm"
act_md5 = "eafd7b0986f3edaebaf1dd89f19d49bf" dl_link = ...
act_md5 = ...
partition = "system" partition = "system"
files = [ files = [
"etc/nodataperm.sh", "etc/nodataperm.sh",
"etc/init/nodataperm.rc", "etc/init/nodataperm.rc",
"framework/services.jar" "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): 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(): 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" 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: with open(services_jar, "rb") as f:
f_gz.write(f.read()) f_gz.write(f.read())
os.chmod(os.path.join(extract_path, "framework", "services.jar"), 0o644) 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", "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 ...") 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): def extra2(self):
if not container.use_overlayfs(): if not container.use_overlayfs():
services_jar = os.path.join(self.copy_dir, self.partition, "framework", "services.jar") services_jar = os.path.join(
gz_filename = services_jar+".gz" self.copy_dir, self.partition, "framework", "services.jar")
gz_filename = services_jar+".gz"
with gzip.GzipFile(gz_filename) as f_gz: with gzip.GzipFile(gz_filename) as f_gz:
with open(services_jar, "wb") as f: with open(services_jar, "wb") as f:
f.writelines(f_gz) f.writelines(f_gz)

View file

@ -6,6 +6,7 @@ from tools import container
from tools.helper import run from tools.helper import run
class Smartdock(General): class Smartdock(General):
id = "smartdock"
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"
partition = "system" partition = "system"
extract_to = "/tmp/smartdockunpack" extract_to = "/tmp/smartdockunpack"
@ -16,6 +17,15 @@ class Smartdock(General):
"etc/permissions/permissions_cu.axel.smartdock.xml", "etc/permissions/permissions_cu.axel.smartdock.xml",
"priv-app/SmartDock" "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): 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")):
@ -27,14 +37,8 @@ class Smartdock(General):
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 extra2(self): rc_dir = os.path.join(self.copy_dir, self.partition, "etc/init/smartdock.rc")
index = 0 if not os.path.exists(os.path.dirname(rc_dir)):
while not container.is_running(): os.makedirs(os.path.dirname(rc_dir))
list = ["\\", "|", "/", ""] with open(rc_dir, "w") as f:
sleep(0.5) f.write(self.rc_content)
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"])

View file

@ -7,6 +7,7 @@ from tools.logger import Logger
class Widevine(General): class Widevine(General):
id = "widevine"
partition = "vendor" partition = "vendor"
dl_links = { dl_links = {
# "x86": ["https://github.com/supremegamers/vendor_google_proprietary_widevine-prebuilt/archive/94c9ee172e3d78fecc81863f50a59e3646f7a2bd.zip", "a31f325453c5d239c21ecab8cfdbd878"], # "x86": ["https://github.com/supremegamers/vendor_google_proprietary_widevine-prebuilt/archive/94c9ee172e3d78fecc81863f50a59e3646f7a2bd.zip", "a31f325453c5d239c21ecab8cfdbd878"],

View file

@ -1,22 +1,22 @@
import configparser import configparser
import os import os
import sys import sys
import dbus # import dbus
from tools.helper import run from tools.helper import run
from tools.logger import Logger from tools.logger import Logger
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(): # def use_dbus():
try: # try:
DBusContainerService() # DBusContainerService()
except: # except:
return False # return False
return True # return True
def use_overlayfs(): def use_overlayfs():
cfg = configparser.ConfigParser() cfg = configparser.ConfigParser()
@ -34,30 +34,20 @@ def use_overlayfs():
return False return False
def get_session(): # def get_session():
return DBusContainerService().GetSession() # return DBusContainerService().GetSession()
def stop(): def stop():
if use_dbus(): # if use_dbus():
session = DBusContainerService().GetSession() # session = DBusContainerService().GetSession()
if session: # if session:
DBusContainerService().Stop(False) # DBusContainerService().Stop(False)
else: # else:
run(["waydroid", "container", "stop"]) 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(): def is_running():
if use_dbus():
if DBusContainerService().GetSession():
return True
return False
else:
return "Session:\tRUNNING" in run(["waydroid", "status"]).stdout.decode() return "Session:\tRUNNING" in run(["waydroid", "status"]).stdout.decode()
def upgrade():
run(["waydroid", "upgrade", "-o"], ignore=r"\[.*\] Stopping container\n\[.*\] Starting container")

View file

@ -131,6 +131,3 @@ def check_root():
if os.geteuid() != 0: if os.geteuid() != 0:
Logger.error("This script must be run as root. Aborting.") Logger.error("This script must be run as root. Aborting.")
sys.exit(1) sys.exit(1)
def upgrade():
run(["waydroid", "upgrade", "-o"], ignore=r"\[.*\] Stopping container\n\[.*\] Starting container")