diff --git a/main.py b/main.py index ebb2f5f..f4579fd 100755 --- a/main.py +++ b/main.py @@ -1,9 +1,11 @@ #!/usr/bin/env python3 import argparse -from logging import Logger +import os +from typing import List from stuffs.android_id import AndroidId from stuffs.gapps import Gapps +from stuffs.general import General from stuffs.hidestatusbar import HideStatusBar from stuffs.houdini import Houdini from stuffs.magisk import Magisk @@ -13,159 +15,203 @@ from stuffs.smartdock import Smartdock from stuffs.widevine import Widevine import tools.helper as helper - +from tools import container +from tools import images import argparse -# def main(): -# 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 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): - app = args.app - if "gapps" in app: - Gapps(args.android_version).uninstall() - if "libndk" in app: - Ndk(args.android_version).uninstall() - if "libhoudini" in app: - Houdini(args.android_version).uninstall() - if "magisk" in app: - Magisk().uninstall() - if "widevine" in app: - Widevine(args.android_version).uninstall() - if "smartdock" in app: - Smartdock().uninstall() - if "nodataperm" in app: - Nodataperm().uninstall() - if "microg" in app: - MicroG().uninstall() - if "hidestatus" in app: - HideStatusBar().uninstall() +from tools.logger import Logger + + +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 resize(partition): + img = os.path.join(images.get_image_dir(), 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(partition, copy_dir): + mount_point = "" + if partition == "system": + mount_point = os.path.join(copy_dir) + else: + mount_point = os.path.join(copy_dir, partition) + Logger.info("Umounting {}".format(mount_point)) + images.umount(mount_point) + def main(): - about = """ - WayDroid Helper script v0.3 + + def install_app(args): + 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 ` 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! - """ - helper.check_root() + Use -h flag for help!''') - parser = argparse.ArgumentParser(prog=about) - parser.set_defaults(app="") + subparsers = parser.add_subparsers(title="coomand", dest='command') parser.add_argument('-a', '--android-version', dest='android_version', help='Specify the Android version', default="11", - choices=["11","13"]) - subparsers = parser.add_subparsers(title="subcommands", help="operations") + choices=["11", "13"]) + + # android command + certified = subparsers.add_parser( + 'certified', help='Get device ID to obtain Play Store certification') + certified.set_defaults(func=get_certified) - google_id_parser=subparsers.add_parser('google', - help='grab device id for unblocking Google Apps') - google_id_parser.set_defaults(func=AndroidId().get_id) - # create the parser for the "a" command + 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 = { "dest": "app", "type": str, "nargs": '+', - "metavar":"", + # "metavar":"", } install_help = """ @@ -177,22 +223,33 @@ def main(): smartdock: A desktop mode launcher for Android widevine: Add support for widevine DRM L3 """ - - install_parser = subparsers.add_parser("install",formatter_class=argparse.RawTextHelpFormatter, help='install something') - install_parser.set_defaults(func=install) - install_parser.add_argument(**arg_template,help=install_help) - - uninstall_parser = subparsers.add_parser("uninstall", help='uninstall something') - uninstall_parser.set_defaults(func=uninstall) - uninstall_parser.add_argument(**arg_template) + # 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) + + # remove and its aliases + remove_parser = subparsers.add_parser('remove',aliases=["uninstall"], help='Remove an app') + remove_parser.add_argument( + **arg_template, choices=[*remove_choices,* hack_choices], help='Name of app to remove') + remove_parser.set_defaults(func=remove_app) + + # hack and its aliases + hack_parser = subparsers.add_parser('hack', help='Hack the system') + 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() - if args.app: + if hasattr(args, 'func'): + args_dict = vars(args) + helper.check_root() args.func(args) else: - args.func() + parser.print_help() - if __name__ == "__main__": main() diff --git a/requirements.txt b/requirements.txt index 9a3bf03..cf6e127 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ tqdm requests InquirerPy -dbus-python==1.2.18 diff --git a/stuffs/gapps.py b/stuffs/gapps.py index 486d13b..fd4f777 100644 --- a/stuffs/gapps.py +++ b/stuffs/gapps.py @@ -5,6 +5,7 @@ class Gapps(General): + id = ... partition = "system" dl_links = { "11": { @@ -97,6 +98,10 @@ def __init__(self, android_version="11") -> None: 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": diff --git a/stuffs/general.py b/stuffs/general.py index ac9f87a..ca96696 100644 --- a/stuffs/general.py +++ b/stuffs/general.py @@ -4,8 +4,7 @@ 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 @@ def remove(self): 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 @@ def remove_props(self): 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 @@ def extra1(self): 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") diff --git a/stuffs/hidestatusbar.py b/stuffs/hidestatusbar.py index 2a6df2f..9780c44 100644 --- a/stuffs/hidestatusbar.py +++ b/stuffs/hidestatusbar.py @@ -2,20 +2,30 @@ 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 \ No newline at end of file + return True diff --git a/stuffs/houdini.py b/stuffs/houdini.py index 6856060..7567e5a 100644 --- a/stuffs/houdini.py +++ b/stuffs/houdini.py @@ -7,6 +7,7 @@ class Houdini(General): + id = "libhoudini" partition = "system" dl_links = { "11": ["https://github.com/supremegamers/vendor_intel_proprietary_houdini/archive/81f2a51ef539a35aead396ab7fce2adf89f46e88.zip", "fbff756612b4144797fbc99eadcb6653"], diff --git a/stuffs/magisk.py b/stuffs/magisk.py index 9911630..ddbef10 100644 --- a/stuffs/magisk.py +++ b/stuffs/magisk.py @@ -8,6 +8,7 @@ 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 @@ def extra1(self): 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 = [ diff --git a/stuffs/microg.py b/stuffs/microg.py index b6cc0c0..ea23641 100644 --- a/stuffs/microg.py +++ b/stuffs/microg.py @@ -7,7 +7,23 @@ 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 @@ def __init__(self, android_version="11", variant="Standard") -> None: 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 @@ def copy(self): 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) diff --git a/stuffs/ndk.py b/stuffs/ndk.py index eb547d8..0e7a5b0 100644 --- a/stuffs/ndk.py +++ b/stuffs/ndk.py @@ -6,6 +6,7 @@ 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" diff --git a/stuffs/nodataperm.py b/stuffs/nodataperm.py index 30601c9..d93cc40 100644 --- a/stuffs/nodataperm.py +++ b/stuffs/nodataperm.py @@ -6,36 +6,50 @@ 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) diff --git a/stuffs/smartdock.py b/stuffs/smartdock.py index ca0572b..e192d0e 100644 --- a/stuffs/smartdock.py +++ b/stuffs/smartdock.py @@ -6,6 +6,7 @@ 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 @@ def copy(self): 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) diff --git a/stuffs/widevine.py b/stuffs/widevine.py index 12581fb..ad37a85 100644 --- a/stuffs/widevine.py +++ b/stuffs/widevine.py @@ -7,6 +7,7 @@ class Widevine(General): + id = "widevine" partition = "vendor" dl_links = { # "x86": ["https://github.com/supremegamers/vendor_google_proprietary_widevine-prebuilt/archive/94c9ee172e3d78fecc81863f50a59e3646f7a2bd.zip", "a31f325453c5d239c21ecab8cfdbd878"], diff --git a/tools/container.py b/tools/container.py index aaf8703..7dd2f7c 100644 --- a/tools/container.py +++ b/tools/container.py @@ -1,22 +1,22 @@ import configparser import os import sys -import dbus +# import dbus from tools.helper import run from tools.logger import Logger -def DBusContainerService(object_path="/ContainerManager", intf="id.waydro.ContainerManager"): - return dbus.Interface(dbus.SystemBus().get_object("id.waydro.Container", object_path), intf) +# 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 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_dbus(): +# try: +# DBusContainerService() +# except: +# return False +# return True def use_overlayfs(): cfg = configparser.ConfigParser() @@ -34,30 +34,20 @@ def use_overlayfs(): return False -def get_session(): - return DBusContainerService().GetSession() +# def get_session(): +# return DBusContainerService().GetSession() def stop(): - if use_dbus(): - session = DBusContainerService().GetSession() - if session: - DBusContainerService().Stop(False) - else: + # 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() - - +def upgrade(): + run(["waydroid", "upgrade", "-o"], ignore=r"\[.*\] Stopping container\n\[.*\] Starting container") \ No newline at end of file diff --git a/tools/helper.py b/tools/helper.py index 23b86fd..6ef84cd 100644 --- a/tools/helper.py +++ b/tools/helper.py @@ -131,6 +131,3 @@ def check_root(): if os.geteuid() != 0: Logger.error("This script must be run as root. Aborting.") sys.exit(1) - -def upgrade(): - run(["waydroid", "upgrade", "-o"], ignore=r"\[.*\] Stopping container\n\[.*\] Starting container") \ No newline at end of file